summaryrefslogtreecommitdiff
path: root/examples/read_conf.c
blob: 6b7c18f6641ca0ac94044140800c7c4e7a2f04fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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;
	}
	pom_conf *conf2 = pom_load_string("<inline>", "foo=bar\r\n[j.number]\n"
		"one = I\n"
		"five = V\n", &error);
	if (!conf2) {
		pom_conf_free(conf);
		pom_error_print(error);
		free(error);
		return EXIT_FAILURE;
	}
	pom_conf_merge(conf,pom_conf_section(conf2,"j"));
	pom_conf_print(conf);
	pom_conf_free(conf);
	pom_conf_free(conf2);
}