aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Fisher <sfisher@sdf.org>2014-12-23 14:58:38 -0700
committerStephen Fisher <sfisher@sdf.org>2014-12-24 16:51:45 +0000
commit2d8ec49ffad14a1f1ea7a71c99e617bbfd0767a9 (patch)
tree714a232ac88a3631b37398520ace89902081e42b
parent45daef629d249b1b632efa9fe9e1167a8cc1a936 (diff)
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 <sfisher@sdf.org>
-rw-r--r--capinfos.c17
-rw-r--r--captype.c17
-rw-r--r--dumpcap.c16
-rw-r--r--editcap.c17
-rw-r--r--mergecap.c17
-rw-r--r--rawshark.c17
-rw-r--r--reordercap.c17
-rw-r--r--text2pcap.c17
-rw-r--r--tfshark.c17
-rw-r--r--tshark.c17
-rw-r--r--ui/gtk/main.c16
-rw-r--r--ui/qt/main.cpp17
-rw-r--r--wsutil/ws_version_info.c18
-rw-r--r--wsutil/ws_version_info.h2
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 <wsutil/privileges.h>
#include <wsutil/filesystem.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -998,20 +997,6 @@ process_cap_file(wtap *wth, const char *filename)
}
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)
{
fprintf(output, "\n");
@@ -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 <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -78,20 +77,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)
{
fprintf(output, "\n");
@@ -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 <wsutil/cmdarg_err.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/ws_version_info.h>
#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 <wsutil/md5.h>
#include <wsutil/plugins.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -685,20 +684,6 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
}
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)
{
fprintf(output, "\n");
@@ -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 <wsutil/file_util.h>
#include <wsutil/cmdarg_err.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -74,20 +73,6 @@
#include <wsutil/unicode-utils.h>
#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 <wsutil/filesystem.h>
#include <wsutil/plugins.h>
#include <wsutil/report_err.h>
-#include <wsutil/copyright_info.h>
#include "globals.h"
#include <epan/packet.h>
@@ -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 <wsutil/file_util.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
#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 <string.h>
#include <wsutil/file_util.h>
#include <wsutil/crash_info.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -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 <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/report_err.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/ws_version_info.h>
#include "globals.h"
@@ -737,20 +736,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)
{
/* LIBZ */
@@ -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 <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/report_err.h>
-#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h>
@@ -901,20 +900,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)
{
/* Capture libraries */
@@ -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 <stdio.h>
+
#include <glib.h>
#include "version.h"
#include <wsutil/ws_version_info.h>
+#include <wsutil/copyright_info.h>
+
+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,