diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-02-24 03:33:05 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-02-24 03:33:05 +0000 |
commit | 8bd63530ed159d50e5375f1268b047d5e519c73b (patch) | |
tree | aec410fc717b83b244d5a5272f37e65cec64e457 /gtk/main.c | |
parent | f12ef91219fb2aa5f4e5638f73fc30899e9463e2 (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/main.c')
-rw-r--r-- | gtk/main.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gtk/main.c b/gtk/main.c index 40a1815128..bfeceb4a1e 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1,6 +1,6 @@ /* main.c * - * $Id: main.c,v 1.234 2002/02/24 01:26:45 guy Exp $ + * $Id: main.c,v 1.235 2002/02/24 03:33:05 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1158,9 +1158,11 @@ set_autostop_criterion(const char *autostoparg) return FALSE; } if (strcmp(autostoparg,"duration") == 0) { - cfile.autostop_duration = get_positive_int(p,"autostop duration"); + has_autostop_duration = TRUE; + autostop_duration = get_positive_int(p,"autostop duration"); } else if (strcmp(autostoparg,"filesize") == 0) { - cfile.autostop_filesize = get_positive_int(p,"autostop filesize"); + has_autostop_filesize = TRUE; + autostop_filesize = get_positive_int(p,"autostop filesize"); } else { return FALSE; } @@ -1292,6 +1294,12 @@ main(int argc, char *argv[]) #ifdef HAVE_LIBPCAP has_snaplen = FALSE; snaplen = MIN_PACKET_SIZE; + has_autostop_count = FALSE; + autostop_count = 1; + has_autostop_duration = FALSE; + autostop_duration = 1; + has_autostop_filesize = FALSE; + autostop_filesize = 1; /* If this is a capture child process, it should pay no attention to the "prefs.capture_prom_mode" setting in the preferences file; @@ -1342,8 +1350,6 @@ main(int argc, char *argv[]) cfile.snap = WTAP_MAX_PACKET_SIZE; cfile.count = 0; #ifdef HAVE_LIBPCAP - cfile.autostop_duration = 0; - cfile.autostop_filesize = 0; cfile.ringbuffer_on = FALSE; cfile.ringbuffer_num_files = RINGBUFFER_MIN_NUM_FILES; #endif @@ -1439,7 +1445,13 @@ main(int argc, char *argv[]) break; case 'c': /* Capture xxx packets */ #ifdef HAVE_LIBPCAP - cfile.count = get_positive_int(optarg, "packet count"); + has_autostop_count = TRUE; + autostop_count = get_positive_int(optarg, "packet count"); + if (autostop_count == 0) { + fprintf(stderr, "ethereal: The specified packet count \"%s\" is zero\n", + optarg); + exit(1); + } #else capture_option_specified = TRUE; arg_error = TRUE; @@ -1679,7 +1691,7 @@ main(int argc, char *argv[]) fprintf(stderr, "ethereal: Ring buffer requested, but an \"Update list of packets in real time\" capture is being done.\n"); cfile.ringbuffer_on = FALSE; } - if (cfile.autostop_filesize == 0) { + if (!has_autostop_filesize || autostop_filesize == 0) { fprintf(stderr, "ethereal: Ring buffer requested, but no maximum capture file size was specified.\n"); cfile.ringbuffer_on = FALSE; } |