From 6e0dc69afa4c7171f9e31a50ad20d561189f7346 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@smartai.com> Date: 星期二, 31 八月 2021 17:44:55 +0800 Subject: [PATCH] Merge branch 'master' of http://os.smartai.com:9091/valib/c_bhomebus --- src/bh_api.cpp | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/bh_api.cpp b/src/bh_api.cpp index 8770bdf..9b151fa 100644 --- a/src/bh_api.cpp +++ b/src/bh_api.cpp @@ -338,11 +338,9 @@ strncpy(topics_buf + count, _input.topics[i], min); count += min; - if (total >= strlen(_input.topics[i])) { - total -= strlen(_input.topics[i]); - } + total -= min; - if ((_input.amount > 1) && (i < (_input.amount - 1))) { + if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) { strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC)); total -= 1; count++; @@ -352,7 +350,7 @@ } } - logger->debug("the parsed compound register topics: %s!\n", topics_buf); + //logger->debug("the parsed compound register topics: %s!\n", topics_buf); #else memcpy(topics_buf, topics, topics_len > (sizeof(topics_buf) - 1) ? (sizeof(topics_buf) - 1) : topics_len); #endif @@ -774,11 +772,9 @@ strncpy(topics_buf + count, _input.topics[i], min); count += min; - if (total >= strlen(_input.topics[i])) { - total -= strlen(_input.topics[i]); - } + total -= min; - if ((_input.amount > 1) && (i < (_input.amount - 1))) { + if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) { strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC)); total -= 1; count++; @@ -787,7 +783,7 @@ topics_buf[strlen(topics_buf) - 1] = '\0'; } } - logger->debug("the parsed compound sub topics: %s!\n", topics_buf); + //logger->debug("the parsed compound sub topics: %s!\n", topics_buf); #else memcpy(topics_buf, topics, topics_len > (sizeof(topics_buf) - 1) ? (sizeof(topics_buf) - 1) : topics_len); #endif @@ -915,7 +911,7 @@ int node_arr_len = 0; #if defined(PRO_DE_SERIALIZE) - struct _MsgPublish + struct MsgPublish { const char *topic; const char *data; -- Gitblit v1.8.0