summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <johannes.schindelin@gmx.de>2014-09-30 10:03:57 +0200
committerdscho <johannes.schindelin@gmx.de>2014-09-30 10:03:57 +0200
commitbf87073f7a971f30e41af2a140822c4774c01313 (patch)
tree947b84172cc4002a924e777b2b627ada1f5fdabb
parentfdf5f8876f5f4bd08aa3dc47268c1f4c4590c0bb (diff)
parentfd075263f91eb3816b2e4e8584172805559ff69f (diff)
downloadlibvncserver-bf87073f7a971f30e41af2a140822c4774c01313.zip
libvncserver-bf87073f7a971f30e41af2a140822c4774c01313.tar.gz
Merge pull request #33 from danielgindi/master
More MSVC adjustments, now focuses on the libvncserver
-rw-r--r--compat/msvc/sys/time.h6
-rw-r--r--libvncclient/rfbproto.c7
-rw-r--r--libvncclient/vncviewer.c4
-rw-r--r--libvncserver/httpd.c19
-rw-r--r--libvncserver/main.c2
-rw-r--r--libvncserver/rfbserver.c107
-rw-r--r--libvncserver/sockets.c19
-rw-r--r--libvncserver/stats.c4
-rw-r--r--libvncserver/tightvnc-filetransfer/filetransfermsg.c162
-rw-r--r--libvncserver/tightvnc-filetransfer/filetransfermsg.h9
-rw-r--r--libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c5
-rw-r--r--libvncserver/websockets.c5
-rw-r--r--rfb/rfb.h4
-rw-r--r--rfb/rfbclient.h4
14 files changed, 327 insertions, 30 deletions
diff --git a/compat/msvc/sys/time.h b/compat/msvc/sys/time.h
index c4964d6..0c47060 100644
--- a/compat/msvc/sys/time.h
+++ b/compat/msvc/sys/time.h
@@ -1,8 +1,10 @@
#pragma once
//http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/430449b3-f6dd-4e18-84de-eebd26a8d668
-#include < time.h >
-#include <windows.h> //I've ommited this line.
+
+#include <time.h>
+#include <winsock2.h>
+
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
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 <jpeglib.h>
#endif
+
+#ifndef _MSC_VER
+/* Strings.h is not available in MSVC */
#include <strings.h>
+#endif
+
#include <stdarg.h>
#include <time.h>
@@ -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 <winsock2.h>
#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/httpd.c b/libvncserver/httpd.c
index 792a52b..12d71a8 100644
--- a/libvncserver/httpd.c
+++ b/libvncserver/httpd.c
@@ -43,8 +43,15 @@
#include <errno.h>
#ifdef WIN32
-#include <winsock.h>
+#include <io.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
#define close closesocket
+#if defined(_MSC_VER)
+#include <BaseTsd.h> /* For the missing ssize_t */
+#define ssize_t SSIZE_T
+#define read _read /* Prevent POSIX deprecation warnings */
+#endif
#else
#ifdef LIBVNCSERVER_HAVE_SYS_TIME_H
#include <sys/time.h>
@@ -392,11 +399,13 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
getpeername(rfbScreen->httpSock, (struct sockaddr *)&addr, &addrlen);
#ifdef LIBVNCSERVER_IPv6
- char host[1024];
- if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
- rfbLogPerror("httpProcessInput: error in getnameinfo");
+ {
+ char host[1024];
+ if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
+ rfbLogPerror("httpProcessInput: error in getnameinfo");
+ }
+ rfbLog("httpd: get '%s' for %s\n", fname+1, host);
}
- rfbLog("httpd: get '%s' for %s\n", fname+1, host);
#else
rfbLog("httpd: get '%s' for %s\n", fname+1,
inet_ntoa(addr.sin_addr));
diff --git a/libvncserver/main.c b/libvncserver/main.c
index b8cdde1..9839c85 100644
--- a/libvncserver/main.c
+++ b/libvncserver/main.c
@@ -1051,7 +1051,7 @@ void rfbInitServer(rfbScreenInfoPtr screen)
#endif
rfbInitSockets(screen);
rfbHttpInitSockets(screen);
-#ifndef __MINGW32__
+#ifndef WIN32
if(screen->ignoreSIGPIPE)
signal(SIGPIPE,SIG_IGN);
#endif
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index df7d74c..ad76fbc 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -43,6 +43,9 @@
#endif
#ifdef WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <io.h>
#define write(sock,buf,len) send(sock,buf,len,0)
#else
#ifdef LIBVNCSERVER_HAVE_UNISTD_H
@@ -72,8 +75,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+
+#ifndef WIN32
/* readdir() */
#include <dirent.h>
+#endif
+
/* errno */
#include <errno.h>
/* strftime() */
@@ -83,12 +90,21 @@
#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 WIN32
#ifdef __MINGW32__
-static int compat_mkdir(const char *path, int mode)
-{
- return mkdir(path);
-}
-#define mkdir compat_mkdir
+#define mkdir(path, perms) mkdir(path) /* Omit the perms argument to match POSIX signature */
+#else /* MSVC and other windows compilers */
+#define mkdir(path, perms) _mkdir(path) /* Omit the perms argument to match POSIX signature */
+#endif /* __MINGW32__ else... */
+#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
+#include <direct.h>
#endif
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
@@ -313,12 +329,14 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
if(isUDP) {
rfbLog(" accepted UDP client\n");
- } else {
+ } else {
+#ifdef LIBVNCSERVER_IPv6
+ char host[1024];
+#endif
int one=1;
getpeername(sock, (struct sockaddr *)&addr, &addrlen);
#ifdef LIBVNCSERVER_IPv6
- char host[1024];
if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
rfbLogPerror("rfbNewClient: error in getnameinfo");
cl->host = strdup("");
@@ -1287,8 +1305,15 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
struct stat statbuf;
RFB_FIND_DATA win32filename;
int nOptLen = 0, retval=0;
+#ifdef WIN32
+ WIN32_FIND_DATAA winFindData;
+ HANDLE findHandle;
+ int pathLen, basePathLength;
+ char *basePath;
+#else
DIR *dirp=NULL;
struct dirent *direntp=NULL;
+#endif
FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, FALSE);
@@ -1297,23 +1322,67 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
if (DB) rfbLog("rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent: \"%s\"->\"%s\"\n",buffer, path);
+#ifdef WIN32
+ // Create a search string, like C:\folder\*
+
+ pathLen = strlen(path);
+ basePath = malloc(pathLen + 3);
+ memcpy(basePath, path, pathLen);
+ basePathLength = pathLen;
+ basePath[basePathLength] = '\\';
+ basePath[basePathLength + 1] = '*';
+ basePath[basePathLength + 2] = '\0';
+
+ // Start a search
+ memset(&winFindData, 0, sizeof(winFindData));
+ findHandle = FindFirstFileA(path, &winFindData);
+ free(basePath);
+
+ if (findHandle == INVALID_HANDLE_VALUE)
+#else
dirp=opendir(path);
if (dirp==NULL)
+#endif
return rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, 0, NULL);
+
/* send back the path name (necessary for links) */
if (rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, length, buffer)==FALSE) return FALSE;
+
+#ifdef WIN32
+ while (findHandle != INVALID_HANDLE_VALUE)
+#else
for (direntp=readdir(dirp); direntp!=NULL; direntp=readdir(dirp))
+#endif
{
/* get stats */
- snprintf(retfilename,sizeof(retfilename),"%s/%s", path, direntp->d_name);
+#ifdef WIN32
+ snprintf(retfilename,sizeof(retfilename),"%s/%s", path, winFindData.cFileName);
+#else
+ snprintf(retfilename,sizeof(retfilename),"%s/%s", path, direntp->d_name);
+#endif
retval = stat(retfilename, &statbuf);
if (retval==0)
{
memset((char *)&win32filename, 0, sizeof(win32filename));
+#ifdef WIN32
+ win32filename.dwFileAttributes = winFindData.dwFileAttributes;
+ win32filename.ftCreationTime.dwLowDateTime = winFindData.ftCreationTime.dwLowDateTime;
+ win32filename.ftCreationTime.dwHighDateTime = winFindData.ftCreationTime.dwHighDateTime;
+ win32filename.ftLastAccessTime.dwLowDateTime = winFindData.ftLastAccessTime.dwLowDateTime;
+ win32filename.ftLastAccessTime.dwHighDateTime = winFindData.ftLastAccessTime.dwHighDateTime;
+ win32filename.ftLastWriteTime.dwLowDateTime = winFindData.ftLastWriteTime.dwLowDateTime;
+ win32filename.ftLastWriteTime.dwHighDateTime = winFindData.ftLastWriteTime.dwHighDateTime;
+ win32filename.nFileSizeLow = winFindData.nFileSizeLow;
+ win32filename.nFileSizeHigh = winFindData.nFileSizeHigh;
+ win32filename.dwReserved0 = winFindData.dwReserved0;
+ win32filename.dwReserved1 = winFindData.dwReserved1;
+ strcpy((char *)win32filename.cFileName, winFindData.cFileName);
+ strcpy((char *)win32filename.cAlternateFileName, winFindData.cAlternateFileName);
+#else
win32filename.dwFileAttributes = Swap32IfBE(RFB_FILE_ATTRIBUTE_NORMAL);
if (S_ISDIR(statbuf.st_mode))
- win32filename.dwFileAttributes = Swap32IfBE(RFB_FILE_ATTRIBUTE_DIRECTORY);
+ win32filename.dwFileAttributes = Swap32IfBE(RFB_FILE_ATTRIBUTE_DIRECTORY);
win32filename.ftCreationTime.dwLowDateTime = Swap32IfBE(statbuf.st_ctime); /* Intel Order */
win32filename.ftCreationTime.dwHighDateTime = 0;
win32filename.ftLastAccessTime.dwLowDateTime = Swap32IfBE(statbuf.st_atime); /* Intel Order */
@@ -1328,9 +1397,10 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
/* If this had the full path, we would need to translate to DOS format ("C:\") */
/* rfbFilenameTranslate2DOS(cl, retfilename, win32filename.cFileName); */
strcpy((char *)win32filename.cFileName, direntp->d_name);
+#endif
/* Do not show hidden files (but show how to move up the tree) */
- if ((strcmp(direntp->d_name, "..")==0) || (direntp->d_name[0]!='.'))
+ if ((strcmp((char *)win32filename.cFileName, "..")==0) || (win32filename.cFileName[0]!='.'))
{
nOptLen = sizeof(RFB_FIND_DATA) - MAX_PATH - 14 + strlen((char *)win32filename.cFileName);
/*
@@ -1338,13 +1408,30 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
*/
if (rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADirectory, 0, nOptLen, (char *)&win32filename)==FALSE)
{
+#ifdef WIN32
+ FindClose(findHandle);
+#else
closedir(dirp);
+#endif
return FALSE;
}
}
}
+
+ if (FindNextFileA(findHandle, &winFindData) == 0)
+ {
+ FindClose(findHandle);
+ findHandle = INVALID_HANDLE_VALUE;
+ }
}
+#ifdef WIN32
+ if (findHandle != INVALID_HANDLE_VALUE)
+ {
+ FindClose(findHandle);
+ }
+#else
closedir(dirp);
+#endif
/* End of the transfer */
return rfbSendFileTransferMessage(cl, rfbDirPacket, 0, 0, 0, NULL);
}
diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c
index d2f814b..a7a829a 100644
--- a/libvncserver/sockets.c
+++ b/libvncserver/sockets.c
@@ -98,6 +98,8 @@ int deny_severity=LOG_WARNING;
#endif
#if defined(WIN32)
+#include <winsock2.h>
+#include <ws2tcpip.h>
#ifndef __MINGW32__
#pragma warning (disable: 4018 4761)
#endif
@@ -109,6 +111,13 @@ int deny_severity=LOG_WARNING;
#define closesocket close
#endif
+#ifdef _MSC_VER
+#define SHUT_RD 0x00
+#define SHUT_WR 0x01
+#define SHUT_RDWR 0x02
+#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 */
@@ -451,11 +460,13 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
#endif
#ifdef LIBVNCSERVER_IPv6
- char host[1024];
- if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
- rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
+ {
+ char host[1024];
+ if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
+ rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
+ }
+ rfbLog("Got connection from client %s\n", host);
}
- rfbLog("Got connection from client %s\n", host);
#else
rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
#endif
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 <rfb/rfb.h>
+#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/tightvnc-filetransfer/filetransfermsg.c b/libvncserver/tightvnc-filetransfer/filetransfermsg.c
index a0d7a5e..88fbe9a 100644
--- a/libvncserver/tightvnc-filetransfer/filetransfermsg.c
+++ b/libvncserver/tightvnc-filetransfer/filetransfermsg.c
@@ -27,8 +27,34 @@
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
+
+#ifdef WIN32
+#include <io.h>
+#include <direct.h>
+#include <sys/utime.h>
+#ifdef _MSC_VER
+#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
+#define S_IWUSR S_IWRITE
+#define S_IRUSR S_IREAD
+#define S_IWOTH 0x0000002
+#define S_IROTH 0x0000004
+#define S_IWGRP 0x0000010
+#define S_IRGRP 0x0000020
+#define mkdir(path, perms) _mkdir(path) /* Match POSIX signature */
+/* Prevent POSIX deprecation warnings on MSVC */
+#define creat _creat
+#define open _open
+#define read _read
+#define write _write
+#define close _close
+#define unlink _unlink
+#endif /* _MSC_VER */
+#else
#include <dirent.h>
#include <utime.h>
+#endif
+
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -100,17 +126,140 @@ GetFileListResponseMsg(char* path, char flags)
return fileListMsg;
}
-#ifndef __GNUC__
+#if !defined(__GNUC__) && !defined(_MSC_VER)
#define __FUNCTION__ "unknown"
#endif
+#ifdef WIN32
+
+/* Most of the Windows version here is based on https://github.com/danielgindi/FileDir */
+
+#define FILETIME_TO_TIME_T(FILETIME) (((((__int64)FILETIME.dwLowDateTime) | (((__int64)FILETIME.dwHighDateTime) << 32)) - 116444736000000000L) / 10000000L)
+
+#ifdef FILE_ATTRIBUTE_INTEGRITY_STREAM
+#define IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM))
+#else
+#define IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) 0
+#endif
+
+#ifdef FILE_ATTRIBUTE_NO_SCRUB_DATA
+#define IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA))
+#else
+#define IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) 0
+#endif
+
+#define IS_REGULAR_FILE(dwFileAttributes) \
+ ( \
+ !!(dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || \
+ ( \
+ !(dwFileAttributes & FILE_ATTRIBUTE_DEVICE) && \
+ !(dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && \
+ !(dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) && \
+ !IS_REGULAR_FILE_HAS_ATTRIBUTE_INTEGRITY_STREAM(dwFileAttributes) && \
+ !IS_REGULAR_FILE_HAS_ATTRIBUTE_NO_SCRUB_DATA(dwFileAttributes) && \
+ !(dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) && \
+ !(dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) \
+ ) \
+ )
+
+#define IS_FOLDER(dwFileAttributes) (!!(dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+
+int
+CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag)
+{
+ int pathLen, basePathLength;
+ char *basePath, *pChar;
+ WIN32_FIND_DATAA winFindData;
+ HANDLE findHandle;
+
+ if(path == NULL) {
+ return FAILURE;
+ }
+
+ if(strlen(path) == 0) {
+ /* In this case we will send the list of entries in ftp root*/
+ sprintf(path, "%s%s", GetFtpRoot(), "/");
+ }
+
+ /* Create a search string, like C:\folder\* */
+
+ pathLen = strlen(path);
+ basePath = malloc(pathLen + 3);
+ memcpy(basePath, path, pathLen);
+ basePathLength = pathLen;
+ basePath[basePathLength] = '\\';
+ basePath[basePathLength + 1] = '*';
+ basePath[basePathLength + 2] = '\0';
+
+ /* Start a search */
+ memset(&winFindData, 0, sizeof(winFindData));
+ findHandle = FindFirstFileA(path, &winFindData);
+
+ basePath[basePathLength] = '\0'; /* Restore to a basePath + \ */
+ /* Convert \ to / */
+ for(pChar = basePath; *pChar; pChar++) {
+ if (*pChar == '\\') {
+ *pChar = '/';
+ }
+ }
+
+ /* While we can find a next file do...
+ But ignore \. and '.. entries, which are current folder and parent folder respectively */
+ while(findHandle != INVALID_HANDLE_VALUE && winFindData.cFileName[0] == '.' &&
+ (winFindData.cFileName[1] == '\0' ||
+ (winFindData.cFileName[1] == '.' && winFindData.cFileName[2] == '\0'))) {
+ char fullpath[PATH_MAX];
+ fullpath[0] = 0;
+
+ strncpy_s(fullpath, PATH_MAX, basePath, basePathLength);
+ strncpy_s(fullpath + basePathLength, PATH_MAX - basePathLength, winFindData.cFileName, (int)strlen(winFindData.cFileName));
+
+ if(IS_FOLDER(winFindData.dwFileAttributes)) {
+ if (AddFileListItemInfo(pFileListInfo, winFindData.cFileName, -1, 0) == 0) {
+ rfbLog("File [%s]: Method [%s]: Add directory %s in the"
+ " list failed\n", __FILE__, __FUNCTION__, fullpath);
+ continue;
+ }
+ }
+ else if(IS_REGULAR_FILE(winFindData.dwFileAttributes)) {
+ if(flag) {
+ unsigned int fileSize = (winFindData.nFileSizeHigh * (MAXDWORD+1)) + winFindData.nFileSizeLow;
+ if(AddFileListItemInfo(pFileListInfo, winFindData.cFileName, fileSize, FILETIME_TO_TIME_T(winFindData.ftLastWriteTime)) == 0) {
+ rfbLog("File [%s]: Method [%s]: Add file %s in the "
+ "list failed\n", __FILE__, __FUNCTION__, fullpath);
+ continue;
+ }
+ }
+ }
+
+ if(FindNextFileA(findHandle, &winFindData) == 0) {
+ FindClose(findHandle);
+ findHandle = INVALID_HANDLE_VALUE;
+ }
+ }
+
+ if(findHandle != INVALID_HANDLE_VALUE) {
+ FindClose(findHandle);
+ }
+
+ free(basePath);
+
+ return SUCCESS;
+}
+
+#else /* WIN32 */
+
int
CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag)
{
DIR* pDir = NULL;
struct dirent* pDirent = NULL;
-
- if((path == NULL) || (strlen(path) == 0)) {
+
+ if(path == NULL) {
+ return FAILURE;
+ }
+
+ if(strlen(path) == 0) {
/* In this case we will send the list of entries in ftp root*/
sprintf(path, "%s%s", GetFtpRoot(), "/");
}
@@ -170,6 +319,8 @@ CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag)
return SUCCESS;
}
+#endif
+
FileTransferMsg
CreateFileListErrMsg(char flags)
@@ -623,6 +774,10 @@ CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp)
* Method to handle create directory request.
******************************************************************************/
+#ifdef _MSC_VER
+#undef CreateDirectory /* Prevent macro clashes under Windows */
+#endif /* _MSC_VER */
+
void
CreateDirectory(char* dirName)
{
@@ -633,4 +788,3 @@ CreateDirectory(char* dirName)
__FILE__, __FUNCTION__, dirName);
}
}
-
diff --git a/libvncserver/tightvnc-filetransfer/filetransfermsg.h b/libvncserver/tightvnc-filetransfer/filetransfermsg.h
index 30e58df..3b27bd0 100644
--- a/libvncserver/tightvnc-filetransfer/filetransfermsg.h
+++ b/libvncserver/tightvnc-filetransfer/filetransfermsg.h
@@ -26,6 +26,11 @@
#ifndef FILE_TRANSFER_MSG_H
#define FILE_TRANSFER_MSG_H
+#ifdef _MSC_VER
+#pragma push_macro("CreateDirectory")
+#undef CreateDirectory /* Prevent macro clashes under Windows */
+#endif /* _MSC_VER */
+
typedef struct _FileTransferMsg {
char* data;
unsigned int length;
@@ -50,5 +55,9 @@ void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr data);
void FreeFileTransferMsg(FileTransferMsg ftm);
+#ifdef _MSC_VER
+# pragma pop_macro("CreateDirectory") /* Restore original macro */
+#endif /* _MSC_VER */
+
#endif
diff --git a/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c b/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
index 2bd5ba1..5517c85 100644
--- a/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
+++ b/libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
@@ -22,13 +22,18 @@
* Date : 14th July 2005
*/
+#ifndef _MSC_VER
#include <pwd.h>
+#endif /* _MSC_VER
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef _MSC_VER
#include <dirent.h>
#include <pthread.h>
+#endif /* _MSC_VER
#include <sys/stat.h>
#include <sys/types.h>
#include <limits.h>
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 <rfb/rfb.h>
-#include <resolv.h> /* __b64_ntop */
/* errno */
#include <errno.h>
+#ifndef _MSC_VER
+#include <resolv.h> /* __b64_ntop */
+#endif
+
#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
#include <endian.h>
#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
diff --git a/rfb/rfb.h b/rfb/rfb.h
index 16b6b66..f7919c6 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -52,7 +52,7 @@ extern "C"
#include <sys/types.h>
#endif
-#ifdef __MINGW32__
+#ifdef WIN32
#undef SOCKET
#include <winsock2.h>
#ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
@@ -267,7 +267,7 @@ typedef struct _rfbScreenInfo
SOCKET listenSock;
int maxSock;
int maxFd;
-#ifdef __MINGW32__
+#ifdef WIN32
struct fd_set allFds;
#else
fd_set allFds;
diff --git a/rfb/rfbclient.h b/rfb/rfbclient.h
index 9ac3c37..aedb4f4 100644
--- a/rfb/rfbclient.h
+++ b/rfb/rfbclient.h
@@ -31,6 +31,10 @@
* @file rfbclient.h
*/
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN /* Prevent loading any Winsock 1.x headers from windows.h */
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
OpenPOWER on IntegriCloud