diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-04-19 22:32:52 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-04-19 22:32:52 +0000 |
commit | 5115a265a90d07aac274f7579285caeba266f128 (patch) | |
tree | ddfdaeb49ad3322cb6fd2ebd48a180ca8282efc8 /capture_ui_utils.c | |
parent | 6b90d6085e06758dde6441656b2e779b06446e5c (diff) |
fix some minor bugs with the current interface name:
-always show descriptive string in combo box
-correct the initialization, so cancelling the option dialog won't make trouble
svn path=/trunk/; revision=14144
Diffstat (limited to 'capture_ui_utils.c')
-rw-r--r-- | capture_ui_utils.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/capture_ui_utils.c b/capture_ui_utils.c index 1bbcb02558..dd93d2ce24 100644 --- a/capture_ui_utils.c +++ b/capture_ui_utils.c @@ -148,6 +148,60 @@ get_interface_descriptive_name(const char *if_name) return descr; } + +/* search interface info by interface name */ +static if_info_t * +search_info(GList *if_list, gchar *if_name) +{ + GList *if_entry; + if_info_t *if_info; + + + for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) { + if_info = if_entry->data; + + if(strcmp(if_name, if_info->name) == 0) { + return if_info; + } + } + + return NULL; +} + + +/* build the string to display in the combo box for the given interface */ +char * +build_capture_combo_name(GList *if_list, gchar *if_name) +{ + gchar *descr; + char *if_string; + if_info_t *if_info; + + + /* Do we have a user-supplied description? */ + descr = capture_dev_user_descr_find(if_name); + if (descr != NULL) { + /* Yes, we have a user-supplied description; use it. */ + if_string = g_strdup_printf("%s: %s", descr, if_name); + g_free(descr); + } else { + /* No, we don't have a user-supplied description; did we get + one from the OS or libpcap? */ + if_info = search_info(if_list, if_name); + if (if_info && if_info->description != NULL) { + /* Yes - use it. */ + if_string = g_strdup_printf("%s: %s", if_info->description, + if_info->name); + } else { + /* No. */ + if_string = g_strdup(if_name); + } + } + + return if_string; +} + + GList * build_capture_combo_list(GList *if_list, gboolean do_hide) { |