building release type

This commit is contained in:
Dominik Kuhn 2024-08-23 10:24:25 +02:00
parent 328f4ec329
commit 220949d94d
4 changed files with 49 additions and 46 deletions

View File

@ -1,10 +1,10 @@
{
"configurations": [
{
"name": "x64-Debug",
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "clang_cl_x64" ],
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
@ -53,6 +53,11 @@
},
{
"name": "WITH_STATIC_LIBRARIES",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_LIB_CPP",
"value": "False",
"type": "BOOL"
}

View File

@ -18,37 +18,37 @@
if (CJSON_FOUND )
add_definitions("-DWITH_CJSON")
set( CLIENT_INC ${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${mosquitto_SOURCE_DIR}/deps
${mosquitto_SOURCE_DIR}/src ${CJSON_INCLUDE_DIRS} )
set (MOSQUITTO_IDIR "" CACHE FILEPATH "C:/Program Files/mosquitto/devel/" )
set (MOSQUITTO_LIBRARIES "" CACHE FILEPATH "C:/Program Files/mosquitto/devel/")
set (PLUGIN_NAME wamo)
set( CLIENT_DIR ${mosquitto_BINARY_DIR}/lib ${CJSON_DIR})
include_directories(${CLIENT_INC})
link_directories(${CLIENT_DIR} ${mosquitto_SOURCE_DIR})
add_library(wamo MODULE
add_library(${PLUGIN_NAME} MODULE
${PLUGIN_NAME}.c
json_help.c
json_help.h
wamo.c)
set_target_properties(wamo PROPERTIES
)
target_include_directories(${PLUGIN_NAME} PRIVATE
"${CJSON_INCLUDE_DIRS}"
"${STDBOOL_H_PATH} ${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"C:/Program Files/mosquitto/devel/"
)
target_link_directories(${PLUGIN_NAME} PRIVATE ${MOSQUITTO_LIBRARIES} )
set_target_properties(${PLUGIN_NAME} PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1
)
set_target_properties(wamo PROPERTIES PREFIX "")
set_target_properties(wamo PROPERTIES IMPORTED_IMPLIB ${CJSON_LIBRARIES})
target_link_libraries(wamo ${CJSON_LIBRARIES})
set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "")
set_target_properties(${PLUGIN_NAME} PROPERTIES IMPORTED_IMPLIB ${CJSON_LIBRARIES})
target_link_libraries(${PLUGIN_NAME} PRIVATE ${CJSON_LIBRARIES})
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set_target_properties(wamo PROPERTIES IMPORTED_IMPLIB mosquitto)
target_link_libraries(wamo mosquitto)
install(TARGETS wamo
DESTINATION "${CMAKE_INSTALL_BINDIR}")
else()
install(TARGETS wamo
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto)
endif()
endif()
endif()

View File

@ -71,22 +71,23 @@ int json_del_id_from_array(cJSON* json, const char* name, const char* id)
jtmp = cJSON_GetObjectItem(json, name);
if (jtmp) {
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 1");
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 1");
if (cJSON_IsArray(jtmp) == true) {
// cJSON_DeleteItemFromObject(json, name);
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 2");
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 2");
cJSON_ArrayForEach(tid, jtmp)
{
if ( strcmp( cJSON_GetStringValue(tid),id) == 0)
{
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 3");
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 3");
detached_item = cJSON_DetachItemFromArray(jtmp, array_index);
}
else
{
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 4");
return MOSQ_ERR_INVAL;
// mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: deleting item from array .. debug 4");
}
array_index++;
}

View File

@ -51,9 +51,7 @@ static cJSON* subscribedTopics = NULL;
static int callback_control(int event, void* event_data, void* userdata)
{
struct mosquitto_evt_acl_check* ed = event_data;
char* payload = NULL;
uint32_t payload_len;
UNUSED(event);
UNUSED(userdata);
@ -67,38 +65,37 @@ static int callback_control(int event, void* event_data, void* userdata)
json_create_array(subscribedTopics, topic);
json_add_id_to_array(subscribedTopics, topic, client_id);
char* json_string = cJSON_Print(subscribedTopics);
payload = cJSON_PrintUnformatted(subscribedTopics);
char* payload = cJSON_PrintUnformatted(subscribedTopics);
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s subscribed to topic %s", client_id, topic);
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
payload_len = strlen(payload);
uint32_t payload_len = strlen(payload);
if (payload_len > MQTT_MAX_PAYLOAD) {
free(payload);
return MOSQ_ERR_PAYLOAD_SIZE;
}
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: DEBUG MESSAGE BEFORE PUBLISHING ...");
mosquitto_broker_publish(NULL, "mqtt/subscriptions",
(int)payload_len, payload, 0, true, NULL);
mosquitto_broker_publish_copy(NULL, "mqtt/subscriptions",
(int)payload_len, payload, 0, 0, NULL);
}
else if (access == MOSQ_ACL_UNSUBSCRIBE) {
json_del_id_from_array(subscribedTopics, topic, client_id);
char* json_string = cJSON_Print(subscribedTopics);
payload = cJSON_PrintUnformatted(subscribedTopics);
char* payload = cJSON_PrintUnformatted(subscribedTopics);
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: client with id %s unscribed to topic %s", client_id, topic);
mosquitto_log_printf(MOSQ_LOG_INFO, "wamo: subscribed topics %s", json_string);
if (payload == NULL) return MOSQ_ERR_MALFORMED_PACKET;
payload_len = strlen(payload);
uint32_t payload_len = strlen(payload);
if (payload_len > MQTT_MAX_PAYLOAD) {
free(payload);
return MOSQ_ERR_PAYLOAD_SIZE;
}
mosquitto_broker_publish(NULL, "mqtt/subscriptions",
(int)payload_len, payload, 0, true, NULL);
mosquitto_broker_publish_copy(NULL, "mqtt/subscriptions",
(int)payload_len, payload, 0, 0, NULL);
}