aboutsummaryrefslogtreecommitdiffstats
path: root/capture_loop.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2006-01-04 02:50:56 +0000
committerGuy Harris <guy@alum.mit.edu>2006-01-04 02:50:56 +0000
commitd0a1b97ee711e63257194f1e38efe73662e8dd60 (patch)
tree2aece69289389f15cbcbadf33aea4294fb846fb3 /capture_loop.c
parent4f7175aa8bc2596e7aef87aa9902c88fa8b4f2be (diff)
downloadwireshark-d0a1b97ee711e63257194f1e38efe73662e8dd60.tar.gz
wireshark-d0a1b97ee711e63257194f1e38efe73662e8dd60.tar.bz2
wireshark-d0a1b97ee711e63257194f1e38efe73662e8dd60.zip
Handle a null-string file name in "capture_loop_open_output()" - that's
what indicates that we're supposed to write to the standard output (Tethereal turns "-" into ""). svn path=/trunk/; revision=16941
Diffstat (limited to 'capture_loop.c')
-rw-r--r--capture_loop.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/capture_loop.c b/capture_loop.c
index b22593a756..3ee9f05c5e 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -1015,20 +1015,33 @@ 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 (capture_opts->multi_files_on) {
- /* ringbuffer is enabled */
- *save_file_fd = ringbuf_init(capfile_name,
- (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0);
-
- /* we need the ringbuf name */
- if(*save_file_fd != -1) {
- g_free(capfile_name);
- capfile_name = g_strdup(ringbuf_current_filename());
+ if (strcmp(capfile_name, "") == 0) {
+ /* Write to the standard output. */
+ if (capture_opts->multi_files_on) {
+ /* ringbuffer is enabled; that doesn't work with standard output */
+ g_snprintf(errmsg, errmsg_len,
+ "Ring buffer requested, but capture is being written to the standard error.");
+ g_free(capfile_name);
+ return FALSE;
+ } else {
+ *save_file_fd = 1;
}
} else {
- /* Try to open/create the specified file for use as a capture buffer. */
- *save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
- 0600);
+ if (capture_opts->multi_files_on) {
+ /* ringbuffer is enabled */
+ *save_file_fd = ringbuf_init(capfile_name,
+ (capture_opts->has_ring_num_files) ? capture_opts->ring_num_files : 0);
+
+ /* we need the ringbuf name */
+ if(*save_file_fd != -1) {
+ g_free(capfile_name);
+ capfile_name = g_strdup(ringbuf_current_filename());
+ }
+ } else {
+ /* Try to open/create the specified file for use as a capture buffer. */
+ *save_file_fd = open(capfile_name, O_RDWR|O_BINARY|O_TRUNC|O_CREAT,
+ 0600);
+ }
}
is_tempfile = FALSE;
} else {