aboutsummaryrefslogtreecommitdiffstats
path: root/reordercap.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 /reordercap.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 'reordercap.c')
-rw-r--r--reordercap.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/reordercap.c b/reordercap.c
index 9939f26987..efbbfdaf36 100644
--- a/reordercap.c
+++ b/reordercap.c
@@ -204,7 +204,7 @@ DIAG_OFF(cast-qual)
DIAG_ON(cast-qual)
int file_count;
char *infile;
- char *outfile;
+ const char *outfile;
/* Get the compile-time version information string */
comp_info_str = get_compiled_version_info(NULL, get_reordercap_compiled_info);
@@ -275,8 +275,14 @@ DIAG_ON(cast-qual)
nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
/* Open outfile (same filetype/encap as input file) */
- pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
- 65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+ if (strcmp(outfile, "-") == 0) {
+ pdh = wtap_dump_fdopen_ng(1, wtap_file_type_subtype(wth), wtap_file_encap(wth),
+ 65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+ outfile = "standard output";
+ } else {
+ pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
+ 65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
+ }
g_free(idb_inf);
idb_inf = NULL;