summaryrefslogtreecommitdiff
path: root/examples/read_conf.c
blob: c4cabfcf596c5be9b0ebdab0ba73727173037fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdlib.h>
#include <string.h>
#include <inttypes.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;
	}
	uint64_t value;
	const char *s = pom_conf_get_uint(conf, "number.best", &value);
	printf("%" PRIu64 "\n", value);
	if (s) printf(" -> %s\n",s);
	pom_conf_print(conf);
	pom_conf_free(conf);
}