[Aggregator] Allow "-o-" to use standard output

This commit is contained in:
Matteo Cypriani 2011-03-23 16:05:31 +01:00
parent 58795d03d5
commit 05dc912385
1 changed files with 11 additions and 6 deletions

View File

@ -449,12 +449,17 @@ void* monitor_requests()
&serv, &client) ;
/* Open output file */
fd = fopen(cfg_getstr(cfg, "output_file"), "a") ; // We use add mode
if (fd == NULL) // If we failed to open the file,
if (strcmp("-", cfg_getstr(cfg, "output_file")) == 0)
fd = stdout ;
else
{
perror("Cannot open output file") ;
fprintf(stderr, "Redirecting output to standard output.") ;
fd = stdout ; // we fail back to stdout.
fd = fopen(cfg_getstr(cfg, "output_file"), "a") ; // add mode
if (fd == NULL) // If we failed to open the file,
{
perror("Cannot open output file") ;
fprintf(stderr, "Redirecting output to standard output.\n") ;
fd = stdout ; // we fail back to stdout.
}
}
while (run)
@ -1193,7 +1198,7 @@ void print_usage()
"Output options:\n"
"\t-o output_file\t\tAggregated requests will be appended to"
" this file.\n"
" this file ('-' designates the standard output).\n"
"\t-i positionner_ip\tIP address of the localisation server"
" (default: %s).\n"
"\t-p positioner_port\tAggregated requests are transmitted to"