From b1ec796bda9e8e93da8ffa7825b3713980330ee8 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Wed, 24 May 2006 04:41:36 +0000 Subject: [PATCH] complete largefile support --- build/config.mk | 6 +- configure.in | 145 ++++++++------- doc/html/changelog.html | 9 +- include/share/grabbag/file.h | 5 + src/flac/analyze.c | 7 +- src/flac/decode.c | 42 +++-- src/flac/encode.c | 37 ++-- src/flac/encode.h | 11 +- src/flac/local_string_utils.c | 4 + src/flac/main.c | 37 ++-- src/libFLAC/bitbuffer.c | 4 + src/libFLAC/bitmath.c | 4 + src/libFLAC/cpu.c | 8 +- src/libFLAC/crc.c | 4 + src/libFLAC/file_decoder.c | 14 +- src/libFLAC/file_encoder.c | 16 +- src/libFLAC/fixed.c | 4 + src/libFLAC/float.c | 4 + src/libFLAC/format.c | 8 +- src/libFLAC/lpc.c | 4 + src/libFLAC/md5.c | 8 +- src/libFLAC/memory.c | 8 +- src/libFLAC/metadata_iterators.c | 165 +++++++++--------- src/libFLAC/metadata_object.c | 4 + src/libFLAC/seekable_stream_decoder.c | 4 + src/libFLAC/seekable_stream_encoder.c | 4 + src/libFLAC/stream_decoder.c | 8 +- src/libFLAC/stream_encoder.c | 8 +- src/libFLAC/stream_encoder_framing.c | 4 + src/libFLAC/window.c | 4 + src/libOggFLAC/file_decoder.c | 14 +- src/libOggFLAC/file_encoder.c | 16 +- src/libOggFLAC/ogg_decoder_aspect.c | 4 + src/libOggFLAC/ogg_encoder_aspect.c | 4 + src/libOggFLAC/ogg_helper.c | 4 + src/libOggFLAC/ogg_mapping.c | 4 + src/libOggFLAC/seekable_stream_decoder.c | 4 + src/libOggFLAC/seekable_stream_encoder.c | 4 + src/libOggFLAC/stream_decoder.c | 4 + src/libOggFLAC/stream_encoder.c | 4 + src/metaflac/operations.c | 4 + src/metaflac/operations_shorthand_cuesheet.c | 16 +- src/metaflac/operations_shorthand_seektable.c | 4 + .../operations_shorthand_streaminfo.c | 4 + .../operations_shorthand_vorbiscomment.c | 11 +- src/metaflac/options.c | 4 + src/metaflac/usage.c | 4 + src/metaflac/utils.c | 4 + src/monkeys_audio_utilities/flac_mac/main.c | 4 + src/monkeys_audio_utilities/flac_ren/main.c | 12 +- src/plugin_common/charset.c | 8 +- src/plugin_common/dither.c | 4 + src/plugin_common/replaygain.c | 4 + src/plugin_common/tags.c | 4 + src/plugin_winamp2/Makefile.am | 4 +- src/plugin_winamp2/{config.c => configure.c} | 6 +- src/plugin_winamp2/{config.h => configure.h} | 0 src/plugin_winamp2/in_flac.c | 31 ++-- src/plugin_winamp2/in_flac.dsp | 4 +- src/plugin_winamp2/infobox.c | 6 +- src/plugin_winamp2/playback.c | 22 ++- src/plugin_winamp2/playback.h | 4 +- src/plugin_xmms/charset.c | 4 + src/plugin_xmms/configure.c | 4 + src/plugin_xmms/fileinfo.c | 8 + src/plugin_xmms/http.c | 9 +- src/plugin_xmms/plugin.c | 45 ++--- src/plugin_xmms/tag.c | 4 + src/share/getopt/getopt.c | 4 +- src/share/getopt/getopt1.c | 4 +- src/share/grabbag/cuesheet.c | 4 + src/share/grabbag/file.c | 4 + src/share/grabbag/replaygain.c | 4 + src/share/grabbag/seektable.c | 4 + .../replaygain_analysis/replaygain_analysis.c | 4 + .../replaygain_synthesis.c | 4 + src/share/utf8/charset.c | 4 +- src/share/utf8/charset_test.c | 4 + src/share/utf8/iconvert.c | 4 +- src/share/utf8/makemap.c | 4 + src/share/utf8/utf8.c | 8 +- src/test_grabbag/cuesheet/main.c | 13 +- src/test_libFLAC++/decoders.cpp | 31 ++-- src/test_libFLAC++/file_utils.c | 8 +- src/test_libFLAC++/file_utils.h | 13 +- src/test_libFLAC++/metadata_manip.cpp | 34 ++-- src/test_libFLAC++/metadata_utils.c | 4 + src/test_libFLAC/bitbuffer.c | 4 + src/test_libFLAC/decoders.c | 37 ++-- src/test_libFLAC/encoders.c | 4 + src/test_libFLAC/file_utils.c | 8 +- src/test_libFLAC/file_utils.h | 13 +- src/test_libFLAC/format.c | 4 + src/test_libFLAC/main.c | 4 + src/test_libFLAC/metadata.c | 4 + src/test_libFLAC/metadata_manip.c | 26 +-- src/test_libFLAC/metadata_object.c | 4 + src/test_libFLAC/metadata_utils.c | 4 + src/test_libOggFLAC++/decoders.cpp | 31 ++-- src/test_libOggFLAC++/file_utils.c | 8 +- src/test_libOggFLAC++/file_utils.h | 11 +- src/test_libOggFLAC++/metadata_utils.c | 4 + src/test_libOggFLAC/decoders.c | 37 ++-- src/test_libOggFLAC/encoders.c | 4 + src/test_libOggFLAC/file_utils.c | 8 +- src/test_libOggFLAC/file_utils.h | 11 +- src/test_libOggFLAC/main.c | 4 + src/test_libOggFLAC/metadata_utils.c | 4 + src/test_seeking/main.c | 4 +- src/test_streams/main.c | 4 + 110 files changed, 878 insertions(+), 413 deletions(-) rename src/plugin_winamp2/{config.c => configure.c} (95%) rename src/plugin_winamp2/{config.h => configure.h} (100%) diff --git a/build/config.mk b/build/config.mk index 400949d4..3def3dba 100644 --- a/build/config.mk +++ b/build/config.mk @@ -44,12 +44,12 @@ all default: $(DEFAULT_BUILD) VERSION=\"CVS\" ifeq ($(DARWIN_BUILD),yes) -#CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -DFLAC__SYS_DARWIN -CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DFLAC__HAS_OGG -DFLAC__SYS_DARWIN +#CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFLAC__SYS_DARWIN +CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFLAC__SYS_DARWIN ICONV_INCLUDE_DIR=$(HOME)/local.i18n/include ICONV_LIB_DIR=$(HOME)/local.i18n/lib else -CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG +CONFIG_CFLAGS=-DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 endif OGG_INCLUDE_DIR=$(HOME)/local/include diff --git a/configure.in b/configure.in index fddfb87b..ffe07ac4 100644 --- a/configure.in +++ b/configure.in @@ -42,6 +42,9 @@ AC_PROG_MAKE_SET AC_SYS_LARGEFILE AC_FUNC_FSEEKO +#@@@ new name is AC_CONFIG_HEADERS +AM_CONFIG_HEADER(config.h) + AC_CHECK_TYPES(socklen_t, [], []) dnl check for getopt in standard library @@ -49,13 +52,25 @@ dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] ) AC_CHECK_FUNCS(getopt_long, [], []) case "$host_cpu" in - i*86) cpu_ia32=true ; AC_DEFINE(FLAC__CPU_IA32) ;; - powerpc) cpu_ppc=true ; AC_DEFINE(FLAC__CPU_PPC) ;; - sparc) cpu_sparc=true ; AC_DEFINE(FLAC__CPU_SPARC) ;; + i*86) + cpu_ia32=true + AC_DEFINE(FLAC__CPU_IA32) + AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386]) + ;; + powerpc) + cpu_ppc=true + AC_DEFINE(FLAC__CPU_PPC) + AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC]) + ;; + sparc) + cpu_sparc=true + AC_DEFINE(FLAC__CPU_SPARC) + AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC]) + ;; esac -AM_CONDITIONAL(FLaC__CPU_IA32, test x$cpu_ia32 = xtrue) -AM_CONDITIONAL(FLaC__CPU_PPC, test x$cpu_ppc = xtrue) -AM_CONDITIONAL(FLaC__CPU_SPARC, test x$cpu_sparc = xtrue) +AM_CONDITIONAL(FLaC__CPU_IA32, test "x$cpu_ia32" = xtrue) +AM_CONDITIONAL(FLaC__CPU_PPC, test "x$cpu_ppc" = xtrue) +AM_CONDITIONAL(FLaC__CPU_SPARC, test "x$cpu_sparc" = xtrue) case "$host" in i386-*-openbsd3.[[0-3]]) OBJ_FORMAT=aoutb ;; *-*-cygwin|*mingw*) OBJ_FORMAT=win32 ;; @@ -63,20 +78,30 @@ case "$host" in esac AC_SUBST(OBJ_FORMAT) case "$host" in - *-pc-linux-gnu) sys_linux=true ; AC_DEFINE(FLAC__SYS_LINUX) ;; - *-*-darwin*) sys_darwin=true ; AC_DEFINE(FLAC__SYS_DARWIN) ;; + *-pc-linux-gnu) + sys_linux=true + AC_DEFINE(FLAC__SYS_LINUX) + AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux]) + ;; + *-*-darwin*) + sys_darwin=true + AC_DEFINE(FLAC__SYS_DARWIN) + AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X]) + ;; esac -AM_CONDITIONAL(FLaC__SYS_DARWIN, test x$sys_darwin = xtrue) -AM_CONDITIONAL(FLaC__SYS_LINUX, test x$sys_linux = xtrue) +AM_CONDITIONAL(FLaC__SYS_DARWIN, test "x$sys_darwin" = xtrue) +AM_CONDITIONAL(FLaC__SYS_LINUX, test "x$sys_linux" = xtrue) -if test x$cpu_ia32 = xtrue ; then +if test "x$cpu_ia32" = xtrue ; then AC_DEFINE(FLAC__ALIGN_MALLOC_DATA) +AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries]) fi -AC_ARG_ENABLE(asm-optimizations, [ --disable-asm-optimizations Don't use any assembly optimization routines], asm_opt=no, asm_opt=yes) -AM_CONDITIONAL(FLaC__NO_ASM, test x$asm_opt = xno) -if test x$asm_opt = xno ; then +AC_ARG_ENABLE(asm-optimizations, AC_HELP_STRING([--disable-asm-optimizations], [Don't use any assembly optimization routines]), asm_opt=no, asm_opt=yes) +AM_CONDITIONAL(FLaC__NO_ASM, test "x$asm_opt" = xno) +if test "x$asm_opt" = xno ; then AC_DEFINE(FLAC__NO_ASM) +AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code]) fi AC_ARG_ENABLE(debug, @@ -86,7 +111,7 @@ AC_ARG_ENABLE(debug, no) debug=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac],[debug=false]) -AM_CONDITIONAL(DEBUG, test x$debug = xtrue) +AM_CONDITIONAL(DEBUG, test "x$debug" = xtrue) AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support by asserting that the OS supports SSE instructions], @@ -95,9 +120,10 @@ AC_ARG_ENABLE(sse, no) sse_os=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-sse) ;; esac],[sse_os=false]) -AM_CONDITIONAL(FLaC__SSE_OS, test x$sse_os = xtrue) -if test x$sse_os = xtrue ; then +AM_CONDITIONAL(FLaC__SSE_OS, test "x$sse_os" = xtrue) +if test "x$sse_os" = xtrue ; then AC_DEFINE(FLAC__SSE_OS) +AH_TEMPLATE(FLAC__SSE_OS, [define if your operating system supports SSE instructions]) fi AC_ARG_ENABLE(3dnow, @@ -107,9 +133,10 @@ AC_ARG_ENABLE(3dnow, no) use_3dnow=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-3dnow) ;; esac],[use_3dnow=true]) -AM_CONDITIONAL(FLaC__USE_3DNOW, test x$use_3dnow = xtrue) -if test x$use_3dnow = xtrue ; then +AM_CONDITIONAL(FLaC__USE_3DNOW, test "x$use_3dnow" = xtrue) +if test "x$use_3dnow" = xtrue ; then AC_DEFINE(FLAC__USE_3DNOW) +AH_TEMPLATE(FLAC__USE_3DNOW, [define to enable use of 3Dnow! instructions]) fi AC_ARG_ENABLE(altivec, @@ -119,9 +146,10 @@ AC_ARG_ENABLE(altivec, no) use_altivec=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-altivec) ;; esac],[use_altivec=true]) -AM_CONDITIONAL(FLaC__USE_ALTIVEC, test x$use_altivec = xtrue) -if test x$use_altivec = xtrue ; then +AM_CONDITIONAL(FLaC__USE_ALTIVEC, test "x$use_altivec" = xtrue) +if test "x$use_altivec" = xtrue ; then AC_DEFINE(FLAC__USE_ALTIVEC) +AH_TEMPLATE(FLAC__USE_ALTIVEC, [define to enable use of Altivec instructions]) fi AC_ARG_ENABLE(local-xmms-plugin, @@ -131,7 +159,7 @@ AC_ARG_ENABLE(local-xmms-plugin, no) install_xmms_plugin_locally=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-local-xmms-plugin) ;; esac],[install_xmms_plugin_locally=false]) -AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test x$install_xmms_plugin_locally = xtrue) +AM_CONDITIONAL(FLaC__INSTALL_XMMS_PLUGIN_LOCALLY, test "x$install_xmms_plugin_locally" = xtrue) AC_ARG_ENABLE(exhaustive-tests, [ --enable-exhaustive-tests Enable exhaustive testing], @@ -140,50 +168,57 @@ AC_ARG_ENABLE(exhaustive-tests, no) exhaustive_tests=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-exhaustive-tests) ;; esac],[exhaustive_tests=false]) -AM_CONDITIONAL(FLaC__EXHAUSTIVE_TESTS, test x$exhaustive_tests = xtrue) -if test x$exhaustive_tests = xtrue ; then +AM_CONDITIONAL(FLaC__EXHAUSTIVE_TESTS, test "x$exhaustive_tests" = xtrue) +if test "x$exhaustive_tests" = xtrue ; then AC_DEFINE(FLAC__EXHAUSTIVE_TESTS) +AH_TEMPLATE(FLAC__EXHAUSTIVE_TESTS, [define to run even more tests]) fi AC_ARG_ENABLE(valgrind-testing, -[ --enable-valgrind-testing Run all tests inside Valgrind], +AC_HELP_STRING([--enable-valgrind-testing], [Run all tests inside Valgrind]), [case "${enableval}" in yes) valgrind_testing=true ;; no) valgrind_testing=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-valgrind-testing) ;; esac],[valgrind_testing=false]) -AM_CONDITIONAL(FLaC__VALGRIND_TESTING, test x$valgrind_testing = xtrue) -if test x$valgrind_testing = xtrue ; then +AM_CONDITIONAL(FLaC__VALGRIND_TESTING, test "x$valgrind_testing" = xtrue) +if test "x$valgrind_testing" = xtrue ; then AC_DEFINE(FLAC__VALGRIND_TESTING) +AH_TEMPLATE(FLAC__VALGRIND_TESTING, [define to enable use of Valgrind in testers]) fi +AC_ARG_ENABLE(doxygen-docs, +AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen]), +[case "${enableval}" in + yes) enable_doxygen_docs=true ;; + no) enable_doxygen_docs=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-doxygen-docs) ;; +esac],[enable_doxygen_docs=true]) +if test "x$enable_doxygen_docs" != xno ; then + AC_CHECK_PROGS(DOXYGEN, doxygen) +fi +AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN") + dnl check for ogg library XIPH_PATH_OGG(have_ogg=yes, AC_MSG_WARN([*** Ogg development enviroment not installed - Ogg support will not be built])) -AM_CONDITIONAL(FLaC__HAS_OGG, [test x$have_ogg = xyes]) -if test x$have_ogg = xyes ; then +AM_CONDITIONAL(FLaC__HAS_OGG, [test "x$have_ogg" = xyes]) +if test "x$have_ogg" = xyes ; then AC_DEFINE(FLAC__HAS_OGG) +AH_TEMPLATE(FLAC__HAS_OGG, [define if you have the ogg library]) fi AM_PATH_XMMS(0.9.5.1, , AC_MSG_WARN([*** XMMS >= 0.9.5.1 not installed - xmms support will not be built])) -AM_CONDITIONAL(FLaC__HAS_XMMS, test x$XMMS_INPUT_PLUGIN_DIR != x) +AM_CONDITIONAL(FLaC__HAS_XMMS, test -n "$XMMS_INPUT_PLUGIN_DIR") dnl check for i18n(internationalization); these are from libiconv/gettext AM_ICONV AM_LANGINFO_CODESET -AC_ARG_ENABLE(doxygen_docs, AC_HELP_STRING([--disable-doxygen-docs], [Disable API documentation building via Doxygen])) -if test "x$enable_doxygen_docs" != "xno" ; then - AC_CHECK_PROGS(DOXYGEN, doxygen) -fi -AM_CONDITIONAL(FLaC__HAS_DOXYGEN, test -n "$DOXYGEN") -if test -n "$DOXYGEN" ; then -AC_DEFINE(FLAC__HAS_DOXYGEN) -fi - AC_CHECK_PROGS(DOCBOOK_TO_MAN, docbook-to-man docbook2man) AM_CONDITIONAL(FLaC__HAS_DOCBOOK_TO_MAN, test -n "$DOCBOOK_TO_MAN") if test -n "$DOCBOOK_TO_MAN" ; then AC_DEFINE(FLAC__HAS_DOCBOOK_TO_MAN) +AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man]) fi # only matters for x86 @@ -191,6 +226,7 @@ AC_CHECK_PROGS(NASM, nasm) AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM") if test -n "$NASM" ; then AC_DEFINE(FLAC__HAS_NASM) +AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler]) fi # only matters for PowerPC @@ -203,18 +239,20 @@ AM_CONDITIONAL(FLaC__HAS_AS, test "$AS" = "as") AM_CONDITIONAL(FLaC__HAS_GAS, test "$AS" = "gas") if test "$AS" = "as" ; then AC_DEFINE(FLAC__HAS_AS) +AH_TEMPLATE(FLAC__HAS_AS, [define if you are compiling for PowerPC and have the 'as' assembler]) fi if test "$AS" = "gas" ; then # funniest. macro. ever. AC_DEFINE(FLAC__HAS_GAS) +AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler]) fi OUR_CFLAGS_HEAD='-I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include' -if test x$debug = xtrue; then +if test "x$debug" = xtrue; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -g -O0 -DDEBUG" else OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O2 -DNDEBUG" - if test x$GCC = xyes; then + if test "x$GCC" = xyes; then OUR_CFLAGS_HEAD="$OUR_CFLAGS_HEAD -O3 -fomit-frame-pointer -funroll-loops -finline-functions -Wall -W -Winline -DFLaC__INLINE=__inline__" fi fi @@ -225,27 +263,7 @@ CXXFLAGS="$OUR_CFLAGS_HEAD $CXXFLAGS" AM_CONDITIONAL(FLaC__HAS_AS__TEMPORARILY_DISABLED, test "yes" = "no") AM_CONDITIONAL(FLaC__HAS_GAS__TEMPORARILY_DISABLED, test "yes" = "no") -AM_CONFIG_HEADER(config.h) -AH_TEMPLATE(FLAC__ALIGN_MALLOC_DATA, [define to align allocated memory on 32-byte boundaries]) -AH_TEMPLATE(FLAC__CPU_IA32, [define if building for ia32/i386]) -AH_TEMPLATE(FLAC__CPU_PPC, [define if building for PowerPC]) -AH_TEMPLATE(FLAC__CPU_SPARC, [define if building for SPARC]) -AH_TEMPLATE(FLAC__SYS_DARWIN, [define if building for Darwin / MacOS X]) -AH_TEMPLATE(FLAC__SYS_LINUX, [define if building for Linux]) -AH_TEMPLATE(FLAC__EXHAUSTIVE_TESTS, [define to run even more tests]) -AH_TEMPLATE(FLAC__VALGRIND_TESTING, [define to enable use of Valgrind in testers]) -AH_TEMPLATE(FLAC__HAS_DOXYGEN, [define if you have Doxygen]) -AH_TEMPLATE(FLAC__HAS_DOCBOOK_TO_MAN, [define if you have docbook-to-man or docbook2man]) -AH_TEMPLATE(FLAC__HAS_NASM, [define if you are compiling for x86 and have the NASM assembler]) -AH_TEMPLATE(FLAC__HAS_AS, [define if you are compiling for PowerPC and have the 'as' assembler]) -AH_TEMPLATE(FLAC__HAS_GAS, [define if you are compiling for PowerPC and have the 'gas' assembler]) -AH_TEMPLATE(FLAC__HAS_OGG, [define if you have the ogg library]) -AH_TEMPLATE(FLAC__NO_ASM, [define to disable use of assembly code]) -AH_TEMPLATE(FLAC__SSE_OS, [define if your operating system supports SSE instructions]) -AH_TEMPLATE(FLAC__USE_3DNOW, [define to enable use of 3Dnow! instructions]) -AH_TEMPLATE(FLAC__USE_ALTIVEC, [define to enable use of Altivec instructions]) - -AC_OUTPUT( \ +AC_CONFIG_FILES([ \ Makefile \ src/Makefile \ src/libFLAC/Makefile \ @@ -311,4 +329,5 @@ AC_OUTPUT( \ obj/release/bin/Makefile \ obj/release/lib/Makefile \ flac.pbproj/Makefile \ -) +]) +AC_OUTPUT diff --git a/doc/html/changelog.html b/doc/html/changelog.html index 2aabf844..144e06e8 100644 --- a/doc/html/changelog.html +++ b/doc/html/changelog.html @@ -65,7 +65,7 @@
  • General:
  • @@ -98,6 +98,7 @@
  • @@ -105,14 +106,16 @@ plugins:
  • build system:
  • diff --git a/include/share/grabbag/file.h b/include/share/grabbag/file.h index f98003f6..e7d02cf9 100644 --- a/include/share/grabbag/file.h +++ b/include/share/grabbag/file.h @@ -23,6 +23,11 @@ #ifndef GRABAG__FILE_H #define GRABAG__FILE_H +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for off_t */ #include /* for FILE */ #include "FLAC/ordinals.h" diff --git a/src/flac/analyze.c b/src/flac/analyze.c index 614b4d25..207543e7 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -16,6 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include #include #include #include @@ -208,7 +213,7 @@ FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename) outfile = fopen(filename, "w"); if(0 == outfile) { - fprintf(stderr, "ERROR opening %s\n", filename); + fprintf(stderr, "ERROR opening %s: %s\n", filename, strerror(errno)); return false; } diff --git a/src/flac/decode.c b/src/flac/decode.c index 920f89e7..5940ab98 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H -#include +#if HAVE_CONFIG_H +# include #endif #if defined _WIN32 && !defined __CYGWIN__ @@ -26,10 +26,16 @@ #else # include #endif +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include #include /* for floor() */ -#include /* for FILE et al. */ -#include /* for strcmp() */ +#include /* for FILE etc. */ +#include /* for strcmp(), strerror() */ #include "FLAC/all.h" #include "share/grabbag.h" #include "share/replaygain_synthesis.h" @@ -72,9 +78,9 @@ typedef struct { struct { FLAC__bool needs_fixup; - unsigned riff_offset; /* or FORM offset for AIFF */ - unsigned data_offset; /* or SSND offset for AIFF */ - unsigned frames_offset; /* AIFF only */ + off_t riff_offset; /* or FORM offset for AIFF */ + off_t data_offset; /* or SSND offset for AIFF */ + off_t frames_offset; /* AIFF only */ } wave_chunk_size_fixup; FLAC__bool is_big_endian; @@ -292,7 +298,7 @@ FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__ } else { if(0 == (d->fout = fopen(outfilename, "wb"))) { - flac__utils_printf(stderr, 1, "%s: ERROR: can't open output file %s\n", d->inbasefilename, outfilename); + flac__utils_printf(stderr, 1, "%s: ERROR: can't open output file %s: %s\n", d->inbasefilename, outfilename, strerror(errno)); DecoderSession_destroy(d, /*error_occurred=*/true); return false; } @@ -639,7 +645,7 @@ FLAC__bool write_necessary_headers(DecoderSession *decoder_session) return false; if(decoder_session->wave_chunk_size_fixup.needs_fixup) - decoder_session->wave_chunk_size_fixup.riff_offset = ftell(decoder_session->fout); + decoder_session->wave_chunk_size_fixup.riff_offset = ftello(decoder_session->fout); if(!write_little_endian_uint32(decoder_session->fout, aligned_data_size+36)) /* filesize-8 */ return false; @@ -672,7 +678,7 @@ FLAC__bool write_necessary_headers(DecoderSession *decoder_session) return false; if(decoder_session->wave_chunk_size_fixup.needs_fixup) - decoder_session->wave_chunk_size_fixup.data_offset = ftell(decoder_session->fout); + decoder_session->wave_chunk_size_fixup.data_offset = ftello(decoder_session->fout); if(!write_little_endian_uint32(decoder_session->fout, (FLAC__uint32)data_size)) /* data size */ return false; @@ -682,7 +688,7 @@ FLAC__bool write_necessary_headers(DecoderSession *decoder_session) return false; if(decoder_session->wave_chunk_size_fixup.needs_fixup) - decoder_session->wave_chunk_size_fixup.riff_offset = ftell(decoder_session->fout); + decoder_session->wave_chunk_size_fixup.riff_offset = ftello(decoder_session->fout); if(!write_big_endian_uint32(decoder_session->fout, aligned_data_size+46)) /* filesize-8 */ return false; @@ -697,7 +703,7 @@ FLAC__bool write_necessary_headers(DecoderSession *decoder_session) return false; if(decoder_session->wave_chunk_size_fixup.needs_fixup) - decoder_session->wave_chunk_size_fixup.frames_offset = ftell(decoder_session->fout); + decoder_session->wave_chunk_size_fixup.frames_offset = ftello(decoder_session->fout); if(!write_big_endian_uint32(decoder_session->fout, (FLAC__uint32)decoder_session->total_samples)) return false; @@ -712,7 +718,7 @@ FLAC__bool write_necessary_headers(DecoderSession *decoder_session) return false; if(decoder_session->wave_chunk_size_fixup.needs_fixup) - decoder_session->wave_chunk_size_fixup.data_offset = ftell(decoder_session->fout); + decoder_session->wave_chunk_size_fixup.data_offset = ftello(decoder_session->fout); if(!write_big_endian_uint32(decoder_session->fout, (FLAC__uint32)data_size+8)) /* data size */ return false; @@ -805,11 +811,11 @@ FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out { const char *fmt_desc = (is_wave_out? "WAVE" : "AIFF"); FLAC__bool (*write_it)(FILE *, FLAC__uint32) = (is_wave_out? write_little_endian_uint32 : write_big_endian_uint32); - FILE *f = fopen(outfilename, "r+b"); FLAC__uint32 data_size, aligned_data_size; + FILE *f = fopen(outfilename, "r+b"); if(0 == f) { - flac__utils_printf(stderr, 1, "ERROR, couldn't open file %s while fixing up %s chunk size\n", outfilename, fmt_desc); + flac__utils_printf(stderr, 1, "ERROR, couldn't open file %s while fixing up %s chunk size: %s\n", outfilename, fmt_desc, strerror(errno)); return false; } @@ -817,7 +823,7 @@ FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out if(aligned_data_size & 1) aligned_data_size++; - if(fseek(f, riff_offset, SEEK_SET) < 0) { + if(fseeko(f, riff_offset, SEEK_SET) < 0) { flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc); fclose(f); return false; @@ -828,7 +834,7 @@ FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out return false; } if(!is_wave_out) { - if(fseek(f, frames_offset, SEEK_SET) < 0) { + if(fseeko(f, frames_offset, SEEK_SET) < 0) { flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc); fclose(f); return false; @@ -839,7 +845,7 @@ FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out return false; } } - if(fseek(f, data_offset, SEEK_SET) < 0) { + if(fseeko(f, data_offset, SEEK_SET) < 0) { flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc); fclose(f); return false; diff --git a/src/flac/encode.c b/src/flac/encode.c index 61d1b030..8d421483 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -16,25 +16,32 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #if defined _WIN32 && !defined __CYGWIN__ /* where MSVC puts unlink() */ # include #else # include #endif +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif +#include #include /* for LONG_MAX */ #include /* for floor() */ #include /* for FILE etc. */ #include /* for malloc */ -#include /* for strcmp() */ +#include /* for strcmp(), strerror( */ #include "FLAC/all.h" #include "share/grabbag.h" #include "encode.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef FLAC__HAS_OGG #include "OggFLAC/stream_encoder.h" #include "OggFLAC/file_encoder.h" @@ -160,7 +167,7 @@ static FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset); /* * public routines */ -int flac__encode_aif(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options, FLAC__bool is_aifc) +int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options, FLAC__bool is_aifc) { EncoderSession encoder_session; FLAC__uint16 x; @@ -525,7 +532,7 @@ int flac__encode_aif(FILE *infile, long infilesize, const char *infilename, cons return EncoderSession_finish_ok(&encoder_session, info_align_carry, info_align_zero); } -int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options) +int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options) { EncoderSession encoder_session; FLAC__bool is_unsigned_samples = false; @@ -860,7 +867,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons return EncoderSession_finish_ok(&encoder_session, info_align_carry, info_align_zero); } -int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, raw_encode_options_t options) +int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, raw_encode_options_t options) { EncoderSession encoder_session; size_t bytes_read; @@ -906,7 +913,7 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons else { /* *options.common.align_reservoir_samples will be 0 unless --sector-align is used */ FLAC__ASSERT(options.common.sector_align || *options.common.align_reservoir_samples == 0); - total_samples_in_input = (unsigned)infilesize / bytes_per_wide_sample + *options.common.align_reservoir_samples; + total_samples_in_input = (FLAC__uint64)infilesize / bytes_per_wide_sample + *options.common.align_reservoir_samples; } /* @@ -918,13 +925,13 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons encoder_session.until = (FLAC__uint64)options.common.until_specification.value.samples; FLAC__ASSERT(!options.common.sector_align || encoder_session.until == 0); - infilesize -= (unsigned)encoder_session.skip * bytes_per_wide_sample; /*@@@ WATCHOUT: 4GB limit */ + infilesize -= (off_t)encoder_session.skip * bytes_per_wide_sample; encoder_session.total_samples_to_encode = total_samples_in_input - encoder_session.skip; if(encoder_session.until > 0) { const FLAC__uint64 trim = total_samples_in_input - encoder_session.until; FLAC__ASSERT(total_samples_in_input > 0); FLAC__ASSERT(!options.common.sector_align); - infilesize -= (unsigned int)trim * bytes_per_wide_sample; + infilesize -= (off_t)trim * bytes_per_wide_sample; encoder_session.total_samples_to_encode -= trim; } if(infilesize >= 0 && options.common.sector_align) { @@ -979,7 +986,7 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons } else { *options.common.align_reservoir_samples = align_remainder; - infilesize -= (long)((*options.common.align_reservoir_samples) * bytes_per_wide_sample); + infilesize -= (off_t)((*options.common.align_reservoir_samples) * bytes_per_wide_sample); FLAC__ASSERT(infilesize >= 0); } } @@ -1024,7 +1031,7 @@ int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, cons } } else { - const FLAC__uint64 max_input_bytes = (FLAC__uint64)infilesize; + const FLAC__uint64 max_input_bytes = infilesize; FLAC__uint64 total_input_bytes_read = 0; while(total_input_bytes_read < max_input_bytes) { { @@ -1858,7 +1865,7 @@ FLAC__bool parse_cuesheet_(FLAC__StreamMetadata **cuesheet, const char *cuesheet } if(0 == (f = fopen(cuesheet_filename, "r"))) { - flac__utils_printf(stderr, 1, "%s: ERROR opening cuesheet \"%s\" for reading\n", inbasefilename, cuesheet_filename); + flac__utils_printf(stderr, 1, "%s: ERROR opening cuesheet \"%s\" for reading: %s\n", inbasefilename, cuesheet_filename, strerror(errno)); return false; } @@ -2143,7 +2150,7 @@ FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset) while(offset > 0) { long need = (long)min(offset, LONG_MAX); - if(fseek(f, need, SEEK_CUR) < 0) { + if(fseeko(f, need, SEEK_CUR) < 0) { need = (long)min(offset, sizeof(dump)); if((long)fread(dump, 1, need, f) < need) return false; diff --git a/src/flac/encode.h b/src/flac/encode.h index 40739d62..cfda5434 100644 --- a/src/flac/encode.h +++ b/src/flac/encode.h @@ -19,6 +19,11 @@ #ifndef flac__encode_h #define flac__encode_h +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/metadata.h" #include "utils.h" @@ -84,8 +89,8 @@ typedef struct { unsigned sample_rate; } raw_encode_options_t; -int flac__encode_aif(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options, FLAC__bool is_aifc); -int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options); -int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, raw_encode_options_t options); +int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options, FLAC__bool is_aifc); +int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, wav_encode_options_t options); +int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, raw_encode_options_t options); #endif diff --git a/src/flac/local_string_utils.c b/src/flac/local_string_utils.c index 9b0d49f1..1d78d18e 100644 --- a/src/flac/local_string_utils.c +++ b/src/flac/local_string_utils.c @@ -1,6 +1,10 @@ /* flac - Command-line FLAC encoder/decoder */ +#if HAVE_CONFIG_H +# include +#endif + #include #include "utils.h" diff --git a/src/flac/main.c b/src/flac/main.c index 7c947629..14db8daf 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -16,7 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include +#include #include #include #include @@ -24,10 +29,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #if !defined _MSC_VER && !defined __MINGW32__ /* unlink is in stdio.h in VC++ */ #include /* for unlink() */ @@ -245,7 +246,7 @@ static struct { int format_channels; int format_bps; int format_sample_rate; - long format_input_size; + off_t format_input_size; int blocksize; int min_residual_partition_order; int max_residual_partition_order; @@ -591,7 +592,7 @@ FLAC__bool init_options() option_values.format_channels = -1; option_values.format_bps = -1; option_values.format_sample_rate = -1; - option_values.format_input_size = -1; + option_values.format_input_size = (off_t)(-1); option_values.blocksize = -1; option_values.min_residual_partition_order = -1; option_values.max_residual_partition_order = -1; @@ -682,7 +683,23 @@ int parse_option(int short_option, const char *long_option, const char *option_a } else if(0 == strcmp(long_option, "input-size")) { FLAC__ASSERT(0 != option_argument); - option_values.format_input_size = atol(option_argument); + { + char *end; +#ifdef _MSC_VER + FLAC__int64 i; + i = strtol(option_argument, &end, 10); /* [2G limit] */ +#else + long long i; + i = strtoll(option_argument, &end, 10); +#endif + if(0 == strlen(option_argument) || *end) + return usage_error("ERROR: --%s must be a number\n", long_option); + option_values.format_input_size = (off_t)i; + if(option_values.format_input_size != i) /* check if off_t is smaller than long long */ + return usage_error("ERROR: --%s too large; this flac does not support filesizes over 2GB\n", long_option); + if(option_values.format_input_size <= 0) + return usage_error("ERROR: --%s must be > 0\n", long_option); + } } else if(0 == strcmp(long_option, "cue")) { FLAC__ASSERT(0 != option_argument); @@ -1533,7 +1550,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ FileFormat fmt = RAW; FLAC__bool is_aifc = false; int retval; - long infilesize; + off_t infilesize; encode_options_t common_options; const char *outfilename = get_encoded_outfilename(infilename); @@ -1552,13 +1569,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ } if(0 == strcmp(infilename, "-")) { - infilesize = -1; + infilesize = (off_t)(-1); encode_infile = grabbag__file_get_binary_stdin(); } else { infilesize = grabbag__file_get_filesize(infilename); if(0 == (encode_infile = fopen(infilename, "rb"))) { - flac__utils_printf(stderr, 1, "ERROR: can't open input file %s\n", infilename); + flac__utils_printf(stderr, 1, "ERROR: can't open input file %s: %s\n", infilename, strerror(errno)); return 1; } } diff --git a/src/libFLAC/bitbuffer.c b/src/libFLAC/bitbuffer.c index b120de43..f6b1b74f 100644 --- a/src/libFLAC/bitbuffer.c +++ b/src/libFLAC/bitbuffer.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for malloc() */ #include /* for memcpy(), memset() */ #include "private/bitbuffer.h" diff --git a/src/libFLAC/bitmath.c b/src/libFLAC/bitmath.c index bad52e76..a3e8b373 100644 --- a/src/libFLAC/bitmath.c +++ b/src/libFLAC/bitmath.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "private/bitmath.h" #include "FLAC/assert.h" diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c index 3bb8ff3b..de2bb2a3 100644 --- a/src/libFLAC/cpu.c +++ b/src/libFLAC/cpu.c @@ -29,14 +29,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "private/cpu.h" #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #if defined FLAC__CPU_PPC # if !defined FLAC__NO_ASM # if defined FLAC__SYS_DARWIN diff --git a/src/libFLAC/crc.c b/src/libFLAC/crc.c index dbe7f037..1d31ca32 100644 --- a/src/libFLAC/crc.c +++ b/src/libFLAC/crc.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "private/crc.h" /* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ diff --git a/src/libFLAC/file_decoder.c b/src/libFLAC/file_decoder.c index d2e7de44..6e499edd 100644 --- a/src/libFLAC/file_decoder.c +++ b/src/libFLAC/file_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ #include /* for strcmp() */ @@ -36,6 +40,10 @@ #if defined _MSC_VER || defined __MINGW32__ #include /* for _setmode() */ #include /* for _O_BINARY */ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell #elif defined __CYGWIN__ #include /* for setmode(), O_BINARY */ #include /* for _O_BINARY */ @@ -606,7 +614,7 @@ FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const FLAC__SeekableStreamD FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; (void)decoder; - if(fseek(file_decoder->private_->file, (long)absolute_byte_offset, SEEK_SET) < 0) + if(fseeko(file_decoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; else return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; @@ -615,10 +623,10 @@ FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const FLAC__SeekableStreamD FLAC__SeekableStreamDecoderTellStatus tell_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; - long pos; + off_t pos; (void)decoder; - if((pos = ftell(file_decoder->private_->file)) < 0) + if((pos = ftello(file_decoder->private_->file)) < 0) return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; else { *absolute_byte_offset = (FLAC__uint64)pos; diff --git a/src/libFLAC/file_encoder.c b/src/libFLAC/file_encoder.c index 2501779f..3469bfd9 100644 --- a/src/libFLAC/file_encoder.c +++ b/src/libFLAC/file_encoder.c @@ -29,9 +29,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ #include /* for strlen(), strcpy() */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "FLAC/assert.h" #include "protected/file_encoder.h" @@ -724,7 +734,7 @@ FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamE FLAC__ASSERT(0 != file_encoder); - if(fseek(file_encoder->private_->file, (long)absolute_byte_offset, SEEK_SET) < 0) + if(fseeko(file_encoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR; else return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK; @@ -733,13 +743,13 @@ FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamE FLAC__SeekableStreamEncoderTellStatus tell_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { FLAC__FileEncoder *file_encoder = (FLAC__FileEncoder*)client_data; - long offset; + off_t offset; (void)encoder; FLAC__ASSERT(0 != file_encoder); - offset = ftell(file_encoder->private_->file); + offset = ftello(file_encoder->private_->file); if(offset < 0) { return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_ERROR; diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index d6833529..d432962a 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include "private/bitmath.h" #include "private/fixed.h" diff --git a/src/libFLAC/float.c b/src/libFLAC/float.c index 534aa8d4..7c58f651 100644 --- a/src/libFLAC/float.c +++ b/src/libFLAC/float.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/assert.h" #include "private/float.h" diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index 199053bc..b5dfcaac 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -29,16 +29,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for qsort() */ #include "FLAC/assert.h" #include "FLAC/format.h" #include "private/format.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef min #undef min #endif diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c index 14099da9..ab73d0ba 100644 --- a/src/libFLAC/lpc.c +++ b/src/libFLAC/lpc.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include "FLAC/assert.h" #include "FLAC/format.h" diff --git a/src/libFLAC/md5.c b/src/libFLAC/md5.c index 9679387d..5ea127a8 100644 --- a/src/libFLAC/md5.c +++ b/src/libFLAC/md5.c @@ -23,15 +23,15 @@ * Still in the public domain. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for malloc() */ #include /* for memcpy() */ #include "private/md5.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifndef FLaC__INLINE #define FLaC__INLINE #endif diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c index 287a74c4..956cb296 100644 --- a/src/libFLAC/memory.c +++ b/src/libFLAC/memory.c @@ -29,13 +29,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "private/memory.h" #include "FLAC/assert.h" -#ifdef HAVE_CONFIG_H -#include -#endif - void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) { void *x; diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index 88d72277..525b7597 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -37,6 +41,10 @@ #if defined _MSC_VER || defined __MINGW32__ #include /* for utime() */ #include /* for chmod() */ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell #else #include /* some flavors of BSD (like OS X) require this to get time_t */ #include /* for utime() */ @@ -109,10 +117,10 @@ static unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IO static unsigned seek_to_first_metadata_block_(FILE *f); static FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append); -static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, long fixup_is_last_flag_offset, FLAC__bool backup); +static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, off_t fixup_is_last_flag_offset, FLAC__bool backup); -static FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, unsigned bytes/*@@@ 4G limit*/, FLAC__Metadata_SimpleIteratorStatus *status); -static FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, unsigned bytes/*@@@ 4G limit*/, FLAC__Metadata_SimpleIteratorStatus *status); +static FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status); +static FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status); static FLAC__bool copy_remaining_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__Metadata_SimpleIteratorStatus *status); static FLAC__bool copy_remaining_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__Metadata_SimpleIteratorStatus *status); @@ -288,9 +296,8 @@ struct FLAC__Metadata_SimpleIterator { FLAC__bool has_stats; FLAC__bool is_writable; FLAC__Metadata_SimpleIteratorStatus status; - /*@@@ 2G limits here because of the offset type: */ - long offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH]; - long first_offset; /* this is the offset to the STREAMINFO block */ + off_t offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH]; + off_t first_offset; /* this is the offset to the STREAMINFO block */ unsigned depth; /* this is the metadata block header of the current block we are pointing to: */ FLAC__bool is_last; @@ -399,7 +406,7 @@ static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *it switch(ret) { case 0: iterator->depth = 0; - iterator->first_offset = iterator->offset[iterator->depth] = ftell(iterator->file); + iterator->first_offset = iterator->offset[iterator->depth] = ftello(iterator->file); return read_metadata_block_header_(iterator); case 1: iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; @@ -474,19 +481,19 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIte if(iterator->is_last) return false; - if(0 != fseek(iterator->file, iterator->length, SEEK_CUR)) { + if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } - iterator->offset[iterator->depth] = ftell(iterator->file); + iterator->offset[iterator->depth] = ftello(iterator->file); return read_metadata_block_header_(iterator); } FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator) { - long this_offset; + off_t this_offset; FLAC__ASSERT(0 != iterator); FLAC__ASSERT(0 != iterator->file); @@ -494,7 +501,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIte if(iterator->offset[iterator->depth] == iterator->first_offset) return false; - if(0 != fseek(iterator->file, iterator->first_offset, SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->first_offset, SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -502,13 +509,13 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIte if(!read_metadata_block_header_(iterator)) return false; - /* we ignore any error from ftell() and catch it in fseek() */ - while(ftell(iterator->file) + (long)iterator->length < iterator->offset[iterator->depth]) { - if(0 != fseek(iterator->file, iterator->length, SEEK_CUR)) { + /* we ignore any error from ftello() and catch it in fseeko() */ + while(ftello(iterator->file) + (off_t)iterator->length < iterator->offset[iterator->depth]) { + if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } - this_offset = ftell(iterator->file); + this_offset = ftello(iterator->file); if(!read_metadata_block_header_(iterator)) return false; } @@ -543,7 +550,7 @@ FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Me } /* back up to the beginning of the block data to stay consistent */ - if(0 != fseek(iterator->file, iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH, SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH, SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; FLAC__metadata_object_delete(block); return 0; @@ -557,7 +564,7 @@ FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Me FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding) { - FLAC__ASSERT_DECLARATION(long debug_target_offset = iterator->offset[iterator->depth];) + FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth];) FLAC__bool ret; FLAC__ASSERT(0 != iterator); @@ -584,13 +591,13 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp if(use_padding && iterator->length >= FLAC__STREAM_METADATA_HEADER_LENGTH + block->length) { ret = write_metadata_block_stationary_with_padding_(iterator, block, iterator->length - FLAC__STREAM_METADATA_HEADER_LENGTH - block->length, block->is_last); FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } else { ret = rewrite_whole_file_(iterator, block, /*append=*/false); FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } } @@ -633,21 +640,21 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp if(padding_leftover == 0) { ret = write_metadata_block_stationary_(iterator, block); FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } else { FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH); ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last); FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } } else { ret = rewrite_whole_file_(iterator, block, /*append=*/false); FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(!ret || ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } } @@ -658,7 +665,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Meta unsigned padding_leftover = 0; FLAC__bool padding_is_last = false; - FLAC__ASSERT_DECLARATION(long debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;) + FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;) FLAC__bool ret; FLAC__ASSERT(0 != iterator); @@ -713,28 +720,28 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Meta if(padding_leftover == 0) { ret = write_metadata_block_stationary_(iterator, block); FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } else { FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH); ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last); FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } } else { ret = rewrite_whole_file_(iterator, block, /*append=*/true); FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset); - FLAC__ASSERT(ftell(iterator->file) == debug_target_offset + (long)FLAC__STREAM_METADATA_HEADER_LENGTH); + FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH); return ret; } } FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding) { - FLAC__ASSERT_DECLARATION(long debug_target_offset = iterator->offset[iterator->depth];) + FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth];) FLAC__bool ret; if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO) { @@ -756,14 +763,14 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_S FLAC__metadata_object_delete(padding); if(!FLAC__metadata_simple_iterator_prev(iterator)) return false; - FLAC__ASSERT(iterator->offset[iterator->depth] + (long)FLAC__STREAM_METADATA_HEADER_LENGTH + (long)iterator->length == debug_target_offset); - FLAC__ASSERT(ftell(iterator->file) + (long)iterator->length == debug_target_offset); + FLAC__ASSERT(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length == debug_target_offset); + FLAC__ASSERT(ftello(iterator->file) + (off_t)iterator->length == debug_target_offset); return true; } else { ret = rewrite_whole_file_(iterator, 0, /*append=*/false); - FLAC__ASSERT(iterator->offset[iterator->depth] + (long)FLAC__STREAM_METADATA_HEADER_LENGTH + (long)iterator->length == debug_target_offset); - FLAC__ASSERT(ftell(iterator->file) + (long)iterator->length == debug_target_offset); + FLAC__ASSERT(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length == debug_target_offset); + FLAC__ASSERT(ftello(iterator->file) + (off_t)iterator->length == debug_target_offset); return ret; } } @@ -788,13 +795,13 @@ struct FLAC__Metadata_Chain { FLAC__Metadata_Node *tail; unsigned nodes; FLAC__Metadata_ChainStatus status; - long first_offset, last_offset; /*@@@ 2G limit */ + off_t first_offset, last_offset; /* * This is the length of the chain initially read from the FLAC file. * it is used to compare against the current length to decide whether * or not the whole file has to be rewritten. */ - unsigned initial_length; /*@@@ 4G limit */ + off_t initial_length; }; struct FLAC__Metadata_Iterator { @@ -913,10 +920,10 @@ static void chain_delete_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node node_delete_(node); } -static unsigned chain_calculate_length_(FLAC__Metadata_Chain *chain) +static off_t chain_calculate_length_(FLAC__Metadata_Chain *chain) { const FLAC__Metadata_Node *node; - unsigned length = 0; + off_t length = 0; for(node = chain->head; node; node = node->next) length += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length); return length; @@ -995,20 +1002,20 @@ static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLA /* WATCHOUT: Make sure to also update the logic in * FLAC__metadata_chain_check_if_tempfile_needed() if the logic here changes. */ -static unsigned chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) +static off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) { - unsigned current_length = chain_calculate_length_(chain); + off_t current_length = chain_calculate_length_(chain); if(use_padding) { /* if the metadata shrank and the last block is padding, we just extend the last padding block */ if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { - const unsigned delta = chain->initial_length - current_length; + const off_t delta = chain->initial_length - current_length; chain->tail->data->length += delta; current_length += delta; FLAC__ASSERT(current_length == chain->initial_length); } /* if the metadata shrank more than 4 bytes then there's room to add another padding block */ - else if(current_length + FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) { + else if(current_length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) { FLAC__StreamMetadata *padding; FLAC__Metadata_Node *node; if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) { @@ -1028,16 +1035,16 @@ static unsigned chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool } /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */ else if(current_length > chain->initial_length) { - const unsigned delta = current_length - chain->initial_length; + const off_t delta = current_length - chain->initial_length; if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { /* if the delta is exactly the size of the last padding block, remove the padding block */ - if(chain->tail->data->length + FLAC__STREAM_METADATA_HEADER_LENGTH == delta) { + if((off_t)chain->tail->data->length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) { chain_delete_node_(chain, chain->tail); current_length = chain_calculate_length_(chain); FLAC__ASSERT(current_length == chain->initial_length); } /* if there is at least 'delta' bytes of padding, trim the padding down */ - else if(chain->tail->data->length >= delta) { + else if((off_t)chain->tail->data->length >= delta) { chain->tail->data->length -= delta; current_length -= delta; FLAC__ASSERT(current_length == chain->initial_length); @@ -1080,7 +1087,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; return false; } - chain->first_offset = (long)pos; + chain->first_offset = (off_t)pos; } { @@ -1125,7 +1132,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR; return false; } - chain->last_offset = (long)pos; + chain->last_offset = (off_t)pos; } chain->initial_length = chain_calculate_length_(chain); @@ -1156,7 +1163,7 @@ static FLAC__bool chain_rewrite_metadata_in_place_cb_(FLAC__Metadata_Chain *chai } } - /*FLAC__ASSERT(fflush(), ftell() == chain->last_offset);*/ + /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ chain->status = FLAC__METADATA_CHAIN_STATUS_OK; return true; @@ -1220,10 +1227,10 @@ static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *t return false; } } - /*FLAC__ASSERT(fflush(), ftell() == chain->last_offset);*/ + /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ /* copy the file postfix (everything after the metadata) */ - if(0 != fseek(f, chain->last_offset, SEEK_SET)) { + if(0 != fseeko(f, chain->last_offset, SEEK_SET)) { cleanup_tempfile_(&tempfile, &tempfilename); chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR; return false; @@ -1269,7 +1276,7 @@ static FLAC__bool chain_rewrite_file_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHa return false; } } - /*FLAC__ASSERT(fflush(), ftell() == chain->last_offset);*/ + /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/ /* copy the file postfix (everything after the metadata) */ if(0 != seek_cb(handle, chain->last_offset, SEEK_SET)) { @@ -1371,7 +1378,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata * but doesn't actually alter the chain. Make sure to update the logic * here if chain_prepare_for_write_() changes. */ - const unsigned current_length = chain_calculate_length_(chain); + const off_t current_length = chain_calculate_length_(chain); FLAC__ASSERT(0 != chain); @@ -1380,17 +1387,17 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) return false; /* if the metadata shrank more than 4 bytes then there's room to add another padding block */ - else if(current_length + FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) + else if(current_length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) return false; /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */ else if(current_length > chain->initial_length) { - const unsigned delta = current_length - chain->initial_length; + const off_t delta = current_length - chain->initial_length; if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) { /* if the delta is exactly the size of the last padding block, remove the padding block */ - if(chain->tail->data->length + FLAC__STREAM_METADATA_HEADER_LENGTH == delta) + if((off_t)chain->tail->data->length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) return false; /* if there is at least 'delta' bytes of padding, trim the padding down */ - else if(chain->tail->data->length >= delta) + else if((off_t)chain->tail->data->length >= delta) return false; } } @@ -1403,7 +1410,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC { struct stat stats; const char *tempfile_path_prefix = 0; - unsigned current_length; + off_t current_length; FLAC__ASSERT(0 != chain); @@ -1447,7 +1454,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks) { - unsigned current_length; + off_t current_length; FLAC__ASSERT(0 != chain); @@ -1479,7 +1486,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Cha FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks) { - unsigned current_length; + off_t current_length; FLAC__ASSERT(0 != chain); @@ -2410,7 +2417,7 @@ FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IO FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block) { - if(0 != fseek(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2421,7 +2428,7 @@ FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *itera if(!write_metadata_block_data_(iterator->file, &iterator->status, block)) return false; - if(0 != fseek(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2433,7 +2440,7 @@ FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIt { FLAC__StreamMetadata *padding; - if(0 != fseek(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2464,7 +2471,7 @@ FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIt FLAC__metadata_object_delete(padding); - if(0 != fseek(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2477,7 +2484,7 @@ FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__St FILE *tempfile; char *tempfilename; int fixup_is_last_code = 0; /* 0 => no need to change any is_last flags */ - long fixup_is_last_flag_offset = -1; + off_t fixup_is_last_flag_offset = -1; FLAC__ASSERT(0 != block || append == false); @@ -2534,7 +2541,7 @@ FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator) { FLAC__ASSERT(iterator->depth > 0); iterator->depth--; - if(0 != fseek(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { + if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2605,9 +2612,9 @@ unsigned seek_to_first_metadata_block_(FILE *f) FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append) { - const long offset_end = append? iterator->offset[iterator->depth] + (long)FLAC__STREAM_METADATA_HEADER_LENGTH + (long)iterator->length : iterator->offset[iterator->depth]; + const off_t offset_end = append? iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length : iterator->offset[iterator->depth]; - if(0 != fseek(iterator->file, 0, SEEK_SET)) { + if(0 != fseeko(iterator->file, 0, SEEK_SET)) { iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; } @@ -2623,12 +2630,12 @@ FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iter return true; } -FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, long fixup_is_last_flag_offset, FLAC__bool backup) +FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, off_t fixup_is_last_flag_offset, FLAC__bool backup) { - long save_offset = iterator->offset[iterator->depth]; /*@@@ 2G limit */ + off_t save_offset = iterator->offset[iterator->depth]; FLAC__ASSERT(0 != *tempfile); - if(0 != fseek(iterator->file, save_offset + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length, SEEK_SET)) { + if(0 != fseeko(iterator->file, save_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length, SEEK_SET)) { cleanup_tempfile_(tempfile, tempfilename); iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; @@ -2647,7 +2654,7 @@ FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *ite */ /* MAGIC NUMBERs here; we know the is_last flag is the high bit of the byte at this location */ FLAC__byte x; - if(0 != fseek(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { + if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { cleanup_tempfile_(tempfile, tempfilename); iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; @@ -2665,7 +2672,7 @@ FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *ite FLAC__ASSERT(!(x & 0x80)); x |= 0x80; } - if(0 != fseek(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { + if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { cleanup_tempfile_(tempfile, tempfilename); iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR; return false; @@ -2688,7 +2695,7 @@ FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *ite if(!simple_iterator_prime_input_(iterator, !iterator->is_writable)) return false; if(backup) { - while(iterator->offset[iterator->depth] + (long)FLAC__STREAM_METADATA_HEADER_LENGTH + (long)iterator->length < save_offset) + while(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length < save_offset) if(!FLAC__metadata_simple_iterator_next(iterator)) return false; return true; @@ -2702,10 +2709,10 @@ FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *ite } } -FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, unsigned bytes/*@@@ 4G limit*/, FLAC__Metadata_SimpleIteratorStatus *status) +FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status) { FLAC__byte buffer[8192]; - unsigned n; + size_t n; while(bytes > 0) { n = min(sizeof(buffer), bytes); @@ -2723,10 +2730,10 @@ FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, unsigned bytes/*@ return true; } -FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, unsigned bytes/*@@@ 4G limit*/, FLAC__Metadata_SimpleIteratorStatus *status) +FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status) { FLAC__byte buffer[8192]; - unsigned n; + size_t n; while(bytes > 0) { n = min(sizeof(buffer), bytes); @@ -2890,20 +2897,14 @@ void set_file_stats_(const char *filename, struct stat *stats) #endif } -/* @@@ WATCHOUT @@@ - * We cast FLAC__int64 to long and use fseek()/ftell() because - * none of our operations on metadata is ever likely to go past - * 2 gigabytes. - */ int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence) { - FLAC__ASSERT(offset <= 0x7fffffff); - return fseek((FILE*)handle, (long)offset, whence); + return fseeko((FILE*)handle, (off_t)offset, whence); } FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle) { - return (long)ftell((FILE*)handle); + return ftello((FILE*)handle); } FLAC__Metadata_ChainStatus get_equivalent_status_(FLAC__Metadata_SimpleIteratorStatus status) diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index a192aff2..521a49b6 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include diff --git a/src/libFLAC/seekable_stream_decoder.c b/src/libFLAC/seekable_stream_decoder.c index 7db83096..c301d1f7 100644 --- a/src/libFLAC/seekable_stream_decoder.c +++ b/src/libFLAC/seekable_stream_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for calloc() */ #include /* for memcpy()/memcmp() */ diff --git a/src/libFLAC/seekable_stream_encoder.c b/src/libFLAC/seekable_stream_encoder.c index 771c085d..b943db7c 100644 --- a/src/libFLAC/seekable_stream_encoder.c +++ b/src/libFLAC/seekable_stream_encoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for calloc() */ #include /* for memcpy() */ diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index e0fd36a5..657ece35 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ #include /* for memset/memcpy() */ @@ -43,10 +47,6 @@ #include "private/lpc.h" #include "private/memory.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef max #undef max #endif diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index 2ff2f1cf..6ecb8728 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -32,6 +32,10 @@ /*@@@@@@*/ #undef WINDOW_DEBUG_OUTPUT +#if HAVE_CONFIG_H +# include +#endif + #include #include #include /* for malloc() */ @@ -51,10 +55,6 @@ #include "private/stream_encoder_framing.h" #include "private/window.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef min #undef min #endif diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c index 311dd31d..87611b7b 100644 --- a/src/libFLAC/stream_encoder_framing.c +++ b/src/libFLAC/stream_encoder_framing.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for strlen() */ #include "private/stream_encoder_framing.h" diff --git a/src/libFLAC/window.c b/src/libFLAC/window.c index a13a21f9..04cd662c 100644 --- a/src/libFLAC/window.c +++ b/src/libFLAC/window.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include "FLAC/assert.h" #include "FLAC/format.h" diff --git a/src/libOggFLAC/file_decoder.c b/src/libOggFLAC/file_decoder.c index 3e8d372f..926f6bc0 100644 --- a/src/libOggFLAC/file_decoder.c +++ b/src/libOggFLAC/file_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ #include /* for strcmp() */ @@ -36,6 +40,10 @@ #if defined _MSC_VER || defined __MINGW32__ #include /* for _setmode() */ #include /* for _O_BINARY */ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell #elif defined __CYGWIN__ #include /* for setmode(), O_BINARY */ #include /* for _O_BINARY */ @@ -597,7 +605,7 @@ OggFLAC__SeekableStreamDecoderSeekStatus seek_callback_(const OggFLAC__SeekableS OggFLAC__FileDecoder *file_decoder = (OggFLAC__FileDecoder *)client_data; (void)decoder; - if(fseek(file_decoder->private_->file, (long)absolute_byte_offset, SEEK_SET) < 0) + if(fseeko(file_decoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; else return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; @@ -606,10 +614,10 @@ OggFLAC__SeekableStreamDecoderSeekStatus seek_callback_(const OggFLAC__SeekableS OggFLAC__SeekableStreamDecoderTellStatus tell_callback_(const OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { OggFLAC__FileDecoder *file_decoder = (OggFLAC__FileDecoder *)client_data; - long pos; + off_t pos; (void)decoder; - if((pos = ftell(file_decoder->private_->file)) < 0) + if((pos = ftello(file_decoder->private_->file)) < 0) return OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; else { *absolute_byte_offset = (FLAC__uint64)pos; diff --git a/src/libOggFLAC/file_encoder.c b/src/libOggFLAC/file_encoder.c index b16c5814..e9e2821a 100644 --- a/src/libOggFLAC/file_encoder.c +++ b/src/libOggFLAC/file_encoder.c @@ -29,9 +29,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ #include /* for strlen(), strcpy() */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "FLAC/assert.h" #include "OggFLAC/seekable_stream_encoder.h" #include "protected/file_encoder.h" @@ -756,7 +766,7 @@ FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const OggFLAC__SeekableStre FLAC__ASSERT(0 != file_encoder); - if(fseek(file_encoder->private_->file, (long)absolute_byte_offset, SEEK_SET) < 0) + if(fseeko(file_encoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR; else return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK; @@ -765,13 +775,13 @@ FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const OggFLAC__SeekableStre FLAC__SeekableStreamEncoderTellStatus tell_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { OggFLAC__FileEncoder *file_encoder = (OggFLAC__FileEncoder*)client_data; - long offset; + off_t offset; (void)encoder; FLAC__ASSERT(0 != file_encoder); - offset = ftell(file_encoder->private_->file); + offset = ftello(file_encoder->private_->file); if(offset < 0) { return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_ERROR; diff --git a/src/libOggFLAC/ogg_decoder_aspect.c b/src/libOggFLAC/ogg_decoder_aspect.c index 14b6f1ef..06e2852e 100644 --- a/src/libOggFLAC/ogg_decoder_aspect.c +++ b/src/libOggFLAC/ogg_decoder_aspect.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for memcpy() */ #include "FLAC/assert.h" #include "private/ogg_decoder_aspect.h" diff --git a/src/libOggFLAC/ogg_encoder_aspect.c b/src/libOggFLAC/ogg_encoder_aspect.c index 97d4bc02..0ca9eed6 100644 --- a/src/libOggFLAC/ogg_encoder_aspect.c +++ b/src/libOggFLAC/ogg_encoder_aspect.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for memset() */ #include "FLAC/assert.h" #include "private/ogg_encoder_aspect.h" diff --git a/src/libOggFLAC/ogg_helper.c b/src/libOggFLAC/ogg_helper.c index 20979072..bebd7f06 100644 --- a/src/libOggFLAC/ogg_helper.c +++ b/src/libOggFLAC/ogg_helper.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for malloc() */ #include /* for memcmp(), memcpy() */ #include "FLAC/assert.h" diff --git a/src/libOggFLAC/ogg_mapping.c b/src/libOggFLAC/ogg_mapping.c index 6dd2367c..bfd27ad0 100644 --- a/src/libOggFLAC/ogg_mapping.c +++ b/src/libOggFLAC/ogg_mapping.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include "private/ogg_mapping.h" const unsigned OggFLAC__MAPPING_PACKET_TYPE_LEN = 8; /* bits */ diff --git a/src/libOggFLAC/seekable_stream_decoder.c b/src/libOggFLAC/seekable_stream_decoder.c index 668b5ec1..9721ef88 100644 --- a/src/libOggFLAC/seekable_stream_decoder.c +++ b/src/libOggFLAC/seekable_stream_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for calloc() */ #include /* for memcpy()/memcmp() */ diff --git a/src/libOggFLAC/seekable_stream_encoder.c b/src/libOggFLAC/seekable_stream_encoder.c index 855b2345..b222905e 100644 --- a/src/libOggFLAC/seekable_stream_encoder.c +++ b/src/libOggFLAC/seekable_stream_encoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for calloc() */ #include /* for memcpy() */ diff --git a/src/libOggFLAC/stream_decoder.c b/src/libOggFLAC/stream_decoder.c index bc253c07..21557c6c 100644 --- a/src/libOggFLAC/stream_decoder.c +++ b/src/libOggFLAC/stream_decoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for calloc() */ #include "FLAC/assert.h" #include "protected/stream_decoder.h" diff --git a/src/libOggFLAC/stream_encoder.c b/src/libOggFLAC/stream_encoder.c index dd172ea9..1c7c95a8 100644 --- a/src/libOggFLAC/stream_encoder.c +++ b/src/libOggFLAC/stream_encoder.c @@ -29,6 +29,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for calloc() */ #include "FLAC/assert.h" diff --git a/src/metaflac/operations.c b/src/metaflac/operations.c index dd81039a..173c091b 100644 --- a/src/metaflac/operations.c +++ b/src/metaflac/operations.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "operations.h" #include "usage.h" #include "utils.h" diff --git a/src/metaflac/operations_shorthand_cuesheet.c b/src/metaflac/operations_shorthand_cuesheet.c index a4d11a08..bd37fd45 100644 --- a/src/metaflac/operations_shorthand_cuesheet.c +++ b/src/metaflac/operations_shorthand_cuesheet.c @@ -16,11 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include +#include /* for snprintf() */ +#include #include "options.h" #include "utils.h" #include "FLAC/assert.h" #include "share/grabbag.h" -#include static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link); static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename); @@ -118,7 +124,7 @@ FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, f = fopen(cs_filename, "r"); if(0 == f) { - fprintf(stderr, "%s: ERROR: can't open import file %s\n", filename, cs_filename); + fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, cs_filename, strerror(errno)); return false; } @@ -183,7 +189,7 @@ FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cueshe f = fopen(cs_filename, "w"); if(0 == f) { - fprintf(stderr, "%s: ERROR: can't open export file %s\n", filename, cs_filename); + fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, cs_filename, strerror(errno)); return false; } @@ -193,7 +199,11 @@ FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cueshe return false; } +#ifdef _MSC_VER + _snprintf(ref, reflen, "\"%s\" FLAC", filename); +#else snprintf(ref, reflen, "\"%s\" FLAC", filename); +#endif grabbag__cuesheet_emit(f, cuesheet, ref); diff --git a/src/metaflac/operations_shorthand_seektable.c b/src/metaflac/operations_shorthand_seektable.c index 8ab93e28..51ba63e4 100644 --- a/src/metaflac/operations_shorthand_seektable.c +++ b/src/metaflac/operations_shorthand_seektable.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "utils.h" #include "FLAC/assert.h" #include "FLAC/file_decoder.h" diff --git a/src/metaflac/operations_shorthand_streaminfo.c b/src/metaflac/operations_shorthand_streaminfo.c index f9d729f9..738bec01 100644 --- a/src/metaflac/operations_shorthand_streaminfo.c +++ b/src/metaflac/operations_shorthand_streaminfo.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "options.h" #include "utils.h" #include "FLAC/assert.h" diff --git a/src/metaflac/operations_shorthand_vorbiscomment.c b/src/metaflac/operations_shorthand_vorbiscomment.c index e28cbb5c..700cdb44 100644 --- a/src/metaflac/operations_shorthand_vorbiscomment.c +++ b/src/metaflac/operations_shorthand_vorbiscomment.c @@ -16,11 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "options.h" #include "utils.h" #include "FLAC/assert.h" #include "share/grabbag.h" /* for grabbag__file_get_filesize() */ #include "share/utf8.h" +#include #include #include @@ -195,10 +200,10 @@ FLAC__bool set_vc_field(const char *filename, FLAC__StreamMetadata *block, const die("out of memory allocating tag value"); data[size] = '\0'; if(0 == (f = fopen(field->field_value, "rb")) || fread(data, 1, size, f) != (size_t)size) { + fprintf(stderr, "%s: ERROR: while reading file '%s' for '%s' tag value: %s\n", filename, field->field_value, field->field_name, strerror(errno)); free(data); if(f) fclose(f); - fprintf(stderr, "%s: ERROR: while reading file '%s' for '%s' tag value\n", filename, field->field_value, field->field_name); return false; } fclose(f); @@ -291,7 +296,7 @@ FLAC__bool import_vc_from(const char *filename, FLAC__StreamMetadata *block, con f = fopen(vc_filename->value, "r"); if(0 == f) { - fprintf(stderr, "%s: ERROR: can't open import file %s\n", filename, vc_filename->value); + fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, vc_filename->value, strerror(errno)); return false; } @@ -348,7 +353,7 @@ FLAC__bool export_vc_to(const char *filename, FLAC__StreamMetadata *block, const f = fopen(vc_filename->value, "w"); if(0 == f) { - fprintf(stderr, "%s: ERROR: can't open export file %s\n", filename, vc_filename->value); + fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, vc_filename->value, strerror(errno)); return false; } diff --git a/src/metaflac/options.c b/src/metaflac/options.c index 7e947427..8deeaad8 100644 --- a/src/metaflac/options.c +++ b/src/metaflac/options.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "options.h" #include "usage.h" #include "utils.h" diff --git a/src/metaflac/usage.c b/src/metaflac/usage.c index 4ba9f588..2ee9a4d3 100644 --- a/src/metaflac/usage.c +++ b/src/metaflac/usage.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "usage.h" #include "FLAC/format.h" #include diff --git a/src/metaflac/utils.c b/src/metaflac/utils.c index 6dd88f83..75991d64 100644 --- a/src/metaflac/utils.c +++ b/src/metaflac/utils.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "utils.h" #include "FLAC/assert.h" #include "share/utf8.h" diff --git a/src/monkeys_audio_utilities/flac_mac/main.c b/src/monkeys_audio_utilities/flac_mac/main.c index 45a6665c..adc7aea5 100644 --- a/src/monkeys_audio_utilities/flac_mac/main.c +++ b/src/monkeys_audio_utilities/flac_mac/main.c @@ -22,6 +22,10 @@ * how to do this. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/monkeys_audio_utilities/flac_ren/main.c b/src/monkeys_audio_utilities/flac_ren/main.c index bb07cc9f..b307fd59 100644 --- a/src/monkeys_audio_utilities/flac_ren/main.c +++ b/src/monkeys_audio_utilities/flac_ren/main.c @@ -16,10 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include -#include +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include int main(int argc, char *argv[]) { diff --git a/src/plugin_common/charset.c b/src/plugin_common/charset.c index 575ac2ae..e63c5c4b 100644 --- a/src/plugin_common/charset.c +++ b/src/plugin_common/charset.c @@ -20,15 +20,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef HAVE_ICONV #include #endif diff --git a/src/plugin_common/dither.c b/src/plugin_common/dither.c index d7e0bae0..feaf298a 100644 --- a/src/plugin_common/dither.c +++ b/src/plugin_common/dither.c @@ -20,6 +20,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "dither.h" #include "FLAC/assert.h" diff --git a/src/plugin_common/replaygain.c b/src/plugin_common/replaygain.c index b9c83a49..8818d17a 100644 --- a/src/plugin_common/replaygain.c +++ b/src/plugin_common/replaygain.c @@ -17,6 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "replaygain.h" #include "FLAC/ordinals.h" #include "FLAC/metadata.h" diff --git a/src/plugin_common/tags.c b/src/plugin_common/tags.c index cf5a6ce8..a8b283dd 100644 --- a/src/plugin_common/tags.c +++ b/src/plugin_common/tags.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/plugin_winamp2/Makefile.am b/src/plugin_winamp2/Makefile.am index fa193e87..684e1704 100644 --- a/src/plugin_winamp2/Makefile.am +++ b/src/plugin_winamp2/Makefile.am @@ -18,8 +18,8 @@ SUBDIRS = include EXTRA_DIST = \ - config.h \ - config.c \ + configure.h \ + configure.c \ in_flac.c \ in_flac.dsp \ infobox.c \ diff --git a/src/plugin_winamp2/config.c b/src/plugin_winamp2/configure.c similarity index 95% rename from src/plugin_winamp2/config.c rename to src/plugin_winamp2/configure.c index 913b59bc..53975b31 100644 --- a/src/plugin_winamp2/config.c +++ b/src/plugin_winamp2/configure.c @@ -16,10 +16,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include -#include "config.h" +#include "configure.h" #include "tagz.h" #include "resource.h" diff --git a/src/plugin_winamp2/config.h b/src/plugin_winamp2/configure.h similarity index 100% rename from src/plugin_winamp2/config.h rename to src/plugin_winamp2/configure.h diff --git a/src/plugin_winamp2/in_flac.c b/src/plugin_winamp2/in_flac.c index 6c3bea4e..48af5f34 100644 --- a/src/plugin_winamp2/in_flac.c +++ b/src/plugin_winamp2/in_flac.c @@ -16,11 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include +#include /* for INT_MAX */ #include #include "winamp2/in2.h" -#include "config.h" +#include "configure.h" #include "infobox.h" #include "tagz.h" @@ -326,33 +331,33 @@ static void getfileinfo(char *filename, char *title, int *length_in_msec) { FLAC__StreamMetadata streaminfo; - if (!filename || !*filename) - { + if (!filename || !*filename) { filename = lastfn_; - if (length_in_msec) - { - *length_in_msec = (int)file_info_.length_in_msec; - length_in_msec = 0; /* force skip in following code */ + if (length_in_msec) { + *length_in_msec = file_info_.length_in_msec; + length_in_msec = 0; /* force skip in following code */ } } - if (!FLAC__metadata_get_streaminfo(filename, &streaminfo)) - { + if (!FLAC__metadata_get_streaminfo(filename, &streaminfo)) { if (length_in_msec) *length_in_msec = -1; return; } - if (title) - { + if (title) { static WCHAR buffer[400]; format_title(filename, buffer, 400); WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, buffer, -1, title, 400, NULL, NULL); } - if (length_in_msec) + if (length_in_msec) { /* with VC++ you have to spoon feed it the casting from uint64->int64->double */ - *length_in_msec = (int)((double)(FLAC__int64)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); + FLAC__uint64 l = (FLAC__uint64)((double)(FLAC__int64)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); + if (l > INT_MAX) + l = INT_MAX; + *length_in_msec = (int)l; + } } /* diff --git a/src/plugin_winamp2/in_flac.dsp b/src/plugin_winamp2/in_flac.dsp index 5be233ae..82468058 100644 --- a/src/plugin_winamp2/in_flac.dsp +++ b/src/plugin_winamp2/in_flac.dsp @@ -107,11 +107,11 @@ SOURCE=.\include\winamp2\out.h # End Group # Begin Source File -SOURCE=.\config.c +SOURCE=.\configure.c # End Source File # Begin Source File -SOURCE=.\config.h +SOURCE=.\configure.h # End Source File # Begin Source File diff --git a/src/plugin_winamp2/infobox.c b/src/plugin_winamp2/infobox.c index 640238e1..2f9bce1e 100644 --- a/src/plugin_winamp2/infobox.c +++ b/src/plugin_winamp2/infobox.c @@ -16,12 +16,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include "FLAC/all.h" #include "plugin_common/all.h" #include "infobox.h" -#include "config.h" +#include "configure.h" #include "resource.h" diff --git a/src/plugin_winamp2/playback.c b/src/plugin_winamp2/playback.c index d15ceb78..78965e52 100644 --- a/src/plugin_winamp2/playback.c +++ b/src/plugin_winamp2/playback.c @@ -16,6 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include /* for INT_MAX */ #include #include /* for memmove() */ #include "playback.h" @@ -60,8 +65,7 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - FLAC__ASSERT(metadata->data.stream_info.total_samples < 0x100000000); /* this plugin can only handle < 4 gigasamples */ - file_info->total_samples = (unsigned)(metadata->data.stream_info.total_samples&0xfffffffful); + file_info->total_samples = metadata->data.stream_info.total_samples; file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample; file_info->channels = metadata->data.stream_info.channels; file_info->sample_rate = metadata->data.stream_info.sample_rate; @@ -72,7 +76,14 @@ static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__Stre file_info->abort_flag = true; return; } - file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5); + + { + /* with VC++ you have to spoon feed it the casting from uint64->int64->double */ + FLAC__uint64 l = (FLAC__uint64)((double)(FLAC__int64)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5); + if (l > INT_MAX) + l = INT_MAX; + file_info->length_in_msec = (int)l; + } } else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { @@ -143,7 +154,7 @@ FLAC__bool FLAC_plugin__decoder_init(FLAC__FileDecoder *decoder, const char *fil file_info->eof = false; file_info->seek_to = -1; file_info->is_playing = true; - file_info->average_bps = (unsigned)(filesize / (125.*file_info->total_samples/file_info->sample_rate)); + file_info->average_bps = (unsigned)(filesize / (125.*(double)(FLAC__int64)file_info->total_samples/(double)file_info->sample_rate)); bh_index_last_w = 0; bh_index_last_o = BITRATE_HIST_SIZE; @@ -176,8 +187,7 @@ void FLAC_plugin__decoder_delete(FLAC__FileDecoder *decoder) int FLAC_plugin__seek(FLAC__FileDecoder *decoder, file_info_struct *file_info) { int pos; - const FLAC__uint64 target_sample = - (FLAC__uint64)file_info->total_samples*file_info->seek_to / file_info->length_in_msec; + const FLAC__uint64 target_sample = file_info->total_samples * file_info->seek_to / file_info->length_in_msec; if (!FLAC__file_decoder_seek_absolute(decoder, target_sample)) return -1; diff --git a/src/plugin_winamp2/playback.h b/src/plugin_winamp2/playback.h index a39149b6..41207916 100644 --- a/src/plugin_winamp2/playback.h +++ b/src/plugin_winamp2/playback.h @@ -38,12 +38,12 @@ typedef struct { volatile FLAC__bool abort_flag; volatile FLAC__bool eof; volatile int seek_to; - unsigned total_samples; + FLAC__uint64 total_samples; unsigned bits_per_sample; unsigned output_bits_per_sample; unsigned channels; unsigned sample_rate; - unsigned length_in_msec; + int length_in_msec; /* int (instead of FLAC__uint64) only because that's what Winamp uses; seeking won't work right if this maxes out */ unsigned average_bps; FLAC__bool has_replaygain; double replay_scale; diff --git a/src/plugin_xmms/charset.c b/src/plugin_xmms/charset.c index a75db2c0..ddbca983 100644 --- a/src/plugin_xmms/charset.c +++ b/src/plugin_xmms/charset.c @@ -20,6 +20,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/plugin_xmms/configure.c b/src/plugin_xmms/configure.c index 6e6f5714..4fd3448a 100644 --- a/src/plugin_xmms/configure.c +++ b/src/plugin_xmms/configure.c @@ -21,6 +21,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/plugin_xmms/fileinfo.c b/src/plugin_xmms/fileinfo.c index 01f8dbac..a79dac06 100644 --- a/src/plugin_xmms/fileinfo.c +++ b/src/plugin_xmms/fileinfo.c @@ -18,6 +18,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for strlen() */ #include @@ -223,7 +227,11 @@ static void show_file_info() (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60)); if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) { +#if _FILE_OFFSET_BITS = 64 + label_set_text(flac_filesize, _("Filesize: %lld B"), _stat.st_size); +#else label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size); +#endif if (streaminfo.data.stream_info.total_samples) label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"), 8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate), diff --git a/src/plugin_xmms/http.c b/src/plugin_xmms/http.c index 0876bb46..fadede1f 100644 --- a/src/plugin_xmms/http.c +++ b/src/plugin_xmms/http.c @@ -16,6 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* modified for FLAC support by Steven Richman (2003) */ + +#if HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -35,10 +40,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "configure.h" #include "plugin_common/locale_hack.h" #include "FLAC/format.h" diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c index 1d4e61a7..d6f409f2 100644 --- a/src/plugin_xmms/plugin.c +++ b/src/plugin_xmms/plugin.c @@ -16,6 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include #include #include #include @@ -30,10 +35,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef HAVE_LANGINFO_CODESET #include #endif @@ -52,13 +53,6 @@ #endif #define min(x,y) ((x)<(y)?(x):(y)) -/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ -#ifdef _MSC_VER -#define FLAC__U64L(x) x -#else -#define FLAC__U64L(x) x##LLU -#endif - extern void FLAC_XMMS__file_info_box(char *filename); typedef struct { @@ -66,11 +60,11 @@ typedef struct { FLAC__bool is_playing; FLAC__bool eof; FLAC__bool play_thread_open; /* if true, is_playing must also be true */ - unsigned total_samples; + FLAC__uint64 total_samples; unsigned bits_per_sample; unsigned channels; unsigned sample_rate; - unsigned length_in_msec; + int length_in_msec; /* int (instead of FLAC__uint64) only because that's what XMMS uses; seeking won't work right if this maxes out */ gchar *title; AFormat sample_format; unsigned sample_format_bytes_per_sample; @@ -450,8 +444,12 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec) if(title) { *title = flac_format_song_title(filename); } - if(length_in_msec) - *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); + if(length_in_msec) { + FLAC__uint64 l = (FLAC__uint64)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); + if (l > INT_MAX) + l = INT_MAX; + *length_in_msec = (int)l; + } } /*********************************************************************** @@ -524,8 +522,8 @@ void *play_loop_(void *arg) xmms_usleep(10000); if(decoder_func_table_->seekable && file_info_.seek_to_in_sec != -1) { const double distance = (double)file_info_.seek_to_in_sec * 1000.0 / (double)file_info_.length_in_msec; - unsigned target_sample = (unsigned)(distance * (double)file_info_.total_samples); - if(FLAC__file_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) { + FLAC__uint64 target_sample = (FLAC__uint64)(distance * (double)file_info_.total_samples); + if(FLAC__file_decoder_seek_absolute(decoder_, target_sample)) { flac_ip.output->flush(file_info_.seek_to_in_sec * 1000); bh_index_last_w = bh_index_last_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; if(!FLAC__file_decoder_get_decode_position(decoder_, &decode_position_frame)) @@ -610,8 +608,7 @@ static FLAC__bool http_decoder_set_md5_checking (void *decoder, FLAC__bool value { (void) value; // operation unsupported - return FLAC__stream_decoder_get_state ((const FLAC__StreamDecoder *) decoder) == - FLAC__STREAM_DECODER_UNINITIALIZED; + return FLAC__stream_decoder_get_state ((const FLAC__StreamDecoder *) decoder) == FLAC__STREAM_DECODER_UNINITIALIZED; } static FLAC__bool http_decoder_set_url (void *decoder, const char* url) @@ -800,12 +797,16 @@ void metadata_callback_(const void *decoder, const FLAC__StreamMetadata *metadat file_info_struct *file_info = (file_info_struct *)client_data; (void)decoder; if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - FLAC__ASSERT(metadata->data.stream_info.total_samples < FLAC__U64L(0x100000000)); /* this plugin can only handle < 4 gigasamples */ - file_info->total_samples = (unsigned)(metadata->data.stream_info.total_samples&0xffffffff); + file_info->total_samples = metadata->data.stream_info.total_samples; file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample; file_info->channels = metadata->data.stream_info.channels; file_info->sample_rate = metadata->data.stream_info.sample_rate; - file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5); + { + FLAC__uint64 l = (FLAC__uint64)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5); + if (l > INT_MAX) + l = INT_MAX; + file_info->length_in_msec = (int)l; + } } else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { double gain, peak; diff --git a/src/plugin_xmms/tag.c b/src/plugin_xmms/tag.c index 0d73c832..308f064f 100644 --- a/src/plugin_xmms/tag.c +++ b/src/plugin_xmms/tag.c @@ -19,6 +19,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/share/getopt/getopt.c b/src/share/getopt/getopt.c index 1e90fa8a..279dff02 100644 --- a/src/share/getopt/getopt.c +++ b/src/share/getopt/getopt.c @@ -41,8 +41,8 @@ # define _NO_PROTO #endif -#ifdef HAVE_CONFIG_H -# include +#if HAVE_CONFIG_H +# include #endif #if !defined __STDC__ || !__STDC__ diff --git a/src/share/getopt/getopt1.c b/src/share/getopt/getopt1.c index 6c8c1cae..1e57486b 100644 --- a/src/share/getopt/getopt1.c +++ b/src/share/getopt/getopt1.c @@ -32,8 +32,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H -#include +#if HAVE_CONFIG_H +# include #endif #include "share/getopt.h" diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c index 19c8938c..3de01ed5 100644 --- a/src/share/grabbag/cuesheet.c +++ b/src/share/grabbag/cuesheet.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "share/grabbag.h" #include "FLAC/assert.h" #include diff --git a/src/share/grabbag/file.c b/src/share/grabbag/file.c index 62959545..7d7cb5e6 100644 --- a/src/share/grabbag/file.c +++ b/src/share/grabbag/file.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #if defined _MSC_VER || defined __MINGW32__ #include /* for utime() */ #include /* for chmod(), _setmode(), unlink() */ diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c index ca3316d7..356fc9fb 100644 --- a/src/share/grabbag/replaygain.c +++ b/src/share/grabbag/replaygain.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "share/grabbag.h" #include "share/replaygain_analysis.h" #include "FLAC/assert.h" diff --git a/src/share/grabbag/seektable.c b/src/share/grabbag/seektable.c index 92f4201c..7893eb1b 100644 --- a/src/share/grabbag/seektable.c +++ b/src/share/grabbag/seektable.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "share/grabbag.h" #include "FLAC/assert.h" #include /* for atoi() */ diff --git a/src/share/replaygain_analysis/replaygain_analysis.c b/src/share/replaygain_analysis/replaygain_analysis.c index 43e2ba66..5b9637c5 100644 --- a/src/share/replaygain_analysis/replaygain_analysis.c +++ b/src/share/replaygain_analysis/replaygain_analysis.c @@ -89,6 +89,10 @@ * Optimization/clarity suggestions are welcome. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/share/replaygain_synthesis/replaygain_synthesis.c b/src/share/replaygain_synthesis/replaygain_synthesis.c index b4970921..85c5aac3 100644 --- a/src/share/replaygain_synthesis/replaygain_synthesis.c +++ b/src/share/replaygain_synthesis/replaygain_synthesis.c @@ -34,6 +34,10 @@ * Additional code by Magnus Holmgren and Gian-Carlo Pascutto */ +#if HAVE_CONFIG_H +# include +#endif + #include /* for memset() */ #include #include "private/fast_float_math_hack.h" diff --git a/src/share/utf8/charset.c b/src/share/utf8/charset.c index 0b796996..3d130642 100644 --- a/src/share/utf8/charset.c +++ b/src/share/utf8/charset.c @@ -27,8 +27,8 @@ * 8-bit char, 16-bit short and 32-bit int. */ -#ifdef HAVE_CONFIG_H -#include +#if HAVE_CONFIG_H +# include #endif #ifndef HAVE_ICONV /* should be ifdef USE_CHARSET_CONVERT */ diff --git a/src/share/utf8/charset_test.c b/src/share/utf8/charset_test.c index 87426d0a..1d5bf717 100644 --- a/src/share/utf8/charset_test.c +++ b/src/share/utf8/charset_test.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if HAVE_CONFIG_H +# include +#endif + #include #include diff --git a/src/share/utf8/iconvert.c b/src/share/utf8/iconvert.c index a23168f6..b72ad863 100644 --- a/src/share/utf8/iconvert.c +++ b/src/share/utf8/iconvert.c @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_CONFIG_H -#include +#if HAVE_CONFIG_H +# include #endif #ifdef HAVE_ICONV diff --git a/src/share/utf8/makemap.c b/src/share/utf8/makemap.c index e19c1960..72a9de18 100644 --- a/src/share/utf8/makemap.c +++ b/src/share/utf8/makemap.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include diff --git a/src/share/utf8/utf8.c b/src/share/utf8/utf8.c index 174d51fe..a77e38ba 100644 --- a/src/share/utf8/utf8.c +++ b/src/share/utf8/utf8.c @@ -21,13 +21,13 @@ * Convert a string between UTF-8 and the locale's charset. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "utf8.h" #include "charset.h" diff --git a/src/test_grabbag/cuesheet/main.c b/src/test_grabbag/cuesheet/main.c index 1986f97f..6bbf04a3 100644 --- a/src/test_grabbag/cuesheet/main.c +++ b/src/test_grabbag/cuesheet/main.c @@ -16,6 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include #include #include #include @@ -40,7 +45,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64 fin = stdin; } else if(0 == (fin = fopen(infilename, "r"))) { - fprintf(stderr, "can't open file %s for reading\n", infilename); + fprintf(stderr, "can't open file %s for reading: %s\n", infilename, strerror(errno)); return 255; } if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, is_cdda, lead_out_offset))) { @@ -60,7 +65,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64 } sprintf(tmpfilename, "%s.1", infilename); if(0 == (fout = fopen(tmpfilename, "w"))) { - fprintf(stderr, "can't open file %s for writing\n", tmpfilename); + fprintf(stderr, "can't open file %s for writing: %s\n", tmpfilename, strerror(errno)); FLAC__metadata_object_delete(cuesheet); return 255; } @@ -72,7 +77,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64 * pass 2 */ if(0 == (fin = fopen(tmpfilename, "r"))) { - fprintf(stderr, "can't open file %s for reading\n", tmpfilename); + fprintf(stderr, "can't open file %s for reading: %s\n", tmpfilename, strerror(errno)); return 255; } if(0 != (cuesheet = grabbag__cuesheet_parse(fin, &error_message, &last_line_read, is_cdda, lead_out_offset))) { @@ -92,7 +97,7 @@ static int do_cuesheet(const char *infilename, FLAC__bool is_cdda, FLAC__uint64 } sprintf(tmpfilename, "%s.2", infilename); if(0 == (fout = fopen(tmpfilename, "w"))) { - fprintf(stderr, "can't open file %s for writing\n", tmpfilename); + fprintf(stderr, "can't open file %s for writing: %s\n", tmpfilename, strerror(errno)); FLAC__metadata_object_delete(cuesheet); return 255; } diff --git a/src/test_libFLAC++/decoders.cpp b/src/test_libFLAC++/decoders.cpp index d682cfd8..a6ba8e73 100644 --- a/src/test_libFLAC++/decoders.cpp +++ b/src/test_libFLAC++/decoders.cpp @@ -16,6 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include +#include +#include +#if defined _MSC_VER || defined __MINGW32__ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "decoders.h" extern "C" { #include "file_utils.h" @@ -25,10 +34,6 @@ extern "C" { #include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal() #include "FLAC++/decoder.h" #include "share/grabbag.h" -#include -#include -#include -#include #ifdef _MSC_VER // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) @@ -39,7 +44,7 @@ static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, static ::FLAC__StreamMetadata *expected_metadata_sequence_[8]; static unsigned num_expected_; static const char *flacfilename_ = "metadata.flac"; -static unsigned flacfilesize_; +static off_t flacfilesize_; static bool die_(const char *msg) { @@ -221,7 +226,7 @@ bool StreamDecoder::test_respond() current_metadata_number_ = 0; - if(::fseek(file_, 0, SEEK_SET) < 0) { + if(fseeko(file_, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -333,7 +338,7 @@ static bool test_stream_decoder() printf("opening FLAC file... "); decoder->file_ = ::fopen(flacfilename_, "rb"); if(0 == decoder->file_) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -421,7 +426,7 @@ static bool test_stream_decoder() decoder->current_metadata_number_ = 0; printf("rewinding input... "); - if(::fseek(decoder->file_, 0, SEEK_SET) < 0) { + if(fseeko(decoder->file_, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } @@ -835,7 +840,7 @@ public: if(error_occurred_) return ::FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; - if(::fseek(file_, (long)absolute_byte_offset, SEEK_SET) < 0) { + if(fseeko(file_, (off_t)absolute_byte_offset, SEEK_SET) < 0) { error_occurred_ = true; return ::FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; } @@ -848,7 +853,7 @@ public: if(error_occurred_) return ::FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; - long offset = ::ftell(file_); + off_t offset = ftello(file_); *absolute_byte_offset = (FLAC__uint64)offset; if(offset < 0) { @@ -925,7 +930,7 @@ bool SeekableStreamDecoder::test_respond() current_metadata_number_ = 0; - if(::fseek(file_, 0, SEEK_SET) < 0) { + if(fseeko(file_, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -1048,7 +1053,7 @@ static bool test_seekable_stream_decoder() printf("opening FLAC file... "); decoder->file_ = ::fopen(flacfilename_, "rb"); if(0 == decoder->file_) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -1148,7 +1153,7 @@ static bool test_seekable_stream_decoder() decoder->current_metadata_number_ = 0; printf("rewinding input... "); - if(::fseek(decoder->file_, 0, SEEK_SET) < 0) { + if(fseeko(decoder->file_, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } diff --git a/src/test_libFLAC++/file_utils.c b/src/test_libFLAC++/file_utils.c index 800bbc9b..8baf9ead 100644 --- a/src/test_libFLAC++/file_utils.c +++ b/src/test_libFLAC++/file_utils.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "file_utils.h" #include "FLAC/assert.h" #include "FLAC/stream_encoder.h" @@ -61,7 +65,7 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const (void)encoder, (void)metadata, (void)client_data; } -FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) { FLAC__int32 samples[1024]; FLAC__StreamEncoder *encoder; @@ -136,7 +140,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned * if(stat(output_filename, &filestats) != 0) return false; else - *output_filesize = (unsigned)filestats.st_size; + *output_filesize = filestats.st_size; } return true; diff --git a/src/test_libFLAC++/file_utils.h b/src/test_libFLAC++/file_utils.h index 74b7201e..12846166 100644 --- a/src/test_libFLAC++/file_utils.h +++ b/src/test_libFLAC++/file_utils.h @@ -19,8 +19,17 @@ #ifndef FLAC__TEST_LIBFLAC_FILE_UTILS_H #define FLAC__TEST_LIBFLAC_FILE_UTILS_H -#include "FLAC/format.h" +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif -FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); +#include "FLAC/format.h" +#include /* for off_t */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +#endif + +FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); #endif diff --git a/src/test_libFLAC++/metadata_manip.cpp b/src/test_libFLAC++/metadata_manip.cpp index 44e2a27e..ada4f9ec 100644 --- a/src/test_libFLAC++/metadata_manip.cpp +++ b/src/test_libFLAC++/metadata_manip.cpp @@ -16,6 +16,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include /* for malloc() */ +#include /* for memcpy()/memset() */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for utime() */ +#include /* for chmod() */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#else +#include /* some flavors of BSD (like OS X) require this to get time_t */ +#include /* for utime() */ +#include /* for chown(), unlink() */ +#endif +#include /* for stat(), maybe chmod() */ extern "C" { #include "file_utils.h" } @@ -23,19 +38,6 @@ extern "C" { #include "FLAC++/decoder.h" #include "FLAC++/metadata.h" #include "share/grabbag.h" -#include -#include /* for malloc() */ -#include /* for memcpy()/memset() */ - -#if defined _MSC_VER || defined __MINGW32__ -#include /* for utime() */ -#include /* for chmod() */ -#else -#include /* some flavors of BSD (like OS X) require this to get time_t */ -#include /* for utime() */ -#include /* for chown(), unlink() */ -#endif -#include /* for stat(), maybe chmod() */ /****************************************************************************** The general strategy of these tests (for interface levels 1 and 2) is @@ -275,14 +277,14 @@ static size_t chain_write_cb_(const void *ptr, size_t size, size_t nmemb, ::FLAC static int chain_seek_cb_(::FLAC__IOHandle handle, FLAC__int64 offset, int whence) { - long o = (long)offset; + off_t o = (off_t)offset; FLAC__ASSERT(offset == o); - return fseek((FILE*)handle, o, whence); + return fseeko((FILE*)handle, o, whence); } static FLAC__int64 chain_tell_cb_(::FLAC__IOHandle handle) { - return ftell((FILE*)handle); + return ftello((FILE*)handle); } static int chain_eof_cb_(::FLAC__IOHandle handle) diff --git a/src/test_libFLAC++/metadata_utils.c b/src/test_libFLAC++/metadata_utils.c index dcfa7654..c8669829 100644 --- a/src/test_libFLAC++/metadata_utils.c +++ b/src/test_libFLAC++/metadata_utils.c @@ -20,6 +20,10 @@ * These are not tests, just utility functions used by the metadata tests */ +#if HAVE_CONFIG_H +# include +#endif + #include "metadata_utils.h" #include "FLAC/metadata.h" #include diff --git a/src/test_libFLAC/bitbuffer.c b/src/test_libFLAC/bitbuffer.c index 70c99516..52b5eaa6 100644 --- a/src/test_libFLAC/bitbuffer.c +++ b/src/test_libFLAC/bitbuffer.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/assert.h" #include "private/bitbuffer.h" /* from the libFLAC private include area */ #include diff --git a/src/test_libFLAC/decoders.c b/src/test_libFLAC/decoders.c index 8a63ab7e..f208a5bf 100644 --- a/src/test_libFLAC/decoders.c +++ b/src/test_libFLAC/decoders.c @@ -16,6 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#if defined _MSC_VER || defined __MINGW32__ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "decoders.h" #include "file_utils.h" #include "metadata_utils.h" @@ -24,10 +37,6 @@ #include "FLAC/seekable_stream_decoder.h" #include "FLAC/stream_decoder.h" #include "share/grabbag.h" -#include -#include -#include -#include typedef struct { FILE *file; @@ -43,7 +52,7 @@ static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, ap static FLAC__StreamMetadata *expected_metadata_sequence_[8]; static unsigned num_expected_; static const char *flacfilename_ = "metadata.flac"; -static unsigned flacfilesize_; +static off_t flacfilesize_; static FLAC__bool die_(const char *msg) { @@ -265,7 +274,7 @@ static FLAC__bool stream_decoder_test_respond_(FLAC__StreamDecoder *decoder, str dcd->current_metadata_number = 0; - if(fseek(dcd->file, 0, SEEK_SET) < 0) { + if(fseeko(dcd->file, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -371,7 +380,7 @@ static FLAC__bool test_stream_decoder() printf("opening FLAC file... "); decoder_client_data.file = fopen(flacfilename_, "rb"); if(0 == decoder_client_data.file) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -462,7 +471,7 @@ static FLAC__bool test_stream_decoder() decoder_client_data.current_metadata_number = 0; printf("rewinding input... "); - if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) { + if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } @@ -814,7 +823,7 @@ static FLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_callba if(dcd->error_occurred) return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; - if(fseek(dcd->file, (long)absolute_byte_offset, SEEK_SET) < 0) { + if(fseeko(dcd->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) { dcd->error_occurred = true; return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; } @@ -825,7 +834,7 @@ static FLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_callba static FLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { seekable_stream_decoder_client_data_struct *dcd = (seekable_stream_decoder_client_data_struct*)client_data; - long offset; + off_t offset; (void)decoder; @@ -837,7 +846,7 @@ static FLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_callba if(dcd->error_occurred) return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; - offset = ftell(dcd->file); + offset = ftello(dcd->file); *absolute_byte_offset = (FLAC__uint64)offset; if(offset < 0) { @@ -940,7 +949,7 @@ static FLAC__bool seekable_stream_decoder_test_respond_(FLAC__SeekableStreamDeco dcd->current_metadata_number = 0; - if(fseek(dcd->file, 0, SEEK_SET) < 0) { + if(fseeko(dcd->file, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -1076,7 +1085,7 @@ static FLAC__bool test_seekable_stream_decoder() printf("opening FLAC file... "); decoder_client_data.file = fopen(flacfilename_, "rb"); if(0 == decoder_client_data.file) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -1176,7 +1185,7 @@ static FLAC__bool test_seekable_stream_decoder() decoder_client_data.current_metadata_number = 0; printf("rewinding input... "); - if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) { + if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } diff --git a/src/test_libFLAC/encoders.c b/src/test_libFLAC/encoders.c index 25eb9433..34ec1ae5 100644 --- a/src/test_libFLAC/encoders.c +++ b/src/test_libFLAC/encoders.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "encoders.h" #include "file_utils.h" #include "metadata_utils.h" diff --git a/src/test_libFLAC/file_utils.c b/src/test_libFLAC/file_utils.c index 800bbc9b..8baf9ead 100644 --- a/src/test_libFLAC/file_utils.c +++ b/src/test_libFLAC/file_utils.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "file_utils.h" #include "FLAC/assert.h" #include "FLAC/stream_encoder.h" @@ -61,7 +65,7 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const (void)encoder, (void)metadata, (void)client_data; } -FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) { FLAC__int32 samples[1024]; FLAC__StreamEncoder *encoder; @@ -136,7 +140,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned * if(stat(output_filename, &filestats) != 0) return false; else - *output_filesize = (unsigned)filestats.st_size; + *output_filesize = filestats.st_size; } return true; diff --git a/src/test_libFLAC/file_utils.h b/src/test_libFLAC/file_utils.h index 74b7201e..12846166 100644 --- a/src/test_libFLAC/file_utils.h +++ b/src/test_libFLAC/file_utils.h @@ -19,8 +19,17 @@ #ifndef FLAC__TEST_LIBFLAC_FILE_UTILS_H #define FLAC__TEST_LIBFLAC_FILE_UTILS_H -#include "FLAC/format.h" +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif -FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); +#include "FLAC/format.h" +#include /* for off_t */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +#endif + +FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); #endif diff --git a/src/test_libFLAC/format.c b/src/test_libFLAC/format.c index ee44c24b..9c55a9a8 100644 --- a/src/test_libFLAC/format.c +++ b/src/test_libFLAC/format.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/assert.h" #include "FLAC/format.h" #include diff --git a/src/test_libFLAC/main.c b/src/test_libFLAC/main.c index 244adb9c..0ff40bb8 100644 --- a/src/test_libFLAC/main.c +++ b/src/test_libFLAC/main.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "bitbuffer.h" #include "decoders.h" #include "encoders.h" diff --git a/src/test_libFLAC/metadata.c b/src/test_libFLAC/metadata.c index ba35d3d8..a972d406 100644 --- a/src/test_libFLAC/metadata.c +++ b/src/test_libFLAC/metadata.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "metadata.h" #include diff --git a/src/test_libFLAC/metadata_manip.c b/src/test_libFLAC/metadata_manip.c index 26d1a80b..55d85ef9 100644 --- a/src/test_libFLAC/metadata_manip.c +++ b/src/test_libFLAC/metadata_manip.c @@ -16,24 +16,30 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "file_utils.h" -#include "metadata_utils.h" -#include "FLAC/assert.h" -#include "FLAC/file_decoder.h" -#include "FLAC/metadata.h" -#include "share/grabbag.h" +#if HAVE_CONFIG_H +# include +#endif + #include #include /* for malloc() */ - #if defined _MSC_VER || defined __MINGW32__ #include /* for utime() */ #include /* for chmod() */ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell #else #include /* some flavors of BSD (like OS X) require this to get time_t */ #include /* for utime() */ #include /* for chown(), unlink() */ #endif #include /* for stat(), maybe chmod() */ +#include "file_utils.h" +#include "metadata_utils.h" +#include "FLAC/assert.h" +#include "FLAC/file_decoder.h" +#include "FLAC/metadata.h" +#include "share/grabbag.h" /****************************************************************************** @@ -258,14 +264,14 @@ static size_t chain_write_cb_(const void *ptr, size_t size, size_t nmemb, FLAC__ static int chain_seek_cb_(FLAC__IOHandle handle, FLAC__int64 offset, int whence) { - long o = (long)offset; + off_t o = (off_t)offset; FLAC__ASSERT(offset == o); - return fseek((FILE*)handle, o, whence); + return fseeko((FILE*)handle, o, whence); } static FLAC__int64 chain_tell_cb_(FLAC__IOHandle handle) { - return ftell((FILE*)handle); + return ftello((FILE*)handle); } static int chain_eof_cb_(FLAC__IOHandle handle) diff --git a/src/test_libFLAC/metadata_object.c b/src/test_libFLAC/metadata_object.c index 6d8b8d47..2805d41e 100644 --- a/src/test_libFLAC/metadata_object.c +++ b/src/test_libFLAC/metadata_object.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/assert.h" #include "FLAC/metadata.h" #include "metadata_utils.h" diff --git a/src/test_libFLAC/metadata_utils.c b/src/test_libFLAC/metadata_utils.c index dcfa7654..c8669829 100644 --- a/src/test_libFLAC/metadata_utils.c +++ b/src/test_libFLAC/metadata_utils.c @@ -20,6 +20,10 @@ * These are not tests, just utility functions used by the metadata tests */ +#if HAVE_CONFIG_H +# include +#endif + #include "metadata_utils.h" #include "FLAC/metadata.h" #include diff --git a/src/test_libOggFLAC++/decoders.cpp b/src/test_libOggFLAC++/decoders.cpp index 5d0a0dc9..0222cd9a 100644 --- a/src/test_libOggFLAC++/decoders.cpp +++ b/src/test_libOggFLAC++/decoders.cpp @@ -16,6 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include +#include +#include +#if defined _MSC_VER || defined __MINGW32__ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "decoders.h" extern "C" { #include "file_utils.h" @@ -25,10 +34,6 @@ extern "C" { #include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal() #include "OggFLAC++/decoder.h" #include "share/grabbag.h" -#include -#include -#include -#include #ifdef _MSC_VER // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) @@ -39,7 +44,7 @@ static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, static ::FLAC__StreamMetadata *expected_metadata_sequence_[8]; static unsigned num_expected_; static const char *oggflacfilename_ = "metadata.ogg"; -static unsigned oggflacfilesize_; +static off_t oggflacfilesize_; static bool die_(const char *msg) { @@ -223,7 +228,7 @@ bool StreamDecoder::test_respond() current_metadata_number_ = 0; - if(::fseek(file_, 0, SEEK_SET) < 0) { + if(fseeko(file_, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -344,7 +349,7 @@ static bool test_stream_decoder() printf("opening Ogg FLAC file... "); decoder->file_ = ::fopen(oggflacfilename_, "rb"); if(0 == decoder->file_) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -427,7 +432,7 @@ static bool test_stream_decoder() decoder->current_metadata_number_ = 0; printf("rewinding input... "); - if(::fseek(decoder->file_, 0, SEEK_SET) < 0) { + if(fseeko(decoder->file_, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } @@ -841,7 +846,7 @@ public: if(error_occurred_) return ::OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; - if(::fseek(file_, (long)absolute_byte_offset, SEEK_SET) < 0) { + if(fseeko(file_, (off_t)absolute_byte_offset, SEEK_SET) < 0) { error_occurred_ = true; return ::OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; } @@ -854,7 +859,7 @@ public: if(error_occurred_) return ::OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; - long offset = ::ftell(file_); + off_t offset = ftello(file_); *absolute_byte_offset = (FLAC__uint64)offset; if(offset < 0) { @@ -935,7 +940,7 @@ bool SeekableStreamDecoder::test_respond() current_metadata_number_ = 0; - if(::fseek(file_, 0, SEEK_SET) < 0) { + if(fseeko(file_, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -1067,7 +1072,7 @@ static bool test_seekable_stream_decoder() printf("opening Ogg FLAC file... "); decoder->file_ = ::fopen(oggflacfilename_, "rb"); if(0 == decoder->file_) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -1162,7 +1167,7 @@ static bool test_seekable_stream_decoder() decoder->current_metadata_number_ = 0; printf("rewinding input... "); - if(::fseek(decoder->file_, 0, SEEK_SET) < 0) { + if(fseeko(decoder->file_, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } diff --git a/src/test_libOggFLAC++/file_utils.c b/src/test_libOggFLAC++/file_utils.c index ea7d4abb..d397b5b7 100644 --- a/src/test_libOggFLAC++/file_utils.c +++ b/src/test_libOggFLAC++/file_utils.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "file_utils.h" #include "FLAC/assert.h" #include "OggFLAC/stream_encoder.h" @@ -63,7 +67,7 @@ static void encoder_metadata_callback_(const OggFLAC__StreamEncoder *encoder, co (void)encoder, (void)metadata, (void)client_data; } -FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) { FLAC__int32 samples[1024]; OggFLAC__StreamEncoder *encoder; @@ -139,7 +143,7 @@ FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigne if(stat(output_filename, &filestats) != 0) return false; else - *output_filesize = (unsigned)filestats.st_size; + *output_filesize = filestats.st_size; } return true; diff --git a/src/test_libOggFLAC++/file_utils.h b/src/test_libOggFLAC++/file_utils.h index 69361e77..736ec927 100644 --- a/src/test_libOggFLAC++/file_utils.h +++ b/src/test_libOggFLAC++/file_utils.h @@ -19,10 +19,19 @@ #ifndef OggFLAC__TEST_LIBOGGFLAC_FILE_UTILS_H #define OggFLAC__TEST_LIBOGGFLAC_FILE_UTILS_H +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/format.h" +#include /* for off_t */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +#endif extern const long file_utils__serial_number; -FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); +FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); #endif diff --git a/src/test_libOggFLAC++/metadata_utils.c b/src/test_libOggFLAC++/metadata_utils.c index dcfa7654..c8669829 100644 --- a/src/test_libOggFLAC++/metadata_utils.c +++ b/src/test_libOggFLAC++/metadata_utils.c @@ -20,6 +20,10 @@ * These are not tests, just utility functions used by the metadata tests */ +#if HAVE_CONFIG_H +# include +#endif + #include "metadata_utils.h" #include "FLAC/metadata.h" #include diff --git a/src/test_libOggFLAC/decoders.c b/src/test_libOggFLAC/decoders.c index a6f5ca9f..2f356be6 100644 --- a/src/test_libOggFLAC/decoders.c +++ b/src/test_libOggFLAC/decoders.c @@ -16,6 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#if defined _MSC_VER || defined __MINGW32__ +//@@@ [2G limit] hacks for MSVC6 +#define fseeko fseek +#define ftello ftell +#endif #include "decoders.h" #include "file_utils.h" #include "metadata_utils.h" @@ -24,10 +37,6 @@ #include "OggFLAC/seekable_stream_decoder.h" #include "OggFLAC/stream_decoder.h" #include "share/grabbag.h" -#include -#include -#include -#include typedef struct { FILE *file; @@ -43,7 +52,7 @@ static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, ap static FLAC__StreamMetadata *expected_metadata_sequence_[8]; static unsigned num_expected_; static const char *oggflacfilename_ = "metadata.ogg"; -static unsigned oggflacfilesize_; +static off_t oggflacfilesize_; static FLAC__bool die_(const char *msg) { @@ -277,7 +286,7 @@ static FLAC__bool stream_decoder_test_respond_(OggFLAC__StreamDecoder *decoder, dcd->current_metadata_number = 0; - if(fseek(dcd->file, 0, SEEK_SET) < 0) { + if(fseeko(dcd->file, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -393,7 +402,7 @@ static FLAC__bool test_stream_decoder() printf("opening Ogg FLAC file... "); decoder_client_data.file = fopen(oggflacfilename_, "rb"); if(0 == decoder_client_data.file) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -479,7 +488,7 @@ static FLAC__bool test_stream_decoder() decoder_client_data.current_metadata_number = 0; printf("rewinding input... "); - if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) { + if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } @@ -831,7 +840,7 @@ static OggFLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_cal if(dcd->error_occurred) return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; - if(fseek(dcd->file, (long)absolute_byte_offset, SEEK_SET) < 0) { + if(fseeko(dcd->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) { dcd->error_occurred = true; return OggFLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; } @@ -842,7 +851,7 @@ static OggFLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_cal static OggFLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_callback_(const OggFLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { seekable_stream_decoder_client_data_struct *dcd = (seekable_stream_decoder_client_data_struct*)client_data; - long offset; + off_t offset; (void)decoder; @@ -854,7 +863,7 @@ static OggFLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_cal if(dcd->error_occurred) return OggFLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; - offset = ftell(dcd->file); + offset = ftello(dcd->file); *absolute_byte_offset = (FLAC__uint64)offset; if(offset < 0) { @@ -957,7 +966,7 @@ static FLAC__bool seekable_stream_decoder_test_respond_(OggFLAC__SeekableStreamD dcd->current_metadata_number = 0; - if(fseek(dcd->file, 0, SEEK_SET) < 0) { + if(fseeko(dcd->file, 0, SEEK_SET) < 0) { printf("FAILED rewinding input, errno = %d\n", errno); return false; } @@ -1103,7 +1112,7 @@ static FLAC__bool test_seekable_stream_decoder() printf("opening Ogg FLAC file... "); decoder_client_data.file = fopen(oggflacfilename_, "rb"); if(0 == decoder_client_data.file) { - printf("ERROR\n"); + printf("ERROR (%s)\n", strerror(errno)); return false; } printf("OK\n"); @@ -1198,7 +1207,7 @@ static FLAC__bool test_seekable_stream_decoder() decoder_client_data.current_metadata_number = 0; printf("rewinding input... "); - if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) { + if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) { printf("FAILED, errno = %d\n", errno); return false; } diff --git a/src/test_libOggFLAC/encoders.c b/src/test_libOggFLAC/encoders.c index b9bc2d98..cd0f1db0 100644 --- a/src/test_libOggFLAC/encoders.c +++ b/src/test_libOggFLAC/encoders.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "encoders.h" #include "file_utils.h" #include "metadata_utils.h" diff --git a/src/test_libOggFLAC/file_utils.c b/src/test_libOggFLAC/file_utils.c index ea7d4abb..d397b5b7 100644 --- a/src/test_libOggFLAC/file_utils.c +++ b/src/test_libOggFLAC/file_utils.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "file_utils.h" #include "FLAC/assert.h" #include "OggFLAC/stream_encoder.h" @@ -63,7 +67,7 @@ static void encoder_metadata_callback_(const OggFLAC__StreamEncoder *encoder, co (void)encoder, (void)metadata, (void)client_data; } -FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) { FLAC__int32 samples[1024]; OggFLAC__StreamEncoder *encoder; @@ -139,7 +143,7 @@ FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigne if(stat(output_filename, &filestats) != 0) return false; else - *output_filesize = (unsigned)filestats.st_size; + *output_filesize = filestats.st_size; } return true; diff --git a/src/test_libOggFLAC/file_utils.h b/src/test_libOggFLAC/file_utils.h index 69361e77..736ec927 100644 --- a/src/test_libOggFLAC/file_utils.h +++ b/src/test_libOggFLAC/file_utils.h @@ -19,10 +19,19 @@ #ifndef OggFLAC__TEST_LIBOGGFLAC_FILE_UTILS_H #define OggFLAC__TEST_LIBOGGFLAC_FILE_UTILS_H +/* needed because of off_t */ +#if HAVE_CONFIG_H +# include +#endif + #include "FLAC/format.h" +#include /* for off_t */ +#if defined _MSC_VER || defined __MINGW32__ +#include /* for off_t */ +#endif extern const long file_utils__serial_number; -FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); +FLAC__bool file_utils__generate_oggflacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata); #endif diff --git a/src/test_libOggFLAC/main.c b/src/test_libOggFLAC/main.c index 5be727f5..a8a65113 100644 --- a/src/test_libOggFLAC/main.c +++ b/src/test_libOggFLAC/main.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include "decoders.h" #include "encoders.h" diff --git a/src/test_libOggFLAC/metadata_utils.c b/src/test_libOggFLAC/metadata_utils.c index dcfa7654..c8669829 100644 --- a/src/test_libOggFLAC/metadata_utils.c +++ b/src/test_libOggFLAC/metadata_utils.c @@ -20,6 +20,10 @@ * These are not tests, just utility functions used by the metadata tests */ +#if HAVE_CONFIG_H +# include +#endif + #include "metadata_utils.h" #include "FLAC/metadata.h" #include diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index 36dbc4f9..de9df191 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H -#include +#if HAVE_CONFIG_H +# include #endif #include diff --git a/src/test_streams/main.c b/src/test_streams/main.c index fc4e631b..1780a584 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#if HAVE_CONFIG_H +# include +#endif + #include #include #include