MTK HTTP 协议之数据结构及枚举定义

做个记录也算是一个保存,有需要的朋友可以参考

nw_define.h

用来保存数据结构和枚举

 

#ifndef __NW_DEFINE_H__
#define __NW_DEFINE_H__

/* standard c start */
typedef	char	nw_int8;
typedef signed char nw_S8;
typedef	unsigned char	nw_uint8;
typedef int	nw_int32;
typedef unsigned int	nw_uint32;
typedef short	nw_int16;
typedef unsigned short	nw_uint16;

#ifdef WIN32
typedef unsigned __int64	nw_uint64;
typedef __int64	nw_int64;
#else
typedef unsigned long long	nw_uint64;
typedef long long	nw_int64;
#endif
/* standard c end */

#define NW_ATTR_HIDDEN           0x02
#define NW_READ_WRITE            0x00000000L
#define NW_READ_ONLY             0x00000100L
#define NW_OPEN_DIR              0x00000800L
#define NW_CREATE                0x00010000L
#define NW_CREATE_ALWAYS         0x00020000L 

typedef struct _NW_HTTP_DATA	NW_HTTP_DATA;
typedef struct _NW_HTTP_REQ_INFO   NW_HTTP_REQ_INFO;

#define SOCKET_SUPPORT_ID_MAX	(4)

//回调函数指针
typedef void (*NW_HTTP_EVENT_CALLABCK)(NW_HTTP_DATA *http_data, nw_uint32 event_type, nw_uint32 i_param, nw_uint32 w_param); // i_param 、w_param指向静态数据存储区的指针

//request头部数据结构体
typedef struct _NW_HTTP_REQ_INFO
{
	nw_int8 *url;              	   //请求地址
	nw_int8 *ref_url; 				     //referer参数
	nw_int8 *ua;              	   //User-Agent参数
	nw_int8 *head_param;      	   //其他请求头参数
	nw_int8 *get_data;         	   //Get方式传递的数据
	nw_uint8 *post_data;      	 	 //Post方式发送的数据
	nw_uint32 post_data_length;  	 //Post时数据的长度
	nw_uint32 req_type;         	 //请求方式 Get\Post\Head
};


//response头部数据结构体
typedef struct _NW_HTTP_RESP_INFO
{
	nw_uint32 status;		       //返回响应状态
	nw_uint32 content_length;	 //body长度
	nw_uint32 content_offset;	 //body在返回数据中offset
	nw_uint32 content_type;    //数据类型
	nw_uint32 is_chunked;      //数据传送是否为chunk方式
	nw_int8 *location;         //location
	nw_uint32 charset;         //编码方式
}NW_HTTP_RESP_INFO;


typedef struct _NW_HTTP_DATA
{
/* request关联数据 start */
	NW_HTTP_REQ_INFO nw_req_info;     		 //请求头部数据
	nw_int8 *nw_req_head_buf; 		    		 //指向请求头数据
	nw_uint32 nw_req_head_length; 		     //请求头数据长度
	nw_uint32 nw_req_head_offset;		     	 //请求头数据offset

	nw_uint8 *nw_send_buf; 			    			 //指向发送缓冲区
	nw_uint32 nw_send_buf_size; 		    	 //发送缓冲区大小
	nw_uint32 nw_send_data_length;		     //发送数据长度

	nw_uint32 nw_net_type; //连接方式
	nw_uint32 nw_timeout_id;             	 //http连接超时处理
/* request关联数据 end */

/* response关联数据 start */
	NW_HTTP_RESP_INFO nw_resp_info;    		 //返回的头部数据结构
	nw_int8 *nw_resp_head_buf; 		    		 //指向返回头部数据
	nw_uint32 nw_resp_head_length; 	     	 //response头部数据长度
	nw_uint32 nw_resp_head_offset;		     //response 头部数据offset

	nw_uint32 nw_can_recv;			    		   //缓冲区满标识
	nw_uint8 *nw_recv_buf;			     			 //指向接收缓冲区
	nw_uint32 nw_recv_buf_size;		    		 //接收数据缓冲区大小
	nw_uint32 nw_recv_data_length;		     //接收数据长度

	//缓冲数据标识(缓冲buffer不会定义的很大,需要分次数接收数据处理)
	nw_uint32 nw_peek_data_length;         //数据多次接收
	nw_uint32 nw_peek_state;               //数据接收次数标识
/* response关联数据 end */

	//HTTP_APP_MANAGER http_app;                  //http实体管理
	nw_int32 nw_soc_id;
	NW_HTTP_EVENT_CALLABCK nw_event_callback;		//通知上层处理数据的回调接口
	nw_int32 file_handle;
};  

typedef enum
{
	NW_HTTP_TYPE_GET = 0,
	NW_HTTP_TYPE_POST,
	NW_HTTP_TYPE_HEAD,
};

typedef enum
{
	NW_HTTP_TYPE_CMWAP = 0,
	NW_HTTP_TYPE_CMNET,
	NW_HTTP_TYPE_CDWAP,
	NW_HTTP_TYPE_CDNET,
};

typedef void (*NW_TIMER_CALLBACK)(void* nw_timer_param_i, void *nw_timer_param_w);

typedef enum  __NW_TIMER_TYPE
{
	NW_TIMER_HTTP_TIMER_OUT = 0,
	NW_TIMER_HTTP_TIMER_OTHER, //起timer需要这里扩展类型。
	NW_TIMER_HTTP_TIMER_MAX,
	
}NW_TIMER_TYPE;

typedef struct __NW_TIMER_DATA
{
	nw_uint32	timer_id; 	
	nw_int32	time; 
	NW_TIMER_CALLBACK callback_func; 
	nw_int8 used;
	nw_uint32 remain_time;
	nw_uint32 soc_id;
	NW_TIMER_TYPE type;
	void *nw_timer_param_i;
	void *nw_timer_param_w;
}NW_TIMER_DATA;

typedef enum __NW_HTTP_CONTENT_TYPE
{
	NW_MIME_TEXT_HTML = 1, 
	NW_MIME_TEXT_XHTML, 
	NW_MIME_TEXT_WML, 
	NW_MIME_TEXT_PLAIN, 
	NW_MIME_IMAGE_JPEG, 
	NW_MIME_IMAGE_GIF, 
	NW_MIME_IMAGE_PNG, 
	NW_MIME_EBK2_ZLIB_PAGE, 	
	NW_MIME_JAVA_JAD, 
	NW_MIME_JAVA_JAR, 
	NW_MIME_SYMBIAN_SIS, 
	NW_MIME_MMS, 

	NW_HTTP_CONTENT_TYPE_MAX
}NW_HTTP_CONTENT_TYPE;

#endif /* #ifndef __NW_DEFINE_H__ */


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值