summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-09-12 13:10:53 -0400
committerpommicket <pommicket@gmail.com>2025-09-12 13:10:53 -0400
commit81c1cecf40b0733446fb0d945505155d87bf74c6 (patch)
tree2649bf5e70359c24e8c906438efe48304fa1be9c /examples
parent9865b70c855500ea3cae76fb8c9986bdf6f249ca (diff)
Getting items
Diffstat (limited to 'examples')
-rw-r--r--examples/conf.pom7
-rw-r--r--examples/read_conf.c8
2 files changed, 14 insertions, 1 deletions
diff --git a/examples/conf.pom b/examples/conf.pom
index 1054e41..8df17e7 100644
--- a/examples/conf.pom
+++ b/examples/conf.pom
@@ -2,8 +2,13 @@
bar = 10
# testing
-
+Hello = 5
# here's another comment
[jibjabjobdsfajkha]
win = yes
+
+[number]
+ one = 1
+[]
+thing=yup
diff --git a/examples/read_conf.c b/examples/read_conf.c
index ed33e21..966f0a2 100644
--- a/examples/read_conf.c
+++ b/examples/read_conf.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include "pom.h"
@@ -11,6 +12,13 @@ int main(int argc, char **argv) {
free(error);
return EXIT_FAILURE;
}
+ printf("number.one: %s\n", pom_conf_get(conf, "number.one"));
+ printf("number.tow: %s\n", pom_conf_get_or_default(conf, "number.tow", "(none)"));
+ printf("has thing? %d\n", pom_conf_has(conf, "thing"));
+ const char *file; uint64_t line;
+ if (pom_conf_location(conf, "thing", &file, &line)) {
+ printf("\tthing location: %s:%" PRIu64 "\n", file,line);
+ }
const pom_item *item;
pom_item_iter *iter = NULL;
while ((item = pom_conf_next_item(conf, &iter))) {