endswap.h \
getopt.h \
grabbag.h \
+ macros.h \
replaygain_analysis.h \
replaygain_synthesis.h \
utf8.h
--- /dev/null
+/* libFLAC - Free Lossless Audio Codec library
+ * Copyright (C) 2013 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.
+ */
+
+#include <errno.h>
+
+/* FLAC_CHECK_RETURN : Check the return value of of the provided function and
+ * print and error message if it fails (ie returns a value < 0).
+ */
+
+#define FLAC_CHECK_RETURN(x) \
+ { if ((x) < 0) \
+ printf ("%s : %s\n", #x, strerror (errno)) ; \
+ }
#include "FLAC/stream_decoder.h"
#include "share/alloc.h"
#include "share/compat.h"
+#include "share/macros.h"
#include "private/macros.h"
#include "private/memory.h"
(void)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__
- (void)chown(filename, stats->st_uid, -1);
- (void)chown(filename, -1, stats->st_gid);
+ FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
+ FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
#endif
}
}
ret = true;
- while(ret && !feof(f)) {
- fgets(line, sizeof(line), f);
+ while(ret && !feof(f) && fgets(line, sizeof(line), f) != NULL) {
if(!feof(f)) {
char *p = strchr(line, '\n');
if(0 == p) {
#include "FLAC++/metadata.h"
#include "share/grabbag.h"
#include "share/compat.h"
+#include "share/macros.h"
extern "C" {
#include "test_libs_common/file_utils_flac.h"
}
(void)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
- (void)chown(filename, stats->st_uid, (gid_t)(-1));
- (void)chown(filename, (uid_t)(-1), stats->st_gid);
+ FLAC_CHECK_RETURN(chown(filename, stats->st_uid, (gid_t)(-1)));
+ FLAC_CHECK_RETURN(chown(filename, (uid_t)(-1), stats->st_gid));
#endif
}
#include "FLAC/metadata.h"
#include "share/grabbag.h"
#include "share/compat.h"
+#include "share/macros.h"
#include "test_libs_common/file_utils_flac.h"
#include "test_libs_common/metadata_utils.h"
#include "metadata.h"
(void)chmod(filename, stats->st_mode);
(void)utime(filename, &srctime);
#if !defined _MSC_VER && !defined __MINGW32__
- (void)chown(filename, stats->st_uid, -1);
- (void)chown(filename, -1, stats->st_gid);
+ FLAC_CHECK_RETURN(chown(filename, stats->st_uid, -1));
+ FLAC_CHECK_RETURN(chown(filename, -1, stats->st_gid));
#endif
}
signed char c;
for(i = 0; i < samples; i++) {
for(j = 0; j < channels; j++) {
- fread(&c, 1, 1, f);
- pcm[j][i] = c;
+ if (fread(&c, 1, 1, f) == 1)
+ pcm[j][i] = c;
}
}
}
unsigned char c[2];
for(i = 0; i < samples; i++) {
for(j = 0; j < channels; j++) {
- fread(&c, 1, 2, f);
- pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1];
+ if (fread(&c, 1, 2, f) == 2)
+ pcm[j][i] = ((int)((signed char)c[0])) << 8 | (int)c[1];
}
}
}