diff options
author | Joursoir <chat@joursoir.net> | 2021-05-19 08:09:36 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-05-19 08:09:36 +0000 |
commit | f2dd637e6ea2ba2ea0c4f48a5f7def23ac38173b (patch) | |
tree | 6557bdfdeacbddd326cd932c0ae3baf905e1bba4 | |
parent | 17c4d7a48c3c9bf7052b6a47d9e3bc66d554def4 (diff) | |
download | ctimeline-f2dd637e6ea2ba2ea0c4f48a5f7def23ac38173b.tar.gz ctimeline-f2dd637e6ea2ba2ea0c4f48a5f7def23ac38173b.tar.bz2 ctimeline-f2dd637e6ea2ba2ea0c4f48a5f7def23ac38173b.zip |
ctimeline: open config file in function
-rw-r--r-- | ctimeline.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ctimeline.c b/ctimeline.c index cfb4e05..4bbb7bf 100644 --- a/ctimeline.c +++ b/ctimeline.c @@ -136,13 +136,16 @@ int read_config_line(FILE *f, string *name, string *value) return 0; } -void parse_config_file(FILE *f) +int parse_config_file(const char *fname) { - string *name = string_alloc(NULL); - string *value = string_alloc(NULL); + FILE *f = fopen(fname, "r"); + if(!f) // #TODO: print warning in logs + return 1; + + string *name = string_alloc(NULL, NULL); + string *value = string_alloc(NULL, NULL); while(read_config_line(f, name, value) == 0) { - // printf("name: %s; value: %s\n", name->s, value->s); handle_config_context(name->s, value->s); string_reset(name); string_reset(value); @@ -150,6 +153,8 @@ void parse_config_file(FILE *f) string_release(name); string_release(value); + fclose(f); + return 0; } int main(int argc, char **argv) |