aboutsummaryrefslogtreecommitdiffstats
path: root/capture_loop.c
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2007-01-01 17:04:38 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2007-01-01 17:04:38 +0000
commit611aff6783ceed3479c4668b2c3d0ee8904b197a (patch)
treeee8dea091d52c02e3b44b52d3931e12e48a550fd /capture_loop.c
parenteb67054b1649b634158542aa57ffab0cd91cb784 (diff)
Fix "dumpcap -w -" to use binmode on stdout if Windows;
(The related tests in suite-capture.sh should now work correctly). (Also: Print error message if attempting to use ring-buffers with a named pipe). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20255 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'capture_loop.c')
-rw-r--r--capture_loop.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/capture_loop.c b/capture_loop.c
index d85de3dca3..d35a00afcb 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -1110,18 +1110,26 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
* case the caller destroys it after we return.
*/
capfile_name = g_strdup(capture_opts->save_file);
- if (strcmp(capfile_name, "-") == 0) {
- /* Write to the standard output. */
+
+ if (capture_opts->output_to_pipe == TRUE) { /* either "-" or named pipe */
if (capture_opts->multi_files_on) {
- /* ringbuffer is enabled; that doesn't work with standard output */
+ /* ringbuffer is enabled; that doesn't work with standard output or a named pipe */
g_snprintf(errmsg, errmsg_len,
- "Ring buffer requested, but capture is being written to the standard output.");
+ "Ring buffer requested, but capture is being written to standard output or to a named pipe.");
g_free(capfile_name);
return FALSE;
- } else {
+ }
+ if (strcmp(capfile_name, "-") == 0) {
+ /* write to stdout */
*save_file_fd = 1;
+#ifdef _WIN32
+ /* set output pipe to binary mode to avoid Windows text-mode processing (eg: for CR/LF) */
+ _setmode(1, O_BINARY);
+#endif
}
- } else {
+ } /* if (...output_to_pipe ... */
+
+ else {
if (capture_opts->multi_files_on) {
/* ringbuffer is enabled */
*save_file_fd = ringbuf_init(capfile_name,