From feb8a4d2e3453feea53b7b1ff024e82e7403b422 Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Thu, 5 May 2022 13:28:50 +0300 Subject: [PATCH] [cli] To print version info to stdout when everything is ok. --- src/cli.c | 4 ++-- src/cli.h | 2 +- src/encmain.c | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cli.c b/src/cli.c index 5e8d9908..b4f920bc 100644 --- a/src/cli.c +++ b/src/cli.c @@ -391,9 +391,9 @@ void print_usage(void) } -void print_version(void) +void print_version(bool to_stderr) { - fprintf(stdout, + fprintf(to_stderr ? stderr : stdout, "uvg266 " VERSION_STRING " [" UVG_COMPILER_STRING "] " UVG_COMPILE_DATE "\n"); } diff --git a/src/cli.h b/src/cli.h index 26859213..73912bd1 100644 --- a/src/cli.h +++ b/src/cli.h @@ -65,7 +65,7 @@ cmdline_opts_t* cmdline_opts_parse(const uvg_api *api, int argc, char *argv[]); void cmdline_opts_free(const uvg_api *api, cmdline_opts_t *opts); void print_usage(void); -void print_version(void); +void print_version(bool); void print_help(void); void print_frame_info(const uvg_frame_info *const info, const double frame_psnr[3], diff --git a/src/encmain.c b/src/encmain.c index 1b19f5fb..2ca3bdc3 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -479,23 +479,24 @@ int main(int argc, char *argv[]) const uvg_api * const api = uvg_api_get(8); - print_version(); opts = cmdline_opts_parse(api, argc, argv); // If problem with command line options, print banner and shutdown. if (!opts) { + print_version(false); print_usage(); goto exit_failure; } if (opts->version) { - print_version(); + print_version(false); goto done; } if (opts->help) { print_help(); goto done; } + print_version(true); input = open_input_file(opts->input); if (input == NULL) {