capfile_name = g_strdup(save_file);
if (capture_opts->multi_files_on) {
/* ringbuffer is enabled */
- cfile.save_file_fd = ringbuf_init(capfile_name,
+ capture_opts->save_file_fd = ringbuf_init(capfile_name,
(capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0);
} else {
/* Try to open/create the specified file for use as a capture buffer. */
- cfile.save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
+ capture_opts->save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
0600);
}
*is_tempfile = FALSE;
} else {
/* Choose a random name for the temporary capture buffer */
- cfile.save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
+ capture_opts->save_file_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
capfile_name = g_strdup(tmpname);
*is_tempfile = TRUE;
}
/* did we fail to open the output file? */
- if (cfile.save_file_fd == -1) {
+ if (capture_opts->save_file_fd == -1) {
if (is_tempfile) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"The temporary file to which the capture would be saved (\"%s\")"
int linktype; /**< Data link type to use, or -1 for
"use default" */
gboolean capture_child; /**< True if this is the child for "-S" */
+ int save_file_fd; /**< File descriptor for saved file */
/* GUI related */
gboolean sync_mode; /**< Fork a child to do the capture,
ld->wtap_pdh = ringbuf_init_wtap_dump_fdopen(WTAP_FILE_PCAP, ld->wtap_linktype,
file_snaplen, &err);
} else {
- ld->wtap_pdh = wtap_dump_fdopen(cfile.save_file_fd, WTAP_FILE_PCAP,
+ ld->wtap_pdh = wtap_dump_fdopen(capture_opts->save_file_fd, WTAP_FILE_PCAP,
ld->wtap_linktype, file_snaplen, &err);
}
}
/* Switch to the next ringbuffer file */
- if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &cfile.save_file_fd, &ld.err)) {
+ if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &capture_opts->save_file_fd, &ld.err)) {
/* File switch succeeded: reset the conditions */
cnd_reset(cnd_autostop_size);
if (cnd_file_duration) {
}
/* Switch to the next ringbuffer file */
- if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &cfile.save_file_fd, &ld.err)) {
+ if (ringbuf_switch_file(&ld.wtap_pdh, &cfile.save_file, &capture_opts->save_file_fd, &ld.err)) {
/* file switch succeeded: reset the conditions */
cnd_reset(cnd_file_duration);
if(cnd_autostop_size)
} else {
/* We can't use the save file, and we have no wtap_dump stream
to close in order to close it, so close the FD directly. */
- close(cfile.save_file_fd);
+ close(capture_opts->save_file_fd);
/* We couldn't even start the capture, so get rid of the capture
file. */
argv = sync_pipe_add_arg(argv, &argc, cfile.save_file);
argv = sync_pipe_add_arg(argv, &argc, "-W");
- sprintf(save_file_fd,"%d",cfile.save_file_fd); /* in lieu of itoa */
+ sprintf(save_file_fd,"%d",capture_opts->save_file_fd); /* in lieu of itoa */
argv = sync_pipe_add_arg(argv, &argc, save_file_fd);
if (capture_opts->has_autostop_packets) {
/* Close the save file FD, as we won't be using it - we'll be opening
it and reading the save file through Wiretap. */
- close(cfile.save_file_fd);
+ close(capture_opts->save_file_fd);
if (fork_child == -1) {
/* We couldn't even create the child process. */
#endif
cf->iface = NULL;
cf->save_file = NULL;
- cf->save_file_fd = -1;
cf->has_snap = FALSE;
cf->snap = WTAP_MAX_PACKET_SIZE;
cf->count = 0;
int snap; /* Maximum captured packet length */
gchar *iface; /* Interface */
gchar *save_file; /* File that user saved capture to */
- int save_file_fd; /* File descriptor for saved file */
wtap *wth; /* Wiretap session */
dfilter_t *rfcode; /* Compiled read filter program */
gchar *dfilter; /* Display filter string */
#ifdef _WIN32
capture_opts->buffer_size = 1;
#endif
+ capture_opts->save_file_fd = -1;
capture_opts->quit_after_cap = FALSE;
capture_opts->has_autostop_packets = FALSE;
* the error flags for the user in the non-libpcap case.
*/
case 'W': /* Write to capture file FD xxx */
- cfile.save_file_fd = atoi(optarg);
+ capture_opts->save_file_fd = atoi(optarg);
break;
#endif
case 'z':
}
if (capture_opts->capture_child) {
- if (cfile.save_file_fd == -1) {
+ if (capture_opts->save_file_fd == -1) {
/* XXX - send this to the standard output as something our parent
should put in an error message box? */
fprintf(stderr, "%s: \"-W\" flag not specified\n", CHILD_NAME);
gboolean write_err;
gboolean dump_ok;
dfilter_t *rfcode = NULL;
+ int save_file_fd;
/* Initialize all data structures used for dissection. */
init_dissection();
goto error;
}
if (capture_opts.ringbuffer_on) {
- cfile.save_file_fd = ringbuf_init(cfile.save_file,
+ save_file_fd = ringbuf_init(cfile.save_file,
capture_opts.ringbuffer_num_files);
- if (cfile.save_file_fd != -1) {
+ if (save_file_fd != -1) {
ld.pdh = ringbuf_init_wtap_dump_fdopen(out_file_type, ld.linktype,
file_snaplen, &err);
} else {
its maximum size. */
if (capture_opts.ringbuffer_on) {
/* Switch to the next ringbuffer file */
- if (ringbuf_switch_file(&ld.pdh, &cfile.save_file, &cfile.save_file_fd, &loop_err)) {
+ if (ringbuf_switch_file(&ld.pdh, &cfile.save_file, &save_file_fd, &loop_err)) {
/* File switch succeeded: reset the condition */
cnd_reset(cnd_stop_capturesize);
if (cnd_ring_timeout) {
loop_data *ldat = (loop_data *) user;
int loop_err;
int err;
+ int save_file_fd;
/* Convert from libpcap to Wiretap format.
If that fails, ignore the packet (wtap_process_pcap_packet has
*/
if (cnd_ring_timeout != NULL && cnd_eval(cnd_ring_timeout)) {
/* time elapsed for this ring file, switch to the next */
- if (ringbuf_switch_file(&ldat->pdh, &cfile.save_file, &cfile.save_file_fd, &loop_err)) {
+ if (ringbuf_switch_file(&ldat->pdh, &cfile.save_file, &save_file_fd, &loop_err)) {
/* File switch succeeded: reset the condition */
cnd_reset(cnd_ring_timeout);
} else {