diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2003-02-22 07:53:10 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2003-02-22 07:53:10 +0000 |
commit | ed1760b6b3194d68cdf6edbae01079e9efbc2e09 (patch) | |
tree | 9a0596fed56b4985e15b7d677c43c0bda80fbabb | |
parent | d302e66cd7b633e557bcb1504149ff3a7b39198c (diff) | |
download | lcd4linux-ed1760b6b3194d68cdf6edbae01079e9efbc2e09.tar.gz |
[lcd4linux @ 2003-02-22 07:53:09 by reinelt]
cfg_get(key,defval)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@183 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r-- | BeckmannEgle.c | 9 | ||||
-rw-r--r-- | Crystalfontz.c | 13 | ||||
-rw-r--r-- | Cwlinux.c | 9 | ||||
-rw-r--r-- | HD44780.c | 13 | ||||
-rw-r--r-- | M50530.c | 11 | ||||
-rw-r--r-- | MatrixOrbital.c | 11 | ||||
-rw-r--r-- | PalmPilot.c | 19 | ||||
-rw-r--r-- | Raster.c | 21 | ||||
-rw-r--r-- | SIN.c | 7 | ||||
-rw-r--r-- | T6963.c | 7 | ||||
-rw-r--r-- | Text.c | 9 | ||||
-rw-r--r-- | USBLCD.c | 9 | ||||
-rw-r--r-- | XWindow.c | 21 | ||||
-rw-r--r-- | cfg.c | 13 | ||||
-rw-r--r-- | cfg.h | 7 | ||||
-rw-r--r-- | exec.c | 15 | ||||
-rw-r--r-- | filter.c | 7 | ||||
-rw-r--r-- | lcd4linux.c | 11 | ||||
-rw-r--r-- | mail.c | 9 | ||||
-rw-r--r-- | mail2.c | 7 | ||||
-rw-r--r-- | processor.c | 13 | ||||
-rw-r--r-- | seti.c | 7 | ||||
-rw-r--r-- | system.c | 15 |
23 files changed, 166 insertions, 97 deletions
diff --git a/BeckmannEgle.c b/BeckmannEgle.c index 00d0f9b..8eff046 100644 --- a/BeckmannEgle.c +++ b/BeckmannEgle.c @@ -1,4 +1,4 @@ -/* $Id: BeckmannEgle.c,v 1.11 2002/08/22 05:51:36 reinelt Exp $ +/* $Id: BeckmannEgle.c,v 1.12 2003/02/22 07:53:09 reinelt Exp $ * * driver for Beckmann+Egle mini terminals * @@ -20,6 +20,9 @@ * * * $Log: BeckmannEgle.c,v $ + * Revision 1.12 2003/02/22 07:53:09 reinelt + * cfg_get(key,defval) + * * Revision 1.11 2002/08/22 05:51:36 reinelt * cosmetic changes * @@ -219,14 +222,14 @@ int BE_init (LCD *Self) Port=NULL; } - port=cfg_get ("Port"); + port=cfg_get ("Port", NULL); if (port==NULL || *port=='\0') { error ("BeckmannEgle: no 'Port' entry in %s", cfg_file()); return -1; } Port=strdup(port); - s=cfg_get("Type"); + s=cfg_get("Type", NULL); if (s==NULL || *s=='\0') { error ("BeckmannEgle: no 'Type' entry in %s", cfg_file()); return -1; diff --git a/Crystalfontz.c b/Crystalfontz.c index 0a87f81..e672c84 100644 --- a/Crystalfontz.c +++ b/Crystalfontz.c @@ -1,4 +1,4 @@ -/* $Id: Crystalfontz.c,v 1.8 2002/08/19 04:41:20 reinelt Exp $ +/* $Id: Crystalfontz.c,v 1.9 2003/02/22 07:53:09 reinelt Exp $ * * driver for display modules from Crystalfontz * @@ -19,6 +19,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: Crystalfontz.c,v $ + * Revision 1.9 2003/02/22 07:53:09 reinelt + * cfg_get(key,defval) + * * Revision 1.8 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * @@ -136,7 +139,7 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; Port=NULL; } - if ((port=cfg_get("Port"))==NULL || *port=='\0') { + if ((port=cfg_get("Port",NULL))==NULL || *port=='\0') { error ("CrystalFontz: no 'Port' entry in %s", cfg_file()); return -1; } @@ -146,7 +149,7 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; sprintf(Port,"/dev/%s",port); } - speed=cfg_get("Speed")?:"9600"; + speed=cfg_get("Speed","9600"); switch(atoi(speed)) { case 1200: Speed=B1200; @@ -214,13 +217,13 @@ char cmd_contrast[2]={ CRYFON_CONTRAST_CTRL, }; usleep(350000); write(Device, CRYFON_HIDE_CURSOR CRYFON_SCROLL_OFF CRYFON_WRAP_OFF,3); - backlight=cfg_get("Backlight")?:NULL; + backlight=cfg_get("Backlight",NULL); if (backlight) { cmd_backlight[1]=atoi(backlight); write(Device,cmd_backlight,4); } - contrast=cfg_get("Contrast")?:NULL; + contrast=cfg_get("Contrast",NULL); if (contrast) { cmd_contrast[1]=atoi(contrast); write(Device,cmd_contrast,2); @@ -1,4 +1,4 @@ -/* $Id: Cwlinux.c,v 1.4 2003/02/22 07:23:24 reinelt Exp $ +/* $Id: Cwlinux.c,v 1.5 2003/02/22 07:53:09 reinelt Exp $ * * driver for Cwlinux serial display modules * @@ -20,6 +20,9 @@ * * * $Log: Cwlinux.c,v $ + * Revision 1.5 2003/02/22 07:53:09 reinelt + * cfg_get(key,defval) + * * Revision 1.4 2003/02/22 07:23:24 reinelt * Cwlinux fixes * @@ -206,14 +209,14 @@ int CW_init(LCD * Self) Port = NULL; } - port = cfg_get("Port"); + port = cfg_get("Port",NULL); if (port == NULL || *port == '\0') { error("Cwlinux: no 'Port' entry in %s", cfg_file()); return -1; } Port = strdup(port); - speed = cfg_get("Speed") ? : "19200"; + speed = cfg_get("Speed","19200"); switch (atoi(speed)) { case 9600: @@ -1,4 +1,4 @@ -/* $Id: HD44780.c,v 1.25 2002/08/19 09:11:34 reinelt Exp $ +/* $Id: HD44780.c,v 1.26 2003/02/22 07:53:09 reinelt Exp $ * * driver for display modules based on the HD44780 chip * @@ -20,6 +20,9 @@ * * * $Log: HD44780.c,v $ + * Revision 1.26 2003/02/22 07:53:09 reinelt + * cfg_get(key,defval) + * * Revision 1.25 2002/08/19 09:11:34 reinelt * changed HD44780 to use generic bar functions * @@ -415,7 +418,7 @@ int HD_init (LCD *Self) int rows=-1, cols=-1, gpos=-1; char *s, *e; - s=cfg_get ("Port"); + s=cfg_get ("Port",NULL); if (s==NULL || *s=='\0') { error ("HD44780: no 'Port' entry in %s", cfg_file()); return -1; @@ -432,7 +435,7 @@ int HD_init (LCD *Self) } #ifdef USE_OLD_UDELAY - s=cfg_get ("Delay"); + s=cfg_get ("Delay",NULL); if (s==NULL || *s=='\0') { error ("HD44780: no 'Delay' entry in %s", cfg_file()); return -1; @@ -443,7 +446,7 @@ int HD_init (LCD *Self) } #endif - s=cfg_get("Size"); + s=cfg_get("Size",NULL); if (s==NULL || *s=='\0') { error ("HD44780: no 'Size' entry in %s", cfg_file()); return -1; @@ -453,7 +456,7 @@ int HD_init (LCD *Self) return -1; } - s=cfg_get ("GPOs"); + s=cfg_get ("GPOs",NULL); if (s==NULL) { gpos=0; } @@ -1,4 +1,4 @@ -/* $Id: M50530.c,v 1.5 2002/08/19 10:51:06 reinelt Exp $ +/* $Id: M50530.c,v 1.6 2003/02/22 07:53:10 reinelt Exp $ * * driver for display modules based on the M50530 chip * @@ -20,6 +20,9 @@ * * * $Log: M50530.c,v $ + * Revision 1.6 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.5 2002/08/19 10:51:06 reinelt * M50530 driver using new generic bar functions * @@ -239,14 +242,14 @@ int M5_init (LCD *Self) PPdev=NULL; } - s=cfg_get ("Port"); + s=cfg_get ("Port",NULL); if (s==NULL || *s=='\0') { error ("M50530: no 'Port' entry in %s", cfg_file()); return -1; } PPdev=strdup(s); - s=cfg_get("Size"); + s=cfg_get("Size",NULL); if (s==NULL || *s=='\0') { error ("M50530: no 'Size' entry in %s", cfg_file()); return -1; @@ -256,7 +259,7 @@ int M5_init (LCD *Self) return -1; } - s=cfg_get ("GPOs"); + s=cfg_get ("GPOs",NULL); if (s==NULL) { gpos=0; } else { diff --git a/MatrixOrbital.c b/MatrixOrbital.c index c0c8901..60d3525 100644 --- a/MatrixOrbital.c +++ b/MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: MatrixOrbital.c,v 1.26 2003/02/13 10:40:17 reinelt Exp $ +/* $Id: MatrixOrbital.c,v 1.27 2003/02/22 07:53:10 reinelt Exp $ * * driver for Matrix Orbital serial display modules * @@ -20,6 +20,9 @@ * * * $Log: MatrixOrbital.c,v $ + * Revision 1.27 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.26 2003/02/13 10:40:17 reinelt * * changed "copyright" to "2003" @@ -222,7 +225,7 @@ static int MO_contrast (void) char buffer[4]; int contrast; - contrast=atoi(cfg_get("Contrast")?:"160"); + contrast=atoi(cfg_get("Contrast","160")); snprintf (buffer, 4, "\376P%c", contrast); MO_write (buffer, 3); return 0; @@ -293,14 +296,14 @@ static int MO_init (LCD *Self, int protocol) Port=NULL; } - port=cfg_get ("Port"); + port=cfg_get ("Port",NULL); if (port==NULL || *port=='\0') { error ("MatrixOrbital: no 'Port' entry in %s", cfg_file()); return -1; } Port=strdup(port); - speed=cfg_get("Speed")?:"19200"; + speed=cfg_get("Speed","19200"); switch (atoi(speed)) { case 1200: diff --git a/PalmPilot.c b/PalmPilot.c index 8a4be9c..1fad1ed 100644 --- a/PalmPilot.c +++ b/PalmPilot.c @@ -1,4 +1,4 @@ -/* $Id: PalmPilot.c,v 1.7 2002/08/19 04:41:20 reinelt Exp $ +/* $Id: PalmPilot.c,v 1.8 2003/02/22 07:53:10 reinelt Exp $ * * driver for 3Com Palm Pilot * @@ -20,6 +20,9 @@ * * * $Log: PalmPilot.c,v $ + * Revision 1.8 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.7 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * @@ -209,14 +212,14 @@ int Palm_init (LCD *Self) Port=NULL; } - port=cfg_get ("Port"); + port=cfg_get ("Port",NULL); if (port==NULL || *port=='\0') { error ("PalmPilot: no 'Port' entry in %s", cfg_file()); return -1; } Port=strdup(port); - speed=cfg_get("Speed")?:"19200"; + speed=cfg_get("Speed","19200"); switch (atoi(speed)) { case 1200: @@ -241,29 +244,29 @@ int Palm_init (LCD *Self) 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) { + if (sscanf(s=cfg_get("size","20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { error ("PalmPilot: bad size '%s'", s); return -1; } - if (sscanf(s=cfg_get("font")?:"6x8", "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { + if (sscanf(s=cfg_get("font","6x8"), "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { 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) { + if (sscanf(s=cfg_get("pixel","1+0"), "%d+%d", &pixel, &pgap)!=2 || pixel<1 || pgap<0) { error ("PalmPilot: bad pixel '%s'", s); return -1; } - if (sscanf(s=cfg_get("gap")?:"0x0", "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { + if (sscanf(s=cfg_get("gap","0x0"), "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { error ("PalmPilot: bad gap '%s'", s); return -1; } if (rgap<0) rgap=pixel+pgap; if (cgap<0) cgap=pixel+pgap; - border=atoi(cfg_get("border")?:"0"); + border=atoi(cfg_get("border","0")); if (pix_init (rows, cols, xres, yres)!=0) { error ("PalmPilot: pix_init(%d, %d, %d, %d) failed", rows, cols, xres, yres); @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.20 2002/08/19 04:41:20 reinelt Exp $ +/* $Id: Raster.c,v 1.21 2003/02/22 07:53:10 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,9 @@ * * * $Log: Raster.c,v $ + * Revision 1.21 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.20 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * @@ -338,39 +341,39 @@ int Raster_init (LCD *Self) return -1; } - if (sscanf(s=cfg_get("size")?:"20x4", "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { + if (sscanf(s=cfg_get("size","20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { error ("Raster: bad size '%s'", s); return -1; } - if (sscanf(s=cfg_get("font")?:"5x8", "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { + if (sscanf(s=cfg_get("font","5x8"), "%dx%d", &xres, &yres)!=2 || xres<5 || yres<7) { 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) { + if (sscanf(s=cfg_get("pixel","4+1"), "%d+%d", &pixel, &pgap)!=2 || pixel<1 || pgap<0) { error ("Raster: bad pixel '%s'", s); return -1; } - if (sscanf(s=cfg_get("gap")?:"3x3", "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { + if (sscanf(s=cfg_get("gap","3x3"), "%dx%d", &cgap, &rgap)!=2 || cgap<-1 || rgap<-1) { error ("Raster: bad gap '%s'", s); return -1; } if (rgap<0) rgap=pixel+pgap; if (cgap<0) cgap=pixel+pgap; - border=atoi(cfg_get("border")?:"0"); + border=atoi(cfg_get("border","0")); - if (sscanf(s=cfg_get("foreground")?:"#102000", "#%x", &foreground)!=1) { + if (sscanf(s=cfg_get("foreground","#102000"), "#%x", &foreground)!=1) { error ("Raster: bad foreground color '%s'", s); return -1; } - if (sscanf(s=cfg_get("halfground")?:"#70c000", "#%x", &halfground)!=1) { + if (sscanf(s=cfg_get("halfground","#70c000"), "#%x", &halfground)!=1) { error ("Raster: bad halfground color '%s'", s); return -1; } - if (sscanf(s=cfg_get("background")?:"#80d000", "#%x", &background)!=1) { + if (sscanf(s=cfg_get("background","#80d000"), "#%x", &background)!=1) { error ("Raster: bad background color '%s'", s); return -1; } @@ -1,4 +1,4 @@ -/* $Id: SIN.c,v 1.7 2001/04/27 05:04:57 reinelt Exp $ +/* $Id: SIN.c,v 1.8 2003/02/22 07:53:10 reinelt Exp $ * * driver for SIN router displays * @@ -20,6 +20,9 @@ * * * $Log: SIN.c,v $ + * Revision 1.8 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.7 2001/04/27 05:04:57 reinelt * * replaced OPEN_MAX with sysconf() @@ -177,7 +180,7 @@ int SIN_init (LCD *Self) Port=NULL; } - port=cfg_get ("Port"); + port=cfg_get ("Port",NULL); if (port==NULL || *port=='\0') { error ("SIN: no 'Port' entry in %s", cfg_file()); return -1; @@ -1,4 +1,4 @@ -/* $Id: T6963.c,v 1.4 2002/08/21 06:09:53 reinelt Exp $ +/* $Id: T6963.c,v 1.5 2003/02/22 07:53:10 reinelt Exp $ * * driver for display modules based on the Toshiba T6963 chip * @@ -20,6 +20,9 @@ * * * $Log: T6963.c,v $ + * Revision 1.5 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.4 2002/08/21 06:09:53 reinelt * some T6963 fixes, ndelay wrap * @@ -377,7 +380,7 @@ int T6_init (LCD *Self) PPdev=NULL; } - port=cfg_get ("Port"); + port=cfg_get ("Port",NULL); if (port==NULL || *port=='\0') { error ("T6963: no 'Port' entry in %s", cfg_file()); return -1; @@ -1,4 +1,4 @@ -/* $Id: Text.c,v 1.7 2003/02/17 04:27:58 reinelt Exp $ +/* $Id: Text.c,v 1.8 2003/02/22 07:53:10 reinelt Exp $ * * pure ncurses based text driver * @@ -20,6 +20,9 @@ * * * $Log: Text.c,v $ + * Revision 1.8 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.7 2003/02/17 04:27:58 reinelt * Text (curses) driver: cosmetic changes * @@ -119,7 +122,7 @@ int Text_init (LCD *Self) return -1; } - if (sscanf(s=cfg_get("size")?:"20x4", "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { + if (sscanf(s=cfg_get("size","20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) { error ("Text: bad size '%s'", s); return -1; } @@ -204,7 +207,7 @@ int Text_put (int row, int col, char *text) int Text_bar (int type, int row, int col, int max, int len1, int len2) { int len, i; - if (cfg_get("TextBar")) + if (cfg_get("TextBar", NULL)) mvwprintw(w, row+1 , col+1, "%d %d %d", max, len1, len2); else { len = min(len1, len2); @@ -1,4 +1,4 @@ -/* $Id: USBLCD.c,v 1.7 2002/08/19 09:11:34 reinelt Exp $ +/* $Id: USBLCD.c,v 1.8 2003/02/22 07:53:10 reinelt Exp $ * * Driver for USBLCD ( see http://www.usblcd.de ) * This Driver is based on HD44780.c @@ -22,6 +22,9 @@ * * * $Log: USBLCD.c,v $ + * Revision 1.8 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.7 2002/08/19 09:11:34 reinelt * changed HD44780 to use generic bar functions * @@ -212,7 +215,7 @@ int USBLCD_init (LCD *Self) free(Port); Port=NULL; } - if ((port=cfg_get("Port"))==NULL || *port=='\0') { + if ((port=cfg_get("Port",NULL))==NULL || *port=='\0') { error ("USBLCD: no 'Port' entry in %s", cfg_file()); return -1; } @@ -225,7 +228,7 @@ int USBLCD_init (LCD *Self) debug ("using device %s ", Port); - s=cfg_get("Size"); + s=cfg_get("Size",NULL); if (s==NULL || *s=='\0') { error ("USBLCD: no 'Size' entry in %s", cfg_file()); return -1; @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.29 2003/02/18 06:13:44 reinelt Exp $ +/* $Id: XWindow.c,v 1.30 2003/02/22 07:53:10 reinelt Exp $ * * X11 Driver for LCD4Linux * @@ -20,6 +20,9 @@ * * * $Log: XWindow.c,v $ + * Revision 1.30 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.29 2003/02/18 06:13:44 reinelt * X11 driver fixes and cleanup * @@ -383,32 +386,32 @@ int xlcdinit(LCD *Self) { char *s; - if (sscanf(s=cfg_get("size")?:"20x4","%dx%d",&cols,&rows)!=2 + if (sscanf(s=cfg_get("size","20x4"),"%dx%d",&cols,&rows)!=2 || rows<1 || cols<1) { error ("X11: bad size '%s'",s); return -1; } - if (sscanf(s=cfg_get("font")?:"5x8","%dx%d",&xres,&yres)!=2 + if (sscanf(s=cfg_get("font","5x8"),"%dx%d",&xres,&yres)!=2 || xres<5 || yres>10) { error ("X11: bad font '%s'",s); return -1; } - if (sscanf(s=cfg_get("pixel")?:"4+1","%d+%d",&pixel,&pgap)!=2 + if (sscanf(s=cfg_get("pixel","4+1"),"%d+%d",&pixel,&pgap)!=2 || pixel<1 || pgap<0) { error ("X11: bad pixel '%s'",s); return -1; } - if (sscanf(s=cfg_get("gap")?:"3x3","%dx%d",&cgap,&rgap)!=2 + if (sscanf(s=cfg_get("gap","-1x-1"),"%dx%d",&cgap,&rgap)!=2 || cgap<-1 || rgap<-1) { error ("X11: bad gap '%s'",s); return -1; } if (rgap<0) rgap=pixel+pgap; if (cgap<0) cgap=pixel+pgap; - border=atoi(cfg_get("border")?:"0"); - rgbfg=cfg_get("foreground")?:"#000000"; - rgbbg=cfg_get("background")?:"#80d000"; - rgbhg=cfg_get("halfground")?:"#70c000"; + border=atoi(cfg_get("border","0")); + rgbfg=cfg_get("foreground","#000000"); + rgbbg=cfg_get("background","#80d000"); + rgbhg=cfg_get("halfground","#70c000"); if (*rgbfg=='\\') rgbfg++; if (*rgbbg=='\\') rgbbg++; if (*rgbhg=='\\') rgbhg++; @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.12 2001/03/09 12:14:24 reinelt Exp $ +/* $Id: cfg.c,v 1.13 2003/02/22 07:53:10 reinelt Exp $ * * config file stuff * @@ -20,6 +20,9 @@ * * * $Log: cfg.c,v $ + * Revision 1.13 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.12 2001/03/09 12:14:24 reinelt * * minor cleanups @@ -97,9 +100,9 @@ * should be called before cfg_read() * so we can specify 'default values' * - * cfg_get (key) + * cfg_get (key, defval) * return the a value for a given key - * or NULL if key does not exist + * or <defval> if key does not exist * * cfg_read (file) * read configuration from file @@ -210,7 +213,7 @@ void cfg_set (char *key, char *val) cfg_add (key, val, 0); } -char *cfg_get (char *key) +char *cfg_get (char *key, char *defval) { int i; @@ -219,7 +222,7 @@ char *cfg_get (char *key) return Config[i].val; } } - return NULL; + return defval; } static int check_cfg_file(char *file) @@ -1,4 +1,4 @@ -/* $Id: cfg.h,v 1.2 2000/04/03 04:46:38 reinelt Exp $ +/* $Id: cfg.h,v 1.3 2003/02/22 07:53:10 reinelt Exp $ * * config file stuff * @@ -20,6 +20,9 @@ * * * $Log: cfg.h,v $ + * Revision 1.3 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.2 2000/04/03 04:46:38 reinelt * * added '-c key=val' option @@ -39,7 +42,7 @@ int cfg_cmd (char *arg); void cfg_set (char *key, char *value); -char *cfg_get (char *key); +char *cfg_get (char *key, char *defval); int cfg_read (char *file); char *cfg_file (void); @@ -1,4 +1,4 @@ -/* $Id: exec.c,v 1.8 2003/02/05 04:31:38 reinelt Exp $ +/* $Id: exec.c,v 1.9 2003/02/22 07:53:10 reinelt Exp $ * * exec ('x*') functions * @@ -20,6 +20,9 @@ * * * $Log: exec.c,v $ + * Revision 1.9 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.8 2003/02/05 04:31:38 reinelt * * T_EXEC: remove trailing CR/LF @@ -97,7 +100,7 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val) if (now[index] > 0) { /* delay in Ticks ? */ sprintf(xn, "Tick_x%d", index); - p = cfg_get(xn); + p = cfg_get(xn,NULL); if (p && *p) { if (ticks[index]++ % atoi(p) != 0) return 0; @@ -105,7 +108,7 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val) else { sprintf(xn, "Delay_x%d", index); /* delay in Delay_x* sec ? */ - if (time(NULL) <= now[index] + atoi(cfg_get(xn)?:"1")) { + if (time(NULL) <= now[index] + atoi(cfg_get(xn,"1"))) { return 0; } } @@ -114,7 +117,7 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val) *val = -1; sprintf(xn, "x%d", index); - command = cfg_get(xn); + command = cfg_get(xn,NULL); if (!command || !*command) { error("Empty command for 'x%d'", index); @@ -154,9 +157,9 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val) double max, min; *val = atof(buff); sprintf(xn, "Max_x%d", index); - max = atof(cfg_get(xn)?:"100")?:100; + max = atof(cfg_get(xn,"100")); sprintf(xn, "Min_x%d", index); - min = atof(cfg_get(xn)?:"0"); + min = atof(cfg_get(xn,"0")); if (max != min) *val = (*val - min)/(max - min); } @@ -1,4 +1,4 @@ -/* $Id: filter.c,v 1.5 2001/08/05 17:13:29 reinelt Exp $ +/* $Id: filter.c,v 1.6 2003/02/22 07:53:10 reinelt Exp $ * * smooth and damp functions * @@ -20,6 +20,9 @@ * * * $Log: filter.c,v $ + * Revision 1.6 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.5 2001/08/05 17:13:29 reinelt * * cleaned up inlude of sys/time.h and time.h @@ -136,7 +139,7 @@ double damp(char *name, double value) int i, j; if (tau==-1) - tau=atoi(cfg_get("tau")?:"500"); + tau=atoi(cfg_get("tau","500")); if (tau==0.0) return value; diff --git a/lcd4linux.c b/lcd4linux.c index e3a5c70..3afc6dd 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.35 2003/02/13 10:40:17 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.36 2003/02/22 07:53:10 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,9 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.36 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.35 2003/02/13 10:40:17 reinelt * * changed "copyright" to "2003" @@ -401,7 +404,7 @@ int main (int argc, char *argv[]) if (cfg_read (cfg)==-1) exit (1); - driver=cfg_get("display"); + driver=cfg_get("display",NULL); if (driver==NULL || *driver=='\0') { error ("%s: missing 'display' entry!", cfg_file()); exit (1); @@ -418,8 +421,8 @@ int main (int argc, char *argv[]) signal(SIGQUIT, handler); signal(SIGTERM, handler); - tick=atoi(cfg_get("tick")?:"100"); - tack=atoi(cfg_get("tack")?:"500"); + tick=atoi(cfg_get("tick","100")); + tack=atoi(cfg_get("tack","500")); process_init(); lcd_clear(); @@ -1,4 +1,4 @@ -/* $Id: mail.c,v 1.11 2001/09/12 05:58:16 reinelt Exp $ +/* $Id: mail.c,v 1.12 2003/02/22 07:53:10 reinelt Exp $ * * email specific functions * @@ -20,6 +20,9 @@ * * * $Log: mail.c,v $ + * Revision 1.12 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.11 2001/09/12 05:58:16 reinelt * fixed bug in mail2.c * @@ -121,7 +124,7 @@ int Mail (int index, int *num, int *unseen) } if (now[index] > 0) { /* not first time, delay */ sprintf(txt1, "Delay_e%d", index); - if (time(NULL)<=now[index]+atoi(cfg_get(txt1)?:"5")) + if (time(NULL)<=now[index]+atoi(cfg_get(txt1,"5"))) return 0; // no more then 5/Delay_eX seconds after last check? } time(&now[index]); // for Mailbox #index @@ -129,7 +132,7 @@ int Mail (int index, int *num, int *unseen) Build the filename from the config */ snprintf(buffer, sizeof(buffer), "Mailbox%d", index); - fnp1=cfg_get(buffer); + fnp1=cfg_get(buffer,NULL); if (fnp1==NULL || *fnp1=='\0') { cfgmbx[index]=FALSE; // There is now entry for Mailbox #index } @@ -1,4 +1,4 @@ -/* $Id: mail2.c,v 1.7 2002/12/05 19:23:01 reinelt Exp $ +/* $Id: mail2.c,v 1.8 2003/02/22 07:53:10 reinelt Exp $ * * mail: pop3, imap, news functions * @@ -20,6 +20,9 @@ * * * $Log: mail2.c,v $ + * Revision 1.8 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.7 2002/12/05 19:23:01 reinelt * fixed undefined operations found by gcc3 * @@ -201,7 +204,7 @@ static int check_nntp(char *user, char *pass, char *machine, *total = 0; *unseen = 0; - strcpy(buf, cfg_get("Newsrc") ?: ".newsrc"); + strcpy(buf, cfg_get("Newsrc",".newsrc")); if (*buf == 0 || ((fp = fopen(buf, "r")) == NULL)) { error("Couldn't open .newsrc-file '%s'", buf); return -1; diff --git a/processor.c b/processor.c index 0b37c1e..d193a44 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.29 2003/02/05 04:31:38 reinelt Exp $ +/* $Id: processor.c,v 1.30 2003/02/22 07:53:10 reinelt Exp $ * * main data processing * @@ -20,6 +20,9 @@ * * * $Log: processor.c,v $ + * Revision 1.30 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.29 2003/02/05 04:31:38 reinelt * * T_EXEC: remove trailing CR/LF @@ -351,7 +354,7 @@ static double query_bar (int token) { static int alarm; alarm=((alarm+1) % 3); - if(value < atoi(cfg_get("battwarning")?:"10") && !alarm) /* flash bar */ + if(value < atoi(cfg_get("battwarning","10")) && !alarm) /* flash bar */ value = 0; return value/100; } @@ -655,7 +658,7 @@ void process_init (void) { int i; - load.overload=atof(cfg_get("overload")?:"2.0"); + load.overload=atof(cfg_get("overload","2.0")); lcd_query (&rows, &cols, &xres, &yres, &supported_bars, &gpos); if (rows>ROWS) { @@ -671,7 +674,7 @@ void process_init (void) for (i=1; i<=rows; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "Row%d", i); - p=cfg_get(buffer)?:""; + p=cfg_get(buffer,""); debug ("%s: %s", buffer, p); row[i]=strdup(parse_row(p, supported_bars, token_usage)); } @@ -679,7 +682,7 @@ void process_init (void) for (i=1; i<=gpos; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "GPO%d", i); - p=cfg_get(buffer)?:""; + p=cfg_get(buffer,""); debug ("%s: %s", buffer, p); gpo[i]=parse_gpo(p, token_usage); } @@ -1,4 +1,4 @@ -/* $Id: seti.c,v 1.6 2001/09/12 05:37:22 reinelt Exp $ +/* $Id: seti.c,v 1.7 2003/02/22 07:53:10 reinelt Exp $ * * seti@home specific functions * @@ -20,6 +20,9 @@ * * * $Log: seti.c,v $ + * Revision 1.7 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.6 2001/09/12 05:37:22 reinelt * * fixed a bug in seti.c (file was never closed, lcd4linux run out of fd's @@ -94,7 +97,7 @@ int Seti (double *perc, double *cput) time(&now); if (fd==-2) { - char *dir=cfg_get("SetiDir"); + char *dir=cfg_get("SetiDir",NULL); if (dir==NULL || *dir=='\0') { error ("%s: missing 'SetiDir' entry!\n", cfg_file()); fd=-1; @@ -1,4 +1,4 @@ -/* $Id: system.c,v 1.25 2002/12/05 19:12:47 reinelt Exp $ +/* $Id: system.c,v 1.26 2003/02/22 07:53:10 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,9 @@ * * * $Log: system.c,v $ + * Revision 1.26 2003/02/22 07:53:10 reinelt + * cfg_get(key,defval) + * * Revision 1.25 2002/12/05 19:12:47 reinelt * sensors factor and offset patch from Petri Damsten <petri.damsten@raketti.net> * @@ -763,7 +766,7 @@ int Sensor (int index, double *val, double *min, double *max) if (fd[index]==-2) { snprintf(buffer, 32, "Sensor%d", index); - sensor[index]=cfg_get(buffer); + sensor[index]=cfg_get(buffer, NULL); if (sensor[index]==NULL || *sensor[index]=='\0') { error ("%s: no entry for '%s'", cfg_file(), buffer); fd[index]=-1; @@ -771,18 +774,18 @@ int Sensor (int index, double *val, double *min, double *max) } snprintf(buffer, 32, "Sensor%d_min", index); - min_buf[index]=atof(cfg_get(buffer)?:"0"); + min_buf[index]=atof(cfg_get(buffer,"0")); *min=min_buf[index]; snprintf(buffer, 32, "Sensor%d_max", index); - max_buf[index]=atof(cfg_get(buffer)?:"100"); + max_buf[index]=atof(cfg_get(buffer,"100")); *max=max_buf[index]; snprintf(buffer, 32, "Sensor%d_factor", index); - factor_buf[index]=atof(cfg_get(buffer)?:"1"); + factor_buf[index]=atof(cfg_get(buffer,"1")); snprintf(buffer, 32, "Sensor%d_offset", index); - offset_buf[index]=atof(cfg_get(buffer)?:"0"); + offset_buf[index]=atof(cfg_get(buffer,"0")); fd[index]=open(sensor[index], O_RDONLY); if (fd[index]==-1) { |