complete largefile support
diff --git a/build/config.mk b/build/config.mk
index 400949d..3def3db 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -44,12 +44,12 @@
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 fddfb87..ffe07ac 100644
--- a/configure.in
+++ b/configure.in
@@ -42,6 +42,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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_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 @@
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 @@
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 2aabf84..144e06e 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -65,7 +65,7 @@
<li>
General:
<ul>
- <li>(none)</li>
+ <li>Large file (>2GB) support everywhere</li>
</ul>
</li>
<li>
@@ -98,6 +98,7 @@
<ul>
<li>Added a new option <a href="documentation.html#metaflac_shorthand_set_tag_from_file"><span class="argument">--set-tag-from-file</span></a> for setting a tag from file (e.g. for importing a cuesheet as a tag).</li>
<li>Added shorthand operation <a href="documentation.html#metaflac_shorthand_remove_replay_gain"><span class="argument">--remove-replay-gain</span></a> for removing ReplayGain tags.</li>
+ <li><a href="documentation.html#metaflac_shorthand_export_cuesheet_to"><span class="argument">--export-cuesheet-to</span></a> now properly specifies the FLAC file name (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1272825&group_id=13478&atid=363478">SF #1272825</a>).</li>
<li>Importing of non-CDDA-compliant cuesheets now issues a warning.</li>
</ul>
</li>
@@ -105,14 +106,16 @@
plugins:
<ul>
<li>When ReplayGain is on, if tags for the preferred kind of gain (album/track) are not in a stream, the other kind will be used.</li>
- <li>Add ReplayGain info to file info box in XMMS plugin</li>
+ <li>Added ReplayGain info to file info box in XMMS plugin</li>
<li>Fixed UTF-8 decoder to disallow non-shortest-form and surrogate sequences (see <a href="http://www.unicode.org/versions/corrigendum1.html">here</a>).</li>
</ul>
</li>
<li>
build system:
<ul>
- <li>Add support for building on OS/2 with EMX (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1229495&group_id=13478&atid=113478">SF #1229495</a>)</li>
+ <li>Added support for building on OS/2 with EMX (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1229495&group_id=13478&atid=113478">SF #1229495</a>)</li>
+ <li>Added <span class="argument">--disable-doxygen-docs</span> to <span class="command">configure</span> for disabling Doxygen-based API doc generation (<a href="https://sourceforge.net/tracker/index.php?func=detail&aid=1365935&group_id=13478&atid=313478">SF #1365935</a>).</li>
+ <li>Added large file support with <span class="argument">AC_SYS_LARGEFILE</span>; use <span class="argument">--disable-largefile</span> with <span class="command">configure</span> to disable.</li>
</ul>
</li>
<li>
diff --git a/include/share/grabbag/file.h b/include/share/grabbag/file.h
index f98003f..e7d02cf 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 <config.h>
+#endif
+
#include <sys/types.h> /* for off_t */
#include <stdio.h> /* for FILE */
#include "FLAC/ordinals.h"
diff --git a/src/flac/analyze.c b/src/flac/analyze.c
index 614b4d2..207543e 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 <config.h>
+#endif
+
+#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -208,7 +213,7 @@
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 920f89e..5940ab9 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
#if defined _WIN32 && !defined __CYGWIN__
@@ -26,10 +26,16 @@
#else
# include <unistd.h>
#endif
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* for off_t */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
+#endif
#include <errno.h>
#include <math.h> /* for floor() */
-#include <stdio.h> /* for FILE et al. */
-#include <string.h> /* for strcmp() */
+#include <stdio.h> /* for FILE etc. */
+#include <string.h> /* for strcmp(), strerror() */
#include "FLAC/all.h"
#include "share/grabbag.h"
#include "share/replaygain_synthesis.h"
@@ -72,9 +78,9 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 61d1b03..8d42148 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 <config.h>
+#endif
+
#if defined _WIN32 && !defined __CYGWIN__
/* where MSVC puts unlink() */
# include <io.h>
#else
# include <unistd.h>
#endif
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* for off_t */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
+#endif
+#include <errno.h>
#include <limits.h> /* for LONG_MAX */
#include <math.h> /* for floor() */
#include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for malloc */
-#include <string.h> /* for strcmp() */
+#include <string.h> /* for strcmp(), strerror( */
#include "FLAC/all.h"
#include "share/grabbag.h"
#include "encode.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef FLAC__HAS_OGG
#include "OggFLAC/stream_encoder.h"
#include "OggFLAC/file_encoder.h"
@@ -160,7 +167,7 @@
/*
* 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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
}
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 @@
}
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 @@
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 40739d6..cfda543 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 <config.h>
+#endif
+
#include "FLAC/metadata.h"
#include "utils.h"
@@ -84,8 +89,8 @@
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 9b0d49f..1d78d18 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 <config.h>
+#endif
+
#include <string.h>
#include "utils.h"
diff --git a/src/flac/main.c b/src/flac/main.c
index 7c94762..14db8da 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 <config.h>
+#endif
+
#include <ctype.h>
+#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
@@ -24,10 +29,6 @@
#include <string.h>
#include <time.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#if !defined _MSC_VER && !defined __MINGW32__
/* unlink is in stdio.h in VC++ */
#include <unistd.h> /* for unlink() */
@@ -245,7 +246,7 @@
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 @@
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 @@
}
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 @@
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 @@
}
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 b120de4..f6b1b74 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 <config.h>
+#endif
+
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy(), memset() */
#include "private/bitbuffer.h"
diff --git a/src/libFLAC/bitmath.c b/src/libFLAC/bitmath.c
index bad52e7..a3e8b37 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 <config.h>
+#endif
+
#include "private/bitmath.h"
#include "FLAC/assert.h"
diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c
index 3bb8ff3..de2bb2a 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 <config.h>
+#endif
+
#include "private/cpu.h"
#include <stdlib.h>
#include <stdio.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#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 dbe7f03..1d31ca3 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 <config.h>
+#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 d2e7de4..6e499ed 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strcmp() */
@@ -36,6 +40,10 @@
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for _setmode() */
#include <fcntl.h> /* for _O_BINARY */
+#include <sys/types.h> /* for off_t */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
#elif defined __CYGWIN__
#include <io.h> /* for setmode(), O_BINARY */
#include <fcntl.h> /* for _O_BINARY */
@@ -606,7 +614,7 @@
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__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 2501779..3469bfd 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strlen(), strcpy() */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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__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__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 d683352..d432962 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 <config.h>
+#endif
+
#include <math.h>
#include "private/bitmath.h"
#include "private/fixed.h"
diff --git a/src/libFLAC/float.c b/src/libFLAC/float.c
index 534aa8d..7c58f65 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 <config.h>
+#endif
+
#include "FLAC/assert.h"
#include "private/float.h"
diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c
index 199053b..b5dfcaa 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for qsort() */
#include "FLAC/assert.h"
#include "FLAC/format.h"
#include "private/format.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef min
#undef min
#endif
diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c
index 14099da..ab73d0b 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 <config.h>
+#endif
+
#include <math.h>
#include "FLAC/assert.h"
#include "FLAC/format.h"
diff --git a/src/libFLAC/md5.c b/src/libFLAC/md5.c
index 9679387..5ea127a 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 <config.h>
+#endif
+
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy() */
#include "private/md5.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c
index 287a74c..956cb29 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 <config.h>
+#endif
+
#include "private/memory.h"
#include "FLAC/assert.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#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 88d7227..525b759 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 <config.h>
+#endif
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,6 +41,10 @@
#if defined _MSC_VER || defined __MINGW32__
#include <sys/utime.h> /* for utime() */
#include <io.h> /* for chmod() */
+#include <sys/types.h> /* for off_t */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
#else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */
@@ -109,10 +117,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
/* 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__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 @@
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 @@
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 @@
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 @@
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__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 @@
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 @@
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 @@
/* 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 @@
}
/* 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 @@
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 @@
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 @@
}
}
- /*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 @@
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 @@
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 @@
* 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 @@
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 @@
{
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_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_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_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 @@
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__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__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 @@
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__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 @@
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 @@
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 @@
*/
/* 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__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 @@
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 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 @@
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 @@
#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 a192aff..521a49b 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/src/libFLAC/seekable_stream_decoder.c b/src/libFLAC/seekable_stream_decoder.c
index 7db8309..c301d1f 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for calloc() */
#include <string.h> /* for memcpy()/memcmp() */
diff --git a/src/libFLAC/seekable_stream_encoder.c b/src/libFLAC/seekable_stream_encoder.c
index 771c085..b943db7 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for calloc() */
#include <string.h> /* for memcpy() */
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c
index e0fd36a..657ece3 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memset/memcpy() */
@@ -43,10 +47,6 @@
#include "private/lpc.h"
#include "private/memory.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef max
#undef max
#endif
diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c
index 2ff2f1c..6ecb872 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 <config.h>
+#endif
+
#include <limits.h>
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
@@ -51,10 +55,6 @@
#include "private/stream_encoder_framing.h"
#include "private/window.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef min
#undef min
#endif
diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c
index 311dd31..87611b7 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 <config.h>
+#endif
+
#include <stdio.h>
#include <string.h> /* for strlen() */
#include "private/stream_encoder_framing.h"
diff --git a/src/libFLAC/window.c b/src/libFLAC/window.c
index a13a21f..04cd662 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 <config.h>
+#endif
+
#include <math.h>
#include "FLAC/assert.h"
#include "FLAC/format.h"
diff --git a/src/libOggFLAC/file_decoder.c b/src/libOggFLAC/file_decoder.c
index 3e8d372..926f6bc 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strcmp() */
@@ -36,6 +40,10 @@
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for _setmode() */
#include <fcntl.h> /* for _O_BINARY */
+#include <sys/types.h> /* for off_t */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
#elif defined __CYGWIN__
#include <io.h> /* for setmode(), O_BINARY */
#include <fcntl.h> /* for _O_BINARY */
@@ -597,7 +605,7 @@
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__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 b16c581..e9e2821 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strlen(), strcpy() */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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__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__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 14b6f1e..06e2852 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 <config.h>
+#endif
+
#include <string.h> /* 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 97d4bc0..0ca9eed 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 <config.h>
+#endif
+
#include <string.h> /* 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 2097907..bebd7f0 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 <config.h>
+#endif
+
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcmp(), memcpy() */
#include "FLAC/assert.h"
diff --git a/src/libOggFLAC/ogg_mapping.c b/src/libOggFLAC/ogg_mapping.c
index 6dd2367..bfd27ad 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 <config.h>
+#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 668b5ec..9721ef8 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for calloc() */
#include <string.h> /* for memcpy()/memcmp() */
diff --git a/src/libOggFLAC/seekable_stream_encoder.c b/src/libOggFLAC/seekable_stream_encoder.c
index 855b234..b222905 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for calloc() */
#include <string.h> /* for memcpy() */
diff --git a/src/libOggFLAC/stream_decoder.c b/src/libOggFLAC/stream_decoder.c
index bc253c0..21557c6 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 <config.h>
+#endif
+
#include <stdlib.h> /* 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 dd172ea..1c7c95a 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for calloc() */
#include "FLAC/assert.h"
diff --git a/src/metaflac/operations.c b/src/metaflac/operations.c
index dd81039..173c091 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 <config.h>
+#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 a4d11a0..bd37fd4 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 <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h> /* for snprintf() */
+#include <string.h>
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "share/grabbag.h"
-#include <string.h>
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 @@
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 @@
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 @@
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 8ab93e2..51ba63e 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 <config.h>
+#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 f9d729f..738bec0 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 <config.h>
+#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 e28cbb5..700cdb4 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 <config.h>
+#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 <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -195,10 +200,10 @@
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 @@
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 @@
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 7e94742..8deeaad 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 <config.h>
+#endif
+
#include "options.h"
#include "usage.h"
#include "utils.h"
diff --git a/src/metaflac/usage.c b/src/metaflac/usage.c
index 4ba9f58..2ee9a4d 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 <config.h>
+#endif
+
#include "usage.h"
#include "FLAC/format.h"
#include <stdarg.h>
diff --git a/src/metaflac/utils.c b/src/metaflac/utils.c
index 6dd88f8..75991d6 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 <config.h>
+#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 45a6665..adc7aea 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 <config.h>
+#endif
+
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
diff --git a/src/monkeys_audio_utilities/flac_ren/main.c b/src/monkeys_audio_utilities/flac_ren/main.c
index bb07cc9..b307fd5 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<io.h>
-#include<sys/stat.h>
-#include<wtypes.h>
-#include<winbase.h>
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <io.h>
+#include <sys/stat.h>
+#include <wtypes.h>
+#include <winbase.h>
int main(int argc, char *argv[])
{
diff --git a/src/plugin_common/charset.c b/src/plugin_common/charset.c
index 575ac2a..e63c5c4 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
diff --git a/src/plugin_common/dither.c b/src/plugin_common/dither.c
index d7e0bae..feaf298 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 <config.h>
+#endif
+
#include "dither.h"
#include "FLAC/assert.h"
diff --git a/src/plugin_common/replaygain.c b/src/plugin_common/replaygain.c
index b9c83a4..8818d17 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 <config.h>
+#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 cf5a6ce..a8b283d 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 <config.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/src/plugin_winamp2/Makefile.am b/src/plugin_winamp2/Makefile.am
index fa193e8..684e170 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 98%
rename from src/plugin_winamp2/config.c
rename to src/plugin_winamp2/configure.c
index 913b59b..53975b3 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 <config.h>
+#endif
+
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
-#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 6c3bea4..48af5f3 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 <config.h>
+#endif
+
#include <windows.h>
+#include <limits.h> /* for INT_MAX */
#include <stdio.h>
#include "winamp2/in2.h"
-#include "config.h"
+#include "configure.h"
#include "infobox.h"
#include "tagz.h"
@@ -326,33 +331,33 @@
{
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 5be233a..8246805 100644
--- a/src/plugin_winamp2/in_flac.dsp
+++ b/src/plugin_winamp2/in_flac.dsp
@@ -107,11 +107,11 @@
# 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 640238e..2f9bce1 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 <config.h>
+#endif
+
#include <windows.h>
#include <stdio.h>
#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 d15ceb7..78965e5 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 <config.h>
+#endif
+
+#include <limits.h> /* for INT_MAX */
#include <stdlib.h>
#include <string.h> /* for memmove() */
#include "playback.h"
@@ -60,8 +65,7 @@
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 @@
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 @@
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 @@
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 a39149b..4120791 100644
--- a/src/plugin_winamp2/playback.h
+++ b/src/plugin_winamp2/playback.h
@@ -38,12 +38,12 @@
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 a75db2c..ddbca98 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <glib.h>
#include <string.h>
diff --git a/src/plugin_xmms/configure.c b/src/plugin_xmms/configure.c
index 6e6f571..4fd3448 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <glib.h>
diff --git a/src/plugin_xmms/fileinfo.c b/src/plugin_xmms/fileinfo.c
index 01f8dba..a79dac0 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <string.h> /* for strlen() */
#include <sys/types.h>
@@ -223,7 +227,11 @@
(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 0876bb4..fadede1 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 <config.h>
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -35,10 +40,6 @@
#include <xmms/util.h>
#include <xmms/plugin.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#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 1d4e61a..d6f409f 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 <config.h>
+#endif
+
+#include <limits.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
@@ -30,10 +35,6 @@
#include <xmms/configfile.h>
#include <xmms/titlestring.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef HAVE_LANGINFO_CODESET
#include <langinfo.h>
#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 @@
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 @@
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 @@
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 @@
{
(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 @@
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 0d73c83..308f064 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
diff --git a/src/share/getopt/getopt.c b/src/share/getopt/getopt.c
index 1e90fa8..279dff0 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
#if !defined __STDC__ || !__STDC__
diff --git a/src/share/getopt/getopt1.c b/src/share/getopt/getopt1.c
index 6c8c1ca..1e57486 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
#include "share/getopt.h"
diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c
index 19c8938..3de01ed 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 <config.h>
+#endif
+
#include "share/grabbag.h"
#include "FLAC/assert.h"
#include <stdio.h>
diff --git a/src/share/grabbag/file.c b/src/share/grabbag/file.c
index 6295954..7d7cb5e 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 <config.h>
+#endif
+
#if defined _MSC_VER || defined __MINGW32__
#include <sys/utime.h> /* for utime() */
#include <io.h> /* for chmod(), _setmode(), unlink() */
diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c
index ca3316d..356fc9f 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 <config.h>
+#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 92f4201..7893eb1 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 <config.h>
+#endif
+
#include "share/grabbag.h"
#include "FLAC/assert.h"
#include <stdlib.h> /* for atoi() */
diff --git a/src/share/replaygain_analysis/replaygain_analysis.c b/src/share/replaygain_analysis/replaygain_analysis.c
index 43e2ba6..5b9637c 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/share/replaygain_synthesis/replaygain_synthesis.c b/src/share/replaygain_synthesis/replaygain_synthesis.c
index b497092..85c5aac 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 <config.h>
+#endif
+
#include <string.h> /* for memset() */
#include <math.h>
#include "private/fast_float_math_hack.h"
diff --git a/src/share/utf8/charset.c b/src/share/utf8/charset.c
index 0b79699..3d13064 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#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 87426d0..1d5bf71 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 <config.h>
+#endif
+
#include <assert.h>
#include <string.h>
diff --git a/src/share/utf8/iconvert.c b/src/share/utf8/iconvert.c
index a23168f..b72ad86 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
#ifdef HAVE_ICONV
diff --git a/src/share/utf8/makemap.c b/src/share/utf8/makemap.c
index e19c196..72a9de1 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 <config.h>
+#endif
+
#include <errno.h>
#include <iconv.h>
#include <stdio.h>
diff --git a/src/share/utf8/utf8.c b/src/share/utf8/utf8.c
index 174d51f..a77e38b 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 <config.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "utf8.h"
#include "charset.h"
diff --git a/src/test_grabbag/cuesheet/main.c b/src/test_grabbag/cuesheet/main.c
index 1986f97..6bbf04a 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 <config.h>
+#endif
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -40,7 +45,7 @@
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 @@
}
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 @@
* 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 @@
}
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 d682cfd..a6ba8e7 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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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 @@
#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
#include "FLAC++/decoder.h"
#include "share/grabbag.h"
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#ifdef _MSC_VER
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
@@ -39,7 +44,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 800bbc9..8baf9ea 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 <config.h>
+#endif
+
#include "file_utils.h"
#include "FLAC/assert.h"
#include "FLAC/stream_encoder.h"
@@ -61,7 +65,7 @@
(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 @@
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 74b7201..1284616 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 <config.h>
+#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 <stdlib.h> /* for off_t */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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 44e2a27..ada4f9e 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 <stdio.h>
+#include <stdlib.h> /* for malloc() */
+#include <string.h> /* for memcpy()/memset() */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/utime.h> /* for utime() */
+#include <io.h> /* for chmod() */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
+#else
+#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
+#include <utime.h> /* for utime() */
+#include <unistd.h> /* for chown(), unlink() */
+#endif
+#include <sys/stat.h> /* for stat(), maybe chmod() */
extern "C" {
#include "file_utils.h"
}
@@ -23,19 +38,6 @@
#include "FLAC++/decoder.h"
#include "FLAC++/metadata.h"
#include "share/grabbag.h"
-#include <stdio.h>
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcpy()/memset() */
-
-#if defined _MSC_VER || defined __MINGW32__
-#include <sys/utime.h> /* for utime() */
-#include <io.h> /* for chmod() */
-#else
-#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
-#include <utime.h> /* for utime() */
-#include <unistd.h> /* for chown(), unlink() */
-#endif
-#include <sys/stat.h> /* for stat(), maybe chmod() */
/******************************************************************************
The general strategy of these tests (for interface levels 1 and 2) is
@@ -275,14 +277,14 @@
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 dcfa765..c866982 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 <config.h>
+#endif
+
#include "metadata_utils.h"
#include "FLAC/metadata.h"
#include <stdio.h>
diff --git a/src/test_libFLAC/bitbuffer.c b/src/test_libFLAC/bitbuffer.c
index 70c9951..52b5eaa 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 <config.h>
+#endif
+
#include "FLAC/assert.h"
#include "private/bitbuffer.h" /* from the libFLAC private include area */
#include <stdio.h>
diff --git a/src/test_libFLAC/decoders.c b/src/test_libFLAC/decoders.c
index 8a63ab7..f208a5b 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 <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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 <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
typedef struct {
FILE *file;
@@ -43,7 +52,7 @@
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 @@
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 @@
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 @@
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 @@
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__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 @@
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 @@
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 @@
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 @@
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 25eb943..34ec1ae 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 <config.h>
+#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 800bbc9..8baf9ea 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 <config.h>
+#endif
+
#include "file_utils.h"
#include "FLAC/assert.h"
#include "FLAC/stream_encoder.h"
@@ -61,7 +65,7 @@
(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 @@
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 74b7201..1284616 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 <config.h>
+#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 <stdlib.h> /* for off_t */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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 ee44c24..9c55a9a 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 <config.h>
+#endif
+
#include "FLAC/assert.h"
#include "FLAC/format.h"
#include <stdio.h>
diff --git a/src/test_libFLAC/main.c b/src/test_libFLAC/main.c
index 244adb9..0ff40bb 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 <config.h>
+#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 ba35d3d..a972d40 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 <config.h>
+#endif
+
#include "metadata.h"
#include <stdio.h>
diff --git a/src/test_libFLAC/metadata_manip.c b/src/test_libFLAC/metadata_manip.c
index 26d1a80..55d85ef 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 <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
-
#if defined _MSC_VER || defined __MINGW32__
#include <sys/utime.h> /* for utime() */
#include <io.h> /* for chmod() */
+//@@@ [2G limit] hacks for MSVC6
+#define fseeko fseek
+#define ftello ftell
#else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */
#include <unistd.h> /* for chown(), unlink() */
#endif
#include <sys/stat.h> /* 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 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 6d8b8d4..2805d41 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 <config.h>
+#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 dcfa765..c866982 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 <config.h>
+#endif
+
#include "metadata_utils.h"
#include "FLAC/metadata.h"
#include <stdio.h>
diff --git a/src/test_libOggFLAC++/decoders.cpp b/src/test_libOggFLAC++/decoders.cpp
index 5d0a0dc..0222cd9 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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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 @@
#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
#include "OggFLAC++/decoder.h"
#include "share/grabbag.h"
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#ifdef _MSC_VER
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
@@ -39,7 +44,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 ea7d4ab..d397b5b 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 <config.h>
+#endif
+
#include "file_utils.h"
#include "FLAC/assert.h"
#include "OggFLAC/stream_encoder.h"
@@ -63,7 +67,7 @@
(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 @@
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 69361e7..736ec92 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 <config.h>
+#endif
+
#include "FLAC/format.h"
+#include <stdlib.h> /* for off_t */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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 dcfa765..c866982 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 <config.h>
+#endif
+
#include "metadata_utils.h"
#include "FLAC/metadata.h"
#include <stdio.h>
diff --git a/src/test_libOggFLAC/decoders.c b/src/test_libOggFLAC/decoders.c
index a6f5ca9..2f356be 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 <config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#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 <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
typedef struct {
FILE *file;
@@ -43,7 +52,7 @@
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 @@
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 @@
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 @@
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 @@
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__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 @@
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 @@
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 @@
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 @@
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 b9bc2d9..cd0f1db 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 <config.h>
+#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 ea7d4ab..d397b5b 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 <config.h>
+#endif
+
#include "file_utils.h"
#include "FLAC/assert.h"
#include "OggFLAC/stream_encoder.h"
@@ -63,7 +67,7 @@
(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 @@
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 69361e7..736ec92 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 <config.h>
+#endif
+
#include "FLAC/format.h"
+#include <stdlib.h> /* for off_t */
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/types.h> /* 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 5be727f..a8a6511 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 <config.h>
+#endif
+
#include "decoders.h"
#include "encoders.h"
diff --git a/src/test_libOggFLAC/metadata_utils.c b/src/test_libOggFLAC/metadata_utils.c
index dcfa765..c866982 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 <config.h>
+#endif
+
#include "metadata_utils.h"
#include "FLAC/metadata.h"
#include <stdio.h>
diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c
index 36dbc4f..de9df19 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 <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
#include <signal.h>
diff --git a/src/test_streams/main.c b/src/test_streams/main.c
index fc4e631..1780a58 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 <config.h>
+#endif
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>