From: yvs Date: Fri, 8 May 2026 14:06:55 +0000 (+0400) Subject: options: show build features with -vv X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=d64e5cc5e7ce0db52e82b2485bc5357dcf4fd2a8;p=thirdparty%2Fmtr.git options: show build features with -vv Adapt the mtr085 verbose-version idea so -v keeps the existing version output while -vv also reports the main compiled-in feature switches. Ported-from: yvs2014/mtr085@eb6f41cfcc4bc7c741805769efa88cc2de9ac99d Original-author: yvs --- diff --git a/ui/mtr.c b/ui/mtr.c index de47683..344bd86 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -344,6 +344,65 @@ static void init_fld_options( ctl->available_options[i] = 0; } +static void print_build_feature( + const char *name, + int enabled) +{ + printf(" %-8s %s\n", name, enabled ? "yes" : "no"); +} + +static void print_version( + int verbose) +{ + printf("mtr " PACKAGE_VERSION "\n"); + + if (verbose < 2) { + return; + } + + puts("features:"); +#ifdef ENABLE_IPV6 + print_build_feature("ipv6", 1); +#else + print_build_feature("ipv6", 0); +#endif +#ifdef HAVE_CURSES + print_build_feature("curses", 1); +#else + print_build_feature("curses", 0); +#endif +#ifdef HAVE_CURSESW + print_build_feature("cursesw", 1); +#else + print_build_feature("cursesw", 0); +#endif +#ifdef ENABLE_BRAILLE + print_build_feature("braille", 1); +#else + print_build_feature("braille", 0); +#endif +#ifdef HAVE_GTK + print_build_feature("gtk", 1); +#else + print_build_feature("gtk", 0); +#endif +#ifdef HAVE_JANSSON + print_build_feature("json", 1); +#else + print_build_feature("json", 0); +#endif +#ifdef HAVE_IPINFO + print_build_feature("ipinfo", 1); +#else + print_build_feature("ipinfo", 0); +#endif +#ifdef SO_MARK + print_build_feature("mark", 1); +#else + print_build_feature("mark", 0); +#endif +} + static void parse_arg( struct mtr_ctl *ctl, @@ -441,6 +500,7 @@ static void parse_arg( enum { num_options = sizeof(long_options) / sizeof(struct option) }; char short_options[num_options * 2]; size_t n, p; + int version_count = 0; for (n = p = 0; n < num_options; n++) { if (CHAR_MAX < long_options[n].val) { @@ -462,8 +522,7 @@ static void parse_arg( switch (opt) { case 'v': - printf("mtr " PACKAGE_VERSION "\n"); - exit(EXIT_SUCCESS); + version_count++; break; case 'h': usage(stdout); @@ -725,6 +784,11 @@ static void parse_arg( } } + if (version_count > 0) { + print_version(version_count); + exit(EXIT_SUCCESS); + } + if (ctl->DisplayMode == DisplayReport || ctl->DisplayMode == DisplayTXT || #ifdef HAVE_JANSSON