Commit 59afe36f authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

Add file include/share/compat.h and start moving CPP hackery into it.

parent 49491910
......@@ -28,11 +28,9 @@
# include <config.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "share/compat.h"
#include "FLAC/stream_decoder.h"
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
......
......@@ -28,12 +28,10 @@
# include <config.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "share/compat.h"
#include "FLAC/metadata.h"
#include "FLAC/stream_encoder.h"
......
/* libFLAC - Free Lossless Audio Codec library
* Copyright (C) 2012 Xiph.org Foundation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Xiph.org Foundation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This is the prefered location of all CPP hackery to make $random_compiler
* work like something approaching a C99 (or maybe more accurately GNU99)
* compiler.
*
* It is assumed that this header will be included after "config.h".
*/
#if defined _WIN32 && !defined __CYGWIN__
/* where MSVC puts unlink() */
# include <io.h>
#else
# include <unistd.h>
#endif
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
......@@ -20,23 +20,6 @@
# 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 */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <errno.h>
#include <math.h> /* for floor() */
#include <stdio.h> /* for FILE etc. */
......@@ -44,6 +27,7 @@
#include "FLAC/all.h"
#include "share/grabbag.h"
#include "share/replaygain_synthesis.h"
#include "share/compat.h"
#include "decode.h"
typedef struct {
......
......@@ -20,23 +20,6 @@
# 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 */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <errno.h>
#include <limits.h> /* for LONG_MAX */
#include <math.h> /* for floor() */
......@@ -46,6 +29,7 @@
#include "FLAC/all.h"
#include "share/alloc.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "encode.h"
#ifdef min
......
......@@ -20,23 +20,13 @@
# include <config.h>
#endif
#if defined _MSC_VER || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for calloc() etc. */
#include <string.h> /* for memcmp() etc. */
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "share/alloc.h"
#include "share/compat.h"
#include "foreign_metadata.h"
#ifdef min
......
......@@ -23,17 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined _MSC_VER || defined __MINGW32__
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "share/compat.h"
#include "foreign_metadata.h"
static FLAC__uint32 unpack32be_(const FLAC__byte *b)
......
......@@ -46,14 +46,6 @@
#endif
#include <io.h> /* for chmod() */
#include <sys/types.h> /* for off_t */
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */
......@@ -66,6 +58,7 @@
#include "FLAC/assert.h"
#include "FLAC/stream_decoder.h"
#include "share/alloc.h"
#include "share/compat.h"
#ifdef max
#undef max
......
......@@ -46,19 +46,10 @@
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy() */
#include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "FLAC/assert.h"
#include "FLAC/stream_decoder.h"
#include "share/alloc.h"
#include "share/compat.h"
#include "protected/stream_encoder.h"
#include "private/bitwriter.h"
#include "private/bitmath.h"
......@@ -100,7 +91,7 @@
* parameter estimation in this encoder is very good, almost always
* yielding compression within 0.1% of the optimal parameters.
*/
#undef ENABLE_RICE_PARAMETER_SEARCH
#undef ENABLE_RICE_PARAMETER_SEARCH
typedef struct {
......@@ -236,7 +227,7 @@ static unsigned evaluate_lpc_subframe_(
#endif
static unsigned evaluate_verbatim_subframe_(
FLAC__StreamEncoder *encoder,
FLAC__StreamEncoder *encoder,
const FLAC__int32 signal[],
unsigned blocksize,
unsigned subframe_bps,
......@@ -824,7 +815,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_(
metadata_picture_has_type1 = true;
/* standard icon must be 32x32 pixel PNG */
if(
m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD &&
m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD &&
(
(strcmp(m->data.picture.mime_type, "image/png") && strcmp(m->data.picture.mime_type, "-->")) ||
m->data.picture.width != 32 ||
......@@ -1173,7 +1164,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(
/*is_ogg=*/true
);
}
static FLAC__StreamEncoderInitStatus init_FILE_internal_(
FLAC__StreamEncoder *encoder,
FILE *file,
......@@ -1235,7 +1226,7 @@ static FLAC__StreamEncoderInitStatus init_FILE_internal_(
return init_status;
}
FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(
FLAC__StreamEncoder *encoder,
FILE *file,
......@@ -1245,7 +1236,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(
{
return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/false);
}
FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(
FLAC__StreamEncoder *encoder,
FILE *file,
......
......@@ -27,9 +27,7 @@
#include "FLAC/metadata.h"
#include "share/alloc.h"
#include "share/grabbag.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include "share/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -21,15 +21,13 @@
#endif
#include <errno.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h> /* for snprintf() */
#include <string.h>
#include "options.h"
#include "utils.h"
#include "FLAC/assert.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "operations_shorthand.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, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);
......
......@@ -24,9 +24,7 @@
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include "share/compat.h"
#include <string.h>
#include "operations_shorthand.h"
......
......@@ -21,10 +21,8 @@
#endif
#include "share/grabbag.h"
#include "share/compat.h"
#include "FLAC/assert.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -24,20 +24,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined _MSC_VER || defined __MINGW32__
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#endif
#include "decoders.h"
#include "FLAC/assert.h"
#include "FLAC/stream_decoder.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h"
......
......@@ -21,9 +21,6 @@
#endif
#include <errno.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -31,6 +28,7 @@
#include "FLAC/assert.h"
#include "FLAC/stream_encoder.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h"
......
......@@ -26,14 +26,6 @@
#if defined _MSC_VER || defined __MINGW32__
#include <sys/utime.h> /* for utime() */
#include <io.h> /* for chmod() */
#if _MSC_VER <= 1600 /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
#else
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
#include <utime.h> /* for utime() */
......@@ -44,6 +36,7 @@
#include "FLAC/stream_decoder.h"
#include "FLAC/metadata.h"
#include "share/grabbag.h"
#include "share/compat.h"
#include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h"
#include "metadata.h"
......
......@@ -23,10 +23,8 @@
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h"
#include "share/compat.h"
#include "metadata.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcmp() */
......
......@@ -26,9 +26,7 @@
#include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h"
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include "share/compat.h"
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcmp() */
......
......@@ -20,9 +20,6 @@
# include <config.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -36,6 +33,7 @@
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
#include "FLAC/stream_decoder.h"
#include "share/compat.h"
typedef struct {
FLAC__int32 **pcm;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment