forked from libconfuse/libconfuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue libconfuse#24: Add support for CFGF_DEPRECATED and CFGF_DRO…
…P option flags - `CFGF_DEPRECATED` causes a deprecated warning message for an option - `CFGF_DEPRECATED | CFGF_DROP` causes a deprecated option to be dropped Note: `CFGF_DROP` must currently be used with `CFG_DEPRECATED` to have an effect on the option. Signed-off-by: Sebastian Geiger <sbastig@gmx.net> Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Example of how to deprecate and drop options by Sebastian Geiger */ | ||
#include "confuse.h" | ||
#include <string.h> | ||
|
||
int main(void) | ||
{ | ||
int i, repeat; | ||
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; | ||
} | ||
|
||
/** | ||
* Local Variables: | ||
* version-control: t | ||
* indent-tabs-mode: t | ||
* c-file-style: "linux" | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Example of how to deprecate and drop options by Sebastian Geiger | ||
targets = {"Fish", "Cat"} | ||
repeat = 1 | ||
foobar = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters