#include <wiretap/wtap.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <cli_main.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
wtap *wth;
int err;
/* Get the decimal point. */
decimal_point = g_strdup(localeconv()->decimal_point);
- /* 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("Capinfos (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("Capinfos (Wireshark)", NULL, NULL, NULL);
#ifdef _WIN32
create_app_running_mutex();
break;
case 'h':
- printf("Capinfos (Wireshark) %s\n"
- "Print various information (infos) about capture files.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Print various information (infos) about capture files.");
print_usage(stdout);
goto exit;
break;
case 'v':
- comp_info_str = get_compiled_version_info(NULL, NULL);
- runtime_info_str = get_runtime_version_info(NULL);
- show_version("Capinfos (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
goto exit;
break;
#include <wiretap/wtap.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
wtap *wth;
int err;
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();
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;
#include <errno.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/strtoi.h>
#include <cli_main.h>
#include <version_info.h>
GString *cpu_info_str = g_string_new("");
get_cpu_info(cpu_info_str);
- char *appname = g_strdup_printf("Dumpcap (Wireshark) %s", get_ws_vcs_version_info());
successful = pcapng_write_session_header_block(ld->pdh,
(const char *)capture_opts->capture_comment, /* Comment */
cpu_info_str->str, /* HW */
os_info_str->str, /* OS */
- appname,
+ get_appname_and_version(),
-1, /* section_length */
&ld->bytes_written,
&err);
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "%s: wrote dumpcap SHB %d", G_STRFUNC, successful);
g_string_free(cpu_info_str, TRUE);
- g_free(appname);
}
for (unsigned i = 0; successful && (i < ld->saved_idbs->len); i++) {
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
int opt;
static const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
cmdarg_err_init(dumpcap_cmdarg_err, dumpcap_cmdarg_err_cont);
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(NULL, get_dumpcap_compiled_info);
-
- /* Get the run-time version information string */
- runtime_info_str = get_runtime_version_info(get_dumpcap_runtime_info);
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("Dumpcap (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("Dumpcap (Wireshark)", NULL, get_dumpcap_compiled_info,
+ get_dumpcap_runtime_info);
#ifdef _WIN32
create_app_running_mutex();
while ((opt = getopt_long(argc, argv, OPTSTRING, long_options, NULL)) != -1) {
switch (opt) {
case 'h': /* Print help and exit */
- printf("Dumpcap (Wireshark) %s\n"
- "Capture network packets and dump them into a pcapng or pcap file.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Capture network packets and dump them into a pcapng or pcap file.");
print_usage(stdout);
exit_main(0);
break;
case 'v': /* Show version and exit */
- comp_info_str = get_compiled_version_info(NULL, get_dumpcap_compiled_info);
- runtime_info_str = get_runtime_version_info(get_dumpcap_runtime_info);
- show_version("Dumpcap (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
exit_main(0);
break;
/*** capture option specific ***/
# include "wsutil/strptime.h"
#endif
-#include <wsutil/crash_info.h>
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
#include <wsutil/filesystem.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
- char *appname;
char *init_progfile_dir_error;
wtap *wth = NULL;
int i, j, read_err, write_err;
create_app_running_mutex();
#endif /* _WIN32 */
- /* 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);
-
- /* Get the application name with version info */
- appname = g_strdup_printf("Editcap (Wireshark) %s", get_ws_vcs_version_info());
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("%s\n"
- "\n"
- "%s"
- "\n"
- "%s",
- appname, 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("Editcap (Wireshark)", NULL, NULL, NULL);
/*
* Get credential information for later use.
break;
case 'h':
- printf("Editcap (Wireshark) %s\n"
- "Edit and/or translate the format of capture files.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Edit and/or translate the format of capture files.");
print_usage(stdout);
goto clean_exit;
break;
break;
case 'V':
- comp_info_str = get_compiled_version_info(NULL, NULL);
- runtime_info_str = get_runtime_version_info(NULL);
- show_version("Editcap (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
goto clean_exit;
break;
/* If we don't have an application name add one */
if (wtap_block_get_string_option_value(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS) {
- wtap_block_add_string_option_format(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "%s", appname);
+ wtap_block_add_string_option_format(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "%s", get_appname_and_version());
}
pdh = editcap_dump_open(filename, ¶ms, &write_err);
#include <epan/epan.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#include <wsutil/report_message.h>
static int
fuzz_init(int argc _U_, char **argv)
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
char *err_msg = NULL;
if (init_progfile_dir_error != NULL)
fprintf(stderr, "fuzzshark: Can't get pathname of oss-fuzzshark program: %s.\n", init_progfile_dir_error);
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
-
- /* Get the run-time version information string */
- runtime_info_str = get_runtime_version_info(epan_get_runtime_version_info);
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("OSS Fuzzshark (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("OSS Fuzzshark (Wireshark)", NULL,
+ epan_get_compiled_version_info, epan_get_runtime_version_info);
init_report_message(failure_warning_message, failure_warning_message,
open_failure_message, read_failure_message, write_failure_message);
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
- char *appname;
char *init_progfile_dir_error;
int opt;
static const struct option long_options[] = {
create_app_running_mutex();
#endif /* _WIN32 */
- /* 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);
-
- /* Get the application name with version info */
- appname = g_strdup_printf("mergecap (Wireshark) %s", get_ws_vcs_version_info());
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("%s\n"
- "\n"
- "%s"
- "\n"
- "%s",
- appname, 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("Mergecap (Wireshark)", NULL, NULL, NULL);
/*
* Get credential information for later use.
break;
case 'h':
- printf("Mergecap (Wireshark) %s\n"
- "Merge two or more capture files into one.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Merge two or more capture files into one.");
print_usage(stdout);
goto clean_exit;
break;
break;
case 'V':
- comp_info_str = get_compiled_version_info(NULL, NULL);
- runtime_info_str = get_runtime_version_info(NULL);
- show_version("Mergecap (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
goto clean_exit;
break;
status = merge_files_to_stdout(file_type,
(const char *const *) &argv[optind],
in_file_count, do_append, mode, snaplen,
- appname, verbose ? &cb : NULL,
+ get_appname_and_version(),
+ verbose ? &cb : NULL,
&err, &err_info, &err_fileno, &err_framenum);
} else {
/* merge the files to the outfile */
status = merge_files(out_filename, file_type,
(const char *const *) &argv[optind], in_file_count,
- do_append, mode, snaplen, appname, verbose ? &cb : NULL,
+ do_append, mode, snaplen, get_appname_and_version(),
+ verbose ? &cb : NULL,
&err, &err_info, &err_fileno, &err_framenum);
}
#include <epan/epan.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/plugins.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
int opt, i;
cmdarg_err_init(rawshark_cmdarg_err, rawshark_cmdarg_err_cont);
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
-
- /* 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("Rawshark (Wireshark) %s\n"
- "\n"
- "%s"
- "\n"
- "%s",
- get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+ /* Initialize the version information. */
+ ws_init_version_info("Rawshark (Wireshark)", NULL,
+ epan_get_compiled_version_info,
+ NULL);
#ifdef _WIN32
create_app_running_mutex();
g_ptr_array_add(disp_fields, g_strdup(optarg));
break;
case 'h': /* Print help and exit */
- printf("Rawshark (Wireshark) %s\n"
- "Dump and analyze network traffic.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Dump and analyze network traffic.");
print_usage(stdout);
goto clean_exit;
break;
break;
case 'v': /* Show version and exit */
{
- show_version("Rawshark (Wireshark)", comp_info_str, runtime_info_str);
+ show_version();
goto clean_exit;
}
default:
clean_exit:
g_free(pipe_name);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
epan_free(cfile.epan);
epan_cleanup();
extcap_cleanup();
#endif
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
wtap *wth = NULL;
wtap_dumper *pdh = NULL;
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("Reordercap (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("Reordercap (Wireshark)", NULL, NULL, NULL);
/*
* Get credential information for later use.
write_output_regardless = FALSE;
break;
case 'h':
- printf("Reordercap (Wireshark) %s\n"
- "Reorder timestamps of input file frames into output file.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Reorder timestamps of input file frames into output file.");
print_usage(stdout);
goto clean_exit;
case 'v':
- comp_info_str = get_compiled_version_info(NULL, NULL);
- runtime_info_str = get_runtime_version_info(NULL);
- show_version("Reordercap (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
goto clean_exit;
case '?':
print_usage(stderr);
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
int
main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
char *err_msg = NULL;
init_progfile_dir_error);
}
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
-
- /* Get the run-time version information string */
- runtime_info_str = get_runtime_version_info(epan_get_runtime_version_info);
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("Sharkd (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("Sharkd (Wireshark)", NULL,
+ epan_get_compiled_version_info,
+ epan_get_runtime_version_info);
if (sharkd_init(argc, argv) < 0)
{
#include <stdlib.h>
#include <string.h>
#include <wsutil/file_util.h>
-#include <wsutil/crash_info.h>
#include <cli_main.h>
#include <version_info.h>
#include <wsutil/inet_addr.h>
gboolean success;
if (use_pcapng) {
- char *appname;
char *comment;
- appname = g_strdup_printf("text2pcap (Wireshark) %s", get_ws_vcs_version_info());
comment = g_strdup_printf("Generated from input file %s.", input_filename);
success = pcapng_write_session_header_block(output_file,
comment,
NULL, /* HW */
NULL, /* OS */
- appname,
+ get_appname_and_version(),
-1, /* section_length */
&bytes_written,
&err);
- g_free(appname);
g_free(comment);
if (success) {
success = pcapng_write_interface_description_block(output_file,
static int
parse_options (int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
int c;
char *p;
static const struct option long_options[] = {
};
struct tm *now_tm;
- /* 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("Text2pcap (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("Text2pcap (Wireshark)", NULL, NULL, NULL);
/* Scan CLI parameters */
while ((c = getopt_long(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
- printf("Text2pcap (Wireshark) %s\n"
- "Generate a capture file from an ASCII hexdump of packets.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Generate a capture file from an ASCII hexdump of packets.");
print_usage(stdout);
exit(0);
break;
break;
case 'v':
- comp_info_str = get_compiled_version_info(NULL, NULL);
- runtime_info_str = get_runtime_version_info(NULL);
- show_version("Text2pcap (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;
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
output = stdout;
- fprintf(output, "TFShark (Wireshark) %s\n", get_ws_vcs_version_info());
+ fprintf(output, "%s\n", get_appname_and_version());
fprintf(output, "\n");
fprintf(output, "Usage: tfshark -G [report]\n");
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
int opt;
static const struct option long_options[] = {
initialize_funnel_ops();
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
-
- /* Get the run-time version information string */
- runtime_info_str = get_runtime_version_info(get_tfshark_runtime_version_info);
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("TFShark (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("TFShark (Wireshark)", NULL,
+ epan_get_compiled_version_info,
+ get_tfshark_runtime_version_info);
/*
* In order to have the -X opts assigned before the wslua machine starts
break;
case 'h': /* Print help and exit */
- printf("TFShark (Wireshark) %s\n"
- "Dump and analyze network traffic.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Analyze file structure.");
print_usage(stdout);
goto clean_exit;
break;
}
break;
case 'v': /* Show version and exit */
- comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
- runtime_info_str = get_runtime_version_info(get_tfshark_runtime_version_info);
- show_version("TFShark (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
goto clean_exit;
case 'O': /* Only output these protocols */
/* already processed; just ignore it now */
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
output = stdout;
- fprintf(output, "TShark (Wireshark) %s\n", get_ws_vcs_version_info());
+ fprintf(output, "%s\n", get_appname_and_version());
fprintf(output, "\n");
fprintf(output, "Usage: tshark -G [report]\n");
int
real_main(int argc, char *argv[])
{
- GString *comp_info_str;
- GString *runtime_info_str;
char *init_progfile_dir_error;
int opt;
static const struct option long_options[] = {
#endif /* HAVE_LIBPCAP */
#endif /* _WIN32 */
- /* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(get_tshark_compiled_version_info,
- epan_get_compiled_version_info);
-
- /* Get the run-time version information string */
- runtime_info_str = get_runtime_version_info(get_tshark_runtime_version_info);
-
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("TShark (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("TShark (Wireshark)", get_tshark_compiled_version_info,
+ epan_get_compiled_version_info,
+ get_tshark_runtime_version_info);
/* Fail sometimes. Useful for testing fuzz scripts. */
/* if (g_random_int_range(0, 100) < 5) abort(); */
break;
case 'h': /* Print help and exit */
- printf("TShark (Wireshark) %s\n"
- "Dump and analyze network traffic.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
+ show_help_header("Dump and analyze network traffic.");
print_usage(stdout);
exit_status = EXIT_SUCCESS;
goto clean_exit;
break;
}
case 'v': /* Show version and exit */
- comp_info_str = get_compiled_version_info(get_tshark_compiled_version_info,
- epan_get_compiled_version_info);
- runtime_info_str = get_runtime_version_info(get_tshark_runtime_version_info);
- show_version("TShark (Wireshark)", comp_info_str, runtime_info_str);
- g_string_free(comp_info_str, TRUE);
- g_string_free(runtime_info_str, TRUE);
+ show_version();
/* We don't really have to cleanup here, but it's a convenient way to test
* start-up and shut-down of the epan library without any UI-specific
* cruft getting in the way. Makes the results of running
/* If we don't have an application name add Tshark */
if (wtap_block_get_string_option_value(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS) {
/* this is free'd by wtap_block_free() later */
- wtap_block_add_string_option_format(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
+ wtap_block_add_string_option_format(g_array_index(params.shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "%s", get_appname_and_version());
}
tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file);
#endif
if (for_help_option) {
+ show_help_header("Interactively dump and analyze network traffic.");
output = stdout;
- fprintf(output, "Wireshark %s\n"
- "Interactively dump and analyze network traffic.\n"
- "See https://www.wireshark.org for more information.\n",
- get_ws_vcs_version_info());
} else {
output = stderr;
}
}
#endif
-void commandline_early_options(int argc, char *argv[],
- GString *comp_info_str, GString *runtime_info_str)
+void commandline_early_options(int argc, char *argv[])
{
int opt;
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
create_console();
#endif
- show_version("Wireshark", comp_info_str, runtime_info_str);
+ show_version();
#ifdef _WIN32
destroy_console();
#endif
extern void commandline_print_usage(gboolean for_help_option);
-extern void commandline_early_options(int argc, char *argv[],
- GString *comp_info_str, GString *runtime_info_str);
+extern void commandline_early_options(int argc, char *argv[]);
/* Command-line options that don't have direct API calls to handle the data */
typedef struct commandline_param_info
#include <wsutil/clopts_common.h>
#include <wsutil/cmdarg_err.h>
-#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/privileges.h>
#ifdef HAVE_PLUGINS
#endif
#endif
gchar *err_msg = NULL;
- GString *comp_info_str = NULL;
- GString *runtime_info_str = NULL;
QString dfilter, read_filter;
#ifdef HAVE_LIBPCAP
#endif /* _WIN32 */
/* Get the compile-time version information string */
- comp_info_str = get_compiled_version_info(get_wireshark_qt_compiled_info,
- get_gui_compiled_info);
-
- /* Assemble the run-time version information string */
- runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
+ ws_init_version_info("Wireshark", get_wireshark_qt_compiled_info,
+ get_gui_compiled_info, get_wireshark_runtime_info);
/* Create the user profiles directory */
if (create_profiles_dir(&rf_path) == -1) {
g_free(rf_path);
}
- commandline_early_options(argc, argv, comp_info_str, runtime_info_str);
+ commandline_early_options(argc, argv);
#ifdef _WIN32
reset_library_path();
QString cf_name;
unsigned int in_file_type = WTAP_TYPE_AUTO;
- /* Add it to the information to be reported on a crash. */
- ws_add_crash_info("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);
-
#ifdef _WIN32
/* Start windows sockets */
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
* UTF-8 string containing the name of the application used to create
* this section.
*/
- wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
+ wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "%s", get_appname_and_version());
/* Create fake IDB info */
exp_pdu_tap_data->idb_inf = g_new(wtapng_iface_descriptions_t,1);
#include <wsutil/cpu_info.h>
#include <wsutil/copyright_info.h>
#include <wsutil/os_version_info.h>
+#include <wsutil/crash_info.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf */
#include <wsutil/plugins.h>
+static char *appname_with_version;
+static char *comp_info;
+static char *runtime_info;
+
+void
+ws_init_version_info(const char *appname,
+ void (*prepend_compile_time_info)(GString *),
+ void (*append_compile_time_info)(GString *),
+ void (*additional_run_time_info)(GString *))
+{
+ GString *comp_info_str, *runtime_info_str;
+
+ /*
+ * Combine the supplied application name string with the
+ * version - including the VCS version, for a build from
+ * a checkout.
+ */
+ appname_with_version = g_strdup_printf("%s %s",
+ appname, get_ws_vcs_version_info());
+
+ /* Get the compile-time version information string */
+ comp_info_str = get_compiled_version_info(prepend_compile_time_info,
+ append_compile_time_info);
+
+ /* Get the run-time version information string */
+ runtime_info_str = get_runtime_version_info(additional_run_time_info);
+
+ comp_info = g_string_free(comp_info_str, FALSE);
+ runtime_info = g_string_free(runtime_info_str, FALSE);
+
+ /* Add this information to the information to be reported on a crash. */
+ ws_add_crash_info("%s\n"
+ "\n"
+ "%s\n"
+ "%s",
+ appname_with_version, comp_info, runtime_info);
+}
+
+const char *
+get_appname_and_version(void)
+{
+ return appname_with_version;
+}
+
/*
* If the string doesn't end with a newline, append one.
* Then word-wrap it to 80 columns.
return str;
}
-void
-show_version(const gchar *prog_name_str, GString *comp_info_str,
- GString *runtime_info_str)
-{
- ws_debug_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
* from a tree checked out from Wireshark's version control system,
*micro = VERSION_MICRO;
}
+void
+show_version(void)
+{
+ ws_debug_printf("%s\n"
+ "\n"
+ "%s\n"
+ "%s\n"
+ "%s",
+ appname_with_version, get_copyright_info(),
+ comp_info, runtime_info);
+}
+
+void
+show_help_header(const char *description)
+{
+ ws_debug_printf("%s\n"
+ "%s\n"
+ "See https://www.wireshark.org for more information.\n",
+ appname_with_version, description);
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
extern "C" {
#endif /* __cplusplus */
+/*
+ * Initialize information about the program for various purposes, including
+ * reporting the version and build information for the program, putting
+ * that information into crash dumps if possible, and giving the program
+ * name and version information into capture files written by the program
+ * if possible.
+ *
+ * "appname" is a string that appears at the beginning of the information;
+ * it should include the application name, followed by "(Wireshark)" if
+ * the program isn't Wireshark.
+ *
+ * "prepend_compile_time_info" is called at the start to prepend any
+ * additional build information before the standard library information.
+ *
+ * "append_compile_time_info" is called at the end to append any additional
+ * build information after the standard library information. This is
+ * required in order to, for example, put Qt information at the
+ * end of the string, as we don't use Qt in TShark.
+ *
+ * "additional_info" is called at the end to append any additional
+ * run-time information; this is required in order to, for example,
+ * put the libcap information at the end of the string, as we currently
+ * don't use libcap in TShark.
+ */
+void ws_init_version_info(const char *appname,
+ void (*prepend_compile_time_info)(GString *),
+ void (*append_compile_time_info)(GString *),
+ void (*additional_run_time_info)(GString *));
+
+/*
+ * Get a string giving the application name, as provided to
+ * ws_init_version_info(), followed by a string giving the
+ * application version.
+ */
+const char *get_appname_and_version(void);
+
/*
* Get various library compile-time versions, put them in a GString,
* and return the GString.
*/
GString *get_runtime_version_info(void (*additional_info)(GString *));
-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,
*/
void get_ws_version_number(int *major, int *minor, int *micro);
+/*
+ * Show the program name and version number information on the standard
+ * output; this is used for command-line "show the version" options.
+ */
+void show_version(void);
+
+/*
+ * Show the program name and version number information, a supplied
+ * description string, and a "See {URL} for more information" message.
+ * This is used for command-line "help" options.
+ */
+void show_help_header(const char *description);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
* UTF-8 string containing the name of the application used to create
* this section.
*/
- wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
+ wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "%s", get_appname_and_version());
/* Add header to the array */
g_array_append_val(shb_hdrs, shb_hdr);