Move some option checking to common code.
authorGuy Harris <guy@alum.mit.edu>
Sun, 19 Jun 2016 23:36:57 +0000 (16:36 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sun, 19 Jun 2016 23:37:08 +0000 (23:37 +0000)
Change-Id: Icff9dacd73ea933c59ed664db05098dd8cb3dbf5
Reviewed-on: https://code.wireshark.org/review/16029
Reviewed-by: Guy Harris <guy@alum.mit.edu>
ui/commandline.c
ui/gtk/main.c
wireshark-qt.cpp

index a7a164c0fbaf62e0e80519a64c607bd063257ebf..38c6f386e805c93d54840720959736baa8ea2f03 100644 (file)
@@ -652,6 +652,54 @@ void commandline_other_options(int argc, char *argv[], commandline_param_info_t*
         commandline_print_usage(FALSE);
         exit(1);
     }
+
+    if (param_info->start_capture && param_info->list_link_layer_types) {
+        /* Specifying *both* is bogus. */
+        cmdarg_err("You can't specify both -L and a live capture.");
+        exit(1);
+    }
+
+    if (param_info->list_link_layer_types) {
+        /* We're supposed to list the link-layer types for an interface;
+           did the user also specify a capture file to be read? */
+        if (param_info->cf_name) {
+            /* Yes - that's bogus. */
+            cmdarg_err("You can't specify -L and a capture file to be read.");
+            exit(1);
+        }
+        /* No - did they specify a ring buffer option? */
+        if (global_capture_opts.multi_files_on) {
+            cmdarg_err("Ring buffer requested, but a capture isn't being done.");
+            exit(1);
+        }
+    } else {
+        /* We're supposed to do a live capture; did the user also specify
+           a capture file to be read? */
+        if (param_info->start_capture && param_info->cf_name) {
+            /* Yes - that's bogus. */
+            cmdarg_err("You can't specify both a live capture and a capture file to be read.");
+            exit(1);
+        }
+
+        /* No - was the ring buffer option specified and, if so, does it make
+           sense? */
+        if (global_capture_opts.multi_files_on) {
+            /* Ring buffer works only under certain conditions:
+             a) ring buffer does not work with temporary files;
+             b) real_time_mode and multi_files_on are mutually exclusive -
+             real_time_mode takes precedence;
+             c) it makes no sense to enable the ring buffer if the maximum
+             file size is set to "infinite". */
+            if (global_capture_opts.save_file == NULL) {
+                cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
+                global_capture_opts.multi_files_on = FALSE;
+            }
+            if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
+                cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
+                /* XXX - this must be redesigned as the conditions changed */
+            }
+        }
+    }
 }
 
 /*
index a30792e37235acd65acff0840aac9840d8e9797e..8524dd7c98dd54862681e8ba7dc84fbe0e1c85f9 100644 (file)
@@ -2380,53 +2380,6 @@ main(int argc, char *argv[])
 
 #ifdef HAVE_LIBPCAP
     fill_in_local_interfaces(main_window_update);
-    if (commandline_info.start_capture && commandline_info.list_link_layer_types) {
-        /* Specifying *both* is bogus. */
-        cmdarg_err("You can't specify both -L and a live capture.");
-        exit(1);
-    }
-
-    if (commandline_info.list_link_layer_types) {
-        /* We're supposed to list the link-layer types for an interface;
-           did the user also specify a capture file to be read? */
-        if (commandline_info.cf_name) {
-            /* Yes - that's bogus. */
-            cmdarg_err("You can't specify -L and a capture file to be read.");
-        exit(1);
-        }
-        /* No - did they specify a ring buffer option? */
-        if (global_capture_opts.multi_files_on) {
-            cmdarg_err("Ring buffer requested, but a capture isn't being done.");
-            exit(1);
-        }
-    } else {
-        /* We're supposed to do a live capture; did the user also specify
-           a capture file to be read? */
-        if (commandline_info.start_capture && commandline_info.cf_name) {
-            /* Yes - that's bogus. */
-            cmdarg_err("You can't specify both a live capture and a capture file to be read.");
-            exit(1);
-        }
-
-        /* No - was the ring buffer option specified and, if so, does it make
-           sense? */
-        if (global_capture_opts.multi_files_on) {
-            /* Ring buffer works only under certain conditions:
-             a) ring buffer does not work with temporary files;
-             b) real_time_mode and multi_files_on are mutually exclusive -
-             real_time_mode takes precedence;
-             c) it makes no sense to enable the ring buffer if the maximum
-             file size is set to "infinite". */
-            if (global_capture_opts.save_file == NULL) {
-                cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
-                global_capture_opts.multi_files_on = FALSE;
-            }
-            if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
-                cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
-                /* XXX - this must be redesigned as the conditions changed */
-            }
-        }
-    }
 
     if (commandline_info.start_capture || commandline_info.list_link_layer_types) {
         /* We're supposed to do a live capture or get a list of link-layer
index 5e5743f611fadbd848c9eb3381c0189f40b8e368..9bc9ac826e7fc0c22dbfe490f9fec8cd0ea8a1ab 100644 (file)
@@ -633,54 +633,6 @@ int main(int argc, char *argv[])
 #ifdef HAVE_LIBPCAP
     fill_in_local_interfaces(main_window_update);
 
-    if (commandline_info.start_capture && commandline_info.list_link_layer_types) {
-        /* Specifying *both* is bogus. */
-        cmdarg_err("You can't specify both -L and a live capture.");
-        exit(1);
-    }
-
-    if (commandline_info.list_link_layer_types) {
-        /* We're supposed to list the link-layer types for an interface;
-           did the user also specify a capture file to be read? */
-        if (!cf_name.isEmpty()) {
-            /* Yes - that's bogus. */
-            cmdarg_err("You can't specify -L and a capture file to be read.");
-        exit(1);
-        }
-        /* No - did they specify a ring buffer option? */
-        if (global_capture_opts.multi_files_on) {
-            cmdarg_err("Ring buffer requested, but a capture isn't being done.");
-            exit(1);
-        }
-    } else {
-        /* We're supposed to do a live capture; did the user also specify
-           a capture file to be read? */
-        if (commandline_info.start_capture && !cf_name.isEmpty()) {
-            /* Yes - that's bogus. */
-            cmdarg_err("You can't specify both a live capture and a capture file to be read.");
-            exit(1);
-        }
-
-        /* No - was the ring buffer option specified and, if so, does it make
-           sense? */
-        if (global_capture_opts.multi_files_on) {
-            /* Ring buffer works only under certain conditions:
-             a) ring buffer does not work with temporary files;
-             b) real_time_mode and multi_files_on are mutually exclusive -
-             real_time_mode takes precedence;
-             c) it makes no sense to enable the ring buffer if the maximum
-             file size is set to "infinite". */
-            if (global_capture_opts.save_file == NULL) {
-                cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
-                global_capture_opts.multi_files_on = FALSE;
-            }
-            if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
-                cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
-                /* XXX - this must be redesigned as the conditions changed */
-            }
-        }
-    }
-
     if (commandline_info.start_capture || commandline_info.list_link_layer_types) {
         /* We're supposed to do a live capture or get a list of link-layer
            types for a live capture device; if the user didn't specify an