summaryrefslogtreecommitdiff
path: root/src/config/tipidee-config-internal.h
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-23 10:31:31 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-23 10:31:31 +0000
commit12891d0e8551e3d6bb7bf1429f936e04be4da8b5 (patch)
tree7e4ac4bb5dc895b1b7604c8c9f76cca470964162 /src/config/tipidee-config-internal.h
parent941ff50d2183999d8f1cbd249b6a892f70091ded (diff)
downloadtipidee-12891d0e8551e3d6bb7bf1429f936e04be4da8b5.tar.xz
Refactor tipidee-config code to accommodate for headers
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/config/tipidee-config-internal.h')
-rw-r--r--src/config/tipidee-config-internal.h59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/config/tipidee-config-internal.h b/src/config/tipidee-config-internal.h
index 7ffee8a..190ac45 100644
--- a/src/config/tipidee-config-internal.h
+++ b/src/config/tipidee-config-internal.h
@@ -7,13 +7,16 @@
#include <string.h>
#include <skalibs/buffer.h>
+#include <skalibs/strerr.h>
#include <skalibs/stralloc.h>
+#include <skalibs/genalloc.h>
#include <skalibs/cdbmake.h>
+#include <skalibs/avltree.h>
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-typedef struct confnode_s confnode, *confnode_ref ;
-struct confnode_s
+typedef struct node_s node, *node_ref ;
+struct node_s
{
uint32_t key ;
uint32_t keylen ;
@@ -22,7 +25,16 @@ struct confnode_s
uint32_t filepos ;
uint32_t line ;
} ;
-#define CONFNODE_ZERO { .key = 0, .keylen = 0, .data = 0, .datalen = 0 }
+#define NODE_ZERO { .key = 0, .keylen = 0, .data = 0, .datalen = 0 }
+
+typedef struct repo_s repo, *repo_ref ;
+struct repo_s
+{
+ genalloc ga ;
+ avltree tree ;
+ stralloc *storage ;
+} ;
+#define REPO_ZERO { .ga = GENALLOC_ZERO, .tree = AVLTREE_ZERO, .storage = 0 }
struct global_s
{
@@ -33,20 +45,42 @@ struct global_s
extern struct global_s g ;
- /* confnode */
+ /* node */
+
+extern void node_start (stralloc *, node *, char const *, size_t, uint32_t) ;
+extern void node_add (stralloc *, node *, char const *, size_t) ;
-extern void confnode_start (confnode *, char const *, size_t, uint32_t) ;
-extern void confnode_add (confnode *, char const *, size_t) ;
+
+ /* repo */
+
+extern void *node_dtok (uint32_t, void *) ;
+extern int node_cmp (void const *, void const *, void *) ;
+extern node const *repo_search (repo const *, char const *) ;
+extern void repo_add (repo *, node const *) ;
+extern void repo_update (repo *, node const *) ;
/* conftree */
-extern confnode const *conftree_search (char const *) ;
-extern void conftree_add (confnode const *) ;
-extern void conftree_update (confnode const *) ;
+extern void confnode_start (node *, char const *, size_t, uint32_t) ;
+extern void confnode_add (node *, char const *, size_t) ;
+
+extern node const *conftree_search (char const *) ;
+extern void conftree_add (node const *) ;
+extern void conftree_update (node const *) ;
extern int conftree_write (cdbmaker *) ;
+ /* headers */
+
+extern void header_start (node *, char const *, size_t, uint32_t) ;
+extern void header_add (node *, char const *, size_t) ;
+
+extern node const *headers_search (char const *) ;
+extern void headers_add (node const *) ;
+extern int headers_write (void) ;
+
+
/* lexparse */
extern void conf_lexparse (buffer *, char const *) ;
@@ -56,4 +90,11 @@ extern void conf_lexparse (buffer *, char const *) ;
extern void conf_defaults (void) ;
+
+ /* headers */
+
+extern node const *headers_search (char const *) ;
+extern void headers_add (node const *) ;
+extern void headers_finish (void) ;
+
#endif