From 43dfd45faa8af0b239a671b25ab6a398fa32f5c6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 12 Dec 2018 18:16:15 -0800 Subject: Move more version-info-related stuff to version_info.c. Have a ws_init_version_info() routine that, given an application name string: constructs the app-name-and-version-information string, and saves it; adds the initial crash information on platforms that support it, and saves it. Have show_version() use the saved information and take no arguments. Add a show_help_header() routine to print the header for --help command-line options, given a description of the application; it prints the application name and version information, the description, and the "See {wireshark.org URL}" line. Use those routines in various places, including providing the "application name" string in pcapng SHBs. Change-Id: I0042a8fcc91aa919ad5c381a8b8674a007ce66df Reviewed-on: https://code.wireshark.org/review/31029 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- captype.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'captype.c') diff --git a/captype.c b/captype.c index 50de540f41..b35728e26c 100644 --- a/captype.c +++ b/captype.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -81,8 +80,6 @@ failure_message_cont(const char *msg_format, va_list ap) int real_main(int argc, char *argv[]) { - GString *comp_info_str; - GString *runtime_info_str; char *init_progfile_dir_error; wtap *wth; int err; @@ -101,21 +98,8 @@ real_main(int argc, char *argv[]) cmdarg_err_init(failure_warning_message, failure_message_cont); - /* Get the compile-time version information string */ - comp_info_str = get_compiled_version_info(NULL, NULL); - - /* Get the run-time version information string */ - runtime_info_str = get_runtime_version_info(NULL); - - /* Add it to the information to be reported on a crash. */ - ws_add_crash_info("Captype (Wireshark) %s\n" - "\n" - "%s" - "\n" - "%s", - get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str); - g_string_free(comp_info_str, TRUE); - g_string_free(runtime_info_str, TRUE); + /* Initialize the version information. */ + ws_init_version_info("Captype (Wireshark)", NULL, NULL, NULL); #ifdef _WIN32 create_app_running_mutex(); @@ -149,20 +133,13 @@ real_main(int argc, char *argv[]) switch (opt) { case 'h': - printf("Captype (Wireshark) %s\n" - "Print the file types of capture files.\n" - "See https://www.wireshark.org for more information.\n", - get_ws_vcs_version_info()); + show_help_header("Print the file types of capture files."); print_usage(stdout); exit(0); break; case 'v': - comp_info_str = get_compiled_version_info(NULL, NULL); - runtime_info_str = get_runtime_version_info(NULL); - show_version("Captype (Wireshark)", comp_info_str, runtime_info_str); - g_string_free(comp_info_str, TRUE); - g_string_free(runtime_info_str, TRUE); + show_version(); exit(0); break; -- cgit v1.2.3