diff options
| author | Federico Angelilli <code@fedang.net> | 2024-05-13 00:01:14 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-05-13 00:01:14 +0200 |
| commit | af0de70502d4b5bd8e18cd2b7b4b732c17610844 (patch) | |
| tree | b9cdbbc38c0569422fd81292af19801ed9b9e8b8 /test/ini.c | |
| parent | b5ee786a0aece3e0401d08f5d378d3a0e4e8a7c1 (diff) | |
Add any_ini.h and related test
Diffstat (limited to 'test/ini.c')
| -rw-r--r-- | test/ini.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ini.c b/test/ini.c new file mode 100644 index 0000000..3097e98 --- /dev/null +++ b/test/ini.c @@ -0,0 +1,38 @@ +#include <string.h> +#include <stdio.h> + +#define ANY_INI_IMPLEMENT +#include "any_ini.h" + +int main() +{ + const char *src = + "ciao = 10\n" + "global = yes\n" + " complex name with space = value with space \n" + "\n[sus]\n" + "nice = 1\n" + ";comment\n" + "another=10;x\n" + "true=1 ;xx\n" + " # comment 2 ;\n" + "\ntry = catch 123 bool\n" + " k e y = value pair! ; comment\n"; + + any_ini_t ini; + any_ini_init(&ini, src, strlen(src)); + + char *section = "", *key, *value; + + do { + printf("SECTION: %s\n", section); + + while ((key = any_ini_next_key(&ini)) != NULL) { + value = any_ini_next_value(&ini); + printf("PAIR: `%s` = `%s`\n", key, value); + } + + } while ((section = any_ini_next_section(&ini)) != NULL); + + return 0; +} |
