Build fix for Windows.

This commit is contained in:
Roger Light 2020-09-30 09:44:36 +01:00
parent e8a641c759
commit ff2636b3ae
4 changed files with 22 additions and 6 deletions

View File

@ -16,6 +16,11 @@ Contributors:
#include "config.h"
#ifdef WIN32
/* For rand_s on Windows */
# define _CRT_RAND_S
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h>
@ -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;
}

View File

@ -44,10 +44,6 @@ Contributors:
# endif
#endif
#ifdef WITH_BRIDGE
#include <poll.h>
#endif
#include "mosquitto_internal.h"
#include "mosquitto_broker.h"
#include "mosquitto_plugin.h"

View File

@ -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)

View File

@ -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);