From 2d8ec49ffad14a1f1ea7a71c99e617bbfd0767a9 Mon Sep 17 00:00:00 2001 From: Stephen Fisher Date: Tue, 23 Dec 2014 14:58:38 -0700 Subject: Move twelve show_version() functions from the varoius programs and Wireshark UI files into a single one in wsutil. Change-Id: I0a64f0cc8106bd681bd185289c36272c4c43baad Reviewed-on: https://code.wireshark.org/review/6026 Reviewed-by: Stephen Fisher --- capinfos.c | 17 +---------------- captype.c | 17 +---------------- dumpcap.c | 16 +--------------- editcap.c | 17 +---------------- mergecap.c | 17 +---------------- rawshark.c | 17 +---------------- reordercap.c | 17 +---------------- text2pcap.c | 17 +---------------- tfshark.c | 17 +---------------- tshark.c | 17 +---------------- ui/gtk/main.c | 16 +--------------- ui/qt/main.cpp | 17 +---------------- wsutil/ws_version_info.c | 18 ++++++++++++++++++ wsutil/ws_version_info.h | 2 ++ 14 files changed, 32 insertions(+), 190 deletions(-) diff --git a/capinfos.c b/capinfos.c index 59056267a1..8b4bfeaf05 100644 --- a/capinfos.c +++ b/capinfos.c @@ -84,7 +84,6 @@ #include #include #include -#include #include #include @@ -997,20 +996,6 @@ process_cap_file(wtap *wth, const char *filename) return status; } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Capinfos (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - static void print_usage(FILE *output) { @@ -1409,7 +1394,7 @@ main(int argc, char *argv[]) break; case 'v': - show_version(comp_info_str, runtime_info_str); + show_version("Capinfos (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/captype.c b/captype.c index 0864ba6222..5d6789ddb7 100644 --- a/captype.c +++ b/captype.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include @@ -77,20 +76,6 @@ #include "version_info.h" -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Captype (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - static void print_usage(FILE *output) { @@ -219,7 +204,7 @@ main(int argc, char *argv[]) break; case 'v': - show_version(comp_info_str, runtime_info_str); + show_version("Captype (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/dumpcap.c b/dumpcap.c index 8057f01ea2..31e40f7252 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -72,7 +72,6 @@ #include #include -#include #include #ifndef HAVE_GETOPT @@ -553,19 +552,6 @@ print_usage(FILE *output) fprintf(output, "Use Ctrl-C to stop capturing at any time.\n"); } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Dumpcap (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str); -} - /* * Report an error in command-line arguments. * If we're a capture child, send a message back to the parent, otherwise @@ -4581,7 +4567,7 @@ main(int argc, char *argv[]) break; case 'v': /* Show version and exit */ { - show_version(comp_info_str, runtime_info_str); + show_version("Dumpcap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit_main(0); diff --git a/editcap.c b/editcap.c index 78338618e4..911e556a38 100644 --- a/editcap.c +++ b/editcap.c @@ -88,7 +88,6 @@ #include #include #include -#include #include #include @@ -684,20 +683,6 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) { return FALSE; } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Editcap (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - static void print_usage(FILE *output) { @@ -1180,7 +1165,7 @@ main(int argc, char *argv[]) break; case 'V': - show_version(comp_info_str, runtime_info_str); + show_version("Editcap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/mergecap.c b/mergecap.c index c483e8feef..9cd1d7066d 100644 --- a/mergecap.c +++ b/mergecap.c @@ -58,7 +58,6 @@ #include #include #include -#include #include #include @@ -74,20 +73,6 @@ #include #endif /* _WIN32 */ -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Mergecap (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - /* * Show the usage */ @@ -329,7 +314,7 @@ main(int argc, char *argv[]) break; case 'V': - show_version(comp_info_str, runtime_info_str); + show_version("Mergecap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/rawshark.c b/rawshark.c index f70c418526..c0a0593096 100644 --- a/rawshark.c +++ b/rawshark.c @@ -75,7 +75,6 @@ #include #include #include -#include #include "globals.h" #include @@ -421,20 +420,6 @@ set_link_type(const char *lt_arg) { return FALSE; } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Rawshark (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, - runtime_info_str->str); -} - int main(int argc, char *argv[]) { @@ -754,7 +739,7 @@ main(int argc, char *argv[]) break; case 'v': /* Show version and exit */ { - show_version(comp_info_str, runtime_info_str); + show_version("Rawshark (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/reordercap.c b/reordercap.c index 9ac0b6738f..ba5a9d87a4 100644 --- a/reordercap.c +++ b/reordercap.c @@ -48,26 +48,11 @@ #include #include -#include #include #include #include "version_info.h" -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Reordercap (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - /* Show command-line usage */ static void print_usage(FILE *output) @@ -254,7 +239,7 @@ main(int argc, char *argv[]) print_usage(stdout); exit(0); case 'v': - show_version(comp_info_str, runtime_info_str); + show_version("Reordercap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/text2pcap.c b/text2pcap.c index 9b8b9ebd14..bdbd4e4ddc 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -112,7 +112,6 @@ #include #include #include -#include #include #include @@ -1415,20 +1414,6 @@ fail_null_str: } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("Text2pcap (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - /*---------------------------------------------------------------------- * Print usage string and exit */ @@ -1786,7 +1771,7 @@ parse_options (int argc, char *argv[]) break; case 'v': - show_version(comp_info_str, runtime_info_str); + show_version("Text2pcap (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); exit(0); diff --git a/tfshark.c b/tfshark.c index cd6909c25f..30c91a4cff 100644 --- a/tfshark.c +++ b/tfshark.c @@ -70,7 +70,6 @@ #include #include #include -#include #include #include "globals.h" @@ -736,20 +735,6 @@ print_current_user(void) { } } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("TFShark (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, - runtime_info_str->str); -} - static void get_tfshark_compiled_version_info(GString *str) { @@ -1274,7 +1259,7 @@ main(int argc, char *argv[]) break; case 'v': /* Show version and exit */ { - show_version(comp_info_str, runtime_info_str); + show_version("TFShark (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); /* We don't really have to cleanup here, but it's a convenient way to test diff --git a/tshark.c b/tshark.c index a958580a93..52cc84679a 100644 --- a/tshark.c +++ b/tshark.c @@ -75,7 +75,6 @@ #include #include #include -#include #include #include @@ -900,20 +899,6 @@ print_current_user(void) { } } -static void -show_version(GString *comp_info_str, GString *runtime_info_str) -{ - printf("TShark (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), - comp_info_str->str, runtime_info_str->str); -} - static void get_tshark_compiled_version_info(GString *str) { @@ -1619,7 +1604,7 @@ main(int argc, char *argv[]) break; case 'v': /* Show version and exit */ { - show_version(comp_info_str, runtime_info_str); + show_version("TShark (Wireshark)", comp_info_str, runtime_info_str); g_string_free(comp_info_str, TRUE); g_string_free(runtime_info_str, TRUE); /* We don't really have to cleanup here, but it's a convenient way to test diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 83ab1fd482..6675ec29d5 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -1255,20 +1255,6 @@ print_usage(gboolean for_help_option) { #endif } -static void -show_version(void) -{ - printf("Wireshark %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, - runtime_info_str->str); -} - /* * Report an error in command-line arguments. * Creates a console on Windows. @@ -2364,7 +2350,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 create_console(); #endif - show_version(); + show_version("Wireshark", comp_info_str, runtime_info_str); #ifdef _WIN32 destroy_console(); #endif diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 8bc39b0be2..3048c92b5e 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -281,21 +281,6 @@ print_usage(gboolean for_help_option) { #endif } -// xxx copied from ../gtk/main.c -static void -show_version(void) -{ - printf("Wireshark %s\n" - "\n" - "%s" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, - runtime_info_str->str); -} - /* * Report an error in command-line arguments. * Creates a console on Windows. @@ -693,7 +678,7 @@ int main(int argc, char *argv[]) #ifdef _WIN32 create_console(); #endif - show_version(); + show_version("Wireshark", comp_info_str, runtime_info_str); #ifdef _WIN32 destroy_console(); #endif diff --git a/wsutil/ws_version_info.c b/wsutil/ws_version_info.c index f3d5dc1789..4fb68dd2bc 100644 --- a/wsutil/ws_version_info.c +++ b/wsutil/ws_version_info.c @@ -22,11 +22,29 @@ #include "config.h" +#include + #include #include "version.h" #include +#include + +void +show_version(const gchar *prog_name_str, GString *comp_info_str, + GString *runtime_info_str) +{ + printf("%s %s\n" + "\n" + "%s" + "\n" + "%s" + "\n" + "%s", + prog_name_str, get_ws_vcs_version_info(), get_copyright_info(), + comp_info_str->str, runtime_info_str->str); +} /* * Return a version number string for Wireshark, including, for builds diff --git a/wsutil/ws_version_info.h b/wsutil/ws_version_info.h index e9e718e10e..6d573e2105 100644 --- a/wsutil/ws_version_info.h +++ b/wsutil/ws_version_info.h @@ -30,6 +30,8 @@ extern "C" { #endif /* __cplusplus */ +WS_DLL_PUBLIC void show_version(const gchar *prog_name, GString *comp_info_str, GString *runtime_info_str); + /* * Return a version number string for Wireshark, including, for builds * from a tree checked out from Wireshark's version control system, -- cgit v1.2.3