Annotation of embedaddon/confuse/doc/listing4.c, revision 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_LIST("targets", "{World}", CFGF_NONE),
! 9: CFG_INT("repeat", 1, CFGF_NONE),
! 10: CFG_END()
! 11: };
! 12: cfg_t *cfg;
! 13: int repeat;
! 14: int i;
! 15:
! 16: cfg = cfg_init(opts, CFGF_NONE);
! 17: if(cfg_parse(cfg, "hello.conf") == CFG_PARSE_ERROR)
! 18: return 1;
! 19:
! 20: repeat = cfg_getint(cfg, "repeat");
! 21: while(repeat--)
! 22: {
! 23: printf("Hello");
! 24: for(i = 0; i < cfg_size(cfg, "targets"); i++)
! 25: printf(", %s", cfg_getnstr(cfg, "targets", i));
! 26: printf("!\n");
! 27: }
! 28:
! 29: cfg_free(cfg);
! 30: return 0;
! 31: }
! 32:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>