If output name is dash - write to stdout

This commit is contained in:
Daniel Eneyev 2014-11-13 12:45:53 +03:00
parent c46b75a0ca
commit 992a98c5c4

View file

@ -216,8 +216,15 @@ int main(int argc, char *argv[])
goto exit_failure; goto exit_failure;
} }
// Open output file and check that it was opened correctly // Check if the output file name is a dash, this means stdout
if (!strcmp(cfg->output, "-")) {
output = stdout;
} else {
// Otherwise we try to open the output file
output = fopen(cfg->output, "wb"); output = fopen(cfg->output, "wb");
}
// Check that output was opened correctly
if (output == NULL) { if (output == NULL) {
fprintf(stderr, "Could not open output file, shutting down!\n"); fprintf(stderr, "Could not open output file, shutting down!\n");
goto exit_failure; goto exit_failure;