#include "conf.h"
/* Types */
-typedef enum { number, string } type_t;
+typedef enum { NUMBER, STRING } type_t;
typedef struct {
type_t type;
if ((entry = conf_get(key))) {
tdelete(entry, &conf, conf_cmp);
free(entry->key);
- if (entry->type == string)
+ if (entry->type == STRING)
free(entry->str);
free(entry);
}
entry = new0(entry_t);
entry->key = strdup(key);
if (str) {
- entry->type = string;
+ entry->type = STRING;
entry->str = strdup(str);
printf("set_str: %s = %s\n", key, str);
} else {
- entry->type = number;
+ entry->type = NUMBER;
entry->num = num;
printf("set_num: %s = %d\n", key, num);
}
int conf_get_int(const char *key, int def)
{
entry_t *entry = conf_get(key);
- return entry && entry->type == number
+ return entry && entry->type == NUMBER
? entry->num : def;
}
const char *conf_get_str(const char *key, const char *def)
{
entry_t *entry = conf_get(key);
- return entry && entry->type == string
+ return entry && entry->type == STRING
? entry->str : def;
}