X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fflac%2Fiffscan.c;h=2a8a0ce464e4f1363b2c12f7e5cf260127805e35;hb=2199d086921eb37d249cae0731f334556ec6209d;hp=64e96388716b0476eee84fc0bbd1e1ff74cc8095;hpb=7617cacb282a00c0188aca3fec5613aa1d038740;p=platform%2Fupstream%2Fflac.git diff --git a/src/flac/iffscan.c b/src/flac/iffscan.c index 64e9638..2a8a0ce 100644 --- a/src/flac/iffscan.c +++ b/src/flac/iffscan.c @@ -1,5 +1,5 @@ /* iffscan - Simple AIFF/RIFF chunk scanner - * Copyright (C) 2007,2008 Josh Coalson + * Copyright (C) 2007,2008,2009 Josh Coalson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -11,9 +11,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #if HAVE_CONFIG_H @@ -23,13 +23,7 @@ #include #include #include -#if defined _MSC_VER || defined __MINGW32__ -#include /* for off_t */ -#if _MSC_VER <= 1600 /* @@@ [2G limit] */ -#define fseeko fseek -#define ftello ftell -#endif -#endif +#include "share/compat.h" #include "foreign_metadata.h" static FLAC__uint32 unpack32be_(const FLAC__byte *b) @@ -64,43 +58,50 @@ int main(int argc, char *argv[]) size_t i; FLAC__uint32 size; +#ifdef _WIN32 + if (get_utf8_argv(&argc, &argv) != 0) { + fprintf(stderr, "%ERROR: failed to convert command line parameters to UTF-8\n"); + return 1; + } +#endif + if(argc != 2) { - fprintf(stderr, "usage: %s { file.wav | file.aif }\n", argv[0]); + flac_fprintf(stderr, "usage: %s { file.wav | file.aif }\n", argv[0]); return 1; } fn = argv[1]; - if(0 == (f = fopen(fn, "rb")) || fread(buf, 1, 4, f) != 4) { - fprintf(stderr, "ERROR opening %s for reading\n", fn); + if(0 == (f = flac_fopen(fn, "rb")) || fread(buf, 1, 4, f) != 4) { + flac_fprintf(stderr, "ERROR opening %s for reading\n", fn); return 1; } fclose(f); if(0 == (fm = flac__foreign_metadata_new(memcmp(buf, "RIFF", 4) && memcmp(buf, "RF64", 4)? FOREIGN_BLOCK_TYPE__AIFF : FOREIGN_BLOCK_TYPE__RIFF))) { - fprintf(stderr, "ERROR: out of memory\n"); + flac_fprintf(stderr, "ERROR: out of memory\n"); return 1; } if(fm->type == FOREIGN_BLOCK_TYPE__AIFF) { if(!flac__foreign_metadata_read_from_aiff(fm, fn, &error)) { - fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); + flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); return 1; } } else { if(!flac__foreign_metadata_read_from_wave(fm, fn, &error)) { - fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); + flac_fprintf(stderr, "ERROR reading chunks from %s: %s\n", fn, error); return 1; } } - if(0 == (f = fopen(fn, "rb"))) { - fprintf(stderr, "ERROR opening %s for reading\n", fn); + if(0 == (f = flac_fopen(fn, "rb"))) { + flac_fprintf(stderr, "ERROR opening %s for reading\n", fn); return 1; } for(i = 0; i < fm->num_blocks; i++) { if(fseeko(f, fm->blocks[i].offset, SEEK_SET) < 0) { - fprintf(stderr, "ERROR seeking in %s\n", fn); + flac_fprintf(stderr, "ERROR seeking in %s\n", fn); return 1; } if(fread(buf, 1, i==0?12:8, f) != (i==0?12:8)) { - fprintf(stderr, "ERROR reading %s\n", fn); + flac_fprintf(stderr, "ERROR reading %s\n", fn); return 1; } size = unpack32_((const FLAC__byte*)buf+4, fm->type); @@ -111,18 +112,12 @@ int main(int argc, char *argv[]) printf(" offset size=%08x=(%10u)", fm->ssnd_offset_size, fm->ssnd_offset_size); else if(fm->type == FOREIGN_BLOCK_TYPE__RIFF && i == 1 && !memcmp(buf, "ds64", 4)) { if(fread(buf+8, 1, 36-8, f) != 36-8) { - fprintf(stderr, "ERROR reading %s\n", fn); + flac_fprintf(stderr, "ERROR reading %s\n", fn); return 1; } -#ifdef _MSC_VER - printf(" RIFF size=%016I64x=(%I64u)", unpack64le_(buf+8), unpack64le_(buf+8)); - printf(" data size=%016I64x=(%I64u)", unpack64le_(buf+16), unpack64le_(buf+16)); - printf(" sample count=%016I64x=(%I64u)", unpack64le_(buf+24), unpack64le_(buf+24)); -#else - printf(" RIFF size=%016llx=(%llu)", unpack64le_(buf+8), unpack64le_(buf+8)); - printf(" data size=%016llx=(%llu)", unpack64le_(buf+16), unpack64le_(buf+16)); - printf(" sample count=%016llx=(%llu)", unpack64le_(buf+24), unpack64le_(buf+24)); -#endif + printf(" RIFF size=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+8), unpack64le_(buf+8)); + printf(" data size=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+16), unpack64le_(buf+16)); + printf(" sample count=%016" PRIx64 "=(" PRIu64 ")", unpack64le_(buf+24), unpack64le_(buf+24)); printf(" table size=%08x=(%u)", unpack32le_(buf+32), unpack32le_(buf+32)); } printf("\n");