董大銮 1 yıl önce
ebeveyn
işleme
efbf069216

+ 1 - 0
inc/proto/MqttLog.h

@@ -15,6 +15,7 @@ enum LOG_TYPE
     LOG_TYPE_MQTT = 1,
     LOG_TYPE_DATA = 2,
     LOG_TYPE_FUNC = 4,
+    LOG_TYPE_DB   = 8,
     LOG_TYPE_ALL  = 0xffff
 };
 

+ 29 - 30
src/MqttClient/MqttApi.cpp

@@ -6,44 +6,43 @@
 
 int testAdd(int a, int b)
 {
-	auto cid = "YVQuIJXwW1k77yO0yLWWxvtwppyNOr4sQtDMv4f+7vIuBudxMOtZSttSJkc+gXsX";
-	MqttLog(MQTT_LOG_ERROR, "aes deocde: %s", cid);
-	auto len = base64DecodeLength(cid, strlen(cid));
-	auto cbytes = new uint8_t[len];
-	auto retLen = base64Decode(cbytes, len, (uint8_t*)cid, strlen(cid));
+    auto cid = "YVQuIJXwW1k77yO0yLWWxvtwppyNOr4sQtDMv4f+7vIuBudxMOtZSttSJkc+gXsX";
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "aes deocde: %s", cid);
+    auto len    = base64DecodeLength(cid, strlen(cid));
+    auto cbytes = new uint8_t[len];
+    auto retLen = base64Decode(cbytes, len, (uint8_t *)cid, strlen(cid));
 
-	auto need = aesDecryptLength(len);
-	uint8_t* outBytes = new uint8_t[need];
-	auto outLen = aesDecrypt(cbytes, len, nullptr, outBytes);
-	outBytes[outLen] = 0;
-	MqttLog(MQTT_LOG_ERROR, "aes deocde result: %s", outBytes + 4);
-	delete[] outBytes;
-	delete[] cbytes;
+    auto     need     = aesDecryptLength(len);
+    uint8_t *outBytes = new uint8_t[need];
+    auto     outLen   = aesDecrypt(cbytes, len, nullptr, outBytes);
+    outBytes[outLen]  = 0;
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "aes deocde result: %s", outBytes + 4);
+    delete[] outBytes;
+    delete[] cbytes;
 
-	auto pas = "hN0AF2XX6+rD4vZEfafQo9Ant7O26OAqS9U9b8qUqg5qSDFfLwhaiQ==";
-	MqttLog(MQTT_LOG_ERROR, "des deocde: %s", pas);
-	len = base64DecodeLength(pas, strlen(pas));
-	cbytes = new uint8_t[len];
-	base64Decode(cbytes, len, (uint8_t*)pas, strlen(pas));
-	desDecrypt(cbytes, len, outBytes);
-	outBytes[0x20] = 0;
-	MqttLog(MQTT_LOG_ERROR, "des deocde result: %s", outBytes);
+    auto pas = "hN0AF2XX6+rD4vZEfafQo9Ant7O26OAqS9U9b8qUqg5qSDFfLwhaiQ==";
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "des deocde: %s", pas);
+    len    = base64DecodeLength(pas, strlen(pas));
+    cbytes = new uint8_t[len];
+    base64Decode(cbytes, len, (uint8_t *)pas, strlen(pas));
+    desDecrypt(cbytes, len, outBytes);
+    outBytes[0x20] = 0;
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "des deocde result: %s", outBytes);
 
-
-	MqttLog(MQTT_LOG_DEBUG, "add: %d, %d", a, b);
-	MqttLog(MQTT_LOG_INFO, "add: %d, %d", a, b);
-	MqttLog(MQTT_LOG_WARN, "add: %d, %d", a, b);
-	MqttLog(MQTT_LOG_ERROR, "add: %d, %d", a, b);
-	return a + b;
+    MqttLog(LOG_DEBUG, LOG_TYPE_FUNC, "add: %d, %d", a, b);
+    MqttLog(LOG_INFO, LOG_TYPE_FUNC, "add: %d, %d", a, b);
+    MqttLog(LOG_WARN, LOG_TYPE_FUNC, "add: %d, %d", a, b);
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "add: %d, %d", a, b);
+    return a + b;
 }
 
