]> mj.ucw.cz Git - eval.git/blob - ucw/simple-lists.h
MO-P: Templates: New homes for Jessie
[eval.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 /***
16  * To simplify very common usage of circular linked links, whose nodes can hold only one or two trivial values,
17  * we define some generic node types, called the simple nodes.
18  *
19  * To avoid some type casts, values in simple nodes are defined as unions of most frequent types.
20  ***/
21
22 /**
23  * Simple node with one value.
24  **/
25 typedef struct simp_node {
26   cnode n;
27   union {
28     char *s;
29     void *p;
30     int i;
31     uns u;
32   };
33 } simp_node;
34
35 /**
36  * Simple node with two values.
37  **/
38 typedef struct simp2_node {
39   cnode n;
40   union {
41     char *s1;
42     void *p1;
43     int i1;
44     uns u1;
45   };
46   union {
47     char *s2;
48     void *p2;
49     int i2;
50     uns u2;
51   };
52 } simp2_node;
53
54 struct mempool;
55
56 /**
57  * Allocate a new one-value node on memory pool @mp and insert it to @l. The value is undefined and should be changed afterwards.
58  **/
59 simp_node *simp_append(struct mempool *mp, clist *l);
60
61 /**
62  * Allocate a new two-value node on memory pool @mp and insert it to @l. The values are undefined and should be changed afterwards.
63  **/
64 simp2_node *simp2_append(struct mempool *mp, clist *l);
65
66 /* Configuration sections */
67
68 /**
69  * Default definition of the configuration section with one-value string node. Identifier of the value is `String`.
70  **/
71 extern struct cf_section cf_string_list_config;
72
73 /**
74  * Default definition of the configuration section with two-value string node. Identifiers of the values are `Src` and `Dest`.
75  **/
76 extern struct cf_section cf_2string_list_config;
77
78 #endif