~ubuntu-branches/ubuntu/precise/flac/precise-updates

« back to all changes in this revision

Viewing changes to src/metaflac/operations_shorthand_cuesheet.c

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-05-29 22:56:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529225636-ljeff8xxip09qaap
Tags: 1.1.4-1
* New upstream release. closes: #405167, #411311
  - libOggFLAC and libOggFLAC++ have been merged into libFLAC, so
    remove their corresponding packages.
  - Because of the API changes required to effect the above, there has
    been yet another soname bump. libflac7 -> libflac8 and
    libflac++5 -> libflac++6. Emails have been dispatched to the
    maintainers of dependent packages.
* Some notes on patches that were removed:
  - 02_stdin_stdout, 06_manpage_mention_utf8_convert: merged upstream
  - 08_manpage_warnings: Upstream has changed the manpage so it defintely
    can't fit in in 80 cols, so just forget about it. We'll live.
  - 05_eof_warnings_are_errors: Upstream decided to add a -w option to
    flac to treat all warnings as errors. I am going to defer to that
    for now, but if people think it's stupid let me know and I'll port
    the patch forward.
  - 04_stack_smasher: was a backport from 1.1.3, so it's obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* metaflac - Command-line FLAC metadata editor
2
 
 * Copyright (C) 2001,2002,2003,2004,2005  Josh Coalson
 
2
 * Copyright (C) 2001,2002,2003,2004,2005,2006,2007  Josh Coalson
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU General Public License
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
17
 */
18
18
 
 
19
#if HAVE_CONFIG_H
 
20
#  include <config.h>
 
21
#endif
 
22
 
 
23
#include <errno.h>
 
24
#include <stdio.h> /* for snprintf() */
 
25
#include <string.h>
19
26
#include "options.h"
20
27
#include "utils.h"
21
28
#include "FLAC/assert.h"
22
29
#include "share/grabbag.h"
23
 
#include <string.h>
24
30
 
25
31
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, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);
26
32
static FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename);
118
124
                f = fopen(cs_filename, "r");
119
125
 
120
126
        if(0 == f) {
121
 
                fprintf(stderr, "%s: ERROR: can't open import file %s\n", filename, cs_filename);
 
127
                fprintf(stderr, "%s: ERROR: can't open import file %s: %s\n", filename, cs_filename, strerror(errno));
122
128
                return false;
123
129
        }
124
130
 
132
138
                return false;
133
139
        }
134
140
 
 
141
        if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) {
 
142
                fprintf(stderr, "%s: ERROR parsing cuesheet \"%s\": %s\n", filename, cs_filename, error_message);
 
143
                return false;
 
144
        }
 
145
 
 
146
        /* if we're expecting CDDA, warn about non-compliance */
 
147
        if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) {
 
148
                fprintf(stderr, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", filename, cs_filename, error_message);
 
149
                (*cuesheet)->data.cue_sheet.is_cd = false;
 
150
        }
 
151
 
135
152
        /* add seekpoints for each index point if required */
136
153
        if(0 != seekpoint_specification) {
137
154
                char spec[128];
145
162
#ifdef _MSC_VER
146
163
                                sprintf(spec, "%I64u;", tr->offset + tr->indices[index].offset);
147
164
#else
148
 
                                sprintf(spec, "%llu;", tr->offset + tr->indices[index].offset);
 
165
                                sprintf(spec, "%llu;", (unsigned long long)(tr->offset + tr->indices[index].offset));
149
166
#endif
150
167
                                local_strcat(seekpoint_specification, spec);
151
168
                        }
159
176
FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cuesheet, const char *cs_filename)
160
177
{
161
178
        FILE *f;
 
179
        char *ref = 0;
 
180
        size_t reflen;
162
181
 
163
182
        if(0 == cs_filename || strlen(cs_filename) == 0) {
164
183
                fprintf(stderr, "%s: ERROR: empty export file name\n", filename);
170
189
                f = fopen(cs_filename, "w");
171
190
 
172
191
        if(0 == f) {
173
 
                fprintf(stderr, "%s: ERROR: can't open export file %s\n", filename, cs_filename);
174
 
                return false;
175
 
        }
176
 
 
177
 
        grabbag__cuesheet_emit(f, cuesheet, "\"dummy.wav\" WAVE");
 
192
                fprintf(stderr, "%s: ERROR: can't open export file %s: %s\n", filename, cs_filename, strerror(errno));
 
193
                return false;
 
194
        }
 
195
 
 
196
        reflen = strlen(filename) + 7 + 1;
 
197
        if(0 == (ref = malloc(reflen))) {
 
198
                fprintf(stderr, "%s: ERROR: allocating memory\n", filename);
 
199
                return false;
 
200
        }
 
201
 
 
202
#if defined _MSC_VER || defined __MINGW32__
 
203
        _snprintf(ref, reflen, "\"%s\" FLAC", filename);
 
204
#else
 
205
        snprintf(ref, reflen, "\"%s\" FLAC", filename);
 
206
#endif
 
207
 
 
208
        grabbag__cuesheet_emit(f, cuesheet, ref);
 
209
 
 
210
        free(ref);
178
211
 
179
212
        if(f != stdout)
180
213
                fclose(f);