]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2000-04-03 04:46:38 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 3 Apr 2000 04:46:38 +0000 (04:46 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Mon, 3 Apr 2000 04:46:38 +0000 (04:46 +0000)
added '-c key=val' option

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@34 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

README
README.Raster
README.X11
cfg.c
cfg.h
lcd4linux.c
lcd4linux.conf.sample

diff --git a/README b/README
index 3840096cadb358d1f0e33f9afad8bcb1ff5d298b..6fc58d66ca70613714fc1183be5afdd86930ce55 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 #
-# $Id: README,v 1.2 2000/03/26 19:03:52 reinelt Exp $
+# $Id: README,v 1.3 2000/04/03 04:46:38 reinelt Exp $
 #
 
 This is the README file for lcd4linux
@@ -14,6 +14,21 @@ It supports displaying text values and different types of bars: Horizontal and
 vertical bars, logarithmic bars, split bars (two independent bars in one row).
 
 
+USAGE
+
+lcd4linux -h  
+print version number and a small help text, then exit
+
+lcd4linux -l 
+list available drivers
+
+lcd4linux [-c key=val] [-f config-file] [-o output]
+run lcd4linux 
+use configuration from 'config-file' instead of /etc/lcd4linux.conf
+write picture to 'output' (raster driver only)
+overwrite entries from the config-file with '-c'
+
+
 SUPPORTED DISPLAYS
 
 * Matrox Orbital <http://www.matrixorbital.com>
index b0e05b4ba2008d85fd9f505404743d6d74b6aab9..2ef517204b679292b45db421129e2322b9b94238 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: README.Raster,v 1.1 2000/03/26 20:00:44 reinelt Exp $
+# $Id: README.Raster,v 1.2 2000/04/03 04:46:38 reinelt Exp $
 #
 
 This is the README file for the Raster display driver for lcd4linux
@@ -38,7 +38,9 @@ pixelsize*pixelsize pixels. If you want to, you can emulate the gap
 between this lcd cells by specifying a pixelgap greater than zero.
 Sometimes there's a gap between characters, too. You can specify this 
 gap (in pixels again) horizontally and vertically. Usually this gap
-is the same size as a cell (which is pixelsize+pixelgap). 
+is the same size as a cell (which is pixelsize+pixelgap). If you specify
+either the row gap or the column gap as -1, this cell size will be used
+instead.
 
 If you use a font of 5x8, some characters may use the first and the last 
 pixel. So you should specify a column gap, otherwise the caracters may 
index 0df71a79c279eb42b343a1b99bbbffecaabffc37..7b5562425a3ceb4ab148ddc9a8c1fc6986c5267b 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: README.X11,v 1.1 2000/03/28 08:48:33 reinelt Exp $
+# $Id: README.X11,v 1.2 2000/04/03 04:46:38 reinelt Exp $
 #
 
 This is the README file for the X11 display driver for lcd4linux
@@ -34,7 +34,9 @@ pixelsize*pixelsize pixels. If you want to, you can emulate the gap
 between this lcd cells by specifying a pixelgap greater than zero.
 Sometimes there's a gap between characters, too. You can specify this 
 gap (in pixels again) horizontally and vertically. Usually this gap
-is the same size as a cell (which is pixelsize+pixelgap). 
+is the same size as a cell (which is pixelsize+pixelgap).  If you specify
+either the row gap or the column gap as -1, this cell size will be used
+instead.
 
 If you use a font of 5x8, some characters may use the first and the last 
 pixel. So you should specify a column gap, otherwise the caracters may 
diff --git a/cfg.c b/cfg.c
index 7a9fa141b0787debda489c92aaf101202a148e31..f44add395816131c641189b8b97f04f2e5627715 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.5 2000/03/28 07:22:15 reinelt Exp $
+/* $Id: cfg.c,v 1.6 2000/04/03 04:46:38 reinelt Exp $
  *
  * config file stuff
  *
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.6  2000/04/03 04:46:38  reinelt
+ *
+ * added '-c key=val' option
+ *
  * Revision 1.5  2000/03/28 07:22:15  reinelt
  *
  * version 0.95 released
 /* 
  * exported functions:
  *
+ * cfg_cmd (arg)
+ *   allows us to overwrite entries in the 
+ *   config-file from the command line.
+ *   arg is 'key=value'
+ *   cfg_cmd can be called _before_ cfg_read()
+ *   returns 0 if ok, -1 if arg cannot be parsed
+ *
  * cfg_set (key, value)
  *   pre-set key's value
  *   should be called before cfg_read()
@@ -85,6 +96,7 @@
 typedef struct {
   char *key;
   char *val;
+  int lock;
 } ENTRY;
 
 static char  *Config_File=NULL;
@@ -92,7 +104,7 @@ static ENTRY *Config=NULL;
 static int   nConfig=0;
 
 
-static char *strip (char *s)
+static char *strip (char *s, int strip_comments)
 {
   char *p;
   
@@ -100,7 +112,7 @@ static char *strip (char *s)
   for (p=s; *p; p++) {
     if (*p=='"') do p++; while (*p && *p!='\n' && *p!='"');
     if (*p=='\'') do p++; while (*p && *p!='\n' && *p!='\'');
-    if (*p=='\n' || (*p=='#' && (p==s || *(p-1)!='\\'))) {
+    if (*p=='\n' || (strip_comments && *p=='#' && (p==s || *(p-1)!='\\'))) {
       *p='\0';
       break;
     }
@@ -125,12 +137,13 @@ static char *dequote (char *string)
   return string;
 }
 
-void cfg_set (char *key, char *val)
+static void cfg_add (char *key, char *val, int lock)
 {
   int i;
   
   for (i=0; i<nConfig; i++) {
     if (strcasecmp(Config[i].key, key)==0) {
+      if (Config[i].lock>lock) return;
       if (Config[i].val) free (Config[i].val);
       Config[i].val=dequote(strdup(val));
       return;
@@ -140,6 +153,30 @@ void cfg_set (char *key, char *val)
   Config=realloc(Config, nConfig*sizeof(ENTRY));
   Config[i].key=strdup(key);
   Config[i].val=dequote(strdup(val));
+  Config[i].lock=lock;
+}
+
+int cfg_cmd (char *arg)
+{
+  char *key, *val;
+  char buffer[256];
+  
+  strncpy (buffer, arg, sizeof(buffer));
+  key=strip(buffer, 0);
+  for (val=key; *val; val++) {
+    if (*val=='=') {
+      *val++='\0';
+      break;
+    }
+  }
+  if (*key=='\0' || *val=='\0') return -1;
+  cfg_add (key, val, 1);
+  return 0;
+}
+
+void cfg_set (char *key, char *val)
+{
+  cfg_add (key, val, 0);
 }
 
 char *cfg_get (char *key)
@@ -170,14 +207,14 @@ int cfg_read (char *file)
   Config_File=strdup(file);
     
   while ((line=fgets(buffer,256,stream))!=NULL) {
-    if (*(line=strip(line))=='\0') continue;
+    if (*(line=strip(line, 1))=='\0') continue;
     for (p=line; *p; p++) {
       if (isblank(*p)) {
        *p++='\0';
        break;
       }
     }
-    p=strip(p);
+    p=strip(p, 1);
     if (*p) for (s=p; *(s+1); s++);
     else s=p;
     if (*p=='"' && *s=='"') {
diff --git a/cfg.h b/cfg.h
index 1cbad765588502bd45352777eaf9293d0f2eb1b6..0f7d778cd149ed0a151b0f420a7c60fcdf4af3fd 100644 (file)
--- a/cfg.h
+++ b/cfg.h
@@ -1,4 +1,4 @@
-/* $Id: cfg.h,v 1.1 2000/03/10 11:40:47 reinelt Exp $
+/* $Id: cfg.h,v 1.2 2000/04/03 04:46:38 reinelt Exp $
  *
  * config file stuff
  *
  *
  *
  * $Log: cfg.h,v $
+ * Revision 1.2  2000/04/03 04:46:38  reinelt
+ *
+ * added '-c key=val' option
+ *
  * Revision 1.1  2000/03/10 11:40:47  reinelt
  * *** empty log message ***
  *
@@ -33,6 +37,7 @@
 #ifndef _CFG_H_
 #define _CFG_H_
 
+int   cfg_cmd (char *arg);
 void  cfg_set (char *key, char *value);
 char *cfg_get (char *key);
 int   cfg_read (char *file);
index 9bbd28f7f496b8ea8ab793e4a0d162be10a58910..bd0fc7ff799a43170b13416e957fcee088b55f9e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.15 2000/04/01 22:40:42 herp Exp $
+/* $Id: lcd4linux.c,v 1.16 2000/04/03 04:46:38 reinelt Exp $
  *
  * LCD4Linux
  *
  *
  *
  * $Log: lcd4linux.c,v $
+ * Revision 1.16  2000/04/03 04:46:38  reinelt
+ *
+ * added '-c key=val' option
+ *
  * Revision 1.15  2000/04/01 22:40:42  herp
  * geometric correction (too many pixelgaps)
  * lcd4linux main should return int, not void
@@ -108,7 +112,7 @@ int tick, tack;
 static void usage(void)
 {
   printf ("%s\n", release);
-  printf ("usage: lcd4linux [-h] [-l] [-f config-file] [-o output-file]\n");
+  printf ("usage: lcd4linux [-h] [-l] [-c key=value] [-f config-file] [-o output-file]\n");
 }
 
 int main (int argc, char *argv[])
@@ -117,8 +121,14 @@ int main (int argc, char *argv[])
   char *driver;
   int c, smooth;
 
-  while ((c=getopt (argc, argv, "hlf:o:"))!=EOF) {
+  while ((c=getopt (argc, argv, "c:f:hlo:"))!=EOF) {
     switch (c) {
+    case 'c':
+      if (cfg_cmd (optarg)<0) {
+       fprintf (stderr, "%s: illegal argument -c %s\n", argv[0], optarg);
+       exit(2);
+      }
+      break;
     case 'h':
       usage();
       exit(0);
index 526f43061b79665905a4d1f7bbfccdbdf6b75411..271ca3a0b11ec7e913e6b1aac1ab48fe7ef1930f 100644 (file)
@@ -7,7 +7,7 @@
 #size 20x4
 #font 5x8
 #pixel 3+0
-#gap 3x3
+#gap -1x-1
 #border 10
 #foreground \#102000
 #halfground \#70c000
@@ -17,7 +17,7 @@ Display X11
 size 20x5
 font 5x8
 pixel 1+0
-gap 1x1
+gap -1x-1
 border 1
 foreground \#102000
 halfground \#90c000