]> mj.ucw.cz Git - libucw.git/commitdiff
Replaced cf_string_node and cf_2string_node by more general simp_node
authorMartin Mares <mj@ucw.cz>
Sat, 27 May 2006 12:24:33 +0000 (14:24 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 27 May 2006 12:24:33 +0000 (14:24 +0200)
and simp2_node and moved it to the libucw. (These are needed at many
places, in many cases unrelated to configuration.)

lib/Makefile
lib/simple-lists.c [new file with mode: 0644]
lib/simple-lists.h [new file with mode: 0644]

index ae6cd736e48118b1b0459f3f238192883d18bf70..30ce8e3cfa53529ed0384bf0ff132a4c7699c532 100644 (file)
@@ -9,7 +9,7 @@ endif
 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 \
diff --git a/lib/simple-lists.c b/lib/simple-lists.c
new file mode 100644 (file)
index 0000000..8f14a3f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *     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
+  }
+};
diff --git a/lib/simple-lists.h b/lib/simple-lists.h
new file mode 100644 (file)
index 0000000..d4dd081
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *     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