35 printf (
"initialised\n");
37 printf (
"destroyed\n");
44 TEST (configitem_simple)
48 LumieraConfigitem item;
50 item = lumiera_configitem_new (argv[2]);
53 printf (
"line = '%s'\n", item->line);
55 printf (
"key = '%.*s'\n", (
int)item->key_size, item->key);
58 printf (
"delim = '%c'\n", *item->delim);
59 printf (
"value = '%s'\n", item->delim+1);
62 lumiera_configitem_delete (item, NULL);
69 lumiera_config_lookup lookup;
72 LumieraConfigitem item = lumiera_configitem_new (
"foo.bar = test");
76 CHECK (found == item);
94 printf (
"failure setting first time '%s%s': %s\n", argv[2], argv[3],
lumiera_error ());
96 if (lumiera_config_get (argv[2], &value))
97 printf (
"%s\n", value);
99 printf (
"failure retrieving '%s': %s\n", argv[2],
lumiera_error ());
102 printf (
"failure setting second time '%s%s': %s\n", argv[2], argv[4],
lumiera_error ());
104 if (lumiera_config_get (argv[2], &value))
105 printf (
"%s\n", value);
107 printf (
"failure retrieving '%s': %s\n", argv[2],
lumiera_error ());
118 printf (
"failure setting first time '%s%s': %s\n", argv[2], argv[3],
lumiera_error ());
121 printf (
"failure setting second time '%s%s': %s\n", argv[2], argv[3],
lumiera_error ());
124 if (lumiera_config_get (argv[2], &value))
125 printf (
"%s\n", value);
127 printf (
"failure retrieving '%s': %s\n", argv[2],
lumiera_error ());
138 long long number = 0;
143 printf (
"%lld\n", number);
149 TEST (number_get_nodefault)
153 long long number = 0;
156 printf (
"%lld\n", number);
167 signed long long number = atoll (argv[3]);
169 if (!lumiera_config_number_set (argv[2], &number))
170 printf (
"failed setting number '%s=%lld': %s\n", argv[2], number,
lumiera_error ());
173 printf (
"'%lld'\n", number);
188 if (lumiera_config_string_get (argv[2], &
string))
189 printf (
"'%s'\n",
string);
200 if (!lumiera_config_string_set (argv[2], &argv[3]))
201 printf (
"failed setting string '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
204 if (lumiera_config_string_get (argv[2], &
string))
205 printf (
"'%s'\n",
string);
220 if (lumiera_config_word_get (argv[2], &word))
221 printf (
"'%s'\n", word);
234 if (!lumiera_config_word_set (argv[2], &argv[3]))
235 printf (
"failed setting word '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
238 if (lumiera_config_word_get (argv[2], &word))
239 printf (
"'%s'\n", word);
245 TEST (configitem_simple_ctor_dtor)
249 LumieraConfigitem item;
251 item = lumiera_configitem_new (argv[2]);
255 TEST (configitem_simple_content_check)
259 LumieraConfigitem item;
261 item = lumiera_configitem_new (argv[2]);
265 printf(
"item->line = '%s'\n", item->line);
267 if ( item->key_size )
269 printf(
"item->key_size = '%zi'\n", item->key_size);
273 printf(
"item->key = '%s'\n", item->key);
277 printf(
"item->delim = '%s'\n", item->delim);
282 TEST (wordlist_get_nth)
288 if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
289 printf (
"failed setting word '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
293 printf (
"'%s'\n", word?word:
"NULL");
303 if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
304 printf (
"failed setting word '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
308 printf (
"'%d'\n", n);
312 TEST (wordlist_replace)
320 if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
321 printf (
"failed setting word '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
326 printf (
"'%s'\n", wordlist);
339 if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
340 printf (
"failed setting word '%s=%s': %s\n", argv[2], argv[3],
lumiera_error ());
344 printf (
"'%s'\n", wordlist);
350 printf (
"'%s'\n", wordlist);
LumieraConfigLookupentry lumiera_config_lookup_insert(LumieraConfigLookup self, LumieraConfigitem item)
Add a config item to a lookup structure.
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.
Draft for a configuration system (2008).
LumieraConfigitem lumiera_config_lookup_item_find(LumieraConfigLookup self, const char *key)
Find a the topmost config item stored to a given key.
Helpers and support macros for defining test executables in C.
Interface for a lumiera configuration system (draft).
Round robin temporary buffers.
int lumiera_config_wordlist_find(const char *key, const char *value, const char *delims)
Find the index of a word in a wordlist.
LumieraConfigitem lumiera_config_setdefault(const char *line)
Installs a default value for a config key.
lumiera_err lumiera_error(void)
Get and clear current error state.
const char * lumiera_config_wordlist_get_nth(const char *key, unsigned nth, const char *delims)
return nth word of a wordlist
LumieraConfigitem lumiera_config_lookup_remove(LumieraConfigLookup self, LumieraConfigitem item)
Remove a config item from a lookup structure.
void lumiera_config_destroy()
Destroys the configuration subsystem.
LumieraConfigLookup lumiera_config_lookup_destroy(LumieraConfigLookup self)
Destroy a lookup structure.
const char * lumiera_config_number_get(const char *key, long long *value)
Number signed integer numbers, in different formats (decimal, hex, oct, binary(for masks)) ...
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.
LumieraConfigLookup lumiera_config_lookup_init(LumieraConfigLookup self)
Initialise a lookup structure.
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.