From 992a98c5c480d0d7af7ba6de8e2d42f4665806ff Mon Sep 17 00:00:00 2001 From: Daniel Eneyev Date: Thu, 13 Nov 2014 12:45:53 +0300 Subject: [PATCH] If output name is dash - write to stdout --- src/encmain.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index 64559158..8dca6685 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -216,8 +216,15 @@ int main(int argc, char *argv[]) goto exit_failure; } - // Open output file and check that it was opened correctly - output = fopen(cfg->output, "wb"); + // 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"); + } + + // Check that output was opened correctly if (output == NULL) { fprintf(stderr, "Could not open output file, shutting down!\n"); goto exit_failure;