diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2018-12-06 09:23:52 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2018-12-06 09:23:52 +0200 |
commit | eabd52462bfdb409121b351f198d535649d2b3b9 (patch) | |
tree | 434ec71438df3c822d34fc0b8d83fa977264c546 /src/cklist.c | |
parent | bd85acf6a408674bcdcb5116963fe4fea2247280 (diff) | |
download | ck-eabd52462bfdb409121b351f198d535649d2b3b9.tar.gz ck-eabd52462bfdb409121b351f198d535649d2b3b9.tar.bz2 ck-eabd52462bfdb409121b351f198d535649d2b3b9.zip |
Add log to file, fix list ckconf bug
Diffstat (limited to 'src/cklist.c')
-rw-r--r-- | src/cklist.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cklist.c b/src/cklist.c index f255556..4ba51bc 100644 --- a/src/cklist.c +++ b/src/cklist.c @@ -191,6 +191,29 @@ int list_exists(cklist *ckl, const char *str) { return 0; } +int list_write_to_file(cklist *ckl, char *path, int append) { + list_rewind(ckl); + if (!list_size(ckl)) { + return -1; + } + FILE *f; + if (append) { + f = fopen(path, "a"); + } + else { + f = fopen(path, "w"); + } + if (!f) { + return -1; + } + do { + fputs(list_get(ckl), f); + } while(list_next(ckl)); + fclose(f); + list_rewind(ckl); + return 0; +} + unsigned int list_size(cklist *ckl) { return ckl->size; } |