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
67094d7c
Commit
67094d7c
authored
Oct 11, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced xalloc with malloc functions, udp input support (untested), fixed http
parent
519a8e0e
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
204 additions
and
236 deletions
+204
-236
auth.c
auth.c
+4
-16
corre.c
corre.c
+4
-4
httpd.c
httpd.c
+3
-3
main.c
main.c
+11
-1
rfb.h
rfb.h
+56
-106
rfbserver.c
rfbserver.c
+99
-77
rre.c
rre.c
+4
-4
sockets.c
sockets.c
+5
-7
sraRegion.c
sraRegion.c
+2
-2
tableinit24.c
tableinit24.c
+2
-2
tableinittctemplate.c
tableinittctemplate.c
+2
-2
tight.c
tight.c
+8
-8
zlib.c
zlib.c
+4
-4
No files found.
auth.c
View file @
67094d7c
...
@@ -30,10 +30,6 @@
...
@@ -30,10 +30,6 @@
#include <stdlib.h>
#include <stdlib.h>
#include "rfb.h"
#include "rfb.h"
char
*
rfbAuthPasswdFile
=
NULL
;
/*
/*
* rfbAuthNewClient is called when we reach the point of authenticating
* rfbAuthNewClient is called when we reach the point of authenticating
* a new client. If authentication isn't being used then we simply send
* a new client. If authentication isn't being used then we simply send
...
@@ -49,15 +45,12 @@ rfbAuthNewClient(cl)
...
@@ -49,15 +45,12 @@ rfbAuthNewClient(cl)
cl
->
state
=
RFB_AUTHENTICATION
;
cl
->
state
=
RFB_AUTHENTICATION
;
if
(
rfbAuthPasswdFile
&&
!
cl
->
reverseConnection
)
{
if
(
cl
->
screen
->
rfbAuthPasswdData
&&
!
cl
->
reverseConnection
)
{
*
(
CARD32
*
)
buf
=
Swap32IfLE
(
rfbVncAuth
);
*
(
CARD32
*
)
buf
=
Swap32IfLE
(
rfbVncAuth
);
vncRandomBytes
(
cl
->
authChallenge
);
vncRandomBytes
(
cl
->
authChallenge
);
memcpy
(
&
buf
[
4
],
(
char
*
)
cl
->
authChallenge
,
CHALLENGESIZE
);
memcpy
(
&
buf
[
4
],
(
char
*
)
cl
->
authChallenge
,
CHALLENGESIZE
);
len
=
4
+
CHALLENGESIZE
;
len
=
4
+
CHALLENGESIZE
;
}
else
{
}
else
{
*
(
CARD32
*
)
buf
=
Swap32IfLE
(
rfbNoAuth
);
*
(
CARD32
*
)
buf
=
Swap32IfLE
(
rfbNoAuth
);
len
=
4
;
len
=
4
;
cl
->
state
=
RFB_INITIALISATION
;
cl
->
state
=
RFB_INITIALISATION
;
...
@@ -80,7 +73,7 @@ void
...
@@ -80,7 +73,7 @@ void
rfbAuthProcessClientMessage
(
cl
)
rfbAuthProcessClientMessage
(
cl
)
rfbClientPtr
cl
;
rfbClientPtr
cl
;
{
{
char
*
passwd
;
char
passwd
[
1024
]
;
int
i
,
n
;
int
i
,
n
;
CARD8
response
[
CHALLENGESIZE
];
CARD8
response
[
CHALLENGESIZE
];
CARD32
authResult
;
CARD32
authResult
;
...
@@ -92,14 +85,9 @@ rfbAuthProcessClientMessage(cl)
...
@@ -92,14 +85,9 @@ rfbAuthProcessClientMessage(cl)
return
;
return
;
}
}
passwd
=
vncDecryptPasswdFromFile
(
rfbAuthPasswdFile
);
if
(
!
cl
->
screen
->
getPassword
(
cl
,
passwd
,
MAXPWLEN
))
{
rfbLog
(
"rfbAuthProcessClientMessage: could not get password
\n
"
);
if
(
passwd
==
NULL
)
{
rfbLog
(
"rfbAuthProcessClientMessage: could not get password from %s
\n
"
,
rfbAuthPasswdFile
);
authResult
=
Swap32IfLE
(
rfbVncAuthFailed
);
authResult
=
Swap32IfLE
(
rfbVncAuthFailed
);
if
(
WriteExact
(
cl
,
(
char
*
)
&
authResult
,
4
)
<
0
)
{
if
(
WriteExact
(
cl
,
(
char
*
)
&
authResult
,
4
)
<
0
)
{
rfbLogPerror
(
"rfbAuthProcessClientMessage: write"
);
rfbLogPerror
(
"rfbAuthProcessClientMessage: write"
);
}
}
...
...
corre.c
View file @
67094d7c
...
@@ -105,17 +105,17 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
...
@@ -105,17 +105,17 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
if
(
rreBeforeBufSize
<
maxRawSize
)
{
if
(
rreBeforeBufSize
<
maxRawSize
)
{
rreBeforeBufSize
=
maxRawSize
;
rreBeforeBufSize
=
maxRawSize
;
if
(
rreBeforeBuf
==
NULL
)
if
(
rreBeforeBuf
==
NULL
)
rreBeforeBuf
=
(
char
*
)
x
alloc
(
rreBeforeBufSize
);
rreBeforeBuf
=
(
char
*
)
m
alloc
(
rreBeforeBufSize
);
else
else
rreBeforeBuf
=
(
char
*
)
x
realloc
(
rreBeforeBuf
,
rreBeforeBufSize
);
rreBeforeBuf
=
(
char
*
)
realloc
(
rreBeforeBuf
,
rreBeforeBufSize
);
}
}
if
(
rreAfterBufSize
<
maxRawSize
)
{
if
(
rreAfterBufSize
<
maxRawSize
)
{
rreAfterBufSize
=
maxRawSize
;
rreAfterBufSize
=
maxRawSize
;
if
(
rreAfterBuf
==
NULL
)
if
(
rreAfterBuf
==
NULL
)
rreAfterBuf
=
(
char
*
)
x
alloc
(
rreAfterBufSize
);
rreAfterBuf
=
(
char
*
)
m
alloc
(
rreAfterBufSize
);
else
else
rreAfterBuf
=
(
char
*
)
x
realloc
(
rreAfterBuf
,
rreAfterBufSize
);
rreAfterBuf
=
(
char
*
)
realloc
(
rreAfterBuf
,
rreAfterBufSize
);
}
}
(
*
cl
->
translateFn
)(
cl
->
translateLookupTable
,
&
(
cl
->
screen
->
rfbServerFormat
),
(
*
cl
->
translateFn
)(
cl
->
translateLookupTable
,
&
(
cl
->
screen
->
rfbServerFormat
),
...
...
httpd.c
View file @
67094d7c
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
"<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \
"<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \
"<BODY><H1>File Not Found</H1></BODY>\n"
"<BODY><H1>File Not Found</H1></BODY>\n"
#define OK_STR "HTTP/1.0 200 OK\n\n"
#define OK_STR "HTTP/1.0 200 OK\n
Content-Type: text/html\n
\n"
static
void
httpProcessInput
();
static
void
httpProcessInput
();
static
Bool
compareAndSkip
(
char
**
ptr
,
const
char
*
str
);
static
Bool
compareAndSkip
(
char
**
ptr
,
const
char
*
str
);
...
@@ -273,7 +273,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
...
@@ -273,7 +273,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
/* Open the file */
/* Open the file */
if
((
fd
=
fopen
(
fullFname
,
O_RDONLY
))
<
0
)
{
if
((
fd
=
fopen
(
fullFname
,
"r"
))
<=
0
)
{
rfbLogPerror
(
"httpProcessInput: open"
);
rfbLogPerror
(
"httpProcessInput: open"
);
WriteExact
(
&
cl
,
NOT_FOUND_STR
,
strlen
(
NOT_FOUND_STR
));
WriteExact
(
&
cl
,
NOT_FOUND_STR
,
strlen
(
NOT_FOUND_STR
));
httpCloseSock
(
rfbScreen
);
httpCloseSock
(
rfbScreen
);
...
@@ -283,7 +283,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
...
@@ -283,7 +283,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
WriteExact
(
&
cl
,
OK_STR
,
strlen
(
OK_STR
));
WriteExact
(
&
cl
,
OK_STR
,
strlen
(
OK_STR
));
while
(
1
)
{
while
(
1
)
{
int
n
=
fread
(
buf
,
BUF_SIZE
-
1
,
1
,
fd
);
int
n
=
fread
(
buf
,
1
,
BUF_SIZE
-
1
,
fd
);
if
(
n
<
0
)
{
if
(
n
<
0
)
{
rfbLogPerror
(
"httpProcessInput: read"
);
rfbLogPerror
(
"httpProcessInput: read"
);
fclose
(
fd
);
fclose
(
fd
);
...
...
main.c
View file @
67094d7c
...
@@ -326,7 +326,7 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
...
@@ -326,7 +326,7 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
rfbScreen
->
rfbMaxClientWait
=
atoi
(
argv
[
++
i
]);
rfbScreen
->
rfbMaxClientWait
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-rfbauth"
)
==
0
)
{
/* -rfbauth passwd-file */
}
else
if
(
strcmp
(
argv
[
i
],
"-rfbauth"
)
==
0
)
{
/* -rfbauth passwd-file */
if
(
i
+
1
>=
argc
)
usage
();
if
(
i
+
1
>=
argc
)
usage
();
rfbScreen
->
rfbAuthPasswd
File
=
argv
[
++
i
];
rfbScreen
->
rfbAuthPasswd
Data
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-desktop"
)
==
0
)
{
/* -desktop desktop-name */
}
else
if
(
strcmp
(
argv
[
i
],
"-desktop"
)
==
0
)
{
/* -desktop desktop-name */
if
(
i
+
1
>=
argc
)
usage
();
if
(
i
+
1
>=
argc
)
usage
();
rfbScreen
->
desktopName
=
argv
[
++
i
];
rfbScreen
->
desktopName
=
argv
[
++
i
];
...
@@ -400,6 +400,15 @@ rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
...
@@ -400,6 +400,15 @@ rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
return
(
cl
->
screen
->
cursor
);
return
(
cl
->
screen
->
cursor
);
}
}
Bool
defaultGetPassword
(
rfbClientPtr
cl
,
char
*
passwd
,
int
len
)
{
char
*
pwd
=
vncDecryptPasswdFromFile
(
cl
->
screen
->
rfbAuthPasswdData
);
if
(
!
pwd
)
return
(
FALSE
);
strncpy
(
passwd
,
pwd
,
MAXPWLEN
);
return
(
TRUE
);
}
void
doNothingWithClient
(
rfbClientPtr
cl
)
void
doNothingWithClient
(
rfbClientPtr
cl
)
{
{
}
}
...
@@ -511,6 +520,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
...
@@ -511,6 +520,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
rfbScreen
->
setXCutText
=
defaultSetXCutText
;
rfbScreen
->
setXCutText
=
defaultSetXCutText
;
rfbScreen
->
getCursorPtr
=
defaultGetCursorPtr
;
rfbScreen
->
getCursorPtr
=
defaultGetCursorPtr
;
rfbScreen
->
setTranslateFunction
=
rfbSetTranslateFunction
;
rfbScreen
->
setTranslateFunction
=
rfbSetTranslateFunction
;
rfbScreen
->
getPassword
=
defaultGetPassword
;
rfbScreen
->
newClientHook
=
doNothingWithClient
;
rfbScreen
->
newClientHook
=
doNothingWithClient
;
rfbScreen
->
displayHook
=
0
;
rfbScreen
->
displayHook
=
0
;
...
...
rfb.h
View file @
67094d7c
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <zlib.h>
#include "keysym.h"
#include "keysym.h"
/* TODO: this stuff has to go into autoconf */
/* TODO: this stuff has to go into autoconf */
...
@@ -35,19 +36,13 @@ typedef unsigned int CARD32;
...
@@ -35,19 +36,13 @@ typedef unsigned int CARD32;
typedef
CARD32
Pixel
;
typedef
CARD32
Pixel
;
typedef
CARD32
KeySym
;
typedef
CARD32
KeySym
;
/* for some strange reason, "typedef signed char Bool;" yields a four byte
/* for some strange reason, "typedef signed char Bool;" yields a four byte
signed int on
an SGI
, but only for rfbserver.o!!! */
signed int on
IRIX
, but only for rfbserver.o!!! */
#define Bool signed char
#define Bool signed char
#undef FALSE
#undef FALSE
#define FALSE 0
#define FALSE 0
#undef TRUE
#undef TRUE
#define TRUE -1
#define TRUE -1
#define xalloc malloc
#define xrealloc realloc
#define xfree free
#include <zlib.h>
#include "rfbproto.h"
#include "rfbproto.h"
#ifdef __linux__
#ifdef __linux__
...
@@ -84,7 +79,6 @@ typedef CARD32 KeySym;
...
@@ -84,7 +79,6 @@ typedef CARD32 KeySym;
#ifdef WIN32
#ifdef WIN32
#include <winsock.h>
#include <winsock.h>
//#define sockaddr_in sockaddr*
#undef SOCKET
#undef SOCKET
#define SOCKET int
#define SOCKET int
#else
#else
...
@@ -134,6 +128,18 @@ int max(int,int);
...
@@ -134,6 +128,18 @@ int max(int,int);
#define IF_PTHREADS(x)
#define IF_PTHREADS(x)
#endif
#endif
/* end of stuff for autoconf */
/* if you use pthreads, but don't define HAVE_PTHREADS, the structs
get all mixed up. So this gives a linker error reminding you to compile
the library and your application (at least the parts including rfb.h)
with the same support for pthreads. */
#ifdef HAVE_PTHREADS
#define rfbInitServer rfbInitServerWithPthreads
#else
#define rfbInitServer rfbInitServerWithoutPthreads
#endif
#define MAX_ENCODINGS 10
#define MAX_ENCODINGS 10
struct
rfbClientRec
;
struct
rfbClientRec
;
...
@@ -146,6 +152,7 @@ typedef void (*PtrAddEventProcPtr) (int buttonMask, int x, int y, struct rfbClie
...
@@ -146,6 +152,7 @@ typedef void (*PtrAddEventProcPtr) (int buttonMask, int x, int y, struct rfbClie
typedef
void
(
*
SetXCutTextProcPtr
)
(
char
*
str
,
int
len
,
struct
rfbClientRec
*
cl
);
typedef
void
(
*
SetXCutTextProcPtr
)
(
char
*
str
,
int
len
,
struct
rfbClientRec
*
cl
);
typedef
struct
rfbCursor
*
(
*
GetCursorProcPtr
)
(
struct
rfbClientRec
*
pScreen
);
typedef
struct
rfbCursor
*
(
*
GetCursorProcPtr
)
(
struct
rfbClientRec
*
pScreen
);
typedef
Bool
(
*
SetTranslateFunctionProcPtr
)(
struct
rfbClientRec
*
cl
);
typedef
Bool
(
*
SetTranslateFunctionProcPtr
)(
struct
rfbClientRec
*
cl
);
typedef
Bool
(
*
GetPasswordProcPtr
)(
struct
rfbClientRec
*
cl
,
char
*
passWord
,
int
len
);
typedef
void
(
*
NewClientHookPtr
)(
struct
rfbClientRec
*
cl
);
typedef
void
(
*
NewClientHookPtr
)(
struct
rfbClientRec
*
cl
);
typedef
void
(
*
DisplayHookPtr
)(
struct
rfbClientRec
*
cl
);
typedef
void
(
*
DisplayHookPtr
)(
struct
rfbClientRec
*
cl
);
...
@@ -158,26 +165,10 @@ typedef struct {
...
@@ -158,26 +165,10 @@ typedef struct {
}
data
;
/* there have to be count*3 entries */
}
data
;
/* there have to be count*3 entries */
}
rfbColourMap
;
}
rfbColourMap
;
/* this is why windows and it's programs are so huge:
You can't do something like
#define MUTEX(m)
struct {
int i;
MUTEX(m); // this evaluates to ";", and that is not acceptable
// to Visual C++
}
*/
#ifdef WIN32
#undef MUTEX
#define MUTEX(mutex) char dummy##mutex
#undef COND
#define COND(cond) char dummy##cond
#endif
/*
/*
* Per-screen (framebuffer) structure. There is only one of these, since we
* Per-screen (framebuffer) structure. There can be as many as you wish,
* don't allow the X server to have multiple screens.
* each serving different clients. However, you have to call
* rfbProcessEvents for each of these.
*/
*/
typedef
struct
typedef
struct
...
@@ -245,21 +236,26 @@ typedef struct
...
@@ -245,21 +236,26 @@ typedef struct
rfbColourMap
colourMap
;
/* set this if rfbServerFormat.trueColour==FALSE */
rfbColourMap
colourMap
;
/* set this if rfbServerFormat.trueColour==FALSE */
char
*
desktopName
;
char
*
desktopName
;
char
rfbThisHost
[
255
];
char
rfbThisHost
[
255
];
int
rfbPort
;
int
rfbPort
;
Bool
socketInitDone
;
SOCKET
rfbListenSock
;
SOCKET
inetdSock
;
int
maxSock
;
int
maxSock
;
int
maxFd
;
int
maxFd
;
SOCKET
rfbListenSock
;
fd_set
allFds
;
Bool
socketInitDone
;
SOCKET
inetdSock
;
Bool
inetdInitDone
;
int
udpPort
;
int
udpPort
;
SOCKET
udpSock
;
SOCKET
udpSock
;
struct
rfbClientRec
*
udpClient
;
struct
rfbClientRec
*
udpClient
;
Bool
udpSockConnected
;
Bool
udpSockConnected
;
struct
sockaddr_in
udpRemoteAddr
;
struct
sockaddr_in
udpRemoteAddr
;
Bool
inetdInitDone
;
fd_set
allFds
;
int
rfbMaxClientWait
;
int
rfbMaxClientWait
;
/* http stuff */
/* http stuff */
Bool
httpInitDone
;
Bool
httpInitDone
;
int
httpPort
;
int
httpPort
;
char
*
httpDir
;
char
*
httpDir
;
...
@@ -267,7 +263,9 @@ typedef struct
...
@@ -267,7 +263,9 @@ typedef struct
SOCKET
httpSock
;
SOCKET
httpSock
;
FILE
*
httpFP
;
FILE
*
httpFP
;
char
*
rfbAuthPasswdFile
;
GetPasswordProcPtr
getPassword
;
char
*
rfbAuthPasswdData
;
int
rfbDeferUpdateTime
;
int
rfbDeferUpdateTime
;
char
*
rfbScreen
;
char
*
rfbScreen
;
Bool
rfbAlwaysShared
;
Bool
rfbAlwaysShared
;
...
@@ -295,8 +293,8 @@ typedef struct
...
@@ -295,8 +293,8 @@ typedef struct
/* displayHook is called just before a frame buffer update */
/* displayHook is called just before a frame buffer update */
DisplayHookPtr
displayHook
;
DisplayHookPtr
displayHook
;
MUTEX
(
cursorMutex
);
#ifdef HAVE_PTHREADS
#ifdef HAVE_PTHREADS
MUTEX
(
cursorMutex
);
Bool
backgroundLoop
;
Bool
backgroundLoop
;
#endif
#endif
...
@@ -345,6 +343,8 @@ typedef struct rfbClientRec {
...
@@ -345,6 +343,8 @@ typedef struct rfbClientRec {
/* private data. You should put any application client specific data
/* private data. You should put any application client specific data
* into a struct and let clientData point to it. Don't forget to
* into a struct and let clientData point to it. Don't forget to
* free the struct via clientGoneHook!
* free the struct via clientGoneHook!
*
* This is useful if the IO functions have to behave client specific.
*/
*/
void
*
clientData
;
void
*
clientData
;
ClientGoneHookPtr
clientGoneHook
;
ClientGoneHookPtr
clientGoneHook
;
...
@@ -360,15 +360,12 @@ typedef struct rfbClientRec {
...
@@ -360,15 +360,12 @@ typedef struct rfbClientRec {
}
state
;
}
state
;
Bool
reverseConnection
;
Bool
reverseConnection
;
Bool
readyForSetColourMapEntries
;
Bool
readyForSetColourMapEntries
;
Bool
useCopyRect
;
Bool
useCopyRect
;
int
preferredEncoding
;
int
preferredEncoding
;
int
correMaxWidth
,
correMaxHeight
;
int
correMaxWidth
,
correMaxHeight
;
/* The following member is only used during VNC authentication */
/* The following member is only used during VNC authentication */
CARD8
authChallenge
[
CHALLENGESIZE
];
CARD8
authChallenge
[
CHALLENGESIZE
];
/* The following members represent the update needed to get the client's
/* The following members represent the update needed to get the client's
...
@@ -397,7 +394,6 @@ typedef struct rfbClientRec {
...
@@ -397,7 +394,6 @@ typedef struct rfbClientRec {
sraRegionPtr
copyRegion
;
/* the destination region of the copy */
sraRegionPtr
copyRegion
;
/* the destination region of the copy */
int
copyDX
,
copyDY
;
/* the translation by which the copy happens */
int
copyDX
,
copyDY
;
/* the translation by which the copy happens */
sraRegionPtr
modifiedRegion
;
sraRegionPtr
modifiedRegion
;
/* As part of the FramebufferUpdateRequest, a client can express interest
/* As part of the FramebufferUpdateRequest, a client can express interest
...
@@ -407,31 +403,25 @@ typedef struct rfbClientRec {
...
@@ -407,31 +403,25 @@ typedef struct rfbClientRec {
sraRegionPtr
requestedRegion
;
sraRegionPtr
requestedRegion
;
/* TODO: */
/* The following members represent the state of the "deferred update" timer
/* The following members represent the state of the "deferred update" timer
- when the framebuffer is modified and the client is ready, in most
- when the framebuffer is modified and the client is ready, in most
cases it is more efficient to defer sending the update by a few
cases it is more efficient to defer sending the update by a few
milliseconds so that several changes to the framebuffer can be combined
milliseconds so that several changes to the framebuffer can be combined
into a single update. */
into a single update. */
/* no deferred timer here; server has to do it alone */
/* Bool deferredUpdateScheduled;
OsTimerPtr deferredUpdateTimer; */
/* translateFn points to the translation function which is used to copy
/* translateFn points to the translation function which is used to copy
and translate a rectangle from the framebuffer to an output buffer. */
and translate a rectangle from the framebuffer to an output buffer. */
rfbTranslateFnType
translateFn
;
rfbTranslateFnType
translateFn
;
char
*
translateLookupTable
;
char
*
translateLookupTable
;
rfbPixelFormat
format
;
rfbPixelFormat
format
;
/*
/*
* UPDATE_BUF_SIZE must be big enough to send at least one whole line of the
* UPDATE_BUF_SIZE must be big enough to send at least one whole line of the
* framebuffer. So for a max screen width of say 2K with 32-bit pixels this
* framebuffer. So for a max screen width of say 2K with 32-bit pixels this
* means 8K minimum.
* means 8K minimum.
*/
*/
#define UPDATE_BUF_SIZE 30000
#define UPDATE_BUF_SIZE 30000
...
@@ -455,7 +445,6 @@ typedef struct rfbClientRec {
...
@@ -455,7 +445,6 @@ typedef struct rfbClientRec {
struct
z_stream_s
compStream
;
struct
z_stream_s
compStream
;
Bool
compStreamInited
;
Bool
compStreamInited
;
CARD32
zlibCompressLevel
;
CARD32
zlibCompressLevel
;
/* tight encoding -- preserve zlib streams' state for each client */
/* tight encoding -- preserve zlib streams' state for each client */
...
@@ -476,7 +465,8 @@ typedef struct rfbClientRec {
...
@@ -476,7 +465,8 @@ typedef struct rfbClientRec {
#ifdef HAVE_PTHREADS
#ifdef HAVE_PTHREADS
/* whenever a client is referenced, the refCount has to be incremented
/* whenever a client is referenced, the refCount has to be incremented
and afterwards decremented.
and afterwards decremented, so that the client is not cleaned up
while being referenced.
Use the functions rfbIncrClientRef(cl) and rfbDecrClientRef(cl);
Use the functions rfbIncrClientRef(cl) and rfbDecrClientRef(cl);
*/
*/
int
refCount
;
int
refCount
;
...
@@ -490,7 +480,6 @@ typedef struct rfbClientRec {
...
@@ -490,7 +480,6 @@ typedef struct rfbClientRec {
}
rfbClientRec
,
*
rfbClientPtr
;
}
rfbClientRec
,
*
rfbClientPtr
;
/*
/*
* This macro is used to test whether there is a framebuffer update needing to
* This macro is used to test whether there is a framebuffer update needing to
* be sent to the client.
* be sent to the client.
...
@@ -501,28 +490,6 @@ typedef struct rfbClientRec {
...
@@ -501,28 +490,6 @@ typedef struct rfbClientRec {
((cl)->enableCursorShapeUpdates && (cl)->cursorWasChanged) || \
((cl)->enableCursorShapeUpdates && (cl)->cursorWasChanged) || \
!sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion))
!sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion))
//REGION_NOTEMPTY(&((cl)->screenInfo->screen),&(cl)->copyRegion) ||
//REGION_NOTEMPTY(&((cl)->screenInfo->screen),&(cl)->modifiedRegion))
/*
* This macro creates an empty region (ie. a region with no areas) if it is
* given a rectangle with a width or height of zero. It appears that
* REGION_INTERSECT does not quite do the right thing with zero-width
* rectangles, but it should with completely empty regions.
*/
#define SAFE_REGION_INIT(pscreen, preg, rect, size) \
{ \
if ( ( (rect) ) && \
( ( (rect)->x2 == (rect)->x1 ) || \
( (rect)->y2 == (rect)->y1 ) ) ) { \
REGION_INIT( (pscreen), (preg), NullBox, 0 ); \
} else { \
REGION_INIT( (pscreen), (preg), (rect), (size) ); \
} \
}
/*
/*
* Macros for endian swapping.
* Macros for endian swapping.
*/
*/
...
@@ -544,22 +511,12 @@ static const int rfbEndianTest = (_BYTE_ORDER == _LITTLE_ENDIAN);
...
@@ -544,22 +511,12 @@ static const int rfbEndianTest = (_BYTE_ORDER == _LITTLE_ENDIAN);
#define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l))
#define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l))
#define Swap32IfLE(l) (rfbEndianTest ? Swap32(l) : (l))
#define Swap32IfLE(l) (rfbEndianTest ? Swap32(l) : (l))
/* main.c */
extern
void
rfbLog
(
char
*
format
,
...);
extern
void
rfbLogPerror
(
char
*
str
);
void
rfbScheduleCopyRect
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
dx
,
int
dy
);
void
rfbScheduleCopyRegion
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
copyRegion
,
int
dx
,
int
dy
);
void
rfbDoCopyRect
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
dx
,
int
dy
);
void
rfbDoCopyRegion
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
copyRegion
,
int
dx
,
int
dy
);
/* sockets.c */
/* sockets.c */
extern
int
rfbMaxClientWait
;
extern
int
rfbMaxClientWait
;
extern
void
rfbInitSockets
(
rfbScreenInfoPtr
rfbScreen
);
extern
void
rfbDisconnectUDPSock
(
rfbScreenInfoPtr
rfbScreen
);
extern
void
rfbCloseClient
(
rfbClientPtr
cl
);
extern
void
rfbCloseClient
(
rfbClientPtr
cl
);
extern
int
ReadExact
(
rfbClientPtr
cl
,
char
*
buf
,
int
len
);
extern
int
ReadExact
(
rfbClientPtr
cl
,
char
*
buf
,
int
len
);
extern
int
WriteExact
(
rfbClientPtr
cl
,
char
*
buf
,
int
len
);
extern
int
WriteExact
(
rfbClientPtr
cl
,
char
*
buf
,
int
len
);
...
@@ -585,12 +542,13 @@ extern void rfbReleaseClientIterator(rfbClientIteratorPtr iterator);
...
@@ -585,12 +542,13 @@ extern void rfbReleaseClientIterator(rfbClientIteratorPtr iterator);
extern
void
rfbNewClientConnection
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
void
rfbNewClientConnection
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
rfbClientPtr
rfbNewClient
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
rfbClientPtr
rfbNewClient
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
rfbClientPtr
rfbNewUDPClient
(
rfbScreenInfoPtr
rfbScreen
);
extern
rfbClientPtr
rfbReverseConnection
(
rfbScreenInfoPtr
rfbScreen
,
char
*
host
,
int
port
);
extern
rfbClientPtr
rfbReverseConnection
(
rfbScreenInfoPtr
rfbScreen
,
char
*
host
,
int
port
);
extern
void
rfbClientConnectionGone
(
rfbClientPtr
cl
);
extern
void
rfbClientConnectionGone
(
rfbClientPtr
cl
);
extern
void
rfbProcessClientMessage
(
rfbClientPtr
cl
);
extern
void
rfbProcessClientMessage
(
rfbClientPtr
cl
);
extern
void
rfbClientConnFailed
(
rfbClientPtr
cl
,
char
*
reason
);
extern
void
rfbClientConnFailed
(
rfbClientPtr
cl
,
char
*
reason
);
extern
void
rfbNewUDPConnection
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
void
rfbNewUDPConnection
(
rfbScreenInfoPtr
rfbScreen
,
int
sock
);
extern
void
rfbProcessUDPInput
(
rfb
ClientPtr
cl
);
extern
void
rfbProcessUDPInput
(
rfb
ScreenInfoPtr
rfbScreen
);
extern
Bool
rfbSendFramebufferUpdate
(
rfbClientPtr
cl
,
sraRegionPtr
updateRegion
);
extern
Bool
rfbSendFramebufferUpdate
(
rfbClientPtr
cl
,
sraRegionPtr
updateRegion
);
extern
Bool
rfbSendRectEncodingRaw
(
rfbClientPtr
cl
,
int
x
,
int
y
,
int
w
,
int
h
);
extern
Bool
rfbSendRectEncodingRaw
(
rfbClientPtr
cl
,
int
x
,
int
y
,
int
w
,
int
h
);
extern
Bool
rfbSendUpdateBuf
(
rfbClientPtr
cl
);
extern
Bool
rfbSendUpdateBuf
(
rfbClientPtr
cl
);
...
@@ -628,8 +586,6 @@ extern void httpCheckFds();
...
@@ -628,8 +586,6 @@ extern void httpCheckFds();
/* auth.c */
/* auth.c */
extern
char
*
rfbAuthPasswdFile
;
extern
char
*
rfbAuthPasswdFile
;
extern
Bool
rfbAuthenticating
;
extern
void
rfbAuthNewClient
(
rfbClientPtr
cl
);
extern
void
rfbAuthNewClient
(
rfbClientPtr
cl
);
extern
void
rfbAuthProcessClientMessage
(
rfbClientPtr
cl
);
extern
void
rfbAuthProcessClientMessage
(
rfbClientPtr
cl
);
...
@@ -709,11 +665,6 @@ extern void defaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
...
@@ -709,11 +665,6 @@ extern void defaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
extern
void
rfbResetStats
(
rfbClientPtr
cl
);
extern
void
rfbResetStats
(
rfbClientPtr
cl
);
extern
void
rfbPrintStats
(
rfbClientPtr
cl
);
extern
void
rfbPrintStats
(
rfbClientPtr
cl
);
/* socket.c */
extern
void
rfbInitSockets
(
rfbScreenInfoPtr
rfbScreen
);
extern
void
rfbDisconnectUDPSock
(
rfbScreenInfoPtr
cl
);
/* font.c */
/* font.c */
typedef
struct
rfbFontData
{
typedef
struct
rfbFontData
{
...
@@ -734,20 +685,19 @@ void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int
...
@@ -734,20 +685,19 @@ void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int
/* main.c */
/* main.c */
extern
void
rfbLog
(
char
*
format
,
...);
extern
void
rfbLogPerror
(
char
*
str
);
void
rfbScheduleCopyRect
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
dx
,
int
dy
);
void
rfbScheduleCopyRegion
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
copyRegion
,
int
dx
,
int
dy
);
void
rfbDoCopyRect
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
dx
,
int
dy
);
void
rfbDoCopyRegion
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
copyRegion
,
int
dx
,
int
dy
);
void
rfbMarkRectAsModified
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
);
void
rfbMarkRectAsModified
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
);
void
rfbMarkRegionAsModified
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
modRegion
);
void
rfbMarkRegionAsModified
(
rfbScreenInfoPtr
rfbScreen
,
sraRegionPtr
modRegion
);
void
doNothingWithClient
(
rfbClientPtr
cl
);
void
doNothingWithClient
(
rfbClientPtr
cl
);
/* if you use pthreads, but don't define HAVE_PTHREADS, the structs
get all mixed up. So this gives a linker error reminding you to compile
the library and your application (at least the parts including rfb.h)
with the same support for pthreads. */
#ifdef HAVE_PTHREADS
#define rfbInitServer rfbInitServerWithPthreads
#else
#define rfbInitServer rfbInitServerWithoutPthreads
#endif
/* functions to make a vnc server */
/* functions to make a vnc server */
extern
rfbScreenInfoPtr
rfbGetScreen
(
int
argc
,
char
**
argv
,
extern
rfbScreenInfoPtr
rfbGetScreen
(
int
argc
,
char
**
argv
,
int
width
,
int
height
,
int
bitsPerSample
,
int
samplesPerPixel
,
int
width
,
int
height
,
int
bitsPerSample
,
int
samplesPerPixel
,
...
...
rfbserver.c
View file @
67094d7c
...
@@ -173,108 +173,128 @@ rfbReverseConnection(rfbScreen,host, port)
...
@@ -173,108 +173,128 @@ rfbReverseConnection(rfbScreen,host, port)
*/
*/
rfbClientPtr
rfbClientPtr
rfbNew
Client
(
rfbScreen
,
sock
)
rfbNew
TCPOrUDPClient
(
rfbScreen
,
sock
,
isUDP
)
rfbScreenInfoPtr
rfbScreen
;
rfbScreenInfoPtr
rfbScreen
;
int
sock
;
int
sock
;
Bool
isUDP
;
{
{
rfbProtocolVersionMsg
pv
;
rfbProtocolVersionMsg
pv
;
rfbClientIteratorPtr
iterator
;
rfbClientIteratorPtr
iterator
;
rfbClientPtr
cl
;
rfbClientPtr
cl
,
cl_
;
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
int
addrlen
=
sizeof
(
struct
sockaddr_in
);
int
addrlen
=
sizeof
(
struct
sockaddr_in
);
int
i
;
int
i
;
rfbLog
(
" other clients:
\n
"
);
cl
=
(
rfbClientPtr
)
malloc
(
sizeof
(
rfbClientRec
));
iterator
=
rfbGetClientIterator
(
rfbScreen
);
while
((
cl
=
rfbClientIteratorNext
(
iterator
))
!=
NULL
)
{
rfbLog
(
" %s
\n
"
,
cl
->
host
);
}
rfbReleaseClientIterator
(
iterator
);
cl
=
(
rfbClientPtr
)
xalloc
(
sizeof
(
rfbClientRec
));
FD_SET
(
sock
,
&
(
rfbScreen
->
allFds
));
cl
->
screen
=
rfbScreen
;
cl
->
screen
=
rfbScreen
;
cl
->
sock
=
sock
;
cl
->
sock
=
sock
;
getpeername
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
rfbResetStats
(
cl
);
cl
->
host
=
strdup
(
inet_ntoa
(
addr
.
sin_addr
));
INIT_MUTEX
(
cl
->
outputMutex
);
if
(
isUDP
)
{
INIT_MUTEX
(
cl
->
refCountMutex
);
rfbLog
(
" accepted UDP client
\n
"
);
INIT_COND
(
cl
->
deleteCond
);
}
else
{
getpeername
(
sock
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
cl
->
host
=
strdup
(
inet_ntoa
(
addr
.
sin_addr
));
cl
->
state
=
RFB_PROTOCOL_VERSION
;
rfbLog
(
" other clients:
\n
"
);
iterator
=
rfbGetClientIterator
(
rfbScreen
);
while
((
cl_
=
rfbClientIteratorNext
(
iterator
))
!=
NULL
)
{
rfbLog
(
" %s
\n
"
,
cl_
->
host
);
}
rfbReleaseClientIterator
(
iterator
);
cl
->
reverseConnection
=
FALSE
;
FD_SET
(
sock
,
&
(
rfbScreen
->
allFds
));
cl
->
readyForSetColourMapEntries
=
FALSE
;
INIT_MUTEX
(
cl
->
outputMutex
);
cl
->
useCopyRect
=
FALSE
;
INIT_MUTEX
(
cl
->
refCountMutex
);
cl
->
preferredEncoding
=
rfbEncodingRaw
;
INIT_COND
(
cl
->
deleteCond
);
cl
->
correMaxWidth
=
48
;
cl
->
correMaxHeight
=
48
;
cl
->
copyRegion
=
sraRgnCreate
();
cl
->
state
=
RFB_PROTOCOL_VERSION
;
cl
->
copyDX
=
0
;
cl
->
copyDY
=
0
;
cl
->
reverseConnection
=
FALSE
;
cl
->
readyForSetColourMapEntries
=
FALSE
;
cl
->
useCopyRect
=
FALSE
;
cl
->
preferredEncoding
=
rfbEncodingRaw
;
cl
->
correMaxWidth
=
48
;
cl
->
correMaxHeight
=
48
;
cl
->
copyRegion
=
sraRgnCreate
();
cl
->
copyDX
=
0
;
cl
->
copyDY
=
0
;
cl
->
modifiedRegion
=
cl
->
modifiedRegion
=
sraRgnCreateRect
(
0
,
0
,
rfbScreen
->
width
,
rfbScreen
->
height
);
sraRgnCreateRect
(
0
,
0
,
rfbScreen
->
width
,
rfbScreen
->
height
);
INIT_MUTEX
(
cl
->
updateMutex
);
INIT_MUTEX
(
cl
->
updateMutex
);
INIT_COND
(
cl
->
updateCond
);
INIT_COND
(
cl
->
updateCond
);
cl
->
requestedRegion
=
sraRgnCreate
();
cl
->
requestedRegion
=
sraRgnCreate
();
cl
->
format
=
cl
->
screen
->
rfbServerFormat
;
cl
->
format
=
cl
->
screen
->
rfbServerFormat
;
cl
->
translateFn
=
rfbTranslateNone
;
cl
->
translateFn
=
rfbTranslateNone
;
cl
->
translateLookupTable
=
NULL
;
cl
->
translateLookupTable
=
NULL
;
LOCK
(
rfbClientListMutex
);
LOCK
(
rfbClientListMutex
);
IF_PTHREADS
(
cl
->
refCount
=
0
);
IF_PTHREADS
(
cl
->
refCount
=
0
);
cl
->
next
=
rfbScreen
->
rfbClientHead
;
cl
->
next
=
rfbScreen
->
rfbClientHead
;
cl
->
prev
=
NULL
;
cl
->
prev
=
NULL
;
if
(
rfbScreen
->
rfbClientHead
)
if
(
rfbScreen
->
rfbClientHead
)
rfbScreen
->
rfbClientHead
->
prev
=
cl
;
rfbScreen
->
rfbClientHead
->
prev
=
cl
;
rfbScreen
->
rfbClientHead
=
cl
;
rfbScreen
->
rfbClientHead
=
cl
;
UNLOCK
(
rfbClientListMutex
);
UNLOCK
(
rfbClientListMutex
);
cl
->
tightCompressLevel
=
TIGHT_DEFAULT_COMPRESSION
;
cl
->
tightCompressLevel
=
TIGHT_DEFAULT_COMPRESSION
;
cl
->
tightQualityLevel
=
-
1
;
cl
->
tightQualityLevel
=
-
1
;
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
cl
->
zsActive
[
i
]
=
FALSE
;
cl
->
zsActive
[
i
]
=
FALSE
;
cl
->
enableCursorShapeUpdates
=
FALSE
;
cl
->
enableCursorShapeUpdates
=
FALSE
;
cl
->
useRichCursorEncoding
=
FALSE
;
cl
->
useRichCursorEncoding
=
FALSE
;
cl
->
enableLastRectEncoding
=
FALSE
;
cl
->
enableLastRectEncoding
=
FALSE
;
rfbResetStats
(
cl
);
cl
->
compStreamInited
=
FALSE
;
cl
->
compStream
.
total_in
=
0
;
cl
->
compStream
.
total_out
=
0
;
cl
->
compStream
.
zalloc
=
Z_NULL
;
cl
->
compStream
.
zfree
=
Z_NULL
;
cl
->
compStream
.
opaque
=
Z_NULL
;
cl
->
compStreamInited
=
FALSE
;
cl
->
zlibCompressLevel
=
5
;
cl
->
compStream
.
total_in
=
0
;
cl
->
compStream
.
total_out
=
0
;
cl
->
compStream
.
zalloc
=
Z_NULL
;
cl
->
compStream
.
zfree
=
Z_NULL
;
cl
->
compStream
.
opaque
=
Z_NULL
;
cl
->
zlibCompressLevel
=
5
;
sprintf
(
pv
,
rfbProtocolVersionFormat
,
rfbProtocolMajorVersion
,
rfbProtocolMinorVersion
);
sprintf
(
pv
,
rfbProtocolVersionFormat
,
rfbProtocolMajorVersion
,
if
(
WriteExact
(
cl
,
pv
,
sz_rfbProtocolVersionMsg
)
<
0
)
{
rfbProtocolMinorVersion
);
cl
->
clientData
=
NULL
;
cl
->
clientGoneHook
=
doNothingWithClient
;
cl
->
screen
->
newClientHook
(
cl
);
if
(
WriteExact
(
cl
,
pv
,
sz_rfbProtocolVersionMsg
)
<
0
)
{
rfbLogPerror
(
"rfbNewClient: write"
);
rfbLogPerror
(
"rfbNewClient: write"
);
rfbCloseClient
(
cl
);
rfbCloseClient
(
cl
);
return
NULL
;
return
NULL
;
}
}
}
cl
->
clientData
=
NULL
;
cl
->
clientGoneHook
=
doNothingWithClient
;
cl
->
screen
->
newClientHook
(
cl
);
return
cl
;
return
cl
;
}
}
rfbClientPtr
rfbNewClient
(
rfbScreen
,
sock
)
rfbScreenInfoPtr
rfbScreen
;
int
sock
;
{
return
(
rfbNewTCPOrUDPClient
(
rfbScreen
,
sock
,
FALSE
));
}
rfbClientPtr
rfbNewUDPClient
(
rfbScreen
)
rfbScreenInfoPtr
rfbScreen
;
{
return
((
rfbScreen
->
udpClient
=
rfbNewTCPOrUDPClient
(
rfbScreen
,
rfbScreen
->
udpSock
,
TRUE
)));
}
/*
/*
* rfbClientConnectionGone is called from sockets.c just after a connection
* rfbClientConnectionGone is called from sockets.c just after a connection
...
@@ -342,7 +362,7 @@ rfbClientConnectionGone(cl)
...
@@ -342,7 +362,7 @@ rfbClientConnectionGone(cl)
rfbPrintStats
(
cl
);
rfbPrintStats
(
cl
);
x
free
(
cl
);
free
(
cl
);
}
}
...
@@ -434,14 +454,14 @@ rfbClientConnFailed(cl, reason)
...
@@ -434,14 +454,14 @@ rfbClientConnFailed(cl, reason)
char
*
buf
;
char
*
buf
;
int
len
=
strlen
(
reason
);
int
len
=
strlen
(
reason
);
buf
=
(
char
*
)
x
alloc
(
8
+
len
);
buf
=
(
char
*
)
m
alloc
(
8
+
len
);
((
CARD32
*
)
buf
)[
0
]
=
Swap32IfLE
(
rfbConnFailed
);
((
CARD32
*
)
buf
)[
0
]
=
Swap32IfLE
(
rfbConnFailed
);
((
CARD32
*
)
buf
)[
1
]
=
Swap32IfLE
(
len
);
((
CARD32
*
)
buf
)[
1
]
=
Swap32IfLE
(
len
);
memcpy
(
buf
+
8
,
reason
,
len
);
memcpy
(
buf
+
8
,
reason
,
len
);
if
(
WriteExact
(
cl
,
buf
,
8
+
len
)
<
0
)
if
(
WriteExact
(
cl
,
buf
,
8
+
len
)
<
0
)
rfbLogPerror
(
"rfbClientConnFailed: write"
);
rfbLogPerror
(
"rfbClientConnFailed: write"
);
x
free
(
buf
);
free
(
buf
);
rfbCloseClient
(
cl
);
rfbCloseClient
(
cl
);
}
}
...
@@ -808,19 +828,19 @@ rfbProcessClientNormalMessage(cl)
...
@@ -808,19 +828,19 @@ rfbProcessClientNormalMessage(cl)
msg
.
cct
.
length
=
Swap32IfLE
(
msg
.
cct
.
length
);
msg
.
cct
.
length
=
Swap32IfLE
(
msg
.
cct
.
length
);
str
=
(
char
*
)
x
alloc
(
msg
.
cct
.
length
);
str
=
(
char
*
)
m
alloc
(
msg
.
cct
.
length
);
if
((
n
=
ReadExact
(
cl
,
str
,
msg
.
cct
.
length
))
<=
0
)
{
if
((
n
=
ReadExact
(
cl
,
str
,
msg
.
cct
.
length
))
<=
0
)
{
if
(
n
!=
0
)
if
(
n
!=
0
)
rfbLogPerror
(
"rfbProcessClientNormalMessage: read"
);
rfbLogPerror
(
"rfbProcessClientNormalMessage: read"
);
x
free
(
str
);
free
(
str
);
rfbCloseClient
(
cl
);
rfbCloseClient
(
cl
);
return
;
return
;
}
}
cl
->
screen
->
setXCutText
(
str
,
msg
.
cct
.
length
,
cl
);
cl
->
screen
->
setXCutText
(
str
,
msg
.
cct
.
length
,
cl
);
x
free
(
str
);
free
(
str
);
return
;
return
;
...
@@ -1388,18 +1408,21 @@ rfbNewUDPConnection(rfbScreen,sock)
...
@@ -1388,18 +1408,21 @@ rfbNewUDPConnection(rfbScreen,sock)
* number of bytes we can possibly get.
* number of bytes we can possibly get.
*/
*/
#if 0
void
void
rfbProcessUDPInput(rfb
ClientPtr cl
)
rfbProcessUDPInput
(
rfb
ScreenInfoPtr
rfbScreen
)
{
{
int
n
;
int
n
;
rfbClientPtr
cl
=
rfbScreen
->
udpClient
;
rfbClientToServerMsg
msg
;
rfbClientToServerMsg
msg
;
if ((n = read(cl->udpSock, (char *)&msg, sizeof(msg))) <= 0) {
if
(
!
cl
)
return
;
if
((
n
=
read
(
rfbScreen
->
udpSock
,
(
char
*
)
&
msg
,
sizeof
(
msg
)))
<=
0
)
{
if
(
n
<
0
)
{
if
(
n
<
0
)
{
rfbLogPerror
(
"rfbProcessUDPInput: read"
);
rfbLogPerror
(
"rfbProcessUDPInput: read"
);
}
}
rfbDisconnectUDPSock(
cl
);
rfbDisconnectUDPSock
(
rfbScreen
);
return
;
return
;
}
}
...
@@ -1408,7 +1431,7 @@ rfbProcessUDPInput(rfbClientPtr cl)
...
@@ -1408,7 +1431,7 @@ rfbProcessUDPInput(rfbClientPtr cl)
case
rfbKeyEvent
:
case
rfbKeyEvent
:
if
(
n
!=
sz_rfbKeyEventMsg
)
{
if
(
n
!=
sz_rfbKeyEventMsg
)
{
rfbLog
(
"rfbProcessUDPInput: key event incorrect length
\n
"
);
rfbLog
(
"rfbProcessUDPInput: key event incorrect length
\n
"
);
rfbDisconnectUDPSock(
cl
);
rfbDisconnectUDPSock
(
rfbScreen
);
return
;
return
;
}
}
cl
->
screen
->
kbdAddEvent
(
msg
.
ke
.
down
,
(
KeySym
)
Swap32IfLE
(
msg
.
ke
.
key
),
cl
);
cl
->
screen
->
kbdAddEvent
(
msg
.
ke
.
down
,
(
KeySym
)
Swap32IfLE
(
msg
.
ke
.
key
),
cl
);
...
@@ -1417,7 +1440,7 @@ rfbProcessUDPInput(rfbClientPtr cl)
...
@@ -1417,7 +1440,7 @@ rfbProcessUDPInput(rfbClientPtr cl)
case
rfbPointerEvent
:
case
rfbPointerEvent
:
if
(
n
!=
sz_rfbPointerEventMsg
)
{
if
(
n
!=
sz_rfbPointerEventMsg
)
{
rfbLog
(
"rfbProcessUDPInput: ptr event incorrect length
\n
"
);
rfbLog
(
"rfbProcessUDPInput: ptr event incorrect length
\n
"
);
rfbDisconnectUDPSock(
cl
);
rfbDisconnectUDPSock
(
rfbScreen
);
return
;
return
;
}
}
cl
->
screen
->
ptrAddEvent
(
msg
.
pe
.
buttonMask
,
cl
->
screen
->
ptrAddEvent
(
msg
.
pe
.
buttonMask
,
...
@@ -1427,7 +1450,6 @@ rfbProcessUDPInput(rfbClientPtr cl)
...
@@ -1427,7 +1450,6 @@ rfbProcessUDPInput(rfbClientPtr cl)
default
:
default
:
rfbLog
(
"rfbProcessUDPInput: unknown message type %d
\n
"
,
rfbLog
(
"rfbProcessUDPInput: unknown message type %d
\n
"
,
msg
.
type
);
msg
.
type
);
rfbDisconnectUDPSock(
cl
);
rfbDisconnectUDPSock
(
rfbScreen
);
}
}
}
}
#endif
rre.c
View file @
67094d7c
...
@@ -71,17 +71,17 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
...
@@ -71,17 +71,17 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
if
(
rreBeforeBufSize
<
maxRawSize
)
{
if
(
rreBeforeBufSize
<
maxRawSize
)
{
rreBeforeBufSize
=
maxRawSize
;
rreBeforeBufSize
=
maxRawSize
;
if
(
rreBeforeBuf
==
NULL
)
if
(
rreBeforeBuf
==
NULL
)
rreBeforeBuf
=
(
char
*
)
x
alloc
(
rreBeforeBufSize
);
rreBeforeBuf
=
(
char
*
)
m
alloc
(
rreBeforeBufSize
);
else
else
rreBeforeBuf
=
(
char
*
)
x
realloc
(
rreBeforeBuf
,
rreBeforeBufSize
);
rreBeforeBuf
=
(
char
*
)
realloc
(
rreBeforeBuf
,
rreBeforeBufSize
);
}
}
if
(
rreAfterBufSize
<
maxRawSize
)
{
if
(
rreAfterBufSize
<
maxRawSize
)
{
rreAfterBufSize
=
maxRawSize
;
rreAfterBufSize
=
maxRawSize
;
if
(
rreAfterBuf
==
NULL
)
if
(
rreAfterBuf
==
NULL
)
rreAfterBuf
=
(
char
*
)
x
alloc
(
rreAfterBufSize
);
rreAfterBuf
=
(
char
*
)
m
alloc
(
rreAfterBufSize
);
else
else
rreAfterBuf
=
(
char
*
)
x
realloc
(
rreAfterBuf
,
rreAfterBufSize
);
rreAfterBuf
=
(
char
*
)
realloc
(
rreAfterBuf
,
rreAfterBufSize
);
}
}
(
*
cl
->
translateFn
)(
cl
->
translateLookupTable
,
(
*
cl
->
translateFn
)(
cl
->
translateLookupTable
,
...
...
sockets.c
View file @
67094d7c
...
@@ -214,15 +214,14 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
...
@@ -214,15 +214,14 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
}
}
if
((
rfbScreen
->
udpSock
!=
-
1
)
&&
FD_ISSET
(
rfbScreen
->
udpSock
,
&
fds
))
{
if
((
rfbScreen
->
udpSock
!=
-
1
)
&&
FD_ISSET
(
rfbScreen
->
udpSock
,
&
fds
))
{
if
(
!
rfbScreen
->
udpClient
)
rfbNewUDPClient
(
rfbScreen
);
if
(
recvfrom
(
rfbScreen
->
udpSock
,
buf
,
1
,
MSG_PEEK
,
if
(
recvfrom
(
rfbScreen
->
udpSock
,
buf
,
1
,
MSG_PEEK
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
)
<
0
)
{
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
)
<
0
)
{
rfbLogPerror
(
"rfbCheckFds: UDP: recvfrom"
);
rfbLogPerror
(
"rfbCheckFds: UDP: recvfrom"
);
rfbDisconnectUDPSock
(
rfbScreen
);
rfbDisconnectUDPSock
(
rfbScreen
);
rfbScreen
->
udpSockConnected
=
FALSE
;
}
else
{
}
else
{
if
(
!
rfbScreen
->
udpSockConnected
||
if
(
!
rfbScreen
->
udpSockConnected
||
(
memcmp
(
&
addr
,
&
rfbScreen
->
udpRemoteAddr
,
addrlen
)
!=
0
))
(
memcmp
(
&
addr
,
&
rfbScreen
->
udpRemoteAddr
,
addrlen
)
!=
0
))
{
{
...
@@ -242,8 +241,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
...
@@ -242,8 +241,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
rfbNewUDPConnection
(
rfbScreen
,
rfbScreen
->
udpSock
);
rfbNewUDPConnection
(
rfbScreen
,
rfbScreen
->
udpSock
);
}
}
/* TODO: UDP also needs a client
rfbProcessUDPInput
(
rfbScreen
);
rfbProcessUDPInput(rfbScreen,rfbScreen->udpSock); */
}
}
FD_CLR
(
rfbScreen
->
udpSock
,
&
fds
);
FD_CLR
(
rfbScreen
->
udpSock
,
&
fds
);
...
@@ -263,7 +261,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
...
@@ -263,7 +261,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
void
void
rfbDisconnectUDPSock
(
rfbScreenInfoPtr
rfbScreen
)
rfbDisconnectUDPSock
(
rfbScreenInfoPtr
rfbScreen
)
{
{
rfbScreen
->
udpSockConnected
=
FALSE
;
rfbScreen
->
udpSockConnected
=
FALSE
;
}
}
...
...
sraRegion.c
View file @
67094d7c
...
@@ -76,7 +76,7 @@ sraSpanRemove(sraSpan *span) {
...
@@ -76,7 +76,7 @@ sraSpanRemove(sraSpan *span) {
void
void
sraSpanDestroy
(
sraSpan
*
span
)
{
sraSpanDestroy
(
sraSpan
*
span
)
{
if
(
span
->
subspan
)
sraSpanListDestroy
(
span
->
subspan
);
if
(
span
->
subspan
)
sraSpanListDestroy
(
span
->
subspan
);
x
free
(
span
);
free
(
span
);
}
}
void
void
...
@@ -153,7 +153,7 @@ sraSpanListDestroy(sraSpanList *list) {
...
@@ -153,7 +153,7 @@ sraSpanListDestroy(sraSpanList *list) {
sraSpanDestroy
(
curr
);
sraSpanDestroy
(
curr
);
curr
=
next
;
curr
=
next
;
}
}
x
free
(
list
);
free
(
list
);
}
}
void
void
...
...
tableinit24.c
View file @
67094d7c
...
@@ -82,7 +82,7 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
...
@@ -82,7 +82,7 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
int
nEntries
=
1
<<
in
->
bitsPerPixel
;
int
nEntries
=
1
<<
in
->
bitsPerPixel
;
if
(
*
table
)
free
(
*
table
);
if
(
*
table
)
free
(
*
table
);
*
table
=
(
char
*
)
x
alloc
(
nEntries
*
3
+
1
);
*
table
=
(
char
*
)
m
alloc
(
nEntries
*
3
+
1
);
t
=
(
CARD8
*
)
*
table
;
t
=
(
CARD8
*
)
*
table
;
for
(
i
=
0
;
i
<
nEntries
;
i
++
)
{
for
(
i
=
0
;
i
<
nEntries
;
i
++
)
{
...
@@ -121,7 +121,7 @@ rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
...
@@ -121,7 +121,7 @@ rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
CARD8
*
blueTable
;
CARD8
*
blueTable
;
if
(
*
table
)
free
(
*
table
);
if
(
*
table
)
free
(
*
table
);
*
table
=
(
char
*
)
x
alloc
((
in
->
redMax
+
in
->
greenMax
+
in
->
blueMax
+
3
)
*
table
=
(
char
*
)
m
alloc
((
in
->
redMax
+
in
->
greenMax
+
in
->
blueMax
+
3
)
*
3
+
1
);
*
3
+
1
);
redTable
=
(
CARD8
*
)
*
table
;
redTable
=
(
CARD8
*
)
*
table
;
greenTable
=
redTable
+
3
*
(
in
->
redMax
+
1
);
greenTable
=
redTable
+
3
*
(
in
->
redMax
+
1
);
...
...
tableinittctemplate.c
View file @
67094d7c
...
@@ -66,7 +66,7 @@ rfbInitTrueColourSingleTableOUT (char **table, rfbPixelFormat *in,
...
@@ -66,7 +66,7 @@ rfbInitTrueColourSingleTableOUT (char **table, rfbPixelFormat *in,
int
nEntries
=
1
<<
in
->
bitsPerPixel
;
int
nEntries
=
1
<<
in
->
bitsPerPixel
;
if
(
*
table
)
free
(
*
table
);
if
(
*
table
)
free
(
*
table
);
*
table
=
(
char
*
)
x
alloc
(
nEntries
*
sizeof
(
OUT_T
));
*
table
=
(
char
*
)
m
alloc
(
nEntries
*
sizeof
(
OUT_T
));
t
=
(
OUT_T
*
)
*
table
;
t
=
(
OUT_T
*
)
*
table
;
for
(
i
=
0
;
i
<
nEntries
;
i
++
)
{
for
(
i
=
0
;
i
<
nEntries
;
i
++
)
{
...
@@ -104,7 +104,7 @@ rfbInitTrueColourRGBTablesOUT (char **table, rfbPixelFormat *in,
...
@@ -104,7 +104,7 @@ rfbInitTrueColourRGBTablesOUT (char **table, rfbPixelFormat *in,
OUT_T
*
blueTable
;
OUT_T
*
blueTable
;
if
(
*
table
)
free
(
*
table
);
if
(
*
table
)
free
(
*
table
);
*
table
=
(
char
*
)
x
alloc
((
in
->
redMax
+
in
->
greenMax
+
in
->
blueMax
+
3
)
*
table
=
(
char
*
)
m
alloc
((
in
->
redMax
+
in
->
greenMax
+
in
->
blueMax
+
3
)
*
sizeof
(
OUT_T
));
*
sizeof
(
OUT_T
));
redTable
=
(
OUT_T
*
)
*
table
;
redTable
=
(
OUT_T
*
)
*
table
;
greenTable
=
redTable
+
in
->
redMax
+
1
;
greenTable
=
redTable
+
in
->
redMax
+
1
;
...
...
tight.c
View file @
67094d7c
...
@@ -241,9 +241,9 @@ rfbSendRectEncodingTight(cl, x, y, w, h)
...
@@ -241,9 +241,9 @@ rfbSendRectEncodingTight(cl, x, y, w, h)
if
(
tightBeforeBufSize
<
4
)
{
if
(
tightBeforeBufSize
<
4
)
{
tightBeforeBufSize
=
4
;
tightBeforeBufSize
=
4
;
if
(
tightBeforeBuf
==
NULL
)
if
(
tightBeforeBuf
==
NULL
)
tightBeforeBuf
=
(
char
*
)
x
alloc
(
tightBeforeBufSize
);
tightBeforeBuf
=
(
char
*
)
m
alloc
(
tightBeforeBufSize
);
else
else
tightBeforeBuf
=
(
char
*
)
x
realloc
(
tightBeforeBuf
,
tightBeforeBuf
=
(
char
*
)
realloc
(
tightBeforeBuf
,
tightBeforeBufSize
);
tightBeforeBufSize
);
}
}
...
@@ -503,18 +503,18 @@ SendRectSimple(cl, x, y, w, h)
...
@@ -503,18 +503,18 @@ SendRectSimple(cl, x, y, w, h)
if
(
tightBeforeBufSize
<
maxBeforeSize
)
{
if
(
tightBeforeBufSize
<
maxBeforeSize
)
{
tightBeforeBufSize
=
maxBeforeSize
;
tightBeforeBufSize
=
maxBeforeSize
;
if
(
tightBeforeBuf
==
NULL
)
if
(
tightBeforeBuf
==
NULL
)
tightBeforeBuf
=
(
char
*
)
x
alloc
(
tightBeforeBufSize
);
tightBeforeBuf
=
(
char
*
)
m
alloc
(
tightBeforeBufSize
);
else
else
tightBeforeBuf
=
(
char
*
)
x
realloc
(
tightBeforeBuf
,
tightBeforeBuf
=
(
char
*
)
realloc
(
tightBeforeBuf
,
tightBeforeBufSize
);
tightBeforeBufSize
);
}
}
if
(
tightAfterBufSize
<
maxAfterSize
)
{
if
(
tightAfterBufSize
<
maxAfterSize
)
{
tightAfterBufSize
=
maxAfterSize
;
tightAfterBufSize
=
maxAfterSize
;
if
(
tightAfterBuf
==
NULL
)
if
(
tightAfterBuf
==
NULL
)
tightAfterBuf
=
(
char
*
)
x
alloc
(
tightAfterBufSize
);
tightAfterBuf
=
(
char
*
)
m
alloc
(
tightAfterBufSize
);
else
else
tightAfterBuf
=
(
char
*
)
x
realloc
(
tightAfterBuf
,
tightAfterBuf
=
(
char
*
)
realloc
(
tightAfterBuf
,
tightAfterBufSize
);
tightAfterBufSize
);
}
}
...
@@ -844,7 +844,7 @@ SendGradientRect(cl, w, h)
...
@@ -844,7 +844,7 @@ SendGradientRect(cl, w, h)
}
}
if
(
prevRowBuf
==
NULL
)
if
(
prevRowBuf
==
NULL
)
prevRowBuf
=
(
int
*
)
x
alloc
(
2048
*
3
*
sizeof
(
int
));
prevRowBuf
=
(
int
*
)
m
alloc
(
2048
*
3
*
sizeof
(
int
));
cl
->
updateBuf
[
cl
->
ublen
++
]
=
(
streamId
|
rfbTightExplicitFilter
)
<<
4
;
cl
->
updateBuf
[
cl
->
ublen
++
]
=
(
streamId
|
rfbTightExplicitFilter
)
<<
4
;
cl
->
updateBuf
[
cl
->
ublen
++
]
=
rfbTightFilterGradient
;
cl
->
updateBuf
[
cl
->
ublen
++
]
=
rfbTightFilterGradient
;
...
@@ -1645,7 +1645,7 @@ SendJpegRect(cl, x, y, w, h, quality)
...
@@ -1645,7 +1645,7 @@ SendJpegRect(cl, x, y, w, h, quality)
if
(
cl
->
screen
->
rfbServerFormat
.
bitsPerPixel
==
8
)
if
(
cl
->
screen
->
rfbServerFormat
.
bitsPerPixel
==
8
)
return
SendFullColorRect
(
cl
,
w
,
h
);
return
SendFullColorRect
(
cl
,
w
,
h
);
srcBuf
=
(
CARD8
*
)
x
alloc
(
w
*
3
);
srcBuf
=
(
CARD8
*
)
m
alloc
(
w
*
3
);
if
(
srcBuf
==
NULL
)
{
if
(
srcBuf
==
NULL
)
{
return
SendFullColorRect
(
cl
,
w
,
h
);
return
SendFullColorRect
(
cl
,
w
,
h
);
}
}
...
...
zlib.c
View file @
67094d7c
...
@@ -75,9 +75,9 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
...
@@ -75,9 +75,9 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
if
(
zlibBeforeBufSize
<
maxRawSize
)
{
if
(
zlibBeforeBufSize
<
maxRawSize
)
{
zlibBeforeBufSize
=
maxRawSize
;
zlibBeforeBufSize
=
maxRawSize
;
if
(
zlibBeforeBuf
==
NULL
)
if
(
zlibBeforeBuf
==
NULL
)
zlibBeforeBuf
=
(
char
*
)
x
alloc
(
zlibBeforeBufSize
);
zlibBeforeBuf
=
(
char
*
)
m
alloc
(
zlibBeforeBufSize
);
else
else
zlibBeforeBuf
=
(
char
*
)
x
realloc
(
zlibBeforeBuf
,
zlibBeforeBufSize
);
zlibBeforeBuf
=
(
char
*
)
realloc
(
zlibBeforeBuf
,
zlibBeforeBufSize
);
}
}
/* zlib compression is not useful for very small data sets.
/* zlib compression is not useful for very small data sets.
...
@@ -115,9 +115,9 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
...
@@ -115,9 +115,9 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
if
(
zlibAfterBufSize
<
maxCompSize
)
{
if
(
zlibAfterBufSize
<
maxCompSize
)
{
zlibAfterBufSize
=
maxCompSize
;
zlibAfterBufSize
=
maxCompSize
;
if
(
zlibAfterBuf
==
NULL
)
if
(
zlibAfterBuf
==
NULL
)
zlibAfterBuf
=
(
char
*
)
x
alloc
(
zlibAfterBufSize
);
zlibAfterBuf
=
(
char
*
)
m
alloc
(
zlibAfterBufSize
);
else
else
zlibAfterBuf
=
(
char
*
)
x
realloc
(
zlibAfterBuf
,
zlibAfterBufSize
);
zlibAfterBuf
=
(
char
*
)
realloc
(
zlibAfterBuf
,
zlibAfterBufSize
);
}
}
/*
/*
...
...
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