From ff2636b3ae6ecd00e13c0a38394c626c97c50117 Mon Sep 17 00:00:00 2001 From: Roger Light Date: Wed, 30 Sep 2020 09:44:36 +0100 Subject: [PATCH] Build fix for Windows. --- client/sub_client_output.c | 17 ++++++++++++++++- src/mosquitto_broker_internal.h | 4 ---- src/mosquitto_passwd.c | 3 ++- src/mux_poll.c | 4 ++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/client/sub_client_output.c b/client/sub_client_output.c index 546ea0fb..b039a115 100644 --- a/client/sub_client_output.c +++ b/client/sub_client_output.c @@ -16,6 +16,11 @@ Contributors: #include "config.h" +#ifdef WIN32 + /* For rand_s on Windows */ +# define _CRT_RAND_S +#endif + #include #include #include @@ -737,21 +742,31 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit void rand_init(void) { +#ifndef WIN32 struct tm *ti = NULL; long ns; if(!get_time(&ti, &ns)){ srandom(ns); } +#endif } void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties) { - long r; +#ifdef WIN32 + unsigned int r = 0; +#else + long r = 0; +#endif if(cfg->random_filter < 10000){ +#ifdef WIN32 + rand_s(&r); +#else r = random(); +#endif if((r%10000) >= cfg->random_filter){ return; } diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index f2dbd1f9..1a6e1874 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -44,10 +44,6 @@ Contributors: # endif #endif -#ifdef WITH_BRIDGE -#include -#endif - #include "mosquitto_internal.h" #include "mosquitto_broker.h" #include "mosquitto_plugin.h" diff --git a/src/mosquitto_passwd.c b/src/mosquitto_passwd.c index 28f0853b..845c44f8 100644 --- a/src/mosquitto_passwd.c +++ b/src/mosquitto_passwd.c @@ -66,6 +66,8 @@ struct cb_helper { bool found; }; +static enum pwhash hashtype = pw_sha512_pbkdf2; + #ifdef WIN32 static FILE *mpw_tmpfile(void) { @@ -74,7 +76,6 @@ static FILE *mpw_tmpfile(void) #else static char alphanum[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; -static enum pwhash hashtype = pw_sha512_pbkdf2; static unsigned char tmpfile_path[36]; static FILE *mpw_tmpfile(void) diff --git a/src/mux_poll.c b/src/mux_poll.c index da1ee6ba..25b61bed 100644 --- a/src/mux_poll.c +++ b/src/mux_poll.c @@ -59,7 +59,9 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol static struct pollfd *pollfds = NULL; static int pollfd_max; +#ifndef WIN32 static sigset_t my_sigblock; +#endif int mux_poll__init(struct mosquitto_db *db, mosq_sock_t *listensock, int listensock_count) { @@ -173,7 +175,9 @@ int mux_poll__handle(struct mosquitto_db *db, mosq_sock_t *listensock, int liste mosq_sock_t sock; int i; int fdcount; +#ifndef WIN32 sigset_t origsig; +#endif #ifndef WIN32 sigprocmask(SIG_SETMASK, &my_sigblock, &origsig);