aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-03-28 15:31:13 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-03-28 15:31:13 +0000
commit9d6ac60cefff17895674beaf30447b7a2c9285fc (patch)
treeafad86f42c3922fe5312deb0752f39c15db559ed
parentdaa67c79ba2b65c3893ffdf9022c5cf64025c4e7 (diff)
downloadwireshark-9d6ac60cefff17895674beaf30447b7a2c9285fc.tar.gz
wireshark-9d6ac60cefff17895674beaf30447b7a2c9285fc.tar.bz2
wireshark-9d6ac60cefff17895674beaf30447b7a2c9285fc.zip
remove capture_child flag from capture_opts as it's no longer required
svn path=/trunk/; revision=13954
-rw-r--r--capture.c16
-rw-r--r--capture.h14
-rw-r--r--capture_loop.c45
-rw-r--r--capture_opts.c2
-rw-r--r--capture_sync.c3
-rw-r--r--gtk/capture_info_dlg.c2
-rw-r--r--gtk/main.c13
7 files changed, 33 insertions, 62 deletions
diff --git a/capture.c b/capture.c
index 703c674764..86b7cd1ba3 100644
--- 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,18 +326,20 @@ 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)
{
/* kill the capture child, if we have one */
diff --git a/capture.h b/capture.h
index 1fb9e0d697..2acffc4738 100644
--- 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);
diff --git a/capture_loop.c b/capture_loop.c
index c47589a2f6..0be43ae0f1 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -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);
- }
}
diff --git a/capture_opts.c b/capture_opts.c
index 00f3d1a0bf..ddcea18f5c 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -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);
diff --git a/capture_sync.c b/capture_sync.c
index 25f3c8ddcd..4e2ba36d7b 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -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
diff --git a/gtk/capture_info_dlg.c b/gtk/capture_info_dlg.c
index bbc6661333..4e54210d3d 100644
--- a/gtk/capture_info_dlg.c
+++ b/gtk/capture_info_dlg.c
@@ -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);
}
diff --git a/gtk/main.c b/gtk/main.c
index a269d867d0..f4fd53ae77 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -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