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