Tiny INI parser

test.c 549B

1234567891011121314151617181920212223
  1. #include "nini.h"
  2. #include <string.h>
  3. const char *testfile =
  4. "# Comment ...........\n"
  5. "rootkey = Value\r\n"
  6. "\r\n"
  7. " [ Section@name!@+12346 ]\r\n"
  8. "sec.key-a_b-1 = 444\r\n"
  9. "sec.key2 = Test 123456 with spaces\r\n"
  10. "[ this is a section with spaces nthat will be removed ]\n"
  11. "this_one_has_no_eol = 123456";
  12. void test_cb(const char *section, const char *key, const char *value, void *userData)
  13. {
  14. printf("[%s] >%s< = >%s<\r\n", section, key, value);
  15. }
  16. int main (void) {
  17. ini_parse_file(testfile, strlen(testfile), test_cb, NULL);
  18. }