aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-11-09 17:21:46 -0800
committerGuy Harris <guy@alum.mit.edu>2015-11-10 01:23:22 +0000
commit6c3c6de340ff2016b06c0081c6c822c723d40f80 (patch)
tree8948698b6ec024cc6fa1382c14bdcba0396a602a /tshark.c
parent411112a1ff172a6ef7530c06a8887de1973a1205 (diff)
Treat "-" as "standard input" in the CLI, not in libwiretap.
That's a UI convention, and the GUI shouldn't honor that convention - a user might get confused if they try to save to "-" and end up with nothing (and with a ton of crap in a log file if programs launched from the GUI end up with their standard output and error logged). While we're at it, make randcap report write and close errors. Change-Id: I9c450f0ca0320ce4c36d13d209b56d72edb43012 Reviewed-on: https://code.wireshark.org/review/11666 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tshark.c b/tshark.c
index 8d3d3052bf..a43417b63e 100644
--- a/tshark.c
+++ b/tshark.c
@@ -3199,13 +3199,25 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
if (linktype != WTAP_ENCAP_PER_PACKET &&
out_file_type == WTAP_FILE_TYPE_SUBTYPE_PCAP) {
tshark_debug("tshark: writing PCAP format to %s", save_file);
- pdh = wtap_dump_open(save_file, out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, &err);
+ if (strcmp(save_file, "-")) {
+ /* Write to the standard output. */
+ pdh = wtap_dump_fdopen(1, out_file_type, linktype,
+ snapshot_length, FALSE /* compressed */, &err);
+ } else {
+ pdh = wtap_dump_open(save_file, out_file_type, linktype,
+ snapshot_length, FALSE /* compressed */, &err);
+ }
}
else {
tshark_debug("tshark: writing format type %d, to %s", out_file_type, save_file);
- pdh = wtap_dump_open_ng(save_file, out_file_type, linktype,
- snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, nrb_hdr, &err);
+ if (strcmp(save_file, "-")) {
+ /* Write to the standard output. */
+ pdh = wtap_dump_fdopen_ng(1, out_file_type, linktype,
+ snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, nrb_hdr, &err);
+ } else {
+ pdh = wtap_dump_open_ng(save_file, out_file_type, linktype,
+ snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, nrb_hdr, &err);
+ }
}
g_free(idb_inf);