From a71c28313e3e3ef0f2e235f78eaf38fca52deb1f Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Thu, 10 Aug 2000 09:44:09 +0000 Subject: [lcd4linux @ 2000-08-10 09:44:09 by reinelt] new debugging scheme: error(), info(), debug() uses syslog if in daemon mode --- BeckmannEgle.c | 45 +- Crystalfontz.c | 48 +- HD44780.c | 41 +- Makefile.am | 2 +- Makefile.in | 18 +- MatrixOrbital.c | 41 +- PalmPilot.c | 41 +- README | 4 +- Raster.c | 40 +- Skeleton.c | 10 +- XWindow.c | 34 +- cfg.c | 10 +- debug.h | 14 +- display.c | 11 +- fontmap.c | 1623 ++++++++++++++++++++++++++++--------------------------- isdn.c | 21 +- lcd4linux.c | 45 +- lock.c | 28 +- parser.c | 24 +- processor.c | 11 +- system.c | 119 ++-- 21 files changed, 1162 insertions(+), 1068 deletions(-) diff --git a/BeckmannEgle.c b/BeckmannEgle.c index c660bf9..d434092 100644 --- a/BeckmannEgle.c +++ b/BeckmannEgle.c @@ -1,4 +1,4 @@ -/* $Id: BeckmannEgle.c,v 1.3 2000/08/09 09:50:29 reinelt Exp $ +/* $Id: BeckmannEgle.c,v 1.4 2000/08/10 09:44:09 reinelt Exp $ * * driver for Beckmann+Egle mini terminals * @@ -20,6 +20,11 @@ * * * $Log: BeckmannEgle.c,v $ + * Revision 1.4 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.3 2000/08/09 09:50:29 reinelt * * opened 0.98 development @@ -120,25 +125,25 @@ static int BE_open (void) if ((pid=lock_port(Port))!=0) { if (pid==-1) - fprintf (stderr, "BeckmannEgle: port %s could not be locked\n", Port); + error ("BeckmannEgle: port %s could not be locked", Port); else - fprintf (stderr, "BeckmannEgle: port %s is locked by process %d\n", Port, pid); + error ("BeckmannEgle: port %s is locked by process %d", Port, pid); return -1; } fd = open(Port, O_RDWR | O_NOCTTY | O_NDELAY); if (fd==-1) { - fprintf (stderr, "BeckmannEgle: open(%s) failed: %s\n", Port, strerror(errno)); + error ("BeckmannEgle: open(%s) failed: %s", Port, strerror(errno)); return -1; } if (tcgetattr(fd, &portset)==-1) { - fprintf (stderr, "BeckmannEgle: tcgetattr(%s) failed: %s\n", Port, strerror(errno)); + error ("BeckmannEgle: tcgetattr(%s) failed: %s", Port, strerror(errno)); return -1; } cfmakeraw(&portset); // 8N1 portset.c_cflag |= CSTOPB; // 2 stop bits cfsetospeed(&portset, B9600); // 9600 baud if (tcsetattr(fd, TCSANOW, &portset)==-1) { - fprintf (stderr, "BeckmannEgle: tcsetattr(%s) failed: %s\n", Port, strerror(errno)); + error ("BeckmannEgle: tcsetattr(%s) failed: %s", Port, strerror(errno)); return -1; } return fd; @@ -152,7 +157,7 @@ static void BE_write (char *string, int len) usleep(1000); if (write (Device, string, len)>=0) return; } - fprintf (stderr, "BeckmannEgle: write(%s) failed: %s\n", Port, strerror(errno)); + error ("BeckmannEgle: write(%s) failed: %s", Port, strerror(errno)); } } @@ -216,13 +221,13 @@ static void BE_compact_bars (void) int i, j, r, c, min; int pack_i, pack_j; int pass1=1; - int error[nSegment][nSegment]; + int deviation[nSegment][nSegment]; if (nSegment>CHARS+2) { for (i=2; irows=rows; Self->cols=cols; @@ -530,7 +535,7 @@ int BE_flush (void) int BE_quit (void) { - debug ("closing port %s\n", Port); + debug ("closing port %s", Port); close (Device); unlock_port(Port); return 0; diff --git a/Crystalfontz.c b/Crystalfontz.c index 9b3c370..f3aea30 100644 --- a/Crystalfontz.c +++ b/Crystalfontz.c @@ -1,4 +1,4 @@ -/* $Id: Crystalfontz.c,v 1.4 2000/08/09 09:50:29 reinelt Exp $ +/* $Id: Crystalfontz.c,v 1.5 2000/08/10 09:44:09 reinelt Exp $ * * driver for display modules from Crystalfontz * @@ -19,6 +19,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: Crystalfontz.c,v $ + * Revision 1.5 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.4 2000/08/09 09:50:29 reinelt * * opened 0.98 development @@ -65,7 +70,7 @@ static char isAnyBarDirty; int cryfonquit(void) { - debug ("closing port %s\n", Port); + debug ("closing port %s", Port); close(Device); unlock_port(Port); exit(0); @@ -77,26 +82,23 @@ pid_t pid; struct termios portset; if ((pid=lock_port(Port))!=0) { - if (pid==-1) fprintf(stderr,"Crystalfontz: port %s could not be locked\n",Port); - else fprintf(stderr,"Crystalfontz: port %s is locked by process %d\n",Port,pid); + if (pid==-1) error ("Crystalfontz: port %s could not be locked",Port); + else error ("Crystalfontz: port %s is locked by process %d",Port,pid); return -1; } fd=open(Port,O_RDWR|O_NOCTTY|O_NDELAY); if (fd==-1) { - fprintf(stderr,"Crystalfontz: open(%s) failed: %s\n", - Port,strerror(errno)); + error ("Crystalfontz: open(%s) failed: %s", Port, strerror(errno)); return -1; } if (tcgetattr(fd,&portset)==-1) { - fprintf(stderr,"Crystalfontz: tcgetattr(%s) failed: %s\n", - Port,strerror(errno)); + error ("Crystalfontz: tcgetattr(%s) failed: %s", Port, strerror(errno)); return -1; } cfmakeraw(&portset); cfsetospeed(&portset,Speed); if (tcsetattr(fd, TCSANOW, &portset)==-1) { - fprintf(stderr,"Crystalfontz: tcsetattr(%s) failed: %s\n", - Port,strerror(errno)); + error ("Crystalfontz: tcsetattr(%s) failed: %s", Port, strerror(errno)); return -1; } return fd; @@ -118,8 +120,7 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; } if ((port=cfg_get("Port"))==NULL || *port=='\0') { - fprintf(stderr,"CrystalFontz: no 'Port' entry in %s\n", - cfg_file()); + error ("CrystalFontz: no 'Port' entry in %s", cfg_file()); return -1; } if (port[0]=='/') Port=strdup(port); @@ -143,12 +144,11 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; Speed=B19200; break; default: - fprintf(stderr,"CrystalFontz: unsupported speed '%s' in '%s'\n", - speed,cfg_file()); + error ("CrystalFontz: unsupported speed '%s' in '%s'", speed, cfg_file()); return -1; } - debug ("using port %s at %d baud\n", Port, atoi(speed)); + debug ("using port %s at %d baud", Port, atoi(speed)); if ((Device=cryfonopen())==-1) return -1; @@ -158,32 +158,32 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; Txtbuf=(char *)malloc(tdim); if (Txtbuf==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } CustCharMap=(char *)malloc(tdim); if (CustCharMap==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } BackupTxtbuf=(char *)malloc(tdim); if (BackupTxtbuf==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } Barbuf=(char *)malloc(bdim); if (Barbuf==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } BackupBarbuf=(char *)malloc(bdim); if (BackupBarbuf==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } isBarDirty=(char *)malloc(Lcd.rows); if (isBarDirty==NULL) { - fprintf(stderr,"CrystalFontz: out of memory\n"); + error ("CrystalFontz: out of memory"); return -1; } memset(Txtbuf,' ',tdim); @@ -444,7 +444,7 @@ int x; } /* else: internal consistency failure */ else { - printf("Crystalfontz: internal consistency failure 1\n"); + error ("Crystalfontz: internal consistency failure 1"); exit(0); } } @@ -457,7 +457,7 @@ int ci,x; CustCharMap[x]=-1; cust_chars[ci].use_count--; if (cust_chars[i].use_count==-1) { - printf("Crystalfontz: internal consistency failure 2\n"); + error ("Crystalfontz: internal consistency failure 2"); exit(0); } } @@ -520,7 +520,7 @@ int i,j,k1,k2,ci; writeChar(i,j,128+ci); use_cust_char(i,j,ci); } - else printf("failed to alloc a custom char\n"); + else error ("failed to alloc a custom char"); } } BackupBarbuf[k1]=c1; diff --git a/HD44780.c b/HD44780.c index a31db00..27000ee 100644 --- a/HD44780.c +++ b/HD44780.c @@ -1,4 +1,4 @@ -/* $Id: HD44780.c,v 1.7 2000/08/09 09:50:29 reinelt Exp $ +/* $Id: HD44780.c,v 1.8 2000/08/10 09:44:09 reinelt Exp $ * * driver for display modules based on the HD44780 chip * @@ -20,6 +20,11 @@ * * * $Log: HD44780.c,v $ + * Revision 1.8 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.7 2000/08/09 09:50:29 reinelt * * opened 0.98 development @@ -145,9 +150,9 @@ static void HD_write (char *string, int len, int delay) static int HD_open (void) { - debug ("using port 0x%x\n", Port); + debug ("using port 0x%x", Port); if (ioperm(Port, 3, 1)!=0) { - fprintf (stderr, "HD44780: ioperm(0x%x) failed: %s\n", Port, strerror(errno)); + error ("HD44780: ioperm(0x%x) failed: %s", Port, strerror(errno)); return -1; } @@ -222,13 +227,13 @@ static void HD_compact_bars (void) int i, j, r, c, min; int pack_i, pack_j; int pass1=1; - int error[nSegment][nSegment]; + int deviation[nSegment][nSegment]; if (nSegment>CHARS+2) { for (i=2; i=0) return; } - fprintf (stderr, "MatrixOrbital: write(%s) failed: %s\n", Port, strerror(errno)); + error ("MatrixOrbital: write(%s) failed: %s", Port, strerror(errno)); } } @@ -268,13 +273,13 @@ static void MO_compact_bars (void) int i, j, r, c, min; int pack_i, pack_j; int pass1=1; - int error[nSegment][nSegment]; + int deviation[nSegment][nSegment]; if (nSegment>CHARS+2) { for (i=2; i=0) return; } - fprintf (stderr, "PalmPilot: write(%s) failed: %s\n", Port, strerror(errno)); + error ("PalmPilot: write(%s) failed: %s", Port, strerror(errno)); } } @@ -124,14 +129,14 @@ int Palm_flush (void) if (bitbuf==NULL) { if ((bitbuf=malloc(xsize*ysize*sizeof(*bitbuf)))==NULL) { - fprintf (stderr, "PalmPilot: malloc(%d) failed: %s\n", xsize*ysize*sizeof(*bitbuf), strerror(errno)); + error ("PalmPilot: malloc(%d) failed: %s", xsize*ysize*sizeof(*bitbuf), strerror(errno)); return -1; } } if (rowbuf==NULL) { if ((rowbuf=malloc(((xsize+7)/8)*sizeof(*rowbuf)))==NULL) { - fprintf (stderr, "PalmPilot: malloc(%d) failed: %s\n", ((xsize+7)/8)*sizeof(*rowbuf), strerror(errno)); + error ("PalmPilot: malloc(%d) failed: %s", ((xsize+7)/8)*sizeof(*rowbuf), strerror(errno)); return -1; } } @@ -186,7 +191,7 @@ int Palm_init (LCD *Self) port=cfg_get ("Port"); if (port==NULL || *port=='\0') { - fprintf (stderr, "PalmPilot: no 'Port' entry in %s\n", cfg_file()); + error ("PalmPilot: no 'Port' entry in %s", cfg_file()); return -1; } Port=strdup(port); @@ -210,29 +215,29 @@ int Palm_init (LCD *Self) Speed=B19200; break; default: - fprintf (stderr, "PalmPilot: unsupported speed '%s' in %s\n", speed, cfg_file()); + error ("PalmPilot: unsupported speed '%s' in %s", speed, cfg_file()); return -1; } - debug ("using port %s at %d baud\n", Port, atoi(speed)); + debug ("using port %s at %d baud", Port, atoi(speed)); if (sscanf(s=cfg_get("size")?:"20x4", "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { - fprintf (stderr, "PalmPilot: bad size '%s'\n", s); + error ("PalmPilot: bad size '%s'", s); return -1; } if (sscanf(s=cfg_get("font")?:"6x8", "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { - fprintf (stderr, "PalmPilot: bad font '%s'\n", s); + error ("PalmPilot: bad font '%s'", s); return -1; } if (sscanf(s=cfg_get("pixel")?:"1+0", "%d+%d", &pixel, &pgap)!=2 || pixel<1 || pgap<0) { - fprintf (stderr, "PalmPilot: bad pixel '%s'\n", s); + error ("PalmPilot: bad pixel '%s'", s); return -1; } if (sscanf(s=cfg_get("gap")?:"0x0", "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { - fprintf (stderr, "PalmPilot: bad gap '%s'\n", s); + error ("PalmPilot: bad gap '%s'", s); return -1; } if (rgap<0) rgap=pixel+pgap; @@ -241,7 +246,7 @@ int Palm_init (LCD *Self) border=atoi(cfg_get("border")?:"0"); if (pix_init (rows, cols, xres, yres)!=0) { - fprintf (stderr, "PalmPilot: pix_init(%d, %d, %d, %d) failed\n", rows, cols, xres, yres); + error ("PalmPilot: pix_init(%d, %d, %d, %d) failed", rows, cols, xres, yres); return -1; } @@ -272,7 +277,7 @@ int Palm_bar (int type, int row, int col, int max, int len1, int len2) int Palm_quit (void) { - debug ("closing port %s\n", Port); + debug ("closing port %s", Port); close (Device); unlock_port (Port); return 0; diff --git a/README b/README index 2000a02..a0d49a6 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ # -# $Id: README,v 1.8 2000/08/09 14:14:11 reinelt Exp $ +# $Id: README,v 1.9 2000/08/10 09:44:09 reinelt Exp $ # This is the README file for lcd4linux @@ -32,7 +32,7 @@ do not fork and detach with '-F' use configuration from 'config-file' instead of /etc/lcd4linux.conf write picture to 'output' (raster driver only) suppress startup splash screen with '-q' -generate debugging messages with '-v' (implies -F) +generate debugging messages with '-v' SUPPORTED DISPLAYS diff --git a/Raster.c b/Raster.c index d2eba13..9e9dc98 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.9 2000/04/03 04:01:31 reinelt Exp $ +/* $Id: Raster.c,v 1.10 2000/08/10 09:44:09 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,11 @@ * * * $Log: Raster.c,v $ + * Revision 1.10 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.9 2000/04/03 04:01:31 reinelt * * if 'gap' is specified as -1, a gap of (pixelsize+pixelgap) is selected automatically @@ -83,6 +88,7 @@ #include +#include "debug.h" #include "cfg.h" #include "display.h" #include "pixmap.h" @@ -119,14 +125,14 @@ int Raster_flush (void) if (bitbuf==NULL) { if ((bitbuf=malloc(xsize*ysize*sizeof(*bitbuf)))==NULL) { - fprintf (stderr, "Raster: malloc(%d) failed: %s\n", xsize*ysize*sizeof(*bitbuf), strerror(errno)); + error ("Raster: malloc(%d) failed: %s", xsize*ysize*sizeof(*bitbuf), strerror(errno)); return -1; } } if (rowbuf==NULL) { if ((rowbuf=malloc(3*xsize*sizeof(*rowbuf)))==NULL) { - fprintf (stderr, "Raster: malloc(%d) failed: %s\n", 3*xsize*sizeof(*rowbuf), strerror(errno)); + error ("Raster: malloc(%d) failed: %s", 3*xsize*sizeof(*rowbuf), strerror(errno)); return -1; } } @@ -148,13 +154,13 @@ int Raster_flush (void) snprintf (tmp, sizeof(tmp), "%s.tmp", path); if ((fd=open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0644))<0) { - fprintf (stderr, "Raster: open(%s) failed: %s\n", tmp, strerror(errno)); + error ("Raster: open(%s) failed: %s", tmp, strerror(errno)); return -1; } snprintf (buffer, sizeof(buffer), "P6\n%d %d\n255\n", xsize, ysize); if (write (fd, buffer, strlen(buffer))<0) { - fprintf (stderr, "Raster: write(%s) failed: %s\n", tmp, strerror(errno)); + error ("Raster: write(%s) failed: %s", tmp, strerror(errno)); return -1; } @@ -179,17 +185,17 @@ int Raster_flush (void) rowbuf[c++]=B[i]; } if (write (fd, rowbuf, c)<0) { - fprintf (stderr, "Raster: write(%s) failed: %s\n", tmp, strerror(errno)); + error ("Raster: write(%s) failed: %s", tmp, strerror(errno)); return -1; } } if (close (fd)<0) { - fprintf (stderr, "Raster: close(%s) failed: %s\n", tmp, strerror(errno)); + error ("Raster: close(%s) failed: %s", tmp, strerror(errno)); return -1; } if (rename (tmp, path)<0) { - fprintf (stderr, "Raster: close(%s) failed: %s\n", tmp, strerror(errno)); + error ("Raster: close(%s) failed: %s", tmp, strerror(errno)); return -1; } @@ -211,27 +217,27 @@ int Raster_init (LCD *Self) int xres=1, yres=-1; if (output==NULL || *output=='\0') { - fprintf (stderr, "Raster: no output file specified (use -o switch)\n"); + error ("Raster: no output file specified (use -o switch)"); return -1; } if (sscanf(s=cfg_get("size")?:"20x4", "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { - fprintf (stderr, "Raster: bad size '%s'\n", s); + error ("Raster: bad size '%s'", s); return -1; } if (sscanf(s=cfg_get("font")?:"5x8", "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { - fprintf (stderr, "Raster: bad font '%s'\n", s); + error ("Raster: bad font '%s'", s); return -1; } if (sscanf(s=cfg_get("pixel")?:"4+1", "%d+%d", &pixel, &pgap)!=2 || pixel<1 || pgap<0) { - fprintf (stderr, "Raster: bad pixel '%s'\n", s); + error ("Raster: bad pixel '%s'", s); return -1; } if (sscanf(s=cfg_get("gap")?:"3x3", "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { - fprintf (stderr, "Raster: bad gap '%s'\n", s); + error ("Raster: bad gap '%s'", s); return -1; } if (rgap<0) rgap=pixel+pgap; @@ -240,20 +246,20 @@ int Raster_init (LCD *Self) border=atoi(cfg_get("border")?:"0"); if (sscanf(s=cfg_get("foreground")?:"#102000", "#%x", &foreground)!=1) { - fprintf (stderr, "Raster: bad foreground color '%s'\n", s); + error ("Raster: bad foreground color '%s'", s); return -1; } if (sscanf(s=cfg_get("halfground")?:"#70c000", "#%x", &halfground)!=1) { - fprintf (stderr, "Raster: bad halfground color '%s'\n", s); + error ("Raster: bad halfground color '%s'", s); return -1; } if (sscanf(s=cfg_get("background")?:"#80d000", "#%x", &background)!=1) { - fprintf (stderr, "Raster: bad background color '%s'\n", s); + error ("Raster: bad background color '%s'", s); return -1; } if (pix_init (rows, cols, xres, yres)!=0) { - fprintf (stderr, "Raster: pix_init(%d, %d, %d, %d) failed\n", rows, cols, xres, yres); + error ("Raster: pix_init(%d, %d, %d, %d) failed", rows, cols, xres, yres); return -1; } diff --git a/Skeleton.c b/Skeleton.c index b583913..16c0445 100644 --- a/Skeleton.c +++ b/Skeleton.c @@ -1,4 +1,4 @@ -/* $Id: Skeleton.c,v 1.4 2000/03/26 18:46:28 reinelt Exp $ +/* $Id: Skeleton.c,v 1.5 2000/08/10 09:44:09 reinelt Exp $ * * skeleton driver for new display modules * @@ -20,6 +20,11 @@ * * * $Log: Skeleton.c,v $ + * Revision 1.5 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.4 2000/03/26 18:46:28 reinelt * * bug in pixmap.c that leaded to empty bars fixed @@ -53,6 +58,7 @@ #include #include +#include "debug.h" #include "cfg.h" #include "display.h" @@ -67,7 +73,7 @@ int Skel_init (LCD *Self) { Lcd=*Self; - fprintf (stderr, "Skeleton: This driver does not drive anything!"); + error ("Skeleton: This driver does not drive anything!"); return -1; Skel_clear(); diff --git a/XWindow.c b/XWindow.c index 0956138..ad8c207 100644 --- a/XWindow.c +++ b/XWindow.c @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.19 2000/08/09 09:50:29 reinelt Exp $ +/* $Id: XWindow.c,v 1.20 2000/08/10 09:44:09 reinelt Exp $ * * X11 Driver for LCD4Linux * @@ -20,6 +20,11 @@ * * * $Log: XWindow.c,v $ + * Revision 1.20 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.19 2000/08/09 09:50:29 reinelt * * opened 0.98 development @@ -112,6 +117,7 @@ #include #include +#include "debug.h" #include "cfg.h" #include "display.h" #include "pixmap.h" @@ -190,12 +196,12 @@ static int init_shm(int nbytes,unsigned char **buf) { shmid=shmget(IPC_PRIVATE,nbytes,SHM_R|SHM_W); if (shmid==-1) { - perror("X11: shmget() failed"); + error ("X11: shmget() failed: %s", strerror(errno)); return -1; } *buf=shmat(shmid,NULL,0); if (*buf==NULL) { - perror("X11: shmat() failed"); + error ("X11: shmat() failed: %s", strerror(errno)); return -1; } return 0; @@ -210,7 +216,7 @@ union semun semun; semid=semget(IPC_PRIVATE,1,SEM_ALTER); if (semid==-1) { - perror("X11: semget() failed"); + error ("X11: semget() failed: %s", strerror(errno)); return -1; } semun.val=1; @@ -219,11 +225,11 @@ union semun semun; ppid=getpid(); switch(async_updater_pid=fork()) { case -1: - perror("X11: fork() failed"); + error ("X11: fork() failed: %s", strerror(errno)); return -1; case 0: async_update(); - fprintf(stderr,"X11: async_update failed\n"); + error ("X11: async_update failed"); kill(ppid,SIGTERM); exit(-1); default: @@ -240,7 +246,7 @@ XColor co_dummy; XEvent ev; if ((dp=XOpenDisplay(NULL))==NULL) { - fprintf(stderr,"X11: can't open display\n"); + error ("X11: can't open display"); return -1; } sc=DefaultScreen(dp); @@ -251,17 +257,17 @@ XEvent ev; cm=DefaultColormap(dp,sc); if (XAllocNamedColor(dp,cm,rgbfg,&co[0],&co_dummy)==False) { - fprintf(stderr,"X11: can't alloc foreground color '%s'\n", + error ("X11: can't alloc foreground color '%s'", rgbfg); return -1; } if (XAllocNamedColor(dp,cm,rgbbg,&co[1],&co_dummy)==False) { - fprintf(stderr,"X11: can't alloc background color '%s'\n", + error ("X11: can't alloc background color '%s'", rgbbg); return -1; } if (XAllocNamedColor(dp,cm,rgbhg,&co[2],&co_dummy)==False) { - fprintf(stderr,"X11: can't alloc halfground color '%s'\n", + error ("X11: can't alloc halfground color '%s'", rgbhg); return -1; } @@ -304,22 +310,22 @@ char *s; if (sscanf(s=cfg_get("size")?:"20x4","%dx%d",&cols,&rows)!=2 || rows<1 || cols<1) { - fprintf(stderr,"X11: bad size '%s'\n",s); + error ("X11: bad size '%s'",s); return -1; } if (sscanf(s=cfg_get("font")?:"5x8","%dx%d",&xres,&yres)!=2 || xres<5 || yres>10) { - fprintf(stderr,"X11: bad font '%s'\n",s); + error ("X11: bad font '%s'",s); return -1; } if (sscanf(s=cfg_get("pixel")?:"4+1","%d+%d",&pixel,&pgap)!=2 || pixel<1 || pgap<0) { - fprintf(stderr,"X11: bad pixel '%s'\n",s); + error ("X11: bad pixel '%s'",s); return -1; } if (sscanf(s=cfg_get("gap")?:"3x3","%dx%d",&cgap,&rgap)!=2 || cgap<-1 || rgap<-1) { - fprintf(stderr,"X11: bad gap '%s'\n",s); + error ("X11: bad gap '%s'",s); return -1; } if (rgap<0) rgap=pixel+pgap; diff --git a/cfg.c b/cfg.c index af0afd4..59805b2 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.8 2000/07/31 06:46:35 reinelt Exp $ +/* $Id: cfg.c,v 1.9 2000/08/10 09:44:09 reinelt Exp $ * * config file stuff * @@ -20,6 +20,11 @@ * * * $Log: cfg.c,v $ + * Revision 1.9 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.8 2000/07/31 06:46:35 reinelt * * eliminated some compiler warnings with glibc @@ -103,6 +108,7 @@ #include #include +#include "debug.h" #include "cfg.h" typedef struct { @@ -211,7 +217,7 @@ int cfg_read (char *file) stream=fopen (file, "r"); if (stream==NULL) { - fprintf (stderr, "open(%s) failed: %s\n", file, strerror(errno)); + error ("open(%s) failed: %s", file, strerror(errno)); return-1; } diff --git a/debug.h b/debug.h index bd2b9fa..44bac26 100644 --- a/debug.h +++ b/debug.h @@ -1,4 +1,4 @@ -/* $Id: debug.h,v 1.1 2000/04/15 11:13:54 reinelt Exp $ +/* $Id: debug.h,v 1.2 2000/08/10 09:44:09 reinelt Exp $ * * debug messages * @@ -20,6 +20,11 @@ * * * $Log: debug.h,v $ + * Revision 1.2 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.1 2000/04/15 11:13:54 reinelt * * added '-d' (debugging) switch @@ -32,7 +37,10 @@ #ifndef _DEBUG_H_ #define _DEBUG_H_ -extern int debugging; -#define debug(args...) do { if (debugging) printf(__FILE__ ": " args); } while(0) +void message (int level, const char *format, ...); + +#define debug(args...) message (2, __FILE__ ": " args) +#define info(args...) message (1, args) +#define error(args...) message (0, args) #endif diff --git a/display.c b/display.c index ca3bb0c..bd166e5 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.19 2000/08/09 09:50:29 reinelt Exp $ +/* $Id: display.c,v 1.20 2000/08/10 09:44:09 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,11 @@ * * * $Log: display.c,v $ + * Revision 1.20 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.19 2000/08/09 09:50:29 reinelt * * opened 0.98 development @@ -138,6 +143,8 @@ #include #include + +#include "debug.h" #include "cfg.h" #include "display.h" @@ -195,7 +202,7 @@ int lcd_init (char *driver) } } } - fprintf (stderr, "lcd_init(%s) failed: no such display\n", driver); + error ("lcd_init(%s) failed: no such display", driver); return -1; } diff --git a/fontmap.c b/fontmap.c index dc3746d..da30fe5 100644 --- a/fontmap.c +++ b/fontmap.c @@ -1,4 +1,4 @@ -/* $Id: fontmap.c,v 1.3 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: fontmap.c,v 1.4 2000/08/10 09:44:09 reinelt Exp $ * * 5x8 font * @@ -20,6 +20,11 @@ * * * $Log: fontmap.c,v $ + * Revision 1.4 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.3 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -42,815 +47,815 @@ #include "pixmap.h" #include "fontmap.h" -#define b______ 0x00 -#define b_____O 0x01 -#define b____O_ 0x02 -#define b____OO 0x03 -#define b___O__ 0x04 -#define b___O_O 0x05 -#define b___OO_ 0x06 -#define b___OOO 0x07 -#define b__O___ 0x08 -#define b__O__O 0x09 -#define b__O_O_ 0x0a -#define b__O_OO 0x0b -#define b__OO__ 0x0c -#define b__OO_O 0x0d -#define b__OOO_ 0x0e -#define b__OOOO 0x0f -#define b_O____ 0x10 -#define b_O___O 0x11 -#define b_O__O_ 0x12 -#define b_O__OO 0x13 -#define b_O_O__ 0x14 -#define b_O_O_O 0x15 -#define b_O_OO_ 0x16 -#define b_O_OOO 0x17 -#define b_OO___ 0x18 -#define b_OO__O 0x19 -#define b_OO_O_ 0x1a -#define b_OO_OO 0x1b -#define b_OOO__ 0x1c -#define b_OOO_O 0x1d -#define b_OOOO_ 0x1e -#define b_OOOOO 0x1f +#define ______ 0x00 +#define _____O 0x01 +#define ____O_ 0x02 +#define ____OO 0x03 +#define ___O__ 0x04 +#define ___O_O 0x05 +#define ___OO_ 0x06 +#define ___OOO 0x07 +#define __O___ 0x08 +#define __O__O 0x09 +#define __O_O_ 0x0a +#define __O_OO 0x0b +#define __OO__ 0x0c +#define __OO_O 0x0d +#define __OOO_ 0x0e +#define __OOOO 0x0f +#define _O____ 0x10 +#define _O___O 0x11 +#define _O__O_ 0x12 +#define _O__OO 0x13 +#define _O_O__ 0x14 +#define _O_O_O 0x15 +#define _O_OO_ 0x16 +#define _O_OOO 0x17 +#define _OO___ 0x18 +#define _OO__O 0x19 +#define _OO_O_ 0x1a +#define _OO_OO 0x1b +#define _OOO__ 0x1c +#define _OOO_O 0x1d +#define _OOOO_ 0x1e +#define _OOOOO 0x1f unsigned char Fontmap[256][8]={ - [0x20] { b______, - b______, - b______, - b______, - b______, - b______, - b______, - b______ }, - [0x21] { b___O__, - b___O__, - b___O__, - b___O__, - b______, - b______, - b___O__, - b______ }, - [0x22] { b__O_O_, - b__O_O_, - b__O_O_, - b______, - b______, - b______, - b______, - b______ }, - [0x23] { b__O_O_, - b__O_O_, - b_OOOOO, - b__O_O_, - b_OOOOO, - b__O_O_, - b__O_O_, - b______ }, - [0x24] { b___O__, - b__OOOO, - b_O_O__, - b__OOO_, - b___O_O, - b_OOOO_, - b___O__, - b______ }, - [0x25] { b_OO___, - b_OO__O, - b____O_, - b___O__, - b__O___, - b_O__OO, - b____OO, - b______ }, - [0x26] { b__OO__, - b_O__O_, - b_O_O__, - b__O___, - b_O_O_O, - b_O__O_, - b__OO_O, - b______ }, - [0x27] { b__OO__, - b___O__, - b__O___, - b______, - b______, - b______, - b______, - b______ }, - [0x28] { b____O_, - b___O__, - b__O___, - b__O___, - b__O___, - b___O__, - b____O_, - b______ }, - [0x29] { b__O___, - b___O__, - b____O_, - b____O_, - b____O_, - b___O__, - b__O___, - b______ }, - [0x2a] { b______, - b___O__, - b_O_O_O, - b__OOO_, - b_O_O_O, - b___O__, - b______, - b______ }, - [0x2b] { b______, - b___O__, - b___O__, - b_OOOOO, - b___O__, - b___O__, - b______, - b______ }, - [0x2c] { b______, - b______, - b______, - b______, - b__OO__, - b___O__, - b__O___, - b______ }, - [0x2d] { b______, - b______, - b______, - b_OOOOO, - b______, - b______, - b______, - b______ }, - [0x2e] { b______, - b______, - b______, - b______, - b______, - b__OO__, - b__OO__, - b______ }, - [0x2f] { b______, - b_____O, - b____O_, - b___O__, - b__O___, - b_O____, - b______, - b______ }, - [0x30] { b__OOO_, - b_O___O, - b_O__OO, - b_O_O_O, - b_OO__O, - b_O___O, - b__OOO_, - b______ }, - [0x31] { b___O__, - b__OO__, - b___O__, - b___O__, - b___O__, - b___O__, - b__OOO_, - b______ }, - [0x32] { b__OOO_, - b_O___O, - b_____O, - b____O_, - b___O__, - b__O___, - b_OOOOO, - b______ }, - [0x33] { b_OOOOO, - b____O_, - b___O__, - b____O_, - b_____O, - b_O___O, - b__OOO_, - b______ }, - [0x34] { b____O_, - b___OO_, - b__O_O_, - b_O__O_, - b_OOOOO, - b____O_, - b____O_, - b______ }, - [0x35] { b_OOOOO, - b_O____, - b_O____, - b_OOOO_, - b_____O, - b_O___O, - b__OOO_, - b______ }, - [0x36] { b___OO_, - b__O___, - b_O____, - b_OOOO_, - b_O___O, - b_O___O, - b__OOO_, - b______ }, - [0x37] { b_OOOOO, - b_____O, - b____O_, - b___O__, - b__O___, - b__O___, - b__O___, - b______ }, - [0x38] { b__OOO_, - b_O___O, - b_O___O, - b__OOO_, - b_O___O, - b_O___O, - b__OOO_, - b______ }, - [0x39] { b__OOO_, - b_O___O, - b_O___O, - b__OOOO, - b_____O, - b____O_, - b__OO__, - b______ }, - [0x3a] { b______, - b__OO__, - b__OO__, - b______, - b__OO__, - b__OO__, - b______, - b______ }, - [0x3b] { b______, - b__OO__, - b__OO__, - b______, - b__OO__, - b___O__, - b__O___, - b______ }, - [0x3c] { b____O_, - b___O__, - b__O___, - b_O____, - b__O___, - b___O__, - b____O_, - b______ }, - [0x3d] { b______, - b______, - b_OOOOO, - b______, - b_OOOOO, - b______, - b______, - b______ }, - [0x3e] { b_O____, - b__O___, - b___O__, - b____O_, - b___O__, - b__O___, - b_O____, - b______ }, - [0x3f] { b__OOO_, - b_O___O, - b_____O, - b____O_, - b___O__, - b______, - b___O__, - b______ }, - [0x40] { b__OOO_, - b_O___O, - b_____O, - b__OO_O, - b_O_O_O, - b_O_O_O, - b__OOO_, - b______ }, - [0x41] { b__OOO_, - b_O___O, - b_O___O, - b_O___O, - b_OOOOO, - b_O___O, - b_O___O, - b______ }, - [0x42] { b_OOOO_, - b_O___O, - b_O___O, - b_OOOO_, - b_O___O, - b_O___O, - b_OOOO_, - b______ }, - [0x43] { b__OOO_, - b_O___O, - b_O____, - b_O____, - b_O____, - b_O___O, - b__OOO_, - b______ }, - [0x44] { b_OOO__, - b_O__O_, - b_O___O, - b_O___O, - b_O___O, - b_O__O_, - b_OOO__, - b______ }, - [0x45] { b_OOOOO, - b_O____, - b_O____, - b_OOOO_, - b_O____, - b_O____, - b_OOOOO, - b______ }, - [0x46] { b_OOOOO, - b_O____, - b_O____, - b_OOOO_, - b_O____, - b_O____, - b_O____, - b______ }, - [0x47] { b__OOO_, - b_O___O, - b_O____, - b_O_OOO, - b_O___O, - b_O___O, - b__OOOO, - b______ }, - [0x48] { b_O___O, - b_O___O, - b_O___O, - b_OOOOO, - b_O___O, - b_O___O, - b_O___O, - b______ }, - [0x49] { b__OOO_, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b__OOO_, - b______ }, - [0x4a] { b___OOO, - b____O_, - b____O_, - b____O_, - b____O_, - b_O__O_, - b__OO__, - b______ }, - [0x4b] { b_O___O, - b_O__O_, - b_O_O__, - b_OO___, - b_O_O__, - b_O__O_, - b_O___O, - b______ }, - [0x4c] { b_O____, - b_O____, - b_O____, - b_O____, - b_O____, - b_O____, - b_OOOOO, - b______ }, - [0x4d] { b_O___O, - b_OO_OO, - b_O_O_O, - b_O_O_O, - b_O___O, - b_O___O, - b_O___O, - b______ }, - [0x4e] { b_O___O, - b_O___O, - b_OO__O, - b_O_O_O, - b_O__OO, - b_O___O, - b_O___O, - b______ }, - [0x4f] { b__OOO_, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b__OOO_, - b______ }, - [0x50] { b_OOOO_, - b_O___O, - b_O___O, - b_OOOO_, - b_O____, - b_O____, - b_O____, - b______ }, - [0x51] { b__OOO_, - b_O___O, - b_O___O, - b_O___O, - b_O_O_O, - b_O__O_, - b__OO_O, - b______ }, - [0x52] { b_OOOO_, - b_O___O, - b_O___O, - b_OOOO_, - b_O_O__, - b_O__O_, - b_O___O, - b______ }, - [0x53] { b__OOOO, - b_O____, - b_O____, - b__OOO_, - b_____O, - b_____O, - b_OOOO_, - b______ }, - [0x54] { b_OOOOO, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b______ }, - [0x55] { b_O___O, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b__OOO_, - b______ }, - [0x56] { b_O___O, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b__O_O_, - b___O__, - b______ }, - [0x57] { b_O___O, - b_O___O, - b_O___O, - b_O_O_O, - b_O_O_O, - b_O_O_O, - b__O_O_, - b______ }, - [0x58] { b_O___O, - b_O___O, - b__O_O_, - b___O__, - b__O_O_, - b_O___O, - b_O___O, - b______ }, - [0x59] { b_O___O, - b_O___O, - b_O___O, - b__O_O_, - b___O__, - b___O__, - b___O__, - b______ }, - [0x5a] { b_OOOOO, - b_____O, - b____O_, - b___O__, - b__O___, - b_O____, - b_OOOOO, - b______ }, - [0x5b] { b__OOO_, - b__O___, - b__O___, - b__O___, - b__O___, - b__O___, - b__OOO_, - b______ }, - [0x5c] { b_O___O, - b__O_O_, - b_OOOOO, - b___O__, - b_OOOOO, - b___O__, - b___O__, - b______ }, - [0x5d] { b__OOO_, - b____O_, - b____O_, - b____O_, - b____O_, - b____O_, - b__OOO_, - b______ }, - [0x5e] { b___O__, - b__O_O_, - b_O___O, - b______, - b______, - b______, - b______, - b______ }, - [0x5f] { b______, - b______, - b______, - b______, - b______, - b______, - b_OOOOO, - b______ }, - [0x60] { b__O___, - b___O__, - b____O_, - b______, - b______, - b______, - b______, - b______ }, - [0x61] { b______, - b______, - b__OOO_, - b_____O, - b__OOOO, - b_O___O, - b__OOOO, - b______ }, - [0x62] { b_O____, - b_O____, - b_O____, - b_O_OO_, - b_OO__O, - b_O___O, - b_OOOO_, - b______ }, - [0x63] { b______, - b______, - b__OOO_, - b_O____, - b_O____, - b_O___O, - b__OOO_, - b______ }, - [0x64] { b_____O, - b_____O, - b_____O, - b__OO_O, - b_O__OO, - b_O___O, - b__OOOO, - b______ }, - [0x65] { b______, - b______, - b__OOO_, - b_O___O, - b_OOOOO, - b_O____, - b__OOO_, - b______ }, - [0x66] { b___OO_, - b__O__O, - b__O___, - b_OOO__, - b__O___, - b__O___, - b__O___, - b______ }, - [0x67] { b______, - b__OOOO, - b_O___O, - b_O___O, - b__OOOO, - b_____O, - b__OOO_, - b______ }, - [0x68] { b_O____, - b_O____, - b_O_OO_, - b_OO__O, - b_O___O, - b_O___O, - b_O___O, - b______ }, - [0x69] { b___O__, - b______, - b__OO__, - b___O__, - b___O__, - b___O__, - b__OOO_, - b______ }, - [0x6a] { b____O_, - b______, - b___OO_, - b____O_, - b____O_, - b_O__O_, - b__OO__, - b______ }, - [0x6b] { b__O___, - b__O___, - b__O__O, - b__O_O_, - b__OO__, - b__O_O_, - b__O__O, - b______ }, - [0x6c] { b__OO__, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b__OOO_, - b______ }, - [0x6d] { b______, - b______, - b_OO_O_, - b_O_O_O, - b_O_O_O, - b_O___O, - b_O___O, - b______ }, - [0x6e] { b______, - b______, - b_OOOO_, - b_O___O, - b_O___O, - b_O___O, - b_O___O, - b______ }, - [0x6f] { b______, - b______, - b__OOO_, - b_O___O, - b_O___O, - b_O___O, - b__OOO_, - b______ }, - [0x70] { b______, - b______, - b_OOOO_, - b_O___O, - b_OOOO_, - b_O____, - b_O____, - b______ }, - [0x71] { b______, - b______, - b__OO_O, - b_O__OO, - b__OOOO, - b_____O, - b_____O, - b______ }, - [0x72] { b______, - b______, - b_O_OO_, - b_OO__O, - b_O____, - b_O____, - b_O____, - b______ }, - [0x73] { b______, - b______, - b__OOO_, - b_O____, - b__OOO_, - b_____O, - b_OOOO_, - b______ }, - [0x74] { b__O___, - b_OOO__, - b__O___, - b__O___, - b__O___, - b__O__O, - b___OO_, - b______ }, - [0x75] { b______, - b______, - b_O___O, - b_O___O, - b_O___O, - b_O__OO, - b__OO_O, - b______ }, - [0x76] { b______, - b______, - b_O___O, - b_O___O, - b_O___O, - b__O_O_, - b___O__, - b______ }, - [0x77] { b______, - b______, - b_O___O, - b_O___O, - b_O___O, - b_O_O_O, - b__O_O_, - b______ }, - [0x78] { b______, - b______, - b_O___O, - b__O_O_, - b___O__, - b__O_O_, - b_O___O, - b______ }, - [0x79] { b______, - b______, - b_O___O, - b_O___O, - b__OOOO, - b_____O, - b__OOO_, - b______ }, - [0x7a] { b______, - b______, - b_OOOOO, - b____O_, - b___O__, - b__O___, - b_OOOOO, - b______ }, - [0x7b] { b____O_, - b___O__, - b___O__, - b__O___, - b___O__, - b___O__, - b____O_, - b______ }, - [0x7c] { b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b___O__, - b______ }, - [0x7d] { b__O___, - b___O__, - b___O__, - b____O_, - b___O__, - b___O__, - b__O___, - b______ }, - [0x7e] { b______, - b___O__, - b____O_, - b_OOOOO, - b____O_, - b___O__, - b______, - b______ }, + [0x20] { ______, + ______, + ______, + ______, + ______, + ______, + ______, + ______ }, + [0x21] { ___O__, + ___O__, + ___O__, + ___O__, + ______, + ______, + ___O__, + ______ }, + [0x22] { __O_O_, + __O_O_, + __O_O_, + ______, + ______, + ______, + ______, + ______ }, + [0x23] { __O_O_, + __O_O_, + _OOOOO, + __O_O_, + _OOOOO, + __O_O_, + __O_O_, + ______ }, + [0x24] { ___O__, + __OOOO, + _O_O__, + __OOO_, + ___O_O, + _OOOO_, + ___O__, + ______ }, + [0x25] { _OO___, + _OO__O, + ____O_, + ___O__, + __O___, + _O__OO, + ____OO, + ______ }, + [0x26] { __OO__, + _O__O_, + _O_O__, + __O___, + _O_O_O, + _O__O_, + __OO_O, + ______ }, + [0x27] { __OO__, + ___O__, + __O___, + ______, + ______, + ______, + ______, + ______ }, + [0x28] { ____O_, + ___O__, + __O___, + __O___, + __O___, + ___O__, + ____O_, + ______ }, + [0x29] { __O___, + ___O__, + ____O_, + ____O_, + ____O_, + ___O__, + __O___, + ______ }, + [0x2a] { ______, + ___O__, + _O_O_O, + __OOO_, + _O_O_O, + ___O__, + ______, + ______ }, + [0x2b] { ______, + ___O__, + ___O__, + _OOOOO, + ___O__, + ___O__, + ______, + ______ }, + [0x2c] { ______, + ______, + ______, + ______, + __OO__, + ___O__, + __O___, + ______ }, + [0x2d] { ______, + ______, + ______, + _OOOOO, + ______, + ______, + ______, + ______ }, + [0x2e] { ______, + ______, + ______, + ______, + ______, + __OO__, + __OO__, + ______ }, + [0x2f] { ______, + _____O, + ____O_, + ___O__, + __O___, + _O____, + ______, + ______ }, + [0x30] { __OOO_, + _O___O, + _O__OO, + _O_O_O, + _OO__O, + _O___O, + __OOO_, + ______ }, + [0x31] { ___O__, + __OO__, + ___O__, + ___O__, + ___O__, + ___O__, + __OOO_, + ______ }, + [0x32] { __OOO_, + _O___O, + _____O, + ____O_, + ___O__, + __O___, + _OOOOO, + ______ }, + [0x33] { _OOOOO, + ____O_, + ___O__, + ____O_, + _____O, + _O___O, + __OOO_, + ______ }, + [0x34] { ____O_, + ___OO_, + __O_O_, + _O__O_, + _OOOOO, + ____O_, + ____O_, + ______ }, + [0x35] { _OOOOO, + _O____, + _O____, + _OOOO_, + _____O, + _O___O, + __OOO_, + ______ }, + [0x36] { ___OO_, + __O___, + _O____, + _OOOO_, + _O___O, + _O___O, + __OOO_, + ______ }, + [0x37] { _OOOOO, + _____O, + ____O_, + ___O__, + __O___, + __O___, + __O___, + ______ }, + [0x38] { __OOO_, + _O___O, + _O___O, + __OOO_, + _O___O, + _O___O, + __OOO_, + ______ }, + [0x39] { __OOO_, + _O___O, + _O___O, + __OOOO, + _____O, + ____O_, + __OO__, + ______ }, + [0x3a] { ______, + __OO__, + __OO__, + ______, + __OO__, + __OO__, + ______, + ______ }, + [0x3b] { ______, + __OO__, + __OO__, + ______, + __OO__, + ___O__, + __O___, + ______ }, + [0x3c] { ____O_, + ___O__, + __O___, + _O____, + __O___, + ___O__, + ____O_, + ______ }, + [0x3d] { ______, + ______, + _OOOOO, + ______, + _OOOOO, + ______, + ______, + ______ }, + [0x3e] { _O____, + __O___, + ___O__, + ____O_, + ___O__, + __O___, + _O____, + ______ }, + [0x3f] { __OOO_, + _O___O, + _____O, + ____O_, + ___O__, + ______, + ___O__, + ______ }, + [0x40] { __OOO_, + _O___O, + _____O, + __OO_O, + _O_O_O, + _O_O_O, + __OOO_, + ______ }, + [0x41] { __OOO_, + _O___O, + _O___O, + _O___O, + _OOOOO, + _O___O, + _O___O, + ______ }, + [0x42] { _OOOO_, + _O___O, + _O___O, + _OOOO_, + _O___O, + _O___O, + _OOOO_, + ______ }, + [0x43] { __OOO_, + _O___O, + _O____, + _O____, + _O____, + _O___O, + __OOO_, + ______ }, + [0x44] { _OOO__, + _O__O_, + _O___O, + _O___O, + _O___O, + _O__O_, + _OOO__, + ______ }, + [0x45] { _OOOOO, + _O____, + _O____, + _OOOO_, + _O____, + _O____, + _OOOOO, + ______ }, + [0x46] { _OOOOO, + _O____, + _O____, + _OOOO_, + _O____, + _O____, + _O____, + ______ }, + [0x47] { __OOO_, + _O___O, + _O____, + _O_OOO, + _O___O, + _O___O, + __OOOO, + ______ }, + [0x48] { _O___O, + _O___O, + _O___O, + _OOOOO, + _O___O, + _O___O, + _O___O, + ______ }, + [0x49] { __OOO_, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + __OOO_, + ______ }, + [0x4a] { ___OOO, + ____O_, + ____O_, + ____O_, + ____O_, + _O__O_, + __OO__, + ______ }, + [0x4b] { _O___O, + _O__O_, + _O_O__, + _OO___, + _O_O__, + _O__O_, + _O___O, + ______ }, + [0x4c] { _O____, + _O____, + _O____, + _O____, + _O____, + _O____, + _OOOOO, + ______ }, + [0x4d] { _O___O, + _OO_OO, + _O_O_O, + _O_O_O, + _O___O, + _O___O, + _O___O, + ______ }, + [0x4e] { _O___O, + _O___O, + _OO__O, + _O_O_O, + _O__OO, + _O___O, + _O___O, + ______ }, + [0x4f] { __OOO_, + _O___O, + _O___O, + _O___O, + _O___O, + _O___O, + __OOO_, + ______ }, + [0x50] { _OOOO_, + _O___O, + _O___O, + _OOOO_, + _O____, + _O____, + _O____, + ______ }, + [0x51] { __OOO_, + _O___O, + _O___O, + _O___O, + _O_O_O, + _O__O_, + __OO_O, + ______ }, + [0x52] { _OOOO_, + _O___O, + _O___O, + _OOOO_, + _O_O__, + _O__O_, + _O___O, + ______ }, + [0x53] { __OOOO, + _O____, + _O____, + __OOO_, + _____O, + _____O, + _OOOO_, + ______ }, + [0x54] { _OOOOO, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + ______ }, + [0x55] { _O___O, + _O___O, + _O___O, + _O___O, + _O___O, + _O___O, + __OOO_, + ______ }, + [0x56] { _O___O, + _O___O, + _O___O, + _O___O, + _O___O, + __O_O_, + ___O__, + ______ }, + [0x57] { _O___O, + _O___O, + _O___O, + _O_O_O, + _O_O_O, + _O_O_O, + __O_O_, + ______ }, + [0x58] { _O___O, + _O___O, + __O_O_, + ___O__, + __O_O_, + _O___O, + _O___O, + ______ }, + [0x59] { _O___O, + _O___O, + _O___O, + __O_O_, + ___O__, + ___O__, + ___O__, + ______ }, + [0x5a] { _OOOOO, + _____O, + ____O_, + ___O__, + __O___, + _O____, + _OOOOO, + ______ }, + [0x5b] { __OOO_, + __O___, + __O___, + __O___, + __O___, + __O___, + __OOO_, + ______ }, + [0x5c] { _O___O, + __O_O_, + _OOOOO, + ___O__, + _OOOOO, + ___O__, + ___O__, + ______ }, + [0x5d] { __OOO_, + ____O_, + ____O_, + ____O_, + ____O_, + ____O_, + __OOO_, + ______ }, + [0x5e] { ___O__, + __O_O_, + _O___O, + ______, + ______, + ______, + ______, + ______ }, + [0x5f] { ______, + ______, + ______, + ______, + ______, + ______, + _OOOOO, + ______ }, + [0x60] { __O___, + ___O__, + ____O_, + ______, + ______, + ______, + ______, + ______ }, + [0x61] { ______, + ______, + __OOO_, + _____O, + __OOOO, + _O___O, + __OOOO, + ______ }, + [0x62] { _O____, + _O____, + _O____, + _O_OO_, + _OO__O, + _O___O, + _OOOO_, + ______ }, + [0x63] { ______, + ______, + __OOO_, + _O____, + _O____, + _O___O, + __OOO_, + ______ }, + [0x64] { _____O, + _____O, + _____O, + __OO_O, + _O__OO, + _O___O, + __OOOO, + ______ }, + [0x65] { ______, + ______, + __OOO_, + _O___O, + _OOOOO, + _O____, + __OOO_, + ______ }, + [0x66] { ___OO_, + __O__O, + __O___, + _OOO__, + __O___, + __O___, + __O___, + ______ }, + [0x67] { ______, + __OOOO, + _O___O, + _O___O, + __OOOO, + _____O, + __OOO_, + ______ }, + [0x68] { _O____, + _O____, + _O_OO_, + _OO__O, + _O___O, + _O___O, + _O___O, + ______ }, + [0x69] { ___O__, + ______, + __OO__, + ___O__, + ___O__, + ___O__, + __OOO_, + ______ }, + [0x6a] { ____O_, + ______, + ___OO_, + ____O_, + ____O_, + _O__O_, + __OO__, + ______ }, + [0x6b] { __O___, + __O___, + __O__O, + __O_O_, + __OO__, + __O_O_, + __O__O, + ______ }, + [0x6c] { __OO__, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + __OOO_, + ______ }, + [0x6d] { ______, + ______, + _OO_O_, + _O_O_O, + _O_O_O, + _O___O, + _O___O, + ______ }, + [0x6e] { ______, + ______, + _OOOO_, + _O___O, + _O___O, + _O___O, + _O___O, + ______ }, + [0x6f] { ______, + ______, + __OOO_, + _O___O, + _O___O, + _O___O, + __OOO_, + ______ }, + [0x70] { ______, + ______, + _OOOO_, + _O___O, + _OOOO_, + _O____, + _O____, + ______ }, + [0x71] { ______, + ______, + __OO_O, + _O__OO, + __OOOO, + _____O, + _____O, + ______ }, + [0x72] { ______, + ______, + _O_OO_, + _OO__O, + _O____, + _O____, + _O____, + ______ }, + [0x73] { ______, + ______, + __OOO_, + _O____, + __OOO_, + _____O, + _OOOO_, + ______ }, + [0x74] { __O___, + _OOO__, + __O___, + __O___, + __O___, + __O__O, + ___OO_, + ______ }, + [0x75] { ______, + ______, + _O___O, + _O___O, + _O___O, + _O__OO, + __OO_O, + ______ }, + [0x76] { ______, + ______, + _O___O, + _O___O, + _O___O, + __O_O_, + ___O__, + ______ }, + [0x77] { ______, + ______, + _O___O, + _O___O, + _O___O, + _O_O_O, + __O_O_, + ______ }, + [0x78] { ______, + ______, + _O___O, + __O_O_, + ___O__, + __O_O_, + _O___O, + ______ }, + [0x79] { ______, + ______, + _O___O, + _O___O, + __OOOO, + _____O, + __OOO_, + ______ }, + [0x7a] { ______, + ______, + _OOOOO, + ____O_, + ___O__, + __O___, + _OOOOO, + ______ }, + [0x7b] { ____O_, + ___O__, + ___O__, + __O___, + ___O__, + ___O__, + ____O_, + ______ }, + [0x7c] { ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + ___O__, + ______ }, + [0x7d] { __O___, + ___O__, + ___O__, + ____O_, + ___O__, + ___O__, + __O___, + ______ }, + [0x7e] { ______, + ___O__, + ____O_, + _OOOOO, + ____O_, + ___O__, + ______, + ______ }, - [0x7f] { b______, - b___O__, - b__O___, - b_OOOOO, - b__O___, - b___O__, - b______, - b______ }, - [0xb0] { b__OOO_, - b__O_O_, - b__OOO_, - b______, - b______, - b______, - b______, - b______ }, + [0x7f] { ______, + ___O__, + __O___, + _OOOOO, + __O___, + ___O__, + ______, + ______ }, + [0xb0] { __OOO_, + __O_O_, + __OOO_, + ______, + ______, + ______, + ______, + ______ }, }; diff --git a/isdn.c b/isdn.c index d19f5b7..4879b55 100644 --- a/isdn.c +++ b/isdn.c @@ -1,4 +1,4 @@ -/* $Id: isdn.c,v 1.6 2000/04/15 11:56:35 reinelt Exp $ +/* $Id: isdn.c,v 1.7 2000/08/10 09:44:09 reinelt Exp $ * * ISDN specific functions * @@ -20,6 +20,11 @@ * * * $Log: isdn.c,v $ + * Revision 1.7 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.6 2000/04/15 11:56:35 reinelt * * more debug messages @@ -83,25 +88,25 @@ static int Usage (void) fd=open ("/dev/isdninfo", O_RDONLY | O_NDELAY); if (fd==-1) { - perror ("open(/dev/isdninfo) failed"); + error ("open(/dev/isdninfo) failed: %s", strerror(errno)); return 0; } if (read (fd, buffer, sizeof(buffer))==-1) { - perror ("read(/dev/isdninfo) failed"); + error ("read(/dev/isdninfo) failed: %s", strerror(errno)); fd=-1; return 0; } if (close(fd)==-1) { - perror ("close(/dev/isdninfo) failed"); + error ("close(/dev/isdninfo) failed: %s", strerror(errno)); fd=-1; return 0; } p=strstr(buffer, "usage:"); if (p==NULL) { - fprintf (stderr, "parse(/dev/isdninfo) failed: no usage line\n"); + error ("parse(/dev/isdninfo) failed: no usage line"); fd=-1; return 0; } @@ -130,14 +135,14 @@ int Isdn (int *rx, int *tx, int *usage) if (fd==-2) { fd = open("/dev/isdninfo", O_RDONLY | O_NDELAY); if (fd==-1) { - perror ("open(/dev/isdninfo) failed"); + error ("open(/dev/isdninfo) failed: %s", strerror(errno)); return -1; } - debug ("open (/proc/isdninfo)=%d\n", fd); + debug ("open (/proc/isdninfo)=%d", fd); } if (ioctl(fd, IIOCGETCPS, &cps)) { - perror("ioctl(IIOCGETCPS) failed"); + error("ioctl(IIOCGETCPS) failed: %s", strerror(errno)); fd=-1; return -1; } diff --git a/lcd4linux.c b/lcd4linux.c index 3236937..2bb62eb 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.25 2000/08/09 14:14:11 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.26 2000/08/10 09:44:09 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,11 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.26 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.25 2000/08/09 14:14:11 reinelt * * new switch -F (do not fork) @@ -159,7 +164,8 @@ char *release="LCD4Linux " VERSION " (c) 2000 Michael Reinelt "; char *output=NULL; int got_signal=0; -int debugging=0; +int debugging=1; +int foreground=0; int tick, tack; static void usage(void) @@ -225,7 +231,7 @@ void calibrate (void) void handler (int signal) { - debug ("got signal %d\n", signal); + debug ("got signal %d", signal); got_signal=signal; } @@ -234,7 +240,6 @@ int main (int argc, char *argv[]) char *cfg="/etc/lcd4linux.conf"; char *driver; int c, smooth; - int foreground=0; int quiet=0; while ((c=getopt (argc, argv, "c:dFf:hlo:qv"))!=EOF) { @@ -269,7 +274,6 @@ int main (int argc, char *argv[]) break; case 'v': debugging++; - foreground++; break; default: exit(2); @@ -283,24 +287,23 @@ int main (int argc, char *argv[]) if (!foreground) { pid_t i; - // debugging does not make sense here - // because -v implies -F which sets foreground=1 - // debug ("going background...\n"); + debug ("going background..."); i=fork(); if (i<0) { - perror ("fork() failed"); + error ("fork() failed: %s", strerror(errno)); exit (1); } - printf ("fork() returned %d\n", i); if (i!=0) exit (0); - close (0); - close (1); - printf ("Hallo stdout\n"); - fprintf (stderr, "Hallo stderr\n"); + + // close stdin/out/err ??? + // open (dev/null) ??? } - - debug ("LCD4Linux " VERSION "\n"); + + if (foreground) + debug ("LCD4Linux " VERSION); + else + info ("Version " VERSION " starting"); // set default values @@ -314,11 +317,11 @@ int main (int argc, char *argv[]) driver=cfg_get("display"); if (driver==NULL || *driver=='\0') { - fprintf (stderr, "%s: missing 'display' entry!\n", cfg_file()); + error ("%s: missing 'display' entry!", cfg_file()); exit (1); } - debug ("initializing driver %s\n", driver); + debug ("initializing driver %s", driver); if (lcd_init(driver)==-1) { exit (1); } @@ -339,7 +342,7 @@ int main (int argc, char *argv[]) lcd_clear(); } - debug ("starting main loop\n"); + debug ("starting main loop"); smooth=0; while (got_signal==0) { @@ -349,14 +352,14 @@ int main (int argc, char *argv[]) usleep(tick*1000); } - debug ("leaving main loop\n"); + debug ("leaving main loop"); lcd_clear(); if (!quiet) hello(); lcd_quit(); if (got_signal==SIGHUP) { - debug ("restarting\n"); + debug ("restarting"); } exit (0); } diff --git a/lock.c b/lock.c index dc83a10..2e02f35 100644 --- a/lock.c +++ b/lock.c @@ -1,4 +1,4 @@ -/* $Id: lock.c,v 1.1 2000/04/07 05:42:20 reinelt Exp $ +/* $Id: lock.c,v 1.2 2000/08/10 09:44:09 reinelt Exp $ * * UUCP style locking * @@ -20,6 +20,11 @@ * * * $Log: lock.c,v $ + * Revision 1.2 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.1 2000/04/07 05:42:20 reinelt * * UUCP style lockfiles for the serial port @@ -51,6 +56,7 @@ #include +#include "debug.h" #include "lock.h" @@ -71,18 +77,18 @@ pid_t lock_port (char *port) snprintf(tempfile, sizeof(tempfile), LOCK, "TMP.XXXXXX"); if (mktemp(tempfile)==NULL) { - fprintf(stderr, "mktemp(%s) failed.\n", tempfile); + error ("mktemp(%s) failed.", tempfile); return -1; } if ((fd=creat(tempfile, 0664))==-1) { - fprintf(stderr, "creat(%s) failed: %s\n", tempfile, strerror(errno)); + error ("creat(%s) failed: %s", tempfile, strerror(errno)); return -1; } snprintf (buffer, sizeof(buffer), "%10d\n", (int)getpid()); if (write(fd, buffer, strlen(buffer))!=strlen(buffer)) { - fprintf(stderr, "write(%s) failed: %s\n", tempfile, strerror(errno)); + error ("write(%s) failed: %s", tempfile, strerror(errno)); close(fd); unlink(tempfile); return -1; @@ -93,42 +99,42 @@ pid_t lock_port (char *port) while (link(tempfile, lockfile)==-1) { if (errno!=EEXIST) { - fprintf(stderr, "link(%s, %s) failed: %s\n", tempfile, lockfile, strerror(errno)); + error ("link(%s, %s) failed: %s", tempfile, lockfile, strerror(errno)); unlink(tempfile); return -1; } if ((fd=open(lockfile, O_RDONLY))==-1) { if (errno==ENOENT) continue; // lockfile disappared - fprintf (stderr, "open(%s) failed: %s\n", lockfile, strerror(errno)); + error ("open(%s) failed: %s", lockfile, strerror(errno)); unlink (tempfile); return -1; } len=read(fd, buffer, sizeof(buffer)-1); if (len<0) { - fprintf (stderr, "read(%s) failed: %s\n", lockfile, strerror(errno)); + error ("read(%s) failed: %s", lockfile, strerror(errno)); unlink (tempfile); return -1; } buffer[len]='\0'; if (sscanf(buffer, "%d", &pid)!=1 || pid==0) { - fprintf (stderr, "scan(%s) failed.\n", lockfile); + error ("scan(%s) failed.", lockfile); unlink (tempfile); return -1; } if (pid==getpid()) { - fprintf (stderr, "%s already locked by us. uh-oh...\n", lockfile); + error ("%s already locked by us. uh-oh...", lockfile); unlink(tempfile); return 0; } if ((kill(pid, 0)==-1) && errno==ESRCH) { - fprintf (stderr, "removing stale lockfile %s\n", lockfile); + error ("removing stale lockfile %s", lockfile); if (unlink(lockfile)==-1 && errno!=ENOENT) { - fprintf (stderr, "unlink(%s) failed: %s\n", lockfile, strerror(errno)); + error ("unlink(%s) failed: %s", lockfile, strerror(errno)); unlink(tempfile); return pid; } diff --git a/parser.c b/parser.c index b15eb4f..f9fd99d 100644 --- a/parser.c +++ b/parser.c @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.6 2000/05/21 06:20:35 reinelt Exp $ +/* $Id: parser.c,v 1.7 2000/08/10 09:44:09 reinelt Exp $ * * row definition parser * @@ -20,6 +20,11 @@ * * * $Log: parser.c,v $ + * Revision 1.7 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.6 2000/05/21 06:20:35 reinelt * * added ppp throughput @@ -70,6 +75,7 @@ #include #include +#include "debug.h" #include "display.h" #include "parser.h" @@ -174,7 +180,7 @@ char *parse (char *string, int supported_bars, int usage[]) case '%': if ((token=get_token (++s, &s, 0, usage))==-1) { - fprintf (stderr, "WARNING: unknown token <%%%c> in <%s>\n", *s, string); + error ("WARNING: unknown token <%%%c> in <%s>", *s, string); } else { *p++='%'; *p++=token; @@ -184,21 +190,21 @@ char *parse (char *string, int supported_bars, int usage[]) case '$': type=bar_type(tolower(*++s)); if (type==0) { - fprintf (stderr, "WARNING: invalid bar type <$%c> in <%s>\n", *s, string); + error ("WARNING: invalid bar type <$%c> in <%s>", *s, string); break; } if (!(type & supported_bars)) { - fprintf (stderr, "WARNING: driver does not support bar type '%c'\n", *s); + error ("WARNING: driver does not support bar type '%c'", *s); break; } if (isupper(*s)) type |= BAR_LOG; len=strtol(++s, &s, 10); if (len<1 || len>127) { - fprintf (stderr, "WARNING: invalid bar length in <%s>\n", string); + error ("WARNING: invalid bar length in <%s>", string); break; } if ((token=get_token (s, &s, 0, usage))==-1) { - fprintf (stderr, "WARNING: unknown token <$%c> in <%s>\n", *s, string); + error ("WARNING: unknown token <$%c> in <%s>", *s, string); break; } token2=-1; @@ -208,11 +214,11 @@ char *parse (char *string, int supported_bars, int usage[]) } else if ((type & BAR_V) && (supported_bars & BAR_V2)) { type |= BAR_V2; } else { - fprintf (stderr, "WARNING: driver does not support double bars\n"); + error ("WARNING: driver does not support double bars"); break; } if ((token2=get_token (s+1, &s, 0, usage))==-1) { - fprintf (stderr, "WARNING: unknown token <$%c> in <%s>\n", *s, string); + error ("WARNING: unknown token <$%c> in <%s>", *s, string); break; } } @@ -231,7 +237,7 @@ char *parse (char *string, int supported_bars, int usage[]) unsigned int c=0; int n; sscanf (s+1, "%3o%n", &c, &n); if (c==0 || c>255) { - fprintf (stderr, "WARNING: illegal '\\' in <%s>\n", string); + error ("WARNING: illegal '\\' in <%s>", string); } else { *p++=c; s+=n+1; diff --git a/processor.c b/processor.c index da1c3d2..9a2e9ab 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.7 2000/07/31 10:43:44 reinelt Exp $ +/* $Id: processor.c,v 1.8 2000/08/10 09:44:09 reinelt Exp $ * * main data processing * @@ -20,6 +20,11 @@ * * * $Log: processor.c,v $ + * Revision 1.8 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.7 2000/07/31 10:43:44 reinelt * * some changes to support kernel-2.4 (different layout of various files in /proc) @@ -431,12 +436,12 @@ void process_init (void) load.overload=atof(cfg_get("overload")?:"2.0"); lcd_query (&rows, &cols, &xres, &yres, &supported_bars); - debug ("%d rows, %d columns, %dx%d pixels\n", rows, cols, xres, yres); + debug ("%d rows, %d columns, %dx%d pixels", rows, cols, xres, yres); for (i=1; i<=rows; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "Row%d", i); p=cfg_get(buffer)?:""; - debug ("%s: %s\n", buffer, p); + debug ("%s: %s", buffer, p); row[i]=strdup(parse(p, supported_bars, token_usage)); } } diff --git a/system.c b/system.c index e063543..3aba79d 100644 --- a/system.c +++ b/system.c @@ -1,4 +1,4 @@ -/* $Id: system.c,v 1.15 2000/08/09 11:03:07 reinelt Exp $ +/* $Id: system.c,v 1.16 2000/08/10 09:44:09 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,11 @@ * * * $Log: system.c,v $ + * Revision 1.16 2000/08/10 09:44:09 reinelt + * + * new debugging scheme: error(), info(), debug() + * uses syslog if in daemon mode + * * Revision 1.15 2000/08/09 11:03:07 reinelt * * fixed a bug in system.c where the format of /proc/net/dev was not correctly @@ -172,11 +177,11 @@ static int parse_meminfo (char *tag, char *buffer) p=strstr(buffer, tag); if (p==NULL) { - fprintf (stderr, "parse(/proc/meminfo) failed: no '%s' line\n", tag); + error ("parse(/proc/meminfo) failed: no '%s' line", tag); return -1; } if (sscanf(p+strlen(tag), "%lu", &val)<1) { - fprintf (stderr, "scanf(/proc/meminfo) failed\n"); + error ("scanf(/proc/meminfo) failed"); return -1; } return val; @@ -189,10 +194,10 @@ char *System(void) if (*buffer=='\0') { if (uname(&ubuf)==-1) { - perror ("uname() failed"); + error ("uname() failed: %s", strerror(errno)); strcpy (buffer, "unknown"); } else { - debug ("uname(sysname)=%s\n", ubuf.sysname); + debug ("uname(sysname)=%s", ubuf.sysname); strncpy (buffer, ubuf.sysname, sizeof(buffer)); } } @@ -206,10 +211,10 @@ char *Release(void) if (*buffer=='\0') { if (uname(&ubuf)==-1) { - perror ("uname() failed"); + error ("uname() failed: %s", strerror(errno)); strcpy (buffer, "unknown"); } else { - debug ("uname(release)=%s\n", ubuf.release); + debug ("uname(release)=%s", ubuf.release); strncpy (buffer, ubuf.release, sizeof(buffer)); } } @@ -223,10 +228,10 @@ char *Processor(void) if (*buffer=='\0') { if (uname(&ubuf)==-1) { - perror ("uname() failed"); + error ("uname() failed: %s", strerror(errno)); strcpy (buffer, "unknown"); } else { - debug ("uname(machine)=%s\n", ubuf.machine); + debug ("uname(machine)=%s", ubuf.machine); strncpy (buffer, ubuf.machine, sizeof(buffer)); } } @@ -244,13 +249,13 @@ double BogoMips (void) char *p; int fd=open("/proc/cpuinfo", O_RDONLY); if (fd==-1) { - perror ("open(/proc/cpuinfo) failed"); + error ("open(/proc/cpuinfo) failed: %s", strerror(errno)); val=-1; return -1; } - debug ("open(proc/cpuinfo)=%d\n", fd); + debug ("open(proc/cpuinfo)=%d", fd); if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror ("read(/proc/cpuinfo) failed"); + error ("read(/proc/cpuinfo) failed: %s", strerror(errno)); close (fd); val=-1; return -1; @@ -258,16 +263,16 @@ double BogoMips (void) close (fd); p=strstr(buffer, "bogomips"); if (p==NULL) { - fprintf (stderr, "parse(/proc/cpuinfo) failed: no 'bogomips' line\n"); + error ("parse(/proc/cpuinfo) failed: no 'bogomips' line"); val=-1; return -1; } if (sscanf(p+8, " : %lf", &val)<1) { - fprintf (stderr, "scanf(/proc/cpuinfo) failed\n"); + error ("scanf(/proc/cpuinfo) failed"); val=-1; return -1; } - debug ("BogoMips=%f\n", val); + debug ("BogoMips=%f", val); } return val; } @@ -279,10 +284,10 @@ int Memory(void) if (value==-1) { if (stat("/proc/kcore", &buf)==-1) { - perror ("stat(/proc/kcore) failed"); + error ("stat(/proc/kcore) failed: %s", strerror(errno)); value=0; } else { - debug ("sizeof(/proc/kcore)=%ld bytes\n", buf.st_size); + debug ("sizeof(/proc/kcore)=%ld bytes", buf.st_size); value=buf.st_size>>20; } } @@ -314,19 +319,19 @@ int Ram (int *total, int *free, int *shared, int *buffered, int *cached) if (fd==-2) { fd = open("/proc/meminfo", O_RDONLY | O_NDELAY); if (fd==-1) { - perror ("open(/proc/meminfo) failed"); + error ("open(/proc/meminfo) failed: %s", strerror(errno)); return -1; } - debug ("open(/proc/meminfo)=%d\n", fd); + debug ("open(/proc/meminfo)=%d", fd); } if (lseek(fd, 0L, SEEK_SET)!=0) { - perror ("lseek(/proc/meminfo) failed"); + error ("lseek(/proc/meminfo) failed: %s", strerror(errno)); fd=-1; return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror ("read(/proc/meminfo) failed"); + error ("read(/proc/meminfo) failed: %s", strerror(errno)); fd=-1; return -1; } @@ -383,26 +388,26 @@ int Load (double *load1, double *load2, double *load3) if (fd==-2) { fd=open("/proc/loadavg", O_RDONLY); if (fd==-1) { - perror ("open(/proc/loadavg) failed"); + error ("open(/proc/loadavg) failed: %s", strerror(errno)); return -1; } - debug ("open(/proc/loadavg)=%d\n", fd); + debug ("open(/proc/loadavg)=%d", fd); } if (lseek(fd, 0L, SEEK_SET)!=0) { - perror("lseek(/proc/loadavg) failed"); + error("lseek(/proc/loadavg) failed: %s", strerror(errno)); fd=-1; return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror("read(/proc/loadavg) failed"); + error("read(/proc/loadavg) failed: %s", strerror(errno)); fd=-1; return -1; } if (sscanf(buffer, "%lf %lf %lf", &val1, &val2, &val3)<3) { - fprintf(stderr, "scanf(/proc/loadavg) failed\n"); + error ("scanf(/proc/loadavg) failed"); fd=-1; return -1; } @@ -431,25 +436,25 @@ int Busy (double *user, double *nice, double *system, double *idle) if (fd==-2) { fd=open("/proc/stat", O_RDONLY); if (fd==-1) { - perror ("open(proc/stat) failed"); + error ("open(proc/stat) failed: %s", strerror(errno)); return -1; } - debug ("open (/proc/stat)=%d\n", fd); + debug ("open (/proc/stat)=%d", fd); } if (lseek(fd, 0L, SEEK_SET)!=0) { - perror ("lseek(/proc/stat) failed"); + error ("lseek(/proc/stat) failed: %s", strerror(errno)); fd=-1; return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror ("read(/proc/stat) failed"); + error ("read(/proc/stat) failed: %s", strerror(errno)); fd=-1; return -1; } - if (sscanf(buffer, "%*s %lu %lu %lu %lu\n", &v1, &v2, &v3, &v4)<4) { - fprintf (stderr, "scanf(/proc/stat) failed\n"); + if (sscanf(buffer, "%*s %lu %lu %lu %lu", &v1, &v2, &v3, &v4)<4) { + error ("scanf(/proc/stat) failed"); fd=-1; return -1; } @@ -482,19 +487,19 @@ int Disk (int *r, int *w) if (fd==-2) { fd = open("/proc/stat", O_RDONLY | O_NDELAY); if (fd==-1) { - perror ("open(/proc/stat) failed"); + error ("open(/proc/stat) failed: %s", strerror(errno)); return -1; } - debug ("open (/proc/stat)=%d\n", fd); + debug ("open (/proc/stat)=%d", fd); } if (lseek(fd, 0L, SEEK_SET)!=0) { - perror ("lseek(/proc/stat) failed"); + error ("lseek(/proc/stat) failed: %s", strerror(errno)); fd=-1; return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror ("read(/proc/stat) failed"); + error ("read(/proc/stat) failed: %s", strerror(errno)); fd=-1; return -1; } @@ -523,23 +528,23 @@ int Disk (int *r, int *w) unsigned long w1, w2, w3, w4; p=strstr(buffer, "disk_rblk"); if (p==NULL) { - fprintf (stderr, "parse(/proc/stat) failed: neither 'disk_io' nor 'disk_rblk' found\n"); + error ("parse(/proc/stat) failed: neither 'disk_io' nor 'disk_rblk' found"); fd=-1; return -1; } - if (sscanf(p+9, "%lu %lu %lu %lu\n", &r1, &r2, &r3, &r4)<4) { - fprintf (stderr, "scanf(/proc/stat) failed\n"); + if (sscanf(p+9, "%lu %lu %lu %lu", &r1, &r2, &r3, &r4)<4) { + error ("scanf(/proc/stat) failed"); fd=-1; return -1; } p=strstr(buffer, "disk_wblk"); if (p==NULL) { - fprintf (stderr, "parse(/proc/stat) failed: no 'disk_wblk' line\n"); + error ("parse(/proc/stat) failed: no 'disk_wblk' line"); fd=-1; return -1; } - if (sscanf(p+9, "%lu %lu %lu %lu\n", &w1, &w2, &w3, &w4)<4) { - fprintf (stderr, "scanf(/proc/stat) failed\n"); + if (sscanf(p+9, "%lu %lu %lu %lu", &w1, &w2, &w3, &w4)<4) { + error ("scanf(/proc/stat) failed"); fd=-1; return -1; } @@ -567,36 +572,36 @@ int Net (int *rx, int *tx, int *bytes) if (fd==-2) { struct utsname ubuf; if (uname(&ubuf)==-1) { - perror ("uname() failed"); + error ("uname() failed: %s", strerror(errno)); fd=-1; return -1; } if (strncmp(ubuf.release,"2.0.",4)==0) { - debug ("using old /proc/net/dev format\n"); + debug ("using old /proc/net/dev format"); proc_net_dev_fmt=" eth%*d: %ld %*d %*d %*d %*d %ld"; proc_net_dev_bytes=0; } else { - debug ("using new /proc/net/dev format\n"); + debug ("using new /proc/net/dev format"); proc_net_dev_fmt=" eth%*d: %ld %*d %*d %*d %*d %*d %*d %*d %ld"; proc_net_dev_bytes=1; } fd = open("/proc/net/dev", O_RDONLY | O_NDELAY); if (fd==-1) { - perror ("open(/proc/net/dev) failed"); + error ("open(/proc/net/dev) failed: %s", strerror(errno)); return -1; } - debug ("open (/proc/net/dev)=%d\n", fd); + debug ("open (/proc/net/dev)=%d", fd); } if (lseek(fd, 0L, SEEK_SET)!=0) { - perror ("lseek(/proc/net/dev) failed"); + error ("lseek(/proc/net/dev) failed: %s", strerror(errno)); fd=-1; return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { - perror ("read(/proc/net/dev) failed"); + error ("read(/proc/net/dev) failed: %s", strerror(errno)); fd=-1; return -1; } @@ -633,10 +638,10 @@ int PPP (int unit, int *rx, int *tx) if (fd==-2) { fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd==-1) { - perror ("socket() failed"); + error ("socket() failed: %s", strerror(errno)); return -1; } - debug ("socket()=%d\n", fd); + debug ("socket()=%d", fd); } memset (&req, 0, sizeof (req)); @@ -681,7 +686,7 @@ int Sensor (int index, double *val, double *min, double *max) snprintf(buffer, 32, "Sensor%d", index); sensor[index]=cfg_get(buffer); if (sensor[index]==NULL || *sensor[index]=='\0') { - fprintf (stderr, "%s: no entry for '%s'\n", cfg_file(), buffer); + error ("%s: no entry for '%s'", cfg_file(), buffer); fd[index]=-1; return -1; } @@ -693,26 +698,26 @@ int Sensor (int index, double *val, double *min, double *max) fd[index]=open(sensor[index], O_RDONLY); if (fd[index]==-1) { - fprintf (stderr, "open(%s) failed: %s\n", sensor[index], strerror(errno)); + error ("open(%s) failed: %s", sensor[index], strerror(errno)); return -1; } - debug ("open (%s)=%d\n", sensor[index], fd[index]); + debug ("open (%s)=%d", sensor[index], fd[index]); } if (lseek(fd[index], 0L, SEEK_SET)!=0) { - fprintf (stderr, "lseek(%s) failed: %s\n", sensor[index], strerror(errno)); + error ("lseek(%s) failed: %s", sensor[index], strerror(errno)); fd[index]=-1; return -1; } if (read (fd[index], &buffer, sizeof(buffer)-1)==-1) { - fprintf (stderr, "read(%s) failed: %s\n", sensor[index], strerror(errno)); + error ("read(%s) failed: %s", sensor[index], strerror(errno)); fd[index]=-1; return -1; } if (sscanf(buffer, "%*f %*f %lf", &value)<1) { - fprintf (stderr, "scanf(%s) failed\n", sensor[index]); + error ("scanf(%s) failed", sensor[index]); fd[index]=-1; return -1; } -- cgit v1.2.3