diff options
-rw-r--r-- | capture_loop.c | 2 | ||||
-rw-r--r-- | tethereal.c | 19 | ||||
-rw-r--r-- | wiretap/file_access.c | 4 |
3 files changed, 12 insertions, 13 deletions
diff --git a/capture_loop.c b/capture_loop.c index 3ee9f05c5e..e2302a2d6a 100644 --- a/capture_loop.c +++ b/capture_loop.c @@ -1015,7 +1015,7 @@ 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) { + 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 */ diff --git a/tethereal.c b/tethereal.c index c3d892763c..ed447a40e6 100644 --- a/tethereal.c +++ b/tethereal.c @@ -598,7 +598,7 @@ output_file_description(const char *fname) char *save_file_string; /* Get a string that describes what we're writing to */ - if (*fname == '\0') { + if (strcmp(fname, "-") == 0) { /* We're writing to the standard output */ save_file_string = g_strdup("standard output"); } else { @@ -1039,6 +1039,11 @@ main(int argc, char *argv[]) } } + /* If we're not writing to a file and "-q" wasn't specified + we should print packet information */ + if (save_file == NULL && !quiet) + print_packet_info = TRUE; + /* See if we're writing a capture file and the file is a pipe */ #ifdef HAVE_LIBPCAP ld.output_to_pipe = FALSE; @@ -1053,11 +1058,9 @@ main(int argc, char *argv[]) output and have either of them be useful. */ if (print_packet_info) { cmdarg_err("You can't write both raw packet data and dissected packets" - " to the standard error."); + " to the standard output."); exit(1); } - g_free(save_file); - save_file = g_strdup(""); #ifdef HAVE_LIBPCAP /* XXX - should we check whether it's a pipe? It's arguably silly to do "-w - >output_file" rather than "-w output_file", @@ -1068,6 +1071,7 @@ main(int argc, char *argv[]) } #ifdef HAVE_LIBPCAP else { + /* not a capture file, test for a FIFO (aka named pipe) */ err = test_for_fifo(save_file); switch (err) { @@ -1087,11 +1091,6 @@ main(int argc, char *argv[]) } } #endif - } else { - /* We're not writing to a file, so we should print packet information - unless "-q" was specified. */ - if (!quiet) - print_packet_info = TRUE; } #ifndef HAVE_LIBPCAP @@ -1161,7 +1160,7 @@ main(int argc, char *argv[]) "the capture isn't being saved to a file."); exit(1); } - if (strcmp(save_file, "") == 0) { + if (strcmp(save_file, "-") == 0) { cmdarg_err("Multiple capture files requested, but " "the capture is being written to the standard output."); exit(1); diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 90e4fe437e..09b810f7d9 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -603,8 +603,8 @@ wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap, if (wdh == NULL) return NULL; /* couldn't allocate it */ - /* Empty filename means stdout */ - if (*filename == '\0') { + /* "-" means stdout */ + if (strcmp(filename, "-") == 0) { if(compressed) { g_free(wdh); return NULL; /* compress won't work on stdout */ |