File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / confuse / examples / deprecated.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:49:17 2021 UTC (3 years, 3 months ago) by misho
Branches: confuse, MAIN
CVS tags: v3_3, HEAD
confuse 3.3

    1: /* Example of how to deprecate and drop options by Sebastian Geiger */
    2: #include "confuse.h"
    3: #include <string.h>
    4: 
    5: int main(void)
    6: {
    7: 	int repeat;
    8: 	size_t i;
    9: 	cfg_opt_t opts[] = {
   10: 		CFG_STR_LIST("targets", "{World}", CFGF_DEPRECATED),
   11: 		CFG_INT("repeat", 1, CFGF_DEPRECATED),
   12: 		CFG_INT("foobar", 1, CFGF_DEPRECATED | CFGF_DROP),
   13: 		CFG_END()
   14: 	};
   15: 	cfg_t *cfg;
   16: 
   17: 	cfg = cfg_init(opts, CFGF_NONE);
   18: 	if (cfg_parse(cfg, "deprecated.conf") == CFG_PARSE_ERROR)
   19: 		return 1;
   20: 
   21: 	repeat = cfg_getint(cfg, "repeat");
   22: 	while (repeat--) {
   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_print_indent(cfg, stdout, 4);
   30: 	cfg_free(cfg);
   31: 
   32: 	return 0;
   33: }
   34: 
   35: /**
   36:  * Local Variables:
   37:  *  indent-tabs-mode: t
   38:  *  c-file-style: "linux"
   39:  * End:
   40:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>