X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fconf-test.c;h=e8ba0458c568e90045ff948b56ee709b81d89e77;hb=984b27ee84b371d605c1402784039b3803a25983;hp=fb353f91bbf924d3af98ed8d10e08385e3b28acb;hpb=712d4ad76dc6ba3a2dbd591165debfe0ac0c8a71;p=libucw.git diff --git a/ucw/conf-test.c b/ucw/conf-test.c index fb353f91..e8ba0458 100644 --- a/ucw/conf-test.c +++ b/ucw/conf-test.c @@ -2,6 +2,7 @@ * Insane tester of reading configuration files * * (c) 2006 Robert Spalek + * (c) 2012 Martin Mares */ #include @@ -15,7 +16,6 @@ #include static int verbose; -static int new_context; static int reload; struct sub_sect_1 { @@ -173,7 +173,7 @@ static struct option long_opts[] = { }; static char *help = "\ -Usage: conf-test [ctxt] \n\ +Usage: conf-test [ctxt] [nojournal] \n\ \n\ Options:\n" CF_USAGE "\ -r, --reload\t\tReload configuration\n\ @@ -195,12 +195,19 @@ int main(int argc, char *argv[]) { log_init(argv[0]); - struct cf_context *cc = NULL, *prev = NULL; - if (argc > 1 && !strcmp(argv[1], "ctxt")) { - cc = cf_new_context(); - prev = cf_switch_context(cc); - argc--, argv++; + + // Special arguments which have to be parsed before cf_getopt() + while (argc > 1) { + if (!strcmp(argv[1], "ctxt")) { + cc = cf_new_context(); + prev = cf_switch_context(cc); + argc--, argv++; + } else if (!strcmp(argv[1], "nojournal")) { + cf_set_journalling(0); + argc--, argv++; + } else + break; } cf_declare_section("top", &cf_top, 0); @@ -209,7 +216,6 @@ main(int argc, char *argv[]) int opt; while ((opt = cf_getopt(argc, argv, short_opts, long_opts, NULL)) >= 0) switch (opt) { - case 'n': new_context++; break; case 'r': reload++; break; case 'v': verbose++; break; default: usage("unknown option %c\n", opt); @@ -228,9 +234,9 @@ main(int argc, char *argv[]) bclose(out); } - if (new_context) { + if (cc) { cf_switch_context(prev); - cf_free_context(cc); + cf_delete_context(cc); } return 0;