31 extern LumieraConfig lumiera_global_config;
48 value += strspn (value, delims);
49 len = strcspn (value, delims);
68 size_t vlen = strlen (value);
74 for (
int idx = 0; *itr; itr += len, ++idx)
76 itr += strspn (itr, delims);
77 len = strcspn (itr, delims);
79 if (len == vlen && !strncmp (itr, value, vlen))
91 const char* str = NULL;
92 size_t vlen = strlen (value);
100 if (lumiera_config_get (key, &wordlist))
102 const char* start = wordlist + strspn (wordlist,
" \t,;");
104 for (
const char* itr = start; *itr; itr += len)
106 const char* left_end = itr;
107 itr += strspn (itr, delims);
108 len = strcspn (itr, delims);
110 if (len == vlen && !strncmp (itr, value, vlen))
114 itr += strspn (itr, delims);
118 "%.*s%.*s%.1s%s%.1s%s%.1s%s",
119 start - wordlist, wordlist,
120 left_end - start, start,
121 (left_end - start && subst1 && *subst1) ? delims :
"",
122 (subst1 && *subst1) ? subst1 :
"",
123 ((left_end - start || (subst1 && *subst1)) && subst2 && *subst2) ? delims :
"",
124 (subst2 && *subst2) ? subst2 :
"",
125 ((left_end - start || (subst1 && *subst1) || (subst2 && *subst2)) && *itr) ? delims :
"",
145 const char* wordlist = NULL;
151 if (lumiera_config_get (key, &wordlist))
153 size_t vlen = strlen (value);
156 for (
const char* itr = wordlist; *itr; itr += len)
158 itr += strspn (itr, delims);
159 len = strcspn (itr, delims);
161 if (len == vlen && !strncmp (itr, value, vlen))
167 wordlist[strspn (wordlist, delims)] ? delims :
"",
184 lumiera_config_wordlist_remove_nth (
const char* key,
unsigned nth)
190 lumiera_config_wordlist_append (
const char* key,
const char** value,
unsigned nth)
196 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.