Loading...
Searching...
No Matches
deprecated.c
/* Example of how to deprecate and drop options by Sebastian Geiger */
#include "confuse.h"
#include <string.h>
int main(void)
{
int repeat;
size_t i;
cfg_opt_t opts[] = {
CFG_STR_LIST("targets", "{World}", CFGF_DEPRECATED),
CFG_INT("repeat", 1, CFGF_DEPRECATED),
CFG_INT("foobar", 1, CFGF_DEPRECATED | CFGF_DROP),
CFG_END()
};
cfg_t *cfg;
cfg = cfg_init(opts, CFGF_NONE);
if (cfg_parse(cfg, "deprecated.conf") == CFG_PARSE_ERROR)
return 1;
repeat = cfg_getint(cfg, "repeat");
while (repeat--) {
printf("Hello");
for (i = 0; i < cfg_size(cfg, "targets"); i++)
printf(", %s", cfg_getnstr(cfg, "targets", i));
printf("!\n");
}
cfg_print_indent(cfg, stdout, 4);
cfg_free(cfg);
return 0;
}
confuse.h
A configuration file parser library.
CFGF_NONE
#define CFGF_NONE
Flags.
Definition confuse.h:82
CFG_END
#define CFG_END()
Terminate list of options.
Definition confuse.h:858
CFG_PARSE_ERROR
#define CFG_PARSE_ERROR
Error parsing the configuration.
Definition confuse.h:106
CFG_INT
#define CFG_INT(name, def, flags)
Initialize an integer option.
Definition confuse.h:473
CFGF_DEPRECATED
#define CFGF_DEPRECATED
option is deprecated and should be ignored.
Definition confuse.h:94
CFGF_DROP
#define CFGF_DROP
option should be dropped after parsing
Definition confuse.h:95
CFG_STR_LIST
#define CFG_STR_LIST(name, def, flags)
Initialize a string list option.
Definition confuse.h:381
cfg_opt_t
Data structure holding information about an option.
Definition confuse.h:324
cfg_t
Data structure holding information about a "section".
Definition confuse.h:250