/*
- * Copyright (c) 2011, Andy Spencer <andy753421@gmail.com>
+ * Copyright (c) 2011-2012, Andy Spencer <andy753421@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#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;
}
{
conf_argc = argc;
conf_argv = argv;
- snprintf(conf_path, sizeof(conf_path),
- "%s/%s", getenv("HOME"), ".wmpus");
+ snprintf(conf_path, sizeof(conf_path), "%s/%s",
+ getenv("HOME") ?: getenv("HOMEPATH") ?: ".",
+ ".wmpus");
conf_reload();
}