Tim's Changes

pull/1/head
dscho 21 years ago
parent 22405c3ddd
commit ff9fbd971b

@ -230,18 +230,18 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt
/*cursor->backRed=cursor->backGreen=cursor->backBlue=0xffff;*/
cursor->foreRed=cursor->foreGreen=cursor->foreBlue=0xffff;
cursor->source = (char*)calloc(w,height);
cursor->source = (unsigned char*)calloc(w,height);
for(j=0,cp=cursorString;j<height;j++)
for(i=0,bit=0x80;i<width;i++,bit=(bit&1)?0x80:bit>>1,cp++)
if(*cp!=' ') cursor->source[j*w+i/8]|=bit;
if(maskString) {
cursor->mask = (char*)calloc(w,height);
cursor->mask = (unsigned char*)calloc(w,height);
for(j=0,cp=maskString;j<height;j++)
for(i=0,bit=0x80;i<width;i++,bit=(bit&1)?0x80:bit>>1,cp++)
if(*cp!=' ') cursor->mask[j*w+i/8]|=bit;
} else
cursor->mask = rfbMakeMaskForXCursor(width,height,cursor->source);
cursor->mask = (unsigned char*)rfbMakeMaskForXCursor(width,height,cursor->source);
return(cursor);
}
@ -291,7 +291,7 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
char *back=(char*)&background;
unsigned char bit;
cursor->source=(char*)calloc(w,cursor->height);
cursor->source=(unsigned char*)calloc(w,cursor->height);
if(format->bigEndian)
back+=4-bpp;
@ -310,10 +310,11 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
rfbPixelFormat* format=&rfbScreen->rfbServerFormat;
int i,j,w=(cursor->width+7)/8,bpp=format->bitsPerPixel/8;
CARD32 background,foreground;
char *cp,*back=(char*)&background,*fore=(char*)&foreground;
char *back=(char*)&background,*fore=(char*)&foreground;
unsigned char *cp;
unsigned char bit;
cp=cursor->richSource=(char*)calloc(cursor->width*bpp,cursor->height);
cp=cursor->richSource=(unsigned char*)calloc(cursor->width*bpp,cursor->height);
if(format->bigEndian) {
back+=4-bpp;

@ -34,7 +34,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
}
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const unsigned char* string,Pixel colour)
int x,int y,const char* string,Pixel colour)
{
while(*string) {
x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour);
@ -100,7 +100,7 @@ int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
}
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,const unsigned char* string,
int x,int y,const char* string,
int x1,int y1,int x2,int y2,
Pixel colour,Pixel backColour)
{
@ -111,7 +111,7 @@ void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
}
}
int rfbWidthOfString(rfbFontDataPtr font,const unsigned char* string)
int rfbWidthOfString(rfbFontDataPtr font,const char* string)
{
int i=0;
while(*string) {
@ -166,7 +166,7 @@ rfbFontDataPtr rfbLoadConsoleFont(char *filename)
if(!f) return(0);
p=(rfbFontDataPtr)malloc(sizeof(rfbFontData));
p->data=(char*)malloc(4096);
p->data=(unsigned char*)malloc(4096);
if(1!=fread(p->data,4096,1,f)) {
free(p->data);
free(p);

@ -113,7 +113,7 @@ httpCheckFds(rfbScreenInfoPtr rfbScreen)
fd_set fds;
struct timeval tv;
struct sockaddr_in addr;
int addrlen = sizeof(addr);
socklen_t addrlen = sizeof(addr);
if (!rfbScreen->httpDir)
return;
@ -196,7 +196,7 @@ static void
httpProcessInput(rfbScreenInfoPtr rfbScreen)
{
struct sockaddr_in addr;
int addrlen = sizeof(addr);
socklen_t addrlen = sizeof(addr);
char fullFname[256];
char *fname;
unsigned int maxFnameLen;

@ -34,11 +34,21 @@
MUTEX(logMutex);
int rfbEnableLogging=1;
/* we cannot compare to _LITTLE_ENDIAN, because some systems
(as Solaris) assume little endian if _LITTLE_ENDIAN is
defined, even if _BYTE_ORDER is not _LITTLE_ENDIAN */
char rfbEndianTest = (_BYTE_ORDER == 1234);
/* from rfbserver.c */
void rfbIncrClientRef(rfbClientPtr cl);
void rfbDecrClientRef(rfbClientPtr cl);
void rfbLogEnable(int enabled) {
rfbEnableLogging=enabled;
}
/*
* rfbLog prints a time-stamped message to the log file (stderr).
*/
@ -50,6 +60,9 @@ rfbLog(const char *format, ...)
char buf[256];
time_t log_clock;
if(!rfbEnableLogging)
return;
LOCK(logMutex);
va_start(args, format);
@ -259,7 +272,9 @@ clientOutput(void *data)
UNLOCK(cl->updateMutex);
/* Now actually send the update. */
rfbIncrClientRef(cl);
rfbSendFramebufferUpdate(cl, updateRegion);
rfbDecrClientRef(cl);
sraRgnDestroy(updateRegion);
}
@ -300,7 +315,7 @@ listenerRun(void *data)
int client_fd;
struct sockaddr_in peer;
rfbClientPtr cl;
int len;
socklen_t len;
len = sizeof(peer);
@ -397,7 +412,7 @@ rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl)
}
/* response is cl->authChallenge vncEncrypted with passwd */
Bool defaultPasswordCheck(rfbClientPtr cl,char* response,int len)
Bool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
{
int i;
char *passwd=vncDecryptPasswdFromFile(cl->screen->rfbAuthPasswdData);
@ -427,7 +442,7 @@ Bool defaultPasswordCheck(rfbClientPtr cl,char* response,int len)
/* for this method, rfbAuthPasswdData is really a pointer to an array
of char*'s, where the last pointer is 0. */
Bool rfbCheckPasswordByList(rfbClientPtr cl,char* response,int len)
Bool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len)
{
char **passwds;

25
rfb.h

@ -47,6 +47,9 @@ typedef unsigned long KeySym;
#define SIGNED signed
/* for some strange reason, "typedef signed char Bool;" yields a four byte
signed int on IRIX, but only for rfbserver.o!!! */
#ifdef Bool
#undef Bool
#endif
#define Bool signed char
#undef FALSE
#define FALSE 0
@ -179,7 +182,7 @@ typedef void (*PtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbCli
typedef void (*SetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl);
typedef struct rfbCursor* (*GetCursorProcPtr) (struct _rfbClientRec* pScreen);
typedef Bool (*SetTranslateFunctionProcPtr)(struct _rfbClientRec* cl);
typedef Bool (*PasswordCheckProcPtr)(struct _rfbClientRec* cl,char* encryptedPassWord,int len);
typedef Bool (*PasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len);
typedef enum rfbNewClientAction (*NewClientHookPtr)(struct _rfbClientRec* cl);
typedef void (*DisplayHookPtr)(struct _rfbClientRec* cl);
@ -261,7 +264,7 @@ typedef struct _rfbScreenInfo
rfbPixelFormat rfbServerFormat;
rfbColourMap colourMap; /* set this if rfbServerFormat.trueColour==FALSE */
char* desktopName;
const char* desktopName;
char rfbThisHost[255];
Bool autoPort;
@ -560,7 +563,8 @@ extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen);
extern void rfbCloseClient(rfbClientPtr cl);
extern int ReadExact(rfbClientPtr cl, char *buf, int len);
extern int WriteExact(rfbClientPtr cl, char *buf, int len);
extern int ReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
extern int WriteExact(rfbClientPtr cl, const char *buf, int len);
extern void rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
extern int ConnectToTcpAddr(char* host, int port);
@ -623,8 +627,8 @@ extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour,
extern int httpPort;
extern char *httpDir;
extern void httpInitSockets();
extern void httpCheckFds();
extern void httpInitSockets(rfbScreenInfoPtr rfbScreen);
extern void httpCheckFds(rfbScreenInfoPtr rfbScreen);
@ -722,11 +726,11 @@ typedef struct rfbFontData {
} rfbFontData,* rfbFontDataPtr;
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,Pixel colour);
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const unsigned char* string,Pixel colour);
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,Pixel colour);
/* if colour==backColour, background is transparent */
int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,int x1,int y1,int x2,int y2,Pixel colour,Pixel backColour);
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const unsigned char* string,int x1,int y1,int x2,int y2,Pixel colour,Pixel backColour);
int rfbWidthOfString(rfbFontDataPtr font,const unsigned char* string);
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,int x1,int y1,int x2,int y2,Pixel colour,Pixel backColour);
int rfbWidthOfString(rfbFontDataPtr font,const char* string);
int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c);
void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2);
/* this returns the smallest box enclosing any character of font. */
@ -759,13 +763,14 @@ extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen,
/* cargs.c */
extern void rfbUsage();
extern void rfbUsage(void);
extern void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]);
extern void rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]);
extern void rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]);
/* main.c */
extern void rfbLogEnable(int enabled);
extern void rfbLog(const char *format, ...);
extern void rfbLogPerror(const char *str);
@ -781,7 +786,7 @@ void doNothingWithClient(rfbClientPtr cl);
enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl);
/* to check against plain passwords */
Bool rfbCheckPasswordByList(rfbClientPtr cl,char* response,int len);
Bool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len);
/* functions to make a vnc server */
extern rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,

