Support -w even if we're not built with pcap.

You can, for example, do

	tshark -r file1 -Y filter -w file2

to read a file, apply a read filter, and write the packets that match
the filter to another file even if you can't capture traffic.

Change-Id: Ifd5e1d5c0e745edef5e98ec4babc720bfbcee6d9
Reviewed-on: https://code.wireshark.org/review/2627
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-06-24 13:48:40 -07:00
parent deda668e4c
commit 0fb9369a5e
1 changed files with 16 additions and 3 deletions

View File

@ -188,6 +188,11 @@ static void capture_cleanup(int);
static void report_counts_siginfo(int);
#endif /* SIGINFO */
#endif /* _WIN32 */
#else /* HAVE_LIBPCAP */
static char *output_file_name;
#endif /* HAVE_LIBPCAP */
static int load_cap_file(capture_file *, char *, int, gboolean, int, gint64);
@ -1322,8 +1327,16 @@ main(int argc, char *argv[])
return status;
}
#else
capture_option_specified = TRUE;
arg_error = TRUE;
if (opt == 'w') {
/*
* Output file name, if we're reading a file and writing to another
* file.
*/
output_file_name = optarg;
} else {
capture_option_specified = TRUE;
arg_error = TRUE;
}
#endif
break;
case 'C':
@ -2077,7 +2090,7 @@ main(int argc, char *argv[])
global_capture_opts.has_autostop_packets ? global_capture_opts.autostop_packets : 0,
global_capture_opts.has_autostop_filesize ? global_capture_opts.autostop_filesize : 0);
#else
err = load_cap_file(&cfile, NULL, out_file_type, out_file_name_res, 0, 0);
err = load_cap_file(&cfile, output_file_name, out_file_type, out_file_name_res, 0, 0);
#endif
}
CATCH(OutOfMemoryError) {