annotate src/libsndfile-1.0.25/regtest/sndfile-regtest.c @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents c7265573341e
children
rev   line source
Chris@0 1 /*
Chris@0 2 ** Copyright (C) 2005-2011 Erik de Castro Lopo
Chris@0 3 **
Chris@0 4 ** This program is free software; you can redistribute it and/or modify
Chris@0 5 ** it under the terms of the GNU General Public License as published by
Chris@0 6 ** the Free Software Foundation; either version 2 of the License, or
Chris@0 7 ** (at your option) any later version.
Chris@0 8 **
Chris@0 9 ** This program is distributed in the hope that it will be useful,
Chris@0 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 ** GNU General Public License for more details.
Chris@0 13 **
Chris@0 14 ** You should have received a copy of the GNU General Public License
Chris@0 15 ** along with this program; if not, write to the Free Software
Chris@0 16 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Chris@0 17 */
Chris@0 18
Chris@0 19 #include "config.h"
Chris@0 20
Chris@0 21 #include <stdio.h>
Chris@0 22 #include <stdlib.h>
Chris@0 23 #include <string.h>
Chris@0 24
Chris@0 25 #include <sndfile.h>
Chris@0 26
Chris@0 27 #if HAVE_SQLITE3
Chris@0 28
Chris@0 29 #include "regtest.h"
Chris@0 30
Chris@0 31 enum
Chris@0 32 { OPT_ADD_FILE = 0x0100,
Chris@0 33 OPT_CREATE_DB = 0x0200,
Chris@0 34 OPT_DEL_ENTRY = 0x0400,
Chris@0 35 OPT_LIST_ALL = 0x0800,
Chris@0 36 OPT_TEST_ALL = 0x1000,
Chris@0 37 OPT_VERBOSE = 0x2000
Chris@0 38 } ;
Chris@0 39
Chris@0 40 static void print_libsndfile_version (void) ;
Chris@0 41
Chris@0 42 int
Chris@0 43 main (int argc, char * argv [])
Chris@0 44 { const char *db_name = "./.sndfile-regtest.db" ;
Chris@0 45 REG_DB *reg_db ;
Chris@0 46 int k, retval ;
Chris@0 47
Chris@0 48 if (argc < 2)
Chris@0 49 { printf ("\nUsage message goes here.\n\n") ;
Chris@0 50 exit (0) ;
Chris@0 51 } ;
Chris@0 52
Chris@0 53 if (argc == 2 && strcmp (argv [1], "--create-db") == 0)
Chris@0 54 return db_create (db_name) ;
Chris@0 55
Chris@0 56 reg_db = db_open (db_name) ;
Chris@0 57
Chris@0 58 if (argc == 2)
Chris@0 59 { if (strcmp (argv [1], "--list-all") == 0)
Chris@0 60 return db_list_all (reg_db) ;
Chris@0 61
Chris@0 62 if (strcmp (argv [1], "--check-all") == 0)
Chris@0 63 { print_libsndfile_version () ;
Chris@0 64 retval = db_check_all (reg_db) ;
Chris@0 65 puts ("\nDone.\n") ;
Chris@0 66 return retval ;
Chris@0 67 } ;
Chris@0 68 } ;
Chris@0 69
Chris@0 70 if (argc == 3 && strcmp (argv [1], "--del-entry") == 0)
Chris@0 71 { db_del_entry (reg_db, argv [2]) ;
Chris@0 72 db_close (reg_db) ;
Chris@0 73 return 0 ;
Chris@0 74 } ;
Chris@0 75
Chris@0 76 if (strcmp (argv [1], "--check-file") == 0)
Chris@0 77 { print_libsndfile_version () ;
Chris@0 78
Chris@0 79 for (k = 2 ; k < argc ; k++)
Chris@0 80 db_check_file (reg_db, argv [k]) ;
Chris@0 81 db_close (reg_db) ;
Chris@0 82 return 0 ;
Chris@0 83 } ;
Chris@0 84
Chris@0 85 if (strcmp (argv [1], "--add-file") == 0)
Chris@0 86 { print_libsndfile_version () ;
Chris@0 87
Chris@0 88 for (k = 2 ; k < argc ; k++)
Chris@0 89 db_add_file (reg_db, argv [k]) ;
Chris@0 90 db_close (reg_db) ;
Chris@0 91 return 0 ;
Chris@0 92 } ;
Chris@0 93
Chris@0 94 printf ("\nError : unhandled command line args :") ;
Chris@0 95 for (k = 1 ; k < argc ; k++)
Chris@0 96 printf (" %s", argv [k]) ;
Chris@0 97 puts ("\n") ;
Chris@0 98
Chris@0 99 return 1 ;
Chris@0 100 } /* main */
Chris@0 101
Chris@0 102 static void
Chris@0 103 print_libsndfile_version (void)
Chris@0 104 { char version [64] ;
Chris@0 105
Chris@0 106 sf_command (NULL, SFC_GET_LIB_VERSION, version, sizeof (version)) ;
Chris@0 107 printf ("\nsndfile-regtest : using %s\n\n", version) ;
Chris@0 108 } /* print_lib_version */
Chris@0 109
Chris@0 110 #else
Chris@0 111
Chris@0 112 int
Chris@0 113 main (void)
Chris@0 114 {
Chris@0 115 puts ("\nThis program was not compiled with libsqlite3 and hence doesn't work.\n") ;
Chris@0 116
Chris@0 117 return 0 ;
Chris@0 118 } /* main */
Chris@0 119
Chris@0 120 #endif
Chris@0 121