diff options
| author | João Valverde <j@v6e.pt> | 2021-09-29 12:29:11 +0100 |
|---|---|---|
| committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-09-30 13:08:32 +0000 |
| commit | e6a12256113700c135fe96c7196857eadf99044d (patch) | |
| tree | 0d446c33fee26fb6d12332f3cbbc561ad9834d27 | |
| parent | 19d27eff980f144f39d06950228b7ffd854476da (diff) | |
| download | wireshark-e6a12256113700c135fe96c7196857eadf99044d.tar.gz wireshark-e6a12256113700c135fe96c7196857eadf99044d.tar.bz2 wireshark-e6a12256113700c135fe96c7196857eadf99044d.zip | |
wslog: Alias --log-domain to --log-domains
I keep mistyping this if there is only one domain and it's annoying.
| -rw-r--r-- | wsutil/wslog.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/wsutil/wslog.c b/wsutil/wslog.c index 918fdad5d0..92eeac23e3 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -37,7 +37,10 @@ #define ENV_VAR_LEVEL "WIRESHARK_LOG_LEVEL" /* Log domains enabled/disabled. */ -#define ENV_VAR_DOMAINS "WIRESHARK_LOG_DOMAINS" +#define ENV_VAR_DOMAIN "WIRESHARK_LOG_DOMAIN" + +/* Alias "domain" and "domains". */ +#define ENV_VAR_DOMAIN_S "WIRESHARK_LOG_DOMAINS" /* Log level that generates a trap and aborts. Can be "critical" * or "warning". */ @@ -296,7 +299,8 @@ enum ws_log_level ws_log_set_level_str(const char *str_level) static const char *opt_level = "--log-level"; -static const char *opt_domains = "--log-domains"; +/* Alias "domain" and "domains". */ +static const char *opt_domain = "--log-domain"; static const char *opt_file = "--log-file"; static const char *opt_fatal = "--log-fatal"; static const char *opt_debug = "--log-debug"; @@ -341,9 +345,13 @@ int ws_log_parse_args(int *argc_ptr, char *argv[], option = opt_level; optlen = strlen(opt_level); } - else if (g_str_has_prefix(*ptr, opt_domains)) { - option = opt_domains; - optlen = strlen(opt_domains); + else if (g_str_has_prefix(*ptr, opt_domain)) { + option = opt_domain; + optlen = strlen(opt_domain); + /* Alias "domain" and "domains". Last form wins. */ + if (*(*ptr + optlen) == 's') { + optlen += 1; + } } else if (g_str_has_prefix(*ptr, opt_file)) { option = opt_file; @@ -407,7 +415,7 @@ int ws_log_parse_args(int *argc_ptr, char *argv[], ret += 1; } } - else if (option == opt_domains) { + else if (option == opt_domain) { ws_log_set_domain_filter(value); } else if (option == opt_file) { @@ -643,8 +651,10 @@ void ws_log_init(const char *progname, } } - env = g_getenv(ENV_VAR_DOMAINS); - if (env != NULL) + /* Alias "domain" and "domains". The plural form wins. */ + if ((env = g_getenv(ENV_VAR_DOMAIN_S)) != NULL) + ws_log_set_domain_filter(env); + else if ((env = g_getenv(ENV_VAR_DOMAIN)) != NULL) ws_log_set_domain_filter(env); env = g_getenv(ENV_VAR_DEBUG); |
