declare constant function parameters const (as well as constant function return values)

This commit is contained in:
marschap
2006-09-12 16:23:24 +00:00
parent f34c246200
commit cc2c84a7b8
21 changed files with 78 additions and 68 deletions
+22 -22
View File
@@ -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
View File
@@ -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.
*/