From ecf23f882ca1b8aaf0863980fc4781c515da1695 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期一, 12 十二月 2022 16:49:03 +0800 Subject: [PATCH] add req rep --- message.h | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/message.h b/message.h index dc289df..6024a7b 100644 --- a/message.h +++ b/message.h @@ -16,7 +16,7 @@ struct cstrarr{ struct cstr* arr; - size_t size; + size_t count; }; // 杩涚▼娉ㄥ唽淇℃伅 struct creg{ @@ -88,16 +88,10 @@ }; ////////////////////////////////////////// -// request body -struct creq{ - struct cstr path; - struct cstr body; -}; // request msg struct creqmsg{ struct cstr procid; - struct creq msg; - void* src; + struct cstr msg; }; // decode stack err msg struct cstackmsgerr{ @@ -128,10 +122,8 @@ // reply msg struct crepmsg{ - struct cstr json; - - int success; - struct cstr msg; + int errcode; + struct cstr errmsg; struct cstr data; }; @@ -141,7 +133,7 @@ struct cstr cstr_new(const char* str, const size_t len); void cstr_free(struct cstr str); -struct cstrarr cstr_arr_new(const size_t len); +struct cstrarr cstr_arr_new(const size_t count); void cstr_arr_add(struct cstrarr* arr, const char* data, const size_t len, const size_t idx); void cstr_arr_free(struct cstrarr arr); @@ -161,8 +153,10 @@ void free_submsg_proclist(struct cproclist* ppl); // request msg -struct creqmsg* to_reqmsg(const char* pid, const size_t pids, - const char* data, const size_t size, void* src); +struct creqmsg* to_reqmsg(const char* pid,const size_t pids,const char* data,const size_t size); +struct creqmsg* make_req_msg(const char* topic, const size_t topics, + const char* data, const size_t datal); + void free_reqmsg(struct creqmsg* msg); // decode err msg struct cstackmsgerr* get_reqmsg_stackerr(struct creqmsg* msg); @@ -172,8 +166,11 @@ void free_reqmsg_stack(struct cstackmsg* msg); // reply msg -struct crepmsg* make_reply_msg(const int success, const char* msg, const size_t msgl, +struct cstr make_reply_msg_json(const int success, const char* msg, const size_t msgl, const char* data, const size_t datal); +struct crepmsg* make_reply_msg(const int errcode, const char* errmsg, const size_t emsgl, + const char* data, const size_t datal); + void free_reply_msg(struct crepmsg* msg); #ifdef __cplusplus -- Gitblit v1.8.0