If we're not running as a child process, report the interfaces on which
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 22 Nov 2011 10:08:26 +0000 (10:08 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 22 Nov 2011 10:08:26 +0000 (10:08 +0000)
we're capturing.  (We do not require a -i flag; the message could be
useful if you don't specify the interface, as it lets you know which
interface was chosen, which might not be the interface you'd think it
would be.  Yes, that's arguably a libpcap bug, which I plan to look at;
it should probably try to figure out which interfaces are "active" if
possible, and prefer those.)

Use cmdarg_err() for invalid capture filters and other capture errors.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39983 f5534014-38df-0310-8fa8-9805f1628bb7

dumpcap.c

index bf0def121712e62ba1f9e77fd45f1298e810fc71..96eb7d49af1848ed8582c35a3ad17109fc4906dd 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -3708,6 +3708,7 @@ main(int argc, char *argv[])
 #if defined(__APPLE__) && defined(__LP64__)
     struct utsname       osinfo;
 #endif
+    char                *sep;
 
 #ifdef _WIN32
     arg_list_utf_16to8(argc, argv);
@@ -4232,12 +4233,23 @@ main(int argc, char *argv[])
 
     /* Let the user know what interfaces were chosen. */
     /* get_interface_descriptive_name() is not available! */
+    sep = "";
+    if (!capture_child)
+      fprintf(stderr, "Interfaces: ");
     for (j = 0; j < global_capture_opts.ifaces->len; j++) {
         interface_options interface_opts;
 
         interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
-        g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s", interface_opts.name);
+        if (capture_child) {
+              g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n",
+                    interface_opts.name);
+        } else {
+              fprintf(stderr, "%s%s", sep, interface_opts.name);
+       }
+       sep = ", ";
     }
+    if (!capture_child)
+      fprintf(stderr, "\n");
 
     if (list_link_layer_types) {
         /* Get the list of link-layer types for the capture device. */
@@ -4459,11 +4471,11 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
              * the error message below.
              */
             interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
-            fprintf(stderr,
-              "Invalid capture filter \"%s\" for interface %s!\n"
+            cmdarg_err(
+              "Invalid capture filter: \"%s\" for interface %s!\n"
               "\n"
               "That string isn't a valid capture filter (%s).\n"
-              "See the User's Guide for a description of the capture filter syntax.\n",
+              "See the User's Guide for a description of the capture filter syntax.",
               interface_opts.cfilter, interface_opts.name, errmsg);
         }
     }
@@ -4479,9 +4491,9 @@ report_capture_error(const char *error_msg, const char *secondary_error_msg)
             "Secondary Error: %s", secondary_error_msg);
         sync_pipe_errmsg_to_parent(2, error_msg, secondary_error_msg);
     } else {
-        fprintf(stderr, "%s\n", error_msg);
+        cmdarg_err("%s", error_msg);
         if (secondary_error_msg[0] != '\0')
-          fprintf(stderr, "%s\n", secondary_error_msg);
+          cmdarg_err_cont("%s", secondary_error_msg);
     }
 }