aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfg.c48
-rw-r--r--cfg.h34
-rw-r--r--debug.c8
-rw-r--r--debug.h8
-rw-r--r--drv.c10
-rw-r--r--drv.h14
-rw-r--r--drv_BeckmannEgle.c16
-rw-r--r--drv_Crystalfontz.c59
-rw-r--r--drv_Curses.c21
-rw-r--r--drv_Cwlinux.c20
-rw-r--r--drv_HD44780.c31
-rw-r--r--drv_Image.c14
-rw-r--r--drv_M50530.c33
-rw-r--r--drv_MatrixOrbital.c24
-rw-r--r--drv_MilfordInstruments.c16
-rw-r--r--drv_NULL.c18
-rw-r--r--drv_T6963.c28
-rw-r--r--drv_USBLCD.c18
-rw-r--r--drv_X11.c16
-rw-r--r--drv_generic_graphic.c14
-rw-r--r--drv_generic_graphic.h12
-rw-r--r--drv_generic_parport.c32
-rw-r--r--drv_generic_parport.h20
-rw-r--r--drv_generic_serial.c22
-rw-r--r--drv_generic_serial.h14
-rw-r--r--drv_generic_text.c22
-rw-r--r--drv_generic_text.h19
-rw-r--r--evaluator.c24
-rw-r--r--evaluator.h18
-rw-r--r--hash.c18
-rw-r--r--hash.h12
-rw-r--r--layout.c10
-rw-r--r--layout.h8
-rw-r--r--plugin_cfg.c8
-rw-r--r--plugin_exec.c14
-rw-r--r--plugin_i2c_sensors.c16
-rwxr-xr-xplugin_imon.c18
-rw-r--r--plugin_isdn.c10
-rw-r--r--plugin_proc_stat.c14
-rw-r--r--plugin_uptime.c12
-rwxr-xr-xplugin_wireless.c36
-rw-r--r--qprintf.c30
-rw-r--r--thread.c18
-rw-r--r--thread.h18
-rw-r--r--timer.c10
-rw-r--r--timer.h8
-rw-r--r--udelay.c17
-rw-r--r--udelay.h8
-rw-r--r--widget.c10
-rw-r--r--widget.h10
-rw-r--r--widget_icon.c8
51 files changed, 569 insertions, 377 deletions
diff --git a/cfg.c b/cfg.c
index 8d9388e..4a9ebea 100644
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.39 2004/03/11 06:39:58 reinelt Exp $^
+/* $Id: cfg.c,v 1.40 2004/06/20 10:09:52 reinelt Exp $^
*
* config file stuff
*
@@ -23,6 +23,10 @@
*
*
* $Log: cfg.c,v $
+ * Revision 1.40 2004/06/20 10:09:52 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.39 2004/03/11 06:39:58 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -299,7 +303,7 @@ static int c_sort (const void *a, const void *b)
// remove leading and trailing whitespace
-static char *strip (char *s, int strip_comments)
+static char *strip (char *s, const int strip_comments)
{
char *p;
@@ -356,9 +360,9 @@ static char *dequote (char *string)
// which if a string contains only valid chars
// i.e. start with a char and contains chars and nums
-static int validchars (char *string)
+static int validchars (const char *string)
{
- char *c;
+ const char *c;
for (c=string; *c; c++) {
// first and following chars
@@ -371,7 +375,7 @@ static int validchars (char *string)
}
-static void cfg_add (char *section, char *key, char *val, int lock)
+static void cfg_add (const char *section, const char *key, const char *val, const int lock)
{
char *buffer;
ENTRY *entry;
@@ -410,7 +414,7 @@ static void cfg_add (char *section, char *key, char *val, int lock)
}
-int l4l_cfg_cmd (char *arg)
+int cfg_cmd (const char *arg)
{
char *key, *val;
char buffer[256];
@@ -430,7 +434,7 @@ int l4l_cfg_cmd (char *arg)
}
-char *l4l_cfg_list (char *section)
+char *cfg_list (const char *section)
{
int i, len;
char *key, *list;
@@ -461,7 +465,7 @@ char *l4l_cfg_list (char *section)
}
-static char *cfg_lookup (char *section, char *key)
+static char *cfg_lookup (const char *section, const char *key)
{
int len;
char *buffer;
@@ -496,16 +500,16 @@ static char *cfg_lookup (char *section, char *key)
}
-char *l4l_cfg_get_raw (char *section, char *key, char *defval)
+char *cfg_get_raw (const char *section, const char *key, const char *defval)
{
char *val=cfg_lookup(section, key);
if (val!=NULL) return val;
- return defval;
+ return (char *)defval;
}
-char *l4l_cfg_get (char *section, char *key, char *defval)
+char *cfg_get (const char *section, const char *key, const char *defval)
{
char *expression;
char *retval;
@@ -530,7 +534,7 @@ char *l4l_cfg_get (char *section, char *key, char *defval)
}
-int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int *value)
+int cfg_number (const char *section, const char *key, const int defval, const int min, const int max, int *value)
{
char *expression;
void *tree = NULL;
@@ -575,7 +579,7 @@ int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int
}
-static int cfg_check_source(char *file)
+static int cfg_check_source(const char *file)
{
/* as passwords and commands are stored in the config file,
* we will check that:
@@ -616,7 +620,7 @@ static int cfg_check_source(char *file)
}
-static int cfg_read (char *file)
+static int cfg_read (const char *file)
{
FILE *stream;
char buffer[256];
@@ -757,7 +761,7 @@ static int cfg_read (char *file)
}
-int l4l_cfg_init (char *file)
+int cfg_init (const char *file)
{
if (cfg_check_source(file) == -1) {
error("config file '%s' is insecure, aborting", file);
@@ -773,7 +777,7 @@ int l4l_cfg_init (char *file)
}
-char *l4l_cfg_source (void)
+char *cfg_source (void)
{
if (Config_File)
return Config_File;
@@ -782,7 +786,7 @@ char *l4l_cfg_source (void)
}
-int l4l_cfg_exit (void)
+int cfg_exit (void)
{
int i;
for (i=0; i<nConfig; i++) {
@@ -803,13 +807,3 @@ int l4l_cfg_exit (void)
return 0;
}
-
-int (*cfg_init) (char *source) = l4l_cfg_init;
-char *(*cfg_source) (void) = l4l_cfg_source;
-int (*cfg_cmd) (char *arg) = l4l_cfg_cmd;
-char *(*cfg_list) (char *section) = l4l_cfg_list;
-char *(*cfg_get_raw) (char *section, char *key, char *defval) = l4l_cfg_get_raw;
-char *(*cfg_get) (char *section, char *key, char *defval) = l4l_cfg_get;
-int (*cfg_number) (char *section, char *key, int defval,
- int min, int max, int *value) = l4l_cfg_number;
-int (*cfg_exit) (void) = l4l_cfg_exit;
diff --git a/cfg.h b/cfg.h
index 2a43eed..38b04e4 100644
--- a/cfg.h
+++ b/cfg.h
@@ -1,4 +1,4 @@
-/* $Id: cfg.h,v 1.10 2004/01/30 20:57:55 reinelt Exp $
+/* $Id: cfg.h,v 1.11 2004/06/20 10:09:53 reinelt Exp $
*
* config file stuff
*
@@ -22,6 +22,10 @@
*
*
* $Log: cfg.h,v $
+ * Revision 1.11 2004/06/20 10:09:53 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.10 2004/01/30 20:57:55 reinelt
* HD44780 patch from Martin Hejl
* dmalloc integrated
@@ -69,24 +73,14 @@
#ifndef _CFG_H_
#define _CFG_H_
-extern int (*cfg_init) (char *source);
-extern char *(*cfg_source) (void);
-extern int (*cfg_cmd) (char *arg);
-extern char *(*cfg_list) (char *section);
-extern char *(*cfg_get_raw) (char *section, char *key, char *defval);
-extern char *(*cfg_get) (char *section, char *key, char *defval);
-extern int (*cfg_number) (char *section, char *key, int defval,
- int min, int max, int *value);
-extern int (*cfg_exit) (void);
-
-int l4l_cfg_init (char *file);
-char *l4l_cfg_source (void);
-int l4l_cfg_cmd (char *arg);
-char *l4l_cfg_list (char *section);
-char *l4l_cfg_get_raw (char *section, char *key, char *defval);
-char *l4l_cfg_get (char *section, char *key, char *defval);
-int l4l_cfg_number (char *section, char *key, int defval,
- int min, int max, int *value);
-int l4l_cfg_exit (void);
+int cfg_init (const char *file);
+char *cfg_source (void);
+int cfg_cmd (const char *arg);
+char *cfg_list (const char *section);
+char *cfg_get_raw (const char *section, const char *key, const char *defval);
+char *cfg_get (const char *section, const char *key, const char *defval);
+int cfg_number (const char *section, const char *key, const int defval,
+ const int min, const int max, int *value);
+int cfg_exit (void);
#endif
diff --git a/debug.c b/debug.c
index 55bb16d..ecfe034 100644
--- a/debug.c
+++ b/debug.c
@@ -1,4 +1,4 @@
-/* $Id: debug.c,v 1.8 2004/05/26 11:37:36 reinelt Exp $
+/* $Id: debug.c,v 1.9 2004/06/20 10:09:54 reinelt Exp $
*
* debug() and error() functions
*
@@ -22,6 +22,10 @@
*
*
* $Log: debug.c,v $
+ * Revision 1.9 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.8 2004/05/26 11:37:36 reinelt
*
* Curses driver ported.
@@ -78,7 +82,7 @@ int running_background = 0;
int verbose_level = 0;
-void message (int level, const char *format, ...)
+void message (const int level, const char *format, ...)
{
va_list ap;
char buffer[256];
diff --git a/debug.h b/debug.h
index f730cb2..2a30d8c 100644
--- a/debug.h
+++ b/debug.h
@@ -1,4 +1,4 @@
-/* $Id: debug.h,v 1.7 2004/04/12 04:55:59 reinelt Exp $
+/* $Id: debug.h,v 1.8 2004/06/20 10:09:54 reinelt Exp $
*
* debug messages
*
@@ -22,6 +22,10 @@
*
*
* $Log: debug.h,v $
+ * Revision 1.8 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.7 2004/04/12 04:55:59 reinelt
* emitted a BIG FAT WARNING if msr.h could not be found (and therefore
* the gettimeofday() delay loop would be used)
@@ -62,7 +66,7 @@ extern int running_foreground;
extern int running_background;
extern int verbose_level;
-void message (int level, const char *format, ...);
+void message (const int level, const char *format, ...);
#define debug(args...) message (2, __FILE__ ": " args)
#define info(args...) message (1, args)
diff --git a/drv.c b/drv.c
index 4c2a6e8..55fdf62 100644
--- a/drv.c
+++ b/drv.c
@@ -1,4 +1,4 @@
-/* $Id: drv.c,v 1.18 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv.c,v 1.19 2004/06/20 10:09:54 reinelt Exp $
*
* new framework for display drivers
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv.c,v $
+ * Revision 1.19 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.18 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -230,7 +234,7 @@ int drv_list (void)
}
-int drv_init (char *section, char *driver, int quiet)
+int drv_init (const char *section, const char *driver, const int quiet)
{
int i;
for (i = 0; Driver[i]; i++) {
@@ -245,7 +249,7 @@ int drv_init (char *section, char *driver, int quiet)
}
-int drv_quit (int quiet)
+int drv_quit (const int quiet)
{
if (Drv->quit == NULL) return 0;
return Drv->quit(quiet);
diff --git a/drv.h b/drv.h
index 4635c3d..bd9b9b1 100644
--- a/drv.h
+++ b/drv.h
@@ -1,4 +1,4 @@
-/* $Id: drv.h,v 1.5 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv.h,v 1.6 2004/06/20 10:09:54 reinelt Exp $
*
* new framework for display drivers
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv.h,v $
+ * Revision 1.6 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -56,8 +60,8 @@
typedef struct DRIVER {
char *name;
int (*list) (void);
- int (*init) (char *section, int quiet);
- int (*quit) (int quiet);
+ int (*init) (const char *section, const int quiet);
+ int (*quit) (const int quiet);
} DRIVER;
@@ -67,7 +71,7 @@ typedef struct DRIVER {
extern char *output;
int drv_list (void);
-int drv_init (char *section, char *driver, int quiet);
-int drv_quit (int quiet);
+int drv_init (const char *section, const char *driver, const int quiet);
+int drv_quit (const int quiet);
#endif
diff --git a/drv_BeckmannEgle.c b/drv_BeckmannEgle.c
index 082fad7..9cbe418 100644
--- a/drv_BeckmannEgle.c
+++ b/drv_BeckmannEgle.c
@@ -1,4 +1,4 @@
-/* $Id: drv_BeckmannEgle.c,v 1.7 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_BeckmannEgle.c,v 1.8 2004/06/20 10:09:54 reinelt Exp $
*
* driver for Beckmann+Egle mini terminals
* Copyright 2000 Michael Reinelt <reinelt@eunet.at>
@@ -22,6 +22,10 @@
*
*
* $Log: drv_BeckmannEgle.c,v $
+ * Revision 1.8 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.7 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -116,7 +120,7 @@ static int Model;
// *** hardware dependant functions ***
// ****************************************
-static void drv_BE_write (int row, int col, unsigned char *data, int len)
+static void drv_BE_write (const int row, const int col, const unsigned char *data, const int len)
{
char cmd[] = "\033[y;xH";
@@ -128,7 +132,7 @@ static void drv_BE_write (int row, int col, unsigned char *data, int len)
}
-static void drv_BE_defchar (int ascii, unsigned char *matrix)
+static void drv_BE_defchar (const int ascii, const unsigned char *matrix)
{
int i;
char cmd[32];
@@ -156,7 +160,7 @@ static void drv_BE_clear (void)
}
-static int drv_BE_start (char *section, int quiet)
+static int drv_BE_start (const char *section, const int quiet)
{
int i;
char *model;
@@ -235,7 +239,7 @@ int drv_BE_list (void)
// initialize driver & display
-int drv_BE_init (char *section, int quiet)
+int drv_BE_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -295,7 +299,7 @@ int drv_BE_init (char *section, int quiet)
// close driver & display
-int drv_BE_quit (int quiet) {
+int drv_BE_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c
index fb75ac0..1102cbc 100644
--- a/drv_Crystalfontz.c
+++ b/drv_Crystalfontz.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.26 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.27 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for Crystalfontz display modules
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_Crystalfontz.c,v $
+ * Revision 1.27 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.26 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -223,7 +227,7 @@ static MODEL Models[] = {
// x^0 + x^5 + x^12
#define CRCPOLY 0x8408
-static unsigned short CRC (unsigned char *p, size_t len, unsigned short seed)
+static unsigned short CRC (const unsigned char *p, size_t len, unsigned short seed)
{
int i;
while (len--) {
@@ -234,12 +238,12 @@ static unsigned short CRC (unsigned char *p, size_t len, unsigned short seed)
return ~seed;
}
-static unsigned char LSB (unsigned short word)
+static unsigned char LSB (const unsigned short word)
{
return word & 0xff;
}
-static unsigned char MSB (unsigned short word)
+static unsigned char MSB (const unsigned short word)
{
return word >> 8;
}
@@ -363,7 +367,7 @@ static void drv_CF_timer (void *notused)
}
-static void drv_CF_send (int cmd, int len, char *data)
+static void drv_CF_send (const int cmd, int len, const unsigned char *data)
{
unsigned char buffer[22];
unsigned short crc;
@@ -389,7 +393,7 @@ static void drv_CF_send (int cmd, int len, char *data)
}
-static void drv_CF_write1 (int row, int col, unsigned char *data, int len)
+static void drv_CF_write1 (const int row, const int col, const unsigned char *data, const int len)
{
char cmd[3]="\021xy"; // set cursor position
@@ -405,46 +409,49 @@ static void drv_CF_write1 (int row, int col, unsigned char *data, int len)
}
-static void drv_CF_write2 (int row, int col, unsigned char *data, int len)
+static void drv_CF_write2 (const int row, const int col, const unsigned char *data, const int len)
{
+ int l = len;
+
// limit length
- if (col+len>16) len=16-col;
- if (len<0) len=0;
+ if (col + l > 16) l = 16 - col;
+ if (l < 0) l = 0;
// sanity check
- if (row>=2 || col+len>16) {
+ if (row >= 2 || col + l > 16) {
error ("%s: internal error: write outside linebuffer bounds!", Name);
return;
}
- memcpy (Line+16*row+col, data, len);
- drv_CF_send (7+row, 16, Line+16*row);
+ memcpy (Line + 16 * row + col, data, l);
+ drv_CF_send (7 + row, 16, Line + 16 * row);
}
-static void drv_CF_write3 (int row, int col, unsigned char *data, int len)
+static void drv_CF_write3 (const int row, const int col, const unsigned char *data, const int len)
{
+ int l = len;
char cmd[23];
// limit length
- if (col + len > 20) len = 20 - col;
- if (len < 0) len = 0;
+ if (col + l > 20) l = 20 - col;
+ if (l < 0) l = 0;
// sanity check
- if (row >= 2 || col + len > 20) {
+ if (row >= 2 || col + l > 20) {
error ("%s: internal error: write outside display bounds!", Name);
return;
}
cmd[0] = col;
cmd[1] = row;
- memcpy (cmd+2, data, len);
+ memcpy (cmd+2, data, l);
- drv_CF_send (31, len+2, cmd);
+ drv_CF_send (31, l+2, cmd);
}
-static void drv_CF_defchar1 (int ascii, unsigned char *matrix)
+static void drv_CF_defchar1 (const int ascii, const unsigned char *matrix)
{
int i;
char cmd[10]="\031n"; // set custom char bitmap
@@ -458,7 +465,7 @@ static void drv_CF_defchar1 (int ascii, unsigned char *matrix)
}
-static void drv_CF_defchar23 (int ascii, unsigned char *matrix)
+static void drv_CF_defchar23 (const int ascii, const unsigned char *matrix)
{
int i;
char buffer[9];
@@ -759,7 +766,7 @@ static void drv_CF_start_3 (void)
}
-static int drv_CF_start (char *section)
+static int drv_CF_start (const char *section)
{
int i;
char *model;
@@ -851,7 +858,7 @@ static int drv_CF_start (char *section)
// ****************************************
-static void plugin_contrast (RESULT *result, int argc, RESULT *argv[])
+static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[])
{
double contrast;
@@ -871,7 +878,7 @@ static void plugin_contrast (RESULT *result, int argc, RESULT *argv[])
}
-static void plugin_backlight (RESULT *result, int argc, RESULT *argv[])
+static void plugin_backlight (RESULT *result, const int argc, RESULT *argv[])
{
double backlight;
@@ -891,7 +898,7 @@ static void plugin_backlight (RESULT *result, int argc, RESULT *argv[])
}
-static void plugin_fan_pwm (RESULT *result, int argc, RESULT *argv[])
+static void plugin_fan_pwm (RESULT *result, const int argc, RESULT *argv[])
{
double pwm;
@@ -941,7 +948,7 @@ int drv_CF_list (void)
// initialize driver & display
-int drv_CF_init (char *section, int quiet)
+int drv_CF_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -1031,7 +1038,7 @@ int drv_CF_init (char *section, int quiet)
// close driver & display
-int drv_CF_quit (int quiet) {
+int drv_CF_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_Curses.c b/drv_Curses.c
index 7550e6b..7b1be2d 100644
--- a/drv_Curses.c
+++ b/drv_Curses.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Curses.c,v 1.5 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_Curses.c,v 1.6 2004/06/20 10:09:54 reinelt Exp $
*
* pure ncurses based text driver
*
@@ -26,6 +26,10 @@
*
*
* $Log: drv_Curses.c,v $
+ * Revision 1.6 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -96,8 +100,9 @@ static void drv_Curs_clear (void)
}
-static void drv_Curs_write (int row, int col, unsigned char *data, int len)
+static void drv_Curs_write (const int row, const int col, const unsigned char *data, const int len)
{
+ int l = len;
char *p;
while ((p = strpbrk(data, "\r\n")) != NULL) {
@@ -105,15 +110,15 @@ static void drv_Curs_write (int row, int col, unsigned char *data, int len)
}
if (col < DCOLS) {
- if (DCOLS-col < len ) len = DCOLS-col;
- mvwprintw(w, row+1 , col+1, "%.*s", DCOLS-col, data);
+ if (DCOLS-col < l ) l = DCOLS-col;
+ mvwprintw(w, row+1 , col+1, "%.*s", l, data);
wmove(w, DROWS+1, 0);
wrefresh(w);
}
}
-static void drv_Curs_defchar (int ascii, unsigned char *buffer)
+static void drv_Curs_defchar (const int ascii, const unsigned char *buffer)
{
// empty
}
@@ -161,7 +166,7 @@ int curses_error(char *buffer)
}
-static int drv_Curs_start (char *section, int quiet)
+static int drv_Curs_start (const char *section, const int quiet)
{
char *s;
@@ -245,7 +250,7 @@ int drv_Curs_list (void)
// initialize driver & display
-int drv_Curs_init (char *section, int quiet)
+int drv_Curs_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -296,7 +301,7 @@ int drv_Curs_init (char *section, int quiet)
// close driver & display
-int drv_Curs_quit (int quiet) {
+int drv_Curs_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_Cwlinux.c b/drv_Cwlinux.c
index 9d23088..00973bd 100644
--- a/drv_Cwlinux.c
+++ b/drv_Cwlinux.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Cwlinux.c,v 1.16 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_Cwlinux.c,v 1.17 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for Cwlinux display modules
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_Cwlinux.c,v $
+ * Revision 1.17 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.16 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -159,7 +163,7 @@ static MODEL Models[] = {
// *** hardware dependant functions ***
// ****************************************
-static void drv_CW_write (int row, int col, unsigned char *data, int len)
+static void drv_CW_write (const int row, const int col, const unsigned char *data, const int len)
{
char cmd[6]="\376Gxy\375";
@@ -171,7 +175,7 @@ static void drv_CW_write (int row, int col, unsigned char *data, int len)
}
-static void drv_CW1602_defchar (int ascii, unsigned char *buffer)
+static void drv_CW1602_defchar (const int ascii, const unsigned char *buffer)
{
int i;
char cmd[12]="\376Nn12345678\375";
@@ -186,7 +190,7 @@ static void drv_CW1602_defchar (int ascii, unsigned char *buffer)
}
-static void drv_CW12232_defchar (int ascii, unsigned char *buffer)
+static void drv_CW12232_defchar (const int ascii, const unsigned char *buffer)
{
int i, j;
char cmd[10]="\376Nn123456\375";
@@ -256,7 +260,7 @@ static int drv_CW_brightness (int brightness)
}
-static int drv_CW_start (char *section)
+static int drv_CW_start (const char *section)
{
int i;
char *model;
@@ -323,7 +327,7 @@ static int drv_CW_start (char *section)
// ****************************************
-static void plugin_brightness (RESULT *result, int argc, RESULT *argv[])
+static void plugin_brightness (RESULT *result, const int argc, RESULT *argv[])
{
double brightness;
@@ -370,7 +374,7 @@ int drv_CW_list (void)
// initialize driver & display
-int drv_CW_init (char *section, int quiet)
+int drv_CW_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -445,7 +449,7 @@ int drv_CW_init (char *section, int quiet)
// close driver & display
-int drv_CW_quit (int quiet) {
+int drv_CW_quit (const int quiet) {
info("%s: shutting down.", Name);
drv_generic_text_quit();
diff --git a/drv_HD44780.c b/drv_HD44780.c
index f71bab8..8dea43a 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.29 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.30 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for HD44780-based displays
*
@@ -29,6 +29,10 @@
*
*
* $Log: drv_HD44780.c,v $
+ * Revision 1.30 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.29 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -366,7 +370,7 @@ static void wait_for_busy_flag(int controller)
}
-static void drv_HD_nibble(unsigned char controller, unsigned char nibble)
+static void drv_HD_nibble(const unsigned char controller, const unsigned char nibble)
{
unsigned char enable;
@@ -397,7 +401,7 @@ static void drv_HD_nibble(unsigned char controller, unsigned char nibble)
}
-static void drv_HD_byte (unsigned char controller, unsigned char data, unsigned char RS)
+static void drv_HD_byte (const unsigned char controller, const unsigned char data, const unsigned char RS)
{
// send high nibble of the data
drv_HD_nibble (controller, ((data>>4)&0x0f)|RS);
@@ -410,7 +414,7 @@ static void drv_HD_byte (unsigned char controller, unsigned char data, unsigned
}
-static void drv_HD_command (unsigned char controller, unsigned char cmd, int delay)
+static void drv_HD_command (const unsigned char controller, const unsigned char cmd, const int delay)
{
unsigned char enable;
@@ -450,8 +454,9 @@ static void drv_HD_command (unsigned char controller, unsigned char cmd, int del
}
-static void drv_HD_data (unsigned char controller, char *string, int len, int delay)
+static void drv_HD_data (const unsigned char controller, const char *string, const int len, const int delay)
{
+ int l = len;
unsigned char enable;
// sanity check
@@ -474,7 +479,7 @@ static void drv_HD_data (unsigned char controller, char *string, int len, int de
ndelay(T_AS);
}
- while (len--) {
+ while (l--) {
if (UseBusy) {
wait_for_busy_flag(controller);
@@ -496,7 +501,7 @@ static void drv_HD_data (unsigned char controller, char *string, int len, int de
} else { // 4 bit mode
- while (len--) {
+ while (l--) {
if (UseBusy) wait_for_busy_flag(controller);
// send data with RS enabled
@@ -548,14 +553,14 @@ static void drv_HD_goto (int row, int col)
}
-static void drv_HD_write (int row, int col, unsigned char *data, int len)
+static void drv_HD_write (const int row, const int col, const unsigned char *data, const int len)
{
drv_HD_goto (row, col);
drv_HD_data (currController, data, len, T_EXEC);
}
-static void drv_HD_defchar (int ascii, unsigned char *matrix)
+static void drv_HD_defchar (const int ascii, const unsigned char *matrix)
{
int i;
unsigned char buffer[8];
@@ -590,7 +595,7 @@ static int drv_HD_brightness (int brightness)
// Fixme: GPO's
#if 0
-static void drv_HD_setGPO (int bits)
+static void drv_HD_setGPO (const int bits)
{
if (Lcd.gpos>0) {
@@ -608,7 +613,7 @@ static void drv_HD_setGPO (int bits)
#endif
-static int drv_HD_start (char *section, int quiet)
+static int drv_HD_start (const char *section, const int quiet)
{
char *model, *strsize;
int rows=-1, cols=-1, gpos=-1;
@@ -806,7 +811,7 @@ int drv_HD_list (void)
// initialize driver & display
-int drv_HD_init (char *section, int quiet)
+int drv_HD_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int asc255bug;
@@ -874,7 +879,7 @@ int drv_HD_init (char *section, int quiet)
// close driver & display
-int drv_HD_quit (int quiet) {
+int drv_HD_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_Image.c b/drv_Image.c
index 3d5b086..41daaeb 100644
--- a/drv_Image.c
+++ b/drv_Image.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Image.c,v 1.6 2004/06/19 08:20:19 reinelt Exp $
+/* $Id: drv_Image.c,v 1.7 2004/06/20 10:09:54 reinelt Exp $
*
* new style Image (PPM/PNG) Driver for LCD4Linux
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_Image.c,v $
+ * Revision 1.7 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.6 2004/06/19 08:20:19 reinelt
*
* compiler warning in image driver fixed
@@ -329,7 +333,7 @@ static void drv_IMG_timer (void *notused)
}
-static void drv_IMG_blit(int row, int col, int height, int width)
+static void drv_IMG_blit(const int row, const int col, const int height, const int width)
{
int r, c;
@@ -345,7 +349,7 @@ static void drv_IMG_blit(int row, int col, int height, int width)
}
-static int drv_IMG_start (char *section)
+static int drv_IMG_start (const char *section)
{
char *s;
@@ -485,7 +489,7 @@ int drv_IMG_list (void)
// initialize driver & display
-int drv_IMG_init (char *section, int quiet)
+int drv_IMG_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -525,7 +529,7 @@ int drv_IMG_init (char *section, int quiet)
// close driver & display
-int drv_IMG_quit (int quiet) {
+int drv_IMG_quit (const int quiet) {
info("%s: shutting down.", Name);
drv_generic_graphic_quit();
diff --git a/drv_M50530.c b/drv_M50530.c
index 2749912..cddf0cc 100644
--- a/drv_M50530.c
+++ b/drv_M50530.c
@@ -1,4 +1,4 @@
-/* $Id: drv_M50530.c,v 1.11 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_M50530.c,v 1.12 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for M50530-based displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_M50530.c,v $
+ * Revision 1.12 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.11 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -138,7 +142,7 @@ static MODEL Models[] = {
// *** hardware dependant functions ***
// ****************************************
-static void drv_M5_command (unsigned int cmd, int delay)
+static void drv_M5_command (const unsigned int cmd, const int delay)
{
// put data on DB1..DB8
@@ -170,23 +174,24 @@ static void drv_M5_clear (void)
}
-static void drv_M5_write (int row, int col, unsigned char *data, int len)
+static void drv_M5_write (const int row, const int col, const unsigned char *data, const int len)
{
+ int l = len;
unsigned int cmd;
unsigned int pos;
- pos=row*48+col;
- if (row>3) pos-=168;
- drv_M5_command (0x300|pos, 20);
+ pos = row * 48 + col;
+ if (row > 3) pos -= 168;
+ drv_M5_command (0x300 | pos, 20);
- while (len--) {
- cmd=*data++;
- drv_M5_command (0x100|cmd, 20);
+ while (l--) {
+ cmd = *data++;
+ drv_M5_command (0x100 | cmd, 20);
}
}
-static void drv_M5_defchar (int ascii, unsigned char *matrix)
+static void drv_M5_defchar (const int ascii, const unsigned char *matrix)
{
int i;
@@ -202,7 +207,7 @@ static void drv_M5_defchar (int ascii, unsigned char *matrix)
// Fixme: GPO's
#if 0
-static void drv_M5_setGPO (int bits)
+static void drv_M5_setGPO (const int bits)
{
if (Lcd.gpos>0) {
@@ -220,7 +225,7 @@ static void drv_M5_setGPO (int bits)
#endif
-static int drv_M5_start (char *section, int quiet)
+static int drv_M5_start (const char *section, const int quiet)
{
char *model, *s;
int rows=-1, cols=-1, gpos=-1;
@@ -329,7 +334,7 @@ int drv_M5_list (void)
// initialize driver & display
-int drv_M5_init (char *section, int quiet)
+int drv_M5_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -388,7 +393,7 @@ int drv_M5_init (char *section, int quiet)
// close driver & display
-int drv_M5_quit (int quiet) {
+int drv_M5_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 6e7cbc8..0b9af92 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.32 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.33 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.33 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.32 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -254,7 +258,7 @@ static void drv_MO_clear (void)
}
-static void drv_MO_write (int row, int col, unsigned char *data, int len)
+static void drv_MO_write (const int row, const int col, const unsigned char *data, const int len)
{
char cmd[5]="\376Gyx";
@@ -266,7 +270,7 @@ static void drv_MO_write (int row, int col, unsigned char *data, int len)
}
-static void drv_MO_defchar (int ascii, unsigned char *matrix)
+static void drv_MO_defchar (const int ascii, const unsigned char *matrix)
{
int i;
char cmd[11]="\376N";
@@ -420,7 +424,7 @@ static int drv_MO_rpm (int num)
}
-static int drv_MO_start (char *section, int quiet)
+static int drv_MO_start (const char *section, const int quiet)
{
int i;
char *model;
@@ -527,7 +531,7 @@ static int drv_MO_start (char *section, int quiet)
// ****************************************
-static void plugin_contrast (RESULT *result, int argc, RESULT *argv[])
+static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[])
{
double contrast;
@@ -547,7 +551,7 @@ static void plugin_contrast (RESULT *result, int argc, RESULT *argv[])
}
-static void plugin_backlight (RESULT *result, int argc, RESULT *argv[])
+static void plugin_backlight (RESULT *result, const int argc, RESULT *argv[])
{
double backlight;
@@ -567,7 +571,7 @@ static void plugin_backlight (RESULT *result, int argc, RESULT *argv[])
}
-static void plugin_gpo (RESULT *result, int argc, RESULT *argv[])
+static void plugin_gpo (RESULT *result, const int argc, RESULT *argv[])
{
double gpo;
@@ -587,7 +591,7 @@ static void plugin_gpo (RESULT *result, int argc, RESULT *argv[])
}
-static void plugin_pwm (RESULT *result, int argc, RESULT *argv[])
+static void plugin_pwm (RESULT *result, const int argc, RESULT *argv[])
{
double pwm;
@@ -643,7 +647,7 @@ int drv_MO_list (void)
// initialize driver & display
-int drv_MO_init (char *section, int quiet)
+int drv_MO_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -707,7 +711,7 @@ int drv_MO_init (char *section, int quiet)
// close driver & display
-int drv_MO_quit (int quiet) {
+int drv_MO_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_MilfordInstruments.c b/drv_MilfordInstruments.c
index 8e9e6bb..396ce86 100644
--- a/drv_MilfordInstruments.c
+++ b/drv_MilfordInstruments.c
@@ -1,4 +1,4 @@
-/* $Id: drv_MilfordInstruments.c,v 1.9 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_MilfordInstruments.c,v 1.10 2004/06/20 10:09:54 reinelt Exp $
*
* driver for Milford Instruments 'BPK' piggy-back serial interface board
* for standard Hitachi 44780 compatible lcd modules.
@@ -27,6 +27,10 @@
*
*
* $Log: drv_MilfordInstruments.c,v $
+ * Revision 1.10 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.9 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -118,7 +122,7 @@ static void drv_MI_clear (void)
}
-static void drv_MI_write (int row, int col, unsigned char *data, int len)
+static void drv_MI_write (const int row, const int col, const unsigned char *data, const int len)
{
char cmd[2] = "\376x";
char ddbase = 128;
@@ -135,7 +139,7 @@ static void drv_MI_write (int row, int col, unsigned char *data, int len)
}
-static void drv_MI_defchar (int ascii, unsigned char *matrix)
+static void drv_MI_defchar (const int ascii, const unsigned char *matrix)
{
int i;
char cmd[10]="\376x";
@@ -150,7 +154,7 @@ static void drv_MI_defchar (int ascii, unsigned char *matrix)
}
-static int drv_MI_start (char *section, int quiet)
+static int drv_MI_start (const char *section, const int quiet)
{
int i;
char *model;
@@ -225,7 +229,7 @@ int drv_MI_list (void)
// initialize driver & display
-int drv_MI_init (char *section, int quiet)
+int drv_MI_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -285,7 +289,7 @@ int drv_MI_init (char *section, int quiet)
// close driver & display
-int drv_MI_quit (int quiet) {
+int drv_MI_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_NULL.c b/drv_NULL.c
index daafeed..1527c65 100644
--- a/drv_NULL.c
+++ b/drv_NULL.c
@@ -1,4 +1,4 @@
-/* $Id: drv_NULL.c,v 1.3 2004/06/06 06:51:59 reinelt Exp $
+/* $Id: drv_NULL.c,v 1.4 2004/06/20 10:09:54 reinelt Exp $
*
* NULL driver (for testing)
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_NULL.c,v $
+ * Revision 1.4 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.3 2004/06/06 06:51:59 reinelt
*
* do not display end splash screen if quiet=1
@@ -63,26 +67,26 @@
#include "drv_generic_text.h"
-static char Name[]="NULL";
+static char Name[] = "NULL";
// ****************************************
// *** hardware dependant functions ***
// ****************************************
-static void drv_NULL_write (int row, int col, unsigned char *data, int len)
+static void drv_NULL_write (const int row, const int col, const unsigned char *data, const int len)
{
// empty
}
-static void drv_NULL_defchar (int ascii, unsigned char *matrix)
+static void drv_NULL_defchar (const int ascii, const unsigned char *matrix)
{
// empty
}
-static int drv_NULL_start (char *section)
+static int drv_NULL_start (const char *section)
{
char *s;
@@ -132,7 +136,7 @@ int drv_NULL_list (void)
// initialize driver & display
-int drv_NULL_init (char *section, int quiet)
+int drv_NULL_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -182,7 +186,7 @@ int drv_NULL_init (char *section, int quiet)
// close driver & display
-int drv_NULL_quit (int quiet) {
+int drv_NULL_quit (const int quiet) {
info("%s: shutting down.", Name);
drv_generic_text_quit();
diff --git a/drv_T6963.c b/drv_T6963.c
index 870d274..e256075 100644
--- a/drv_T6963.c
+++ b/drv_T6963.c
@@ -1,4 +1,4 @@
-/* $Id: drv_T6963.c,v 1.9 2004/06/17 06:23:39 reinelt Exp $
+/* $Id: drv_T6963.c,v 1.10 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for T6963-based displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_T6963.c,v $
+ * Revision 1.10 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.9 2004/06/17 06:23:39 reinelt
*
* hash handling rewritten to solve performance issues
@@ -199,7 +203,7 @@ static void drv_T6_status2 (void)
}
-static void drv_T6_write_cmd (unsigned char cmd)
+static void drv_T6_write_cmd (const unsigned char cmd)
{
// wait until the T6963 is idle
drv_T6_status1();
@@ -221,7 +225,7 @@ static void drv_T6_write_cmd (unsigned char cmd)
}
-static void drv_T6_write_data (unsigned char data)
+static void drv_T6_write_data (const unsigned char data)
{
// wait until the T6963 is idle
drv_T6_status1();
@@ -252,7 +256,7 @@ static void drv_T6_write_data (unsigned char data)
}
-static void drv_T6_write_auto (unsigned char data)
+static void drv_T6_write_auto (const unsigned char data)
{
// wait until the T6963 is idle
drv_T6_status2();
@@ -284,14 +288,14 @@ static void drv_T6_write_auto (unsigned char data)
#if 0 // not used
-static void drv_T6_send_byte (unsigned char cmd, unsigned char data)
+static void drv_T6_send_byte (const unsigned char cmd, const unsigned char data)
{
drv_T6_write_data(data);
drv_T6_write_cmd(cmd);
}
#endif
-static void drv_T6_send_word (unsigned char cmd, unsigned short data)
+static void drv_T6_send_word (const unsigned char cmd, const unsigned short data)
{
drv_T6_write_data(data&0xff);
drv_T6_write_data(data>>8);
@@ -299,7 +303,7 @@ static void drv_T6_send_word (unsigned char cmd, unsigned short data)
}
-static void drv_T6_clear(unsigned short addr, int len)
+static void drv_T6_clear(const unsigned short addr, const int len)
{
int i;
@@ -317,7 +321,7 @@ static void drv_T6_clear(unsigned short addr, int len)
}
-static void drv_T6_copy(unsigned short addr, unsigned char *data, int len)
+static void drv_T6_copy(const unsigned short addr, const unsigned char *data, const int len)
{
int i;
@@ -335,7 +339,7 @@ static void drv_T6_copy(unsigned short addr, unsigned char *data, int len)
}
-static void drv_T6_blit(int row, int col, int height, int width)
+static void drv_T6_blit(const int row, const int col, const int height, const int width)
{
int i, j, e, m;
int r, c;
@@ -370,7 +374,7 @@ static void drv_T6_blit(int row, int col, int height, int width)
}
}
-static int drv_T6_start (char *section)
+static int drv_T6_start (const char *section)
{
char *model, *s;
int rows, TROWS, TCOLS;
@@ -529,7 +533,7 @@ int drv_T6_list (void)
// initialize driver & display
-int drv_T6_init (char *section, int quiet)
+int drv_T6_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -578,7 +582,7 @@ int drv_T6_init (char *section, int quiet)
// close driver & display
-int drv_T6_quit (int quiet) {
+int drv_T6_quit (const int quiet) {
info("%s: shutting down.", Name);
diff --git a/drv_USBLCD.c b/drv_USBLCD.c
index 52355b6..b625b53 100644
--- a/drv_USBLCD.c
+++ b/drv_USBLCD.c
@@ -1,4 +1,4 @@
-/* $Id: drv_USBLCD.c,v 1.11 2004/06/19 08:20:19 reinelt Exp $
+/* $Id: drv_USBLCD.c,v 1.12 2004/06/20 10:09:54 reinelt Exp $
*
* new style driver for USBLCD displays
*
@@ -26,6 +26,10 @@
*
*
* $Log: drv_USBLCD.c,v $
+ * Revision 1.12 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.11 2004/06/19 08:20:19 reinelt
*
* compiler warning in image driver fixed
@@ -148,7 +152,7 @@ static void drv_UL_send ()
}
-static void drv_UL_command (unsigned char cmd)
+static void drv_UL_command (const unsigned char cmd)
{
*BufPtr++='\0';
*BufPtr++=cmd;
@@ -163,7 +167,7 @@ static void drv_UL_clear (void)
}
-static void drv_UL_write (int row, int col, unsigned char *data, int len)
+static void drv_UL_write (const int row, const int col, const unsigned char *data, int len)
{
int pos = (row%2)*64 + (row/2)*20 + col;
drv_UL_command (0x80|pos);
@@ -176,7 +180,7 @@ static void drv_UL_write (int row, int col, unsigned char *data, int len)
drv_UL_send();
}
-static void drv_UL_defchar (int ascii, unsigned char *matrix)
+static void drv_UL_defchar (const int ascii, const unsigned char *matrix)
{
int i;
@@ -191,7 +195,7 @@ static void drv_UL_defchar (int ascii, unsigned char *matrix)
}
-static int drv_UL_start (char *section, int quiet)
+static int drv_UL_start (const char *section, const int quiet)
{
int rows=-1, cols=-1;
int major, minor;
@@ -331,7 +335,7 @@ int drv_UL_list (void)
// initialize driver & display
-int drv_UL_init (char *section, int quiet)
+int drv_UL_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int asc255bug;
@@ -398,7 +402,7 @@ int drv_UL_init (char *section, int quiet)
// close driver & display
-int drv_UL_quit (int quiet)
+int drv_UL_quit (const int quiet)
{
info("%s: shutting down.", Name);
diff --git a/drv_X11.c b/drv_X11.c
index db34906..78a2563 100644
--- a/drv_X11.c
+++ b/drv_X11.c
@@ -1,4 +1,4 @@
-/* $Id: drv_X11.c,v 1.5 2004/06/08 21:46:38 reinelt Exp $
+/* $Id: drv_X11.c,v 1.6 2004/06/20 10:09:54 reinelt Exp $
*
* new style X11 Driver for LCD4Linux
*
@@ -26,6 +26,10 @@
*
*
* $Log: drv_X11.c,v $
+ * Revision 1.6 2004/06/20 10:09:54 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2004/06/08 21:46:38 reinelt
*
* splash screen for X11 driver (and generic graphic driver)
@@ -115,7 +119,7 @@ static Pixmap pm;
// *** hardware dependant functions ***
// ****************************************
-static void drv_X11_blit(int row, int col, int height, int width)
+static void drv_X11_blit(const int row, const int col, const int height, const int width)
{
int r, c;
int dirty = 0;
@@ -138,7 +142,7 @@ static void drv_X11_blit(int row, int col, int height, int width)
}
-static void drv_X11_expose(int x, int y, int width, int height)
+static void drv_X11_expose(const int x, const int y, const int width, const int height)
{
/*
* theory of operation:
@@ -181,7 +185,7 @@ static void drv_X11_timer (void *notused)
}
-static int drv_X11_start (char *section)
+static int drv_X11_start (const char *section)
{
char *s;
XSetWindowAttributes wa;
@@ -350,7 +354,7 @@ int drv_X11_list (void)
// initialize driver & display
-int drv_X11_init (char *section, int quiet)
+int drv_X11_init (const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
@@ -403,7 +407,7 @@ int drv_X11_init (char *section, int quiet)
// close driver & display
-int drv_X11_quit (int quiet) {
+int drv_X11_quit (const int quiet) {
info("%s: shutting down.", Name);
drv_generic_graphic_quit();
diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c
index 1ca96e0..a571024 100644
--- a/drv_generic_graphic.c
+++ b/drv_generic_graphic.c
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_graphic.c,v $
+ * Revision 1.10 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.9 2004/06/09 06:40:29 reinelt
*
* splash screen for T6963 driver
@@ -175,7 +179,7 @@ int drv_generic_graphic_clear (void)
// *** generic text handling ***
// ****************************************
-static void drv_generic_graphic_render (int row, int col, unsigned char *txt)
+static void drv_generic_graphic_render (const int row, const int col, const unsigned char *txt)
{
int c, r, x, y;
int len = strlen(txt);
@@ -206,7 +210,7 @@ static void drv_generic_graphic_render (int row, int col, unsigned char *txt)
// say hello to the user
-int drv_generic_graphic_greet (char *msg1, char *msg2)
+int drv_generic_graphic_greet (const char *msg1, const char *msg2)
{
char *line1[] = { "* LCD4Linux " VERSION " *",
"LCD4Linux " VERSION,
@@ -393,10 +397,10 @@ int drv_generic_graphic_bar_draw (WIDGET *W)
// *** generic init/quit ***
// ****************************************
-int drv_generic_graphic_init (char *section, char *driver)
+int drv_generic_graphic_init (const char *section, const char *driver)
{
- Section=section;
- Driver=driver;
+ Section = (char*)section;
+ Driver = (char*)driver;
// init layout framebuffer
LROWS = 0;
diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h
index ef7ee5a..e868fb0 100644
--- a/drv_generic_graphic.h
+++ b/drv_generic_graphic.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_graphic.h,v 1.4 2004/06/08 21:46:38 reinelt Exp $
+/* $Id: drv_generic_graphic.h,v 1.5 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for graphic displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_graphic.h,v $
+ * Revision 1.5 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.4 2004/06/08 21:46:38 reinelt
*
* splash screen for X11 driver (and generic graphic driver)
@@ -60,12 +64,12 @@ extern int XRES, YRES; // pixel width/height of one char
extern unsigned char *drv_generic_graphic_FB;
// these functions must be implemented by the real driver
-void (*drv_generic_graphic_real_blit)(int row, int col, int height, int width);
+void (*drv_generic_graphic_real_blit)(const int row, const int col, const int height, const int width);
// generic functions and widget callbacks
-int drv_generic_graphic_init (char *section, char *driver);
+int drv_generic_graphic_init (const char *section, const char *driver);
int drv_generic_graphic_clear (void);
-int drv_generic_graphic_greet (char *msg1, char *msg2);
+int drv_generic_graphic_greet (const char *msg1, const char *msg2);
int drv_generic_graphic_draw (WIDGET *W);
int drv_generic_graphic_icon_draw (WIDGET *W);
int drv_generic_graphic_bar_draw (WIDGET *W);
diff --git a/drv_generic_parport.c b/drv_generic_parport.c
index a4b7643..277cf5e 100644
--- a/drv_generic_parport.c
+++ b/drv_generic_parport.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_parport.c,v 1.5 2004/04/12 05:14:42 reinelt Exp $
+/* $Id: drv_generic_parport.c,v 1.6 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for serial and parport access
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_parport.c,v $
+ * Revision 1.6 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2004/04/12 05:14:42 reinelt
* another BIG FAT WARNING on the use of raw ports instead of ppdev
*
@@ -115,12 +119,12 @@ static int PPfd=-1;
#endif
-int drv_generic_parport_open (char *section, char *driver)
+int drv_generic_parport_open (const char *section, const char *driver)
{
char *s, *e;
- Section=section;
- Driver=driver;
+ Section = (char*)section;
+ Driver = (char*)driver;
udelay_init();
@@ -230,7 +234,7 @@ int drv_generic_parport_close (void)
}
-unsigned char drv_generic_parport_wire_ctrl (char *name, unsigned char *deflt)
+unsigned char drv_generic_parport_wire_ctrl (const char *name, const unsigned char *deflt)
{
unsigned char w;
char wire[256];
@@ -275,7 +279,7 @@ unsigned char drv_generic_parport_wire_ctrl (char *name, unsigned char *deflt)
}
-unsigned char drv_generic_parport_wire_data (char *name, unsigned char *deflt)
+unsigned char drv_generic_parport_wire_data (const char *name, const unsigned char *deflt)
{
unsigned char w;
char wire[256];
@@ -305,7 +309,7 @@ unsigned char drv_generic_parport_wire_data (char *name, unsigned char *deflt)
}
-void drv_generic_parport_direction (int direction)
+void drv_generic_parport_direction (const int direction)
{
#ifdef WITH_PPDEV
if (PPdev) {
@@ -320,32 +324,34 @@ void drv_generic_parport_direction (int direction)
}
-void drv_generic_parport_control (unsigned char mask, unsigned char value)
+void drv_generic_parport_control (const unsigned char mask, const unsigned char value)
{
+ unsigned char val;
+
// 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!
- value = mask & (value ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD));
+ val = mask & (value ^ (PARPORT_CONTROL_STROBE|PARPORT_CONTROL_SELECT|PARPORT_CONTROL_AUTOFD));
#ifdef WITH_PPDEV
if (PPdev) {
struct ppdev_frob_struct frob;
frob.mask=mask;
- frob.val=value;
+ frob.val=val;
ioctl (PPfd, PPFCONTROL, &frob);
} else
#endif
{
// code stolen from linux/parport_pc.h
- ctr = (ctr & ~mask) ^ value;
+ ctr = (ctr & ~mask) ^ val;
outb (ctr, Port+2);
}
}
-void drv_generic_parport_toggle (unsigned char bits, int level, int delay)
+void drv_generic_parport_toggle (const unsigned char bits, const int level, const int delay)
{
unsigned char value1, value2;
@@ -394,7 +400,7 @@ void drv_generic_parport_toggle (unsigned char bits, int level, int delay)
}
-void drv_generic_parport_data (unsigned char data)
+void drv_generic_parport_data (const unsigned char data)
{
#ifdef WITH_PPDEV
if (PPdev) {
diff --git a/drv_generic_parport.h b/drv_generic_parport.h
index 5e35ca6..7e23205 100644
--- a/drv_generic_parport.h
+++ b/drv_generic_parport.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_parport.h,v 1.2 2004/01/20 15:32:49 reinelt Exp $
+/* $Id: drv_generic_parport.h,v 1.3 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for parallel port displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_parport.h,v $
+ * Revision 1.3 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.2 2004/01/20 15:32:49 reinelt
* first version of Next Generation HD44780 (untested! but it compiles...)
* some cleanup in the other drivers
@@ -77,14 +81,14 @@
#ifndef _DRV_GENERIC_PARPORT_H_
#define _DRV_GENERIC_PARPORT_H_
-int drv_generic_parport_open (char *section, char *driver);
+int drv_generic_parport_open (const char *section, const char *driver);
int drv_generic_parport_close (void);
-unsigned char drv_generic_parport_wire_ctrl (char *name, unsigned char *deflt);
-unsigned char drv_generic_parport_wire_data (char *name, unsigned char *deflt);
-void drv_generic_parport_direction (int direction);
-void drv_generic_parport_control (unsigned char mask, unsigned char value);
-void drv_generic_parport_toggle (unsigned char bit, int level, int delay);
-void drv_generic_parport_data (unsigned char data);
+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);
+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);
+void drv_generic_parport_data (const unsigned char data);
unsigned char drv_generic_parport_read (void);
void drv_generic_parport_debug (void);
diff --git a/drv_generic_serial.c b/drv_generic_serial.c
index 0548981..b1e1fef 100644
--- a/drv_generic_serial.c
+++ b/drv_generic_serial.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_serial.c,v 1.11 2004/06/01 06:45:30 reinelt Exp $
+/* $Id: drv_generic_serial.c,v 1.12 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for serial and usbserial displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_serial.c,v $
+ * Revision 1.12 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.11 2004/06/01 06:45:30 reinelt
*
* some Fixme's processed
@@ -125,6 +129,7 @@
#include "drv_generic_serial.h"
+static char *Section;
static char *Driver;
static char *Port;
static speed_t Speed;
@@ -138,7 +143,7 @@ static int Device=-1;
// *** generic serial/USB communication ***
// ****************************************
-static pid_t drv_generic_serial_lock_port (char *Port)
+static pid_t drv_generic_serial_lock_port (const char *Port)
{
char lockfile[256];
char tempfile[256];
@@ -236,7 +241,7 @@ static pid_t drv_generic_serial_lock_port (char *Port)
}
-static pid_t drv_generic_serial_unlock_port (char *Port)
+static pid_t drv_generic_serial_unlock_port (const char *Port)
{
char lockfile[256];
char *port, *p;
@@ -259,13 +264,14 @@ static pid_t drv_generic_serial_unlock_port (char *Port)
}
-int drv_generic_serial_open (char *section, char *driver, unsigned int flags)
+int drv_generic_serial_open (const char *section, const char *driver, const unsigned int flags)
{
int i, fd;
pid_t pid;
struct termios portset;
- Driver = driver;
+ Section = (char*)section;
+ Driver = (char*)driver;
Port=cfg_get(section, "Port", NULL);
if (Port==NULL || *Port=='\0') {
@@ -326,7 +332,7 @@ int drv_generic_serial_open (char *section, char *driver, unsigned int flags)
}
-int drv_generic_serial_poll (unsigned char *string, int len)
+int drv_generic_serial_poll (unsigned char *string, const int len)
{
int ret;
if (Device == -1) return -1;
@@ -338,7 +344,7 @@ int drv_generic_serial_poll (unsigned char *string, int len)
}
-int drv_generic_serial_read (unsigned char *string, int len)
+int drv_generic_serial_read (unsigned char *string, const int len)
{
int run, ret;
@@ -357,7 +363,7 @@ int drv_generic_serial_read (unsigned char *string, int len)
}
-void drv_generic_serial_write (unsigned char *string, int len)
+void drv_generic_serial_write (const unsigned char *string, const int len)
{
int run, ret;
diff --git a/drv_generic_serial.h b/drv_generic_serial.h
index 42c9bb5..c90333a 100644
--- a/drv_generic_serial.h
+++ b/drv_generic_serial.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_serial.h,v 1.5 2004/06/01 06:45:30 reinelt Exp $
+/* $Id: drv_generic_serial.h,v 1.6 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for serial and usbserial displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_serial.h,v $
+ * Revision 1.6 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2004/06/01 06:45:30 reinelt
*
* some Fixme's processed
@@ -59,10 +63,10 @@
#ifndef _DRV_GENERIC_SERIALH_
#define _DRV_GENERIC_SERIAL_H_
-int drv_generic_serial_open (char *section, char *driver, unsigned int flags);
-int drv_generic_serial_poll (unsigned char *string, int len);
-int drv_generic_serial_read (unsigned char *string, int len);
-void drv_generic_serial_write (unsigned char *string, int len);
+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_close (void);
#endif
diff --git a/drv_generic_text.c b/drv_generic_text.c
index a8d1d1d..bd93849 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.17 2004/06/05 06:41:40 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.18 2004/06/20 10:09:55 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_text.c,v $
+ * Revision 1.18 2004/06/20 10:09:55 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.17 2004/06/05 06:41:40 reinelt
*
* chancged splash screen again
@@ -278,11 +282,11 @@ static void drv_generic_text_resizeFB (int rows, int cols)
// *** generic text handling ***
// ****************************************
-int drv_generic_text_init (char *section, char *driver)
+int drv_generic_text_init (const char *section, const char *driver)
{
- Section=section;
- Driver=driver;
+ Section = (char*)section;
+ Driver = (char*)driver;
// init display framebuffer
DisplayFB = (char*)malloc(DCOLS*DROWS*sizeof(char));
@@ -305,7 +309,7 @@ int drv_generic_text_init (char *section, char *driver)
// say hello to the user
-int drv_generic_text_greet (char *msg1, char *msg2)
+int drv_generic_text_greet (const char *msg1, const char *msg2)
{
int i;
int flag = 0;
@@ -513,7 +517,7 @@ static void drv_generic_text_bar_clear(void)
}
-int drv_generic_text_bar_init (int single_segments)
+int drv_generic_text_bar_init (const int single_segments)
{
if (BarFB) free (BarFB);
@@ -533,7 +537,7 @@ int drv_generic_text_bar_init (int single_segments)
}
-void drv_generic_text_bar_add_segment(int val1, int val2, DIRECTION dir, int ascii)
+void drv_generic_text_bar_add_segment(const int val1, const int val2, const DIRECTION dir, const int ascii)
{
Segment[fSegment].val1=val1;
Segment[fSegment].val2=val2;
@@ -546,7 +550,7 @@ void drv_generic_text_bar_add_segment(int val1, int val2, DIRECTION dir, int asc
}
-static void drv_generic_text_bar_create_bar (int row, int col, DIRECTION dir, int len, int val1, int val2)
+static void drv_generic_text_bar_create_bar (int row, int col, const DIRECTION dir, int len, int val1, int val2)
{
int rev=0;
@@ -650,7 +654,7 @@ static void drv_generic_text_bar_create_segments (void)
}
-static int drv_generic_text_bar_segment_error (int i, int j)
+static int drv_generic_text_bar_segment_error (const int i, const int j)
{
int res;
int i1, i2, j1, j2;
diff --git a/drv_generic_text.h b/drv_generic_text.h
index 9bf9b4a..5740de5 100644
--- a/drv_generic_text.h
+++ b/drv_generic_text.h
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.12 2004/06/05 06:41:40 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.13 2004/06/20 10:09:56 reinelt Exp $
*
* generic driver helper for text-based displays
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_generic_text.h,v $
+ * Revision 1.13 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.12 2004/06/05 06:41:40 reinelt
*
* chancged splash screen again
@@ -91,20 +95,19 @@ extern int CHARS, CHAR0; // number of user-defineable characters, ASCII of first
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)(int row, int col, unsigned char *data, int len);
-void (*drv_generic_text_real_defchar)(int ascii, unsigned char *buffer);
+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);
// generic functions and widget callbacks
-int drv_generic_text_init (char *section, char *driver);
-int drv_generic_text_greet (char *msg1, char *msg2);
+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);
int drv_generic_text_icon_init (void);
int drv_generic_text_icon_draw (WIDGET *W);
-int drv_generic_text_bar_init (int single_segments);
-void drv_generic_text_bar_add_segment (int val1, int val2, DIRECTION dir, int ascii);
+int drv_generic_text_bar_init (const int single_segments);
+void drv_generic_text_bar_add_segment (const int val1, const int val2, const DIRECTION dir, const int ascii);
int drv_generic_text_bar_draw (WIDGET *W);
int drv_generic_text_quit (void);
-
#endif
diff --git a/evaluator.c b/evaluator.c
index 9902d03..2be3b7e 100644
--- a/evaluator.c
+++ b/evaluator.c
@@ -1,4 +1,4 @@
-/* $Id: evaluator.c,v 1.19 2004/04/12 11:12:25 reinelt Exp $
+/* $Id: evaluator.c,v 1.20 2004/06/20 10:09:56 reinelt Exp $
*
* expression evaluation
*
@@ -23,6 +23,10 @@
*
*
* $Log: evaluator.c,v $
+ * Revision 1.20 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.19 2004/04/12 11:12:25 reinelt
* added plugin_isdn, removed old ISDN client
* fixed some real bad bugs in the evaluator
@@ -337,7 +341,7 @@ static RESULT* DupResult (RESULT *result)
}
-RESULT* SetResult (RESULT **result, int type, void *value)
+RESULT* SetResult (RESULT **result, const int type, const void *value)
{
if (*result == NULL) {
if ((*result = NewResult()) == NULL)
@@ -422,7 +426,7 @@ char* R2S (RESULT *result)
}
-static VARIABLE *FindVariable (char *name)
+static VARIABLE *FindVariable (const char *name)
{
int i;
@@ -435,7 +439,7 @@ static VARIABLE *FindVariable (char *name)
}
-int SetVariable (char *name, RESULT *value)
+int SetVariable (const char *name, RESULT *value)
{
VARIABLE *V;
@@ -455,7 +459,7 @@ int SetVariable (char *name, RESULT *value)
}
-int SetVariableNumeric (char *name, double value)
+int SetVariableNumeric (const char *name, const double value)
{
RESULT result = {0, 0, 0, NULL};
RESULT *rp = &result;
@@ -466,7 +470,7 @@ int SetVariableNumeric (char *name, double value)
}
-int SetVariableString (char *name, char *value)
+int SetVariableString (const char *name, const char *value)
{
RESULT result = {0, 0, 0, NULL};
RESULT *rp = &result;
@@ -491,7 +495,7 @@ void DeleteVariables(void)
}
-static FUNCTION* FindFunction (char *name)
+static FUNCTION* FindFunction (const char *name)
{
int i;
@@ -504,7 +508,7 @@ static FUNCTION* FindFunction (char *name)
}
-int AddFunction (char *name, int argc, void (*func)())
+int AddFunction (const char *name, const int argc, void (*func)())
{
nFunction++;
Function = realloc(Function, nFunction*sizeof(FUNCTION));
@@ -1174,13 +1178,13 @@ static int EvalTree (NODE *Root)
}
-int Compile (char* expression, void **tree)
+int Compile (const char* expression, void **tree)
{
NODE *Root;
*tree = NULL;
- Expression = expression;
+ Expression = (char*) expression;
ExprPtr = Expression;
Parse();
diff --git a/evaluator.h b/evaluator.h
index 12b52ba..6b5339c 100644
--- a/evaluator.h
+++ b/evaluator.h
@@ -1,4 +1,4 @@
-/* $Id: evaluator.h,v 1.6 2004/03/11 06:39:59 reinelt Exp $
+/* $Id: evaluator.h,v 1.7 2004/06/20 10:09:56 reinelt Exp $
*
* expression evaluation
*
@@ -23,6 +23,10 @@
*
*
* $Log: evaluator.h,v $
+ * Revision 1.7 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.6 2004/03/11 06:39:59 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -76,22 +80,22 @@ typedef struct {
} RESULT;
-int SetVariable (char *name, RESULT *value);
-int SetVariableNumeric (char *name, double value);
-int SetVariableString (char *name, char *value);
+int SetVariable (const char *name, RESULT *value);
+int SetVariableNumeric (const char *name, const double value);
+int SetVariableString (const char *name, const char *value);
-int AddFunction (char *name, int argc, void (*func)());
+int AddFunction (const char *name, const int argc, void (*func)());
void DeleteVariables (void);
void DeleteFunctions (void);
void DelResult (RESULT *result);
-RESULT* SetResult (RESULT **result, int type, void *value);
+RESULT* SetResult (RESULT **result, const int type, const void *value);
double R2N (RESULT *result);
char* R2S (RESULT *result);
-int Compile (char *expression, void **tree);
+int Compile (const char *expression, void **tree);
int Eval (void *tree, RESULT *result);
void DelTree (void *tree);
diff --git a/hash.c b/hash.c
index bd3f73c..3a43f7e 100644
--- a/hash.c
+++ b/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.21 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: hash.c,v 1.22 2004/06/20 10:09:56 reinelt Exp $
*
* hashes (associative arrays)
*
@@ -23,6 +23,10 @@
*
*
* $Log: hash.c,v $
+ * Revision 1.22 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.21 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -227,7 +231,7 @@ 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!!
-static char* split (const char *val, int column, const char *delimiter)
+static char* split (const char *val, const int column, const char *delimiter)
{
static char buffer[256];
int num, len;
@@ -261,7 +265,7 @@ static char* split (const char *val, int column, const char *delimiter)
// 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, int do_sort)
+static HASH_ITEM* hash_lookup (HASH *Hash, const char *key, const int do_sort)
{
HASH_ITEM *Item = NULL;
@@ -318,7 +322,7 @@ int hash_age (HASH *Hash, const char *key)
// add an entry to the column header table
-void hash_set_column (HASH *Hash, int number, const char *column)
+void hash_set_column (HASH *Hash, const int number, const char *column)
{
if (Hash == NULL) return;
@@ -369,7 +373,7 @@ char *hash_get (HASH *Hash, const char *key, const char *column)
// get a delta value from the delta table
-double hash_get_delta (HASH *Hash, const char *key, const char *column, int delay)
+double hash_get_delta (HASH *Hash, const char *key, const char *column, const int delay)
{
HASH_ITEM *Item;
HASH_SLOT *Slot1, *Slot2;
@@ -432,7 +436,7 @@ double hash_get_delta (HASH *Hash, const char *key, const char *column, int dela
// 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, int delay)
+double hash_get_regex (HASH *Hash, const char *key, const char *column, const int delay)
{
double sum;
regex_t preg;
@@ -467,7 +471,7 @@ double hash_get_regex (HASH *Hash, const char *key, const char *column, int dela
// 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, int delta)
+static HASH_ITEM* hash_set (HASH *Hash, const char *key, const char *value, const int delta)
{
HASH_ITEM *Item;
HASH_SLOT *Slot;
diff --git a/hash.h b/hash.h
index a5b8c0a..cb4d705 100644
--- a/hash.h
+++ b/hash.h
@@ -1,4 +1,4 @@
-/* $Id: hash.h,v 1.14 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: hash.h,v 1.15 2004/06/20 10:09:56 reinelt Exp $
*
* hashes (associative arrays)
*
@@ -23,6 +23,10 @@
*
*
* $Log: hash.h,v $
+ * Revision 1.15 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.14 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -131,12 +135,12 @@ void hash_create (HASH *Hash);
int hash_age (HASH *Hash, const char *key);
-void hash_set_column (HASH *Hash, int number, const char *column);
+void hash_set_column (HASH *Hash, const int number, const char *column);
void hash_set_delimiter (HASH *Hash, const char *delimiter);
char *hash_get (HASH *Hash, const char *key, const char *column);
-double hash_get_delta (HASH *Hash, const char *key, const char *column, int delay);
-double hash_get_regex (HASH *Hash, const char *key, const char *column, int delay);
+double hash_get_delta (HASH *Hash, const char *key, const char *column, const int delay);
+double hash_get_regex (HASH *Hash, const char *key, const char *column, const int delay);
void hash_put (HASH *Hash, const char *key, const char *value);
void hash_put_delta (HASH *Hash, const char *key, const char *value);
diff --git a/layout.c b/layout.c
index c60a4ff..ef560dd 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.11 2004/06/02 09:41:19 reinelt Exp $
+/* $Id: layout.c,v 1.12 2004/06/20 10:09:56 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,10 @@
*
*
* $Log: layout.c,v $
+ * Revision 1.12 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.11 2004/06/02 09:41:19 reinelt
*
* prepared support for startup splash screen
@@ -96,7 +100,7 @@
#endif
-int layout_addItem (char *name, int row, int col)
+int layout_addItem (const char *name, const int row, const int col)
{
// allocate widget
widget_add (name, row-1, col-1);
@@ -104,7 +108,7 @@ int layout_addItem (char *name, int row, int col)
}
-int layout_init (char *layout)
+int layout_init (const char *layout)
{
char *section;
char *list, *l;
diff --git a/layout.h b/layout.h
index 2870260..8c3490e 100644
--- a/layout.h
+++ b/layout.h
@@ -1,4 +1,4 @@
-/* $Id: layout.h,v 1.1 2004/01/10 20:22:33 reinelt Exp $
+/* $Id: layout.h,v 1.2 2004/06/20 10:09:56 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,10 @@
*
*
* $Log: layout.h,v $
+ * Revision 1.2 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.1 2004/01/10 20:22:33 reinelt
* added new function 'cfg_list()' (not finished yet)
* added layout.c (will replace processor.c someday)
@@ -34,6 +38,6 @@
#ifndef _LAYOUT_H_
#define _LAYOUT_H_
-int layout_init(char *section);
+int layout_init(const char *section);
#endif
diff --git a/plugin_cfg.c b/plugin_cfg.c
index e2abcd7..874360c 100644
--- a/plugin_cfg.c
+++ b/plugin_cfg.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_cfg.c,v 1.8 2004/03/11 06:39:59 reinelt Exp $
+/* $Id: plugin_cfg.c,v 1.9 2004/06/20 10:09:56 reinelt Exp $
*
* plugin for config file access
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_cfg.c,v $
+ * Revision 1.9 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.8 2004/03/11 06:39:59 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -127,7 +131,7 @@ static void load_variables (void)
}
-static void my_cfg (RESULT *result, int argc, RESULT *argv[])
+static void my_cfg (RESULT *result, const int argc, RESULT *argv[])
{
int i, len;
char *value;
diff --git a/plugin_exec.c b/plugin_exec.c
index a9a37c8..54a8aa1 100644
--- a/plugin_exec.c
+++ b/plugin_exec.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_exec.c,v 1.3 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_exec.c,v 1.4 2004/06/20 10:09:56 reinelt Exp $
*
* plugin for external processes
*
@@ -27,6 +27,10 @@
*
*
* $Log: plugin_exec.c,v $
+ * Revision 1.4 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.3 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -88,7 +92,7 @@ static HASH EXEC;
// x^0 + x^5 + x^12
#define CRCPOLY 0x8408
-static unsigned short CRC (unsigned char *s)
+static unsigned short CRC (const unsigned char *s)
{
int i;
unsigned short crc;
@@ -149,7 +153,7 @@ static void exec_thread (void *data)
}
-static void destroy_exec_thread (int n)
+static void destroy_exec_thread (const int n)
{
if (Thread[n].mutex != 0) mutex_destroy(Thread[n].mutex);
if (Thread[n].cmd) free (Thread[n].cmd);
@@ -166,7 +170,7 @@ static void destroy_exec_thread (int n)
}
-static int create_exec_thread (char *cmd, char *key, int delay)
+static int create_exec_thread (const char *cmd, const char *key, const int delay)
{
char name[10];
@@ -208,7 +212,7 @@ static int create_exec_thread (char *cmd, char *key, int delay)
}
-static int do_exec (char *cmd, char *key, int delay)
+static int do_exec (const char *cmd, const char *key, int delay)
{
int i, age;
diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c
index 14ef61e..cf6cdeb 100644
--- a/plugin_i2c_sensors.c
+++ b/plugin_i2c_sensors.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_i2c_sensors.c,v 1.18 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_i2c_sensors.c,v 1.19 2004/06/20 10:09:56 reinelt Exp $
*
* I2C sensors plugin
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_i2c_sensors.c,v $
+ * Revision 1.19 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.18 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -168,13 +172,13 @@ static const char *procfs_tokens[4][3] = {
{"fan_min", "fan_input", ""} // for fan#
};
-static int (*parse_i2c_sensors)(char *key);
+static int (*parse_i2c_sensors)(const char *key);
/***********************************************\
* Parsing for new 2.6 kernels 'sysfs' interface *
\***********************************************/
-static int parse_i2c_sensors_sysfs(char *key)
+static int parse_i2c_sensors_sysfs(const char *key)
{
char val[32];
char buffer[32];
@@ -221,7 +225,7 @@ static int parse_i2c_sensors_sysfs(char *key)
* Parsing for old 2.4 kernels 'procfs' interface *
\************************************************/
-static int parse_i2c_sensors_procfs(char *key)
+static int parse_i2c_sensors_procfs(const char *key)
{
char file[64];
FILE *stream;
@@ -232,7 +236,7 @@ static int parse_i2c_sensors_procfs(char *key)
int pos=0;
const char delim[3]=" \n";
char final_key[32];
- char *number = &key[strlen(key)-1];
+ const char *number = &key[strlen(key)-1];
int tokens_index;
// debug("%s -> %s", key, number);
strcpy(file, path);
@@ -310,7 +314,7 @@ void my_i2c_sensors(RESULT *result, RESULT *arg)
}
-void my_i2c_sensors_path(char *method)
+void my_i2c_sensors_path(const char *method)
{
struct dirent *dir;
struct dirent *file;
diff --git a/plugin_imon.c b/plugin_imon.c
index 7566f01..d80c0bf 100755
--- a/plugin_imon.c
+++ b/plugin_imon.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_imon.c,v 1.9 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_imon.c,v 1.10 2004/06/20 10:09:56 reinelt Exp $
*
* imond/telmond data processing
*
@@ -22,6 +22,10 @@
*
*
* $Log: plugin_imon.c,v $
+ * Revision 1.10 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.9 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -101,7 +105,7 @@ static int err=0;
* service_connect (host_name, port) - connect to tcp-service
*----------------------------------------------------------------------------
*/
-static int service_connect (char * host_name, int port){
+static int service_connect (const char * host_name, const int port){
struct sockaddr_in addr;
struct hostent * host_p;
int fd;
@@ -150,7 +154,7 @@ static int service_connect (char * host_name, int port){
*----------------------------------------------------------------------------
*/
static void
-send_command (int fd, char * str)
+send_command (const int fd, const char * str)
{
char buf[256];
int len = strlen (str);
@@ -167,7 +171,7 @@ send_command (int fd, char * str)
*----------------------------------------------------------------------------
*/
static char *
-get_answer (int fd)
+get_answer (const int fd)
{
static char buf[8192];
int len;
@@ -207,7 +211,7 @@ get_answer (int fd)
*----------------------------------------------------------------------------
*/
static char *
-get_value (char * cmd)
+get_value (const char * cmd)
{
char * answer;
@@ -316,7 +320,7 @@ void init(){
}
}
-static int parse_imon(char *cmd){
+static int parse_imon(const char *cmd){
// reread every half sec only
int age=hash_age(&IMON, cmd);
if (age>0 && age<=500) return 0;
@@ -357,7 +361,7 @@ static void my_imon_version (RESULT *result){
SetResult(&result, R_STRING, val);
}
-static int parse_imon_rates(char *channel){
+static int parse_imon_rates(const char *channel){
char buf[128],in[25],out[25];
char *s;
int age;
diff --git a/plugin_isdn.c b/plugin_isdn.c
index 4298d94..aaf2d4a 100644
--- a/plugin_isdn.c
+++ b/plugin_isdn.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_isdn.c,v 1.2 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_isdn.c,v 1.3 2004/06/20 10:09:56 reinelt Exp $
*
* plugin for ISDN subsystem
*
@@ -26,6 +26,10 @@
*
*
* $Log: plugin_isdn.c,v $
+ * Revision 1.3 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.2 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -78,7 +82,7 @@ static HASH ISDN_INFO;
static HASH ISDN_CPS;
-static void hash_put_info (char *name, int channel, char *val)
+static void hash_put_info (const char *name, const int channel, const char *val)
{
char key[16];
@@ -162,7 +166,7 @@ static void my_isdn_info (RESULT *result, RESULT *arg1, RESULT *arg2)
#ifdef HAVE_LINUX_ISDN_H
-static void hash_put_cps (int channel, CPS *cps)
+static void hash_put_cps (const int channel, const CPS *cps)
{
char key[16], val[16];
diff --git a/plugin_proc_stat.c b/plugin_proc_stat.c
index 6c20755..b55c22b 100644
--- a/plugin_proc_stat.c
+++ b/plugin_proc_stat.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_proc_stat.c,v 1.20 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_proc_stat.c,v 1.21 2004/06/20 10:09:56 reinelt Exp $
*
* plugin for /proc/stat parsing
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_proc_stat.c,v $
+ * Revision 1.21 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.20 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -131,13 +135,13 @@ static HASH Stat;
static FILE *stream = NULL;
-static void hash_put1 (char *key1, char *val)
+static void hash_put1 (const char *key1, const char *val)
{
hash_put_delta (&Stat, key1, val);
}
-static void hash_put2 (char *key1, char *key2, char *val)
+static void hash_put2 (const char *key1, const char *key2, const char *val)
{
char key[32];
@@ -146,7 +150,7 @@ static void hash_put2 (char *key1, char *key2, char *val)
}
-static void hash_put3 (char *key1, char *key2, char *key3, char *val)
+static void hash_put3 (const char *key1, const char *key2, const char *key3, const char *val)
{
char key[32];
@@ -276,7 +280,7 @@ static int parse_proc_stat (void)
}
-static void my_proc_stat (RESULT *result, int argc, RESULT *argv[])
+static void my_proc_stat (RESULT *result, const int argc, RESULT *argv[])
{
char *string;
double number;
diff --git a/plugin_uptime.c b/plugin_uptime.c
index 1519ad1..7b701c3 100644
--- a/plugin_uptime.c
+++ b/plugin_uptime.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_uptime.c,v 1.1 2004/05/22 18:30:02 reinelt Exp $
+/* $Id: plugin_uptime.c,v 1.2 2004/06/20 10:09:56 reinelt Exp $
*
* plugin for uptime
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_uptime.c,v $
+ * Revision 1.2 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.1 2004/05/22 18:30:02 reinelt
*
* added plugin 'uptime'
@@ -56,7 +60,7 @@
static int fd = -2;
-static char *itoa(char* buffer, size_t size, unsigned int value)
+static char *itoa(char* buffer, const size_t size, unsigned int value)
{
char *p;
@@ -78,7 +82,7 @@ static char *itoa(char* buffer, size_t size, unsigned int value)
}
-char *struptime (unsigned int uptime, char *format)
+char *struptime (const unsigned int uptime, const char *format)
{
static char string[256];
const char *src;
@@ -186,7 +190,7 @@ double getuptime (void)
}
-static void my_uptime (RESULT *result, int argc, RESULT *argv[])
+static void my_uptime (RESULT *result, const int argc, RESULT *argv[])
{
int age;
static double uptime = 0.0;
diff --git a/plugin_wireless.c b/plugin_wireless.c
index 23385fa..4c0807f 100755
--- a/plugin_wireless.c
+++ b/plugin_wireless.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_wireless.c,v 1.4 2004/06/17 06:23:43 reinelt Exp $
+/* $Id: plugin_wireless.c,v 1.5 2004/06/20 10:09:56 reinelt Exp $
*
* Wireless Extension plugin
*
@@ -28,6 +28,10 @@
*
*
* $Log: plugin_wireless.c,v $
+ * Revision 1.5 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.4 2004/06/17 06:23:43 reinelt
*
* hash handling rewritten to solve performance issues
@@ -123,13 +127,13 @@ static char *operation_mode[] = {
};
-static void ioctl_error(int line) {
+static void ioctl_error(const int line) {
error("IOCTL call to wireless extensions in line %d returned error", line);
}
-int do_ioctl(int sock, /* Socket to the kernel */
- char * ifname, /* Device name */
- int request, /* WE ID */
+int do_ioctl(const int sock, /* Socket to the kernel */
+ const char * ifname, /* Device name */
+ const int request, /* WE ID */
struct iwreq * pwrq) /* Fixed part of the request */
{
/* Set device name */
@@ -139,8 +143,8 @@ int do_ioctl(int sock, /* Socket to the kernel */
return(ioctl(sock, request, pwrq));
}
-int get_range_info( int sock,
- char * ifname,
+int get_range_info(const int sock,
+ const char * ifname,
struct iw_range *range)
{
struct iwreq req;
@@ -167,7 +171,7 @@ int get_range_info( int sock,
-static int get_ifname(struct iwreq *preq, char *dev) {
+static int get_ifname(struct iwreq *preq, const char *dev) {
/* do not cache this call !!! */
struct iwreq req;
char key_buffer[32];
@@ -190,7 +194,7 @@ static int get_ifname(struct iwreq *preq, char *dev) {
}
-static int get_frequency(char* dev,char* key) {
+static int get_frequency(const char* dev,const char* key) {
/* Get frequency / channel */
struct iwreq req;
char qprintf_buffer[1024];
@@ -235,7 +239,7 @@ static int get_frequency(char* dev,char* key) {
}
-static int get_essid(char* dev,char* key) {
+static int get_essid(const char* dev, const char* key) {
/* Get ESSID */
struct iwreq req;
char key_buffer[32];
@@ -270,7 +274,7 @@ static int get_essid(char* dev,char* key) {
}
-static int get_op_mode(char* dev,char* key) {
+static int get_op_mode(const char* dev, const char* key) {
/* Get operation mode */
struct iwreq req;
char key_buffer[32];
@@ -302,7 +306,7 @@ static int get_op_mode(char* dev,char* key) {
}
-static int get_bitrate(char* dev,char* key) {
+static int get_bitrate(const char* dev, const char* key) {
/* Get bit rate */
struct iwreq req;
char key_buffer[32];
@@ -344,7 +348,7 @@ static int get_bitrate(char* dev,char* key) {
return(0);
}
-static int get_sens(char* dev,char* key) {
+static int get_sens(const char* dev, const char* key) {
/* Get sensitivity */
struct iwreq req;
struct iw_range range;
@@ -394,7 +398,7 @@ static int get_sens(char* dev,char* key) {
}
-static int get_sec_mode(char* dev,char* key) {
+static int get_sec_mode(const char* dev, const char* key) {
// Get encryption information
struct iwreq req;
char key_buffer[32];
@@ -441,7 +445,7 @@ static int get_sec_mode(char* dev,char* key) {
return(0);
}
-static int get_stats(char *dev, char *key)
+static int get_stats(const char *dev, const char *key)
{
struct iw_statistics stats;
struct iwreq req;
@@ -523,7 +527,7 @@ static int check_socket() {
}
-static void save_result(RESULT *result, char* dev, char* key, int res) {
+static void save_result(RESULT *result, const char* dev, const char* key, const int res) {
char key_buffer[64];
char* val=NULL;
qprintf(key_buffer, sizeof(key_buffer), "%s.%s", dev,key);
diff --git a/qprintf.c b/qprintf.c
index 4b9a42d..0d831c8 100644
--- a/qprintf.c
+++ b/qprintf.c
@@ -1,4 +1,4 @@
-/* $Id: qprintf.c,v 1.3 2004/04/12 11:12:26 reinelt Exp $
+/* $Id: qprintf.c,v 1.4 2004/06/20 10:09:56 reinelt Exp $
*
* simple but quick snprintf() replacement
*
@@ -26,6 +26,10 @@
*
*
* $Log: qprintf.c,v $
+ * Revision 1.4 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.3 2004/04/12 11:12:26 reinelt
* added plugin_isdn, removed old ISDN client
* fixed some real bad bugs in the evaluator
@@ -55,11 +59,11 @@
#include <stdarg.h>
#include <string.h>
-static char *itoa(char* buffer, size_t size, int value)
+static char *itoa(char* buffer, const size_t size, int value)
{
char *p;
int sign;
-
+
// sanity checks
if (buffer==NULL || size<2) return (NULL);
@@ -88,7 +92,7 @@ static char *itoa(char* buffer, size_t size, int value)
}
-static char *utoa(char* buffer, size_t size, unsigned int value)
+static char *utoa(char* buffer, const size_t size, unsigned int value)
{
char *p;
@@ -110,7 +114,7 @@ static char *utoa(char* buffer, size_t size, unsigned int value)
}
-static char *utox(char* buffer, size_t size, unsigned int value)
+static char *utox(char* buffer, const size_t size, unsigned int value)
{
char *p;
int digit;
@@ -134,7 +138,7 @@ static char *utox(char* buffer, size_t size, unsigned int value)
}
-int qprintf(char *str, size_t size, const char *format, ...) {
+int qprintf(char *str, const size_t size, const char *format, ...) {
va_list ap;
const char *src;
@@ -145,12 +149,10 @@ int qprintf(char *str, size_t size, const char *format, ...) {
dst = str;
len = 0;
- // leave room for terminating zero
- size--;
-
va_start(ap, format);
- while (len < size) {
+ // use size-1 for terminating zero
+ while (len < size-1) {
if (*src=='%') {
char buf[12], *s;
@@ -160,7 +162,7 @@ int qprintf(char *str, size_t size, const char *format, ...) {
case 's':
src++;
s = va_arg(ap, char *);
- while (len < size && *s != '\0') {
+ while (len < size-1 && *s != '\0') {
len++;
*dst++ = *s++;
}
@@ -178,7 +180,7 @@ int qprintf(char *str, size_t size, const char *format, ...) {
src++;
u = va_arg(ap, unsigned int);
s = utoa (buf, sizeof(buf), u);
- while (len < size && *s != '\0') {
+ while (len < size-1 && *s != '\0') {
len++;
*dst++ = *s++;
}
@@ -187,7 +189,7 @@ int qprintf(char *str, size_t size, const char *format, ...) {
src++;
u = va_arg(ap, unsigned int);
s = utox (buf, sizeof(buf), u);
- while (len < size && *s != '\0') {
+ while (len < size-1 && *s != '\0') {
len++;
*dst++ = *s++;
}
@@ -206,7 +208,7 @@ int qprintf(char *str, size_t size, const char *format, ...) {
va_end(ap);
// enforce terminating zero
- if (len>=size && *(dst-1)!='\0') {
+ if (len>=size-1 && *(dst-1)!='\0') {
len++;
*dst='\0';
}
diff --git a/thread.c b/thread.c
index 99c51fe..4a9fffd 100644
--- a/thread.c
+++ b/thread.c
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.4 2004/06/01 06:45:30 reinelt Exp $
+/* $Id: thread.c,v 1.5 2004/06/20 10:09:56 reinelt Exp $
*
* thread handling (mutex, shmem, ...)
*
@@ -26,6 +26,10 @@
*
*
* $Log: thread.c,v $
+ * Revision 1.5 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.4 2004/06/01 06:45:30 reinelt
*
* some Fixme's processed
@@ -123,7 +127,7 @@ int mutex_create (void)
}
-void mutex_lock (int semid)
+void mutex_lock (const int semid)
{
struct sembuf sembuf;
sembuf.sem_num = 0;
@@ -133,7 +137,7 @@ void mutex_lock (int semid)
}
-void mutex_unlock (int semid)
+void mutex_unlock (const int semid)
{
struct sembuf sembuf;
sembuf.sem_num = 0;
@@ -143,14 +147,14 @@ void mutex_unlock (int semid)
}
-void mutex_destroy (int semid)
+void mutex_destroy (const int semid)
{
union semun arg;
semctl(semid, 0, IPC_RMID, arg);
}
-int shm_create (void **buffer, int size)
+int shm_create (void **buffer, const int size)
{
int shmid;
@@ -170,14 +174,14 @@ int shm_create (void **buffer, int size)
}
-void shm_destroy (int shmid, void *buffer)
+void shm_destroy (const int shmid, const void *buffer)
{
shmdt (buffer);
shmctl(shmid, IPC_RMID, NULL);
}
-int thread_create (char *name, void (*thread)(void *data), void *data)
+int thread_create (const char *name, void (*thread)(void *data), void *data)
{
pid_t pid, ppid;
diff --git a/thread.h b/thread.h
index 30ea1a9..16b5ecc 100644
--- a/thread.h
+++ b/thread.h
@@ -1,4 +1,4 @@
-/* $Id: thread.h,v 1.3 2004/04/08 10:48:25 reinelt Exp $
+/* $Id: thread.h,v 1.4 2004/06/20 10:09:56 reinelt Exp $
*
* thread handling (mutex, shmem, ...)
*
@@ -26,6 +26,10 @@
*
*
* $Log: thread.h,v $
+ * Revision 1.4 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.3 2004/04/08 10:48:25 reinelt
* finished plugin_exec
* modified thread handling
@@ -44,13 +48,13 @@
#define _THREAD_H_
int mutex_create (void);
-void mutex_lock (int semid);
-void mutex_unlock (int semid);
-void mutex_destroy (int semid);
+void mutex_lock (const int semid);
+void mutex_unlock (const int semid);
+void mutex_destroy (const int semid);
-int shm_create (void **buffer, int size);
-void shm_destroy (int shmid, void *buffer) ;
+int shm_create (void **buffer, const int size);
+void shm_destroy (const int shmid, const void *buffer);
-int thread_create (char *name, void (*thread)(void *data), void *data);
+int thread_create (const char *name, void (*thread)(void *data), void *data);
#endif
diff --git a/timer.c b/timer.c
index 6d478d0..14b8239 100644
--- a/timer.c
+++ b/timer.c
@@ -1,4 +1,4 @@
-/* $Id: timer.c,v 1.7 2004/06/01 06:45:30 reinelt Exp $
+/* $Id: timer.c,v 1.8 2004/06/20 10:09:56 reinelt Exp $
*
* generic timer handling
*
@@ -21,6 +21,10 @@
*
*
* $Log: timer.c,v $
+ * Revision 1.8 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.7 2004/06/01 06:45:30 reinelt
*
* some Fixme's processed
@@ -99,7 +103,7 @@ TIMER *Timers=NULL;
int nTimers=0;
-static void timer_inc (struct timeval *tv, int msec)
+static void timer_inc (struct timeval *tv, const int msec)
{
tv->tv_sec += msec / 1000;
tv->tv_usec += (msec - 1000*(msec/1000)) * 1000;
@@ -111,7 +115,7 @@ static void timer_inc (struct timeval *tv, int msec)
}
-int timer_add (void (*callback)(void *data), void *data, int interval, int one_shot)
+int timer_add (void (*callback)(void *data), void *data, const int interval, const int one_shot)
{
int i;
struct timeval now;
diff --git a/timer.h b/timer.h
index 4f54676..9ff9e95 100644
--- a/timer.h
+++ b/timer.h
@@ -1,4 +1,4 @@
-/* $Id: timer.h,v 1.3 2004/06/01 06:45:30 reinelt Exp $
+/* $Id: timer.h,v 1.4 2004/06/20 10:09:56 reinelt Exp $
*
* generic timer handling
*
@@ -23,6 +23,10 @@
*
*
* $Log: timer.h,v $
+ * Revision 1.4 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.3 2004/06/01 06:45:30 reinelt
*
* some Fixme's processed
@@ -45,7 +49,7 @@
#ifndef _TIMER_H_
#define _TIMER_H_
-int timer_add (void(*callback)(void *data), void *data, int interval, int one_shot);
+int timer_add (void(*callback)(void *data), void *data, const int interval, const int one_shot);
int timer_process (struct timespec *delay);
void timer_exit();
diff --git a/udelay.c b/udelay.c
index f332bb0..bfbdf00 100644
--- a/udelay.c
+++ b/udelay.c
@@ -1,4 +1,4 @@
-/* $Id: udelay.c,v 1.16 2004/04/12 05:14:42 reinelt Exp $
+/* $Id: udelay.c,v 1.17 2004/06/20 10:09:56 reinelt Exp $
*
* short delays
*
@@ -22,6 +22,10 @@
*
*
* $Log: udelay.c,v $
+ * Revision 1.17 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.16 2004/04/12 05:14:42 reinelt
* another BIG FAT WARNING on the use of raw ports instead of ppdev
*
@@ -146,7 +150,7 @@
unsigned long loops_per_usec;
-void ndelay (unsigned long nsec)
+void ndelay (const unsigned long nsec)
{
unsigned long loop=(nsec*loops_per_usec+999)/1000;
@@ -265,7 +269,7 @@ void udelay_init (void)
}
-void ndelay (unsigned long nsec)
+void ndelay (const unsigned long nsec)
{
#ifdef HAVE_ASM_MSR_H
@@ -273,14 +277,15 @@ void ndelay (unsigned long nsec)
if (ticks_per_usec) {
unsigned int t1, t2;
-
- nsec=(nsec*ticks_per_usec+999)/1000;
+ unsigned long tsc;
+
+ tsc=(nsec*ticks_per_usec+999)/1000;
rdtscl(t1);
do {
rep_nop();
rdtscl(t2);
- } while ((t2-t1)<nsec);
+ } while ((t2-t1)<tsc);
} else
diff --git a/udelay.h b/udelay.h
index fd7e873..ddfc8d9 100644
--- a/udelay.h
+++ b/udelay.h
@@ -1,4 +1,4 @@
-/* $Id: udelay.h,v 1.5 2003/10/05 17:58:50 reinelt Exp $
+/* $Id: udelay.h,v 1.6 2004/06/20 10:09:56 reinelt Exp $
*
* short delays
*
@@ -22,6 +22,10 @@
*
*
* $Log: udelay.h,v $
+ * Revision 1.6 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.5 2003/10/05 17:58:50 reinelt
* libtool junk; copyright messages cleaned up
*
@@ -70,7 +74,7 @@ void udelay_init (void);
#endif
-void ndelay (unsigned long nsec);
+void ndelay (const unsigned long nsec);
#define udelay(usec) ndelay(usec*1000)
diff --git a/widget.c b/widget.c
index e7be927..79387b5 100644
--- a/widget.c
+++ b/widget.c
@@ -1,4 +1,4 @@
-/* $Id: widget.c,v 1.14 2004/05/26 11:37:36 reinelt Exp $
+/* $Id: widget.c,v 1.15 2004/06/20 10:09:56 reinelt Exp $
*
* generic widget handling
*
@@ -21,6 +21,10 @@
*
*
* $Log: widget.c,v $
+ * Revision 1.15 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.14 2004/05/26 11:37:36 reinelt
*
* Curses driver ported.
@@ -153,7 +157,7 @@ void widget_unregister(void) {
nClasses=0;
}
-int widget_add (char *name, int row, int col)
+int widget_add (const char *name, const int row, const int col)
{
int i;
char *section;
@@ -210,7 +214,7 @@ int widget_add (char *name, int row, int col)
Widget=&(Widgets[nWidgets]);
nWidgets++;
- Widget->name = name;
+ Widget->name = (char*)name;
Widget->class = Class;
Widget->row = row;
Widget->col = col;
diff --git a/widget.h b/widget.h
index 6fcfe11..af386be 100644
--- a/widget.h
+++ b/widget.h
@@ -1,4 +1,4 @@
-/* $Id: widget.h,v 1.8 2004/03/03 03:47:04 reinelt Exp $
+/* $Id: widget.h,v 1.9 2004/06/20 10:09:56 reinelt Exp $
*
* generic widget handling
*
@@ -23,6 +23,10 @@
*
*
* $Log: widget.h,v $
+ * Revision 1.9 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.8 2004/03/03 03:47:04 reinelt
* big patch from Martin Hejl:
* - use qprintf() where appropriate
@@ -86,8 +90,8 @@ typedef struct WIDGET{
-int widget_register (WIDGET_CLASS *widget);
+int widget_register (WIDGET_CLASS *widget);
void widget_unregister (void);
-int widget_add (char *name, int row, int col);
+int widget_add (const char *name, const int row, const int col);
#endif
diff --git a/widget_icon.c b/widget_icon.c
index 95edb8f..a516cb2 100644
--- a/widget_icon.c
+++ b/widget_icon.c
@@ -1,4 +1,4 @@
-/* $Id: widget_icon.c,v 1.11 2004/03/11 06:39:59 reinelt Exp $
+/* $Id: widget_icon.c,v 1.12 2004/06/20 10:09:56 reinelt Exp $
*
* icon widget handling
*
@@ -21,6 +21,10 @@
*
*
* $Log: widget_icon.c,v $
+ * Revision 1.12 2004/06/20 10:09:56 reinelt
+ *
+ * 'const'ified the whole source
+ *
* Revision 1.11 2004/03/11 06:39:59 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -104,7 +108,7 @@
// icons always are 8 pixels high
#define YRES 8
-static void widget_icon_read_bitmap (char *section, WIDGET_ICON *Icon)
+static void widget_icon_read_bitmap (const char *section, WIDGET_ICON *Icon)
{
int row, n;
char key[15];