From ba9e213d3f01555d823aaf453798a148dade45a4 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 13 十二月 2022 09:56:18 +0800
Subject: [PATCH] 添加注释

---
 main.cpp         |   15 +-
 message.cpp      |   73 +++++----
 message.h        |  192 ++++++++++++++++++++-------
 exported_symbols |   25 +++
 CMakeLists.txt   |    2 
 cbhomeclient.cpp |   15 +
 cbhomeclient.h   |   43 +++++
 7 files changed, 264 insertions(+), 101 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cdbef0..29d8e34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@
     )
 
 add_library(objs OBJECT ${src})
-# set(CMAKE_SHARED_LINKER_FLAGS  ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exported_symbols")
+set(CMAKE_SHARED_LINKER_FLAGS  ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exported_symbols")
 add_library(${Target} SHARED $<TARGET_OBJECTS:objs>)
 target_link_libraries(${Target} PRIVATE bhome_msg)
 
diff --git a/cbhomeclient.cpp b/cbhomeclient.cpp
index 9c8701e..574dcfd 100644
--- a/cbhomeclient.cpp
+++ b/cbhomeclient.cpp
@@ -324,12 +324,17 @@
     return bus_send_reply(cli->bus, src, pbstr.data(), pbstr.size());
 }
 
-
-
 ////////////////////////////////////////////////////
+int bus_client_publish(void* handle, const char* topic, const size_t topicl, const char* data, const size_t size){
+    MsgPublish pbmsg;
+    pbmsg.set_topic(topic, topicl);
+    pbmsg.set_data(data, size);
+    auto pbstr = pbmsg.SerializeAsString();
+    return bus_client_pubmsg(handle, pbstr.data(), pbstr.size());
+}
+
 // test
