File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / confuse / doc / listing3.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Jan 24 14:48:55 2017 UTC (7 years, 5 months ago) by misho
Branches: confuse, MAIN
CVS tags: v3_3, v2_7, HEAD
confuse 2.7

    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>