3 #include "../include/iniparser.h"
5 // gcc -Wall -Wextra -g iniparser_test.c stringptr.c iniparser.c -o iniparser_test
10 stringptr
* ini
= stringptr_copy(SPLITERAL("[main]\nfoo=bar\nbar=baz\n[section1]\nbaz=blah\nblah=foo\n"));
11 // we need stringptr_copy since stringptr_linesplit modifies the buffer. which would segfault using a literal.
12 stringptrlist
* lines
= stringptr_linesplit(ini
);
14 sec
= iniparser_get_section(lines
, SPLITERAL("main"));
15 iniparser_getvalue(lines
, &sec
, SPLITERAL("bar"), &result
);
17 printf("[main] bar=%s, size=%d\n", result
.ptr
, (int) result
.size
);
20 sec
= iniparser_get_section(lines
, SPLITERAL("section1"));
21 iniparser_getvalue(lines
, &sec
, SPLITERAL("blah"), &result
);
23 printf("blah=%s, size=%d\n", result
.ptr
, (int) result
.size
);