summaryrefslogtreecommitdiffstats
path: root/libvncserver
diff options
context:
space:
mode:
Diffstat (limited to 'libvncserver')
-rwxr-xr-xlibvncserver/auth.c6
-rw-r--r--libvncserver/cargs.c10
-rwxr-xr-xlibvncserver/corre.c31
-rw-r--r--libvncserver/cursor.c18
-rwxr-xr-xlibvncserver/d3des.c32
-rwxr-xr-xlibvncserver/font.c6
-rwxr-xr-xlibvncserver/hextile.c67
-rwxr-xr-xlibvncserver/httpd.c6
-rw-r--r--libvncserver/main.c54
-rw-r--r--libvncserver/private.h23
-rwxr-xr-xlibvncserver/rfbregion.c54
-rw-r--r--libvncserver/rfbserver.c123
-rwxr-xr-xlibvncserver/rre.c31
-rwxr-xr-xlibvncserver/selbox.c4
-rwxr-xr-xlibvncserver/sockets.c34
-rw-r--r--libvncserver/tight.c300
-rwxr-xr-xlibvncserver/translate.c29
-rw-r--r--libvncserver/vncauth.c8
-rw-r--r--libvncserver/zlib.c18
-rw-r--r--libvncserver/zrle.c3
-rw-r--r--libvncserver/zrleencodetemplate.c2
-rw-r--r--libvncserver/zrleoutstream.c3
22 files changed, 408 insertions, 454 deletions
diff --git a/libvncserver/auth.c b/libvncserver/auth.c
index 06976a3..0988538 100755
--- a/libvncserver/auth.c
+++ b/libvncserver/auth.c
@@ -35,8 +35,7 @@
*/
void
-rfbAuthNewClient(cl)
- rfbClientPtr cl;
+rfbAuthNewClient(rfbClientPtr cl)
{
char buf[4 + CHALLENGESIZE];
int len;
@@ -68,8 +67,7 @@ rfbAuthNewClient(cl)
*/
void
-rfbAuthProcessClientMessage(cl)
- rfbClientPtr cl;
+rfbAuthProcessClientMessage(rfbClientPtr cl)
{
int n;
uint8_t response[CHALLENGESIZE];
diff --git a/libvncserver/cargs.c b/libvncserver/cargs.c
index fbd3cc9..d0e3309 100644
--- a/libvncserver/cargs.c
+++ b/libvncserver/cargs.c
@@ -14,7 +14,7 @@
#include <rfb/rfb.h>
-extern rfbStringToAddr(char *str, in_addr_t *iface);
+extern int rfbStringToAddr(char *str, in_addr_t *iface);
void
rfbUsage(void)
@@ -88,7 +88,7 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
return FALSE;
}
passwds[0] = argv[++i];
- passwds[1] = 0;
+ passwds[1] = NULL;
rfbScreen->authPasswdData = (void*)passwds;
rfbScreen->passwordCheck = rfbCheckPasswordByList;
} else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */
@@ -149,12 +149,6 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
return TRUE;
}
-void rfbSizeUsage()
-{
- fprintf(stderr, "-width sets the width of the framebuffer\n");
- fprintf(stderr, "-height sets the height of the framebuffer\n");
-}
-
rfbBool
rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[])
{
diff --git a/libvncserver/corre.c b/libvncserver/corre.c
index 511a34b..058a77c 100755
--- a/libvncserver/corre.c
+++ b/libvncserver/corre.c
@@ -57,9 +57,11 @@ static rfbBool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y,
*/
rfbBool
-rfbSendRectEncodingCoRRE(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingCoRRE(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
if (h > cl->correMaxHeight) {
return (rfbSendRectEncodingCoRRE(cl, x, y, w, cl->correMaxHeight) &&
@@ -85,9 +87,11 @@ rfbSendRectEncodingCoRRE(cl, x, y, w, h)
*/
static rfbBool
-rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
rfbRREHeader hdr;
@@ -206,11 +210,7 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \
static int \
-subrectEncode##bpp(data,w,h) \
- uint##bpp##_t *data; \
- int w; \
- int h; \
-{ \
+subrectEncode##bpp(uint##bpp##_t *data, int w, int h) { \
uint##bpp##_t cl; \
rfbCoRRERectangle subrect; \
int x,y; \
@@ -277,7 +277,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \
\
numsubs += 1; \
- *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
+ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbCoRRERectangle); \
rreAfterBufLen += sz_rfbCoRRERectangle; \
@@ -306,12 +306,9 @@ DEFINE_SUBRECT_ENCODE(32)
* getBgColour() gets the most prevalent colour in a byte array.
*/
static uint32_t
-getBgColour(data,size,bpp)
- char *data;
- int size;
- int bpp;
+getBgColour(char *data, int size, int bpp)
{
-
+
#define NUMCLRS 256
static int counts[NUMCLRS];
diff --git a/libvncserver/cursor.c b/libvncserver/cursor.c
index 2577064..4794140 100644
--- a/libvncserver/cursor.c
+++ b/libvncserver/cursor.c
@@ -24,14 +24,14 @@
#include <rfb/rfb.h>
#include <rfb/rfbregion.h>
+#include "private.h"
/*
* Send cursor shape either in X-style format or in client pixel format.
*/
rfbBool
-rfbSendCursorShape(cl)
- rfbClientPtr cl;
+rfbSendCursorShape(rfbClientPtr cl)
{
rfbCursorPtr pCursor;
rfbFramebufferUpdateRectHeader rect;
@@ -360,8 +360,8 @@ void rfbFreeCursor(rfbCursorPtr cursor)
else {
cursor->cleanup=cursor->cleanupSource=cursor->cleanupMask
=cursor->cleanupRichSource=FALSE;
- cursor->source=cursor->mask=cursor->richSource=0;
- cursor->alphaSource=0;
+ cursor->source=cursor->mask=cursor->richSource=NULL;
+ cursor->alphaSource=NULL;
}
}
@@ -633,9 +633,9 @@ void rfbRedrawAfterHideCursor(rfbClientPtr cl,sraRegionPtr updateRegion)
}
}
-/* for debugging */
+#ifdef DEBUG
-void rfbPrintXCursor(rfbCursorPtr cursor)
+static void rfbPrintXCursor(rfbCursorPtr cursor)
{
int i,i1,j,w=(cursor->width+7)/8;
unsigned char bit;
@@ -649,6 +649,8 @@ void rfbPrintXCursor(rfbCursorPtr cursor)
}
}
+#endif
+
void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c)
{
rfbClientIteratorPtr iterator;
@@ -660,7 +662,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c)
iterator=rfbGetClientIterator(rfbScreen);
while((cl=rfbClientIteratorNext(iterator)))
if(!cl->enableCursorShapeUpdates)
- rfbRedrawAfterHideCursor(cl,0);
+ rfbRedrawAfterHideCursor(cl,NULL);
rfbReleaseClientIterator(iterator);
if(rfbScreen->cursor->cleanup)
@@ -673,7 +675,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c)
while((cl=rfbClientIteratorNext(iterator))) {
cl->cursorWasChanged = TRUE;
if(!cl->enableCursorShapeUpdates)
- rfbRedrawAfterHideCursor(cl,0);
+ rfbRedrawAfterHideCursor(cl,NULL);
}
rfbReleaseClientIterator(iterator);
diff --git a/libvncserver/d3des.c b/libvncserver/d3des.c
index 21362ad..2df1aab 100755
--- a/libvncserver/d3des.c
+++ b/libvncserver/d3des.c
@@ -71,9 +71,8 @@ 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 rfbDesKey(key, edf) /* Thanks to James Gillogly & Phil Karn! */
-unsigned char *key;
-int edf;
+void rfbDesKey(unsigned char *key,
+ int edf)
{
register int i, j, l, m, n;
unsigned char pc1m[56], pcr[56];
@@ -108,8 +107,7 @@ int edf;
return;
}
-static void cookey(raw1)
-register unsigned long *raw1;
+static void cookey(register unsigned long *raw1)
{
register unsigned long *cook, *raw0;
unsigned long dough[32];
@@ -131,8 +129,7 @@ register unsigned long *raw1;
return;
}
-void rfbCPKey(into)
-register unsigned long *into;
+void rfbCPKey(register unsigned long *into)
{
register unsigned long *from, *endp;
@@ -141,8 +138,7 @@ register unsigned long *into;
return;
}
-void rfbUseKey(from)
-register unsigned long *from;
+void rfbUseKey(register unsigned long *from)
{
register unsigned long *to, *endp;
@@ -151,8 +147,8 @@ register unsigned long *from;
return;
}
-void rfbDes(inblock, outblock)
-unsigned char *inblock, *outblock;
+void rfbDes(unsigned char *inblock,
+ unsigned char *outblock)
{
unsigned long work[2];
@@ -162,9 +158,8 @@ unsigned char *inblock, *outblock;
return;
}
-static void scrunch(outof, into)
-register unsigned char *outof;
-register unsigned long *into;
+static void scrunch(register unsigned char *outof,
+ register unsigned long *into)
{
*into = (*outof++ & 0xffL) << 24;
*into |= (*outof++ & 0xffL) << 16;
@@ -177,9 +172,8 @@ register unsigned long *into;
return;
}
-static void unscrun(outof, into)
-register unsigned long *outof;
-register unsigned char *into;
+static void unscrun(register unsigned long *outof,
+ register unsigned char *into)
{
*into++ = (unsigned char)((*outof >> 24) & 0xffL);
*into++ = (unsigned char)((*outof >> 16) & 0xffL);
@@ -336,8 +330,8 @@ static unsigned long SP8[64] = {
0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
-static void desfunc(block, keys)
-register unsigned long *block, *keys;
+static void desfunc(register unsigned long *block,
+ register unsigned long *keys)
{
register unsigned long fval, work, right, leftt;
register int round;
diff --git a/libvncserver/font.c b/libvncserver/font.c
index 18c1bbb..267d8a2 100755
--- a/libvncserver/font.c
+++ b/libvncserver/font.c
@@ -145,7 +145,7 @@ void rfbWholeFontBBox(rfbFontDataPtr font,
int i;
int* m=font->metaData;
- (*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=-INT_MAX+1;
+ (*x1)=(*y1)=INT_MAX; (*x2)=(*y2)=1-(INT_MAX);
for(i=0;i<256;i++) {
if(m[i*5+1]-m[i*5+3]>(*x2))
(*x2)=m[i*5+1]-m[i*5+3];
@@ -164,14 +164,14 @@ rfbFontDataPtr rfbLoadConsoleFont(char *filename)
rfbFontDataPtr p;
int i;
- if(!f) return(0);
+ if(!f) return NULL;
p=(rfbFontDataPtr)malloc(sizeof(rfbFontData));
p->data=(unsigned char*)malloc(4096);
if(1!=fread(p->data,4096,1,f)) {
free(p->data);
free(p);
- return(0);
+ return NULL;
}
fclose(f);
p->metaData=(int*)malloc(256*5*sizeof(int));
diff --git a/libvncserver/hextile.c b/libvncserver/hextile.c
index 55cf049..70ee67f 100755
--- a/libvncserver/hextile.c
+++ b/libvncserver/hextile.c
@@ -37,9 +37,11 @@ static rfbBool sendHextiles32(rfbClientPtr cl, int x, int y, int w, int h);
*/
rfbBool
-rfbSendRectEncodingHextile(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingHextile(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
@@ -89,29 +91,26 @@ rfbSendRectEncodingHextile(cl, x, y, w, h)
#define DEFINE_SEND_HEXTILES(bpp) \
\
\
-static rfbBool subrectEncode##bpp(rfbClientPtr cli, uint##bpp##_t *data, int w, int h, \
- uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono); \
-static void testColours##bpp(uint##bpp##_t *data, int size, rfbBool *mono, \
- rfbBool *solid, uint##bpp##_t *bg, uint##bpp##_t *fg); \
+static rfbBool subrectEncode##bpp(rfbClientPtr cli, uint##bpp##_t *data, \
+ int w, int h, uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono);\
+static void testColours##bpp(uint##bpp##_t *data, int size, rfbBool *mono, \
+ rfbBool *solid, uint##bpp##_t *bg, uint##bpp##_t *fg); \
\
\
/* \
* rfbSendHextiles \
*/ \
\
-static rfbBool \
-sendHextiles##bpp(cl, rx, ry, rw, rh) \
- rfbClientPtr cl; \
- int rx, ry, rw, rh; \
-{ \
+static rfbBool \
+sendHextiles##bpp(rfbClientPtr cl, int rx, int ry, int rw, int rh) { \
int x, y, w, h; \
int startUblen; \
char *fbptr; \
- uint##bpp##_t bg = 0, fg = 0, newBg, newFg; \
- rfbBool mono, solid; \
- rfbBool validBg = FALSE; \
- rfbBool validFg = FALSE; \
- uint##bpp##_t clientPixelData[16*16*(bpp/8)]; \
+ uint##bpp##_t bg = 0, fg = 0, newBg, newFg; \
+ rfbBool mono, solid; \
+ rfbBool validBg = FALSE; \
+ rfbBool validFg = FALSE; \
+ uint##bpp##_t clientPixelData[16*16*(bpp/8)]; \
\
for (y = ry; y < ry+rh; y += 16) { \
for (x = rx; x < rx+rw; x += 16) { \
@@ -128,11 +127,11 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
} \
\
fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y) \
- + (x * (cl->screen->bitsPerPixel / 8))); \
+ + (x * (cl->screen->bitsPerPixel / 8))); \
\
(*cl->translateFn)(cl->translateLookupTable, &(cl->screen->serverFormat), \
&cl->format, fbptr, (char *)clientPixelData, \
- cl->screen->paddedWidthInBytes, w, h); \
+ cl->screen->paddedWidthInBytes, w, h); \
\
startUblen = cl->ublen; \
cl->updateBuf[startUblen] = 0; \
@@ -149,7 +148,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
} \
\
if (solid) { \
- cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
+ cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
continue; \
} \
\
@@ -176,7 +175,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
(*cl->translateFn)(cl->translateLookupTable, \
&(cl->screen->serverFormat), &cl->format, fbptr, \
(char *)clientPixelData, \
- cl->screen->paddedWidthInBytes, w, h); \
+ cl->screen->paddedWidthInBytes, w, h); \
\
memcpy(&cl->updateBuf[cl->ublen], (char *)clientPixelData, \
w * h * (bpp/8)); \
@@ -184,7 +183,7 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
cl->ublen += w * h * (bpp/8); \
} \
\
- cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
+ cl->bytesSent[rfbEncodingHextile] += cl->ublen - startUblen; \
} \
} \
\
@@ -192,17 +191,17 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
} \
\
\
-static rfbBool \
-subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h, \
- uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono) \
+static rfbBool \
+subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h, \
+ uint##bpp##_t bg, uint##bpp##_t fg, rfbBool mono) \
{ \
- uint##bpp##_t cl2; \
+ uint##bpp##_t cl2; \
int x,y; \
int i,j; \
int hx=0,hy,vx=0,vy; \
int hyflag; \
- uint##bpp##_t *seg; \
- uint##bpp##_t *line; \
+ uint##bpp##_t *seg; \
+ uint##bpp##_t *line; \
int hw,hh,vw,vh; \
int thex,they,thew,theh; \
int numsubs = 0; \
@@ -295,15 +294,9 @@ subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h,
*/ \
\
static void \
-testColours##bpp(data,size,mono,solid,bg,fg) \
- uint##bpp##_t *data; \
- int size; \
- rfbBool *mono; \
- rfbBool *solid; \
- uint##bpp##_t *bg; \
- uint##bpp##_t *fg; \
-{ \
- uint##bpp##_t colour1 = 0, colour2 = 0; \
+testColours##bpp(uint##bpp##_t *data, int size, rfbBool *mono, rfbBool *solid, \
+ uint##bpp##_t *bg, uint##bpp##_t *fg) { \
+ uint##bpp##_t colour1 = 0, colour2 = 0; \
int n1 = 0, n2 = 0; \
*mono = TRUE; \
*solid = TRUE; \
diff --git a/libvncserver/httpd.c b/libvncserver/httpd.c
index f341d1a..4be8f55 100755
--- a/libvncserver/httpd.c
+++ b/libvncserver/httpd.c
@@ -69,7 +69,7 @@
#define OK_STR "HTTP/1.0 200 OK\nContent-Type: text/html\r\n\r\n"
-static void httpProcessInput();
+static void httpProcessInput(rfbScreenInfoPtr screen);
static rfbBool compareAndSkip(char **ptr, const char *str);
static rfbBool parseParams(const char *request, char *result, int max_bytes);
static rfbBool validateString(char *str);
@@ -131,7 +131,7 @@ rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
fd_set fds;
struct timeval tv;
struct sockaddr_in addr;
- size_t addrlen = sizeof(addr);
+ socklen_t addrlen = sizeof(addr);
if (!rfbScreen->httpDir)
return;
@@ -221,7 +221,7 @@ static void
httpProcessInput(rfbScreenInfoPtr rfbScreen)
{
struct sockaddr_in addr;
- size_t addrlen = sizeof(addr);
+ socklen_t addrlen = sizeof(addr);
char fullFname[512];
char params[1024];
char *ptr;
diff --git a/libvncserver/main.c b/libvncserver/main.c
index bec7e2f..7c7bc3d 100644
--- a/libvncserver/main.c
+++ b/libvncserver/main.c
@@ -10,8 +10,10 @@
* see GPL (latest version) for full details
*/
+#define _BSD_SOURCE
#include <rfb/rfb.h>
#include <rfb/rfbregion.h>
+#include "private.h"
#include <stdarg.h>
#include <errno.h>
@@ -35,10 +37,10 @@
#include <time.h>
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
-MUTEX(logMutex);
+static MUTEX(logMutex);
#endif
-int rfbEnableLogging=1;
+static int rfbEnableLogging=1;
#ifdef LIBVNCSERVER_WORDS_BIGENDIAN
char rfbEndianTest = 0;
@@ -46,10 +48,6 @@ char rfbEndianTest = 0;
char rfbEndianTest = -1;
#endif
-/* from rfbserver.c */
-void rfbIncrClientRef(rfbClientPtr cl);
-void rfbDecrClientRef(rfbClientPtr cl);
-
void rfbLogEnable(int enabled) {
rfbEnableLogging=enabled;
}
@@ -58,7 +56,7 @@ void rfbLogEnable(int enabled) {
* rfbLog prints a time-stamped message to the log file (stderr).
*/
-void
+static void
rfbDefaultLog(const char *format, ...)
{
va_list args;
@@ -220,6 +218,8 @@ void rfbMarkRectAsModified(rfbScreenInfoPtr screen,int x1,int y1,int x2,int y2)
}
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
+#include <unistd.h>
+
static void *
clientOutput(void *data)
{
@@ -305,7 +305,7 @@ listenerRun(void *data)
int client_fd;
struct sockaddr_in peer;
rfbClientPtr cl;
- size_t len;
+ socklen_t len;
len = sizeof(peer);
@@ -355,7 +355,6 @@ rfbDefaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
rfbClientIteratorPtr iterator;
rfbClientPtr other_client;
rfbScreenInfoPtr s = cl->screen;
- rfbCursorPtr c = s->cursor;
if (x != s->cursorX || y != s->cursorY) {
LOCK(s->cursorMutex);
@@ -378,7 +377,7 @@ rfbDefaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
}
}
-void rfbDefaultSetXCutText(char* text, int len, rfbClientPtr cl)
+static void rfbDefaultSetXCutText(char* text, int len, rfbClientPtr cl)
{
}
@@ -393,7 +392,7 @@ static rfbCursor myCursor =
8, 7, 3, 3,
0, 0, 0,
0xffff, 0xffff, 0xffff,
- 0
+ NULL
};
#else
static rfbCursor myCursor =
@@ -407,17 +406,17 @@ static rfbCursor myCursor =
width: 8, height: 7, xhot: 3, yhot: 3,
foreRed: 0, foreGreen: 0, foreBlue: 0,
backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff,
- richSource: 0
+ richSource: NULL
};
#endif
-rfbCursorPtr rfbDefaultGetCursorPtr(rfbClientPtr cl)
+static rfbCursorPtr rfbDefaultGetCursorPtr(rfbClientPtr cl)
{
return(cl->screen->cursor);
}
/* response is cl->authChallenge vncEncrypted with passwd */
-rfbBool rfbDefaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
+static rfbBool rfbDefaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
{
int i;
char *passwd=rfbDecryptPasswdFromFile(cl->screen->authPasswdData);
@@ -473,12 +472,12 @@ void rfbDoNothingWithClient(rfbClientPtr cl)
{
}
-enum rfbNewClientAction rfbDefaultNewClientHook(rfbClientPtr cl)
+static enum rfbNewClientAction rfbDefaultNewClientHook(rfbClientPtr cl)
{
return RFB_CLIENT_ACCEPT;
}
-rfbBool rfbDefaultProcessCustomClientMessage(rfbClientPtr cl,uint8_t type)
+static rfbBool rfbDefaultProcessCustomClientMessage(rfbClientPtr cl,uint8_t type)
{
return FALSE;
}
@@ -541,8 +540,8 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);
screen->autoPort=FALSE;
- screen->clientHead=0;
- screen->pointerClient=0;
+ screen->clientHead=NULL;
+ screen->pointerClient=NULL;
screen->port=5900;
screen->socketState=RFB_SOCKET_INIT;
@@ -552,7 +551,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
screen->udpSock=-1;
screen->udpSockConnected=FALSE;
screen->udpPort=0;
- screen->udpClient=0;
+ screen->udpClient=NULL;
screen->maxFd=0;
screen->listenSock=-1;
@@ -568,7 +567,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
screen->alwaysShared = FALSE;
screen->neverShared = FALSE;
screen->dontDisconnect = FALSE;
- screen->authPasswdData = 0;
+ screen->authPasswdData = NULL;
screen->authPasswdFirstViewOnly = 1;
screen->width = width;
@@ -586,7 +585,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
if(!rfbProcessArguments(screen,argc,argv)) {
free(screen);
- return 0;
+ return NULL;
}
#ifdef WIN32
@@ -626,7 +625,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
screen->getCursorPtr = rfbDefaultGetCursorPtr;
screen->setTranslateFunction = rfbSetTranslateFunction;
screen->newClientHook = rfbDefaultNewClientHook;
- screen->displayHook = 0;
+ screen->displayHook = NULL;
screen->processCustomClientMessage = rfbDefaultProcessCustomClientMessage;
/* initialize client list and iterator mutex */
@@ -709,10 +708,6 @@ void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer,
rfbReleaseClientIterator(iterator);
}
-#ifdef LIBVNCSERVER_HAVE_LIBJPEG
-extern void TightCleanup();
-#endif
-
/* hang up on all clients and free all reserved memory */
void rfbScreenCleanup(rfbScreenInfoPtr screen)
@@ -732,10 +727,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr screen)
TINI_MUTEX(screen->cursorMutex);
if(screen->cursor && screen->cursor->cleanup)
rfbFreeCursor(screen->cursor);
- free(screen);
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
- rfbTightCleanup();
+ rfbTightCleanup(screen);
#endif
+ free(screen);
}
void rfbInitServer(rfbScreenInfoPtr screen)
@@ -781,9 +776,6 @@ void gettimeofday(struct timeval* tv,char* dummy)
}
#endif
-/* defined in rfbserver.c, but kind of "private" */
-rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i);
-
rfbBool
rfbProcessEvents(rfbScreenInfoPtr screen,long usec)
{
diff --git a/libvncserver/private.h b/libvncserver/private.h
new file mode 100644
index 0000000..594512e
--- /dev/null
+++ b/libvncserver/private.h
@@ -0,0 +1,23 @@
+#ifndef RFB_PRIVATE_H
+#define RFB_PRIVATE_H
+
+/* from cursor.c */
+
+void rfbShowCursor(rfbClientPtr cl);
+void rfbHideCursor(rfbClientPtr cl);
+void rfbRedrawAfterHideCursor(rfbClientPtr cl,sraRegionPtr updateRegion);
+
+/* from main.c */
+
+rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i);
+
+/* from tight.c */
+
+extern void rfbTightCleanup(rfbScreenInfoPtr screen);
+
+/* from zrle.c */
+
+extern void rfbFreeZrleData(rfbClientPtr cl);
+
+#endif
+
diff --git a/libvncserver/rfbregion.c b/libvncserver/rfbregion.c
index fdac51e..9da6b1a 100755
--- a/libvncserver/rfbregion.c
+++ b/libvncserver/rfbregion.c
@@ -30,7 +30,7 @@ typedef struct sraRegion {
sraSpanList *sraSpanListDup(const sraSpanList *src);
void sraSpanListDestroy(sraSpanList *list);
-sraSpan *
+static sraSpan *
sraSpanCreate(int start, int end, const sraSpanList *subspan) {
sraSpan *item = (sraSpan*)malloc(sizeof(sraSpan));
item->_next = item->_prev = NULL;
@@ -40,7 +40,7 @@ sraSpanCreate(int start, int end, const sraSpanList *subspan) {
return item;
}
-sraSpan *
+static sraSpan *
sraSpanDup(const sraSpan *src) {
sraSpan *span;
if (!src) return NULL;
@@ -48,7 +48,7 @@ sraSpanDup(const sraSpan *src) {
return span;
}
-void
+static void
sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) {
newspan->_next = after->_next;
newspan->_prev = after;
@@ -56,7 +56,7 @@ sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) {
after->_next = newspan;
}
-void
+static void
sraSpanInsertBefore(sraSpan *newspan, sraSpan *before) {
newspan->_next = before;
newspan->_prev = before->_prev;
@@ -64,19 +64,20 @@ sraSpanInsertBefore(sraSpan *newspan, sraSpan *before) {
before->_prev = newspan;
}
-void
+static void
sraSpanRemove(sraSpan *span) {
span->_prev->_next = span->_next;
span->_next->_prev = span->_prev;
}
-void
+static void
sraSpanDestroy(sraSpan *span) {
if (span->subspan) sraSpanListDestroy(span->subspan);
free(span);
}
-void
+#ifdef DEBUG
+static void
sraSpanCheck(const sraSpan *span, const char *text) {
/* Check the span is valid! */
if (span->start == span->end) {
@@ -84,12 +85,13 @@ sraSpanCheck(const sraSpan *span, const char *text) {
printf(":%d-%d\n", span->start, span->end);
}
}
+#endif
/* -=- SpanList routines */
-void sraSpanPrint(const sraSpan *s);
+static void sraSpanPrint(const sraSpan *s);
-void
+static void
sraSpanListPrint(const sraSpanList *l) {
sraSpan *curr;
if (!l) {
@@ -112,8 +114,8 @@ sraSpanPrint(const sraSpan *s) {
sraSpanListPrint(s->subspan);
}
-sraSpanList *
-sraSpanListCreate() {
+static sraSpanList *
+sraSpanListCreate(void) {
sraSpanList *item = (sraSpanList*)malloc(sizeof(sraSpanList));
item->front._next = &(item->back);
item->front._prev = NULL;
@@ -152,7 +154,7 @@ sraSpanListDestroy(sraSpanList *list) {
free(list);
}
-void
+static void
sraSpanListMakeEmpty(sraSpanList *list) {
sraSpan *curr, *next;
while (list->front._next != &(list->back)) {
@@ -168,7 +170,7 @@ sraSpanListMakeEmpty(sraSpanList *list) {
list->back._next = NULL;
}
-rfbBool
+static rfbBool
sraSpanListEqual(const sraSpanList *s1, const sraSpanList *s2) {
sraSpan *sp1, *sp2;
@@ -201,12 +203,12 @@ sraSpanListEqual(const sraSpanList *s1, const sraSpanList *s2) {
}
}
-rfbBool
+static rfbBool
sraSpanListEmpty(const sraSpanList *list) {
return (list->front._next == &(list->back));
}
-unsigned long
+static unsigned long
sraSpanListCount(const sraSpanList *list) {
sraSpan *curr = list->front._next;
unsigned long count = 0;
@@ -221,7 +223,7 @@ sraSpanListCount(const sraSpanList *list) {
return count;
}
-void
+static void
sraSpanMergePrevious(sraSpan *dest) {
sraSpan *prev = dest->_prev;
@@ -242,7 +244,7 @@ sraSpanMergePrevious(sraSpan *dest) {
}
}
-void
+static void
sraSpanMergeNext(sraSpan *dest) {
sraSpan *next = dest->_next;
while ((next->_next) &&
@@ -262,7 +264,7 @@ sraSpanMergeNext(sraSpan *dest) {
}
}
-void
+static void
sraSpanListOr(sraSpanList *dest, const sraSpanList *src) {
sraSpan *d_curr, *s_curr;
int s_start, s_end;
@@ -352,7 +354,7 @@ sraSpanListOr(sraSpanList *dest, const sraSpanList *src) {
}
}
-rfbBool
+static rfbBool
sraSpanListAnd(sraSpanList *dest, const sraSpanList *src) {
sraSpan *d_curr, *s_curr, *d_next;
@@ -432,7 +434,7 @@ sraSpanListAnd(sraSpanList *dest, const sraSpanList *src) {
return !sraSpanListEmpty(dest);
}
-rfbBool
+static rfbBool
sraSpanListSubtract(sraSpanList *dest, const sraSpanList *src) {
sraSpan *d_curr, *s_curr;
@@ -506,7 +508,7 @@ sraSpanListSubtract(sraSpanList *dest, const sraSpanList *src) {
/* -=- Region routines */
sraRegion *
-sraRgnCreate() {
+sraRgnCreate(void) {
return (sraRegion*)sraSpanListCreate();
}
@@ -686,7 +688,7 @@ sraRectangleIterator *sraRgnGetIterator(sraRegion *s)
sraRectangleIterator *i =
(sraRectangleIterator*)malloc(sizeof(sraRectangleIterator));
if(!i)
- return(0);
+ return NULL;
/* we have to recurse eventually. So, the first sPtr is the pointer to
the sraSpan in the first level. the second sPtr is the pointer to
@@ -695,7 +697,7 @@ sraRectangleIterator *sraRgnGetIterator(sraRegion *s)
i->sPtrs = (sraSpan**)malloc(sizeof(sraSpan*)*DEFSIZE);
if(!i->sPtrs) {
free(i);
- return(0);
+ return NULL;
}
i->ptrSize = DEFSIZE;
i->sPtrs[0] = &(s->front);
@@ -703,7 +705,7 @@ sraRectangleIterator *sraRgnGetIterator(sraRegion *s)
i->ptrPos = 0;
i->reverseX = 0;
i->reverseY = 0;
- return(i);
+ return i;
}
sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY)
@@ -718,13 +720,13 @@ sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfb
return(i);
}
-rfbBool sraReverse(sraRectangleIterator *i)
+static rfbBool sraReverse(sraRectangleIterator *i)
{
return( ((i->ptrPos&2) && i->reverseX) ||
(!(i->ptrPos&2) && i->reverseY));
}
-sraSpan* sraNextSpan(sraRectangleIterator *i)
+static sraSpan* sraNextSpan(sraRectangleIterator *i)
{
if(sraReverse(i))
return(i->sPtrs[i->ptrPos]->_prev);
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index f3aaa30..fceb02c 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -24,9 +24,11 @@
* USA.
*/
+#define _BSD_SOURCE
#include <string.h>
#include <rfb/rfb.h>
#include <rfb/rfbregion.h>
+#include "private.h"
#ifdef LIBVNCSERVER_HAVE_FCNTL_H
#include <fcntl.h>
@@ -60,11 +62,6 @@
#define DEBUGPROTO(x)
#endif
-/* from cursor.c */
-
-void rfbShowCursor(rfbClientPtr cl);
-void rfbHideCursor(rfbClientPtr cl);
-void rfbRedrawAfterHideCursor(rfbClientPtr cl,sraRegionPtr updateRegion);
static void rfbProcessClientProtocolVersion(rfbClientPtr cl);
static void rfbProcessClientNormalMessage(rfbClientPtr cl);
@@ -92,7 +89,7 @@ void rfbDecrClientRef(rfbClientPtr cl) {}
#endif
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
-MUTEX(rfbClientListMutex);
+static MUTEX(rfbClientListMutex);
#endif
struct rfbClientIterator {
@@ -118,7 +115,7 @@ rfbGetClientIterator(rfbScreenInfoPtr rfbScreen)
{
rfbClientIteratorPtr i =
(rfbClientIteratorPtr)malloc(sizeof(struct rfbClientIterator));
- i->next = 0;
+ i->next = NULL;
i->screen = rfbScreen;
return i;
}
@@ -175,9 +172,8 @@ rfbReleaseClientIterator(rfbClientIteratorPtr iterator)
*/
void
-rfbNewClientConnection(rfbScreen,sock)
- rfbScreenInfoPtr rfbScreen;
- int sock;
+rfbNewClientConnection(rfbScreenInfoPtr rfbScreen,
+ int sock)
{
rfbClientPtr cl;
@@ -195,10 +191,9 @@ rfbNewClientConnection(rfbScreen,sock)
*/
rfbClientPtr
-rfbReverseConnection(rfbScreen,host, port)
- rfbScreenInfoPtr rfbScreen;
- char *host;
- int port;
+rfbReverseConnection(rfbScreenInfoPtr rfbScreen,
+ char *host,
+ int port)
{
int sock;
rfbClientPtr cl;
@@ -221,17 +216,16 @@ rfbReverseConnection(rfbScreen,host, port)
* means.
*/
-rfbClientPtr
-rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
- rfbScreenInfoPtr rfbScreen;
- int sock;
- rfbBool isUDP;
+static rfbClientPtr
+rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
+ int sock,
+ rfbBool isUDP)
{
rfbProtocolVersionMsg pv;
rfbClientIteratorPtr iterator;
rfbClientPtr cl,cl_;
struct sockaddr_in addr;
- size_t addrlen = sizeof(struct sockaddr_in);
+ socklen_t addrlen = sizeof(struct sockaddr_in);
cl = (rfbClientPtr)calloc(sizeof(rfbClientRec),1);
@@ -287,7 +281,7 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
cl->correMaxWidth = 48;
cl->correMaxHeight = 48;
#ifdef LIBVNCSERVER_HAVE_LIBZ
- cl->zrleData = 0;
+ cl->zrleData = NULL;
#endif
cl->copyRegion = sraRgnCreate();
@@ -378,16 +372,14 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
}
rfbClientPtr
-rfbNewClient(rfbScreen,sock)
- rfbScreenInfoPtr rfbScreen;
- int sock;
+rfbNewClient(rfbScreenInfoPtr rfbScreen,
+ int sock)
{
return(rfbNewTCPOrUDPClient(rfbScreen,sock,FALSE));
}
rfbClientPtr
-rfbNewUDPClient(rfbScreen)
- rfbScreenInfoPtr rfbScreen;
+rfbNewUDPClient(rfbScreenInfoPtr rfbScreen)
{
return((rfbScreen->udpClient=
rfbNewTCPOrUDPClient(rfbScreen,rfbScreen->udpSock,TRUE)));
@@ -399,8 +391,7 @@ rfbNewUDPClient(rfbScreen)
*/
void
-rfbClientConnectionGone(cl)
- rfbClientPtr cl;
+rfbClientConnectionGone(rfbClientPtr cl)
{
int i;
@@ -417,7 +408,7 @@ rfbClientConnectionGone(cl)
close(cl->sock);
#ifdef LIBVNCSERVER_HAVE_LIBZ
- FreeZrleData(cl);
+ rfbFreeZrleData(cl);
#endif
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
@@ -456,7 +447,7 @@ rfbClientConnectionGone(cl)
#endif
if (cl->screen->pointerClient == cl)
- cl->screen->pointerClient = 0;
+ cl->screen->pointerClient = NULL;
sraRgnDestroy(cl->modifiedRegion);
sraRgnDestroy(cl->requestedRegion);
@@ -485,8 +476,7 @@ rfbClientConnectionGone(cl)
*/
void
-rfbProcessClientMessage(cl)
- rfbClientPtr cl;
+rfbProcessClientMessage(rfbClientPtr cl)
{
switch (cl->state) {
case RFB_PROTOCOL_VERSION:
@@ -511,8 +501,7 @@ rfbProcessClientMessage(cl)
*/
static void
-rfbProcessClientProtocolVersion(cl)
- rfbClientPtr cl;
+rfbProcessClientProtocolVersion(rfbClientPtr cl)
{
rfbProtocolVersionMsg pv;
int n, major_, minor_;
@@ -566,9 +555,8 @@ rfbProcessClientProtocolVersion(cl)
*/
void
-rfbClientConnFailed(cl, reason)
- rfbClientPtr cl;
- char *reason;
+rfbClientConnFailed(rfbClientPtr cl,
+ char *reason)
{
char *buf;
int len = strlen(reason);
@@ -591,8 +579,7 @@ rfbClientConnFailed(cl, reason)
*/
static void
-rfbProcessClientInitMessage(cl)
- rfbClientPtr cl;
+rfbProcessClientInitMessage(rfbClientPtr cl)
{
rfbClientInitMsg ci;
char buf[256];
@@ -686,8 +673,7 @@ static rfbBool rectSwapIfLEAndClip(uint16_t* x,uint16_t* y,uint16_t* w,uint16_t*
*/
static void
-rfbProcessClientNormalMessage(cl)
- rfbClientPtr cl;
+rfbProcessClientNormalMessage(rfbClientPtr cl)
{
int n=0;
rfbClientToServerMsg msg;
@@ -824,7 +810,7 @@ rfbProcessClientNormalMessage(cl)
cl->host);
/* if cursor was drawn, hide the cursor */
if(!cl->enableCursorShapeUpdates)
- rfbRedrawAfterHideCursor(cl,0);
+ rfbRedrawAfterHideCursor(cl,NULL);
cl->enableCursorShapeUpdates = TRUE;
cl->cursorWasChanged = TRUE;
@@ -835,7 +821,7 @@ rfbProcessClientNormalMessage(cl)
cl->host);
/* if cursor was drawn, hide the cursor */
if(!cl->enableCursorShapeUpdates)
- rfbRedrawAfterHideCursor(cl,0);
+ rfbRedrawAfterHideCursor(cl,NULL);
cl->enableCursorShapeUpdates = TRUE;
cl->useRichCursorEncoding = TRUE;
@@ -1001,7 +987,7 @@ rfbProcessClientNormalMessage(cl)
return;
if (msg.pe.buttonMask == 0)
- cl->screen->pointerClient = 0;
+ cl->screen->pointerClient = NULL;
else
cl->screen->pointerClient = cl;
@@ -1065,11 +1051,10 @@ rfbProcessClientNormalMessage(cl)
*/
rfbBool
-rfbSendFramebufferUpdate(cl, givenUpdateRegion)
- rfbClientPtr cl;
- sraRegionPtr givenUpdateRegion;
+rfbSendFramebufferUpdate(rfbClientPtr cl,
+ sraRegionPtr givenUpdateRegion)
{
- sraRectangleIterator* i=0;
+ sraRectangleIterator* i=NULL;
sraRect rect;
int nUpdateRegionRects;
rfbFramebufferUpdateMsg *fu = (rfbFramebufferUpdateMsg *)cl->updateBuf;
@@ -1392,10 +1377,10 @@ updateFailed:
*/
rfbBool
-rfbSendCopyRegion(cl, reg, dx, dy)
- rfbClientPtr cl;
- sraRegionPtr reg;
- int dx, dy;
+rfbSendCopyRegion(rfbClientPtr cl,
+ sraRegionPtr reg,
+ int dx,
+ int dy)
{
int x, y, w, h;
rfbFramebufferUpdateRectHeader rect;
@@ -1443,9 +1428,11 @@ rfbSendCopyRegion(cl, reg, dx, dy)
*/
rfbBool
-rfbSendRectEncodingRaw(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingRaw(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
int nlines;
@@ -1516,8 +1503,7 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
*/
rfbBool
-rfbSendLastRectMarker(cl)
- rfbClientPtr cl;
+rfbSendLastRectMarker(rfbClientPtr cl)
{
rfbFramebufferUpdateRectHeader rect;
@@ -1548,9 +1534,9 @@ rfbSendLastRectMarker(cl)
*/
rfbBool
-rfbSendNewFBSize(cl, w, h)
- rfbClientPtr cl;
- int w, h;
+rfbSendNewFBSize(rfbClientPtr cl,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
@@ -1582,8 +1568,7 @@ rfbSendNewFBSize(cl, w, h)
*/
rfbBool
-rfbSendUpdateBuf(cl)
- rfbClientPtr cl;
+rfbSendUpdateBuf(rfbClientPtr cl)
{
if(cl->sock<0)
return FALSE;
@@ -1604,10 +1589,9 @@ rfbSendUpdateBuf(cl)
*/
rfbBool
-rfbSendSetColourMapEntries(cl, firstColour, nColours)
- rfbClientPtr cl;
- int firstColour;
- int nColours;
+rfbSendSetColourMapEntries(rfbClientPtr cl,
+ int firstColour,
+ int nColours)
{
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
@@ -1707,12 +1691,11 @@ rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len)
* packets (such as 100s of pen readings per second!).
*/
-unsigned char ptrAcceleration = 50;
+static unsigned char ptrAcceleration = 50;
void
-rfbNewUDPConnection(rfbScreen,sock)
- rfbScreenInfoPtr rfbScreen;
- int sock;
+rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,
+ int sock)
{
if (write(sock, &ptrAcceleration, 1) < 0) {
rfbLogPerror("rfbNewUDPConnection: write");
diff --git a/libvncserver/rre.c b/libvncserver/rre.c
index 768b1cc..ca11bb3 100755
--- a/libvncserver/rre.c
+++ b/libvncserver/rre.c
@@ -53,9 +53,11 @@ static uint32_t getBgColour(char *data, int size, int bpp);
*/
rfbBool
-rfbSendRectEncodingRRE(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingRRE(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
rfbRREHeader hdr;
@@ -175,26 +177,22 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \
static int \
-subrectEncode##bpp(data,w,h) \
- uint##bpp##_t *data; \
- int w; \
- int h; \
-{ \
- uint##bpp##_t cl; \
+subrectEncode##bpp(uint##bpp##_t *data, int w, int h) { \
+ uint##bpp##_t cl; \
rfbRectangle subrect; \
int x,y; \
int i,j; \
int hx=0,hy,vx=0,vy; \
int hyflag; \
- uint##bpp##_t *seg; \
- uint##bpp##_t *line; \
+ uint##bpp##_t *seg; \
+ uint##bpp##_t *line; \
int hw,hh,vw,vh; \
int thex,they,thew,theh; \
int numsubs = 0; \
int newLen; \
- uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
+ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\
- *((uint##bpp##_t*)rreAfterBuf) = bg; \
+ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\
rreAfterBufLen = (bpp/8); \
\
@@ -246,7 +244,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \
\
numsubs += 1; \
- *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
+ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \
rreAfterBufLen += sz_rfbRectangle; \
@@ -275,10 +273,7 @@ DEFINE_SUBRECT_ENCODE(32)
* getBgColour() gets the most prevalent colour in a byte array.
*/
static uint32_t
-getBgColour(data,size,bpp)
- char *data;
- int size;
- int bpp;
+getBgColour(char *data, int size, int bpp)
{
#define NUMCLRS 256
diff --git a/libvncserver/selbox.c b/libvncserver/selbox.c
index 3633d06..bbc6d52 100755
--- a/libvncserver/selbox.c
+++ b/libvncserver/selbox.c
@@ -197,7 +197,7 @@ static void selPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl)
static rfbCursorPtr selGetCursorPtr(rfbClientPtr cl)
{
- return(0);
+ return NULL;
}
int rfbSelectBox(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
@@ -263,7 +263,7 @@ int rfbSelectBox(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
rfbScreen->kbdAddEvent = selKbdAddEvent;
rfbScreen->ptrAddEvent = selPtrAddEvent;
rfbScreen->getCursorPtr = selGetCursorPtr;
- rfbScreen->displayHook = 0;
+ rfbScreen->displayHook = NULL;
/* backup screen */
for(j=0;j<y2-y1;j++)
diff --git a/libvncserver/sockets.c b/libvncserver/sockets.c
index 9025df8..24a787d 100755
--- a/libvncserver/sockets.c
+++ b/libvncserver/sockets.c
@@ -216,7 +216,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
fd_set fds;
struct timeval tv;
struct sockaddr_in addr;
- size_t addrlen = sizeof(addr);
+ socklen_t addrlen = sizeof(addr);
char buf[6];
const int one = 1;
int sock;
@@ -342,8 +342,7 @@ rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen)
void
-rfbCloseClient(cl)
- rfbClientPtr cl;
+rfbCloseClient(rfbClientPtr cl)
{
LOCK(cl->updateMutex);
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
@@ -371,10 +370,9 @@ rfbCloseClient(cl)
*/
int
-rfbConnect(rfbScreen, host, port)
- rfbScreenInfoPtr rfbScreen;
- char *host;
- int port;
+rfbConnect(rfbScreenInfoPtr rfbScreen,
+ char *host,
+ int port)
{
int sock;
int one = 1;
@@ -476,10 +474,9 @@ int rfbReadExact(rfbClientPtr cl,char* buf,int len)
*/
int
-rfbWriteExact(cl, buf, len)
- rfbClientPtr cl;
- const char *buf;
- int len;
+rfbWriteExact(rfbClientPtr cl,
+ const char *buf,
+ int len)
{
int sock = cl->sock;
int n;
@@ -573,9 +570,8 @@ rfbStringToAddr(char *str, in_addr_t *addr) {
}
int
-rfbListenOnTCPPort(port, iface)
- int port;
- in_addr_t iface;
+rfbListenOnTCPPort(int port,
+ in_addr_t iface)
{
struct sockaddr_in addr;
int sock;
@@ -607,9 +603,8 @@ rfbListenOnTCPPort(port, iface)
}
int
-rfbConnectToTcpAddr(host, port)
- char *host;
- int port;
+rfbConnectToTcpAddr(char *host,
+ int port)
{
struct hostent *hp;
int sock;
@@ -641,9 +636,8 @@ rfbConnectToTcpAddr(host, port)
}
int
-rfbListenOnUDPPort(port, iface)
- int port;
- in_addr_t iface;
+rfbListenOnUDPPort(int port,
+ in_addr_t iface)
{
struct sockaddr_in addr;
int sock;
diff --git a/libvncserver/tight.c b/libvncserver/tight.c
index 296eca0..4d76e8f 100644
--- a/libvncserver/tight.c
+++ b/libvncserver/tight.c
@@ -26,6 +26,7 @@
/*#include <stdio.h>*/
#include <rfb/rfb.h>
+#include "private.h"
#ifdef WIN32
#define XMD_H
@@ -98,6 +99,7 @@ typedef struct PALETTE_s {
COLOR_LIST list[256];
} PALETTE;
+/* TODO: move into rfbScreen struct */
static int paletteNumColors, paletteMaxColors;
static uint32_t monoBackground, monoForeground;
static PALETTE palette;
@@ -112,7 +114,7 @@ static char *tightAfterBuf = NULL;
static int *prevRowBuf = NULL;
-void rfbTightCleanup()
+void rfbTightCleanup(rfbScreenInfoPtr screen)
{
if(tightBeforeBufSize) {
free(tightBeforeBuf);
@@ -197,9 +199,11 @@ static void JpegSetDstManager(j_compress_ptr cinfo);
*/
int
-rfbNumCodedRectsTight(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbNumCodedRectsTight(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
int maxRectSize, maxRectWidth;
int subrectMaxWidth, subrectMaxHeight;
@@ -223,9 +227,11 @@ rfbNumCodedRectsTight(cl, x, y, w, h)
}
rfbBool
-rfbSendRectEncodingTight(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingTight(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
int nMaxRows;
uint32_t colorValue;
@@ -363,11 +369,14 @@ rfbSendRectEncodingTight(cl, x, y, w, h)
}
static void
-FindBestSolidArea(cl, x, y, w, h, colorValue, w_ptr, h_ptr)
- rfbClientPtr cl;
- int x, y, w, h;
- uint32_t colorValue;
- int *w_ptr, *h_ptr;
+FindBestSolidArea(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h,
+ uint32_t colorValue,
+ int *w_ptr,
+ int *h_ptr)
{
int dx, dy, dw, dh;
int w_prev;
@@ -405,11 +414,16 @@ FindBestSolidArea(cl, x, y, w, h, colorValue, w_ptr, h_ptr)
}
static void
-ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr)
- rfbClientPtr cl;
- int x, y, w, h;
- uint32_t colorValue;
- int *x_ptr, *y_ptr, *w_ptr, *h_ptr;
+ExtendSolidArea(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h,
+ uint32_t colorValue,
+ int *x_ptr,
+ int *y_ptr,
+ int *w_ptr,
+ int *h_ptr)
{
int cx, cy;
@@ -463,18 +477,19 @@ static rfbBool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint3
#define DEFINE_CHECK_SOLID_FUNCTION(bpp) \
\
-static rfbBool \
-CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, rfbBool needSameColor) \
+static rfbBool \
+CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, \
+ uint32_t* colorPtr, rfbBool needSameColor) \
{ \
- uint##bpp##_t *fbptr; \
- uint##bpp##_t colorValue; \
+ uint##bpp##_t *fbptr; \
+ uint##bpp##_t colorValue; \
int dx, dy; \
\
- fbptr = (uint##bpp##_t *) \
+ fbptr = (uint##bpp##_t *) \
&cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + x * (bpp/8)]; \
\
colorValue = *fbptr; \
- if (needSameColor && (uint32_t)colorValue != *colorPtr) \
+ if (needSameColor && (uint32_t)colorValue != *colorPtr) \
return FALSE; \
\
for (dy = 0; dy < h; dy++) { \
@@ -485,7 +500,7 @@ CheckSolidTile##bpp(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* color
fbptr = (uint##bpp##_t *)((uint8_t *)fbptr + cl->screen->paddedWidthInBytes); \
} \
\
- *colorPtr = (uint32_t)colorValue; \
+ *colorPtr = (uint32_t)colorValue; \
return TRUE; \
}
@@ -494,9 +509,7 @@ DEFINE_CHECK_SOLID_FUNCTION(16)
DEFINE_CHECK_SOLID_FUNCTION(32)
static rfbBool
-SendRectSimple(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+SendRectSimple(rfbClientPtr cl, int x, int y, int w, int h)
{
int maxBeforeSize, maxAfterSize;
int maxRectSize, maxRectWidth;
@@ -549,9 +562,11 @@ SendRectSimple(cl, x, y, w, h)
}
static rfbBool
-SendSubrect(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+SendSubrect(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
char *fbptr;
rfbBool success = FALSE;
@@ -625,9 +640,11 @@ SendSubrect(cl, x, y, w, h)
}
static rfbBool
-SendTightHeader(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+SendTightHeader(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
@@ -657,8 +674,7 @@ SendTightHeader(cl, x, y, w, h)
*/
static rfbBool
-SendSolidRect(cl)
- rfbClientPtr cl;
+SendSolidRect(rfbClientPtr cl)
{
int len;
@@ -683,9 +699,9 @@ SendSolidRect(cl)
}
static rfbBool
-SendMonoRect(cl, w, h)
- rfbClientPtr cl;
- int w, h;
+SendMonoRect(rfbClientPtr cl,
+ int w,
+ int h)
{
int streamId = 1;
int paletteLen, dataLen;
@@ -748,9 +764,9 @@ SendMonoRect(cl, w, h)
}
static rfbBool
-SendIndexedRect(cl, w, h)
- rfbClientPtr cl;
- int w, h;
+SendIndexedRect(rfbClientPtr cl,
+ int w,
+ int h)
{
int streamId = 2;
int i, entryLen;
@@ -811,9 +827,9 @@ SendIndexedRect(cl, w, h)
}
static rfbBool
-SendFullColorRect(cl, w, h)
- rfbClientPtr cl;
- int w, h;
+SendFullColorRect(rfbClientPtr cl,
+ int w,
+ int h)
{
int streamId = 0;
int len;
@@ -838,9 +854,9 @@ SendFullColorRect(cl, w, h)
}
static rfbBool
-SendGradientRect(cl, w, h)
- rfbClientPtr cl;
- int w, h;
+SendGradientRect(rfbClientPtr cl,
+ int w,
+ int h)
{
int streamId = 3;
int len;
@@ -877,9 +893,11 @@ SendGradientRect(cl, w, h)
}
static rfbBool
-CompressData(cl, streamId, dataLen, zlibLevel, zlibStrategy)
- rfbClientPtr cl;
- int streamId, dataLen, zlibLevel, zlibStrategy;
+CompressData(rfbClientPtr cl,
+ int streamId,
+ int dataLen,
+ int zlibLevel,
+ int zlibStrategy)
{
z_streamp pz;
int err;
@@ -931,9 +949,8 @@ CompressData(cl, streamId, dataLen, zlibLevel, zlibStrategy)
return SendCompressedData(cl, tightAfterBufSize - pz->avail_out);
}
-static rfbBool SendCompressedData(cl, compressedLen)
- rfbClientPtr cl;
- int compressedLen;
+static rfbBool SendCompressedData(rfbClientPtr cl,
+ int compressedLen)
{
int i, portionLen;
@@ -972,8 +989,7 @@ static rfbBool SendCompressedData(cl, compressedLen)
*/
static void
-FillPalette8(count)
- int count;
+FillPalette8(int count)
{
uint8_t *data = (uint8_t *)tightBeforeBuf;
uint8_t c0, c1;
@@ -1017,11 +1033,9 @@ FillPalette8(count)
#define DEFINE_FILL_PALETTE_FUNCTION(bpp) \
\
static void \
-FillPalette##bpp(count) \
- int count; \
-{ \
- uint##bpp##_t *data = (uint##bpp##_t *)tightBeforeBuf; \
- uint##bpp##_t c0, c1, ci; \
+FillPalette##bpp(int count) { \
+ uint##bpp##_t *data = (uint##bpp##_t *)tightBeforeBuf; \
+ uint##bpp##_t c0, c1, ci; \
int i, n0, n1, ni; \
\
c0 = data[0]; \
@@ -1050,32 +1064,32 @@ FillPalette##bpp(count) \
} \
if (i >= count) { \
if (n0 > n1) { \
- monoBackground = (uint32_t)c0; \
- monoForeground = (uint32_t)c1; \
+ monoBackground = (uint32_t)c0; \
+ monoForeground = (uint32_t)c1; \
} else { \
- monoBackground = (uint32_t)c1; \
- monoForeground = (uint32_t)c0; \
+ monoBackground = (uint32_t)c1; \
+ monoForeground = (uint32_t)c0; \
} \
paletteNumColors = 2; /* Two colors */ \
return; \
} \
\
PaletteReset(); \
- PaletteInsert (c0, (uint32_t)n0, bpp); \
- PaletteInsert (c1, (uint32_t)n1, bpp); \
+ PaletteInsert (c0, (uint32_t)n0, bpp); \
+ PaletteInsert (c1, (uint32_t)n1, bpp); \
\
ni = 1; \
for (i++; i < count; i++) { \
if (data[i] == ci) { \
ni++; \
} else { \
- if (!PaletteInsert (ci, (uint32_t)ni, bpp)) \
+ if (!PaletteInsert (ci, (uint32_t)ni, bpp)) \
return; \
ci = data[i]; \
ni = 1; \
} \
} \
- PaletteInsert (ci, (uint32_t)ni, bpp); \
+ PaletteInsert (ci, (uint32_t)ni, bpp); \
}
DEFINE_FILL_PALETTE_FUNCTION(16)
@@ -1097,10 +1111,9 @@ PaletteReset(void)
}
static int
-PaletteInsert(rgb, numPixels, bpp)
- uint32_t rgb;
- int numPixels;
- int bpp;
+PaletteInsert(uint32_t rgb,
+ int numPixels,
+ int bpp)
{
COLOR_LIST *pnode;
COLOR_LIST *prev_pnode = NULL;
@@ -1169,11 +1182,10 @@ PaletteInsert(rgb, numPixels, bpp)
* Color components assumed to be byte-aligned.
*/
-static void Pack24(cl, buf, fmt, count)
- rfbClientPtr cl;
- char *buf;
- rfbPixelFormat *fmt;
- int count;
+static void Pack24(rfbClientPtr cl,
+ char *buf,
+ rfbPixelFormat *fmt,
+ int count)
{
uint32_t *buf32;
uint32_t pix;
@@ -1207,16 +1219,13 @@ static void Pack24(cl, buf, fmt, count)
#define DEFINE_IDX_ENCODE_FUNCTION(bpp) \
\
static void \
-EncodeIndexedRect##bpp(buf, count) \
- uint8_t *buf; \
- int count; \
-{ \
+EncodeIndexedRect##bpp(uint8_t *buf, int count) { \
COLOR_LIST *pnode; \
- uint##bpp##_t *src; \
- uint##bpp##_t rgb; \
+ uint##bpp##_t *src; \
+ uint##bpp##_t rgb; \
int rep = 0; \
\
- src = (uint##bpp##_t *) buf; \
+ src = (uint##bpp##_t *) buf; \
\
while (count--) { \
rgb = *src++; \
@@ -1225,10 +1234,10 @@ EncodeIndexedRect##bpp(buf, count) \
} \
pnode = palette.hash[HASH_FUNC##bpp(rgb)]; \
while (pnode != NULL) { \
- if ((uint##bpp##_t)pnode->rgb == rgb) { \
- *buf++ = (uint8_t)pnode->idx; \
+ if ((uint##bpp##_t)pnode->rgb == rgb) { \
+ *buf++ = (uint8_t)pnode->idx; \
while (rep) { \
- *buf++ = (uint8_t)pnode->idx; \
+ *buf++ = (uint8_t)pnode->idx; \
rep--; \
} \
break; \
@@ -1244,18 +1253,15 @@ DEFINE_IDX_ENCODE_FUNCTION(32)
#define DEFINE_MONO_ENCODE_FUNCTION(bpp) \
\
static void \
-EncodeMonoRect##bpp(buf, w, h) \
- uint8_t *buf; \
- int w, h; \
-{ \
- uint##bpp##_t *ptr; \
- uint##bpp##_t bg; \
+EncodeMonoRect##bpp(uint8_t *buf, int w, int h) { \
+ uint##bpp##_t *ptr; \
+ uint##bpp##_t bg; \
unsigned int value, mask; \
int aligned_width; \
int x, y, bg_bits; \
\
- ptr = (uint##bpp##_t *) buf; \
- bg = (uint##bpp##_t) monoBackground; \
+ ptr = (uint##bpp##_t *) buf; \
+ bg = (uint##bpp##_t) monoBackground; \
aligned_width = w - w % 8; \
\
for (y = 0; y < h; y++) { \
@@ -1276,7 +1282,7 @@ EncodeMonoRect##bpp(buf, w, h) \
value |= mask; \
} \
} \
- *buf++ = (uint8_t)value; \
+ *buf++ = (uint8_t)value; \
} \
\
mask = 0x80; \
@@ -1290,7 +1296,7 @@ EncodeMonoRect##bpp(buf, w, h) \
} \
mask >>= 1; \
} \
- *buf++ = (uint8_t)value; \
+ *buf++ = (uint8_t)value; \
} \
}
@@ -1306,11 +1312,7 @@ DEFINE_MONO_ENCODE_FUNCTION(32)
*/
static void
-FilterGradient24(cl, buf, fmt, w, h)
- rfbClientPtr cl;
- char *buf;
- rfbPixelFormat *fmt;
- int w, h;
+FilterGradient24(rfbClientPtr cl, char *buf, rfbPixelFormat *fmt, int w, int h)
{
uint32_t *buf32;
uint32_t pix32;
@@ -1368,14 +1370,10 @@ FilterGradient24(cl, buf, fmt, w, h)
#define DEFINE_GRADIENT_FILTER_FUNCTION(bpp) \
\
static void \
-FilterGradient##bpp(cl, buf, fmt, w, h) \
- rfbClientPtr cl; \
- uint##bpp##_t *buf; \
- rfbPixelFormat *fmt; \
- int w, h; \
-{ \
- uint##bpp##_t pix, diff; \
- rfbBool endianMismatch; \
+FilterGradient##bpp(rfbClientPtr cl, uint##bpp##_t *buf, \
+ rfbPixelFormat *fmt, int w, int h) { \
+ uint##bpp##_t pix, diff; \
+ rfbBool endianMismatch; \
int *prevRowPtr; \
int maxColor[3], shiftBits[3]; \
int pixHere[3], pixUpper[3], pixLeft[3], pixUpperLeft[3]; \
@@ -1445,10 +1443,7 @@ DEFINE_GRADIENT_FILTER_FUNCTION(32)
#define DETECT_MIN_HEIGHT 8
static int
-DetectSmoothImage (cl, fmt, w, h)
- rfbClientPtr cl;
- rfbPixelFormat *fmt;
- int w, h;
+DetectSmoothImage (rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h)
{
long avgError;
@@ -1488,10 +1483,10 @@ DetectSmoothImage (cl, fmt, w, h)
}
static unsigned long
-DetectSmoothImage24 (cl, fmt, w, h)
- rfbClientPtr cl;
- rfbPixelFormat *fmt;
- int w, h;
+DetectSmoothImage24 (rfbClientPtr cl,
+ rfbPixelFormat *fmt,
+ int w,
+ int h)
{
int off;
int x, y, d, dx, c;
@@ -1550,13 +1545,9 @@ DetectSmoothImage24 (cl, fmt, w, h)
#define DEFINE_DETECT_FUNCTION(bpp) \
\
static unsigned long \
-DetectSmoothImage##bpp (cl, fmt, w, h) \
- rfbClientPtr cl; \
- rfbPixelFormat *fmt; \
- int w, h; \
-{ \
- rfbBool endianMismatch; \
- uint##bpp##_t pix; \
+DetectSmoothImage##bpp (rfbClientPtr cl, rfbPixelFormat *fmt, int w, int h) {\
+ rfbBool endianMismatch; \
+ uint##bpp##_t pix; \
int maxColor[3], shiftBits[3]; \
int x, y, d, dx, c; \
int diffStat[256]; \
@@ -1564,7 +1555,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
int sample, sum, left[3]; \
unsigned long avgError; \
\
- endianMismatch = (!cl->screen->serverFormat.bigEndian != !fmt->bigEndian); \
+ endianMismatch = (!cl->screen->serverFormat.bigEndian != !fmt->bigEndian); \
\
maxColor[0] = fmt->redMax; \
maxColor[1] = fmt->greenMax; \
@@ -1578,7 +1569,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
y = 0, x = 0; \
while (y < h && x < w) { \
for (d = 0; d < h - y && d < w - x - DETECT_SUBROW_WIDTH; d++) { \
- pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d]; \
+ pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d]; \
if (endianMismatch) { \
pix = Swap##bpp(pix); \
} \
@@ -1586,7 +1577,7 @@ DetectSmoothImage##bpp (cl, fmt, w, h)
left[c] = (int)(pix >> shiftBits[c] & maxColor[c]); \
} \
for (dx = 1; dx <= DETECT_SUBROW_WIDTH; dx++) { \
- pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d+dx]; \
+ pix = ((uint##bpp##_t *)tightBeforeBuf)[(y+d)*w+x+d+dx]; \
if (endianMismatch) { \
pix = Swap##bpp(pix); \
} \
@@ -1641,10 +1632,7 @@ static rfbBool jpegError;
static int jpegDstDataLen;
static rfbBool
-SendJpegRect(cl, x, y, w, h, quality)
- rfbClientPtr cl;
- int x, y, w, h;
- int quality;
+SendJpegRect(rfbClientPtr cl, int x, int y, int w, int h, int quality)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
@@ -1704,10 +1692,11 @@ SendJpegRect(cl, x, y, w, h, quality)
}
static void
-PrepareRowForJpeg(cl, dst, x, y, count)
- rfbClientPtr cl;
- uint8_t *dst;
- int x, y, count;
+PrepareRowForJpeg(rfbClientPtr cl,
+ uint8_t *dst,
+ int x,
+ int y,
+ int count)
{
if (cl->screen->serverFormat.bitsPerPixel == 32) {
if ( cl->screen->serverFormat.redMax == 0xFF &&
@@ -1724,10 +1713,11 @@ PrepareRowForJpeg(cl, dst, x, y, count)
}
static void
-PrepareRowForJpeg24(cl, dst, x, y, count)
- rfbClientPtr cl;
- uint8_t *dst;
- int x, y, count;
+PrepareRowForJpeg24(rfbClientPtr cl,
+ uint8_t *dst,
+ int x,
+ int y,
+ int count)
{
uint32_t *fbptr;
uint32_t pix;
@@ -1746,35 +1736,31 @@ PrepareRowForJpeg24(cl, dst, x, y, count)
#define DEFINE_JPEG_GET_ROW_FUNCTION(bpp) \
\
static void \
-PrepareRowForJpeg##bpp(cl, dst, x, y, count) \
- rfbClientPtr cl; \
- uint8_t *dst; \
- int x, y, count; \
-{ \
- uint##bpp##_t *fbptr; \
- uint##bpp##_t pix; \
+PrepareRowForJpeg##bpp(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { \
+ uint##bpp##_t *fbptr; \
+ uint##bpp##_t pix; \
int inRed, inGreen, inBlue; \
\
- fbptr = (uint##bpp##_t *) \
- &cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + \
+ fbptr = (uint##bpp##_t *) \
+ &cl->screen->frameBuffer[y * cl->screen->paddedWidthInBytes + \
x * (bpp / 8)]; \
\
while (count--) { \
pix = *fbptr++; \
\
inRed = (int) \
- (pix >> cl->screen->serverFormat.redShift & cl->screen->serverFormat.redMax); \
+ (pix >> cl->screen->serverFormat.redShift & cl->screen->serverFormat.redMax); \
inGreen = (int) \
(pix >> cl->screen->serverFormat.greenShift & cl->screen->serverFormat.greenMax); \
inBlue = (int) \
- (pix >> cl->screen->serverFormat.blueShift & cl->screen->serverFormat.blueMax); \
+ (pix >> cl->screen->serverFormat.blueShift & cl->screen->serverFormat.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); \
+ *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); \
} \
}
diff --git a/libvncserver/translate.c b/libvncserver/translate.c
index 56018d4..500d47d 100755
--- a/libvncserver/translate.c
+++ b/libvncserver/translate.c
@@ -134,7 +134,7 @@ typedef void (*rfbInitCMTableFnType)(char **table, rfbPixelFormat *in,
typedef void (*rfbInitTableFnType)(char **table, rfbPixelFormat *in,
rfbPixelFormat *out);
-rfbInitCMTableFnType rfbInitColourMapSingleTableFns[COUNT_OFFSETS] = {
+static rfbInitCMTableFnType rfbInitColourMapSingleTableFns[COUNT_OFFSETS] = {
rfbInitColourMapSingleTable8,
rfbInitColourMapSingleTable16,
#ifdef LIBVNCSERVER_ALLOW24BPP
@@ -143,7 +143,7 @@ rfbInitCMTableFnType rfbInitColourMapSingleTableFns[COUNT_OFFSETS] = {
rfbInitColourMapSingleTable32
};
-rfbInitTableFnType rfbInitTrueColourSingleTableFns[COUNT_OFFSETS] = {
+static rfbInitTableFnType rfbInitTrueColourSingleTableFns[COUNT_OFFSETS] = {
rfbInitTrueColourSingleTable8,
rfbInitTrueColourSingleTable16,
#ifdef LIBVNCSERVER_ALLOW24BPP
@@ -152,7 +152,7 @@ rfbInitTableFnType rfbInitTrueColourSingleTableFns[COUNT_OFFSETS] = {
rfbInitTrueColourSingleTable32
};
-rfbInitTableFnType rfbInitTrueColourRGBTablesFns[COUNT_OFFSETS] = {
+static rfbInitTableFnType rfbInitTrueColourRGBTablesFns[COUNT_OFFSETS] = {
rfbInitTrueColourRGBTables8,
rfbInitTrueColourRGBTables16,
#ifdef LIBVNCSERVER_ALLOW24BPP
@@ -161,7 +161,7 @@ rfbInitTableFnType rfbInitTrueColourRGBTablesFns[COUNT_OFFSETS] = {
rfbInitTrueColourRGBTables32
};
-rfbTranslateFnType rfbTranslateWithSingleTableFns[COUNT_OFFSETS][COUNT_OFFSETS] = {
+static rfbTranslateFnType rfbTranslateWithSingleTableFns[COUNT_OFFSETS][COUNT_OFFSETS] = {
{ rfbTranslateWithSingleTable8to8,
rfbTranslateWithSingleTable8to16,
#ifdef LIBVNCSERVER_ALLOW24BPP
@@ -188,7 +188,7 @@ rfbTranslateFnType rfbTranslateWithSingleTableFns[COUNT_OFFSETS][COUNT_OFFSETS]
rfbTranslateWithSingleTable32to32 }
};
-rfbTranslateFnType rfbTranslateWithRGBTablesFns[COUNT_OFFSETS][COUNT_OFFSETS] = {
+static rfbTranslateFnType rfbTranslateWithRGBTablesFns[COUNT_OFFSETS][COUNT_OFFSETS] = {
{ rfbTranslateWithRGBTables8to8,
rfbTranslateWithRGBTables8to16,
#ifdef LIBVNCSERVER_ALLOW24BPP
@@ -242,8 +242,7 @@ rfbTranslateNone(char *table, rfbPixelFormat *in, rfbPixelFormat *out,
*/
rfbBool
-rfbSetTranslateFunction(cl)
- rfbClientPtr cl;
+rfbSetTranslateFunction(rfbClientPtr cl)
{
rfbLog("Pixel format for client %s:\n",cl->host);
PrintPixelFormat(&cl->format);
@@ -359,8 +358,7 @@ rfbSetTranslateFunction(cl)
*/
static rfbBool
-rfbSetClientColourMapBGR233(cl)
- rfbClientPtr cl;
+rfbSetClientColourMapBGR233(rfbClientPtr cl)
{
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
@@ -414,10 +412,7 @@ rfbSetClientColourMapBGR233(cl)
*/
rfbBool
-rfbSetClientColourMap(cl, firstColour, nColours)
- rfbClientPtr cl;
- int firstColour;
- int nColours;
+rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours)
{
if (cl->screen->serverFormat.trueColour || !cl->readyForSetColourMapEntries) {
return TRUE;
@@ -448,10 +443,7 @@ rfbSetClientColourMap(cl, firstColour, nColours)
*/
void
-rfbSetClientColourMaps(rfbScreen, firstColour, nColours)
- rfbScreenInfoPtr rfbScreen;
- int firstColour;
- int nColours;
+rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours)
{
rfbClientIteratorPtr i;
rfbClientPtr cl;
@@ -463,8 +455,7 @@ rfbSetClientColourMaps(rfbScreen, firstColour, nColours)
}
static void
-PrintPixelFormat(pf)
- rfbPixelFormat *pf;
+PrintPixelFormat(rfbPixelFormat *pf)
{
if (pf->bitsPerPixel == 1) {
rfbLog(" 1 bpp, %s sig bit in each byte is leftmost on the screen.\n",
diff --git a/libvncserver/vncauth.c b/libvncserver/vncauth.c
index f530cc4..4c81d30 100644
--- a/libvncserver/vncauth.c
+++ b/libvncserver/vncauth.c
@@ -21,6 +21,8 @@
* vncauth.c - Functions for VNC password management and authentication.
*/
+#define _BSD_SOURCE
+#define _POSIX_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -47,6 +49,9 @@
#endif
+/* libvncclient does not need this */
+#ifndef rfbEncryptBytes
+
/*
* We use a fixed key to store passwords, since we assume that our local
* file system is secure but nonetheless don't want to store passwords
@@ -147,7 +152,7 @@ rfbRandomBytes(unsigned char *bytes)
static rfbBool s_srandom_called = FALSE;
if (!s_srandom_called) {
- srandom((unsigned int)time(0) ^ (unsigned int)getpid());
+ srandom((unsigned int)time(NULL) ^ (unsigned int)getpid());
s_srandom_called = TRUE;
}
@@ -156,6 +161,7 @@ rfbRandomBytes(unsigned char *bytes)
}
}
+#endif
/*
* Encrypt CHALLENGESIZE bytes in memory using a password.
diff --git a/libvncserver/zlib.c b/libvncserver/zlib.c
index 77e79c8..8503f59 100644
--- a/libvncserver/zlib.c
+++ b/libvncserver/zlib.c
@@ -52,10 +52,12 @@ static int zlibAfterBufLen;
* rectangle encoding.
*/
-rfbBool
-rfbSendOneRectEncodingZlib(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+static rfbBool
+rfbSendOneRectEncodingZlib(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
rfbFramebufferUpdateRectHeader rect;
rfbZlibHeader hdr;
@@ -230,9 +232,11 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
*/
rfbBool
-rfbSendRectEncodingZlib(cl, x, y, w, h)
- rfbClientPtr cl;
- int x, y, w, h;
+rfbSendRectEncodingZlib(rfbClientPtr cl,
+ int x,
+ int y,
+ int w,
+ int h)
{
int maxLines;
int linesRemaining;
diff --git a/libvncserver/zrle.c b/libvncserver/zrle.c
index 4990fc2..da9e67b 100644
--- a/libvncserver/zrle.c
+++ b/libvncserver/zrle.c
@@ -25,6 +25,7 @@
*/
#include "rfb/rfb.h"
+#include "private.h"
#include "zrleoutstream.h"
@@ -174,7 +175,7 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
}
-void FreeZrleData(rfbClientPtr cl)
+void rfbFreeZrleData(rfbClientPtr cl)
{
if (cl->zrleData)
zrleOutStreamFree(cl->zrleData);
diff --git a/libvncserver/zrleencodetemplate.c b/libvncserver/zrleencodetemplate.c
index 78bcb24..7c89c40 100644
--- a/libvncserver/zrleencodetemplate.c
+++ b/libvncserver/zrleencodetemplate.c
@@ -70,7 +70,7 @@ static zrlePaletteHelper paletteHelper;
void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os);
-void ZRLE_ENCODE (int x, int y, int w, int h,
+static void ZRLE_ENCODE (int x, int y, int w, int h,
zrleOutStream* os, void* buf
EXTRA_ARGS
)
diff --git a/libvncserver/zrleoutstream.c b/libvncserver/zrleoutstream.c
index d22d649..4efe609 100644
--- a/libvncserver/zrleoutstream.c
+++ b/libvncserver/zrleoutstream.c
@@ -209,8 +209,7 @@ static int zrleOutStreamOverrun(zrleOutStream *os,
return size;
}
-static inline int zrleOutStreamCheck(zrleOutStream *os,
- int size)
+static int zrleOutStreamCheck(zrleOutStream *os, int size)
{
if (os->in.ptr + size > os->in.end) {
return zrleOutStreamOverrun(os, size);