From 78ee1c72c670a71bfd165448676fc65bff802916 Mon Sep 17 00:00:00 2001 From: gramanas Date: Mon, 19 Nov 2018 19:11:06 +0200 Subject: Add ability to use ck without secret dir --- src/confparser.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/confparser.c') 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); \ } -- cgit v1.2.3