The Styleguide section has been moved to the Wireshark Developer's Guide.
[obnox/wireshark/wip.git] / capture_ui_utils.c
index c975aa6df581f4bddf92c2d06b2ece6f344cb5a1..c8f9be7dc851ff27db79bb57331bc7e3aac88466 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <glib.h>
 
-#include <epan/prefs.h>
-#include "capture-pcap-util.h"
+#include "epan/prefs.h"
+#include "epan/ex-opt.h"
+#include "capture_ifinfo.h"
 #include "capture_ui_utils.h"
 
 /*
@@ -130,12 +132,12 @@ capture_dev_user_linktype_find(const gchar *if_name)
 /*
  * Return as descriptive a name for an interface as we can get.
  * If the user has specified a comment, use that.  Otherwise,
- * if get_interface_list() supplies a description, use that,
+ * if capture_interface_list() supplies a description, use that,
  * otherwise use the interface name.
  *
  * The result must be g_free()'d when you're done with it.
  *
- * Note: given that this calls get_interface_list(), which attempts to
+ * Note: given that this calls capture_interface_list(), which attempts to
  * open all adapters it finds in order to check whether they can be
  * captured on, this is an expensive routine to call, so don't call it
  * frequently.
@@ -154,11 +156,22 @@ get_interface_descriptive_name(const char *if_name)
   if (descr != NULL) {
     /* Yes - make a copy of that. */
     descr = g_strdup(descr);
+  } else if (strcmp(if_name, "-") == 0) {
+    /*
+     * Strictly speaking, -X (extension) options are for modules, e.g. Lua
+     * and using one here stretches that definition. However, this doesn't
+     * waste a single-letter option on something that might be rarely used
+     * and is backward-compatible to 1.0.
+     */
+    descr = g_strdup(ex_opt_get_nth("stdin_descr", 0));
+    if (!descr) {
+      descr = g_strdup("Standard input");
+    }
   } else {
     /* No, we don't have a user-supplied description; did we get
        one from the OS or libpcap? */
     descr = NULL;
-    if_list = get_interface_list(&err, NULL);
+    if_list = capture_interface_list(&err, NULL);
     if (if_list != NULL && if_name != NULL) {
       if_entry = if_list;
       do {