47 cmp_fn (
const void* a,
const void* b);
50 delete_fn (PSplaynode node);
53 key_fn (
const PSplaynode node);
61 TRACE (configlookup_dbg);
62 psplay_init (&self->tree, cmp_fn, key_fn, delete_fn);
70 TRACE (configlookup_dbg);
77 LumieraConfigLookupentry
80 TRACE (configlookup_dbg,
"%s", item->line);
84 REQUIRE (item->key_size);
90 LumieraConfigLookupentry
entry = (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
92 entry = (LumieraConfigLookupentry)
psplay_insert (&self->tree, &lumiera_config_lookupentry_new (key)->node, 100);
94 llist_insert_head (&entry->configitems, &item->lookup);
99 LumieraConfigLookupentry
102 TRACE (configlookup_dbg,
"%s", item->line);
106 REQUIRE (item->key_size);
109 LumieraConfigLookupentry
entry = (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
111 entry = (LumieraConfigLookupentry)
psplay_insert (&self->tree, &lumiera_config_lookupentry_new (key)->node, 100);
116 llist_insert_tail (&entry->configitems, &item->lookup);
124 TRACE (configlookup_dbg,
"%s", item->line);
125 REQUIRE (!llist_is_empty (&item->lookup),
"item is not in a lookup");
127 if (llist_is_single (&item->lookup))
130 LumieraConfigLookupentry
entry =
LLIST_TO_STRUCTP (llist_next (&item->lookup), lumiera_config_lookupentry, configitems);
131 llist_unlink (&item->lookup);
137 llist_unlink (&item->lookup);
144 LumieraConfigLookupentry
147 TRACE (configlookup_dbg,
"%s", key);
148 return (LumieraConfigLookupentry)
psplay_find (&self->tree, key, 100);
155 TRACE (configlookup_dbg,
"%s", key);
157 LumieraConfigLookupentry
entry =
160 if (entry && !llist_is_empty (&entry->configitems))
161 return LLIST_TO_STRUCTP (llist_head (&entry->configitems), lumiera_configitem, lookup);
170 TRACE (configlookup_dbg,
"%s", key);
172 LumieraConfigLookupentry
entry =
175 if (entry && !llist_is_empty (&entry->configitems))
176 return LLIST_TO_STRUCTP (llist_tail (&entry->configitems), lumiera_configitem, lookup);
185 LumieraConfigLookupentry
186 lumiera_config_lookupentry_init (LumieraConfigLookupentry
self,
const char* key)
188 TRACE (configlookup_dbg,
"%s", key);
192 llist_init (&self->configitems);
199 LumieraConfigLookupentry
200 lumiera_config_lookupentry_new (
const char* key)
202 return lumiera_config_lookupentry_init (
lumiera_malloc (
sizeof (lumiera_config_lookupentry)), key);
206 LumieraConfigLookupentry
207 lumiera_config_lookupentry_destroy (LumieraConfigLookupentry
self)
209 TRACE (configlookup_dbg);
212 REQUIRE (llist_is_empty (&self->configitems),
"lookup node still in use");
220 lumiera_config_lookupentry_delete (LumieraConfigLookupentry
self)
222 lumiera_free (lumiera_config_lookupentry_destroy (
self));
226 cmp_fn (
const void* a,
const void* b)
228 return strcmp ((
const char*)a, (
const char*)b);
232 delete_fn (PSplaynode node)
234 lumiera_config_lookupentry_delete ((LumieraConfigLookupentry) node);
239 key_fn (
const PSplaynode node)
241 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.