diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-04-29 21:36:52 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-04-29 21:36:52 +0300 |
commit | 93eae1c206796d76e930c0c4860e4ead9c8fca14 (patch) | |
tree | 239940d27be834bcd16b28d6fcd03db4a00f3072 /src/confparser.c | |
parent | 25ccc84ac00a7b3975dfdb0cc415522ca7793f0f (diff) | |
download | ck-93eae1c206796d76e930c0c4860e4ead9c8fca14.tar.gz ck-93eae1c206796d76e930c0c4860e4ead9c8fca14.tar.bz2 ck-93eae1c206796d76e930c0c4860e4ead9c8fca14.zip |
linkin park
Diffstat (limited to 'src/confparser.c')
-rw-r--r-- | src/confparser.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/confparser.c b/src/confparser.c index 0f193e0..80120c8 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -43,7 +43,7 @@ int read_next_line(char *line, FILE *f) { } ConfVar match_variables(char *line, char matched[]) { - if (line[0] == '#' || util_is_str_empty(line)) { + if (line[0] == '#' || str_is_empty(line)) { return CV_NO_VAL_OR_COMMENT; } #define X(var, str, name) \ @@ -74,7 +74,7 @@ ConfigParserResult parse(Conf *conf, UserOpt *opt) { int flag = 1; char line[STR_L]; char matched[STR_L]; - while (read_next_line(line, confPtr)) { + while (read_next_line(line, confPtr) == 0) { if (strlen(line) > STR_L) { return CPR_WRONG_CONFIG; } @@ -84,7 +84,6 @@ ConfigParserResult parse(Conf *conf, UserOpt *opt) { conf->var = malloc(strlen(matched)+1); \ strcpy(conf->var, matched); \ if (!util_is_dir(matched)) { \ - free(conf->var); \ return CPR_WRONG_##var; \ } \ break; @@ -111,9 +110,10 @@ int config_file_parse(Conf *conf, UserOpt *opt) { switch (parse(conf, opt)) { #define X(var,str,name) \ case CPR_WRONG_##var: \ - printf("Config error:\n" \ + printf("--[ Config error ]--\n" \ "%s: %s\n" \ "defined in config does not exist\n", name, conf->var); \ + free(conf->var); \ return 0; \ break; CONFIG_VARIABLES_TABLE @@ -128,6 +128,15 @@ int config_file_parse(Conf *conf, UserOpt *opt) { } } +void free_conf(Conf *conf) { + if (conf->VC_dir) { + free(conf->VC_dir); + } + if (conf->SCRT_dir) { + free(conf->SCRT_dir); + } +} + int init_create_config_file(UserOpt *opt) { char tmp[200]; if (!util_file_exists(opt->argv[0])) { |