From d48262753eecd46a5ba0fc13bbc8c336fa16c207 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 12 Aug 2018 19:02:22 -0700 Subject: [PATCH] Move get_iface_display_name() to ui/iface_lists.c. It's only used there, so move it there. Change-Id: I68472150e020ba94166782e3e4c08cba94c0f9ee Reviewed-on: https://code.wireshark.org/review/29114 Reviewed-by: Guy Harris --- ui/capture_ui_utils.c | 57 ------------------------------------------- ui/capture_ui_utils.h | 9 ------- ui/iface_lists.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 66 deletions(-) diff --git a/ui/capture_ui_utils.c b/ui/capture_ui_utils.c index 53328b7a69..92ff44d77f 100644 --- a/ui/capture_ui_utils.c +++ b/ui/capture_ui_utils.c @@ -587,63 +587,6 @@ get_iface_list_string(capture_options *capture_opts, guint32 style) } return iface_list_string; } - -gchar * -get_iface_display_name(const gchar *description, const if_info_t *if_info) -{ - /* Do we have a user-supplied description? */ - if (description && description[0]) { - /* - * Yes - show both the user-supplied description and a name for the - * interface. - */ -#ifdef _WIN32 - /* - * On Windows, if we have a friendly name, just show it - * rather than the name, as the name is a string made out - * of the device GUID, and not at all friendly. - */ - gchar *if_string = if_info->friendly_name ? if_info->friendly_name : if_info->name; - return g_strdup_printf("%s: %s", description, if_string); -#else - /* - * On UN*X, show the interface name; it's short and somewhat - * friendly, and many UN*X users are used to interface names, - * so we should show it. - */ - return g_strdup_printf("%s: %s", description, if_info->name); -#endif - } - - if (if_info->friendly_name) { - /* We have a friendly name from the OS. */ -#ifdef _WIN32 - /* - * On Windows, if we have a friendly name, just show it, - * don't show the name, as that's a string made out of - * the device GUID, and not at all friendly. - */ - return g_strdup_printf("%s", if_info->friendly_name); -#else - /* - * On UN*X, if we have a friendly name, show it along - * with the interface name; the interface name is short - * and somewhat friendly, and many UN*X users are used - * to interface names, so we should show it. - */ - return g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name); -#endif - } - - if (if_info->vendor_description) { - /* We have a device description from libpcap. */ - return g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name); - } - - /* No additional descriptions found. */ - return g_strdup(if_info->name); -} - #endif /* HAVE_LIBPCAP */ /* diff --git a/ui/capture_ui_utils.h b/ui/capture_ui_utils.h index 22ab891735..84f0abd024 100644 --- a/ui/capture_ui_utils.h +++ b/ui/capture_ui_utils.h @@ -156,15 +156,6 @@ extern void set_active_dlt(interface_t *device, int global_default_dlt); extern GString *get_iface_list_string(capture_options *capture_opts, guint32 style); -/** Get the interface display name to present in the interfaces list. - * - * @param description A user-specified capture device description - * @param if_info The if_info for the interface - * - * @return A interface display name (must be g_free'd later) - */ -extern gchar *get_iface_display_name(const gchar *description, const if_info_t *if_info); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ui/iface_lists.c b/ui/iface_lists.c index 7b5566d00f..fa9153b4b3 100644 --- a/ui/iface_lists.c +++ b/ui/iface_lists.c @@ -60,6 +60,62 @@ fill_from_ifaces (interface_t *device) return FALSE; } +static gchar * +get_iface_display_name(const gchar *description, const if_info_t *if_info) +{ + /* Do we have a user-supplied description? */ + if (description && description[0]) { + /* + * Yes - show both the user-supplied description and a name for the + * interface. + */ +#ifdef _WIN32 + /* + * On Windows, if we have a friendly name, just show it + * rather than the name, as the name is a string made out + * of the device GUID, and not at all friendly. + */ + gchar *if_string = if_info->friendly_name ? if_info->friendly_name : if_info->name; + return g_strdup_printf("%s: %s", description, if_string); +#else + /* + * On UN*X, show the interface name; it's short and somewhat + * friendly, and many UN*X users are used to interface names, + * so we should show it. + */ + return g_strdup_printf("%s: %s", description, if_info->name); +#endif + } + + if (if_info->friendly_name) { + /* We have a friendly name from the OS. */ +#ifdef _WIN32 + /* + * On Windows, if we have a friendly name, just show it, + * don't show the name, as that's a string made out of + * the device GUID, and not at all friendly. + */ + return g_strdup_printf("%s", if_info->friendly_name); +#else + /* + * On UN*X, if we have a friendly name, show it along + * with the interface name; the interface name is short + * and somewhat friendly, and many UN*X users are used + * to interface names, so we should show it. + */ + return g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name); +#endif + } + + if (if_info->vendor_description) { + /* We have a device description from libpcap. */ + return g_strdup_printf("%s: %s", if_info->vendor_description, if_info->name); + } + + /* No additional descriptions found. */ + return g_strdup(if_info->name); +} + /* * Fetch the list of local interfaces with capture_interface_list() * and set the list of "all interfaces" in *capture_opts to include