Chris@0: /* Chris@0: ** Copyright (C) 2005-2011 Erik de Castro Lopo Chris@0: ** Chris@0: ** This program is free software; you can redistribute it and/or modify Chris@0: ** it under the terms of the GNU General Public License as published by Chris@0: ** the Free Software Foundation; either version 2 of the License, or Chris@0: ** (at your option) any later version. Chris@0: ** Chris@0: ** This program is distributed in the hope that it will be useful, Chris@0: ** but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: ** GNU General Public License for more details. Chris@0: ** Chris@0: ** You should have received a copy of the GNU General Public License Chris@0: ** along with this program; if not, write to the Free Software Chris@0: ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Chris@0: */ Chris@0: Chris@0: #include "config.h" Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: Chris@0: #include Chris@0: Chris@0: #if HAVE_SQLITE3 Chris@0: Chris@0: #include "regtest.h" Chris@0: Chris@0: enum Chris@0: { OPT_ADD_FILE = 0x0100, Chris@0: OPT_CREATE_DB = 0x0200, Chris@0: OPT_DEL_ENTRY = 0x0400, Chris@0: OPT_LIST_ALL = 0x0800, Chris@0: OPT_TEST_ALL = 0x1000, Chris@0: OPT_VERBOSE = 0x2000 Chris@0: } ; Chris@0: Chris@0: static void print_libsndfile_version (void) ; Chris@0: Chris@0: int Chris@0: main (int argc, char * argv []) Chris@0: { const char *db_name = "./.sndfile-regtest.db" ; Chris@0: REG_DB *reg_db ; Chris@0: int k, retval ; Chris@0: Chris@0: if (argc < 2) Chris@0: { printf ("\nUsage message goes here.\n\n") ; Chris@0: exit (0) ; Chris@0: } ; Chris@0: Chris@0: if (argc == 2 && strcmp (argv [1], "--create-db") == 0) Chris@0: return db_create (db_name) ; Chris@0: Chris@0: reg_db = db_open (db_name) ; Chris@0: Chris@0: if (argc == 2) Chris@0: { if (strcmp (argv [1], "--list-all") == 0) Chris@0: return db_list_all (reg_db) ; Chris@0: Chris@0: if (strcmp (argv [1], "--check-all") == 0) Chris@0: { print_libsndfile_version () ; Chris@0: retval = db_check_all (reg_db) ; Chris@0: puts ("\nDone.\n") ; Chris@0: return retval ; Chris@0: } ; Chris@0: } ; Chris@0: Chris@0: if (argc == 3 && strcmp (argv [1], "--del-entry") == 0) Chris@0: { db_del_entry (reg_db, argv [2]) ; Chris@0: db_close (reg_db) ; Chris@0: return 0 ; Chris@0: } ; Chris@0: Chris@0: if (strcmp (argv [1], "--check-file") == 0) Chris@0: { print_libsndfile_version () ; Chris@0: Chris@0: for (k = 2 ; k < argc ; k++) Chris@0: db_check_file (reg_db, argv [k]) ; Chris@0: db_close (reg_db) ; Chris@0: return 0 ; Chris@0: } ; Chris@0: Chris@0: if (strcmp (argv [1], "--add-file") == 0) Chris@0: { print_libsndfile_version () ; Chris@0: Chris@0: for (k = 2 ; k < argc ; k++) Chris@0: db_add_file (reg_db, argv [k]) ; Chris@0: db_close (reg_db) ; Chris@0: return 0 ; Chris@0: } ; Chris@0: Chris@0: printf ("\nError : unhandled command line args :") ; Chris@0: for (k = 1 ; k < argc ; k++) Chris@0: printf (" %s", argv [k]) ; Chris@0: puts ("\n") ; Chris@0: Chris@0: return 1 ; Chris@0: } /* main */ Chris@0: Chris@0: static void Chris@0: print_libsndfile_version (void) Chris@0: { char version [64] ; Chris@0: Chris@0: sf_command (NULL, SFC_GET_LIB_VERSION, version, sizeof (version)) ; Chris@0: printf ("\nsndfile-regtest : using %s\n\n", version) ; Chris@0: } /* print_lib_version */ Chris@0: Chris@0: #else Chris@0: Chris@0: int Chris@0: main (void) Chris@0: { Chris@0: puts ("\nThis program was not compiled with libsqlite3 and hence doesn't work.\n") ; Chris@0: Chris@0: return 0 ; Chris@0: } /* main */ Chris@0: Chris@0: #endif Chris@0: