aboutsummaryrefslogtreecommitdiffstats
path: root/src/cklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cklist.c')
-rw-r--r--src/cklist.c23
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;
}