From 2aea45f0c9ffc0dcc9857478f086142ccf7811f0 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 16 Jun 2020 13:36:06 +0200 Subject: Add all and list debug options, convert announce to use debugging --- main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1ebe59e..f7023c4 100644 --- a/main.c +++ b/main.c @@ -92,6 +92,9 @@ const struct { },{ .name = "malloc", .val = DBG_MALLOC + },{ + .name = "announce", + .val = DBG_ANN },{ .name = NULL, .val = 0 @@ -118,10 +121,11 @@ cfg_init(int argc, char **argv) static struct option long_options[] = { { "homedir", required_argument, 0, 'h' }, { "debug", required_argument, 0, 'd' }, + { "verbose", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, ":h:d:", + c = getopt_long(argc, argv, ":h:d:v", long_options, &option_index); if (c == -1) break; @@ -130,7 +134,21 @@ cfg_init(int argc, char **argv) case 'h': cfg->homedir = optarg; break; + case 'v': + debug_mask |= DBG_VERBOSE; + break; case 'd': + if (!strcasecmp(optarg, "all")) { + debug_mask = ~0; + break; + } else if (!strcasecmp(optarg, "list")) { + error("Debug categories:\n"); + error(" * all\n"); + for (i = 0; debug_category_str[i].name; i++) + error(" * %s\n", debug_category_str[i].name); + exit(EXIT_FAILURE); + } + for (i = 0; debug_category_str[i].name; i++) { if (!strcasecmp(optarg, debug_category_str[i].name)) break; -- cgit v1.2.3