Annotation of embedaddon/confuse/doc/listing3.c, revision 1.1.1.1
1.1 misho 1: #include <stdio.h>
2: #include <confuse.h>
3:
4: int main(void)
5: {
6: cfg_opt_t opts[] =
7: {
8: CFG_STR("target", "World", CFGF_NONE),
9: CFG_INT("repeat", 1, CFGF_NONE),
10: CFG_END()
11: };
12: cfg_t *cfg;
13: int repeat;
14:
15: cfg = cfg_init(opts, CFGF_NONE);
16: if(cfg_parse(cfg, "hello.conf") == CFG_PARSE_ERROR)
17: return 1;
18:
19: repeat = cfg_getint(cfg, "repeat");
20: while(repeat--)
21: printf("Hello, %s!\n", cfg_getstr(cfg, "target"));
22:
23: cfg_free(cfg);
24: return 0;
25: }
26:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>