rfbErr introduced

pull/1/head
dscho 21 years ago
parent 79c414ab99
commit 4fcb60871b

@ -1,3 +1,4 @@
introduce rfbErr for Errors (Erik)
make rfbLog overridable (suggested by Erik)
don't reutrn on EINTR in WriteExact()/ReadExact() (suggested by Erik)
use AX_PREFIX_CONFIG_H to prefix constants in config.h to avoid

@ -83,7 +83,7 @@ rfbAuthProcessClientMessage(cl)
}
if(!cl->screen->passwordCheck(cl,(const char*)response,CHALLENGESIZE)) {
rfbLog("rfbAuthProcessClientMessage: password check failed\n");
rfbErr("rfbAuthProcessClientMessage: password check failed\n");
authResult = Swap32IfLE(rfbVncAuthFailed);
if (WriteExact(cl, (char *)&authResult, 4) < 0) {
rfbLogPerror("rfbAuthProcessClientMessage: write");

@ -1135,7 +1135,7 @@ void shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
xim = XShmCreateImage(dpy, visual, bpp, ZPixmap, NULL, shm, w, h);
if (xim == NULL) {
rfbLog( "XShmCreateImage(%s) failed.\n", name);
rfbErr( "XShmCreateImage(%s) failed.\n", name);
exit(1);
}
@ -1145,7 +1145,7 @@ void shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
xim->bytes_per_line * xim->height, IPC_CREAT | 0777);
if (shm->shmid == -1) {
rfbLog("shmget(%s) failed.\n", name);
rfbErr("shmget(%s) failed.\n", name);
perror("shmget");
exit(1);
}
@ -1153,7 +1153,7 @@ void shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
shm->shmaddr = xim->data = (char *) shmat(shm->shmid, 0, 0);
if (shm->shmaddr == (char *)-1) {
rfbLog("shmat(%s) failed.\n", name);
rfbErr("shmat(%s) failed.\n", name);
perror("shmat");
exit(1);
}
@ -1161,7 +1161,7 @@ void shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
shm->readOnly = False;
if (! XShmAttach(dpy, shm)) {
rfbLog("XShmAttach(%s) failed.\n", name);
rfbErr("XShmAttach(%s) failed.\n", name);
exit(1);
}

@ -54,7 +54,7 @@ int main(int argc,char** argv)
rfbScreen = s;
font=rfbLoadConsoleFont(DEFAULTFONT);
if(!font) {
rfbLog("Couldn't find %s\n",DEFAULTFONT);
rfbErr("Couldn't find %s\n",DEFAULTFONT);
exit(1);
}

@ -410,7 +410,7 @@ KbdAddEvent(rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl)
}
if (!found) {
rfbLog("warning: couldn't figure out keycode for X keysym %d (0x%x)\n",
rfbErr("warning: couldn't figure out keycode for X keysym %d (0x%x)\n",
(int)keySym, (int)keySym);
} else {
/* Hopefully I can get away with not specifying a CGCharCode.

@ -223,7 +223,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
cl.sock=rfbScreen->httpSock;
if (strlen(rfbScreen->httpDir) > 255) {
rfbLog("-httpd directory too long\n");
rfbErr("-httpd directory too long\n");
httpCloseSock(rfbScreen);
return;
}
@ -238,7 +238,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
ssize_t got;
if (buf_filled > sizeof (buf)) {
rfbLog("httpProcessInput: HTTP request is too long\n");
rfbErr("httpProcessInput: HTTP request is too long\n");
httpCloseSock(rfbScreen);
return;
}
@ -248,7 +248,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
if (got <= 0) {
if (got == 0) {
rfbLog("httpd: premature connection close\n");
rfbErr("httpd: premature connection close\n");
} else {
if (errno == EAGAIN) {
return;
@ -274,7 +274,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
const static char* PROXY_OK_STR = "HTTP/1.0 200 OK\r\nContent-Type: octet-stream\r\nPragma: no-cache\r\n\r\n";
if(!strncmp(buf, "CONNECT ", 8)) {
if(atoi(strchr(buf, ':')+1)!=rfbScreen->rfbPort) {
rfbLog("httpd: CONNECT format invalid.\n");
rfbErr("httpd: CONNECT format invalid.\n");
WriteExact(&cl,INVALID_REQUEST_STR, strlen(INVALID_REQUEST_STR));
httpCloseSock(rfbScreen);
return;
@ -297,7 +297,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
}
if (strncmp(buf, "GET ", 4)) {
rfbLog("httpd: no GET line\n");
rfbErr("httpd: no GET line\n");
httpCloseSock(rfbScreen);
return;
} else {
@ -306,26 +306,26 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
}
if (strlen(buf) > maxFnameLen) {
rfbLog("httpd: GET line too long\n");
rfbErr("httpd: GET line too long\n");
httpCloseSock(rfbScreen);
return;
}
if (sscanf(buf, "GET %s HTTP/1.0", fname) != 1) {
rfbLog("httpd: couldn't parse GET line\n");
rfbErr("httpd: couldn't parse GET line\n");
httpCloseSock(rfbScreen);
return;
}
if (fname[0] != '/') {
rfbLog("httpd: filename didn't begin with '/'\n");
rfbErr("httpd: filename didn't begin with '/'\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
}
if (strchr(fname+1, '/') != NULL) {
rfbLog("httpd: asking for file in other directory\n");
rfbErr("httpd: asking for file in other directory\n");
WriteExact(&cl, NOT_FOUND_STR, strlen(NOT_FOUND_STR));
httpCloseSock(rfbScreen);
return;
@ -343,7 +343,7 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen)
*ptr = '\0';
if (!parseParams(&ptr[1], params, 1024)) {
params[0] = '\0';
rfbLog("httpd: bad parameters in the URL\n");
rfbErr("httpd: bad parameters in the URL\n");
}
}

@ -83,10 +83,11 @@ rfbDefaultLog(const char *format, ...)
}
rfbLogProc rfbLog=rfbDefaultLog;
rfbLogProc rfbErr=rfbDefaultLog;
void rfbLogPerror(const char *str)
{
rfbLog("%s: %s\n", str, strerror(errno));
rfbErr("%s: %s\n", str, strerror(errno));
}
void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy)
@ -442,7 +443,7 @@ rfbBool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
char *passwd=vncDecryptPasswdFromFile(cl->screen->rfbAuthPasswdData);
if(!passwd) {
rfbLog("Couldn't read password file: %s\n",cl->screen->rfbAuthPasswdData);
rfbErr("Couldn't read password file: %s\n",cl->screen->rfbAuthPasswdData);
return(FALSE);
}
@ -456,7 +457,7 @@ rfbBool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
free(passwd);
if (memcmp(cl->authChallenge, response, len) != 0) {
rfbLog("rfbAuthProcessClientMessage: authentication failed from %s\n",
rfbErr("rfbAuthProcessClientMessage: authentication failed from %s\n",
cl->host);
return(FALSE);
}
@ -481,7 +482,7 @@ rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len)
}
}
rfbLog("rfbAuthProcessClientMessage: authentication failed from %s\n",
rfbErr("rfbAuthProcessClientMessage: authentication failed from %s\n",
cl->host);
return(FALSE);
}
@ -550,7 +551,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
INIT_MUTEX(logMutex);
if(width&3)
rfbLog("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);
rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);
rfbScreen->autoPort=FALSE;
rfbScreen->rfbClientHead=0;
@ -667,7 +668,7 @@ void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
old_format = rfbScreen->rfbServerFormat;
if (width & 3)
rfbLog("WARNING: New width (%d) is not a multiple of 4.\n", width);
rfbErr("WARNING: New width (%d) is not a multiple of 4.\n", width);
rfbScreen->width = width;
rfbScreen->height = height;
@ -826,7 +827,7 @@ void rfbRunEventLoop(rfbScreenInfoPtr rfbScreen, long usec, rfbBool runInBackgro
pthread_create(&listener_thread, NULL, listenerRun, rfbScreen);
return;
#else
rfbLog("Can't run in background, because I don't have PThreads!\n");
rfbErr("Can't run in background, because I don't have PThreads!\n");
return;
#endif
}

@ -730,7 +730,7 @@ extern rfbBool rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc
extern void rfbLogEnable(int enabled);
typedef void (*rfbLogProc)(const char *format, ...);
extern rfbLogProc rfbLog;
extern rfbLogProc rfbLog, rfbErr;
extern void rfbLogPerror(const char *str);
void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy);

@ -759,7 +759,7 @@ rfbBool sraRgnIteratorNext(sraRectangleIterator* i,sraRect* r)
}
if((i->ptrPos%4)!=2) {
rfbLog("sraRgnIteratorNext: offset is wrong (%d%%4!=2)\n",i->ptrPos);
rfbErr("sraRgnIteratorNext: offset is wrong (%d%%4!=2)\n",i->ptrPos);
return FALSE;
}

@ -521,7 +521,7 @@ rfbProcessClientProtocolVersion(cl)
if (sscanf(pv,rfbProtocolVersionFormat,&major_,&minor_) != 2) {
char name[1024];
if(sscanf(pv,"RFB %03d.%03d %1024s\n",&major_,&minor_,name) != 3) {
rfbLog("rfbProcessClientProtocolVersion: not a valid RFB client\n");
rfbErr("rfbProcessClientProtocolVersion: not a valid RFB client\n");
rfbCloseClient(cl);
return;
}
@ -533,7 +533,7 @@ rfbProcessClientProtocolVersion(cl)
if (major_ != rfbProtocolMajorVersion) {
/* Major version mismatch - send a ConnFailed message */
rfbLog("Major version mismatch\n");
rfbErr("Major version mismatch\n");
sprintf(failureReason,
"RFB protocol version mismatch - server %d.%d, client %d.%d",
rfbProtocolMajorVersion,rfbProtocolMinorVersion,major_,minor_);
@ -1448,7 +1448,7 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
nlines = (UPDATE_BUF_SIZE - cl->ublen) / bytesPerLine;
if (nlines == 0) {
rfbLog("rfbSendRectEncodingRaw: send buffer too small for %d "
rfbErr("rfbSendRectEncodingRaw: send buffer too small for %d "
"bytes per line\n", bytesPerLine);
rfbCloseClient(cl);
return FALSE;
@ -1698,7 +1698,7 @@ rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen)
case rfbKeyEvent:
if (n != sz_rfbKeyEventMsg) {
rfbLog("rfbProcessUDPInput: key event incorrect length\n");
rfbErr("rfbProcessUDPInput: key event incorrect length\n");
rfbDisconnectUDPSock(rfbScreen);
return;
}
@ -1707,7 +1707,7 @@ rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen)
case rfbPointerEvent:
if (n != sz_rfbPointerEventMsg) {
rfbLog("rfbProcessUDPInput: ptr event incorrect length\n");
rfbErr("rfbProcessUDPInput: ptr event incorrect length\n");
rfbDisconnectUDPSock(rfbScreen);
return;
}
@ -1716,7 +1716,7 @@ rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen)
break;
default:
rfbLog("rfbProcessUDPInput: unknown message type %d\n",
rfbErr("rfbProcessUDPInput: unknown message type %d\n",
msg.type);
rfbDisconnectUDPSock(rfbScreen);
}

@ -307,7 +307,7 @@ getBgColour(data,size,bpp)
for (j=0; j<size; j++) {
k = (int)(((uint8_t *)data)[j]);
if (k >= NUMCLRS) {
rfbLog("getBgColour: unusual colour = %d\n", k);
rfbErr("getBgColour: unusual colour = %d\n", k);
return 0;
}
counts[k] += 1;

@ -474,7 +474,7 @@ WriteExact(cl, buf, len)
} else if (n == 0) {
rfbLog("WriteExact: write returned 0?\n");
rfbErr("WriteExact: write returned 0?\n");
return 0;
} else {

@ -259,7 +259,7 @@ rfbSetTranslateFunction(cl)
#endif
(cl->screen->rfbServerFormat.bitsPerPixel != 32))
{
rfbLog("%s: server bits per pixel not 8, 16 or 32 (is %d)\n",
rfbErr("%s: server bits per pixel not 8, 16 or 32 (is %d)\n",
"rfbSetTranslateFunction",
cl->screen->rfbServerFormat.bitsPerPixel);
rfbCloseClient(cl);
@ -273,14 +273,14 @@ rfbSetTranslateFunction(cl)
#endif
(cl->format.bitsPerPixel != 32))
{
rfbLog("%s: client bits per pixel not 8, 16 or 32\n",
rfbErr("%s: client bits per pixel not 8, 16 or 32\n",
"rfbSetTranslateFunction");
rfbCloseClient(cl);
return FALSE;
}
if (!cl->format.trueColour && (cl->format.bitsPerPixel != 8)) {
rfbLog("rfbSetTranslateFunction: client has colour map "
rfbErr("rfbSetTranslateFunction: client has colour map "
"but %d-bit - can only cope with 8-bit colour maps\n",
cl->format.bitsPerPixel);
rfbCloseClient(cl);
@ -369,7 +369,7 @@ rfbSetClientColourMapBGR233(cl)
int r, g, b;
if (cl->format.bitsPerPixel != 8 ) {
rfbLog("%s: client not 8 bits per pixel\n",
rfbErr("%s: client not 8 bits per pixel\n",
"rfbSetClientColourMapBGR233");
rfbCloseClient(cl);
return FALSE;

@ -57,7 +57,7 @@ void do_key(rfbBool down,rfbKeySym keySym,rfbClientPtr cl)
tty_inject_device=open(device,O_WRONLY);
ret=ioctl(tty_inject_device,TIOCSTI,&keySym);
if(ret<0)
rfbLog("Couldn't reopen device %s!\n",device);
rfbErr("Couldn't reopen device %s!\n",device);
}
}
}
@ -88,7 +88,7 @@ int main(int argc,char **argv)
if(argc>1) {
if((tty=atoi(argv[1]))<1) {
rfbLog("Usage: %s [tty_number [vnc args]]\n",argv[0]);
rfbErr("Usage: %s [tty_number [vnc args]]\n",argv[0]);
exit(1);
} else {
argv++;
@ -100,7 +100,7 @@ int main(int argc,char **argv)
sprintf(tty_device,"/dev/tty%d",tty);
if((tty_inject_device=open(tty_device,O_WRONLY))<0) {
rfbLog("Couldn't open tty device %s!\n",tty_device);
rfbErr("Couldn't open tty device %s!\n",tty_device);
exit(1);
}
rfbLog("Using device %s.\n",tty_device);
@ -142,7 +142,7 @@ int main(int argc,char **argv)
if(!console->currentlyMarking) {
tty_file=fopen(tty_device,"rb");
if(!tty_file) {
rfbLog("cannot open device \"%s\"\n",
rfbErr("cannot open device \"%s\"\n",
tty_device);
exit(1);
}

@ -35,7 +35,7 @@ int main(int argc, char **argv)
if(programArg0<argc) {
int in[2],out[2],err[2],pid;
if(pipe(in)<0 || pipe(out)<0 || pipe(err)<0) {
rfbLog("Couldn't make pipes!");
rfbErr("Couldn't make pipes!");
return(1);
}

@ -164,7 +164,7 @@ rfbSendOneRectEncodingZlib(cl, x, y, w, h)
zlibAfterBufLen = cl->compStream.total_out - previousOut;
if ( deflateResult != Z_OK ) {
rfbLog("zlib deflation error: %s\n", cl->compStream.msg);
rfbErr("zlib deflation error: %s\n", cl->compStream.msg);
return FALSE;
}

Loading…
Cancel
Save