summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--auth.c2
-rw-r--r--contrib/x11vnc.c8
-rw-r--r--examples/fontsel.c2
-rw-r--r--examples/mac.c2
-rw-r--r--httpd.c20
-rw-r--r--main.c15
-rw-r--r--rfb/rfb.h2
-rwxr-xr-xrfbregion.c2
-rw-r--r--rfbserver.c12
-rw-r--r--rre.c2
-rw-r--r--sockets.c2
-rw-r--r--translate.c8
-rw-r--r--vncterm/LinuxVNC.c8
-rw-r--r--vncterm/VNCommand.c2
-rw-r--r--zlib.c2
16 files changed, 46 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 251947c..22c4d8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/auth.c b/auth.c
index 5b1cda8..ec253dd 100644
--- a/auth.c
+++ b/auth.c
@@ -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");
diff --git a/contrib/x11vnc.c b/contrib/x11vnc.c
index 0616ff1..d37d51a 100644
--- a/contrib/x11vnc.c
+++ b/contrib/x11vnc.c
@@ -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);
}
diff --git a/examples/fontsel.c b/examples/fontsel.c
index 9ff47a6..4aa702c 100644
--- a/examples/fontsel.c
+++ b/examples/fontsel.c
@@ -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);
}
diff --git a/examples/mac.c b/examples/mac.c
index 1730c3d..ca4fe3d 100644
--- a/examples/mac.c
+++ b/examples/mac.c
@@ -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.
diff --git a/httpd.c b/httpd.c
index b7060a1..bae63c5 100644
--- a/httpd.c
+++ b/httpd.c
@@ -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");
}
}
diff --git a/main.c b/main.c
index 8a59d76..a1ae93a 100644
--- a/main.c
+++ b/main.c
@@ -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
}
diff --git a/rfb/rfb.h b/rfb/rfb.h
index 8c22ce1..85d23f3 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -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);
diff --git a/rfbregion.c b/rfbregion.c
index 0d871c4..cfcd510 100755
--- a/rfbregion.c
+++ b/rfbregion.c
@@ -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;
}
diff --git a/rfbserver.c b/rfbserver.c
index c21df14..2644ee7 100644
--- a/rfbserver.c
+++ b/rfbserver.c
@@ -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);
}
diff --git a/rre.c b/rre.c
index c74d224..3e00c05 100644
--- a/rre.c
+++ b/rre.c
@@ -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;
diff --git a/sockets.c b/sockets.c
index 0c6173f..a785904 100644
--- a/sockets.c
+++ b/sockets.c
@@ -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 {
diff --git a/translate.c b/translate.c
index 5f746f0..d5f0896 100644
--- a/translate.c
+++ b/translate.c
@@ -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;
diff --git a/vncterm/LinuxVNC.c b/vncterm/LinuxVNC.c
index dfb961e..0817fbb 100644
--- a/vncterm/LinuxVNC.c
+++ b/vncterm/LinuxVNC.c
@@ -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);
}
diff --git a/vncterm/VNCommand.c b/vncterm/VNCommand.c
index 7292350..358aa1f 100644
--- a/vncterm/VNCommand.c
+++ b/vncterm/VNCommand.c
@@ -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);
}
diff --git a/zlib.c b/zlib.c
index 1231db7..e4ab1bd 100644
--- a/zlib.c
+++ b/zlib.c
@@ -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;
}