aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/capture_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-02-24 03:33:05 +0000
committerGuy Harris <guy@alum.mit.edu>2002-02-24 03:33:05 +0000
commit8bd63530ed159d50e5375f1268b047d5e519c73b (patch)
treeaec410fc717b83b244d5a5272f37e65cec64e457 /gtk/capture_dlg.c
parentf12ef91219fb2aa5f4e5638f73fc30899e9463e2 (diff)
"autostop_filesize" and "autostop_duration" don't need to be in the
"capture_file" structure - they're a property of an in-progress capture, not a property of an open capture file. Make them just variables. The maximum number of packets to be captured should be a variable separate from the "count" field in the "capture_file" structure - the latter is a count of the packets in the capture file in question. Have Boolean variables indicating whether a maximum packet count, maximum capture file size, and maximum capture duration were specified. If an option isn't set, and we're doing an "update list of packets in real time" capture, don't pass the option to the child process with a command-line argument. Don't create "stop when the capture file reaches this size" or "stop when the capture's run for this long" conditions if a maximum capture file size or a maximum capture duration, respectively, haven't been specified. Don't test or free a condition if it wasn't created. Don't allow a 0 argument to the "-c" flag - the absence of a "-c" flag is the way you specify "no limit on the number of packets". Initialize the check boxes and spin buttons for the "maximum packets to capture", "maximum capture size", and "maximum capture duration" options to the values they had in the last capture. If an option wasn't specified, don't read its value from the dialog box and set the variable. svn path=/trunk/; revision=4795
Diffstat (limited to 'gtk/capture_dlg.c')
-rw-r--r--gtk/capture_dlg.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 6ee99b7bfe..e0ae080a1a 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
- * $Id: capture_dlg.c,v 1.59 2002/02/22 11:41:22 guy Exp $
+ * $Id: capture_dlg.c,v 1.60 2002/02/24 03:33:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -387,13 +387,13 @@ capture_prep_cb(GtkWidget *w, gpointer d)
gtk_widget_show(count_hb);
count_cb = gtk_check_button_new_with_label("Stop capture after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(count_cb), FALSE);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(count_cb), has_autostop_count);
gtk_signal_connect(GTK_OBJECT(count_cb), "toggled",
GTK_SIGNAL_FUNC(capture_prep_adjust_sensitivity), GTK_OBJECT(cap_open_w));
gtk_box_pack_start(GTK_BOX(count_hb), count_cb, FALSE, FALSE, 0);
gtk_widget_show(count_cb);
- count_adj = (GtkAdjustment *) gtk_adjustment_new(1,
+ count_adj = (GtkAdjustment *) gtk_adjustment_new(autostop_count,
1, INT_MAX, 1.0, 10.0, 0.0);
count_sb = gtk_spin_button_new (count_adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (count_sb), TRUE);
@@ -412,13 +412,14 @@ capture_prep_cb(GtkWidget *w, gpointer d)
gtk_widget_show(filesize_hb);
filesize_cb = gtk_check_button_new_with_label("");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(filesize_cb), FALSE);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(filesize_cb),
+ has_autostop_filesize);
gtk_signal_connect(GTK_OBJECT(filesize_cb), "toggled",
GTK_SIGNAL_FUNC(capture_prep_adjust_sensitivity), GTK_OBJECT(cap_open_w));
gtk_box_pack_start(GTK_BOX(filesize_hb), filesize_cb, FALSE, FALSE, 0);
gtk_widget_show(filesize_cb);
- filesize_adj = (GtkAdjustment *) gtk_adjustment_new(1,
+ filesize_adj = (GtkAdjustment *) gtk_adjustment_new(autostop_filesize,
1, INT_MAX, 1.0, 10.0, 0.0);
filesize_sb = gtk_spin_button_new (filesize_adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (filesize_sb), TRUE);
@@ -437,13 +438,14 @@ capture_prep_cb(GtkWidget *w, gpointer d)
gtk_widget_show(duration_hb);
duration_cb = gtk_check_button_new_with_label("Stop capture after");
- gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(duration_cb), FALSE);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(duration_cb),
+ has_autostop_duration);
gtk_signal_connect(GTK_OBJECT(duration_cb), "toggled",
GTK_SIGNAL_FUNC(capture_prep_adjust_sensitivity), GTK_OBJECT(cap_open_w));
gtk_box_pack_start(GTK_BOX(duration_hb), duration_cb, FALSE, FALSE, 0);
gtk_widget_show(duration_cb);
- duration_adj = (GtkAdjustment *) gtk_adjustment_new(1,
+ duration_adj = (GtkAdjustment *) gtk_adjustment_new(autostop_duration,
1, INT_MAX, 1.0, 10.0, 0.0);
duration_sb = gtk_spin_button_new (duration_adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (duration_sb), TRUE);
@@ -764,22 +766,17 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
save_file = NULL;
}
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(count_cb)))
- cfile.count = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(count_sb));
- else
- cfile.count = 0; /* no limit */
+ has_autostop_count = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(count_cb));
+ if (has_autostop_count)
+ autostop_count = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(count_sb));
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filesize_cb))) {
- cfile.autostop_filesize =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(filesize_sb));
- } else
- cfile.autostop_filesize = 0; /* no limit */
+ has_autostop_filesize = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filesize_cb));
+ if (has_autostop_filesize)
+ autostop_filesize = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(filesize_sb));
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(duration_cb))) {
- cfile.autostop_duration =
- gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(duration_sb));
- } else
- cfile.autostop_duration = 0; /* no limit */
+ has_autostop_duration = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(duration_cb));
+ if (has_autostop_duration)
+ autostop_duration = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(duration_sb));
sync_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sync_cb));
@@ -801,7 +798,7 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"You must specify a save file if you want to use the ring buffer.");
return;
- } else if (cfile.autostop_filesize == 0) {
+ } else if (!has_autostop_filesize || autostop_filesize == 0) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"You must specify a file size at which to rotate the capture files\n"
"if you want to use the ring buffer.");