aboutsummaryrefslogtreecommitdiffstats
path: root/src/confparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/confparser.c')
-rw-r--r--src/confparser.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/confparser.c b/src/confparser.c
index 6c01e6d..48f0c71 100644
--- a/src/confparser.c
+++ b/src/confparser.c
@@ -16,7 +16,7 @@ ERRLOG(configfile);
static const char * const CONFIG_NAME = "/ckrc";
void initialize_conf(Conf *c) {
-#define X(var, str, name) \
+#define X(var, str, name, optional) \
c->var = NULL;
CONFIG_VARIABLES_TABLE
#undef X
@@ -35,7 +35,7 @@ ConfVar match_variables(char *line, char matched[]) {
if (line[0] == '#' || str_is_empty(line)) {
return CV_NO_VAL_OR_COMMENT;
}
-#define X(var, str, name) \
+#define X(var, str, name, optional) \
if (sscanf(line, str, matched) == 1) { \
return CV_##var; \
}
@@ -109,7 +109,7 @@ int config_file_parse(Conf *conf, UserOpt *opt) {
return -1;
}
switch(match_variables(line, matched)) {
-#define X(var, str, name) \
+#define X(var, str, name, optional) \
case CV_##var: \
conf->var = malloc(strlen(matched)+1); \
strcpy(conf->var, matched); \
@@ -131,8 +131,8 @@ int config_file_parse(Conf *conf, UserOpt *opt) {
}
/* Could add an optional row that would make the config var
* optional. */
-#define X(var, str, name) \
- if (!conf->var) { \
+#define X(var, str, name, optional) \
+ if (!optional && !conf->var) { \
ERR("Missing %s", name); \
return -1; \
}
@@ -142,7 +142,7 @@ int config_file_parse(Conf *conf, UserOpt *opt) {
}
void free_conf(Conf *conf) {
-#define X(var,str,name) \
+#define X(var, str, name, optional) \
if (conf->var) { \
free(conf->var); \
}