diff options
Diffstat (limited to 'src/confparser.c')
-rw-r--r-- | src/confparser.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/confparser.c b/src/confparser.c index 7f61037..64bfe34 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -14,7 +14,9 @@ #include "ckutil.h" #include "confparser.h" +#include "ckerrlog.h" +ERRLOG(configfile); const char * const CONFIG_NAME = "/ckrc"; @@ -86,13 +88,19 @@ ConfigParserResult parse(Conf *conf, UserOpt *opt) { if (!util_is_dir(matched)) { \ return CPR_WRONG_##var; \ } \ + LOG("Found %s: %s", name, conf->var); \ break; CONFIG_VARIABLES_TABLE #undef X case CV_NO_VAL_OR_COMMENT: break; default: - printf("%s:\n%s\n", "Config error in line", line); + if (line[strlen(line) - 1] == '\n') { + ERR("Config error in line: %.*s", strlen(line) - 1, line); + } + else { + ERR("Config error in line: %s", line); + } } } #define X(var, str) \ @@ -107,21 +115,20 @@ ConfigParserResult parse(Conf *conf, UserOpt *opt) { } int config_file_parse(Conf *conf, UserOpt *opt) { + LOG("Using '%s' for ck configuration directory", opt->confDir); switch (parse(conf, opt)) { #define X(var,str,name) \ case CPR_WRONG_##var: \ - printf("--[ Config error ]--\n" \ - "%s: %s\n" \ - "defined in config does not exist\n", name, conf->var); \ + ERR("%s %s defined in config doesn't exist", name, conf->var); \ return 0; \ break; CONFIG_VARIABLES_TABLE #undef X case CPR_NO_CONFIG_FILE: - printf("The config file specified could not be found\n"); + ERR("The config file specified could not be found"); return 0; case CPR_WRONG_CONFIG: - printf("Config help\n"); + ERR("Config help\n"); case CPR_OK: return 1; } @@ -139,13 +146,13 @@ void free_conf(Conf *conf) { int init_create_config_file(UserOpt *opt) { char absVCdir[STR_L]; if (!util_file_exists(list_get_at(opt->args, 0), absVCdir)) { - printf("Version control directory: %s\ndoes not exist.\n", list_get_at(opt->args, 0)); + ERR("Version control directory: %s\ndoes not exist.\n", list_get_at(opt->args, 0)); return 1; } char absSRdir[STR_L]; if (!util_file_exists(list_get_at(opt->args, 1), absSRdir)) { - printf("Secret directory: %s\ndoes not exist.\n", list_get_at(opt->args, 1)); + ERR("Secret directory: %s\ndoes not exist.\n", list_get_at(opt->args, 1)); return 1; } |