From f67062061fe9bdf44375cb19aba334db2ab3d196 Mon Sep 17 00:00:00 2001 From: Robert Spalek Date: Sat, 22 Apr 2006 15:48:04 +0200 Subject: [PATCH] conf2: fill in the skeleton of the tester --- lib/conf2-test.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/conf2-test.c b/lib/conf2-test.c index b3fac69b..21326f05 100644 --- a/lib/conf2-test.c +++ b/lib/conf2-test.c @@ -9,7 +9,11 @@ #include "lib/clists.h" #include +#include #include +#include + +static int verbose; struct sub_sect_1 { struct cnode n; @@ -92,7 +96,7 @@ time_parser(uns number, byte **pars, time_t *ptr) return NULL; } -static struct cf_section cf_top UNUSED = { +static struct cf_section cf_top = { CF_COMMIT(init_top), CF_COMMIT(commit_top), CF_ITEMS { @@ -111,8 +115,42 @@ static struct cf_section cf_top UNUSED = { } }; +static byte short_opts[] = CF_SHORT_OPTS "v"; +static struct option long_opts[] = { + CF_LONG_OPTS + {"verbose", 0, 0, 'v'}, + {NULL, 0, 0, 0} +}; + +static char *help = "\ +Usage: conf2-test \n\ +\n\ +Options:\n" +CF_USAGE +"-v\t\tBe verbose\n\ +"; + +static void NONRET +usage(void) +{ + fputs(help, stderr); + exit(1); +} + int -main(void) +main(int argc, char *argv[]) { + log_init(argv[0]); + cf_declare_section("top", &cf_top, 0); + + int opt; + while ((opt = cf_get_opt(argc, argv, short_opts, long_opts, NULL)) >= 0) + switch (opt) { + case 'v': verbose++; break; + default: usage(); + } + if (optind < argc) + usage(); + return 0; } -- 2.39.2