aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file_access.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 /wiretap/file_access.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 'wiretap/file_access.c')
-rw-r--r--wiretap/file_access.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 15e5940ac7..c667118408 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -2217,34 +2217,16 @@ wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
if (wdh == NULL)
return NULL;
- /* "-" means stdout */
- if (strcmp(filename, "-") == 0) {
- if (compressed) {
- *err = EINVAL; /* XXX - return a Wiretap error code for this */
- g_free(wdh);
- return NULL; /* compress won't work on stdout */
- }
-#ifdef _WIN32
- if (_setmode(fileno(stdout), O_BINARY) == -1) {
- /* "Should not happen" */
- *err = errno;
- g_free(wdh);
- return NULL; /* couldn't put standard output in binary mode */
- }
-#endif
- wdh->fh = stdout;
- } else {
- /* In case "fopen()" fails but doesn't set "errno", set "errno"
- to a generic "the open failed" error. */
- errno = WTAP_ERR_CANT_OPEN;
- fh = wtap_dump_file_open(wdh, filename);
- if (fh == NULL) {
- *err = errno;
- g_free(wdh);
- return NULL; /* can't create file */
- }
- wdh->fh = fh;
+ /* In case "fopen()" fails but doesn't set "errno", set "errno"
+ to a generic "the open failed" error. */
+ errno = WTAP_ERR_CANT_OPEN;
+ fh = wtap_dump_file_open(wdh, filename);
+ if (fh == NULL) {
+ *err = errno;
+ g_free(wdh);
+ return NULL; /* can't create file */
}
+ wdh->fh = fh;
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) {
/* Get rid of the file we created; we couldn't finish