diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-10-10 17:14:17 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-10-10 17:14:17 +0200 |
commit | 754ff9123ec9e2dd317351cd7c631ffa9f76b343 (patch) | |
tree | 8f375f7134b38e01cc0622d0ceb04f080faa18ab /conf.c | |
parent | 7cca327d228d6314e30fc5418cae0b9fbd4691cb (diff) |
ported all custom configs to common config
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -21,13 +21,7 @@ #include <stdlib.h> #include "conf.h" -struct conf_item_t { - char *key; - char *value; - struct conf_item_t *next; -}; - -static struct conf_item_t *conf_items; +static DB_conf_item_t *conf_items; int conf_load (void) { @@ -86,7 +80,7 @@ conf_free (void) { const char * conf_get_str (const char *key, const char *def) { - for (struct conf_item_t *it = conf_items; it; it = it->next) { + for (DB_conf_item_t *it = conf_items; it; it = it->next) { if (!strcasecmp (key, it->key)) { return it->value; } @@ -106,17 +100,28 @@ conf_get_int (const char *key, int def) { return v ? atoi (v) : def; } +DB_conf_item_t * +conf_find (const char *group, DB_conf_item_t *prev) { + int l = strlen (group); + for (DB_conf_item_t *it = prev ? prev->next : conf_items; it; it = it->next) { + if (!strncasecmp (group, it->key, l)) { + return it; + } + } + return NULL; +} + void conf_set_str (const char *key, const char *val) { - for (struct conf_item_t *it = conf_items; it; it = it->next) { + for (DB_conf_item_t *it = conf_items; it; it = it->next) { if (!strcasecmp (key, it->key)) { free (it->value); it->value = strdup (val); return; } } - struct conf_item_t *it = malloc (sizeof (struct conf_item_t)); - memset (it, 0, sizeof (struct conf_item_t)); + DB_conf_item_t *it = malloc (sizeof (DB_conf_item_t)); + memset (it, 0, sizeof (DB_conf_item_t)); it->next = conf_items; it->key = strdup (key); it->value = strdup (val); |