This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
NyLPC_cHttpBasicBodyParser.h
00001 /********************************************************************************* 00002 * PROJECT: MiMic 00003 * -------------------------------------------------------------------------------- 00004 * 00005 * This file is part of MiMic 00006 * Copyright (C)2011 Ryo Iizuka 00007 * 00008 * MiMic is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published 00010 * by the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * 00021 * For further information please contact. 00022 * http://nyatla.jp/ 00023 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp> 00024 * 00025 *********************************************************************************/ 00026 00027 #ifndef NyLPC_TcHttpBasicBodyParser_H 00028 #define NyLPC_TcHttpBasicBodyParser_H 00029 #include "NyLPC_stdlib.h" 00030 #include "NyLPC_cHttpStream.h" 00031 #include "NyLPC_cHttpBasicHeaderParser.h" 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif /* __cplusplus */ 00035 00036 00037 00038 00039 00040 /** 00041 * このクラスは、HttpBodyのパーサを定義します。 00042 * BasicBodyParserは結果値をコールバック関数で通知します。 00043 */ 00044 typedef struct NyLPC_TcHttpBasicBodyParser NyLPC_TcHttpBasicBodyParser_t; 00045 00046 /** 00047 * BodyParserのステータス定義値。 00048 */ 00049 typedef NyLPC_TUInt8 NyLPC_TcHttpBasicBodyParser_ST; 00050 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_HEADER_START ((NyLPC_TcHttpBasicBodyParser_ST)0x11)//ヘッダ解析待ち 00051 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_HEADER_SP ((NyLPC_TcHttpBasicBodyParser_ST)0x12)//ヘッダ解析中 00052 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_HEADER_EXT ((NyLPC_TcHttpBasicBodyParser_ST)0x13)//ヘッダ解析中 00053 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_BODY ((NyLPC_TcHttpBasicBodyParser_ST)0x14)//フッタ解析中 00054 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_FOOTER ((NyLPC_TcHttpBasicBodyParser_ST)0x15)//フッタ解析中 00055 #define NyLPC_TcHttpBasicBodyParser_ST_CHUNK_END ((NyLPC_TcHttpBasicBodyParser_ST)0x16)//フッタ解析中 00056 #define NyLPC_TcHttpBasicBodyParser_ST_BODY ((NyLPC_TcHttpBasicBodyParser_ST)0x17)//BODYパース中 00057 #define NyLPC_TcHttpBasicBodyParser_ST_EOB ((NyLPC_TcHttpBasicBodyParser_ST)0x7F)//BODY確定 00058 #define NyLPC_TcHttpBasicBodyParser_ST_ERROR ((NyLPC_TcHttpBasicBodyParser_ST)0x80)//終わり 00059 #define NyLPC_TcHttpBasicBodyParser_ST_NULL ((NyLPC_TcHttpBasicBodyParser_ST)0x00)//初期状態 00060 00061 00062 #define NyLPC_TcHttpBasicBodyParser_ST_isError(i_v) ((i_v)==NyLPC_TcHttpBasicBodyParser_ST_ERROR) 00063 00064 00065 /** 00066 * parserのHandler 00067 */ 00068 typedef NyLPC_TBool (*NyLPC_TcHttpBasicBodyParser_bodyHandler) (NyLPC_TcHttpBasicBodyParser_t* i_inst,NyLPC_TChar i_c); 00069 00070 struct NyLPC_TcHttpBasicBodyParser_Handler 00071 { 00072 NyLPC_TcHttpBasicBodyParser_bodyHandler bodyHandler; 00073 }; 00074 00075 00076 00077 00078 /** 00079 * クラス構造体 00080 */ 00081 struct NyLPC_TcHttpBasicBodyParser 00082 { 00083 NyLPC_THttpMessgeHeader_TransferEncoding _encode_type; 00084 NyLPC_TcHttpBasicBodyParser_ST _status; 00085 union{ 00086 struct{ 00087 int recv_len; 00088 }chunked; 00089 struct{ 00090 NyLPC_TUInt32 content_length; 00091 }normal; 00092 }_data; 00093 struct NyLPC_TcHttpBasicBodyParser_Handler* _handler; 00094 }; 00095 00096 00097 void NyLPC_cHttpBasicBodyParser_initialize(NyLPC_TcHttpBasicBodyParser_t* i_inst,struct NyLPC_TcHttpBasicBodyParser_Handler* i_handler); 00098 #define NyLPC_cHttpBasicBodyParser_finalize(i_inst) 00099 #define NyLPC_cHttpBasicBodyParser_getState(i_v) ((i_v)->_status) 00100 00101 /** 00102 * パーサの開始処理をします。 00103 * 関数は、parseInit->parseChar[n回]->(parseStream)->parseFinishの順でコールします。 00104 * parseChar、又はparseStreamでエラーが発生した場合は、後続の関数を呼び出すことは出来ません。 00105 * parseCharでEOHに達した場合、parseCharまたはparseStreamを続けて呼ぶことは出来ません。 00106 * parseFinishはparseCharまたはparseStreamでEOHに達した場合のみ呼び出すことが出来ます。 00107 */ 00108 void NyLPC_cHttpBasicBodyParser_parseInit(NyLPC_TcHttpBasicBodyParser_t* i_instt,const struct NyLPC_THttpBasicHeader* i_info); 00109 00110 /** 00111 * パーサの処理を閉じます。 00112 * @return 00113 * パース処理が正常に終了したかの真偽値 00114 */ 00115 NyLPC_TBool NyLPC_cHttpBasicBodyParser_parseFinish(NyLPC_TcHttpBasicBodyParser_t* i_inst); 00116 00117 /** 00118 * HTTPストリームをパースします。 00119 * @return 00120 */ 00121 NyLPC_TInt32 NyLPC_cHttpBasicBodyParser_parseChar(NyLPC_TcHttpBasicBodyParser_t* i_inst,const NyLPC_TChar* i_c,NyLPC_TInt32 i_size); 00122 00123 00124 /** 00125 * ストリームから読み出して、EOHに達するまでパースします。 00126 * コール前にNyLPC_cHttpBasicHeaderParser_parseInitでパーサを開始してください。 00127 * @return 00128 * 処理が正常に終了したかを返します。 00129 * TRUEの場合、ステータスはEOHに達しています。(parseFinishをコールできます。) 00130 */ 00131 //NyLPC_TcHttpBasicBodyParser_ST NyLPC_cHttpBasicHeaderParser_parseStream(NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TcHttpStream_t* i_stream,NyLPC_TChar* i_buf,NyLPC_TUInt16 i_buf_size,NyLPC_TUInt16 i_out_size); 00132 00133 #ifdef __cplusplus 00134 } 00135 #endif /* __cplusplus */ 00136 00137 #endif
Generated on Tue Jul 12 2022 15:46:15 by 1.7.2