Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
bf87073f
Commit
bf87073f
authored
Sep 30, 2014
by
dscho
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33 from danielgindi/master
More MSVC adjustments, now focuses on the libvncserver
parents
fdf5f887
fd075263
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
327 additions
and
30 deletions
+327
-30
time.h
compat/msvc/sys/time.h
+4
-2
rfbproto.c
libvncclient/rfbproto.c
+6
-1
vncviewer.c
libvncclient/vncviewer.c
+4
-0
httpd.c
libvncserver/httpd.c
+14
-5
main.c
libvncserver/main.c
+1
-1
rfbserver.c
libvncserver/rfbserver.c
+97
-10
sockets.c
libvncserver/sockets.c
+15
-4
stats.c
libvncserver/stats.c
+4
-0
filetransfermsg.c
libvncserver/tightvnc-filetransfer/filetransfermsg.c
+158
-4
filetransfermsg.h
libvncserver/tightvnc-filetransfer/filetransfermsg.h
+9
-0
handlefiletransferrequest.c
...cserver/tightvnc-filetransfer/handlefiletransferrequest.c
+5
-0
websockets.c
libvncserver/websockets.c
+4
-1
rfb.h
rfb/rfb.h
+2
-2
rfbclient.h
rfb/rfbclient.h
+4
-0
No files found.
compat/msvc/sys/time.h
View file @
bf87073f
#pragma once
#pragma once
//http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/430449b3-f6dd-4e18-84de-eebd26a8d668
//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)
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#else
...
...
libvncclient/rfbproto.c
View file @
bf87073f
...
@@ -53,7 +53,12 @@
...
@@ -53,7 +53,12 @@
#endif
#endif
#include <jpeglib.h>
#include <jpeglib.h>
#endif
#endif
#ifndef _MSC_VER
/* Strings.h is not available in MSVC */
#include <strings.h>
#include <strings.h>
#endif
#include <stdarg.h>
#include <stdarg.h>
#include <time.h>
#include <time.h>
...
@@ -65,7 +70,7 @@
...
@@ -65,7 +70,7 @@
#include "tls.h"
#include "tls.h"
#ifdef _MSC_VER
#ifdef _MSC_VER
# define snprintf _snprintf
# define snprintf _snprintf
/* MSVC went straight to the underscored syntax */
#endif
#endif
/*
/*
...
...
libvncclient/vncviewer.c
View file @
bf87073f
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
#include <winsock2.h>
#include <winsock2.h>
#endif
#endif
#ifdef _MSC_VER
#define strdup _strdup
/* Prevent POSIX deprecation warnings */
#endif
#ifdef __STRICT_ANSI__
#ifdef __STRICT_ANSI__
#define _BSD_SOURCE
#define _BSD_SOURCE
#define _POSIX_SOURCE
#define _POSIX_SOURCE
...
...
libvncserver/httpd.c
View file @
bf87073f
...
@@ -43,8 +43,15 @@
...
@@ -43,8 +43,15 @@
#include <errno.h>
#include <errno.h>
#ifdef WIN32
#ifdef WIN32
#include <winsock.h>
#include <io.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define close closesocket
#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
#else
#ifdef LIBVNCSERVER_HAVE_SYS_TIME_H
#ifdef LIBVNCSERVER_HAVE_SYS_TIME_H
#include <sys/time.h>
#include <sys/time.h>
...
@@ -392,11 +399,13 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
...
@@ -392,11 +399,13 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
getpeername
(
rfbScreen
->
httpSock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
getpeername
(
rfbScreen
->
httpSock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
#ifdef LIBVNCSERVER_IPv6
#ifdef LIBVNCSERVER_IPv6
{
char
host
[
1024
];
char
host
[
1024
];
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
rfbLogPerror
(
"httpProcessInput: error in getnameinfo"
);
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
#else
rfbLog
(
"httpd: get '%s' for %s
\n
"
,
fname
+
1
,
rfbLog
(
"httpd: get '%s' for %s
\n
"
,
fname
+
1
,
inet_ntoa
(
addr
.
sin_addr
));
inet_ntoa
(
addr
.
sin_addr
));
...
...
libvncserver/main.c
View file @
bf87073f
...
@@ -1051,7 +1051,7 @@ void rfbInitServer(rfbScreenInfoPtr screen)
...
@@ -1051,7 +1051,7 @@ void rfbInitServer(rfbScreenInfoPtr screen)
#endif
#endif
rfbInitSockets
(
screen
);
rfbInitSockets
(
screen
);
rfbHttpInitSockets
(
screen
);
rfbHttpInitSockets
(
screen
);
#ifndef
__MINGW32__
#ifndef
WIN32
if
(
screen
->
ignoreSIGPIPE
)
if
(
screen
->
ignoreSIGPIPE
)
signal
(
SIGPIPE
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
#endif
#endif
...
...
libvncserver/rfbserver.c
View file @
bf87073f
...
@@ -43,6 +43,9 @@
...
@@ -43,6 +43,9 @@
#endif
#endif
#ifdef WIN32
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
#define write(sock,buf,len) send(sock,buf,len,0)
#define write(sock,buf,len) send(sock,buf,len,0)
#else
#else
#ifdef LIBVNCSERVER_HAVE_UNISTD_H
#ifdef LIBVNCSERVER_HAVE_UNISTD_H
...
@@ -72,8 +75,12 @@
...
@@ -72,8 +75,12 @@
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
#ifndef WIN32
/* readdir() */
/* readdir() */
#include <dirent.h>
#include <dirent.h>
#endif
/* errno */
/* errno */
#include <errno.h>
#include <errno.h>
/* strftime() */
/* strftime() */
...
@@ -83,12 +90,21 @@
...
@@ -83,12 +90,21 @@
#include "rfbssl.h"
#include "rfbssl.h"
#endif
#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__
#ifdef __MINGW32__
static
int
compat_mkdir
(
const
char
*
path
,
int
mode
)
#define mkdir(path, perms) mkdir(path)
/* Omit the perms argument to match POSIX signature */
{
#else
/* MSVC and other windows compilers */
return
mkdir
(
path
);
#define mkdir(path, perms) _mkdir(path)
/* Omit the perms argument to match POSIX signature */
}
#endif
/* __MINGW32__ else... */
#define mkdir compat_mkdir
#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
#include <direct.h>
#endif
#endif
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
...
@@ -314,11 +330,13 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
...
@@ -314,11 +330,13 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
if
(
isUDP
)
{
if
(
isUDP
)
{
rfbLog
(
" accepted UDP client
\n
"
);
rfbLog
(
" accepted UDP client
\n
"
);
}
else
{
}
else
{
#ifdef LIBVNCSERVER_IPv6
char
host
[
1024
];
#endif
int
one
=
1
;
int
one
=
1
;
getpeername
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
getpeername
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
#ifdef LIBVNCSERVER_IPv6
#ifdef LIBVNCSERVER_IPv6
char
host
[
1024
];
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
rfbLogPerror
(
"rfbNewClient: error in getnameinfo"
);
rfbLogPerror
(
"rfbNewClient: error in getnameinfo"
);
cl
->
host
=
strdup
(
""
);
cl
->
host
=
strdup
(
""
);
...
@@ -1287,8 +1305,15 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
...
@@ -1287,8 +1305,15 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
struct
stat
statbuf
;
struct
stat
statbuf
;
RFB_FIND_DATA
win32filename
;
RFB_FIND_DATA
win32filename
;
int
nOptLen
=
0
,
retval
=
0
;
int
nOptLen
=
0
,
retval
=
0
;
#ifdef WIN32
WIN32_FIND_DATAA
winFindData
;
HANDLE
findHandle
;
int
pathLen
,
basePathLength
;
char
*
basePath
;
#else
DIR
*
dirp
=
NULL
;
DIR
*
dirp
=
NULL
;
struct
dirent
*
direntp
=
NULL
;
struct
dirent
*
direntp
=
NULL
;
#endif
FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN
(
""
,
cl
,
FALSE
);
FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN
(
""
,
cl
,
FALSE
);
...
@@ -1297,20 +1322,64 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
...
@@ -1297,20 +1322,64 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
if
(
DB
)
rfbLog
(
"rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent:
\"
%s
\"
->
\"
%s
\"\n
"
,
buffer
,
path
);
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
);
dirp
=
opendir
(
path
);
if
(
dirp
==
NULL
)
if
(
dirp
==
NULL
)
#endif
return
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
rfbADirectory
,
0
,
0
,
NULL
);
return
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
rfbADirectory
,
0
,
0
,
NULL
);
/* send back the path name (necessary for links) */
/* send back the path name (necessary for links) */
if
(
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
rfbADirectory
,
0
,
length
,
buffer
)
==
FALSE
)
return
FALSE
;
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
))
for
(
direntp
=
readdir
(
dirp
);
direntp
!=
NULL
;
direntp
=
readdir
(
dirp
))
#endif
{
{
/* get stats */
/* get stats */
#ifdef WIN32
snprintf
(
retfilename
,
sizeof
(
retfilename
),
"%s/%s"
,
path
,
winFindData
.
cFileName
);
#else
snprintf
(
retfilename
,
sizeof
(
retfilename
),
"%s/%s"
,
path
,
direntp
->
d_name
);
snprintf
(
retfilename
,
sizeof
(
retfilename
),
"%s/%s"
,
path
,
direntp
->
d_name
);
#endif
retval
=
stat
(
retfilename
,
&
statbuf
);
retval
=
stat
(
retfilename
,
&
statbuf
);
if
(
retval
==
0
)
if
(
retval
==
0
)
{
{
memset
((
char
*
)
&
win32filename
,
0
,
sizeof
(
win32filename
));
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
);
win32filename
.
dwFileAttributes
=
Swap32IfBE
(
RFB_FILE_ATTRIBUTE_NORMAL
);
if
(
S_ISDIR
(
statbuf
.
st_mode
))
if
(
S_ISDIR
(
statbuf
.
st_mode
))
win32filename
.
dwFileAttributes
=
Swap32IfBE
(
RFB_FILE_ATTRIBUTE_DIRECTORY
);
win32filename
.
dwFileAttributes
=
Swap32IfBE
(
RFB_FILE_ATTRIBUTE_DIRECTORY
);
...
@@ -1328,9 +1397,10 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
...
@@ -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:\") */
/* If this had the full path, we would need to translate to DOS format ("C:\") */
/* rfbFilenameTranslate2DOS(cl, retfilename, win32filename.cFileName); */
/* rfbFilenameTranslate2DOS(cl, retfilename, win32filename.cFileName); */
strcpy
((
char
*
)
win32filename
.
cFileName
,
direntp
->
d_name
);
strcpy
((
char
*
)
win32filename
.
cFileName
,
direntp
->
d_name
);
#endif
/* Do not show hidden files (but show how to move up the tree) */
/* Do not show hidden files (but show how to move up the tree) */
if
((
strcmp
(
direntp
->
d_name
,
".."
)
==
0
)
||
(
direntp
->
d_n
ame
[
0
]
!=
'.'
))
if
((
strcmp
(
(
char
*
)
win32filename
.
cFileName
,
".."
)
==
0
)
||
(
win32filename
.
cFileN
ame
[
0
]
!=
'.'
))
{
{
nOptLen
=
sizeof
(
RFB_FIND_DATA
)
-
MAX_PATH
-
14
+
strlen
((
char
*
)
win32filename
.
cFileName
);
nOptLen
=
sizeof
(
RFB_FIND_DATA
)
-
MAX_PATH
-
14
+
strlen
((
char
*
)
win32filename
.
cFileName
);
/*
/*
...
@@ -1338,13 +1408,30 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
...
@@ -1338,13 +1408,30 @@ rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
*/
*/
if
(
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
rfbADirectory
,
0
,
nOptLen
,
(
char
*
)
&
win32filename
)
==
FALSE
)
if
(
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
rfbADirectory
,
0
,
nOptLen
,
(
char
*
)
&
win32filename
)
==
FALSE
)
{
{
#ifdef WIN32
FindClose
(
findHandle
);
#else
closedir
(
dirp
);
closedir
(
dirp
);
#endif
return
FALSE
;
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
);
closedir
(
dirp
);
#endif
/* End of the transfer */
/* End of the transfer */
return
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
0
,
0
,
0
,
NULL
);
return
rfbSendFileTransferMessage
(
cl
,
rfbDirPacket
,
0
,
0
,
0
,
NULL
);
}
}
...
...
libvncserver/sockets.c
View file @
bf87073f
...
@@ -98,6 +98,8 @@ int deny_severity=LOG_WARNING;
...
@@ -98,6 +98,8 @@ int deny_severity=LOG_WARNING;
#endif
#endif
#if defined(WIN32)
#if defined(WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef __MINGW32__
#ifndef __MINGW32__
#pragma warning (disable: 4018 4761)
#pragma warning (disable: 4018 4761)
#endif
#endif
...
@@ -109,6 +111,13 @@ int deny_severity=LOG_WARNING;
...
@@ -109,6 +111,13 @@ int deny_severity=LOG_WARNING;
#define closesocket close
#define closesocket close
#endif
#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
int
rfbMaxClientWait
=
20000
;
/* time (ms) after which we decide client has
gone away - needed to stop us hanging */
gone away - needed to stop us hanging */
...
@@ -451,11 +460,13 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
...
@@ -451,11 +460,13 @@ rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
#endif
#endif
#ifdef LIBVNCSERVER_IPv6
#ifdef LIBVNCSERVER_IPv6
{
char
host
[
1024
];
char
host
[
1024
];
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
if
(
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
addrlen
,
host
,
sizeof
(
host
),
NULL
,
0
,
NI_NUMERICHOST
)
!=
0
)
{
rfbLogPerror
(
"rfbProcessNewConnection: error in getnameinfo"
);
rfbLogPerror
(
"rfbProcessNewConnection: error in getnameinfo"
);
}
}
rfbLog
(
"Got connection from client %s
\n
"
,
host
);
rfbLog
(
"Got connection from client %s
\n
"
,
host
);
}
#else
#else
rfbLog
(
"Got connection from client %s
\n
"
,
inet_ntoa
(
addr
.
sin_addr
));
rfbLog
(
"Got connection from client %s
\n
"
,
inet_ntoa
(
addr
.
sin_addr
));
#endif
#endif
...
...
libvncserver/stats.c
View file @
bf87073f
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
#include <rfb/rfb.h>
#include <rfb/rfb.h>
#ifdef _MSC_VER
#define snprintf _snprintf
/* Missing in MSVC */
#endif
char
*
messageNameServer2Client
(
uint32_t
type
,
char
*
buf
,
int
len
);
char
*
messageNameServer2Client
(
uint32_t
type
,
char
*
buf
,
int
len
);
char
*
messageNameClient2Server
(
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
);
char
*
encodingName
(
uint32_t
enc
,
char
*
buf
,
int
len
);
...
...
libvncserver/tightvnc-filetransfer/filetransfermsg.c
View file @
bf87073f
...
@@ -27,8 +27,34 @@
...
@@ -27,8 +27,34 @@
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include <fcntl.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 <dirent.h>
#include <utime.h>
#include <utime.h>
#endif
#include <errno.h>
#include <errno.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/stat.h>
...
@@ -100,17 +126,140 @@ GetFileListResponseMsg(char* path, char flags)
...
@@ -100,17 +126,140 @@ GetFileListResponseMsg(char* path, char flags)
return
fileListMsg
;
return
fileListMsg
;
}
}
#if
ndef __GNUC__
#if
!defined(__GNUC__) && !defined(_MSC_VER)
#define __FUNCTION__ "unknown"
#define __FUNCTION__ "unknown"
#endif
#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
int
CreateFileListInfo
(
FileListInfoPtr
pFileListInfo
,
char
*
path
,
int
flag
)
CreateFileListInfo
(
FileListInfoPtr
pFileListInfo
,
char
*
path
,
int
flag
)
{
{
DIR
*
pDir
=
NULL
;
DIR
*
pDir
=
NULL
;
struct
dirent
*
pDirent
=
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*/
/* In this case we will send the list of entries in ftp root*/
sprintf
(
path
,
"%s%s"
,
GetFtpRoot
(),
"/"
);
sprintf
(
path
,
"%s%s"
,
GetFtpRoot
(),
"/"
);
}
}
...
@@ -170,6 +319,8 @@ CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag)
...
@@ -170,6 +319,8 @@ CreateFileListInfo(FileListInfoPtr pFileListInfo, char* path, int flag)
return
SUCCESS
;
return
SUCCESS
;
}
}
#endif
FileTransferMsg
FileTransferMsg
CreateFileListErrMsg
(
char
flags
)
CreateFileListErrMsg
(
char
flags
)
...
@@ -623,6 +774,10 @@ CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp)
...
@@ -623,6 +774,10 @@ CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr rtcp)
* Method to handle create directory request.
* Method to handle create directory request.
******************************************************************************/
******************************************************************************/
#ifdef _MSC_VER
#undef CreateDirectory
/* Prevent macro clashes under Windows */
#endif
/* _MSC_VER */
void
void
CreateDirectory
(
char
*
dirName
)
CreateDirectory
(
char
*
dirName
)
{
{
...
@@ -633,4 +788,3 @@ CreateDirectory(char* dirName)
...
@@ -633,4 +788,3 @@ CreateDirectory(char* dirName)
__FILE__
,
__FUNCTION__
,
dirName
);
__FILE__
,
__FUNCTION__
,
dirName
);
}
}
}
}
libvncserver/tightvnc-filetransfer/filetransfermsg.h
View file @
bf87073f
...
@@ -26,6 +26,11 @@
...
@@ -26,6 +26,11 @@
#ifndef FILE_TRANSFER_MSG_H
#ifndef FILE_TRANSFER_MSG_H
#define 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
{
typedef
struct
_FileTransferMsg
{
char
*
data
;
char
*
data
;
unsigned
int
length
;
unsigned
int
length
;
...
@@ -50,5 +55,9 @@ void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr data);
...
@@ -50,5 +55,9 @@ void CloseUndoneFileTransfer(rfbClientPtr cl, rfbTightClientPtr data);
void
FreeFileTransferMsg
(
FileTransferMsg
ftm
);
void
FreeFileTransferMsg
(
FileTransferMsg
ftm
);
#ifdef _MSC_VER
# pragma pop_macro("CreateDirectory")
/* Restore original macro */
#endif
/* _MSC_VER */
#endif
#endif
libvncserver/tightvnc-filetransfer/handlefiletransferrequest.c
View file @
bf87073f
...
@@ -22,13 +22,18 @@
...
@@ -22,13 +22,18 @@
* Date : 14th July 2005
* Date : 14th July 2005
*/
*/
#ifndef _MSC_VER
#include <pwd.h>
#include <pwd.h>
#endif
/* _MSC_VER
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#ifndef _MSC_VER
#include <dirent.h>
#include <dirent.h>
#include <pthread.h>
#include <pthread.h>
#endif /* _MSC_VER
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include <limits.h>
#include <limits.h>
...
...
libvncserver/websockets.c
View file @
bf87073f
...
@@ -31,10 +31,13 @@
...
@@ -31,10 +31,13 @@
#endif
#endif
#include <rfb/rfb.h>
#include <rfb/rfb.h>
#include <resolv.h>
/* __b64_ntop */
/* errno */
/* errno */
#include <errno.h>
#include <errno.h>
#ifndef _MSC_VER
#include <resolv.h>
/* __b64_ntop */
#endif
#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
#include <endian.h>
#include <endian.h>
#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
...
...
rfb/rfb.h
View file @
bf87073f
...
@@ -52,7 +52,7 @@ extern "C"
...
@@ -52,7 +52,7 @@ extern "C"
#include <sys/types.h>
#include <sys/types.h>
#endif
#endif
#ifdef
__MINGW32__
#ifdef
WIN32
#undef SOCKET
#undef SOCKET
#include <winsock2.h>
#include <winsock2.h>
#ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
#ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
...
@@ -267,7 +267,7 @@ typedef struct _rfbScreenInfo
...
@@ -267,7 +267,7 @@ typedef struct _rfbScreenInfo
SOCKET
listenSock
;
SOCKET
listenSock
;
int
maxSock
;
int
maxSock
;
int
maxFd
;
int
maxFd
;
#ifdef
__MINGW32__
#ifdef
WIN32
struct
fd_set
allFds
;
struct
fd_set
allFds
;
#else
#else
fd_set
allFds
;
fd_set
allFds
;
...
...
rfb/rfbclient.h
View file @
bf87073f
...
@@ -31,6 +31,10 @@
...
@@ -31,6 +31,10 @@
* @file rfbclient.h
* @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 <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment