From eabd52462bfdb409121b351f198d535649d2b3b9 Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 6 Dec 2018 09:23:52 +0200 Subject: Add log to file, fix list ckconf bug --- src/cklist.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/cklist.c') 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; } -- cgit v1.2.3