X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=lib%2Fsrc%2Fhttp%2FNyLPC_cHttpBasicHeaderParser.h;h=93372df5264fd889241a6c0223d4923f26c28f19;hb=6f577ed92e46bc8bf0463a7330ff698ec75853f2;hp=42d23c369e930d6fbdbb0d7cfc53e769f27f6be6;hpb=1caf76555c1132c3348a2fbe414493313853b6a0;p=mimic%2FMiMicSDK.git
diff --git a/lib/src/http/NyLPC_cHttpBasicHeaderParser.h b/lib/src/http/NyLPC_cHttpBasicHeaderParser.h
index 42d23c3..93372df 100644
--- a/lib/src/http/NyLPC_cHttpBasicHeaderParser.h
+++ b/lib/src/http/NyLPC_cHttpBasicHeaderParser.h
@@ -19,16 +19,44 @@
* along with this program. If not, see .
*
* For further information please contact.
- * http://nyatla.jp/
- * or
+ * http://nyatla.jp/
+ * or
*
*********************************************************************************/
-#ifndef NyLPC_TcHttpBasicHeader_H
-#define NyLPC_TcHttpBasicHeader_H
+#ifndef NyLPC_TcHttpBasicHeaderParser_H
+#define NyLPC_TcHttpBasicHeaderParser_H
#include "NyLPC_stdlib.h"
#include "NyLPC_cHttpStream.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * HeaderParserã®ã¹ãã¼ã¿ã¹å®ç¾©å¤ã
+ */
+typedef NyLPC_TUInt8 NyLPC_TcHttpBasicHeaderParser_ST;
+#define NyLPC_TcHttpBasicHeaderParser_ST_START ((NyLPC_TcHttpBasicHeaderParser_ST)0x01)//HTTPã¹ãã¼ã¿ã¹ã©ã¤ã³ãããªã¯ã¨ã¹ãã©ã¤ã³
+#define NyLPC_TcHttpBasicHeaderParser_ST_RL_URL ((NyLPC_TcHttpBasicHeaderParser_ST)0x12)//URL
+#define NyLPC_TcHttpBasicHeaderParser_ST_RL_VERSION ((NyLPC_TcHttpBasicHeaderParser_ST)0x13)//VERSION
+#define NyLPC_TcHttpBasicHeaderParser_ST_SL_STATUSCODE ((NyLPC_TcHttpBasicHeaderParser_ST)0x21)//ã¹ãã¼ã¿ã¹ã³ã¼ã
+#define NyLPC_TcHttpBasicHeaderParser_ST_SL_REASON ((NyLPC_TcHttpBasicHeaderParser_ST)0x22)//Reason-Phrase
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSGHEAD ((NyLPC_TcHttpBasicHeaderParser_ST)0x31)//MESSAGE
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSGPARAM ((NyLPC_TcHttpBasicHeaderParser_ST)0x32)//MESSAGEãã©ã¡ã¼ã¿é¨
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSG_CONTENTLENGTH ((NyLPC_TcHttpBasicHeaderParser_ST)0x33)//MESSAGEContentLength
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSG_CONNECTION ((NyLPC_TcHttpBasicHeaderParser_ST)0x34)//MESSAGEConnection
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSG_TRANSFERENCODING ((NyLPC_TcHttpBasicHeaderParser_ST)0x35)//TransferEncoding
+#define NyLPC_TcHttpBasicHeaderParser_ST_MSG_RANGE ((NyLPC_TcHttpBasicHeaderParser_ST)0x36)//Range
+#define NyLPC_TcHttpBasicHeaderParser_ST_EOH ((NyLPC_TcHttpBasicHeaderParser_ST)0x7F)//çµãã
+#define NyLPC_TcHttpBasicHeaderParser_ST_ERROR ((NyLPC_TcHttpBasicHeaderParser_ST)0x80)//çµãã
+/*
+ ãã©ã¤ãã¼ãé¢æ°
+*/
+#define NyLPC_TcHttpBasicHeaderParser_ST_isError(i_v) ((i_v)==NyLPC_TcHttpBasicHeaderParser_ST_ERROR)
+
+
+
/**
* ãã®ã¯ã©ã¹ã¯ãHttpãããã®ãã¼ãµãå®ç¾©ãã¾ãã
*/
@@ -39,18 +67,25 @@ typedef struct NyLPC_TcHttpBasicHeaderParser NyLPC_TcHttpBasicHeaderParser_t;
* HTTPã¡ã½ããã®å®ç¾©å¤ã
*/
typedef NyLPC_TUInt8 NyLPC_THttpMethodType;
-#define NyLPC_THttpMethodType_GET ((NyLPC_THttpMethodType)0x01)
-#define NyLPC_THttpMethodType_POST ((NyLPC_THttpMethodType)0x02)
-#define NyLPC_THttpMethodType_HEAD ((NyLPC_THttpMethodType)0x03)
+//HTTP STANDARD
+#define NyLPC_THttpMethodType_NULL ((NyLPC_THttpMethodType)0x00)
+#define NyLPC_THttpMethodType_GET ((NyLPC_THttpMethodType)0x01)
+#define NyLPC_THttpMethodType_POST ((NyLPC_THttpMethodType)0x02)
+#define NyLPC_THttpMethodType_HEAD ((NyLPC_THttpMethodType)0x03)
+//SSDP
+#define NyLPC_THttpMethodType_M_SEARCH ((NyLPC_THttpMethodType)0x11)
+#define NyLPC_THttpMethodType_NOTIFY ((NyLPC_THttpMethodType)0x12)
+
+const char* NyLPC_THttpMethodType_toString(NyLPC_THttpMethodType i_method);
/**
* HTTPãã¼ã¸ã§ã³ã®å®ç¾©å¤
*/
typedef NyLPC_TUInt8 NyLPC_THttpVersion;
-#define NyLPC_THttpVersion_09 ((NyLPC_THttpVersion)0x01)
-#define NyLPC_THttpVersion_10 ((NyLPC_THttpVersion)0x02)
-#define NyLPC_THttpVersion_11 ((NyLPC_THttpVersion)0x03)
-#define NyLPC_THttpVersion_UNKNOWN ((NyLPC_THttpVersion)0x04)
+#define NyLPC_THttpVersion_09 ((NyLPC_THttpVersion)0x01)
+#define NyLPC_THttpVersion_10 ((NyLPC_THttpVersion)0x02)
+#define NyLPC_THttpVersion_11 ((NyLPC_THttpVersion)0x03)
+#define NyLPC_THttpVersion_UNKNOWN ((NyLPC_THttpVersion)0x04)
typedef NyLPC_TUInt8 NyLPC_THttpHeaderType;
@@ -62,10 +97,11 @@ typedef NyLPC_TUInt8 NyLPC_THttpMessgeHeader_Connection;
#define NyLPC_THttpMessgeHeader_Connection_NONE ((NyLPC_THttpMessgeHeader_Connection)0x01)
#define NyLPC_THttpMessgeHeader_Connection_CLOSE ((NyLPC_THttpMessgeHeader_Connection)0x02)
#define NyLPC_THttpMessgeHeader_Connection_KEEPALIVE ((NyLPC_THttpMessgeHeader_Connection)0x03)
+#define NyLPC_THttpMessgeHeader_Connection_UPGRADE ((NyLPC_THttpMessgeHeader_Connection)0x04)
#define NyLPC_THttpMessgeHeader_Connection_UNKNOWN ((NyLPC_THttpMessgeHeader_Connection)0x10)
typedef NyLPC_TUInt8 NyLPC_THttpMessgeHeader_TransferEncoding;
-#define NyLPC_THttpMessgeHeader_TransferEncoding_NONE ((NyLPC_THttpMessgeHeader_TransferEncoding)0x01) //TEã¯ãªã
+#define NyLPC_THttpMessgeHeader_TransferEncoding_NONE ((NyLPC_THttpMessgeHeader_TransferEncoding)0x01) //TEã¯ãªã
#define NyLPC_THttpMessgeHeader_TransferEncoding_CHUNKED ((NyLPC_THttpMessgeHeader_TransferEncoding)0x02)
#define NyLPC_THttpMessgeHeader_TransferEncoding_UNKNOWN ((NyLPC_THttpMessgeHeader_TransferEncoding)0x10)
@@ -80,20 +116,21 @@ typedef NyLPC_TUInt8 NyLPC_THttpMessgeHeader_TransferEncoding;
*/
struct NyLPC_THttpBasicHeader
{
- NyLPC_THttpHeaderType type;
- union{
- struct{
- NyLPC_THttpVersion version;
- NyLPC_THttpMethodType method;
- }req;
- struct{
- NyLPC_THttpVersion version;
- NyLPC_TUInt32 status;
- }res;
- }startline;
- NyLPC_THttpMessgeHeader_TransferEncoding transfer_encoding;
- NyLPC_TUInt32 content_length;
- NyLPC_THttpMessgeHeader_Connection connection;
+ NyLPC_THttpMessgeHeader_TransferEncoding transfer_encoding;
+ NyLPC_THttpMessgeHeader_Connection connection;
+ NyLPC_THttpHeaderType type;
+ NyLPC_TUInt8 _padding;
+ union{
+ struct{
+ NyLPC_THttpVersion version;
+ NyLPC_THttpMethodType method;
+ }req;
+ struct{
+ NyLPC_THttpVersion version;
+ NyLPC_TUInt32 status;
+ }res;
+ }startline;
+ NyLPC_TUInt32 content_length;
};
/**
@@ -114,7 +151,6 @@ NyLPC_TBool NyLPC_THttpBasicHeader_isPersistent(const struct NyLPC_THttpBasicHea
-#define NyLPC_TcHttpBasicHeaderParser_ST_isError(i_v) ((i_v)==NyLPC_TcHttpBasicHeaderParser_ST_ERROR)
/**
* ç¬èªã®ã¡ãã»ã¼ã¸ãã£ã¼ã«ããåãåãã¤ãã³ããã³ãã©ã§ãã
@@ -136,47 +172,86 @@ typedef NyLPC_TBool (*NyLPC_cHttpBasicHeaderParser_messageHandler) (NyLPC_TcHttp
* URLã¨ã³ã - i_cã«0ãæå®ãã¦ãURLãå®äºããäºãæ示ãã¾ãã
*
*/
-/**
-ã¡ãã»ã¼ã¸ãã³ãã©ã¯NyLPC_cHttpBasicHeaderParserããï¼ç¨®é¡ã®ã¡ãã»ã¼ã¸ãåãåãã¾ãã
- 1.URLã¡ãã»ã¼ã¸ - i_cã«\0以å¤ã®æåãæå®ãã¦ãURLå¤ãå
¥åããã¦ããäºãæ示ãã¾ãã
- 2.URLã¨ã³ã - i_cã«0ãæå®ãã¦ãURLãå®äºããäºãæ示ãã¾ãã
-*/
typedef NyLPC_TBool (*NyLPC_cHttpBasicHeaderParser_urlHandler) (NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TChar i_c,struct NyLPC_THttpBasicHeader* o_out);
+/**
+ * HTTPããããã¼ãµãã³ãã©ã®éåã§ãã
+ * ãã³ãã©ã«NULLæå®ã®å ´åTRUEãè¿ããã¨è¦ãªãã¾ãã
+ */
struct NyLPC_TcHttpBasicHeaderParser_Handler
{
- NyLPC_cHttpBasicHeaderParser_messageHandler messageHandler;
- NyLPC_cHttpBasicHeaderParser_urlHandler urlHandler;
+ NyLPC_cHttpBasicHeaderParser_messageHandler messageHandler;
+ NyLPC_cHttpBasicHeaderParser_urlHandler urlHandler;
};
/**
-ã¯ã©ã¹æ§é ä½
-*/
+ * ã¯ã©ã¹æ§é ä½
+ */
struct NyLPC_TcHttpBasicHeaderParser
{
- /**ç¶æ¿ã¯ã©ã¹ã§å®è£
ãã¹ãã¤ã³ã¿ãã§ã¤ã¹*/
- const struct NyLPC_TcHttpBasicHeaderParser_Handler* _handler;
- NyLPC_TUInt16 _rcode;//_stãERRORã®æã«ã¨ã©ã¼ã³ã¼ããæ ¼ç´ããã
- /**ã¯ã¼ã¯æåå*/
- NyLPC_TcStr_t _wsb;
- /**ã¯ã¼ã¯æååã®ãããã¡*/
- char _wsb_buf[NyLPC_cHttpBasicHeaderParser_SIZE_OF_WBS];
+ /**ç¶æ¿ã¯ã©ã¹ã§å®è£
ãã¹ãã¤ã³ã¿ãã§ã¤ã¹*/
+ const struct NyLPC_TcHttpBasicHeaderParser_Handler* _handler;
+ NyLPC_TUInt16 _rcode;//_stãERRORã®æã«ã¨ã©ã¼ã³ã¼ããæ ¼ç´ããã
+ /** ãã¼ã¹ã®å®è¡ç¶æ
*/
+ NyLPC_TcHttpBasicHeaderParser_ST _st;
+ /**ã¯ã¼ã¯æåå*/
+ NyLPC_TcStr_t _wsb;
+ /**ã¯ã¼ã¯æååã®ãããã¡*/
+ char _wsb_buf[NyLPC_cHttpBasicHeaderParser_SIZE_OF_WBS];
};
-void NyLPC_cHttpBasicHeaderParser_initialize(NyLPC_TcHttpBasicHeaderParser_t* i_inst);
+void NyLPC_cHttpBasicHeaderParser_initialize(NyLPC_TcHttpBasicHeaderParser_t* i_inst,const struct NyLPC_TcHttpBasicHeaderParser_Handler* i_handler);
#define NyLPC_cHttpBasicHeaderParser_finalize(i_inst)
-NyLPC_TBool NyLPC_cHttpBasicHeaderParser_parse(NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TcHttpStream_t* i_stream,struct NyLPC_THttpBasicHeader* o_out);
+/**
+ * ãã¼ãµã®éå§å¦çããã¾ãã
+ * é¢æ°ã¯ãparseInit->parseChar[nå]->(parseStream)->parseFinishã®é ã§ã³ã¼ã«ãã¾ãã
+ * parseCharãåã¯parseStreamã§ã¨ã©ã¼ãçºçããå ´åã¯ãå¾ç¶ã®é¢æ°ãå¼ã³åºããã¨ã¯åºæ¥ã¾ããã
+ * parseCharã§EOHã«éããå ´åãparseCharã¾ãã¯parseStreamãç¶ãã¦å¼ã¶ãã¨ã¯åºæ¥ã¾ããã
+ * parseFinishã¯parseCharã¾ãã¯parseStreamã§EOHã«éããå ´åã®ã¿å¼ã³åºããã¨ãåºæ¥ã¾ãã
+ */
+void NyLPC_cHttpBasicHeaderParser_parseInit(NyLPC_TcHttpBasicHeaderParser_t* i_inst,struct NyLPC_THttpBasicHeader* o_out);
+
+/**
+ * ãã¼ãµã®å¦çãéãã¾ãã
+ * @return
+ * ãã¼ã¹å¦çãæ£å¸¸ã«çµäºãããã®çå½å¤
+ */
+NyLPC_TBool NyLPC_cHttpBasicHeaderParser_parseFinish(NyLPC_TcHttpBasicHeaderParser_t* i_inst,struct NyLPC_THttpBasicHeader* o_out);
+
+/**
+ * æååããã¼ã¹ãã¾ãã
+ * ã³ã¼ã«åã«NyLPC_cHttpBasicHeaderParser_parseInitã§ãã¼ãµãéå§ãã¦ãã ããã
+ * @return
+ * ãã¼ã¹ããæåæ°ãã¨ã©ã¼ã®å ´å-1ã§ãã
+ * 0以ä¸ã®å ´åãgetParseStatusã§ãã¼ãµã®ç¶æ
ã確èªãã¦ãã ããã
+ */
+NyLPC_TInt32 NyLPC_cHttpBasicHeaderParser_parseChar(NyLPC_TcHttpBasicHeaderParser_t* i_inst,const NyLPC_TChar* i_c,NyLPC_TInt32 i_size,struct NyLPC_THttpBasicHeader* o_out);
+
+
+/**
+ * ã¹ããªã¼ã ããèªã¿åºãã¦ãEOHã«éããã¾ã§ãã¼ã¹ãã¾ãã
+ * ã³ã¼ã«åã«NyLPC_cHttpBasicHeaderParser_parseInitã§ãã¼ãµãéå§ãã¦ãã ããã
+ * @return
+ * å¦çãæ£å¸¸ã«çµäºããããè¿ãã¾ãã
+ * TRUEã®å ´åãã¹ãã¼ã¿ã¹ã¯EOHã«éãã¦ãã¾ãã(parseFinishãã³ã¼ã«ã§ãã¾ãã)
+ */
+NyLPC_TBool NyLPC_cHttpBasicHeaderParser_parseStream(NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TiHttpPtrStream_t* i_stream,struct NyLPC_THttpBasicHeader* o_out);
+
+
/**
* parseé¢æ°ãã¨ã©ã¼ã®å ´åã«ã
* åè£ã®ã¨ã©ã¼ã®ã¹ãã¼ã¿ã¹ã³ã¼ããè¿ãã
*/
#define NyLPC_cHttpBasicHeaderParser_getStatusCode(inst) ((inst)->_rcode)
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
#endif