rename structures key & section to ConfigKey & ConfigSection to avoid

generation wrong links in Doxygen
This commit is contained in:
marschap
2008-12-21 17:40:42 +00:00
parent 02d2bca304
commit ca9964e03a
+50 -48
View File
@@ -25,32 +25,34 @@
#include "shared/report.h"
typedef struct key {
char *name;
char *value;
struct key *next_key;
} key;
/** configuration key */
typedef struct _config_key {
char *name; /**< name of the config key */
char *value; /**< value of the config key */
struct _config_key *next_key; /**< pointer to next config key */
} ConfigKey;
typedef struct section {
char *name;
key *first_key;
struct section *next_section;
} section;
/** configuration section */
typedef struct _config_section {
char *name; /**< name of the config section */
ConfigKey *first_key; /**< config keys in the config section */
struct _config_section *next_section; /**< pointer to next config section */
} ConfigSection;
static section *first_section = NULL;
static ConfigSection *first_section = NULL;
/* Yes there is a static. It's C after all :)*/
static section *find_section(const char *sectionname);
static section *add_section(const char *sectionname);
static key *find_key(section *s, const char *keyname, int skip);
static key *add_key(section *s, const char *keyname, const char *value);
static ConfigSection *find_section(const char *sectionname);
static ConfigSection *add_section(const char *sectionname);
static ConfigKey *find_key(ConfigSection *s, const char *keyname, int skip);
static ConfigKey *add_key(ConfigSection *s, const char *keyname, const char *value);
static char get_next_char_f(FILE *f);
#if defined(LCDPROC_CONFIG_READ_STRING)
static int process_config(section **current_section, char(*get_next_char)(), const char *source_descr, FILE *f);
static int process_config(ConfigSection **current_section, char(*get_next_char)(), const char *source_descr, FILE *f);
#else
static int process_config(section **current_section, const char *source_descr, FILE *f);
static int process_config(ConfigSection **current_section, const char *source_descr, FILE *f);
#endif
@@ -64,7 +66,7 @@ static int process_config(section **current_section, const char *source_descr, F
int config_read_file(const char *filename)
{
FILE *f;
section *curr_section = NULL;
ConfigSection *curr_section = NULL;
int result = 0;
report(RPT_NOTICE, "Using Configuration File: %s", filename);
@@ -91,7 +93,7 @@ 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;
section *s;
ConfigSection *s;
/* We use a nested fuction to transfer the characters from buffer to parser*/
char get_next_char() {
@@ -145,7 +147,7 @@ int config_read_string(const char *sectionname, const char *str)
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);
ConfigKey *k = find_key(find_section(sectionname), keyname, skip);
if (k == NULL)
return default_value;
@@ -182,7 +184,7 @@ const char *config_get_string(const char *sectionname, const 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);
ConfigKey *k = find_key(find_section(sectionname), keyname, skip);
if (k == NULL)
return default_value;
@@ -221,7 +223,7 @@ short config_get_bool(const char *sectionname, const char *keyname,
short config_get_tristate(const char *sectionname, const char *keyname,
int skip, const char *name3rd, short default_value)
{
key *k = find_key(find_section(sectionname), keyname, skip);
ConfigKey *k = find_key(find_section(sectionname), keyname, skip);
if (k == NULL)
return default_value;
@@ -257,7 +259,7 @@ short config_get_tristate(const char *sectionname, const 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);
ConfigKey *k = find_key(find_section(sectionname), keyname, skip);
if (k != NULL) {
char *end;
@@ -284,7 +286,7 @@ long int config_get_int(const char *sectionname, const 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);
ConfigKey *k = find_key(find_section(sectionname), keyname, skip);
if (k != NULL) {
char *end;
@@ -317,11 +319,11 @@ int config_has_section(const char *sectionname)
*/
int config_has_key(const char *sectionname, const char *keyname)
{
section *s = find_section(sectionname);
ConfigSection *s = find_section(sectionname);
int count = 0;
if (s != NULL) {
key *k;
ConfigKey *k;
for (k = s->first_key; k != NULL; k = k->next_key) {
/* Did we find the right key ?*/
@@ -336,12 +338,12 @@ int config_has_key(const char *sectionname, const char *keyname)
/** Clear configuration. */
void config_clear(void)
{
section *s;
section *next_s;
ConfigSection *s;
ConfigSection *next_s;
for (s = first_section; s != NULL; s = next_s) {
key *k;
key *next_k;
ConfigKey *k;
ConfigKey *next_k;
for (k = s->first_key; k != NULL; k = next_k) {
/* Advance before we destroy the current key */
@@ -365,9 +367,9 @@ void config_clear(void)
/**** INTERNAL FUNCTIONS ****/
static section *find_section(const char *sectionname)
static ConfigSection *find_section(const char *sectionname)
{
section *s;
ConfigSection *s;
for (s = first_section; s != NULL; s = s->next_section) {
if (strcasecmp(s->name, sectionname) == 0) {
@@ -378,15 +380,15 @@ static section *find_section(const char *sectionname)
}
static section *add_section(const char *sectionname)
static ConfigSection *add_section(const char *sectionname)
{
section *s;
section **place = &first_section;
ConfigSection *s;
ConfigSection **place = &first_section;
for (s = first_section; s != NULL; s = s->next_section)
place = &(s->next_section);
*place = (section*) malloc(sizeof(section));
*place = (ConfigSection *) malloc(sizeof(ConfigSection));
if (*place != NULL) {
(*place)->name = strdup(sectionname);
(*place)->first_key = NULL;
@@ -397,11 +399,11 @@ static section *add_section(const char *sectionname)
}
static key *find_key(section *s, const char *keyname, int skip)
static ConfigKey *find_key(ConfigSection *s, const char *keyname, int skip)
{
key *k;
ConfigKey *k;
int count = 0;
key *last_key = NULL;
ConfigKey *last_key = NULL;
/* Check for NULL section*/
if (s == NULL)
@@ -425,16 +427,16 @@ static key *find_key(section *s, const char *keyname, int skip)
}
static key *add_key(section *s, const char *keyname, const char *value)
static ConfigKey *add_key(ConfigSection *s, const char *keyname, const char *value)
{
if (s != NULL) {
key *k;
key **place = &(s->first_key);
ConfigKey *k;
ConfigKey **place = &(s->first_key);
for (k = s->first_key; k != NULL; k = k->next_key)
place = &(k->next_key);
*place = (key *) malloc(sizeof(key));
*place = (ConfigKey *) malloc(sizeof(ConfigKey));
if (*place != NULL) {
(*place)->name = strdup(keyname);
(*place)->value = strdup(value);
@@ -480,9 +482,9 @@ static char get_next_char_f(FILE *f)
#if defined(LCDPROC_CONFIG_READ_STRING)
static int process_config(section **current_section, char(*get_next_char)(), const char *source_descr, FILE *f)
static int process_config(ConfigSection **current_section, char(*get_next_char)(), const char *source_descr, FILE *f)
#else
static int process_config(section **current_section, const char *source_descr, FILE *f)
static int process_config(ConfigSection **current_section, const char *source_descr, FILE *f)
#endif
{
int state = ST_INITIAL;
@@ -494,7 +496,7 @@ static int process_config(section **current_section, const char *source_descr, F
char value[MAXVALUELENGTH+1];
int value_pos = 0;
int escape = 0;
key *k;
ConfigKey *k;
int line_nr = 1;
int error = 0;
@@ -807,10 +809,10 @@ static int process_config(section **current_section, const char *source_descr, F
#if CONFIGFILE_DEBUGTEST
void config_dump(void)
{
section *s;
ConfigSection *s;
for (s = first_section; s != NULL; s = s->next_section) {
key *k;
ConfigKey *k;
fprintf(stderr, "[%s]\n", s->name);