Fix building with Visual Studio 2008
This older Microsoft compiler does not support mixing declarations and code and misses some error defines. This commit enables building with VS2008 by moving up some variable declarations and defining error codes to their WinSock counterparts in case they're not defined. Signed-off-by: Christian Beier <info@christianbeier.net>
This commit is contained in:
parent
d3dd89da82
commit
fe10226cc9
@ -756,8 +756,9 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
|
||||
|
||||
tmp = strchr(url, '@');
|
||||
if(tmp) {
|
||||
char *colon;
|
||||
*tmp++ = 0;
|
||||
char *colon = strchr(url, ':');
|
||||
colon = strchr(url, ':');
|
||||
if(colon) {
|
||||
*colon = 0;
|
||||
cfg->password = strdup(colon + 1);
|
||||
|
9
config.h
9
config.h
@ -33,6 +33,15 @@
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define snprintf sprintf_s
|
||||
# define EPROTO ECONNABORTED
|
||||
# ifndef ECONNABORTED
|
||||
# define ECONNABORTED WSAECONNABORTED
|
||||
# endif
|
||||
# ifndef ENOTCONN
|
||||
# define ENOTCONN WSAENOTCONN
|
||||
# endif
|
||||
# ifndef ECONNREFUSED
|
||||
# define ECONNREFUSED WSAECONNREFUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -49,7 +49,7 @@ extern "C" {
|
||||
# define libmosq_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900 && !defined(bool)
|
||||
# ifndef __cplusplus
|
||||
# define bool char
|
||||
# define true 1
|
||||
|
@ -57,6 +57,8 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
DWORD ulen = UNLEN;
|
||||
SECURITY_DESCRIPTOR sd;
|
||||
DWORD dwCreationDisposition;
|
||||
int fd;
|
||||
FILE *fptr;
|
||||
|
||||
switch(mode[0]){
|
||||
case 'a':
|
||||
@ -97,12 +99,12 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
||||
|
||||
LocalFree(pacl);
|
||||
|
||||
int fd = _open_osfhandle((intptr_t)hfile, 0);
|
||||
fd = _open_osfhandle((intptr_t)hfile, 0);
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FILE *fptr = _fdopen(fd, mode);
|
||||
fptr = _fdopen(fd, mode);
|
||||
if (!fptr) {
|
||||
_close(fd);
|
||||
return NULL;
|
||||
|
@ -36,6 +36,9 @@ typedef SSIZE_T ssize_t;
|
||||
# define COMPAT_ECONNRESET WSAECONNRESET
|
||||
# define COMPAT_EINTR WSAEINTR
|
||||
# define COMPAT_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
# ifndef EINPROGRESS
|
||||
# define EINPROGRESS WSAEINPROGRESS
|
||||
# endif
|
||||
#else
|
||||
# define COMPAT_CLOSE(a) close(a)
|
||||
# define COMPAT_ECONNRESET ECONNRESET
|
||||
|
@ -24,7 +24,9 @@ Contributors:
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#if !(defined(_MSC_VER) && _MSC_VER <= 1500)
|
||||
# define _WIN32_WINNT _WIN32_WINNT_VISTA
|
||||
#endif
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <unistd.h>
|
||||
|
@ -2028,15 +2028,16 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
|
||||
#endif
|
||||
}else if(!strcmp(token, "topic")){
|
||||
#ifdef WITH_BRIDGE
|
||||
char *topic = NULL;
|
||||
enum mosquitto__bridge_direction direction = bd_out;
|
||||
uint8_t qos = 0;
|
||||
char *local_prefix = NULL, *remote_prefix = NULL;
|
||||
|
||||
if(reload) continue; /* FIXME */
|
||||
if(!cur_bridge){
|
||||
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
char *topic = NULL;
|
||||
enum mosquitto__bridge_direction direction = bd_out;
|
||||
uint8_t qos = 0;
|
||||
char *local_prefix = NULL, *remote_prefix = NULL;
|
||||
|
||||
token = strtok_r(NULL, " ", &saveptr);
|
||||
if(token){
|
||||
|
Loading…
Reference in New Issue
Block a user