summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2014-06-23 17:07:22 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2014-06-23 17:17:51 +1000
commitc1a09a5065aa382510a0e21c3dacdd90d7d49683 (patch)
tree50f5e6a91f980a198725bda9b2fe15ec6fb2f5ee
parentff8b1ae3b59b32aed8983ee9dc697da9d0d5f0b7 (diff)
programs/*.c : Clean up and normailize printing of version strings.
Suggested-by: Jan Stary <hans@stare.cz>
-rw-r--r--examples/list_formats.c11
-rw-r--r--programs/sndfile-cmp.c13
-rw-r--r--programs/sndfile-info.c16
3 files changed, 7 insertions, 33 deletions
diff --git a/examples/list_formats.c b/examples/list_formats.c
index 6d462f0..348c81b 100644
--- a/examples/list_formats.c
+++ b/examples/list_formats.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2001-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** 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 121d25a..9175ddf 100644
--- a/programs/sndfile-cmp.c
+++ b/programs/sndfile-cmp.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2008-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2008 Conrad Parker <conrad@metadecks.org>
**
** All rights reserved.
@@ -125,20 +125,11 @@ out :
} /* 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 <filename> <filename>\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 06982fd..db5362e 100644
--- a/programs/sndfile-info.c
+++ b/programs/sndfile-info.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 1999-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** All rights reserved.
**
@@ -47,7 +47,6 @@
#include <windows.h>
#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 ;
@@ -118,15 +115,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 <file> ...\n", progname) ;
printf (" Prints out information about one or more sound files.\n\n") ;
@@ -138,6 +126,8 @@ usage_exit (const char *progname)
printf (" Prints out the channel map for the given file.\n\n") ;
printf (" %s --cart <file>\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") ;