#include #include #include #include "pom.h" int main(int argc, char **argv) { pom_error *error; pom_conf *conf = pom_load_path(argc >= 2 ? argv[1] : "conf.pom", &error); if (!conf) { pom_error_print(error); 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(pom_conf_section(conf, "number"), &iter))) { printf("Number: %s, Value: %s\n", item->key, item->value); } pom_unread_key_iter *unread = NULL; const char *key; while ((key = pom_conf_next_unread_key(conf, &unread))) { printf("Unrecognized key: %s\n", key); } pom_key_iter *keys = NULL; while ((key = pom_conf_next_key(conf, &keys))) { printf("Top-level key: %s\n", key); } pom_conf_free(conf); }