From aceb1f30497619786f1827e4c65992b890a07410 Mon Sep 17 00:00:00 2001 From: Lorry Date: Wed, 18 Jul 2012 20:35:05 +0100 Subject: Tarball conversion --- regtest/Makefile.am | 11 + regtest/Makefile.in | 607 ++++++++++++++++++++++++++++++++++++++++++++++ regtest/checksum.c | 117 +++++++++ regtest/database.c | 495 +++++++++++++++++++++++++++++++++++++ regtest/regtest.h | 38 +++ regtest/sndfile-regtest.c | 121 +++++++++ 6 files changed, 1389 insertions(+) create mode 100644 regtest/Makefile.am create mode 100644 regtest/Makefile.in create mode 100644 regtest/checksum.c create mode 100644 regtest/database.c create mode 100644 regtest/regtest.h create mode 100644 regtest/sndfile-regtest.c (limited to 'regtest') diff --git a/regtest/Makefile.am b/regtest/Makefile.am new file mode 100644 index 0000000..4d1ed4c --- /dev/null +++ b/regtest/Makefile.am @@ -0,0 +1,11 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = sndfile-regtest + +noinst_HEADERS = regtest.h + +INCLUDES = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS) + +sndfile_regtest_SOURCES = sndfile-regtest.c database.c checksum.c +sndfile_regtest_LDADD = $(top_builddir)/src/libsndfile.la $(SQLITE3_LIBS) + diff --git a/regtest/Makefile.in b/regtest/Makefile.in new file mode 100644 index 0000000..9d69251 --- /dev/null +++ b/regtest/Makefile.in @@ -0,0 +1,607 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = sndfile-regtest$(EXEEXT) +subdir = regtest +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/M4/add_cflags.m4 \ + $(top_srcdir)/M4/add_cxxflags.m4 $(top_srcdir)/M4/clip_mode.m4 \ + $(top_srcdir)/M4/endian.m4 $(top_srcdir)/M4/extra_largefile.m4 \ + $(top_srcdir)/M4/extra_pkg.m4 \ + $(top_srcdir)/M4/flexible_array.m4 \ + $(top_srcdir)/M4/gcc_version.m4 $(top_srcdir)/M4/libtool.m4 \ + $(top_srcdir)/M4/lrint.m4 $(top_srcdir)/M4/lrintf.m4 \ + $(top_srcdir)/M4/ltoptions.m4 $(top_srcdir)/M4/ltsugar.m4 \ + $(top_srcdir)/M4/ltversion.m4 $(top_srcdir)/M4/lt~obsolete.m4 \ + $(top_srcdir)/M4/mkoctfile_version.m4 \ + $(top_srcdir)/M4/octave.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am_sndfile_regtest_OBJECTS = sndfile-regtest.$(OBJEXT) \ + database.$(OBJEXT) checksum.$(OBJEXT) +sndfile_regtest_OBJECTS = $(am_sndfile_regtest_OBJECTS) +am__DEPENDENCIES_1 = +sndfile_regtest_DEPENDENCIES = $(top_builddir)/src/libsndfile.la \ + $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/Cfg/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(sndfile_regtest_SOURCES) +DIST_SOURCES = $(sndfile_regtest_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CLEAN_VERSION = @CLEAN_VERSION@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTERNAL_CFLAGS = @EXTERNAL_CFLAGS@ +EXTERNAL_LIBS = @EXTERNAL_LIBS@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@ +GCC_MINOR_VERSION = @GCC_MINOR_VERSION@ +GCC_VERSION = @GCC_VERSION@ +GETCONF = @GETCONF@ +GREP = @GREP@ +HAVE_AUTOGEN = @HAVE_AUTOGEN@ +HAVE_MKOCTFILE = @HAVE_MKOCTFILE@ +HAVE_OCTAVE = @HAVE_OCTAVE@ +HAVE_OCTAVE_CONFIG = @HAVE_OCTAVE_CONFIG@ +HAVE_WINE = @HAVE_WINE@ +HOST_TRIPLET = @HOST_TRIPLET@ +HTML_BGCOLOUR = @HTML_BGCOLOUR@ +HTML_FGCOLOUR = @HTML_FGCOLOUR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MKOCTFILE = @MKOCTFILE@ +MKOCTFILE_VERSION = @MKOCTFILE_VERSION@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCTAVE = @OCTAVE@ +OCTAVE_CONFIG = @OCTAVE_CONFIG@ +OCTAVE_CONFIG_VERSION = @OCTAVE_CONFIG_VERSION@ +OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@ +OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@ +OCTAVE_VERSION = @OCTAVE_VERSION@ +OGG_CFLAGS = @OGG_CFLAGS@ +OGG_LIBS = @OGG_LIBS@ +OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@ +OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +RC = @RC@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SF_COUNT_MAX = @SF_COUNT_MAX@ +SHARED_VERSION_INFO = @SHARED_VERSION_INFO@ +SHELL = @SHELL@ +SHLIB_VERSION_ARG = @SHLIB_VERSION_ARG@ +SIZEOF_SF_COUNT_T = @SIZEOF_SF_COUNT_T@ +SNDIO_LIBS = @SNDIO_LIBS@ +SPEEX_CFLAGS = @SPEEX_CFLAGS@ +SPEEX_LIBS = @SPEEX_LIBS@ +SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ +SQLITE3_LIBS = @SQLITE3_LIBS@ +STRIP = @STRIP@ +TYPEOF_SF_COUNT_T = @TYPEOF_SF_COUNT_T@ +VERSION = @VERSION@ +VORBISENC_CFLAGS = @VORBISENC_CFLAGS@ +VORBISENC_LIBS = @VORBISENC_LIBS@ +VORBIS_CFLAGS = @VORBIS_CFLAGS@ +VORBIS_LIBS = @VORBIS_LIBS@ +WIN_RC_VERSION = @WIN_RC_VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +htmldocdir = @htmldocdir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_HEADERS = regtest.h +INCLUDES = -I$(top_srcdir)/src $(SQLITE3_CFLAGS) $(OS_SPECIFIC_CFLAGS) +sndfile_regtest_SOURCES = sndfile-regtest.c database.c checksum.c +sndfile_regtest_LDADD = $(top_builddir)/src/libsndfile.la $(SQLITE3_LIBS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu regtest/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu regtest/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +sndfile-regtest$(EXEEXT): $(sndfile_regtest_OBJECTS) $(sndfile_regtest_DEPENDENCIES) + @rm -f sndfile-regtest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(sndfile_regtest_OBJECTS) $(sndfile_regtest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksum.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/database.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sndfile-regtest.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/regtest/checksum.c b/regtest/checksum.c new file mode 100644 index 0000000..7f433a4 --- /dev/null +++ b/regtest/checksum.c @@ -0,0 +1,117 @@ +/* +** Copyright (C) 2005-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* +** A simple checksum for short, int and float data. +*/ + +#include "sfconfig.h" + +#include +#include +#include +#include + +#include + +#include "regtest.h" + +#define BIG_PRIME 999983 + +#define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) + +static int short_checksum (SNDFILE * file, int start) ; +static int int_checksum (SNDFILE * file, int start) ; +static int float_checksum (SNDFILE * file, int start) ; + +int +calc_checksum (SNDFILE * file, const SF_INFO * info) +{ int start ; + + /* Seed the checksum with data from the SF_INFO struct. */ + start = info->samplerate ; + start = start * BIG_PRIME + info->channels ; + start = start * BIG_PRIME + info->format ; + + switch (info->format & SF_FORMAT_SUBMASK) + { case SF_FORMAT_FLOAT : + case SF_FORMAT_DOUBLE : + return float_checksum (file, start) ; + + case SF_FORMAT_PCM_24 : + case SF_FORMAT_PCM_32 : + return int_checksum (file, start) ; + + default : + return short_checksum (file, start) ; + } ; + + return 0 ; +} /* calc_checksum */ + +/*------------------------------------------------------------------------------ +*/ + +static union +{ short s [1 << 16] ; + int i [1 << 15] ; + float f [1 << 15] ; +} data ; + +static int +short_checksum (SNDFILE * file, int start) +{ int k, count ; + + do + { count = (int) sf_read_short (file, data.s, ARRAY_LEN (data.s)) ; + for (k = 0 ; k < count ; k++) + start = start * BIG_PRIME + data.s [k] ; + } + while (count > 0) ; + + return start ; +} /* short_checksum */ + +static int +int_checksum (SNDFILE * file, int start) +{ int k, count ; + + do + { count = (int) sf_read_int (file, data.i, ARRAY_LEN (data.i)) ; + for (k = 0 ; k < count ; k++) + start = start * BIG_PRIME + data.i [k] ; + } + while (count > 0) ; + + return start ; +} /* int_checksum */ + +static int +float_checksum (SNDFILE * file, int start) +{ int k, count ; + + do + { count = (int) sf_read_float (file, data.f, ARRAY_LEN (data.f)) ; + for (k = 0 ; k < count ; k++) + start = start * BIG_PRIME + lrintf (0x7FFFFFFF * data.f [k]) ; + } + while (count > 0) ; + + return start ; +} /* float_checksum */ + diff --git a/regtest/database.c b/regtest/database.c new file mode 100644 index 0000000..f800a2c --- /dev/null +++ b/regtest/database.c @@ -0,0 +1,495 @@ +/* +** Copyright (C) 2005-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include "regtest.h" + +#if HAVE_SQLITE3 + +#include + +typedef struct +{ sqlite3 *sql ; + + int count ; + int ekey_max ; + + /* Filename and pathname for file. */ + char filename [256] ; + char pathname [512] ; + + /* Storage for createding SQL commands. Must be larger than logbuf below. */ + char cmdbuf [1 << 15] ; + + /* Storage for log buffer retrieved from SNDFILE* .*/ + char logbuf [1 << 14] ; + +} REGTEST_DB ; + +/* In checksum.c */ +int calc_checksum (SNDFILE * file, const SF_INFO * info) ; + +static void get_filename_pathname (REGTEST_DB * db, const char *filepath) ; +static void single_quote_replace (char * buf) ; + +static int get_ekey_from_filename (REGTEST_DB * db, const char *filepath) ; +static int get_filename_pathname_by_ekey (REGTEST_DB * db, int ekey) ; +static int check_file_by_ekey (REGTEST_DB * db, int ekey) ; + +static int count_callback (REGTEST_DB * db, int argc, char **argv, char **colname) ; +static int ekey_max_callback (REGTEST_DB * db, int argc, char **argv, char **colname) ; +static int callback (void *unused, int argc, char **argv, char **colname) ; + +REG_DB * +db_open (const char * db_name) +{ REGTEST_DB * db ; + int err ; + + if ((db = malloc (sizeof (REGTEST_DB))) == NULL) + { perror ("malloc") ; + exit (1) ; + } ; + + if ((err = sqlite3_open (db_name, &(db->sql))) != 0) + { printf ("Can't open database: %s\n", sqlite3_errmsg (db->sql)) ; + sqlite3_close (db->sql) ; + free (db) ; + exit (1) ; + } ; + + return (REG_DB *) db ; +} /* db_open */ + +int +db_create (const char * db_name) +{ REGTEST_DB * db ; + const char *cmd ; + char * errmsg = NULL ; + int err ; + + db = (REGTEST_DB *) db_open (db_name) ; + + cmd = "create table sndfile (ekey INTEGER PRIMARY KEY," + "fname VARCHAR(1)," + "fpath VARCHAR(1)," + "srate INTEGER," + "frames VARCHAR(1)," + "channels INTEGER," + "format VARCHAR(1)," + "checksum VARCHAR(1)," + "logbuf VARCHAR(1)" + ");" ; + + err = sqlite3_exec (db->sql, cmd, callback, 0, &errmsg) ; + if (err != SQLITE_OK) + printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + + sqlite3_close (db->sql) ; + free (db) ; + + return 0 ; +} /* db_create */ + +int +db_close (REG_DB * db_handle) +{ REGTEST_DB * db ; + + db = (REGTEST_DB *) db_handle ; + + sqlite3_close (db->sql) ; + free (db) ; + + return 0 ; +} /* db_close */ + +/*============================================================================== +*/ + +int +db_file_exists (REG_DB * db_handle, const char * filename) +{ REGTEST_DB * db ; + const char * cptr ; + char * errmsg ; + int err ; + + db = (REGTEST_DB *) db_handle ; + + if ((cptr = strrchr (filename, '/')) != NULL) + filename = cptr + 1 ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname from sndfile where fname='%s'", filename) ; + + db->count = 0 ; + err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) count_callback, db, &errmsg) ; + if (err == 0 && db->count == 1) + return 1 ; + + return 0 ; +} /* db_file_exists */ + +int +db_add_file (REG_DB * db_handle, const char * filepath) +{ REGTEST_DB * db ; + SNDFILE * sndfile ; + SF_INFO info ; + char * errmsg ; + int err, checksum ; + + db = (REGTEST_DB *) db_handle ; + + get_filename_pathname (db, filepath) ; + + if (db_file_exists (db_handle, filepath)) + { printf (" %s : already in database\n", db->filename) ; + return 0 ; + } ; + + memset (&info, 0, sizeof (info)) ; + sndfile = sf_open (db->pathname, SFM_READ, &info) ; + sf_command (sndfile, SFC_GET_LOG_INFO, db->logbuf, sizeof (db->logbuf)) ; + checksum = (sndfile == NULL) ? 0 : calc_checksum (sndfile, &info) ; + sf_close (sndfile) ; + + if (sndfile == NULL) + { printf (" %s : could not open : %s\n", db->filename, sf_strerror (NULL)) ; + puts (db->logbuf) ; + return 1 ; + } ; + + single_quote_replace (db->logbuf) ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "insert into sndfile " + "(fname, fpath, srate, frames, channels, format, checksum, logbuf) values" + "('%s','%s',%d,'%ld', %d, '0x%08x', '0x%08x', '%s');", + db->filename, db->pathname, info.samplerate, (long) info.frames, info.channels, info.format, checksum, db->logbuf) ; + + if (strlen (db->cmdbuf) >= sizeof (db->cmdbuf) - 1) + { printf ("strlen (db->cmdbuf) too long.\n") ; + exit (1) ; + } ; + + err = sqlite3_exec (db->sql, db->cmdbuf, callback, 0, &errmsg) ; + if (err != SQLITE_OK) + { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + puts (db->cmdbuf) ; + } ; + + return 0 ; +} /* db_add_file */ + +int +db_check_file (REG_DB * db_handle, const char * filepath) +{ REGTEST_DB * db ; + int ekey ; + + if (db_file_exists (db_handle, filepath) == 0) + { printf ("\nFile not in database.\n\n") ; + exit (0) ; + } ; + + db = (REGTEST_DB *) db_handle ; + + ekey = get_ekey_from_filename (db, filepath) ; + + return check_file_by_ekey (db, ekey) ; +} /* db_check_file */ + +/*============================================================================== +*/ + +int +db_check_all (REG_DB * db_handle) +{ REGTEST_DB * db ; + char * errmsg ; + int err, ekey ; + + db = (REGTEST_DB *) db_handle ; + + db->ekey_max = 0 ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select ekey from sndfile") ; + + err = sqlite3_exec (db->sql, db->cmdbuf, (sqlite3_callback) ekey_max_callback, db, &errmsg) ; + if (err != SQLITE_OK) + { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + puts (db->cmdbuf) ; + } ; + + for (ekey = 1 ; ekey <= db->ekey_max ; ekey++) + if (get_filename_pathname_by_ekey (db, ekey) != 0) + check_file_by_ekey (db, ekey) ; + + return 0 ; +} /* db_check_all */ + + +int +db_list_all (REG_DB * db_handle) +{ + printf ("%s : %p\n", __func__, db_handle) ; + return 0 ; +} /* db_list_all */ + +int +db_del_entry (REG_DB * db_handle, const char * entry) +{ + printf ("%s : %p %s\n", __func__, db_handle, entry) ; + return 0 ; +} /* db_del_entry */ + +/*============================================================================== +*/ + +static int +get_ekey_from_filename (REGTEST_DB * db, const char *filepath) +{ char * errmsg, **result ; + int err, ekey = 0, rows, cols ; + + get_filename_pathname (db, filepath) ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select ekey from sndfile where fname='%s'", db->filename) ; + + err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; + if (err != SQLITE_OK) + { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + puts (db->cmdbuf) ; + } ; + + if (cols != 1 || rows != 1) + { printf ("Bad juju!! rows = %d cols = %d\n", rows, cols) ; + exit (1) ; + } ; + + ekey = strtol (result [1], NULL, 10) ; + + sqlite3_free_table (result) ; + + return ekey ; +} /* get_ekey_from_filename */ + +static int +get_filename_pathname_by_ekey (REGTEST_DB * db, int ekey) +{ char *errmsg, **result ; + int err, rows, cols ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname,fpath from sndfile where ekey='%d'", ekey) ; + + err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; + if (err != SQLITE_OK) + { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + puts (db->cmdbuf) ; + return 0 ; + } ; + + if (cols != 2 || rows != 1) + { printf ("\nError (%s %d) : rows = %d cols = %d\n", __func__, __LINE__, rows, cols) ; + exit (1) ; + } ; + + snprintf (db->filename, sizeof (db->filename), "%s", result [2]) ; + snprintf (db->pathname, sizeof (db->pathname), "%s", result [3]) ; + + sqlite3_free_table (result) ; + + return 1 ; +} /* get_filename_pathname_by_ekey */ + +static int +check_file_by_ekey (REGTEST_DB * db, int ekey) +{ SNDFILE * sndfile ; + SF_INFO info ; + char * errmsg, **result ; + int err, k, rows, cols, checksum ; + + printf (" %s : ", db->filename) ; + fflush (stdout) ; + + memset (&info, 0, sizeof (info)) ; + sndfile = sf_open (db->pathname, SFM_READ, &info) ; + sf_command (sndfile, SFC_GET_LOG_INFO, db->logbuf, sizeof (db->logbuf)) ; + checksum = (sndfile == NULL) ? 0 : calc_checksum (sndfile, &info) ; + sf_close (sndfile) ; + + if (sndfile == NULL) + { printf ("\n\nError : Could not open '%s' : %s\n", db->pathname, sf_strerror (NULL)) ; + puts (db->logbuf) ; + exit (1) ; + } ; + + single_quote_replace (db->logbuf) ; + + snprintf (db->cmdbuf, sizeof (db->cmdbuf), "select fname,srate,frames,channels,format," + "checksum,logbuf from sndfile where ekey='%d'", ekey) ; + + err = sqlite3_get_table (db->sql, db->cmdbuf, &result, &rows, &cols, &errmsg) ; + if (err != SQLITE_OK) + { printf ("Line %d : SQL error: %s\n", __LINE__, errmsg) ; + puts (db->cmdbuf) ; + } ; + + for (k = 0 ; k < cols ; k++) + { if (strcmp (result [k], "fname") == 0) + { if (strcmp (result [k + cols], db->filename) == 0) + continue ; + printf ("\n\nError : fname doesn't match : %s != %s\n", result [k + cols], db->filename) ; + } ; + + if (strcmp (result [k], "srate") == 0) + { if (strtol (result [k + cols], NULL, 10) == info.samplerate) + continue ; + printf ("\n\nError : srate doesn't match : %s == %d\n", result [k + cols], info.samplerate) ; + } ; + + if (strcmp (result [k], "frames") == 0) + { if (strtoll (result [k + cols], NULL, 10) == info.frames) + continue ; + printf ("\n\nError : frames doesn't match : %s == %ld\n", result [k + cols], (long) info.frames) ; + } ; + + if (strcmp (result [k], "channels") == 0) + { if (strtol (result [k + cols], NULL, 10) == info.channels) + continue ; + printf ("\n\nError : channels doesn't match : %s == %d\n", result [k + cols], info.channels) ; + } ; + + if (strcmp (result [k], "format") == 0) + { if (strtol (result [k + cols], NULL, 16) == info.format) + continue ; + printf ("\n\nError : format doesn't match : %s == 0x%08x\n", result [k + cols], info.format) ; + } ; + + if (strcmp (result [k], "checksum") == 0) + { int db_val = (int) strtoll (result [k + cols], NULL, 16) ; + + if (db_val == checksum) + continue ; + printf ("\n\nError : checksum doesn't match : 0x%08x == 0x%08x\n", db_val, checksum) ; + } ; + + if (strcmp (result [k], "logbuf") == 0) + continue ; + + printf ("\nHere is the old logubuffer :\n\n%s\n\nand the new :\n\n%s\n\n", result [2 * cols - 1], db->logbuf) ; + exit (1) ; + } ; + + sqlite3_free_table (result) ; + + puts ("ok") ; + + return 0 ; +} /* check_file_by_ekey */ + +/*============================================================================== +*/ + +static void +get_filename_pathname (REGTEST_DB * db, const char *filepath) +{ const char * cptr ; + int slen ; + + if (filepath [0] != '/') + { memset (db->pathname, 0, sizeof (db->pathname)) ; + if (getcwd (db->pathname, sizeof (db->pathname)) == NULL) + { perror ("\ngetcwd failed") ; + exit (1) ; + } ; + + slen = strlen (db->pathname) ; + db->pathname [slen ++] = '/' ; + snprintf (db->pathname + slen, sizeof (db->pathname) - slen, "%s", filepath) ; + } + else + snprintf (db->pathname, sizeof (db->pathname), "%s", filepath) ; + + if ((cptr = strrchr (db->pathname, '/')) == NULL) + { printf ("\nError : bad pathname %s\n", filepath) ; + exit (1) ; + } ; + + snprintf (db->filename, sizeof (db->filename), "%s", cptr + 1) ; +} /* get filename_pathname */ + +static void +single_quote_replace (char * buf) +{ while ((buf = strchr (buf, '\'')) != 0) + buf [0] = '"' ; +} /* single_quote_replace */ + +static int +count_callback (REGTEST_DB * db, int argc, char **argv, char **colname) +{ db->count ++ ; + + (void) argc ; + (void) argv ; + (void) colname ; + return 0 ; +} /* count_callback */ + +static int +ekey_max_callback (REGTEST_DB * db, int argc, char **argv, char **unused) +{ int ekey ; + + (void) argc ; + (void) unused ; + + ekey = strtol (argv [0], NULL, 10) ; + if (ekey > db->ekey_max) + db->ekey_max = ekey ; + + return 0 ; +} /* ekey_max_callback */ + +static int +callback (void *unused, int argc, char **argv, char **colname) +{ int k ; + + (void) unused ; + + for (k = 0 ; k < argc ; k++) + printf ("%s = %s\n", colname [k], argv [k] ? argv [k] : "NULL") ; + + printf ("\n") ; + + return 0 ; +} /* callback */ + +#else + +int dummy (void) ; + +int +dummy (void) +{ /* + ** Empty dummy fnction so tha compiler doesn't winge about an + ** empty file. + */ + return 0 ; +} /* dummy */ + +#endif diff --git a/regtest/regtest.h b/regtest/regtest.h new file mode 100644 index 0000000..567d97b --- /dev/null +++ b/regtest/regtest.h @@ -0,0 +1,38 @@ +/* +** Copyright (C) 2005-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +typedef struct REG_DB_tag REG_DB ; + +/* In database.c */ +REG_DB * db_open (const char * db_name) ; + +int db_create (const char * dbname) ; + +int db_close (REG_DB * db_handle) ; + +int db_file_exists (REG_DB * db_handle, const char * filename) ; +int db_add_file (REG_DB * db_handle, const char * filename) ; +int db_check_file (REG_DB * db_handle, const char * filename) ; + +int db_list_all (REG_DB * db_handle) ; +int db_check_all (REG_DB * db_handle) ; +int db_del_entry (REG_DB * db_handle, const char * entry) ; + +/* In checksum.c */ +int calc_checksum (SNDFILE * file, const SF_INFO * info) ; + diff --git a/regtest/sndfile-regtest.c b/regtest/sndfile-regtest.c new file mode 100644 index 0000000..a28caa2 --- /dev/null +++ b/regtest/sndfile-regtest.c @@ -0,0 +1,121 @@ +/* +** Copyright (C) 2005-2011 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "config.h" + +#include +#include +#include + +#include + +#if HAVE_SQLITE3 + +#include "regtest.h" + +enum +{ OPT_ADD_FILE = 0x0100, + OPT_CREATE_DB = 0x0200, + OPT_DEL_ENTRY = 0x0400, + OPT_LIST_ALL = 0x0800, + OPT_TEST_ALL = 0x1000, + OPT_VERBOSE = 0x2000 +} ; + +static void print_libsndfile_version (void) ; + +int +main (int argc, char * argv []) +{ const char *db_name = "./.sndfile-regtest.db" ; + REG_DB *reg_db ; + int k, retval ; + + if (argc < 2) + { printf ("\nUsage message goes here.\n\n") ; + exit (0) ; + } ; + + if (argc == 2 && strcmp (argv [1], "--create-db") == 0) + return db_create (db_name) ; + + reg_db = db_open (db_name) ; + + if (argc == 2) + { if (strcmp (argv [1], "--list-all") == 0) + return db_list_all (reg_db) ; + + if (strcmp (argv [1], "--check-all") == 0) + { print_libsndfile_version () ; + retval = db_check_all (reg_db) ; + puts ("\nDone.\n") ; + return retval ; + } ; + } ; + + if (argc == 3 && strcmp (argv [1], "--del-entry") == 0) + { db_del_entry (reg_db, argv [2]) ; + db_close (reg_db) ; + return 0 ; + } ; + + if (strcmp (argv [1], "--check-file") == 0) + { print_libsndfile_version () ; + + for (k = 2 ; k < argc ; k++) + db_check_file (reg_db, argv [k]) ; + db_close (reg_db) ; + return 0 ; + } ; + + if (strcmp (argv [1], "--add-file") == 0) + { print_libsndfile_version () ; + + for (k = 2 ; k < argc ; k++) + db_add_file (reg_db, argv [k]) ; + db_close (reg_db) ; + return 0 ; + } ; + + printf ("\nError : unhandled command line args :") ; + for (k = 1 ; k < argc ; k++) + printf (" %s", argv [k]) ; + puts ("\n") ; + + return 1 ; +} /* main */ + +static void +print_libsndfile_version (void) +{ char version [64] ; + + sf_command (NULL, SFC_GET_LIB_VERSION, version, sizeof (version)) ; + printf ("\nsndfile-regtest : using %s\n\n", version) ; +} /* print_lib_version */ + +#else + +int +main (void) +{ + puts ("\nThis program was not compiled with libsqlite3 and hence doesn't work.\n") ; + + return 0 ; +} /* main */ + +#endif + -- cgit v1.2.1