xuxiuxi
2017-05-11 109ffe9a777658936a38d0c146579a67c60a0d17
FaceServer/ev_proto.h
@@ -3,8 +3,22 @@
#include <stddef.h>
#include <stdint.h>
#include <limits.h>
#pragma pack(1)
struct EVPProto
{
   enum EVPP
   {
      EVPP__FIRST,
      EVPP_RAW_BIN = 1,
      EVPP_RAW_TEXT,
      EVPP_PROTOBUF,
      EVPP_HTTP,
      EVPP__LAST
   };
};
struct EVPCommand
{
@@ -13,7 +27,7 @@
      EVPC__FIRST,
      EVPC_STATUS = 1,
      EVPC_USER_DEFINE = 128,
      EVPC__LAST
      EVPC__LAST = USHRT_MAX
   };
};
@@ -25,6 +39,8 @@
      EVPS_OK = 1,
      EVPS_ERROR = 128,
      EVPS_INTERNAL_ERROR,
      EVPS_PROTO_ERROR,
      EVPS_COMMAND_ERROR,
      EVPS_PARAMETER_ERROR,
      EVPS__LAST
   };
@@ -32,19 +48,36 @@
struct EVPHeader
{
private:
   uint8_t _padding1;
public:
   uint8_t proto;  // EVPProto::EVPP
   int16_t cmd;   // EVPCommand::EVPC
   uint32_t size;   // sizeof(EVPHeader)+sizeof(subcmd)
   void hton();
   void ntoh();
   EVPHeader() : _padding1(0), proto(EVPProto::EVPP__FIRST), cmd(EVPCommand::EVPC__FIRST), size(8)
   {}
};
struct EVP_Status
{
   int16_t status;
   void hton();
   void ntoh();
};
struct EVP_VariableBuffer
{
   int16_t type;
   uint8_t buff[0];
   void hton();
   void ntoh();
};
//#todo