/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
+ * Copyright (C) 2000-2009 Josh Coalson
+ * Copyright (C) 2011-2013 Xiph.Org Foundation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
/* technically this should be in an "export.c" but this is convenient enough */
-#ifdef FLAC_API_SUPPORTS_OGG_FLAC
-FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = FLAC__HAS_OGG ;
+FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC =
+#if FLAC__HAS_OGG
+ 1
#else
-FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = 0 ;
+ 0
#endif
+;
/***********************************************************************
*
***********************************************************************/
-static FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
+static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
/***********************************************************************
*
if(0 == write_callback || 0 == error_callback)
return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
- file = filename? fopen(filename, "rb") : stdin;
+ file = filename? flac_fopen(filename, "rb") : stdin;
if(0 == file)
return FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE;
id = 0;
continue;
}
+
+ if(id >= 3)
+ return false;
+
if(x == ID3V2_TAG_[id]) {
id++;
i = 0;
return false;
}
for(j = 0; j < track->num_indices; j++) {
- FLAC__StreamMetadata_CueSheet_Index *index = &track->indices[j];
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &index->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN))
+ FLAC__StreamMetadata_CueSheet_Index *indx = &track->indices[j];
+ if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &indx->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN))
return false; /* read_callback_ sets the state for us */
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN))
return false; /* read_callback_ sets the state for us */
- index->number = (FLAC__byte)x;
+ indx->number = (FLAC__byte)x;
if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN))
return false; /* read_callback_ sets the state for us */
FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
{
-#if defined _MSC_VER || defined __MINGW32__
- struct _stat64 filestats;
-#else
- struct stat filestats;
-#endif
+ struct flac_stat_s filestats;
(void)client_data;
if(decoder->private_->file == stdin)
return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
-#if defined _MSC_VER || defined __MINGW32__
- else if(_fstat64(fileno(decoder->private_->file), &filestats) != 0)
-#else
- else if(fstat(fileno(decoder->private_->file), &filestats) != 0)
-#endif
+ else if(flac_fstat(fileno(decoder->private_->file), &filestats) != 0)
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
else {
*stream_length = (FLAC__uint64)filestats.st_size;