summaryrefslogtreecommitdiff
path: root/examples/read_conf.c
blob: ed33e2195821bf90e23db9c29cd1a0c5bd0389d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdlib.h>
#include <string.h>

#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;
	}
	const pom_item *item;
	pom_item_iter *iter = NULL;
	while ((item = pom_conf_next_item(conf, &iter))) {
	    printf("Key: %s, Value: %s\n", item->key, item->value);
	}
	pom_conf_free(conf);
}