-int bus_client_pubmsg(void* handle, void* data, const size_t size){
+int bus_client_pubmsg(void* handle, const char* data, const size_t size){
     client* cli = ptr(handle);
-    bus_publish(cli->bus, data, size, 100);
-    return 0;
+    return bus_publish(cli->bus, data, size, 100);
 }
diff --git a/cbhomeclient.h b/cbhomeclient.h
index 3056b04..fba5c9e 100644
--- a/cbhomeclient.h
+++ b/cbhomeclient.h
@@ -10,17 +10,52 @@
 extern "C"{
 #endif
 
+/*
+    閰嶅悎 message.h[cpp] 浣跨敤
+*/
+/*
+    鍒濆鍖� bus client锛宻rvid 琛ㄦ槑褰撳墠鏈哄櫒鐨� srvid 鐢ㄤ簬杩滅▼閫氫俊锛岀洰鍓嶆病鐢�
+    rinfo 鏄敞鍐岃繘绋嬬殑娑堟伅锛屽崟杩涚▼澶氭璋冪敤锛岄渶瑕佷娇鐢ㄤ笉鍚岀殑rinfo
+*/
 void* bus_client_init(const char* srvid, const size_t sidsize, const creg* rinfo);
+/*
+    閲婃斁 bus client
+*/
 void bus_client_free(void* handle);
 
+/*
+    鑾峰彇璁㈤槄鐨勬秷鎭紝璁㈤槄娑堟伅閫氳繃绾跨▼涓嶅仠璇诲彇锛屾澶勪粠缂撳瓨涓鍙�
+    鍙�氳繃 message.h 瀵瑰簲鐨� get_submsg_db get_submsg_proclist 鑾峰彇瀵瑰簲鐨勬秷鎭�
+*/
 struct csubmsg* bus_client_get_submsg(void* handle);
+/*
+    鍙戝竷娑堟伅锛宒ata 鏄� MsgPublish protobuffer搴忓垪鍖栧悗鐨勬暟鎹�
+*/
+int bus_client_pubmsg(void* handle, const char* data, const size_t size);
+/*
+    鍙戝竷娑堟伅锛宼opic 鏄彂甯冧富棰橈紝 data 鏄彂甯冪殑娑堟伅浣�
+*/
+int bus_client_publish(void* handle, const char* topic, const size_t topicl, const char* data, const size_t size);
 
+/*
+    鑾峰彇 request 娑堟伅锛岄�氳繃绾跨▼璇诲彇锛屾澶勪粠缂撳瓨涓鍙�
+    鍙�氳繃 message.h 鐨� get_reqmsg_stackerr get_reqmsg_stack 鑾峰彇瀵瑰簲鐨勬秷鎭�
+    src 鏄摢涓�涓繘绋嬭姹傜殑鏍囪瘑绗�
+    鍙互鍝嶅簲澶氫釜request鍙戦�佺殑娑堟伅锛屽悓鏃堕渶瑕佹弧瓒冲紓姝ュ搷搴旓紝浣跨敤 src 杩涜鍖哄垎
+    绫讳技涓巘cp/ip鐨剆ocket锛屾爣璇嗕竴涓繛鎺�
+*/
 struct creqmsg* bus_client_get_reqmsg(void* handle, void** src);
-int bus_client_request(void* handle, struct creqmsg* msg, struct crepmsg** repmsg);
+/*
+    鍝嶅簲娑堟伅鍥炲锛宻rc鏄繛鎺ユ爣璇嗙锛宮sg鏄渶瑕佸洖澶嶇殑娑堟伅
+    閫氳繃 message.h 鐨� make_reply_msg 鍒涘缓
+*/
 int bus_client_reply_msg(void* handle, void* src, const struct crepmsg* msg);
-
-// test
-int bus_client_pubmsg(void* handle, void* data, const size_t size);
+/*
+    鍚屾鐨剅equest璇锋眰锛屽彂閫� creqmsg 鑾峰彇 crepmsg 鍥炲
+    閫氳繃 message.h 鐨� make_req_msg 鍒涘缓 request 娑堟伅
+    鑾峰彇鐨� crepmsg 鍥炲娑堟伅锛岄渶瑕佷娇鐢� free_reply_msg 閲婃斁
+*/
+int bus_client_request(void* handle, struct creqmsg* msg, struct crepmsg** repmsg);
 
 #ifdef __cplusplus
 }
diff --git a/exported_symbols b/exported_symbols
index 5df1201..9f57710 100644
--- a/exported_symbols
+++ b/exported_symbols
@@ -3,11 +3,36 @@
     bus_client_init;
     bus_client_free;
     bus_client_get_submsg;
+    bus_client_pubmsg;
+    bus_client_publish;
+    bus_client_get_reqmsg;
+    bus_client_reply_msg;
+    bus_client_request;
+    cstr_new;
+    cstr_free;
+    cstr_arr_new;
+    cstr_arr_add;
+    cstr_arr_free;
+    make_proc_info;
+    clone_proc_info;
+    free_proc_info;
+    free_creg;
+    to_submsg;
     free_submsg;
     get_submsg_db;
     free_submsg_db;
     get_submsg_proclist;
     free_submsg_proclist;
+    to_reqmsg;
+    make_req_msg;
+    free_reqmsg;
+    get_reqmsg_stackerr;
+    free_reqmsg_stackerr;
+    get_reqmsg_stack;
+    free_reqmsg_stack;
+    make_reply_msg_json;
+    make_reply_msg;
+    free_reply_msg;
 
 local:
     *;
diff --git a/main.cpp b/main.cpp
index 1e57df9..6d0e4bd 100644
--- a/main.cpp
+++ b/main.cpp
@@ -46,13 +46,14 @@
     while (true) {
         for(auto && i : topics){
             auto msg = base_msg + "test_ps pub message "+i+"-->msg-"+to_string(count++);
-            MsgPublish pbmsg;
-            pbmsg.set_topic(i);
-            pbmsg.set_data(msg);
-            auto data = pbmsg.SerializeAsString();
-            // TestPub(i.c_str(), i.length(), data.c_str(), data.length());
-            int pubres = bus_client_pubmsg(handle, (void*)data.data(), data.size());
-            printf("======>> bus_client_pubmsg [%s]\n", msg.c_str());
+            // MsgPublish pbmsg;
+            // pbmsg.set_topic(i);
+            // pbmsg.set_data(msg);
+            // auto data = pbmsg.SerializeAsString();
+            // int ret = bus_client_pubmsg(handle, data.data(), data.size());
+
+            int ret = bus_client_publish(handle, i.data(), i.size(), msg.data(), msg.size());
+            printf("======>> bus_client_pubmsg [%s] ret %d\n", msg.c_str(), ret);
             this_thread::sleep_for(chrono::seconds{2});
         }
     }
diff --git a/message.cpp b/message.cpp
index 394e1d4..9699470 100644
--- a/message.cpp
+++ b/message.cpp
@@ -22,19 +22,22 @@
 
 template <class T> T* ptrT(const size_t l=1){ return (T*)calloc(l, sizeof(T)); }
 
-static struct cstr cstr_clone(const struct cstr old){
-    return cstr_new(old.str, old.size);
-}
-static struct cstr cstr_ref(char* str, const size_t len){
+static inline struct cstr null_cstr(){
     struct cstr cs;
     memset(&cs, 0, sizeof(cs));
+    return cs;
+}
+static inline struct cstr cstr_ref(char* str, const size_t len){
+    struct cstr cs = null_cstr();
     cs.size = len;
     cs.str = str;
     return cs;
 }
+static inline struct cstr cstr_clone(const struct cstr old){
+    return cstr_new(old.str, old.size);
+}
 struct cstr cstr_new(const char* str, const size_t len){
-    struct cstr cs;
-    memset(&cs, 0, sizeof(cs));
+    struct cstr cs = null_cstr();
     cs.size = len;
     cs.str = ptrT<char>(len);
     memcpy(cs.str, str, len);
@@ -43,9 +46,13 @@
 void cstr_free(struct cstr str){
     if (str.str && str.size) free(str.str);
 }
-struct cstrarr cstr_arr_new(const size_t count){
+static inline struct cstrarr null_cstr_arr(){
     struct cstrarr arr;
     memset(&arr, 0, sizeof(arr));
+    return arr;
+}
+struct cstrarr cstr_arr_new(const size_t count){
+    struct cstrarr arr = null_cstr_arr();
     arr.arr = (struct cstr*)calloc(count, sizeof(struct cstr));
     arr.count = count;
     return arr;
@@ -63,21 +70,16 @@
     free(arr.arr);
 }
 
-void free_creg(struct creg* reg){
-    if (reg){
-        if (reg->pinfo) free_proc_info(reg->pinfo);
-        cstr_arr_free(reg->channel);
-        cstr_arr_free(reg->topic_pub);
-        cstr_arr_free(reg->topic_sub);
-        cstr_arr_free(reg->topic_sub_net);
-        free(reg);
-    }
+struct cproc* make_proc_info(const struct cstr name, const struct cstr id, const struct cstr info){
+    auto proc = ptrT<struct cproc>();
+    proc->name = cstr_clone(name);
+    proc->id = cstr_clone(id);
+    // proc->info = cstr_clone(info);
+    return proc;
 }
-
-struct cproc* clone_proc_info(struct cproc* pi){
+struct cproc* clone_proc_info(const struct cproc* pi){
     if (!pi) return NULL;
     auto newpi = ptrT<struct cproc>();
-    *newpi = *pi;
     newpi->name = cstr_clone(newpi->name);
     newpi->id = cstr_clone(newpi->id);
     // todo: ignore info
@@ -91,6 +93,17 @@
         cstr_free(pi->id);
         cstr_free(pi->info);
         free(pi);
+    }
+}
+
+void free_creg(struct creg* reg){
+    if (reg){
+        if (reg->pinfo) free_proc_info(reg->pinfo);
+        cstr_arr_free(reg->channel);
+        cstr_arr_free(reg->topic_pub);
+        cstr_arr_free(reg->topic_sub);
+        cstr_arr_free(reg->topic_sub_net);
+        free(reg);
     }
 }
 
@@ -183,9 +196,7 @@
 
     auto assign_arr = [&obj](yyjson_val* v){
         const size_t count = yyjson_arr_size(v);
-        struct cstrarr arr;
-        memset(&arr, 0, sizeof(arr));
-        arr.count = count;
+        struct cstrarr arr = cstr_arr_new(count);
         for(size_t i = 0; i < count; i++){
             auto sv = yyjson_arr_get(v, i);
             char* entry = NULL;
@@ -355,11 +366,11 @@
     const size_t size = msg->msg.size;
 
     auto pl = ptrT<struct cproclist>();
-    pl->cli = json2cclients(data, size, &pl->clientsize);
+    pl->cli = json2cclients(data, size, &pl->count);
     return pl;
 }
 void free_submsg_proclist(struct cproclist* pl){
-    if (pl) if (pl->cli) free_cclients(pl->cli, pl->clientsize);
+    if (pl) if (pl->cli) free_cclients(pl->cli, pl->count);
 }
 
 //////////////////////////////////////////////////
@@ -388,12 +399,12 @@
     return msg;
 }
 
-struct creqmsg* make_req_msg(const char* topic, const size_t topics,
+struct creqmsg* make_req_msg(const char* topic, const size_t topicl,
                                 const char* data, const size_t datal)
 {
     auto msg = ptrT<struct creqmsg>();
     MsgRequestTopic msgRT;
-    msgRT.set_topic(topic, topics);
+    msgRT.set_topic(topic, topicl);
     msgRT.set_data(data, datal);
 
     auto pbstr = msgRT.SerializeAsString();
@@ -411,9 +422,8 @@
 }
 
 struct cstackmsgerr* get_reqmsg_stackerr(struct creqmsg* msg){
-    struct cstr path, body;
-    memset(&path, 0, sizeof(path));
-    memset(&body, 0, sizeof(body));
+    struct cstr path = null_cstr();
+    struct cstr body = null_cstr();
     tie(path, body) = json2reqmsg(msg->msg);
     if (body.size == 0) return NULL;
 
@@ -443,9 +453,8 @@
 }
 // decode success msg
 struct cstackmsg* get_reqmsg_stack(struct creqmsg* msg){
-    struct cstr path, body;
-    memset(&path, 0, sizeof(path));
-    memset(&body, 0, sizeof(body));
+    struct cstr path = null_cstr();
+    struct cstr body = null_cstr();
     tie(path, body) = json2reqmsg(msg->msg);
     if (body.size == 0) return NULL;
 
diff --git a/message.h b/message.h
index 6024a7b..e22be44 100644
--- a/message.h
+++ b/message.h
@@ -4,38 +4,38 @@
 #include <stddef.h>
 
 struct cstr{
-    char*  str;
-    size_t size;
+    char*  str;         // 瀛楃涓插唴瀹�
+    size_t size;        // 瀛楃涓查暱搴�
 };
 // 杩涚▼淇℃伅
 struct cproc{
-    struct cstr name;
-    struct cstr id;
-    struct cstr info;
+    struct cstr name;   // 杩涚▼鍚嶅瓧
+    struct cstr id;     // 杩涚▼id
+    struct cstr info;   // 杩涚▼鍏朵粬淇℃伅锛岀洰鍓嶆病鐢�
 };
 
 struct cstrarr{
-    struct cstr* arr;
-    size_t count;
+    struct cstr* arr;   // 瀛楃涓叉暟缁�
+    size_t count;       // 瀛楃涓叉暟缁勯暱搴�
 };
 // 杩涚▼娉ㄥ唽淇℃伅
 struct creg{
-    struct cproc*  pinfo;
+    struct cproc*  pinfo;       // 闇�瑕佹敞鍐岀殑杩涚▼淇℃伅
 
-    cstrarr channel;
-    cstrarr topic_pub;
-    cstrarr topic_sub;
-    cstrarr topic_sub_net;
+    cstrarr channel;            // 杩涚▼鎻愪緵鐨勮姹傚搷搴旀湇鍔$殑涓婚
+    cstrarr topic_pub;          // 杩涚▼鎻愪緵鐨勫彂甯冭闃呯殑鍙戝竷涓婚
+    cstrarr topic_sub;          // 杩涚▼闇�瑕佽闃呯殑涓婚
+    cstrarr topic_sub_net;      // 杩涚▼闇�瑕佽闃呯殑缃戠粶涓婚锛岀洰鍓嶆病鐢�
 };
 
 // 鍏朵粬杩涚▼淇℃伅
 struct cclient{
-    struct creg*  rinfo;
+    struct creg*  rinfo;        // 浠h〃鍏朵粬杩涚▼鐨勮繘绋嬩俊鎭�
 
-    int replykey;
-    int hbcnt;
-    int dcnt;
-    int status;
+    int replykey;               // 娌$敤锛屼笂涓�涓増鏈敤鍏变韩鍐呭瓨锛屾涓簁ey
+    int hbcnt;                  // 蹇冭烦娆℃暟锛熷彲鑳芥病鐢�
+    int dcnt;                   // deadcount锛屽彲鑳芥病鐢紵
+    int status;                 // 杩涚▼鐘舵�侊紝鍙兘娌$敤锛�
 };
 
 //TableChanged enum
@@ -59,118 +59,206 @@
     T_Voice = 16,       //鎶ヨ澹伴煶鍙戠敓鍙樺寲
 };
 enum DbAction {
-    Insert = 0,     //Insert
-    Update = 1,     //Update
-    Delete = 2,     //Delete
+    Insert = 0,     //Insert db
+    Update = 1,     //Update db
+    Delete = 2,     //Delete db
 };
 
 // 鏁版嵁搴撳彉鍖栦俊鎭�
 struct DbChangeMsg{
     TableChanged table;     //鍙樺寲鐨勮〃
     struct cstr   id;      //鍙樺寲鏁版嵁id
-    DbAction action;        //action
+    DbAction action;        //action/ DbAction[Insert/Update/Delete]
     struct cstr   info;    //鍙樺寲鍐呭
 };
 
 // 璁㈤槄娑堟伅
 struct csubmsg{
-    struct cstr topic;
+    struct cstr topic;      // 鏀跺埌鐨勮闃呮秷鎭殑涓婚锛屽尯鍒嗛偅绉嶈闃呮秷鎭�
 
     // private
     // enum MsgT {NONE=0, DB, PROCLIST} type;
-    struct cstr msg;
+    struct cstr msg;        // 鏀跺埌鐨勮闃呮秷鎭殑body
 };
 
 // 鍏朵粬娉ㄥ唽杩涚▼鍒楄〃锛屽鏁版嵁搴撹繘绋嬮渶瑕佸惎鍔ㄥ啀杩愯pollcontrol閫昏緫
 struct cproclist{
-    struct  cclient* cli;
-    size_t  clientsize;
+    struct  cclient* cli;   // 鍏朵粬杩涚▼鐨勫垪琛�
+    size_t  count;          // 鍏朵粬杩涚▼鐨勫垪琛ㄧ殑count
 };
 
 //////////////////////////////////////////
 // request msg
+/*
+    姝ゆ秷鎭棦浣滀负鎺ユ敹鐨剅equest msg鐨勭粨鏋勶紝涔熶綔涓哄彂閫乺equest 娑堟伅鐨勭粨鏋�
+    鎺ユ敹request娑堟伅浼氬甫鏈夊彂鍑簉equest娑堟伅鐨勮繘绋嬬殑id锛宲rocid
+*/
 struct creqmsg{
-    struct cstr procid;
-    struct cstr msg;
+    struct cstr procid;     // 鍙戦�乺equest娑堟伅鐨勮繘绋媔d
+    struct cstr msg;        // request娑堟伅浣�
 };
 // decode stack err msg
+/*
+    pollcontrol浼氭帴鏀舵暟鎹爤瑙g爜鍙戦�佺殑瑙g爜澶辫触娑堟伅锛岀敤浜庣疆缃戦〉鐘舵��
+*/
 struct cstackmsgerr{
-    struct cstr stackid;
-    struct cstr fileid;
+    struct cstr stackid;    // 瑙g爜澶辫触鐨勬暟鎹爤id
+    struct cstr fileid;     // 瑙g爜澶辫触鐨勬枃浠秈d
 };
 // stack file
+/*
+    鏁版嵁鏍堢殑鏂囦欢鍒楄〃锛屽搴� protomsg.FileAnalysis 浣嗘槸姝ょ粨鏋勪綋闈炲父闀�
+    鐪嬩唬鐮佸簲璇ュ彧闇�瑕佽В鏋愬嚭鐨勫嚑涓�
+*/
 struct cstackfile{
-    struct cstr id;
-    struct cstr name;
-    struct cstr path;
-    int type;
-    void* noused;
+    struct cstr id;         // 鏂囦欢id
+    struct cstr name;       // 鏂囦欢name
+    struct cstr path;       // 鏂囦欢璺緞
+    int type;               // 鏂囦欢绫诲瀷 1锛歷ideo锛�2锛歱icture
+    void* noused;           // 鏈娇鐢�
 };
 // decode stack success msg
+/*
+    pollcontrol浼氭帴鏀舵暟鎹爤瑙g爜瀹屾垚鐨勬秷鎭紝鐒跺悗涓嬪彂鏂扮殑鏁版嵁鏍堜换鍔�
+*/
 struct cstackmsg{
-    int procnum;
-    struct cstr stackid;
-    struct cstr stackname;
-    int type;
-    int shmkey;
-    int width;
+    int procnum;                // decoder 鍚姩鐨勮繘绋嬪彿锛屾暟鎹爤鍙兘浼氭湁鏁颁釜decoder鍚屾椂杩愯
+    struct cstr stackid;        // 鏁版嵁鏍� id
+    struct cstr stackname;      // 鏁版嵁鏍� name
+    int type;                   // 鏁版嵁鏍堢被鍨� video picture
+    int shmkey;                 // 鏁版嵁鏍堜娇鐢ㄧ殑鍏变韩鍐呭瓨key
+    int width;                  // 鍒嗚鲸鐜�
     int height;
-    int fps;
-    struct cstackfile* files;
+    int fps;                    // fps 閲囨牱 fps/s
+    struct cstackfile* files;   // 鏁版嵁鏍堟枃浠跺垪琛�
     size_t filescnt;
 };
 
 // reply msg
+// 瀵瑰簲 bhome_msg.MsgRequestTopicReply
 struct crepmsg{
-    int errcode;
-    struct cstr errmsg;
-    struct cstr data;
+    int errcode;                // 鐩稿簲request璇锋眰鐨勬秷鎭紝閿欒鐮�
+    struct cstr errmsg;         // 閿欒娑堟伅
+    struct cstr data;           // 娑堟伅浣�
 };
 
 #ifdef __cplusplus
 extern "C"{
 #endif
-
+/*
+    灏佽浜咰鎺ュ彛鐨剆tring
+    cstr_new 鍒涘缓涓�涓猻tring锛屽寘鎷唴瀛樺湴鍧�鍜岄暱搴︼紝浼氭嫹璐濆弬鏁�
+    蹇呴』浣跨敤cstr_free閲婃斁
+*/
 struct cstr cstr_new(const char* str, const size_t len);
 void cstr_free(struct cstr str);
+/*
+    灏佽瀛楃涓叉暟缁勶紝鍏朵腑鏄竴涓猻truct cstr鏁扮粍锛屽寘鎷寚鍚戞暟缁勭殑鎸囬拡鍜宑ount
+    閫氳繃cstr_arr_add娣诲姞瀛楃涓诧紝鍐呴儴浼氭嫹璐濆瓧绗︿覆
+    蹇呴』浣跨敤cstr_arr_free閲婃斁
+*/
 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);
 
-void free_creg(struct creg* reg);
-
-struct cproc* clone_proc_info(struct cproc* pi);
+/*
+    鍒涘缓struct cproc 缁撴瀯锛屽搴攑rocinfo锛屼繚瀛榩roc鐨刵ame锛宨d锛宨nfo[褰撳墠娌℃湁浣跨敤]
+    蹇呴』浣跨敤free_proc_info閲婃斁
+*/
+struct cproc* make_proc_info(const struct cstr name, const struct cstr id, const struct cstr info);
+/*
+    浠庡凡瀛樺湪鐨刾roc鍏嬮殕锛屼細鎷疯礉锛屼娇鐢╢ree_proc_info閲婃斁
+*/
+struct cproc* clone_proc_info(const struct cproc* pi);
 void free_proc_info(struct cproc* pi);
 
+/*
+    閲婃斁creg缁撴瀯鎸囬拡
+    creg缁撴瀯鍙互浣跨敤涓婅堪make_proc_info銆乧str_arr_new銆乧str_new鍑芥暟鍒涘缓
+*/
+void free_creg(struct creg* reg);
 // 璁㈤槄娑堟伅鐩稿叧锛岃闃呮暟鎹簱db娑堟伅鍜岃繘绋嬪垪琛╬roclist娑堟伅
+/*
+    cbhomeclient.cpp涓娇鐢紝灏嗘帴鏀跺埌鐨剆ubmsg瑙e寘鎴恈submsg
+    鍖呮嫭topic鍜宮sg鏁版嵁锛宮sg鏁版嵁骞舵湭鍙嶅簭鍒楀寲
+    蹇呴』浣跨敤free_submsg閲婃斁
+*/
 struct csubmsg* to_submsg(const char* data, const size_t size);
 void free_submsg(struct csubmsg* msg);
 // db msg
+/*
+    鎺ユ敹鍒扮殑submsg鍦╬ollcontrol涓彲鑳戒负鏁版嵁搴撴洿鏂扮殑閫氱煡
+    灏哻submsg涓湭鍙嶅簭鍒楀寲鐨勬暟鎹В鍖呮垚db鐨勬暟鎹牸寮�
+    蹇呴』鐢╢ree_submsg_db閲婃斁
+*/
 struct DbChangeMsg* get_submsg_db(struct csubmsg* msg);
 void free_submsg_db(struct DbChangeMsg* msg);
 // proclist msg
+/*
+    鎺ユ敹鍒扮殑submsg鍦╬ollcontrol涓彲鑳戒负鍏冲績鐨勫叾浠栬繘绋嬬殑鍒楄〃
+    灏哻submsg涓湭鍙嶅簭鍒楀寲鐨勬暟鎹В鍖呮垚杩涚▼鐨勫垪琛�
+    蹇呴』鐢╢ree_submsg_proclist閲婃斁
+*/
 struct cproclist* get_submsg_proclist(struct csubmsg* msg);
 void free_submsg_proclist(struct cproclist* ppl);
 
 // request msg
+/*
+    cbhomeclient.cpp涓娇鐢紝灏嗘帴鏀跺埌鐨剅equest璇锋眰鏁版嵁瑙e寘鎴恈reqmsg
+    鍖呮嫭request杩涚▼鐨刾rocid鍜宮sg鏁版嵁锛宮sg鏁版嵁骞舵湭鍙嶅簭鍒楀寲
+    蹇呴』浣跨敤free_reqmsg閲婃斁
+*/
 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,
+void free_reqmsg(struct creqmsg* msg);
+/*
+    鏈繘绋嬪悜鍏朵粬杩涚▼璇锋眰鏁版嵁鏋勫缓
+    鍖呮嫭璇锋眰鐨勪富棰榯opic鍜岃姹傜殑鏁版嵁body[data]
+    蹇呴』浣跨敤free_reqmsg閲婃斁
+*/
+struct creqmsg* make_req_msg(const char* topic, const size_t topicl,
                                 const char* data, const size_t datal);
 
-void free_reqmsg(struct creqmsg* msg);
 // decode err msg
+/*
+    鎺ユ敹鍒扮殑creqmsg鍦╬ollcontrol涓彲鑳戒负鏁版嵁鏍堣В鐮侀敊璇俊鎭�
+    灏哻reqmsg涓湭鍙嶅簭鍒楀寲鐨勬暟鎹В鍖呮垚cstackmsgerr锛屽寘鎷暟鎹爤id stackid鍜屾枃浠秈d fileid
+    蹇呴』鐢╢ree_reqmsg_stackerr閲婃斁
+*/
 struct cstackmsgerr* get_reqmsg_stackerr(struct creqmsg* msg);
 void free_reqmsg_stackerr(struct cstackmsgerr* msg);
 // decode success msg
+/*
+    鎺ユ敹鍒扮殑creqmsg鍦╬ollcontrol涓彲鑳戒负鏁版嵁鏍堣В鐮佸畬鎴愪俊鎭�
+    灏哻reqmsg涓湭鍙嶅簭鍒楀寲鐨勬暟鎹В鍖呮垚cstackmsg
+    鍖呮嫭
+    int procnum;    // 鍚姩鐨刣ecoder杩涚▼num
+    struct cstr stackid;
+    struct cstr stackname;
+    int type;   // video picture
+    int shmkey;
+    int width;
+    int height;
+    int fps;
+    struct cstackfile* files; // 鏂囦欢鍒楄〃
+    size_t filescnt; // 鏂囦欢鏁伴噺
+    蹇呴』鐢╢ree_reqmsg_stackerr閲婃斁
+*/
 struct cstackmsg* get_reqmsg_stack(struct creqmsg* msg);
 void free_reqmsg_stack(struct cstackmsg* msg);
 
 // reply msg
+/*
+    no use 灏唕eply娑堟伅搴忓垪鍖栦负json锛岀洰鍓嶆病鏈変娇鐢�
+    浣跨敤 cstr_free 閲婃斁
+*/
 struct cstr make_reply_msg_json(const int success, const char* msg, const size_t msgl,
                                 const char* data, const size_t datal);
+/*
+    鍒涘缓 creqmsg 鍖呮嫭errcode銆乪rrmsg鍜屾秷鎭綋data
+    浣跨敤 free_reply_msg 閲婃斁
+*/
 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