global structures/functions should have "rfb", "sra" or "zrle" as prefix,

while structure members should not
pull/1/head
dscho 20 years ago
parent 0d3b958b47
commit 97299606da

@ -29,7 +29,7 @@ int main (int argc, char **argv)
server = rfbGetScreen (&argc, argv, maxx, maxy, 8, 3, bpp);
server->desktopName = "Zippy das wundersquirrel\'s VNC server";
server->frameBuffer = (char*)malloc(maxx*maxy*bpp);
server->rfbAlwaysShared = TRUE;
server->alwaysShared = TRUE;
server->kbdAddEvent = on_key_press;
server->ptrAddEvent = on_mouse_event;
@ -76,7 +76,7 @@ void draw_primary_colors (char* frame_buffer, int x1, int y1, int x2, int y2)
/* Dscho's versions (slower, but works for bpp != 3 or 4) */
void draw_primary_colours_generic(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2)
{
rfbPixelFormat f=s->rfbServerFormat;
rfbPixelFormat f=s->serverFormat;
int i,j;
for(j=y1;j<y2;j++)
for(i=x1;i<x2;i++)
@ -90,7 +90,7 @@ void draw_primary_colours_generic(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2
void draw_primary_colours_generic_fast(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2)
{
rfbPixelFormat f=s->rfbServerFormat;
rfbPixelFormat f=s->serverFormat;
int i,j,y3=(y1*2+y2)/3,y4=(y1+y2*2)/3;
/* draw first pixel */
rfbDrawPixel(s,x1,y1,f.redMax<<f.redShift);
@ -108,7 +108,7 @@ void draw_primary_colours_generic_fast(rfbScreenInfoPtr s,int x1,int y1,int x2,i
void draw_primary_colours_generic_ultrafast(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2)
{
rfbPixelFormat f=s->rfbServerFormat;
rfbPixelFormat f=s->serverFormat;
int y3=(y1*2+y2)/3,y4=(y1+y2*2)/3;
/* fill rectangles */
rfbFillRect(s,x1,y1,x2,y3,f.redMax<<f.redShift);

@ -8,7 +8,7 @@ int main(int argc,char** argv)
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,256,256,8,1,1);
server->rfbServerFormat.trueColour=FALSE;
server->serverFormat.trueColour=FALSE;
server->colourMap.count=256;
server->colourMap.is16=FALSE;
for(i=0;i<256;i++) {

@ -157,7 +157,7 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
cd->oldx=x; cd->oldy=y; cd->oldButton=buttonMask;
}
defaultPtrAddEvent(buttonMask,x,y,cl);
rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
}
/* aux function to draw a character to x, y */
@ -277,7 +277,7 @@ int main(int argc,char** argv)
rfbGetScreen(&argc,argv,maxx,maxy,8,3,bpp);
rfbScreen->desktopName = "LibVNCServer Example";
rfbScreen->frameBuffer = (char*)malloc(maxx*maxy*bpp);
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->alwaysShared = TRUE;
rfbScreen->ptrAddEvent = doptr;
rfbScreen->kbdAddEvent = dokey;
rfbScreen->newClientHook = newclient;

@ -64,7 +64,7 @@ int main(int argc,char** argv)
rfbScreen->desktopName = argv[1];
else
rfbScreen->desktopName = "Picture";
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->alwaysShared = TRUE;
rfbScreen->kbdAddEvent = HandleKey;
/* enable http */
@ -76,7 +76,7 @@ int main(int argc,char** argv)
fclose(in);
if(picType!=TRUECOLOUR) {
rfbScreen->rfbServerFormat.trueColour=FALSE;
rfbScreen->serverFormat.trueColour=FALSE;
rfbScreen->colourMap.count=256;
rfbScreen->colourMap.is16=FALSE;
rfbScreen->colourMap.data.bytes=malloc(256*3);

@ -57,7 +57,7 @@ int main(int argc,char** argv)
rfbScreen->desktopName = argv[1];
else
rfbScreen->desktopName = "Picture";
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->alwaysShared = TRUE;
rfbScreen->kbdAddEvent = HandleKey;
/* enable http */

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
if (argc != 3)
usage();
if (vncEncryptAndStorePasswd(argv[1], argv[2]) != 0) {
if (rfbEncryptAndStorePasswd(argv[1], argv[2]) != 0) {
printf("storing password failed.\n");
return 1;
} else {

@ -105,7 +105,7 @@ int main(int argc,char** argv)
s->colourMap.is16=FALSE;
s->colourMap.count=2;
s->colourMap.data.bytes=(unsigned char*)"\xd0\xd0\xd0\x30\x01\xe0";
s->rfbServerFormat.trueColour=FALSE;
s->serverFormat.trueColour=FALSE;
s->frameBuffer=f;
s->kbdAddEvent=dokey;
s->ptrAddEvent=doptr;

@ -246,7 +246,7 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
return SetNonBlocking(client->sock);
}
static void rfbEncryptBytes(unsigned char *bytes, char *passwd);
extern void rfbClientEncryptBytes(unsigned char* bytes, char* passwd);
/*
* InitialiseRFBConnection.
@ -327,7 +327,7 @@ InitialiseRFBConnection(rfbClient* client)
passwd[8] = '\0';
}
rfbEncryptBytes(challenge, passwd);
rfbClientEncryptBytes(challenge, passwd);
/* Lose the password from memory */
for (i = strlen(passwd); i >= 0; i--) {
@ -1136,14 +1136,14 @@ JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData,
/* avoid name clashes with LibVNCServer */
#define vncEncryptBytes rfbEncryptBytes
#define vncEncryptAndStorePasswd rfbEncryptAndStorePasswdUnused
#define vncDecryptPasswdFromFile rfbDecryptPasswdFromFileUnused
#define vncRandomBytes rfbRandomBytesUnused
#define des rfbDES
#define deskey rfbDESKey
#define usekey rfbUseKey
#define cpkey rfbCPKey
#define rfbEncryptBytes rfbClientEncryptBytes
#define rfbEncryptAndStorePasswd rfbClientEncryptAndStorePasswdUnused
#define rfbDecryptPasswdFromFile rfbClientDecryptPasswdFromFileUnused
#define rfbRandomBytes rfbClientRandomBytesUnused
#define rfbDes rfbClientDes
#define rfbDesKey rfbClientDesKey
#define rfbUseKey rfbClientUseKey
#define rfbCPKey rfbClientCPKey
#include "../libvncserver/vncauth.c"
#include "../libvncserver/d3des.c"

@ -43,9 +43,9 @@ rfbAuthNewClient(cl)
cl->state = RFB_AUTHENTICATION;
if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) {
if (cl->screen->authPasswdData && !cl->reverseConnection) {
*(uint32_t *)buf = Swap32IfLE(rfbVncAuth);
vncRandomBytes(cl->authChallenge);
rfbRandomBytes(cl->authChallenge);
memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE);
len = 4 + CHALLENGESIZE;
} else {
@ -54,7 +54,7 @@ rfbAuthNewClient(cl)
cl->state = RFB_INITIALISATION;
}
if (WriteExact(cl, buf, len) < 0) {
if (rfbWriteExact(cl, buf, len) < 0) {
rfbLogPerror("rfbAuthNewClient: write");
rfbCloseClient(cl);
return;
@ -75,7 +75,7 @@ rfbAuthProcessClientMessage(cl)
uint8_t response[CHALLENGESIZE];
uint32_t authResult;
if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) {
if ((n = rfbReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) {
if (n != 0)
rfbLogPerror("rfbAuthProcessClientMessage: read");
rfbCloseClient(cl);
@ -85,7 +85,7 @@ rfbAuthProcessClientMessage(cl)
if(!cl->screen->passwordCheck(cl,(const char*)response,CHALLENGESIZE)) {
rfbErr("rfbAuthProcessClientMessage: password check failed\n");
authResult = Swap32IfLE(rfbVncAuthFailed);
if (WriteExact(cl, (char *)&authResult, 4) < 0) {
if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
}
rfbCloseClient(cl);
@ -94,7 +94,7 @@ rfbAuthProcessClientMessage(cl)
authResult = Swap32IfLE(rfbVncAuthOK);
if (WriteExact(cl, (char *)&authResult, 4) < 0) {
if (rfbWriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");
rfbCloseClient(cl);
return;

@ -64,19 +64,19 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
rfbUsage();
return FALSE;
}
rfbScreen->rfbPort = atoi(argv[++i]);
rfbScreen->port = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbwait") == 0) { /* -rfbwait ms */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->rfbMaxClientWait = atoi(argv[++i]);
rfbScreen->maxClientWait = atoi(argv[++i]);
} else if (strcmp(argv[i], "-rfbauth") == 0) { /* -rfbauth passwd-file */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->rfbAuthPasswdData = argv[++i];
rfbScreen->authPasswdData = argv[++i];
} else if (strcmp(argv[i], "-passwd") == 0) { /* -passwd password */
char **passwds = malloc(sizeof(char**)*2);
if (i + 1 >= *argc) {
@ -85,14 +85,14 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
}
passwds[0] = argv[++i];
passwds[1] = 0;
rfbScreen->rfbAuthPasswdData = (void*)passwds;
rfbScreen->authPasswdData = (void*)passwds;
rfbScreen->passwordCheck = rfbCheckPasswordByList;
} else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */
if (i + 1 >= *argc) {
rfbUsage();
return FALSE;
}
rfbScreen->rfbDeferUpdateTime = atoi(argv[++i]);
rfbScreen->deferUpdateTime = atoi(argv[++i]);
} else if (strcmp(argv[i], "-desktop") == 0) { /* -desktop desktop-name */
if (i + 1 >= *argc) {
rfbUsage();
@ -100,11 +100,11 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
}
rfbScreen->desktopName = argv[++i];
} else if (strcmp(argv[i], "-alwaysshared") == 0) {
rfbScreen->rfbAlwaysShared = TRUE;
rfbScreen->alwaysShared = TRUE;
} else if (strcmp(argv[i], "-nevershared") == 0) {
rfbScreen->rfbNeverShared = TRUE;
rfbScreen->neverShared = TRUE;
} else if (strcmp(argv[i], "-dontdisconnect") == 0) {
rfbScreen->rfbDontDisconnect = TRUE;
rfbScreen->dontDisconnect = TRUE;
} else if (strcmp(argv[i], "-httpdir") == 0) { /* -httpdir directory-path */
if (i + 1 >= *argc) {
rfbUsage();

@ -115,7 +115,7 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
rreAfterBuf = (char *)realloc(rreAfterBuf, rreAfterBufSize);
}
(*cl->translateFn)(cl->translateLookupTable,&(cl->screen->rfbServerFormat),
(*cl->translateFn)(cl->translateLookupTable,&(cl->screen->serverFormat),
&cl->format, fbptr, rreBeforeBuf,
cl->screen->paddedWidthInBytes, w, h);
@ -141,8 +141,8 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
return rfbSendRectEncodingRaw(cl, x, y, w, h);
}
cl->rfbRectanglesSent[rfbEncodingCoRRE]++;
cl->rfbBytesSent[rfbEncodingCoRRE] += (sz_rfbFramebufferUpdateRectHeader
cl->rectanglesSent[rfbEncodingCoRRE]++;
cl->bytesSent[rfbEncodingCoRRE] += (sz_rfbFramebufferUpdateRectHeader
+ sz_rfbRREHeader + rreAfterBufLen);
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader

@ -46,11 +46,11 @@ rfbSendCursorShape(cl)
if (cl->useRichCursorEncoding) {
if(pCursor && !pCursor->richSource)
MakeRichCursorFromXCursor(cl->screen,pCursor);
rfbMakeRichCursorFromXCursor(cl->screen,pCursor);
rect.encoding = Swap32IfLE(rfbEncodingRichCursor);
} else {
if(pCursor && !pCursor->source)
MakeXCursorFromRichCursor(cl->screen,pCursor);
rfbMakeXCursorFromRichCursor(cl->screen,pCursor);
rect.encoding = Swap32IfLE(rfbEncodingXCursor);
}
@ -73,8 +73,8 @@ rfbSendCursorShape(cl)
sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbCursorShapeBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->rfbCursorShapeUpdatesSent++;
cl->cursorShapeBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->cursorShapeUpdatesSent++;
if (!rfbSendUpdateBuf(cl))
return FALSE;
@ -139,10 +139,10 @@ rfbSendCursorShape(cl)
}
} else {
/* RichCursor encoding. */
int bpp1=cl->screen->rfbServerFormat.bitsPerPixel/8,
int bpp1=cl->screen->serverFormat.bitsPerPixel/8,
bpp2=cl->format.bitsPerPixel/8;
(*cl->translateFn)(cl->translateLookupTable,
&(cl->screen->rfbServerFormat),
&(cl->screen->serverFormat),
&cl->format, (char*)pCursor->richSource,
&cl->updateBuf[cl->ublen],
pCursor->width*bpp1, pCursor->width, pCursor->height);
@ -163,8 +163,8 @@ rfbSendCursorShape(cl)
/* Send everything we have prepared in the cl->updateBuf[]. */
cl->rfbCursorShapeBytesSent += (cl->ublen - saved_ublen);
cl->rfbCursorShapeUpdatesSent++;
cl->cursorShapeBytesSent += (cl->ublen - saved_ublen);
cl->cursorShapeUpdatesSent++;
if (!rfbSendUpdateBuf(cl))
return FALSE;
@ -196,8 +196,8 @@ rfbSendCursorPos(rfbClientPtr cl)
sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbCursorPosBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->rfbCursorPosUpdatesSent++;
cl->cursorPosBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->cursorPosUpdatesSent++;
if (!rfbSendUpdateBuf(cl))
return FALSE;
@ -326,9 +326,9 @@ void rfbFreeCursor(rfbCursorPtr cursor)
}
/* background and foregroud colour have to be set beforehand */
void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
{
rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
rfbPixelFormat* format=&rfbScreen->serverFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8,
width=cursor->width*bpp;
uint32_t background;
@ -352,9 +352,9 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
cursor->source[j*w+i/8]|=bit;
}
void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
{
rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
rfbPixelFormat* format=&rfbScreen->serverFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8;
uint32_t background,foreground;
char *back=(char*)&background,*fore=(char*)&foreground;
@ -387,7 +387,7 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
void rfbUndrawCursor(rfbScreenInfoPtr s)
{
rfbCursorPtr c=s->cursor;
int j,x1,x2,y1,y2,bpp=s->rfbServerFormat.bitsPerPixel/8,
int j,x1,x2,y1,y2,bpp=s->serverFormat.bitsPerPixel/8,
rowstride=s->paddedWidthInBytes;
LOCK(s->cursorMutex);
if(!s->cursorIsDrawn || !c) {
@ -429,7 +429,7 @@ void rfbUndrawCursor(rfbScreenInfoPtr s)
void rfbDrawCursor(rfbScreenInfoPtr s)
{
rfbCursorPtr c=s->cursor;
int i,j,x1,x2,y1,y2,i1,j1,bpp=s->rfbServerFormat.bitsPerPixel/8,
int i,j,x1,x2,y1,y2,i1,j1,bpp=s->serverFormat.bitsPerPixel/8,
rowstride=s->paddedWidthInBytes,
bufSize,w;
rfbBool wasChanged=FALSE;
@ -487,7 +487,7 @@ void rfbDrawCursor(rfbScreenInfoPtr s)
}
if(!c->richSource)
MakeRichCursorFromXCursor(s,c);
rfbMakeRichCursorFromXCursor(s,c);
/* now the cursor has to be drawn */
for(j=0;j<y2;j++)

@ -71,7 +71,7 @@ static unsigned char pc2[48] = {
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
void deskey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
void rfbDesKey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
unsigned char *key;
int edf;
{
@ -127,11 +127,11 @@ register unsigned long *raw1;
*cook |= (*raw1 & 0x0003f000L) >> 4;
*cook++ |= (*raw1 & 0x0000003fL);
}
usekey(dough);
rfbUseKey(dough);
return;
}
void cpkey(into)
void rfbCPKey(into)
register unsigned long *into;
{
register unsigned long *from, *endp;
@ -141,7 +141,7 @@ register unsigned long *into;
return;
}
void usekey(from)
void rfbUseKey(from)
register unsigned long *from;
{
register unsigned long *to, *endp;
@ -151,7 +151,7 @@ register unsigned long *from;
return;
}
void des(inblock, outblock)
void rfbDes(inblock, outblock)
unsigned char *inblock, *outblock;
{
unsigned long work[2];

@ -25,25 +25,25 @@
#define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */
extern void deskey(unsigned char *, int);
extern void rfbDesKey(unsigned char *, int);
/* hexkey[8] MODE
* Sets the internal key register according to the hexadecimal
* key contained in the 8 bytes of hexkey, according to the DES,
* for encryption or decryption according to MODE.
*/
extern void usekey(unsigned long *);
extern void rfbUseKey(unsigned long *);
/* cookedkey[32]
* Loads the internal key register with the data in cookedkey.
*/
extern void cpkey(unsigned long *);
extern void rfbCPKey(unsigned long *);
/* cookedkey[32]
* Copies the contents of the internal key register into the storage
* located at &cookedkey[0].
*/
extern void des(unsigned char *, unsigned char *);
extern void rfbDes(unsigned char *, unsigned char *);
/* from[8] to[8]
* Encrypts/Decrypts (according to the key currently loaded in the
* internal key register) one block of eight bytes at address 'from'

@ -7,7 +7,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
unsigned char* data=font->data+font->metaData[c*5];
unsigned char d=*data;
int rowstride=rfbScreen->paddedWidthInBytes;
int bpp=rfbScreen->rfbServerFormat.bitsPerPixel/8;
int bpp=rfbScreen->serverFormat.bitsPerPixel/8;
char *colour=(char*)&col;
if(!rfbEndianTest)
@ -52,7 +52,7 @@ int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
unsigned char* data=font->data+font->metaData[c*5];
unsigned char d;
int rowstride=rfbScreen->paddedWidthInBytes;
int bpp=rfbScreen->rfbServerFormat.bitsPerPixel/8,extra_bytes=0;
int bpp=rfbScreen->serverFormat.bitsPerPixel/8,extra_bytes=0;
char* colour=(char*)&col;
char* bcolour=(char*)&bcol;

@ -58,8 +58,8 @@ rfbSendRectEncodingHextile(cl, x, y, w, h)
sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbRectanglesSent[rfbEncodingHextile]++;
cl->rfbBytesSent[rfbEncodingHextile] += sz_rfbFramebufferUpdateRectHeader;
cl->rectanglesSent[rfbEncodingHextile]++;
cl->bytesSent[rfbEncodingHextile] += sz_rfbFramebufferUpdateRectHeader;
switch (cl->format.bitsPerPixel) {
case 8:
@ -130,7 +130,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) \
+ (x * (cl->screen->bitsPerPixel / 8))); \
\
(*cl->translateFn)(cl->translateLookupTable, &(cl->screen->rfbServerFormat), \
(*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), \
&cl->format, fbptr, (char *)clientPixelData, \
cl->screen->paddedWidthInBytes, w, h); \
\
@ -149,7 +149,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
} \
\
if (solid) { \
cl->rfbBytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
continue; \
} \
\
@ -174,7 +174,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
cl->ublen = startUblen; \
cl->updateBuf[cl->ublen++] = rfbHextileRaw; \
(*cl->translateFn)(cl->translateLookupTable, \
&(cl->screen->rfbServerFormat), &cl->format, fbptr, \
&(cl->screen->serverFormat), &cl->format, fbptr, \
(char *)clientPixelData, \
cl->screen->paddedWidthInBytes, w, h); \
\
@ -184,7 +184,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
cl->ublen += w * h * (bpp/8); \
} \
\
cl->rfbBytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
} \
} \
\

@ -84,7 +84,7 @@ static size_t buf_filled=0;
*/
void
httpInitSockets(rfbScreenInfoPtr rfbScreen)
rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen)
{
if (rfbScreen->httpInitDone)
return;
@ -95,14 +95,14 @@ httpInitSockets(rfbScreenInfoPtr rfbScreen)
return;
if (rfbScreen->httpPort == 0) {
rfbScreen->httpPort = rfbScreen->rfbPort-100;
rfbScreen->httpPort = rfbScreen->port-100;
}
rfbLog("Listening for HTTP connections on TCP port %d\n", rfbScreen->httpPort);
rfbLog(" URL http://%s:%d\n",rfbScreen->rfbThisHost,rfbScreen->httpPort);
rfbLog(" URL http://%s:%d\n",rfbScreen->thisHost,rfbScreen->httpPort);
if ((rfbScreen->httpListenSock = ListenOnTCPPort(rfbScreen->httpPort)) < 0) {
if ((rfbScreen->httpListenSock = rfbListenOnTCPPort(rfbScreen->httpPort)) < 0) {
rfbLogPerror("ListenOnTCPPort");
return;
}
@ -117,7 +117,7 @@ httpInitSockets(rfbScreenInfoPtr rfbScreen)
*/
void
httpCheckFds(rfbScreenInfoPtr rfbScreen)
rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
{
int nfds;
fd_set fds;
@ -274,15 +274,15 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if(rfbScreen->httpEnableProxyConnect) {
const static char* PROXY_OK_STR = "HTTP/1.0 200 OK\r\nContent-Type: octet-stream\r\nPragma: no-cache\r\n\r\n";
if(!strncmp(buf, "CONNECT ", 8)) {
if(atoi(strchr(buf, ':')+1)!=rfbScreen->rfbPort) {
if(atoi(strchr(buf, ':')+1)!=rfbScreen->port) {
rfbErr("httpd: CONNECT format invalid.\n");
WriteExact(&cl,INVALID_REQUEST_STR, strlen(INVALID_REQUEST_STR));
rfbWriteExact(&cl,INVALID_REQUEST_STR, strlen(INVALID_REQUEST_STR));
httpCloseSock(rfbScreen);
return;
}
/* proxy connection */
rfbLog("httpd: client asked for CONNECT\n");
WriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR));
rfbWriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR));
rfbNewClientConnection(rfbScreen,rfbScreen->httpSock);
rfbScreen->httpSock = -1;
return;
@ -290,7 +290,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if (!strncmp(buf, "GET ",4) && !strncmp(strchr(buf,'/'),"/proxied.connection HTTP/1.", 27)) {
/* proxy connection */
rfbLog("httpd: client asked for /proxied.connection\n");
WriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR));
rfbWriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR));
rfbNewClientConnection(rfbScreen,rfbScreen->httpSock);
rfbScreen->httpSock = -1;
return;
@ -320,14 +320,14 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if (fname[0] != '/') {
rfbErr("httpd: filename didn't begin with '/'\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
}
if (strchr(fname+1, '/') != NULL) {
rfbErr("httpd: asking for file in other directory\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
}
@ -366,12 +366,12 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if ((fd = fopen(fullFname, "r")) == 0) {
rfbLogPerror("httpProcessInput: open");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
rfbWriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
}
WriteExact(&cl, OK_STR, strlen(OK_STR));
rfbWriteExact(&cl, OK_STR, strlen(OK_STR));
while (1) {
int n = fread(buf, 1, BUF_SIZE-1, fd);
@ -397,74 +397,74 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
buf[n] = 0; /* make sure it's null-terminated */
while ((dollar = strchr(ptr, '$'))!=NULL) {
WriteExact(&cl, ptr, (dollar - ptr));
rfbWriteExact(&cl, ptr, (dollar - ptr));
ptr = dollar;
if (compareAndSkip(&ptr, "$WIDTH")) {
sprintf(str, "%d", rfbScreen->width);
WriteExact(&cl, str, strlen(str));
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$HEIGHT")) {
sprintf(str, "%d", rfbScreen->height);
WriteExact(&cl, str, strlen(str));
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$APPLETWIDTH")) {
sprintf(str, "%d", rfbScreen->width);
WriteExact(&cl, str, strlen(str));
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$APPLETHEIGHT")) {
sprintf(str, "%d", rfbScreen->height + 32);
WriteExact(&cl, str, strlen(str));
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$PORT")) {
sprintf(str, "%d", rfbScreen->rfbPort);
WriteExact(&cl, str, strlen(str));
sprintf(str, "%d", rfbScreen->port);
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$DESKTOP")) {
WriteExact(&cl, rfbScreen->desktopName, strlen(rfbScreen->desktopName));
rfbWriteExact(&cl, rfbScreen->desktopName, strlen(rfbScreen->desktopName));
} else if (compareAndSkip(&ptr, "$DISPLAY")) {
sprintf(str, "%s:%d", rfbScreen->rfbThisHost, rfbScreen->rfbPort-5900);
WriteExact(&cl, str, strlen(str));
sprintf(str, "%s:%d", rfbScreen->thisHost, rfbScreen->port-5900);
rfbWriteExact(&cl, str, strlen(str));
} else if (compareAndSkip(&ptr, "$USER")) {
#ifndef WIN32
if (user) {
WriteExact(&cl, user,
rfbWriteExact(&cl, user,
strlen(user));
} else
#endif
WriteExact(&cl, "?", 1);
rfbWriteExact(&cl, "?", 1);
} else if (compareAndSkip(&ptr, "$PARAMS")) {
if (params[0] != '\0')
WriteExact(&cl, params, strlen(params));
rfbWriteExact(&cl, params, strlen(params));
} else {
if (!compareAndSkip(&ptr, "$$"))
ptr++;
if (WriteExact(&cl, "$", 1) < 0) {
if (rfbWriteExact(&cl, "$", 1) < 0) {
fclose(fd);
httpCloseSock(rfbScreen);
return;
}
}
}
if (WriteExact(&cl, ptr, (&buf[n] - ptr)) < 0)
if (rfbWriteExact(&cl, ptr, (&buf[n] - ptr)) < 0)
break;
} else {
/* For files not ending .vnc, just write out the buffer */
if (WriteExact(&cl, buf, n) < 0)
if (rfbWriteExact(&cl, buf, n) < 0)
break;
}
}

@ -159,22 +159,22 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in
rfbReleaseClientIterator(iterator);
}
void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy)
void rfbDoCopyRegion(rfbScreenInfoPtr screen,sraRegionPtr copyRegion,int dx,int dy)
{
sraRectangleIterator* i;
sraRect rect;
int j,widthInBytes,bpp=rfbScreen->rfbServerFormat.bitsPerPixel/8,
rowstride=rfbScreen->paddedWidthInBytes;
int j,widthInBytes,bpp=screen->serverFormat.bitsPerPixel/8,
rowstride=screen->paddedWidthInBytes;
char *in,*out;
rfbUndrawCursor(rfbScreen);
rfbUndrawCursor(screen);
/* copy it, really */
i = sraRgnGetReverseIterator(copyRegion,dx<0,dy<0);
while(sraRgnIteratorNext(i,&rect)) {
widthInBytes = (rect.x2-rect.x1)*bpp;
out = rfbScreen->frameBuffer+rect.x1*bpp+rect.y1*rowstride;
in = rfbScreen->frameBuffer+(rect.x1-dx)*bpp+(rect.y1-dy)*rowstride;
out = screen->frameBuffer+rect.x1*bpp+rect.y1*rowstride;
in = screen->frameBuffer+(rect.x1-dx)*bpp+(rect.y1-dy)*rowstride;
if(dy<0)
for(j=rect.y1;j<rect.y2;j++,out+=rowstride,in+=rowstride)
memmove(out,in,widthInBytes);
@ -186,27 +186,27 @@ void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,i
}
}
rfbScheduleCopyRegion(rfbScreen,copyRegion,dx,dy);
rfbScheduleCopyRegion(screen,copyRegion,dx,dy);
}
void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy)
void rfbDoCopyRect(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2,int dx,int dy)
{
sraRegionPtr region = sraRgnCreateRect(x1,y1,x2,y2);
rfbDoCopyRegion(rfbScreen,region,dx,dy);
rfbDoCopyRegion(screen,region,dx,dy);
}
void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy)
void rfbScheduleCopyRect(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2,int dx,int dy)
{
sraRegionPtr region = sraRgnCreateRect(x1,y1,x2,y2);
rfbScheduleCopyRegion(rfbScreen,region,dx,dy);
rfbScheduleCopyRegion(screen,region,dx,dy);
}
void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion)
void rfbMarkRegionAsModified(rfbScreenInfoPtr screen,sraRegionPtr modRegion)
{
rfbClientIteratorPtr iterator;
rfbClientPtr cl;
iterator=rfbGetClientIterator(rfbScreen);
iterator=rfbGetClientIterator(screen);
while((cl=rfbClientIteratorNext(iterator))) {
LOCK(cl->updateMutex);
sraRgnOr(cl->modifiedRegion,modRegion);
@ -217,23 +217,23 @@ void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion)
rfbReleaseClientIterator(iterator);
}
void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2)
void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2)
{
sraRegionPtr region;
int i;
if(x1>x2) { i=x1; x1=x2; x2=i; }
if(x1<0) x1=0;
if(x2>=rfbScreen->width) x2=rfbScreen->width-1;
if(x2>=screen->width) x2=screen->width-1;
if(x1==x2) return;
if(y1>y2) { i=y1; y1=y2; y2=i; }
if(y1<0) y1=0;
if(y2>=rfbScreen->height) y2=rfbScreen->height-1;
if(y2>=screen->height) y2=screen->height-1;
if(y1==y2) return;
region = sraRgnCreateRect(x1,y1,x2,y2);
rfbMarkRegionAsModified(rfbScreen,region);
rfbMarkRegionAsModified(screen,region);
sraRgnDestroy(region);
}
@ -269,7 +269,7 @@ clientOutput(void *data)
/* OK, now, to save bandwidth, wait a little while for more
updates to come along. */
usleep(cl->screen->rfbDeferUpdateTime * 1000);
usleep(cl->screen->deferUpdateTime * 1000);
/* Now, get the region we're going to update, and remove
it from cl->modifiedRegion _before_ we send the update.
@ -319,7 +319,7 @@ clientInput(void *data)
static void*
listenerRun(void *data)
{
rfbScreenInfoPtr rfbScreen=(rfbScreenInfoPtr)data;
rfbScreenInfoPtr screen=(rfbScreenInfoPtr)data;
int client_fd;
struct sockaddr_in peer;
rfbClientPtr cl;
@ -328,9 +328,9 @@ listenerRun(void *data)
len = sizeof(peer);
/* TODO: this thread wont die by restarting the server */
while ((client_fd = accept(rfbScreen->rfbListenSock,
while ((client_fd = accept(screen->listenSock,
(struct sockaddr*)&peer, &len)) >= 0) {
cl = rfbNewClient(rfbScreen,client_fd);
cl = rfbNewClient(screen,client_fd);
len = sizeof(peer);
if (cl && !cl->onHold )
@ -363,12 +363,12 @@ rfbRefuseOnHoldClient(rfbClientPtr cl)
}
static void
defaultKbdAddEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl)
rfbDefaultKbdAddEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl)
{
}
void
defaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
rfbDefaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
{
rfbClientIteratorPtr iterator;
rfbClientPtr other_client;
@ -398,7 +398,7 @@ defaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
}
}
void defaultSetXCutText(char* text, int len, rfbClientPtr cl)
void rfbDefaultSetXCutText(char* text, int len, rfbClientPtr cl)
{
}
@ -431,23 +431,23 @@ static rfbCursor myCursor =
};
#endif
rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
rfbCursorPtr rfbDefaultGetCursorPtr(rfbClientPtr cl)
{
return(cl->screen->cursor);
}
/* response is cl->authChallenge vncEncrypted with passwd */
rfbBool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
rfbBool rfbDefaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
{
int i;
char *passwd=vncDecryptPasswdFromFile(cl->screen->rfbAuthPasswdData);
char *passwd=rfbDecryptPasswdFromFile(cl->screen->authPasswdData);
if(!passwd) {
rfbErr("Couldn't read password file: %s\n",cl->screen->rfbAuthPasswdData);
rfbErr("Couldn't read password file: %s\n",cl->screen->authPasswdData);
return(FALSE);
}
vncEncryptBytes(cl->authChallenge, passwd);
rfbEncryptBytes(cl->authChallenge, passwd);
/* Lose the password from memory */
for (i = strlen(passwd); i >= 0; i--) {
@ -457,7 +457,7 @@ rfbBool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
free(passwd);
if (memcmp(cl->authChallenge, response, len) != 0) {
rfbErr("rfbAuthProcessClientMessage: authentication failed from %s\n",
rfbErr("authProcessClientMessage: authentication failed from %s\n",
cl->host);
return(FALSE);
}
@ -465,55 +465,55 @@ rfbBool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
return(TRUE);
}
/* for this method, rfbAuthPasswdData is really a pointer to an array
/* for this method, authPasswdData is really a pointer to an array
of char*'s, where the last pointer is 0. */
rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len)
{
char **passwds;
int i=0;
for(passwds=(char**)cl->screen->rfbAuthPasswdData;*passwds;passwds++,i++) {
for(passwds=(char**)cl->screen->authPasswdData;*passwds;passwds++,i++) {
uint8_t auth_tmp[CHALLENGESIZE];
memcpy((char *)auth_tmp, (char *)cl->authChallenge, CHALLENGESIZE);
vncEncryptBytes(auth_tmp, *passwds);
rfbEncryptBytes(auth_tmp, *passwds);
if (memcmp(auth_tmp, response, len) == 0) {
if(i>=cl->screen->rfbAuthPasswdFirstViewOnly)
if(i>=cl->screen->authPasswdFirstViewOnly)
cl->viewOnly=TRUE;
return(TRUE);
}
}
rfbErr("rfbAuthProcessClientMessage: authentication failed from %s\n",
rfbErr("authProcessClientMessage: authentication failed from %s\n",
cl->host);
return(FALSE);
}
void doNothingWithClient(rfbClientPtr cl)
void rfbDoNothingWithClient(rfbClientPtr cl)
{
}
enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl)
enum rfbNewClientAction rfbDefaultNewClientHook(rfbClientPtr cl)
{
return RFB_CLIENT_ACCEPT;
}
/*
* Update server's pixel format in rfbScreenInfo structure. This
* Update server's pixel format in screenInfo structure. This
* function is called from rfbGetScreen() and rfbNewFramebuffer().
*/
static void rfbInitServerFormat(rfbScreenInfoPtr rfbScreen, int bitsPerSample)
static void rfbInitServerFormat(rfbScreenInfoPtr screen, int bitsPerSample)
{
rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
rfbPixelFormat* format=&screen->serverFormat;
format->bitsPerPixel = rfbScreen->bitsPerPixel;
format->depth = rfbScreen->depth;
format->bitsPerPixel = screen->bitsPerPixel;
format->depth = screen->depth;
format->bigEndian = rfbEndianTest?FALSE:TRUE;
format->trueColour = TRUE;
rfbScreen->colourMap.count = 0;
rfbScreen->colourMap.is16 = 0;
rfbScreen->colourMap.data.bytes = NULL;
screen->colourMap.count = 0;
screen->colourMap.is16 = 0;
screen->colourMap.data.bytes = NULL;
if (format->bitsPerPixel == 8) {
format->redMax = 7;
@ -548,104 +548,104 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
int width,int height,int bitsPerSample,int samplesPerPixel,
int bytesPerPixel)
{
rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo));
rfbScreenInfoPtr screen=malloc(sizeof(rfbScreenInfo));
INIT_MUTEX(logMutex);
if(width&3)
rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);
rfbScreen->autoPort=FALSE;
rfbScreen->rfbClientHead=0;
rfbScreen->rfbPort=5900;
rfbScreen->socketInitDone=FALSE;
rfbScreen->inetdInitDone = FALSE;
rfbScreen->inetdSock=-1;
rfbScreen->udpSock=-1;
rfbScreen->udpSockConnected=FALSE;
rfbScreen->udpPort=0;
rfbScreen->udpClient=0;
rfbScreen->maxFd=0;
rfbScreen->rfbListenSock=-1;
rfbScreen->httpInitDone=FALSE;
rfbScreen->httpEnableProxyConnect=FALSE;
rfbScreen->httpPort=0;
rfbScreen->httpDir=NULL;
rfbScreen->httpListenSock=-1;
rfbScreen->httpSock=-1;
rfbScreen->desktopName = "LibVNCServer";
rfbScreen->rfbAlwaysShared = FALSE;
rfbScreen->rfbNeverShared = FALSE;
rfbScreen->rfbDontDisconnect = FALSE;
rfbScreen->rfbAuthPasswdData = 0;
rfbScreen->rfbAuthPasswdFirstViewOnly = 1;
screen->autoPort=FALSE;
screen->clientHead=0;
screen->port=5900;
screen->socketInitDone=FALSE;
screen->inetdInitDone = FALSE;
screen->inetdSock=-1;
screen->udpSock=-1;
screen->udpSockConnected=FALSE;
screen->udpPort=0;
screen->udpClient=0;
screen->maxFd=0;
screen->listenSock=-1;
screen->httpInitDone=FALSE;
screen->httpEnableProxyConnect=FALSE;
screen->httpPort=0;
screen->httpDir=NULL;
screen->httpListenSock=-1;
screen->httpSock=-1;
screen->desktopName = "LibVNCServer";
screen->alwaysShared = FALSE;
screen->neverShared = FALSE;
screen->dontDisconnect = FALSE;
screen->authPasswdData = 0;
screen->authPasswdFirstViewOnly = 1;
rfbScreen->width = width;
rfbScreen->height = height;
rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel;
screen->width = width;
screen->height = height;
screen->bitsPerPixel = screen->depth = 8*bytesPerPixel;
rfbScreen->passwordCheck = defaultPasswordCheck;
screen->passwordCheck = rfbDefaultPasswordCheck;
rfbScreen->ignoreSIGPIPE = TRUE;
screen->ignoreSIGPIPE = TRUE;
/* disable progressive updating per default */
rfbScreen->progressiveSliceHeight = 0;
screen->progressiveSliceHeight = 0;
if(!rfbProcessArguments(rfbScreen,argc,argv)) {
free(rfbScreen);
if(!rfbProcessArguments(screen,argc,argv)) {
free(screen);
return 0;
}
#ifdef WIN32
{
DWORD dummy=255;
GetComputerName(rfbScreen->rfbThisHost,&dummy);
GetComputerName(screen->thisHost,&dummy);
}
#else
gethostname(rfbScreen->rfbThisHost, 255);
gethostname(screen->thisHost, 255);
#endif
rfbScreen->paddedWidthInBytes = width*bytesPerPixel;
screen->paddedWidthInBytes = width*bytesPerPixel;
/* format */
rfbInitServerFormat(rfbScreen, bitsPerSample);
rfbInitServerFormat(screen, bitsPerSample);
/* cursor */
rfbScreen->cursorIsDrawn = FALSE;
rfbScreen->dontSendFramebufferUpdate = FALSE;
rfbScreen->cursorX=rfbScreen->cursorY=rfbScreen->underCursorBufferLen=0;
rfbScreen->underCursorBuffer=NULL;
rfbScreen->dontConvertRichCursorToXCursor = FALSE;
rfbScreen->cursor = &myCursor;
INIT_MUTEX(rfbScreen->cursorMutex);
screen->cursorIsDrawn = FALSE;
screen->dontSendFramebufferUpdate = FALSE;
screen->cursorX=screen->cursorY=screen->underCursorBufferLen=0;
screen->underCursorBuffer=NULL;
screen->dontConvertRichCursorToXCursor = FALSE;
screen->cursor = &myCursor;
INIT_MUTEX(screen->cursorMutex);
IF_PTHREADS(rfbScreen->backgroundLoop = FALSE);
IF_PTHREADS(screen->backgroundLoop = FALSE);
rfbScreen->rfbDeferUpdateTime=5;
rfbScreen->maxRectsPerUpdate=50;
screen->deferUpdateTime=5;
screen->maxRectsPerUpdate=50;
/* proc's and hook's */
rfbScreen->kbdAddEvent = defaultKbdAddEvent;
rfbScreen->kbdReleaseAllKeys = doNothingWithClient;
rfbScreen->ptrAddEvent = defaultPtrAddEvent;
rfbScreen->setXCutText = defaultSetXCutText;
rfbScreen->getCursorPtr = defaultGetCursorPtr;
rfbScreen->setTranslateFunction = rfbSetTranslateFunction;
rfbScreen->newClientHook = defaultNewClientHook;
rfbScreen->displayHook = 0;
screen->kbdAddEvent = rfbDefaultKbdAddEvent;
screen->kbdReleaseAllKeys = rfbDoNothingWithClient;
screen->ptrAddEvent = rfbDefaultPtrAddEvent;
screen->setXCutText = rfbDefaultSetXCutText;
screen->getCursorPtr = rfbDefaultGetCursorPtr;
screen->setTranslateFunction = rfbSetTranslateFunction;
screen->newClientHook = rfbDefaultNewClientHook;
screen->displayHook = 0;
/* initialize client list and iterator mutex */
rfbClientListInit(rfbScreen);
rfbClientListInit(screen);
return(rfbScreen);
return(screen);
}
/*
@ -656,7 +656,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
* the caller.
*/
void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer,
int width, int height,
int bitsPerSample, int samplesPerPixel,
int bytesPerPixel)
@ -668,44 +668,44 @@ void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
/* Remove the pointer */
rfbUndrawCursor(rfbScreen);
rfbUndrawCursor(screen);
/* Update information in the rfbScreenInfo structure */
/* Update information in the screenInfo structure */
old_format = rfbScreen->rfbServerFormat;
old_format = screen->serverFormat;
if (width & 3)
rfbErr("WARNING: New width (%d) is not a multiple of 4.\n", width);
rfbScreen->width = width;
rfbScreen->height = height;
rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel;
rfbScreen->paddedWidthInBytes = width*bytesPerPixel;
screen->width = width;
screen->height = height;
screen->bitsPerPixel = screen->depth = 8*bytesPerPixel;
screen->paddedWidthInBytes = width*bytesPerPixel;
rfbInitServerFormat(rfbScreen, bitsPerSample);
rfbInitServerFormat(screen, bitsPerSample);
if (memcmp(&rfbScreen->rfbServerFormat, &old_format,
if (memcmp(&screen->serverFormat, &old_format,
sizeof(rfbPixelFormat)) != 0) {
format_changed = TRUE;
}
rfbScreen->frameBuffer = framebuffer;
screen->frameBuffer = framebuffer;
/* Adjust pointer position if necessary */
if (rfbScreen->cursorX >= width)
rfbScreen->cursorX = width - 1;
if (rfbScreen->cursorY >= height)
rfbScreen->cursorY = height - 1;
if (screen->cursorX >= width)
screen->cursorX = width - 1;
if (screen->cursorY >= height)
screen->cursorY = height - 1;
/* For each client: */
iterator = rfbGetClientIterator(rfbScreen);
iterator = rfbGetClientIterator(screen);
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
/* Re-install color translation tables if necessary */
if (format_changed)
rfbScreen->setTranslateFunction(cl);
screen->setTranslateFunction(cl);
/* Mark the screen contents as changed, and schedule sending
NewFBSize message if supported by this client. */
@ -730,9 +730,9 @@ void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
extern void TightCleanup();
#endif
void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
void rfbScreenCleanup(rfbScreenInfoPtr screen)
{
rfbClientIteratorPtr i=rfbGetClientIterator(rfbScreen);
rfbClientIteratorPtr i=rfbGetClientIterator(screen);
rfbClientPtr cl,cl1=rfbClientIteratorNext(i);
while(cl1) {
cl=rfbClientIteratorNext(i);
@ -742,27 +742,27 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
rfbReleaseClientIterator(i);
/* TODO: hang up on all clients and free all reserved memory */
#define FREE_IF(x) if(rfbScreen->x) free(rfbScreen->x)
#define FREE_IF(x) if(screen->x) free(screen->x)
FREE_IF(colourMap.data.bytes);
FREE_IF(underCursorBuffer);
TINI_MUTEX(rfbScreen->cursorMutex);
if(rfbScreen->cursor)
rfbFreeCursor(rfbScreen->cursor);
free(rfbScreen);
TINI_MUTEX(screen->cursorMutex);
if(screen->cursor)
rfbFreeCursor(screen->cursor);
free(screen);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
TightCleanup();
rfbTightCleanup();
#endif
}
void rfbInitServer(rfbScreenInfoPtr rfbScreen)
void rfbInitServer(rfbScreenInfoPtr screen)
{
#ifdef WIN32
WSADATA trash;
int i=WSAStartup(MAKEWORD(2,2),&trash);
#endif
rfbInitSockets(rfbScreen);
httpInitSockets(rfbScreen);
if(rfbScreen->ignoreSIGPIPE)
rfbInitSockets(screen);
rfbHttpInitSockets(screen);
if(screen->ignoreSIGPIPE)
signal(SIGPIPE,SIG_IGN);
}
@ -784,27 +784,27 @@ void gettimeofday(struct timeval* tv,char* dummy)
rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i);
void
rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
rfbProcessEvents(rfbScreenInfoPtr screen,long usec)
{
rfbClientIteratorPtr i;
rfbClientPtr cl,clPrev;
struct timeval tv;
if(usec<0)
usec=rfbScreen->rfbDeferUpdateTime*1000;
usec=screen->deferUpdateTime*1000;
rfbCheckFds(rfbScreen,usec);
httpCheckFds(rfbScreen);
rfbCheckFds(screen,usec);
rfbHttpCheckFds(screen);
#ifdef CORBA
corbaCheckFds(rfbScreen);
corbaCheckFds(screen);
#endif
i = rfbGetClientIterator(rfbScreen);
i = rfbGetClientIterator(screen);
cl=rfbClientIteratorHead(i);
while(cl) {
if (cl->sock >= 0 && !cl->onHold && FB_UPDATE_PENDING(cl) &&
!sraRgnEmpty(cl->requestedRegion)) {
if(rfbScreen->rfbDeferUpdateTime == 0) {
if(screen->deferUpdateTime == 0) {
rfbSendFramebufferUpdate(cl,cl->modifiedRegion);
} else if(cl->startDeferring.tv_usec == 0) {
gettimeofday(&cl->startDeferring,NULL);
@ -815,7 +815,7 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
if(tv.tv_sec < cl->startDeferring.tv_sec /* at midnight */
|| ((tv.tv_sec-cl->startDeferring.tv_sec)*1000
+(tv.tv_usec-cl->startDeferring.tv_usec)/1000)
> rfbScreen->rfbDeferUpdateTime) {
> screen->deferUpdateTime) {
cl->startDeferring.tv_usec = 0;
rfbSendFramebufferUpdate(cl,cl->modifiedRegion);
}
@ -829,15 +829,15 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
rfbReleaseClientIterator(i);
}
void rfbRunEventLoop(rfbScreenInfoPtr rfbScreen, long usec, rfbBool runInBackground)
void rfbRunEventLoop(rfbScreenInfoPtr screen, long usec, rfbBool runInBackground)
{
if(runInBackground) {
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
pthread_t listener_thread;
rfbScreen->backgroundLoop = TRUE;
screen->backgroundLoop = TRUE;
pthread_create(&listener_thread, NULL, listenerRun, rfbScreen);
pthread_create(&listener_thread, NULL, listenerRun, screen);
return;
#else
rfbErr("Can't run in background, because I don't have PThreads!\n");
@ -846,8 +846,8 @@ void rfbRunEventLoop(rfbScreenInfoPtr rfbScreen, long usec, rfbBool runInBackgro
}
if(usec<0)
usec=rfbScreen->rfbDeferUpdateTime*1000;
usec=screen->deferUpdateTime*1000;
while(1)
rfbProcessEvents(rfbScreen,usec);
rfbProcessEvents(screen,usec);
}

@ -60,7 +60,7 @@
#define DEBUGPROTO(x)
#endif
rfbClientPtr pointerClient = NULL; /* Mutex for pointer events */
static rfbClientPtr pointerClient = NULL; /* "Mutex" for pointer events */
static void rfbProcessClientProtocolVersion(rfbClientPtr cl);
static void rfbProcessClientNormalMessage(rfbClientPtr cl);
@ -105,7 +105,7 @@ rfbClientListInit(rfbScreenInfoPtr rfbScreen)
/* we cannot continue, because rfbBool is supposed to be char everywhere */
exit(1);
}
rfbScreen->rfbClientHead = NULL;
rfbScreen->clientHead = NULL;
INIT_MUTEX(rfbClientListMutex);
}
@ -125,11 +125,11 @@ rfbClientIteratorHead(rfbClientIteratorPtr i)
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
if(i->next != 0) {
rfbDecrClientRef(i->next);
rfbIncrClientRef(i->screen->rfbClientHead);
rfbIncrClientRef(i->screen->clientHead);
}
#endif
LOCK(rfbClientListMutex);
i->next = i->screen->rfbClientHead;
i->next = i->screen->clientHead;
UNLOCK(rfbClientListMutex);
return i->next;
}
@ -139,7 +139,7 @@ rfbClientIteratorNext(rfbClientIteratorPtr i)
{
if(i->next == 0) {
LOCK(rfbClientListMutex);
i->next = i->screen->rfbClientHead;
i->next = i->screen->clientHead;
UNLOCK(rfbClientListMutex);
} else {
IF_PTHREADS(rfbClientPtr cl = i->next);
@ -298,19 +298,19 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
cl->requestedRegion = sraRgnCreate();
cl->format = cl->screen->rfbServerFormat;
cl->format = cl->screen->serverFormat;
cl->translateFn = rfbTranslateNone;
cl->translateLookupTable = NULL;
LOCK(rfbClientListMutex);
IF_PTHREADS(cl->refCount = 0);
cl->next = rfbScreen->rfbClientHead;
cl->next = rfbScreen->clientHead;
cl->prev = NULL;
if (rfbScreen->rfbClientHead)
rfbScreen->rfbClientHead->prev = cl;
if (rfbScreen->clientHead)
rfbScreen->clientHead->prev = cl;
rfbScreen->rfbClientHead = cl;
rfbScreen->clientHead = cl;
UNLOCK(rfbClientListMutex);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
@ -345,7 +345,7 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
sprintf(pv,rfbProtocolVersionFormat,rfbProtocolMajorVersion,
rfbProtocolMinorVersion);
if (WriteExact(cl, pv, sz_rfbProtocolVersionMsg) < 0) {
if (rfbWriteExact(cl, pv, sz_rfbProtocolVersionMsg) < 0) {
rfbLogPerror("rfbNewClient: write");
rfbCloseClient(cl);
/* TODO: memory leak here (cl is never freed)
@ -357,7 +357,7 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
}
cl->clientData = NULL;
cl->clientGoneHook = doNothingWithClient;
cl->clientGoneHook = rfbDoNothingWithClient;
switch (cl->screen->newClientHook(cl)) {
case RFB_CLIENT_ON_HOLD:
cl->onHold = TRUE;
@ -406,7 +406,7 @@ rfbClientConnectionGone(cl)
if (cl->prev)
cl->prev->next = cl->next;
else
cl->screen->rfbClientHead = cl->next;
cl->screen->clientHead = cl->next;
if (cl->next)
cl->next->prev = cl->prev;
@ -512,7 +512,7 @@ rfbProcessClientProtocolVersion(cl)
int n, major_, minor_;
char failureReason[256];
if ((n = ReadExact(cl, pv, sz_rfbProtocolVersionMsg)) <= 0) {
if ((n = rfbReadExact(cl, pv, sz_rfbProtocolVersionMsg)) <= 0) {
if (n == 0)
rfbLog("rfbProcessClientProtocolVersion: client gone\n");
else
@ -572,7 +572,7 @@ rfbClientConnFailed(cl, reason)
((uint32_t *)buf)[1] = Swap32IfLE(len);
memcpy(buf + 8, reason, len);
if (WriteExact(cl, buf, 8 + len) < 0)
if (rfbWriteExact(cl, buf, 8 + len) < 0)
rfbLogPerror("rfbClientConnFailed: write");
free(buf);
rfbCloseClient(cl);
@ -595,7 +595,7 @@ rfbProcessClientInitMessage(cl)
rfbClientIteratorPtr iterator;
rfbClientPtr otherCl;
if ((n = ReadExact(cl, (char *)&ci,sz_rfbClientInitMsg)) <= 0) {
if ((n = rfbReadExact(cl, (char *)&ci,sz_rfbClientInitMsg)) <= 0) {
if (n == 0)
rfbLog("rfbProcessClientInitMessage: client gone\n");
else
@ -606,7 +606,7 @@ rfbProcessClientInitMessage(cl)
si->framebufferWidth = Swap16IfLE(cl->screen->width);
si->framebufferHeight = Swap16IfLE(cl->screen->height);
si->format = cl->screen->rfbServerFormat;
si->format = cl->screen->serverFormat;
si->format.redMax = Swap16IfLE(si->format.redMax);
si->format.greenMax = Swap16IfLE(si->format.greenMax);
si->format.blueMax = Swap16IfLE(si->format.blueMax);
@ -618,7 +618,7 @@ rfbProcessClientInitMessage(cl)
len = strlen(buf + sz_rfbServerInitMsg);
si->nameLength = Swap32IfLE(len);
if (WriteExact(cl, buf, sz_rfbServerInitMsg + len) < 0) {
if (rfbWriteExact(cl, buf, sz_rfbServerInitMsg + len) < 0) {
rfbLogPerror("rfbProcessClientInitMessage: write");
rfbCloseClient(cl);
return;
@ -627,9 +627,9 @@ rfbProcessClientInitMessage(cl)
cl->state = RFB_NORMAL;
if (!cl->reverseConnection &&
(cl->screen->rfbNeverShared || (!cl->screen->rfbAlwaysShared && !ci.shared))) {
(cl->screen->neverShared || (!cl->screen->alwaysShared && !ci.shared))) {
if (cl->screen->rfbDontDisconnect) {
if (cl->screen->dontDisconnect) {
iterator = rfbGetClientIterator(cl->screen);
while ((otherCl = rfbClientIteratorNext(iterator)) != NULL) {
if ((otherCl != cl) && (otherCl->state == RFB_NORMAL)) {
@ -688,7 +688,7 @@ rfbProcessClientNormalMessage(cl)
rfbClientToServerMsg msg;
char *str;
if ((n = ReadExact(cl, (char *)&msg, 1)) <= 0) {
if ((n = rfbReadExact(cl, (char *)&msg, 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl);
@ -699,7 +699,7 @@ rfbProcessClientNormalMessage(cl)
case rfbSetPixelFormat:
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbSetPixelFormatMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -725,7 +725,7 @@ rfbProcessClientNormalMessage(cl)
case rfbFixColourMapEntries:
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbFixColourMapEntriesMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -743,7 +743,7 @@ rfbProcessClientNormalMessage(cl)
int i;
uint32_t enc;
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbSetEncodingsMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -761,7 +761,7 @@ rfbProcessClientNormalMessage(cl)
cl->useNewFBSize = FALSE;
for (i = 0; i < msg.se.nEncodings; i++) {
if ((n = ReadExact(cl, (char *)&enc, 4)) <= 0) {
if ((n = rfbReadExact(cl, (char *)&enc, 4)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl);
@ -915,7 +915,7 @@ rfbProcessClientNormalMessage(cl)
{
sraRegionPtr tmpRegion;
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbFramebufferUpdateRequestMsg-1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -962,9 +962,9 @@ rfbProcessClientNormalMessage(cl)
case rfbKeyEvent:
cl->rfbKeyEventsRcvd++;
cl->keyEventsRcvd++;
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbKeyEventMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -981,9 +981,9 @@ rfbProcessClientNormalMessage(cl)
case rfbPointerEvent:
cl->rfbPointerEventsRcvd++;
cl->pointerEventsRcvd++;
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbPointerEventMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -1009,7 +1009,7 @@ rfbProcessClientNormalMessage(cl)
case rfbClientCutText:
if ((n = ReadExact(cl, ((char *)&msg) + 1,
if ((n = rfbReadExact(cl, ((char *)&msg) + 1,
sz_rfbClientCutTextMsg - 1)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
@ -1021,7 +1021,7 @@ rfbProcessClientNormalMessage(cl)
str = (char *)malloc(msg.cct.length);
if ((n = ReadExact(cl, str, msg.cct.length)) <= 0) {
if ((n = rfbReadExact(cl, str, msg.cct.length)) <= 0) {
if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read");
free(str);
@ -1081,7 +1081,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
LOCK(cl->updateMutex);
cl->newFBSizePending = FALSE;
UNLOCK(cl->updateMutex);
cl->rfbFramebufferUpdateMessagesSent++;
cl->framebufferUpdateMessagesSent++;
fu->type = rfbFramebufferUpdate;
fu->nRects = Swap16IfLE(1);
cl->ublen = sz_rfbFramebufferUpdateMsg;
@ -1211,7 +1211,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
* Now send the update.
*/
cl->rfbFramebufferUpdateMessagesSent++;
cl->framebufferUpdateMessagesSent++;
if (cl->preferredEncoding == rfbEncodingCoRRE) {
nUpdateRegionRects = 0;
@ -1315,7 +1315,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
int w = rect.x2 - x;
int h = rect.y2 - y;
cl->rfbRawBytesEquivalent += (sz_rfbFramebufferUpdateRectHeader
cl->rawBytesEquivalent += (sz_rfbFramebufferUpdateRectHeader
+ w * (cl->format.bitsPerPixel / 8) * h);
switch (cl->preferredEncoding) {
@ -1438,8 +1438,8 @@ rfbSendCopyRegion(cl, reg, dx, dy)
memcpy(&cl->updateBuf[cl->ublen], (char *)&cr, sz_rfbCopyRect);
cl->ublen += sz_rfbCopyRect;
cl->rfbRectanglesSent[rfbEncodingCopyRect]++;
cl->rfbBytesSent[rfbEncodingCopyRect]
cl->rectanglesSent[rfbEncodingCopyRect]++;
cl->bytesSent[rfbEncodingCopyRect]
+= sz_rfbFramebufferUpdateRectHeader + sz_rfbCopyRect;
}
@ -1477,8 +1477,8 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbRectanglesSent[rfbEncodingRaw]++;
cl->rfbBytesSent[rfbEncodingRaw]
cl->rectanglesSent[rfbEncodingRaw]++;
cl->bytesSent[rfbEncodingRaw]
+= sz_rfbFramebufferUpdateRectHeader + bytesPerLine * h;
nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine;
@ -1488,7 +1488,7 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
nlines = h;
(*cl->translateFn)(cl->translateLookupTable,
&(cl->screen->rfbServerFormat),
&(cl->screen->serverFormat),
&cl->format, fbptr, &cl->updateBuf[cl->ublen],
cl->screen->paddedWidthInBytes, w, nlines);
@ -1544,8 +1544,8 @@ rfbSendLastRectMarker(cl)
memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbLastRectMarkersSent++;
cl->rfbLastRectBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->lastRectMarkersSent++;
cl->lastRectBytesSent += sz_rfbFramebufferUpdateRectHeader;
return TRUE;
}
@ -1578,8 +1578,8 @@ rfbSendNewFBSize(cl, w, h)
sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbLastRectMarkersSent++;
cl->rfbLastRectBytesSent += sz_rfbFramebufferUpdateRectHeader;
cl->lastRectMarkersSent++;
cl->lastRectBytesSent += sz_rfbFramebufferUpdateRectHeader;
return TRUE;
}
@ -1597,7 +1597,7 @@ rfbSendUpdateBuf(cl)
if(cl->sock<0)
return FALSE;
if (WriteExact(cl, cl->updateBuf, cl->ublen) < 0) {
if (rfbWriteExact(cl, cl->updateBuf, cl->ublen) < 0) {
rfbLogPerror("rfbSendUpdateBuf: write");
rfbCloseClient(cl);
return FALSE;
@ -1648,7 +1648,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours)
len += nColours * 3 * 2;
if (WriteExact(cl, buf, len) < 0) {
if (rfbWriteExact(cl, buf, len) < 0) {
rfbLogPerror("rfbSendSetColourMapEntries: write");
rfbCloseClient(cl);
return FALSE;
@ -1670,7 +1670,7 @@ rfbSendBell(rfbScreenInfoPtr rfbScreen)
i = rfbGetClientIterator(rfbScreen);
while((cl=rfbClientIteratorNext(i))) {
b.type = rfbBell;
if (WriteExact(cl, (char *)&b, sz_rfbBellMsg) < 0) {
if (rfbWriteExact(cl, (char *)&b, sz_rfbBellMsg) < 0) {
rfbLogPerror("rfbSendBell: write");
rfbCloseClient(cl);
}
@ -1694,13 +1694,13 @@ rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len)
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
sct.type = rfbServerCutText;
sct.length = Swap32IfLE(len);
if (WriteExact(cl, (char *)&sct,
if (rfbWriteExact(cl, (char *)&sct,
sz_rfbServerCutTextMsg) < 0) {
rfbLogPerror("rfbSendServerCutText: write");
rfbCloseClient(cl);
continue;
}
if (WriteExact(cl, str, len) < 0) {
if (rfbWriteExact(cl, str, len) < 0) {
rfbLogPerror("rfbSendServerCutText: write");
rfbCloseClient(cl);
}
@ -1793,13 +1793,13 @@ void rfbSendBackChannel(rfbScreenInfoPtr rfbScreen,char* str,int len)
if (cl->enableBackChannel) {
sct.type = rfbBackChannel;
sct.length = Swap32IfLE(len);
if (WriteExact(cl, (char *)&sct,
if (rfbWriteExact(cl, (char *)&sct,
sz_rfbBackChannelMsg) < 0) {
rfbLogPerror("rfbSendBackChannel: write");
rfbCloseClient(cl);
continue;
}
if (WriteExact(cl, str, len) < 0) {
if (rfbWriteExact(cl, str, len) < 0) {
rfbLogPerror("rfbSendBackChannel: write");
rfbCloseClient(cl);
}

@ -84,7 +84,7 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
}
(*cl->translateFn)(cl->translateLookupTable,
&(cl->screen->rfbServerFormat),
&(cl->screen->serverFormat),
&cl->format, fbptr, rreBeforeBuf,
cl->screen->paddedWidthInBytes, w, h);
@ -110,8 +110,8 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
return rfbSendRectEncodingRaw(cl, x, y, w, h);
}
cl->rfbRectanglesSent[rfbEncodingRRE]++;
cl->rfbBytesSent[rfbEncodingRRE] += (sz_rfbFramebufferUpdateRectHeader
cl->rectanglesSent[rfbEncodingRRE]++;
cl->bytesSent[rfbEncodingRRE] += (sz_rfbFramebufferUpdateRectHeader
+ sz_rfbRREHeader + rreAfterBufLen);
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbRREHeader

@ -209,10 +209,10 @@ int rfbSelectBox(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int bpp = rfbScreen->bitsPerPixel/8;
char* frameBufferBackup;
void* screenDataBackup = rfbScreen->screenData;
KbdAddEventProcPtr kbdAddEventBackup = rfbScreen->kbdAddEvent;
PtrAddEventProcPtr ptrAddEventBackup = rfbScreen->ptrAddEvent;
GetCursorProcPtr getCursorPtrBackup = rfbScreen->getCursorPtr;
DisplayHookPtr displayHookBackup = rfbScreen->displayHook;
rfbKbdAddEventProcPtr kbdAddEventBackup = rfbScreen->kbdAddEvent;
rfbPtrAddEventProcPtr ptrAddEventBackup = rfbScreen->ptrAddEvent;
rfbGetCursorProcPtr getCursorPtrBackup = rfbScreen->getCursorPtr;
rfbDisplayHookPtr displayHookBackup = rfbScreen->displayHook;
rfbSelectData selData;
int i,j,k;
int fx1,fy1,fx2,fy2; /* for font bbox */

@ -139,8 +139,8 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
rfbLog("Autoprobing TCP port \n");
for (i = 5900; i < 6000; i++) {
if ((rfbScreen->rfbListenSock = ListenOnTCPPort(i)) >= 0) {
rfbScreen->rfbPort = i;
if ((rfbScreen->listenSock = rfbListenOnTCPPort(i)) >= 0) {
rfbScreen->port = i;
break;
}
}
@ -150,28 +150,28 @@ rfbInitSockets(rfbScreenInfoPtr rfbScreen)
return;
}
rfbLog("Autoprobing selected port %d\n", rfbScreen->rfbPort);
rfbLog("Autoprobing selected port %d\n", rfbScreen->port);
FD_ZERO(&(rfbScreen->allFds));
FD_SET(rfbScreen->rfbListenSock, &(rfbScreen->allFds));
rfbScreen->maxFd = rfbScreen->rfbListenSock;
FD_SET(rfbScreen->listenSock, &(rfbScreen->allFds));
rfbScreen->maxFd = rfbScreen->listenSock;
}
else if(rfbScreen->rfbPort>0) {
rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->rfbPort);
else if(rfbScreen->port>0) {
rfbLog("Listening for VNC connections on TCP port %d\n", rfbScreen->port);
if ((rfbScreen->rfbListenSock = ListenOnTCPPort(rfbScreen->rfbPort)) < 0) {
if ((rfbScreen->listenSock = rfbListenOnTCPPort(rfbScreen->port)) < 0) {
rfbLogPerror("ListenOnTCPPort");
return;
}
FD_ZERO(&(rfbScreen->allFds));
FD_SET(rfbScreen->rfbListenSock, &(rfbScreen->allFds));
rfbScreen->maxFd = rfbScreen->rfbListenSock;
FD_SET(rfbScreen->listenSock, &(rfbScreen->allFds));
rfbScreen->maxFd = rfbScreen->listenSock;
}
if (rfbScreen->udpPort != 0) {
rfbLog("rfbInitSockets: listening for input on UDP port %d\n",rfbScreen->udpPort);
if ((rfbScreen->udpSock = ListenOnUDPPort(rfbScreen->udpPort)) < 0) {
if ((rfbScreen->udpSock = rfbListenOnUDPPort(rfbScreen->udpPort)) < 0) {
rfbLogPerror("ListenOnUDPPort");
return;
}
@ -223,9 +223,9 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
return;
}
if (rfbScreen->rfbListenSock != -1 && FD_ISSET(rfbScreen->rfbListenSock, &fds)) {
if (rfbScreen->listenSock != -1 && FD_ISSET(rfbScreen->listenSock, &fds)) {
if ((sock = accept(rfbScreen->rfbListenSock,
if ((sock = accept(rfbScreen->listenSock,
(struct sockaddr *)&addr, &addrlen)) < 0) {
rfbLogPerror("rfbCheckFds: accept");
return;
@ -260,7 +260,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
rfbNewClient(rfbScreen,sock);
FD_CLR(rfbScreen->rfbListenSock, &fds);
FD_CLR(rfbScreen->listenSock, &fds);
if (--nfds == 0)
return;
}
@ -359,7 +359,7 @@ rfbConnect(rfbScreen, host, port)
rfbLog("Making connection to client on host %s port %d\n",
host,port);
if ((sock = ConnectToTcpAddr(host, port)) < 0) {
if ((sock = rfbConnectToTcpAddr(host, port)) < 0) {
rfbLogPerror("connection failed");
return -1;
}
@ -393,7 +393,7 @@ rfbConnect(rfbScreen, host, port)
*/
int
ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
{
int sock = cl->sock;
int n;
@ -441,9 +441,9 @@ ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
return 1;
}
int ReadExact(rfbClientPtr cl,char* buf,int len)
int rfbReadExact(rfbClientPtr cl,char* buf,int len)
{
return(ReadExactTimeout(cl,buf,len,rfbMaxClientWait));
return(rfbReadExactTimeout(cl,buf,len,rfbMaxClientWait));
}
/*
@ -453,7 +453,7 @@ int ReadExact(rfbClientPtr cl,char* buf,int len)
*/
int
WriteExact(cl, buf, len)
rfbWriteExact(cl, buf, len)
rfbClientPtr cl;
const char *buf;
int len;
@ -531,7 +531,7 @@ WriteExact(cl, buf, len)
}
int
ListenOnTCPPort(port)
rfbListenOnTCPPort(port)
int port;
{
struct sockaddr_in addr;
@ -565,7 +565,7 @@ ListenOnTCPPort(port)
}
int
ConnectToTcpAddr(host, port)
rfbConnectToTcpAddr(host, port)
char *host;
int port;
{
@ -599,7 +599,7 @@ ConnectToTcpAddr(host, port)
}
int
ListenOnUDPPort(port)
rfbListenOnUDPPort(port)
int port;
{
struct sockaddr_in addr;

@ -44,19 +44,19 @@ rfbResetStats(rfbClientPtr cl)
{
int i;
for (i = 0; i < MAX_ENCODINGS; i++) {
cl->rfbBytesSent[i] = 0;
cl->rfbRectanglesSent[i] = 0;
cl->bytesSent[i] = 0;
cl->rectanglesSent[i] = 0;
}
cl->rfbLastRectMarkersSent = 0;
cl->rfbLastRectBytesSent = 0;
cl->rfbCursorShapeBytesSent = 0;
cl->rfbCursorShapeUpdatesSent = 0;
cl->rfbCursorPosBytesSent = 0;
cl->rfbCursorPosUpdatesSent = 0;
cl->rfbFramebufferUpdateMessagesSent = 0;
cl->rfbRawBytesEquivalent = 0;
cl->rfbKeyEventsRcvd = 0;
cl->rfbPointerEventsRcvd = 0;
cl->lastRectMarkersSent = 0;
cl->lastRectBytesSent = 0;
cl->cursorShapeBytesSent = 0;
cl->cursorShapeUpdatesSent = 0;
cl->cursorPosBytesSent = 0;
cl->cursorPosUpdatesSent = 0;
cl->framebufferUpdateMessagesSent = 0;
cl->rawBytesEquivalent = 0;
cl->keyEventsRcvd = 0;
cl->pointerEventsRcvd = 0;
}
void
@ -68,52 +68,52 @@ rfbPrintStats(rfbClientPtr cl)
rfbLog("Statistics:\n");
if ((cl->rfbKeyEventsRcvd != 0) || (cl->rfbPointerEventsRcvd != 0))
if ((cl->keyEventsRcvd != 0) || (cl->pointerEventsRcvd != 0))
rfbLog(" key events received %d, pointer events %d\n",
cl->rfbKeyEventsRcvd, cl->rfbPointerEventsRcvd);
cl->keyEventsRcvd, cl->pointerEventsRcvd);
for (i = 0; i < MAX_ENCODINGS; i++) {
totalRectanglesSent += cl->rfbRectanglesSent[i];
totalBytesSent += cl->rfbBytesSent[i];
totalRectanglesSent += cl->rectanglesSent[i];
totalBytesSent += cl->bytesSent[i];
}
totalRectanglesSent += (cl->rfbCursorShapeUpdatesSent +
cl->rfbCursorPosUpdatesSent +
cl->rfbLastRectMarkersSent);
totalBytesSent += (cl->rfbCursorShapeBytesSent +
cl->rfbCursorPosBytesSent +
cl->rfbLastRectBytesSent);
totalRectanglesSent += (cl->cursorShapeUpdatesSent +
cl->cursorPosUpdatesSent +
cl->lastRectMarkersSent);
totalBytesSent += (cl->cursorShapeBytesSent +
cl->cursorPosBytesSent +
cl->lastRectBytesSent);
rfbLog(" framebuffer updates %d, rectangles %d, bytes %d\n",
cl->rfbFramebufferUpdateMessagesSent, totalRectanglesSent,
cl->framebufferUpdateMessagesSent, totalRectanglesSent,
totalBytesSent);
if (cl->rfbLastRectMarkersSent != 0)
if (cl->lastRectMarkersSent != 0)
rfbLog(" LastRect and NewFBSize markers %d, bytes %d\n",
cl->rfbLastRectMarkersSent, cl->rfbLastRectBytesSent);
cl->lastRectMarkersSent, cl->lastRectBytesSent);
if (cl->rfbCursorShapeUpdatesSent != 0)
if (cl->cursorShapeUpdatesSent != 0)
rfbLog(" cursor shape updates %d, bytes %d\n",
cl->rfbCursorShapeUpdatesSent, cl->rfbCursorShapeBytesSent);
cl->cursorShapeUpdatesSent, cl->cursorShapeBytesSent);
if (cl->rfbCursorPosUpdatesSent != 0)
if (cl->cursorPosUpdatesSent != 0)
rfbLog(" cursor position updates %d, bytes %d\n",
cl->rfbCursorPosUpdatesSent, cl->rfbCursorPosBytesSent);
cl->cursorPosUpdatesSent, cl->cursorPosBytesSent);
for (i = 0; i < MAX_ENCODINGS; i++) {
if (cl->rfbRectanglesSent[i] != 0)
if (cl->rectanglesSent[i] != 0)
rfbLog(" %s rectangles %d, bytes %d\n",
encNames[i], cl->rfbRectanglesSent[i], cl->rfbBytesSent[i]);
encNames[i], cl->rectanglesSent[i], cl->bytesSent[i]);
}
if ((totalBytesSent - cl->rfbBytesSent[rfbEncodingCopyRect]) != 0) {
if ((totalBytesSent - cl->bytesSent[rfbEncodingCopyRect]) != 0) {
rfbLog(" raw bytes equivalent %d, compression ratio %f\n",
cl->rfbRawBytesEquivalent,
(double)cl->rfbRawBytesEquivalent
cl->rawBytesEquivalent,
(double)cl->rawBytesEquivalent
/ (double)(totalBytesSent
- cl->rfbBytesSent[rfbEncodingCopyRect]-
cl->rfbCursorShapeBytesSent -
cl->rfbCursorPosBytesSent -
cl->rfbLastRectBytesSent));
- cl->bytesSent[rfbEncodingCopyRect]-
cl->cursorShapeBytesSent -
cl->cursorPosBytesSent -
cl->lastRectBytesSent));
}
}

@ -112,7 +112,7 @@ static char *tightAfterBuf = NULL;
static int *prevRowBuf = NULL;
void TightCleanup()
void rfbTightCleanup()
{
if(tightBeforeBufSize) {
free(tightBeforeBuf);
@ -330,7 +330,7 @@ rfbSendRectEncodingTight(cl, x, y, w, h)
(cl->screen->paddedWidthInBytes * y_best) +
(x_best * (cl->screen->bitsPerPixel / 8)));
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->rfbServerFormat,
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, tightBeforeBuf,
cl->screen->paddedWidthInBytes, 1, 1);
@ -451,7 +451,7 @@ ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr)
static rfbBool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, rfbBool needSameColor)
{
switch(cl->screen->rfbServerFormat.bitsPerPixel) {
switch(cl->screen->serverFormat.bitsPerPixel) {
case 32:
return CheckSolidTile32(cl, x, y, w, h, colorPtr, needSameColor);
case 16:
@ -568,7 +568,7 @@ SendSubrect(cl, x, y, w, h)
fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y)
+ (x * (cl->screen->bitsPerPixel / 8)));
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->rfbServerFormat,
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, tightBeforeBuf,
cl->screen->paddedWidthInBytes, w, h);
@ -646,8 +646,8 @@ SendTightHeader(cl, x, y, w, h)
sz_rfbFramebufferUpdateRectHeader);
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
cl->rfbRectanglesSent[rfbEncodingTight]++;
cl->rfbBytesSent[rfbEncodingTight] += sz_rfbFramebufferUpdateRectHeader;
cl->rectanglesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight] += sz_rfbFramebufferUpdateRectHeader;
return TRUE;
}
@ -677,7 +677,7 @@ SendSolidRect(cl)
memcpy (&cl->updateBuf[cl->ublen], tightBeforeBuf, len);
cl->ublen += len;
cl->rfbBytesSent[rfbEncodingTight] += len + 1;
cl->bytesSent[rfbEncodingTight] += len + 1;
return TRUE;
}
@ -720,7 +720,7 @@ SendMonoRect(cl, w, h)
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteLen);
cl->ublen += paletteLen;
cl->rfbBytesSent[rfbEncodingTight] += 3 + paletteLen;
cl->bytesSent[rfbEncodingTight] += 3 + paletteLen;
break;
case 16:
@ -731,7 +731,7 @@ SendMonoRect(cl, w, h)
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, 4);
cl->ublen += 4;
cl->rfbBytesSent[rfbEncodingTight] += 7;
cl->bytesSent[rfbEncodingTight] += 7;
break;
default:
@ -739,7 +739,7 @@ SendMonoRect(cl, w, h)
cl->updateBuf[cl->ublen++] = (char)monoBackground;
cl->updateBuf[cl->ublen++] = (char)monoForeground;
cl->rfbBytesSent[rfbEncodingTight] += 5;
cl->bytesSent[rfbEncodingTight] += 5;
}
return CompressData(cl, streamId, dataLen,
@ -785,7 +785,7 @@ SendIndexedRect(cl, w, h)
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * entryLen);
cl->ublen += paletteNumColors * entryLen;
cl->rfbBytesSent[rfbEncodingTight] += 3 + paletteNumColors * entryLen;
cl->bytesSent[rfbEncodingTight] += 3 + paletteNumColors * entryLen;
break;
case 16:
@ -798,7 +798,7 @@ SendIndexedRect(cl, w, h)
memcpy(&cl->updateBuf[cl->ublen], tightAfterBuf, paletteNumColors * 2);
cl->ublen += paletteNumColors * 2;
cl->rfbBytesSent[rfbEncodingTight] += 3 + paletteNumColors * 2;
cl->bytesSent[rfbEncodingTight] += 3 + paletteNumColors * 2;
break;
default:
@ -824,7 +824,7 @@ SendFullColorRect(cl, w, h)
}
cl->updateBuf[cl->ublen++] = 0x00; /* stream id = 0, no flushing, no filter */
cl->rfbBytesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight]++;
if (usePixelFormat24) {
Pack24(cl, tightBeforeBuf, &cl->format, w * h);
@ -858,7 +858,7 @@ SendGradientRect(cl, w, h)
cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4;
cl->updateBuf[cl->ublen++] = rfbTightFilterGradient;
cl->rfbBytesSent[rfbEncodingTight] += 2;
cl->bytesSent[rfbEncodingTight] += 2;
if (usePixelFormat24) {
FilterGradient24(cl, tightBeforeBuf, &cl->format, w, h);
@ -887,7 +887,7 @@ CompressData(cl, streamId, dataLen, zlibLevel, zlibStrategy)
if (dataLen < TIGHT_MIN_TO_COMPRESS) {
memcpy(&cl->updateBuf[cl->ublen], tightBeforeBuf, dataLen);
cl->ublen += dataLen;
cl->rfbBytesSent[rfbEncodingTight] += dataLen;
cl->bytesSent[rfbEncodingTight] += dataLen;
return TRUE;
}
@ -938,15 +938,15 @@ static rfbBool SendCompressedData(cl, compressedLen)
int i, portionLen;
cl->updateBuf[cl->ublen++] = compressedLen & 0x7F;
cl->rfbBytesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight]++;
if (compressedLen > 0x7F) {
cl->updateBuf[cl->ublen-1] |= 0x80;
cl->updateBuf[cl->ublen++] = compressedLen >> 7 & 0x7F;
cl->rfbBytesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight]++;
if (compressedLen > 0x3FFF) {
cl->updateBuf[cl->ublen-1] |= 0x80;
cl->updateBuf[cl->ublen++] = compressedLen >> 14 & 0xFF;
cl->rfbBytesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight]++;
}
}
@ -962,7 +962,7 @@ static rfbBool SendCompressedData(cl, compressedLen)
memcpy(&cl->updateBuf[cl->ublen], &tightAfterBuf[i], portionLen);
cl->ublen += portionLen;
}
cl->rfbBytesSent[rfbEncodingTight] += compressedLen;
cl->bytesSent[rfbEncodingTight] += compressedLen;
return TRUE;
}
@ -1181,7 +1181,7 @@ static void Pack24(cl, buf, fmt, count)
buf32 = (uint32_t *)buf;
if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) {
if (!cl->screen->serverFormat.bigEndian == !fmt->bigEndian) {
r_shift = fmt->redShift;
g_shift = fmt->greenShift;
b_shift = fmt->blueShift;
@ -1323,7 +1323,7 @@ FilterGradient24(cl, buf, fmt, w, h)
buf32 = (uint32_t *)buf;
memset (prevRowBuf, 0, w * 3 * sizeof(int));
if (!cl->screen->rfbServerFormat.bigEndian == !fmt->bigEndian) {
if (!cl->screen->serverFormat.bigEndian == !fmt->bigEndian) {
shiftBits[0] = fmt->redShift;
shiftBits[1] = fmt->greenShift;
shiftBits[2] = fmt->blueShift;
@ -1384,7 +1384,7 @@ FilterGradient##bpp(cl, buf, fmt, w, h) \
\
memset (prevRowBuf, 0, w * 3 * sizeof(int)); \
\
endianMismatch = (!cl->screen->rfbServerFormat.bigEndian != !fmt->bigEndian); \
endianMismatch = (!cl->screen->serverFormat.bigEndian != !fmt->bigEndian); \
\
maxColor[0] = fmt->redMax; \
maxColor[1] = fmt->greenMax; \
@ -1452,7 +1452,7 @@ DetectSmoothImage (cl, fmt, w, h)
{
long avgError;
if ( cl->screen->rfbServerFormat.bitsPerPixel == 8 || fmt->bitsPerPixel == 8 ||
if ( cl->screen->serverFormat.bitsPerPixel == 8 || fmt->bitsPerPixel == 8 ||
w < DETECT_MIN_WIDTH || h < DETECT_MIN_HEIGHT ) {
return 0;
}
@ -1564,7 +1564,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
int sample, sum, left[3]; \
unsigned long avgError; \
\
endianMismatch = (!cl->screen->rfbServerFormat.bigEndian != !fmt->bigEndian); \
endianMismatch = (!cl->screen->serverFormat.bigEndian != !fmt->bigEndian); \
\
maxColor[0] = fmt->redMax; \
maxColor[1] = fmt->greenMax; \
@ -1652,7 +1652,7 @@ SendJpegRect(cl, x, y, w, h, quality)
JSAMPROW rowPointer[1];
int dy;
if (cl->screen->rfbServerFormat.bitsPerPixel == 8)
if (cl->screen->serverFormat.bitsPerPixel == 8)
return SendFullColorRect(cl, w, h);
srcBuf = (uint8_t *)malloc(w * 3);
@ -1698,7 +1698,7 @@ SendJpegRect(cl, x, y, w, h, quality)
}
cl->updateBuf[cl->ublen++] = (char)(rfbTightJpeg << 4);
cl->rfbBytesSent[rfbEncodingTight]++;
cl->bytesSent[rfbEncodingTight]++;
return SendCompressedData(cl, jpegDstDataLen);
}
@ -1709,10 +1709,10 @@ PrepareRowForJpeg(cl, dst, x, y, count)
uint8_t *dst;
int x, y, count;
{
if (cl->screen->rfbServerFormat.bitsPerPixel == 32) {
if ( cl->screen->rfbServerFormat.redMax == 0xFF &&
cl->screen->rfbServerFormat.greenMax == 0xFF &&
cl->screen->rfbServerFormat.blueMax == 0xFF ) {
if (cl->screen->serverFormat.bitsPerPixel == 32) {
if ( cl->screen->serverFormat.redMax == 0xFF &&
cl->screen->serverFormat.greenMax == 0xFF &&
cl->screen->serverFormat.blueMax == 0xFF ) {
PrepareRowForJpeg24(cl, dst, x, y, count);
} else {
PrepareRowForJpeg32(cl, dst, x, y, count);
@ -1737,9 +1737,9 @@ PrepareRowForJpeg24(cl, dst, x, y, count)
while (count--) {
pix = *fbptr++;
*dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.redShift);
*dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.greenShift);
*dst++ = (uint8_t)(pix >> cl->screen->rfbServerFormat.blueShift);
*dst++ = (uint8_t)(pix >> cl->screen->serverFormat.redShift);
*dst++ = (uint8_t)(pix >> cl->screen->serverFormat.greenShift);
*dst++ = (uint8_t)(pix >> cl->screen->serverFormat.blueShift);
}
}
@ -1763,18 +1763,18 @@ PrepareRowForJpeg##bpp(cl, dst, x, y, count)
pix = *fbptr++; \
\
inRed = (int) \
(pix >> cl->screen->rfbServerFormat.redShift & cl->screen->rfbServerFormat.redMax); \
(pix >> cl->screen->serverFormat.redShift & cl->screen->serverFormat.redMax); \
inGreen = (int) \
(pix >> cl->screen->rfbServerFormat.greenShift & cl->screen->rfbServerFormat.greenMax); \
(pix >> cl->screen->serverFormat.greenShift & cl->screen->serverFormat.greenMax); \
inBlue = (int) \
(pix >> cl->screen->rfbServerFormat.blueShift & cl->screen->rfbServerFormat.blueMax); \
(pix >> cl->screen->serverFormat.blueShift & cl->screen->serverFormat.blueMax); \
\
*dst++ = (uint8_t)((inRed * 255 + cl->screen->rfbServerFormat.redMax / 2) / \
cl->screen->rfbServerFormat.redMax); \
*dst++ = (uint8_t)((inGreen * 255 + cl->screen->rfbServerFormat.greenMax / 2) / \
cl->screen->rfbServerFormat.greenMax); \
*dst++ = (uint8_t)((inBlue * 255 + cl->screen->rfbServerFormat.blueMax / 2) / \
cl->screen->rfbServerFormat.blueMax); \
*dst++ = (uint8_t)((inRed * 255 + cl->screen->serverFormat.redMax / 2) / \
cl->screen->serverFormat.redMax); \
*dst++ = (uint8_t)((inGreen * 255 + cl->screen->serverFormat.greenMax / 2) / \
cl->screen->serverFormat.greenMax); \
*dst++ = (uint8_t)((inBlue * 255 + cl->screen->serverFormat.blueMax / 2) / \
cl->screen->serverFormat.blueMax); \
} \
}

@ -252,16 +252,16 @@ rfbSetTranslateFunction(cl)
* Check that bits per pixel values are valid
*/
if ((cl->screen->rfbServerFormat.bitsPerPixel != 8) &&
(cl->screen->rfbServerFormat.bitsPerPixel != 16) &&
if ((cl->screen->serverFormat.bitsPerPixel != 8) &&
(cl->screen->serverFormat.bitsPerPixel != 16) &&
#ifdef LIBVNCSERVER_ALLOW24BPP
(cl->screen->rfbServerFormat.bitsPerPixel != 24) &&
(cl->screen->serverFormat.bitsPerPixel != 24) &&
#endif
(cl->screen->rfbServerFormat.bitsPerPixel != 32))
(cl->screen->serverFormat.bitsPerPixel != 32))
{
rfbErr("%s: server bits per pixel not 8, 16 or 32 (is %d)\n",
"rfbSetTranslateFunction",
cl->screen->rfbServerFormat.bitsPerPixel);
cl->screen->serverFormat.bitsPerPixel);
rfbCloseClient(cl);
return FALSE;
}
@ -307,7 +307,7 @@ rfbSetTranslateFunction(cl)
/* truecolour -> truecolour */
if (PF_EQ(cl->format,cl->screen->rfbServerFormat)) {
if (PF_EQ(cl->format,cl->screen->serverFormat)) {
/* client & server the same */
@ -316,36 +316,36 @@ rfbSetTranslateFunction(cl)
return TRUE;
}
if ((cl->screen->rfbServerFormat.bitsPerPixel < 16) ||
((!cl->screen->rfbServerFormat.trueColour || !rfbEconomicTranslate) &&
(cl->screen->rfbServerFormat.bitsPerPixel == 16))) {
if ((cl->screen->serverFormat.bitsPerPixel < 16) ||
((!cl->screen->serverFormat.trueColour || !rfbEconomicTranslate) &&
(cl->screen->serverFormat.bitsPerPixel == 16))) {
/* we can use a single lookup table for <= 16 bpp */
cl->translateFn = rfbTranslateWithSingleTableFns
[BPP2OFFSET(cl->screen->rfbServerFormat.bitsPerPixel)]
[BPP2OFFSET(cl->screen->serverFormat.bitsPerPixel)]
[BPP2OFFSET(cl->format.bitsPerPixel)];
if(cl->screen->rfbServerFormat.trueColour)
if(cl->screen->serverFormat.trueColour)
(*rfbInitTrueColourSingleTableFns
[BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable,
&(cl->screen->rfbServerFormat), &cl->format);
&(cl->screen->serverFormat), &cl->format);
else
(*rfbInitColourMapSingleTableFns
[BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable,
&(cl->screen->rfbServerFormat), &cl->format,&cl->screen->colourMap);
&(cl->screen->serverFormat), &cl->format,&cl->screen->colourMap);
} else {
/* otherwise we use three separate tables for red, green and blue */
cl->translateFn = rfbTranslateWithRGBTablesFns
[BPP2OFFSET(cl->screen->rfbServerFormat.bitsPerPixel)]
[BPP2OFFSET(cl->screen->serverFormat.bitsPerPixel)]
[BPP2OFFSET(cl->format.bitsPerPixel)];
(*rfbInitTrueColourRGBTablesFns
[BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable,
&(cl->screen->rfbServerFormat), &cl->format);
&(cl->screen->serverFormat), &cl->format);
}
return TRUE;
@ -396,7 +396,7 @@ rfbSetClientColourMapBGR233(cl)
len += 256 * 3 * 2;
if (WriteExact(cl, buf, len) < 0) {
if (rfbWriteExact(cl, buf, len) < 0) {
rfbLogPerror("rfbSetClientColourMapBGR233: write");
rfbCloseClient(cl);
return FALSE;
@ -419,7 +419,7 @@ rfbSetClientColourMap(cl, firstColour, nColours)
int firstColour;
int nColours;
{
if (cl->screen->rfbServerFormat.trueColour || !cl->readyForSetColourMapEntries) {
if (cl->screen->serverFormat.trueColour || !cl->readyForSetColourMapEntries) {
return TRUE;
}
@ -430,7 +430,7 @@ rfbSetClientColourMap(cl, firstColour, nColours)
if (cl->format.trueColour) {
(*rfbInitColourMapSingleTableFns
[BPP2OFFSET(cl->format.bitsPerPixel)]) (&cl->translateLookupTable,
&cl->screen->rfbServerFormat, &cl->format,&cl->screen->colourMap);
&cl->screen->serverFormat, &cl->format,&cl->screen->colourMap);
sraRgnDestroy(cl->modifiedRegion);
cl->modifiedRegion =

@ -62,7 +62,7 @@ static unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7};
*/
int
vncEncryptAndStorePasswd(char *passwd, char *fname)
rfbEncryptAndStorePasswd(char *passwd, char *fname)
{
FILE *fp;
unsigned int i;
@ -88,8 +88,8 @@ vncEncryptAndStorePasswd(char *passwd, char *fname)
/* Do encryption in-place - this way we overwrite our copy of the plaintext
password */
deskey(fixedkey, EN0);
des(encryptedPasswd, encryptedPasswd);
rfbDesKey(fixedkey, EN0);
rfbDes(encryptedPasswd, encryptedPasswd);
for (i = 0; i < 8; i++) {
putc(encryptedPasswd[i], fp);
@ -107,7 +107,7 @@ vncEncryptAndStorePasswd(char *passwd, char *fname)
*/
char *
vncDecryptPasswdFromFile(char *fname)
rfbDecryptPasswdFromFile(char *fname)
{
FILE *fp;
int i, ch;
@ -126,8 +126,8 @@ vncDecryptPasswdFromFile(char *fname)
fclose(fp);
deskey(fixedkey, DE1);
des(passwd, passwd);
rfbDesKey(fixedkey, DE1);
rfbDes(passwd, passwd);
passwd[8] = 0;
@ -141,7 +141,7 @@ vncDecryptPasswdFromFile(char *fname)
*/
void
vncRandomBytes(unsigned char *bytes)
rfbRandomBytes(unsigned char *bytes)
{
int i;
static rfbBool s_srandom_called = FALSE;
@ -162,7 +162,7 @@ vncRandomBytes(unsigned char *bytes)
*/
void
vncEncryptBytes(unsigned char *bytes, char *passwd)
rfbEncryptBytes(unsigned char *bytes, char *passwd)
{
unsigned char key[8];
unsigned int i;
@ -177,9 +177,9 @@ vncEncryptBytes(unsigned char *bytes, char *passwd)
}
}
deskey(key, EN0);
rfbDesKey(key, EN0);
for (i = 0; i < CHALLENGESIZE; i += 8) {
des(bytes+i, bytes+i);
rfbDes(bytes+i, bytes+i);
}
}

@ -122,7 +122,7 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
/*
* Convert pixel data to client format.
*/
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->rfbServerFormat,
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
&cl->format, fbptr, zlibBeforeBuf,
cl->screen->paddedWidthInBytes, w, h);
@ -174,8 +174,8 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
*/
/* Update statics */
cl->rfbRectanglesSent[rfbEncodingZlib]++;
cl->rfbBytesSent[rfbEncodingZlib] += (sz_rfbFramebufferUpdateRectHeader
cl->rectanglesSent[rfbEncodingZlib]++;
cl->bytesSent[rfbEncodingZlib] += (sz_rfbFramebufferUpdateRectHeader
+ sz_rfbZlibHeader + zlibAfterBufLen);
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader

@ -33,7 +33,7 @@
+ (cl->screen->paddedWidthInBytes * ty) \
+ (tx * (cl->screen->bitsPerPixel / 8))); \
\
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->rfbServerFormat,\
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,\
&cl->format, fbptr, (char*)buf, \
cl->screen->paddedWidthInBytes, tw, th); }
@ -123,8 +123,8 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
break;
}
cl->rfbRectanglesSent[rfbEncodingZRLE]++;
cl->rfbBytesSent[rfbEncodingZRLE] += (sz_rfbFramebufferUpdateRectHeader
cl->rectanglesSent[rfbEncodingZRLE]++;
cl->bytesSent[rfbEncodingZRLE] += (sz_rfbFramebufferUpdateRectHeader
+ sz_rfbZRLEHeader + ZRLE_BUFFER_LENGTH(&zos->out));
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZRLEHeader

@ -112,15 +112,15 @@ enum rfbNewClientAction {
RFB_CLIENT_REFUSE
};
typedef void (*KbdAddEventProcPtr) (rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl);
typedef void (*KbdReleaseAllKeysProcPtr) (struct _rfbClientRec* cl);
typedef void (*PtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbClientRec* cl);
typedef void (*SetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl);
typedef struct rfbCursor* (*GetCursorProcPtr) (struct _rfbClientRec* pScreen);
typedef rfbBool (*SetTranslateFunctionProcPtr)(struct _rfbClientRec* cl);
typedef rfbBool (*PasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len);
typedef enum rfbNewClientAction (*NewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl);
typedef void (*rfbKbdAddEventProcPtr) (rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl);
typedef void (*rfbKbdReleaseAllKeysProcPtr) (struct _rfbClientRec* cl);
typedef void (*rfbPtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbClientRec* cl);
typedef void (*rfbSetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl);
typedef struct rfbCursor* (*rfbGetCursorProcPtr) (struct _rfbClientRec* pScreen);
typedef rfbBool (*rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec* cl);
typedef rfbBool (*rfbPasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len);
typedef enum rfbNewClientAction (*rfbNewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*rfbDisplayHookPtr)(struct _rfbClientRec* cl);
typedef struct {
uint32_t count;
@ -198,14 +198,14 @@ typedef struct _rfbScreenInfo
/* additions by libvncserver */
rfbPixelFormat rfbServerFormat;
rfbPixelFormat serverFormat;
rfbColourMap colourMap; /* set this if rfbServerFormat.trueColour==FALSE */
const char* desktopName;
char rfbThisHost[255];
char thisHost[255];
rfbBool autoPort;
int rfbPort;
SOCKET rfbListenSock;
int port;
SOCKET listenSock;
int maxSock;
int maxFd;
fd_set allFds;
@ -220,7 +220,7 @@ typedef struct _rfbScreenInfo
rfbBool udpSockConnected;
struct sockaddr_in udpRemoteAddr;
int rfbMaxClientWait;
int maxClientWait;
/* http stuff */
rfbBool httpInitDone;
@ -230,22 +230,24 @@ typedef struct _rfbScreenInfo
SOCKET httpListenSock;
SOCKET httpSock;
PasswordCheckProcPtr passwordCheck;
void* rfbAuthPasswdData;
rfbPasswordCheckProcPtr passwordCheck;
void* authPasswdData;
/* If rfbAuthPasswdData is given a list, this is the first
view only password. */
int rfbAuthPasswdFirstViewOnly;
int authPasswdFirstViewOnly;
/* send only this many rectangles in one update */
int maxRectsPerUpdate;
/* this is the amount of milliseconds to wait at least before sending
* an update. */
int rfbDeferUpdateTime;
char* rfbScreen;
rfbBool rfbAlwaysShared;
rfbBool rfbNeverShared;
rfbBool rfbDontDisconnect;
struct _rfbClientRec* rfbClientHead;
int deferUpdateTime;
#ifdef TODELETE
char* screen;
#endif
rfbBool alwaysShared;
rfbBool neverShared;
rfbBool dontDisconnect;
struct _rfbClientRec* clientHead;
/* cursor */
int cursorX, cursorY,oldCursorX,oldCursorY,underCursorBufferLen;
@ -257,17 +259,17 @@ typedef struct _rfbScreenInfo
* The buffer will not be freed by
*/
char* frameBuffer;
KbdAddEventProcPtr kbdAddEvent;
KbdReleaseAllKeysProcPtr kbdReleaseAllKeys;
PtrAddEventProcPtr ptrAddEvent;
SetXCutTextProcPtr setXCutText;
GetCursorProcPtr getCursorPtr;
SetTranslateFunctionProcPtr setTranslateFunction;
rfbKbdAddEventProcPtr kbdAddEvent;
rfbKbdReleaseAllKeysProcPtr kbdReleaseAllKeys;
rfbPtrAddEventProcPtr ptrAddEvent;
rfbSetXCutTextProcPtr setXCutText;
rfbGetCursorProcPtr getCursorPtr;
rfbSetTranslateFunctionProcPtr setTranslateFunction;
/* newClientHook is called just after a new client is created */
NewClientHookPtr newClientHook;
rfbNewClientHookPtr newClientHook;
/* displayHook is called just before a frame buffer update */
DisplayHookPtr displayHook;
rfbDisplayHookPtr displayHook;
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
MUTEX(cursorMutex);
@ -409,18 +411,18 @@ typedef struct _rfbClientRec {
/* statistics */
int rfbBytesSent[MAX_ENCODINGS];
int rfbRectanglesSent[MAX_ENCODINGS];
int rfbLastRectMarkersSent;
int rfbLastRectBytesSent;
int rfbCursorShapeBytesSent;
int rfbCursorShapeUpdatesSent;
int rfbCursorPosBytesSent;
int rfbCursorPosUpdatesSent;
int rfbFramebufferUpdateMessagesSent;
int rfbRawBytesEquivalent;
int rfbKeyEventsRcvd;
int rfbPointerEventsRcvd;
int bytesSent[MAX_ENCODINGS];
int rectanglesSent[MAX_ENCODINGS];
int lastRectMarkersSent;
int lastRectBytesSent;
int cursorShapeBytesSent;
int cursorShapeUpdatesSent;
int cursorPosBytesSent;
int cursorPosUpdatesSent;
int framebufferUpdateMessagesSent;
int rawBytesEquivalent;
int keyEventsRcvd;
int pointerEventsRcvd;
#ifdef LIBVNCSERVER_HAVE_LIBZ
/* zlib encoding -- necessary compression state info per client */
@ -520,20 +522,17 @@ extern int rfbMaxClientWait;
extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen);
extern void rfbCloseClient(rfbClientPtr cl);
extern int ReadExact(rfbClientPtr cl, char *buf, int len);
extern int ReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
extern int WriteExact(rfbClientPtr cl, const char *buf, int len);
extern int rfbReadExact(rfbClientPtr cl, char *buf, int len);
extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len);
extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
extern int ConnectToTcpAddr(char* host, int port);
extern int ListenOnTCPPort(int port);
extern int ListenOnUDPPort(int port);
extern int rfbConnectToTcpAddr(char* host, int port);
extern int rfbListenOnTCPPort(int port);
extern int rfbListenOnUDPPort(int port);
/* rfbserver.c */
extern rfbClientPtr pointerClient;
/* Routines to iterate over the client list in a thread-safe way.
Only a single iterator can be in use at a time process-wide. */
typedef struct rfbClientIterator *rfbClientIteratorPtr;
@ -583,8 +582,8 @@ extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour,
/* httpd.c */
extern void httpInitSockets(rfbScreenInfoPtr rfbScreen);
extern void httpCheckFds(rfbScreenInfoPtr rfbScreen);
extern void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen);
extern void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen);
@ -660,20 +659,20 @@ extern rfbBool rfbSendCursorPos(rfbClientPtr cl);
extern void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap);
extern rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskString);
extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString);
extern void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbFreeCursor(rfbCursorPtr cursor);
extern void rfbDrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbUndrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,rfbBool freeOld);
/* cursor handling for the pointer */
extern void defaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
extern void rfbDefaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
/* zrle.c */
#ifdef LIBVNCSERVER_HAVE_LIBZ
extern rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w,int h);
extern void FreeZrleData(rfbClientPtr cl);
extern void rfbFreeZrleData(rfbClientPtr cl);
#endif
/* stats.c */
@ -751,7 +750,7 @@ void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,i
void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2);
void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion);
void doNothingWithClient(rfbClientPtr cl);
void rfbDoNothingWithClient(rfbClientPtr cl);
enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl);
/* to check against plain passwords */

@ -991,10 +991,10 @@ typedef union {
#define MAXPWLEN 8
#define CHALLENGESIZE 16
extern int vncEncryptAndStorePasswd(char *passwd, char *fname);
extern char *vncDecryptPasswdFromFile(char *fname);
extern void vncRandomBytes(unsigned char *bytes);
extern void vncEncryptBytes(unsigned char *bytes, char *passwd);
extern int rfbEncryptAndStorePasswd(char *passwd, char *fname);
extern char *rfbDecryptPasswdFromFile(char *fname);
extern void rfbRandomBytes(unsigned char *bytes);
extern void rfbEncryptBytes(unsigned char *bytes, char *passwd);
#endif

@ -13,9 +13,9 @@ int main(int argc,char** argv)
#define CHECK(a,b) if(screen->a!=b) { fprintf(stderr,#a " is %d (should be " #b ")\n",screen->a); ret=1; }
CHECK(width,1024);
CHECK(height,768);
CHECK(rfbAlwaysShared,TRUE);
CHECK(alwaysShared,TRUE);
CHECK(httpPort,3002);
CHECK(rfbDontDisconnect,TRUE);
CHECK(dontDisconnect,TRUE);
if(fake_argc!=2) {
fprintf(stderr,"fake_argc is %d (should be 2)\n",fake_argc);
ret=1;

@ -21,7 +21,7 @@ int main(int argc,char** argv)
rfbScreenInfoPtr server=rfbGetScreen(&argc,argv,width,height,8,3,4);
server->frameBuffer=(char*)malloc(width*height*4);
initBackground(server);
server->rfbDeferUpdateTime=0;
server->deferUpdateTime=0;
rfbInitServer(server);
r=0;

@ -114,12 +114,12 @@ int main(int argc,char **argv)
/* console init */
console=vcGetConsole(&argc,argv,width,height,&vgaFont,TRUE);
for(i=0;i<16;i++) {
console->rfbScreen->colourMap.data.bytes[i*3+0]=default_red[color_table[i]];
console->rfbScreen->colourMap.data.bytes[i*3+1]=default_grn[color_table[i]];
console->rfbScreen->colourMap.data.bytes[i*3+2]=default_blu[color_table[i]];
console->screen->colourMap.data.bytes[i*3+0]=default_red[color_table[i]];
console->screen->colourMap.data.bytes[i*3+1]=default_grn[color_table[i]];
console->screen->colourMap.data.bytes[i*3+2]=default_blu[color_table[i]];
}
console->rfbScreen->desktopName=title;
console->rfbScreen->kbdAddEvent=do_key;
console->screen->desktopName=title;
console->screen->kbdAddEvent=do_key;
console->selectTimeOut=100000;
console->wrapBottomToTop=TRUE;
#ifdef USE_OLD_VCS

@ -25,24 +25,24 @@ unsigned char colourMap16[16*3]={
void MakeColourMap16(vncConsolePtr c)
{
int i,j;
rfbColourMap* colourMap=&(c->rfbScreen->colourMap);
rfbColourMap* colourMap=&(c->screen->colourMap);
if(colourMap->count)
free(colourMap->data.bytes);
colourMap->data.bytes=malloc(16*3);
memcpy(colourMap->data.bytes,colourMap16,16*3);
colourMap->count=16;
colourMap->is16=FALSE;
c->rfbScreen->rfbServerFormat.trueColour=FALSE;
c->screen->serverFormat.trueColour=FALSE;
}
void vcDrawOrHideCursor(vncConsolePtr c)
{
int i,j,w=c->rfbScreen->paddedWidthInBytes;
char *b=c->rfbScreen->frameBuffer+c->y*c->cHeight*w+c->x*c->cWidth;
int i,j,w=c->screen->paddedWidthInBytes;
char *b=c->screen->frameBuffer+c->y*c->cHeight*w+c->x*c->cWidth;
for(j=c->cy1;j<c->cy2;j++)
for(i=c->cx1;i<c->cx2;i++)
b[j*w+i]^=0x0f;
rfbMarkRectAsModified(c->rfbScreen,
rfbMarkRectAsModified(c->screen,
c->x*c->cWidth+c->cx1,c->y*c->cHeight+c->cy1,
c->x*c->cWidth+c->cx2,c->y*c->cHeight+c->cy2);
c->cursorIsDrawn=c->cursorIsDrawn?FALSE:TRUE;
@ -50,7 +50,7 @@ void vcDrawOrHideCursor(vncConsolePtr c)
void vcDrawCursor(vncConsolePtr c)
{
rfbDrawCursor(c->rfbScreen);
rfbDrawCursor(c->screen);
if(c->cursorActive && !c->cursorIsDrawn && c->y<c->height && c->x<c->width) {
/* rfbLog("DrawCursor: %d,%d\n",c->x,c->y); */
vcDrawOrHideCursor(c);
@ -59,7 +59,7 @@ void vcDrawCursor(vncConsolePtr c)
void vcHideCursor(vncConsolePtr c)
{
rfbUndrawCursor(c->rfbScreen);
rfbUndrawCursor(c->screen);
if(c->currentlyMarking)
vcUnmark(c);
if(c->cursorIsDrawn) {
@ -126,23 +126,23 @@ vncConsolePtr vcGetConsole(int *argc,char **argv,
if(c->cy1<0)
c->cy2=0;
c->rfbScreen=
c->screen=
rfbGetScreen(argc,argv,c->cWidth*c->width,c->cHeight*c->height,8,1,1);
c->rfbScreen->screenData=(void*)c;
c->rfbScreen->displayHook=vcMakeSureCursorIsDrawn;
c->rfbScreen->frameBuffer=
(char*)malloc(c->rfbScreen->width*c->rfbScreen->height);
memset(c->rfbScreen->frameBuffer,c->backColour,
c->rfbScreen->width*c->rfbScreen->height);
c->rfbScreen->kbdAddEvent=vcKbdAddEventProc;
c->rfbScreen->ptrAddEvent=vcPtrAddEventProc;
c->rfbScreen->setXCutText=vcSetXCutTextProc;
c->screen->screenData=(void*)c;
c->screen->displayHook=vcMakeSureCursorIsDrawn;
c->screen->frameBuffer=
(char*)malloc(c->screen->width*c->screen->height);
memset(c->screen->frameBuffer,c->backColour,
c->screen->width*c->screen->height);
c->screen->kbdAddEvent=vcKbdAddEventProc;
c->screen->ptrAddEvent=vcPtrAddEventProc;
c->screen->setXCutText=vcSetXCutTextProc;
MakeColourMap16(c);
c->foreColour=0x7;
c->backColour=0;
rfbInitServer(c->rfbScreen);
rfbInitServer(c->screen);
return(c);
}
@ -153,7 +153,7 @@ vncConsolePtr vcGetConsole(int *argc,char **argv,
void vcScroll(vncConsolePtr c,int lineCount)
{
int y1,y2;
rfbScreenInfoPtr s=c->rfbScreen;
rfbScreenInfoPtr s=c->screen;
if(lineCount==0)
return;
@ -232,7 +232,7 @@ void vcPutChar(vncConsolePtr c,unsigned char ch)
void vcPutCharColour(vncConsolePtr c,unsigned char ch,unsigned char foreColour,unsigned char backColour)
{
rfbScreenInfoPtr s=c->rfbScreen;
rfbScreenInfoPtr s=c->screen;
int j,x,y;
vcHideCursor(c);
@ -394,15 +394,15 @@ void vcPtrAddEventProc(int buttonMask,int x,int y,rfbClientPtr cl)
{
vncConsolePtr c=(vncConsolePtr)cl->screen->screenData;
rfbUndrawCursor(c->rfbScreen);
rfbUndrawCursor(c->screen);
if(c->wasRightButtonDown) {
if((buttonMask&4)==0) {
if(c->selection) {
char* s;
for(s=c->selection;*s;s++) {
c->rfbScreen->kbdAddEvent(1,*s,cl);
c->rfbScreen->kbdAddEvent(0,*s,cl);
c->screen->kbdAddEvent(1,*s,cl);
c->screen->kbdAddEvent(0,*s,cl);
}
}
c->wasRightButtonDown=0;
@ -455,9 +455,9 @@ void vcPtrAddEventProc(int buttonMask,int x,int y,rfbClientPtr cl)
memcpy(c->selection,c->screenBuffer+i,j-i);
c->selection[j-i]=0;
vcUnmark(c);
rfbGotXCutText(c->rfbScreen,c->selection,j-i);
rfbGotXCutText(c->screen,c->selection,j-i);
}
defaultPtrAddEvent(buttonMask,x,y,cl);
rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
}
void vcSetXCutTextProc(char* str,int len, struct _rfbClientRec* cl)
@ -475,12 +475,12 @@ void vcToggleMarkCell(vncConsolePtr c,int pos)
int x=(pos%c->width)*c->cWidth,
y=(pos/c->width)*c->cHeight;
int i,j;
rfbScreenInfoPtr s=c->rfbScreen;
rfbScreenInfoPtr s=c->screen;
char *b=s->frameBuffer+y*s->width+x;
for(j=0;j<c->cHeight;j++)
for(i=0;i<c->cWidth;i++)
b[j*s->width+i]^=0x0f;
rfbMarkRectAsModified(c->rfbScreen,x,y,x+c->cWidth,y+c->cHeight);
rfbMarkRectAsModified(c->screen,x,y,x+c->cWidth,y+c->cHeight);
}
void vcUnmark(vncConsolePtr c)
@ -498,6 +498,6 @@ void vcUnmark(vncConsolePtr c)
void vcProcessEvents(vncConsolePtr c)
{
rfbProcessEvents(c->rfbScreen,c->selectTimeOut);
rfbProcessEvents(c->screen,c->selectTimeOut);
}

@ -52,7 +52,7 @@ typedef struct vncConsole {
rfbBool dontDrawCursor; /* for example, while scrolling */
rfbFontDataPtr font;
rfbScreenInfoPtr rfbScreen;
rfbScreenInfoPtr screen;
} vncConsole, *vncConsolePtr;
#ifdef USE_ATTRIBUTE_BUFFER

@ -1904,7 +1904,7 @@ enum rfbNewClientAction new_client(rfbClientPtr client) {
}
if (connect_once) {
if (screen->rfbDontDisconnect && screen->rfbNeverShared) {
if (screen->dontDisconnect && screen->neverShared) {
if (! shared && accepted_client) {
rfbLog("denying additional client: %s\n",
client->host);
@ -4247,7 +4247,7 @@ void check_xevents(void) {
static int first = 1, sent_some_sel = 0;
static time_t last_request = 0;
time_t now = time(0);
int have_clients = screen->rfbClientHead ? 1 : 0;
int have_clients = screen->clientHead ? 1 : 0;
X_LOCK;
if (first && (watch_selection || vnc_connect)) {
@ -5161,7 +5161,7 @@ void set_colormap(void) {
if (first) {
screen->colourMap.count = NCOLOR;
screen->rfbServerFormat.trueColour = FALSE;
screen->serverFormat.trueColour = FALSE;
screen->colourMap.is16 = TRUE;
screen->colourMap.data.shorts = (unsigned short*)
malloc(3*sizeof(short) * NCOLOR);
@ -5477,15 +5477,15 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
#endif
screen->paddedWidthInBytes = rfb_bytes_per_line;
screen->rfbServerFormat.bitsPerPixel = fb->bits_per_pixel;
screen->rfbServerFormat.depth = fb->depth;
screen->rfbServerFormat.trueColour = (uint8_t) TRUE;
screen->serverFormat.bitsPerPixel = fb->bits_per_pixel;
screen->serverFormat.depth = fb->depth;
screen->serverFormat.trueColour = (uint8_t) TRUE;
have_masks = ((fb->red_mask|fb->green_mask|fb->blue_mask) != 0);
if (force_indexed_color) {
have_masks = 0;
}
if ( ! have_masks && screen->rfbServerFormat.bitsPerPixel == 8
if ( ! have_masks && screen->serverFormat.bitsPerPixel == 8
&& CellsOfScreen(ScreenOfDisplay(dpy,scr)) ) {
/* indexed colour */
if (!quiet) {
@ -5513,41 +5513,41 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
}
/* convert masks to bit shifts and max # colors */
screen->rfbServerFormat.redShift = 0;
screen->serverFormat.redShift = 0;
if ( fb->red_mask ) {
while ( ! (fb->red_mask
& (1 << screen->rfbServerFormat.redShift) ) ) {
screen->rfbServerFormat.redShift++;
& (1 << screen->serverFormat.redShift) ) ) {
screen->serverFormat.redShift++;
}
}
screen->rfbServerFormat.greenShift = 0;
screen->serverFormat.greenShift = 0;
if ( fb->green_mask ) {
while ( ! (fb->green_mask
& (1 << screen->rfbServerFormat.greenShift) ) ) {
screen->rfbServerFormat.greenShift++;
& (1 << screen->serverFormat.greenShift) ) ) {
screen->serverFormat.greenShift++;
}
}
screen->rfbServerFormat.blueShift = 0;
screen->serverFormat.blueShift = 0;
if ( fb->blue_mask ) {
while ( ! (fb->blue_mask
& (1 << screen->rfbServerFormat.blueShift) ) ) {
screen->rfbServerFormat.blueShift++;
& (1 << screen->serverFormat.blueShift) ) ) {
screen->serverFormat.blueShift++;
}
}
screen->rfbServerFormat.redMax
= fb->red_mask >> screen->rfbServerFormat.redShift;
screen->rfbServerFormat.greenMax
= fb->green_mask >> screen->rfbServerFormat.greenShift;
screen->rfbServerFormat.blueMax
= fb->blue_mask >> screen->rfbServerFormat.blueShift;
screen->serverFormat.redMax
= fb->red_mask >> screen->serverFormat.redShift;
screen->serverFormat.greenMax
= fb->green_mask >> screen->serverFormat.greenShift;
screen->serverFormat.blueMax
= fb->blue_mask >> screen->serverFormat.blueShift;
main_red_max = screen->rfbServerFormat.redMax;
main_green_max = screen->rfbServerFormat.greenMax;
main_blue_max = screen->rfbServerFormat.blueMax;
main_red_max = screen->serverFormat.redMax;
main_green_max = screen->serverFormat.greenMax;
main_blue_max = screen->serverFormat.blueMax;
main_red_shift = screen->rfbServerFormat.redShift;
main_green_shift = screen->rfbServerFormat.greenShift;
main_blue_shift = screen->rfbServerFormat.blueShift;
main_red_shift = screen->serverFormat.redShift;
main_green_shift = screen->serverFormat.greenShift;
main_blue_shift = screen->serverFormat.blueShift;
}
if (overlay && ! quiet) {
rfbLog("\n");
@ -5587,7 +5587,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
fclose(stdout);
/* we keep stderr for logging */
screen->inetdSock = fd;
screen->rfbPort = 0;
screen->port = 0;
} else if (! got_rfbport) {
screen->autoPort = TRUE;
@ -5595,16 +5595,16 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (! got_nevershared && ! got_alwaysshared) {
if (shared) {
screen->rfbAlwaysShared = TRUE;
screen->alwaysShared = TRUE;
} else {
screen->rfbDontDisconnect = TRUE;
screen->rfbNeverShared = TRUE;
screen->dontDisconnect = TRUE;
screen->neverShared = TRUE;
}
}
/* XXX the following is based on libvncserver defaults. */
if (screen->rfbDeferUpdateTime == 5) {
if (screen->deferUpdateTime == 5) {
/* XXX will be fixed someday */
screen->rfbDeferUpdateTime = defer_update;
screen->deferUpdateTime = defer_update;
}
/* event callbacks: */
@ -5625,8 +5625,8 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
rfbInitServer(screen);
bpp = screen->rfbServerFormat.bitsPerPixel;
depth = screen->rfbServerFormat.depth;
bpp = screen->serverFormat.bitsPerPixel;
depth = screen->serverFormat.depth;
if (scaling) {
mark_rect_as_modified(0, 0, dpy_x, dpy_y, 0);
@ -5635,11 +5635,11 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (viewonly_passwd) {
/* append the view only passwd after the normal passwd */
char **passwds_new = malloc(3*sizeof(char**));
char **passwds_old = (char **) screen->rfbAuthPasswdData;
char **passwds_old = (char **) screen->authPasswdData;
passwds_new[0] = passwds_old[0];
passwds_new[1] = viewonly_passwd;
passwds_new[2] = NULL;
screen->rfbAuthPasswdData = (void*) passwds_new;
screen->authPasswdData = (void*) passwds_new;
}
}
@ -6564,7 +6564,7 @@ static void scale_and_mark_rect(int X1, int Y1, int X2, int Y2) {
shrink = 0;
}
if (! screen->rfbServerFormat.trueColour) {
if (! screen->serverFormat.trueColour) {
/*
* PseudoColor colormap... blending leads to random colors.
*/
@ -8265,7 +8265,7 @@ static void watch_loop(void) {
check_xevents();
check_connect_inputs();
if (! screen->rfbClientHead) { /* waiting for a client */
if (! screen->clientHead) { /* waiting for a client */
usleep(200 * 1000);
continue;
}
@ -9176,7 +9176,7 @@ int main(int argc, char* argv[]) {
CHECK_ARGC
passwdfile = argv[++i];
} else if (!strcmp(arg, "-storepasswd")) {
if (i+2 >= argc || vncEncryptAndStorePasswd(argv[i+1],
if (i+2 >= argc || rfbEncryptAndStorePasswd(argv[i+1],
argv[i+2]) != 0) {
fprintf(stderr, "-storepasswd failed\n");
exit(1);
@ -10020,7 +10020,7 @@ int main(int argc, char* argv[]) {
}
if (! inetd) {
if (! screen->rfbPort || screen->rfbListenSock < 0) {
if (! screen->port || screen->listenSock < 0) {
rfbLog("Error: could not obtain listening port.\n");
clean_up_exit(1);
}
@ -10028,9 +10028,9 @@ int main(int argc, char* argv[]) {
if (! quiet) {
rfbLog("screen setup finished.\n");
}
if (screen->rfbPort) {
if (screen->port) {
char *host = this_host();
int port = screen->rfbPort;
int port = screen->port;
if (host != NULL) {
/* note that vncviewer special cases 5900-5999 */
if (inetd) {
@ -10061,7 +10061,7 @@ int main(int argc, char* argv[]) {
if (inetd) {
; /* should not occur (rfbPort) */
} else {
fprintf(stdout, "PORT=%d\n", screen->rfbPort);
fprintf(stdout, "PORT=%d\n", screen->port);
}
fflush(stdout);
}

Loading…
Cancel
Save