blob: 54a1e86c2daeac11956f5f14bd37dedd481687d3 (
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
29
30
31
32
33
34
35
36
37
|
#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) {
char *string = pom_error_to_string(error);
for (char *s=string; *s; s++)
if (*s >= 'a' && *s <= 'z')
*s += 'A' - 'a';
printf("%s\n",string);
free(string);
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 *copy = pom_conf_copy(conf);
pom_conf_merge(copy,pom_conf_section(conf2,"j"));
pom_conf *copy2 = pom_conf_copy(copy);
pom_conf_print(copy2);
pom_conf_free(conf);
pom_conf_free(copy);
pom_conf_free(copy2);
pom_conf_free(conf2);
}
|