From fbf48c65f343c2d3cce8ccd69975e9526f209fc5 Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Sat, 20 Sep 2014 16:39:16 +0300 Subject: `strings.h` and `resolv.h` are not available on MSVC, and some POSIX functions are renamed or deprecated For all of those missing/deprecated POSIX functions, we just add a macro mapping to the _underscored version of MSVC. --- libvncclient/rfbproto.c | 7 ++++++- libvncclient/vncviewer.c | 4 ++++ libvncserver/rfbserver.c | 7 +++++++ libvncserver/sockets.c | 4 ++++ libvncserver/stats.c | 4 ++++ libvncserver/websockets.c | 5 ++++- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c index 0afa3dc..5893a24 100644 --- a/libvncclient/rfbproto.c +++ b/libvncclient/rfbproto.c @@ -53,7 +53,12 @@ #endif #include #endif + +#ifndef _MSC_VER +/* Strings.h is not available in MSVC */ #include +#endif + #include #include @@ -65,7 +70,7 @@ #include "tls.h" #ifdef _MSC_VER -# define snprintf _snprintf +# define snprintf _snprintf /* MSVC went straight to the underscored syntax */ #endif /* diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c index 9d657ed..b12116c 100644 --- a/libvncclient/vncviewer.c +++ b/libvncclient/vncviewer.c @@ -26,6 +26,10 @@ #include #endif +#ifdef _MSC_VER +#define strdup _strdup /* Prevent POSIX deprecation warnings */ +#endif + #ifdef __STRICT_ANSI__ #define _BSD_SOURCE #define _POSIX_SOURCE diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index df7d74c..4056318 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -83,6 +83,13 @@ #include "rfbssl.h" #endif +#ifdef _MSC_VER +#define snprintf _snprintf /* Missing in MSVC */ +/* Prevent POSIX deprecation warnings */ +#define close _close +#define strdup _strdup +#endif + #ifdef __MINGW32__ static int compat_mkdir(const char *path, int mode) { diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c index d2f814b..6c225e9 100644 --- a/libvncserver/sockets.c +++ b/libvncserver/sockets.c @@ -109,6 +109,10 @@ int deny_severity=LOG_WARNING; #define closesocket close #endif +#ifdef _MSC_VER +#define snprintf _snprintf /* Missing in MSVC */ +#endif + int rfbMaxClientWait = 20000; /* time (ms) after which we decide client has gone away - needed to stop us hanging */ diff --git a/libvncserver/stats.c b/libvncserver/stats.c index 39de1c6..b99da01 100644 --- a/libvncserver/stats.c +++ b/libvncserver/stats.c @@ -26,6 +26,10 @@ #include +#ifdef _MSC_VER +#define snprintf _snprintf /* Missing in MSVC */ +#endif + char *messageNameServer2Client(uint32_t type, char *buf, int len); char *messageNameClient2Server(uint32_t type, char *buf, int len); char *encodingName(uint32_t enc, char *buf, int len); diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c index bd5d9d0..34f04d7 100644 --- a/libvncserver/websockets.c +++ b/libvncserver/websockets.c @@ -31,10 +31,13 @@ #endif #include -#include /* __b64_ntop */ /* errno */ #include +#ifndef _MSC_VER +#include /* __b64_ntop */ +#endif + #ifdef LIBVNCSERVER_HAVE_ENDIAN_H #include #elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H -- cgit v1.1