diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-16 13:36:06 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-16 13:36:06 +0200 |
commit | 2aea45f0c9ffc0dcc9857478f086142ccf7811f0 (patch) | |
tree | 35ff73ed74cbc99da9500554d164055983836bee /main.c | |
parent | 9eeffbeab84e71bd0a4cc0855cb1f72ad1849ba6 (diff) |
Add all and list debug options, convert announce to use debugging
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -93,6 +93,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; |