/* metaflac - Command-line FLAC metadata editor
- * Copyright (C) 2001,2002,2003,2004,2005,2006 Josh Coalson
+ * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
#include "utils.h"
#include "FLAC/assert.h"
#include "FLAC/metadata.h"
+#include "share/alloc.h"
#include "share/grabbag.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "operations_shorthand.h"
-static void show_version();
+static void show_version(void);
static FLAC__bool do_major_operation(const CommandLineOptions *options);
static FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options);
static FLAC__bool do_major_operation__list(const char *filename, FLAC__Metadata_Chain *chain, const CommandLineOptions *options);
* local routines
*/
-void show_version()
+void show_version(void)
{
printf("metaflac %s\n", FLAC__VERSION_STRING);
}
FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options)
{
- FLAC__bool ok = true, needs_write = false;
+ FLAC__bool ok = true, needs_write = false, is_ogg = false;
FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new();
if(0 == chain)
die("out of memory allocating chain");
- if(!FLAC__metadata_chain_read(chain, filename)) {
+ /*@@@@ lame way of guessing the file type */
+ if(strlen(filename) >= 4 && (0 == strcmp(filename+strlen(filename)-4, ".oga") || 0 == strcmp(filename+strlen(filename)-4, ".ogg")))
+ is_ogg = true;
+
+ if(! (is_ogg? FLAC__metadata_chain_read_ogg(chain, filename) : FLAC__metadata_chain_read(chain, filename)) ) {
print_error_with_chain_status(chain, "%s: ERROR: reading metadata", filename);
FLAC__metadata_chain_delete(chain);
return false;
}
if(
- 0 == (title_gains = (float*)malloc(sizeof(float) * num_files)) ||
- 0 == (title_peaks = (float*)malloc(sizeof(float) * num_files))
+ 0 == (title_gains = (float*)safe_malloc_mul_2op_(sizeof(float), /*times*/num_files)) ||
+ 0 == (title_peaks = (float*)safe_malloc_mul_2op_(sizeof(float), /*times*/num_files))
)
die("out of memory allocating space for title gains/peaks");
#ifdef _MSC_VER
PPR; printf(" total samples: %I64u\n", block->data.stream_info.total_samples);
#else
- PPR; printf(" total samples: %llu\n", block->data.stream_info.total_samples);
+ PPR; printf(" total samples: %llu\n", (unsigned long long)block->data.stream_info.total_samples);
#endif
PPR; printf(" MD5 signature: ");
for(i = 0; i < 16; i++) {
#ifdef _MSC_VER
PPR; printf(" point %u: sample_number=%I64u, stream_offset=%I64u, frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
#else
- PPR; printf(" point %u: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
+ PPR; printf(" point %u: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, (unsigned long long)block->data.seek_table.points[i].sample_number, (unsigned long long)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
#endif
}
else {
#ifdef _MSC_VER
PPR; printf(" lead-in: %I64u\n", block->data.cue_sheet.lead_in);
#else
- PPR; printf(" lead-in: %llu\n", block->data.cue_sheet.lead_in);
+ PPR; printf(" lead-in: %llu\n", (unsigned long long)block->data.cue_sheet.lead_in);
#endif
PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks);
#ifdef _MSC_VER
PPR; printf(" offset: %I64u\n", track->offset);
#else
- PPR; printf(" offset: %llu\n", track->offset);
+ PPR; printf(" offset: %llu\n", (unsigned long long)track->offset);
#endif
if(is_last) {
PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID");
#ifdef _MSC_VER
PPR; printf(" offset: %I64u\n", index->offset);
#else
- PPR; printf(" offset: %llu\n", index->offset);
+ PPR; printf(" offset: %llu\n", (unsigned long long)index->offset);
#endif
PPR; printf(" number: %u\n", (unsigned)index->number);
}