From 12891d0e8551e3d6bb7bf1429f936e04be4da8b5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 23 Oct 2023 10:31:31 +0000 Subject: Refactor tipidee-config code to accommodate for headers Signed-off-by: Laurent Bercot --- src/config/tipidee-config-internal.h | 59 ++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 9 deletions(-) (limited to 'src/config/tipidee-config-internal.h') 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 #include +#include #include +#include #include +#include #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 -- cgit v1.2.3