1
/* plugin_common - Routines common to several plugins
2
* Copyright (C) 2002,2003 Josh Coalson
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include "FLAC/assert.h"
23
#include "locale_hack.h"
27
* Do not sort genres!!
28
* Last Update: 2000/04/30
30
static const char * const FLAC_plugin__id3v1_tag_genre_table[] =
52
"Alternative", /* 20 */
57
"Euro-Techno", /* 25 */
72
"Altern Rock", /* 40 */
77
"Meditative", /* 45 */
122
"Avantgarde", /* 90 */
127
"Slow Rock", /* 95 */
147
"Folklore", /* 115 */
157
"Dance Hall", /* 125 */
168
"Christian Gangsta Rap",
172
"Contemporary Christian",/* 140 */
183
FLAC__bool FLAC_plugin__id3v1_tag_get(const char *filename, FLAC_Plugin__Id3v1_Tag *tag)
188
FLAC__ASSERT(0 != filename);
189
FLAC__ASSERT(0 != tag);
191
memset(tag, 0, sizeof(FLAC_Plugin__Id3v1_Tag));
193
if(0 == (f = fopen(filename, "rb")))
195
if(-1 == fseek(f, -128, SEEK_END)) {
199
if(fread(raw, 1, 128, f) < 128) {
204
if(strncmp(raw, "TAG", 3))
207
memcpy(tag->tag, raw, 3);
208
memcpy(tag->title, raw+3, 30);
209
memcpy(tag->artist, raw+33, 30);
210
memcpy(tag->album, raw+63, 30);
211
memcpy(tag->year, raw+93, 4);
212
memcpy(tag->comment.v1_0.comment, raw+97, 30);
213
tag->genre = raw[127];
218
const char *FLAC_plugin__id3v1_tag_get_genre_as_string(unsigned char genre_code)
220
if (genre_code < FLAC_plugin__id3v1_tag_genre_table_max())
221
return gettext(FLAC_plugin__id3v1_tag_genre_table[genre_code]);
226
unsigned FLAC_plugin__id3v1_tag_genre_table_max()
228
return sizeof(FLAC_plugin__id3v1_tag_genre_table) / sizeof(FLAC_plugin__id3v1_tag_genre_table[0]) - 1;