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>
This commit is contained in:
Stephen Fisher 2014-12-23 14:58:38 -07:00
parent 45daef629d
commit 2d8ec49ffa
14 changed files with 32 additions and 190 deletions

View File

@ -84,7 +84,6 @@
#include <wsutil/privileges.h> #include <wsutil/privileges.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
@ -997,20 +996,6 @@ process_cap_file(wtap *wth, const char *filename)
return status; 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 static void
print_usage(FILE *output) print_usage(FILE *output)
{ {
@ -1409,7 +1394,7 @@ main(int argc, char *argv[])
break; break;
case 'v': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -54,7 +54,6 @@
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
@ -77,20 +76,6 @@
#include "version_info.h" #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 static void
print_usage(FILE *output) print_usage(FILE *output)
{ {
@ -219,7 +204,7 @@ main(int argc, char *argv[])
break; break;
case 'v': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -72,7 +72,6 @@
#include <wsutil/cmdarg_err.h> #include <wsutil/cmdarg_err.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
#ifndef HAVE_GETOPT #ifndef HAVE_GETOPT
@ -553,19 +552,6 @@ print_usage(FILE *output)
fprintf(output, "Use Ctrl-C to stop capturing at any time.\n"); 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. * Report an error in command-line arguments.
* If we're a capture child, send a message back to the parent, otherwise * If we're a capture child, send a message back to the parent, otherwise
@ -4581,7 +4567,7 @@ main(int argc, char *argv[])
break; break;
case 'v': /* Show version and exit */ 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit_main(0); exit_main(0);

View File

@ -88,7 +88,6 @@
#include <wsutil/md5.h> #include <wsutil/md5.h>
#include <wsutil/plugins.h> #include <wsutil/plugins.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
@ -684,20 +683,6 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
return FALSE; 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 static void
print_usage(FILE *output) print_usage(FILE *output)
{ {
@ -1180,7 +1165,7 @@ main(int argc, char *argv[])
break; break;
case 'V': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -58,7 +58,6 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/cmdarg_err.h> #include <wsutil/cmdarg_err.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
@ -74,20 +73,6 @@
#include <wsutil/unicode-utils.h> #include <wsutil/unicode-utils.h>
#endif /* _WIN32 */ #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 * Show the usage
*/ */
@ -329,7 +314,7 @@ main(int argc, char *argv[])
break; break;
case 'V': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -75,7 +75,6 @@
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/plugins.h> #include <wsutil/plugins.h>
#include <wsutil/report_err.h> #include <wsutil/report_err.h>
#include <wsutil/copyright_info.h>
#include "globals.h" #include "globals.h"
#include <epan/packet.h> #include <epan/packet.h>
@ -421,20 +420,6 @@ set_link_type(const char *lt_arg) {
return FALSE; 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 int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -754,7 +739,7 @@ main(int argc, char *argv[])
break; break;
case 'v': /* Show version and exit */ 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -48,26 +48,11 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
#include "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 */ /* Show command-line usage */
static void static void
print_usage(FILE *output) print_usage(FILE *output)
@ -254,7 +239,7 @@ main(int argc, char *argv[])
print_usage(stdout); print_usage(stdout);
exit(0); exit(0);
case 'v': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -112,7 +112,6 @@
#include <string.h> #include <string.h>
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/crash_info.h> #include <wsutil/crash_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_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 * Print usage string and exit
*/ */
@ -1786,7 +1771,7 @@ parse_options (int argc, char *argv[])
break; break;
case 'v': 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(comp_info_str, TRUE);
g_string_free(runtime_info_str, TRUE); g_string_free(runtime_info_str, TRUE);
exit(0); exit(0);

View File

@ -70,7 +70,6 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/report_err.h> #include <wsutil/report_err.h>
#include <wsutil/copyright_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
#include "globals.h" #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 static void
get_tfshark_compiled_version_info(GString *str) get_tfshark_compiled_version_info(GString *str)
{ {
@ -1274,7 +1259,7 @@ main(int argc, char *argv[])
break; break;
case 'v': /* Show version and exit */ 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(comp_info_str, TRUE);
g_string_free(runtime_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 /* We don't really have to cleanup here, but it's a convenient way to test

View File

@ -75,7 +75,6 @@
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include <wsutil/report_err.h> #include <wsutil/report_err.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h> #include <wsutil/os_version_info.h>
#include <wsutil/ws_version_info.h> #include <wsutil/ws_version_info.h>
@ -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 static void
get_tshark_compiled_version_info(GString *str) get_tshark_compiled_version_info(GString *str)
{ {
@ -1619,7 +1604,7 @@ main(int argc, char *argv[])
break; break;
case 'v': /* Show version and exit */ 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(comp_info_str, TRUE);
g_string_free(runtime_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 /* We don't really have to cleanup here, but it's a convenient way to test

View File

@ -1255,20 +1255,6 @@ print_usage(gboolean for_help_option) {
#endif #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. * Report an error in command-line arguments.
* Creates a console on Windows. * Creates a console on Windows.
@ -2364,7 +2350,7 @@ main(int argc, char *argv[])
#ifdef _WIN32 #ifdef _WIN32
create_console(); create_console();
#endif #endif
show_version(); show_version("Wireshark", comp_info_str, runtime_info_str);
#ifdef _WIN32 #ifdef _WIN32
destroy_console(); destroy_console();
#endif #endif

View File

@ -281,21 +281,6 @@ print_usage(gboolean for_help_option) {
#endif #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. * Report an error in command-line arguments.
* Creates a console on Windows. * Creates a console on Windows.
@ -693,7 +678,7 @@ int main(int argc, char *argv[])
#ifdef _WIN32 #ifdef _WIN32
create_console(); create_console();
#endif #endif
show_version(); show_version("Wireshark", comp_info_str, runtime_info_str);
#ifdef _WIN32 #ifdef _WIN32
destroy_console(); destroy_console();
#endif #endif

View File

@ -22,11 +22,29 @@
#include "config.h" #include "config.h"
#include <stdio.h>
#include <glib.h> #include <glib.h>
#include "version.h" #include "version.h"
#include <wsutil/ws_version_info.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 * Return a version number string for Wireshark, including, for builds

View File

@ -30,6 +30,8 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #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 * Return a version number string for Wireshark, including, for builds
* from a tree checked out from Wireshark's version control system, * from a tree checked out from Wireshark's version control system,