zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame] | 1 | #ifndef _SP_MSGPACK_H_ |
| 2 | #define _SP_MSGPACK_H_ |
| 3 | |
| 4 | |
| 5 | #include "../msgpack/cwpack.h" |
| 6 | #include "sp_config.h" |
| 7 | |
| 8 | #ifdef __cplusplus |
| 9 | extern "C" { |
| 10 | #endif |
| 11 | |
| 12 | typedef struct |
| 13 | { |
| 14 | const char* key; |
| 15 | union |
| 16 | { |
| 17 | int32 intval; |
| 18 | const char* strval; |
| 19 | const uint8* binval; |
| 20 | } val; |
| 21 | int32 strlen; |
| 22 | } unpack_field_t; |
| 23 | |
| 24 | int32 sp_pack_init(cw_pack_context* pack,uint8* buf,uint16 len); |
| 25 | void sp_pack_put_str(cw_pack_context* pack,const char* parakey,const char* paraval); |
| 26 | void sp_pack_put_int(cw_pack_context* pack,const char* parakey,const int paraval); |
| 27 | void sp_pack_put_bin(cw_pack_context* pack,const char* parakey,const uint8* paraval, |
| 28 | const uint16 len); |
| 29 | uint16 sp_pack_length(cw_pack_context* pack); |
| 30 | |
| 31 | int32 sp_unpack_init(cw_unpack_context* unpack,uint8* buf,uint16 len); |
| 32 | uint8 sp_unpack_map_size(cw_unpack_context* unpack); |
| 33 | uint8 sp_unpack_value(cw_unpack_context* unpack,unpack_field_t* field); |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | } |
| 37 | #endif |
| 38 | |
| 39 | #endif |
| 40 | |