extcap: clean up the version number handling.
Have the version parameter be just the version number; other code expects it to be that. Have additional parameters for the "compiled with" and "running with" information. Add a extcap_version_print() routine to show the version message, printing {exename} version {version} and then printing Compiled with {compiled_with} if "compiled with" information is supplied and printing Running with {running_with} if "running with" information is supplied. This fixes some messages, as well as fixing the display of extcap modules in the About dialog. Change-Id: I3d298d30e83bd363abd599d75adfc780a90f34fd Reviewed-on: https://code.wireshark.org/review/37877 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
This commit is contained in:
parent
44ca0af5df
commit
e4835191cb
|
@ -2583,7 +2583,7 @@ int main(int argc, char *argv[]) {
|
|||
switch (result) {
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
ret = EXIT_CODE_SUCCESS;
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
|
|
|
@ -551,11 +551,11 @@ int main(int argc, char *argv[])
|
|||
help_url = data_file_url("ciscodump.html");
|
||||
extcap_base_set_util_info(extcap_conf, argv[0], CISCODUMP_VERSION_MAJOR, CISCODUMP_VERSION_MINOR,
|
||||
CISCODUMP_VERSION_RELEASE, help_url);
|
||||
extcap_base_add_info(extcap_conf, "Compiled with libssh version %s", LIBSSH_VERSION_STRING);
|
||||
extcap_base_set_compiled_with(extcap_conf, "libssh version %s", LIBSSH_VERSION_STRING);
|
||||
#ifdef HAVE_SSH_VERSION
|
||||
extcap_base_add_info(extcap_conf, "Running with libssh version %s", ssh_version(0));
|
||||
extcap_base_set_running_with(extcap_conf, "libssh version %s", ssh_version(0));
|
||||
#else
|
||||
extcap_base_add_info(extcap_conf, "Running with libssh (unknown version)");
|
||||
extcap_base_set_running_with(extcap_conf, "libssh (unknown version)");
|
||||
#endif
|
||||
g_free(help_url);
|
||||
extcap_base_register_interface(extcap_conf, CISCODUMP_EXTCAP_INTERFACE, "Cisco remote capture", 147, "Remote capture dependent DLT");
|
||||
|
@ -603,7 +603,7 @@ int main(int argc, char *argv[])
|
|||
goto end;
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
goto end;
|
||||
|
||||
case OPT_REMOTE_HOST:
|
||||
|
|
|
@ -536,7 +536,7 @@ int main(int argc, char *argv[])
|
|||
goto end;
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
goto end;
|
||||
|
||||
case OPT_INTERFACE_ID:
|
||||
|
|
|
@ -83,8 +83,7 @@ void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename,
|
|||
if (!minor)
|
||||
g_assert(!release);
|
||||
|
||||
extcap->version = g_strdup_printf("%s version %s%s%s%s%s",
|
||||
extcap->exename,
|
||||
extcap->version = g_strdup_printf("%s%s%s%s%s",
|
||||
major,
|
||||
minor ? "." : "",
|
||||
minor ? minor : "",
|
||||
|
@ -93,18 +92,22 @@ void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename,
|
|||
extcap->helppage = g_strdup(helppage);
|
||||
}
|
||||
|
||||
void extcap_base_add_info(extcap_parameters * extcap, const char *fmt, ...)
|
||||
void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...)
|
||||
{
|
||||
gchar * old_version = extcap->version;
|
||||
va_list ap;
|
||||
gchar * info;
|
||||
|
||||
va_start(ap, fmt);
|
||||
info = g_strdup_vprintf(fmt, ap);
|
||||
extcap->compiled_with = g_strdup_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
extcap->running_with = g_strdup_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
extcap->version = g_strdup_printf("%s\n%s", old_version, info);
|
||||
g_free(old_version);
|
||||
g_free(info);
|
||||
}
|
||||
|
||||
static void extcap_custom_log(const gchar *log_domain,
|
||||
|
@ -266,6 +269,8 @@ void extcap_base_cleanup(extcap_parameters ** extcap)
|
|||
g_free((*extcap)->fifo);
|
||||
g_free((*extcap)->interface);
|
||||
g_free((*extcap)->version);
|
||||
g_free((*extcap)->compiled_with);
|
||||
g_free((*extcap)->running_with);
|
||||
g_free((*extcap)->helppage);
|
||||
g_free((*extcap)->help_header);
|
||||
g_free((*extcap)->ws_version);
|
||||
|
@ -280,6 +285,15 @@ static void extcap_print_option(gpointer option, gpointer user_data _U_)
|
|||
printf("\t%s: %s\n", o->optname, o->optdesc);
|
||||
}
|
||||
|
||||
void extcap_version_print(extcap_parameters * extcap)
|
||||
{
|
||||
printf("%s version %s\n", extcap->exename, extcap->version);
|
||||
if (extcap->compiled_with != NULL)
|
||||
printf("Compiled with %s\n", extcap->compiled_with);
|
||||
if (extcap->running_with != NULL)
|
||||
printf("Running with %s\n", extcap->running_with);
|
||||
}
|
||||
|
||||
void extcap_help_print(extcap_parameters * extcap)
|
||||
{
|
||||
printf("\nWireshark - %s v%s\n\n", extcap->exename, extcap->version);
|
||||
|
|
|
@ -66,6 +66,8 @@ typedef struct _extcap_parameters
|
|||
char * capture_filter;
|
||||
|
||||
char * version;
|
||||
char * compiled_with;
|
||||
char * running_with;
|
||||
char * helppage;
|
||||
uint8_t capture;
|
||||
uint8_t show_config;
|
||||
|
@ -87,12 +89,14 @@ typedef struct _extcap_parameters
|
|||
void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
|
||||
void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
|
||||
void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
|
||||
void extcap_base_add_info(extcap_parameters * extcap, const char *fmt, ...);
|
||||
void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...);
|
||||
void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...);
|
||||
uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
|
||||
uint8_t extcap_base_handle_interface(extcap_parameters * extcap);
|
||||
void extcap_base_cleanup(extcap_parameters ** extcap);
|
||||
void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
|
||||
void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc);
|
||||
void extcap_version_print(extcap_parameters * extcap);
|
||||
void extcap_help_print(extcap_parameters * extcap);
|
||||
void extcap_cmdline_debug(char** ar, const unsigned n);
|
||||
void extcap_init_custom_log(const char* filename);
|
||||
|
|
|
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
|||
while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
|
||||
switch (result) {
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
ret = EXIT_SUCCESS;
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ int main(int argc, char **argv)
|
|||
goto end;
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
ret = EXIT_SUCCESS;
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -373,11 +373,11 @@ int main(int argc, char *argv[])
|
|||
extcap_base_set_util_info(extcap_conf, argv[0], SSHDUMP_VERSION_MAJOR, SSHDUMP_VERSION_MINOR,
|
||||
SSHDUMP_VERSION_RELEASE, help_url);
|
||||
g_free(help_url);
|
||||
extcap_base_add_info(extcap_conf, "Compiled with libssh version %s", LIBSSH_VERSION_STRING);
|
||||
extcap_base_set_compiled_with(extcap_conf, "libssh version %s", LIBSSH_VERSION_STRING);
|
||||
#ifdef HAVE_SSH_VERSION
|
||||
extcap_base_add_info(extcap_conf, "Running with libssh version %s", ssh_version(0));
|
||||
extcap_base_set_running_with(extcap_conf, "libssh version %s", ssh_version(0));
|
||||
#else
|
||||
extcap_base_add_info(extcap_conf, "Running with libssh (unknown version)");
|
||||
extcap_base_set_running_with(extcap_conf, "libssh (unknown version)");
|
||||
#endif
|
||||
extcap_base_register_interface(extcap_conf, SSH_EXTCAP_INTERFACE, "SSH remote capture", 147, "Remote capture dependent DLT");
|
||||
|
||||
|
@ -426,7 +426,7 @@ int main(int argc, char *argv[])
|
|||
goto end;
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
ret = EXIT_SUCCESS;
|
||||
goto end;
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ int main(int argc, char *argv[])
|
|||
goto end;
|
||||
|
||||
case OPT_VERSION:
|
||||
printf("%s\n", extcap_conf->version);
|
||||
extcap_version_print(extcap_conf);
|
||||
goto end;
|
||||
|
||||
case OPT_PORT:
|
||||
|
|
Loading…
Reference in New Issue