@ -71,6 +71,9 @@ void rfbDecrClientRef(rfbClientPtr cl)
TSIGNAL(cl->deleteCond);
UNLOCK(cl->refCountMutex);
}
#else
void rfbIncrClientRef(rfbClientPtr cl) {}
void rfbDecrClientRef(rfbClientPtr cl) {}
#endif
MUTEX(rfbClientListMutex);
@ -190,7 +193,7 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
rfbClientIteratorPtr iterator;
rfbClientPtr cl,cl_;
struct sockaddr_in addr;
int addrlen = sizeof(struct sockaddr_in);
socklen_t addrlen = sizeof(struct sockaddr_in);
int i;
cl = (rfbClientPtr)calloc(sizeof(rfbClientRec),1);
@ -529,7 +532,7 @@ rfbProcessClientInitMessage(cl)
si->format.blueMax = Swap16IfLE(si->format.blueMax);
if (strlen(cl->screen->desktopName) > 128) /* sanity check on desktop name len */
cl->screen->desktopName[128] = 0;
((char*)cl->screen->desktopName)[128] = 0;
strcpy(buf + sz_rfbServerInitMsg, cl->screen->desktopName);
len = strlen(buf + sz_rfbServerInitMsg);

@ -180,7 +180,7 @@ rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec)
fd_set fds;
struct timeval tv;
struct sockaddr_in addr;
int addrlen = sizeof(addr);
socklen_t addrlen = sizeof(addr);
char buf[6];
const int one = 1;
int sock;
@ -311,6 +311,7 @@ rfbCloseClient(cl)
LOCK(cl->updateMutex);
if (cl->sock != -1) {
FD_CLR(cl->sock,&(cl->screen->allFds));
shutdown(cl->sock,SHUT_RDWR);
close(cl->sock);
cl->sock = -1;
}
@ -369,10 +370,7 @@ rfbConnect(rfbScreen, host, port)
*/
int
ReadExact(cl, buf, len)
rfbClientPtr cl;
char *buf;
int len;
ReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
{
int sock = cl->sock;
int n;
@ -401,8 +399,8 @@ ReadExact(cl, buf, len)
FD_ZERO(&fds);
FD_SET(sock, &fds);
tv.tv_sec = rfbMaxClientWait / 1000;
tv.tv_usec = (rfbMaxClientWait % 1000) * 1000;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
n = select(sock+1, &fds, NULL, &fds, &tv);
if (n < 0) {
rfbLogPerror("ReadExact: select");
@ -417,7 +415,10 @@ ReadExact(cl, buf, len)
return 1;
}
int ReadExact(rfbClientPtr cl,char* buf,int len)
{
return(ReadExactTimeout(cl,buf,len,rfbMaxClientWait));
}
/*
* WriteExact writes an exact number of bytes to a client. Returns 1 if
@ -428,7 +429,7 @@ ReadExact(cl, buf, len)
int
WriteExact(cl, buf, len)
rfbClientPtr cl;
char *buf;
const char *buf;
int len;
{
int sock = cl->sock;
@ -535,7 +536,7 @@ ConnectToTcpAddr(host, port)
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if ((addr.sin_addr.s_addr = inet_addr(host)) == -1)
if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)
{
if (!(hp = gethostbyname(host))) {
errno = EINVAL;

@ -172,9 +172,6 @@ sraSpanListMakeEmpty(sraSpanList *list) {
list->back._next = NULL;
}
int sraMax(int a, int b) {return (a>b)?a:b;}
int sraMin(int a, int b) {return (a<b)?a:b;}
Bool
sraSpanListEqual(const sraSpanList *s1, const sraSpanList *s2) {
sraSpan *sp1, *sp2;

@ -27,7 +27,7 @@
#include <stdlib.h>
#include "rfb.h"
static char* encNames[] = {
static const char* encNames[] = {
"raw", "copyRect", "RRE", "[encoding 3]", "CoRRE", "hextile",
"zlib", "tight", "[encoding 8]", "[encoding 9]"
};

@ -34,7 +34,7 @@ rfbInitColourMapSingleTable24(char **table, rfbPixelFormat *in,
CARD32 i, r, g, b, outValue;
CARD8 *t;
CARD8 c;
int nEntries = 1 << in->bitsPerPixel;
unsigned int nEntries = 1 << in->bitsPerPixel;
int shift = colourMap->is16?16:8;
if (*table) free(*table);

@ -449,9 +449,9 @@ CheckSolidTile(cl, x, y, w, h, colorPtr, needSameColor)
#define DEFINE_CHECK_SOLID_FUNCTION(bpp) \
\
static Bool \
CheckSolidTile##bpp(cl, x, y, w, h, colorPtr, needSameColor) \
CheckSolidTile##bpp(cl, x, y, w, h, colorPtr, needSameColor) \
rfbClientPtr cl; \
int x, y; \
int x, y, w, h; \
CARD32 *colorPtr; \
Bool needSameColor; \
{ \

@ -29,7 +29,7 @@
#include "sraRegion.h"
static void PrintPixelFormat(rfbPixelFormat *pf);
static Bool rfbSetClientColourMapBGR233();
static Bool rfbSetClientColourMapBGR233(rfbClientPtr cl);
Bool rfbEconomicTranslate = FALSE;
@ -38,7 +38,7 @@ Bool rfbEconomicTranslate = FALSE;
*/
static const rfbPixelFormat BGR233Format = {
8, 8, 0, 1, 7, 7, 3, 0, 3, 6
8, 8, 0, 1, 7, 7, 3, 0, 3, 6, 0, 0
};

Loading…
Cancel
Save