declare constant function parameters const (as well as constant function return values)
This commit is contained in:
@@ -175,9 +175,9 @@ int process_command_line(int argc, char **argv)
|
||||
return error;
|
||||
}
|
||||
|
||||
int process_configfile(char * configfile)
|
||||
int process_configfile(char *configfile)
|
||||
{
|
||||
char * tmp;
|
||||
const char *tmp;
|
||||
|
||||
if (configfile == NULL)
|
||||
configfile = DEFAULT_CONFIGFILE;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "menu.h"
|
||||
|
||||
/* recursively read the menu hierarchy */
|
||||
MenuEntry *menu_read(MenuEntry *parent, char *name)
|
||||
MenuEntry *menu_read(MenuEntry *parent, const char *name)
|
||||
{
|
||||
static int id = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ MenuEntry *menu_read(MenuEntry *parent, char *name)
|
||||
|
||||
if (config_get_string(name, "Entry", 0, NULL) != NULL) {
|
||||
MenuEntry **addr = &me->entries;
|
||||
char *entryname;
|
||||
const char *entryname;
|
||||
int index = 0;
|
||||
|
||||
// it is a sub-menu
|
||||
|
||||
@@ -41,7 +41,7 @@ typedef struct menu_entry {
|
||||
} MenuEntry;
|
||||
|
||||
|
||||
MenuEntry *menu_read(MenuEntry *parent, char *name);
|
||||
MenuEntry *menu_read(MenuEntry *parent, const char *ame);
|
||||
int menu_sock_send(MenuEntry *me, MenuEntry *parent, int sock);
|
||||
MenuEntry *menu_find_by_id(MenuEntry *me, int id);
|
||||
const char *menu_command(MenuEntry *me);
|
||||
|
||||
@@ -67,7 +67,7 @@ static struct option const long_options[] =
|
||||
static int
|
||||
iface_process_configfile()
|
||||
{
|
||||
char *unit;
|
||||
const char *unit;
|
||||
|
||||
debug( RPT_DEBUG, "%s()", __FUNCTION__ );
|
||||
|
||||
|
||||
@@ -15,6 +15,17 @@
|
||||
#include <sys/statvfs.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_GETLOADAVG
|
||||
# include <sys/loadavg.h>
|
||||
#endif
|
||||
|
||||
@@ -330,7 +330,7 @@ static int
|
||||
process_configfile(char *configfile)
|
||||
{
|
||||
int k;
|
||||
char *tmp;
|
||||
const char *tmp;
|
||||
|
||||
debug(RPT_DEBUG, "%s(%s)", __FUNCTION__, (configfile) ? configfile : "<null>");
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ int
|
||||
drivers_load_driver( char * name )
|
||||
{
|
||||
Driver * driver;
|
||||
char * s;
|
||||
const char * s;
|
||||
char * driverpath;
|
||||
char * filename;
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ static void CwLnx_draw_frame(Driver *drvthis, char *dat);
|
||||
static char CwLnx_parse_keypad_setting(Driver *drvthis, char * keyname, char default_value)
|
||||
{
|
||||
char return_val = 0;
|
||||
char * s;
|
||||
const char *s;
|
||||
char buf[255];
|
||||
|
||||
s = drvthis->config_get_string(drvthis->name, keyname, 0, NULL);
|
||||
@@ -501,7 +501,7 @@ int CwLnx_init(Driver * drvthis)
|
||||
int tmp;
|
||||
int w;
|
||||
int h;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
PrivateData *p;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static void EyeboxOne_use_led(int fd, int led, int color);
|
||||
static char EyeboxOne_parse_keypad_setting (Driver *drvthis, char * keyname, char default_value)
|
||||
{
|
||||
char return_val = 0;
|
||||
char * s;
|
||||
const char *s;
|
||||
char buf[255];
|
||||
|
||||
s = drvthis->config_get_string(drvthis->name, keyname, 0, NULL);
|
||||
|
||||
@@ -229,7 +229,7 @@ static void MtxOrb_old_hbar (Driver *drvthis, int x, int y, int len);
|
||||
static char MtxOrb_parse_keypad_setting (Driver *drvthis, char * keyname, char default_value)
|
||||
{
|
||||
char return_val = 0;
|
||||
char * s;
|
||||
const char *s;
|
||||
char buf[255];
|
||||
|
||||
s = drvthis->config_get_string(drvthis->name, keyname, 0, NULL);
|
||||
|
||||
@@ -258,8 +258,7 @@ void
|
||||
serial_HD44780_backlight (PrivateData *p, unsigned char state)
|
||||
{
|
||||
/* TODO */
|
||||
if(p->have_backlight);
|
||||
return 0;
|
||||
//if (p->have_backlight) ....
|
||||
}
|
||||
|
||||
unsigned char
|
||||
|
||||
@@ -111,7 +111,7 @@ static char *defaultKeyMapMatrix[KEYPAD_MAXY][KEYPAD_MAXX] = {
|
||||
void HD44780_position (Driver *drvthis, int x, int y);
|
||||
static void uPause (PrivateData *p, int usecs);
|
||||
unsigned char HD44780_scankeypad(PrivateData *p);
|
||||
static int parse_span_list (int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], char *spanlist);
|
||||
static int parse_span_list (int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist);
|
||||
|
||||
// Vars for the server core
|
||||
MODULE_EXPORT char * api_version = API_VERSION;
|
||||
@@ -132,7 +132,7 @@ HD44780_init (Driver * drvthis)
|
||||
// TODO: remove the two magic numbers below
|
||||
// TODO: single point of return
|
||||
char buf[40];
|
||||
char *s;
|
||||
const char *s;
|
||||
int i;
|
||||
int if_type = IF_TYPE_PARPORT;
|
||||
PrivateData *p;
|
||||
@@ -1072,7 +1072,7 @@ HD44780_output (Driver *drvthis, int on)
|
||||
// returns number of span elements, -1 on parse error
|
||||
|
||||
int
|
||||
parse_span_list (int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], char *spanlist)
|
||||
parse_span_list (int *spanListArray[], int *spLsize, int *dispOffsets[], int *dOffsize, int *dispSizeArray[], const char *spanlist)
|
||||
{
|
||||
int j = 0, retVal = 0;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ joy_init (Driver *drvthis)
|
||||
|
||||
for (i = 0; i < p->axes; i++) {
|
||||
char mapkey[50];
|
||||
char *mapval;
|
||||
const char *mapval;
|
||||
|
||||
snprintf(mapkey, sizeof(mapkey), "Map_Axis%dneg", i+1);
|
||||
mapval = drvthis->config_get_string(drvthis->name, mapkey, 0, NULL);
|
||||
@@ -154,7 +154,7 @@ joy_init (Driver *drvthis)
|
||||
|
||||
for (i = 0; i < p->buttons; i++) {
|
||||
char mapkey[50];
|
||||
char *mapval;
|
||||
const char *mapval;
|
||||
|
||||
snprintf(mapkey, sizeof(mapkey), "Map_Button%d", i+1);
|
||||
mapval = drvthis->config_get_string(drvthis->name, mapkey, 0, NULL);
|
||||
|
||||
+10
-10
@@ -169,13 +169,13 @@ typedef struct lcd_logical_driver {
|
||||
|
||||
/******** Variables in server core available for drivers ********/
|
||||
|
||||
char * name; /* Name of this driver */
|
||||
char * filename; /* Filename of the shared module */
|
||||
char *name; /* Name of this driver */
|
||||
char *filename; /* Filename of the shared module */
|
||||
|
||||
MODULE_HANDLE module_handle; /* The handle of the loaded shared module
|
||||
Is platform specific */
|
||||
|
||||
void * private_data; /* Filled by server by calling store_private_ptr()
|
||||
void *private_data; /* Filled by server by calling store_private_ptr()
|
||||
Driver should cast this to it's own
|
||||
private structure pointer */
|
||||
|
||||
@@ -188,16 +188,16 @@ typedef struct lcd_logical_driver {
|
||||
/* Configfile functions */
|
||||
/* See configfile.h for descriptions and usage. */
|
||||
|
||||
short (*config_get_bool)( char *sectionname, char *keyname, int skip, short default_value );
|
||||
long int (*config_get_int) ( char *sectionname, char *keyname, int skip, long int default_value );
|
||||
double (*config_get_float) ( char *sectionname, char *keyname, int skip, double default_value );
|
||||
char *( *config_get_string) ( char *sectionname, char *keyname, int skip, char *default_value );
|
||||
int (*config_has_section) ( char *sectionname );
|
||||
int (*config_has_key) ( char *sectionname, char *keyname );
|
||||
short (*config_get_bool) (const char *sectionname, const char *keyname, int skip, short default_value);
|
||||
long int (*config_get_int) (const char *sectionname, const char *keyname, int skip, long int default_value);
|
||||
double (*config_get_float) (const char *sectionname, const char *keyname, int skip, double default_value);
|
||||
const char *( *config_get_string)(const char *sectionname, const char *keyname, int skip, const char *default_value);
|
||||
int (*config_has_section) (const char *sectionname);
|
||||
int (*config_has_key) (const char *sectionname, const char *keyname);
|
||||
|
||||
/* Reporting function */
|
||||
/* Easily usable by including drivers/report.h */
|
||||
void (*report) ( const int level, const char *format, .../*args*/ );
|
||||
void (*report) (const int level, const char *format, .../*args*/ );
|
||||
|
||||
/* Display properties functions (for drivers that adapt to other loaded drivers) */
|
||||
int (*request_display_width) ();
|
||||
|
||||
@@ -104,7 +104,7 @@ lcterm_init (Driver *drvthis)
|
||||
/* Get and parse size */
|
||||
{
|
||||
int w, h;
|
||||
char *s = drvthis->config_get_string(drvthis->name, "Size", 0, "16x2");
|
||||
const char *s = drvthis->config_get_string(drvthis->name, "Size", 0, "16x2");
|
||||
|
||||
debug(RPT_DEBUG, "%s: reading size: %s", __FUNCTION__, s);
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ unsigned char sed1330_readkeypad (PrivateData *p, unsigned int YData);
|
||||
MODULE_EXPORT int
|
||||
sed1330_init( Driver * drvthis )
|
||||
{
|
||||
char * s;
|
||||
const char *s;
|
||||
PrivateData * p;
|
||||
unsigned char data[8];
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ ula200_init(Driver *drvthis)
|
||||
{
|
||||
PrivateData *p;
|
||||
int err, i;
|
||||
char *s;
|
||||
const char *s;
|
||||
|
||||
// Alocate and store private data
|
||||
p = (PrivateData *) malloc( sizeof( PrivateData) );
|
||||
|
||||
+1
-1
@@ -404,7 +404,7 @@ process_command_line(int argc, char **argv)
|
||||
static int
|
||||
process_configfile(char *configfile)
|
||||
{
|
||||
char * s;
|
||||
const char *s;
|
||||
/*char buf[64];*/
|
||||
|
||||
debug( RPT_DEBUG, "%s()", __FUNCTION__ );
|
||||
|
||||
@@ -72,7 +72,7 @@ MenuEventFunc (brightness_handler);
|
||||
|
||||
int menuscreens_init()
|
||||
{
|
||||
char *tmp;
|
||||
const char *tmp;
|
||||
|
||||
debug (RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
|
||||
+22
-22
@@ -40,25 +40,25 @@ typedef struct section {
|
||||
} section;
|
||||
|
||||
|
||||
static section * first_section = NULL;
|
||||
static section *first_section = NULL;
|
||||
/* Yes there is a static. It's C after all :)*/
|
||||
|
||||
|
||||
section * find_section(char * sectionname);
|
||||
section * add_section(char * sectionname);
|
||||
key * find_key(section * s, char * keyname, int skip);
|
||||
key * add_key(section * s, char * keyname, char * value);
|
||||
section *find_section(const char *sectionname);
|
||||
section *add_section(const char *sectionname);
|
||||
key *find_key(section *s, const char *keyname, int skip);
|
||||
key *add_key(section *s, const char *keyname, const char *value);
|
||||
char get_next_char_f(FILE *f);
|
||||
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, FILE *f);
|
||||
int process_config(section **current_section, char(*get_next_char)(), char modify_section_allowed, const char *source_descr, FILE *f);
|
||||
|
||||
|
||||
#ifdef WITH_LDAP_SUPPORT
|
||||
int connect_to_ldap(void);
|
||||
|
||||
static LDAP * ld = NULL;
|
||||
static LDAP *ld = NULL;
|
||||
int use_ldap = 0;
|
||||
|
||||
static char * ldap_host = NULL, * ldap_base_dn = NULL;
|
||||
static char *ldap_host = NULL, *ldap_base_dn = NULL;
|
||||
int ldap_port;
|
||||
|
||||
/* not supported for now
|
||||
@@ -70,7 +70,7 @@ int ldap_port;
|
||||
|
||||
/**** EXTERNAL FUNCTIONS ****/
|
||||
|
||||
int config_read_file(char *filename)
|
||||
int config_read_file(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
section *curr_section = NULL;
|
||||
@@ -123,7 +123,7 @@ int config_read_file(char *filename)
|
||||
}
|
||||
|
||||
|
||||
int config_read_string(char *sectionname, char *str)
|
||||
int config_read_string(const char *sectionname, const char *str)
|
||||
/* All the config parameters are placed in the given section in memory.*/
|
||||
{
|
||||
int pos = 0;
|
||||
@@ -143,8 +143,8 @@ int config_read_string(char *sectionname, char *str)
|
||||
}
|
||||
|
||||
|
||||
char *config_get_string(char * sectionname, char * keyname,
|
||||
int skip, char * default_value)
|
||||
const char *config_get_string(const char *sectionname, const char *keyname,
|
||||
int skip, const char *default_value)
|
||||
{
|
||||
key *k = find_key(find_section(sectionname), keyname, skip);
|
||||
|
||||
@@ -165,7 +165,7 @@ char *config_get_string(char * sectionname, char * keyname,
|
||||
}
|
||||
|
||||
|
||||
short config_get_bool(char *sectionname, char *keyname,
|
||||
short config_get_bool(const char *sectionname, const char *keyname,
|
||||
int skip, short default_value)
|
||||
{
|
||||
key *k = find_key(find_section(sectionname), keyname, skip);
|
||||
@@ -187,7 +187,7 @@ short config_get_bool(char *sectionname, char *keyname,
|
||||
}
|
||||
|
||||
|
||||
long int config_get_int(char *sectionname, char *keyname,
|
||||
long int config_get_int(const char *sectionname, const char *keyname,
|
||||
int skip, long int default_value)
|
||||
{
|
||||
key *k = find_key(find_section(sectionname), keyname, skip);
|
||||
@@ -204,7 +204,7 @@ long int config_get_int(char *sectionname, char *keyname,
|
||||
}
|
||||
|
||||
|
||||
double config_get_float(char *sectionname, char *keyname,
|
||||
double config_get_float(const char *sectionname, const char *keyname,
|
||||
int skip, double default_value)
|
||||
{
|
||||
key *k = find_key(find_section(sectionname), keyname, skip);
|
||||
@@ -221,13 +221,13 @@ double config_get_float(char *sectionname, char *keyname,
|
||||
}
|
||||
|
||||
|
||||
int config_has_section(char *sectionname)
|
||||
int config_has_section(const char *sectionname)
|
||||
{
|
||||
return (find_section(sectionname) != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int config_has_key(char *sectionname, char *keyname)
|
||||
int config_has_key(const char *sectionname, const char *keyname)
|
||||
{
|
||||
section *s = find_section(sectionname);
|
||||
int count = 0;
|
||||
@@ -320,7 +320,7 @@ connect_to_ldap(void)
|
||||
#define BUFSIZE 255
|
||||
#endif /* WITH_LDAP_SUPPORT */
|
||||
|
||||
section * find_section(char * sectionname)
|
||||
section *find_section(const char *sectionname)
|
||||
{
|
||||
section *s;
|
||||
|
||||
@@ -374,7 +374,7 @@ section * find_section(char * sectionname)
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
section * add_section(char * sectionname)
|
||||
section *add_section(const char *sectionname)
|
||||
{
|
||||
section *s;
|
||||
section **place = &first_section;
|
||||
@@ -392,7 +392,7 @@ section * add_section(char * sectionname)
|
||||
return(*place);
|
||||
}
|
||||
|
||||
key * find_key(section * s, char * keyname, int skip)
|
||||
key *find_key(section *s, const char *keyname, int skip)
|
||||
{
|
||||
key *k;
|
||||
int count = 0;
|
||||
@@ -516,7 +516,7 @@ key * find_key(section * s, char * keyname, int skip)
|
||||
return NULL; /* not found*/
|
||||
}
|
||||
|
||||
key * add_key(section * s, char * keyname, char * value)
|
||||
key *add_key(section *s, const char *keyname, const char *value)
|
||||
{
|
||||
if (s != NULL) {
|
||||
key *k;
|
||||
@@ -566,7 +566,7 @@ char get_next_char_f(FILE *f)
|
||||
|
||||
|
||||
|
||||
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, FILE *f)
|
||||
int process_config(section **current_section, char(*get_next_char)(), char modify_section_allowed, const char *source_descr, FILE *f)
|
||||
{
|
||||
char state = ST_INITIAL;
|
||||
char ch;
|
||||
|
||||
+12
-12
@@ -19,21 +19,21 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
int config_read_file( char *filename );
|
||||
int config_read_file(const char *filename);
|
||||
/* Opens the specified file and reads everything into memory.
|
||||
* Returns -1 on parsing errors.
|
||||
* Returns -2 if the file could not be opened or a read error occured.
|
||||
* Returns -16 if a malloc went wrong.
|
||||
*/
|
||||
|
||||
int config_read_string( char *sectionname, char *str );
|
||||
int config_read_string(const char *sectionname, const char *str);
|
||||
/* Reads everything in the string into memory.
|
||||
* Returns -1 on parsing errors.
|
||||
* Returns -16 if a malloc went wrong.
|
||||
*/
|
||||
|
||||
short config_get_bool( char *sectionname, char *keyname,
|
||||
int skip, short default_value );
|
||||
short config_get_bool(const char *sectionname, const char *keyname,
|
||||
int skip, short default_value);
|
||||
/* Tries to interpret a value in the config file as a boolean.
|
||||
* 0, false, no, n = false
|
||||
* 1, true, yes, y = true
|
||||
@@ -44,16 +44,16 @@ short config_get_bool( char *sectionname, char *keyname,
|
||||
* last.
|
||||
*/
|
||||
|
||||
long int config_get_int( char *sectionname, char *keyname,
|
||||
int skip, long int default_value );
|
||||
long int config_get_int(const char *sectionname, const char *keyname,
|
||||
int skip, long int default_value);
|
||||
/* Tries to interpret a value in the config file as an integer.*/
|
||||
|
||||
double config_get_float( char *sectionname, char *keyname,
|
||||
int skip, double default_value );
|
||||
double config_get_float(const char *sectionname, const char *keyname,
|
||||
int skip, double default_value);
|
||||
/* Tries to interpret a value in the config file as a float.*/
|
||||
|
||||
char *config_get_string( char * sectionname, char * keyname,
|
||||
int skip, char * default_value );
|
||||
const char *config_get_string(const char *sectionname, const char *keyname,
|
||||
int skip, const char *default_value);
|
||||
/* Returns a pointer to the string associated with the specified key.
|
||||
* The string should never be modified, and used only short-term. You can
|
||||
* for example scan it or copy it. In successive calls this function can
|
||||
@@ -80,12 +80,12 @@ char *config_get_string( char * sectionname, char * keyname,
|
||||
*
|
||||
*/
|
||||
|
||||
int config_has_section( char *sectionname );
|
||||
int config_has_section(const char *sectionname);
|
||||
/* Checks if a specified section exists.
|
||||
* Returns whether it exists.
|
||||
*/
|
||||
|
||||
int config_has_key( char *sectionname, char *keyname );
|
||||
int config_has_key(const char *sectionname, const char *keyname);
|
||||
/* Checks if a specified key within the specified section exists.
|
||||
* Returns the number of times the key exists.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user