cheliequan
2023-01-29 dccc1ca1304dc1fcb86c8e24edd491509269b3e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "dbapi.h"
#include "util.h"
 
using namespace protomsg;
 
//获取服务器本机配置信息
bool dbapi_get_server_get_sn(void *handle, char *reply_msg) {
    const char *topic = DATA_URL_PREFIX("/version/snBus");
    return bus_dbapi_get_str(handle, topic, &reply_msg);
}
 
bool dbapi_get_server_get_is_sys_expired(void *handle) {
    char *reply_msg = NULL;
    bool is_expired = false;
    bool ret = false;
    bool expire_val = false;
 
    ret = dbapi_get_server_get_sn(handle, reply_msg);
    if (ret && reply_msg != NULL) {
        // Read JSON and get root
        yyjson_doc *doc = yyjson_read(reply_msg, strlen(reply_msg), 0);
        yyjson_val *root = yyjson_doc_get_root(doc);
 
        yyjson_val *data = yyjson_obj_get(root, "expire");
        expire_val = yyjson_get_bool(data);
        printf("expire: %d\n", expire_val);
        yyjson_doc_free(doc);
    }
 
    free(reply_msg);
 
    return expire_val;
}