summaryrefslogtreecommitdiff
path: root/src/config/shibari-cache-config-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/shibari-cache-config-internal.h')
-rw-r--r--src/config/shibari-cache-config-internal.h77
1 files changed, 31 insertions, 46 deletions
diff --git a/src/config/shibari-cache-config-internal.h b/src/config/shibari-cache-config-internal.h
index c7b0197..77f3e79 100644
--- a/src/config/shibari-cache-config-internal.h
+++ b/src/config/shibari-cache-config-internal.h
@@ -7,85 +7,70 @@
#include <string.h>
#include <stdlib.h>
+#include <skalibs/diuint32.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>
+#include <skalibs/cdbmake.h>
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
+#define diestorage() strerr_diefu2x(100, "add node to configuration tree", ": too much data")
+
+typedef int memcmp_func (void const *, void const *, size_t) ;
+typedef memcmp_func *memcmp_func_ref ;
typedef struct node_s node, *node_ref ;
struct node_s
{
- uint32_t key ;
- uint32_t keylen ;
- uint32_t data ;
- uint32_t datalen ;
- uint32_t filepos ;
+ diuint32 key ;
uint32_t line ;
+ stralloc data ;
} ;
-#define NODE_ZERO { .key = 0, .keylen = 0, .data = 0, .datalen = 0 }
+#define NODE_ZERO { .key = DIUINT32_ZERO, .line = 0, .data = STRALLOC_ZERO }
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
-{
stralloc storage ;
+ genalloc list ; /* node */
+ avltree tree ;
} ;
-#define GLOBAL_ZERO { .storage = STRALLOC_ZERO }
-
-extern struct global_s g ;
-
-
- /* util */
-
-extern int keycmp (void const *, void const *) ; /* for any struct starting with a string key */
-#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &keycmp)
-
-
- /* node */
-
-extern void node_start (stralloc *, node *, char const *, size_t, uint32_t) ;
-extern void node_add (stralloc *, node *, char const *, size_t) ;
+#define REPO_ZERO { .storage = STRALLOC_ZERO, .list = GENALLOC_ZERO, .tree = AVLTREE_ZERO }
/* 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 *) ;
+extern void repo_init (repo *) ;
+extern node *repo_search (repo *, char const *, uint32_t) ;
+#define repo_searchs(rp, key) repo_search(rp, (key), strlen(key))
+extern void repo_add_new (repo *, char const *, uint32_t, char const *, size_t, uint32_t, int) ;
+#define repo_adds_new(rp, key, data, datalen, line, accu) repo_add_new(rp, key, strlen(key), data, datalen, line, accu)
+extern uint32_t repo_add (repo *, char const *, uint32_t, char const *, size_t, uint32_t, int, memcmp_func_ref) ;
+#define repo_adds(rp, key, data, datalen, line, accu, f) repo_add(rp, key, strlen(key), data, datalen, line, accu, f)
+extern int repo_write (cdbmaker *, repo const *) ;
+extern void repo_free (repo *) ;
- /* conftree */
+ /* lexparse */
-extern void confnode_start (node *, char const *, size_t, uint32_t) ;
-extern void confnode_add (node *, char const *, size_t) ;
+extern void conf_lexparse (buffer *, char const *) ;
-extern node const *conftree_search (char const *) ;
-extern void conftree_add (node const *) ;
-extern void conftree_update (node const *) ;
-extern int conftree_write (cdbmaker *) ;
+ /* defaults */
+extern void conf_defaults (void) ;
- /* lexparse */
-extern void conf_lexparse (buffer *, char const *) ;
+ /* util */
+extern int keycmp (void const *, void const *) ; /* for any struct starting with a string key */
+#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &keycmp)
- /* defaults */
-extern void conf_defaults (void) ;
+ /* main */
+
+extern repo conf ;
#endif