Commit 5030d53f authored by dscho's avatar dscho

converted CARD{8,16,32} to uint{8,16,32}_t and included support for stdint.h

parent f86f9cec
...@@ -3,7 +3,7 @@ DIST_SUBDIRS=examples contrib ...@@ -3,7 +3,7 @@ DIST_SUBDIRS=examples contrib
bin_SCRIPTS = libvncserver-config bin_SCRIPTS = libvncserver-config
include_HEADERS=include/rfb.h include/rfbconfig.h include/rfbproto.h \ include_HEADERS=include/rfb.h include/rfbconfig.h include/rfbint.h include/rfbproto.h \
include/keysym.h include/keysym.h
noinst_HEADERS=sraRegion.h d3des.h zrleDecode.h zrleEncode.h \ noinst_HEADERS=sraRegion.h d3des.h zrleDecode.h zrleEncode.h \
......
immediate: immediate:
---------- ----------
autoconf also CARD8,CARD16,...
x11vnc: clipboard, cursor x11vnc: clipboard, cursor
extra_bytes in rfbDrawCharWithClip. extra_bytes in rfbDrawCharWithClip.
tested mouse buttons make copy rect, but text is not marked as mod. tested mouse buttons make copy rect, but text is not marked as mod.
...@@ -25,6 +24,7 @@ CORBA ...@@ -25,6 +24,7 @@ CORBA
done: done:
----- -----
.autoconf also CARD8,CARD16,...
.autoconf .autoconf
.internal HTTP tunnelling feature (needs a special GET target and a few .internal HTTP tunnelling feature (needs a special GET target and a few
. changes to java applet). . changes to java applet).
......
This diff is collapsed.
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
/* /*
...@@ -46,12 +44,12 @@ rfbAuthNewClient(cl) ...@@ -46,12 +44,12 @@ rfbAuthNewClient(cl)
cl->state = RFB_AUTHENTICATION; cl->state = RFB_AUTHENTICATION;
if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) { if (cl->screen->rfbAuthPasswdData && !cl->reverseConnection) {
*(CARD32 *)buf = Swap32IfLE(rfbVncAuth); *(uint32_t *)buf = Swap32IfLE(rfbVncAuth);
vncRandomBytes(cl->authChallenge); vncRandomBytes(cl->authChallenge);
memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE); memcpy(&buf[4], (char *)cl->authChallenge, CHALLENGESIZE);
len = 4 + CHALLENGESIZE; len = 4 + CHALLENGESIZE;
} else { } else {
*(CARD32 *)buf = Swap32IfLE(rfbNoAuth); *(uint32_t *)buf = Swap32IfLE(rfbNoAuth);
len = 4; len = 4;
cl->state = RFB_INITIALISATION; cl->state = RFB_INITIALISATION;
} }
...@@ -74,8 +72,8 @@ rfbAuthProcessClientMessage(cl) ...@@ -74,8 +72,8 @@ rfbAuthProcessClientMessage(cl)
rfbClientPtr cl; rfbClientPtr cl;
{ {
int n; int n;
CARD8 response[CHALLENGESIZE]; uint8_t response[CHALLENGESIZE];
CARD32 authResult; uint32_t authResult;
if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) { if ((n = ReadExact(cl, (char *)response, CHALLENGESIZE)) <= 0) {
if (n != 0) if (n != 0)
......
...@@ -71,6 +71,8 @@ AC_C_INLINE ...@@ -71,6 +71,8 @@ AC_C_INLINE
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_HEADER_TIME AC_HEADER_TIME
AC_TYPE_SOCKLEN_T
AC_CREATE_STDINT_H(include/rfbint.h)
# Checks for library functions. # Checks for library functions.
AC_FUNC_MALLOC AC_FUNC_MALLOC
......
...@@ -461,7 +461,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) { ...@@ -461,7 +461,7 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
screen->paddedWidthInBytes = fb->bytes_per_line; screen->paddedWidthInBytes = fb->bytes_per_line;
screen->rfbServerFormat.bitsPerPixel = fb->bits_per_pixel; screen->rfbServerFormat.bitsPerPixel = fb->bits_per_pixel;
screen->rfbServerFormat.depth = fb->depth; screen->rfbServerFormat.depth = fb->depth;
screen->rfbServerFormat.trueColour = (CARD8) TRUE; screen->rfbServerFormat.trueColour = (uint8_t) TRUE;
if ( screen->rfbServerFormat.bitsPerPixel == 8 ) { if ( screen->rfbServerFormat.bitsPerPixel == 8 ) {
/* 8 bpp */ /* 8 bpp */
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
/* /*
...@@ -45,10 +43,10 @@ static int rreAfterBufSize = 0; ...@@ -45,10 +43,10 @@ static int rreAfterBufSize = 0;
static char *rreAfterBuf = NULL; static char *rreAfterBuf = NULL;
static int rreAfterBufLen; static int rreAfterBufLen;
static int subrectEncode8(CARD8 *data, int w, int h); static int subrectEncode8(uint8_t *data, int w, int h);
static int subrectEncode16(CARD16 *data, int w, int h); static int subrectEncode16(uint16_t *data, int w, int h);
static int subrectEncode32(CARD32 *data, int w, int h); static int subrectEncode32(uint32_t *data, int w, int h);
static CARD32 getBgColour(char *data, int size, int bpp); static uint32_t getBgColour(char *data, int size, int bpp);
static Bool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y, static Bool rfbSendSmallRectEncodingCoRRE(rfbClientPtr cl, int x, int y,
int w, int h); int w, int h);
...@@ -123,13 +121,13 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h) ...@@ -123,13 +121,13 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
nSubrects = subrectEncode8((CARD8 *)rreBeforeBuf, w, h); nSubrects = subrectEncode8((uint8_t *)rreBeforeBuf, w, h);
break; break;
case 16: case 16:
nSubrects = subrectEncode16((CARD16 *)rreBeforeBuf, w, h); nSubrects = subrectEncode16((uint16_t *)rreBeforeBuf, w, h);
break; break;
case 32: case 32:
nSubrects = subrectEncode32((CARD32 *)rreBeforeBuf, w, h); nSubrects = subrectEncode32((uint32_t *)rreBeforeBuf, w, h);
break; break;
default: default:
rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel);
...@@ -209,25 +207,25 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h) ...@@ -209,25 +207,25 @@ rfbSendSmallRectEncodingCoRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \ #define DEFINE_SUBRECT_ENCODE(bpp) \
static int \ static int \
subrectEncode##bpp(data,w,h) \ subrectEncode##bpp(data,w,h) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int w; \ int w; \
int h; \ int h; \
{ \ { \
CARD##bpp cl; \ uint##bpp##_t cl; \
rfbCoRRERectangle subrect; \ rfbCoRRERectangle subrect; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
int newLen; \ int newLen; \
CARD##bpp bg = (CARD##bpp)getBgColour((char*)data,w*h,bpp); \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\ \
*((CARD##bpp*)rreAfterBuf) = bg; \ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\ \
rreAfterBufLen = (bpp/8); \ rreAfterBufLen = (bpp/8); \
\ \
...@@ -279,7 +277,7 @@ subrectEncode##bpp(data,w,h) \ ...@@ -279,7 +277,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \ return -1; \
\ \
numsubs += 1; \ numsubs += 1; \
*((CARD##bpp*)(rreAfterBuf + rreAfterBufLen)) = cl; \ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \ rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbCoRRERectangle); \ memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbCoRRERectangle); \
rreAfterBufLen += sz_rfbCoRRERectangle; \ rreAfterBufLen += sz_rfbCoRRERectangle; \
...@@ -307,7 +305,7 @@ DEFINE_SUBRECT_ENCODE(32) ...@@ -307,7 +305,7 @@ DEFINE_SUBRECT_ENCODE(32)
/* /*
* getBgColour() gets the most prevalent colour in a byte array. * getBgColour() gets the most prevalent colour in a byte array.
*/ */
static CARD32 static uint32_t
getBgColour(data,size,bpp) getBgColour(data,size,bpp)
char *data; char *data;
int size; int size;
...@@ -320,13 +318,13 @@ getBgColour(data,size,bpp) ...@@ -320,13 +318,13 @@ getBgColour(data,size,bpp)
int i,j,k; int i,j,k;
int maxcount = 0; int maxcount = 0;
CARD8 maxclr = 0; uint8_t maxclr = 0;
if (bpp != 8) { if (bpp != 8) {
if (bpp == 16) { if (bpp == 16) {
return ((CARD16 *)data)[0]; return ((uint16_t *)data)[0];
} else if (bpp == 32) { } else if (bpp == 32) {
return ((CARD32 *)data)[0]; return ((uint32_t *)data)[0];
} else { } else {
rfbLog("getBgColour: bpp %d?\n",bpp); rfbLog("getBgColour: bpp %d?\n",bpp);
exit(1); exit(1);
...@@ -338,7 +336,7 @@ getBgColour(data,size,bpp) ...@@ -338,7 +336,7 @@ getBgColour(data,size,bpp)
} }
for (j=0; j<size; j++) { for (j=0; j<size; j++) {
k = (int)(((CARD8 *)data)[j]); k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) { if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k); rfbLog("getBgColour: unusual colour = %d\n", k);
exit(1); exit(1);
...@@ -346,7 +344,7 @@ getBgColour(data,size,bpp) ...@@ -346,7 +344,7 @@ getBgColour(data,size,bpp)
counts[k] += 1; counts[k] += 1;
if (counts[k] > maxcount) { if (counts[k] > maxcount) {
maxcount = counts[k]; maxcount = counts[k];
maxclr = ((CARD8 *)data)[j]; maxclr = ((uint8_t *)data)[j];
} }
} }
......
...@@ -40,8 +40,8 @@ rfbSendCursorShape(cl) ...@@ -40,8 +40,8 @@ rfbSendCursorShape(cl)
int saved_ublen; int saved_ublen;
int bitmapRowBytes, maskBytes, dataBytes; int bitmapRowBytes, maskBytes, dataBytes;
int i, j; int i, j;
CARD8 *bitmapData; uint8_t *bitmapData;
CARD8 bitmapByte; uint8_t bitmapByte;
pCursor = cl->screen->getCursorPtr(cl); pCursor = cl->screen->getCursorPtr(cl);
/*if(!pCursor) return TRUE;*/ /*if(!pCursor) return TRUE;*/
...@@ -131,7 +131,7 @@ rfbSendCursorShape(cl) ...@@ -131,7 +131,7 @@ rfbSendCursorShape(cl)
memcpy(&cl->updateBuf[cl->ublen], (char *)&colors, sz_rfbXCursorColors); memcpy(&cl->updateBuf[cl->ublen], (char *)&colors, sz_rfbXCursorColors);
cl->ublen += sz_rfbXCursorColors; cl->ublen += sz_rfbXCursorColors;
bitmapData = (CARD8 *)pCursor->source; bitmapData = (uint8_t *)pCursor->source;
for (i = 0; i < pCursor->height; i++) { for (i = 0; i < pCursor->height; i++) {
for (j = 0; j < bitmapRowBytes; j++) { for (j = 0; j < bitmapRowBytes; j++) {
...@@ -154,7 +154,7 @@ rfbSendCursorShape(cl) ...@@ -154,7 +154,7 @@ rfbSendCursorShape(cl)
/* Prepare transparency mask. */ /* Prepare transparency mask. */
bitmapData = (CARD8 *)pCursor->mask; bitmapData = (uint8_t *)pCursor->mask;
for (i = 0; i < pCursor->height; i++) { for (i = 0; i < pCursor->height; i++) {
for (j = 0; j < bitmapRowBytes; j++) { for (j = 0; j < bitmapRowBytes; j++) {
...@@ -322,7 +322,7 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) ...@@ -322,7 +322,7 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
rfbPixelFormat* format=&rfbScreen->rfbServerFormat; rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8, int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8,
width=cursor->width*bpp; width=cursor->width*bpp;
CARD32 background; uint32_t background;
char *back=(char*)&background; char *back=(char*)&background;
unsigned char bit; unsigned char bit;
...@@ -344,7 +344,7 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor) ...@@ -344,7 +344,7 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
{ {
rfbPixelFormat* format=&rfbScreen->rfbServerFormat; rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8; int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8;
CARD32 background,foreground; uint32_t background,foreground;
char *back=(char*)&background,*fore=(char*)&foreground; char *back=(char*)&background,*fore=(char*)&foreground;
unsigned char *cp; unsigned char *cp;
unsigned char bit; unsigned char bit;
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
static Bool sendHextiles8(rfbClientPtr cl, int x, int y, int w, int h); static Bool sendHextiles8(rfbClientPtr cl, int x, int y, int w, int h);
...@@ -90,10 +89,10 @@ rfbSendRectEncodingHextile(cl, x, y, w, h) ...@@ -90,10 +89,10 @@ rfbSendRectEncodingHextile(cl, x, y, w, h)
#define DEFINE_SEND_HEXTILES(bpp) \ #define DEFINE_SEND_HEXTILES(bpp) \
\ \
\ \
static Bool subrectEncode##bpp(rfbClientPtr cli, CARD##bpp *data, int w, int h, \ static Bool subrectEncode##bpp(rfbClientPtr cli, uint##bpp##_t *data, int w, int h, \
CARD##bpp bg, CARD##bpp fg, Bool mono); \ uint##bpp##_t bg, uint##bpp##_t fg, Bool mono); \
static void testColours##bpp(CARD##bpp *data, int size, Bool *mono, \ static void testColours##bpp(uint##bpp##_t *data, int size, Bool *mono, \
Bool *solid, CARD##bpp *bg, CARD##bpp *fg); \ Bool *solid, uint##bpp##_t *bg, uint##bpp##_t *fg); \
\ \
\ \
/* \ /* \
...@@ -108,11 +107,11 @@ sendHextiles##bpp(cl, rx, ry, rw, rh) ...@@ -108,11 +107,11 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
int x, y, w, h; \ int x, y, w, h; \
int startUblen; \ int startUblen; \
char *fbptr; \ char *fbptr; \
CARD##bpp bg = 0, fg = 0, newBg, newFg; \ uint##bpp##_t bg = 0, fg = 0, newBg, newFg; \
Bool mono, solid; \ Bool mono, solid; \
Bool validBg = FALSE; \ Bool validBg = FALSE; \
Bool validFg = FALSE; \ Bool validFg = FALSE; \
CARD##bpp clientPixelData[16*16*(bpp/8)]; \ uint##bpp##_t clientPixelData[16*16*(bpp/8)]; \
\ \
for (y = ry; y < ry+rh; y += 16) { \ for (y = ry; y < ry+rh; y += 16) { \
for (x = rx; x < rx+rw; x += 16) { \ for (x = rx; x < rx+rw; x += 16) { \
...@@ -194,16 +193,16 @@ sendHextiles##bpp(cl, rx, ry, rw, rh) ...@@ -194,16 +193,16 @@ sendHextiles##bpp(cl, rx, ry, rw, rh)
\ \
\ \
static Bool \ static Bool \
subrectEncode##bpp(rfbClientPtr cl, CARD##bpp *data, int w, int h, \ subrectEncode##bpp(rfbClientPtr cl, uint##bpp##_t *data, int w, int h, \
CARD##bpp bg, CARD##bpp fg, Bool mono) \ uint##bpp##_t bg, uint##bpp##_t fg, Bool mono) \
{ \ { \
CARD##bpp cl2; \ uint##bpp##_t cl2; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
...@@ -297,14 +296,14 @@ subrectEncode##bpp(rfbClientPtr cl, CARD##bpp *data, int w, int h, ...@@ -297,14 +296,14 @@ subrectEncode##bpp(rfbClientPtr cl, CARD##bpp *data, int w, int h,
\ \
static void \ static void \
testColours##bpp(data,size,mono,solid,bg,fg) \ testColours##bpp(data,size,mono,solid,bg,fg) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int size; \ int size; \
Bool *mono; \ Bool *mono; \
Bool *solid; \ Bool *solid; \
CARD##bpp *bg; \ uint##bpp##_t *bg; \
CARD##bpp *fg; \ uint##bpp##_t *fg; \
{ \ { \
CARD##bpp colour1 = 0, colour2 = 0; \ uint##bpp##_t colour1 = 0, colour2 = 0; \
int n1 = 0, n2 = 0; \ int n1 = 0, n2 = 0; \
*mono = TRUE; \ *mono = TRUE; \
*solid = TRUE; \ *solid = TRUE; \
......
...@@ -22,32 +22,43 @@ ...@@ -22,32 +22,43 @@
* USA. * USA.
*/ */
#include <stdio.h> #include "rfb.h"
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <errno.h>
#ifdef WIN32 #ifdef WIN32
#include <winsock.h> #include <winsock.h>
#define close closesocket #define close closesocket
#else #else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <pwd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <unistd.h>
#endif #endif
#include <fcntl.h> #include <pwd.h>
#include <errno.h> #endif
#ifdef USE_LIBWRAP #ifdef USE_LIBWRAP
#include <tcpd.h> #include <tcpd.h>
#endif #endif
#include "rfb.h"
#define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\n\r\n" \ #define NOT_FOUND_STR "HTTP/1.0 404 Not found\r\n\r\n" \
"<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \ "<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \
"<BODY><H1>File Not Found</H1></BODY>\n" "<BODY><H1>File Not Found</H1></BODY>\n"
......
rfbconfig.h rfbconfig.h
rfbconfig.h.in rfbconfig.h.in
stamp-h1 stamp-h*
rfbint.h
...@@ -36,52 +36,47 @@ extern "C" ...@@ -36,52 +36,47 @@ extern "C"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "rfbconfig.h" #include "rfbconfig.h"
#include "rfbint.h"
#include "keysym.h" #include "keysym.h"
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include <zlib.h> #include <zlib.h>
#endif #endif
/* TODO: this stuff has to go into autoconf */
typedef unsigned char CARD8;
typedef unsigned short CARD16;
typedef unsigned int CARD32;
typedef CARD32 Pixel;
/* typedef CARD32 KeySym; */
typedef unsigned long KeySym;
#define SIGNED signed
typedef signed char Bool;
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE -1
#include "rfbproto.h" #include "rfbproto.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#if defined(WIN32) #if defined(WIN32)
#define WORDS_BIGENDIAN #define WORDS_BIGENDIAN
#undef Bool #undef Bool
#define Bool int #define Bool int
#endif
#ifdef __sgi__
typedef int socklen_t;
#endif
#ifdef WIN32
#include <sys/timeb.h> #include <sys/timeb.h>
#include <winsock.h> #include <winsock.h>
#undef SOCKET #undef SOCKET
#define SOCKET int #define SOCKET int
#else #else
#define max(a,b) (((a)>(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b))
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#define SOCKET int #define SOCKET int
#ifndef Bool
typedef int8_t Bool;
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE -1
#endif #endif
#endif
typedef uint32_t KeySym;
typedef uint32_t Pixel;
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE ((in_addr_t) 0xffffffff) #define INADDR_NONE ((in_addr_t) 0xffffffff)
...@@ -171,11 +166,11 @@ typedef enum rfbNewClientAction (*NewClientHookPtr)(struct _rfbClientRec* cl); ...@@ -171,11 +166,11 @@ typedef enum rfbNewClientAction (*NewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl); typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl);
typedef struct { typedef struct {
CARD32 count; uint32_t count;
Bool is16; /* is the data format short? */ Bool is16; /* is the data format short? */
union { union {
CARD8* bytes; uint8_t* bytes;
CARD16* shorts; uint16_t* shorts;
} data; /* there have to be count*3 entries */ } data; /* there have to be count*3 entries */
} rfbColourMap; } rfbColourMap;
...@@ -390,7 +385,7 @@ typedef struct _rfbClientRec { ...@@ -390,7 +385,7 @@ typedef struct _rfbClientRec {
int correMaxWidth, correMaxHeight; int correMaxWidth, correMaxHeight;
/* The following member is only used during VNC authentication */ /* The following member is only used during VNC authentication */
CARD8 authChallenge[CHALLENGESIZE]; uint8_t authChallenge[CHALLENGESIZE];
/* The following members represent the update needed to get the client's /* The following members represent the update needed to get the client's
framebuffer from its present state to the current state of our framebuffer from its present state to the current state of our
...@@ -473,7 +468,7 @@ typedef struct _rfbClientRec { ...@@ -473,7 +468,7 @@ typedef struct _rfbClientRec {
struct z_stream_s compStream; struct z_stream_s compStream;
Bool compStreamInited; Bool compStreamInited;
CARD32 zlibCompressLevel; uint32_t zlibCompressLevel;
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
/* tight encoding -- preserve zlib streams' state for each client */ /* tight encoding -- preserve zlib streams' state for each client */
......
...@@ -60,10 +60,10 @@ ...@@ -60,10 +60,10 @@
*/ */
typedef struct { typedef struct {
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
CARD16 w; uint16_t w;
CARD16 h; uint16_t h;
} rfbRectangle; } rfbRectangle;
#define sz_rfbRectangle 8 #define sz_rfbRectangle 8
...@@ -75,32 +75,32 @@ typedef struct { ...@@ -75,32 +75,32 @@ typedef struct {
typedef struct { typedef struct {
CARD8 bitsPerPixel; /* 8,16,32 only */ uint8_t bitsPerPixel; /* 8,16,32 only */
CARD8 depth; /* 8 to 32 */ uint8_t depth; /* 8 to 32 */
CARD8 bigEndian; /* True if multi-byte pixels are interpreted uint8_t bigEndian; /* True if multi-byte pixels are interpreted
as big endian, or if single-bit-per-pixel as big endian, or if single-bit-per-pixel
has most significant bit of the byte has most significant bit of the byte
corresponding to first (leftmost) pixel. Of corresponding to first (leftmost) pixel. Of
course this is meaningless for 8 bits/pix */ course this is meaningless for 8 bits/pix */
CARD8 trueColour; /* If false then we need a "colour map" to uint8_t trueColour; /* If false then we need a "colour map" to
convert pixels to RGB. If true, xxxMax and convert pixels to RGB. If true, xxxMax and
xxxShift specify bits used for red, green xxxShift specify bits used for red, green
and blue */ and blue */
/* the following fields are only meaningful if trueColour is true */ /* the following fields are only meaningful if trueColour is true */
CARD16 redMax; /* maximum red value (= 2^n - 1 where n is the uint16_t redMax; /* maximum red value (= 2^n - 1 where n is the
number of bits used for red). Note this number of bits used for red). Note this
value is always in big endian order. */ value is always in big endian order. */
CARD16 greenMax; /* similar for green */ uint16_t greenMax; /* similar for green */
CARD16 blueMax; /* and blue */ uint16_t blueMax; /* and blue */
CARD8 redShift; /* number of shifts needed to get the red uint8_t redShift; /* number of shifts needed to get the red
value in a pixel to the least significant value in a pixel to the least significant
bit. To find the red value from a given bit. To find the red value from a given
pixel, do the following: pixel, do the following:
...@@ -112,12 +112,12 @@ typedef struct { ...@@ -112,12 +112,12 @@ typedef struct {
4) You now have the red value between 0 and 4) You now have the red value between 0 and
redMax. */ redMax. */
CARD8 greenShift; /* similar for green */ uint8_t greenShift; /* similar for green */
CARD8 blueShift; /* and blue */ uint8_t blueShift; /* and blue */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
} rfbPixelFormat; } rfbPixelFormat;
...@@ -216,7 +216,7 @@ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ ...@@ -216,7 +216,7 @@ typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */
*/ */
typedef struct { typedef struct {
CARD8 shared; uint8_t shared;
} rfbClientInitMsg; } rfbClientInitMsg;
#define sz_rfbClientInitMsg 1 #define sz_rfbClientInitMsg 1
...@@ -231,10 +231,10 @@ typedef struct { ...@@ -231,10 +231,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD16 framebufferWidth; uint16_t framebufferWidth;
CARD16 framebufferHeight; uint16_t framebufferHeight;
rfbPixelFormat format; /* the server's preferred pixel format */ rfbPixelFormat format; /* the server's preferred pixel format */
CARD32 nameLength; uint32_t nameLength;
/* followed by char name[nameLength] */ /* followed by char name[nameLength] */
} rfbServerInitMsg; } rfbServerInitMsg;
...@@ -363,9 +363,9 @@ typedef struct { ...@@ -363,9 +363,9 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFramebufferUpdate */ uint8_t type; /* always rfbFramebufferUpdate */
CARD8 pad; uint8_t pad;
CARD16 nRects; uint16_t nRects;
/* followed by nRects rectangles */ /* followed by nRects rectangles */
} rfbFramebufferUpdateMsg; } rfbFramebufferUpdateMsg;
...@@ -381,7 +381,7 @@ typedef struct { ...@@ -381,7 +381,7 @@ typedef struct {
typedef struct { typedef struct {
rfbRectangle r; rfbRectangle r;
CARD32 encoding; /* one of the encoding types rfbEncoding... */ uint32_t encoding; /* one of the encoding types rfbEncoding... */
} rfbFramebufferUpdateRectHeader; } rfbFramebufferUpdateRectHeader;
#define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4)
...@@ -399,8 +399,8 @@ typedef struct { ...@@ -399,8 +399,8 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD16 srcX; uint16_t srcX;
CARD16 srcY; uint16_t srcY;
} rfbCopyRect; } rfbCopyRect;
#define sz_rfbCopyRect 4 #define sz_rfbCopyRect 4
...@@ -414,7 +414,7 @@ typedef struct { ...@@ -414,7 +414,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 nSubrects; uint32_t nSubrects;
} rfbRREHeader; } rfbRREHeader;
#define sz_rfbRREHeader 4 #define sz_rfbRREHeader 4
...@@ -429,10 +429,10 @@ typedef struct { ...@@ -429,10 +429,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 x; uint8_t x;
CARD8 y; uint8_t y;
CARD8 w; uint8_t w;
CARD8 h; uint8_t h;
} rfbCoRRERectangle; } rfbCoRRERectangle;
#define sz_rfbCoRRERectangle 4 #define sz_rfbCoRRERectangle 4
...@@ -498,7 +498,7 @@ typedef struct { ...@@ -498,7 +498,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 nBytes; uint32_t nBytes;
} rfbZlibHeader; } rfbZlibHeader;
#define sz_rfbZlibHeader 4 #define sz_rfbZlibHeader 4
...@@ -661,12 +661,12 @@ typedef struct { ...@@ -661,12 +661,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 foreRed; uint8_t foreRed;
CARD8 foreGreen; uint8_t foreGreen;
CARD8 foreBlue; uint8_t foreBlue;
CARD8 backRed; uint8_t backRed;
CARD8 backGreen; uint8_t backGreen;
CARD8 backBlue; uint8_t backBlue;
} rfbXCursorColors; } rfbXCursorColors;
#define sz_rfbXCursorColors 6 #define sz_rfbXCursorColors 6
...@@ -692,7 +692,7 @@ typedef struct { ...@@ -692,7 +692,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD32 length; uint32_t length;
} rfbZRLEHeader; } rfbZRLEHeader;
#define sz_rfbZRLEHeader 4 #define sz_rfbZRLEHeader 4
...@@ -711,12 +711,12 @@ typedef struct { ...@@ -711,12 +711,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetColourMapEntries */ uint8_t type; /* always rfbSetColourMapEntries */
CARD8 pad; uint8_t pad;
CARD16 firstColour; uint16_t firstColour;
CARD16 nColours; uint16_t nColours;
/* Followed by nColours * 3 * CARD16 /* Followed by nColours * 3 * uint16_t
r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
} rfbSetColourMapEntriesMsg; } rfbSetColourMapEntriesMsg;
...@@ -730,7 +730,7 @@ typedef struct { ...@@ -730,7 +730,7 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbBell */ uint8_t type; /* always rfbBell */
} rfbBellMsg; } rfbBellMsg;
#define sz_rfbBellMsg 1 #define sz_rfbBellMsg 1
...@@ -742,10 +742,10 @@ typedef struct { ...@@ -742,10 +742,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbServerCutText */ uint8_t type; /* always rfbServerCutText */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
CARD32 length; uint32_t length;
/* followed by char text[length] */ /* followed by char text[length] */
} rfbServerCutTextMsg; } rfbServerCutTextMsg;
...@@ -762,7 +762,7 @@ typedef rfbServerCutTextMsg rfbBackChannelMsg; ...@@ -762,7 +762,7 @@ typedef rfbServerCutTextMsg rfbBackChannelMsg;
*/ */
typedef union { typedef union {
CARD8 type; uint8_t type;
rfbFramebufferUpdateMsg fu; rfbFramebufferUpdateMsg fu;
rfbSetColourMapEntriesMsg scme; rfbSetColourMapEntriesMsg scme;
rfbBellMsg b; rfbBellMsg b;
...@@ -784,9 +784,9 @@ typedef union { ...@@ -784,9 +784,9 @@ typedef union {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetPixelFormat */ uint8_t type; /* always rfbSetPixelFormat */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
rfbPixelFormat format; rfbPixelFormat format;
} rfbSetPixelFormatMsg; } rfbSetPixelFormatMsg;
...@@ -801,12 +801,12 @@ typedef struct { ...@@ -801,12 +801,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFixColourMapEntries */ uint8_t type; /* always rfbFixColourMapEntries */
CARD8 pad; uint8_t pad;
CARD16 firstColour; uint16_t firstColour;
CARD16 nColours; uint16_t nColours;
/* Followed by nColours * 3 * CARD16 /* Followed by nColours * 3 * uint16_t
r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */
} rfbFixColourMapEntriesMsg; } rfbFixColourMapEntriesMsg;
...@@ -821,10 +821,10 @@ typedef struct { ...@@ -821,10 +821,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbSetEncodings */ uint8_t type; /* always rfbSetEncodings */
CARD8 pad; uint8_t pad;
CARD16 nEncodings; uint16_t nEncodings;
/* followed by nEncodings * CARD32 encoding types */ /* followed by nEncodings * uint32_t encoding types */
} rfbSetEncodingsMsg; } rfbSetEncodingsMsg;
#define sz_rfbSetEncodingsMsg 4 #define sz_rfbSetEncodingsMsg 4
...@@ -837,12 +837,12 @@ typedef struct { ...@@ -837,12 +837,12 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbFramebufferUpdateRequest */ uint8_t type; /* always rfbFramebufferUpdateRequest */
CARD8 incremental; uint8_t incremental;
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
CARD16 w; uint16_t w;
CARD16 h; uint16_t h;
} rfbFramebufferUpdateRequestMsg; } rfbFramebufferUpdateRequestMsg;
#define sz_rfbFramebufferUpdateRequestMsg 10 #define sz_rfbFramebufferUpdateRequestMsg 10
...@@ -880,10 +880,10 @@ typedef struct { ...@@ -880,10 +880,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbKeyEvent */ uint8_t type; /* always rfbKeyEvent */
CARD8 down; /* true if down (press), false if up */ uint8_t down; /* true if down (press), false if up */
CARD16 pad; uint16_t pad;
CARD32 key; /* key is specified as an X keysym */ uint32_t key; /* key is specified as an X keysym */
} rfbKeyEventMsg; } rfbKeyEventMsg;
#define sz_rfbKeyEventMsg 8 #define sz_rfbKeyEventMsg 8
...@@ -894,10 +894,10 @@ typedef struct { ...@@ -894,10 +894,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbPointerEvent */ uint8_t type; /* always rfbPointerEvent */
CARD8 buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ uint8_t buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */
CARD16 x; uint16_t x;
CARD16 y; uint16_t y;
} rfbPointerEventMsg; } rfbPointerEventMsg;
#define rfbButton1Mask 1 #define rfbButton1Mask 1
...@@ -913,10 +913,10 @@ typedef struct { ...@@ -913,10 +913,10 @@ typedef struct {
*/ */
typedef struct { typedef struct {
CARD8 type; /* always rfbClientCutText */ uint8_t type; /* always rfbClientCutText */
CARD8 pad1; uint8_t pad1;
CARD16 pad2; uint16_t pad2;
CARD32 length; uint32_t length;
/* followed by char text[length] */ /* followed by char text[length] */
} rfbClientCutTextMsg; } rfbClientCutTextMsg;
...@@ -929,7 +929,7 @@ typedef struct { ...@@ -929,7 +929,7 @@ typedef struct {
*/ */
typedef union { typedef union {
CARD8 type; uint8_t type;
rfbSetPixelFormatMsg spf; rfbSetPixelFormatMsg spf;
rfbFixColourMapEntriesMsg fcme; rfbFixColourMapEntriesMsg fcme;
rfbSetEncodingsMsg se; rfbSetEncodingsMsg se;
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
* see GPL (latest version) for full details * see GPL (latest version) for full details
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
...@@ -20,12 +18,16 @@ ...@@ -20,12 +18,16 @@
#define true -1 #define true -1
#endif #endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifndef WIN32 #ifndef WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
...@@ -734,7 +736,7 @@ void rfbInitServer(rfbScreenInfoPtr rfbScreen) ...@@ -734,7 +736,7 @@ void rfbInitServer(rfbScreenInfoPtr rfbScreen)
httpInitSockets(rfbScreen); httpInitSockets(rfbScreen);
} }
#ifdef WIN32 #ifndef HAVE_GETTIMEOFDAY
#include <fcntl.h> #include <fcntl.h>
#include <conio.h> #include <conio.h>
#include <sys/timeb.h> #include <sys/timeb.h>
......
...@@ -24,23 +24,30 @@ ...@@ -24,23 +24,30 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef WIN32 #ifdef WIN32
#define write(sock,buf,len) send(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0)
#else #else
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <pwd.h> #include <pwd.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <fcntl.h> #endif
#include <sys/types.h>
#ifdef CORBA #ifdef CORBA
#include <vncserverctrl.h> #include <vncserverctrl.h>
...@@ -538,8 +545,8 @@ rfbClientConnFailed(cl, reason) ...@@ -538,8 +545,8 @@ rfbClientConnFailed(cl, reason)
int len = strlen(reason); int len = strlen(reason);
buf = (char *)malloc(8 + len); buf = (char *)malloc(8 + len);
((CARD32 *)buf)[0] = Swap32IfLE(rfbConnFailed); ((uint32_t *)buf)[0] = Swap32IfLE(rfbConnFailed);
((CARD32 *)buf)[1] = Swap32IfLE(len); ((uint32_t *)buf)[1] = Swap32IfLE(len);
memcpy(buf + 8, reason, len); memcpy(buf + 8, reason, len);
if (WriteExact(cl, buf, 8 + len) < 0) if (WriteExact(cl, buf, 8 + len) < 0)
...@@ -692,7 +699,7 @@ rfbProcessClientNormalMessage(cl) ...@@ -692,7 +699,7 @@ rfbProcessClientNormalMessage(cl)
case rfbSetEncodings: case rfbSetEncodings:
{ {
int i; int i;
CARD32 enc; uint32_t enc;
if ((n = ReadExact(cl, ((char *)&msg) + 1, if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbSetEncodingsMsg - 1)) <= 0) { sz_rfbSetEncodingsMsg - 1)) <= 0) {
...@@ -828,15 +835,15 @@ rfbProcessClientNormalMessage(cl) ...@@ -828,15 +835,15 @@ rfbProcessClientNormalMessage(cl)
#endif #endif
default: default:
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
if ( enc >= (CARD32)rfbEncodingCompressLevel0 && if ( enc >= (uint32_t)rfbEncodingCompressLevel0 &&
enc <= (CARD32)rfbEncodingCompressLevel9 ) { enc <= (uint32_t)rfbEncodingCompressLevel9 ) {
cl->zlibCompressLevel = enc & 0x0F; cl->zlibCompressLevel = enc & 0x0F;
#ifdef HAVE_LIBJPEG #ifdef HAVE_LIBJPEG
cl->tightCompressLevel = enc & 0x0F; cl->tightCompressLevel = enc & 0x0F;
rfbLog("Using compression level %d for client %s\n", rfbLog("Using compression level %d for client %s\n",
cl->tightCompressLevel, cl->host); cl->tightCompressLevel, cl->host);
} else if ( enc >= (CARD32)rfbEncodingQualityLevel0 && } else if ( enc >= (uint32_t)rfbEncodingQualityLevel0 &&
enc <= (CARD32)rfbEncodingQualityLevel9 ) { enc <= (uint32_t)rfbEncodingQualityLevel9 ) {
cl->tightQualityLevel = enc & 0x0F; cl->tightQualityLevel = enc & 0x0F;
rfbLog("Using image quality level %d for client %s\n", rfbLog("Using image quality level %d for client %s\n",
cl->tightQualityLevel, cl->host); cl->tightQualityLevel, cl->host);
...@@ -1178,7 +1185,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -1178,7 +1185,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
fu->type = rfbFramebufferUpdate; fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) { if (nUpdateRegionRects != 0xFFFF) {
fu->nRects = Swap16IfLE((CARD16)(sraRgnCountRects(updateCopyRegion) + fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) +
nUpdateRegionRects + nUpdateRegionRects +
!!sendCursorShape + !!sendCursorPos)); !!sendCursorShape + !!sendCursorPos));
} else { } else {
...@@ -1516,7 +1523,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours) ...@@ -1516,7 +1523,7 @@ rfbSendSetColourMapEntries(cl, firstColour, nColours)
{ {
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
CARD16 *rgb = (CARD16 *)(&buf[sz_rfbSetColourMapEntriesMsg]); uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]);
rfbColourMap* cm = &cl->screen->colourMap; rfbColourMap* cm = &cl->screen->colourMap;
int i, len; int i, len;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
/* /*
...@@ -43,10 +42,10 @@ static int rreAfterBufSize = 0; ...@@ -43,10 +42,10 @@ static int rreAfterBufSize = 0;
static char *rreAfterBuf = NULL; static char *rreAfterBuf = NULL;
static int rreAfterBufLen; static int rreAfterBufLen;
static int subrectEncode8(CARD8 *data, int w, int h); static int subrectEncode8(uint8_t *data, int w, int h);
static int subrectEncode16(CARD16 *data, int w, int h); static int subrectEncode16(uint16_t *data, int w, int h);
static int subrectEncode32(CARD32 *data, int w, int h); static int subrectEncode32(uint32_t *data, int w, int h);
static CARD32 getBgColour(char *data, int size, int bpp); static uint32_t getBgColour(char *data, int size, int bpp);
/* /*
...@@ -91,13 +90,13 @@ rfbSendRectEncodingRRE(cl, x, y, w, h) ...@@ -91,13 +90,13 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
switch (cl->format.bitsPerPixel) { switch (cl->format.bitsPerPixel) {
case 8: case 8:
nSubrects = subrectEncode8((CARD8 *)rreBeforeBuf, w, h); nSubrects = subrectEncode8((uint8_t *)rreBeforeBuf, w, h);
break; break;
case 16: case 16:
nSubrects = subrectEncode16((CARD16 *)rreBeforeBuf, w, h); nSubrects = subrectEncode16((uint16_t *)rreBeforeBuf, w, h);
break; break;
case 32: case 32:
nSubrects = subrectEncode32((CARD32 *)rreBeforeBuf, w, h); nSubrects = subrectEncode32((uint32_t *)rreBeforeBuf, w, h);
break; break;
default: default:
rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel); rfbLog("getBgColour: bpp %d?\n",cl->format.bitsPerPixel);
...@@ -177,25 +176,25 @@ rfbSendRectEncodingRRE(cl, x, y, w, h) ...@@ -177,25 +176,25 @@ rfbSendRectEncodingRRE(cl, x, y, w, h)
#define DEFINE_SUBRECT_ENCODE(bpp) \ #define DEFINE_SUBRECT_ENCODE(bpp) \
static int \ static int \
subrectEncode##bpp(data,w,h) \ subrectEncode##bpp(data,w,h) \
CARD##bpp *data; \ uint##bpp##_t *data; \
int w; \ int w; \
int h; \ int h; \
{ \ { \
CARD##bpp cl; \ uint##bpp##_t cl; \
rfbRectangle subrect; \ rfbRectangle subrect; \
int x,y; \ int x,y; \
int i,j; \ int i,j; \
int hx=0,hy,vx=0,vy; \ int hx=0,hy,vx=0,vy; \
int hyflag; \ int hyflag; \
CARD##bpp *seg; \ uint##bpp##_t *seg; \
CARD##bpp *line; \ uint##bpp##_t *line; \
int hw,hh,vw,vh; \ int hw,hh,vw,vh; \
int thex,they,thew,theh; \ int thex,they,thew,theh; \
int numsubs = 0; \ int numsubs = 0; \
int newLen; \ int newLen; \
CARD##bpp bg = (CARD##bpp)getBgColour((char*)data,w*h,bpp); \ uint##bpp##_t bg = (uint##bpp##_t)getBgColour((char*)data,w*h,bpp); \
\ \
*((CARD##bpp*)rreAfterBuf) = bg; \ *((uint##bpp##_t*)rreAfterBuf) = bg; \
\ \
rreAfterBufLen = (bpp/8); \ rreAfterBufLen = (bpp/8); \
\ \
...@@ -247,7 +246,7 @@ subrectEncode##bpp(data,w,h) \ ...@@ -247,7 +246,7 @@ subrectEncode##bpp(data,w,h) \
return -1; \ return -1; \
\ \
numsubs += 1; \ numsubs += 1; \
*((CARD##bpp*)(rreAfterBuf + rreAfterBufLen)) = cl; \ *((uint##bpp##_t*)(rreAfterBuf + rreAfterBufLen)) = cl; \
rreAfterBufLen += (bpp/8); \ rreAfterBufLen += (bpp/8); \
memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \ memcpy(&rreAfterBuf[rreAfterBufLen],&subrect,sz_rfbRectangle); \
rreAfterBufLen += sz_rfbRectangle; \ rreAfterBufLen += sz_rfbRectangle; \
...@@ -275,7 +274,7 @@ DEFINE_SUBRECT_ENCODE(32) ...@@ -275,7 +274,7 @@ DEFINE_SUBRECT_ENCODE(32)
/* /*
* getBgColour() gets the most prevalent colour in a byte array. * getBgColour() gets the most prevalent colour in a byte array.
*/ */
static CARD32 static uint32_t
getBgColour(data,size,bpp) getBgColour(data,size,bpp)
char *data; char *data;
int size; int size;
...@@ -288,13 +287,13 @@ getBgColour(data,size,bpp) ...@@ -288,13 +287,13 @@ getBgColour(data,size,bpp)
int i,j,k; int i,j,k;
int maxcount = 0; int maxcount = 0;
CARD8 maxclr = 0; uint8_t maxclr = 0;
if (bpp != 8) { if (bpp != 8) {
if (bpp == 16) { if (bpp == 16) {
return ((CARD16 *)data)[0]; return ((uint16_t *)data)[0];
} else if (bpp == 32) { } else if (bpp == 32) {
return ((CARD32 *)data)[0]; return ((uint32_t *)data)[0];
} else { } else {
rfbLog("getBgColour: bpp %d?\n",bpp); rfbLog("getBgColour: bpp %d?\n",bpp);
exit(1); exit(1);
...@@ -306,7 +305,7 @@ getBgColour(data,size,bpp) ...@@ -306,7 +305,7 @@ getBgColour(data,size,bpp)
} }
for (j=0; j<size; j++) { for (j=0; j<size; j++) {
k = (int)(((CARD8 *)data)[j]); k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) { if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k); rfbLog("getBgColour: unusual colour = %d\n", k);
exit(1); exit(1);
...@@ -314,7 +313,7 @@ getBgColour(data,size,bpp) ...@@ -314,7 +313,7 @@ getBgColour(data,size,bpp)
counts[k] += 1; counts[k] += 1;
if (counts[k] > maxcount) { if (counts[k] > maxcount) {
maxcount = counts[k]; maxcount = counts[k];
maxclr = ((CARD8 *)data)[j]; maxclr = ((uint8_t *)data)[j];
} }
} }
......
...@@ -39,8 +39,12 @@ ...@@ -39,8 +39,12 @@
* USA. * USA.
*/ */
#include <stdio.h> #include "rfb.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef WIN32 #ifdef WIN32
#pragma warning (disable: 4018 4761) #pragma warning (disable: 4018 4761)
#define close closesocket #define close closesocket
...@@ -49,14 +53,23 @@ ...@@ -49,14 +53,23 @@
#define ETIMEDOUT WSAETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT
#define write(sock,buf,len) send(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0)
#else #else
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#if defined(__linux__) && defined(NEED_TIMEVAL) #if defined(__linux__) && defined(NEED_TIMEVAL)
struct timeval struct timeval
{ {
...@@ -64,7 +77,11 @@ struct timeval ...@@ -64,7 +77,11 @@ struct timeval
} }
; ;
#endif #endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#endif
#include <errno.h> #include <errno.h>
#ifdef USE_LIBWRAP #ifdef USE_LIBWRAP
...@@ -74,8 +91,6 @@ int allow_severity=LOG_INFO; ...@@ -74,8 +91,6 @@ int allow_severity=LOG_INFO;
int deny_severity=LOG_WARNING; int deny_severity=LOG_WARNING;
#endif #endif
#include "rfb.h"
/*#ifndef WIN32 /*#ifndef WIN32
int max(int i,int j) { return(i<j?j:i); } int max(int i,int j) { return(i<j?j:i); }
#endif #endif
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
#include <stdlib.h>
#include <stdio.h>
/* -=- Internal Span structure */ /* -=- Internal Span structure */
struct sraRegion; struct sraRegion;
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
static const char* encNames[] = { static const char* encNames[] = {
......
...@@ -24,22 +24,22 @@ ...@@ -24,22 +24,22 @@
*/ */
static void static void
rfbInitOneRGBTable24 (CARD8 *table, int inMax, int outMax, int outShift,int swap); rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,int swap);
static void static void
rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in, rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in,
rfbPixelFormat *out,rfbColourMap* colourMap) rfbPixelFormat *out,rfbColourMap* colourMap)
{ {
CARD32 i, r, g, b, outValue; uint32_t i, r, g, b, outValue;
CARD8 *t; uint8_t *t;
CARD8 c; uint8_t c;
unsigned int nEntries = 1 << in->bitsPerPixel; unsigned int nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8; int shift = colourMap->is16?16:8;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc(nEntries * 3 + 1); *table = (char *)malloc(nEntries * 3 + 1);
t = (CARD8 *)*table; t = (uint8_t *)*table;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
r = g = b = 0; r = g = b = 0;
...@@ -57,7 +57,7 @@ rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in, ...@@ -57,7 +57,7 @@ rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in,
outValue = ((((r * (1 + out->redMax)) >> shift) << out->redShift) | outValue = ((((r * (1 + out->redMax)) >> shift) << out->redShift) |
(((g * (1 + out->greenMax)) >> shift) << out->greenShift) | (((g * (1 + out->greenMax)) >> shift) << out->greenShift) |
(((b * (1 + out->blueMax)) >> shift) << out->blueShift)); (((b * (1 + out->blueMax)) >> shift) << out->blueShift));
*(CARD32*)&t[3*i] = outValue; *(uint32_t*)&t[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(t+3*i,t+3*i+1,3); memmove(t+3*i,t+3*i+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
...@@ -77,13 +77,13 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in, ...@@ -77,13 +77,13 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
{ {
int i,outValue; int i,outValue;
int inRed, inGreen, inBlue, outRed, outGreen, outBlue; int inRed, inGreen, inBlue, outRed, outGreen, outBlue;
CARD8 *t; uint8_t *t;
CARD8 c; uint8_t c;
int nEntries = 1 << in->bitsPerPixel; int nEntries = 1 << in->bitsPerPixel;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc(nEntries * 3 + 1); *table = (char *)malloc(nEntries * 3 + 1);
t = (CARD8 *)*table; t = (uint8_t *)*table;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
inRed = (i >> in->redShift) & in->redMax; inRed = (i >> in->redShift) & in->redMax;
...@@ -97,7 +97,7 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in, ...@@ -97,7 +97,7 @@ rfbInitTrueColourSingleTable24 (char **table, rfbPixelFormat *in,
outValue = ((outRed << out->redShift) | outValue = ((outRed << out->redShift) |
(outGreen << out->greenShift) | (outGreen << out->greenShift) |
(outBlue << out->blueShift)); (outBlue << out->blueShift));
*(CARD32*)&t[3*i] = outValue; *(uint32_t*)&t[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(t+3*i,t+3*i+1,3); memmove(t+3*i,t+3*i+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
...@@ -116,14 +116,14 @@ static void ...@@ -116,14 +116,14 @@ static void
rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in, rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
rfbPixelFormat *out) rfbPixelFormat *out)
{ {
CARD8 *redTable; uint8_t *redTable;
CARD8 *greenTable; uint8_t *greenTable;
CARD8 *blueTable; uint8_t *blueTable;
if (*table) free(*table); if (*table) free(*table);
*table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3) *table = (char *)malloc((in->redMax + in->greenMax + in->blueMax + 3)
* 3 + 1); * 3 + 1);
redTable = (CARD8 *)*table; redTable = (uint8_t *)*table;
greenTable = redTable + 3*(in->redMax + 1); greenTable = redTable + 3*(in->redMax + 1);
blueTable = greenTable + 3*(in->greenMax + 1); blueTable = greenTable + 3*(in->greenMax + 1);
...@@ -136,17 +136,17 @@ rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in, ...@@ -136,17 +136,17 @@ rfbInitTrueColourRGBTables24 (char **table, rfbPixelFormat *in,
} }
static void static void
rfbInitOneRGBTable24 (CARD8 *table, int inMax, int outMax, int outShift, rfbInitOneRGBTable24 (uint8_t *table, int inMax, int outMax, int outShift,
int swap) int swap)
{ {
int i; int i;
int nEntries = inMax + 1; int nEntries = inMax + 1;
CARD32 outValue; uint32_t outValue;
CARD8 c; uint8_t c;
for (i = 0; i < nEntries; i++) { for (i = 0; i < nEntries; i++) {
outValue = ((i * outMax + inMax / 2) / inMax) << outShift; outValue = ((i * outMax + inMax / 2) / inMax) << outShift;
*(CARD32 *)&table[3*i] = outValue; *(uint32_t *)&table[3*i] = outValue;
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(table+3*i,table+3*i+1,3); memmove(table+3*i,table+3*i+1,3);
if (swap) { if (swap) {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define SwapOUT(x) CONCAT2E(Swap,OUT(x))
#define rfbInitColourMapSingleTableOUT \ #define rfbInitColourMapSingleTableOUT \
CONCAT2E(rfbInitColourMapSingleTable,OUT) CONCAT2E(rfbInitColourMapSingleTable,OUT)
...@@ -46,9 +46,9 @@ static void ...@@ -46,9 +46,9 @@ static void
rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in, rfbInitColourMapSingleTableOUT(char **table, rfbPixelFormat *in,
rfbPixelFormat *out,rfbColourMap* colourMap) rfbPixelFormat *out,rfbColourMap* colourMap)
{ {
CARD32 i, r, g, b; uint32_t i, r, g, b;
OUT_T *t; OUT_T *t;
CARD32 nEntries = 1 << in->bitsPerPixel; uint32_t nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8; int shift = colourMap->is16?16:8;
if (*table) free(*table); if (*table) free(*table);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define SwapOUT(x) CONCAT2E(Swap,OUT(x)) #define SwapOUT(x) CONCAT2E(Swap,OUT(x))
#define rfbInitTrueColourSingleTableOUT \ #define rfbInitTrueColourSingleTableOUT \
CONCAT2E(rfbInitTrueColourSingleTable,OUT) CONCAT2E(rfbInitTrueColourSingleTable,OUT)
......
...@@ -53,19 +53,19 @@ rfbTranslateWithSingleTable24to24 (char *table, rfbPixelFormat *in, ...@@ -53,19 +53,19 @@ rfbTranslateWithSingleTable24to24 (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines - width * 3; int ipextra = bytesBetweenInputLines - width * 3;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *t = (CARD8 *)table; uint8_t *t = (uint8_t *)table;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
CARD8 c; uint8_t c;
while (height > 0) { while (height > 0) {
opLineEnd = op + width*3; opLineEnd = op + width*3;
while (op < opLineEnd) { while (op < opLineEnd) {
*(CARD32*)op = t[((*(CARD32 *)ip)>>shift)&0x00ffffff]; *(uint32_t*)op = t[((*(uint32_t *)ip)>>shift)&0x00ffffff];
if(!rfbEndianTest) if(!rfbEndianTest)
memmove(op,op+1,3); memmove(op,op+1,3);
if (out->bigEndian != in->bigEndian) { if (out->bigEndian != in->bigEndian) {
...@@ -92,21 +92,21 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in, ...@@ -92,21 +92,21 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *redTable = (CARD8 *)table; uint8_t *redTable = (uint8_t *)table;
CARD8 *greenTable = redTable + 3*(in->redMax + 1); uint8_t *greenTable = redTable + 3*(in->redMax + 1);
CARD8 *blueTable = greenTable + 3*(in->greenMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1);
CARD32 outValue,inValue; uint32_t outValue,inValue;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
while (height > 0) { while (height > 0) {
opLineEnd = op+3*width; opLineEnd = op+3*width;
while (op < opLineEnd) { while (op < opLineEnd) {
inValue = ((*(CARD32 *)ip)>>shift)&0x00ffffff; inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff;
outValue = (redTable[(inValue >> in->redShift) & in->redMax] | outValue = (redTable[(inValue >> in->redShift) & in->redMax] |
greenTable[(inValue >> in->greenShift) & in->greenMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] |
blueTable[(inValue >> in->blueShift) & in->blueMax]); blueTable[(inValue >> in->blueShift) & in->blueMax]);
...@@ -121,8 +121,8 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in, ...@@ -121,8 +121,8 @@ rfbTranslateWithRGBTables24to24 (char *table, rfbPixelFormat *in,
#else #else
#define IN_T CONCAT2E(CARD,BPP) #define IN_T CONCAT3E(uint,BPP,_t)
#define OUT_T CONCAT2E(CARD,BPP) #define OUT_T CONCAT3E(uint,BPP,_t)
#define rfbTranslateWithSingleTable24toOUT \ #define rfbTranslateWithSingleTable24toOUT \
CONCAT4E(rfbTranslateWithSingleTable,24,to,BPP) CONCAT4E(rfbTranslateWithSingleTable,24,to,BPP)
#define rfbTranslateWithSingleTableINto24 \ #define rfbTranslateWithSingleTableINto24 \
...@@ -144,7 +144,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in, ...@@ -144,7 +144,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
OUT_T *op = (OUT_T *)optr; OUT_T *op = (OUT_T *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
OUT_T *opLineEnd; OUT_T *opLineEnd;
...@@ -155,7 +155,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in, ...@@ -155,7 +155,7 @@ rfbTranslateWithSingleTable24toOUT (char *table, rfbPixelFormat *in,
opLineEnd = op + width; opLineEnd = op + width;
while (op < opLineEnd) { while (op < opLineEnd) {
*(op++) = t[((*(CARD32 *)ip)>>shift)&0x00ffffff]; *(op++) = t[((*(uint32_t *)ip)>>shift)&0x00ffffff];
ip+=3; ip+=3;
} }
...@@ -177,21 +177,21 @@ rfbTranslateWithRGBTables24toOUT (char *table, rfbPixelFormat *in, ...@@ -177,21 +177,21 @@ rfbTranslateWithRGBTables24toOUT (char *table, rfbPixelFormat *in,
int bytesBetweenInputLines, int bytesBetweenInputLines,
int width, int height) int width, int height)
{ {
CARD8 *ip = (CARD8 *)iptr; uint8_t *ip = (uint8_t *)iptr;
OUT_T *op = (OUT_T *)optr; OUT_T *op = (OUT_T *)optr;
int ipextra = bytesBetweenInputLines - width*3; int ipextra = bytesBetweenInputLines - width*3;
OUT_T *opLineEnd; OUT_T *opLineEnd;
OUT_T *redTable = (OUT_T *)table; OUT_T *redTable = (OUT_T *)table;
OUT_T *greenTable = redTable + in->redMax + 1; OUT_T *greenTable = redTable + in->redMax + 1;
OUT_T *blueTable = greenTable + in->greenMax + 1; OUT_T *blueTable = greenTable + in->greenMax + 1;
CARD32 inValue; uint32_t inValue;
int shift = rfbEndianTest?0:8; int shift = rfbEndianTest?0:8;
while (height > 0) { while (height > 0) {
opLineEnd = &op[width]; opLineEnd = &op[width];
while (op < opLineEnd) { while (op < opLineEnd) {
inValue = ((*(CARD32 *)ip)>>shift)&0x00ffffff; inValue = ((*(uint32_t *)ip)>>shift)&0x00ffffff;
*(op++) = (redTable[(inValue >> in->redShift) & in->redMax] | *(op++) = (redTable[(inValue >> in->redShift) & in->redMax] |
greenTable[(inValue >> in->greenShift) & in->greenMax] | greenTable[(inValue >> in->greenShift) & in->greenMax] |
blueTable[(inValue >> in->blueShift) & in->blueMax]); blueTable[(inValue >> in->blueShift) & in->blueMax]);
...@@ -215,10 +215,10 @@ rfbTranslateWithSingleTableINto24 (char *table, rfbPixelFormat *in, ...@@ -215,10 +215,10 @@ rfbTranslateWithSingleTableINto24 (char *table, rfbPixelFormat *in,
int width, int height) int width, int height)
{ {
IN_T *ip = (IN_T *)iptr; IN_T *ip = (IN_T *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *t = (CARD8 *)table; uint8_t *t = (uint8_t *)table;
while (height > 0) { while (height > 0) {
opLineEnd = op + width * 3; opLineEnd = op + width * 3;
...@@ -247,13 +247,13 @@ rfbTranslateWithRGBTablesINto24 (char *table, rfbPixelFormat *in, ...@@ -247,13 +247,13 @@ rfbTranslateWithRGBTablesINto24 (char *table, rfbPixelFormat *in,
int width, int height) int width, int height)
{ {
IN_T *ip = (IN_T *)iptr; IN_T *ip = (IN_T *)iptr;
CARD8 *op = (CARD8 *)optr; uint8_t *op = (uint8_t *)optr;
int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width; int ipextra = bytesBetweenInputLines / sizeof(IN_T) - width;
CARD8 *opLineEnd; uint8_t *opLineEnd;
CARD8 *redTable = (CARD8 *)table; uint8_t *redTable = (uint8_t *)table;
CARD8 *greenTable = redTable + 3*(in->redMax + 1); uint8_t *greenTable = redTable + 3*(in->redMax + 1);
CARD8 *blueTable = greenTable + 3*(in->greenMax + 1); uint8_t *blueTable = greenTable + 3*(in->greenMax + 1);
CARD32 outValue; uint32_t outValue;
while (height > 0) { while (height > 0) {
opLineEnd = op+3*width; opLineEnd = op+3*width;
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
#error "It is included as part of translate.c" #error "It is included as part of translate.c"
#endif #endif
#define IN_T CONCAT2E(CARD,IN) #define IN_T CONCAT3E(uint,IN,_t)
#define OUT_T CONCAT2E(CARD,OUT) #define OUT_T CONCAT3E(uint,OUT,_t)
#define rfbTranslateWithSingleTableINtoOUT \ #define rfbTranslateWithSingleTableINtoOUT \
CONCAT4E(rfbTranslateWithSingleTable,IN,to,OUT) CONCAT4E(rfbTranslateWithSingleTable,IN,to,OUT)
#define rfbTranslateWithRGBTablesINtoOUT \ #define rfbTranslateWithRGBTablesINtoOUT \
......
This diff is collapsed.
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
* USA. * USA.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include "rfb.h" #include "rfb.h"
#include "sraRegion.h" #include "sraRegion.h"
...@@ -60,6 +58,8 @@ static const rfbPixelFormat BGR233Format = { ...@@ -60,6 +58,8 @@ static const rfbPixelFormat BGR233Format = {
#define CONCAT2(a,b) a##b #define CONCAT2(a,b) a##b
#define CONCAT2E(a,b) CONCAT2(a,b) #define CONCAT2E(a,b) CONCAT2(a,b)
#define CONCAT3(a,b,c) a##b##c
#define CONCAT3E(a,b,c) CONCAT3(a,b,c)
#define CONCAT4(a,b,c,d) a##b##c##d #define CONCAT4(a,b,c,d) a##b##c##d
#define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d) #define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d)
...@@ -364,7 +364,7 @@ rfbSetClientColourMapBGR233(cl) ...@@ -364,7 +364,7 @@ rfbSetClientColourMapBGR233(cl)
{ {
char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2]; char buf[sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2];
rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf; rfbSetColourMapEntriesMsg *scme = (rfbSetColourMapEntriesMsg *)buf;
CARD16 *rgb = (CARD16 *)(&buf[sz_rfbSetColourMapEntriesMsg]); uint16_t *rgb = (uint16_t *)(&buf[sz_rfbSetColourMapEntriesMsg]);
int i, len; int i, len;
int r, g, b; int r, g, b;
......
...@@ -21,21 +21,27 @@ ...@@ -21,21 +21,27 @@
* vncauth.c - Functions for VNC password management and authentication. * vncauth.c - Functions for VNC password management and authentication.
*/ */
#include <stdio.h> #include "rfb.h"
#include <stdlib.h> #include "d3des.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif
#include <time.h> #include <time.h>
#ifdef WIN32 #ifdef WIN32
#define srandom srand #define srandom srand
#define random rand #define random rand
#else #else
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "rfb.h"
#include "d3des.h"
/* /*
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
* or send email to feedback@developvnc.org. * or send email to feedback@developvnc.org.
*/ */
#include <stdio.h>
#include "rfb.h" #include "rfb.h"
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
// Routines to implement Zlib Run-length Encoding (ZRLE). // Routines to implement Zlib Run-length Encoding (ZRLE).
// //
#include <stdio.h>
extern "C" { extern "C" {
#include "rfb.h" #include "rfb.h"
} }
...@@ -158,7 +157,7 @@ Bool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -158,7 +157,7 @@ Bool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
bytesToCopy = mos.length() - i; bytesToCopy = mos.length() - i;
} }
memcpy(cl->updateBuf+cl->ublen, (CARD8*)mos.data() + i, bytesToCopy); memcpy(cl->updateBuf+cl->ublen, (uint8_t*)mos.data() + i, bytesToCopy);
cl->ublen += bytesToCopy; cl->ublen += bytesToCopy;
i += bytesToCopy; i += bytesToCopy;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment