LIBUCW_MODS= \
alloc alloc_str realloc mempool mempool-str mempool-fmt \
mmap pagecache partmap hashfunc \
- lists slists sorter bitsig \
+ lists slists simple-lists sorter bitsig \
log log-file proctitle \
conf-alloc conf-dump conf-input conf-intr conf-journal conf-parse conf-section \
ipaccess \
--- /dev/null
+/*
+ * UCW Library -- Linked Lists of Simple Items
+ *
+ * (c) 2006 Martin Mares <mj@ucw.cz>
+ *
+ * This software may be freely distributed and used according to the terms
+ * of the GNU Lesser General Public License.
+ */
+
+#include "lib/lib.h"
+#include "lib/mempool.h"
+#include "lib/conf.h"
+#include "lib/simple-lists.h"
+
+simp_node *
+simp_append(struct mempool *mp, clist *l)
+{
+ simp_node *n = mp_alloc_fast(mp, sizeof(*n));
+ clist_add_tail(l, &n->n);
+ return n;
+}
+
+simp2_node *
+simp2_append(struct mempool *mp, clist *l)
+{
+ simp2_node *n = mp_alloc_fast(mp, sizeof(*n));
+ clist_add_tail(l, &n->n);
+ return n;
+}
+
+/* Configuration sections for common lists */
+
+struct cf_section cf_string_list_config = {
+ CF_TYPE(simp_node),
+ CF_ITEMS {
+ CF_STRING("String", PTR_TO(simp_node, s)),
+ CF_END
+ }
+};
+
+struct cf_section cf_2string_list_config = {
+ CF_TYPE(simp2_node),
+ CF_ITEMS {
+ CF_STRING("Src", PTR_TO(simp2_node, s1)),
+ CF_STRING("Dest", PTR_TO(simp2_node, s2)),
+ CF_END
+ }
+};
--- /dev/null
+/*
+ * UCW Library -- Linked Lists of Simple Items
+ *
+ * (c) 2006 Martin Mares <mj@ucw.cz>
+ *
+ * This software may be freely distributed and used according to the terms
+ * of the GNU Lesser General Public License.
+ */
+
+#ifndef _UCW_SIMPLE_LISTS_H
+#define _UCW_SIMPLE_LISTS_H
+
+#include "lib/clists.h"
+
+typedef struct simp_node {
+ cnode n;
+ union {
+ byte *s;
+ void *p;
+ int i;
+ uns u;
+ };
+} simp_node;
+
+typedef struct simp2_node {
+ cnode n;
+ union {
+ byte *s1;
+ void *p1;
+ int i1;
+ uns u1;
+ };
+ union {
+ byte *s2;
+ void *p2;
+ int i2;
+ uns u2;
+ };
+} simp2_node;
+
+struct mempool;
+simp_node *simp_append(struct mempool *mp, clist *l);
+simp2_node *simp2_append(struct mempool *mp, clist *l);
+
+/* Configuration sections */
+extern struct cf_section cf_string_list_config;
+extern struct cf_section cf_2string_list_config;
+
+#endif