mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-06 02:52:07 +08:00
Various Windows build fixes.
This commit is contained in:
@@ -15,6 +15,8 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0
|
||||
Contributors:
|
||||
Roger Light - initial implementation and documentation.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <cJSON.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -15,6 +15,8 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0
|
||||
Contributors:
|
||||
Roger Light - initial implementation and documentation.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <cJSON.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -461,6 +461,7 @@ static char *get_default_cfg_location(void)
|
||||
char *env;
|
||||
#else
|
||||
char env[1024];
|
||||
int rc;
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
@@ -331,7 +331,7 @@ static int json_print(const struct mosquitto_message *message, const mosquitto_p
|
||||
return_parse_end = NULL;
|
||||
if(message->payload){
|
||||
tmp = cJSON_ParseWithOpts(message->payload, &return_parse_end, true);
|
||||
if(tmp == NULL || return_parse_end != message->payload + message->payloadlen){
|
||||
if(tmp == NULL || return_parse_end != (uint8_t *)message->payload + message->payloadlen){
|
||||
cJSON_Delete(root);
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,23 @@ Contributors:
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(WITH_BROKER) && !defined(LIBMOSQUITTO_STATIC)
|
||||
# ifdef libmosquitto_EXPORTS
|
||||
# define libmosq_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define libmosq_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
#ifdef WIN32
|
||||
# ifdef mosquitto_EXPORTS
|
||||
# define libmosq_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# ifndef LIBMOSQUITTO_STATIC
|
||||
# ifdef libmosquitto_EXPORTS
|
||||
# define libmosq_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define libmosq_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define libmosq_EXPORT
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define libmosq_EXPORT
|
||||
# define libmosq_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
@@ -58,6 +58,10 @@ struct mosquitto_acl_msg {
|
||||
bool retain;
|
||||
};
|
||||
|
||||
#ifdef WIN32
|
||||
# define mosq_plugin_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* To create an authentication plugin you must include this file then implement
|
||||
* the functions listed in the "Plugin Functions" section below. The resulting
|
||||
@@ -129,7 +133,7 @@ struct mosquitto_acl_msg {
|
||||
* If the broker does not support the version that you require, return -1 to
|
||||
* indicate failure.
|
||||
*/
|
||||
int mosquitto_plugin_version(int supported_version_count, const int *supported_versions);
|
||||
mosq_plugin_EXPORT int mosquitto_plugin_version(int supported_version_count, const int *supported_versions);
|
||||
|
||||
/*
|
||||
* Function: mosquitto_auth_plugin_init
|
||||
@@ -152,7 +156,7 @@ int mosquitto_plugin_version(int supported_version_count, const int *supported_v
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **userdata, struct mosquitto_opt *options, int option_count);
|
||||
mosq_plugin_EXPORT int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **userdata, struct mosquitto_opt *options, int option_count);
|
||||
|
||||
|
||||
/*
|
||||
@@ -172,7 +176,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **userdata, st
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int option_count);
|
||||
mosq_plugin_EXPORT int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int option_count);
|
||||
|
||||
|
||||
|
||||
@@ -195,7 +199,7 @@ int mosquitto_plugin_cleanup(void *userdata, struct mosquitto_opt *options, int
|
||||
* check it is a supported plugin version. Your code must simply return
|
||||
* the version of the plugin interface you support, i.e. 4.
|
||||
*/
|
||||
int mosquitto_auth_plugin_version(void);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_plugin_version(void);
|
||||
|
||||
|
||||
/*
|
||||
@@ -217,7 +221,7 @@ int mosquitto_auth_plugin_version(void);
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *opts, int opt_count);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *opts, int opt_count);
|
||||
|
||||
|
||||
/*
|
||||
@@ -239,7 +243,7 @@ int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *opts, int
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count);
|
||||
|
||||
|
||||
/*
|
||||
@@ -267,7 +271,7 @@ int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, i
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
|
||||
|
||||
|
||||
/*
|
||||
@@ -295,7 +299,7 @@ int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *opts, in
|
||||
* Return 0 on success
|
||||
* Return >0 on failure.
|
||||
*/
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
|
||||
|
||||
|
||||
/*
|
||||
@@ -322,7 +326,7 @@ int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *opts,
|
||||
* MOSQ_ERR_UNKNOWN for an application specific error.
|
||||
* MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
|
||||
*/
|
||||
int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg);
|
||||
|
||||
|
||||
/*
|
||||
@@ -339,7 +343,7 @@ int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *clie
|
||||
* MOSQ_ERR_UNKNOWN for an application specific error.
|
||||
* MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
|
||||
*/
|
||||
int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password);
|
||||
|
||||
|
||||
/*
|
||||
@@ -367,7 +371,7 @@ int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const
|
||||
* Return >0 on failure.
|
||||
* Return MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
|
||||
*/
|
||||
int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len);
|
||||
|
||||
/*
|
||||
* Function: mosquitto_auth_start
|
||||
@@ -394,9 +398,9 @@ int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const
|
||||
* Return MOSQ_ERR_AUTH if authentication was valid but did not succeed.
|
||||
* Return any other relevant positive integer MOSQ_ERR_* to produce an error.
|
||||
*/
|
||||
int mosquitto_auth_start(void *user_data, struct mosquitto *client, const char *method, bool reauth, const void *data_in, uint16_t data_in_len, void **data_out, uint16_t *data_out_len);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_start(void *user_data, struct mosquitto *client, const char *method, bool reauth, const void *data_in, uint16_t data_in_len, void **data_out, uint16_t *data_out_len);
|
||||
|
||||
int mosquitto_auth_continue(void *user_data, struct mosquitto *client, const char *method, const void *data_in, uint16_t data_in_len, void **data_out, uint16_t *data_out_len);
|
||||
mosq_plugin_EXPORT int mosquitto_auth_continue(void *user_data, struct mosquitto *client, const char *method, const void *data_in, uint16_t data_in_len, void **data_out, uint16_t *data_out_len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
add_subdirectory(dynamic-security)
|
||||
add_subdirectory(message-timestamp)
|
||||
if(NOT WIN32)
|
||||
add_subdirectory(message-timestamp)
|
||||
endif(NOT WIN32)
|
||||
add_subdirectory(payload-modification)
|
||||
|
||||
@@ -10,7 +10,7 @@ if (CJSON_FOUND AND WITH_TLS)
|
||||
set( CLIENT_DIR ${mosquitto_BINARY_DIR}/lib ${CJSON_DIR})
|
||||
|
||||
include_directories(${CLIENT_INC})
|
||||
link_directories(${CLIENT_DIR})
|
||||
link_directories(${CLIENT_DIR} ${mosquitto_SOURCE_DIR})
|
||||
|
||||
add_library(mosquitto_dynamic_security SHARED
|
||||
acl.c
|
||||
@@ -33,6 +33,9 @@ if (CJSON_FOUND AND WITH_TLS)
|
||||
set_target_properties(mosquitto_dynamic_security PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(mosquitto_dynamic_security ${CJSON_LIBRARIES})
|
||||
if(WIN32)
|
||||
target_link_libraries(mosquitto_dynamic_security mosquitto)
|
||||
endif(WIN32)
|
||||
|
||||
install(TARGETS mosquitto_dynamic_security RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
|
||||
${STDBOOL_H_PATH} ${STDINT_H_PATH})
|
||||
link_directories(${mosquitto_SOURCE_DIR})
|
||||
|
||||
add_library(mosquitto_payload_modification SHARED mosquitto_payload_modification.c)
|
||||
set_target_properties(mosquitto_payload_modification PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE 1
|
||||
)
|
||||
set_target_properties(mosquitto_payload_modification PROPERTIES PREFIX "")
|
||||
if(WIN32)
|
||||
target_link_libraries(mosquitto_payload_modification mosquitto)
|
||||
endif(WIN32)
|
||||
|
||||
install(TARGETS mosquitto_payload_modification RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
@@ -363,7 +363,11 @@ void log__internal(const char *fmt, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
log__printf(NULL, MOSQ_LOG_INTERNAL, "%s", buf);
|
||||
#else
|
||||
log__printf(NULL, MOSQ_LOG_INTERNAL, "%s%s%s", "\e[32m", buf, "\e[0m");
|
||||
#endif
|
||||
}
|
||||
|
||||
int mosquitto_log_vprintf(int level, const char *fmt, va_list va)
|
||||
|
||||
@@ -16,6 +16,7 @@ Contributors:
|
||||
Roger Light - initial implementation and documentation.
|
||||
*/
|
||||
|
||||
#include "mosquitto_broker.h"
|
||||
#include "memory_mosq.h"
|
||||
|
||||
void *mosquitto_calloc(size_t nmemb, size_t size)
|
||||
|
||||
@@ -279,7 +279,7 @@ static unsigned int psk_server_callback(SSL *ssl, const char *identity, unsigned
|
||||
|
||||
/* The hex to BN conversion results in the length halving, so we can pass
|
||||
* max_psk_len*2 as the max hex key here. */
|
||||
psk_key = mosquitto__calloc(1, max_psk_len*2 + 1);
|
||||
psk_key = mosquitto__calloc(1, (size_t)max_psk_len*2 + 1);
|
||||
if(!psk_key) return 0;
|
||||
|
||||
if(mosquitto_psk_key_get(context, psk_hint, identity, psk_key, (int)max_psk_len*2) != MOSQ_ERR_SUCCESS){
|
||||
|
||||
@@ -62,10 +62,10 @@ int retain__init(void)
|
||||
{
|
||||
struct mosquitto__retainhier *retainhier;
|
||||
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "", strlen(""));
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "", (int)strlen(""));
|
||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", strlen("$SYS"));
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", (int)strlen("$SYS"));
|
||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
|
||||
@@ -16,9 +16,16 @@ Contributors:
|
||||
Roger Light - initial implementation and documentation.
|
||||
Dmitry Kaukov - windows named events implementation.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user