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 <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-08-12 19:02:22 -07:00
parent 6409732b77
commit d48262753e
3 changed files with 56 additions and 66 deletions

View File

@ -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 */
/*

View File

@ -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 */

View File

@ -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