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