diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-11-19 19:11:06 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-11-19 19:11:06 +0200 |
commit | 78ee1c72c670a71bfd165448676fc65bff802916 (patch) | |
tree | 893b0f09dfc84f3fd7f1ac218213012f33d5b612 /src/confparser.c | |
parent | 84bbbb91c9154ca0b1c295eb7d1aa0de59450764 (diff) | |
download | ck-78ee1c72c670a71bfd165448676fc65bff802916.tar.gz ck-78ee1c72c670a71bfd165448676fc65bff802916.tar.bz2 ck-78ee1c72c670a71bfd165448676fc65bff802916.zip |
Add ability to use ck without secret dir
Diffstat (limited to 'src/confparser.c')
-rw-r--r-- | src/confparser.c | 12 |
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); \ } |