initial load of upstream version 1.06.32
[xmlrpc-c] / lib / abyss / src / data.h
1 #ifndef DATA_H_INCLUDED
2 #define DATA_H_INCLUDED
3
4 #include "thread.h"
5
6 /*********************************************************************
7 ** List
8 *********************************************************************/
9
10 typedef struct {
11     void **item;
12     uint16_t size;
13     uint16_t maxsize;
14     abyss_bool autofree;
15 } TList;
16
17 void
18 ListInit(TList * const listP);
19
20 void
21 ListInitAutoFree(TList * const listP);
22
23 void
24 ListFree(TList * const listP);
25
26 void
27 ListFreeItems(TList * const listP);
28
29 abyss_bool
30 ListAdd(TList * const listP,
31         void *  const str);
32
33 void
34 ListRemove(TList * const listP);
35
36 abyss_bool
37 ListAddFromString(TList *      const listP,
38                   const char * const c);
39
40 abyss_bool
41 ListFindString(TList *      const listP,
42                const char * const str,
43                uint16_t *   const indexP);
44
45
46 typedef struct 
47 {
48     char *name,*value;
49     uint16_t hash;
50 } TTableItem;
51
52 typedef struct
53 {
54     TTableItem *item;
55     uint16_t size,maxsize;
56 } TTable;
57
58 void
59 TableInit(TTable * const t);
60
61 void
62 TableFree(TTable * const t);
63
64 abyss_bool
65 TableAdd(TTable *     const t,
66          const char * const name,
67          const char * const value);
68
69 abyss_bool
70 TableAddReplace(TTable *     const t,
71                 const char * const name,
72                 const char * const value);
73
74 abyss_bool
75 TableFindIndex(TTable *     const t,
76                const char * const name,
77                uint16_t *   const index);
78
79 char *
80 TableFind(TTable *     const t,
81           const char * const name);
82
83
84 /*********************************************************************
85 ** Pool
86 *********************************************************************/
87
88 typedef struct _TPoolZone {
89     char * pos;
90     char * maxpos;
91     struct _TPoolZone * next;
92     struct _TPoolZone * prev;
93 /*  char data[0]; Some compilers don't accept this */
94     char data[1];
95 } TPoolZone;
96
97 typedef struct {
98     TPoolZone * firstzone;
99     TPoolZone * currentzone;
100     uint32_t zonesize;
101     TMutex mutex;
102 } TPool;
103
104 abyss_bool
105 PoolCreate(TPool *  const poolP,
106            uint32_t const zonesize);
107
108 void
109 PoolFree(TPool * const poolP);
110
111 void *
112 PoolAlloc(TPool *  const poolP,
113           uint32_t const size);
114
115 void
116 PoolReturn(TPool *  const poolP,
117            void *   const blockP);
118
119 const char *
120 PoolStrdup(TPool *      const poolP,
121            const char * const origString);
122
123
124 #endif