From 77ad1b4a8ab4a15b23cd81cc33b35bf07109617f Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 27 May 2006 14:24:33 +0200 Subject: [PATCH] Replaced cf_string_node and cf_2string_node by more general simp_node and simp2_node and moved it to the libucw. (These are needed at many places, in many cases unrelated to configuration.) --- lib/Makefile | 2 +- lib/simple-lists.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ lib/simple-lists.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 lib/simple-lists.c create mode 100644 lib/simple-lists.h diff --git a/lib/Makefile b/lib/Makefile index ae6cd736..30ce8e3c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 index 00000000..8f14a3fe --- /dev/null +++ b/lib/simple-lists.c @@ -0,0 +1,48 @@ +/* + * UCW Library -- Linked Lists of Simple Items + * + * (c) 2006 Martin Mares + * + * 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 index 00000000..d4dd081e --- /dev/null +++ b/lib/simple-lists.h @@ -0,0 +1,49 @@ +/* + * UCW Library -- Linked Lists of Simple Items + * + * (c) 2006 Martin Mares + * + * 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 -- 2.39.2