From 08426958f2d94f170586fb69475563804f179065 Mon Sep 17 00:00:00 2001 From: Ali Karademir Date: Thu, 25 May 2017 09:47:12 +0300 Subject: [PATCH 1/6] ping period decreased from 60 to 30sec (cherry picked from commit 0c061797f8798c5e0e5d6bb16e93f71459199e71) --- broker/src/handshake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/broker/src/handshake.c b/broker/src/handshake.c index 2be23173..205858c4 100644 --- a/broker/src/handshake.c +++ b/broker/src/handshake.c @@ -256,7 +256,7 @@ void dslink_handle_ping(uv_timer_t* handle) { struct timeval current_time; gettimeofday(¤t_time, NULL); long time_diff = current_time.tv_sec - link->lastWriteTime->tv_sec; - if (time_diff >= 60) { + if (time_diff >= 30) { log_debug("dslink_handle_ping send heartbeat to %s\n", link->name ); broker_ws_send_obj(link, json_object()); } From a0dca87cf12d213bc97731ad8e9067ed73ad4871 Mon Sep 17 00:00:00 2001 From: Ali Karademir Date: Tue, 19 Sep 2017 13:57:44 +0300 Subject: [PATCH 2/6] msgpack feature integrated (cherry picked from commit afc334b028c9b881186ceff6ca43602fd55038cf) --- CMakeLists.txt | 7 +- broker/include/broker/net/ws.h | 2 +- broker/include/broker/remote_dslink.h | 2 + broker/src/handshake.c | 19 ++ broker/src/net/ws.c | 55 ++++- broker/src/net/ws_handler.c | 74 +++++-- broker/src/upstream/upstream_handshake.c | 8 + sdk/include/dslink/dslink.h | 2 + sdk/include/dslink/ws.h | 8 +- sdk/src/dslink.c | 5 + sdk/src/handshake.c | 4 + sdk/src/msg/list_response.c | 1 + sdk/src/ws.c | 265 +++++++++++++++++++++-- 13 files changed, 402 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 472f5d5a..dd577bca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_jansson.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_wslay.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_argtable3.txt") +include("${CMAKE_CURRENT_LIST_DIR}/deps/msgpack-c/CMakeLists.txt") include(ExternalProject) @@ -127,6 +128,7 @@ endif() include_directories("${CMAKE_CURRENT_BINARY_DIR}/include") include_directories("${JANSSON_DIR}/include") include_directories("${CMAKE_CURRENT_LIST_DIR}/sdk/include") +include_directories("${CMAKE_CURRENT_LIST_DIR}/deps/msgpack-c/include") set(DSLINK_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/sdk/src") set(DSLINK_SRC @@ -224,14 +226,14 @@ endif() if (DSLINK_BUILD_STATIC OR DSLINK_BUILD_EXAMPLES) add_library(sdk_dslink_c-static STATIC ${LIBRARY_SRC}) - target_link_libraries(sdk_dslink_c-static jansson libuv ${DSLINK_PLATFORM_LIBS}) + target_link_libraries(sdk_dslink_c-static msgpackc jansson libuv ${DSLINK_PLATFORM_LIBS}) set(DSLINK_INSTALL_TARGETS sdk_dslink_c sdk_dslink_c-static) else() set(DSLINK_INSTALL_TARGETS sdk_dslink_c) endif() add_library(sdk_dslink_c SHARED ${LIBRARY_SRC}) -target_link_libraries(sdk_dslink_c jansson libuv ${DSLINK_PLATFORM_LIBS}) +target_link_libraries(sdk_dslink_c msgpackc jansson libuv ${DSLINK_PLATFORM_LIBS}) set_target_properties(sdk_dslink_c PROPERTIES VERSION ${VERSION} SOVERSION ${VERSION} ) set(DSLINK_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") @@ -255,6 +257,7 @@ if (DSLINK_PACKAGE_INCLUDES) install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/deps/mbedtls/include/" DESTINATION "${DSLINK_INSTALL_INCLUDE_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/deps/wslay/lib/includes/" DESTINATION "${DSLINK_INSTALL_INCLUDE_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/deps/wslay/lib/" DESTINATION "${DSLINK_INSTALL_INCLUDE_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") + install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/deps/msgpack-c/include/" DESTINATION "${DSLINK_INSTALL_INCLUDE_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/deps/jansson/src/" DESTINATION "${DSLINK_INSTALL_INCLUDE_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") endif() diff --git a/broker/include/broker/net/ws.h b/broker/include/broker/net/ws.h index f489c3fd..6cf4cb6e 100644 --- a/broker/include/broker/net/ws.h +++ b/broker/include/broker/net/ws.h @@ -12,7 +12,7 @@ extern "C" { void broker_ws_send_init(Socket *sock, const char *accept); uint32_t broker_ws_send_obj(RemoteDSLink *link, json_t *obj); uint32_t broker_ws_send_obj_link_id(struct Broker* broker, const char *link_name, int upstream, json_t *obj); -int broker_ws_send(RemoteDSLink *link, const char *data); +int broker_ws_send(RemoteDSLink *link, const char *data, int len, int opcode); int broker_ws_generate_accept_key(const char *buf, size_t bufLen, char *out, size_t outLen); int broker_count_json_msg(json_t *json); diff --git a/broker/include/broker/remote_dslink.h b/broker/include/broker/remote_dslink.h index 34c7d389..be9241a9 100644 --- a/broker/include/broker/remote_dslink.h +++ b/broker/include/broker/remote_dslink.h @@ -61,6 +61,8 @@ typedef struct RemoteDSLink { Map responder_streams; PermissionGroups permission_groups; + + int is_msgpack; } RemoteDSLink; int broker_remote_dslink_init(RemoteDSLink *link); diff --git a/broker/src/handshake.c b/broker/src/handshake.c index 205858c4..9eced0b2 100644 --- a/broker/src/handshake.c +++ b/broker/src/handshake.c @@ -211,6 +211,25 @@ json_t *broker_handshake_handle_conn(Broker *broker, } json_object_set_new_nocheck(resp, "path", json_string_nocheck(buf)); + // FORMATS + link->is_msgpack = 0; + json_t* formats_from_link = json_object_get(handshake, "formats"); + + if(formats_from_link != NULL) + { + int arr_size = json_array_size(formats_from_link); + + for(int i = 0; i < arr_size; i++) + { + int ret = strcmp("msgpack", json_string_value(json_array_get(formats_from_link, i))); + if(ret == 0) + link->is_msgpack = 1; + } + } + + json_object_set_new_nocheck(resp, "format", json_string_nocheck( + link->is_msgpack == 1?"msgpack":"json")); + link->path = dslink_strdup(buf); if (!link->path) { goto fail; diff --git a/broker/src/net/ws.c b/broker/src/net/ws.c index 5b43c822..7aa89dbd 100644 --- a/broker/src/net/ws.c +++ b/broker/src/net/ws.c @@ -15,6 +15,9 @@ #include +#include +#include + #define BROKER_WS_RESP "HTTP/1.1 101 Switching Protocols\r\n" \ "Upgrade: websocket\r\n" \ "Connection: Upgrade\r\n" \ @@ -75,13 +78,47 @@ uint32_t broker_ws_send_obj(RemoteDSLink *link, json_t *obj) { link->msgId = 0; } json_object_set_new_nocheck(obj, "msg", json_integer(id)); - char *data = json_dumps(obj, JSON_PRESERVE_ORDER | JSON_COMPACT); + + // DECODE OBJ + char *data = NULL; + int len; + int opcode; + + log_debug("Message(as %s) is trying sent to %s: %s\n", + (link->is_msgpack==1)?"msgpack":"json", + (char *) link->dsId->data, + json_dumps(obj,JSON_INDENT(0))); + + if(link->is_msgpack) { + msgpack_sbuffer* buff = dslink_ws_json_to_msgpack(obj); + data = malloc(buff->size); + len = buff->size; + memcpy(data, buff->data, len); + msgpack_sbuffer_free(buff); + opcode = WSLAY_BINARY_FRAME; + } + else { + data = json_dumps(obj, JSON_PRESERVE_ORDER | JSON_COMPACT); + len = strlen(data); + opcode = WSLAY_TEXT_FRAME; + } + json_object_del(obj, "msg"); if (!data) { return DSLINK_ALLOC_ERR; } - int sentBytes = broker_ws_send(link, data); + + int sentBytes = broker_ws_send(link, data, len, opcode); + + if(sentBytes == -1) + { + log_err("Message(as %s) is failed sent to %s: %s\n", + (link->is_msgpack==1)?"msgpack":"json", + (char *) link->dsId->data, + json_dumps(obj,JSON_INDENT(0))); + } + if (throughput_output_needed()) { int sentMessages = broker_count_json_msg(obj); throughput_add_output(sentBytes, sentMessages); @@ -90,23 +127,27 @@ uint32_t broker_ws_send_obj(RemoteDSLink *link, json_t *obj) { return id; } -int broker_ws_send(RemoteDSLink *link, const char *data) { +int broker_ws_send(RemoteDSLink *link, const char *data, int len, int opcode) { if (!link->ws || !link->client) { return -1; } struct wslay_event_msg msg; msg.msg = (const uint8_t *) data; - msg.msg_length = strlen(data); - msg.opcode = WSLAY_TEXT_FRAME; + msg.msg_length = len; + msg.opcode = opcode; wslay_event_queue_msg(link->ws, &msg); if(link->client->poll && !uv_is_closing((uv_handle_t*)link->client->poll)) { uv_poll_start(link->client->poll, UV_READABLE | UV_WRITABLE, link->client->poll_cb); if (link->isUpstream) { - log_debug("Message sent to upstrem %s: %s\n", (char *) link->name, data); + log_debug("Message(%s) sent to upstream %s: %s\n", + (opcode==WSLAY_TEXT_FRAME)?"text":"binary", + (char *) link->name, data); } else { - log_debug("Message sent to %s: %s\n", (char *) link->dsId->data, data); + log_debug("Message(%s) sent to %s: %s\n", + (opcode==WSLAY_TEXT_FRAME)?"text":"binary", + (char *) link->dsId->data, data); } return (int)msg.msg_length; diff --git a/broker/src/net/ws_handler.c b/broker/src/net/ws_handler.c index 7a0a672f..929125dc 100644 --- a/broker/src/net/ws_handler.c +++ b/broker/src/net/ws_handler.c @@ -9,6 +9,8 @@ #include "broker/msg/msg_handler.h" #include "broker/net/ws.h" +#include +#include ssize_t broker_want_read_cb(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, @@ -112,40 +114,66 @@ void broker_on_ws_data(wslay_event_context_ptr ctx, } gettimeofday(link->lastReceiveTime, NULL); + if (arg->opcode == WSLAY_CONNECTION_CLOSE) { + link->pendingClose = 1; + return; + } + + json_t *data = NULL; + int is_recv_data_msg_pack = 0; + if (arg->opcode == WSLAY_TEXT_FRAME) { if (arg->msg_length == 2 && arg->msg[0] == '{' && arg->msg[1] == '}') { - broker_ws_send(link, "{}"); + broker_ws_send(link, "{}", strlen("{}"), WSLAY_TEXT_FRAME); return; } json_error_t err; - json_t *data = json_loadb((char *) arg->msg, - arg->msg_length, 0, &err); - if (throughput_input_needed()) { - int receiveMessages = 0; - if (data) { - receiveMessages = broker_count_json_msg(data); - } - throughput_add_input(arg->msg_length, receiveMessages); - } - if (!data) { - return; - } - if (link->isUpstream) { - log_debug("Received data from upstream %s: %.*s\n", (char *) link->name, - (int) arg->msg_length, arg->msg); - } else { - log_debug("Received data from %s: %.*s\n", (char *) link->dsId->data, - (int) arg->msg_length, arg->msg); + data = json_loadb((char *) arg->msg, + arg->msg_length, 0, &err); + } + else if(arg->opcode == WSLAY_BINARY_FRAME) + { + msgpack_unpacked msg; + msgpack_unpacked_init(&msg); + msgpack_unpack_next(&msg, (char *) arg->msg, arg->msg_length, NULL); + + /* prints the deserialized object. */ + msgpack_object obj = msg.data; + + data = dslink_ws_msgpack_to_json(&obj); + is_recv_data_msg_pack = 1; + } + + if (throughput_input_needed()) { + int receiveMessages = 0; + if (data) { + receiveMessages = broker_count_json_msg(data); } + throughput_add_input(arg->msg_length, receiveMessages); + } + if (!data) { + return; + } - broker_msg_handle(link, data); - json_decref(data); - } else if (arg->opcode == WSLAY_CONNECTION_CLOSE) { - link->pendingClose = 1; + if (link->isUpstream) { + log_debug("Received data (as %s) from upstream %s: %.*s\n", + (is_recv_data_msg_pack==1)?"msgpack":"json", + (char *) link->name, + (int) arg->msg_length, json_dumps(data, JSON_INDENT(0))); + } else { + log_debug("Received data (as %s) from %s: %.*s\n", + (is_recv_data_msg_pack==1)?"msgpack":"json", + (char *) link->dsId->data, + (int) arg->msg_length, json_dumps(data, JSON_INDENT(0))); } + + broker_msg_handle(link, data); + json_decref(data); + + return; } const struct wslay_event_callbacks *broker_ws_callbacks() { diff --git a/broker/src/upstream/upstream_handshake.c b/broker/src/upstream/upstream_handshake.c index d234555e..23d902b0 100644 --- a/broker/src/upstream/upstream_handshake.c +++ b/broker/src/upstream/upstream_handshake.c @@ -278,6 +278,14 @@ void connect_conn_callback(uv_poll_t *handle, int status, int events) { goto exit; } + const char *format = json_string_value(json_object_get(handshake, "format")); + upstreamPoll->clientDslink->is_msgpack = 0; + upstreamPoll->remoteDSLink->is_msgpack = 0; + if((format != NULL) && (strcmp(format, "msgpack") == 0)) { + upstreamPoll->clientDslink->is_msgpack = 1; + upstreamPoll->remoteDSLink->is_msgpack = 1; + } + if ((dslink_handshake_connect_ws(upstreamPoll->clientDslink->config.broker_url, &upstreamPoll->clientDslink->key, uri, tKey, salt, upstreamPoll->dsId, NULL, &upstreamPoll->sock)) != 0) { upstream_reconnect(upstreamPoll); diff --git a/sdk/include/dslink/dslink.h b/sdk/include/dslink/dslink.h index 52c1053a..5e65e140 100644 --- a/sdk/include/dslink/dslink.h +++ b/sdk/include/dslink/dslink.h @@ -52,6 +52,8 @@ struct DSLink { json_t *link_data; json_t *dslink_json; + + int is_msgpack; }; struct Responder { diff --git a/sdk/include/dslink/ws.h b/sdk/include/dslink/ws.h index 318e9cf5..917c6483 100644 --- a/sdk/include/dslink/ws.h +++ b/sdk/include/dslink/ws.h @@ -7,6 +7,7 @@ extern "C" { #include #include +#include #include "dslink/dslink.h" #include "dslink/socket.h" @@ -25,7 +26,12 @@ void dslink_handshake_handle_ws(DSLink *link, link_callback on_requester_ready_c int dslink_ws_send_obj(struct wslay_event_context *ctx, json_t *obj); int dslink_ws_send(struct wslay_event_context *ctx, - const char *data); + const char *data, const int len, const int opcode); + +int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk); + +msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj); +json_t* dslink_ws_msgpack_to_json(msgpack_object* obj); #ifdef __cplusplus } diff --git a/sdk/src/dslink.c b/sdk/src/dslink.c index 7f5f6ac2..64835f5d 100644 --- a/sdk/src/dslink.c +++ b/sdk/src/dslink.c @@ -448,6 +448,11 @@ int dslink_init_do(DSLink *link, DSLinkCallbacks *cbs) { const char *tKey = json_string_value(json_object_get(handshake, "tempKey")); const char *salt = json_string_value(json_object_get(handshake, "salt")); + const char *format = json_string_value(json_object_get(handshake, "format")); + link->is_msgpack = 0; + if(format != NULL && strcmp(format, "msgpack") == 0) + link->is_msgpack = 1; + if (!(uri && ((tKey && salt) || link->config.token))) { log_fatal("Handshake didn't return the " "necessary parameters to complete\n"); diff --git a/sdk/src/handshake.c b/sdk/src/handshake.c index abbd2ae6..37bd637c 100644 --- a/sdk/src/handshake.c +++ b/sdk/src/handshake.c @@ -361,6 +361,10 @@ char *dslink_handshake_generate_req(DSLink *link, char **dsId) { json_object_set_new(obj, "isRequester", json_boolean(link->is_requester)); json_object_set_new(obj, "isResponder", json_boolean(link->is_responder)); json_object_set_new(obj, "version", json_string_nocheck("1.1.2")); + json_object_set_new(obj, "formats", json_array()); + json_array_append(json_object_get(obj,"formats"), json_string_nocheck("json")); + json_array_append(json_object_get(obj,"formats"), json_string_nocheck("msgpack")); + if (link->link_data) { json_object_set(obj, "linkData", link->link_data); } diff --git a/sdk/src/msg/list_response.c b/sdk/src/msg/list_response.c index 285c8006..67efbace 100644 --- a/sdk/src/msg/list_response.c +++ b/sdk/src/msg/list_response.c @@ -1,4 +1,5 @@ #include +#include #include "dslink/mem/mem.h" #include "dslink/utils.h" #include "dslink/msg/list_response.h" diff --git a/sdk/src/ws.c b/sdk/src/ws.c index 5861500f..0f851b32 100644 --- a/sdk/src/ws.c +++ b/sdk/src/ws.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "dslink/msg/request_handler.h" #include "dslink/msg/response_handler.h" @@ -119,27 +121,53 @@ int dslink_ws_send_obj(wslay_event_context_ptr ctx, json_t *obj) { json_t *jsonMsg = json_integer(msg); json_object_set(obj, "msg", jsonMsg); - char *data = json_dumps(obj, JSON_PRESERVE_ORDER); + log_debug("Message(as %s) is trying sent: %s\n", + (link->is_msgpack==1)?"msgpack":"json", + json_dumps(obj,JSON_INDENT(0))); + + // DECODE OBJ + char* data = NULL; + int len; + int opcode; + + if(link->is_msgpack) + { + msgpack_sbuffer* buff = dslink_ws_json_to_msgpack(obj); + data = malloc(buff->size); + len = buff->size; + memcpy(data, buff->data, len); + msgpack_sbuffer_free(buff); + opcode = WSLAY_BINARY_FRAME; + } + else + { + data = json_dumps(obj, JSON_PRESERVE_ORDER); + len = strlen(data); + opcode = WSLAY_TEXT_FRAME; + } + + json_object_del(obj, "msg"); + json_delete(jsonMsg); + if (!data) { return DSLINK_ALLOC_ERR; } - dslink_ws_send(ctx, data); + dslink_ws_send(ctx, data, len, opcode); dslink_free(data); - json_object_del(obj, "msg"); - json_delete(jsonMsg); - return 0; } static -int dslink_ws_send_internal(wslay_event_context_ptr ctx, const char *data, uint8_t resend) { +int dslink_ws_send_internal(wslay_event_context_ptr ctx, + const char *data, const int len, int opcode, + uint8_t resend) { (void) resend; struct wslay_event_msg msg; msg.msg = (const uint8_t *) data; - msg.msg_length = strlen(data); - msg.opcode = WSLAY_TEXT_FRAME; + msg.msg_length = len; + msg.opcode = opcode; if (wslay_event_queue_msg(ctx, &msg) != 0) { return 1; } @@ -153,15 +181,16 @@ int dslink_ws_send_internal(wslay_event_context_ptr ctx, const char *data, uint8 if(link->poll && !uv_is_closing((uv_handle_t*)link->poll)) { uv_poll_start(link->poll, UV_READABLE | UV_WRITABLE, io_handler); - log_debug("Message queued to be sent: %s\n", data); + log_debug("Message(%s) queued to be sent: %s\n", + (opcode==WSLAY_TEXT_FRAME)?"text":"binary", data); return 0; } return -1; } -int dslink_ws_send(struct wslay_event_context* ctx, const char* data) { - return dslink_ws_send_internal(ctx, data, 0); +int dslink_ws_send(struct wslay_event_context* ctx, const char* data, const int len, const int opcode) { + return dslink_ws_send_internal(ctx, data, len, opcode, 0); } int dslink_handshake_connect_ws(Url *url, @@ -296,23 +325,45 @@ void recv_frame_cb(wslay_event_context_ptr ctx, void *user_data) { (void) ctx; - if (arg->opcode != WSLAY_TEXT_FRAME) { + DSLink *link = user_data; + + json_t *obj = NULL; + int is_recv_data_msg_pack = 0; + + if (arg->opcode == WSLAY_TEXT_FRAME) { + json_error_t err; + obj = json_loadb((char *) arg->msg, arg->msg_length, + JSON_PRESERVE_ORDER, &err); + } + else if(arg->opcode == WSLAY_BINARY_FRAME){ + msgpack_unpacked msg; + msgpack_unpacked_init(&msg); + msgpack_unpack_next(&msg, (char *) arg->msg, arg->msg_length, NULL); + + /* prints the deserialized object. */ + msgpack_object obj_msgpack = msg.data; + + obj = dslink_ws_msgpack_to_json(&obj_msgpack); + is_recv_data_msg_pack = 1; + } + else { return; } - DSLink *link = user_data; gettimeofday(&link->lastReceiveTime, NULL); json_error_t err; - json_t *obj = json_loadb((char *) arg->msg, arg->msg_length, + obj = json_loadb((char *) arg->msg, arg->msg_length, JSON_PRESERVE_ORDER, &err); + if (!obj) { log_err("Failed to parse JSON payload: %.*s\n", (int) arg->msg_length, arg->msg); goto exit; } else { - log_debug("Message received: %.*s\n", - (int) arg->msg_length, arg->msg); + log_debug("Message(as %s) received: %s\n", + (is_recv_data_msg_pack==1)?"msgpack":"json", + json_dumps(obj, JSON_INDENT(0))); } json_t *reqs = json_object_get(obj, "requests"); @@ -429,3 +480,185 @@ void dslink_handshake_handle_ws(DSLink *link, link_callback on_requester_ready_c wslay_event_context_free(ptr); link->_ws = NULL; } + +int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk) +{ +#if 0 + // AK: TODO + char* buf; + size_t buf_len = 0; +#endif + + switch(json_obj->type) + { + case JSON_OBJECT: + msgpack_pack_map(pk, json_object_size(json_obj)); + + const char *key; + json_t *value; + + void *iter = json_object_iter(json_obj); + while(iter) + { + key = json_object_iter_key(iter); + value = json_object_iter_value(iter); + + msgpack_pack_str(pk, strlen(key)); + msgpack_pack_str_body(pk, key, strlen(key)); + + if(sync_json_to_msg_pack(value, pk) != 1) + return 0; + + iter = json_object_iter_next(json_obj, iter); + } + + break; + case JSON_ARRAY: + msgpack_pack_array(pk, json_array_size(json_obj)); + for(size_t i = 0; i < json_array_size(json_obj); i++) + { + if(sync_json_to_msg_pack(json_array_get(json_obj, i), pk) != 1) + return 0; + } + break; +#if 0 + // AK: TODO + case JSON_BINARY: + buf_len = json_binary_length_raw(json_obj); + buf = (char*) malloc(buf_len); + + buf_len = json_binary_value(json_obj, buf); + + msgpack_pack_bin(pk, buf_len); + msgpack_pack_bin_body(pk, buf, buf_len); + + free(buf); + break; +#endif + case JSON_STRING: + msgpack_pack_str(pk, json_string_length(json_obj)); + msgpack_pack_str_body(pk, json_string_value(json_obj), json_string_length(json_obj)); + break; + case JSON_INTEGER: + msgpack_pack_int(pk, json_integer_value(json_obj)); + break; + case JSON_REAL: + msgpack_pack_double(pk, json_real_value(json_obj)); + break; + case JSON_TRUE: + msgpack_pack_true(pk); + break; + case JSON_FALSE: + msgpack_pack_false(pk); + break; + case JSON_NULL : + msgpack_pack_nil(pk); + break; + } + + return 1; +} + +msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj) +{ + msgpack_sbuffer* buffer = msgpack_sbuffer_new(); + msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write); + + if( sync_json_to_msg_pack(json_obj, pk) != 1) + goto ERROR; + + EXIT: + msgpack_packer_free(pk); + return buffer; + + ERROR: + log_fatal("Cannot convert to msg_pack\n") + msgpack_sbuffer_free(buffer); + buffer = NULL; + goto EXIT; +} + + + +json_t* dslink_ws_msgpack_to_json(msgpack_object* msg_obj) +{ + json_t* json_obj = NULL; + json_t* temp = NULL; + + char* text; + + switch(msg_obj->type) + { + case MSGPACK_OBJECT_NIL: + json_obj = json_null(); + break; + case MSGPACK_OBJECT_BOOLEAN: + json_obj = json_boolean(msg_obj->via.boolean); + break; + case MSGPACK_OBJECT_POSITIVE_INTEGER: + json_obj = json_integer(msg_obj->via.u64); + break; + case MSGPACK_OBJECT_NEGATIVE_INTEGER: + json_obj = json_integer(msg_obj->via.i64); + break; + case MSGPACK_OBJECT_FLOAT32: + json_obj = json_real(msg_obj->via.f64); + break; + case MSGPACK_OBJECT_FLOAT: + json_obj = json_real(msg_obj->via.f64); + break; + case MSGPACK_OBJECT_STR: + json_obj = json_stringn_nocheck(msg_obj->via.str.ptr, msg_obj->via.str.size); + break; + case MSGPACK_OBJECT_ARRAY: + json_obj = json_array(); + for(uint32_t i = 0; i < msg_obj->via.array.size; i++) + { + temp = dslink_ws_msgpack_to_json(&msg_obj->via.array.ptr[i]); + if(temp == NULL) + goto ERROR; + + json_array_append(json_obj, temp); + } + break; + case MSGPACK_OBJECT_MAP: + json_obj = json_object(); + + for(uint32_t i = 0; i < msg_obj->via.map.size; i++) + { + msgpack_object_kv* kv = &msg_obj->via.map.ptr[i]; + if(kv->key.type != MSGPACK_OBJECT_STR) + goto ERROR; + + temp = dslink_ws_msgpack_to_json(&kv->val); + if(temp == NULL) + goto ERROR; + + text = malloc(kv->key.via.str.size + 1); + memcpy(text, kv->key.via.str.ptr, kv->key.via.str.size); + text[kv->key.via.str.size] = '\0'; + json_object_set_nocheck(json_obj, text, temp); + free(text); + } + + break; + case MSGPACK_OBJECT_BIN: + // AK: TODO + // json_obj = json_binaryn_nocheck(msg_obj->via.bin.ptr, msg_obj->via.bin.size); + break; + case MSGPACK_OBJECT_EXT: + log_fatal("Cannot convert json BECAUSE EXT NOT IMPLEMENTED\n"); + goto ERROR; + break; + } + + EXIT: + return json_obj; + + ERROR: + if(json_obj != NULL) + json_decref(json_obj); + + json_obj = NULL; + goto EXIT; +} From 44d5a4ee2b7429f037e99eee00f7d8f07a76f1a2 Mon Sep 17 00:00:00 2001 From: akawamura Date: Fri, 7 Dec 2018 14:42:29 -0800 Subject: [PATCH 3/6] msgpack submodule added --- .gitmodules | 3 + CMakeLists.txt | 7 +- deps/README.md | 7 + deps/msgpack-c | 1 + deps/msgpack-c-build/CMakeLists.txt | 547 ++++++++++++++++++++ deps/msgpack-c-build/Files.cmake | 750 ++++++++++++++++++++++++++++ 6 files changed, 1312 insertions(+), 3 deletions(-) create mode 160000 deps/msgpack-c create mode 100644 deps/msgpack-c-build/CMakeLists.txt create mode 100644 deps/msgpack-c-build/Files.cmake diff --git a/.gitmodules b/.gitmodules index 804d9954..ba30e624 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "deps/argtable3"] path = deps/argtable3 url = https://github.com/argtable/argtable3.git +[submodule "deps/msgpack-c"] + path = deps/msgpack-c + url = https://github.com/msgpack/msgpack-c.git diff --git a/CMakeLists.txt b/CMakeLists.txt index dd577bca..e8e50a3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_jansson.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_wslay.txt") include("${CMAKE_CURRENT_LIST_DIR}/deps/CMakeLists_argtable3.txt") -include("${CMAKE_CURRENT_LIST_DIR}/deps/msgpack-c/CMakeLists.txt") include(ExternalProject) @@ -106,9 +105,11 @@ if (NOT NO_WARNINGS) ADD_C_FLAGS("-Wno-clobbered") ADD_C_FLAGS("-Wno-misleading-indentation") ADD_C_FLAGS("-Wno-format-truncation") - ADD_C_FLAGS("-pedantic") +#AK:TODO ADD_C_FLAGS("-pedantic") endif() +include("${CMAKE_CURRENT_LIST_DIR}/deps/msgpack-c-build/CMakeLists.txt") + if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang") ADD_C_FLAGS("-Qunused-arguments") endif() @@ -233,7 +234,7 @@ else() endif() add_library(sdk_dslink_c SHARED ${LIBRARY_SRC}) -target_link_libraries(sdk_dslink_c msgpackc jansson libuv ${DSLINK_PLATFORM_LIBS}) +target_link_libraries(sdk_dslink_c jansson libuv ${DSLINK_PLATFORM_LIBS}) set_target_properties(sdk_dslink_c PROPERTIES VERSION ${VERSION} SOVERSION ${VERSION} ) set(DSLINK_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") diff --git a/deps/README.md b/deps/README.md index 84f387d2..5372601e 100644 --- a/deps/README.md +++ b/deps/README.md @@ -34,3 +34,10 @@ Libuv: - Version: 1.9.1 - Source: https://github.com/libuv/libuv - License: MIT + +msgpack-c: + + - Commit: daa78b4 + - Version: 3.1.1 + - Source: https://github.com/msgpack-c + - License: Boost Sofware 1.0 diff --git a/deps/msgpack-c b/deps/msgpack-c new file mode 160000 index 00000000..daa78b46 --- /dev/null +++ b/deps/msgpack-c @@ -0,0 +1 @@ +Subproject commit daa78b46062d49bc192a921f7192637f58b334cc diff --git a/deps/msgpack-c-build/CMakeLists.txt b/deps/msgpack-c-build/CMakeLists.txt new file mode 100644 index 00000000..b9e6a0c6 --- /dev/null +++ b/deps/msgpack-c-build/CMakeLists.txt @@ -0,0 +1,547 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12) + +IF ((CMAKE_VERSION VERSION_GREATER 3.1) OR + (CMAKE_VERSION VERSION_EQUAL 3.1)) + CMAKE_POLICY(SET CMP0054 NEW) +ENDIF () + +PROJECT (msgpack) + +# https://stackoverflow.com/questions/28344564/cmake-remove-a-compile-flag-for-a-single-translation-unit +macro(apply_global_c_flags_to_all_targets) + separate_arguments(_global_c_flags_list UNIX_COMMAND ${CMAKE_C_FLAGS}) + get_property(_targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) + foreach(_target ${_targets}) + target_compile_options(${_target} PUBLIC ${_global_c_flags_list}) + endforeach() + unset(CMAKE_C_FLAGS) + set(_flag_sync_required TRUE) +endmacro() + +# +# Removes the specified compile flag from the specified target. +# _target - The target to remove the compile flag from +# _flag - The compile flag to remove +# +# Pre: apply_global_c_flags_to_all_targets() must be invoked. +# +macro(remove_flag_from_target _target _flag) + get_target_property(_target_c_flags ${_target} COMPILE_OPTIONS) + message (${_target_c_flags}) + if(_target_c_flags) + list(REMOVE_ITEM _target_c_flags ${_flag}) + message ("REMOVE_FLAG_FROM_TARGET") + message (${_target}) + message (${_target_c_flags}) + message (${_flag}) + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_c_flags}") + endif() +endmacro() + +# Removes the specified compiler flag from the specified file. +# _target - The target that _file belongs to +# _file - The file to remove the compiler flag from +# _flag - The compiler flag to remove. +# +# Pre: apply_global_c_flags_to_all_targets() must be invoked. +# +macro(remove_flag_from_file _target _file _flag) + get_target_property(_target_sources ${_target} SOURCES) + # Check if a sync is required, in which case we'll force a rewrite of the cache variables. + if(_flag_sync_required) + unset(_cached_${_target}_c_flags CACHE) + unset(_cached_${_target}_${_file}_c_flags CACHE) + endif() + get_target_property(_${_target}_c_flags ${_target} COMPILE_OPTIONS) + # On first entry, cache the target compile flags and apply them to each source file + # in the target. + if(NOT _cached_${_target}_c_flags) + # Obtain and cache the target compiler options, then clear them. + get_target_property(_target_c_flags ${_target} COMPILE_OPTIONS) + set(_cached_${_target}_c_flags "${_target_c_flags}" CACHE INTERNAL "") + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "") + # Apply the target compile flags to each source file. + foreach(_source_file ${_target_sources}) + # Check for pre-existing flags set by set_source_files_properties(). + get_source_file_property(_source_file_c_flags ${_source_file} COMPILE_FLAGS) + if(_source_file_c_flags) + separate_arguments(_source_file_c_flags UNIX_COMMAND ${_source_file_c_flags}) + list(APPEND _source_file_c_flags "${_target_c_flags}") + else() + set(_source_file_c_flags "${_target_c_flags}") + endif() + # Apply the compile flags to the current source file. + string(REPLACE ";" " " _source_file_c_flags_string "${_source_file_c_flags}") + set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS "${_source_file_c_flags_string}") + endforeach() + endif() + list(FIND _target_sources ${_file} _file_found_at) + if(_file_found_at GREATER -1) + if(NOT _cached_${_target}_${_file}_c_flags) + # Cache the compile flags for the specified file. + # This is the list that we'll be removing flags from. + get_source_file_property(_source_file_c_flags ${_file} COMPILE_FLAGS) + separate_arguments(_source_file_c_flags UNIX_COMMAND ${_source_file_c_flags}) + set(_cached_${_target}_${_file}_c_flags ${_source_file_c_flags} CACHE INTERNAL "") + endif() + # Remove the specified flag, then re-apply the rest. + list(REMOVE_ITEM _cached_${_target}_${_file}_c_flags ${_flag}) + string(REPLACE ";" " " _cached_${_target}_${_file}_c_flags_string "${_cached_${_target}_${_file}_c_flags}") + set_source_files_properties(${_file} PROPERTIES COMPILE_FLAGS "${_cached_${_target}_${_file}_c_flags_string}") + endif() +endmacro() + +# Setup - BEGIN + +set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/msgpack-c" CACHE PATH "Current source directory" FORCE) + +# Setup -END + +FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/version_master.h contents) +STRING (REGEX MATCH "#define MSGPACK_VERSION_MAJOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents}) +SET (VERSION_MAJOR ${CMAKE_MATCH_1}) +STRING (REGEX MATCH "#define MSGPACK_VERSION_MINOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents}) +SET (VERSION_MINOR ${CMAKE_MATCH_1}) +STRING (REGEX MATCH "#define MSGPACK_VERSION_REVISION *([0-9a-zA-Z_]*)" NULL_OUT ${contents}) +SET (VERSION_REVISION ${CMAKE_MATCH_1}) +SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}) + +SET (prefix ${CMAKE_INSTALL_PREFIX}) +SET (exec_prefix "\${prefix}") +SET (libdir "\${exec_prefix}/lib") +SET (includedir "\${prefix}/include") +SET (GNUCXX_STD_SUPPORT_VERSION "4.3") + +OPTION (MSGPACK_CXX11 "Using c++11 compiler" OFF) +OPTION (MSGPACK_32BIT "32bit compile" OFF) +OPTION (MSGPACK_BOOST "Using boost libraries" OFF) + +IF (APPLE) + SET(CMAKE_MACOSX_RPATH ON) + SET(CMAKE_SKIP_BUILD_RPATH FALSE) + SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + IF ("${isSystemDir}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + ENDIF () +ENDIF () + +IF (MSGPACK_USE_X3_PARSE) + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE -std=c++14 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE -std=c++14 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE ${CMAKE_CXX_FLAGS}") + IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) + MESSAGE ( FATAL_ERROR "MSVC doesn't support C++14.") + ENDIF () + ENDIF () +ELSE () + IF (MSGPACK_CXX17) + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + MESSAGE ( FATAL_ERROR "MSVC doesn't support C++17.") + ENDIF () + ELSEIF (MSGPACK_CXX11) + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) + MESSAGE ( FATAL_ERROR "MSVC doesn't support C++11.") + ENDIF () + ENDIF () + ELSE () + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_STD_SUPPORT_VERSION}) OR + (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_STD_SUPPORT_VERSION})) + SET (CMAKE_CXX_FLAGS "-std=c++98 ${CMAKE_CXX_FLAGS}") + ENDIF () + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-std=c++98 ${CMAKE_CXX_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + IF (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18) + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_CPP03 ${CMAKE_CXX_FLAGS}") + ENDIF () + ENDIF () + ENDIF () +ENDIF () + +IF (MSGPACK_32BIT) + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + SET (CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}") + SET (CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}") + SET (CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}") + ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}") + SET (CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}") + SET (CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}") + ENDIF () +ENDIF () + +OPTION (MSGPACK_BUILD_EXAMPLES "Build msgpack examples." OFF) + +IF (MSGPACK_BOOST) + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}") + SET (Boost_USE_MULTITHREADED ON) + SET (Boost_USE_STATIC_RUNTIME OFF) + FIND_PACKAGE (Boost REQUIRED COMPONENTS chrono context system timer) + INCLUDE_DIRECTORIES ( + ${Boost_INCLUDE_DIRS} + ) + LINK_DIRECTORIES ( + ${Boost_LIBRARY_DIRS} + ) + IF (MSGPACK_BOOST_DIR) + INCLUDE_DIRECTORIES ( + ${MSGPACK_BOOST_DIR} + ) + ENDIF () +ENDIF () + +IF (MSGPACK_CHAR_SIGN) + SET (CMAKE_C_FLAGS "-f${MSGPACK_CHAR_SIGN}-char ${CMAKE_C_FLAGS}") + SET (CMAKE_CXX_FLAGS "-f${MSGPACK_CHAR_SIGN}-char ${CMAKE_CXX_FLAGS}") +ENDIF () + +IF (MSGPACK_DEFAULT_API_VERSION) + SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=${MSGPACK_DEFAULT_API_VERSION} ${CMAKE_CXX_FLAGS}") +ELSE () + SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=3 ${CMAKE_CXX_FLAGS}") +ENDIF () + +FILE (GLOB_RECURSE PREDEF_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/*.h) +FOREACH (F ${PREDEF_FILES}) + SET(M "Converting ${F}") + MESSAGE(STATUS ${M}) + FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/${F} CONTENT) + STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT}) + STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT}) + FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT}) +ENDFOREACH () + +FILE (GLOB_RECURSE PREPROCESSOR_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/*.hpp) +FOREACH (F ${PREPROCESSOR_FILES}) + SET(M "Converting ${F}") + MESSAGE(STATUS ${M}) + FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/${F} CONTENT) + STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT}) + STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT}) + FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT}) +ENDFOREACH () + +FIND_PACKAGE (GTest) +FIND_PACKAGE (ZLIB) +FIND_PACKAGE (Threads) +IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND AND NOT "${MSGPACK_FUZZ_REGRESSION}" STREQUAL "ON") + OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." ON) +ENDIF () + +IF (DEFINED BUILD_SHARED_LIBS) + IF (BUILD_SHARED_LIBS) + IF (DEFINED MSGPACK_ENABLE_SHARED AND NOT MSGPACK_ENABLE_SHARED) + MESSAGE(WARNING "MSGPACK_ENABLE_SHARED is overridden to ON by BUILD_SHARED_LIBS") + ENDIF () + SET (MSGPACK_ENABLE_SHARED ON) + IF (DEFINED MSGPACK_ENABLE_STATIC AND MSGPACK_ENABLE_STATIC) + MESSAGE(WARNING "MSGPACK_ENABLE_STATIC is overridden to OFF by BUILD_SHARED_LIBS") + ENDIF () + SET (MSGPACK_ENABLE_STATIC OFF) + ELSE () + IF (DEFINED MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_SHARED) + MESSAGE(WARNING "MSGPACK_ENABLE_SHARED is overridden to OFF by BUILD_SHARED_LIBS") + ENDIF () + SET (MSGPACK_ENABLE_SHARED OFF) + IF (DEFINED MSGPACK_ENABLE_STATIC AND NOT MSGPACK_ENABLE_STATIC) + MESSAGE(WARNING "MSGPACK_ENABLE_STATIC is overridden to ON by BUILD_SHARED_LIBS") + ENDIF () + SET (MSGPACK_ENABLE_STATIC ON) + ENDIF () +ELSE () + IF (NOT DEFINED MSGPACK_ENABLE_SHARED) + SET (MSGPACK_ENABLE_SHARED ON) + ENDIF () + IF (NOT DEFINED MSGPACK_ENABLE_STATIC) + SET (MSGPACK_ENABLE_STATIC ON) + ENDIF () +ENDIF () + +OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." OFF) + +INCLUDE (CheckCXXSourceCompiles) +CHECK_CXX_SOURCE_COMPILES (" +#include +int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; } +int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; } +int main(int argc, char * argv[]) +{ + atomic_sub(1); + atomic_add(1); +} +" MSGPACK_ENABLE_GCC_CXX_ATOMIC) + +INCLUDE (deps/msgpack-c-build/Files.cmake) + +EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/src/msgpack +) + +CONFIGURE_FILE ( + deps/msgpack-c/msgpack.pc.in + deps/msgpack-c/msgpack.pc + @ONLY +) + +IF (MSGPACK_ENABLE_SHARED) + ADD_LIBRARY (msgpackc SHARED + ${msgpackc_SOURCES} + ${msgpackc_HEADERS} + ) + + SET_TARGET_PROPERTIES (msgpackc PROPERTIES SOVERSION 2 VERSION 2.0.0) + + TARGET_INCLUDE_DIRECTORIES (msgpackc + PUBLIC + $ + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) +ENDIF () + +IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSION VERSION_EQUAL 3.0))) + ADD_LIBRARY (msgpackc-cxx INTERFACE) + + TARGET_INCLUDE_DIRECTORIES (msgpackc-cxx + INTERFACE + $ + $ + $ + ) +ENDIF () + +IF (MSGPACK_ENABLE_STATIC) + ADD_LIBRARY (msgpackc-static STATIC + ${msgpackc_SOURCES} + ${msgpackc_HEADERS} + ) + + TARGET_INCLUDE_DIRECTORIES (msgpackc-static + PUBLIC + $ + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + + IF (NOT MSGPACK_ENABLE_SHARED) + # Add alias for subdirectories + ADD_LIBRARY (msgpackc ALIAS msgpackc-static) + ENDIF () + + SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc") + + IF (MSGPACK_ENABLE_SHARED) + IF (MSVC) + SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX "_import.lib") + ELSEIF (MINGW) + SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX ".dll.a") + ENDIF () + ENDIF () +ENDIF () + +# enable regression testing +IF ("${MSGPACK_FUZZ_REGRESSION}" STREQUAL "ON" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}") + SET (Boost_USE_MULTITHREADED ON) + SET (Boost_USE_STATIC_RUNTIME OFF) + + enable_testing () + ADD_SUBDIRECTORY (fuzz) + SET (MSGPACK_BUILD_EXAMPLES OFF) +ENDIF () + + +IF (MSGPACK_BUILD_TESTS) + ENABLE_TESTING () + # MEMORYCHECK_COMMAND_OPTIONS needs to place prior to CTEST_MEMORYCHECK_COMMAND + SET (MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-leak-kinds=definite,possible --error-exitcode=1") + FIND_PROGRAM(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) + INCLUDE(Dart) + ADD_SUBDIRECTORY (test) +ENDIF () + +IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + IF (MSGPACK_ENABLE_SHARED) + SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra -DPIC") + ENDIF () + IF (MSGPACK_ENABLE_STATIC) + SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra" ) + ENDIF () +ENDIF () + +IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + IF (MSGPACK_ENABLE_SHARED) + SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags") + ENDIF () + IF (MSGPACK_ENABLE_STATIC) + SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags") + ENDIF () +ENDIF () + +IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + ELSE () + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX") + ENDIF () +ENDIF () + +IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10") + SET_SOURCE_FILES_PROPERTIES(${msgpackc_SOURCES} PROPERTIES LANGUAGE CXX) +ENDIF () + +IF ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "sparc") + SET (CMAKE_C_FLAGS "-DMSGPACK_ZONE_ALIGN=8 ${CMAKE_C_FLAGS}") + SET (CMAKE_CXX_FLAGS "-DMSGPACK_ZONE_ALIGN=8 ${CMAKE_CXX_FLAGS}") +ENDIF () + +IF (NOT DEFINED CMAKE_INSTALL_BINDIR) + SET(CMAKE_INSTALL_BINDIR bin) +ENDIF () + +IF (NOT DEFINED CMAKE_INSTALL_LIBDIR) + SET(CMAKE_INSTALL_LIBDIR lib) +ENDIF () + +#[[IF (MSGPACK_BUILD_EXAMPLES) + ADD_SUBDIRECTORY (example) +ENDIF ()]] + +IF (MSGPACK_ENABLE_SHARED) + SET (MSGPACK_INSTALLTARGETS msgpackc) +ENDIF () + +IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSION VERSION_EQUAL 3.0))) + LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-cxx) +ENDIF () + +IF (MSGPACK_ENABLE_STATIC) + LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-static) +ENDIF () + +INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} EXPORT msgpack-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +FOREACH (file ${msgpackc_HEADERS}) + GET_FILENAME_COMPONENT (dir ${file} PATH) + INSTALL (FILES ${file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${dir}) +ENDFOREACH () +IF (NOT MSVC) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +ENDIF () + +##### Configure Flags ##### + +# AK:TODO apply_global_c_flags_to_all_targets() + +# AK:TODO remove_flag_from_target(msgpackc-static -pedantic) +# remove_flag_from_file(msgpackc-static unpack.c -pedantic) + +#[[ +# Doxygen +FIND_PACKAGE (Doxygen) +IF (DOXYGEN_FOUND) + LIST (APPEND Doxyfile_c_CONTENT + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.h" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_c" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + COMMAND ${CMAKE_COMMAND} -E echo "STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + ) + IF (DOXYGEN_DOT_FOUND) + LIST (APPEND Doxyfile_c_CONTENT + COMMAND ${CMAKE_COMMAND} -E echo "HAVE_DOT = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + ) + ENDIF () + ADD_CUSTOM_TARGET ( + doxygen_c + ${Doxyfile_c_CONTENT} + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c + VERBATIM + ) + LIST (APPEND Doxyfile_cpp_CONTENT + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.hpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${CMAKE_COMMAND} -E echo "STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + ) + IF (DOXYGEN_DOT_FOUND) + LIST (APPEND Doxyfile_cpp_CONTENT + COMMAND ${CMAKE_COMMAND} -E echo "HAVE_DOT = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + ) + ENDIF () + ADD_CUSTOM_TARGET ( + doxygen_cpp + ${Doxyfile_cpp_CONTENT} + COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C++\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp + VERBATIM + ) + ADD_CUSTOM_TARGET ( + doxygen + DEPENDS doxygen_c doxygen_cpp + ) +ENDIF () + +INCLUDE (CMakePackageConfigHelpers) + +SET (CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/msgpack") + +WRITE_BASIC_PACKAGE_VERSION_FILE ( + msgpack-config-version.cmake + VERSION ${VERSION} + COMPATIBILITY SameMajorVersion +) + +IF (NOT CMAKE_VERSION VERSION_LESS 3.0) + EXPORT (EXPORT msgpack-targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/msgpack-targets.cmake" + ) +ENDIF () + +CONFIGURE_PACKAGE_CONFIG_FILE (msgpack-config.cmake.in + msgpack-config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" +) + +INSTALL (EXPORT msgpack-targets + FILE + msgpack-targets.cmake + DESTINATION + "${CMAKE_INSTALL_CMAKEDIR}" +) + +INSTALL ( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/msgpack-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/msgpack-config-version.cmake" + DESTINATION + "${CMAKE_INSTALL_CMAKEDIR}" +)]] + diff --git a/deps/msgpack-c-build/Files.cmake b/deps/msgpack-c-build/Files.cmake new file mode 100644 index 00000000..590849dd --- /dev/null +++ b/deps/msgpack-c-build/Files.cmake @@ -0,0 +1,750 @@ +LIST (APPEND msgpackc_SOURCES + deps/msgpack-c/src/objectc.c + deps/msgpack-c/src/unpack.c + deps/msgpack-c/src/version.c + deps/msgpack-c/src/vrefbuffer.c + deps/msgpack-c/src/zone.c +) +LIST (APPEND msgpackc_HEADERS + deps/msgpack-c/include/msgpack.h + deps/msgpack-c/include/msgpack/fbuffer.h + deps/msgpack-c/include/msgpack/gcc_atomic.h + deps/msgpack-c/include/msgpack/object.h + deps/msgpack-c/include/msgpack/pack.h + deps/msgpack-c/include/msgpack/pack_define.h + deps/msgpack-c/include/msgpack/pack_template.h + deps/msgpack-c/include/msgpack/predef.h + deps/msgpack-c/include/msgpack/predef/architecture.h + deps/msgpack-c/include/msgpack/predef/architecture/alpha.h + deps/msgpack-c/include/msgpack/predef/architecture/arm.h + deps/msgpack-c/include/msgpack/predef/architecture/blackfin.h + deps/msgpack-c/include/msgpack/predef/architecture/convex.h + deps/msgpack-c/include/msgpack/predef/architecture/ia64.h + deps/msgpack-c/include/msgpack/predef/architecture/m68k.h + deps/msgpack-c/include/msgpack/predef/architecture/mips.h + deps/msgpack-c/include/msgpack/predef/architecture/parisc.h + deps/msgpack-c/include/msgpack/predef/architecture/ppc.h + deps/msgpack-c/include/msgpack/predef/architecture/ptx.h + deps/msgpack-c/include/msgpack/predef/architecture/pyramid.h + deps/msgpack-c/include/msgpack/predef/architecture/rs6k.h + deps/msgpack-c/include/msgpack/predef/architecture/sparc.h + deps/msgpack-c/include/msgpack/predef/architecture/superh.h + deps/msgpack-c/include/msgpack/predef/architecture/sys370.h + deps/msgpack-c/include/msgpack/predef/architecture/sys390.h + deps/msgpack-c/include/msgpack/predef/architecture/x86.h + deps/msgpack-c/include/msgpack/predef/architecture/x86/32.h + deps/msgpack-c/include/msgpack/predef/architecture/x86/64.h + deps/msgpack-c/include/msgpack/predef/architecture/z.h + deps/msgpack-c/include/msgpack/predef/compiler.h + deps/msgpack-c/include/msgpack/predef/compiler/borland.h + deps/msgpack-c/include/msgpack/predef/compiler/clang.h + deps/msgpack-c/include/msgpack/predef/compiler/comeau.h + deps/msgpack-c/include/msgpack/predef/compiler/compaq.h + deps/msgpack-c/include/msgpack/predef/compiler/diab.h + deps/msgpack-c/include/msgpack/predef/compiler/digitalmars.h + deps/msgpack-c/include/msgpack/predef/compiler/dignus.h + deps/msgpack-c/include/msgpack/predef/compiler/edg.h + deps/msgpack-c/include/msgpack/predef/compiler/ekopath.h + deps/msgpack-c/include/msgpack/predef/compiler/gcc.h + deps/msgpack-c/include/msgpack/predef/compiler/gcc_xml.h + deps/msgpack-c/include/msgpack/predef/compiler/greenhills.h + deps/msgpack-c/include/msgpack/predef/compiler/hp_acc.h + deps/msgpack-c/include/msgpack/predef/compiler/iar.h + deps/msgpack-c/include/msgpack/predef/compiler/ibm.h + deps/msgpack-c/include/msgpack/predef/compiler/intel.h + deps/msgpack-c/include/msgpack/predef/compiler/kai.h + deps/msgpack-c/include/msgpack/predef/compiler/llvm.h + deps/msgpack-c/include/msgpack/predef/compiler/metaware.h + deps/msgpack-c/include/msgpack/predef/compiler/metrowerks.h + deps/msgpack-c/include/msgpack/predef/compiler/microtec.h + deps/msgpack-c/include/msgpack/predef/compiler/mpw.h + deps/msgpack-c/include/msgpack/predef/compiler/nvcc.h + deps/msgpack-c/include/msgpack/predef/compiler/palm.h + deps/msgpack-c/include/msgpack/predef/compiler/pgi.h + deps/msgpack-c/include/msgpack/predef/compiler/sgi_mipspro.h + deps/msgpack-c/include/msgpack/predef/compiler/sunpro.h + deps/msgpack-c/include/msgpack/predef/compiler/tendra.h + deps/msgpack-c/include/msgpack/predef/compiler/visualc.h + deps/msgpack-c/include/msgpack/predef/compiler/watcom.h + deps/msgpack-c/include/msgpack/predef/detail/_cassert.h + deps/msgpack-c/include/msgpack/predef/detail/_exception.h + deps/msgpack-c/include/msgpack/predef/detail/comp_detected.h + deps/msgpack-c/include/msgpack/predef/detail/endian_compat.h + deps/msgpack-c/include/msgpack/predef/detail/os_detected.h + deps/msgpack-c/include/msgpack/predef/detail/platform_detected.h + deps/msgpack-c/include/msgpack/predef/detail/test.h + deps/msgpack-c/include/msgpack/predef/detail/test_def.h + deps/msgpack-c/include/msgpack/predef/hardware.h + deps/msgpack-c/include/msgpack/predef/hardware/simd.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/arm.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/arm/versions.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/ppc.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/ppc/versions.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/x86.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/x86/versions.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/x86_amd.h + deps/msgpack-c/include/msgpack/predef/hardware/simd/x86_amd/versions.h + deps/msgpack-c/include/msgpack/predef/language.h + deps/msgpack-c/include/msgpack/predef/language/cuda.h + deps/msgpack-c/include/msgpack/predef/language/objc.h + deps/msgpack-c/include/msgpack/predef/language/stdc.h + deps/msgpack-c/include/msgpack/predef/language/stdcpp.h + deps/msgpack-c/include/msgpack/predef/library.h + deps/msgpack-c/include/msgpack/predef/library/c.h + deps/msgpack-c/include/msgpack/predef/library/c/_prefix.h + deps/msgpack-c/include/msgpack/predef/library/c/cloudabi.h + deps/msgpack-c/include/msgpack/predef/library/c/gnu.h + deps/msgpack-c/include/msgpack/predef/library/c/uc.h + deps/msgpack-c/include/msgpack/predef/library/c/vms.h + deps/msgpack-c/include/msgpack/predef/library/c/zos.h + deps/msgpack-c/include/msgpack/predef/library/std.h + deps/msgpack-c/include/msgpack/predef/library/std/_prefix.h + deps/msgpack-c/include/msgpack/predef/library/std/cxx.h + deps/msgpack-c/include/msgpack/predef/library/std/dinkumware.h + deps/msgpack-c/include/msgpack/predef/library/std/libcomo.h + deps/msgpack-c/include/msgpack/predef/library/std/modena.h + deps/msgpack-c/include/msgpack/predef/library/std/msl.h + deps/msgpack-c/include/msgpack/predef/library/std/roguewave.h + deps/msgpack-c/include/msgpack/predef/library/std/sgi.h + deps/msgpack-c/include/msgpack/predef/library/std/stdcpp3.h + deps/msgpack-c/include/msgpack/predef/library/std/stlport.h + deps/msgpack-c/include/msgpack/predef/library/std/vacpp.h + deps/msgpack-c/include/msgpack/predef/make.h + deps/msgpack-c/include/msgpack/predef/os.h + deps/msgpack-c/include/msgpack/predef/os/aix.h + deps/msgpack-c/include/msgpack/predef/os/amigaos.h + deps/msgpack-c/include/msgpack/predef/os/android.h + deps/msgpack-c/include/msgpack/predef/os/beos.h + deps/msgpack-c/include/msgpack/predef/os/bsd.h + deps/msgpack-c/include/msgpack/predef/os/bsd/bsdi.h + deps/msgpack-c/include/msgpack/predef/os/bsd/dragonfly.h + deps/msgpack-c/include/msgpack/predef/os/bsd/free.h + deps/msgpack-c/include/msgpack/predef/os/bsd/net.h + deps/msgpack-c/include/msgpack/predef/os/bsd/open.h + deps/msgpack-c/include/msgpack/predef/os/cygwin.h + deps/msgpack-c/include/msgpack/predef/os/haiku.h + deps/msgpack-c/include/msgpack/predef/os/hpux.h + deps/msgpack-c/include/msgpack/predef/os/ios.h + deps/msgpack-c/include/msgpack/predef/os/irix.h + deps/msgpack-c/include/msgpack/predef/os/linux.h + deps/msgpack-c/include/msgpack/predef/os/macos.h + deps/msgpack-c/include/msgpack/predef/os/os400.h + deps/msgpack-c/include/msgpack/predef/os/qnxnto.h + deps/msgpack-c/include/msgpack/predef/os/solaris.h + deps/msgpack-c/include/msgpack/predef/os/unix.h + deps/msgpack-c/include/msgpack/predef/os/vms.h + deps/msgpack-c/include/msgpack/predef/os/windows.h + deps/msgpack-c/include/msgpack/predef/other.h + deps/msgpack-c/include/msgpack/predef/other/endian.h + deps/msgpack-c/include/msgpack/predef/other/workaround.h + deps/msgpack-c/include/msgpack/predef/platform.h + deps/msgpack-c/include/msgpack/predef/platform/cloudabi.h + deps/msgpack-c/include/msgpack/predef/platform/ios.h + deps/msgpack-c/include/msgpack/predef/platform/mingw.h + deps/msgpack-c/include/msgpack/predef/platform/mingw32.h + deps/msgpack-c/include/msgpack/predef/platform/mingw64.h + deps/msgpack-c/include/msgpack/predef/platform/windows_desktop.h + deps/msgpack-c/include/msgpack/predef/platform/windows_phone.h + deps/msgpack-c/include/msgpack/predef/platform/windows_runtime.h + deps/msgpack-c/include/msgpack/predef/platform/windows_server.h + deps/msgpack-c/include/msgpack/predef/platform/windows_store.h + deps/msgpack-c/include/msgpack/predef/platform/windows_system.h + deps/msgpack-c/include/msgpack/predef/platform/windows_uwp.h + deps/msgpack-c/include/msgpack/predef/version.h + deps/msgpack-c/include/msgpack/predef/version_number.h + deps/msgpack-c/include/msgpack/sbuffer.h + deps/msgpack-c/include/msgpack/sysdep.h + deps/msgpack-c/include/msgpack/timestamp.h + deps/msgpack-c/include/msgpack/unpack.h + deps/msgpack-c/include/msgpack/unpack_define.h + deps/msgpack-c/include/msgpack/unpack_template.h + deps/msgpack-c/include/msgpack/util.h + deps/msgpack-c/include/msgpack/version.h + deps/msgpack-c/include/msgpack/version_master.h + deps/msgpack-c/include/msgpack/vrefbuffer.h + deps/msgpack-c/include/msgpack/zbuffer.h + deps/msgpack-c/include/msgpack/zone.h +) +IF (MSGPACK_ENABLE_CXX) + LIST (APPEND msgpackc_HEADERS + deps/msgpack-c/include/msgpack.hpp + deps/msgpack-c/include/msgpack/adaptor/adaptor_base.hpp + deps/msgpack-c/include/msgpack/adaptor/adaptor_base_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/array_ref.hpp + deps/msgpack-c/include/msgpack/adaptor/array_ref_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/bool.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/fusion.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/msgpack_variant.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/msgpack_variant_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/optional.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/string_ref.hpp + deps/msgpack-c/include/msgpack/adaptor/boost/string_view.hpp + deps/msgpack-c/include/msgpack/adaptor/carray.hpp + deps/msgpack-c/include/msgpack/adaptor/char_ptr.hpp + deps/msgpack-c/include/msgpack/adaptor/check_container_size.hpp + deps/msgpack-c/include/msgpack/adaptor/check_container_size_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/array.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/array_char.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/array_unsigned_char.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/chrono.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/forward_list.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/reference_wrapper.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/shared_ptr.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/tuple.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/unique_ptr.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/unordered_map.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp11/unordered_set.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp17/byte.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp17/carray_byte.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp17/optional.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp17/string_view.hpp + deps/msgpack-c/include/msgpack/adaptor/cpp17/vector_byte.hpp + deps/msgpack-c/include/msgpack/adaptor/define.hpp + deps/msgpack-c/include/msgpack/adaptor/define_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/deque.hpp + deps/msgpack-c/include/msgpack/adaptor/ext.hpp + deps/msgpack-c/include/msgpack/adaptor/ext_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/fixint.hpp + deps/msgpack-c/include/msgpack/adaptor/fixint_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/float.hpp + deps/msgpack-c/include/msgpack/adaptor/int.hpp + deps/msgpack-c/include/msgpack/adaptor/int_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/list.hpp + deps/msgpack-c/include/msgpack/adaptor/map.hpp + deps/msgpack-c/include/msgpack/adaptor/map_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/msgpack_tuple.hpp + deps/msgpack-c/include/msgpack/adaptor/msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/nil.hpp + deps/msgpack-c/include/msgpack/adaptor/nil_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/pair.hpp + deps/msgpack-c/include/msgpack/adaptor/raw.hpp + deps/msgpack-c/include/msgpack/adaptor/raw_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/set.hpp + deps/msgpack-c/include/msgpack/adaptor/size_equal_only.hpp + deps/msgpack-c/include/msgpack/adaptor/size_equal_only_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/string.hpp + deps/msgpack-c/include/msgpack/adaptor/tr1/unordered_map.hpp + deps/msgpack-c/include/msgpack/adaptor/tr1/unordered_set.hpp + deps/msgpack-c/include/msgpack/adaptor/v4raw.hpp + deps/msgpack-c/include/msgpack/adaptor/v4raw_decl.hpp + deps/msgpack-c/include/msgpack/adaptor/vector.hpp + deps/msgpack-c/include/msgpack/adaptor/vector_bool.hpp + deps/msgpack-c/include/msgpack/adaptor/vector_char.hpp + deps/msgpack-c/include/msgpack/adaptor/vector_unsigned_char.hpp + deps/msgpack-c/include/msgpack/adaptor/wstring.hpp + deps/msgpack-c/include/msgpack/cpp_config.hpp + deps/msgpack-c/include/msgpack/cpp_config_decl.hpp + deps/msgpack-c/include/msgpack/create_object_visitor.hpp + deps/msgpack-c/include/msgpack/create_object_visitor_decl.hpp + deps/msgpack-c/include/msgpack/fbuffer.hpp + deps/msgpack-c/include/msgpack/fbuffer_decl.hpp + deps/msgpack-c/include/msgpack/gcc_atomic.hpp + deps/msgpack-c/include/msgpack/iterator.hpp + deps/msgpack-c/include/msgpack/iterator_decl.hpp + deps/msgpack-c/include/msgpack/meta.hpp + deps/msgpack-c/include/msgpack/meta_decl.hpp + deps/msgpack-c/include/msgpack/null_visitor.hpp + deps/msgpack-c/include/msgpack/null_visitor_decl.hpp + deps/msgpack-c/include/msgpack/object.hpp + deps/msgpack-c/include/msgpack/object_decl.hpp + deps/msgpack-c/include/msgpack/object_fwd.hpp + deps/msgpack-c/include/msgpack/object_fwd_decl.hpp + deps/msgpack-c/include/msgpack/pack.hpp + deps/msgpack-c/include/msgpack/pack_decl.hpp + deps/msgpack-c/include/msgpack/parse.hpp + deps/msgpack-c/include/msgpack/parse_decl.hpp + deps/msgpack-c/include/msgpack/parse_return.hpp + deps/msgpack-c/include/msgpack/preprocessor.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/add.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/dec.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/detail/div_base.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/div.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/inc.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/mod.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/mul.hpp + deps/msgpack-c/include/msgpack/preprocessor/arithmetic/sub.hpp + deps/msgpack-c/include/msgpack/preprocessor/array.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/data.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/detail/get_data.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/elem.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/insert.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/pop_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/pop_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/push_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/push_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/remove.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/replace.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/reverse.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/size.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/to_list.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/to_seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/array/to_tuple.hpp + deps/msgpack-c/include/msgpack/preprocessor/assert_msg.hpp + deps/msgpack-c/include/msgpack/preprocessor/cat.hpp + deps/msgpack-c/include/msgpack/preprocessor/comma.hpp + deps/msgpack-c/include/msgpack/preprocessor/comma_if.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/equal.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/greater.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/greater_equal.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/less.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/less_equal.hpp + deps/msgpack-c/include/msgpack/preprocessor/comparison/not_equal.hpp + deps/msgpack-c/include/msgpack/preprocessor/config/config.hpp + deps/msgpack-c/include/msgpack/preprocessor/config/limits.hpp + deps/msgpack-c/include/msgpack/preprocessor/control.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/deduce_d.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/detail/dmc/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/detail/edg/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/detail/msvc/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/detail/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/expr_if.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/expr_iif.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/if.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/iif.hpp + deps/msgpack-c/include/msgpack/preprocessor/control/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/debug.hpp + deps/msgpack-c/include/msgpack/preprocessor/debug/assert.hpp + deps/msgpack-c/include/msgpack/preprocessor/debug/error.hpp + deps/msgpack-c/include/msgpack/preprocessor/debug/line.hpp + deps/msgpack-c/include/msgpack/preprocessor/dec.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/auto_rec.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/check.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/dmc/auto_rec.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/is_binary.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/is_nullary.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/is_unary.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/null.hpp + deps/msgpack-c/include/msgpack/preprocessor/detail/split.hpp + deps/msgpack-c/include/msgpack/preprocessor/empty.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum_params_with_a_default.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum_params_with_defaults.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum_shifted.hpp + deps/msgpack-c/include/msgpack/preprocessor/enum_shifted_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/expand.hpp + deps/msgpack-c/include/msgpack/preprocessor/expr_if.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/apply.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/detail/is_empty.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/empty.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/expand.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/identity.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/intercept.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/is_1.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/is_empty.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/is_empty_or_1.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/is_empty_variadic.hpp + deps/msgpack-c/include/msgpack/preprocessor/facilities/overload.hpp + deps/msgpack-c/include/msgpack/preprocessor/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/identity.hpp + deps/msgpack-c/include/msgpack/preprocessor/if.hpp + deps/msgpack-c/include/msgpack/preprocessor/inc.hpp + deps/msgpack-c/include/msgpack/preprocessor/iterate.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/lower1.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/lower2.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/lower3.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/lower4.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/lower5.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper1.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper2.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper3.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper4.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper5.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/finish.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/forward1.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/forward2.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/forward3.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/forward4.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/forward5.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/reverse1.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/reverse2.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/reverse3.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/reverse4.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/iter/reverse5.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/local.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/rlocal.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/self.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/detail/start.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/iterate.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/local.hpp + deps/msgpack-c/include/msgpack/preprocessor/iteration/self.hpp + deps/msgpack-c/include/msgpack/preprocessor/library.hpp + deps/msgpack-c/include/msgpack/preprocessor/limits.hpp + deps/msgpack-c/include/msgpack/preprocessor/list.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/adt.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/append.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/at.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/cat.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/detail/dmc/fold_left.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/detail/edg/fold_left.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/detail/edg/fold_right.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/detail/fold_left.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/detail/fold_right.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/filter.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/first_n.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/fold_left.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/fold_right.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/for_each.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/for_each_i.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/for_each_product.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/rest_n.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/reverse.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/size.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/to_array.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/to_seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/to_tuple.hpp + deps/msgpack-c/include/msgpack/preprocessor/list/transform.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/and.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/bitand.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/bitnor.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/bitor.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/bitxor.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/bool.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/compl.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/nor.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/not.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/or.hpp + deps/msgpack-c/include/msgpack/preprocessor/logical/xor.hpp + deps/msgpack-c/include/msgpack/preprocessor/max.hpp + deps/msgpack-c/include/msgpack/preprocessor/min.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/comma.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/comma_if.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/detail/is_begin_parens.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/is_begin_parens.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/paren.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/paren_if.hpp + deps/msgpack-c/include/msgpack/preprocessor/punctuation/remove_parens.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat_2nd.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat_3rd.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat_from_to.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat_from_to_2nd.hpp + deps/msgpack-c/include/msgpack/preprocessor/repeat_from_to_3rd.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/deduce_r.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/deduce_z.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/detail/dmc/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/detail/edg/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/detail/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/detail/msvc/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_binary_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_params_with_a_default.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_params_with_defaults.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_shifted.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_shifted_binary_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_shifted_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_trailing.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_trailing_binary_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/enum_trailing_params.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/for.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/repeat.hpp + deps/msgpack-c/include/msgpack/preprocessor/repetition/repeat_from_to.hpp + deps/msgpack-c/include/msgpack/preprocessor/selection.hpp + deps/msgpack-c/include/msgpack/preprocessor/selection/max.hpp + deps/msgpack-c/include/msgpack/preprocessor/selection/min.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/cat.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/detail/binary_transform.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/detail/is_empty.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/detail/split.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/detail/to_list_msvc.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/elem.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/filter.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/first_n.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/fold_left.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/fold_right.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/for_each.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/for_each_i.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/for_each_product.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/insert.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/pop_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/pop_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/push_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/push_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/remove.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/replace.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/rest_n.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/reverse.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/size.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/subseq.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/to_array.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/to_list.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/to_tuple.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/transform.hpp + deps/msgpack-c/include/msgpack/preprocessor/seq/variadic_seq_to_seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/counter.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/counter.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/def.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/shared.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/slot1.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/slot2.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/slot3.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/slot4.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/detail/slot5.hpp + deps/msgpack-c/include/msgpack/preprocessor/slot/slot.hpp + deps/msgpack-c/include/msgpack/preprocessor/stringize.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/detail/is_single_return.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/eat.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/elem.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/enum.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/insert.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/pop_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/pop_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/push_back.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/push_front.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/rem.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/remove.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/replace.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/reverse.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/size.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/to_array.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/to_list.hpp + deps/msgpack-c/include/msgpack/preprocessor/tuple/to_seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/detail/is_single_return.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/elem.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/size.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/to_array.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/to_list.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/to_seq.hpp + deps/msgpack-c/include/msgpack/preprocessor/variadic/to_tuple.hpp + deps/msgpack-c/include/msgpack/preprocessor/while.hpp + deps/msgpack-c/include/msgpack/preprocessor/wstringize.hpp + deps/msgpack-c/include/msgpack/sbuffer.hpp + deps/msgpack-c/include/msgpack/sbuffer_decl.hpp + deps/msgpack-c/include/msgpack/type.hpp + deps/msgpack-c/include/msgpack/unpack.hpp + deps/msgpack-c/include/msgpack/unpack_decl.hpp + deps/msgpack-c/include/msgpack/unpack_exception.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/adaptor_base.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/adaptor_base_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/array_ref.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/array_ref_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/bool.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/fusion.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/msgpack_variant.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/optional.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/string_ref.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/boost/string_view.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/carray.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/char_ptr.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/check_container_size.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/check_container_size_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/array.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/array_char.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/array_unsigned_char.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/chrono.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/forward_list.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/reference_wrapper.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/shared_ptr.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/tuple.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/unique_ptr.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/unordered_map.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp11/unordered_set.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp17/byte.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp17/carray_byte.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp17/optional.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp17/string_view.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/cpp17/vector_byte.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/define.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/define_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/deque.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_define_map.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_convert_helper.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_define_array.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_define_map.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/ext.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/ext_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/fixint.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/fixint_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/float.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/int.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/int_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/list.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/map.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/map_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/msgpack_tuple.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/nil.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/nil_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/pair.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/raw.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/raw_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/set.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/size_equal_only.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/size_equal_only_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/string.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/tr1/unordered_map.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/tr1/unordered_set.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/v4raw.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/v4raw_decl.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/vector.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/vector_bool.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/vector_char.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/vector_unsigned_char.hpp + deps/msgpack-c/include/msgpack/v1/adaptor/wstring.hpp + deps/msgpack-c/include/msgpack/v1/cpp_config.hpp + deps/msgpack-c/include/msgpack/v1/cpp_config_decl.hpp + deps/msgpack-c/include/msgpack/v1/detail/cpp03_zone.hpp + deps/msgpack-c/include/msgpack/v1/detail/cpp03_zone_decl.hpp + deps/msgpack-c/include/msgpack/v1/detail/cpp11_zone.hpp + deps/msgpack-c/include/msgpack/v1/detail/cpp11_zone_decl.hpp + deps/msgpack-c/include/msgpack/v1/fbuffer.hpp + deps/msgpack-c/include/msgpack/v1/fbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v1/iterator.hpp + deps/msgpack-c/include/msgpack/v1/iterator_decl.hpp + deps/msgpack-c/include/msgpack/v1/meta.hpp + deps/msgpack-c/include/msgpack/v1/meta_decl.hpp + deps/msgpack-c/include/msgpack/v1/object.hpp + deps/msgpack-c/include/msgpack/v1/object_decl.hpp + deps/msgpack-c/include/msgpack/v1/object_fwd.hpp + deps/msgpack-c/include/msgpack/v1/object_fwd_decl.hpp + deps/msgpack-c/include/msgpack/v1/pack.hpp + deps/msgpack-c/include/msgpack/v1/pack_decl.hpp + deps/msgpack-c/include/msgpack/v1/parse_return.hpp + deps/msgpack-c/include/msgpack/v1/preprocessor.hpp + deps/msgpack-c/include/msgpack/v1/sbuffer.hpp + deps/msgpack-c/include/msgpack/v1/sbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v1/unpack.hpp + deps/msgpack-c/include/msgpack/v1/unpack_decl.hpp + deps/msgpack-c/include/msgpack/v1/unpack_exception.hpp + deps/msgpack-c/include/msgpack/v1/version.hpp + deps/msgpack-c/include/msgpack/v1/versioning.hpp + deps/msgpack-c/include/msgpack/v1/vrefbuffer.hpp + deps/msgpack-c/include/msgpack/v1/vrefbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v1/zbuffer.hpp + deps/msgpack-c/include/msgpack/v1/zbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v1/zone.hpp + deps/msgpack-c/include/msgpack/v1/zone_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/adaptor_base.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/adaptor_base_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/array_ref_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/boost/msgpack_variant_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/check_container_size_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/define_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp03_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp03_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp03_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp11_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp11_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/detail/cpp11_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/ext_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/fixint_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/int_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/map_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/nil_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/raw_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/size_equal_only_decl.hpp + deps/msgpack-c/include/msgpack/v2/adaptor/v4raw_decl.hpp + deps/msgpack-c/include/msgpack/v2/cpp_config_decl.hpp + deps/msgpack-c/include/msgpack/v2/create_object_visitor.hpp + deps/msgpack-c/include/msgpack/v2/create_object_visitor_decl.hpp + deps/msgpack-c/include/msgpack/v2/detail/cpp03_zone_decl.hpp + deps/msgpack-c/include/msgpack/v2/detail/cpp11_zone_decl.hpp + deps/msgpack-c/include/msgpack/v2/fbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v2/iterator_decl.hpp + deps/msgpack-c/include/msgpack/v2/meta_decl.hpp + deps/msgpack-c/include/msgpack/v2/null_visitor.hpp + deps/msgpack-c/include/msgpack/v2/null_visitor_decl.hpp + deps/msgpack-c/include/msgpack/v2/object.hpp + deps/msgpack-c/include/msgpack/v2/object_decl.hpp + deps/msgpack-c/include/msgpack/v2/object_fwd.hpp + deps/msgpack-c/include/msgpack/v2/object_fwd_decl.hpp + deps/msgpack-c/include/msgpack/v2/pack_decl.hpp + deps/msgpack-c/include/msgpack/v2/parse.hpp + deps/msgpack-c/include/msgpack/v2/parse_decl.hpp + deps/msgpack-c/include/msgpack/v2/parse_return.hpp + deps/msgpack-c/include/msgpack/v2/sbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v2/unpack.hpp + deps/msgpack-c/include/msgpack/v2/unpack_decl.hpp + deps/msgpack-c/include/msgpack/v2/vrefbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v2/x3_parse.hpp + deps/msgpack-c/include/msgpack/v2/x3_parse_decl.hpp + deps/msgpack-c/include/msgpack/v2/x3_unpack.hpp + deps/msgpack-c/include/msgpack/v2/x3_unpack_decl.hpp + deps/msgpack-c/include/msgpack/v2/zbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v2/zone_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/adaptor_base.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/adaptor_base_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/array_ref_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/boost/msgpack_variant_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/check_container_size_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/define_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp03_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp03_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp03_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp11_define_array_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp11_define_map_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/detail/cpp11_msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/ext_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/fixint_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/int_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/map_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/msgpack_tuple_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/nil_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/raw_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/size_equal_only_decl.hpp + deps/msgpack-c/include/msgpack/v3/adaptor/v4raw_decl.hpp + deps/msgpack-c/include/msgpack/v3/cpp_config_decl.hpp + deps/msgpack-c/include/msgpack/v3/create_object_visitor_decl.hpp + deps/msgpack-c/include/msgpack/v3/detail/cpp03_zone_decl.hpp + deps/msgpack-c/include/msgpack/v3/detail/cpp11_zone_decl.hpp + deps/msgpack-c/include/msgpack/v3/fbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v3/iterator_decl.hpp + deps/msgpack-c/include/msgpack/v3/meta_decl.hpp + deps/msgpack-c/include/msgpack/v3/null_visitor_decl.hpp + deps/msgpack-c/include/msgpack/v3/object_decl.hpp + deps/msgpack-c/include/msgpack/v3/object_fwd.hpp + deps/msgpack-c/include/msgpack/v3/object_fwd_decl.hpp + deps/msgpack-c/include/msgpack/v3/pack_decl.hpp + deps/msgpack-c/include/msgpack/v3/parse.hpp + deps/msgpack-c/include/msgpack/v3/parse_decl.hpp + deps/msgpack-c/include/msgpack/v3/parse_return.hpp + deps/msgpack-c/include/msgpack/v3/sbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v3/unpack.hpp + deps/msgpack-c/include/msgpack/v3/unpack_decl.hpp + deps/msgpack-c/include/msgpack/v3/vrefbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v3/x3_parse_decl.hpp + deps/msgpack-c/include/msgpack/v3/x3_unpack.hpp + deps/msgpack-c/include/msgpack/v3/x3_unpack_decl.hpp + deps/msgpack-c/include/msgpack/v3/zbuffer_decl.hpp + deps/msgpack-c/include/msgpack/v3/zone_decl.hpp + deps/msgpack-c/include/msgpack/version.hpp + deps/msgpack-c/include/msgpack/versioning.hpp + deps/msgpack-c/include/msgpack/vrefbuffer.hpp + deps/msgpack-c/include/msgpack/vrefbuffer_decl.hpp + deps/msgpack-c/include/msgpack/x3_parse.hpp + deps/msgpack-c/include/msgpack/x3_parse_decl.hpp + deps/msgpack-c/include/msgpack/x3_unpack.hpp + deps/msgpack-c/include/msgpack/x3_unpack_decl.hpp + deps/msgpack-c/include/msgpack/zbuffer.hpp + deps/msgpack-c/include/msgpack/zbuffer_decl.hpp + deps/msgpack-c/include/msgpack/zone.hpp + deps/msgpack-c/include/msgpack/zone_decl.hpp + ) +ENDIF () From 502e6ee743ba865be16b0dc3129bc7a950c05afa Mon Sep 17 00:00:00 2001 From: Ali Karademir Date: Fri, 22 Sep 2017 12:38:35 +0300 Subject: [PATCH 4/6] format=xxx is added to the /ws url; ping updated according to the format (cherry picked from commit 89f6f5b2f1969f720e8db0388e4d571eb36c637d) --- broker/include/broker/net/ws.h | 2 + broker/src/handshake.c | 4 +- broker/src/net/ws.c | 51 ++++++++++++++++++++++ broker/src/net/ws_handler.c | 17 +++++--- broker/src/upstream/upstream_handshake.c | 13 +++++- sdk/include/dslink/ws.h | 1 + sdk/src/dslink.c | 11 ++++- sdk/src/ws.c | 54 +++++++++++++++++++++--- 8 files changed, 133 insertions(+), 20 deletions(-) diff --git a/broker/include/broker/net/ws.h b/broker/include/broker/net/ws.h index 6cf4cb6e..ee87817a 100644 --- a/broker/include/broker/net/ws.h +++ b/broker/include/broker/net/ws.h @@ -10,8 +10,10 @@ extern "C" { void broker_ws_send_init(Socket *sock, const char *accept); + uint32_t broker_ws_send_obj(RemoteDSLink *link, json_t *obj); uint32_t broker_ws_send_obj_link_id(struct Broker* broker, const char *link_name, int upstream, json_t *obj); +int broker_ws_send_ping(RemoteDSLink *link); int broker_ws_send(RemoteDSLink *link, const char *data, int len, int opcode); int broker_ws_generate_accept_key(const char *buf, size_t bufLen, char *out, size_t outLen); diff --git a/broker/src/handshake.c b/broker/src/handshake.c index 9eced0b2..1e4938c1 100644 --- a/broker/src/handshake.c +++ b/broker/src/handshake.c @@ -277,10 +277,10 @@ void dslink_handle_ping(uv_timer_t* handle) { long time_diff = current_time.tv_sec - link->lastWriteTime->tv_sec; if (time_diff >= 30) { log_debug("dslink_handle_ping send heartbeat to %s\n", link->name ); - broker_ws_send_obj(link, json_object()); + broker_ws_send_ping(link); } } else { - broker_ws_send_obj(link, json_object()); + broker_ws_send_ping(link); } if (link->lastReceiveTime) { diff --git a/broker/src/net/ws.c b/broker/src/net/ws.c index 7aa89dbd..0628d756 100644 --- a/broker/src/net/ws.c +++ b/broker/src/net/ws.c @@ -127,6 +127,57 @@ uint32_t broker_ws_send_obj(RemoteDSLink *link, json_t *obj) { return id; } +int broker_ws_send_ping(RemoteDSLink *link) { + json_t *obj = json_object(); + + // DECODE OBJ + char* data = NULL; + int len; + int opcode; + + log_debug("Message (Ping)(as %s) is trying sent to %s\n", + (link->is_msgpack==1)?"msgpack":"json", + (char *) link->dsId->data); + + if(link->is_msgpack) { + msgpack_sbuffer* buff = dslink_ws_json_to_msgpack(obj); + data = malloc(buff->size); + len = buff->size; + memcpy(data, buff->data, len); + msgpack_sbuffer_free(buff); + opcode = WSLAY_BINARY_FRAME; + } + else { + data = json_dumps(obj, JSON_PRESERVE_ORDER | JSON_COMPACT); + len = strlen(data); + opcode = WSLAY_TEXT_FRAME; + } + + if (!data) { + return DSLINK_ALLOC_ERR; + } + + int sentBytes = broker_ws_send(link, data, len, opcode); + + if(sentBytes == -1) + { + log_err("Message (Ping)(as %s) is failed sent to %s\n", + (link->is_msgpack==1)?"msgpack":"json", + (char *) link->dsId->data); + } + + if (throughput_output_needed()) { + int sentMessages = broker_count_json_msg(obj); + throughput_add_output(sentBytes, sentMessages); + } + + + json_delete(obj); + + dslink_free(data); + return 0; +} + int broker_ws_send(RemoteDSLink *link, const char *data, int len, int opcode) { if (!link->ws || !link->client) { return -1; diff --git a/broker/src/net/ws_handler.c b/broker/src/net/ws_handler.c index 929125dc..2b82335a 100644 --- a/broker/src/net/ws_handler.c +++ b/broker/src/net/ws_handler.c @@ -123,13 +123,6 @@ void broker_on_ws_data(wslay_event_context_ptr ctx, int is_recv_data_msg_pack = 0; if (arg->opcode == WSLAY_TEXT_FRAME) { - if (arg->msg_length == 2 - && arg->msg[0] == '{' - && arg->msg[1] == '}') { - broker_ws_send(link, "{}", strlen("{}"), WSLAY_TEXT_FRAME); - return; - } - json_error_t err; data = json_loadb((char *) arg->msg, arg->msg_length, 0, &err); @@ -147,6 +140,16 @@ void broker_on_ws_data(wslay_event_context_ptr ctx, is_recv_data_msg_pack = 1; } + // Check whether it is ping or not + if(data != NULL && json_object_iter(data) == NULL) + { + log_debug("Ping received (as %s), responding back...\n", is_recv_data_msg_pack?"msgpack":"json"); + broker_ws_send_ping(link); + return; + } + + + if (throughput_input_needed()) { int receiveMessages = 0; if (data) { diff --git a/broker/src/upstream/upstream_handshake.c b/broker/src/upstream/upstream_handshake.c index 23d902b0..d344a1bc 100644 --- a/broker/src/upstream/upstream_handshake.c +++ b/broker/src/upstream/upstream_handshake.c @@ -279,15 +279,24 @@ void connect_conn_callback(uv_poll_t *handle, int status, int events) { } const char *format = json_string_value(json_object_get(handshake, "format")); + + // TODO: only remoteDSLink also works, but idk about client, should check in refactor. upstreamPoll->clientDslink->is_msgpack = 0; upstreamPoll->remoteDSLink->is_msgpack = 0; + if((format != NULL) && (strcmp(format, "msgpack") == 0)) { - upstreamPoll->clientDslink->is_msgpack = 1; + upstreamPoll->clientDslink->is_msgpack = 0; upstreamPoll->remoteDSLink->is_msgpack = 1; } + const char* format_str = upstreamPoll->remoteDSLink->is_msgpack?"msgpack":"json"; + + log_info("Format was decided as %s by server\n", format_str); + + + if ((dslink_handshake_connect_ws(upstreamPoll->clientDslink->config.broker_url, &upstreamPoll->clientDslink->key, uri, - tKey, salt, upstreamPoll->dsId, NULL, &upstreamPoll->sock)) != 0) { + tKey, salt, upstreamPoll->dsId, NULL, format_str, &upstreamPoll->sock)) != 0) { upstream_reconnect(upstreamPoll); goto exit; } else { diff --git a/sdk/include/dslink/ws.h b/sdk/include/dslink/ws.h index 917c6483..afdee635 100644 --- a/sdk/include/dslink/ws.h +++ b/sdk/include/dslink/ws.h @@ -21,6 +21,7 @@ int dslink_handshake_connect_ws(Url *url, const char *salt, const char *dsId, const char *token, + const char *format, Socket **sock); void dslink_handshake_handle_ws(DSLink *link, link_callback on_requester_ready_cb); diff --git a/sdk/src/dslink.c b/sdk/src/dslink.c index 64835f5d..4fc4b03c 100644 --- a/sdk/src/dslink.c +++ b/sdk/src/dslink.c @@ -453,6 +453,9 @@ int dslink_init_do(DSLink *link, DSLinkCallbacks *cbs) { if(format != NULL && strcmp(format, "msgpack") == 0) link->is_msgpack = 1; + const char* format_str = link->is_msgpack?"msgpack":"json"; + log_info("Format was decided as %s by server\n", format_str); + if (!(uri && ((tKey && salt) || link->config.token))) { log_fatal("Handshake didn't return the " "necessary parameters to complete\n"); @@ -461,9 +464,13 @@ int dslink_init_do(DSLink *link, DSLinkCallbacks *cbs) { } if ((ret = dslink_handshake_connect_ws(link->config.broker_url, &link->key, uri, - tKey, salt, dsId, link->config.token, &sock)) != 0) { - log_fatal("Failed to connect to the broker: %d\n", ret); + tKey, salt, dsId, link->config.token, format_str, &sock)) != 0) { + + log_fatal("Failed to connect to the broker: %s:%d with error code %d\n", + link->config.broker_url->host, + link->config.broker_url->port, ret); ret = 2; + // ret = DSLINK_COULDNT_CONNECT; goto exit; } else { log_info("Successfully connected to the broker\n"); diff --git a/sdk/src/ws.c b/sdk/src/ws.c index 0f851b32..23a02ea7 100644 --- a/sdk/src/ws.c +++ b/sdk/src/ws.c @@ -159,6 +159,47 @@ int dslink_ws_send_obj(wslay_event_context_ptr ctx, json_t *obj) { return 0; } +int dslink_ws_send_ping(wslay_event_context_ptr ctx) { + DSLink *link = ctx->user_data; + + json_t *obj = json_object(); + + log_debug("Message (ping) (as %s) is trying sent\n", + (link->is_msgpack==1)?"msgpack":"json"); + + // DECODE OBJ + char* data = NULL; + int len; + int opcode; + + if(link->is_msgpack) + { + msgpack_sbuffer* buff = dslink_ws_json_to_msgpack(obj); + data = malloc(buff->size); + len = buff->size; + memcpy(data, buff->data, len); + msgpack_sbuffer_free(buff); + opcode = WSLAY_BINARY_FRAME; + } + else + { + data = json_dumps(obj, JSON_PRESERVE_ORDER); + len = strlen(data); + opcode = WSLAY_TEXT_FRAME; + } + + json_delete(obj); + + if (!data) { + return DSLINK_ALLOC_ERR; + } + + dslink_ws_send(ctx, data, len, opcode); + dslink_free(data); + + return 0; +} + static int dslink_ws_send_internal(wslay_event_context_ptr ctx, const char *data, const int len, int opcode, @@ -200,6 +241,7 @@ int dslink_handshake_connect_ws(Url *url, const char *salt, const char *dsId, const char *token, + const char *format, Socket **sock) { *sock = NULL; int ret = 0; @@ -216,12 +258,12 @@ int dslink_handshake_connect_ws(Url *url, char builtUri[256]; char * encodedDsId = dslink_str_escape(dsId); if (tempKey && salt) { - snprintf(builtUri, sizeof(builtUri) - 1, "%s?auth=%s&dsId=%s", - uri, auth, encodedDsId); + snprintf(builtUri, sizeof(builtUri) - 1, "%s?auth=%s&dsId=%s&format=%s", + uri, auth, encodedDsId, format); } else { // trusted dslink - snprintf(builtUri, sizeof(builtUri) - 1, "%s?dsId=%s&token=%s", - uri, encodedDsId, token); + snprintf(builtUri, sizeof(builtUri) - 1, "%s?dsId=%s&token=%s&format=%s", + uri, encodedDsId, token, format); } dslink_free(encodedDsId); @@ -411,9 +453,7 @@ void ping_handler(uv_timer_t *timer) { log_debug("Pinging...\n"); DSLink *link = timer->data; - json_t *obj = json_object(); - dslink_ws_send_obj(link->_ws, obj); - json_delete(obj); + dslink_ws_send_ping(link->_ws); struct timeval current_time; gettimeofday(¤t_time, NULL); From 1e7b9340800de05a38885a2aab35629f9435b9b0 Mon Sep 17 00:00:00 2001 From: akawamura Date: Mon, 10 Dec 2018 16:23:10 -0800 Subject: [PATCH 5/6] partial cherry picked from commit 02a38076dacb6b935a2a20294ca08a50be869abf. Picked changes related to msgpack only --- CMakeLists.txt | 2 +- broker/src/net/ws_handler.c | 1 + deps/msgpack-c-build/CMakeLists.txt | 5 +- sdk/include/dslink/base64_url.h | 19 ++ sdk/include/dslink/err.h | 3 + sdk/include/dslink/utils.h | 7 + sdk/include/dslink/ws.h | 5 - sdk/src/base64_url.c | 190 ++++++++++++++++ sdk/src/node.c | 3 + sdk/src/utils.c | 185 ++++++++++++++++ sdk/src/ws.c | 181 ---------------- test/CMakeLists.txt | 1 + test/include/cmocka_init.h | 13 ++ test/sdk/utils_msgpack_test.c | 323 ++++++++++++++++++++++++++++ 14 files changed, 748 insertions(+), 190 deletions(-) create mode 100644 test/sdk/utils_msgpack_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e8e50a3e..62b6dbea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,7 +234,7 @@ else() endif() add_library(sdk_dslink_c SHARED ${LIBRARY_SRC}) -target_link_libraries(sdk_dslink_c jansson libuv ${DSLINK_PLATFORM_LIBS}) +target_link_libraries(sdk_dslink_c msgpackc jansson libuv ${DSLINK_PLATFORM_LIBS}) set_target_properties(sdk_dslink_c PROPERTIES VERSION ${VERSION} SOVERSION ${VERSION} ) set(DSLINK_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") diff --git a/broker/src/net/ws_handler.c b/broker/src/net/ws_handler.c index 2b82335a..8ab010be 100644 --- a/broker/src/net/ws_handler.c +++ b/broker/src/net/ws_handler.c @@ -11,6 +11,7 @@ #include "broker/net/ws.h" #include #include +#include ssize_t broker_want_read_cb(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, diff --git a/deps/msgpack-c-build/CMakeLists.txt b/deps/msgpack-c-build/CMakeLists.txt index b9e6a0c6..41d04fb5 100644 --- a/deps/msgpack-c-build/CMakeLists.txt +++ b/deps/msgpack-c-build/CMakeLists.txt @@ -459,7 +459,6 @@ ENDIF () # AK:TODO remove_flag_from_target(msgpackc-static -pedantic) # remove_flag_from_file(msgpackc-static unpack.c -pedantic) -#[[ # Doxygen FIND_PACKAGE (Doxygen) IF (DOXYGEN_FOUND) @@ -525,7 +524,7 @@ IF (NOT CMAKE_VERSION VERSION_LESS 3.0) ) ENDIF () -CONFIGURE_PACKAGE_CONFIG_FILE (msgpack-config.cmake.in +CONFIGURE_PACKAGE_CONFIG_FILE (${CMAKE_CURRENT_SOURCE_DIR}/msgpack-config.cmake.in msgpack-config.cmake INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" ) @@ -543,5 +542,5 @@ INSTALL ( "${CMAKE_CURRENT_BINARY_DIR}/msgpack-config-version.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" -)]] +) diff --git a/sdk/include/dslink/base64_url.h b/sdk/include/dslink/base64_url.h index a08ed34b..a13d6cfd 100644 --- a/sdk/include/dslink/base64_url.h +++ b/sdk/include/dslink/base64_url.h @@ -6,6 +6,7 @@ extern "C" { #endif #include +#include "dslink/err.h" /** * Encodes a string into base64 format without padding @@ -25,6 +26,24 @@ int dslink_base64_url_decode(unsigned char *dst, const unsigned char *src, size_t sLen); +/** + * Encodes a string into base64 format without padding + */ +int dslink_base64_encode(unsigned char *dst, + size_t dLen, + size_t *olen, + const unsigned char *src, + size_t sLen); + +/** + * Decodes a base64 string + */ +int dslink_base64_decode(unsigned char *dst, + size_t dLen, + size_t *oLen, + const unsigned char *src, + size_t sLen); + #ifdef __cplusplus } #endif diff --git a/sdk/include/dslink/err.h b/sdk/include/dslink/err.h index 34903c09..17d0e06c 100644 --- a/sdk/include/dslink/err.h +++ b/sdk/include/dslink/err.h @@ -40,6 +40,9 @@ extern "C" { #define DSLINK_CANNOT_WRITE_FILE -0x5003 #define DSLINK_CANNOT_LOAD_FILE -0x5004 +#define DSLINK_BASE64_BUFFER_TOO_SMALL_ERR -0x6001 +#define DSLINK_BASE64_INVALID_CHARACTER_ERR -0x6002 + #ifdef __cplusplus } #endif diff --git a/sdk/include/dslink/utils.h b/sdk/include/dslink/utils.h index f2305cb1..72060b08 100644 --- a/sdk/include/dslink/utils.h +++ b/sdk/include/dslink/utils.h @@ -6,6 +6,8 @@ extern "C" { #endif #include +#include +#include #define DSLINK_CHECKED_EXEC(func, val) \ if (val) func(val) @@ -25,6 +27,11 @@ size_t dslink_create_ts(char *buf, size_t bufLen); int dslink_sleep(long ms); +int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk); + +msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj); +json_t* dslink_ws_msgpack_to_json(msgpack_object* obj); + const char* dslink_checkIpv4Address(const char* address); const char* dslink_checkIpv6Address(const char* address); int dslink_isipv6address(const char* host); diff --git a/sdk/include/dslink/ws.h b/sdk/include/dslink/ws.h index afdee635..44849ad5 100644 --- a/sdk/include/dslink/ws.h +++ b/sdk/include/dslink/ws.h @@ -29,11 +29,6 @@ int dslink_ws_send_obj(struct wslay_event_context *ctx, json_t *obj); int dslink_ws_send(struct wslay_event_context *ctx, const char *data, const int len, const int opcode); -int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk); - -msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj); -json_t* dslink_ws_msgpack_to_json(msgpack_object* obj); - #ifdef __cplusplus } #endif diff --git a/sdk/src/base64_url.c b/sdk/src/base64_url.c index 26181695..e8f88dec 100644 --- a/sdk/src/base64_url.c +++ b/sdk/src/base64_url.c @@ -4,6 +4,10 @@ #include #include #include "dslink/base64_url.h" +#include "dslink/err.h" + + +// These adapted from mbedtls static const unsigned char base64_enc_map_[64] = { @@ -185,3 +189,189 @@ int dslink_base64_url_decode(unsigned char *dst, return( 0 ); } + +static const unsigned char base64_enc_map[64] = + { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', '+', '/' + }; + +static const unsigned char base64_dec_map[128] = + { + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 62, 127, 127, 127, 63, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, + 127, 64, 127, 127, 127, 0, 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, 127, 127, 127, 127, 127, 127, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 127, 127, 127, 127, 127 + }; + + +int dslink_base64_encode( unsigned char *dst, + size_t dlen, + size_t *olen, + const unsigned char *src, + size_t slen) { + + size_t i, n; + int C1, C2, C3; + unsigned char *p; + + if( slen == 0 ) + { + *olen = 0; + return( 0 ); + } + + n = slen / 3 + ( slen % 3 != 0 ); + + if( n > ( BASE64_SIZE_T_MAX - 1 ) / 4 ) + { + *olen = BASE64_SIZE_T_MAX; + return( DSLINK_BASE64_BUFFER_TOO_SMALL_ERR ); + } + + n *= 4; + + if( dlen < n + 1 ) + { + *olen = n + 1; + return( DSLINK_BASE64_BUFFER_TOO_SMALL_ERR ); + } + + n = ( slen / 3 ) * 3; + + for( i = 0, p = dst; i < n; i += 3 ) + { + C1 = *src++; + C2 = *src++; + C3 = *src++; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F]; + *p++ = base64_enc_map[C3 & 0x3F]; + } + + if( i < slen ) + { + C1 = *src++; + C2 = ( ( i + 1 ) < slen ) ? *src++ : 0; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + + if( ( i + 1 ) < slen ) + *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F]; + else *p++ = '='; + + *p++ = '='; + } + + *olen = p - dst; + *p = 0; + + return( 0 ); +} + + +int dslink_base64_decode( unsigned char *dst, + size_t dlen, + size_t *olen, + const unsigned char *src, + size_t slen) { + size_t i, n; + uint32_t j, x; + unsigned char *p; + + /* First pass: check for validity and get output length */ + for( i = n = j = 0; i < slen; i++ ) + { + /* Skip spaces before checking for EOL */ + x = 0; + while( i < slen && src[i] == ' ' ) + { + ++i; + ++x; + } + + /* Spaces at end of buffer are OK */ + if( i == slen ) + break; + + if( ( slen - i ) >= 2 && + src[i] == '\r' && src[i + 1] == '\n' ) + continue; + + if( src[i] == '\n' ) + continue; + + /* Space inside a line is an error */ + if( x != 0 ) + return( DSLINK_BASE64_INVALID_CHARACTER_ERR ); + + if( src[i] == '=' && ++j > 2 ) + return( DSLINK_BASE64_INVALID_CHARACTER_ERR ); + + if( src[i] > 127 || base64_dec_map[src[i]] == 127 ) + return( DSLINK_BASE64_INVALID_CHARACTER_ERR ); + + if( base64_dec_map[src[i]] < 64 && j != 0 ) + return( DSLINK_BASE64_INVALID_CHARACTER_ERR ); + + n++; + } + + if( n == 0 ) + { + *olen = 0; + return( 0 ); + } + + /* The following expression is to calculate the following formula without + * risk of integer overflow in n: + * n = ( ( n * 6 ) + 7 ) >> 3; + */ + n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 ); + n -= j; + + if( dst == NULL || dlen < n ) + { + *olen = n; + return( DSLINK_BASE64_BUFFER_TOO_SMALL_ERR ); + } + + for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ ) + { + if( *src == '\r' || *src == '\n' || *src == ' ' ) + continue; + + j -= ( base64_dec_map[*src] == 64 ); + x = ( x << 6 ) | ( base64_dec_map[*src] & 0x3F ); + + if( ++n == 4 ) + { + n = 0; + if( j > 0 ) *p++ = (unsigned char)( x >> 16 ); + if( j > 1 ) *p++ = (unsigned char)( x >> 8 ); + if( j > 2 ) *p++ = (unsigned char)( x ); + } + } + + *olen = p - dst; + + return( 0 ); +} + diff --git a/sdk/src/node.c b/sdk/src/node.c index 8efbc4ba..e39c352e 100644 --- a/sdk/src/node.c +++ b/sdk/src/node.c @@ -6,6 +6,9 @@ #include #include "mbedtls/aes.h" +#define LOG_TAG "node" +#include + #include "dslink/node.h" #include "dslink/mem/mem.h" #include "dslink/ws.h" diff --git a/sdk/src/utils.c b/sdk/src/utils.c index 2da156a7..7a812f74 100644 --- a/sdk/src/utils.c +++ b/sdk/src/utils.c @@ -7,6 +7,9 @@ #include "dslink/mem/mem.h" #include "dslink/utils.h" +#define LOG_TAG "utils" +#include "dslink/log.h" + const char *dslink_strcasestr(const char *haystack, const char *needle) { if (!needle || *needle == '\0') { return haystack; @@ -254,6 +257,188 @@ const char* dslink_checkIpv4Address(const char* address) return host; } +int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk) +{ +#if 0 + // AK: TODO + char* buf; + size_t buf_len = 0; +#endif + + switch(json_obj->type) + { + case JSON_OBJECT: + msgpack_pack_map(pk, json_object_size(json_obj)); + + const char *key; + json_t *value; + + void *iter = json_object_iter(json_obj); + while(iter) + { + key = json_object_iter_key(iter); + value = json_object_iter_value(iter); + + msgpack_pack_str(pk, strlen(key)); + msgpack_pack_str_body(pk, key, strlen(key)); + + if(sync_json_to_msg_pack(value, pk) != 1) + return 0; + + iter = json_object_iter_next(json_obj, iter); + } + + break; + case JSON_ARRAY: + msgpack_pack_array(pk, json_array_size(json_obj)); + for(size_t i = 0; i < json_array_size(json_obj); i++) + { + if(sync_json_to_msg_pack(json_array_get(json_obj, i), pk) != 1) + return 0; + } + break; +#if 0 + // AK: TODO + case JSON_BINARY: + buf_len = json_binary_length_raw(json_obj); + buf = (char*) malloc(buf_len); + + buf_len = json_binary_value(json_obj, buf); + + msgpack_pack_bin(pk, buf_len); + msgpack_pack_bin_body(pk, buf, buf_len); + + free(buf); + break; +#endif + case JSON_STRING: + msgpack_pack_str(pk, json_string_length(json_obj)); + msgpack_pack_str_body(pk, json_string_value(json_obj), json_string_length(json_obj)); + break; + case JSON_INTEGER: + msgpack_pack_int(pk, json_integer_value(json_obj)); + break; + case JSON_REAL: + msgpack_pack_double(pk, json_real_value(json_obj)); + break; + case JSON_TRUE: + msgpack_pack_true(pk); + break; + case JSON_FALSE: + msgpack_pack_false(pk); + break; + case JSON_NULL : + msgpack_pack_nil(pk); + break; + } + + return 1; +} + +msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj) +{ + msgpack_sbuffer* buffer = msgpack_sbuffer_new(); + msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write); + + if( sync_json_to_msg_pack(json_obj, pk) != 1) + goto ERROR; + + EXIT: + msgpack_packer_free(pk); + return buffer; + + ERROR: + log_fatal("Cannot convert to msg_pack\n") + msgpack_sbuffer_free(buffer); + buffer = NULL; + goto EXIT; +} + + + +json_t* dslink_ws_msgpack_to_json(msgpack_object* msg_obj) +{ + json_t* json_obj = NULL; + json_t* temp = NULL; + + char* text; + + switch(msg_obj->type) + { + case MSGPACK_OBJECT_NIL: + json_obj = json_null(); + break; + case MSGPACK_OBJECT_BOOLEAN: + json_obj = json_boolean(msg_obj->via.boolean); + break; + case MSGPACK_OBJECT_POSITIVE_INTEGER: + json_obj = json_integer(msg_obj->via.u64); + break; + case MSGPACK_OBJECT_NEGATIVE_INTEGER: + json_obj = json_integer(msg_obj->via.i64); + break; + case MSGPACK_OBJECT_FLOAT32: + json_obj = json_real(msg_obj->via.f64); + break; + case MSGPACK_OBJECT_FLOAT: + json_obj = json_real(msg_obj->via.f64); + break; + case MSGPACK_OBJECT_STR: + json_obj = json_stringn_nocheck(msg_obj->via.str.ptr, msg_obj->via.str.size); + break; + case MSGPACK_OBJECT_ARRAY: + json_obj = json_array(); + for(uint32_t i = 0; i < msg_obj->via.array.size; i++) + { + temp = dslink_ws_msgpack_to_json(&msg_obj->via.array.ptr[i]); + if(temp == NULL) + goto ERROR; + + json_array_append(json_obj, temp); + } + break; + case MSGPACK_OBJECT_MAP: + json_obj = json_object(); + + for(uint32_t i = 0; i < msg_obj->via.map.size; i++) + { + msgpack_object_kv* kv = &msg_obj->via.map.ptr[i]; + if(kv->key.type != MSGPACK_OBJECT_STR) + goto ERROR; + + temp = dslink_ws_msgpack_to_json(&kv->val); + if(temp == NULL) + goto ERROR; + + text = malloc(kv->key.via.str.size + 1); + memcpy(text, kv->key.via.str.ptr, kv->key.via.str.size); + text[kv->key.via.str.size] = '\0'; + json_object_set_nocheck(json_obj, text, temp); + free(text); + } + + break; + case MSGPACK_OBJECT_BIN: + // AK: TODO + // json_obj = json_binaryn_nocheck(msg_obj->via.bin.ptr, msg_obj->via.bin.size); + break; + case MSGPACK_OBJECT_EXT: + log_fatal("Cannot convert json BECAUSE EXT NOT IMPLEMENTED\n"); + goto ERROR; + break; + } + + EXIT: + return json_obj; + + ERROR: + if(json_obj != NULL) + json_decref(json_obj); + + json_obj = NULL; + goto EXIT; +} + const char* dslink_checkIpv6Address(const char* address) { const char* host = address; diff --git a/sdk/src/ws.c b/sdk/src/ws.c index 23a02ea7..2a02360f 100644 --- a/sdk/src/ws.c +++ b/sdk/src/ws.c @@ -521,184 +521,3 @@ void dslink_handshake_handle_ws(DSLink *link, link_callback on_requester_ready_c link->_ws = NULL; } -int sync_json_to_msg_pack(json_t *json_obj, msgpack_packer* pk) -{ -#if 0 - // AK: TODO - char* buf; - size_t buf_len = 0; -#endif - - switch(json_obj->type) - { - case JSON_OBJECT: - msgpack_pack_map(pk, json_object_size(json_obj)); - - const char *key; - json_t *value; - - void *iter = json_object_iter(json_obj); - while(iter) - { - key = json_object_iter_key(iter); - value = json_object_iter_value(iter); - - msgpack_pack_str(pk, strlen(key)); - msgpack_pack_str_body(pk, key, strlen(key)); - - if(sync_json_to_msg_pack(value, pk) != 1) - return 0; - - iter = json_object_iter_next(json_obj, iter); - } - - break; - case JSON_ARRAY: - msgpack_pack_array(pk, json_array_size(json_obj)); - for(size_t i = 0; i < json_array_size(json_obj); i++) - { - if(sync_json_to_msg_pack(json_array_get(json_obj, i), pk) != 1) - return 0; - } - break; -#if 0 - // AK: TODO - case JSON_BINARY: - buf_len = json_binary_length_raw(json_obj); - buf = (char*) malloc(buf_len); - - buf_len = json_binary_value(json_obj, buf); - - msgpack_pack_bin(pk, buf_len); - msgpack_pack_bin_body(pk, buf, buf_len); - - free(buf); - break; -#endif - case JSON_STRING: - msgpack_pack_str(pk, json_string_length(json_obj)); - msgpack_pack_str_body(pk, json_string_value(json_obj), json_string_length(json_obj)); - break; - case JSON_INTEGER: - msgpack_pack_int(pk, json_integer_value(json_obj)); - break; - case JSON_REAL: - msgpack_pack_double(pk, json_real_value(json_obj)); - break; - case JSON_TRUE: - msgpack_pack_true(pk); - break; - case JSON_FALSE: - msgpack_pack_false(pk); - break; - case JSON_NULL : - msgpack_pack_nil(pk); - break; - } - - return 1; -} - -msgpack_sbuffer* dslink_ws_json_to_msgpack(json_t *json_obj) -{ - msgpack_sbuffer* buffer = msgpack_sbuffer_new(); - msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write); - - if( sync_json_to_msg_pack(json_obj, pk) != 1) - goto ERROR; - - EXIT: - msgpack_packer_free(pk); - return buffer; - - ERROR: - log_fatal("Cannot convert to msg_pack\n") - msgpack_sbuffer_free(buffer); - buffer = NULL; - goto EXIT; -} - - - -json_t* dslink_ws_msgpack_to_json(msgpack_object* msg_obj) -{ - json_t* json_obj = NULL; - json_t* temp = NULL; - - char* text; - - switch(msg_obj->type) - { - case MSGPACK_OBJECT_NIL: - json_obj = json_null(); - break; - case MSGPACK_OBJECT_BOOLEAN: - json_obj = json_boolean(msg_obj->via.boolean); - break; - case MSGPACK_OBJECT_POSITIVE_INTEGER: - json_obj = json_integer(msg_obj->via.u64); - break; - case MSGPACK_OBJECT_NEGATIVE_INTEGER: - json_obj = json_integer(msg_obj->via.i64); - break; - case MSGPACK_OBJECT_FLOAT32: - json_obj = json_real(msg_obj->via.f64); - break; - case MSGPACK_OBJECT_FLOAT: - json_obj = json_real(msg_obj->via.f64); - break; - case MSGPACK_OBJECT_STR: - json_obj = json_stringn_nocheck(msg_obj->via.str.ptr, msg_obj->via.str.size); - break; - case MSGPACK_OBJECT_ARRAY: - json_obj = json_array(); - for(uint32_t i = 0; i < msg_obj->via.array.size; i++) - { - temp = dslink_ws_msgpack_to_json(&msg_obj->via.array.ptr[i]); - if(temp == NULL) - goto ERROR; - - json_array_append(json_obj, temp); - } - break; - case MSGPACK_OBJECT_MAP: - json_obj = json_object(); - - for(uint32_t i = 0; i < msg_obj->via.map.size; i++) - { - msgpack_object_kv* kv = &msg_obj->via.map.ptr[i]; - if(kv->key.type != MSGPACK_OBJECT_STR) - goto ERROR; - - temp = dslink_ws_msgpack_to_json(&kv->val); - if(temp == NULL) - goto ERROR; - - text = malloc(kv->key.via.str.size + 1); - memcpy(text, kv->key.via.str.ptr, kv->key.via.str.size); - text[kv->key.via.str.size] = '\0'; - json_object_set_nocheck(json_obj, text, temp); - free(text); - } - - break; - case MSGPACK_OBJECT_BIN: - // AK: TODO - // json_obj = json_binaryn_nocheck(msg_obj->via.bin.ptr, msg_obj->via.bin.size); - break; - case MSGPACK_OBJECT_EXT: - log_fatal("Cannot convert json BECAUSE EXT NOT IMPLEMENTED\n"); - goto ERROR; - break; - } - - EXIT: - return json_obj; - - ERROR: - if(json_obj != NULL) - json_decref(json_obj); - - json_obj = NULL; - goto EXIT; -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6dfbfe1e..635013a4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,7 @@ set(SDK_TEST_SET "col_vec_test" "col_ringbuf_test" "utils_test" + "utils_msgpack_test" "thread_safe_api_test" ) diff --git a/test/include/cmocka_init.h b/test/include/cmocka_init.h index de6cae33..ce90f1af 100644 --- a/test/include/cmocka_init.h +++ b/test/include/cmocka_init.h @@ -9,6 +9,7 @@ */ #pragma once +#include #include #include #include @@ -21,3 +22,15 @@ struct CMUnitTest test_##n \ __attribute__((section("cmocka_init"),used)) = cmocka_unit_test(n); \ void n(void** state) + +#define assert_function_success(a) \ + assert_int_equal((const int)(a), 0) + +// +//#define malloc(size) _test_malloc(size, __FILE__, __LINE__) +//#define calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__) +//#define free(ptr) _test_free(ptr, __FILE__, __LINE__) +// +//#define dslink_malloc(size) _test_malloc(size, __FILE__, __LINE__) +//#define dslink_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__) +//#define dslink_free(ptr) _test_free(ptr, __FILE__, __LINE__) diff --git a/test/sdk/utils_msgpack_test.c b/test/sdk/utils_msgpack_test.c new file mode 100644 index 00000000..62b2021b --- /dev/null +++ b/test/sdk/utils_msgpack_test.c @@ -0,0 +1,323 @@ +#include "cmocka_init.h" +#include +#include +#include +#include +#include +#include +#include + +//static +//void utils_str_replace_all_test(void **state) { +// (void) state; +// +// const char *str = "abc_abc_a"; +// char *rep = dslink_str_replace_all(str, "a", "123"); +// assert_non_null(rep); +// assert_string_equal(rep, "123bc_123bc_123"); +// dslink_free(rep); +// +// str = "abc_abc"; +// rep = dslink_str_replace_all(str, "abc", "1"); +// assert_non_null(rep); +// assert_string_equal(rep, "1_1"); +// dslink_free(rep); +//} + + +// These adapted from mbedtls + +static const struct { + const char *type; + + const char *input; + const char *output; + int output_buffer_size; + int expected_result; + +} base64_tests[] = { + { + "encode_base64", + "Man is distinguished, not only by his reason, but by this singular " + "passion from other animals, which is a lust of the mind, that by a " + "perseverance of delight in the continued and indefatigable generation " + "of knowledge, exceeds the short vehemence of any carnal pleasure.", + + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS" + "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBh" + "IGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodC" + "BpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25v" + "d2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbG" + "Vhc3VyZS4=", + 512, + 0 + }, + {"encode_base64", "f", "Zg==", 5, 0 }, + {"encode_base64", "f", "Zg==", 4, DSLINK_BASE64_BUFFER_TOO_SMALL_ERR }, + {"encode_base64", "foo","Zm9v",5,0}, + {"encode_base64", "foo","Zm9v",4,DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"encode_base64", "foob","Zm9vYg==",9,0}, + {"encode_base64", "foob","Zm9vYg==",8,DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"encode_base64", "fooba","Zm9vYmE=",9,0}, + {"encode_base64", "fooba","Zm9vYmE=",8,DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"encode_base64", "foobar","Zm9vYmFy",9,0}, + {"encode_base64", "foobar","Zm9vYmFy",8,DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"encode_base64", "sdk-dslink-cpp","c2RrLWRzbGluay1jcHA=", 30, 0}, + {"encode_base64", "-cpp", "LWNwcA==", 20, 0}, + + { + "decode_base64", + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieS" + "B0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBh" + "IGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodC" + "BpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25v" + "d2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbG" + "Vhc3VyZS4=", + + "Man is distinguished, not only by his reason, but by this singular " + "passion from other animals, which is a lust of the mind, that by a " + "perseverance of delight in the continued and indefatigable generation " + "of knowledge, exceeds the short vehemence of any carnal pleasure.", + + 512, + 0 + }, + + {"decode_base64", "c2RrLWRzbGluay1jcHA=", "sdk-dslink-cpp", 30, 0}, + {"decode_base64", "LWNwcA==", "-cpp", 20, 0}, + {"decode_base64", "", "", 10, 0}, + {"decode_base64", "Zg==", "f", 10, 0}, + {"decode_base64", "Zm8=", "fo", 10, 0}, + {"decode_base64", "Zm9v", "foo", 10, 0}, + {"decode_base64", "Zm9v", "foo", 1, DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"decode_base64", "Zm9vYg==", "foob", 10, 0}, + {"decode_base64", "Zm9vYmE=", "fooba", 10, 0}, + {"decode_base64", "Zm9vYmFy", "foobar", 10, 0}, + {"decode_base64", "Zm9vYmFy", "foobar", 3, DSLINK_BASE64_BUFFER_TOO_SMALL_ERR}, + {"decode_base64", "zm#=", "", 10, DSLINK_BASE64_INVALID_CHARACTER_ERR}, + {"decode_base64", "zm===", "", 10, DSLINK_BASE64_INVALID_CHARACTER_ERR}, + {"decode_base64", "zm=masd", "", 10, DSLINK_BASE64_INVALID_CHARACTER_ERR}, + {"decode_base64", "zm masd", "", 10, DSLINK_BASE64_INVALID_CHARACTER_ERR}, + +//TODO: Extend url +// { "=123", "", 10, 0}, +// { "123==", "123", 10, 0}, +// { "1+2+3==", "1-2-3", 10, 0}, +// { "1////23==", "1____23", 10, 0}, + +}; + + +static +void base64_test(void **state){ + (void) state; + + for(unsigned int i = 0; i < sizeof(base64_tests) / sizeof(base64_tests[0]); i++) + { + unsigned char* input = (unsigned char*)base64_tests[i].input; + size_t input_size = strlen(base64_tests[i].input); + + int output_buffer_alloc_size = base64_tests[i].output_buffer_size; + unsigned char* output_buffer = malloc(output_buffer_alloc_size); + + size_t olen; + int output_return = 0; + + if(strcmp("encode_base64", base64_tests[i].type) == 0) + output_return = dslink_base64_encode(output_buffer, output_buffer_alloc_size, &olen, input, input_size); + else if(strcmp("decode_base64", base64_tests[i].type) == 0) + output_return = dslink_base64_decode(output_buffer, output_buffer_alloc_size, &olen, input, input_size); + else + fail(); + + assert_int_equal(output_return, base64_tests[i].expected_result); + + if(output_return != 0) + goto continue_; + assert_int_equal(olen, strlen(base64_tests[i].output)); + assert_memory_equal(base64_tests[i].output, output_buffer, olen); + + continue_: + free(output_buffer); + } +} + + +static +json_t* get_test_json() +{ + json_t *json = json_object(); + json_object_set_new(json, "str1", json_string_nocheck((char *) "Hello")); + json_object_set_new(json, "boolean1", json_boolean(1)); + json_object_set_new(json, "str2", json_string_nocheck("")); + json_object_set_new(json, "null1", json_null()); + json_object_set_new(json, "real1", json_real(3.221)); + json_object_set_new(json, "int1", json_integer(3)); + /* json_binary function is not implemented + json_object_set_new(json, "binary1", json_binary("BINARRYYYYY12123123123123123")); + json_object_set_new(json, "binary2", json_binary("BINARRYYYYY")); + json_object_set_new(json, "binary3", json_binary("BINARY")); + json_object_set_new(json, "binary4", json_binary("B")); + json_object_set_new(json, "binary5", json_binary("")); + */ + json_object_set_new(json, "array1", json_array()); + json_array_append(json_object_get(json,"array1"), json_string_nocheck("Hello_2")); + json_array_append(json_object_get(json,"array1"), json_string_nocheck("msgpack32")); + json_array_append(json_object_get(json,"array1"), json_boolean(0)); + json_array_append(json_object_get(json,"array1"), json_null()); + json_array_append(json_object_get(json,"array1"), json_real(3.221)); + json_array_append(json_object_get(json,"array1"), json_integer(3)); + /* json_binary function is not implemented + json_array_append(json_object_get(json,"array1"), json_binary("BINARRYYYYY12123123123123123")); + */ + + return json; + +} + +static +void msgpack_add_bin(msgpack_packer *pk, const char* str) +{ + msgpack_pack_bin(pk, strlen(str)); + msgpack_pack_bin_body(pk, str, strlen(str)); +} + +static +void msgpack_add_str(msgpack_packer *pk, const char* str) +{ + msgpack_pack_str(pk, strlen(str)); + msgpack_pack_str_body(pk, str, strlen(str)); +} + +static +msgpack_sbuffer* get_test_msgpack() +{ + /* msgpack::sbuffer is a simple buffer implementation. */ + msgpack_sbuffer* sbuf = malloc(sizeof(msgpack_sbuffer)); + msgpack_sbuffer_init(sbuf); + + /* serialize values into the buffer using msgpack_sbuffer_write callback function. */ + msgpack_packer pk; + msgpack_packer_init(&pk, sbuf, msgpack_sbuffer_write); + + msgpack_pack_map(&pk, 12); + + msgpack_add_str(&pk, "str1"); + msgpack_add_str(&pk, "Hello"); + + msgpack_add_str(&pk, "boolean1"); + msgpack_pack_true(&pk); + + msgpack_add_str(&pk, "str2"); + msgpack_add_str(&pk, ""); + + msgpack_add_str(&pk, "null1"); + msgpack_pack_nil(&pk); + + msgpack_add_str(&pk, "real1"); + msgpack_pack_double(&pk, (double)3.221); + + msgpack_add_str(&pk, "int1"); + msgpack_pack_int64(&pk, 3); + + msgpack_add_str(&pk, "binary1"); + msgpack_add_bin(&pk, "BINARRYYYYY12123123123123123"); + + msgpack_add_str(&pk, "binary2"); + msgpack_add_bin(&pk, "BINARRYYYYY"); + + msgpack_add_str(&pk, "binary3"); + msgpack_add_bin(&pk, "BINARY"); + + msgpack_add_str(&pk, "binary4"); + msgpack_add_bin(&pk, "B"); + + msgpack_add_str(&pk, "binary5"); + msgpack_add_bin(&pk, ""); + + msgpack_add_str(&pk, "array1"); + msgpack_pack_array(&pk, 7); + + msgpack_add_str(&pk, "Hello_2"); + msgpack_add_str(&pk, "msgpack32"); + msgpack_pack_false(&pk); + msgpack_pack_nil(&pk); + msgpack_pack_double(&pk, 3.221); + msgpack_pack_int64(&pk, 3); + msgpack_add_bin(&pk, "BINARRYYYYY12123123123123123"); + + //msgpack_sbuffer_destroy(&sbuf); + + return sbuf; +} + + +static +void assert_json_equal(const json_t *json_1, const json_t *json_2) +{ + char* js_dump_1 = json_dumps(json_1, JSON_SORT_KEYS); + char* js_dump_2 = json_dumps(json_2, JSON_SORT_KEYS); + + assert_string_equal(js_dump_1, js_dump_2); + + free(js_dump_1); + free(js_dump_2); +} + +static +void json_msgpack_convert_test(void **state) { + (void)state; + + // Base JSON + json_t *json_1 = get_test_json(); + + /////////// + // TEST 1 + /////////// + // JSON to MSGPACK + msgpack_sbuffer* sbuffer = dslink_ws_json_to_msgpack(json_1); + + msgpack_zone mempool; + msgpack_zone_init(&mempool, 2048); + + msgpack_object *deserialized = malloc(sizeof(msgpack_object)); + msgpack_unpack(sbuffer->data, sbuffer->size, NULL, &mempool, deserialized); + + // MSGPACK(from json) to JSON + json_t *json_from_msg_from_json = dslink_ws_msgpack_to_json(deserialized); + + assert_json_equal(json_1, json_from_msg_from_json); + + /////////// + // TEST 2 + /////////// + msgpack_sbuffer* sbuffer2 = get_test_msgpack(); + + msgpack_zone mempool2; + msgpack_zone_init(&mempool2, 2048); + + msgpack_object *deserialized2 = malloc(sizeof(msgpack_object)); + msgpack_unpack(sbuffer2->data, sbuffer2->size, NULL, &mempool2, deserialized2); + + // MSGPACK to JSON + json_t *json_from_msg = dslink_ws_msgpack_to_json(deserialized2); + + assert_json_equal(json_1, json_from_msg); + + + json_decref(json_1); + json_decref(json_from_msg_from_json); + json_decref(json_from_msg); +} + +int main() { + const struct CMUnitTest tests[] = { + //cmocka_unit_test(utils_str_replace_all_test), + cmocka_unit_test(base64_test), + cmocka_unit_test(json_msgpack_convert_test), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +} + + From c668f5df21173e4d7316a69c2a082afb79875d33 Mon Sep 17 00:00:00 2001 From: akawamura Date: Mon, 10 Dec 2018 17:33:00 -0800 Subject: [PATCH 6/6] correct unit tests - removing references to json_binary function --- test/sdk/utils_msgpack_test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/sdk/utils_msgpack_test.c b/test/sdk/utils_msgpack_test.c index 62b2021b..6b75d2ed 100644 --- a/test/sdk/utils_msgpack_test.c +++ b/test/sdk/utils_msgpack_test.c @@ -175,12 +175,14 @@ json_t* get_test_json() } +#if 0 static void msgpack_add_bin(msgpack_packer *pk, const char* str) { msgpack_pack_bin(pk, strlen(str)); msgpack_pack_bin_body(pk, str, strlen(str)); } +#endif static void msgpack_add_str(msgpack_packer *pk, const char* str) @@ -200,7 +202,7 @@ msgpack_sbuffer* get_test_msgpack() msgpack_packer pk; msgpack_packer_init(&pk, sbuf, msgpack_sbuffer_write); - msgpack_pack_map(&pk, 12); + msgpack_pack_map(&pk, 7); msgpack_add_str(&pk, "str1"); msgpack_add_str(&pk, "Hello"); @@ -220,6 +222,7 @@ msgpack_sbuffer* get_test_msgpack() msgpack_add_str(&pk, "int1"); msgpack_pack_int64(&pk, 3); + /* json_binary function is not implemented msgpack_add_str(&pk, "binary1"); msgpack_add_bin(&pk, "BINARRYYYYY12123123123123123"); @@ -234,9 +237,10 @@ msgpack_sbuffer* get_test_msgpack() msgpack_add_str(&pk, "binary5"); msgpack_add_bin(&pk, ""); + */ msgpack_add_str(&pk, "array1"); - msgpack_pack_array(&pk, 7); + msgpack_pack_array(&pk, 6); msgpack_add_str(&pk, "Hello_2"); msgpack_add_str(&pk, "msgpack32"); @@ -244,7 +248,9 @@ msgpack_sbuffer* get_test_msgpack() msgpack_pack_nil(&pk); msgpack_pack_double(&pk, 3.221); msgpack_pack_int64(&pk, 3); + /* json_binary is not implemented msgpack_add_bin(&pk, "BINARRYYYYY12123123123123123"); + */ //msgpack_sbuffer_destroy(&sbuf);