Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
NyLPC_cHttpBodyParser.c
00001 #include "NyLPC_cHttpBodyParser.h" 00002 00003 #define HTTP_TIMEOUT NyLPC_TiHttpPtrStream_DEFAULT_HTTP_TIMEOUT 00004 00005 static NyLPC_TBool bodyHandler(NyLPC_TcHttpBasicBodyParser_t* i_inst,NyLPC_TChar i_c) 00006 { 00007 NyLPC_TcHttpBodyParser_t* inst=(NyLPC_TcHttpBodyParser_t*)i_inst; 00008 *(inst->ref_buf+inst->len)=i_c; 00009 inst->len++; 00010 return inst->buf_size>inst->len; 00011 } 00012 00013 static struct NyLPC_TcHttpBasicBodyParser_Handler _bh={bodyHandler}; 00014 00015 void NyLPC_cHttpBodyParser_initialize(NyLPC_TcHttpBodyParser_t* i_inst) 00016 { 00017 NyLPC_cHttpBasicBodyParser_initialize(&i_inst->_super,&_bh); 00018 } 00019 void NyLPC_cHttpBodyParser_finalize(NyLPC_TcHttpBodyParser_t* i_inst) 00020 { 00021 NyLPC_cHttpBasicBodyParser_finalize(&i_inst->_super); 00022 } 00023 00024 00025 /** 00026 * @param i_out 00027 * 読み出したデータサイズ。戻り値trueの場合のみ有効。0の場合終端。 00028 * @return 00029 * エラーの発生状況 00030 */ 00031 NyLPC_TBool NyLPC_cHttpBodyParser_parseStream(NyLPC_TcHttpBodyParser_t* i_inst,NyLPC_TiHttpPtrStream_t* i_stream,NyLPC_TChar* i_buf,NyLPC_TInt16 i_buf_size,NyLPC_TInt16* i_out) 00032 { 00033 NyLPC_TcHttpBodyParser_t* inst=(NyLPC_TcHttpBodyParser_t*)i_inst; 00034 const char* rp_base; 00035 NyLPC_TInt32 rsize; 00036 inst->len=0; 00037 inst->buf_size=i_buf_size; 00038 inst->ref_buf=i_buf; 00039 if(i_inst->_super._status==NyLPC_TcHttpBasicBodyParser_ST_EOB){ 00040 *i_out=0; 00041 return NyLPC_TBool_TRUE; 00042 } 00043 for(;;){ 00044 //タイムアウト付でストリームから読み出し。 00045 rsize=NyLPC_iHttpPtrStream_pread(i_stream,(const void**)(&rp_base),HTTP_TIMEOUT); 00046 if(rsize<=0){ 00047 //Read失敗 00048 return NyLPC_TBool_FALSE; 00049 } 00050 rsize=NyLPC_cHttpBasicBodyParser_parseChar(&i_inst->_super,rp_base,rsize); 00051 if(i_inst->_super._status==NyLPC_TcHttpBasicBodyParser_ST_ERROR){ 00052 //パース失敗 00053 return NyLPC_TBool_FALSE; 00054 } 00055 NyLPC_iHttpPtrStream_rseek(i_stream,(NyLPC_TUInt16)rsize); 00056 *i_out=i_inst->len; 00057 return NyLPC_TBool_TRUE; 00058 } 00059 }
Generated on Tue Jul 12 2022 16:22:57 by
