annotate src/libsndfile-1.0.27/regtest/sndfile-regtest.c @ 84:08ae793730bd

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