40 extern LumieraConfig lumiera_global_config;
57 value += strspn (value, delims);
58 len = strcspn (value, delims);
77 size_t vlen = strlen (value);
83 for (
int idx = 0; *itr; itr += len, ++idx)
85 itr += strspn (itr, delims);
86 len = strcspn (itr, delims);
88 if (len == vlen && !strncmp (itr, value, vlen))
100 const char* str = NULL;
101 size_t vlen = strlen (value);
109 if (lumiera_config_get (key, &wordlist))
111 const char* start = wordlist + strspn (wordlist,
" \t,;");
113 for (
const char* itr = start; *itr; itr += len)
115 const char* left_end = itr;
116 itr += strspn (itr, delims);
117 len = strcspn (itr, delims);
119 if (len == vlen && !strncmp (itr, value, vlen))
123 itr += strspn (itr, delims);
127 "%.*s%.*s%.1s%s%.1s%s%.1s%s",
128 start - wordlist, wordlist,
129 left_end - start, start,
130 (left_end - start && subst1 && *subst1) ? delims :
"",
131 (subst1 && *subst1) ? subst1 :
"",
132 ((left_end - start || (subst1 && *subst1)) && subst2 && *subst2) ? delims :
"",
133 (subst2 && *subst2) ? subst2 :
"",
134 ((left_end - start || (subst1 && *subst1) || (subst2 && *subst2)) && *itr) ? delims :
"",
154 const char* wordlist = NULL;
160 if (lumiera_config_get (key, &wordlist))
162 size_t vlen = strlen (value);
165 for (
const char* itr = wordlist; *itr; itr += len)
167 itr += strspn (itr, delims);
168 len = strcspn (itr, delims);
170 if (len == vlen && !strncmp (itr, value, vlen))
176 wordlist[strspn (wordlist, delims)] ? delims :
"",
193 lumiera_config_wordlist_remove_nth (
const char* key,
unsigned nth)
199 lumiera_config_wordlist_append (
const char* key,
const char** value,
unsigned nth)
205 lumiera_config_wordlist_preprend (
const char* key,
const char** value,
unsigned nth)
const char * lumiera_config_wordlist_replace(const char *key, const char *value, const char *subst1, const char *subst2, const char *delims)
Universal word replacement function.
char * lumiera_tmpbuf_strndup(const char *src, size_t size)
Duplicate string to a tmpbuf.
Interface for a lumiera configuration system (draft).
#define LUMIERA_MUTEX_SECTION(nobugflag, mtx)
Mutual exclusive section.
This header is for including and configuring NoBug.
Round robin temporary buffers.
Lumiera error handling (C interface).
int lumiera_config_wordlist_find(const char *key, const char *value, const char *delims)
Find the index of a word in a wordlist.
const char * lumiera_config_wordlist_get_nth(const char *key, unsigned nth, const char *delims)
return nth word of a wordlist
const char * lumiera_config_wordlist_get(const char *key, const char **value)
Wordlist words delimited by any of " \t,;".
const char * lumiera_config_wordlist_add(const char *key, const char *value, const char *delims)
Add a word to the end of a wordlist if it doesn't exist already.
LumieraConfigitem lumiera_config_set(const char *key, const char *delim_value)
char * lumiera_tmpbuf_snprintf(size_t size, const char *fmt,...)
Construct a string in a tmpbuf.