-MqttHandle mqttCreate(const char* url)
+MqttHandle mqttCreate(const char *url)
 {
-	return MqttClient::fromUrl(url);
+    return MqttClient::fromUrl(url);
 }
 
 void mqttDestory(MqttHandle mqtt)
 {
-	if (mqtt != nullptr)
-		delete mqtt;
+    if (mqtt != nullptr)
+        delete mqtt;
 }

+ 34 - 31
src/proto/ProtoParser.cpp

@@ -297,13 +297,13 @@ std::string ProtoParser::connectPack(std::string userName)
     return str;
 }
 
-std::string ProtoParser::publish(const std::string &topic, const std::string &payload, const std::string &request, uint32_t &msgId, std::function<void(uint32_t, uint32_t, const std::string &, const std::string &, const std::string &)> cb, const std::string & par)
+std::string ProtoParser::publish(const std::string &topic, const std::string &payload, const std::string &request, uint32_t &msgId, std::function<void(uint32_t, uint32_t, const std::string &, const std::string &, const std::string &)> cb, const std::string &par)
 {
-        auto                        now = timestamp_now();
+    auto now = timestamp_now();
     {
         std::lock_guard<std::mutex> l(_publishLock);
 #ifdef DUMP
-        MqttLog(LOG_INFO, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
+        MqttLog(LOG_DEBUG, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
 #endif
         for (auto it = _publishes.begin(); it != _publishes.end();)
         {
@@ -329,24 +329,24 @@ std::string ProtoParser::publish(const std::string &topic, const std::string &pa
     pack.header.byte      = 0;
     pack.header.bits.type = MqttMsgPublish;
     pack.header.bits.qos  = MqttQosExactlyOnce;
-    pack.topic   = topic;
-    pack.payload = payload;
+    pack.topic            = topic;
+    pack.payload          = payload;
     {
         std::lock_guard<std::mutex> l(_publishLock);
         pack.msgId = ++_msgId;
         if (pack.msgId == 0)
             pack.msgId = ++_msgId;
-        msgId = pack.msgId;
-        auto info = new PublishInfo();
-        info->cb  = cb;
+        msgId         = pack.msgId;
+        auto info     = new PublishInfo();
+        info->cb      = cb;
         info->payload = payload;
         info->topic   = topic;
         info->time    = timestamp_now();
         info->par     = par;
         _publishes.emplace(pack.msgId, info);
-        #ifdef DUMP
-        MqttLog(LOG_INFO, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
-        #endif
+#ifdef DUMP
+        MqttLog(LOG_DEBUG, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
+#endif
     }
 #ifdef DUMP
     MqttLog(LOG_INFO, LOG_TYPE_MQTT, "publish topic: %s, msgId: %d, request: %s", topic.c_str(), pack.msgId, request.c_str());
@@ -471,29 +471,31 @@ int ProtoParser::parse(std::vector<uint8_t> &data)
     {
         MqttPubAckPacket pack;
         mqttFromBuffer(&pack, data);
-        _respMsgId = pack.msgId;
-        _rc        = pack.rc;
-        _payload   = "";
-        _topic     = "";
-        PublishInfo * info=nullptr;
+        _respMsgId        = pack.msgId;
+        _rc               = pack.rc;
+        _payload          = "";
+        _topic            = "";
+        PublishInfo *info = nullptr;
         {
             std::lock_guard<std::mutex> l(_publishLock);
-            auto it = _publishes.find(pack.msgId);
+            auto                        it = _publishes.find(pack.msgId);
             if (it != _publishes.end())
             {
-                info = it->second;
+                info   = it->second;
                 _topic = info->topic;
                 _publishes.erase(it);
-                MqttLog(LOG_INFO, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
+#ifdef DUMP
+                MqttLog(LOG_DEBUG, LOG_TYPE_MQTT, "_publishes size: %d", _publishes.size());
+#endif
             }
         }
         if (_topic.length() > 0 && pack.payload.length() > 0)
         {
             _rc = parsePayload(pack.payload, false);
         }
-        if (info!=nullptr)
+        if (info != nullptr)
         {
-            if (info->cb!=nullptr)
+            if (info->cb != nullptr)
             {
                 info->cb(_respMsgId, _rc, pack.payload, _payload, info->par);
             }
@@ -1077,15 +1079,16 @@ std::string ProtoParser::recallMessagePack(std::string requestJson, uint32_t &ms
 
     std::string str;
     par.SerializeToString(&str);
-    str = dataEncrypt(str);
+    str           = dataEncrypt(str);
     std::string s = std::to_string(mid);
-    return publish("MR", str, requestJson, msgId, [&](auto msgId, auto rc, auto& org, auto& payload, auto& par) 
-    {
-        if (rc == 0)
-        {
-            p->recallMessage(atoll(par.c_str()));
-        }
-    }, s);
+    return publish(
+        "MR", str, requestJson, msgId, [&](auto msgId, auto rc, auto &org, auto &payload, auto &par) {
+            if (rc == 0)
+            {
+                p->recallMessage(atoll(par.c_str()));
+            }
+        },
+        s);
 }
 
 std::string ProtoParser::syncFriendRequestUnreadPack(std::string requestJson, uint32_t &msgId)
@@ -1120,7 +1123,7 @@ std::string ProtoParser::sendMessagePack(std::string requestJson, uint32_t &msgI
     std::string str;
     par.SerializeToString(&str);
     str      = dataEncrypt(str);
-    auto ret = publish("MS", str, requestJson, msgId, [&](auto msgId, auto rc, auto& org, auto& payload, auto& par) {
+    auto ret = publish("MS", str, requestJson, msgId, [&](auto msgId, auto rc, auto &org, auto &payload, auto &par) {
         if (rc == 0)
         {
             if (org.length() == 16)
@@ -1982,7 +1985,7 @@ EM_BOOL ProtoParser::onWebSocketError(int eventType, const EmscriptenWebSocketEr
 EM_BOOL ProtoParser::onWebSocketOpen(int eventType, const EmscriptenWebSocketOpenEvent *websocketEvent, void *userData)
 {
     ProtoParser *parser = (ProtoParser *)userData;
-        
+
     {
         std::lock_guard<std::mutex> l(parser->_publishLock);
         parser->_publishes.clear();

+ 24 - 22
src/proto/ProtoParserPrivate.cpp

@@ -46,21 +46,21 @@ int ProtoParserPrivate::open(const char *pwd)
         FS.mount(NODEFS, {root : '.'}, '/data'););
         */
 #ifdef DUMP
-    MqttLog(MQTT_LOG_INFO, "open database: hcdchat.db");
+    MqttLog(LOG_INFO, LOG_TYPE_DB, "open database: hcdchat.db");
 #endif
     int ret = sqlite3_open("/data/hcdchat.db", &_db);
     if (ret != SQLITE_OK)
         ret = sqlite3_open("hcdchat.db", &_db);
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "open database failed(%d): %s\n", ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "open database failed(%d): %s\n", ret, sqlite3_errmsg(_db));
         return ret;
     }
     sqlite3_key(_db, pwd, strlen(pwd));
     ret = check();
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "check database failed(%d): %s\n", ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "check database failed(%d): %s\n", ret, sqlite3_errmsg(_db));
         return ret;
     }
     sqlite3_busy_timeout(_db, 3000);
@@ -78,7 +78,7 @@ int ProtoParserPrivate::check()
     ret             = sqlite3_exec(_db, sql, nullptr, nullptr, nullptr);
     if (ret != 0)
     {
-        MqttLog(MQTT_LOG_ERROR, "create table t_user_messages failed(%d): %s\n", ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "create table t_user_messages failed(%d): %s\n", ret, sqlite3_errmsg(_db));
         return ret;
     }
 
@@ -86,7 +86,7 @@ int ProtoParserPrivate::check()
     ret = sqlite3_exec(_db, sql, nullptr, nullptr, nullptr);
     if (ret != 0)
     {
-        MqttLog(MQTT_LOG_ERROR, "create table t_messages failed(%d): %s\n", ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "create table t_messages failed(%d): %s\n", ret, sqlite3_errmsg(_db));
         return ret;
     }
 
@@ -294,7 +294,7 @@ void ProtoParserPrivate::recallMessage(uint64_t mid)
 // TODO:
 #else
     bool found = false;
-    for (auto it = _messages.begin(); it != _messages.end() ; it++)
+    for (auto it = _messages.begin(); it != _messages.end(); it++)
     {
         if (it->message_id() == mid)
         {
@@ -311,7 +311,7 @@ void ProtoParserPrivate::recallMessage(uint64_t mid)
     {
         MqttLog(LOG_WARN, LOG_TYPE_FUNC, "recall can't find message with id: %lld", mid);
     }
-    #endif
+#endif
 }
 
 void ProtoParserPrivate::sendMessage(Message &msg, uint32_t msgId)
@@ -334,6 +334,8 @@ void ProtoParserPrivate::sendMessage(Message &msg, uint32_t msgId)
 int ProtoParserPrivate::getMessage(uint64_t id, std::function<bool(const Message &msg)> cb)
 {
 #ifdef USE_SQLITE3
+    // TODO:
+    return 0;
 #else
     for (auto &msg : _messages)
     {
@@ -354,7 +356,7 @@ int ProtoParserPrivate::getMessage(bool before, uint64_t idx, int count, int typ
     int cnt = 0;
 #ifdef USE_SQLITE3
 #if defined DUMP || defined DUMP_MESSAGE
-    MqttLog(MQTT_LOG_INFO, "getMessage, before: %d, idx: %lld, count: %d, type: %d, line: %d, target: %s", before, idx, count, type, line, target);
+    MqttLog(LOG_INFO, LOG_TYPE_FUNC, "getMessage, before: %d, idx: %lld, count: %d, type: %d, line: %d, target: %s", before, idx, count, type, line, target);
 #endif
     std::string sql = "select _mid, _from, _type, _target, _line, _data, _searchable_key, _dt, _content_type, _to from t_messages where _type = ? and _line = ? and _target = ?";
     if (idx == 0)
@@ -375,7 +377,7 @@ int ProtoParserPrivate::getMessage(bool before, uint64_t idx, int count, int typ
         Message msg;        
         toMessage(stmt, msg);
 #if defined DUMP || defined DUMP_MESSAGE
-        MqttLog(MQTT_LOG_INFO, "getMessage: %lld", msg.message_id());
+        MqttLog(LOG_INFO, LOG_TYPE_DB, "getMessage: %lld", msg.message_id());
 #endif
                 
         if(!cb(msg))
@@ -503,7 +505,7 @@ int ProtoParserPrivate::getConversation(const char *keyword, const char *types,
     str2[str2.length() - 1] = ')';
 
 #if defined DUMP || defined DUMP_MESSAGE
-    MqttLog(MQTT_LOG_INFO, "getConversation, types: %s, lines: %s, keyword: %s", types, lines, keyword == nullptr ? "" : keyword);
+    MqttLog(LOG_INFO, LOG_TYPE_DB, "getConversation, types: %s, lines: %s, keyword: %s", types, lines, keyword == nullptr ? "" : keyword);
 #endif
     std::string sql = "select _mid, _from, _type, _target, _line, _data, _searchable_key, _dt, _content_type, _to from (select * from t_messages where _type in " + str1 + " and _line in " + str2 + " ";
     if (keyword != nullptr && strlen(keyword) > 0)
@@ -517,7 +519,7 @@ int ProtoParserPrivate::getConversation(const char *keyword, const char *types,
             toMessage(stmt, msg);
 
 #if defined DUMP || defined DUMP_MESSAGE
-        MqttLog(MQTT_LOG_INFO, "getConversation: %lld", msg.message_id());
+            MqttLog(LOG_INFO, LOG_TYPE_DB ,"getConversation: %lld", msg.message_id());
 #endif
 
             if (!cb(msg))
@@ -588,7 +590,7 @@ int ProtoParserPrivate::exec(const char *sql, std::function<bool(struct sqlite3_
     int ret = sqlite3_prepare(_db, sql, strlen(sql), &stmt, nullptr);
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "sqlite3_prepare(%s) failed(%d): %s\n", sql, ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "sqlite3_prepare(%s) failed(%d): %s\n", sql, ret, sqlite3_errmsg(_db));
         return ret;
     }
     if (pars != nullptr)
@@ -607,7 +609,7 @@ int ProtoParserPrivate::exec(const char *sql, std::function<bool(struct sqlite3_
     }
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "exec(%s) failed(%d): %s\n", sql, ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "exec(%s) failed(%d): %s\n", sql, ret, sqlite3_errmsg(_db));
         return ret;
     }
     return ret;
@@ -649,7 +651,7 @@ int ProtoParserPrivate::insert(const char *sql, std::function<bool(struct sqlite
     auto                 ret  = sqlite3_prepare_v2(_db, sql, strlen(sql), &stmt, nullptr);
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "sqlite3_prepare_v2 failed(%d), sql: (%s), errmsg: %s\n", ret, sql, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "sqlite3_prepare_v2 failed(%d), sql: (%s), errmsg: %s\n", ret, sql, sqlite3_errmsg(_db));
         return ret;
     }
     while (cb(stmt))
@@ -659,7 +661,7 @@ int ProtoParserPrivate::insert(const char *sql, std::function<bool(struct sqlite
             ret = SQLITE_OK;
         if (ret != SQLITE_OK)
         {
-            MqttLog(MQTT_LOG_ERROR, "sqlite3_step failed(%d), errmsg: %s\n", ret, sqlite3_errmsg(_db));
+            MqttLog(LOG_ERROR, LOG_TYPE_DB, "sqlite3_step failed(%d), errmsg: %s\n", ret, sqlite3_errmsg(_db));
             break;
         }
     }
@@ -668,12 +670,12 @@ int ProtoParserPrivate::insert(const char *sql, std::function<bool(struct sqlite
         ret = sqlite3_finalize(stmt);
         if (ret != SQLITE_OK)
         {
-            MqttLog(MQTT_LOG_ERROR, "sqlite3_finalize failed(%d), errmsg: %s\n", ret, sqlite3_errmsg(_db));
+            MqttLog(LOG_ERROR, LOG_TYPE_DB, "sqlite3_finalize failed(%d), errmsg: %s\n", ret, sqlite3_errmsg(_db));
         }
     }
     else
     {
-        MqttLog(MQTT_LOG_WARN, "not invoke sqlite3_finalize");
+        MqttLog(LOG_WARN, LOG_TYPE_DB, "not invoke sqlite3_finalize");
     }
     return ret;
 }
@@ -1002,7 +1004,7 @@ int ProtoParserPrivate::update(PullMessageResult &result, uint64_t &head)
     auto        ret = sqlite3_exec(_db, sql.c_str(), nullptr, nullptr, nullptr);
     if (ret != SQLITE_OK)
     {
-        MqttLog(MQTT_LOG_ERROR, "failed exec: %s: %d, %s", sql.c_str(), ret, sqlite3_errmsg(_db));
+        MqttLog(LOG_ERROR, LOG_TYPE_DB, "failed exec: %s: %d, %s", sql.c_str(), ret, sqlite3_errmsg(_db));
     }
     sql = "insert into t_messages(_mid, _from, _type, _target, _line, _data, _searchable_key, _dt, _content_type, _to) values (?,?,?,?,?,?,?,?,?,?);";
 
@@ -1026,14 +1028,14 @@ int ProtoParserPrivate::update(PullMessageResult &result, uint64_t &head)
         bindText(stmt, col++, entry.to_user().c_str());
         i++;
 #if defined DUMP || defined DUMP_MESSAGE
-        MqttLog(MQTT_LOG_INFO, "insert message %lld, type: %d, line: %d, target: %s", entry.message_id(), entry.conversation().type(), entry.conversation().line(), entry.conversation().target().c_str());
+        MqttLog(LOG_INFO, LOG_TYPE_DB, "insert message %lld, type: %d, line: %d, target: %s", entry.message_id(), entry.conversation().type(), entry.conversation().line(), entry.conversation().target().c_str());
 #endif
         return true;
     });
 #if defined DUMP || defined DUMP_MESSAGE
     auto err = exec("select count(*) from t_messages", [&](struct sqlite3_stmt *stmt) {
         int c = sqlite3_column_int64(stmt, 0);
-        MqttLog(MQTT_LOG_INFO, "t_messages count: %d", c);
+        MqttLog(LOG_INFO, LOG_TYPE_DB, "t_messages count: %d", c);
         return true;
     });
 
@@ -1041,7 +1043,7 @@ int ProtoParserPrivate::update(PullMessageResult &result, uint64_t &head)
         Message msg;
         toMessage(stmt, msg);
 
-        MqttLog(MQTT_LOG_INFO, "getMessage: %lld, type: %d, line: %d, target: %s", msg.message_id(), msg.conversation().type(), msg.conversation().line(), msg.conversation().target().c_str());
+        MqttLog(LOG_INFO, LOG_TYPE_DB, "getMessage: %lld, type: %d, line: %d, target: %s", msg.message_id(), msg.conversation().type(), msg.conversation().line(), msg.conversation().target().c_str());
 
         return true;
     });
@@ -1104,7 +1106,7 @@ void ProtoParserPrivate::test()
         bindText(stmt, col++, entry.to_user().c_str());
         i++;
 #if defined DUMP || defined DUMP_MESSAGE
-        MqttLog(MQTT_LOG_INFO, "insert message %lld, type: %d, line: %d, target: %s", entry.message_id(), entry.conversation().type(), entry.conversation().line(), entry.conversation().target().c_str());
+        MqttLog(LOG_INFO, LOG_TYPE_DB, "insert message %lld, type: %d, line: %d, target: %s", entry.message_id(), entry.conversation().type(), entry.conversation().line(), entry.conversation().target().c_str());
 #endif
         return true;
     });

+ 7 - 7
src/proto/jsonUtils.cpp

@@ -16,8 +16,8 @@ using namespace rapidjson;
         SET_INT(x);         \
     }
 
-int64_t GetInt64(rapidjson::Value& val)
-{    
+int64_t GetInt64(rapidjson::Value &val)
+{
     if (val.IsString())
     {
         return atoll(val.GetString());
@@ -194,18 +194,18 @@ void copy(Message &info, rapidjson::Value &json)
     writer.Key(#y);         \
     writer.Int64(info.x());
 #define WRITE_INT64_STR_2(x, y) \
-    writer.Key(#y);         \
+    writer.Key(#y);             \
     writer.String(std::to_string(info.x()).c_str());
 #define WRITE_INT64(x) WRITE_INT64_2(x, x)
 #define WRITE_INT64_OPT_2(x, y) \
     if (info.has_##x())         \
     {                           \
         WRITE_INT64_2(x, y);    \
-    }                                                  
+    }
 #define WRITE_INT64_STR_OPT_2(x, y) \
-    if (info.has_##x()) \
-    { \
-        WRITE_INT64_STR_2(x, y); \
+    if (info.has_##x())             \
+    {                               \
+        WRITE_INT64_STR_2(x, y);    \
     }
 #define WRITE_INT64_OPT(x) WRITE_INT64_OPT_2(x, x)
 #define WRITE_BOOL_2(x, y) \

+ 1 - 1
src/proto/pch.cpp

@@ -1 +1 @@
-#include "pch.h"
+#include "pch.h"

+ 1 - 1
src/zlib/zconf.h.included

@@ -8,7 +8,7 @@
 #ifndef ZCONF_H
 #define ZCONF_H
 /* #undef Z_PREFIX */
-#define Z_HAVE_UNISTD_H
+/* #undef Z_HAVE_UNISTD_H */
 
 /*
  * If you *really* need a unique prefix for all types and library functions,

+ 4 - 4
tests/TestTcp/main.cpp

@@ -13,7 +13,7 @@
 void TestDecode()
 {
     auto cid = "YVQuIJXwW1k77yO0yLWWxvtwppyNOr4sQtDMv4f+7vIuBudxMOtZSttSJkc+gXsX";
-    MqttLog(MQTT_LOG_ERROR, "aes deocde: %s", cid);
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "aes deocde: %s", cid);
     auto     len      = base64DecodeLength(cid, strlen(cid));
     auto     cbytes   = new uint8_t[len];
     auto     retLen   = base64Decode(cbytes, len, (uint8_t *)cid, strlen(cid));
@@ -21,12 +21,12 @@ void TestDecode()
     uint8_t *outBytes = new uint8_t[need];
     auto     outLen   = aesDecrypt(cbytes, retLen, nullptr, outBytes);
     outBytes[outLen]  = 0;
-    MqttLog(MQTT_LOG_ERROR, "aes deocde result: %s", outBytes + 4);
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "aes deocde result: %s", outBytes + 4);
     delete[] outBytes;
     delete[] cbytes;
 
     auto pas = "hN0AF2XX6+rD4vZEfafQo9Ant7O26OAqS9U9b8qUqg5qSDFfLwhaiQ==";
-    MqttLog(MQTT_LOG_ERROR, "des deocde: %s", pas);
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "des deocde: %s", pas);
     len              = base64DecodeLength(pas, strlen(pas));
     cbytes           = new uint8_t[len];
     retLen           = base64Decode(cbytes, len, (uint8_t *)pas, strlen(pas));
@@ -34,7 +34,7 @@ void TestDecode()
     outBytes         = new uint8_t[need];
     outLen           = desDecrypt(cbytes, retLen, outBytes);
     outBytes[outLen] = 0;
-    MqttLog(MQTT_LOG_ERROR, "des deocde result: %s", outBytes);
+    MqttLog(LOG_ERROR, LOG_TYPE_FUNC, "des deocde result: %s", outBytes);
     delete[] outBytes;
     delete[] cbytes;
 }