From c1a09a5065aa382510a0e21c3dacdd90d7d49683 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Mon, 23 Jun 2014 17:07:22 +1000 Subject: [PATCH] programs/*.c : Clean up and normailize printing of version strings. Suggested-by: Jan Stary --- examples/list_formats.c | 11 ++--------- programs/sndfile-cmp.c | 13 ++----------- programs/sndfile-info.c | 16 +++------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/examples/list_formats.c b/examples/list_formats.c index 6d462f07..348c81b0 100644 --- a/examples/list_formats.c +++ b/examples/list_formats.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001-2011 Erik de Castro Lopo +** Copyright (C) 2001-2014 Erik de Castro Lopo ** ** All rights reserved. ** @@ -41,17 +41,10 @@ int main (void) { SF_FORMAT_INFO info ; SF_INFO sfinfo ; - char buffer [128] ; int format, major_count, subtype_count, m, s ; memset (&sfinfo, 0, sizeof (sfinfo)) ; - buffer [0] = 0 ; - sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; - if (strlen (buffer) < 1) - { printf ("Line %d: could not retrieve lib version.\n", __LINE__) ; - exit (1) ; - } ; - printf ("Version : %s\n\n", buffer) ; + printf ("Version : %s\n\n", sf_version_string ()) ; sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ; diff --git a/programs/sndfile-cmp.c b/programs/sndfile-cmp.c index 121d25a6..9175ddf1 100644 --- a/programs/sndfile-cmp.c +++ b/programs/sndfile-cmp.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2008-2012 Erik de Castro Lopo +** Copyright (C) 2008-2014 Erik de Castro Lopo ** Copyright (C) 2008 Conrad Parker ** ** All rights reserved. @@ -124,21 +124,12 @@ out : return retval ; } /* compare */ -static void -print_version (void) -{ char buffer [256] ; - - sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; - printf ("\nVersion : %s\n\n", buffer) ; -} /* print_version */ - static void usage_exit (void) { - print_version () ; - printf ("Usage : %s \n", progname) ; printf (" Compare the PCM data of two sound files.\n\n") ; + printf ("Using %s.\n\n", sf_version_string ()) ; exit (0) ; } /* usage_exit */ diff --git a/programs/sndfile-info.c b/programs/sndfile-info.c index 06982fd2..db5362e1 100644 --- a/programs/sndfile-info.c +++ b/programs/sndfile-info.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2013 Erik de Castro Lopo +** Copyright (C) 1999-2014 Erik de Castro Lopo ** ** All rights reserved. ** @@ -47,7 +47,6 @@ #include #endif -static void print_version (void) ; static void usage_exit (const char *progname) ; static void info_dump (const char *filename) ; @@ -63,8 +62,6 @@ int main (int argc, char *argv []) { int k ; - print_version () ; - if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0) { usage_exit (program_name (argv [0])) ; return 1 ; @@ -117,15 +114,6 @@ main (int argc, char *argv []) static double data [BUFFER_LEN] ; -static void -print_version (void) -{ char buffer [256] ; - - sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ; - printf ("\nVersion : %s\n\n", buffer) ; -} /* print_version */ - - static void usage_exit (const char *progname) { printf ("Usage :\n %s ...\n", progname) ; @@ -138,6 +126,8 @@ usage_exit (const char *progname) printf (" Prints out the channel map for the given file.\n\n") ; printf (" %s --cart \n", progname) ; printf (" Prints out the cart chunk WAV info for the given file.\n\n") ; + + printf ("Using %s.\n\n", sf_version_string ()) ; #if (defined (_WIN32) || defined (WIN32)) printf ("This is a Unix style command line application which\n" "should be run in a MSDOS box or Command Shell window.\n\n") ;