code cleanup: use "-" for all places, where stdin/stdout is meant

tethereal internally converted the stdout capture filename "-" into "" which doesn't make any real sense and only complicated things.

To make things even more confusing, wiretap expected "" for dump output and "-" for offline reading ...

svn path=/trunk/; revision=16962
This commit is contained in:
Ulf Lamping 2006-01-06 01:06:46 +00:00
parent 6919c9c80f
commit 161d4d7efd
3 changed files with 12 additions and 13 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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 */