diff options
author | reinelt <> | 2004-06-26 09:27:21 +0000 |
---|---|---|
committer | reinelt <> | 2004-06-26 09:27:21 +0000 |
commit | dc5568350b289278d2e85f8d8eaea4e652b4876c (patch) | |
tree | b14a2a596dd615ae17880b7007d6b2b78191af94 | |
parent | 3f9f909fa330cb2ff47b56c43d2a4c5e1dc0a8c0 (diff) | |
download | lcd4linux-dc5568350b289278d2e85f8d8eaea4e652b4876c.tar.gz |
[lcd4linux @ 2004-06-26 09:27:20 by reinelt]
added '-W' to CFLAGS
changed all C++ comments to C ones ('//' => '/* */')
cleaned up a lot of signed/unsigned mistakes
Diffstat (limited to '')
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | cfg.c | 94 | ||||
-rw-r--r-- | debug.c | 10 | ||||
-rw-r--r-- | drv.c | 15 | ||||
-rw-r--r-- | drv.h | 15 | ||||
-rw-r--r-- | drv_BeckmannEgle.c | 186 | ||||
-rw-r--r-- | drv_Crystalfontz.c | 332 | ||||
-rw-r--r-- | drv_Curses.c | 91 | ||||
-rw-r--r-- | drv_Cwlinux.c | 134 | ||||
-rw-r--r-- | drv_HD44780.c | 296 | ||||
-rw-r--r-- | drv_Image.c | 107 | ||||
-rw-r--r-- | drv_M50530.c | 138 | ||||
-rw-r--r-- | drv_MatrixOrbital.c | 146 | ||||
-rw-r--r-- | drv_MilfordInstruments.c | 102 | ||||
-rw-r--r-- | drv_NULL.c | 94 | ||||
-rw-r--r-- | drv_T6963.c | 208 | ||||
-rw-r--r-- | drv_USBLCD.c | 124 | ||||
-rw-r--r-- | drv_X11.c | 88 | ||||
-rw-r--r-- | drv_generic_graphic.c | 86 | ||||
-rw-r--r-- | drv_generic_graphic.h | 20 | ||||
-rw-r--r-- | drv_generic_parport.c | 46 | ||||
-rw-r--r-- | drv_generic_parport.h | 12 | ||||
-rw-r--r-- | drv_generic_serial.c | 31 | ||||
-rw-r--r-- | drv_generic_serial.h | 14 | ||||
-rw-r--r-- | drv_generic_text.c | 132 | ||||
-rw-r--r-- | drv_generic_text.h | 28 | ||||
-rw-r--r-- | evaluator.c | 246 | ||||
-rw-r--r-- | evaluator.h | 10 | ||||
-rw-r--r-- | hash.c | 135 | ||||
-rw-r--r-- | hash.h | 10 | ||||
-rw-r--r-- | layout.c | 22 | ||||
-rw-r--r-- | lcd4linux.c | 38 | ||||
-rw-r--r-- | pid.c | 13 | ||||
-rw-r--r-- | plugin.c | 10 | ||||
-rw-r--r-- | plugin_apm.c | 12 | ||||
-rw-r--r-- | plugin_cfg.c | 26 | ||||
-rw-r--r-- | plugin_cpuinfo.c | 20 | ||||
-rw-r--r-- | plugin_diskstats.c | 16 | ||||
-rw-r--r-- | plugin_dvb.c | 12 | ||||
-rw-r--r-- | plugin_exec.c | 52 | ||||
-rw-r--r-- | plugin_i2c_sensors.c | 46 | ||||
-rwxr-xr-x | plugin_imon.c | 24 | ||||
-rw-r--r-- | plugin_isdn.c | 18 | ||||
-rw-r--r-- | plugin_loadavg.c | 10 | ||||
-rw-r--r-- | plugin_math.c | 14 | ||||
-rw-r--r-- | plugin_meminfo.c | 24 | ||||
-rw-r--r-- | plugin_netdev.c | 18 | ||||
-rw-r--r-- | plugin_pop3.c | 41 | ||||
-rw-r--r-- | plugin_ppp.c | 12 | ||||
-rw-r--r-- | plugin_proc_stat.c | 12 | ||||
-rw-r--r-- | plugin_sample.c | 132 | ||||
-rw-r--r-- | plugin_seti.c | 22 | ||||
-rw-r--r-- | plugin_string.c | 11 | ||||
-rw-r--r-- | plugin_test.c | 32 | ||||
-rw-r--r-- | plugin_time.c | 11 | ||||
-rw-r--r-- | plugin_uptime.c | 22 | ||||
-rwxr-xr-x | plugin_wireless.c | 43 | ||||
-rw-r--r-- | plugin_xmms.c | 26 | ||||
-rw-r--r-- | qprintf.c | 36 | ||||
-rw-r--r-- | qprintf.h | 10 | ||||
-rw-r--r-- | timer.c | 36 | ||||
-rw-r--r-- | udelay.h | 12 | ||||
-rw-r--r-- | widget.c | 30 | ||||
-rw-r--r-- | widget.h | 10 | ||||
-rw-r--r-- | widget_bar.c | 39 | ||||
-rw-r--r-- | widget_bar.h | 38 | ||||
-rw-r--r-- | widget_icon.c | 42 | ||||
-rw-r--r-- | widget_icon.h | 30 | ||||
-rw-r--r-- | widget_text.c | 100 | ||||
-rw-r--r-- | widget_text.h | 40 |
71 files changed, 2274 insertions, 1842 deletions
diff --git a/Makefile.am b/Makefile.am index f70de52..63c79ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ PLUGINS=@PLUGINS@ bin_PROGRAMS = lcd4linux #lib_LTLIBRARIES = liblcd4linux.la -AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall +AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall -W lcd4linux_LDFLAGS = $(X_LIBS) lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@ diff --git a/Makefile.in b/Makefile.in index bfa654f..d88706b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -82,7 +82,7 @@ PLUGINS = @PLUGINS@ bin_PROGRAMS = lcd4linux #lib_LTLIBRARIES = liblcd4linux.la -AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall -ansi +AM_CFLAGS = $(X_CFLAGS) -D_GNU_SOURCE -Wall -W lcd4linux_LDFLAGS = $(X_LIBS) lcd4linux_LDADD = @DRIVERS@ @PLUGINS@ @DRVLIBS@ @PLUGINLIBS@ @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.40 2004/06/20 10:09:52 reinelt Exp $^ +/* $Id: cfg.c,v 1.41 2004/06/26 09:27:20 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,12 @@ * * * $Log: cfg.c,v $ + * Revision 1.41 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.40 2004/06/20 10:09:52 reinelt * * 'const'ified the whole source @@ -282,7 +288,7 @@ static ENTRY *Config=NULL; static int nConfig=0; -// bsearch compare function for config entries +/* bsearch compare function for config entries */ static int c_lookup (const void *a, const void *b) { char *key=(char*)a; @@ -292,7 +298,7 @@ static int c_lookup (const void *a, const void *b) } -// qsort compare function for variables +/* qsort compare function for variables */ static int c_sort (const void *a, const void *b) { ENTRY *ea=(ENTRY*)a; @@ -302,7 +308,7 @@ static int c_sort (const void *a, const void *b) } -// remove leading and trailing whitespace +/* remove leading and trailing whitespace */ static char *strip (char *s, const int strip_comments) { char *p; @@ -321,7 +327,7 @@ static char *strip (char *s, const int strip_comments) } -// unquote a string +/* unquote a string */ static char *dequote (char *string) { int quote=0; @@ -358,16 +364,16 @@ static char *dequote (char *string) } -// which if a string contains only valid chars -// i.e. start with a char and contains chars and nums +/* which if a string contains only valid chars */ +/* i.e. start with a char and contains chars and nums */ static int validchars (const char *string) { const char *c; for (c=string; *c; c++) { - // first and following chars + /* first and following chars */ if ((*c>='A' && *c<='Z') || (*c>='a' && *c<='z') || (*c=='_')) continue; - // only following chars + /* only following chars */ if ((c>string) && ((*c>='0' && *c<='9') || (*c=='.') || (*c=='-'))) continue; return 0; } @@ -380,18 +386,18 @@ static void cfg_add (const char *section, const char *key, const char *val, cons char *buffer; ENTRY *entry; - // allocate buffer + /* allocate buffer */ buffer=malloc(strlen(section)+strlen(key)+2); *buffer='\0'; - // prepare section.key + /* prepare section.key */ if (section!=NULL && *section!='\0') { strcpy(buffer, section); strcat(buffer, "."); } strcat (buffer, key); - // does the key already exist? + /* does the key already exist? */ entry=bsearch(buffer, Config, nConfig, sizeof(ENTRY), c_lookup); if (entry!=NULL) { @@ -439,19 +445,19 @@ char *cfg_list (const char *section) int i, len; char *key, *list; - // calculate key length + /* calculate key length */ len=strlen(section)+1; - // prepare search key + /* prepare search key */ key=malloc(len+1); strcpy (key, section); strcat (key, "."); - // start with empty string + /* start with empty string */ list=malloc(1); *list='\0'; - // search matching entries + /* search matching entries */ for (i=0; i<nConfig; i++) { if (strncasecmp(Config[i].key, key, len)==0) { list=realloc(list, strlen(list)+strlen(Config[i].key)-len+2); @@ -471,26 +477,26 @@ static char *cfg_lookup (const char *section, const char *key) char *buffer; ENTRY *entry; - // calculate key length + /* calculate key length */ len=strlen(key)+1; if (section!=NULL) len+=strlen(section)+1; - // allocate buffer + /* allocate buffer */ buffer=malloc(len); *buffer='\0'; - // prepare section:key + /* prepare section:key */ if (section!=NULL && *section!='\0') { strcpy(buffer, section); strcat(buffer, "."); } strcat (buffer, key); - // search entry + /* search entry */ entry=bsearch(buffer, Config, nConfig, sizeof(ENTRY), c_lookup); - // free buffer again + /* free buffer again */ free (buffer); if (entry!=NULL) @@ -540,9 +546,9 @@ int cfg_number (const char *section, const char *key, const int defval, const in void *tree = NULL; RESULT result = {0, 0, 0, NULL}; - // start with default value - // in case of an (uncatched) error, you have the - // default value set, which may be handy... + /* start with default value */ + /* in case of an (uncatched) error, you have the */ + /* default value set, which may be handy... */ *value=defval; expression=cfg_get_raw(section, key, NULL); @@ -635,27 +641,27 @@ static int cfg_read (const char *file) return -1; } - // start with empty section + /* start with empty section */ strcpy(section, ""); error=0; lineno=0; while ((line=fgets(buffer,256,stream))!=NULL) { - // increment line number + /* increment line number */ lineno++; - // skip empty lines + /* skip empty lines */ if (*(line=strip(line, 1))=='\0') continue; - // reset section flags + /* reset section flags */ section_open=0; section_close=0; - // key is first word + /* key is first word */ key=line; - // search first blank between key and value + /* search first blank between key and value */ for (val=line; *val; val++) { if (isblank(*val)) { *val++='\0'; @@ -663,56 +669,56 @@ static int cfg_read (const char *file) } } - // strip value + /* strip value */ val=strip(val, 1); - // search end of value + /* search end of value */ if (*val) for (end=val; *(end+1); end++); else end=val; - // if last char is '{', a section has been opened + /* if last char is '{', a section has been opened */ if (*end=='{') { section_open=1; *end='\0'; val=strip(val, 0); } - // provess "value" in double-quotes + /* provess "value" in double-quotes */ if (*val=='"' && *end=='"') { *end='\0'; val++; } - // if key is '}', a section has been closed + /* if key is '}', a section has been closed */ if (strcmp(key, "}")==0) { section_close=1; *key='\0'; } - // sanity check: '}' should be the only char in a line + /* sanity check: '}' should be the only char in a line */ if (section_close && (section_open || *val!='\0')) { error ("error in config file '%s' line %d: garbage after '}'", file, lineno); error=1; break; } - // check key for valid chars + /* check key for valid chars */ if (!validchars(key)) { error ("error in config file '%s' line %d: key '%s' is invalid", file, lineno, key); error=1; break; } - // on section-open, check value for valid chars + /* 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 section-open, append new section name + /* on section-open, append new section name */ if (section_open) { - // is the section[] array big enough? + /* 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; @@ -727,9 +733,9 @@ static int cfg_read (const char *file) continue; } - // on section-close, remove last section name + /* on section-close, remove last section name */ if (section_close) { - // sanity check: section already empty? + /* sanity check: section already empty? */ if (*section=='\0') { error ("error in config file '%s' line %d: unmatched closing brace", file, lineno); error=1; @@ -744,12 +750,12 @@ static int cfg_read (const char *file) continue; } - // finally: add key + /* finally: add key */ cfg_add (section, key, val, 0); } - // sanity check: are the braces balanced? + /* sanity check: are the braces balanced? */ if (!error && *section!='\0') { error ("error in config file '%s' line %d: unbalanced braces", file, lineno); error=1; @@ -1,4 +1,4 @@ -/* $Id: debug.c,v 1.9 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: debug.c,v 1.10 2004/06/26 09:27:20 reinelt Exp $ * * debug() and error() functions * @@ -22,6 +22,12 @@ * * * $Log: debug.c,v $ + * Revision 1.10 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.9 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -91,7 +97,7 @@ void message (const int level, const char *format, ...) if (level>verbose_level) return; va_start(ap, format); - (void) vsnprintf(buffer, sizeof(buffer), format, ap); + vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); if (!running_background) { @@ -1,4 +1,4 @@ -/* $Id: drv.c,v 1.19 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv.c,v 1.20 2004/06/26 09:27:20 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,12 @@ * * * $Log: drv.c,v $ + * Revision 1.20 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.19 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -167,9 +173,10 @@ extern DRIVER drv_T6963; extern DRIVER drv_USBLCD; extern DRIVER drv_X11; -// output file for Image driver -// has to be defined here because it's referenced -// even if the raster driver is not included! +/* output file for Image driver + * has to be defined here because it's referenced + * even if the raster driver is not included! + */ char *output=NULL; DRIVER *Driver[] = { @@ -1,4 +1,4 @@ -/* $Id: drv.h,v 1.6 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv.h,v 1.7 2004/06/26 09:27:20 reinelt Exp $ * * new framework for display drivers * @@ -23,6 +23,12 @@ * * * $Log: drv.h,v $ + * Revision 1.7 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -65,9 +71,10 @@ typedef struct DRIVER { } DRIVER; -// output file for Raster driver -// has to be defined here because it's referenced -// even if the raster driver is not included! +/* output file for Raster driver + * has to be defined here because it's referenced + * even if the raster driver is not included! + */ extern char *output; int drv_list (void); diff --git a/drv_BeckmannEgle.c b/drv_BeckmannEgle.c index 6b45191..787005e 100644 --- a/drv_BeckmannEgle.c +++ b/drv_BeckmannEgle.c @@ -1,4 +1,4 @@ -/* $Id: drv_BeckmannEgle.c,v 1.9 2004/06/26 06:12:15 reinelt Exp $ +/* $Id: drv_BeckmannEgle.c,v 1.10 2004/06/26 09:27:20 reinelt Exp $ * * driver for Beckmann+Egle "Mini Terminals" and "Compact Terminals" * Copyright 2000 Michael Reinelt <reinelt@eunet.at> @@ -22,6 +22,12 @@ * * * $Log: drv_BeckmannEgle.c,v $ + * Revision 1.10 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.9 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals @@ -111,7 +117,7 @@ typedef struct { static MODEL Models[] = { - // MultiTerminals + /* MultiTerminals */ { "MT16x1", 1, 16, 1, 0 }, { "MT16x2", 2, 16, 1, 1 }, { "MT16x4", 4, 16, 1, 2 }, @@ -126,7 +132,7 @@ static MODEL Models[] = { { "MT40x2", 2, 40, 1, 11 }, { "MT40x4", 4, 40, 1, 12 }, - // CompactTerminal + /* CompactTerminal */ { "CT20x4", 4, 20, 2, 0 }, { NULL, 0, 0, 0, 0 }, @@ -138,24 +144,24 @@ static int Protocol; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_BuE_clear (void) { switch (Protocol) { case 1: - drv_generic_serial_write (ESC "&#", 3); // clear display + drv_generic_serial_write (ESC "&#", 3); /* clear display */ break; case 2: - drv_generic_serial_write (ESC "LL", 3); // clear display + drv_generic_serial_write (ESC "LL", 3); /* clear display */ break; } } -static void drv_BuE_MT_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_BuE_MT_write (const int row, const int col, const char *data, const int len) { char cmd[] = ESC "[y;xH"; @@ -170,22 +176,22 @@ static void drv_BuE_MT_write (const int row, const int col, const unsigned char static void drv_BuE_MT_defchar (const int ascii, const unsigned char *matrix) { int i; - char cmd[22] = ESC "&T"; // enter transparent mode + char cmd[22] = ESC "&T"; /* enter transparent mode */ - cmd[3] = '\0'; // write cmd - cmd[4] = 0x40|8*ascii; // write CGRAM + cmd[3] = '\0'; /* write cmd */ + cmd[4] = 0x40|8*ascii; /* write CGRAM */ for (i = 0; i < 8; i++) { - cmd[2*i+5] = '\1'; // write data - cmd[2*i+6] = matrix[i] & 0x1f; // character bitmap + cmd[2*i+5] = '\1'; /* write data */ + cmd[2*i+6] = matrix[i] & 0x1f; /* character bitmap */ } - cmd[21] = '\377'; // leave transparent mode + cmd[21] = '\377'; /* leave transparent mode */ drv_generic_serial_write (cmd, 22); } -static void drv_BuE_CT_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_BuE_CT_write (const int row, const int col, const char *data, const int len) { char cmd[] = ESC "LCzs1"; @@ -200,12 +206,12 @@ static void drv_BuE_CT_write (const int row, const int col, const unsigned char static void drv_BuE_CT_defchar (const int ascii, const unsigned char *matrix) { int i; - char cmd[13] = ESC "LZ"; // set custom char + char cmd[13] = ESC "LZ"; /* set custom char */ - // number of user-defined char (0..7) + /* number of user-defined char (0..7) */ cmd[3] = (char) ascii - CHAR0; - // ASCII code to replace + /* ASCII code to replace */ cmd[4] = (char) ascii; for (i = 0; i < 8; i++) { @@ -218,10 +224,10 @@ static void drv_BuE_CT_defchar (const int ascii, const unsigned char *matrix) static int drv_BuE_CT_contrast (int contrast) { - static unsigned char Contrast = 7; + static char Contrast = 7; char cmd[4] = ESC "LKn"; - // -1 is used to query the current contrast + /* -1 is used to query the current contrast */ if (contrast == -1) return Contrast; if (contrast < 0 ) contrast = 0; @@ -238,10 +244,10 @@ static int drv_BuE_CT_contrast (int contrast) static int drv_BuE_CT_backlight (int backlight) { - static unsigned char Backlight=0; + static char Backlight=0; char cmd[4] = ESC "LBn"; - // -1 is used to query the current backlight + /* -1 is used to query the current backlight */ if (backlight == -1) return Backlight; if (backlight < 0) backlight = 0; @@ -259,20 +265,20 @@ static int drv_BuE_CT_backlight (int backlight) static int drv_BuE_CT_gpo (int num, int val) { static int GPO[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; - unsigned char cmd[4] = ESC "Pnx"; + char cmd[4] = ESC "Pnx"; if (num < 0) num = 0; if (num > 7) num = 7; - // -1 is used to query the current GPO + /* -1 is used to query the current GPO */ if (val == -1) return GPO[num]; if (val < 0 ) val = 0; if (val > 255) val = 255; GPO[num] = val; - cmd[2] = (unsigned char)num; - cmd[3] = (unsigned char)val; + cmd[2] = (char)num; + cmd[3] = (char)val; drv_generic_serial_write (cmd, 4); @@ -283,12 +289,12 @@ static int drv_BuE_CT_gpo (int num, int val) static int drv_BuE_CT_gpi (int num) { char cmd[4] = ESC "?Pn"; - unsigned char buffer[4]; + char buffer[4]; if (num < 0) num = 0; if (num > 7) num = 7; - cmd[3] = (unsigned char)num; + cmd[3] = (char)num; drv_generic_serial_write (cmd, 4); usleep (10000); @@ -304,7 +310,7 @@ static int drv_BuE_CT_gpi (int num) static int drv_BuE_CT_adc (void) { - unsigned char buffer[4]; + char buffer[4]; drv_generic_serial_write (ESC "?A", 3); @@ -318,24 +324,24 @@ static int drv_BuE_CT_adc (void) return -1; } - // 10 bit value: 8 bit high, 2 bit low - return 4 * buffer[2] + buffer[3]; + /* 10 bit value: 8 bit high, 2 bit low */ + return 4 * (unsigned char) buffer[2] + (unsigned char) buffer[3]; } static int drv_BuE_CT_pwm (int val) { static int PWM = -1; - unsigned char cmd[4] = ESC "Adm"; + char cmd[4] = ESC "Adm"; - // -1 is used to query the current PWM + /* -1 is used to query the current PWM */ if (val == -1) return PWM; if (val < 0) val = 0; if (val > 255) val = 255; PWM = val; - cmd[2] = (unsigned char) val; + cmd[2] = (char) val; cmd[3] = val == 0 ? 1 : 2; drv_generic_serial_write (cmd, 4); @@ -347,12 +353,12 @@ static int drv_BuE_MT_start (const char *section) { char cmd[] = ESC "&sX"; - // CSTOPB: 2 stop bits + /* CSTOPB: 2 stop bits */ if (drv_generic_serial_open(section, Name, CSTOPB) < 0) return -1; cmd[4] = Models[Model].type; - drv_generic_serial_write (cmd, 4); // select display type - drv_generic_serial_write (ESC "&D", 3); // cursor off + drv_generic_serial_write (cmd, 4); /* select display type */ + drv_generic_serial_write (ESC "&D", 3); /* cursor off */ return 0; } @@ -367,14 +373,14 @@ static int drv_BuE_CT_start (const char *section) if (drv_generic_serial_open(section, Name, 0) < 0) return -1; #if 0 - drv_generic_serial_write (ESC "Kr", 3); // restart terminal + drv_generic_serial_write (ESC "Kr", 3); /* restart terminal */ usleep(10000); #endif - // Fixme: the CT does not return a serial number in byte mode - drv_generic_serial_write (ESC "KM\073", 4); // set parameter mode 'decimal' + /* Fixme: the CT does not return a serial number in byte mode */ + drv_generic_serial_write (ESC "KM\073", 4); /* set parameter mode 'decimal' */ - // read version + /* read version */ drv_generic_serial_write (ESC "?V", 3); usleep(100000); if ((len = drv_generic_serial_read (buffer, -sizeof(buffer))) > 0) { @@ -386,9 +392,9 @@ static int drv_BuE_CT_start (const char *section) } } - drv_generic_serial_write (ESC "KM\072", 4); // set parameter mode 'byte' + drv_generic_serial_write (ESC "KM\072", 4); /* set parameter mode 'byte' */ - // the CT20x4 can control smaller displays, too + /* the CT20x4 can control smaller displays, too */ size = cfg_get(section, "Size", NULL); if (size != NULL && *size != '\0') { int r, c; @@ -398,29 +404,29 @@ static int drv_BuE_CT_start (const char *section) return -1; } info ("%s: display size: %d rows %d columns", Name, r, c); - cmd[3] = (unsigned char) r; - cmd[4] = (unsigned char) c; - drv_generic_serial_write (cmd, 5); // set display size + cmd[3] = (char) r; + cmd[4] = (char) c; + drv_generic_serial_write (cmd, 5); /* set display size */ DCOLS = c; DROWS = r; } - // set contrast + /* set contrast */ if (cfg_number(section, "Contrast", 7, 0, 15, &i) > 0) { drv_BuE_CT_contrast(i); } - // set backlight + /* set backlight */ if (cfg_number(section, "Backlight", 0, 0, 1, &i) > 0) { drv_BuE_CT_backlight(i); } - // identify I/O Port + /* identify I/O Port */ for (i = 0; i < 8; i++) { char cmd[5] = ESC "K?Pn"; - cmd[4] = (unsigned char)i; - drv_generic_serial_write (cmd, 5); // query I/O port + cmd[4] = (char)i; + drv_generic_serial_write (cmd, 5); /* query I/O port */ usleep(10000); if ((len = drv_generic_serial_read (buffer, 4)) == 4) { info ("%s: Port %d is type %d", Name, i, buffer[3]); @@ -458,7 +464,7 @@ static int drv_BuE_start (const char *section) info ("%s: using model '%s'", Name, Models[Model].name); - // initialize global variables + /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; @@ -481,9 +487,9 @@ static int drv_BuE_start (const char *section) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[]) { @@ -583,21 +589,21 @@ static void plugin_pwm (RESULT *result, const int argc, RESULT *argv[]) } -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_BuE_list (void) { int i; @@ -609,33 +615,33 @@ int drv_BuE_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_BuE_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // start display + /* start display */ if ((ret=drv_BuE_start (section)) != 0) { return ret; } - // display preferences - XRES = 5; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ - // real worker functions + /* real worker functions */ switch (Protocol) { case 1: - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 6; // number of bytes a goto command requires + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 6; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_BuE_MT_write; drv_generic_text_real_defchar = drv_BuE_MT_defchar; break; case 2: - CHAR0 = 128; // ASCII of first user-defineable char - GOTO_COST = 6; // number of bytes a goto command requires + CHAR0 = 128; /* ASCII of first user-defineable char */ + GOTO_COST = 6; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_BuE_CT_write; drv_generic_text_real_defchar = drv_BuE_CT_defchar; break; @@ -650,38 +656,38 @@ int drv_BuE_init (const char *section, const int quiet) } } - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins + /* register plugins */ AddFunction ("LCD::contrast", -1, plugin_contrast); AddFunction ("LCD::backlight", -1, plugin_backlight); AddFunction ("LCD::gpo", -1, plugin_gpo); @@ -693,17 +699,17 @@ int drv_BuE_init (const char *section, const int quiet) } -// close driver & display +/* close driver & display */ int drv_BuE_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_BuE_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c index 1102cbc..028637d 100644 --- a/drv_Crystalfontz.c +++ b/drv_Crystalfontz.c @@ -1,4 +1,4 @@ -/* $Id: drv_Crystalfontz.c,v 1.27 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_Crystalfontz.c,v 1.28 2004/06/26 09:27:20 reinelt Exp $ * * new style driver for Crystalfontz display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_Crystalfontz.c,v $ + * Revision 1.28 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.27 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -169,30 +175,30 @@ static int Model; static int Protocol; static int Payload; -// ring buffer for bytes received from the display -static unsigned char RingBuffer[256]; -static int RingRPos = 0; -static int RingWPos = 0; +/* ring buffer for bytes received from the display */ +static char RingBuffer[256]; +static unsigned int RingRPos = 0; +static unsigned int RingWPos = 0; -// packet from the display +/* packet from the display */ struct { unsigned char type; unsigned char size; - unsigned char data[16+1]; // trailing '\0' + unsigned char data[16+1]; /* trailing '\0' */ } Packet; -// Line Buffer for 633 displays +/* Line Buffer for 633 displays */ static char Line[2*16]; -// Fan RPM +/* Fan RPM */ static double Fan_RPM[4] = {0.0,}; -// Temperature sensors +/* Temperature sensors */ static double Temperature[32] = {0.0,}; -// Fixme: GPO's not yet implemented -// static int GPO[8]; +/* Fixme: GPO's not yet implemented */ +/* static int GPO[8]; */ static int GPOS; @@ -206,8 +212,8 @@ typedef struct { int payload; } MODEL; -// Fixme #1: number of gpo's should be verified -// Fixme #2: protocol should be verified +/* Fixme #1: number of gpo's should be verified */ +/* Fixme #2: protocol should be verified */ static MODEL Models[] = { { 626, "626", 2, 16, 0, 1, 0 }, @@ -220,14 +226,14 @@ static MODEL Models[] = { }; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ -// x^0 + x^5 + x^12 +/* x^0 + x^5 + x^12 */ #define CRCPOLY 0x8408 -static unsigned short CRC (const unsigned char *p, size_t len, unsigned short seed) +static unsigned short CRC (const char *p, size_t len, unsigned short seed) { int i; while (len--) { @@ -238,22 +244,22 @@ static unsigned short CRC (const unsigned char *p, size_t len, unsigned short se return ~seed; } -static unsigned char LSB (const unsigned short word) +static char LSB (const unsigned short word) { return word & 0xff; } -static unsigned char MSB (const unsigned short word) +static char MSB (const unsigned short word) { return word >> 8; } -static unsigned char byte (int pos) +static char byte (unsigned int pos) { - pos+=RingRPos; - if (pos>=sizeof(RingBuffer)) - pos-=sizeof(RingBuffer); + pos += RingRPos; + if (pos >= sizeof(RingBuffer)) + pos -= sizeof(RingBuffer); return RingBuffer[pos]; } @@ -263,11 +269,11 @@ static void drv_CF_process_packet (void) switch (Packet.type) { - case 0x80: // Key Activity + case 0x80: /* Key Activity */ debug ("Key Activity: %d", Packet.data[0]); break; - case 0x81: // Fan Speed Report + case 0x81: /* Fan Speed Report */ if (Packet.data[1] == 0xff) { Fan_RPM[Packet.data[0]] = -1.0; } else if (Packet.data[1] < 4) { @@ -277,7 +283,7 @@ static void drv_CF_process_packet (void) } break; - case 0x82: // Temperature Sensor Report + case 0x82: /* Temperature Sensor Report */ switch (Packet.data[3]) { case 0: error ("%s: 1-Wire device #%d: CRC error", Name, Packet.data[0]); @@ -293,7 +299,7 @@ static void drv_CF_process_packet (void) break; default: - // just ignore packet + /* just ignore packet */ break; } @@ -306,46 +312,46 @@ static int drv_CF_poll (void) unsigned short crc; int n, num, size; - // read into RingBuffer + /* read into RingBuffer */ while (1) { - num=drv_generic_serial_poll(buffer, 32); - if (num<=0) break; - // put result into RingBuffer - for (n=0; n<num; n++) { - RingBuffer[RingWPos++]=buffer[n]; - if (RingWPos>=sizeof(RingBuffer)) RingWPos=0; + num = drv_generic_serial_poll(buffer, 32); + if (num <= 0) break; + /* put result into RingBuffer */ + for (n = 0; n < num; n++) { + RingBuffer[RingWPos++] = buffer[n]; + if (RingWPos >= sizeof(RingBuffer)) RingWPos = 0; } } - // process RingBuffer + /* process RingBuffer */ while (1) { - // packet size + /* packet size */ num=RingWPos-RingRPos; if (num < 0) num+=sizeof(RingBuffer); - // minimum packet size=4 + /* minimum packet size=4 */ if (num < 4) return 0; - // valid response types: 01xxxxx 10.. 11.. - // therefore: 00xxxxxx is invalid + /* valid response types: 01xxxxx 10.. 11.. */ + /* therefore: 00xxxxxx is invalid */ if (byte(0)>>6 == 0) goto GARBAGE; - // valid command length is 0 to 16 + /* valid command length is 0 to 16 */ if (byte(1) > 16) goto GARBAGE; - // all bytes available? + /* all bytes available? */ size=byte(1); if (num < size+4) return 0; - // check CRC + /* check CRC */ for (n=0; n<size+4; n++) buffer[n]=byte(n); crc = CRC(buffer, size+2, 0xffff); if (LSB(crc) != byte(size+2)) goto GARBAGE; if (MSB(crc) != byte(size+3)) goto GARBAGE; - // process packet + /* process packet */ Packet.type = buffer[0]; Packet.size = size; memcpy(Packet.data, buffer+2, size); - Packet.data[size]='\0'; // trailing zero - // increment read pointer + Packet.data[size]='\0'; /* trailing zero */ + /* increment read pointer */ RingRPos += size+4; if (RingRPos >= sizeof(RingBuffer)) RingRPos -= sizeof(RingBuffer); - // a packet arrived + /* a packet arrived */ return 1; GARBAGE: debug ("dropping garbage byte %d", byte(0)); @@ -354,12 +360,12 @@ static int drv_CF_poll (void) continue; } - // not reached + /* not reached */ return 0; } -static void drv_CF_timer (void *notused) +static void drv_CF_timer (void __attribute__((unused)) *notused) { while (drv_CF_poll()) { drv_CF_process_packet(); @@ -369,7 +375,7 @@ static void drv_CF_timer (void *notused) static void drv_CF_send (const int cmd, int len, const unsigned char *data) { - unsigned char buffer[22]; + char buffer[22]; unsigned short crc; if (len > Payload) { @@ -393,12 +399,12 @@ static void drv_CF_send (const int cmd, int len, const unsigned char *data) } -static void drv_CF_write1 (const int row, const int col, const unsigned char *data, const int len) +static void drv_CF_write1 (const int row, const int col, const char *data, const int len) { - char cmd[3]="\021xy"; // set cursor position + char cmd[3]="\021xy"; /* set cursor position */ if (row==0 && col==0) { - drv_generic_serial_write ("\001", 1); // cursor home + drv_generic_serial_write ("\001", 1); /* cursor home */ } else { cmd[1]=(char)col; cmd[2]=(char)row; @@ -409,34 +415,34 @@ static void drv_CF_write1 (const int row, const int col, const unsigned char *da } -static void drv_CF_write2 (const int row, const int col, const unsigned char *data, const int len) +static void drv_CF_write2 (const int row, const int col, const char *data, const int len) { int l = len; - // limit length + /* limit length */ if (col + l > 16) l = 16 - col; if (l < 0) l = 0; - // sanity check + /* sanity check */ if (row >= 2 || col + l > 16) { error ("%s: internal error: write outside linebuffer bounds!", Name); return; } memcpy (Line + 16 * row + col, data, l); - drv_CF_send (7 + row, 16, Line + 16 * row); + drv_CF_send (7 + row, 16, (unsigned char *)(Line + 16 * row)); } -static void drv_CF_write3 (const int row, const int col, const unsigned char *data, const int len) +static void drv_CF_write3 (const int row, const int col, const char *data, const int len) { int l = len; - char cmd[23]; + unsigned char cmd[23]; - // limit length + /* limit length */ if (col + l > 20) l = 20 - col; if (l < 0) l = 0; - // sanity check + /* sanity check */ if (row >= 2 || col + l > 20) { error ("%s: internal error: write outside display bounds!", Name); return; @@ -454,9 +460,9 @@ static void drv_CF_write3 (const int row, const int col, const unsigned char *da static void drv_CF_defchar1 (const int ascii, const unsigned char *matrix) { int i; - char cmd[10]="\031n"; // set custom char bitmap + char cmd[10]="\031n"; /* set custom char bitmap */ - // user-defineable chars start at 128, but are defined at 0 + /* user-defineable chars start at 128, but are defined at 0 */ cmd[1]=(char)(ascii-CHAR0); for (i = 0; i < 8; i++) { cmd[i+2] = matrix[i] & 0x3f; @@ -468,12 +474,12 @@ static void drv_CF_defchar1 (const int ascii, const unsigned char *matrix) static void drv_CF_defchar23 (const int ascii, const unsigned char *matrix) { int i; - char buffer[9]; + unsigned char buffer[9]; - // user-defineable chars start at 128, but are defined at 0 + /* user-defineable chars start at 128, but are defined at 0 */ buffer[0] = (char)(ascii-CHAR0); - // clear bit 6 and 7 of the bitmap (blinking) + /* clear bit 6 and 7 of the bitmap (blinking) */ for (i = 0; i < 8; i++) { buffer[i+1] = matrix[i] & 0x3f; } @@ -487,7 +493,7 @@ static int drv_CF_contrast (int contrast) static unsigned char Contrast=0; char buffer[2]; - // -1 is used to query the current contrast + /* -1 is used to query the current contrast */ if (contrast == -1) return Contrast; if (contrast < 0 ) contrast = 0; @@ -497,21 +503,21 @@ static int drv_CF_contrast (int contrast) switch (Protocol) { case 1: - // contrast range 0 to 100 + /* contrast range 0 to 100 */ if (Contrast > 100) Contrast = 100; - buffer[0] = 15; // Set LCD Contrast + buffer[0] = 15; /* Set LCD Contrast */ buffer[1] = Contrast; drv_generic_serial_write (buffer, 2); break; case 2: - // contrast range 0 to 50 + /* contrast range 0 to 50 */ if (Contrast > 50) Contrast = 50; drv_CF_send (13, 1, &Contrast); break; case 3: - // contrast range 0 to 255 + /* contrast range 0 to 255 */ drv_CF_send (13, 1, &Contrast); break; } @@ -525,7 +531,7 @@ static int drv_CF_backlight (int backlight) static unsigned char Backlight=0; char buffer[2]; - // -1 is used to query the current backlight + /* -1 is used to query the current backlight */ if (backlight == -1) return Backlight; if (backlight<0 ) backlight=0; @@ -535,7 +541,7 @@ static int drv_CF_backlight (int backlight) switch (Protocol) { case 1: - buffer[0] = 14; // Set LCD Backlight + buffer[0] = 14; /* Set LCD Backlight */ buffer[1] = Backlight; drv_generic_serial_write (buffer, 2); break; @@ -555,13 +561,13 @@ static int drv_CF_fan_pwm (int fan, int power) { static unsigned char PWM[4] = {100,}; - // sanity check + /* sanity check */ if (fan<1 || fan>4) return -1; - // fan ranges from 1 to 4 + /* fan ranges from 1 to 4 */ fan--; - // -1 is used to query the current power + /* -1 is used to query the current power */ if (power == -1) return PWM[fan]; if (power<0 ) power=0; @@ -582,30 +588,30 @@ static int drv_CF_autodetect (void) { int i, m; - // only autodetect newer displays + /* only autodetect newer displays */ if (Protocol<2) return -1; - // read display type + /* read display type */ drv_CF_send (1, 0, NULL); i=0; while (1) { - // wait 10 msec + /* wait 10 msec */ usleep(10*1000); - // packet available? + /* packet available? */ if (drv_CF_poll()) { - // display type + /* display type */ if (Packet.type==0x41) { char t[7], c; float h, v; info ("%s: display identifies itself as '%s'", Name, Packet.data); - if (sscanf(Packet.data, "%6s:h%f,%c%f", t, &h, &c, &v)!=4) { + if (sscanf((char*)Packet.data, "%6s:h%f,%c%f", t, &h, &c, &v)!=4) { error ("%s: error parsing display identification string", Name); return -1; } info ("%s: display type '%s', hardware version %3.1f, firmware version %c%3.1f", Name, t, h, c, v); if (strncmp(t, "CFA", 3)==0) { for (m=0; Models[m].type!=-1; m++) { - // omit the 'CFA' + /* omit the 'CFA' */ if (strcasecmp(Models[m].name, t+3)==0) return m; } @@ -615,14 +621,14 @@ static int drv_CF_autodetect (void) } drv_CF_process_packet(); } - // wait no longer than 300 msec + /* wait no longer than 300 msec */ if (++i > 30) { error ("%s: display detection timed out", Name); return -1; } } - // not reached + /* not reached */ return -1; } @@ -643,20 +649,20 @@ static int drv_CF_scan_DOW (unsigned char index) { int i; - // Read DOW Device Information + /* Read DOW Device Information */ drv_CF_send (18, 1, &index); i=0; while (1) { - // wait 10 msec + /* wait 10 msec */ usleep(10*1000); - // packet available? + /* packet available? */ if (drv_CF_poll()) { - // DOW Device Info + /* DOW Device Info */ if (Packet.type==0x52) { switch (Packet.data[1]) { case 0x00: - // no device found + /* no device found */ return 0; case 0x22: info ("%s: 1-Wire device #%d: DS1822 temperature sensor found at %s", @@ -675,19 +681,19 @@ static int drv_CF_scan_DOW (unsigned char index) drv_CF_process_packet(); } } - // wait no longer than 300 msec + /* wait no longer than 300 msec */ if (++i > 30) { error ("%s: 1-Wire device #%d detection timed out", Name, index); return -1; } } - // not reached + /* not reached */ return -1; } -// clear display +/* clear display */ static void drv_CF_clear (void) { switch (Protocol) { @@ -702,39 +708,39 @@ static void drv_CF_clear (void) } -// init sequences for 626, 632, 634, 636 +/* init sequences for 626, 632, 634, 636 */ static void drv_CF_start_1 (void) { - drv_generic_serial_write ("\014", 1); // Form Feed (Clear Display) - drv_generic_serial_write ("\004", 1); // hide cursor - drv_generic_serial_write ("\024", 1); // scroll off - drv_generic_serial_write ("\030", 1); // wrap off + drv_generic_serial_write ("\014", 1); /* Form Feed (Clear Display) */ + drv_generic_serial_write ("\004", 1); /* hide cursor */ + drv_generic_serial_write ("\024", 1); /* scroll off */ + drv_generic_serial_write ("\030", 1); /* wrap off */ } -// init sequences for 633 +/* init sequences for 633 */ static void drv_CF_start_2 (void) { int i; unsigned long mask; - char buffer[4]; + unsigned char buffer[4]; - // Clear Display + /* Clear Display */ drv_CF_send ( 6, 0, NULL); - // Set LCD Cursor Style + /* Set LCD Cursor Style */ buffer[0] = 0; drv_CF_send (12, 1, buffer); - // enable Fan Reporting + /* enable Fan Reporting */ buffer[0] = 15; drv_CF_send (16, 1, buffer); - // Set Fan Power to 100% + /* Set Fan Power to 100% */ buffer[0] = buffer[1] = buffer[2] = buffer[3] = 100; drv_CF_send (17, 4, buffer); - // Read DOW Device Information + /* Read DOW Device Information */ mask = 0; for (i = 0; i < 32; i++) { if (drv_CF_scan_DOW(i) == 1) { @@ -742,7 +748,7 @@ static void drv_CF_start_2 (void) } } - // enable Temperature Reporting + /* enable Temperature Reporting */ buffer[0] = mask & 0xff; buffer[1] = (mask>>8) & 0xff; buffer[2] = (mask>>16) & 0xff; @@ -751,15 +757,15 @@ static void drv_CF_start_2 (void) } -// init sequences for 631 +/* init sequences for 631 */ static void drv_CF_start_3 (void) { - char buffer[1]; + unsigned char buffer[1]; - // Clear Display + /* Clear Display */ drv_CF_send ( 6, 0, NULL); - // Set LCD Cursor Style + /* Set LCD Cursor Style */ buffer[0] = 0; drv_CF_send (12, 1, buffer); @@ -785,17 +791,17 @@ static int drv_CF_start (const char *section) info ("%s: using model '%s'", Name, Models[Model].name); } else { Model = -1; - Protocol = 2; //auto-detect only newer displays + Protocol = 2; /*auto-detect only newer displays */ info ("%s: no '%s.Model' entry from %s, auto-detecting", Name, section, cfg_source()); } - // open serial port + /* open serial port */ if (drv_generic_serial_open(section, Name, 0)<0) return -1; - // Fixme: why such a large delay? + /* Fixme: why such a large delay? */ usleep(350*1000); - // display autodetection + /* display autodetection */ i=drv_CF_autodetect(); if (Model==-1) Model=i; if (Model==-1) { @@ -808,7 +814,7 @@ static int drv_CF_start (const char *section) return -1; } - // initialize global variables + /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; GPOS = Models[Model].gpos; @@ -823,28 +829,28 @@ static int drv_CF_start (const char *section) break; case 2: - // regularly process display answers - // Fixme: make 100msec configurable + /* regularly process display answers */ + /* Fixme: make 100msec configurable */ timer_add (drv_CF_timer, NULL, 100, 0); drv_CF_start_2(); - // clear 633 linebuffer + /* clear 633 linebuffer */ memset (Line, ' ', sizeof(Line)); break; case 3: - // regularly process display answers - // Fixme: make 100msec configurable + /* regularly process display answers */ + /* Fixme: make 100msec configurable */ timer_add (drv_CF_timer, NULL, 100, 0); drv_CF_start_3(); break; } - // set contrast + /* set contrast */ if (cfg_number(section, "Contrast", 0, 0, 255, &i)>0) { drv_CF_contrast(i); } - // set backlight + /* set backlight */ if (cfg_number(section, "Backlight", 0, 0, 100, &i)>0) { drv_CF_backlight(i); } @@ -853,9 +859,9 @@ static int drv_CF_start (const char *section) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[]) @@ -917,25 +923,25 @@ static void plugin_fan_pwm (RESULT *result, const int argc, RESULT *argv[]) } } -// Fixme: other plugins for Fans, Temperature sensors, ... +/* Fixme: other plugins for Fans, Temperature sensors, ... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_CF_list (void) { int i; @@ -947,39 +953,39 @@ int drv_CF_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_CF_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // start display + /* start display */ if ((ret = drv_CF_start (section)) != 0) { return ret; } - // display preferences - XRES = 6; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters + /* display preferences */ + XRES = 6; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ - // real worker functions + /* real worker functions */ switch (Protocol) { case 1: - CHAR0 = 128; // ASCII of first user-defineable char - GOTO_COST = 3; // number of bytes a goto command requires + CHAR0 = 128; /* ASCII of first user-defineable char */ + GOTO_COST = 3; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_CF_write1; drv_generic_text_real_defchar = drv_CF_defchar1; break; case 2: - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 999; // there is no goto on 633 + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 999; /* there is no goto on 633 */ drv_generic_text_real_write = drv_CF_write2; drv_generic_text_real_defchar = drv_CF_defchar23; break; case 3: - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 3; // number of bytes a goto command requires + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 3; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_CF_write3; drv_generic_text_real_defchar = drv_CF_defchar23; break; @@ -994,39 +1000,39 @@ int drv_CF_init (const char *section, const int quiet) } } - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment (0, 0, 255, 32); // ASCII 32 = blank + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment (0, 0, 255, 32); /* ASCII 32 = blank */ if (Protocol==2) - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins + /* register plugins */ AddFunction ("LCD::contrast", -1, plugin_contrast); AddFunction ("LCD::backlight", -1, plugin_backlight); if (Protocol == 2) { @@ -1037,17 +1043,17 @@ int drv_CF_init (const char *section, const int quiet) } -// close driver & display +/* close driver & display */ int drv_CF_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_CF_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } diff --git a/drv_Curses.c b/drv_Curses.c index 7b1be2d..b81e172 100644 --- a/drv_Curses.c +++ b/drv_Curses.c @@ -1,4 +1,4 @@ -/* $Id: drv_Curses.c,v 1.6 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_Curses.c,v 1.7 2004/06/26 09:27:20 reinelt Exp $ * * pure ncurses based text driver * @@ -26,6 +26,12 @@ * * * $Log: drv_Curses.c,v $ + * Revision 1.7 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -88,9 +94,9 @@ static WINDOW *e = NULL; static int EROWS; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_Curs_clear (void) { @@ -100,7 +106,7 @@ static void drv_Curs_clear (void) } -static void drv_Curs_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_Curs_write (const int row, const int col, const char *data, const int len) { int l = len; char *p; @@ -118,9 +124,10 @@ static void drv_Curs_write (const int row, const int col, const unsigned char *d } -static void drv_Curs_defchar (const int ascii, const unsigned char *buffer) +static void drv_Curs_defchar (const __attribute__((unused)) int ascii, + const __attribute__((unused)) unsigned char *buffer) { - // empty + /* empty */ } @@ -135,7 +142,7 @@ int curses_error(char *buffer) if (e == NULL) return 0; - // replace \r, \n with underscores + /* replace \r, \n with underscores */ while ((p = strpbrk(buffer, "\r\n")) != NULL) { *p='_'; } @@ -221,27 +228,27 @@ static int drv_Curs_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_Curs_list (void) { printf ("any"); @@ -249,68 +256,68 @@ int drv_Curs_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_Curs_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES = 1; // pixel width of one char - YRES = 1; // pixel height of one char - CHARS = 0; // number of user-defineable characters - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 0; // number of bytes a goto command requires + /* display preferences */ + XRES = 1; /* pixel width of one char */ + YRES = 1; /* pixel height of one char */ + CHARS = 0; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 0; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_Curs_write; drv_generic_text_real_defchar = drv_Curs_defchar; - // start display + /* start display */ if ((ret = drv_Curs_start (section, quiet)) != 0) { return ret; } - // initialize generic text driver + /* initialize generic text driver */ if ((ret = drv_generic_text_init(section, Name)) != 0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret = drv_generic_text_bar_init(1)) != 0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank - drv_generic_text_bar_add_segment (255,255,255,'*'); // asterisk + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + drv_generic_text_bar_add_segment (255,255,255,'*'); /* asterisk */ - // register text widget + /* register text widget */ wc = Widget_Text; wc.draw = drv_generic_text_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc = Widget_Bar; wc.draw = drv_generic_text_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display +/* close driver & display */ int drv_Curs_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_Curs_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } diff --git a/drv_Cwlinux.c b/drv_Cwlinux.c index 00973bd..d7672f4 100644 --- a/drv_Cwlinux.c +++ b/drv_Cwlinux.c @@ -1,4 +1,4 @@ -/* $Id: drv_Cwlinux.c,v 1.17 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_Cwlinux.c,v 1.18 2004/06/26 09:27:20 reinelt Exp $ * * new style driver for Cwlinux display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_Cwlinux.c,v $ + * Revision 1.18 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.17 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -135,8 +141,8 @@ static char Name[]="Cwlinux"; static int Model; static int Protocol; -// Fixme: GPO's not yet implemented -// static int GPO[8]; +/* Fixme: GPO's not yet implemented */ +/* static int GPO[8]; */ static int GPOS; @@ -150,7 +156,7 @@ typedef struct { int protocol; } MODEL; -// Fixme: number of gpo's should be verified +/* Fixme: number of gpo's should be verified */ static MODEL Models[] = { { 0x01, "CW1602", 2, 16, 5, 0, 1 }, @@ -159,11 +165,11 @@ static MODEL Models[] = { }; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ -static void drv_CW_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_CW_write (const int row, const int col, const char *data, const int len) { char cmd[6]="\376Gxy\375"; @@ -186,7 +192,7 @@ static void drv_CW1602_defchar (const int ascii, const unsigned char *buffer) cmd[3+i] = buffer[i] & 0x1f; } drv_generic_serial_write(cmd,12); - usleep(20); // delay for cw1602 to settle the character defined! + usleep(20); /* delay for cw1602 to settle the character defined! */ } @@ -197,8 +203,8 @@ static void drv_CW12232_defchar (const int ascii, const unsigned char *buffer) cmd[2]=(char)ascii; - // The CW12232 uses a vertical bitmap layout, - // so we have to 'rotate' the bitmap. + /* The CW12232 uses a vertical bitmap layout, */ + /* so we have to 'rotate' the bitmap. */ for (i=0; i<6;i++) { cmd[3+i]=0; @@ -215,14 +221,14 @@ static void drv_CW12232_defchar (const int ascii, const unsigned char *buffer) static void drv_CW_clear (void) { #if 0 - drv_generic_serial_write("\376X\375",3); // Clear Display + drv_generic_serial_write("\376X\375",3); /* Clear Display */ #else - // for some mysterious reason, we have to sleep after - // the command _and_ after the CMD_END... + /* for some mysterious reason, we have to sleep after */ + /* the command _and_ after the CMD_END... */ usleep(20); - drv_generic_serial_write("\376X",2); // Clear Display + drv_generic_serial_write("\376X",2); /* Clear Display */ usleep(20); - drv_generic_serial_write("\375",1); // Command End + drv_generic_serial_write("\375",1); /* Command End */ usleep(20); #endif } @@ -233,7 +239,7 @@ static int drv_CW_brightness (int brightness) static unsigned char Brightness = 0; char cmd[5] = "\376A_\375"; - // -1 is used to query the current brightness + /* -1 is used to query the current brightness */ if (brightness == -1) return Brightness; if (brightness < 0 ) brightness = 0; @@ -242,15 +248,15 @@ static int drv_CW_brightness (int brightness) switch (Brightness) { case 0: - // backlight off + /* backlight off */ drv_generic_serial_write ("\376F\375", 3); break; case 8: - // backlight on + /* backlight on */ drv_generic_serial_write ("\376B\375", 3); break; default: - // backlight level + /* backlight level */ cmd[2] = (char)Brightness; drv_generic_serial_write (cmd, 4); break; @@ -281,12 +287,12 @@ static int drv_CW_start (const char *section) return -1; } - // open serial port + /* open serial port */ if (drv_generic_serial_open(section, Name, 0) < 0) return -1; - // this does not work as I'd expect it... + /* this does not work as I'd expect it... */ #if 0 - // read firmware version + /* read firmware version */ generic_serial_read(buffer,sizeof(buffer)); usleep(100000); generic_serial_write ("\3761", 2); @@ -299,7 +305,7 @@ static int drv_CW_start (const char *section) info ("Cwlinux Firmware %d.%d", (int)buffer[0], (int)buffer[1]); #endif - // initialize global variables + /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; XRES = Models[Model].xres; @@ -308,12 +314,12 @@ static int drv_CW_start (const char *section) drv_CW_clear(); - drv_generic_serial_write ("\376D\375", 3); // auto line wrap off - drv_generic_serial_write ("\376R\375", 3); // auto scroll off - drv_generic_serial_write ("\376K\375", 3); // underline cursor off - drv_generic_serial_write ("\376B\375", 3); // backlight on + drv_generic_serial_write ("\376D\375", 3); /* auto line wrap off */ + drv_generic_serial_write ("\376R\375", 3); /* auto scroll off */ + drv_generic_serial_write ("\376K\375", 3); /* underline cursor off */ + drv_generic_serial_write ("\376B\375", 3); /* backlight on */ - // set brightness + /* set brightness */ if (cfg_number(section, "Brightness", 0, 0, 8, &i) > 0) { drv_CW_brightness(i); } @@ -322,9 +328,9 @@ static int drv_CW_start (const char *section) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ static void plugin_brightness (RESULT *result, const int argc, RESULT *argv[]) @@ -347,21 +353,21 @@ static void plugin_brightness (RESULT *result, const int argc, RESULT *argv[]) } -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_CW_list (void) { int i; @@ -373,24 +379,24 @@ int drv_CW_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_CW_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES = 6; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 16; // number of user-defineable characters - CHAR0 = 1; // ASCII of first user-defineable char - GOTO_COST = 3; // number of bytes a goto command requires - - // start display + /* display preferences */ + XRES = 6; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 16; /* number of user-defineable characters */ + CHAR0 = 1; /* ASCII of first user-defineable char */ + GOTO_COST = 3; /* number of bytes a goto command requires */ + + /* start display */ if ((ret=drv_CW_start (section))!=0) return ret; - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_CW_write; switch (Protocol) { @@ -411,53 +417,53 @@ int drv_CW_init (const char *section, const int quiet) } } - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment (0, 0, 255, 32); // ASCII 32 = blank + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment (0, 0, 255, 32); /* ASCII 32 = blank */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins + /* register plugins */ AddFunction ("LCD::brightness", -1, plugin_brightness); return 0; } -// close driver & display +/* close driver & display */ int drv_CW_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear *both* displays + /* clear *both* displays */ drv_CW_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } diff --git a/drv_HD44780.c b/drv_HD44780.c index 8dea43a..30d4bf9 100644 --- a/drv_HD44780.c +++ b/drv_HD44780.c @@ -1,4 +1,4 @@ -/* $Id: drv_HD44780.c,v 1.30 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_HD44780.c,v 1.31 2004/06/26 09:27:20 reinelt Exp $ * * new style driver for HD44780-based displays * @@ -29,6 +29,12 @@ * * * $Log: drv_HD44780.c,v $ + * Revision 1.31 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.30 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -206,11 +212,11 @@ static int Capabilities; * we use the worst-case values. */ -#define T_CYCLE 1000 // Enable cycle time -#define T_PW 450 // Enable pulse width -#define T_AS 60 // Address setup time -#define T_H 40 // Data hold time -#define T_AH 20 // Address hold time +#define T_CYCLE 1000 /* Enable cycle time */ +#define T_PW 450 /* Enable pulse width */ +#define T_AS 60 /* Address setup time */ +#define T_H 40 /* Data hold time */ +#define T_AH 20 /* Address hold time */ /* HD44780 execution timings [microseconds] @@ -218,11 +224,11 @@ static int Capabilities; * we use the worst-case values. */ -#define T_INIT1 4100 // first init sequence: 4.1 msec -#define T_INIT2 100 // second init sequence: 100 usec -#define T_EXEC 80 // normal execution time -#define T_WRCG 120 // CG RAM Write -#define T_CLEAR 1680 // Clear Display +#define T_INIT1 4100 /* first init sequence: 4.1 msec */ +#define T_INIT2 100 /* second init sequence: 100 usec */ +#define T_EXEC 80 /* normal execution time */ +#define T_WRCG 120 /* CG RAM Write */ +#define T_CLEAR 1680 /* Clear Display */ static int Bits=0; @@ -241,9 +247,9 @@ static unsigned char SIGNAL_GPO; static int UseBusy = 0; -// Fixme: GPO's not yet implemented +/* Fixme: GPO's not yet implemented */ static int GPOS; -// static int GPO=0; +/* static int GPO=0; */ typedef struct { @@ -265,9 +271,9 @@ static MODEL Models[] = { }; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void wait_for_busy_flag(int controller) { @@ -294,16 +300,16 @@ static void wait_for_busy_flag(int controller) drv_generic_parport_direction(1); if (Bits==8) { - // Set RW, clear RS + /* Set RW, clear RS */ drv_generic_parport_control(SIGNAL_RW|SIGNAL_RS,SIGNAL_RW); } else { drv_generic_parport_data(SIGNAL_RW); } - // Address set-up time + /* Address set-up time */ ndelay(T_AS); - // rise ENABLE + /* rise ENABLE */ if (Bits==8) { drv_generic_parport_control(enable,enable); } else { @@ -326,7 +332,7 @@ static void wait_for_busy_flag(int controller) struct timeval now, end; if (counter == 5) { - // determine the time when the timeout has expired + /* determine the time when the timeout has expired */ gettimeofday (&end, NULL); end.tv_usec+=MAX_BUSYFLAG_WAIT; while (end.tv_usec>1000000) { @@ -335,7 +341,7 @@ static void wait_for_busy_flag(int controller) } } - // get the current time + /* get the current time */ gettimeofday(&now, NULL); if (now.tv_sec==end.tv_sec?now.tv_usec>=end.tv_usec:now.tv_sec>=end.tv_sec) { error ("%s: timeout waiting for busy flag on controller %x (%x)", Name, controller, data); @@ -345,17 +351,17 @@ static void wait_for_busy_flag(int controller) } } - // RS=low, RW=low, EN=low + /* RS=low, RW=low, EN=low */ if (Bits==8) { - // Lower EN + /* Lower EN */ drv_generic_parport_control(enable,0); - // Address hold time + /* Address hold time */ ndelay(T_AH); drv_generic_parport_control(SIGNAL_RW|SIGNAL_RS,0); } else { - // Lower EN + /* Lower EN */ drv_generic_parport_data(SIGNAL_RW); ndelay(T_AH); drv_generic_parport_data(0); @@ -374,42 +380,42 @@ static void drv_HD_nibble(const unsigned char controller, const unsigned char ni { unsigned char enable; - // enable signal: 'controller' is a bitmask - // bit 0 .. send to controller #0 - // bit 1 .. send to controller #1 - // so we can send a byte to both controllers at the same time! + /* enable signal: 'controller' is a bitmask */ + /* bit 0 .. send to controller #0 */ + /* bit 1 .. send to controller #1 */ + /* so we can send a byte to both controllers at the same time! */ enable=0; if (controller&0x01) enable|=SIGNAL_ENABLE; if (controller&0x02) enable|=SIGNAL_ENABLE2; - // clear ENABLE - // put data on DB1..DB4 - // nibble already contains RS bit! + /* clear ENABLE */ + /* put data on DB1..DB4 */ + /* nibble already contains RS bit! */ drv_generic_parport_data(nibble); - // Address set-up time + /* Address set-up time */ ndelay(T_AS); - // rise ENABLE + /* rise ENABLE */ drv_generic_parport_data(nibble | enable); - // Enable pulse width + /* Enable pulse width */ ndelay(T_PW); - // lower ENABLE + /* lower ENABLE */ drv_generic_parport_data(nibble); } static void drv_HD_byte (const unsigned char controller, const unsigned char data, const unsigned char RS) { - // send high nibble of the data + /* send high nibble of the data */ drv_HD_nibble (controller, ((data>>4)&0x0f)|RS); - // Make sure we honour T_CYCLE + /* Make sure we honour T_CYCLE */ ndelay(T_CYCLE-T_AS-T_PW); - // send low nibble of the data + /* send low nibble of the data */ drv_HD_nibble(controller, (data&0x0f)|RS); } @@ -422,24 +428,24 @@ static void drv_HD_command (const unsigned char controller, const unsigned char if (Bits==8) { - // enable signal: 'controller' is a bitmask - // bit 0 .. send to controller #0 - // bit 1 .. send to controller #1 - // so we can send a byte to both controllers at the same time! + /* enable signal: 'controller' is a bitmask */ + /* bit 0 .. send to controller #0 */ + /* bit 1 .. send to controller #1 */ + /* so we can send a byte to both controllers at the same time! */ enable=0; if (controller&0x01) enable|=SIGNAL_ENABLE; if (controller&0x02) enable|=SIGNAL_ENABLE2; - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (cmd); - // clear RW and RS + /* clear RW and RS */ drv_generic_parport_control (SIGNAL_RW | SIGNAL_RS, 0); - // Address set-up time + /* Address set-up time */ ndelay(T_AS); - // send command + /* send command */ drv_generic_parport_toggle (enable, 1, T_PW); } else { @@ -448,7 +454,7 @@ static void drv_HD_command (const unsigned char controller, const unsigned char } - // wait for command completion + /* wait for command completion */ if (!UseBusy) udelay(delay); } @@ -459,23 +465,23 @@ static void drv_HD_data (const unsigned char controller, const char *string, con int l = len; unsigned char enable; - // sanity check + /* sanity check */ if (len<=0) return; if (Bits==8) { - // enable signal: 'controller' is a bitmask - // bit 0 .. send to controller #0 - // bit 1 .. send to controller #1 - // so we can send a byte to both controllers at the same time! + /* enable signal: 'controller' is a bitmask */ + /* bit 0 .. send to controller #0 */ + /* bit 1 .. send to controller #1 */ + /* so we can send a byte to both controllers at the same time! */ enable=0; if (controller&0x01) enable|=SIGNAL_ENABLE; if (controller&0x02) enable|=SIGNAL_ENABLE2; if (!UseBusy) { - // clear RW, set RS + /* clear RW, set RS */ drv_generic_parport_control (SIGNAL_RW | SIGNAL_RS, SIGNAL_RS); - // Address set-up time + /* Address set-up time */ ndelay(T_AS); } @@ -483,31 +489,31 @@ static void drv_HD_data (const unsigned char controller, const char *string, con if (UseBusy) { wait_for_busy_flag(controller); - // clear RW, set RS + /* clear RW, set RS */ drv_generic_parport_control (SIGNAL_RW | SIGNAL_RS, SIGNAL_RS); - // Address set-up time + /* Address set-up time */ ndelay(T_AS); } - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (*(string++)); - // send command + /* send command */ drv_generic_parport_toggle (enable, 1, T_PW); - // wait for command completion + /* wait for command completion */ if (!UseBusy) udelay(delay); } - } else { // 4 bit mode + } else { /* 4 bit mode */ while (l--) { if (UseBusy) wait_for_busy_flag(controller); - // send data with RS enabled + /* send data with RS enabled */ drv_HD_byte (controller, *(string++), SIGNAL_RS); - // wait for command completion + /* wait for command completion */ if (!UseBusy) udelay(delay); } } @@ -516,7 +522,7 @@ static void drv_HD_data (const unsigned char controller, const char *string, con static void drv_HD_clear (void) { - drv_HD_command (allControllers, 0x01, T_CLEAR); // clear *both* displays + drv_HD_command (allControllers, 0x01, T_CLEAR); /* clear *both* displays */ } @@ -524,7 +530,7 @@ static void drv_HD_goto (int row, int col) { int pos; - // handle multiple displays/controllers + /* handle multiple displays/controllers */ if (numControllers>1 && row>=DROWS/2) { row -= DROWS/2; currController = 2; @@ -532,17 +538,17 @@ static void drv_HD_goto (int row, int col) currController = 1; } - // 16x1 Displays are organized as 8x2 :-( + /* 16x1 Displays are organized as 8x2 :-( */ if (DCOLS==16 && DROWS==1 && col>7) { row++; col-=8; } if (Capabilities & CAP_HD66712) { - // the HD66712 doesn't have a braindamadged RAM layout + /* the HD66712 doesn't have a braindamadged RAM layout */ pos = row*32 + col; } else { - // 16x4 Displays use a slightly different layout + /* 16x4 Displays use a slightly different layout */ if (DCOLS==16 && DROWS==4) { pos = (row%2)*64+(row/2)*16+col; } else { @@ -553,7 +559,7 @@ static void drv_HD_goto (int row, int col) } -static void drv_HD_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_HD_write (const int row, const int col, const char *data, const int len) { drv_HD_goto (row, col); drv_HD_data (currController, data, len, T_EXEC); @@ -563,13 +569,13 @@ static void drv_HD_write (const int row, const int col, const unsigned char *dat static void drv_HD_defchar (const int ascii, const unsigned char *matrix) { int i; - unsigned char buffer[8]; + char buffer[8]; for (i = 0; i < 8; i++) { buffer[i] = matrix[i] & 0x1f; } - // define chars on *both* controllers! + /* define chars on *both* controllers! */ drv_HD_command (allControllers, 0x40|8*ascii, T_EXEC); drv_HD_data (allControllers, buffer, 8, T_WRCG); } @@ -586,27 +592,27 @@ static int drv_HD_brightness (int brightness) cmd='0'+brightness; - drv_HD_command (allControllers, 0x38, T_EXEC); // enable function - drv_HD_data (allControllers, &cmd, 1, T_WRCG); // set brightness + drv_HD_command (allControllers, 0x38, T_EXEC); /* enable function */ + drv_HD_data (allControllers, &cmd, 1, T_WRCG); /* set brightness */ return brightness; } -// Fixme: GPO's +/* Fixme: GPO's */ #if 0 static void drv_HD_setGPO (const int bits) { if (Lcd.gpos>0) { - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (bits); - // 74HCT573 set-up time + /* 74HCT573 set-up time */ ndelay(20); - // send data - // 74HCT573 enable pulse width = 24ns + /* send data */ + /* 74HCT573 enable pulse width = 24ns */ drv_generic_parport_toggle (SIGNAL_GPO, 1, 230); } } @@ -655,10 +661,10 @@ static int drv_HD_start (const char *section, const int quiet) if (cfg_number(section, "Controllers", 1, 1, 2, &numControllers)<0) return -1; info ("%s: using display with %d controllers", Name, numControllers); - // current controller + /* current controller */ currController=1; - // Bitmask for *all* Controllers + /* Bitmask for *all* Controllers */ allControllers = numControllers==2 ? 3 : 1; DROWS = rows; @@ -691,42 +697,42 @@ static int drv_HD_start (const char *section, const int quiet) if ((SIGNAL_GPO = drv_generic_parport_wire_data ("GPO", "GND"))==0xff) return -1; } - // clear all signals + /* clear all signals */ if (Bits==8) { drv_generic_parport_control (SIGNAL_RS|SIGNAL_RW|SIGNAL_ENABLE|SIGNAL_ENABLE2|SIGNAL_GPO, 0); } else { drv_generic_parport_data (0); } - // set direction: write + /* set direction: write */ drv_generic_parport_direction (0); - // initialize *both* displays + /* initialize *both* displays */ if (Bits==8) { - drv_HD_command (allControllers, 0x30, T_INIT1); // 8 Bit mode, wait 4.1 ms - drv_HD_command (allControllers, 0x30, T_INIT2); // 8 Bit mode, wait 100 us - drv_HD_command (allControllers, 0x38, T_EXEC); // 8 Bit mode, 1/16 duty cycle, 5x8 font + drv_HD_command (allControllers, 0x30, T_INIT1); /* 8 Bit mode, wait 4.1 ms */ + drv_HD_command (allControllers, 0x30, T_INIT2); /* 8 Bit mode, wait 100 us */ + drv_HD_command (allControllers, 0x38, T_EXEC); /* 8 Bit mode, 1/16 duty cycle, 5x8 font */ } else { - drv_HD_nibble (allControllers, 0x03); udelay(T_INIT1); // 4 Bit mode, wait 4.1 ms - drv_HD_nibble (allControllers, 0x03); udelay(T_INIT2); // 4 Bit mode, wait 100 us - drv_HD_nibble (allControllers, 0x03); udelay(T_INIT1); // 4 Bit mode, wait 4.1 ms - drv_HD_nibble (allControllers, 0x02); udelay(T_INIT2); // 4 Bit mode, wait 100 us - drv_HD_command (allControllers, 0x28, T_EXEC); // 4 Bit mode, 1/16 duty cycle, 5x8 font + drv_HD_nibble (allControllers, 0x03); udelay(T_INIT1); /* 4 Bit mode, wait 4.1 ms */ + drv_HD_nibble (allControllers, 0x03); udelay(T_INIT2); /* 4 Bit mode, wait 100 us */ + drv_HD_nibble (allControllers, 0x03); udelay(T_INIT1); /* 4 Bit mode, wait 4.1 ms */ + drv_HD_nibble (allControllers, 0x02); udelay(T_INIT2); /* 4 Bit mode, wait 100 us */ + drv_HD_command (allControllers, 0x28, T_EXEC); /* 4 Bit mode, 1/16 duty cycle, 5x8 font */ } - // maybe use busy-flag from now on - // (we can't use the busy flag during the init sequence) + /* maybe use busy-flag from now on */ + /* (we can't use the busy flag during the init sequence) */ cfg_number(section, "UseBusy", 0, 0, 1, &UseBusy); - // make sure we don't use the busy flag with RW wired to GND + /* make sure we don't use the busy flag with RW wired to GND */ if (UseBusy && !SIGNAL_RW) { error("%s: Busyflag is to be used, but RW is wired to GND", Name); UseBusy=0; } - // make sure the display supports busy-flag checking in 4-Bit-Mode - // at the moment this is inly possible with Martin Hejl's gpio driver, - // which allows to use 4 bits as input and 4 bits as output + /* make sure the display supports busy-flag checking in 4-Bit-Mode */ + /* at the moment this is inly possible with Martin Hejl's gpio driver, */ + /* which allows to use 4 bits as input and 4 bits as output */ if (UseBusy && Bits==4 && !(Capabilities&CAP_BUSY4BIT)) { error("%s: Model '%s' does not support busy-flag checking in 4-bit-mode", Name, Models[Model].name); UseBusy=0; @@ -735,20 +741,20 @@ static int drv_HD_start (const char *section, const int quiet) info("%s: %susing busy-flag checking", Name, UseBusy?"":"not "); free(strsize); - drv_HD_command (allControllers, 0x08, T_EXEC); // Display off, cursor off, blink off - drv_HD_command (allControllers, 0x0c, T_CLEAR); // Display on, cursor off, blink off, wait 1.64 ms - drv_HD_command (allControllers, 0x06, T_EXEC); // curser moves to right, no shift + drv_HD_command (allControllers, 0x08, T_EXEC); /* Display off, cursor off, blink off */ + drv_HD_command (allControllers, 0x0c, T_CLEAR); /* Display on, cursor off, blink off, wait 1.64 ms */ + drv_HD_command (allControllers, 0x06, T_EXEC); /* curser moves to right, no shift */ if ((Capabilities & CAP_HD66712) && DROWS > 2) { - drv_HD_command (allControllers, Bits==8?0x3c:0x2c, T_EXEC); // set extended register enable bit - drv_HD_command (allControllers, 0x09, T_EXEC); // set 4-line mode - drv_HD_command (allControllers, Bits==8?0x38:0x28, T_EXEC); // clear extended register enable bit + drv_HD_command (allControllers, Bits==8?0x3c:0x2c, T_EXEC); /* set extended register enable bit */ + drv_HD_command (allControllers, 0x09, T_EXEC); /* set 4-line mode */ + drv_HD_command (allControllers, Bits==8?0x38:0x28, T_EXEC); /* clear extended register enable bit */ } - drv_HD_clear(); // clear *both* displays - drv_HD_command (allControllers, 0x03, T_CLEAR); // return home + drv_HD_clear(); /* clear *both* displays */ + drv_HD_command (allControllers, 0x03, T_CLEAR); /* return home */ - // maybe set brightness + /* maybe set brightness */ if (Capabilities & CAP_BRIGHTNESS) { int brightness; if (cfg_number(section, "Brightness", 0, 0, 3, &brightness)>0) { @@ -769,9 +775,9 @@ static int drv_HD_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ static void plugin_brightness (RESULT *result, RESULT *arg1) @@ -783,22 +789,22 @@ static void plugin_brightness (RESULT *result, RESULT *arg1) } -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_HD_list (void) { int i; @@ -810,66 +816,66 @@ int drv_HD_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_HD_init (const char *section, const int quiet) { WIDGET_CLASS wc; int asc255bug; int ret; - // display preferences - XRES = 5; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 2; // number of bytes a goto command requires + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 2; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_HD_write; drv_generic_text_real_defchar = drv_HD_defchar; - // start display + /* start display */ if ((ret=drv_HD_start (section, quiet))!=0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - // most displays have a full block on ascii 255, but some have kind of - // an 'inverted P'. If you specify 'asc255bug 1 in the config, this - // char will not be used, but rendered by the bar driver + /* add fixed chars to the bar driver */ + /* most displays have a full block on ascii 255, but some have kind of */ + /* an 'inverted P'. If you specify 'asc255bug 1 in the config, this */ + /* char will not be used, but rendered by the bar driver */ cfg_number(section, "asc255bug", 0, 0, 1, &asc255bug); - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ if (!asc255bug) - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins + /* register plugins */ if (Capabilities & CAP_BRIGHTNESS) { AddFunction ("LCD::brightness", 1, plugin_brightness); } @@ -878,22 +884,22 @@ int drv_HD_init (const char *section, const int quiet) } -// close driver & display +/* close driver & display */ int drv_HD_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear *both* displays + /* clear *both* displays */ drv_HD_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } - // clear all signals + /* clear all signals */ if (Bits==8) { drv_generic_parport_control (SIGNAL_RS|SIGNAL_RW|SIGNAL_ENABLE|SIGNAL_ENABLE2|SIGNAL_GPO, 0); } else { diff --git a/drv_Image.c b/drv_Image.c index 41daaeb..5bd0c82 100644 --- a/drv_Image.c +++ b/drv_Image.c @@ -1,4 +1,4 @@ -/* $Id: drv_Image.c,v 1.7 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_Image.c,v 1.8 2004/06/26 09:27:20 reinelt Exp $ * * new style Image (PPM/PNG) Driver for LCD4Linux * @@ -23,6 +23,12 @@ * * * $Log: drv_Image.c,v $ + * Revision 1.8 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.7 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -110,21 +116,21 @@ static enum {PPM, PNG} Format; static unsigned int fg_col, bg_col, hg_col; -static int pixel = -1; // pointsize in pixel -static int pgap = 0; // gap between points -static int rgap = 0; // row gap between lines -static int cgap = 0; // column gap between characters -static int border = 0; // window border +static int pixel = -1; /* pointsize in pixel */ +static int pgap = 0; /* gap between points */ +static int rgap = 0; /* row gap between lines */ +static int cgap = 0; /* column gap between characters */ +static int border = 0; /* window border */ -static int dimx, dimy; // total window dimension in pixel +static int dimx, dimy; /* total window dimension in pixel */ static unsigned char *drv_IMG_FB = NULL; static int dirty = 1; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ #ifdef WITH_PPM static int drv_IMG_flush_PPM (void) @@ -170,12 +176,12 @@ static int drv_IMG_flush_PPM (void) snprintf (path, sizeof(path), output, seq++); qprintf(tmp, sizeof(tmp), "%s.tmp", path); - // remove the file + /* remove the file */ unlink (tmp); - // avoid symlink security hole: - // open it with O_EXCL will fail if the file exists. - // This should not happen because we just unlinked it. + /* avoid symlink security hole: */ + /* open it with O_EXCL will fail if the file exists. */ + /* This should not happen because we just unlinked it. */ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0644))<0) { error ("%s: open(%s) failed: %s", Name, tmp, strerror(errno)); return -1; @@ -271,12 +277,12 @@ static int drv_IMG_flush_PNG (void) snprintf (path, sizeof(path), output, seq++); qprintf (tmp, sizeof(tmp), "%s.tmp", path); - // remove the file + /* remove the file */ unlink (tmp); - // avoid symlink security hole: - // open it with O_EXCL will fail if the file exists. - // This should not happen because we just unlinked it. + /* avoid symlink security hole: */ + /* open it with O_EXCL will fail if the file exists. */ + /* This should not happen because we just unlinked it. */ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_EXCL, 0644))<0) { error ("%s: open(%s) failed: %s", Name, tmp, strerror(errno)); return -1; @@ -326,6 +332,9 @@ static void drv_IMG_flush (void) static void drv_IMG_timer (void *notused) { + /* avoid compiler warning */ + notused = notused; + if (dirty) { drv_IMG_flush(); dirty = 0; @@ -358,7 +367,7 @@ static int drv_IMG_start (const char *section) return -1; } - // read file format from config + /* read file format from config */ s = cfg_get(section, "Format", NULL); if (s == NULL || *s == '\0') { error ("%s: no '%s.Format' entry from %s", Name, section, cfg_source()); @@ -377,7 +386,7 @@ static int drv_IMG_start (const char *section) } free(s); - // read display size from config + /* read display size from config */ if (sscanf(s=cfg_get(section, "Size", "120x32"), "%dx%d", &DCOLS, &DROWS)!=2 || DCOLS<1 || DROWS<1) { error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source()); free(s); @@ -445,11 +454,11 @@ static int drv_IMG_start (const char *section) dimy = DROWS*pixel + (DROWS-1)*pgap + (DROWS/YRES-1)*rgap; - // initially flush the image to a file + /* initially flush the image to a file */ drv_IMG_flush(); - // regularly flush the image to a file - // Fixme: make 100msec configurable + /* regularly flush the image to a file */ + /* Fixme: make 100msec configurable */ timer_add (drv_IMG_timer, NULL, 100, 0); @@ -458,29 +467,29 @@ static int drv_IMG_start (const char *section) -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_graphic_draw(W) -// using drv_generic_graphic_icon_draw(W) -// using drv_generic_graphic_bar_draw(W) +/* using drv_generic_graphic_draw(W) */ +/* using drv_generic_graphic_icon_draw(W) */ +/* using drv_generic_graphic_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_IMG_list (void) { printf ("PPM PNG"); @@ -488,48 +497,48 @@ int drv_IMG_list (void) } -// initialize driver & display -int drv_IMG_init (const char *section, const int quiet) +/* initialize driver & display */ +int drv_IMG_init (const char *section, const __attribute__((unused)) int quiet) { WIDGET_CLASS wc; int ret; - // real worker functions + /* real worker functions */ drv_generic_graphic_real_blit = drv_IMG_blit; - // start display + /* start display */ if ((ret=drv_IMG_start (section))!=0) return ret; - // initialize generic graphic driver + /* initialize generic graphic driver */ if ((ret=drv_generic_graphic_init(section, Name))!=0) return ret; - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_graphic_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_graphic_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_graphic_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display -int drv_IMG_quit (const int quiet) { +/* close driver & display */ +int drv_IMG_quit (const __attribute__((unused)) int quiet) { info("%s: shutting down.", Name); drv_generic_graphic_quit(); diff --git a/drv_M50530.c b/drv_M50530.c index cddf0cc..b576ebe 100644 --- a/drv_M50530.c +++ b/drv_M50530.c @@ -1,4 +1,4 @@ -/* $Id: drv_M50530.c,v 1.12 2004/06/20 10:09:54 reinelt Exp $ +#/* $Id: drv_M50530.c,v 1.13 2004/06/26 09:27:20 reinelt Exp $ * * new style driver for M50530-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_M50530.c,v $ + * Revision 1.13 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.12 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -122,9 +128,9 @@ static unsigned char SIGNAL_IOC1; static unsigned char SIGNAL_IOC2; static unsigned char SIGNAL_GPO; -// Fixme: GPO's not yet implemented +/* Fixme: GPO's not yet implemented */ static int GPOS; -// static int GPO=0; +/* static int GPO=0; */ typedef struct { @@ -138,31 +144,31 @@ static MODEL Models[] = { }; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_M5_command (const unsigned int cmd, const int delay) { - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (cmd&0xff); - // set I/OC1 - // set I/OC2 + /* set I/OC1 */ + /* set I/OC2 */ drv_generic_parport_control (SIGNAL_IOC1|SIGNAL_IOC2, (cmd&0x200?SIGNAL_IOC1:0) | (cmd&0x100?SIGNAL_IOC2:0)); - // Control data setup time + /* Control data setup time */ ndelay(200); - // send command - // EX signal pulse width = 500ns - // Fixme: why 500 ns? Datasheet says 200ns + /* send command */ + /* EX signal pulse width = 500ns */ + /* Fixme: why 500 ns? Datasheet says 200ns */ drv_generic_parport_toggle (SIGNAL_EX, 1, 500); - // wait + /* wait */ udelay(delay); } @@ -170,11 +176,11 @@ static void drv_M5_command (const unsigned int cmd, const int delay) static void drv_M5_clear (void) { - drv_M5_command (0x0001, 1250); // clear display + drv_M5_command (0x0001, 1250); /* clear display */ } -static void drv_M5_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_M5_write (const int row, const int col, const char *data, const int len) { int l = len; unsigned int cmd; @@ -197,28 +203,28 @@ static void drv_M5_defchar (const int ascii, const unsigned char *matrix) drv_M5_command (0x300+192+8*(ascii-CHAR0), 20); - // Fixme: looks like the M50530 cannot control the bottom line - // therefore we have only 7 bytes here + /* Fixme: looks like the M50530 cannot control the bottom line */ + /* therefore we have only 7 bytes here */ for (i=0; i<7; i++) { drv_M5_command (0x100|(matrix[i] & 0x3f), 20); } } -// Fixme: GPO's +/* Fixme: GPO's */ #if 0 static void drv_M5_setGPO (const int bits) { if (Lcd.gpos>0) { - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (bits); - // 74HCT573 set-up time + /* 74HCT573 set-up time */ ndelay(20); - // send data - // 74HCT573 enable pulse width = 24ns + /* send data */ + /* 74HCT573 enable pulse width = 24ns */ drv_generic_parport_toggle (SIGNAL_GPO, 1, 24); } } @@ -274,16 +280,16 @@ static int drv_M5_start (const char *section, const int quiet) if ((SIGNAL_IOC2 = drv_generic_parport_wire_ctrl ("IOC2", "AUTOFD"))==0xff) return -1; if ((SIGNAL_GPO = drv_generic_parport_wire_ctrl ("GPO", "INIT" ))==0xff) return -1; - // clear all signals + /* clear all signals */ drv_generic_parport_control (SIGNAL_EX|SIGNAL_IOC1|SIGNAL_IOC2|SIGNAL_GPO, 0); - // set direction: write + /* set direction: write */ drv_generic_parport_direction (0); - drv_M5_command (0x00FA, 20); // set function mode - drv_M5_command (0x0020, 20); // set display mode - drv_M5_command (0x0050, 20); // set entry mode - drv_M5_command (0x0030, 20); // set display mode + drv_M5_command (0x00FA, 20); /* set function mode */ + drv_M5_command (0x0020, 20); /* set display mode */ + drv_M5_command (0x0050, 20); /* set entry mode */ + drv_M5_command (0x0030, 20); /* set display mode */ drv_M5_clear(); @@ -300,28 +306,28 @@ static int drv_M5_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment +/* none at the moment */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_M5_list (void) { int i; @@ -333,81 +339,81 @@ int drv_M5_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_M5_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES = 5; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 248; // ASCII of first user-defineable char - GOTO_COST = 1; // number of bytes a goto command requires + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 248; /* ASCII of first user-defineable char */ + GOTO_COST = 1; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_M5_write; drv_generic_text_real_defchar = drv_M5_defchar; - // start display + /* start display */ if ((ret=drv_M5_start (section, quiet))!=0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment (0,0,255,32); // ASCII 32 = blank + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment (0,0,255,32); /* ASCII 32 = blank */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins - // none at the moment + /* register plugins */ + /* none at the moment */ return 0; } -// close driver & display +/* close driver & display */ int drv_M5_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_M5_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } - // clear all signals + /* clear all signals */ drv_generic_parport_control (SIGNAL_EX|SIGNAL_IOC1|SIGNAL_IOC2|SIGNAL_GPO, 0); drv_generic_parport_close(); diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c index ca19531..fd2349c 100644 --- a/drv_MatrixOrbital.c +++ b/drv_MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: drv_MatrixOrbital.c,v 1.34 2004/06/26 06:12:15 reinelt Exp $ +/* $Id: drv_MatrixOrbital.c,v 1.35 2004/06/26 09:27:20 reinelt Exp $ * * new style driver for Matrix Orbital serial display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_MatrixOrbital.c,v $ + * Revision 1.35 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.34 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals @@ -202,8 +208,8 @@ static char Name[]="MatrixOrbital"; static int Model; static int Protocol; -// Fixme: GPO's not yet implemented -// static int GPO[8]; +/* Fixme: GPO's not yet implemented */ +/* static int GPO[8]; */ static int GPOS; @@ -216,8 +222,8 @@ typedef struct { int protocol; } MODEL; -// Fixme #1: number of gpo's should be verified -// Fixme #2: protocol should be verified +/* Fixme #1: number of gpo's should be verified */ +/* Fixme #2: protocol should be verified */ static MODEL Models[] = { { 0x01, "LCD0821", 2, 8, 0, 1 }, @@ -249,24 +255,24 @@ static MODEL Models[] = { }; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_MO_clear (void) { switch (Protocol) { case 1: - drv_generic_serial_write ("\014", 1); // Clear Screen + drv_generic_serial_write ("\014", 1); /* Clear Screen */ break; case 2: - drv_generic_serial_write ("\376\130", 2); // Clear Screen + drv_generic_serial_write ("\376\130", 2); /* Clear Screen */ break; } } -static void drv_MO_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_MO_write (const int row, const int col, const char *data, const int len) { char cmd[5]="\376Gyx"; @@ -296,7 +302,7 @@ static int drv_MO_contrast (int contrast) static unsigned char Contrast=0; char cmd[3] = "\376Pn"; - // -1 is used to query the current contrast + /* -1 is used to query the current contrast */ if (contrast == -1) return Contrast; if (contrast < 0 ) contrast = 0; @@ -316,7 +322,7 @@ static int drv_MO_backlight (int backlight) static unsigned char Backlight=0; char cmd[3] = "\376Bn"; - // -1 is used to query the current backlight + /* -1 is used to query the current backlight */ if (backlight == -1) return Backlight; if (backlight < 0 ) backlight = 0; @@ -324,10 +330,10 @@ static int drv_MO_backlight (int backlight) Backlight = backlight; if (backlight < 0) { - // backlight off + /* backlight off */ drv_generic_serial_write ("\376F", 2); } else { - // backlight on for n minutes + /* backlight on for n minutes */ cmd[2] = Backlight; drv_generic_serial_write (cmd, 3); } @@ -344,7 +350,7 @@ static int drv_MO_gpo (int num, int val) if (num < 1) num = 1; if (num > 6) num = 6; - // -1 is used to query the current PWM + /* -1 is used to query the current PWM */ if (val == -1) return GPO[num-1]; if (val < 0) val = 0; @@ -355,9 +361,9 @@ static int drv_MO_gpo (int num, int val) case 1: if (num == 1) { if (val > 0) { - drv_generic_serial_write ("\376W", 2); // GPO on + drv_generic_serial_write ("\376W", 2); /* GPO on */ } else { - drv_generic_serial_write ("\376V", 2); // GPO off + drv_generic_serial_write ("\376V", 2); /* GPO off */ } } else { GPO[num-1] = -1; @@ -366,9 +372,9 @@ static int drv_MO_gpo (int num, int val) case 2: if (val > 0) { - cmd[1] = 'W'; // GPO on + cmd[1] = 'W'; /* GPO on */ } else { - cmd[1] = 'V'; // GPO off + cmd[1] = 'V'; /* GPO off */ } cmd[2] = (char)num; drv_generic_serial_write (cmd, 3); @@ -387,7 +393,7 @@ static int drv_MO_pwm (int num, int val) if (num < 1) num = 1; if (num > 6) num = 6; - // -1 is used to query the current PWM + /* -1 is used to query the current PWM */ if (val == -1) return PWM[num-1]; if (val < 0) val = 0; @@ -425,7 +431,7 @@ static int drv_MO_rpm (int num) debug ("rpm: buffer[5]=0x%01x", buffer[5]); debug ("rpm: buffer[6]=0x%01x", buffer[6]); - // Fixme: RPM calculations??? + /* Fixme: RPM calculations??? */ RPM[num-1] = 42; return RPM[num-1]; @@ -458,7 +464,7 @@ static int drv_MO_start (const char *section, const int quiet) if (drv_generic_serial_open(section, Name, 0)<0) return -1; if (Model == -1 || Models[Model].protocol > 1) { - // read module type + /* read module type */ drv_generic_serial_write ("\3767", 2); usleep(1000); if (drv_generic_serial_read (buffer, 1)==1) { @@ -468,10 +474,10 @@ static int drv_MO_start (const char *section, const int quiet) info ("%s: display reports model '%s' (type 0x%02x)", Name, Models[i].name, Models[i].type); - // auto-dedection + /* auto-dedection */ if (Model==-1) Model=i; - // auto-dedection matches specified model? + /* auto-dedection matches specified model? */ if (Models[i].type!=0xff && Model!=i) { error ("%s: %s.Model '%s' from %s does not match dedected Model '%s'", Name, section, model, cfg_source(), Models[i].name); @@ -483,21 +489,21 @@ static int drv_MO_start (const char *section, const int quiet) } } - // initialize global variables + /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; GPOS = Models[Model].gpos; Protocol = Models[Model].protocol; if (Protocol > 1) { - // read serial number + /* read serial number */ drv_generic_serial_write ("\3765", 2); usleep(100000); if (drv_generic_serial_read (buffer, 2)==2) { info ("%s: display reports serial number 0x%x", Name, *(short*)buffer); } - // read version number + /* read version number */ drv_generic_serial_write ("\3766", 2); usleep(100000); if (drv_generic_serial_read (buffer, 1)==1) { @@ -507,18 +513,18 @@ static int drv_MO_start (const char *section, const int quiet) drv_MO_clear(); - drv_generic_serial_write ("\376B", 3); // backlight on - drv_generic_serial_write ("\376K", 2); // cursor off - drv_generic_serial_write ("\376T", 2); // blink off - drv_generic_serial_write ("\376D", 2); // line wrapping off - drv_generic_serial_write ("\376R", 2); // auto scroll off + drv_generic_serial_write ("\376B", 3); /* backlight on */ + drv_generic_serial_write ("\376K", 2); /* cursor off */ + drv_generic_serial_write ("\376T", 2); /* blink off */ + drv_generic_serial_write ("\376D", 2); /* line wrapping off */ + drv_generic_serial_write ("\376R", 2); /* auto scroll off */ - // set contrast + /* set contrast */ if (cfg_number(section, "Contrast", 0, 0, 255, &i)>0) { drv_MO_contrast(i); } - // set backlight + /* set backlight */ if (cfg_number(section, "Backlight", 0, 0, 255, &i)>0) { drv_MO_backlight(i); } @@ -534,9 +540,9 @@ static int drv_MO_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[]) @@ -628,21 +634,21 @@ static void plugin_rpm (RESULT *result, RESULT *arg1) } -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_MO_list (void) { int i; @@ -654,60 +660,60 @@ int drv_MO_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_MO_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES=5; // pixel width of one char - YRES=8; // pixel height of one char - CHARS=8; // number of user-defineable characters - CHAR0=0; // ASCII of first user-defineable char - GOTO_COST=4; // number of bytes a goto command requires + /* display preferences */ + XRES=5; /* pixel width of one char */ + YRES=8; /* pixel height of one char */ + CHARS=8; /* number of user-defineable characters */ + CHAR0=0; /* ASCII of first user-defineable char */ + GOTO_COST=4; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_MO_write; drv_generic_text_real_defchar = drv_MO_defchar; - // start display + /* start display */ if ((ret=drv_MO_start (section, quiet))!=0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins + /* register plugins */ AddFunction ("LCD::contrast", -1, plugin_contrast); AddFunction ("LCD::backlight", -1, plugin_backlight); AddFunction ("LCD::gpo", -1, plugin_gpo); @@ -718,17 +724,17 @@ int drv_MO_init (const char *section, const int quiet) } -// close driver & display +/* close driver & display */ int drv_MO_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_MO_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } diff --git a/drv_MilfordInstruments.c b/drv_MilfordInstruments.c index 396ce86..2105898 100644 --- a/drv_MilfordInstruments.c +++ b/drv_MilfordInstruments.c @@ -1,4 +1,4 @@ -/* $Id: drv_MilfordInstruments.c,v 1.10 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_MilfordInstruments.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * driver for Milford Instruments 'BPK' piggy-back serial interface board * for standard Hitachi 44780 compatible lcd modules. @@ -27,6 +27,12 @@ * * * $Log: drv_MilfordInstruments.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -112,24 +118,24 @@ static MODEL Models[] = { static int Model; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_MI_clear (void) { - drv_generic_serial_write ("\376\001", 2); // clear screen + drv_generic_serial_write ("\376\001", 2); /* clear screen */ } -static void drv_MI_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_MI_write (const int row, const int col, const char *data, const int len) { char cmd[2] = "\376x"; - char ddbase = 128; - if (row & 1) { // i.e. if row is 1 or 3 + int ddbase = 128; + if (row & 1) { /* i.e. if row is 1 or 3 */ ddbase += 64; } - if (row & 2) { // i.e. if row is 0 or 2. + if (row & 2) { /* i.e. if row is 0 or 2. */ ddbase += 20; } cmd[1] = (char)(ddbase+col); @@ -177,12 +183,12 @@ static int drv_MI_start (const char *section, const int quiet) if (drv_generic_serial_open(section, Name, 0) < 0) return -1; - // initialize global variables + /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; drv_MI_clear(); - drv_generic_serial_write ("\376\014", 2); // cursor off + drv_generic_serial_write ("\376\014", 2); /* cursor off */ if (!quiet) { if (drv_generic_text_greet (Models[Model].name, "Milford Instruments")) { @@ -195,28 +201,28 @@ static int drv_MI_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_MI_list (void) { int i; @@ -228,77 +234,77 @@ int drv_MI_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_MI_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES = 5; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 4; // number of bytes a goto command requires + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 4; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_MI_write; drv_generic_text_real_defchar = drv_MI_defchar; - // start display + /* start display */ if ((ret=drv_MI_start (section, quiet))!=0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display +/* close driver & display */ int drv_MI_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); - // clear display + /* clear display */ drv_MI_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } @@ -1,4 +1,4 @@ -/* $Id: drv_NULL.c,v 1.4 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_NULL.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * NULL driver (for testing) * @@ -23,6 +23,12 @@ * * * $Log: drv_NULL.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -70,19 +76,23 @@ static char Name[] = "NULL"; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ -static void drv_NULL_write (const int row, const int col, const unsigned char *data, const int len) +static void drv_NULL_write (const __attribute__((unused)) int row, + const __attribute__((unused)) int col, + const __attribute__((unused)) char *data, + const __attribute__((unused)) int len) { - // empty + /* empty */ } -static void drv_NULL_defchar (const int ascii, const unsigned char *matrix) +static void drv_NULL_defchar (const __attribute__((unused)) int ascii, + const __attribute__((unused)) unsigned char *matrix) { - // empty + /* empty */ } @@ -107,27 +117,27 @@ static int drv_NULL_start (const char *section) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_NULL_list (void) { printf ("generic"); @@ -135,58 +145,58 @@ int drv_NULL_list (void) } -// initialize driver & display -int drv_NULL_init (const char *section, const int quiet) +/* initialize driver & display */ +int drv_NULL_init (const char *section, const __attribute__((unused)) int quiet) { WIDGET_CLASS wc; int ret; - // display preferences - XRES = 6; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 2; // number of bytes a goto command requires + /* display preferences */ + XRES = 6; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 2; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_NULL_write; drv_generic_text_real_defchar = drv_NULL_defchar; - // start display + /* start display */ if ((ret = drv_NULL_start (section)) != 0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret = drv_generic_text_init(section, Name)) != 0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret = drv_generic_text_bar_init(1)) != 0) return ret; - // add fixed chars to the bar driver - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank - drv_generic_text_bar_add_segment (255,255,255,'*'); // asterisk + /* add fixed chars to the bar driver */ + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ + drv_generic_text_bar_add_segment (255,255,255,'*'); /* asterisk */ - // register text widget + /* register text widget */ wc = Widget_Text; wc.draw = drv_generic_text_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc = Widget_Bar; wc.draw = drv_generic_text_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display -int drv_NULL_quit (const int quiet) { +/* close driver & display */ +int drv_NULL_quit (const __attribute__((unused)) int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); diff --git a/drv_T6963.c b/drv_T6963.c index e256075..b7c28d5 100644 --- a/drv_T6963.c +++ b/drv_T6963.c @@ -1,4 +1,4 @@ -/* $Id: drv_T6963.c,v 1.10 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_T6963.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * new style driver for T6963-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_T6963.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -127,25 +133,25 @@ unsigned char *Buffer1, *Buffer2; static int bug=0; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ -// perform normal status check +/* perform normal status check */ static void drv_T6_status1 (void) { int n; - // turn off data line drivers + /* turn off data line drivers */ drv_generic_parport_direction (1); - // lower CE and RD + /* lower CE and RD */ drv_generic_parport_control (SIGNAL_CE | SIGNAL_RD, 0); - // Access Time: 150 ns + /* Access Time: 150 ns */ ndelay(150); - // wait for STA0=1 and STA1=1 + /* wait for STA0=1 and STA1=1 */ n=0; do { rep_nop(); @@ -156,32 +162,32 @@ static void drv_T6_status1 (void) } } while ((drv_generic_parport_read() & 0x03) != 0x03); - // rise RD and CE + /* rise RD and CE */ drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); - // Output Hold Time: 50 ns + /* Output Hold Time: 50 ns */ ndelay(50); - // turn on data line drivers + /* turn on data line drivers */ drv_generic_parport_direction (0); } -// perform status check in "auto mode" +/* perform status check in "auto mode" */ static void drv_T6_status2 (void) { int n; - // turn off data line drivers + /* turn off data line drivers */ drv_generic_parport_direction (1); - // lower RD and CE + /* lower RD and CE */ drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, 0); - // Access Time: 150 ns + /* Access Time: 150 ns */ ndelay(150); - // wait for STA3=1 + /* wait for STA3=1 */ n=0; do { rep_nop(); @@ -192,102 +198,102 @@ static void drv_T6_status2 (void) } } while ((drv_generic_parport_read() & 0x08) != 0x08); - // rise RD and CE + /* rise RD and CE */ drv_generic_parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); - // Output Hold Time: 50 ns + /* Output Hold Time: 50 ns */ ndelay(50); - // turn on data line drivers + /* turn on data line drivers */ drv_generic_parport_direction (0); } static void drv_T6_write_cmd (const unsigned char cmd) { - // wait until the T6963 is idle + /* wait until the T6963 is idle */ drv_T6_status1(); - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (cmd); - // lower WR and CE + /* lower WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); - // Pulse width + /* Pulse width */ ndelay(80); - // rise WR and CE + /* rise WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - // Data Hold Time + /* Data Hold Time */ ndelay(40); } static void drv_T6_write_data (const unsigned char data) { - // wait until the T6963 is idle + /* wait until the T6963 is idle */ drv_T6_status1(); - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (data); - // lower C/D + /* lower C/D */ drv_generic_parport_control (SIGNAL_CD, 0); - // C/D Setup Time + /* C/D Setup Time */ ndelay(20); - // lower WR and CE + /* lower WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); - // Pulse Width + /* Pulse Width */ ndelay(80); - // rise WR and CE + /* rise WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - // Data Hold Time + /* Data Hold Time */ ndelay(40); - // rise CD + /* rise CD */ drv_generic_parport_control (SIGNAL_CD, SIGNAL_CD); } static void drv_T6_write_auto (const unsigned char data) { - // wait until the T6963 is idle + /* wait until the T6963 is idle */ drv_T6_status2(); - // put data on DB1..DB8 + /* put data on DB1..DB8 */ drv_generic_parport_data (data); - // lower C/D + /* lower C/D */ drv_generic_parport_control (SIGNAL_CD, 0); - // C/D Setup Time + /* C/D Setup Time */ ndelay(20); - // lower WR and CE + /* lower WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, 0); - // Pulse Width + /* Pulse Width */ ndelay(80); - // rise WR and CE + /* rise WR and CE */ drv_generic_parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); - // Data Hold Time + /* Data Hold Time */ ndelay(40); - // rise CD + /* rise CD */ drv_generic_parport_control (SIGNAL_CD, SIGNAL_CD); } -#if 0 // not used +#if 0 /* not used */ static void drv_T6_send_byte (const unsigned char cmd, const unsigned char data) { drv_T6_write_data(data); @@ -307,8 +313,8 @@ static void drv_T6_clear(const unsigned short addr, const int len) { int i; - drv_T6_send_word (0x24, addr); // Set Adress Pointer - drv_T6_write_cmd(0xb0); // Set Data Auto Write + drv_T6_send_word (0x24, addr); /* Set Adress Pointer */ + drv_T6_write_cmd(0xb0); /* Set Data Auto Write */ for (i=0; i<len; i++) { drv_T6_write_auto(0); if (bug) { @@ -317,7 +323,7 @@ static void drv_T6_clear(const unsigned short addr, const int len) } } drv_T6_status2(); - drv_T6_write_cmd(0xb2); // Auto Reset + drv_T6_write_cmd(0xb2); /* Auto Reset */ } @@ -325,8 +331,8 @@ static void drv_T6_copy(const unsigned short addr, const unsigned char *data, co { int i; - drv_T6_send_word (0x24, 0x0200+addr); // Set Adress Pointer - drv_T6_write_cmd(0xb0); // Set Data Auto Write + drv_T6_send_word (0x24, 0x0200+addr); /* Set Adress Pointer */ + drv_T6_write_cmd(0xb0); /* Set Data Auto Write */ for (i=0; i<len; i++) { drv_T6_write_auto(*(data++)); if (bug) { @@ -335,7 +341,7 @@ static void drv_T6_copy(const unsigned short addr, const unsigned char *data, co } } drv_T6_status2(); - drv_T6_write_cmd(0xb2); // Auto Reset + drv_T6_write_cmd(0xb2); /* Auto Reset */ } @@ -348,16 +354,16 @@ static void drv_T6_blit(const int row, const int col, const int height, const in for (c=col; c<col+width; c++) { unsigned char mask = 1<<(XRES-1-c%XRES); if (drv_generic_graphic_FB[r*LCOLS+c]) { - // set bit + /* set bit */ Buffer1[(r*DCOLS+c)/XRES] |= mask; } else { - // clear bit + /* clear bit */ Buffer1[(r*DCOLS+c)/XRES] &= ~mask; } } } - // max address + /* max address */ m=((row+height-1)*DCOLS+col+width)/XRES; for (i=(row*DCOLS+col)/XRES; i<=m; i++) { @@ -396,7 +402,7 @@ static int drv_T6_start (const char *section) return -1; } - // read display size from config + /* read display size from config */ s=cfg_get(section, "Size", NULL); if (s==NULL || *s=='\0') { error ("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); @@ -423,14 +429,14 @@ static int drv_T6_start (const char *section) return -1; } - // Fixme: provider other fonts someday... + /* Fixme: provider other fonts someday... */ if (XRES!=6 && YRES!=8) { error ("%s: bad Font '%s' from %s (only 6x8 at the moment)", Name, s, cfg_source()); return -1; } - TROWS=DROWS/YRES; // text rows - TCOLS=DCOLS/XRES; // text cols + TROWS=DROWS/YRES; /* text rows */ + TCOLS=DCOLS/XRES; /* text cols */ Buffer1=malloc(TCOLS*DROWS); if (Buffer1==NULL) { @@ -458,69 +464,69 @@ static int drv_T6_start (const char *section) if ((SIGNAL_RD=drv_generic_parport_wire_ctrl ("RD", "AUTOFD"))==0xff) return -1; if ((SIGNAL_WR=drv_generic_parport_wire_ctrl ("WR", "INIT") )==0xff) return -1; - // rise CE, CD, RD and WR + /* rise CE, CD, RD and WR */ drv_generic_parport_control (SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR, SIGNAL_CE | SIGNAL_CD | SIGNAL_RD | SIGNAL_WR); - // set direction: write + /* set direction: write */ drv_generic_parport_direction (0); - // initialize display + /* initialize display */ - drv_T6_send_word (0x40, 0x0000); // Set Text Home Address - drv_T6_send_word (0x41, TCOLS); // Set Text Area + drv_T6_send_word (0x40, 0x0000); /* Set Text Home Address */ + drv_T6_send_word (0x41, TCOLS); /* Set Text Area */ - drv_T6_send_word (0x42, 0x0200); // Set Graphic Home Address - drv_T6_send_word (0x43, TCOLS); // Set Graphic Area + drv_T6_send_word (0x42, 0x0200); /* Set Graphic Home Address */ + drv_T6_send_word (0x43, TCOLS); /* Set Graphic Area */ - drv_T6_write_cmd (0x80); // Mode Set: OR mode, Internal CG RAM mode - drv_T6_send_word (0x22, 0x0002); // Set Offset Register - drv_T6_write_cmd (0x98); // Set Display Mode: Curser off, Text off, Graphics on - drv_T6_write_cmd (0xa0); // Set Cursor Pattern: 1 line cursor - drv_T6_send_word (0x21, 0x0000); // Set Cursor Pointer to (0,0) + drv_T6_write_cmd (0x80); /* Mode Set: OR mode, Internal CG RAM mode */ + drv_T6_send_word (0x22, 0x0002); /* Set Offset Register */ + drv_T6_write_cmd (0x98); /* Set Display Mode: Curser off, Text off, Graphics on */ + drv_T6_write_cmd (0xa0); /* Set Cursor Pattern: 1 line cursor */ + drv_T6_send_word (0x21, 0x0000); /* Set Cursor Pointer to (0,0) */ - // clear display + /* clear display */ - // upper half + /* upper half */ rows=TROWS>8?8:TROWS; - drv_T6_clear(0x0000, TCOLS*rows); // clear text area - drv_T6_clear(0x0200, TCOLS*rows*8); // clear graphic area + drv_T6_clear(0x0000, TCOLS*rows); /* clear text area */ + drv_T6_clear(0x0200, TCOLS*rows*8); /* clear graphic area */ - // lower half + /* lower half */ if (TROWS>8) { rows=TROWS-8; - drv_T6_clear(0x8000, TCOLS*rows); // clear text area #2 - drv_T6_clear(0x8200, TCOLS*rows*8); // clear graphic area #2 + drv_T6_clear(0x8000, TCOLS*rows); /* clear text area #2 */ + drv_T6_clear(0x8200, TCOLS*rows*8); /* clear graphic area #2 */ } return 0; } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_graphic_draw(W) -// using drv_generic_graphic_icon_draw(W) -// using drv_generic_graphic_bar_draw(W) +/* using drv_generic_graphic_draw(W) */ +/* using drv_generic_graphic_icon_draw(W) */ +/* using drv_generic_graphic_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_T6_list (void) { int i; @@ -532,20 +538,20 @@ int drv_T6_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_T6_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // real worker functions + /* real worker functions */ drv_generic_graphic_real_blit = drv_T6_blit; - // start display + /* start display */ if ((ret=drv_T6_start (section))!=0) return ret; - // initialize generic graphic driver + /* initialize generic graphic driver */ if ((ret=drv_generic_graphic_init(section, Name))!=0) return ret; @@ -558,30 +564,30 @@ int drv_T6_init (const char *section, const int quiet) } } - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_graphic_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_graphic_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_graphic_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display +/* close driver & display */ int drv_T6_quit (const int quiet) { info("%s: shutting down.", Name); diff --git a/drv_USBLCD.c b/drv_USBLCD.c index 90977d0..3c7d885 100644 --- a/drv_USBLCD.c +++ b/drv_USBLCD.c @@ -1,4 +1,4 @@ -/* $Id: drv_USBLCD.c,v 1.13 2004/06/26 06:12:15 reinelt Exp $ +/* $Id: drv_USBLCD.c,v 1.14 2004/06/26 09:27:21 reinelt Exp $ * * new style driver for USBLCD displays * @@ -26,6 +26,12 @@ * * * $Log: drv_USBLCD.c,v $ + * Revision 1.14 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.13 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals @@ -135,9 +141,9 @@ static unsigned char *Buffer; static unsigned char *BufPtr; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_UL_send () { @@ -169,13 +175,13 @@ static void drv_UL_command (const unsigned char cmd) static void drv_UL_clear (void) { - drv_UL_command (0x01); // clear display - drv_UL_command (0x03); // return home - drv_UL_send(); // flush buffer + drv_UL_command (0x01); /* clear display */ + drv_UL_command (0x03); /* return home */ + drv_UL_send(); /* flush buffer */ } -static void drv_UL_write (const int row, const int col, const unsigned char *data, int len) +static void drv_UL_write (const int row, const int col, const char *data, int len) { int pos = (row%2)*64 + (row/2)*20 + col; drv_UL_command (0x80|pos); @@ -242,21 +248,21 @@ static int drv_UL_start (const char *section, const int quiet) DROWS = rows; DCOLS = cols; - // Init the command buffer + /* Init the command buffer */ Buffer = (char*)malloc(1024); if (Buffer==NULL) { error ("%s: coommand buffer could not be allocated: malloc() failed", Name); return -1; } - // open port + /* open port */ usblcd_file=open(Port,O_WRONLY); if (usblcd_file==-1) { error ("%s: open(%s) failed: %s", Name, Port, strerror(errno)); return -1; } - // get driver version + /* get driver version */ memset(buf,0,sizeof(buf)); if (ioctl(usblcd_file, IOC_GET_DRV_VERSION, buf)!=0) { error ("USBLCD: ioctl() failed, could not get Driver Version!"); @@ -290,16 +296,16 @@ static int drv_UL_start (const char *section, const int quiet) return -1; } - // reset coimmand buffer + /* reset coimmand buffer */ BufPtr=Buffer; - // initialize display - drv_UL_command (0x29); // 8 Bit mode, 1/16 duty cycle, 5x8 font - drv_UL_command (0x08); // Display off, cursor off, blink off - drv_UL_command (0x0c); // Display on, cursor off, blink off - drv_UL_command (0x06); // curser moves to right, no shift + /* initialize display */ + drv_UL_command (0x29); /* 8 Bit mode, 1/16 duty cycle, 5x8 font */ + drv_UL_command (0x08); /* Display off, cursor off, blink off */ + drv_UL_command (0x0c); /* Display on, cursor off, blink off */ + drv_UL_command (0x06); /* curser moves to right, no shift */ - drv_UL_clear(); // clear display + drv_UL_clear(); /* clear display */ if (!quiet) { char buffer[40]; @@ -314,29 +320,29 @@ static int drv_UL_start (const char *section, const int quiet) } -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_text_draw(W) -// using drv_generic_text_icon_draw(W) -// using drv_generic_text_bar_draw(W) +/* using drv_generic_text_draw(W) */ +/* using drv_generic_text_icon_draw(W) */ +/* using drv_generic_text_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_UL_list (void) { printf ("generic"); @@ -344,88 +350,88 @@ int drv_UL_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_UL_init (const char *section, const int quiet) { WIDGET_CLASS wc; int asc255bug; int ret; - // display preferences - XRES = 5; // pixel width of one char - YRES = 8; // pixel height of one char - CHARS = 8; // number of user-defineable characters - CHAR0 = 0; // ASCII of first user-defineable char - GOTO_COST = 2; // number of bytes a goto command requires + /* display preferences */ + XRES = 5; /* pixel width of one char */ + YRES = 8; /* pixel height of one char */ + CHARS = 8; /* number of user-defineable characters */ + CHAR0 = 0; /* ASCII of first user-defineable char */ + GOTO_COST = 2; /* number of bytes a goto command requires */ - // real worker functions + /* real worker functions */ drv_generic_text_real_write = drv_UL_write; drv_generic_text_real_defchar = drv_UL_defchar; - // start display + /* start display */ if ((ret=drv_UL_start (section, quiet))!=0) return ret; - // initialize generic text driver + /* initialize generic text driver */ if ((ret=drv_generic_text_init(section, Name))!=0) return ret; - // initialize generic icon driver + /* initialize generic icon driver */ if ((ret=drv_generic_text_icon_init())!=0) return ret; - // initialize generic bar driver + /* initialize generic bar driver */ if ((ret=drv_generic_text_bar_init(0))!=0) return ret; - // add fixed chars to the bar driver - // most displays have a full block on ascii 255, but some have kind of - // an 'inverted P'. If you specify 'asc255bug 1 in the config, this - // char will not be used, but rendered by the bar driver + /* add fixed chars to the bar driver */ + /* most displays have a full block on ascii 255, but some have kind of */ + /* an 'inverted P'. If you specify 'asc255bug 1 in the config, this */ + /* char will not be used, but rendered by the bar driver */ cfg_number(section, "asc255bug", 0, 0, 1, &asc255bug); - drv_generic_text_bar_add_segment ( 0, 0,255, 32); // ASCII 32 = blank + drv_generic_text_bar_add_segment ( 0, 0,255, 32); /* ASCII 32 = blank */ if (!asc255bug) - drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block + drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_text_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_text_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_text_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display +/* close driver & display */ int drv_UL_quit (const int quiet) { info("%s: shutting down.", Name); - // flush buffer + /* flush buffer */ drv_UL_send(); drv_generic_text_quit(); - // clear display + /* clear display */ drv_UL_clear(); - // say goodbye... + /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } @@ -1,4 +1,4 @@ -/* $Id: drv_X11.c,v 1.6 2004/06/20 10:09:54 reinelt Exp $ +/* $Id: drv_X11.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * new style X11 Driver for LCD4Linux * @@ -26,6 +26,12 @@ * * * $Log: drv_X11.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source @@ -95,13 +101,13 @@ static char Name[]="X11"; static char *fg_col,*bg_col,*hg_col; -static int pixel = -1; // pointsize in pixel -static int pgap = 0; // gap between points -static int rgap = 0; // row gap between lines -static int cgap = 0; // column gap between characters -static int border = 0; // window border +static int pixel = -1; /* pointsize in pixel */ +static int pgap = 0; /* gap between points */ +static int rgap = 0; /* row gap between lines */ +static int cgap = 0; /* column gap between characters */ +static int border = 0; /* window border */ -static int dimx, dimy; // total window dimension in pixel +static int dimx, dimy; /* total window dimension in pixel */ static unsigned char *drv_X11_FB=NULL; @@ -115,9 +121,9 @@ static XColor fg_xc, bg_xc, hg_xc; static Pixmap pm; -// **************************************** -// *** hardware dependant functions *** -// **************************************** +/****************************************/ +/*** hardware dependant functions ***/ +/****************************************/ static void drv_X11_blit(const int row, const int col, const int height, const int width) { @@ -174,7 +180,7 @@ static void drv_X11_expose(const int x, const int y, const int width, const int } -static void drv_X11_timer (void *notused) +static void drv_X11_timer (__attribute__((unused)) void *notused) { XEvent ev; @@ -194,7 +200,7 @@ static int drv_X11_start (const char *section) XEvent ev; - // read display size from config + /* read display size from config */ if (sscanf(s=cfg_get(section, "Size", "120x32"), "%dx%d", &DCOLS, &DROWS)!=2 || DCOLS<1 || DROWS<1) { error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source()); free(s); @@ -242,7 +248,7 @@ static int drv_X11_start (const char *section) return -1; } - // init with 255 so all 'halfground' pixels will be drawn + /* init with 255 so all 'halfground' pixels will be drawn */ memset(drv_X11_FB, 255, DCOLS*DROWS*sizeof(*drv_X11_FB)); if ((dp=XOpenDisplay(NULL))==NULL) { @@ -314,8 +320,8 @@ static int drv_X11_start (const char *section) break; } - // regularly process X events - // Fixme: make 20msec configurable + /* regularly process X events */ + /* Fixme: make 20msec configurable */ timer_add (drv_X11_timer, NULL, 20, 0); return 0; @@ -323,29 +329,29 @@ static int drv_X11_start (const char *section) -// **************************************** -// *** plugins *** -// **************************************** +/****************************************/ +/*** plugins ***/ +/****************************************/ -// none at the moment... +/* none at the moment... */ -// **************************************** -// *** widget callbacks *** -// **************************************** +/****************************************/ +/*** widget callbacks ***/ +/****************************************/ -// using drv_generic_graphic_draw(W) -// using drv_generic_graphic_icon_draw(W) -// using drv_generic_graphic_bar_draw(W) +/* using drv_generic_graphic_draw(W) */ +/* using drv_generic_graphic_icon_draw(W) */ +/* using drv_generic_graphic_bar_draw(W) */ -// **************************************** -// *** exported functions *** -// **************************************** +/****************************************/ +/*** exported functions ***/ +/****************************************/ -// list models +/* list models */ int drv_X11_list (void) { printf ("any"); @@ -353,24 +359,24 @@ int drv_X11_list (void) } -// initialize driver & display +/* initialize driver & display */ int drv_X11_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; - // real worker functions + /* real worker functions */ drv_generic_graphic_real_blit = drv_X11_blit; - // start display + /* start display */ if ((ret=drv_X11_start (section))!=0) return ret; - // initialize generic graphic driver + /* initialize generic graphic driver */ if ((ret=drv_generic_graphic_init(section, Name))!=0) return ret; - // initially expose window + /* initially expose window */ drv_generic_graphic_clear(); drv_X11_expose (0, 0, dimx+2*border, dimy+2*border); @@ -383,31 +389,31 @@ int drv_X11_init (const char *section, const int quiet) } } - // register text widget + /* register text widget */ wc=Widget_Text; wc.draw=drv_generic_graphic_draw; widget_register(&wc); - // register icon widget + /* register icon widget */ wc=Widget_Icon; wc.draw=drv_generic_graphic_icon_draw; widget_register(&wc); - // register bar widget + /* register bar widget */ wc=Widget_Bar; wc.draw=drv_generic_graphic_bar_draw; widget_register(&wc); - // register plugins - // none at the moment... + /* register plugins */ + /* none at the moment... */ return 0; } -// close driver & display -int drv_X11_quit (const int quiet) { +/* close driver & display */ +int drv_X11_quit (const __attribute__((unused)) int quiet) { info("%s: shutting down.", Name); drv_generic_graphic_quit(); diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c index a571024..c0fee2f 100644 --- a/drv_generic_graphic.c +++ b/drv_generic_graphic.c @@ -23,6 +23,12 @@ * * * $Log: drv_generic_graphic.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/20 10:09:55 reinelt * * 'const'ified the whole source @@ -123,35 +129,35 @@ static char *Section=NULL; static char *Driver=NULL; -int DROWS, DCOLS; // display size (pixels!) -int LROWS, LCOLS; // layout size (pixels!) -int XRES, YRES; // pixels of one char cell +int DROWS, DCOLS; /* display size (pixels!) */ +int LROWS, LCOLS; /* layout size (pixels!) */ +int XRES, YRES; /* pixels of one char cell */ unsigned char *drv_generic_graphic_FB = NULL; -// **************************************** -// *** generic Framebuffer stuff *** -// **************************************** +/****************************************/ +/*** generic Framebuffer stuff ***/ +/****************************************/ static void drv_generic_graphic_resizeFB (int rows, int cols) { - char *newFB; + unsigned char *newFB; int row, col; - // Layout FB is large enough + /* Layout FB is large enough */ if (rows<=LROWS && cols<=LCOLS) return; - // get maximum values + /* get maximum values */ if (rows<LROWS) rows=LROWS; if (cols<LCOLS) cols=LCOLS; - // allocate new Layout FB + /* allocate new Layout FB */ newFB = malloc(cols*rows*sizeof(char)); memset (newFB, 0, rows*cols*sizeof(char)); - // transfer contents + /* transfer contents */ if (drv_generic_graphic_FB!=NULL) { for (row=0; row<LROWS; row++) { for (col=0; col<LCOLS; col++) { @@ -175,41 +181,41 @@ int drv_generic_graphic_clear (void) } -// **************************************** -// *** generic text handling *** -// **************************************** +/****************************************/ +/*** generic text handling ***/ +/****************************************/ -static void drv_generic_graphic_render (const int row, const int col, const unsigned char *txt) +static void drv_generic_graphic_render (const int row, const int col, const char *txt) { int c, r, x, y; int len = strlen(txt); - // maybe grow layout framebuffer + /* maybe grow layout framebuffer */ drv_generic_graphic_resizeFB (row + YRES, col + XRES * len); r = row; c = col; - // render text into layout FB + /* render text into layout FB */ while (*txt != '\0') { for (y = 0; y < YRES; y++) { int mask = 1 << XRES; for (x = 0; x < XRES; x++) { mask >>= 1; - drv_generic_graphic_FB[(r+y) * LCOLS + c + x] = Font_6x8[*txt][y]&mask ? 1:0; + drv_generic_graphic_FB[(r+y) * LCOLS + c + x] = Font_6x8[(int)*txt][y]&mask ? 1:0; } } c += XRES; txt++; } - // flush area + /* flush area */ drv_generic_graphic_real_blit (row, col, YRES, XRES*len); } -// say hello to the user +/* say hello to the user */ int drv_generic_graphic_greet (const char *msg1, const char *msg2) { char *line1[] = { "* LCD4Linux " VERSION " *", @@ -228,8 +234,8 @@ int drv_generic_graphic_greet (const char *msg1, const char *msg2) int i; int flag = 0; - int cols = DCOLS/XRES; - int rows = DROWS/YRES; + unsigned int cols = DCOLS/XRES; + unsigned int rows = DROWS/YRES; for (i = 0; line1[i]; i++) { if (strlen(line1[i]) <= cols) { @@ -250,7 +256,7 @@ int drv_generic_graphic_greet (const char *msg1, const char *msg2) } if (msg1 && rows >= 3) { - int len = strlen(msg1); + unsigned int len = strlen(msg1); if ( len <= cols) { drv_generic_graphic_render (YRES * 2, XRES * (cols-len)/2, msg1); flag = 1; @@ -258,7 +264,7 @@ int drv_generic_graphic_greet (const char *msg1, const char *msg2) } if (msg2 && rows >= 4) { - int len = strlen(msg2); + unsigned int len = strlen(msg2); if ( len <= cols) { drv_generic_graphic_render (YRES * 3, XRES * (cols-len)/2, msg2); flag = 1; @@ -277,9 +283,9 @@ int drv_generic_graphic_draw (WIDGET *W) } -// **************************************** -// *** generic icon handling *** -// **************************************** +/****************************************/ +/*** generic icon handling ***/ +/****************************************/ int drv_generic_graphic_icon_draw (WIDGET *W) { @@ -291,10 +297,10 @@ int drv_generic_graphic_icon_draw (WIDGET *W) row = YRES*W->row; col = XRES*W->col; - // maybe grow layout framebuffer + /* maybe grow layout framebuffer */ drv_generic_graphic_resizeFB (row+YRES, col+XRES); - // render icon + /* render icon */ for (y=0; y<YRES; y++) { int mask=1<<XRES; for (x=0; x<XRES; x++) { @@ -308,7 +314,7 @@ int drv_generic_graphic_icon_draw (WIDGET *W) } } - // flush area + /* flush area */ drv_generic_graphic_real_blit (row, col, YRES, XRES); return 0; @@ -316,9 +322,9 @@ int drv_generic_graphic_icon_draw (WIDGET *W) } -// **************************************** -// *** generic bar handling *** -// **************************************** +/****************************************/ +/*** generic bar handling ***/ +/****************************************/ int drv_generic_graphic_bar_draw (WIDGET *W) { @@ -332,7 +338,7 @@ int drv_generic_graphic_bar_draw (WIDGET *W) dir = Bar->direction; len = Bar->length; - // maybe grow layout framebuffer + /* maybe grow layout framebuffer */ if (dir & (DIR_EAST|DIR_WEST)) { drv_generic_graphic_resizeFB (row+YRES, col+XRES*len); } else { @@ -382,7 +388,7 @@ int drv_generic_graphic_bar_draw (WIDGET *W) break; } - // flush area + /* flush area */ if (dir & (DIR_EAST|DIR_WEST)) { drv_generic_graphic_real_blit (row, col, YRES, XRES*len); } else { @@ -393,22 +399,22 @@ int drv_generic_graphic_bar_draw (WIDGET *W) } -// **************************************** -// *** generic init/quit *** -// **************************************** +/****************************************/ +/*** generic init/quit ***/ +/****************************************/ int drv_generic_graphic_init (const char *section, const char *driver) { Section = (char*)section; Driver = (char*)driver; - // init layout framebuffer + /* init layout framebuffer */ LROWS = 0; LCOLS = 0; drv_generic_graphic_FB=NULL; drv_generic_graphic_resizeFB (DROWS, DCOLS); - // sanity check + /* sanity check */ if (drv_generic_graphic_FB==NULL) { error ("%s: framebuffer could not be allocated: malloc() failed", Driver); return -1; diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h index e868fb0..72e2c92 100644 --- a/drv_generic_graphic.h +++ b/drv_generic_graphic.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_graphic.h,v 1.5 2004/06/20 10:09:55 reinelt Exp $ +/* $Id: drv_generic_graphic.h,v 1.6 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for graphic displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_graphic.h,v $ + * Revision 1.6 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.5 2004/06/20 10:09:55 reinelt * * 'const'ified the whole source @@ -56,17 +62,17 @@ #include "widget.h" -extern int DROWS, DCOLS; // display size -extern int LROWS, LCOLS; // layout size -extern int XRES, YRES; // pixel width/height of one char +extern int DROWS, DCOLS; /* display size */ +extern int LROWS, LCOLS; /* layout size */ +extern int XRES, YRES; /* pixel width/height of one char */ -// framebuffer +/* framebuffer */ extern unsigned char *drv_generic_graphic_FB; -// these functions must be implemented by the real driver +/* these functions must be implemented by the real driver */ void (*drv_generic_graphic_real_blit)(const int row, const int col, const int height, const int width); -// generic functions and widget callbacks +/* generic functions and widget callbacks */ int drv_generic_graphic_init (const char *section, const char *driver); int drv_generic_graphic_clear (void); int drv_generic_graphic_greet (const char *msg1, const char *msg2); diff --git a/drv_generic_parport.c b/drv_generic_parport.c index 277cf5e..393eefc 100644 --- a/drv_generic_parport.c +++ b/drv_generic_parport.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_parport.c,v 1.6 2004/06/20 10:09:55 reinelt Exp $ +/* $Id: drv_generic_parport.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for serial and parport access * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_parport.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:55 reinelt * * 'const'ified the whole source @@ -111,7 +117,7 @@ static char *Section=""; static unsigned short Port=0; static char *PPdev=NULL; -// initial value taken from linux/parport_pc.c +/* initial value taken from linux/parport_pc.c */ static unsigned char ctr = 0xc; #ifdef WITH_PPDEV @@ -165,7 +171,7 @@ int drv_generic_parport_open (const char *section, const char *driver) } #if 0 - // Fixme: this always fails here... + /* Fixme: this always fails here... */ if (ioctl(PPfd, PPEXCL)) { debug ("ioctl(%s, PPEXCL) failed: %s", PPdev, strerror(errno)); } else { @@ -234,7 +240,7 @@ int drv_generic_parport_close (void) } -unsigned char drv_generic_parport_wire_ctrl (const char *name, const unsigned char *deflt) +unsigned char drv_generic_parport_wire_ctrl (const char *name, const char *deflt) { unsigned char w; char wire[256]; @@ -279,7 +285,7 @@ unsigned char drv_generic_parport_wire_ctrl (const char *name, const unsigned ch } -unsigned char drv_generic_parport_wire_data (const char *name, const unsigned char *deflt) +unsigned char drv_generic_parport_wire_data (const char *name, const char *deflt) { unsigned char w; char wire[256]; @@ -317,7 +323,7 @@ void drv_generic_parport_direction (const int direction) } else #endif { - // code stolen from linux/parport_pc.h + /* code stolen from linux/parport_pc.h */ ctr = (ctr & ~0x20) ^ (direction?0x20:0x00); outb (ctr, Port+2); } @@ -328,11 +334,11 @@ void drv_generic_parport_control (const unsigned char mask, const unsigned char { unsigned char val; - // any signal affected? - // Note: this may happen in case a signal is hardwired to GND + /* any signal affected? */ + /* Note: this may happen in case a signal is hardwired to GND */ if (mask==0) return; - // Strobe, Select and AutoFeed are inverted! + /* Strobe, Select and AutoFeed are inverted! */ val = mask & (value ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD)); #ifdef WITH_PPDEV @@ -344,7 +350,7 @@ void drv_generic_parport_control (const unsigned char mask, const unsigned char } else #endif { - // code stolen from linux/parport_pc.h + /* code stolen from linux/parport_pc.h */ ctr = (ctr & ~mask) ^ val; outb (ctr, Port+2); } @@ -355,15 +361,15 @@ void drv_generic_parport_toggle (const unsigned char bits, const int level, cons { unsigned char value1, value2; - // any signal affected? - // Note: this may happen in case a signal is hardwired to GND + /* any signal affected? */ + /* Note: this may happen in case a signal is hardwired to GND */ if (bits==0) return; - // prepare value + /* prepare value */ value1=level?bits:0; value2=level?0:bits; - // Strobe, Select and AutoFeed are inverted! + /* Strobe, Select and AutoFeed are inverted! */ value1 = bits & (value1 ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD)); value2 = bits & (value2 ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD)); @@ -373,27 +379,27 @@ void drv_generic_parport_toggle (const unsigned char bits, const int level, cons struct ppdev_frob_struct frob; frob.mask=bits; - // rise + /* rise */ frob.val=value1; ioctl (PPfd, PPFCONTROL, &frob); - // pulse width + /* pulse width */ ndelay(delay); - // lower + /* lower */ frob.val=value2; ioctl (PPfd, PPFCONTROL, &frob); } else #endif { - // rise + /* rise */ ctr = (ctr & ~bits) ^ value1; outb (ctr, Port+2); - // pulse width + /* pulse width */ ndelay(delay); - // lower + /* lower */ ctr = (ctr & ~bits) ^ value2; outb (ctr, Port+2); } diff --git a/drv_generic_parport.h b/drv_generic_parport.h index 7e23205..df52895 100644 --- a/drv_generic_parport.h +++ b/drv_generic_parport.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_parport.h,v 1.3 2004/06/20 10:09:55 reinelt Exp $ +/* $Id: drv_generic_parport.h,v 1.4 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for parallel port displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_parport.h,v $ + * Revision 1.4 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.3 2004/06/20 10:09:55 reinelt * * 'const'ified the whole source @@ -83,8 +89,8 @@ int drv_generic_parport_open (const char *section, const char *driver); int drv_generic_parport_close (void); -unsigned char drv_generic_parport_wire_ctrl (const char *name, const unsigned char *deflt); -unsigned char drv_generic_parport_wire_data (const char *name, const unsigned char *deflt); +unsigned char drv_generic_parport_wire_ctrl (const char *name, const char *deflt); +unsigned char drv_generic_parport_wire_data (const char *name, const char *deflt); void drv_generic_parport_direction (const int direction); void drv_generic_parport_control (const unsigned char mask, const unsigned char value); void drv_generic_parport_toggle (const unsigned char bit, const int level, const int delay); diff --git a/drv_generic_serial.c b/drv_generic_serial.c index 9483532..88fcff2 100644 --- a/drv_generic_serial.c +++ b/drv_generic_serial.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_serial.c,v 1.13 2004/06/26 06:12:15 reinelt Exp $ +/* $Id: drv_generic_serial.c,v 1.14 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for serial and usbserial displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_serial.c,v $ + * Revision 1.14 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.13 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals @@ -101,15 +107,15 @@ * int drv_generic_serial_open (char *section, char *driver, unsigned int flags) * opens the serial port * - * int drv_generic_serial_poll (unsigned char *string, int len) + * int drv_generic_serial_poll (char *string, int len) * reads from the serial or USB port * without retry * - * int drv_generic_serial_read (unsigned char *string, int len); + * int drv_generic_serial_read (char *string, int len); * reads from the serial or USB port * with retry * - * void drv_generic_serial_write (unsigned char *string, int len); + * void drv_generic_serial_write (char *string, int len); * writes to the serial or USB port * * int drv_generic_serial_close (void); @@ -147,9 +153,9 @@ static int Device=-1; #define LOCK "/var/lock/LCK..%s" -// **************************************** -// *** generic serial/USB communication *** -// **************************************** +/****************************************/ +/*** generic serial/USB communication ***/ +/****************************************/ static pid_t drv_generic_serial_lock_port (const char *Port) { @@ -187,7 +193,8 @@ static pid_t drv_generic_serial_lock_port (const char *Port) } snprintf (buffer, sizeof(buffer), "%10d\n", (int)getpid()); - if (write(fd, buffer, strlen(buffer))!=strlen(buffer)) { + len = strlen(buffer); + if (write(fd, buffer, len) != len) { error ("write(%s) failed: %s", tempfile, strerror(errno)); close(fd); unlink(tempfile); @@ -205,7 +212,7 @@ static pid_t drv_generic_serial_lock_port (const char *Port) } if ((fd=open(lockfile, O_RDONLY))==-1) { - if (errno==ENOENT) continue; // lockfile disappared + if (errno==ENOENT) continue; /* lockfile disappared */ error ("open(%s) failed: %s", lockfile, strerror(errno)); unlink (tempfile); return -1; @@ -340,7 +347,7 @@ int drv_generic_serial_open (const char *section, const char *driver, const unsi } -int drv_generic_serial_poll (unsigned char *string, const int len) +int drv_generic_serial_poll (char *string, const int len) { int ret; if (Device == -1) return -1; @@ -352,7 +359,7 @@ int drv_generic_serial_poll (unsigned char *string, const int len) } -int drv_generic_serial_read (unsigned char *string, const int len) +int drv_generic_serial_read (char *string, const int len) { int count, run, ret; @@ -373,7 +380,7 @@ int drv_generic_serial_read (unsigned char *string, const int len) } -void drv_generic_serial_write (const unsigned char *string, const int len) +void drv_generic_serial_write (const char *string, const int len) { int run, ret; diff --git a/drv_generic_serial.h b/drv_generic_serial.h index c90333a..80879ba 100644 --- a/drv_generic_serial.h +++ b/drv_generic_serial.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_serial.h,v 1.6 2004/06/20 10:09:55 reinelt Exp $ +/* $Id: drv_generic_serial.h,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for serial and usbserial displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_serial.h,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:55 reinelt * * 'const'ified the whole source @@ -64,9 +70,9 @@ #define _DRV_GENERIC_SERIAL_H_ int drv_generic_serial_open (const char *section, const char *driver, const unsigned int flags); -int drv_generic_serial_poll (unsigned char *string, const int len); -int drv_generic_serial_read (unsigned char *string, const int len); -void drv_generic_serial_write (const unsigned char *string, const int len); +int drv_generic_serial_poll (char *string, const int len); +int drv_generic_serial_read (char *string, const int len); +void drv_generic_serial_write (const char *string, const int len); int drv_generic_serial_close (void); #endif diff --git a/drv_generic_text.c b/drv_generic_text.c index 8dadb26..d76731e 100644 --- a/drv_generic_text.c +++ b/drv_generic_text.c @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.c,v 1.19 2004/06/26 06:12:15 reinelt Exp $ +/* $Id: drv_generic_text.c,v 1.20 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_text.c,v $ + * Revision 1.20 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.19 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals @@ -112,12 +118,12 @@ * * exported variables: * - * extern int DROWS, DCOLS; // display size - * extern int LROWS, LCOLS; // layout size - * extern int XRES, YRES; // pixel width/height of one char - * extern int GOTO_COST; // number of bytes a goto command requires - * extern int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char - * extern int ICONS; // number of user-defineable characters reserved for icons + * extern int DROWS, DCOLS; display size + * extern int LROWS, LCOLS; layout size + * extern int XRES, YRES; pixel width/height of one char + * extern int GOTO_COST; number of bytes a goto command requires + * extern int CHARS, CHAR0; number of user-defineable characters, ASCII of first char + * extern int ICONS; number of user-defineable characters reserved for icons * * * these functions must be implemented by the real driver: @@ -204,16 +210,16 @@ static char *Section=NULL; static char *Driver=NULL; -int DROWS, DCOLS; // display size -int LROWS, LCOLS; // layout size -int XRES, YRES; // pixels of one char cell -int GOTO_COST; // number of bytes a goto command requires -int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char -int ICONS; // number of user-defineable characters reserved for icons +int DROWS, DCOLS; /* display size */ +int LROWS, LCOLS; /* layout size */ +int XRES, YRES; /* pixels of one char cell */ +int GOTO_COST; /* number of bytes a goto command requires */ +int CHARS, CHAR0; /* number of user-defineable characters, ASCII of first char */ +int ICONS; /* number of user-defineable characters reserved for icons */ -static unsigned char *LayoutFB = NULL; -static unsigned char *DisplayFB = NULL; +static char *LayoutFB = NULL; +static char *DisplayFB = NULL; static int Single_Segments = 0; @@ -224,9 +230,9 @@ static BAR *BarFB = NULL; -// **************************************** -// *** generic Framebuffer stuff *** -// **************************************** +/****************************************/ +/*** generic Framebuffer stuff ***/ +/****************************************/ static void drv_generic_text_resizeFB (int rows, int cols) { @@ -234,19 +240,19 @@ static void drv_generic_text_resizeFB (int rows, int cols) BAR *newBar; int i, row, col; - // Layout FB is large enough + /* Layout FB is large enough */ if (rows<=LROWS && cols<=LCOLS) return; - // get maximum values + /* get maximum values */ if (rows<LROWS) rows=LROWS; if (cols<LCOLS) cols=LCOLS; - // allocate new Layout FB + /* allocate new Layout FB */ newFB=malloc(cols*rows*sizeof(char)); memset (newFB, ' ', rows*cols*sizeof(char)); - // transfer contents + /* transfer contents */ if (LayoutFB!=NULL) { for (row=0; row<LROWS; row++) { for (col=0; col<LCOLS; col++) { @@ -258,7 +264,7 @@ static void drv_generic_text_resizeFB (int rows, int cols) LayoutFB = newFB; - // resize Bar buffer + /* resize Bar buffer */ if (BarFB) { newBar=malloc (rows*cols*sizeof(BAR)); @@ -270,7 +276,7 @@ static void drv_generic_text_resizeFB (int rows, int cols) newBar[i].segment = -1; } - // transfer contents + /* transfer contents */ for (row=0; row<LROWS; row++) { for (col=0; col<LCOLS; col++) { newBar[row*cols+col]=BarFB[row*LCOLS+col]; @@ -286,9 +292,9 @@ static void drv_generic_text_resizeFB (int rows, int cols) } -// **************************************** -// *** generic text handling *** -// **************************************** +/****************************************/ +/*** generic text handling ***/ +/****************************************/ int drv_generic_text_init (const char *section, const char *driver) { @@ -296,17 +302,17 @@ int drv_generic_text_init (const char *section, const char *driver) Section = (char*)section; Driver = (char*)driver; - // init display framebuffer + /* init display framebuffer */ DisplayFB = (char*)malloc(DCOLS*DROWS*sizeof(char)); memset (DisplayFB, ' ', DROWS*DCOLS*sizeof(char)); - // init layout framebuffer + /* init layout framebuffer */ LROWS = 0; LCOLS = 0; LayoutFB=NULL; drv_generic_text_resizeFB (DROWS, DCOLS); - // sanity check + /* sanity check */ if (LayoutFB==NULL || DisplayFB==NULL) { error ("%s: framebuffer could not be allocated: malloc() failed", Driver); return -1; @@ -316,7 +322,7 @@ int drv_generic_text_init (const char *section, const char *driver) } -// say hello to the user +/* say hello to the user */ int drv_generic_text_greet (const char *msg1, const char *msg2) { int i; @@ -337,7 +343,7 @@ int drv_generic_text_greet (const char *msg1, const char *msg2) for (i = 0; line1[i]; i++) { - if (strlen(line1[i]) <= DCOLS) { + if (strlen(line1[i]) <= (unsigned)DCOLS) { drv_generic_text_real_write (0, (DCOLS-strlen(line1[i]))/2, line1[i], strlen(line1[i])); flag = 1; break; @@ -346,7 +352,7 @@ int drv_generic_text_greet (const char *msg1, const char *msg2) if (DROWS >= 2) { for (i = 0; line2[i]; i++) { - if (strlen(line2[i]) <= DCOLS) { + if (strlen(line2[i]) <= (unsigned)DCOLS) { drv_generic_text_real_write (1, (DCOLS-strlen(line2[i]))/2, line2[i], strlen(line2[i])); flag = 1; break; @@ -386,13 +392,13 @@ int drv_generic_text_draw (WIDGET *W) len=strlen(txt); end=col+len; - // maybe grow layout framebuffer + /* maybe grow layout framebuffer */ drv_generic_text_resizeFB (row+1, col+len); fb1 = LayoutFB + row*LCOLS; fb2 = DisplayFB + row*DCOLS; - // transfer new text into layout buffer + /* transfer new text into layout buffer */ memcpy (fb1+col, txt, len); if (row<DROWS) { @@ -402,8 +408,8 @@ int drv_generic_text_draw (WIDGET *W) col0 = col; for (pos1=col, pos2=pos1, col++, equal=0; col<=end && col<DCOLS; col++) { if (fb1[col]==fb2[col]) { - // If we find just one equal byte, we don't break, because this - // would require a goto, which takes several bytes, too. + /* If we find just one equal byte, we don't break, because this */ + /* would require a goto, which takes several bytes, too. */ if (++equal>GOTO_COST) break; } else { pos2=col; @@ -441,9 +447,9 @@ int drv_generic_text_quit (void) { } -// **************************************** -// *** generic icon handling *** -// **************************************** +/****************************************/ +/*** generic icon handling ***/ +/****************************************/ int drv_generic_text_icon_init (void) { @@ -465,13 +471,13 @@ int drv_generic_text_icon_draw (WIDGET *W) row = W->row; col = W->col; - // maybe grow layout framebuffer + /* maybe grow layout framebuffer */ drv_generic_text_resizeFB (row+1, col+1); - // icon deactivated? + /* icon deactivated? */ if (Icon->ascii==-2) return 0; - // ASCII already assigned? + /* ASCII already assigned? */ if (Icon->ascii==-1) { if (icon_counter>=ICONS) { error ("cannot process icon '%s': out of icons", W->name); @@ -482,18 +488,18 @@ int drv_generic_text_icon_draw (WIDGET *W) Icon->ascii=CHAR0+CHARS-icon_counter; } - // maybe redefine icon + /* maybe redefine icon */ if (Icon->curmap!=Icon->prvmap) { drv_generic_text_real_defchar(Icon->ascii, Icon->bitmap+YRES*Icon->curmap); } - // use blank if invisible + /* use blank if invisible */ ascii=Icon->visible?Icon->ascii:' '; - // transfer icon into layout buffer + /* transfer icon into layout buffer */ LayoutFB[row*LCOLS+col]=ascii; - // maybe send icon to the display + /* maybe send icon to the display */ if (row < DROWS && col < DCOLS && DisplayFB[row*DCOLS+col] != ascii) { DisplayFB[row*DCOLS+col]=ascii; drv_generic_text_real_write (row, col, DisplayFB+row*DCOLS+col, 1); @@ -504,9 +510,9 @@ int drv_generic_text_icon_draw (WIDGET *W) } -// **************************************** -// *** generic bar handling *** -// **************************************** +/****************************************/ +/*** generic bar handling ***/ +/****************************************/ static void drv_generic_text_bar_clear(void) { @@ -693,10 +699,10 @@ static void drv_generic_text_bar_pack_segments (void) { int i, j, n, min; int pack_i, pack_j; - int pass1=1; + int pass1 = 1; int error[nSegment][nSegment]; - if (nSegment<=fSegment+CHARS-ICONS) { + if (nSegment <= fSegment + CHARS - ICONS) { return; } @@ -821,8 +827,8 @@ int drv_generic_text_bar_draw (WIDGET *W) dir = Bar->direction; len = Bar->length; - // maybe grow layout framebuffer - // bars *always* grow heading North or East! + /* maybe grow layout framebuffer */ + /* bars *always* grow heading North or East! */ if (dir & (DIR_EAST|DIR_WEST)) { drv_generic_text_resizeFB (row+1, col+len); } else { @@ -842,36 +848,36 @@ int drv_generic_text_bar_draw (WIDGET *W) if (Single_Segments) val2 = val1; - // create this bar + /* create this bar */ drv_generic_text_bar_create_bar (row, col, dir, len, val1, val2); - // process all bars + /* process all bars */ drv_generic_text_bar_create_segments (); drv_generic_text_bar_pack_segments (); drv_generic_text_bar_define_chars(); - // reset usage flags + /* reset usage flags */ for (s=0; s<nSegment; s++) { Segment[s].used=0; } - // set usage flags + /* set usage flags */ for (n=0; n<LROWS*LCOLS; n++) { if ((s=BarFB[n].segment)!=-1) Segment[s].used=1; } - // transfer bars into layout buffer + /* transfer bars into layout buffer */ for (n=0; n<LCOLS*LROWS; n++) { s=BarFB[n].segment; if (s==-1) continue; c=Segment[s].ascii; if (c==-1) continue; - if (s>=fSegment) c+=CHAR0; // ascii offset for user-defineable chars + if (s>=fSegment) c+=CHAR0; /* ascii offset for user-defineable chars */ if(c==LayoutFB[n]) continue; LayoutFB[n]=c; } - // transfer differences to the display + /* transfer differences to the display */ for (row=0; row<DROWS; row++) { for (col=0; col<DCOLS; col++) { int pos1, pos2, equal; @@ -879,8 +885,8 @@ int drv_generic_text_bar_draw (WIDGET *W) col0 = col; for (pos1=col, pos2=pos1, col++, equal=0; col<DCOLS; col++) { if (LayoutFB[row*LCOLS+col]==DisplayFB[row*DCOLS+col]) { - // If we find just one equal byte, we don't break, because this - // would require a goto, which takes several bytes, too. + /* If we find just one equal byte, we don't break, because this */ + /* would require a goto, which takes several bytes, too. */ if (++equal>GOTO_COST) break; } else { pos2=col; diff --git a/drv_generic_text.h b/drv_generic_text.h index 5740de5..6e50bd1 100644 --- a/drv_generic_text.h +++ b/drv_generic_text.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.h,v 1.13 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: drv_generic_text.h,v 1.14 2004/06/26 09:27:21 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,12 @@ * * * $Log: drv_generic_text.h,v $ + * Revision 1.14 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.13 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -87,18 +93,18 @@ #include "widget.h" -extern int DROWS, DCOLS; // display size -extern int LROWS, LCOLS; // layout size -extern int XRES, YRES; // pixel width/height of one char -extern int GOTO_COST; // number of bytes a goto command requires -extern int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char -extern int ICONS; // number of user-defineable characters reserved for icons +extern int DROWS, DCOLS; /* display size */ +extern int LROWS, LCOLS; /* layout size */ +extern int XRES, YRES; /* pixel width/height of one char */ +extern int GOTO_COST; /* number of bytes a goto command requires */ +extern int CHARS, CHAR0; /* number of user-defineable characters, ASCII of first char */ +extern int ICONS; /* number of user-defineable characters reserved for icons */ -// these functions must be implemented by the real driver -void (*drv_generic_text_real_write)(const int row, const int col, const unsigned char *data, const int len); -void (*drv_generic_text_real_defchar)(const int ascii, const unsigned char *buffer); +/* these functions must be implemented by the real driver */ +void (*drv_generic_text_real_write)(const int row, const int col, const char *data, const int len); +void (*drv_generic_text_real_defchar)(const int ascii, const unsigned char *matrix); -// generic functions and widget callbacks +/* generic functions and widget callbacks */ int drv_generic_text_init (const char *section, const char *driver); int drv_generic_text_greet (const char *msg1, const char *msg2); int drv_generic_text_draw (WIDGET *W); diff --git a/evaluator.c b/evaluator.c index 2be3b7e..8877a23 100644 --- a/evaluator.c +++ b/evaluator.c @@ -1,4 +1,4 @@ -/* $Id: evaluator.c,v 1.20 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: evaluator.c,v 1.21 2004/06/26 09:27:21 reinelt Exp $ * * expression evaluation * @@ -23,6 +23,12 @@ * * * $Log: evaluator.c,v $ + * Revision 1.21 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.20 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -172,10 +178,11 @@ #include <dmalloc.h> #endif -// string buffer chunk size +/* string buffer chunk size */ #define CHUNK_SIZE 16 typedef enum { + T_UNDEF, T_NAME, T_NUMBER, T_STRING, @@ -185,30 +192,31 @@ typedef enum { } TOKEN; typedef enum { - O_LST, // expression lists - O_SET, // variable assignements - O_CND, // conditional a?b:c - O_COL, // colon in a?b:c - O_OR, // logical OR - O_AND, // logical AND - O_EQ, // equal - O_NE, // not equal - O_LT, // less than - O_LE, // less or equal - O_GT, // greater than - O_GE, // greater or equal - O_ADD, // addition - O_SUB, // subtraction - O_SGN, // sign '-' - O_CAT, // string concatenation - O_MUL, // multiplication - O_DIV, // division - O_MOD, // modulo - O_POW, // power - O_NOT, // logical NOT - O_BRO, // open brace - O_COM, // comma (argument seperator) - O_BRC // closing brace + O_UNDEF, /* undefined */ + O_LST, /* expression lists */ + O_SET, /* variable assignements */ + O_CND, /* conditional a?b:c */ + O_COL, /* colon in a?b:c */ + O_OR, /* logical OR */ + O_AND, /* logical AND */ + O_EQ, /* equal */ + O_NE, /* not equal */ + O_LT, /* less than */ + O_LE, /* less or equal */ + O_GT, /* greater than */ + O_GE, /* greater or equal */ + O_ADD, /* addition */ + O_SUB, /* subtraction */ + O_SGN, /* sign '-' */ + O_CAT, /* string concatenation */ + O_MUL, /* multiplication */ + O_DIV, /* division */ + O_MOD, /* modulo */ + O_POW, /* power */ + O_NOT, /* logical NOT */ + O_BRO, /* open brace */ + O_COM, /* comma (argument seperator) */ + O_BRC /* closing brace */ } OPERATOR; typedef struct { @@ -240,43 +248,43 @@ typedef struct _NODE { -// operators -// IMPORTANT! list must be sorted by length! +/* operators */ +/* IMPORTANT! list must be sorted by length! */ static PATTERN Pattern[] = { - { ";", 1, O_LST }, // expression lists - { "=", 1, O_SET }, // variable assignements - { "?", 1, O_CND }, // conditional a?b:c - { ":", 1, O_COL }, // colon a?b:c - { "|", 1, O_OR }, // logical OR - { "&", 1, O_AND }, // logical AND - { "<", 1, O_LT }, // less than - { ">", 1, O_GT }, // greater than - { "+", 1, O_ADD }, // addition - { "-", 1, O_SUB }, // subtraction or sign - { ".", 1, O_CAT }, // string concatenation - { "*", 1, O_MUL }, // multiplication - { "/", 1, O_DIV }, // division - { "%", 1, O_MOD }, // modulo - { "^", 1, O_POW }, // power - { "!", 1, O_NOT }, // logical NOT - { "(", 1, O_BRO }, // open brace - { ",", 1, O_COM }, // comma (argument seperator) - { ")", 1, O_BRC }, // closing brace - { "==", 2, O_EQ }, // equal - { "!=", 2, O_NE }, // not equal - { "<=", 2, O_LE }, // less or equal - { ">=", 2, O_GE } // greater or equal + { ";", 1, O_LST }, /* expression lists */ + { "=", 1, O_SET }, /* variable assignements */ + { "?", 1, O_CND }, /* conditional a?b:c */ + { ":", 1, O_COL }, /* colon a?b:c */ + { "|", 1, O_OR }, /* logical OR */ + { "&", 1, O_AND }, /* logical AND */ + { "<", 1, O_LT }, /* less than */ + { ">", 1, O_GT }, /* greater than */ + { "+", 1, O_ADD }, /* addition */ + { "-", 1, O_SUB }, /* subtraction or sign */ + { ".", 1, O_CAT }, /* string concatenation */ + { "*", 1, O_MUL }, /* multiplication */ + { "/", 1, O_DIV }, /* division */ + { "%", 1, O_MOD }, /* modulo */ + { "^", 1, O_POW }, /* power */ + { "!", 1, O_NOT }, /* logical NOT */ + { "(", 1, O_BRO }, /* open brace */ + { ",", 1, O_COM }, /* comma (argument seperator) */ + { ")", 1, O_BRC }, /* closing brace */ + { "==", 2, O_EQ }, /* equal */ + { "!=", 2, O_NE }, /* not equal */ + { "<=", 2, O_LE }, /* less or equal */ + { ">=", 2, O_GE } /* greater or equal */ }; -static char *Expression = NULL; -static char *ExprPtr = NULL; -static char *Word = NULL; -static TOKEN Token = -1; -static OPERATOR Operator = -1; +static char *Expression = NULL; +static char *ExprPtr = NULL; +static char *Word = NULL; +static TOKEN Token = T_UNDEF; +static OPERATOR Operator = O_UNDEF; -static VARIABLE *Variable=NULL; -static int nVariable=0; +static VARIABLE *Variable = NULL; +static int nVariable = 0; static FUNCTION *Function = NULL; static int nFunction = 0; @@ -362,10 +370,10 @@ RESULT* SetResult (RESULT **result, const int type, const void *value) (*result)->type = R_STRING; (*result)->number = 0.0; if ((*result)->string == NULL || len > (*result)->length) { - // buffer is either empty or too small + /* buffer is either empty or too small */ if ((*result)->string) free((*result)->string); - // allocate memory in multiples of CHUNK_SIZE - // note that length does not count the trailing \0 + /* allocate memory in multiples of CHUNK_SIZE */ + /* note that length does not count the trailing \0 */ (*result)->length = CHUNK_SIZE*(len/CHUNK_SIZE+1)-1; (*result)->string = malloc((*result)->length+1); } @@ -540,24 +548,24 @@ void DeleteFunctions(void) static void Parse (void) { - Token = -1; - Operator = -1; + Token = T_UNDEF; + Operator = O_UNDEF; if (Word) { free (Word); Word = NULL; } - // NULL expression? + /* NULL expression? */ if (ExprPtr == NULL) { Word = strdup(""); return; } - // skip leading whitespace + /* skip leading whitespace */ while (is_space(*ExprPtr)) ExprPtr++; - // names + /* names */ if (is_alpha(*ExprPtr)) { char *start = ExprPtr; while (is_alnum(*ExprPtr)) ExprPtr++; @@ -569,7 +577,7 @@ static void Parse (void) Token = T_NAME; } - // numbers + /* numbers */ else if (is_digit(*ExprPtr) || (*ExprPtr=='.' && is_digit(*(ExprPtr+1)))) { char *start = ExprPtr; while (is_digit(*ExprPtr)) ExprPtr++; @@ -581,7 +589,7 @@ static void Parse (void) Token = T_NUMBER; } - // strings + /* strings */ else if (*ExprPtr=='\'') { char *start=++ExprPtr; while (*ExprPtr!='\0' && *ExprPtr!='\'') ExprPtr++; @@ -590,7 +598,7 @@ static void Parse (void) if (*ExprPtr=='\'') ExprPtr++; } - // operators + /* operators */ else { int i; for (i=sizeof(Pattern)/sizeof(Pattern[0])-1; i>=0; i--) { @@ -605,15 +613,15 @@ static void Parse (void) } } - // syntax check - if (Token == -1 && *ExprPtr != '\0') { + /* syntax check */ + if (Token == T_UNDEF && *ExprPtr != '\0') { error ("Evaluator: parse error in <%s>: garbage <%s>", Expression, ExprPtr); } - // skip trailing whitespace + /* skip trailing whitespace */ while (is_space(*ExprPtr)) ExprPtr++; - // empty token + /* empty token */ if (Word==NULL) Word=strdup(""); } @@ -664,11 +672,11 @@ static void LinkNode (NODE *Root, NODE *Child) } -// forward declaration +/* forward declaration */ static NODE* Level01 (void); -// literal numbers, variables, functions +/* literal numbers, variables, functions */ static NODE* Level12 (void) { NODE *Root = NULL; @@ -695,7 +703,7 @@ static NODE* Level12 (void) else if (Token == T_NAME) { - // look-ahead for opening brace + /* look-ahead for opening brace */ if (*ExprPtr == '(') { int argc=0; Root = NewNode(NULL); @@ -704,14 +712,14 @@ static NODE* Level12 (void) Root->Function = FindFunction(Word); if (Root->Function == NULL) { error ("Evaluator: unknown function '%s' in <%s>", Word, Expression); - Root->Token=T_STRING; + Root->Token = T_STRING; SetResult (&Root->Result, R_STRING, ""); } - // opening brace + /* opening brace */ Parse(); do { - Parse(); // read argument + Parse(); /* read argument */ if (Token == T_OPERATOR && Operator == O_BRC) { break; } @@ -725,12 +733,12 @@ static NODE* Level12 (void) argc++; } while (Token == T_OPERATOR && Operator == O_COM); - // check for closing brace + /* check for closing brace */ if (Token != T_OPERATOR || Operator != O_BRC) { error ("Evaluator: missing closing brace in <%s>", Expression); } - // check number of arguments + /* check number of arguments */ if (Root->Function != NULL && Root->Function->argc >= 0 && Root->Function->argc != argc) { error ("Evaluator: wrong number of arguments in <%s>", Expression); while (argc < Root->Function->argc) { @@ -764,11 +772,11 @@ static NODE* Level12 (void) } -// unary + or - signs or logical 'not' +/* unary + or - signs or logical 'not' */ static NODE* Level11 (void) { NODE *Root; - TOKEN sign = -1; + TOKEN sign = T_UNDEF; if (Token == T_OPERATOR && (Operator == O_ADD || Operator == O_SUB || Operator == O_NOT)) { sign = Operator; @@ -788,7 +796,7 @@ static NODE* Level11 (void) } -// x^y +/* x^y */ static NODE* Level10 (void) { NODE *Root; @@ -805,7 +813,7 @@ static NODE* Level10 (void) } -// multiplication, division, modulo +/* multiplication, division, modulo */ static NODE* Level09 (void) { NODE *Root; @@ -822,7 +830,7 @@ static NODE* Level09 (void) } -// addition, subtraction, string concatenation +/* addition, subtraction, string concatenation */ static NODE* Level08 (void) { NODE *Root; @@ -839,7 +847,7 @@ static NODE* Level08 (void) } -// relational operators +/* relational operators */ static NODE* Level07 (void) { NODE *Root; @@ -856,7 +864,7 @@ static NODE* Level07 (void) } -// equal, not equal +/* equal, not equal */ static NODE* Level06 (void) { NODE *Root; @@ -872,7 +880,7 @@ static NODE* Level06 (void) return Root; } -// logical 'and' +/* logical 'and' */ static NODE* Level05 (void) { NODE *Root; @@ -889,7 +897,7 @@ static NODE* Level05 (void) } -// logical 'or' +/* logical 'or' */ static NODE* Level04 (void) { NODE *Root; @@ -906,7 +914,7 @@ static NODE* Level04 (void) } -// conditional expression a?b:c +/* conditional expression a?b:c */ static NODE* Level03 (void) { NODE *Root; @@ -930,12 +938,12 @@ static NODE* Level03 (void) } -// variable assignments +/* variable assignments */ static NODE* Level02 (void) { NODE *Root; - // we have to do a look-ahead if it's really an assignment + /* we have to do a look-ahead if it's really an assignment */ if ((Token == T_NAME) && (*ExprPtr == '=') && (*(ExprPtr+1) != '=')) { char *name = strdup(Word); VARIABLE *V = FindVariable (name); @@ -957,7 +965,7 @@ static NODE* Level02 (void) } -// expression lists +/* expression lists */ static NODE* Level01 (void) { NODE *Root; @@ -994,7 +1002,7 @@ static int EvalTree (NODE *Root) case T_NUMBER: case T_STRING: - // Root->Result already contains the value + /* Root->Result already contains the value */ return 0; case T_VARIABLE: @@ -1004,15 +1012,15 @@ static int EvalTree (NODE *Root) case T_FUNCTION: DelResult (Root->Result); - // prepare parameter list + /* prepare parameter list */ argc = Root->Children; if (argc>10) argc=10; for (i = 0; i < argc; i++) { param[i]=Root->Child[i]->Result; } if (Root->Function->argc < 0) { - // Function with variable argument list: - // pass number of arguments as first parameter + /* Function with variable argument list: */ + /* pass number of arguments as first parameter */ Root->Function->func(Root->Result, argc, ¶m); } else { Root->Function->func(Root->Result, @@ -1024,14 +1032,14 @@ static int EvalTree (NODE *Root) case T_OPERATOR: switch (Root->Operator) { - case O_LST: // expression list: result is last expression + case O_LST: /* expression list: result is last expression */ i = Root->Children-1; type = Root->Child[i]->Result->type; number = Root->Child[i]->Result->number; string = Root->Child[i]->Result->string; break; - case O_SET: // variable assignment + case O_SET: /* variable assignment */ DelResult(Root->Variable->value); Root->Variable->value = DupResult (Root->Child[0]->Result); type = Root->Child[0]->Result->type; @@ -1039,69 +1047,69 @@ static int EvalTree (NODE *Root) string = Root->Child[0]->Result->string; break; - case O_CND: // conditional expression + case O_CND: /* conditional expression */ i = 1+(R2N(Root->Child[0]->Result) == 0.0); type = Root->Child[i]->Result->type; number = Root->Child[i]->Result->number; string = Root->Child[i]->Result->string; break; - case O_OR: // logical OR + case O_OR: /* logical OR */ type = R_NUMBER; number = ((R2N(Root->Child[0]->Result) != 0.0) || (R2N(Root->Child[1]->Result) != 0.0)); break; - case O_AND: // logical AND + case O_AND: /* logical AND */ type = R_NUMBER; number = ((R2N(Root->Child[0]->Result) != 0.0) && (R2N(Root->Child[1]->Result) != 0.0)); break; - case O_EQ: // numeric equal + case O_EQ: /* numeric equal */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) == R2N(Root->Child[1]->Result)); break; - case O_NE: // numeric not equal + case O_NE: /* numeric not equal */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) != R2N(Root->Child[1]->Result)); break; - case O_LT: // numeric less than + case O_LT: /* numeric less than */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) < R2N(Root->Child[1]->Result)); break; - case O_LE: // numeric less equal + case O_LE: /* numeric less equal */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) <= R2N(Root->Child[1]->Result)); break; - case O_GT: // numeric greater than + case O_GT: /* numeric greater than */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) > R2N(Root->Child[1]->Result)); break; - case O_GE: // numeric greater equal + case O_GE: /* numeric greater equal */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) >= R2N(Root->Child[1]->Result)); break; - case O_ADD: // addition + case O_ADD: /* addition */ type = R_NUMBER; number = R2N(Root->Child[0]->Result) + R2N(Root->Child[1]->Result); break; - case O_SUB: // subtraction + case O_SUB: /* subtraction */ type = R_NUMBER; number = R2N(Root->Child[0]->Result) - R2N(Root->Child[1]->Result); break; - case O_SGN: // sign + case O_SGN: /* sign */ type = R_NUMBER; number = -R2N(Root->Child[0]->Result); break; - case O_CAT: // string concatenation + case O_CAT: /* string concatenation */ type = R_STRING; s1 = R2S(Root->Child[0]->Result); s2 = R2S(Root->Child[1]->Result); @@ -1111,12 +1119,12 @@ static int EvalTree (NODE *Root) freeme = 1; break; - case O_MUL: // multiplication + case O_MUL: /* multiplication */ type = R_NUMBER; number = R2N(Root->Child[0]->Result) * R2N(Root->Child[1]->Result); break; - case O_DIV: // division + case O_DIV: /* division */ type = R_NUMBER; dummy = R2N(Root->Child[1]->Result); if (dummy == 0) { @@ -1127,7 +1135,7 @@ static int EvalTree (NODE *Root) } break; - case O_MOD: // modulo + case O_MOD: /* modulo */ type = R_NUMBER; dummy = R2N(Root->Child[1]->Result); if (dummy == 0) { @@ -1138,12 +1146,12 @@ static int EvalTree (NODE *Root) } break; - case O_POW: // x^y + case O_POW: /* x^y */ type = R_NUMBER; number = pow(R2N(Root->Child[0]->Result), R2N(Root->Child[1]->Result)); break; - case O_NOT: // logical NOT + case O_NOT: /* logical NOT */ type = R_NUMBER; number = (R2N(Root->Child[0]->Result) == 0.0); break; @@ -1189,7 +1197,7 @@ int Compile (const char* expression, void **tree) Parse(); if (*Word=='\0') { - // error ("Evaluator: empty expression <%s>", Expression); + /* error ("Evaluator: empty expression <%s>", Expression); */ free (Word); Word = NULL; return -1; diff --git a/evaluator.h b/evaluator.h index 6b5339c..7e37f81 100644 --- a/evaluator.h +++ b/evaluator.h @@ -1,4 +1,4 @@ -/* $Id: evaluator.h,v 1.7 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: evaluator.h,v 1.8 2004/06/26 09:27:21 reinelt Exp $ * * expression evaluation * @@ -23,6 +23,12 @@ * * * $Log: evaluator.h,v $ + * Revision 1.8 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.7 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -68,7 +74,7 @@ #define _EVALUATOR_H_ -// RESULT bitmask +/* RESULT bitmask */ #define R_NUMBER 1 #define R_STRING 2 @@ -1,4 +1,4 @@ -/* $Id: hash.c,v 1.22 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: hash.c,v 1.23 2004/06/26 09:27:21 reinelt Exp $ * * hashes (associative arrays) * @@ -23,6 +23,12 @@ * * * $Log: hash.c,v $ + * Revision 1.23 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.22 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -163,14 +169,14 @@ #include <dmalloc.h> #endif -// number of slots for delta processing +/* number of slots for delta processing */ #define DELTA_SLOTS 64 -// string buffer chunk size +/* string buffer chunk size */ #define CHUNK_SIZE 16 -// initialize a new hash table +/* initialize a new hash table */ void hash_create (HASH *Hash) { Hash->sorted = 0; @@ -188,7 +194,7 @@ void hash_create (HASH *Hash) } -// bsearch compare function for hash items +/* bsearch compare function for hash items */ static int hash_lookup_item (const void *a, const void *b) { char *key = (char*)a; @@ -198,7 +204,7 @@ static int hash_lookup_item (const void *a, const void *b) } -// qsort compare function for hash items +/* qsort compare function for hash items */ static int hash_sort_item (const void *a, const void *b) { HASH_ITEM *ha = (HASH_ITEM*)a; @@ -208,7 +214,7 @@ static int hash_sort_item (const void *a, const void *b) } -// bsearch compare function for hash headers +/* bsearch compare function for hash headers */ static int hash_lookup_column (const void *a, const void *b) { char *key = (char*)a; @@ -218,7 +224,7 @@ static int hash_lookup_column (const void *a, const void *b) } -// qsort compare function for hash headers +/* qsort compare function for hash headers */ static int hash_sort_column (const void *a, const void *b) { HASH_COLUMN *ha = (HASH_COLUMN*)a; @@ -228,13 +234,14 @@ static int hash_sort_column (const void *a, const void *b) } -// split a value into columns and -// return the nth column in a string -// WARNING: does return a pointer to a static string!! +/* split a value into columns and */ +/* return the nth column in a string */ +/* WARNING: does return a pointer to a static string!! */ static char* split (const char *val, const int column, const char *delimiter) { static char buffer[256]; - int num, len; + int num; + size_t len; const char *beg, *end; if (column < 0) return (char*)val; @@ -251,7 +258,7 @@ static char* split (const char *val, const int column, const char *delimiter) beg = end ? end+1 : NULL; } if (beg != NULL) { - len = end ? end - beg : strlen(beg); + len = end ? (size_t)(end - beg) : strlen(beg); if (len >= sizeof(buffer)) len = sizeof(buffer)-1; strncpy (buffer, beg, len); } @@ -261,29 +268,29 @@ static char* split (const char *val, const int column, const char *delimiter) } -// search an entry in the hash table: -// If the table is flagged "sorted", the entry is looked -// up using the bsearch function. If the table is -// unsorted, it will be searched in a linear way +/* search an entry in the hash table: */ +/* If the table is flagged "sorted", the entry is looked */ +/* up using the bsearch function. If the table is */ +/* unsorted, it will be searched in a linear way */ static HASH_ITEM* hash_lookup (HASH *Hash, const char *key, const int do_sort) { HASH_ITEM *Item = NULL; - // maybe sort the array + /* maybe sort the array */ if (do_sort && !Hash->sorted) { qsort(Hash->Items, Hash->nItems, sizeof(HASH_ITEM), hash_sort_item); Hash->sorted = 1; } - // no key was passed + /* no key was passed */ if (key == NULL) return NULL; - // lookup using bsearch + /* lookup using bsearch */ if (Hash->sorted) { Item = bsearch(key, Hash->Items, Hash->nItems, sizeof(HASH_ITEM), hash_lookup_item); } - // linear search + /* linear search */ if (Item == NULL) { int i; for (i = 0; i < Hash->nItems; i++) { @@ -299,9 +306,9 @@ static HASH_ITEM* hash_lookup (HASH *Hash, const char *key, const int do_sort) } -// return the age in milliseconds of an entry from the hash table -// or from the hash table itself if key is NULL -// returns -1 if entry does not exist +/* return the age in milliseconds of an entry from the hash table */ +/* or from the hash table itself if key is NULL */ +/* returns -1 if entry does not exist */ int hash_age (HASH *Hash, const char *key) { HASH_ITEM *Item; @@ -321,7 +328,7 @@ int hash_age (HASH *Hash, const char *key) } -// add an entry to the column header table +/* add an entry to the column header table */ void hash_set_column (HASH *Hash, const int number, const char *column) { if (Hash == NULL) return; @@ -336,7 +343,7 @@ void hash_set_column (HASH *Hash, const int number, const char *column) } -// fetch a column number by column header +/* fetch a column number by column header */ static int hash_get_column (HASH *Hash, const char *key) { HASH_COLUMN *Column; @@ -350,7 +357,7 @@ static int hash_get_column (HASH *Hash, const char *key) } -// set column delimiters +/* set column delimiters */ void hash_set_delimiter (HASH *Hash, const char *delimiter) { if (Hash->delimiter != NULL) free (Hash->delimiter); @@ -358,7 +365,7 @@ void hash_set_delimiter (HASH *Hash, const char *delimiter) } -// get a string from the hash table +/* get a string from the hash table */ char *hash_get (HASH *Hash, const char *key, const char *column) { HASH_ITEM *Item; @@ -372,7 +379,7 @@ char *hash_get (HASH *Hash, const char *key, const char *column) } -// get a delta value from the delta table +/* get a delta value from the delta table */ double hash_get_delta (HASH *Hash, const char *key, const char *column, const int delay) { HASH_ITEM *Item; @@ -382,20 +389,20 @@ double hash_get_delta (HASH *Hash, const char *key, const char *column, const in double dv, dt; struct timeval now, end; - // lookup item + /* lookup item */ Item = hash_lookup(Hash, key, 1); if (Item == NULL) return 0.0; - // this is the "current" Slot + /* this is the "current" Slot */ Slot1 = &(Item->Slot[Item->index]); - // fetch column number + /* fetch column number */ c = hash_get_column(Hash, column); - // if delay is zero, return absolute value + /* if delay is zero, return absolute value */ if (delay == 0) return atof(split(Slot1->value, c, Hash->delimiter)); - // prepare timing values + /* prepare timing values */ now = Slot1->timestamp; end.tv_sec = now.tv_sec; end.tv_usec = now.tv_usec - 1000*delay; @@ -404,7 +411,7 @@ double hash_get_delta (HASH *Hash, const char *key, const char *column, const in end.tv_usec += 1000000; } - // search delta slot + /* search delta slot */ Slot2 = &(Item->Slot[Item->index]); for (i = 1; i < Item->nSlot; i++) { Slot2 = &(Item->Slot[(Item->index + i) % Item->nSlot]); @@ -412,16 +419,16 @@ double hash_get_delta (HASH *Hash, const char *key, const char *column, const in if (timercmp(&(Slot2->timestamp), &end, <)) break; } - // empty slot => try the one before + /* empty slot => try the one before */ if (Slot2->timestamp.tv_sec == 0) { i--; Slot2 = &(Item->Slot[(Item->index + i) % Item->nSlot]); } - // not enough slots available... + /* not enough slots available... */ if (i == 0) return 0.0; - // delta value, delta time + /* delta value, delta time */ v1 = atof(split(Slot1->value, c, Hash->delimiter)); v2 = atof(split(Slot2->value, c, Hash->delimiter)); dv = v1 - v2; @@ -433,9 +440,9 @@ double hash_get_delta (HASH *Hash, const char *key, const char *column, const in } -// get a delta value from the delta table -// key may contain regular expressions, and the sum -// of all matching entries is returned. +/* get a delta value from the delta table */ +/* key may contain regular expressions, and the sum */ +/* of all matching entries is returned. */ double hash_get_regex (HASH *Hash, const char *key, const char *column, const int delay) { double sum; @@ -451,7 +458,7 @@ double hash_get_regex (HASH *Hash, const char *key, const char *column, const in return 0.0; } - // force the table to be sorted by requesting anything + /* force the table to be sorted by requesting anything */ hash_lookup(Hash, NULL, 1); sum = 0.0; @@ -465,11 +472,11 @@ double hash_get_regex (HASH *Hash, const char *key, const char *column, const in } -// insert a key/val pair into the hash table -// If the entry does already exist, it will be overwritten, -// and the table stays sorted (if it has been before). -// Otherwise, the entry is appended at the end, and -// the table will be flagged 'unsorted' afterwards +/* insert a key/val pair into the hash table */ +/* If the entry does already exist, it will be overwritten, */ +/* and the table stays sorted (if it has been before). */ +/* Otherwise, the entry is appended at the end, and */ +/* the table will be flagged 'unsorted' afterwards */ static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, const int delta) { @@ -481,7 +488,7 @@ static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, cons if (Item == NULL) { - // add entry + /* add entry */ Hash->sorted = 0; Hash->nItems++; Hash->Items = realloc(Hash->Items, Hash->nItems * sizeof(HASH_ITEM)); @@ -495,7 +502,7 @@ static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, cons } else { - // maybe enlarge delta table + /* maybe enlarge delta table */ if (Item->nSlot < delta) { Item->nSlot = delta; Item->Slot = realloc (Item->Slot, Item->nSlot * sizeof(HASH_SLOT)); @@ -504,26 +511,26 @@ static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, cons } if (Item->nSlot > 1) { - // move the pointer to the next free slot, wrap around if necessary + /* move the pointer to the next free slot, wrap around if necessary */ if (--Item->index < 0) Item->index = Item->nSlot-1; } - // create entry + /* create entry */ Slot = &(Item->Slot[Item->index]); size = strlen(value) + 1; - // maybe enlarge value buffer + /* maybe enlarge value buffer */ if (size > Slot->size) { - // buffer is either empty or too small - // allocate memory in multiples of CHUNK_SIZE + /* buffer is either empty or too small */ + /* allocate memory in multiples of CHUNK_SIZE */ Slot->size = CHUNK_SIZE * (size / CHUNK_SIZE + 1); Slot->value = realloc(Slot->value, Slot->size); } - // set value + /* set value */ strcpy(Slot->value, value); - // set timestamps + /* set timestamps */ gettimeofday(&(Hash->timestamp), NULL); Slot->timestamp = Hash->timestamp; @@ -531,16 +538,16 @@ static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, cons } -// insert a string into the hash table -// without delta processing +/* insert a string into the hash table */ +/* without delta processing */ void hash_put (HASH *Hash, const char *key, const char *value) { hash_set (Hash, key, value, 1); } -// insert a string into the hash table -// with delta processing +/* insert a string into the hash table */ +/* with delta processing */ void hash_put_delta (HASH *Hash, const char *key, const char *value) { hash_set (Hash, key, value, DELTA_SLOTS); @@ -553,21 +560,21 @@ void hash_destroy (HASH *Hash) if (Hash->Items) { - // free all headers + /* free all headers */ for (i = 0; i < Hash->nColumns; i++) { if (Hash->Columns[i].key) free (Hash->Columns[i].key); } - // free header table + /* free header table */ free (Hash->Columns); - // free all items + /* free all items */ for (i = 0; i < Hash->nItems; i++) { if (Hash->Items[i].key) free (Hash->Items[i].key); if (Hash->Items[i].Slot) free (Hash->Items[i].Slot); } - // free items table + /* free items table */ free (Hash->Items); } @@ -1,4 +1,4 @@ -/* $Id: hash.h,v 1.15 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: hash.h,v 1.16 2004/06/26 09:27:21 reinelt Exp $ * * hashes (associative arrays) * @@ -23,6 +23,12 @@ * * * $Log: hash.h,v $ + * Revision 1.16 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.15 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -95,7 +101,7 @@ #ifndef _HASH_H_ #define _HASH_H_ -// struct timeval +/* struct timeval */ #include <sys/time.h> @@ -1,4 +1,4 @@ -/* $Id: layout.c,v 1.12 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: layout.c,v 1.13 2004/06/26 09:27:21 reinelt Exp $ * * new layouter framework * @@ -23,6 +23,12 @@ * * * $Log: layout.c,v $ + * Revision 1.13 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.12 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -102,7 +108,7 @@ int layout_addItem (const char *name, const int row, const int col) { - // allocate widget + /* allocate widget */ widget_add (name, row-1, col-1); return 0; } @@ -117,23 +123,23 @@ int layout_init (const char *layout) info ("initializing layout '%s'", layout); - // prepare config section - // strlen("Layout:")=7 + /* prepare config section */ + /* strlen("Layout:")=7 */ section=malloc(strlen(layout)+8); strcpy(section, "Layout:"); strcat(section, layout); - // get a list of all keys in this section + /* get a list of all keys in this section */ list=cfg_list(section); - // map to lower char for scanf() + /* map to lower char for scanf() */ for (l=list; *l!='\0'; l++) *l=tolower(*l); l=list; while (l!=NULL) { char *p; int i, n; - // list is delimited by | + /* list is delimited by | */ while (*l=='|') l++; if ((p=strchr(l, '|'))!=NULL) *p='\0'; i=sscanf (l, "row%d.col%d%n", &row, &col, &n); @@ -144,7 +150,7 @@ int layout_init (const char *layout) } free(widget); } - // next field + /* next field */ l=p?p+1:NULL; } free (list); diff --git a/lcd4linux.c b/lcd4linux.c index 77aafe4..4cb15b0 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.72 2004/06/06 06:51:59 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.73 2004/06/26 09:27:21 reinelt Exp $ * * LCD4Linux * @@ -23,6 +23,12 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.73 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.72 2004/06/06 06:51:59 reinelt * * do not display end splash screen if quiet=1 @@ -435,7 +441,7 @@ int main (int argc, char *argv[]) int interactive = 0; int pid; - // save arguments for restart + /* save arguments for restart */ my_argv = malloc(sizeof(char*)*(argc+1)); for (c = 0; c < argc; c++) { my_argv[c] = strdup(argv[c]); @@ -490,7 +496,7 @@ int main (int argc, char *argv[]) exit(2); } - // do not fork in interactive mode + /* do not fork in interactive mode */ if (interactive) { running_foreground=1; } @@ -531,26 +537,26 @@ int main (int argc, char *argv[]) } if (i!=0) exit (0); - // ignore nasty signals + /* ignore nasty signals */ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - // chdir("/") + /* chdir("/") */ if (chdir("/")!=0) { error ("chdir(\"/\") failed: %s", strerror(errno)); exit (1); } - // we want full control over permissions + /* we want full control over permissions */ umask (0); - // detach stdin + /* detach stdin */ if (freopen("/dev/null", "r", stdin)==NULL) { error ("freopen (/dev/null) failed: %s", strerror(errno)); exit (1); } - // detach stdout and stderr + /* detach stdout and stderr */ fd=open("/dev/null", O_WRONLY, 0666); if (fd==-1) { error ("open (/dev/null) failed: %s", strerror(errno)); @@ -562,17 +568,17 @@ int main (int argc, char *argv[]) dup2(fd, STDERR_FILENO); close(fd); - // create PID file + /* create PID file */ if ((pid = pid_init(PIDFILE)) != 0) { error ("lcd4linux already running as process %d", pid); exit (1); } - // now we are a daemon + /* now we are a daemon */ running_background=1; } - // go into interactive mode before display initialization + /* go into interactive mode before display initialization */ if (interactive >= 2) { interactive_mode(); pid_exit(PIDFILE); @@ -580,7 +586,7 @@ int main (int argc, char *argv[]) exit (0); } - // check the conf to see if quiet startup is wanted + /* check the conf to see if quiet startup is wanted */ if (!quiet) { cfg_number(NULL, "Quiet", 0, 0, 1, &quiet); } @@ -592,7 +598,7 @@ int main (int argc, char *argv[]) } free(driver); - // go into interactive mode (display has been initialized) + /* go into interactive mode (display has been initialized) */ if (interactive >= 1) { interactive_mode(); drv_quit(quiet); @@ -601,7 +607,7 @@ int main (int argc, char *argv[]) exit (0); } - // check for new-style layout + /* check for new-style layout */ layout=cfg_get(NULL, "Layout", NULL); if (layout==NULL || *layout=='\0') { error ("missing 'Layout' entry in %s!", cfg_source()); @@ -613,7 +619,7 @@ int main (int argc, char *argv[]) debug ("starting main loop"); - // now install our own signal handler + /* now install our own signal handler */ signal(SIGHUP, handler); signal(SIGINT, handler); signal(SIGQUIT, handler); @@ -636,7 +642,7 @@ int main (int argc, char *argv[]) if (got_signal==SIGHUP) { long fd; debug ("restarting..."); - // close all files on exec + /* close all files on exec */ for (fd=sysconf(_SC_OPEN_MAX); fd>2; fd--) { int flag; if ((flag=fcntl(fd,F_GETFD,0))!=-1) @@ -1,4 +1,4 @@ -/* $Id: pid.c,v 1.6 2004/03/19 06:37:47 reinelt Exp $ +/* $Id: pid.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * PID file handling * @@ -22,6 +22,12 @@ * * * $Log: pid.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/03/19 06:37:47 reinelt * asynchronous thread handling started * @@ -104,7 +110,8 @@ int pid_init (const char *pidfile) } qprintf(buffer, sizeof(buffer), "%d\n", (int)getpid()); - if (write(fd, buffer, strlen(buffer))!=strlen(buffer)) { + len = strlen(buffer); + if (write(fd, buffer, len) != len) { error ("write(%s) failed: %s", tmpfile, strerror(errno)); close(fd); unlink(tmpfile); @@ -122,7 +129,7 @@ int pid_init (const char *pidfile) } if ((fd=open(pidfile, O_RDONLY))==-1) { - if (errno==ENOENT) continue; // pidfile disappared + if (errno==ENOENT) continue; /* pidfile disappared */ error ("open(%s) failed: %s", pidfile, strerror(errno)); unlink (tmpfile); return -1; @@ -1,4 +1,4 @@ -/* $Id: plugin.c,v 1.32 2004/06/07 06:56:55 reinelt Exp $ +/* $Id: plugin.c,v 1.33 2004/06/26 09:27:21 reinelt Exp $ * * plugin handler for the Evaluator * @@ -22,6 +22,12 @@ * * * $Log: plugin.c,v $ + * Revision 1.33 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.32 2004/06/07 06:56:55 reinelt * * added test plugin from Andy Baxter @@ -179,7 +185,7 @@ #include "plugin.h" -// Prototypes +/* Prototypes */ int plugin_init_cfg (void); void plugin_exit_cfg (void); int plugin_init_math (void); diff --git a/plugin_apm.c b/plugin_apm.c index feebb41..90f558a 100644 --- a/plugin_apm.c +++ b/plugin_apm.c @@ -1,4 +1,4 @@ -/* $Id: plugin_apm.c,v 1.2 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_apm.c,v 1.3 2004/06/26 09:27:21 reinelt Exp $ * * plugin for APM (battery status) * @@ -26,6 +26,12 @@ * * * $Log: plugin_apm.c,v $ + * Revision 1.3 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.2 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -61,7 +67,7 @@ #include "hash.h" static int fd = -2; -static HASH APM = { 0, }; +static HASH APM; /* from /usr/src/linux/arch/i386/kernel/apm.c: * @@ -132,7 +138,7 @@ static int parse_proc_apm (void) char buffer[128], *beg, *end; int age, i; - // reread every 10 msec only + /* reread every 10 msec only */ age = hash_age (&APM, NULL); if (age > 0 && age <= 10) return 0; diff --git a/plugin_cfg.c b/plugin_cfg.c index 874360c..abfe022 100644 --- a/plugin_cfg.c +++ b/plugin_cfg.c @@ -1,4 +1,4 @@ -/* $Id: plugin_cfg.c,v 1.9 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_cfg.c,v 1.10 2004/06/26 09:27:21 reinelt Exp $ * * plugin for config file access * @@ -23,6 +23,12 @@ * * * $Log: plugin_cfg.c,v $ + * Revision 1.10 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.9 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -137,29 +143,29 @@ static void my_cfg (RESULT *result, const int argc, RESULT *argv[]) char *value; char *buffer; - // calculate key length + /* calculate key length */ len=0; for (i=0; i<argc; i++) { len+=strlen(R2S(argv[i]))+1; } - // allocate key buffer + /* allocate key buffer */ buffer=malloc(len+1); - // prepare key buffer + /* 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 + /* buffer starts with '.', so cut off first char */ value=cfg_get("", buffer+1, ""); - // store result + /* store result */ SetResult(&result, R_STRING, value); - // free buffer again + /* free buffer again */ free (buffer); free(value); @@ -168,10 +174,10 @@ static void my_cfg (RESULT *result, const int argc, RESULT *argv[]) int plugin_init_cfg (void) { - // load "Variables" section from cfg + /* load "Variables" section from cfg */ load_variables(); - // register plugin + /* register plugin */ AddFunction ("cfg", -1, my_cfg); return 0; @@ -179,5 +185,5 @@ int plugin_init_cfg (void) void plugin_exit_cfg(void) { - + /* empty */ } diff --git a/plugin_cpuinfo.c b/plugin_cpuinfo.c index f5923cc..1e9bdea 100644 --- a/plugin_cpuinfo.c +++ b/plugin_cpuinfo.c @@ -1,4 +1,4 @@ -/* $Id: plugin_cpuinfo.c,v 1.10 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_cpuinfo.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * plugin for /proc/cpuinfo parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_cpuinfo.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -102,7 +108,7 @@ static int parse_cpuinfo (void) { int age; - // reread every second only + /* reread every second only */ age = hash_age(&CPUinfo, NULL); if (age > 0 && age <= 1000) return 0; @@ -119,17 +125,17 @@ static int parse_cpuinfo (void) c = strchr(buffer, ':'); if (c == NULL) continue; key = buffer; val = c+1; - // strip leading blanks from key + /* strip leading blanks from key */ while (isspace(*key)) *key++ = '\0'; - // strip trailing blanks from key + /* strip trailing blanks from key */ do *c = '\0'; while (isspace(*--c)); - // strip leading blanks from value + /* strip leading blanks from value */ while (isspace(*val)) *val++ = '\0'; - // strip trailing blanks from value + /* strip trailing blanks from value */ for (c = val; *c != '\0'; c++); while (isspace(*--c)) *c = '\0'; - // add entry to hash table + /* add entry to hash table */ hash_put (&CPUinfo, key, val); } diff --git a/plugin_diskstats.c b/plugin_diskstats.c index 7dd0b03..6e3e0f6 100644 --- a/plugin_diskstats.c +++ b/plugin_diskstats.c @@ -1,4 +1,4 @@ -/* $Id: plugin_diskstats.c,v 1.4 2004/06/17 10:58:58 reinelt Exp $ +/* $Id: plugin_diskstats.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * plugin for /proc/diskstats parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_diskstats.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/06/17 10:58:58 reinelt * * changed plugin_netdev to use the new fast hash model @@ -70,7 +76,7 @@ static int parse_diskstats (void) { int age; - // reread every 10 msec only + /* reread every 10 msec only */ age = hash_age(&DISKSTATS, NULL); if (age > 0 && age <= 10) return 0; @@ -86,11 +92,11 @@ static int parse_diskstats (void) char buffer[1024]; char dev[64]; char *beg, *end; - int num, len; + unsigned int num, len; if (fgets (buffer, sizeof(buffer), stream) == NULL) break; - // fetch device name (3rd column) as key + /* fetch device name (3rd column) as key */ num = 0; beg = buffer; end = beg; @@ -101,7 +107,7 @@ static int parse_diskstats (void) if (num++ == 2) break; beg = end ? end+1 : NULL; } - len = end ? end - beg : strlen(beg); + len = end ? (unsigned)(end - beg) : strlen(beg); if (len >= sizeof(dev)) len = sizeof(dev)-1; strncpy (dev, beg, len); diff --git a/plugin_dvb.c b/plugin_dvb.c index 90db55e..173605b 100644 --- a/plugin_dvb.c +++ b/plugin_dvb.c @@ -1,4 +1,4 @@ -/* $Id: plugin_dvb.c,v 1.5 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_dvb.c,v 1.6 2004/06/26 09:27:21 reinelt Exp $ * * plugin for DVB status * @@ -23,6 +23,12 @@ * * * $Log: plugin_dvb.c,v $ + * Revision 1.6 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.5 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -92,11 +98,11 @@ static int get_dvb_stats (void) unsigned long ber, ucb; char val[16]; - // reread every 1000 msec only + /* reread every 1000 msec only */ age = hash_age(&DVB, NULL); if (age > 0 && age <= 1000) return 0; - // open frontend + /* open frontend */ fd = open(frontend, O_RDONLY); if (fd == -1) { error ("open(%s) failed: %s", frontend, strerror(errno)); diff --git a/plugin_exec.c b/plugin_exec.c index 54a8aa1..ce60166 100644 --- a/plugin_exec.c +++ b/plugin_exec.c @@ -1,4 +1,4 @@ -/* $Id: plugin_exec.c,v 1.4 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_exec.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * plugin for external processes * @@ -27,6 +27,12 @@ * * * $Log: plugin_exec.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -89,18 +95,18 @@ static int max_thread = -1; static HASH EXEC; -// x^0 + x^5 + x^12 +/* x^0 + x^5 + x^12 */ #define CRCPOLY 0x8408 -static unsigned short CRC (const unsigned char *s) +static unsigned short CRC (const char *s) { int i; unsigned short crc; - // seed value - crc=0xffff; + /* seed value */ + crc = 0xffff; - while (*s!='\0') { + while (*s != '\0') { crc ^= *s++; for (i = 0; i < 8; i++) crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY : 0); @@ -116,10 +122,10 @@ static void exec_thread (void *data) char buffer[SHM_SIZE]; int len; - // use a safe path + /* use a safe path */ putenv ("PATH=/usr/local/bin:/usr/bin:/bin"); - // forever... + /* forever... */ while (1) { pipe = popen(Thread->cmd, "r"); if (pipe == NULL) { @@ -134,19 +140,19 @@ static void exec_thread (void *data) pclose(pipe); } - // force trailing zero + /* force trailing zero */ buffer[len] = '\0'; - // remove trailing CR/LF + /* remove trailing CR/LF */ while (len>0 && (buffer[len-1]=='\n' || buffer[len-1]=='\r')) { buffer[--len]='\0'; } - // lock shared memory + /* lock shared memory */ mutex_lock(Thread->mutex); - // write data + /* write data */ strncpy(Thread->ret, buffer, SHM_SIZE); - // unlock shared memory + /* unlock shared memory */ mutex_unlock(Thread->mutex); usleep (Thread->delay); } @@ -187,21 +193,21 @@ static int create_exec_thread (const char *cmd, const char *key, const int delay Thread[max_thread].key = strdup(key); Thread[max_thread].ret = NULL; - // create communication buffer + /* create communication buffer */ Thread[max_thread].shmid = shm_create ((void**)&Thread[max_thread].ret, SHM_SIZE); - // catch error + /* catch error */ if (Thread[max_thread].shmid < 0) { error ("cannot create exec thread <%s>: shared memory allocation failed!", cmd); destroy_exec_thread (max_thread--); return -1; } - // create thread + /* create thread */ qprintf(name, sizeof(name), "exec-%s", key); Thread[max_thread].pid = thread_create (name, exec_thread, &Thread[max_thread]); - // catch error + /* catch error */ if (Thread[max_thread].pid < 0) { error ("cannot create exec thread <%s>: fork failed?!", cmd); destroy_exec_thread (max_thread--); @@ -220,7 +226,7 @@ static int do_exec (const char *cmd, const char *key, int delay) if (age < 0) { hash_put (&EXEC, key, ""); - // first-time call: create thread + /* first-time call: create thread */ if (delay < 10) { error ("exec(%s): delay %d is too short! using 10 msec", cmd, delay); delay = 10; @@ -231,17 +237,17 @@ static int do_exec (const char *cmd, const char *key, int delay) return 0; } - // reread every 10 msec only + /* reread every 10 msec only */ if (age > 0 && age <= 10) return 0; - // find thread + /* find thread */ for (i = 0; i <= max_thread; i++) { if (strcmp(key, Thread[i].key) == 0) { - // lock shared memory + /* lock shared memory */ mutex_lock(Thread[i].mutex); - // copy data + /* copy data */ hash_put (&EXEC, key, Thread[i].ret); - // unlock shared memory + /* unlock shared memory */ mutex_unlock(Thread[i].mutex); return 0; } diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c index cf6cdeb..2c58556 100644 --- a/plugin_i2c_sensors.c +++ b/plugin_i2c_sensors.c @@ -1,4 +1,4 @@ -/* $Id: plugin_i2c_sensors.c,v 1.19 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_i2c_sensors.c,v 1.20 2004/06/26 09:27:21 reinelt Exp $ * * I2C sensors plugin * @@ -23,6 +23,12 @@ * * * $Log: plugin_i2c_sensors.c,v $ + * Revision 1.20 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.19 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -166,10 +172,10 @@ static char *path=NULL; static HASH I2Csensors; static const char *procfs_tokens[4][3] = { - {"temp_hyst", "temp_max", "temp_input"}, // for temp# - {"in_min", "in_max", "in_input"}, // for in# - {"fan_div1", "fan_div2", "fan_div3"}, // for fan_div - {"fan_min", "fan_input", ""} // for fan# + {"temp_hyst", "temp_max", "temp_input"}, /* for temp# */ + {"in_min", "in_max", "in_input"}, /* for in# */ + {"fan_div1", "fan_div2", "fan_div3"}, /* for fan_div */ + {"fan_min", "fan_input", ""} /* for fan# */ }; static int (*parse_i2c_sensors)(const char *key); @@ -201,9 +207,9 @@ static int parse_i2c_sensors_sysfs(const char *key) return -1; } - // now the formating stuff, depending on the file : - // Some values must be divided by 1000, the others - // are parsed directly (we just remove the \n). + /* now the formating stuff, depending on the file : */ + /* Some values must be divided by 1000, the others */ + /* are parsed directly (we just remove the \n). */ if (!strncmp(key, "temp", 4) || !strncmp(key, "curr", 4) || !strncmp(key, "in", 2) || @@ -211,7 +217,7 @@ static int parse_i2c_sensors_sysfs(const char *key) snprintf(val, sizeof(val), "%f", strtod(buffer, NULL) / 1000.0); } else { qprintf(val, sizeof(val), "%s", buffer); - // we supress this nasty \n at the end + /* we supress this nasty \n at the end */ val[strlen(val)-1]='\0'; } @@ -238,7 +244,7 @@ static int parse_i2c_sensors_procfs(const char *key) char final_key[32]; const char *number = &key[strlen(key)-1]; int tokens_index; - // debug("%s -> %s", key, number); + /* debug("%s -> %s", key, number); */ strcpy(file, path); if (!strncmp(key, "temp_", 5)) { @@ -277,13 +283,13 @@ static int parse_i2c_sensors_procfs(const char *key) running=strdupa(buffer); while(1) { value = strsep (&running, delim); - // debug("%s pos %i -> %s", file, pos , value); + /* debug("%s pos %i -> %s", file, pos , value); */ if (!value || !strcmp(value, "")) { - // debug("%s pos %i -> BREAK", file, pos); + /* debug("%s pos %i -> BREAK", file, pos); */ break; } else { qprintf (final_key, sizeof(final_key), "%s%s", procfs_tokens[tokens_index][pos], number); - // debug ("%s -> %s", final_key, value); + /* debug ("%s -> %s", final_key, value); */ hash_put (&I2Csensors, final_key, value); pos++; } @@ -328,7 +334,7 @@ void my_i2c_sensors_path(const char *method) base="/sys/bus/i2c/devices/"; } else if (!strcmp(method, "procfs")) { base="/proc/sys/dev/sensors/"; - //base="/sensors_2.4/"; // fake dir to test without rebooting 2.4 ;) + /*base="/sensors_2.4/"; // fake dir to test without rebooting 2.4 ;) */ } else { return; } @@ -339,14 +345,14 @@ void my_i2c_sensors_path(const char *method) } while((dir = readdir(fd1))) { - // Skip non-directories and '.' and '..' + /* Skip non-directories and '.' and '..' */ if ((dir->d_type!=DT_DIR && dir->d_type!=DT_LNK) || strcmp(dir->d_name, "." )==0 || strcmp(dir->d_name, "..")==0) { continue; } - // dname is the absolute path + /* dname is the absolute path */ strcpy(dname, base); strcat(dname, dir->d_name); strcat(dname, "/"); @@ -354,7 +360,7 @@ void my_i2c_sensors_path(const char *method) fd2 = opendir(dname); done = 0; while((file = readdir(fd2))) { - // FIXME : do all sensors have a temp_input1 ? + /* FIXME : do all sensors have a temp_input1 ? */ if (!strcmp(file->d_name, "temp_input1") || !strcmp(file->d_name, "temp1_input") || !strcmp(file->d_name, "temp1")) { path = realloc(path, strlen(dname)+1); strcpy(path, dname); @@ -377,7 +383,7 @@ int plugin_init_i2c_sensors (void) path_cfg = cfg_get(NULL, "i2c_sensors-path", ""); if (path_cfg == NULL || *path_cfg == '\0') { - // debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); + /* debug("No path to i2c sensors found in the conf, calling my_i2c_sensors_path()"); */ my_i2c_sensors_path("sysfs"); if (!path) my_i2c_sensors_path("procfs"); @@ -389,7 +395,7 @@ int plugin_init_i2c_sensors (void) } } else { if (path_cfg[strlen(path_cfg)-1] != '/') { - // the headless user forgot the trailing slash :/ + /* the headless user forgot the trailing slash :/ */ error("i2c_sensors: please add a trailing slash to %s from %s", path_cfg, cfg_source()); path_cfg = realloc(path_cfg, strlen(path_cfg)+2); strcat(path_cfg, "/"); @@ -400,7 +406,7 @@ int plugin_init_i2c_sensors (void) } if (path_cfg) free(path_cfg); - // we activate the function only if there's a possibly path found + /* we activate the function only if there's a possibly path found */ if (path!=NULL) { if (strncmp(path, "/sys", 4)==0) { parse_i2c_sensors = parse_i2c_sensors_sysfs; diff --git a/plugin_imon.c b/plugin_imon.c index 30def5d..a7ed6d9 100755 --- a/plugin_imon.c +++ b/plugin_imon.c @@ -1,4 +1,4 @@ -/* $Id: plugin_imon.c,v 1.11 2004/06/24 20:18:08 nicowallmeier Exp $ +/* $Id: plugin_imon.c,v 1.12 2004/06/26 09:27:21 reinelt Exp $ * * imond/telmond data processing * @@ -22,6 +22,12 @@ * * * $Log: plugin_imon.c,v $ + * Revision 1.12 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.11 2004/06/24 20:18:08 nicowallmeier * minor bugfix * @@ -261,7 +267,7 @@ static int parse_telmon(){ static char oldanswer[128]; int age; - // reread every 1 sec only + /* reread every 1 sec only */ age=hash_age(&TELMON, NULL); if (age>0 && age<=1000) return 0; @@ -315,7 +321,7 @@ void init(){ if (fd<0){ err++; - } else if ((ipass!=NULL) && (*ipass!='\0')) { // Passwort senden + } else if ((ipass!=NULL) && (*ipass!='\0')) { /* Passwort senden */ char buf[40]; qprintf(buf,sizeof(buf),"pass %s",ipass); send_command(fd,buf); @@ -324,11 +330,11 @@ void init(){ } static int parse_imon(const char *cmd){ - // reread every half sec only + /* reread every half sec only */ int age=hash_age(&IMON, cmd); if (age>0 && age<=500) return 0; - init(); // establish connection + init(); /* establish connection */ if (err) return -1; @@ -339,7 +345,7 @@ static int parse_imon(const char *cmd){ static void my_imon_version (RESULT *result){ char *val; - // read only ones + /* read only ones */ int age=hash_age(&IMON, "version"); if (age<0){ char *s; @@ -349,7 +355,7 @@ static void my_imon_version (RESULT *result){ return; } s=get_value("version"); - for (;;){ // interne Versionsnummer killen + for (;;){ /* interne Versionsnummer killen */ if (s[0]==' '){ s=s+1; break; @@ -371,11 +377,11 @@ static int parse_imon_rates(const char *channel){ qprintf(buf,sizeof(buf),"rate %s in",channel); - // reread every half sec only + /* reread every half sec only */ age=hash_age(&IMON, buf); if (age>0 && age<=500) return 0; - init(); // establish connection + init(); /* establish connection */ if (err) return -1; diff --git a/plugin_isdn.c b/plugin_isdn.c index aaf2d4a..150be5f 100644 --- a/plugin_isdn.c +++ b/plugin_isdn.c @@ -1,4 +1,4 @@ -/* $Id: plugin_isdn.c,v 1.3 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_isdn.c,v 1.4 2004/06/26 09:27:21 reinelt Exp $ * * plugin for ISDN subsystem * @@ -26,6 +26,12 @@ * * * $Log: plugin_isdn.c,v $ + * Revision 1.4 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.3 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -96,25 +102,25 @@ static int parse_isdninfo (void) FILE *stream; long flags; - // reread every 10 msec only + /* reread every 10 msec only */ age = hash_age(&ISDN_INFO, NULL); if (age > 0 && age <= 10) return 0; - // open file + /* open file */ stream = fopen ("/dev/isdninfo", "r"); if (stream == NULL) { error ("open(/dev/isdninfo) failed: %s", strerror(errno)); return -1; } - // get flags + /* get flags */ flags = fcntl(fileno(stream), F_GETFL); if (flags < 0) { error ("fcntl(/dev/isdninfo, F_GETFL) failed: %s", strerror(errno)); return -1; } - // set O_NONBLOCK + /* set O_NONBLOCK */ if (fcntl (fileno(stream), F_SETFL, flags | O_NONBLOCK) < 0) { error ("fcntl(/dev/isdninfo, F_SETFL, O_NONBLOCK) failed: %s", strerror(errno)); return -1; @@ -187,7 +193,7 @@ static int get_cps(void) CPS cps[ISDN_MAX_CHANNELS]; CPS sum; - // reread every 10 msec only + /* reread every 10 msec only */ age = hash_age(&ISDN_CPS, NULL); if (age > 0 && age <= 10) return 0; diff --git a/plugin_loadavg.c b/plugin_loadavg.c index 4c868b0..ff7f217 100644 --- a/plugin_loadavg.c +++ b/plugin_loadavg.c @@ -1,4 +1,4 @@ -/* $Id: plugin_loadavg.c,v 1.6 2004/03/11 06:39:59 reinelt Exp $ +/* $Id: plugin_loadavg.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * plugin for load average * @@ -23,6 +23,12 @@ * * * $Log: plugin_loadavg.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/03/11 06:39:59 reinelt * big patch from Martin: * - reuse filehandles @@ -131,7 +137,7 @@ static void my_loadavg (RESULT *result, RESULT *arg1) gettimeofday(&now,NULL); age = (now.tv_sec - last_value.tv_sec)*1000 + (now.tv_usec - last_value.tv_usec)/1000; - // reread every 10 msec only + /* reread every 10 msec only */ if (nelem==-1 || age==0 || age>10) { nelem=getloadavg(loadavg, 3); diff --git a/plugin_math.c b/plugin_math.c index 6988a2b..e93c859 100644 --- a/plugin_math.c +++ b/plugin_math.c @@ -1,4 +1,4 @@ -/* $Id: plugin_math.c,v 1.4 2004/03/06 20:31:16 reinelt Exp $ +/* $Id: plugin_math.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * math plugin * @@ -22,6 +22,12 @@ * * * $Log: plugin_math.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/03/06 20:31:16 reinelt * Complete rewrite of the evaluator to get rid of the code * from mark Morley (because of license issues). @@ -124,11 +130,11 @@ static void my_max (RESULT *result, RESULT *arg1, RESULT *arg2) int plugin_init_math (void) { - // set some handy constants + /* set some handy constants */ SetVariableNumeric ("Pi", M_PI); SetVariableNumeric ("e", M_E); - // register some basic math functions + /* register some basic math functions */ AddFunction ("sqrt", 1, my_sqrt); AddFunction ("exp", 1, my_exp); AddFunction ("ln", 1, my_ln); @@ -137,7 +143,7 @@ int plugin_init_math (void) AddFunction ("cos", 1, my_cos); AddFunction ("tan", 1, my_tan); - // min, max + /* min, max */ AddFunction ("min", 2, my_min); AddFunction ("max", 2, my_max); diff --git a/plugin_meminfo.c b/plugin_meminfo.c index a15565e..be5343b 100644 --- a/plugin_meminfo.c +++ b/plugin_meminfo.c @@ -1,4 +1,4 @@ -/* $Id: plugin_meminfo.c,v 1.8 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_meminfo.c,v 1.9 2004/06/26 09:27:21 reinelt Exp $ * * plugin for /proc/meminfo parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_meminfo.c,v $ + * Revision 1.9 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.8 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -93,7 +99,7 @@ static int parse_meminfo (void) { int age; - // reread every 10 msec only + /* reread every 10 msec only */ age=hash_age(&MemInfo, NULL); if (age>0 && age<=10) return 0; @@ -111,20 +117,20 @@ static int parse_meminfo (void) c=strchr(buffer, ':'); if (c==NULL) continue; key=buffer; val=c+1; - // strip leading blanks from key + /* strip leading blanks from key */ while (isspace(*key)) *key++='\0'; - // strip trailing blanks from key + /* strip trailing blanks from key */ do *c='\0'; while (isspace(*--c)); - // strip leading blanks from value + /* strip leading blanks from value */ while (isspace(*val)) *val++='\0'; - // strip trailing blanks from value + /* strip trailing blanks from value */ for (c=val; *c!='\0';c++); while (isspace(*--c)) *c='\0'; - // skip lines that do not end with " kB" + /* skip lines that do not end with " kB" */ if (*c=='B' && *(c-1)=='k' && *(c-2)==' ') { - // strip trailing " kB" from value + /* strip trailing " kB" from value */ *(c-2)='\0'; - // add entry to hash table + /* add entry to hash table */ hash_put (&MemInfo, key, val); } } diff --git a/plugin_netdev.c b/plugin_netdev.c index 93bf107..180f567 100644 --- a/plugin_netdev.c +++ b/plugin_netdev.c @@ -1,4 +1,4 @@ -/* $Id: plugin_netdev.c,v 1.10 2004/06/17 10:58:58 reinelt Exp $ +/* $Id: plugin_netdev.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * plugin for /proc/net/dev parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_netdev.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/17 10:58:58 reinelt * * changed plugin_netdev to use the new fast hash model @@ -101,7 +107,7 @@ static int parse_netdev (void) int row, col; static int first_time = 1; - // reread every 10 msec only + /* reread every 10 msec only */ age = hash_age(&NetDev, NULL); if (age > 0 && age <= 10) return 0; @@ -118,18 +124,18 @@ static int parse_netdev (void) char buffer[256]; char dev[16]; char *beg, *end; - int len; + unsigned int len; if (fgets (buffer, sizeof(buffer), Stream) == NULL) break; switch (++row) { case 1: - // skip row 1 + /* skip row 1 */ continue; case 2: - // row 2 used for headers + /* row 2 used for headers */ if (first_time) { char *RxTx = strrchr(buffer, '|'); first_time = 0; @@ -148,7 +154,7 @@ static int parse_netdev (void) continue; default: - // fetch interface name (1st column) as key + /* fetch interface name (1st column) as key */ beg = buffer; while (*beg && *beg == ' ') beg++; end = beg + 1; diff --git a/plugin_pop3.c b/plugin_pop3.c index 166db8f..da05614 100644 --- a/plugin_pop3.c +++ b/plugin_pop3.c @@ -1,4 +1,4 @@ -/* $Id: plugin_pop3.c,v 1.4 2004/05/31 21:05:13 reinelt Exp $ +/* $Id: plugin_pop3.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * Plugin to check POP3 mail accounts * @@ -27,6 +27,12 @@ * * * $Log: plugin_pop3.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/05/31 21:05:13 reinelt * * fixed lots of bugs in the Cwlinux driver @@ -54,27 +60,26 @@ #include "plugin.h" #include "cfg.h" -//added +/*added */ #include <sys/socket.h> #include <sys/types.h> -//#include <netinet/in.h> +/*#include <netinet/in.h> */ #include <netdb.h> #include <unistd.h> -//#include <pwd.h> +/*#include <pwd.h> */ #include <stdio.h> -// #ifdef WITH_DMALLOC #include <dmalloc.h> #endif -//POP 3 + /*POP 3 */ #define POPERR "-ERR" #define LOCKEDERR "-ERR account is locked by another session or for maintenance, try again." #define BUFSIZE 8192 #define POP3PORT 110 #define MAX_NUM_ACCOUNTS 3 -// + struct check { int id; @@ -86,20 +91,20 @@ struct check { struct check *next; }; -// ************************ PROTOTYPES ******************************** -// list +/************************ PROTOTYPES ********************************/ +/* list */ static struct check *check_node_alloc(void); static void check_node_add(struct check **head, struct check *new_check); static void check_destroy(struct check **head); -// pop3 +/* pop3 */ static void pop3_check_messages(struct check *hi,int verbose); static void pop3_recv_crlf_terminated(int sockfd, char *buf, int size); -// socket +/* socket */ static int tcp_connect(struct check *hi); -// ************************ GLOBAL *********************************** +/************************ GLOBAL ***********************************/ static char Section[] = "Plugin:POP3"; static struct check *head = NULL; -// ******************************************************************** +/********************************************************************/ static void my_POP3check (RESULT *result, RESULT *check) { double value; @@ -112,7 +117,7 @@ static void my_POP3check (RESULT *result, RESULT *check) if (node->id == param) break; } - if (node == NULL) //Inexistent account + if (node == NULL) /*Inexistent account */ value=-1.0; else pop3_check_messages(node,0); @@ -180,7 +185,7 @@ static int getConfig (void) return(n); } -// ************************ LIST *********************************** +/************************ LIST ***********************************/ static struct check *check_node_alloc(void) { struct check *new_check; @@ -213,7 +218,7 @@ static void check_destroy(struct check **head) *head = NULL; } -// ************************ POP3 ******************************** +/************************ POP3 ********************************/ static void pop3_check_messages(struct check *hi,int verbose) { char buf[BUFSIZE]; @@ -294,7 +299,7 @@ static void pop3_recv_crlf_terminated(int sockfd, char *buf, int size) *pos = '\0'; } -// ************************ SOCKET ******************************** +/************************ SOCKET ********************************/ static int tcp_connect(struct check *hi) { struct sockaddr_in addr; @@ -336,7 +341,7 @@ int plugin_init_pop3(void) { int n = getConfig(); - // by now, head should point to a list of all our accounts + /* by now, head should point to a list of all our accounts */ if (head) { info("[POP3] %d POP3 accounts have been succesfully defined",n); diff --git a/plugin_ppp.c b/plugin_ppp.c index e77ed74..e531d90 100644 --- a/plugin_ppp.c +++ b/plugin_ppp.c @@ -1,4 +1,4 @@ -/* $Id: plugin_ppp.c,v 1.6 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_ppp.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * plugin for ppp throughput * @@ -23,6 +23,12 @@ * * * $Log: plugin_ppp.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -92,11 +98,11 @@ static int get_ppp_stats (void) struct ifpppstatsreq req; char key[16], val[16]; - // reread every 10 msec only + /* reread every 10 msec only */ age=hash_age(&PPP, NULL); if (age>0 && age<=10) return 0; - // open socket only once + /* open socket only once */ if (fd==-2) { fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd==-1) { diff --git a/plugin_proc_stat.c b/plugin_proc_stat.c index b55c22b..aac22eb 100644 --- a/plugin_proc_stat.c +++ b/plugin_proc_stat.c @@ -1,4 +1,4 @@ -/* $Id: plugin_proc_stat.c,v 1.21 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_proc_stat.c,v 1.22 2004/06/26 09:27:21 reinelt Exp $ * * plugin for /proc/stat parsing * @@ -23,6 +23,12 @@ * * * $Log: plugin_proc_stat.c,v $ + * Revision 1.22 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.21 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -163,7 +169,7 @@ static int parse_proc_stat (void) { int age; - // reread every 10 msec only + /* reread every 10 msec only */ age=hash_age(&Stat, NULL); if (age>0 && age<=10) return 0; @@ -187,7 +193,7 @@ static int parse_proc_stat (void) cpu=buffer; - // skip "cpu" or "cpu0" block + /* skip "cpu" or "cpu0" block */ if ((end=strpbrk(buffer, delim))!=NULL) *end='\0'; beg=end?end+1:NULL; diff --git a/plugin_sample.c b/plugin_sample.c index 773d270..9f228ac 100644 --- a/plugin_sample.c +++ b/plugin_sample.c @@ -1,4 +1,4 @@ -/* $Id: plugin_sample.c,v 1.6 2004/06/01 06:04:25 reinelt Exp $ +/* $Id: plugin_sample.c,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * plugin template * @@ -23,6 +23,12 @@ * * * $Log: plugin_sample.c,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/01 06:04:25 reinelt * * made README.Plugins and plugin_sample up to date. @@ -61,14 +67,14 @@ */ -// define the include files you need +/* define the include files you need */ #include "config.h" #include <stdlib.h> #include <string.h> #include <ctype.h> -// these should always be included +/* these should always be included */ #include "debug.h" #include "plugin.h" @@ -78,134 +84,134 @@ -// sample function 'mul2' -// takes one argument, a number -// multiplies the number by 2.0 -// Note: all local functions should be declared 'static' +/* sample function 'mul2' */ +/* takes one argument, a number */ +/* multiplies the number by 2.0 */ +/* Note: all local functions should be declared 'static' */ static void my_mul2 (RESULT *result, RESULT *arg1) { double param; double value; - // Get Parameter - // R2N stands for 'Result to Number' + /* Get Parameter */ + /* R2N stands for 'Result to Number' */ param = R2N(arg1); - // calculate value + /* calculate value */ value = param*2.0; - // store result - // when called with R_NUMBER, it assumes the - // next parameter to be a pointer to double + /* store result */ + /* when called with R_NUMBER, it assumes the */ + /* next parameter to be a pointer to double */ SetResult(&result, R_NUMBER, &value); } -// sample function 'mul3' -// takes one argument, a number -// multiplies the number by 3.0 -// same as 'mul2', but shorter +/* sample function 'mul3' */ +/* takes one argument, a number */ +/* multiplies the number by 3.0 */ +/* same as 'mul2', but shorter */ static void my_mul3 (RESULT *result, RESULT *arg1) { - // do it all in one line + /* do it all in one line */ double value = R2N(arg1) * 3.0; - // store result + /* store result */ SetResult(&result, R_NUMBER, &value); } -// sample function 'diff' -// takes two arguments, both numbers -// returns |a-b| +/* sample function 'diff' */ +/* takes two arguments, both numbers */ +/* returns |a-b| */ static void my_diff (RESULT *result, RESULT *arg1, RESULT *arg2) { - // do it all in one line + /* do it all in one line */ double value = R2N(arg1) - R2N(arg2); - // some more calculations... + /* some more calculations... */ if (value < 0) value = -value; - // store result + /* store result */ SetResult(&result, R_NUMBER, &value); } -// sample function 'answer' -// takes no argument! -// returns the answer to all questions +/* sample function 'answer' */ +/* takes no argument! */ +/* returns the answer to all questions */ static void my_answer (RESULT *result) { - // we have to declare a variable because - // SetResult needs a pointer + /* we have to declare a variable because */ + /* SetResult needs a pointer */ double value = 42; - // store result + /* store result */ SetResult(&result, R_NUMBER, &value); } -// sample function 'length' -// takes one argument, a string -// returns the string length +/* sample function 'length' */ +/* takes one argument, a string */ +/* returns the string length */ static void my_length (RESULT *result, RESULT *arg1) { - // Note #1: value *must* be double! - // Note #2: R2S stands for 'Result to String' + /* Note #1: value *must* be double! */ + /* Note #2: R2S stands for 'Result to String' */ double value = strlen(R2S(arg1)); - // store result + /* store result */ SetResult(&result, R_NUMBER, &value); } -// sample function 'upcase' -// takes one argument, a string -// returns the string in upper case letters +/* sample function 'upcase' */ +/* takes one argument, a string */ +/* returns the string in upper case letters */ static void my_upcase (RESULT *result, RESULT *arg1) { char *value, *p; - // create a local copy of the argument - // Do *NOT* try to modify the original string! + /* create a local copy of the argument */ + /* Do *NOT* try to modify the original string! */ value = strdup(R2S(arg1)); - // process the string + /* process the string */ for (p = value; *p != '\0'; p++) *p = toupper(*p); - // store result - // when called with R_STRING, it assumes the - // next parameter to be a pointer to a string - // 'value' is already a char*, so use 'value', not '&value' + /* store result */ + /* when called with R_STRING, it assumes the */ + /* next parameter to be a pointer to a string */ + /* 'value' is already a char*, so use 'value', not '&value' */ SetResult(&result, R_STRING, value); - // free local copy again - // Note that SetResult() makes its own string copy + /* free local copy again */ + /* Note that SetResult() makes its own string copy */ free (value); } -// sample function 'cat' -// takes variable number of arguments, all strings -// returns all prameters concatenated +/* sample function 'cat' */ +/* takes variable number of arguments, all strings */ +/* returns all prameters concatenated */ static void my_concat (RESULT *result, int argc, RESULT *argv[]) { int i, len; char *value, *part; - // start with a empty string + /* start with a empty string */ value = strdup(""); - // process all arguments + /* process all arguments */ for (i = 0; i < argc; i++) { part = R2S(argv[i]); len = strlen(value)+strlen(part); @@ -213,22 +219,22 @@ static void my_concat (RESULT *result, int argc, RESULT *argv[]) strcat(value, part); } - // store result + /* store result */ SetResult(&result, R_STRING, value); - // free local string + /* free local string */ free (value); } -// plugin initialization -// MUST NOT be declared 'static'! +/* plugin initialization */ +/* MUST NOT be declared 'static'! */ int plugin_init_sample (void) { - // register all our cool functions - // the second parameter is the number of arguments - // -1 stands for variable argument list + /* register all our cool functions */ + /* the second parameter is the number of arguments */ + /* -1 stands for variable argument list */ AddFunction ("mul2", 1, my_mul2); AddFunction ("mul3", 1, my_mul3); AddFunction ("answer", 0, my_answer); @@ -242,6 +248,6 @@ int plugin_init_sample (void) void plugin_exit_sample(void) { - // free any allocated memory - // close filedescriptors + /* free any allocated memory */ + /* close filedescriptors */ } diff --git a/plugin_seti.c b/plugin_seti.c index 645d142..1110a81 100644 --- a/plugin_seti.c +++ b/plugin_seti.c @@ -1,4 +1,4 @@ -/* $Id: plugin_seti.c,v 1.3 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_seti.c,v 1.4 2004/06/26 09:27:21 reinelt Exp $ * * plugin for seti@home status reporting * @@ -27,6 +27,12 @@ * * * $Log: plugin_seti.c,v $ + * Revision 1.4 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.3 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -74,10 +80,10 @@ static int parse_seti (void) FILE *stream; int age; - // if a fatal error occured, do nothing + /* if a fatal error occured, do nothing */ if (fatal != 0) return -1; - // reread every 100 msec only + /* reread every 100 msec only */ age=hash_age(&SETI, NULL); if (age>0 && age<=100) return 0; @@ -114,16 +120,16 @@ static int parse_seti (void) c=strchr(buffer, '='); if (c==NULL) continue; key=buffer; val=c+1; - // strip leading blanks from key + /* strip leading blanks from key */ while (isspace(*key)) *key++='\0'; - // strip trailing blanks from key + /* strip trailing blanks from key */ do *c='\0'; while (isspace(*--c)); - // strip leading blanks from value + /* strip leading blanks from value */ while (isspace(*val)) *val++='\0'; - // strip trailing blanks from value + /* strip trailing blanks from value */ for (c=val; *c!='\0';c++); while (isspace(*--c)) *c='\0'; - // add entry to hash table + /* add entry to hash table */ hash_put (&SETI, key, val); } diff --git a/plugin_string.c b/plugin_string.c index 823fc0a..8ec40ee 100644 --- a/plugin_string.c +++ b/plugin_string.c @@ -1,4 +1,4 @@ -/* $Id: plugin_string.c,v 1.4 2004/03/03 03:47:04 reinelt Exp $ +/* $Id: plugin_string.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * string plugin * @@ -23,6 +23,12 @@ * * * $Log: plugin_string.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/03/03 03:47:04 reinelt * big patch from Martin Hejl: * - use qprintf() where appropriate @@ -70,7 +76,7 @@ static void my_strlen (RESULT *result, RESULT *arg1) int plugin_init_string (void) { - // register some basic string functions + /* register some basic string functions */ AddFunction ("strlen", 1, my_strlen); return 0; @@ -78,4 +84,5 @@ int plugin_init_string (void) void plugin_exit_string(void) { + /* empty */ } diff --git a/plugin_test.c b/plugin_test.c index 5fc35ea..2c075b1 100644 --- a/plugin_test.c +++ b/plugin_test.c @@ -1,4 +1,4 @@ -/* $Id: plugin_test.c,v 1.1 2004/06/07 06:56:55 reinelt Exp $ +/* $Id: plugin_test.c,v 1.2 2004/06/26 09:27:21 reinelt Exp $ * * Handy functions for testing displays and debugging code. * @@ -26,6 +26,12 @@ * * * $Log: plugin_test.c,v $ +* Revision 1.2 2004/06/26 09:27:21 reinelt +* +* added '-W' to CFLAGS +* changed all C++ comments to C ones ('//' => '/* */') +* cleaned up a lot of signed/unsigned mistakes +* * Revision 1.1 2004/06/07 06:56:55 reinelt * * added test plugin from Andy Baxter @@ -49,10 +55,11 @@ int plugin_init_test (void); #endif -// used for testing bars - keeps values for a series of 10 bars, -// which are incremented and decremented between 0 and rmax by -// amount rdelta every time they are read. Starting value is rstart. -// rbar gives the number of the test bar. +/* used for testing bars - keeps values for a series of 10 bars, + * which are incremented and decremented between 0 and rmax by + * amount rdelta every time they are read. Starting value is rstart. + * rbar gives the number of the test bar. + */ static void my_test_bar (RESULT *result, RESULT *rbar, RESULT *rmax, RESULT *rstart, RESULT *rdelta) { @@ -64,19 +71,19 @@ static void my_test_bar (RESULT *result, RESULT *rbar, RESULT *rmax, max=R2N(rmax); delta=R2N(rdelta); - // the maths is just to stop double rounding errors and bad values. + /* the maths is just to stop double rounding errors and bad values. */ bar=((int)floor(R2N(rbar)+0.1)) % 10; if ( fabs(delta) > 0.1 ) { - // don't move or init the bar if delta=0 (the widget is only browsing) + /* don't move or init the bar if delta=0 (the widget is only browsing) */ if (values[bar] == -1) { - // first time called. + /* first time called. */ values[bar]=R2N(rstart); deltas[bar]=delta; }; values[bar]+=deltas[bar]; }; if (values[bar] < 0 || values[bar] > max ) { - // turn around. + /* turn around. */ deltas[bar]= -deltas[bar]; values[bar]+= deltas[bar]; }; @@ -85,8 +92,9 @@ static void my_test_bar (RESULT *result, RESULT *rbar, RESULT *rmax, } -// like above, but just switches a value between 1 and -1. Can use to test -// visibility of icons. +/* like above, but just switches a value between 1 and -1. Can use to test + * visibility of icons. + */ static void my_test_onoff (RESULT *result, RESULT *arg1) { static int on[10] = {1,1,1,1,1,1,1,1,1,1}; @@ -112,5 +120,5 @@ int plugin_init_test (void) void plugin_exit_test(void) { - // empty + /* empty */ } diff --git a/plugin_time.c b/plugin_time.c index 4cd0338..13b1985 100644 --- a/plugin_time.c +++ b/plugin_time.c @@ -1,4 +1,4 @@ -/* $Id: plugin_time.c,v 1.1 2004/05/20 07:47:51 reinelt Exp $ +/* $Id: plugin_time.c,v 1.2 2004/06/26 09:27:21 reinelt Exp $ * * time plugin * @@ -23,6 +23,12 @@ * * * $Log: plugin_time.c,v $ + * Revision 1.2 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.1 2004/05/20 07:47:51 reinelt * added plugin_time * @@ -67,7 +73,7 @@ static void my_strftime (RESULT *result, RESULT *arg1, RESULT *arg2) int plugin_init_time (void) { - // register some basic time functions + /* register some basic time functions */ AddFunction ("time", 0, my_time); AddFunction ("strftime", 2, my_strftime); @@ -76,4 +82,5 @@ int plugin_init_time (void) void plugin_exit_time(void) { + /* empty */ } diff --git a/plugin_uptime.c b/plugin_uptime.c index 7b701c3..df718ca 100644 --- a/plugin_uptime.c +++ b/plugin_uptime.c @@ -1,4 +1,4 @@ -/* $Id: plugin_uptime.c,v 1.2 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_uptime.c,v 1.3 2004/06/26 09:27:21 reinelt Exp $ * * plugin for uptime * @@ -23,6 +23,12 @@ * * * $Log: plugin_uptime.c,v $ + * Revision 1.3 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.2 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -64,13 +70,13 @@ static char *itoa(char* buffer, const size_t size, unsigned int value) { char *p; - // sanity checks + /* sanity checks */ if (buffer==NULL || size<2) return (NULL); - // p points to last char + /* p points to last char */ p = buffer+size-1; - // set terminating zero + /* set terminating zero */ *p='\0'; do { @@ -93,7 +99,7 @@ char *struptime (const unsigned int uptime, const char *format) dst = string; len = 0; - // leave room for terminating zero + /* leave room for terminating zero */ size = sizeof(string) - 1; while (len < size) { @@ -160,7 +166,7 @@ char *struptime (const unsigned int uptime, const char *format) } } - // enforce terminating zero + /* enforce terminating zero */ if (len >= size && *(dst-1) != '\0') { len++; *dst = '\0'; @@ -185,7 +191,7 @@ double getuptime (void) buffer[i-1] = '\0'; - // ignore the 2nd value from /proc/uptime + /* ignore the 2nd value from /proc/uptime */ return strtod(buffer, NULL); } @@ -206,7 +212,7 @@ static void my_uptime (RESULT *result, const int argc, RESULT *argv[]) gettimeofday(&now,NULL); age = (now.tv_sec - last_value.tv_sec)*1000 + (now.tv_usec - last_value.tv_usec)/1000; - // reread every 100 msec only + /* reread every 100 msec only */ if (fd == -2 || age == 0 || age > 100) { uptime = getuptime(); if (uptime < 0.0) { diff --git a/plugin_wireless.c b/plugin_wireless.c index 4c0807f..e8f0a69 100755 --- a/plugin_wireless.c +++ b/plugin_wireless.c @@ -1,4 +1,4 @@ -/* $Id: plugin_wireless.c,v 1.5 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: plugin_wireless.c,v 1.6 2004/06/26 09:27:21 reinelt Exp $ * * Wireless Extension plugin * @@ -28,6 +28,12 @@ * * * $Log: plugin_wireless.c,v $ + * Revision 1.6 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.5 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -91,12 +97,12 @@ #endif #define HASH_TTL 100 - -//#define KILO 1e3 -//#define MEGA 1e6 -//#define GIGA 1e9 - - + + /*#define KILO 1e3 */ + /*#define MEGA 1e6 */ + /*#define GIGA 1e9 */ + + #define KEY_LEVEL "level" #define KEY_QUALITY "quality" #define KEY_NOISE "noise" @@ -296,8 +302,11 @@ static int get_op_mode(const char* dev, const char* key) { ioctl_error(__LINE__); return -1; } - - if((req.u.mode > 6) || (req.u.mode < 0)) { + + /* Fixme: req.u.mode is unsigned and therefore never < 0 */ + /* if((req.u.mode > 6) || (req.u.mode < 0)) { */ + + if(req.u.mode > 6) { req.u.mode=7; /* mode not available */ } @@ -399,7 +408,7 @@ static int get_sens(const char* dev, const char* key) { static int get_sec_mode(const char* dev, const char* key) { - // Get encryption information + /* Get encryption information */ struct iwreq req; char key_buffer[32]; char encrypt_key[IW_ENCODING_TOKEN_MAX+1]; @@ -433,9 +442,9 @@ static int get_sec_mode(const char* dev, const char* key) { return(-1); } - // Display encryption information - //if(has_key && (key_flags & IW_ENCODE_INDEX) > 1) - // printf(" [%d]", info->key_flags & IW_ENCODE_INDEX); + /* Display encryption information */ + /*if(has_key && (key_flags & IW_ENCODE_INDEX) > 1) */ + /* printf(" [%d]", info->key_flags & IW_ENCODE_INDEX); */ if(has_key && (key_flags & IW_ENCODE_RESTRICTED)) hash_put(&wireless,key_buffer, "restricted"); @@ -510,13 +519,13 @@ static int get_stats(const char *dev, const char *key) static int check_socket() { - // already handled in a previous run + /* already handled in a previous run */ if (sock==-3) return(-1); - // socket not initialized + /* socket not initialized */ if (sock==-2) sock = socket(AF_INET, SOCK_DGRAM, 0); - // error initilalizing socket + /* error initilalizing socket */ if (sock<=0) { error("Error opening socket for reading wireless stats"); sock=-3; @@ -549,7 +558,7 @@ static void save_result(RESULT *result, const char* dev, const char* key, const } /* - functions exported to the evaluator + *functions exported to the evaluator */ static void wireless_quality(RESULT *result, RESULT *arg1) { diff --git a/plugin_xmms.c b/plugin_xmms.c index e38ef6e..ad25d1a 100644 --- a/plugin_xmms.c +++ b/plugin_xmms.c @@ -1,4 +1,4 @@ -/* $Id: plugin_xmms.c,v 1.10 2004/06/17 06:23:43 reinelt Exp $ +/* $Id: plugin_xmms.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * XMMS-Plugin for LCD4Linux * Copyright 2003 Markus Keil <markus_keil@t-online.de> @@ -21,6 +21,12 @@ * * * $Log: plugin_xmms.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/06/17 06:23:43 reinelt * * hash handling rewritten to solve performance issues @@ -108,31 +114,31 @@ static int parse_xmms_info (void) FILE *xmms_stream; char zeile[200]; - // reread every 100msec only + /* reread every 100msec only */ age=hash_age(&xmms, NULL); if (age>=0 && age<=200) return 0; - // Open Filestream for '/tmp/xmms-info' + /* Open Filestream for '/tmp/xmms-info' */ xmms_stream = fopen("/tmp/xmms-info","r"); - // Check for File + /* Check for File */ if( !xmms_stream ) { error("Error: Cannot open XMMS-Info Stream! Is XMMS started?"); return -1; } - // Read Lines from the Stream + /* Read Lines from the Stream */ while(fgets(zeile,sizeof(zeile),xmms_stream)) { char *c, *key, *val; c=strchr(zeile, ':'); if (c==NULL) continue; key=zeile; val=c+1; - // strip leading blanks from key + /* strip leading blanks from key */ while (isspace(*key)) *key++='\0'; - // strip trailing blanks from key + /* strip trailing blanks from key */ do *c='\0'; while (isspace(*--c)); - // strip leading blanks from value + /* strip leading blanks from value */ while (isspace(*val)) *val++='\0'; - // strip trailing blanks from value + /* strip trailing blanks from value */ for (c=val; *c!='\0';c++); while (isspace(*--c)) *c='\0'; hash_put (&xmms, key, val); @@ -164,7 +170,7 @@ int plugin_init_xmms (void) { hash_create(&xmms); - // register xmms info + /* register xmms info */ AddFunction ("xmms", 1, my_xmms); return 0; @@ -1,4 +1,4 @@ -/* $Id: qprintf.c,v 1.4 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: qprintf.c,v 1.5 2004/06/26 09:27:21 reinelt Exp $ * * simple but quick snprintf() replacement * @@ -26,6 +26,12 @@ * * * $Log: qprintf.c,v $ + * Revision 1.5 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.4 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -64,20 +70,20 @@ static char *itoa(char* buffer, const size_t size, int value) char *p; int sign; - // sanity checks + /* sanity checks */ if (buffer==NULL || size<2) return (NULL); - // remember sign of value + /* remember sign of value */ sign = 0; if (value < 0) { sign = 1; value = -value; } - // p points to last char + /* p points to last char */ p = buffer+size-1; - // set terminating zero + /* set terminating zero */ *p='\0'; do { @@ -96,13 +102,13 @@ static char *utoa(char* buffer, const size_t size, unsigned int value) { char *p; - // sanity checks + /* sanity checks */ if (buffer==NULL || size<2) return (NULL); - // p points to last char + /* p points to last char */ p = buffer+size-1; - // set terminating zero + /* set terminating zero */ *p='\0'; do { @@ -119,13 +125,13 @@ static char *utox(char* buffer, const size_t size, unsigned int value) char *p; int digit; - // sanity checks + /* sanity checks */ if (buffer==NULL || size<2) return (NULL); - // p points to last char + /* p points to last char */ p = buffer+size-1; - // set terminating zero + /* set terminating zero */ *p='\0'; do { @@ -143,7 +149,7 @@ int qprintf(char *str, const size_t size, const char *format, ...) { va_list ap; const char *src; char *dst; - int len; + unsigned int len; src = format; dst = str; @@ -151,7 +157,7 @@ int qprintf(char *str, const size_t size, const char *format, ...) { va_start(ap, format); - // use size-1 for terminating zero + /* use size-1 for terminating zero */ while (len < size-1) { if (*src=='%') { @@ -207,13 +213,13 @@ int qprintf(char *str, const size_t size, const char *format, ...) { va_end(ap); - // enforce terminating zero + /* enforce terminating zero */ if (len>=size-1 && *(dst-1)!='\0') { len++; *dst='\0'; } - // do not count terminating zero + /* do not count terminating zero */ return len-1; } @@ -1,4 +1,4 @@ -/* $Id: qprintf.h,v 1.2 2004/03/03 04:44:16 reinelt Exp $ +/* $Id: qprintf.h,v 1.3 2004/06/26 09:27:21 reinelt Exp $ * * simple but quick snprintf() replacement * @@ -26,6 +26,12 @@ * * * $Log: qprintf.h,v $ + * Revision 1.3 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.2 2004/03/03 04:44:16 reinelt * changes (cosmetics?) to the big patch from Martin * hash patch un-applied @@ -38,7 +44,7 @@ #ifndef _QPRINTF_H_ #define _QPRINTF_H_ -// size_t +/* size_t */ #include <stdio.h> int qprintf(char *str, size_t size, const char *format, ...); @@ -1,4 +1,4 @@ -/* $Id: timer.c,v 1.8 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: timer.c,v 1.9 2004/06/26 09:27:21 reinelt Exp $ * * generic timer handling * @@ -21,6 +21,12 @@ * * * $Log: timer.c,v $ + * Revision 1.9 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.8 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -122,18 +128,18 @@ int timer_add (void (*callback)(void *data), void *data, const int interval, con gettimeofday(&now, NULL); - // find a free slot + /* find a free slot */ for (i=0; i<nTimers; i++) { if (Timers[i].active==0) break; } - // none found, allocate a new slot + /* none found, allocate a new slot */ if (i>=nTimers) { nTimers++; Timers=realloc(Timers, nTimers*sizeof(*Timers)); } - // fill slot + /* fill slot */ Timers[i].callback = callback; Timers[i].data = data; Timers[i].when = now; @@ -141,7 +147,7 @@ int timer_add (void (*callback)(void *data), void *data, const int interval, con Timers[i].one_shot = one_shot; Timers[i].active = 1; - // if one-shot timer, don't fire now + /* if one-shot timer, don't fire now */ if (one_shot) { timer_inc (&Timers[i].when, interval); } @@ -155,26 +161,26 @@ int timer_process (struct timespec *delay) int i, flag, min; struct timeval now; - // the current moment + /* the current moment */ gettimeofday(&now, NULL); - // sanity check + /* sanity check */ if (nTimers==0) { error ("huh? not one single timer to process? dazed and confused..."); return -1; } - // process expired timers + /* process expired timers */ flag=0; for (i=0; i<nTimers; i++) { if (Timers[i].active == 0) continue; if (timercmp(&Timers[i].when, &now, <=)) { flag=1; - // callback + /* callback */ if (Timers[i].callback!=NULL) { Timers[i].callback(Timers[i].data); } - // respawn or delete timer + /* respawn or delete timer */ if (Timers[i].one_shot) { Timers[i].active=0; } else { @@ -184,7 +190,7 @@ int timer_process (struct timespec *delay) } } - // find next timer + /* find next timer */ flag=1; min=-1; for (i=0; i<nTimers; i++) { @@ -200,14 +206,14 @@ int timer_process (struct timespec *delay) return -1; } - // delay until next timer event + /* delay until next timer event */ delay->tv_sec = Timers[min].when.tv_sec - now.tv_sec; delay->tv_nsec = Timers[min].when.tv_usec - now.tv_usec; if (delay->tv_nsec<0) { delay->tv_sec--; delay->tv_nsec += 1000000; } - // nanoseconds!! + /* nanoseconds!! */ delay->tv_nsec *= 1000; return 0; @@ -219,8 +225,8 @@ void timer_exit(void) { nTimers=0; - if (Timers>0) { + if (Timers != NULL) { free(Timers);; - Timers=NULL; + Timers = NULL; } } @@ -1,4 +1,4 @@ -/* $Id: udelay.h,v 1.6 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: udelay.h,v 1.7 2004/06/26 09:27:21 reinelt Exp $ * * short delays * @@ -22,6 +22,12 @@ * * * $Log: udelay.h,v $ + * Revision 1.7 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.6 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -57,9 +63,9 @@ /* stolen from linux/asm-i386/processor.h */ /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ -static inline void rep_nop(void) +static inline void rep_nop (void) { - __asm__ __volatile__("rep;nop"); + __asm__ __volatile__("rep; nop"); } @@ -1,4 +1,4 @@ -/* $Id: widget.c,v 1.15 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: widget.c,v 1.16 2004/06/26 09:27:21 reinelt Exp $ * * generic widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget.c,v $ + * Revision 1.16 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.15 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -107,7 +113,7 @@ #endif -// we use a static array of widgets and not realloc() +/* we use a static array of widgets and not realloc() */ #define MAX_WIDGETS 256 static WIDGET_CLASS *Classes=NULL; @@ -122,9 +128,9 @@ int widget_register (WIDGET_CLASS *widget) { int i; - // sanity check: disallow widget registering after at least one - // widget has been added, because we use realloc here, and there may - // be pointers to the old memory area + /* sanity check: disallow widget registering after at least one */ + /* widget has been added, because we use realloc here, and there may */ + /* be pointers to the old memory area */ if (widget_added) { error ("internal error: register_widget(%s) after add_widget()", widget->name); return -1; @@ -166,13 +172,13 @@ int widget_add (const char *name, const int row, const int col) WIDGET_CLASS *Class; WIDGET *Widget; - // prepare config section - // strlen("Widget:")=7 + /* prepare config section */ + /* strlen("Widget:")=7 */ section=malloc(strlen(name)+8); strcpy(section, "Widget:"); strcat(section, name); - // get widget class + /* get widget class */ class=cfg_get(section, "class", NULL); if (class==NULL || *class=='\0') { error ("error: widget '%s' has no class!", name); @@ -180,7 +186,7 @@ int widget_add (const char *name, const int row, const int col) return -1; } free(section); - // lookup widget class + /* lookup widget class */ Class=NULL; for (i=0; i<nClasses; i++) { if (strcasecmp(class, Classes[i].name)==0) { @@ -195,8 +201,8 @@ int widget_add (const char *name, const int row, const int col) } if (class) free (class); - // do NOT use realloc here because there may be pointers to the old - // memory area, which would point to nowhere if realloc moves the area + /* do NOT use realloc here because there may be pointers to the old */ + /* memory area, which would point to nowhere if realloc moves the area */ if (Widgets==NULL) { Widgets=malloc(MAX_WIDGETS*sizeof(WIDGET)); if (Widgets==NULL) { @@ -205,7 +211,7 @@ int widget_add (const char *name, const int row, const int col) } } - // another sanity check + /* another sanity check */ if (nWidgets>=MAX_WIDGETS) { error ("internal error: widget buffer full!"); return -1; @@ -1,4 +1,4 @@ -/* $Id: widget.h,v 1.9 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: widget.h,v 1.10 2004/06/26 09:27:21 reinelt Exp $ * * generic widget handling * @@ -23,6 +23,12 @@ * * * $Log: widget.h,v $ + * Revision 1.10 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.9 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -69,7 +75,7 @@ #define _WIDGET_H_ -struct WIDGET; // forward declaration +struct WIDGET; /* forward declaration */ typedef struct WIDGET_CLASS { diff --git a/widget_bar.c b/widget_bar.c index 60d2de9..6c58dac 100644 --- a/widget_bar.c +++ b/widget_bar.c @@ -1,4 +1,4 @@ -/* $Id: widget_bar.c,v 1.10 2004/03/11 06:39:59 reinelt Exp $ +/* $Id: widget_bar.c,v 1.11 2004/06/26 09:27:21 reinelt Exp $ * * bar widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget_bar.c,v $ + * Revision 1.11 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.10 2004/03/11 06:39:59 reinelt * big patch from Martin: * - reuse filehandles @@ -106,7 +112,7 @@ void widget_bar_update (void *Self) double val1, val2; double min, max; - // evaluate expressions + /* evaluate expressions */ val1 = 0.0; if (Bar->tree1 != NULL) { Eval(Bar->tree1, &result); @@ -121,7 +127,7 @@ void widget_bar_update (void *Self) DelResult(&result); } - // minimum: if expression is empty, do auto-scaling + /* minimum: if expression is empty, do auto-scaling */ if (Bar->tree_min!=NULL) { Eval(Bar->tree_min, &result); min = R2N(&result); @@ -132,7 +138,7 @@ void widget_bar_update (void *Self) if (val2 < min) min = val2; } - // maximum: if expression is empty, do auto-scaling + /* maximum: if expression is empty, do auto-scaling */ if (Bar->tree_max!=NULL) { Eval(Bar->tree_max, &result); max = R2N(&result); @@ -143,7 +149,7 @@ void widget_bar_update (void *Self) if (val2 > max) max = val2; } - // calculate bar values + /* calculate bar values */ Bar->min=min; Bar->max=max; if (max>min) { @@ -154,7 +160,7 @@ void widget_bar_update (void *Self) Bar->val2=0.0; } - // finally, draw it! + /* finally, draw it! */ if (W->class->draw) W->class->draw(W); @@ -166,8 +172,8 @@ int widget_bar_init (WIDGET *Self) char *section; char *c; WIDGET_BAR *Bar; - // prepare config section - // strlen("Widget:")=7 + /* prepare config section */ + /* strlen("Widget:")=7 */ section=malloc(strlen(Self->name)+8); strcpy(section, "Widget:"); strcat(section, Self->name); @@ -175,30 +181,30 @@ int widget_bar_init (WIDGET *Self) Bar=malloc(sizeof(WIDGET_BAR)); memset (Bar, 0, sizeof(WIDGET_BAR)); - // get raw expressions (we evaluate them ourselves) + /* get raw expressions (we evaluate them ourselves) */ Bar->expression1 = cfg_get_raw (section, "expression", NULL); Bar->expression2 = cfg_get_raw (section, "expression2", NULL); - // sanity check + /* sanity check */ if (Bar->expression1==NULL || *Bar->expression1=='\0') { error ("widget %s has no expression, using '0.0'", Self->name); Bar->expression1="0"; } - // minimum and maximum value + /* minimum and maximum value */ Bar->expr_min = cfg_get_raw (section, "min", NULL); Bar->expr_max = cfg_get_raw (section, "max", NULL); - // compile all expressions + /* compile all expressions */ Compile (Bar->expression1, &Bar->tree1); Compile (Bar->expression2, &Bar->tree2); Compile (Bar->expr_min, &Bar->tree_min); Compile (Bar->expr_max, &Bar->tree_max); - // bar length, default 1 + /* bar length, default 1 */ cfg_number (section, "length", 1, 0, 99999, &(Bar->length)); - // direction: East (default), West, North, South + /* direction: East (default), West, North, South */ c = cfg_get (section, "direction", "E"); switch (toupper(*c)) { case 'E': @@ -219,12 +225,9 @@ int widget_bar_init (WIDGET *Self) } free (c); - // update interval (msec), default 1 sec + /* update interval (msec), default 1 sec */ cfg_number (section, "update", 1000, 10, 99999, &(Bar->update)); - // buffer - // Bar->buffer=malloc(Bar->width+1); - free (section); Self->data=Bar; diff --git a/widget_bar.h b/widget_bar.h index f2e51e1..1f05ef4 100644 --- a/widget_bar.h +++ b/widget_bar.h @@ -1,4 +1,4 @@ -/* $Id: widget_bar.h,v 1.3 2004/03/06 20:31:16 reinelt Exp $ +/* $Id: widget_bar.h,v 1.4 2004/06/26 09:27:21 reinelt Exp $ * * bar widget handling * @@ -23,6 +23,12 @@ * * * $Log: widget_bar.h,v $ + * Revision 1.4 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.3 2004/03/06 20:31:16 reinelt * Complete rewrite of the evaluator to get rid of the code * from mark Morley (because of license issues). @@ -45,21 +51,21 @@ typedef enum { DIR_EAST=1, DIR_WEST=2, DIR_NORTH=4, DIR_SOUTH=8 } DIRECTION; typedef struct WIDGET_BAR { - char *expression1; // expression that delivers the value - char *expression2; // expression that delivers the value - char *expr_min; // expression that delivers the minimum value - char *expr_max; // expression that delivers the maximum value - void *tree1; // pre-compiled expression that delivers the value - void *tree2; // pre-compiled expression that delivers the value - void *tree_min; // pre-compiled expression that delivers the minimum value - void *tree_max; // pre-compiled expression that delivers the maximum value - DIRECTION direction; // bar direction - int length; // bar length - int update; // update interval (msec) - double val1; // bar value, 0.0 ... 1.0 - double val2; // bar value, 0.0 ... 1.0 - double min; // minimum value - double max; // maximum value + char *expression1; /* expression that delivers the value */ + char *expression2; /* expression that delivers the value */ + char *expr_min; /* expression that delivers the minimum value */ + char *expr_max; /* expression that delivers the maximum value */ + void *tree1; /* pre-compiled expression that delivers the value */ + void *tree2; /* pre-compiled expression that delivers the value */ + void *tree_min; /* pre-compiled expression that delivers the minimum value */ + void *tree_max; /* pre-compiled expression that delivers the maximum value */ + DIRECTION direction; /* bar direction */ + int length; /* bar length */ + int update; /* update interval (msec) */ + double val1; /* bar value, 0.0 ... 1.0 */ + double val2; /* bar value, 0.0 ... 1.0 */ + double min; /* minimum value */ + double max; /* maximum value */ } WIDGET_BAR; diff --git a/widget_icon.c b/widget_icon.c index a516cb2..80b8e16 100644 --- a/widget_icon.c +++ b/widget_icon.c @@ -1,4 +1,4 @@ -/* $Id: widget_icon.c,v 1.12 2004/06/20 10:09:56 reinelt Exp $ +/* $Id: widget_icon.c,v 1.13 2004/06/26 09:27:21 reinelt Exp $ * * icon widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget_icon.c,v $ + * Revision 1.13 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.12 2004/06/20 10:09:56 reinelt * * 'const'ified the whole source @@ -105,7 +111,7 @@ #include <dmalloc.h> #endif -// icons always are 8 pixels high +/* icons always are 8 pixels high */ #define YRES 8 static void widget_icon_read_bitmap (const char *section, WIDGET_ICON *Icon) @@ -151,7 +157,7 @@ void widget_icon_update (void *Self) WIDGET_ICON *Icon = W->data; RESULT result = {0, 0, 0, NULL}; - // evaluate expressions + /* evaluate expressions */ Icon->speed = 100; if (Icon->speed_tree!=NULL) { Eval(Icon->speed_tree, &result); @@ -168,19 +174,19 @@ void widget_icon_update (void *Self) DelResult(&result); } - // rotate icon bitmap + /* rotate icon bitmap */ Icon->curmap++; if (Icon->curmap >= Icon->maxmap) Icon->curmap=0; - // finally, draw it! + /* finally, draw it! */ if (W->class->draw) W->class->draw(W); - // store currently visible bitmap + /* store currently visible bitmap */ Icon->prvmap=Icon->curmap; - // add a new one-shot timer + /* add a new one-shot timer */ timer_add (widget_icon_update, Self, Icon->speed, 1); } @@ -192,8 +198,8 @@ int widget_icon_init (WIDGET *Self) char *section; WIDGET_ICON *Icon; - // prepare config section - // strlen("Widget:")=7 + /* prepare config section */ + /* strlen("Widget:")=7 */ section=malloc(strlen(Self->name)+8); strcpy(section, "Widget:"); strcat(section, Self->name); @@ -201,35 +207,35 @@ int widget_icon_init (WIDGET *Self) Icon=malloc(sizeof(WIDGET_ICON)); memset (Icon, 0, sizeof(WIDGET_ICON)); - // get raw expressions (we evaluate them ourselves) + /* get raw expressions (we evaluate them ourselves) */ Icon->speed_expr = cfg_get_raw (section, "speed", NULL); Icon->visible_expr = cfg_get_raw (section, "visible", NULL); - // compile'em + /* compile'em */ Compile (Icon->speed_expr, &Icon->speed_tree); Compile (Icon->visible_expr, &Icon->visible_tree); - // sanity check + /* sanity check */ if (Icon->speed_expr==NULL || *Icon->speed_expr=='\0') { error ("Icon %s has no speed, using '100'", Self->name); Icon->speed_expr="100"; } - // read bitmap + /* read bitmap */ widget_icon_read_bitmap (section, Icon); free (section); Self->data=Icon; - // as the speed is evaluatod on every call, we use 'one-shot'-timers. - // The timer will be reactivated on every call to widget_icon_update(). - // We do the initial call here... + /* as the speed is evaluatod on every call, we use 'one-shot'-timers. */ + /* The timer will be reactivated on every call to widget_icon_update(). */ + /* We do the initial call here... */ Icon->prvmap=-1; - // reset ascii + /* reset ascii */ Icon->ascii=-1; - // just do it! + /* just do it! */ widget_icon_update(Self); return 0; diff --git a/widget_icon.h b/widget_icon.h index f2f3029..4b64f15 100644 --- a/widget_icon.h +++ b/widget_icon.h @@ -1,4 +1,4 @@ -/* $Id: widget_icon.h,v 1.5 2004/03/06 20:31:16 reinelt Exp $ +/* $Id: widget_icon.h,v 1.6 2004/06/26 09:27:21 reinelt Exp $ * * icon widget handling * @@ -23,6 +23,12 @@ * * * $Log: widget_icon.h,v $ + * Revision 1.6 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.5 2004/03/06 20:31:16 reinelt * Complete rewrite of the evaluator to get rid of the code * from mark Morley (because of license issues). @@ -51,17 +57,17 @@ #define _WIDGET_ICON_H_ typedef struct WIDGET_ICON { - char *speed_expr; // expression for update interval - void *speed_tree; // pre-compiled expression for update interval - int speed; // update interval (msec) - char *visible_expr; // expression for visibility - void *visible_tree; // pre-compiled expression for visibility - int visible; // icon visible? - int ascii; // ascii code of icon (depends on the driver) - int curmap; // current bitmap sequence - int prvmap; // previous bitmap sequence - int maxmap; // number of bitmap sequences - unsigned char *bitmap; // bitmaps of (animated) icon + char *speed_expr; /* expression for update interval */ + void *speed_tree; /* pre-compiled expression for update interval */ + int speed; /* update interval (msec) */ + char *visible_expr; /* expression for visibility */ + void *visible_tree; /* pre-compiled expression for visibility */ + int visible; /* icon visible? */ + int ascii; /* ascii code of icon (depends on the driver) */ + int curmap; /* current bitmap sequence */ + int prvmap; /* previous bitmap sequence */ + int maxmap; /* number of bitmap sequences */ + unsigned char *bitmap; /* bitmaps of (animated) icon */ } WIDGET_ICON; extern WIDGET_CLASS Widget_Icon; diff --git a/widget_text.c b/widget_text.c index 5840a34..f15bc5d 100644 --- a/widget_text.c +++ b/widget_text.c @@ -1,4 +1,4 @@ -/* $Id: widget_text.c,v 1.17 2004/03/11 06:39:59 reinelt Exp $ +/* $Id: widget_text.c,v 1.18 2004/06/26 09:27:21 reinelt Exp $ * * simple text widget handling * @@ -21,6 +21,12 @@ * * * $Log: widget_text.c,v $ + * Revision 1.18 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.17 2004/03/11 06:39:59 reinelt * big patch from Martin: * - reuse filehandles @@ -161,13 +167,13 @@ void widget_text_scroll (void *Self) T->scroll++; if (T->scroll >= width+len) T->scroll=0; break; - default: // not reached + default: /* not reached */ pad=0; } dst=T->buffer; - // process prefix + /* process prefix */ src=T->preval; while (num < T->width) { if (*src=='\0') break; @@ -177,27 +183,27 @@ void widget_text_scroll (void *Self) src=T->value; - // pad blanks on the beginning + /* pad blanks on the beginning */ while (pad > 0 && num < T->width) { *(dst++)=' '; num++; pad--; } - // skip src chars (marquee) + /* skip src chars (marquee) */ while (pad<0) { src++; pad++; } - // copy content + /* copy content */ while (num < T->width) { if (*src=='\0') break; *(dst++)=*(src++); num++; } - // pad blanks on the end + /* pad blanks on the end */ src=T->postval; len=strlen(src); while (num < T->width-len) { @@ -205,7 +211,7 @@ void widget_text_scroll (void *Self) num++; } - // process postfix + /* process postfix */ while (num < T->width) { if (*src=='\0') break; *(dst++)=*(src++); @@ -214,7 +220,7 @@ void widget_text_scroll (void *Self) *dst='\0'; - // finally, draw it! + /* finally, draw it! */ if (W->class->draw) W->class->draw(W); } @@ -229,7 +235,7 @@ void widget_text_update (void *Self) char *preval, *postval, *value; int update; - // evaluate prefix + /* evaluate prefix */ if (T->pretree!=NULL) { Eval(T->pretree, &result); preval=strdup(R2S(&result)); @@ -238,7 +244,7 @@ void widget_text_update (void *Self) preval=strdup(""); } - // evaluate postfix + /* evaluate postfix */ if (T->posttree!=NULL) { Eval(T->posttree, &result); postval=strdup(R2S(&result)); @@ -247,30 +253,30 @@ void widget_text_update (void *Self) postval=strdup(""); } - // evaluate expression + /* evaluate expression */ Eval(T->tree, &result); - // string or number? + /* string or number? */ if (T->precision==0xC0DE) { value=strdup(R2S(&result)); } else { double number=R2N(&result); int width=T->width-strlen(preval)-strlen(postval); int precision=T->precision; - // print zero bytes so we can specify NULL as target - // and get the length of the resulting string + /* print zero bytes so we can specify NULL as target */ + /* and get the length of the resulting string */ int size=snprintf (NULL, 0, "%.*f", precision, number); - // number does not fit into field width: try to reduce precision + /* number does not fit into field width: try to reduce precision */ if (width<0) width=0; if (size>width && precision>0) { int delta=size-width; if (delta>precision) delta=precision; precision-=delta; size-=delta; - // zero precision: omit decimal point, too + /* zero precision: omit decimal point, too */ if (precision==0) size--; } - // number still doesn't fit: display '*****' + /* number still doesn't fit: display '*****' */ if (size>width) { value=malloc(width+1); memset (value, '*', width); @@ -285,41 +291,41 @@ void widget_text_update (void *Self) update=0; - // prefix changed? + /* prefix changed? */ if (T->preval == NULL || strcmp(T->preval, preval)!=0) { update=1; if (T->preval) free (T->preval); T->preval=preval; - T->scroll=0; // reset marquee counter + T->scroll=0; /* reset marquee counter */ } else { free (preval); } - // postfix changed? + /* postfix changed? */ if (T->postval == NULL || strcmp(T->postval, postval)!=0) { update=1; if (T->postval) free (T->postval); T->postval=postval; - T->scroll=0; // reset marquee counter + T->scroll=0; /* reset marquee counter */ } else { free (postval); } - // value changed? + /* value changed? */ if (T->value == NULL || strcmp(T->value, value)!=0) { update=1; if (T->value) free (T->value); T->value=value; - T->scroll=0; // reset marquee counter + T->scroll=0; /* reset marquee counter */ } else { free (value); } - // something has changed and should be updated + /* something has changed and should be updated */ if (update) { - // if there's a marquee scroller active, it has its own - // update callback timer, so we do nothing here; otherwise - // we simply call this scroll callback directly + /* if there's a marquee scroller active, it has its own */ + /* update callback timer, so we do nothing here; otherwise */ + /* we simply call this scroll callback directly */ if (T->align!=ALIGN_MARQUEE) { widget_text_scroll (Self); } @@ -333,8 +339,8 @@ int widget_text_init (WIDGET *Self) char *section; char *c; WIDGET_TEXT *Text; - // prepare config section - // strlen("Widget:")=7 + /* prepare config section */ + /* strlen("Widget:")=7 */ section=malloc(strlen(Self->name)+8); strcpy(section, "Widget:"); strcat(section, Self->name); @@ -342,30 +348,30 @@ int widget_text_init (WIDGET *Self) Text=malloc(sizeof(WIDGET_TEXT)); memset (Text, 0, sizeof(WIDGET_TEXT)); - // get raw pre- and postfix (we evaluate it ourselves) + /* get raw pre- and postfix (we evaluate it ourselves) */ Text->prefix = cfg_get_raw (section, "prefix", NULL); Text->postfix = cfg_get_raw (section, "postfix", NULL); - // compile pre- and postfix + /* compile pre- and postfix */ Compile (Text->prefix, &Text->pretree); Compile (Text->postfix, &Text->posttree); - // get raw expression (we evaluate it ourselves) + /* get raw expression (we evaluate it ourselves) */ Text->expression = cfg_get_raw (section, "expression", "''"); Compile (Text->expression, &Text->tree); - // field width, default 10 + /* field width, default 10 */ cfg_number (section, "width", 10, 0, 99999, &(Text->width)); - // precision: number of digits after the decimal point (default: none) - // Note: this is the *maximum* precision on small values, - // for larger values the precision may be reduced to fit into the field width. - // The default value 0xC0DE is used to distinguish between numbers and strings: - // if no precision is given, the result is always treated as a string. If a - // precision is specified, the result is treated as a number. + /* precision: number of digits after the decimal point (default: none) */ + /* Note: this is the *maximum* precision on small values, */ + /* for larger values the precision may be reduced to fit into the field width. */ + /* The default value 0xC0DE is used to distinguish between numbers and strings: */ + /* if no precision is given, the result is always treated as a string. If a */ + /* precision is specified, the result is treated as a number. */ cfg_number (section, "precision", 0xC0DE, 0, 80, &(Text->precision)); - // field alignment: Left (default), Center, Right or Marquee + /* field alignment: Left (default), Center, Right or Marquee */ c = cfg_get (section, "align", "L"); switch (toupper(*c)) { case 'L': @@ -386,26 +392,26 @@ int widget_text_init (WIDGET *Self) } free (c); - // update interval (msec), default 1 sec, 0 stands for never + /* update interval (msec), default 1 sec, 0 stands for never */ cfg_number (section, "update", 1000, 0, 99999, &(Text->update)); - // limit update interval to min 10 msec + /* limit update interval to min 10 msec */ if (Text->update > 0 && Text->update < 10) Text->update = 10; - // marquee scroller speed: interval (msec), default 500msec + /* marquee scroller speed: interval (msec), default 500msec */ if (Text->align==ALIGN_MARQUEE) { cfg_number (section, "speed", 500, 10, 99999, &(Text->speed)); } - // buffer + /* buffer */ Text->buffer=malloc(Text->width+1); free (section); Self->data=Text; - // add update timer, use one-shot if 'update' is zero + /* add update timer, use one-shot if 'update' is zero */ timer_add (widget_text_update, Self, Text->update, Text->update==0); - // a marquee scroller has its own timer and callback + /* a marquee scroller has its own timer and callback */ if (Text->align==ALIGN_MARQUEE) { timer_add (widget_text_scroll, Self, Text->speed, 0); } diff --git a/widget_text.h b/widget_text.h index 4fa9518..7042931 100644 --- a/widget_text.h +++ b/widget_text.h @@ -1,4 +1,4 @@ -/* $Id: widget_text.h,v 1.3 2004/03/06 20:31:16 reinelt Exp $ +/* $Id: widget_text.h,v 1.4 2004/06/26 09:27:21 reinelt Exp $ * * simple text widget handling * @@ -23,6 +23,12 @@ * * * $Log: widget_text.h,v $ + * Revision 1.4 2004/06/26 09:27:21 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.3 2004/03/06 20:31:16 reinelt * Complete rewrite of the evaluator to get rid of the code * from mark Morley (because of license issues). @@ -49,22 +55,22 @@ typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE } ALIGN; typedef struct WIDGET_TEXT { - char *prefix; // expression for label on the left side - void *pretree; // pre-compiled expression for label on the left side - char *preval; // value for label on the left side - char *postfix; // expression for label on the right side - void *posttree; // pre-compiled expression for label on the right side - char *postval; // value for label on the right side - char *expression; // expression that delivers the value - void *tree; // pre-compiled expression that delivers the value - char *value; // evaluated value from expression - char *buffer; // string with 'width+1' bytes allocated - int width; // field width - int precision; // number of digits after the decimal point - ALIGN align; // alignment: L, C, R, M(arquee) - int update; // update interval - int scroll; // marquee starting point - int speed; // marquee scrolling speed + char *prefix; /* expression for label on the left side */ + void *pretree; /* pre-compiled expression for label on the left side */ + char *preval; /* value for label on the left side */ + char *postfix; /* expression for label on the right side */ + void *posttree; /* pre-compiled expression for label on the right side */ + char *postval; /* value for label on the right side */ + char *expression; /* expression that delivers the value */ + void *tree; /* pre-compiled expression that delivers the value */ + char *value; /* evaluated value from expression */ + char *buffer; /* string with 'width+1' bytes allocated */ + int width; /* field width */ + int precision; /* number of digits after the decimal point */ + ALIGN align; /* alignment: L, C, R, M(arquee) */ + int update; /* update interval */ + int scroll; /* marquee starting point */ + int speed; /* marquee scrolling speed */ } WIDGET_TEXT; |