From a6724a226ae21a0a2e61cca85d54cbc09ed64508 Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Sun, 11 May 2014 10:52:19 +0800 Subject: [PATCH] uing qt int defs instead of platform specified int macros. --- .../cluster/cross_svr_messages.h | 70 +++-------- ZoomPipeline_FuncSvr/smartlink/st_message.h | 43 ++----- .../smartlink/st_msg_applayer.h | 112 +++--------------- 3 files changed, 41 insertions(+), 184 deletions(-) diff --git a/ZoomPipeline_FuncSvr/cluster/cross_svr_messages.h b/ZoomPipeline_FuncSvr/cluster/cross_svr_messages.h index 5edbbc9..c98c243 100644 --- a/ZoomPipeline_FuncSvr/cluster/cross_svr_messages.h +++ b/ZoomPipeline_FuncSvr/cluster/cross_svr_messages.h @@ -1,74 +1,36 @@ #ifndef CROSS_SVR_MESSAGES_H #define CROSS_SVR_MESSAGES_H - +#include namespace ZP_Cluster{ #pragma pack (push,1) - -#if defined(__GNUC__) -#include - typedef struct tag_cross_svr_message{ - struct tag_header{ - __UINT16_TYPE__ Mark; //Always be "0x1234" - __UINT8_TYPE__ messagetype; - __INT32_TYPE__ data_length; - } hearder; - union uni_payload{ - __UINT8_TYPE__ data[1]; - struct tag_CSM_heartBeating{ - __UINT32_TYPE__ nClients; - } heartBeating; - - struct tag_CSM_BasicInfo{ - __UINT8_TYPE__ name [64]; - __UINT8_TYPE__ Address_LAN[64]; - __UINT16_TYPE__ port_LAN; - __UINT8_TYPE__ Address_Pub[64]; - __UINT16_TYPE__ port_Pub; - } basicInfo; //msgType 0x01 - struct tag_CSM_Broadcast{ - __UINT8_TYPE__ name [64]; - __UINT8_TYPE__ Address_LAN[64]; - __UINT16_TYPE__ port_LAN; - __UINT8_TYPE__ Address_Pub[64]; - __UINT16_TYPE__ port_Pub; - }broadcastMsg[1];//msgType 0x02 - } payload; - - } CROSS_SVR_MSG; - -#endif - -#if defined(_MSC_VER) - typedef struct tag_cross_svr_message{ struct tag_header{ - unsigned __int16 Mark; //Always be 0x1234 - unsigned __int8 messagetype; - __int32 data_length; + quint16 Mark; //Always be 0x1234 + quint8 messagetype; + quint32 data_length; } hearder; union uni_payload{ - unsigned __int8 data[1]; + quint8 data[1]; struct tag_CSM_heartBeating{ - unsigned __int32 nClients; + quint32 nClients; } heartBeating; struct tag_CSM_BasicInfo{ - unsigned __int8 name [64]; - unsigned __int8 Address_LAN[64]; - unsigned __int16 port_LAN; - unsigned __int8 Address_Pub[64]; - unsigned __int16 port_Pub; + quint8 name [64]; + quint8 Address_LAN[64]; + quint16 port_LAN; + quint8 Address_Pub[64]; + quint16 port_Pub; } basicInfo; struct tag_CSM_Broadcast{ - unsigned __int8 name [64]; - unsigned __int8 Address_LAN[64]; - unsigned __int16 port_LAN; - unsigned __int8 Address_Pub[64]; - unsigned __int16 port_Pub; + quint8 name [64]; + quint8 Address_LAN[64]; + quint16 port_LAN; + quint8 Address_Pub[64]; + quint16 port_Pub; } broadcastMsg[1]; } payload; } CROSS_SVR_MSG; -#endif #pragma pack(pop) } diff --git a/ZoomPipeline_FuncSvr/smartlink/st_message.h b/ZoomPipeline_FuncSvr/smartlink/st_message.h index d51643e..f9912ef 100644 --- a/ZoomPipeline_FuncSvr/smartlink/st_message.h +++ b/ZoomPipeline_FuncSvr/smartlink/st_message.h @@ -1,48 +1,23 @@ #ifndef ST_MESSAGE_H #define ST_MESSAGE_H - +#include namespace ExampleServer{ #pragma pack (push,1) -#if defined(__GNUC__) -#include - /** - * @brief this structure provides a basic trans blocks. - * - */ typedef struct tag_example_message{ - __UINT16_TYPE__ Mark; //Always be "0xAA55" - __UINT32_TYPE__ source_id ; //0xffffffff means from server - __UINT32_TYPE__ destin_id ; //0xffffffff means to server - __UINT16_TYPE__ data_length; //Data at least have 2 byte, for heart-beating counter. - __UINT8_TYPE__ data[1]; + quint16 Mark; //Always be 0xAA55 + quint32 source_id ; //0xffffffff means from server + quint32 destin_id ; //0xffffffff means to server + quint16 data_length; //Data at least have 2 byte, for heart-beating counter. + quint8 data[1]; } EXAMPLE_TRANS_MSG; typedef struct tag_example_heartBeating { - __UINT16_TYPE__ Mark; //Always be 0xBeBe - __UINT32_TYPE__ source_id ; //0xffffffff means from server - __UINT16_TYPE__ tmStamp; + quint16 Mark; //Always be 0xBeBe + quint32 source_id ; //0xffffffff means from server + quint16 tmStamp; } EXAMPLE_HEARTBEATING; -#endif - -#if defined(_MSC_VER) - typedef struct tag_example_message{ - unsigned __int16 Mark; //Always be 0xAA55 - unsigned __int32 source_id ; //0xffffffff means from server - unsigned __int32 destin_id ; //0xffffffff means to server - unsigned __int16 data_length; //Data at least have 2 byte, for heart-beating counter. - unsigned __int8 data[1]; - } EXAMPLE_TRANS_MSG; - typedef struct tag_example_heartBeating - { - unsigned __int16 Mark; //Always be 0xBeBe - unsigned __int32 source_id ; //0xffffffff means from server - unsigned __int16 tmStamp; - } EXAMPLE_HEARTBEATING; -#endif - - #pragma pack(pop) } diff --git a/ZoomPipeline_FuncSvr/smartlink/st_msg_applayer.h b/ZoomPipeline_FuncSvr/smartlink/st_msg_applayer.h index fce993d..a9ba6b5 100644 --- a/ZoomPipeline_FuncSvr/smartlink/st_msg_applayer.h +++ b/ZoomPipeline_FuncSvr/smartlink/st_msg_applayer.h @@ -1,27 +1,24 @@ #ifndef ST_MSG_APPLAYER_H #define ST_MSG_APPLAYER_H - +#include namespace ExampleServer{ #pragma pack (push,1) -#if defined(__GNUC__) -#include - //User Login request //SMARTLINK_MSG_APP::MsgType = 0x0001 typedef struct tag_stMsg_ClientLoginReq{ - __UINT32_TYPE__ user_id; + quint32 user_id; char Passwd[1]; }stMsg_ClientLoginReq; //User Log response //SMARTLINK_MSG_APP::MsgType = 0x7FFE typedef struct tag_stMsg_ClientLoginRsp{ - __UINT8_TYPE__ DoneCode; - __UINT32_TYPE__ UserID; - __UINT8_TYPE__ Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address - __UINT16_TYPE__ port_Redirect; // and a port num. + quint8 DoneCode; //0- successful, 1-redirect, 3-failed. + quint32 UserID; + quint8 Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address + quint16 port_Redirect; // and a port num. } stMsg_ClientLoginRsp; //0x1002 @@ -31,94 +28,19 @@ namespace ExampleServer{ //0x7FFD typedef struct tag_stMsg_ClientLogoutRsp{ - __UINT8_TYPE__ DoneCode; + quint8 DoneCode; }stMsg_ClientLogoutRsp; - //UploadUserListReq,0x1003 typedef struct tag_stMsg_UploadUserListReq{ - __UINT16_TYPE__ UserNum; - __UINT32_TYPE__ pUserIDList[1]; + quint16 UserNum; + quint32 pUserIDList[1]; }stMsg_UploadUserListReq; //User Log response //SMARTLINK_MSG_APP::MsgType = 0x7FFC typedef struct tag_stMsg_UploadUserListRsp{ - __UINT8_TYPE__ DoneCode; - } stMsg_UploadUserListRsp; - - //SMARTLINK_MSG_APP::MsgType = 0x1004 - typedef struct tag_stMsg_DownloadUserListReq{ - - } stMsg_DownloadUserListReq; - - //SMARTLINK_MSG_APP::MsgType = 0x7FFB - typedef struct tag_stMsg_DownloadUserListRsp{ - __UINT8_TYPE__ DoneCode; - __UINT16_TYPE__ UserNum; - __UINT32_TYPE__ pUserIDList[1]; - } stMsg_DownloadUserListRsp; - - - - - typedef struct tag_example_app_layer{ - struct tag_app_layer_header{ - __UINT16_TYPE__ MsgType; - } header; - union union_MsgUnion - { - stMsg_ClientLoginReq msg_ClientLoginReq; - stMsg_ClientLoginRsp msg_ClientLoginRsp; - stMsg_UploadUserListReq msg_UploadUserListReq; - stMsg_UploadUserListRsp msg_UploadUserListRsp; - stMsg_DownloadUserListReq msg_DownloadUserListReq; - stMsg_DownloadUserListRsp msg_DownloadUserListRsp; - stMsg_ClientLogoutReq msg_ClientLogoutReq; - stMsg_ClientLogoutRsp msg_ClientLogoutRsp; - }MsgUnion; - } EXAMPLE_MSG_APP; - -#endif - -#if defined(_MSC_VER) - - //User Login request - //SMARTLINK_MSG_APP::MsgType = 0x0001 - typedef struct tag_stMsg_ClientLoginReq{ - unsigned __int32 user_id; - char Passwd[1]; - }stMsg_ClientLoginReq; - - //User Log response - //SMARTLINK_MSG_APP::MsgType = 0x7FFE - typedef struct tag_stMsg_ClientLoginRsp{ - unsigned __int8 DoneCode; //0- successful, 1-redirect, 3-failed. - unsigned __int32 UserID; - unsigned __int8 Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address - unsigned __int16 port_Redirect; // and a port num. - } stMsg_ClientLoginRsp; - - //0x1002 - typedef struct tag_stMsg_ClientLogoutReq{ - char UserName[1];//max 32 - }stMsg_ClientLogoutReq; - - //0x7FFD - typedef struct tag_stMsg_ClientLogoutRsp{ - unsigned __int8 DoneCode; - }stMsg_ClientLogoutRsp; - - //UploadUserListReq,0x1003 - typedef struct tag_stMsg_UploadUserListReq{ - unsigned __int16 UserNum; - unsigned __int32 pUserIDList[1]; - }stMsg_UploadUserListReq; - - //User Log response - //SMARTLINK_MSG_APP::MsgType = 0x7FFC - typedef struct tag_stMsg_UploadUserListRsp{ - unsigned __int8 DoneCode; + quint8 DoneCode; //char TextInfo[64]; } stMsg_UploadUserListRsp; @@ -130,18 +52,18 @@ namespace ExampleServer{ //SMARTLINK_MSG_APP::MsgType = 0x7FFB typedef struct tag_stMsg_DownloadUserListRsp{ - unsigned __int8 DoneCode; - unsigned __int16 UserNum; - unsigned __int32 pUserIDList[1]; + quint8 DoneCode; + quint16 UserNum; + quint32 pUserIDList[1]; } stMsg_DownloadUserListRsp; typedef struct tag_example_app_layer{ struct tag_app_layer_header{ - unsigned __int16 MsgFmtVersion; - unsigned __int8 AskID; - unsigned __int16 MsgType; + quint16 MsgFmtVersion; + quint8 AskID; + quint16 MsgType; } header; union union_MsgUnion { @@ -158,8 +80,6 @@ namespace ExampleServer{ } EXAMPLE_MSG_APP; -#endif - #pragma pack(pop) -- GitLab