aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-09 04:16:06 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-01-09 04:16:06 +0000
commit9dc6ff97fe8e9c911dfee409114fc5428adf858a (patch)
tree97337d07d0693302ca3031d256bff023a4d18f82
parent1cf54b00c151235704b41d192650a8e75c4ac905 (diff)
downloadlcd4linux-9dc6ff97fe8e9c911dfee409114fc5428adf858a.tar.gz
[lcd4linux @ 2004-01-09 04:16:06 by reinelt]
added 'section' argument to cfg_get(), but NULLed it on all calls by now. git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@298 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r--BeckmannEgle.c11
-rw-r--r--Crystalfontz.c15
-rw-r--r--Cwlinux.c13
-rw-r--r--HD44780.c15
-rw-r--r--M50530.c11
-rw-r--r--MatrixOrbital.c13
-rw-r--r--MilfordInstruments.c11
-rw-r--r--PalmPilot.c21
-rw-r--r--Raster.c23
-rw-r--r--T6963.c7
-rw-r--r--Text.c9
-rw-r--r--USBLCD.c11
-rw-r--r--XWindow.c23
-rw-r--r--cfg.c170
-rw-r--r--cfg.h13
-rw-r--r--exec.c15
-rw-r--r--expr.c11
-rw-r--r--filter.c7
-rw-r--r--icon.c7
-rwxr-xr-ximon.c23
-rw-r--r--lcd4linux.c9
-rw-r--r--mail.c9
-rw-r--r--mail2.c7
-rw-r--r--parport.c13
-rw-r--r--processor.c29
-rw-r--r--seti.c7
-rw-r--r--system.c15
-rw-r--r--wifi.c7
28 files changed, 332 insertions, 193 deletions
diff --git a/BeckmannEgle.c b/BeckmannEgle.c
index a401df9..fefe230 100644
--- a/BeckmannEgle.c
+++ b/BeckmannEgle.c
@@ -1,4 +1,4 @@
-/* $Id: BeckmannEgle.c,v 1.17 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: BeckmannEgle.c,v 1.18 2004/01/09 04:16:06 reinelt Exp $
*
* driver for Beckmann+Egle mini terminals
*
@@ -22,6 +22,9 @@
*
*
* $Log: BeckmannEgle.c,v $
+ * Revision 1.18 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.17 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -242,14 +245,14 @@ int BE_init (LCD *Self)
Port=NULL;
}
- port=cfg_get ("Port", NULL);
+ port=cfg_get (NULL, "Port", NULL);
if (port==NULL || *port=='\0') {
error ("BeckmannEgle: no 'Port' entry in %s", cfg_source());
return -1;
}
Port=strdup(port);
- s=cfg_get("Type", NULL);
+ s=cfg_get(NULL, "Type", NULL);
if (s==NULL || *s=='\0') {
error ("BeckmannEgle: no 'Type' entry in %s", cfg_source());
return -1;
@@ -292,7 +295,7 @@ int BE_init (LCD *Self)
BE_write (buffer, 4); // select display type
BE_write ("\033&D", 3); // cursor off
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number("", "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, BE_define_char);
diff --git a/Crystalfontz.c b/Crystalfontz.c
index 49e27ac..e538e7c 100644
--- a/Crystalfontz.c
+++ b/Crystalfontz.c
@@ -1,4 +1,4 @@
-/* $Id: Crystalfontz.c,v 1.17 2003/11/16 09:45:49 reinelt Exp $
+/* $Id: Crystalfontz.c,v 1.18 2004/01/09 04:16:06 reinelt Exp $
*
* driver for display modules from Crystalfontz
*
@@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: Crystalfontz.c,v $
+ * Revision 1.18 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.17 2003/11/16 09:45:49 reinelt
* Crystalfontz changes, small glitch in getopt() fixed
*
@@ -161,7 +164,7 @@ static int CF_backlight (void)
char buffer[3];
int backlight;
- if (cfg_number("Backlight", 0, 0, 100, &backlight)<0) return -1;
+ if (cfg_number(NULL, "Backlight", 0, 0, 100, &backlight)<0) return -1;
snprintf (buffer, 3, "\016%c", backlight);
CF_write (buffer, 2);
return 0;
@@ -173,7 +176,7 @@ static int CF_contrast (void)
char buffer[3];
int contrast;
- if (cfg_number("Contrast", 50, 0, 100, &contrast)<0) return -1;
+ if (cfg_number(NULL, "Contrast", 50, 0, 100, &contrast)<0) return -1;
snprintf (buffer, 3, "\017%c", contrast);
CF_write (buffer, 2);
return 0;
@@ -227,7 +230,7 @@ static int CF_init (LCD *Self)
Port=NULL;
}
- port=cfg_get ("Port",NULL);
+ port=cfg_get (NULL, "Port", NULL);
if (port==NULL || *port=='\0') {
error ("Crystalfontz: no 'Port' entry in %s", cfg_source());
return -1;
@@ -235,7 +238,7 @@ static int CF_init (LCD *Self)
Port=strdup(port);
- if (cfg_number("Speed", 19200, 1200,19200, &speed)<0) return -1;
+ if (cfg_number(NULL, "Speed", 19200, 1200,19200, &speed)<0) return -1;
switch (speed) {
case 1200:
@@ -260,7 +263,7 @@ static int CF_init (LCD *Self)
Device=CF_open();
if (Device==-1) return -1;
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, CF_define_char);
diff --git a/Cwlinux.c b/Cwlinux.c
index 3ae72ab..e5bb226 100644
--- a/Cwlinux.c
+++ b/Cwlinux.c
@@ -1,4 +1,4 @@
-/* $Id: Cwlinux.c,v 1.16 2003/11/30 16:18:36 reinelt Exp $
+/* $Id: Cwlinux.c,v 1.17 2004/01/09 04:16:06 reinelt Exp $
*
* driver for Cwlinux serial display modules
*
@@ -22,6 +22,9 @@
*
*
* $Log: Cwlinux.c,v $
+ * Revision 1.17 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.16 2003/11/30 16:18:36 reinelt
* Cwlinux: invalidate Framebuffer in case a char got redefined
*
@@ -261,7 +264,7 @@ static void CW_Brightness(void)
int level;
char cmd[5]="\376A_\375";
- if (cfg_number("Brightness", 8, 0, 8, &level)<0) return;
+ if (cfg_number(NULL, "Brightness", 8, 0, 8, &level)<0) return;
switch (level) {
case 0:
@@ -302,14 +305,14 @@ int CW_init(LCD * Self)
Port = NULL;
}
- port = cfg_get("Port",NULL);
+ port = cfg_get(NULL, "Port",NULL);
if (port == NULL || *port == '\0') {
error("Cwlinux: no 'Port' entry in %s", cfg_source());
return -1;
}
Port = strdup(port);
- if (cfg_number("Speed", 19200, 9600,19200, &speed)<0) return -1;
+ if (cfg_number(NULL, "Speed", 19200, 9600,19200, &speed)<0) return -1;
switch (speed) {
case 9600:
Speed = B9600;
@@ -360,7 +363,7 @@ int CW_init(LCD * Self)
// backlight brightness
CW_Brightness();
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, Lcd.xres, Lcd.yres, CHARS, Icons, CW12232_define_char);
diff --git a/HD44780.c b/HD44780.c
index 09c3086..f4a0850 100644
--- a/HD44780.c
+++ b/HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: HD44780.c,v 1.48 2004/01/06 22:33:13 reinelt Exp $
+/* $Id: HD44780.c,v 1.49 2004/01/09 04:16:06 reinelt Exp $
*
* driver for display modules based on the HD44780 chip
*
@@ -28,6 +28,9 @@
*
*
* $Log: HD44780.c,v $
+ * Revision 1.49 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.48 2004/01/06 22:33:13 reinelt
* Copyright statements cleaned up
*
@@ -463,7 +466,7 @@ int HD_init (LCD *Self)
int rows=-1, cols=-1, gpos=-1;
char *s;
- s=cfg_get("Size",NULL);
+ s=cfg_get(NULL, "Size", NULL);
if (s==NULL || *s=='\0') {
error ("HD44780: no 'Size' entry in %s", cfg_source());
return -1;
@@ -473,10 +476,10 @@ int HD_init (LCD *Self)
return -1;
}
- if (cfg_number("GPOs", 0, 0, 8, &gpos)<0) return -1;
+ if (cfg_number(NULL, "GPOs", 0, 0, 8, &gpos)<0) return -1;
info ("HD44780: controlling %d GPO's", gpos);
- if (cfg_number("Controllers", 1, 1, 2, &Controllers)<0) return -1;
+ if (cfg_number(NULL, "Controllers", 1, 1, 2, &Controllers)<0) return -1;
info ("wiring: using display with %d controllers", Controllers);
// current controller
@@ -495,7 +498,7 @@ int HD_init (LCD *Self)
return -1;
}
- if (cfg_number("Bits", 8, 4, 8, &Bits)<0) return -1;
+ if (cfg_number(NULL, "Bits", 8, 4, 8, &Bits)<0) return -1;
if (Bits!=4 && Bits!=8) {
error ("HD44780: bad Bits '%s' in %s, should be '4' or '8'", s, cfg_source());
return -1;
@@ -548,7 +551,7 @@ int HD_init (LCD *Self)
HD_command (0x03, 0x0c, T_CLEAR); // Display on, cursor off, blink off, wait 1.64 ms
HD_command (0x03, 0x06, T_EXEC); // curser moves to right, no shift
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, HD_define_char);
diff --git a/M50530.c b/M50530.c
index 2febde3..ec206e1 100644
--- a/M50530.c
+++ b/M50530.c
@@ -1,4 +1,4 @@
-/* $Id: M50530.c,v 1.16 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: M50530.c,v 1.17 2004/01/09 04:16:06 reinelt Exp $
*
* driver for display modules based on the M50530 chip
*
@@ -22,6 +22,9 @@
*
*
* $Log: M50530.c,v $
+ * Revision 1.17 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.16 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -200,7 +203,7 @@ int M5_init (LCD *Self)
int rows=-1, cols=-1, gpos=-1;
char *s;
- s=cfg_get("Size",NULL);
+ s=cfg_get(NULL, "Size", NULL);
if (s==NULL || *s=='\0') {
error ("M50530: no 'Size' entry in %s", cfg_source());
return -1;
@@ -210,7 +213,7 @@ int M5_init (LCD *Self)
return -1;
}
- if (cfg_number("GPOs", 0, 0, 8, &gpos)<0) return -1;
+ if (cfg_number(NULL, "GPOs", 0, 0, 8, &gpos)<0) return -1;
Self->rows=rows;
Self->cols=cols;
@@ -244,7 +247,7 @@ int M5_init (LCD *Self)
M5_command (0x0050, 20); // set entry mode
M5_command (0x0030, 20); // set display mode
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, M5_define_char);
diff --git a/MatrixOrbital.c b/MatrixOrbital.c
index 78e6c8c..3944cf4 100644
--- a/MatrixOrbital.c
+++ b/MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.49 2003/12/19 05:35:14 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.50 2004/01/09 04:16:06 reinelt Exp $
*
* driver for Matrix Orbital serial display modules
*
@@ -22,6 +22,9 @@
*
*
* $Log: MatrixOrbital.c,v $
+ * Revision 1.50 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.49 2003/12/19 05:35:14 reinelt
* renamed 'client' to 'plugin'
*
@@ -370,7 +373,7 @@ static int MO_contrast (void)
char buffer[4];
int contrast;
- if (cfg_number("Contrast", 160, 0, 255, &contrast)<0) return -1;
+ if (cfg_number(NULL, "Contrast", 160, 0, 255, &contrast)<0) return -1;
snprintf (buffer, 4, "\376P%c", contrast);
MO_write (buffer, 3);
return 0;
@@ -588,14 +591,14 @@ static int MO_init (LCD *Self, int protocol)
Port=NULL;
}
- port=cfg_get ("Port",NULL);
+ port=cfg_get (NULL, "Port", NULL);
if (port==NULL || *port=='\0') {
error ("MatrixOrbital: no 'Port' entry in %s", cfg_source());
return -1;
}
Port=strdup(port);
- if (cfg_number("Speed", 19200, 1200, 19200, &i)<0) return -1;
+ if (cfg_number(NULL, "Speed", 19200, 1200, 19200, &i)<0) return -1;
switch (i) {
case 1200:
Speed=B1200;
@@ -641,7 +644,7 @@ static int MO_init (LCD *Self, int protocol)
info ("Display on %s has Firmware Version 0x%x", Port, *buffer);
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MO_define_char);
diff --git a/MilfordInstruments.c b/MilfordInstruments.c
index 6ef5558..aaf78b7 100644
--- a/MilfordInstruments.c
+++ b/MilfordInstruments.c
@@ -1,4 +1,4 @@
-/* $Id: MilfordInstruments.c,v 1.4 2004/01/06 22:33:13 reinelt Exp $
+/* $Id: MilfordInstruments.c,v 1.5 2004/01/09 04:16:06 reinelt Exp $
*
* driver for Milford Instruments 'BPK' piggy-back serial interface board
* for standard Hitachi 44780 compatible lcd modules.
@@ -24,6 +24,9 @@
*
*
* $Log: MilfordInstruments.c,v $
+ * Revision 1.5 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.4 2004/01/06 22:33:13 reinelt
* Copyright statements cleaned up
*
@@ -166,14 +169,14 @@ static int MI_init (LCD *Self)
Port=NULL;
}
- port=cfg_get ("Port",NULL);
+ port=cfg_get (NULL, "Port", NULL);
if (port==NULL || *port=='\0') {
error ("MilfordInstruments: no 'Port' entry in %s", cfg_source());
return -1;
}
Port=strdup(port);
- if (cfg_number("Speed", 19200, 1200,19200, &speed)<0) return -1;
+ if (cfg_number(NULL, "Speed", 19200, 1200,19200, &speed)<0) return -1;
switch (speed) {
case 2400:
Speed=B2400;
@@ -191,7 +194,7 @@ static int MI_init (LCD *Self)
Device=MI_open();
if (Device==-1) return -1;
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MI_define_char);
diff --git a/PalmPilot.c b/PalmPilot.c
index 61be489..b5360dc 100644
--- a/PalmPilot.c
+++ b/PalmPilot.c
@@ -1,4 +1,4 @@
-/* $Id: PalmPilot.c,v 1.14 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: PalmPilot.c,v 1.15 2004/01/09 04:16:06 reinelt Exp $
*
* driver for 3Com Palm Pilot
*
@@ -22,6 +22,9 @@
*
*
* $Log: PalmPilot.c,v $
+ * Revision 1.15 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.14 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -237,14 +240,14 @@ int Palm_init (LCD *Self)
Port=NULL;
}
- port=cfg_get ("Port",NULL);
+ port=cfg_get (NULL, "Port", NULL);
if (port==NULL || *port=='\0') {
error ("PalmPilot: no 'Port' entry in %s", cfg_source());
return -1;
}
Port=strdup(port);
- if (cfg_number("Speed", 19200, 1200,19200, &speed)<0) return -1;
+ if (cfg_number(NULL, "Speed", 19200, 1200,19200, &speed)<0) return -1;
switch (speed) {
case 1200:
@@ -269,36 +272,36 @@ int Palm_init (LCD *Self)
debug ("using port %s at %d baud", Port, speed);
- if (sscanf(s=cfg_get("size","20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) {
+ if (sscanf(s=cfg_get(NULL, "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(NULL, "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(NULL, "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(NULL, "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;
- if (cfg_number("border", 0, 0, 1000000, &border)<0) return -1;
+ if (cfg_number(NULL, "border", 0, 0, 1000000, &border)<0) return -1;
if (pix_init (rows, cols, xres, yres)!=0) {
error ("PalmPilot: pix_init(%d, %d, %d, %d) failed", rows, cols, xres, yres);
return -1;
}
- if (cfg_number("Icons", 0, 0, 8, &icons) < 0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, 8, &icons) < 0) return -1;
if (icons>0) {
info ("allocating %d icons", icons);
icon_init(rows, cols, xres, yres, 8, icons, pix_icon);
diff --git a/Raster.c b/Raster.c
index 8673396..b443b56 100644
--- a/Raster.c
+++ b/Raster.c
@@ -1,4 +1,4 @@
-/* $Id: Raster.c,v 1.28 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: Raster.c,v 1.29 2004/01/09 04:16:06 reinelt Exp $
*
* driver for raster formats
*
@@ -22,6 +22,9 @@
*
*
* $Log: Raster.c,v $
+ * Revision 1.29 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.28 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -360,39 +363,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(NULL, "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(NULL, "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(NULL, "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(NULL, "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;
- if (cfg_number("border", 0, 0, 1000000, &border)<0) return -1;
+ if (cfg_number(NULL, "border", 0, 0, 1000000, &border)<0) return -1;
- if (sscanf(s=cfg_get("foreground","#102000"), "#%x", &foreground)!=1) {
+ if (sscanf(s=cfg_get(NULL, "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(NULL, "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(NULL, "background", "#80d000"), "#%x", &background)!=1) {
error ("Raster: bad background color '%s'", s);
return -1;
}
@@ -402,7 +405,7 @@ int Raster_init (LCD *Self)
return -1;
}
- if (cfg_number("Icons", 0, 0, 8, &icons) < 0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, 8, &icons) < 0) return -1;
if (icons>0) {
info ("allocating %d icons", icons);
icon_init(rows, cols, xres, yres, 8, icons, pix_icon);
diff --git a/T6963.c b/T6963.c
index 5c53af3..37d3412 100644
--- a/T6963.c
+++ b/T6963.c
@@ -1,4 +1,4 @@
-/* $Id: T6963.c,v 1.13 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: T6963.c,v 1.14 2004/01/09 04:16:06 reinelt Exp $
*
* driver for display modules based on the Toshiba T6963 chip
*
@@ -22,6 +22,9 @@
*
*
* $Log: T6963.c,v $
+ * Revision 1.14 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.13 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -349,7 +352,7 @@ int T6_init (LCD *Self)
return -1;
}
- if (cfg_number("Icons", 0, 0, 8, &Icons) < 0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, 8, &Icons) < 0) return -1;
if (Icons>0) {
info ("allocating %d icons", Icons);
icon_init(Lcd.rows, Lcd.cols, Lcd.xres, Lcd.yres, 8, Icons, pix_icon);
diff --git a/Text.c b/Text.c
index fc3ba33..09e8db9 100644
--- a/Text.c
+++ b/Text.c
@@ -1,4 +1,4 @@
-/* $Id: Text.c,v 1.12 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: Text.c,v 1.13 2004/01/09 04:16:06 reinelt Exp $
*
* pure ncurses based text driver
*
@@ -22,6 +22,9 @@
*
*
* $Log: Text.c,v $
+ * Revision 1.13 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.12 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -138,7 +141,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(NULL, "size", "20x4"), "%dx%d", &cols, &rows)!=2 || rows<1 || cols<1) {
error ("Text: bad size '%s'", s);
return -1;
}
@@ -223,7 +226,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", NULL))
+ if (cfg_get(NULL, "TextBar", NULL))
mvwprintw(w, row+1 , col+1, "%d %d %d", max, len1, len2);
else {
len = min(len1, len2);
diff --git a/USBLCD.c b/USBLCD.c
index 56b22b2..0896abb 100644
--- a/USBLCD.c
+++ b/USBLCD.c
@@ -1,4 +1,4 @@
-/* $Id: USBLCD.c,v 1.19 2004/01/06 22:33:14 reinelt Exp $
+/* $Id: USBLCD.c,v 1.20 2004/01/09 04:16:06 reinelt Exp $
*
* Driver for USBLCD (see http://www.usblcd.de)
*
@@ -25,6 +25,9 @@
*
*
* $Log: USBLCD.c,v $
+ * Revision 1.20 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.19 2004/01/06 22:33:14 reinelt
* Copyright statements cleaned up
*
@@ -251,7 +254,7 @@ int USBLCD_init (LCD *Self)
free(Port);
Port=NULL;
}
- if ((port=cfg_get("Port",NULL))==NULL || *port=='\0') {
+ if ((port=cfg_get(NULL, "Port", NULL))==NULL || *port=='\0') {
error ("USBLCD: no 'Port' entry in %s", cfg_source());
return -1;
}
@@ -264,7 +267,7 @@ int USBLCD_init (LCD *Self)
debug ("using device %s ", Port);
- s=cfg_get("Size",NULL);
+ s=cfg_get(NULL, "Size", NULL);
if (s==NULL || *s=='\0') {
error ("USBLCD: no 'Size' entry in %s", cfg_source());
return -1;
@@ -296,7 +299,7 @@ int USBLCD_init (LCD *Self)
if (USBLCD_open()!=0)
return -1;
- if (cfg_number("Icons", 0, 0, CHARS, &Icons)<0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, CHARS, &Icons)<0) return -1;
if (Icons>0) {
debug ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, USBLCD_define_char);
diff --git a/XWindow.c b/XWindow.c
index fdcaf89..baae92e 100644
--- a/XWindow.c
+++ b/XWindow.c
@@ -1,4 +1,4 @@
-/* $Id: XWindow.c,v 1.37 2004/01/06 22:33:14 reinelt Exp $
+/* $Id: XWindow.c,v 1.38 2004/01/09 04:16:06 reinelt Exp $
*
* X11 Driver for LCD4Linux
*
@@ -22,6 +22,9 @@
*
*
* $Log: XWindow.c,v $
+ * Revision 1.38 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.37 2004/01/06 22:33:14 reinelt
* Copyright statements cleaned up
*
@@ -411,22 +414,22 @@ int xlcdinit(LCD *Self)
{
char *s;
- if (sscanf(s=cfg_get("size","20x4"),"%dx%d",&cols,&rows)!=2
+ if (sscanf(s=cfg_get(NULL, "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(NULL, "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(NULL, "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","-1x-1"),"%dx%d",&cgap,&rgap)!=2
+ if (sscanf(s=cfg_get(NULL, "gap", "-1x-1"),"%dx%d",&cgap,&rgap)!=2
|| cgap<-1 || rgap<-1) {
error ("X11: bad gap '%s'",s);
return -1;
@@ -434,18 +437,18 @@ int xlcdinit(LCD *Self)
if (rgap<0) rgap=pixel+pgap;
if (cgap<0) cgap=pixel+pgap;
- if (cfg_number("border", 0, 0, 1000000, &border)<0) return -1;
+ if (cfg_number(NULL, "border", 0, 0, 1000000, &border)<0) return -1;
- rgbfg=cfg_get("foreground","#000000");
- rgbbg=cfg_get("background","#80d000");
- rgbhg=cfg_get("halfground","#70c000");
+ rgbfg=cfg_get(NULL, "foreground", "#000000");
+ rgbbg=cfg_get(NULL, "background", "#80d000");
+ rgbhg=cfg_get(NULL, "halfground", "#70c000");
if (*rgbfg=='\\') rgbfg++;
if (*rgbbg=='\\') rgbbg++;
if (*rgbhg=='\\') rgbhg++;
if (pix_init(rows,cols,xres,yres)==-1) return -1;
- if (cfg_number("Icons", 0, 0, 8, &icons) < 0) return -1;
+ if (cfg_number(NULL, "Icons", 0, 0, 8, &icons) < 0) return -1;
if (icons>0) {
info ("allocating %d icons", icons);
icon_init(rows, cols, xres, yres, 8, icons, pix_icon);
diff --git a/cfg.c b/cfg.c
index 0940def..bfcfde0 100644
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.22 2004/01/08 06:00:28 reinelt Exp $^
+/* $Id: cfg.c,v 1.23 2004/01/09 04:16:06 reinelt Exp $^
*
* config file stuff
*
@@ -23,13 +23,16 @@
*
*
* $Log: cfg.c,v $
+ * Revision 1.23 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.22 2004/01/08 06:00:28 reinelt
* allowed '.' in key names
- * allowed empty group keys (not only "group anything {", but "anything {")
+ * allowed empty section keys (not only "section anything {", but "anything {")
*
* Revision 1.21 2004/01/08 05:28:12 reinelt
* Luk Claes added to AUTHORS
- * cfg: group handling ('{}') added
+ * cfg: section handling ('{}') added
*
* Revision 1.20 2004/01/07 10:15:41 reinelt
* small glitch in evaluator fixed
@@ -141,10 +144,15 @@
* cfg_cmd can be called _before_ cfg_read()
* returns 0 if ok, -1 if arg cannot be parsed
*
- * cfg_get (key, defval)
- * return the a value for a given key
+ * cfg_get (section, key, defval)
+ * return the a value for a given key in a given section
* or <defval> if key does not exist
*
+ * cfg_number (section, key, defval, min, int max, *value)
+ * return the a value for a given key in a given section
+ * convert it into a number with syntax checking
+ * check if its in a given range
+ *
*/
@@ -247,26 +255,29 @@ static int validchars (char *string)
}
-static void cfg_add (char *group, char *key, char *val, int lock)
+static void cfg_add (char *section, char *key, char *val, int lock)
{
char *buffer;
ENTRY *entry;
// allocate buffer
- buffer=malloc(strlen(group)+strlen(key)+2);
+ buffer=malloc(strlen(section)+strlen(key)+2);
*buffer='\0';
- // prepare group:key
- if (*group!='\0') {
- strcpy(buffer, group);
+ // prepare section.key
+ if (section!=NULL && *section!='\0') {
+ strcpy(buffer, section);
strcat(buffer, ".");
}
strcat (buffer, key);
+ // does the key already exist?
entry=bsearch(buffer, Config, nConfig, sizeof(ENTRY), c_lookup);
if (entry!=NULL) {
+ free (buffer);
if (entry->lock>lock) return;
+ debug ("Warning: key '%s': value '%s' overwritten with '%s'", buffer, entry->val, val);
if (entry->val) free (entry->val);
entry->val=dequote(strdup(val));
return;
@@ -303,11 +314,33 @@ int l4l_cfg_cmd (char *arg)
}
-char *l4l_cfg_get (char *key, char *defval)
+char *l4l_cfg_get (char *section, char *key, char *defval)
{
+ int len;
+ char *buffer;
ENTRY *entry;
- entry=bsearch(key, Config, nConfig, sizeof(ENTRY), c_lookup);
+ // calculate key length
+ len=strlen(key)+1;
+ if (section!=NULL)
+ len+=strlen(section)+1;
+
+ // allocate buffer
+ buffer=malloc(len);
+ *buffer='\0';
+
+ // prepare section:key
+ if (section!=NULL && *section!='\0') {
+ strcpy(buffer, section);
+ strcat(buffer, ".");
+ }
+ strcat (buffer, key);
+
+ // search entry
+ entry=bsearch(buffer, Config, nConfig, sizeof(ENTRY), c_lookup);
+
+ // free buffer again
+ free (buffer);
if (entry!=NULL)
return entry->val;
@@ -316,12 +349,12 @@ char *l4l_cfg_get (char *key, char *defval)
}
-int l4l_cfg_number (char *key, int defval, int min, int max, int *value)
+int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int *value)
{
char *s, *e;
- s=cfg_get(key, NULL);
+ s=cfg_get(section, key, NULL);
if (s==NULL) {
*value=defval;
return 0;
@@ -392,9 +425,9 @@ static int cfg_read (char *file)
{
FILE *stream;
char buffer[256];
- char group[256];
+ char section[256];
char *line, *key, *val, *end;
- int group_open, group_close;
+ int section_open, section_close;
int error, lineno;
stream=fopen (file, "r");
@@ -403,8 +436,8 @@ static int cfg_read (char *file)
return -1;
}
- // start with empty group
- strcpy(group, "");
+ // start with empty section
+ strcpy(section, "");
error=0;
lineno=0;
@@ -416,9 +449,9 @@ static int cfg_read (char *file)
// skip empty lines
if (*(line=strip(line, 1))=='\0') continue;
- // reset group flags
- group_open=0;
- group_close=0;
+ // reset section flags
+ section_open=0;
+ section_close=0;
// key is first word
key=line;
@@ -438,9 +471,9 @@ static int cfg_read (char *file)
if (*val) for (end=val; *(end+1); end++);
else end=val;
- // if last char is '{', a group has been opened
+ // if last char is '{', a section has been opened
if (*end=='{') {
- group_open=1;
+ section_open=1;
*end='\0';
val=strip(val, 0);
}
@@ -457,14 +490,14 @@ static int cfg_read (char *file)
val++;
}
- // if key is '}', a group has been closed
+ // if key is '}', a section has been closed
if (strcmp(key, "}")==0) {
- group_close=1;
+ section_close=1;
*key='\0';
}
// sanity check: '}' should be the only char in a line
- if (group_close && (group_open || *val!='\0')) {
+ if (section_close && (section_open || *val!='\0')) {
error ("error in config file '%s' line %d: garbage after '}'", file, lineno);
error=1;
break;
@@ -477,55 +510,54 @@ static int cfg_read (char *file)
break;
}
- // on group-open, check value for valid chars
- if (group_open && !validchars(val)) {
- error ("error in config file '%s' line %d: group '%s' is invalid", file, lineno, val);
+ // on section-open, check value for valid chars
+ if (section_open && !validchars(val)) {
+ error ("error in config file '%s' line %d: section '%s' is invalid", file, lineno, val);
error=1;
break;
}
- // on group-open, append new group name
- if (group_open) {
- // is the group[] array big enough?
- if (strlen(group)+strlen(key)+3 > sizeof(group)) {
- error ("error in config file '%s' line %d: group buffer overflow", file, lineno);
+ // on section-open, append new section name
+ if (section_open) {
+ // is the section[] array big enough?
+ if (strlen(section)+strlen(key)+3 > sizeof(section)) {
+ error ("error in config file '%s' line %d: section buffer overflow", file, lineno);
error=1;
break;
}
- if (*group!='\0') strcat (group, ".");
- strcat (group, key);
+ if (*section!='\0') strcat (section, ".");
+ strcat (section, key);
if (*val!='\0') {
- strcat (group, ":");
- strcat (group, val);
+ strcat (section, ":");
+ strcat (section, val);
}
continue;
}
- // on group-close, remove last group name
- if (group_close) {
- // sanity check: group already empty?
- if (*group=='\0') {
+ // on section-close, remove last section name
+ if (section_close) {
+ // sanity check: section already empty?
+ if (*section=='\0') {
error ("error in config file '%s' line %d: unmatched closing brace", file, lineno);
error=1;
break;
}
- end=strrchr(group, '.');
+ end=strrchr(section, '.');
if (end==NULL)
- *group='\0';
+ *section='\0';
else
*end='\0';
continue;
}
// finally: add key
- debug ("Michi: add group=<%s> key=<%s> val=<%s>", group, key, val);
- cfg_add (group, key, val, 0);
+ cfg_add (section, key, val, 0);
}
// sanity check: are the braces balanced?
- if (!error && *group!='\0') {
+ if (!error && *section!='\0') {
error ("error in config file '%s' line %d: unbalanced braces", file, lineno);
error=1;
}
@@ -536,9 +568,35 @@ static int cfg_read (char *file)
}
-static void cfg_plugin (RESULT *result, RESULT *arg1)
+static void cfg_plugin (RESULT *result, int argc, RESULT *argv[])
{
- char *value=cfg_get(R2S(arg1), "");
+ int i, len;
+ char *value;
+ char *buffer;
+
+ // calculate key length
+ len=0;
+ for (i=0; i<argc; i++) {
+ len+=strlen(R2S(argv[i]))+1;
+ }
+
+ // allocate key buffer
+ buffer=malloc(len+1);
+
+ // prepare key buffer
+ *buffer='\0';
+ for (i=0; i<argc; i++) {
+ strcat (buffer, ".");
+ strcat (buffer, R2S(argv[i]));
+ }
+
+ // buffer starts with '.', so cut off first char
+ value=cfg_get("", buffer+1, "");
+
+ // free buffer again
+ free (buffer);
+
+ // store result
SetResult(&result, R_STRING, value);
}
@@ -556,7 +614,7 @@ int l4l_cfg_init (char *file)
Config_File=strdup(file);
// register as a plugin
- AddFunction ("cfg", 1, cfg_plugin);
+ AddFunction ("cfg", -1, cfg_plugin);
return 0;
}
@@ -571,9 +629,9 @@ char *l4l_cfg_source (void)
}
-int (*cfg_init) (char *source) = l4l_cfg_init;
-char *(*cfg_source) (void) = l4l_cfg_source;
-int (*cfg_cmd) (char *arg) = l4l_cfg_cmd;
-char *(*cfg_get) (char *key, char *defval) = l4l_cfg_get;
-int (*cfg_number) (char *key, int defval,
- int min, int max, int *value) = l4l_cfg_number;
+int (*cfg_init) (char *source) = l4l_cfg_init;
+char *(*cfg_source) (void) = l4l_cfg_source;
+int (*cfg_cmd) (char *arg) = l4l_cfg_cmd;
+char *(*cfg_get) (char *section, char *key, char *defval) = l4l_cfg_get;
+int (*cfg_number) (char *section, char *key, int defval,
+ int min, int max, int *value) = l4l_cfg_number;
diff --git a/cfg.h b/cfg.h
index ab875e7..b1fa8d6 100644
--- a/cfg.h
+++ b/cfg.h
@@ -1,4 +1,4 @@
-/* $Id: cfg.h,v 1.6 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: cfg.h,v 1.7 2004/01/09 04:16:06 reinelt Exp $
*
* config file stuff
*
@@ -22,6 +22,9 @@
*
*
* $Log: cfg.h,v $
+ * Revision 1.7 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.6 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -54,15 +57,15 @@
extern int (*cfg_init) (char *source);
extern char *(*cfg_source) (void);
extern int (*cfg_cmd) (char *arg);
-extern char *(*cfg_get) (char *key, char *defval);
-extern int (*cfg_number) (char *key, int defval,
+extern char *(*cfg_get) (char *section, char *key, char *defval);
+extern int (*cfg_number) (char *section, char *key, int defval,
int min, int max, int *value);
int l4l_cfg_init (char *file);
char *l4l_cfg_source (void);
int l4l_cfg_cmd (char *arg);
-char *l4l_cfg_get (char *key, char *defval);
-int l4l_cfg_number (char *key, int defval,
+char *l4l_cfg_get (char *section, char *key, char *defval);
+int l4l_cfg_number (char *section, char *key, int defval,
int min, int max, int *value);
#endif
diff --git a/exec.c b/exec.c
index 2402415..903d5e4 100644
--- a/exec.c
+++ b/exec.c
@@ -1,4 +1,4 @@
-/* $Id: exec.c,v 1.10 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: exec.c,v 1.11 2004/01/09 04:16:06 reinelt Exp $
*
* exec ('x*') functions
*
@@ -22,6 +22,9 @@
*
*
* $Log: exec.c,v $
+ * Revision 1.11 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.10 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -105,7 +108,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,NULL);
+ p = cfg_get(NULL, xn, NULL);
if (p && *p) {
if (ticks[index]++ % atoi(p) != 0)
return 0;
@@ -113,7 +116,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(NULL, xn, "1"))) {
return 0;
}
}
@@ -122,7 +125,7 @@ int Exec(int index, char buff[EXEC_TXT_LEN], double *val)
*val = -1;
sprintf(xn, "x%d", index);
- command = cfg_get(xn,NULL);
+ command = cfg_get(NULL, xn, NULL);
if (!command || !*command) {
error("Empty command for 'x%d'", index);
@@ -162,9 +165,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"));
+ max = atof(cfg_get(NULL, xn, "100"));
sprintf(xn, "Min_x%d", index);
- min = atof(cfg_get(xn,"0"));
+ min = atof(cfg_get(NULL, xn, "0"));
if (max != min)
*val = (*val - min)/(max - min);
}
diff --git a/expr.c b/expr.c
index 87d370b..2464a99 100644
--- a/expr.c
+++ b/expr.c
@@ -1,4 +1,4 @@
-/* $Id: expr.c,v 1.1 2004/01/05 11:57:38 reinelt Exp $
+/* $Id: expr.c,v 1.2 2004/01/09 04:16:06 reinelt Exp $
*
* expr ('y*') functions
* This is only a workaround to make the Evaluator usable until
@@ -24,6 +24,9 @@
*
*
* $Log: expr.c,v $
+ * Revision 1.2 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.1 2004/01/05 11:57:38 reinelt
* added %y tokens to make the Evaluator useable
*
@@ -56,7 +59,7 @@ int Expr(int index, char result[EXPR_TXT_LEN], double *val)
return -1;
sprintf(yn, "y%d", index);
- expression = cfg_get(yn,NULL);
+ expression = cfg_get(NULL, yn, NULL);
if (!expression || !*expression) {
error("Empty expression for 'y%d'", index);
@@ -73,9 +76,9 @@ int Expr(int index, char result[EXPR_TXT_LEN], double *val)
double max, min;
*val = atof(result);
sprintf(yn, "Max_y%d", index);
- max = atof(cfg_get(yn,"100"));
+ max = atof(cfg_get(NULL, yn, "100"));
sprintf(yn, "Min_y%d", index);
- min = atof(cfg_get(yn,"0"));
+ min = atof(cfg_get(NULL, yn, "0"));
if (max != min)
*val = (*val - min)/(max - min);
}
diff --git a/filter.c b/filter.c
index 4a7a0d4..53d0472 100644
--- a/filter.c
+++ b/filter.c
@@ -1,4 +1,4 @@
-/* $Id: filter.c,v 1.8 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: filter.c,v 1.9 2004/01/09 04:16:06 reinelt Exp $
*
* smooth and damp functions
*
@@ -22,6 +22,9 @@
*
*
* $Log: filter.c,v $
+ * Revision 1.9 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.8 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -147,7 +150,7 @@ double damp(char *name, double value)
int i, j;
if (tau==-1)
- if (cfg_number("tau", 500, 0, 1000000, &tau)<0) tau=0.0;
+ if (cfg_number(NULL, "tau", 500, 0, 1000000, &tau)<0) tau=0.0;
if (tau==0.0)
return value;
diff --git a/icon.c b/icon.c
index cce5ab0..b21e456 100644
--- a/icon.c
+++ b/icon.c
@@ -1,4 +1,4 @@
-/* $Id: icon.c,v 1.11 2003/10/22 04:32:25 reinelt Exp $
+/* $Id: icon.c,v 1.12 2004/01/09 04:16:06 reinelt Exp $
*
* generic icon and heartbeat handling
*
@@ -22,6 +22,9 @@
*
*
* $Log: icon.c,v $
+ * Revision 1.12 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.11 2003/10/22 04:32:25 reinelt
* fixed icon bug found by Rob van Nieuwkerk
*
@@ -114,7 +117,7 @@ static int icon_read_bitmap (int num)
for (row=0; row<YRES; row++) {
snprintf (key, sizeof(key), "Icon%d.Bitmap%d", num+1, row+1);
- val=cfg_get(key, "");
+ val=cfg_get(NULL, key, "");
map=bm->Data+row;
n=0;
for (v=val; *v!='\0'; v++) {
diff --git a/imon.c b/imon.c
index 1f34766..7d8321e 100755
--- a/imon.c
+++ b/imon.c
@@ -1,4 +1,4 @@
-/* $Id: imon.c,v 1.2 2004/01/06 22:33:14 reinelt Exp $
+/* $Id: imon.c,v 1.3 2004/01/09 04:16:06 reinelt Exp $
*
* imond/telmond data processing
*
@@ -22,6 +22,9 @@
*
*
* $Log: imon.c,v $
+ * Revision 1.3 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.2 2004/01/06 22:33:14 reinelt
* Copyright statements cleaned up
*
@@ -221,19 +224,19 @@ int init(){
int port;
int connect;
- host=cfg_get ("Imon_Host","127.0.0.1");
+ host=cfg_get (NULL, "Imon_Host", "127.0.0.1");
if (*host=='\0') {
error ("Imon: no 'Imon_Host' entry in %s", cfg_source());
return -1;
}
- if (cfg_number("Imon_Port",5000,1,65536,&port)<0){
+ if (cfg_number(NULL, "Imon_Port", 5000,1,65536,&port)<0){
return -1;
}
connect=service_connect(host,port);
- s=cfg_get ("Imon_Pass",NULL);
+ s=cfg_get (NULL, "Imon_Pass", NULL);
if ((s!=NULL) && (*s!='\0')) { // Passwort senden
char buf[40];
sprintf(buf,"pass %s",s);
@@ -255,7 +258,7 @@ int ImonCh(int index, struct imonchannel *ch, int token_usage[]) {
if ((*ch).max_in == 0){ // not initializied
sprintf(buf, "Imon_%d_Dev", index);
- s=cfg_get(buf,NULL);
+ s=cfg_get(NULL, buf, NULL);
if (s==NULL) {
error ("Imon: no 'Imon_%i_Dev' entry in %s", index, cfg_source());
err[index]=1;
@@ -264,10 +267,10 @@ int ImonCh(int index, struct imonchannel *ch, int token_usage[]) {
strcpy((*ch).dev,s);
sprintf(buf, "Imon_%d_MaxIn", index);
- cfg_number(buf,768,1,65536,&(*ch).max_in);
+ cfg_number(NULL, buf,768,1,65536,&(*ch).max_in);
sprintf(buf, "Imon_%d_MaxOut", index);
- cfg_number(buf,128,1,65536,&(*ch).max_out);
+ cfg_number(NULL, buf, 128,1,65536,&(*ch).max_out);
}
sprintf(buf, "status %s", (*ch).dev);
@@ -377,7 +380,7 @@ void phonebook(char *number){
FILE * fp;
char line[256];
- fp = fopen (cfg_get ("Telmon_Phonebook","/etc/phonebook"), "r");
+ fp = fopen (cfg_get (NULL, "Telmon_Phonebook","/etc/phonebook"), "r");
if (! fp) return;
@@ -408,7 +411,7 @@ int Telmon(struct telmon *t){
if (tick++ % 50 != 0) return 0;
if (telmond_fd == -2){ //not initializied
- char *s=cfg_get ("Telmon_Host","127.0.0.1");
+ char *s=cfg_get (NULL, "Telmon_Host","127.0.0.1");
if (*s=='\0') {
error ("Telmon: no 'Telmon_Host' entry in %s", cfg_source());
telmond_fd=-1;
@@ -416,7 +419,7 @@ int Telmon(struct telmon *t){
}
strcpy(host,s);
- if (cfg_number("Telmon_Port",5000,1,65536,&port)<0){
+ if (cfg_number(NULL, "Telmon_Port",5000,1,65536,&port)<0){
telmond_fd=-1;
return -1;
}
diff --git a/lcd4linux.c b/lcd4linux.c
index d9ac05f..4e51b50 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.54 2004/01/08 05:28:12 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.55 2004/01/09 04:16:06 reinelt Exp $
*
* LCD4Linux
*
@@ -22,6 +22,9 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.55 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.54 2004/01/08 05:28:12 reinelt
* Luk Claes added to AUTHORS
* cfg: group handling ('{}') added
@@ -448,7 +451,7 @@ int main (int argc, char *argv[])
if (cfg_init(cfg)==-1)
exit (1);
- driver=cfg_get("display",NULL);
+ driver=cfg_get(NULL, "display", NULL);
if (driver==NULL || *driver=='\0') {
error ("missing 'display' entry in %s!", cfg_source());
exit (1);
@@ -542,7 +545,7 @@ int main (int argc, char *argv[])
// check the conf to see if quiet startup is wanted
if (!quiet) {
- quiet = atoi(cfg_get("Quiet", "0"));
+ quiet = atoi(cfg_get(NULL, "Quiet", "0"));
}
if (!quiet && hello()) {
diff --git a/mail.c b/mail.c
index d5350c3..27e9b30 100644
--- a/mail.c
+++ b/mail.c
@@ -1,4 +1,4 @@
-/* $Id: mail.c,v 1.13 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: mail.c,v 1.14 2004/01/09 04:16:06 reinelt Exp $
*
* email specific functions
*
@@ -22,6 +22,9 @@
*
*
* $Log: mail.c,v $
+ * Revision 1.14 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.13 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -129,7 +132,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(NULL, txt1, "5")))
return 0; // no more then 5/Delay_eX seconds after last check?
}
time(&now[index]); // for Mailbox #index
@@ -137,7 +140,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,NULL);
+ fnp1=cfg_get(NULL, buffer, NULL);
if (fnp1==NULL || *fnp1=='\0') {
cfgmbx[index]=FALSE; // There is now entry for Mailbox #index
}
diff --git a/mail2.c b/mail2.c
index 56ebcad..f543b86 100644
--- a/mail2.c
+++ b/mail2.c
@@ -1,4 +1,4 @@
-/* $Id: mail2.c,v 1.9 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: mail2.c,v 1.10 2004/01/09 04:16:06 reinelt Exp $
*
* mail: pop3, imap, news functions
*
@@ -22,6 +22,9 @@
*
*
* $Log: mail2.c,v $
+ * Revision 1.10 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.9 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -209,7 +212,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(NULL, "Newsrc", ".newsrc"));
if (*buf == 0 || ((fp = fopen(buf, "r")) == NULL)) {
error("Couldn't open .newsrc-file '%s'", buf);
return -1;
diff --git a/parport.c b/parport.c
index 1ebf340..5c4d597 100644
--- a/parport.c
+++ b/parport.c
@@ -1,4 +1,4 @@
-/* $Id: parport.c,v 1.11 2003/10/08 14:21:10 reinelt Exp $
+/* $Id: parport.c,v 1.12 2004/01/09 04:16:06 reinelt Exp $
*
* generic parallel port handling
*
@@ -22,6 +22,9 @@
*
*
* $Log: parport.c,v $
+ * Revision 1.12 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.11 2003/10/08 14:21:10 reinelt
* Changelog; small type in parport.c
*
@@ -159,12 +162,12 @@ int parport_open (void)
char *s, *e;
#ifdef USE_OLD_UDELAY
- if (cfg_number("Delay", 0, 1, 1000000000, &loops_per_usec)<0) return -1;
+ if (cfg_number(NULL, "Delay", 0, 1, 1000000000, &loops_per_usec)<0) return -1;
#else
udelay_init();
#endif
- s=cfg_get ("Port",NULL);
+ s=cfg_get (NULL, "Port", NULL);
if (s==NULL || *s=='\0') {
error ("parport: no 'Port' entry in %s", cfg_source());
return -1;
@@ -265,7 +268,7 @@ unsigned char parport_wire_ctrl (char *name, unsigned char *deflt)
char *s;
snprintf (wire, sizeof(wire), "Wire.%s", name);
- s=cfg_get (wire,deflt);
+ s=cfg_get (NULL, wire, deflt);
if (strcasecmp(s,"STROBE")==0) {
w=PARPORT_CONTROL_STROBE;
} else if(strcasecmp(s,"AUTOFD")==0) {
@@ -309,7 +312,7 @@ unsigned char parport_wire_data (char *name, unsigned char *deflt)
char *s;
snprintf (wire, sizeof(wire), "Wire.%s", name);
- s=cfg_get (wire,deflt);
+ s=cfg_get (NULL, wire, deflt);
if(strlen(s)==3 && strncasecmp(s,"DB",2)==0 && s[2]>='0' && s[2]<='7') {
w=s[2]-'0';
} else if(strcasecmp(s,"GND")==0) {
diff --git a/processor.c b/processor.c
index dc23cbe..dab74df 100644
--- a/processor.c
+++ b/processor.c
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.52 2004/01/05 11:57:38 reinelt Exp $
+/* $Id: processor.c,v 1.53 2004/01/09 04:16:06 reinelt Exp $
*
* main data processing
*
@@ -22,6 +22,9 @@
*
*
* $Log: processor.c,v $
+ * Revision 1.53 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.52 2004/01/05 11:57:38 reinelt
* added %y tokens to make the Evaluator useable
*
@@ -474,7 +477,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(NULL, "battwarning", "10")) && !alarm) /* flash bar */
value = 0;
return value/100;
}
@@ -947,7 +950,7 @@ void process_init (void)
{
int i;
- load.overload=atof(cfg_get("overload","2.0"));
+ load.overload=atof(cfg_get(NULL, "overload", "2.0"));
lcd_query (&rows, &cols, &xres, &yres, &supported_bars, &icons, &gpos);
@@ -966,7 +969,7 @@ void process_init (void)
debug ("Display: %d rows, %d columns, %dx%d pixels, %d icons, %d GPOs", rows, cols, xres, yres, icons, gpos);
- if (cfg_number("Rows", 1, 1, 1000, &lines)<0) {
+ if (cfg_number(NULL, "Rows", 1, 1, 1000, &lines)<0) {
lines=1;
error ("ignoring bad 'Rows' value and using '%d'", lines);
}
@@ -975,7 +978,7 @@ void process_init (void)
lines=ROWS;
}
if (lines>rows) {
- if (cfg_number("Scroll", 1, 1, 1000, &scroll)<0) {
+ if (cfg_number(NULL, "Scroll", 1, 1, 1000, &scroll)<0) {
scroll=1;
error ("ignoring bad 'Scroll' value and using '%d'", scroll);
}
@@ -983,7 +986,7 @@ void process_init (void)
error ("'Scroll' entry in %s is %d, > %d display rows.", cfg_source(), scroll, rows);
error ("This may lead to unexpected results!");
}
- if (cfg_number("Fixed", 0, -1000000, 1000000, &fixed)<0) {
+ if (cfg_number(NULL, "Fixed", 0, -1000000, 1000000, &fixed)<0) {
fixed=0;
error ("ignoring bad 'Fixed' value and using '%d'", fixed);
}
@@ -992,7 +995,7 @@ void process_init (void)
fixed=(fixed<0)? -rows+1 : rows-1;
error ("ignoring bad 'Fixed' value and using '%d'", fixed);
}
- if (cfg_number("Turn", 1000, 1, 1000000, &turn)<0) {
+ if (cfg_number(NULL, "Turn", 1000, 1, 1000000, &turn)<0) {
turn=1000;
error ("ignoring bad 'Scroll' value and using '%d'", turn);
}
@@ -1004,19 +1007,19 @@ void process_init (void)
fixed=0;
}
- if (cfg_number("Tick.Text", 500, 1, 1000000, &tick_text)<0) {
+ if (cfg_number(NULL, "Tick.Text", 500, 1, 1000000, &tick_text)<0) {
tick_text=500;
error ("ignoring bad 'Tick.Text' value and using '%d'", tick_text);
}
- if (cfg_number("Tick.Bar", 100, 1, 1000000, &tick_bar)<0) {
+ if (cfg_number(NULL, "Tick.Bar", 100, 1, 1000000, &tick_bar)<0) {
tick_bar=100;
error ("ignoring bad 'Tick.Bar' value and using '%d'", tick_bar);
}
- if (cfg_number("Tick.Icon", 100, 1, 1000000, &tick_icon)<0) {
+ if (cfg_number(NULL, "Tick.Icon", 100, 1, 1000000, &tick_icon)<0) {
tick_icon=100;
error ("ignoring bad 'Tick.Icon' value and using '%d'", tick_icon);
}
- if (cfg_number("Tick.GPO", 100, 1, 1000000, &tick_gpo)<0) {
+ if (cfg_number(NULL, "Tick.GPO", 100, 1, 1000000, &tick_gpo)<0) {
tick_gpo=100;
error ("ignoring bad 'Tick.GPO' value and using '%d'", tick_gpo);
}
@@ -1044,7 +1047,7 @@ void process_init (void)
for (i=1; i<=lines; i++) {
char buffer[8], *p;
snprintf (buffer, sizeof(buffer), "Row%d", i);
- p=cfg_get(buffer,"");
+ p=cfg_get(NULL, buffer, "");
debug ("%s: %s", buffer, p);
row[i]=strdup(parse_row(p, supported_bars, token_usage));
}
@@ -1053,7 +1056,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(NULL, buffer, "");
debug ("%s: %s", buffer, p);
gpo[i]=parse_gpo(p, token_usage);
}
diff --git a/seti.c b/seti.c
index c387a52..a155e56 100644
--- a/seti.c
+++ b/seti.c
@@ -1,4 +1,4 @@
-/* $Id: seti.c,v 1.11 2004/01/06 22:33:14 reinelt Exp $
+/* $Id: seti.c,v 1.12 2004/01/09 04:16:06 reinelt Exp $
*
* seti@home specific functions
*
@@ -22,6 +22,9 @@
*
*
* $Log: seti.c,v $
+ * Revision 1.12 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.11 2004/01/06 22:33:14 reinelt
* Copyright statements cleaned up
*
@@ -111,7 +114,7 @@ int Seti (double *perc, double *cput)
time(&now);
if (fd==-2) {
- char *dir=cfg_get("SetiDir",NULL);
+ char *dir=cfg_get(NULL, "SetiDir", NULL);
if (dir==NULL || *dir=='\0') {
error ("no 'SetiDir' entry in %s!\n", cfg_source());
fd=-1;
diff --git a/system.c b/system.c
index f013ddd..7fc0919 100644
--- a/system.c
+++ b/system.c
@@ -1,4 +1,4 @@
-/* $Id: system.c,v 1.31 2003/12/01 07:08:51 reinelt Exp $
+/* $Id: system.c,v 1.32 2004/01/09 04:16:06 reinelt Exp $
*
* system status retreivement
*
@@ -22,6 +22,9 @@
*
*
* $Log: system.c,v $
+ * Revision 1.32 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.31 2003/12/01 07:08:51 reinelt
*
* Patches from Xavier:
@@ -792,7 +795,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, NULL);
+ sensor[index]=cfg_get(NULL, buffer, NULL);
if (sensor[index]==NULL || *sensor[index]=='\0') {
error ("no entry for '%s' in %s", buffer, cfg_source());
fd[index]=-1;
@@ -800,18 +803,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(NULL, 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(NULL, 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(NULL, buffer, "1"));
snprintf(buffer, 32, "Sensor%d_offset", index);
- offset_buf[index]=atof(cfg_get(buffer,"0"));
+ offset_buf[index]=atof(cfg_get(NULL, buffer, "0"));
fd[index]=open(sensor[index], O_RDONLY);
if (fd[index]==-1) {
diff --git a/wifi.c b/wifi.c
index 5984504..40958e7 100644
--- a/wifi.c
+++ b/wifi.c
@@ -1,4 +1,4 @@
-/* $Id: wifi.c,v 1.4 2004/01/06 22:33:14 reinelt Exp $
+/* $Id: wifi.c,v 1.5 2004/01/09 04:16:06 reinelt Exp $
*
* WIFI specific functions
*
@@ -25,6 +25,9 @@
*
*
* $Log: wifi.c,v $
+ * Revision 1.5 2004/01/09 04:16:06 reinelt
+ * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
+ *
* Revision 1.4 2004/01/06 22:33:14 reinelt
* Copyright statements cleaned up
*
@@ -75,7 +78,7 @@ int Wifi (int *signal, int *link, int *noise)
char buffer[4096];
char *p;
- char *interface=cfg_get("Wifi.Interface","wlan0");
+ char *interface=cfg_get(NULL, "Wifi.Interface", "wlan0");
*signal=0;
*link=0;