aboutsummaryrefslogtreecommitdiffstats
path: root/src/cklist.h
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-05-08 03:32:44 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-05-08 03:32:44 +0300
commit1f30b63db9aeab2332d269939c46c2fd9a0f0f8d (patch)
treea0ec8aae21f42be4716ecb6fa5b685583c01e2cd /src/cklist.h
parent3a3424774944a421e1b93cbaf533a3500a4d613c (diff)
downloadck-1f30b63db9aeab2332d269939c46c2fd9a0f0f8d.tar.gz
ck-1f30b63db9aeab2332d269939c46c2fd9a0f0f8d.tar.bz2
ck-1f30b63db9aeab2332d269939c46c2fd9a0f0f8d.zip
Some work on lists
Diffstat (limited to 'src/cklist.h')
-rw-r--r--src/cklist.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/cklist.h b/src/cklist.h
new file mode 100644
index 0000000..9c883b5
--- /dev/null
+++ b/src/cklist.h
@@ -0,0 +1,56 @@
+/* cklist.h - Custom list data structure for ck ------------------------*- C -*-
+ *
+ * This file is part of ck, the config keeper
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2018 Anastasis Grammenos
+ * GPLv3 (see LICENCE for the full notice)
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Ck needs a list of strings. Assists with finding the correct config file
+ * to edit when using ck edit and provides a backend to the ck list action.
+ *
+ * -------------------------------------------------------------------------- */
+
+typedef struct cklist_st cklist;
+struct cklist_st {
+ int size;
+ int pos;
+ char **arr;
+};
+
+extern cklist* list_make_new();
+extern void list_add(cklist *ckl, const char *str);
+extern cklist* list_make_and_add(const char *str);
+extern void list_rewind(cklist *ckl);
+
+extern int list_next(cklist *ckl);
+extern char* list_get(cklist *ckl);
+
+extern void list_size(cklist *ckl);
+
+/* rewinds */
+extern cklist* list_duplicate(cklist *ckl);
+/* rewinds */
+extern cklist* list_move(cklist *ckl);
+/* rewinds
+ * copy from index (>=) to the end */
+extern cklist* list_copy_from(cklist *ckl, int index);
+/* rewinds
+ * copy from the start until (<) index*/
+extern cklist* list_copy_until(cklist *ckl, int index);
+
+/* rewinds
+ * copy from (>=) until (<) */
+extern cklist* list_copy_part(cklist *ckl, int from, int until);
+
+/* rewinds */
+extern void list_print_lisp(cklist *ckl);
+/* rewinds */
+extern void list_print(cklist *ckl);
+
+/* Deallocate resources */
+extern void list_free(cklist *ckl);
+