remove capture_child flag from capture_opts as it's no longer required
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 28 Mar 2005 15:31:13 +0000 (15:31 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 28 Mar 2005 15:31:13 +0000 (15:31 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13954 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c
capture.h
capture_loop.c
capture_opts.c
capture_sync.c
gtk/capture_info_dlg.c
gtk/main.c

index 703c67476431452cf451a329b849843b1943154a..86b7cd1ba397d2f96ef0787c497194239be9646f 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -314,8 +314,6 @@ capture_child_stop_signal_handler(int signo _U_)
 int  
 capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats)
 {
-  g_assert(capture_opts->capture_child);
-
 #ifndef _WIN32
   /*
    * Catch SIGUSR1, so that we exit cleanly if the parent process
@@ -328,17 +326,19 @@ capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct
 }
 
 void
-capture_stop(capture_options *capture_opts)
+capture_child_stop(capture_options *capture_opts)
 {
-  /* stop the capture child, if we have one */
-  if (!capture_opts->capture_child) {  
-    sync_pipe_stop(capture_opts);
-  }
-
   /* stop the capture loop */
   capture_loop_stop();
 }
 
+void
+capture_stop(capture_options *capture_opts)
+{
+  /* stop the capture child, if we have one */
+  sync_pipe_stop(capture_opts);
+}
+
 void
 capture_kill_child(capture_options *capture_opts)
 {
index 1fb9e0d69787743dc67a7fb2576d9953b5be53d6..2acffc47383e67f8dab885554b9bd096240b45bf 100644 (file)
--- a/capture.h
+++ b/capture.h
@@ -50,7 +50,6 @@ typedef struct capture_options_tag {
     gboolean promisc_mode;  /**< Capture in promiscuous mode */
     int      linktype;      /**< Data link type to use, or -1 for
                                  "use default" */
-    gboolean capture_child; /**< True if this is the child for "-S" */
     gchar    *save_file;    /**< the capture file name */
 
     /* GUI related */
@@ -118,16 +117,21 @@ extern void capture_input_new_packets(capture_options *capture_opts, int to_read
  */
 extern void capture_input_closed(capture_options *capture_opts);
 
-/** Do the low-level work of a capture (start the capture child).
- *  Returns TRUE if it succeeds, FALSE otherwise. */
-extern int  capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
-
 /** Stop a capture (usually from a menu item). */
 extern void capture_stop(capture_options *capture_opts);
 
 /** Terminate the capture child cleanly when exiting. */
 extern void capture_kill_child(capture_options *capture_opts);
 
+
+
+/** Do the low-level work of a capture (start the capture child).
+ *  Returns TRUE if it succeeds, FALSE otherwise. */
+extern int  capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
+
+/** Stop a capture child (usually from a menu item). */
+extern void capture_child_stop(capture_options *capture_opts);
+
 /** Do the low-level work of a capture.
  *  Returns TRUE if it succeeds, FALSE otherwise. */
 extern int  capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
index c47589a2f65dfc24a95defe10ce5c194382d7471..0be43ae0f1adbd8a767093efc8d3d20bba941fe1 100644 (file)
@@ -601,9 +601,7 @@ static int capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
        mode or fork mode, it shouldn't do any UI stuff until we pop up the
        capture-progress window, and, since we couldn't start the
        capture, we haven't popped it up. */
-    if (!capture_opts->capture_child) {
-      main_window_update();
-    }
+
 
     /* On Win32 OSes, the capture devices are probably available to all
        users; don't warn about permissions problems.
@@ -629,15 +627,6 @@ static int capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
 
     if (ld->cap_pipe_fd == -1) {
 
-      /* If this is a child process that does the capturing in sync
-       * mode or fork mode, it shouldn't do any UI stuff until we pop up the
-       * capture-progress window, and, since we couldn't start the
-       * capture, we haven't popped it up.
-       */
-      if (!capture_opts->capture_child) {
-          main_window_update();
-      }
-
       if (ld->cap_pipe_err == PIPNEXIST) {
        /* Pipe doesn't exist, so output message for interface */
 
@@ -1124,11 +1113,9 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
      in other places as well - and I don't think that works all the
      time in any case, due to libpcap bugs. */
 
-  if (capture_opts->capture_child) {
     /* Well, we should be able to start capturing.
 
-       This is the child process for a sync mode capture, so sync out
-       the capture file, so the header makes it to the file system,
+       Sync out the capture file, so the header makes it to the file system,
        and send a "capture started successfully and capture file created"
        message to our parent so that they'll open the capture file and
        update its windows to indicate that we have a live capture in
@@ -1136,7 +1123,6 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
     fflush(wtap_dump_file(ld.wtap_pdh));
     sync_pipe_capstart_to_parent();
     sync_pipe_filename_to_parent(capture_opts->save_file);
-  }
 
   /* initialize capture stop (and alike) conditions */
   init_capture_stop_conditions();
@@ -1198,9 +1184,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
             if (cnd_file_duration) {
               cnd_reset(cnd_file_duration);
             }
-            if (capture_opts->capture_child) {
-                sync_pipe_filename_to_parent(capture_opts->save_file);
-            }
+            sync_pipe_filename_to_parent(capture_opts->save_file);
           } else {
             /* File switch failed: stop here */
             ld.go = FALSE;
@@ -1236,12 +1220,9 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
         /* do sync here */
         fflush(wtap_dump_file(ld.wtap_pdh));
 
-        if (capture_opts->capture_child) {
-         /* This is the child process for a sync mode capture, so send
-            our parent a message saying we've written out "ld.sync_packets"
+         /* Send our parent a message saying we've written out "ld.sync_packets"
             packets to the capture file. */
         sync_pipe_packet_count_to_parent(ld.packets_sync_pipe);
-        }
 
         ld.packets_sync_pipe = 0;
       }
@@ -1269,9 +1250,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
             cnd_reset(cnd_file_duration);
             if(cnd_autostop_size)
               cnd_reset(cnd_autostop_size);
-            if (capture_opts->capture_child) {
-                sync_pipe_filename_to_parent(capture_opts->save_file);
-            }
+            sync_pipe_filename_to_parent(capture_opts->save_file);
           } else {
             /* File switch failed: stop here */
                ld.go = FALSE;
@@ -1350,10 +1329,8 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
        dropped. */
     if (pcap_stats(ld.pcap_h, stats) >= 0) {
       *stats_known = TRUE;
-      if (capture_opts->capture_child) {
-       /* Let the parent process know. */
-        sync_pipe_drops_to_parent(stats->ps_drop);
-      }
+      /* Let the parent process know. */
+      sync_pipe_drops_to_parent(stats->ps_drop);
     } else {
       g_snprintf(errmsg, sizeof(errmsg),
                "Can't get packet-drop statistics: %s",
@@ -1459,15 +1436,9 @@ capture_loop_get_errmsg(char *errmsg, int errmsglen, const char *fname,
 static void
 capture_loop_popup_errmsg(capture_options *capture_opts, const char *errmsg)
 {
-  if (capture_opts->capture_child) {
-    /* This is the child process for a sync mode capture.
-       Send the error message to our parent, so they can display a
+    /* Send the error message to our parent, so they can display a
        dialog box containing it. */
     sync_pipe_errmsg_to_parent(errmsg);
-  } else {
-    /* Display the dialog box ourselves; there's no parent. */
-    simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", errmsg);
-  }
 }
 
 
index 00f3d1a0bf6f1c9d5f5d1773ea73901ab4f98d2a..ddcea18f5c54c009b59d77afb47b0c35a18d5448 100644 (file)
@@ -59,7 +59,6 @@ capture_opts_init(capture_options *capture_opts, void *cfile)
                                                                     infinite, in effect */
   capture_opts->promisc_mode            = TRUE;             /* promiscuous mode is the default */
   capture_opts->linktype                = -1;               /* the default linktype */
-  capture_opts->capture_child           = FALSE;
   capture_opts->save_file               = NULL;
   capture_opts->sync_mode               = TRUE;
   capture_opts->show_info               = TRUE;
@@ -98,7 +97,6 @@ capture_opts_info(capture_options *capture_opts) {
     g_warning("SnapLen         (%u): %u", capture_opts->has_snaplen, capture_opts->snaplen);
     g_warning("Promisc            : %u", capture_opts->promisc_mode);
     g_warning("LinkType           : %d", capture_opts->linktype);
-    g_warning("Child              : %u", capture_opts->capture_child);
     g_warning("SaveFile           : %s", capture_opts->save_file);
     g_warning("SyncMode           : %u", capture_opts->sync_mode);
     g_warning("ShowInfo           : %u", capture_opts->show_info);
index 25f3c8ddcdc64921498ab1365073eea379d9eb8a..4e2ba36d7b2cc8a6aac7afc85a30578efed7f4f3 100644 (file)
@@ -519,9 +519,6 @@ sync_pipe_input_cb(gint source, gpointer user_data)
   int  to_read = 0;
 
 
-  /* we are a capture parent */
-  g_assert(!capture_opts->capture_child);
-
   if ((nread = read(source, buffer, BUFSIZE)) <= 0) {
     /* The child has closed the sync pipe, meaning it's not going to be
        capturing any more packets.  Pick up its exit status, and
index bbc66613339422095345c80593d5123c9c59d81e..4e54210d3daaabecc8084689350ed69ffb9e1a28 100644 (file)
@@ -75,7 +75,7 @@ pct(gint num, gint denom) {
 
 static void
 capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
-  capture_stop(capture_opts);
+  capture_child_stop(capture_opts);
 }
 
 
index a269d867d0109286b78526e584d666f67aeccca3..f4fd53ae770ab2c7247b5cf00006d1c9ab4efdd5 100644 (file)
@@ -1524,6 +1524,7 @@ main(int argc, char *argv[])
   ethereal_tap_list   *tli = NULL;
   gchar               *tap_opt = NULL;
   GtkWidget           *splash_win = NULL;
+  gboolean             capture_child; /* True if this is the child for "-S" */
 
 #define OPTSTRING_INIT "a:b:B:c:f:Hhi:klLm:nN:o:pP:Qr:R:Ss:t:T:w:vy:z:"
 
@@ -1588,8 +1589,8 @@ main(int argc, char *argv[])
   command_name = get_basename(ethereal_path);
   /* Set "capture_child" to indicate whether this is going to be a child
      process for a "-S" capture. */
-  capture_opts->capture_child = (strcmp(command_name, CHILD_NAME) == 0);
-  if (capture_opts->capture_child) {
+  capture_child = (strcmp(command_name, CHILD_NAME) == 0);
+  if (capture_child) {
     strcat(optstring, OPTSTRING_CHILD);
   }
 #endif
@@ -1608,7 +1609,7 @@ main(int argc, char *argv[])
        they're supposed to override saved preferences. */
   if ((argc < 2 || strcmp(argv[1], "-G") != 0)
 #ifdef HAVE_LIBPCAP
-      && !capture_opts->capture_child
+      && !capture_child
 #endif
       ) {
     splash_win = splash_new("Loading Ethereal ...");
@@ -1736,7 +1737,7 @@ main(int argc, char *argv[])
 
      Otherwise, set promiscuous mode from the preferences setting. */
   /* the same applies to other preferences settings as well. */
-  if (capture_opts->capture_child) {
+  if (capture_child) {
     auto_scroll_live             = FALSE;
   } else {
     capture_opts->promisc_mode   = prefs->capture_prom_mode;
@@ -2204,7 +2205,7 @@ main(int argc, char *argv[])
   gtk_rc_parse(rc_file);
 
 #ifdef HAVE_LIBPCAP
-  font_init(capture_opts->capture_child);
+  font_init(capture_child);
 #else
   font_init(FALSE);
 #endif
@@ -2217,7 +2218,7 @@ main(int argc, char *argv[])
   /* Is this a "child" ethereal, which is only supposed to pop up a
      capture box to let us stop the capture, and run a capture
      to a file that our parent will read? */
-  if (capture_opts->capture_child) {
+  if (capture_child) {
     /* This is the child process for a sync mode or fork mode capture,
        so just do the low-level work of a capture - don't create
        a temporary file and fork off *another* child process (so don't