38 cmp_fn (
const void* a,
const void* b);
41 delete_fn (PSplaynode node);
44 key_fn (
const PSplaynode node);
52 TRACE (configlookup_dbg);
53 psplay_init (&self->tree, cmp_fn, key_fn, delete_fn);
61 TRACE (configlookup_dbg);
68 LumieraConfigLookupentry
71 TRACE (configlookup_dbg,
"%s", item->line);
75 REQUIRE (item->key_size);
81 LumieraConfigLookupentry
entry = (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
83 entry = (LumieraConfigLookupentry)
psplay_insert (&self->tree, &lumiera_config_lookupentry_new (key)->node, 100);
85 llist_insert_head (&entry->configitems, &item->lookup);
90 LumieraConfigLookupentry
93 TRACE (configlookup_dbg,
"%s", item->line);
97 REQUIRE (item->key_size);
100 LumieraConfigLookupentry
entry = (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
102 entry = (LumieraConfigLookupentry)
psplay_insert (&self->tree, &lumiera_config_lookupentry_new (key)->node, 100);
107 llist_insert_tail (&entry->configitems, &item->lookup);
115 TRACE (configlookup_dbg,
"%s", item->line);
116 REQUIRE (!llist_is_empty (&item->lookup),
"item is not in a lookup");
118 if (llist_is_single (&item->lookup))
121 LumieraConfigLookupentry
entry =
LLIST_TO_STRUCTP (llist_next (&item->lookup), lumiera_config_lookupentry, configitems);
122 llist_unlink (&item->lookup);
128 llist_unlink (&item->lookup);
135 LumieraConfigLookupentry
138 TRACE (configlookup_dbg,
"%s", key);
139 return (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
146 TRACE (configlookup_dbg,
"%s", key);
148 LumieraConfigLookupentry
entry =
151 if (entry && !llist_is_empty (&entry->configitems))
152 return LLIST_TO_STRUCTP (llist_head (&entry->configitems), lumiera_configitem, lookup);
161 TRACE (configlookup_dbg,
"%s", key);
163 LumieraConfigLookupentry
entry =
166 if (entry && !llist_is_empty (&entry->configitems))
167 return LLIST_TO_STRUCTP (llist_tail (&entry->configitems), lumiera_configitem, lookup);
176 LumieraConfigLookupentry
177 lumiera_config_lookupentry_init (LumieraConfigLookupentry
self,
const char* key)
179 TRACE (configlookup_dbg,
"%s", key);
183 llist_init (&self->configitems);
190 LumieraConfigLookupentry
191 lumiera_config_lookupentry_new (
const char* key)
193 return lumiera_config_lookupentry_init (
lumiera_malloc (
sizeof (lumiera_config_lookupentry)), key);
197 LumieraConfigLookupentry
198 lumiera_config_lookupentry_destroy (LumieraConfigLookupentry
self)
200 TRACE (configlookup_dbg);
203 REQUIRE (llist_is_empty (&self->configitems),
"lookup node still in use");
211 lumiera_config_lookupentry_delete (LumieraConfigLookupentry
self)
213 lumiera_free (lumiera_config_lookupentry_destroy (
self));
217 cmp_fn (
const void* a,
const void* b)
219 return strcmp ((
const char*)a, (
const char*)b);
223 delete_fn (PSplaynode node)
225 lumiera_config_lookupentry_delete ((LumieraConfigLookupentry) node);
230 key_fn (
const PSplaynode node)
232 return ((LumieraConfigLookupentry) node)->full_key;
Portable and safe wrappers around some C-Lib functions.
LumieraConfigLookupentry lumiera_config_lookup_insert(LumieraConfigLookup self, LumieraConfigitem item)
Add a config item to a lookup structure.
PSplay psplay_destroy(PSplay self)
Destroy a splay tree Frees all elements and associated resources of a splay tree. ...
LumieraConfigitem lumiera_config_lookup_item_find(LumieraConfigLookup self, const char *key)
Find a the topmost config item stored to a given key.
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
PSplay psplay_init(PSplay self, psplay_cmp_fn cmp, psplay_key_fn key, psplay_delete_fn del)
Initialize a splay tree.
Interface for a lumiera configuration system (draft).
LumieraConfigLookupentry lumiera_config_lookup_find(LumieraConfigLookup self, const char *key)
Find a hashtable entry in the lookup structure.
LumieraConfigitem lumiera_config_lookup_item_tail_find(LumieraConfigLookup self, const char *key)
Find a the bottom most config item stored to a given key.
This header is for including and configuring NoBug.
Round robin temporary buffers.
static void lumiera_free(void *mem)
Free previously allocated memory.
PSplaynode psplay_find(PSplay self, const void *key, int splayfactor)
Find a element in a splay tree.
LumieraConfigLookupentry lumiera_config_lookup_insert_default(LumieraConfigLookup self, LumieraConfigitem item)
PSplaynode psplay_insert(PSplay self, PSplaynode node, int splayfactor)
Insert a element into a splay tree.
Lookup of configuration keys in a low-level configuration system.
void * lumiera_malloc(size_t size)
Allocate memory.
char * lumiera_tmpbuf_strcat3(const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len)
Concat up to 3 strings in a tmpbuf.
LumieraConfigitem lumiera_config_lookup_remove(LumieraConfigLookup self, LumieraConfigitem item)
Remove a config item from a lookup structure.
LumieraConfigLookup lumiera_config_lookup_destroy(LumieraConfigLookup self)
Destroy a lookup structure.
LumieraConfigLookup lumiera_config_lookup_init(LumieraConfigLookup self)
Initialise a lookup structure.
#define LLIST_TO_STRUCTP(llist, type, member)
cast back from a member of a structure to a pointer of the structure
char * lumiera_strndup(const char *str, size_t len)
Duplicate a C string.
PSplaynode psplaynode_init(PSplaynode self)
Initialise a splay tree node The user has to place this nodes within his datastructure and must Initi...
void psplay_delete_node(PSplay self, PSplaynode node)
Delete a node from a splay tree.
#define LUMIERA_ERROR_DEFINE(err, msg)
Definition and initialisation of an error constant.
char * lumiera_tmpbuf_snprintf(size_t size, const char *fmt,...)
Construct a string in a tmpbuf.