]> mj.ucw.cz Git - libucw.git/blob - ucw/simple-lists.h
Merge branch 'master' into dev-sizet
[libucw.git] / ucw / simple-lists.h
1 /*
2  *      UCW Library -- Linked Lists of Simple Items
3  *
4  *      (c) 2006 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_SIMPLE_LISTS_H
11 #define _UCW_SIMPLE_LISTS_H
12
13 #include <ucw/clists.h>
14
15 #ifdef CONFIG_UCW_CLEAN_ABI
16 #define cf_2string_list_config ucw_cf_2string_list_config
17 #define cf_string_list_config ucw_cf_string_list_config
18 #define simp2_append ucw_simp2_append
19 #define simp_append ucw_simp_append
20 #endif
21
22 /***
23  * To simplify very common usage of circular linked links, whose nodes can hold only one or two trivial values,
24  * we define some generic node types, called the simple nodes.
25  *
26  * To avoid some type casts, values in simple nodes are defined as unions of most frequent types.
27  ***/
28
29 /**
30  * Simple node with one value.
31  **/
32 typedef struct simp_node {
33   cnode n;
34   union {
35     char *s;
36     void *p;
37     int i;
38     uint u;
39   };
40 } simp_node;
41
42 /**
43  * Simple node with two values.
44  **/
45 typedef struct simp2_node {
46   cnode n;
47   union {
48     char *s1;
49     void *p1;
50     int i1;
51     uint u1;
52   };
53   union {
54     char *s2;
55     void *p2;
56     int i2;
57     uint u2;
58   };
59 } simp2_node;
60
61 struct mempool;
62
63 /**
64  * Allocate a new one-value node on memory pool @mp and insert it to @l. The value is undefined and should be changed afterwards.
65  **/
66 simp_node *simp_append(struct mempool *mp, clist *l);
67
68 /**
69  * Allocate a new two-value node on memory pool @mp and insert it to @l. The values are undefined and should be changed afterwards.
70  **/
71 simp2_node *simp2_append(struct mempool *mp, clist *l);
72
73 /* Configuration sections */
74
75 /**
76  * Default definition of the configuration section with one-value string node. Identifier of the value is `String`.
77  **/
78 extern struct cf_section cf_string_list_config;
79
80 /**
81  * Default definition of the configuration section with two-value string node. Identifiers of the values are `Src` and `Dest`.
82  **/
83 extern struct cf_section cf_2string_list_config;
84
85 #endif