aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-02-11 10:37:59 +0100
committerMax Kellermann <max@duempel.org>2012-02-11 12:37:24 +0100
commit9e5a49b8cb6d655bdab52232f390a4faa9253f99 (patch)
treeb7d0cae68a9b2f7106d5952a64c2761611999d30
parent767ade02f4af8cdb6b7de293d0bd433bc7fd24cf (diff)
downloadmpd-9e5a49b8cb6d655bdab52232f390a4faa9253f99.tar.gz
mpd-9e5a49b8cb6d655bdab52232f390a4faa9253f99.tar.xz
mpd-9e5a49b8cb6d655bdab52232f390a4faa9253f99.zip
tag_id3: use the tag_table library for TXXX
Diffstat (limited to '')
-rw-r--r--src/tag_id3.c25
-rw-r--r--src/tag_table.h16
2 files changed, 26 insertions, 15 deletions
diff --git a/src/tag_id3.c b/src/tag_id3.c
index 829b196b8..1facf3c18 100644
--- a/src/tag_id3.c
+++ b/src/tag_id3.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "tag_id3.h"
+#include "tag_table.h"
#include "tag.h"
#include "riff.h"
#include "aiff.h"
@@ -242,23 +243,17 @@ tag_id3_import_comment(struct tag *dest, struct id3_tag *tag, const char *id,
static enum tag_type
tag_id3_parse_txxx_name(const char *name)
{
- static const struct {
- enum tag_type type;
- const char *name;
- } musicbrainz_txxx[] = {
- { TAG_ALBUM_ARTIST_SORT, "ALBUMARTISTSORT" },
- { TAG_MUSICBRAINZ_ARTISTID, "MusicBrainz Artist Id" },
- { TAG_MUSICBRAINZ_ALBUMID, "MusicBrainz Album Id" },
- { TAG_MUSICBRAINZ_ALBUMARTISTID,
- "MusicBrainz Album Artist Id" },
- { TAG_MUSICBRAINZ_TRACKID, "MusicBrainz Track Id" },
+ static const struct tag_table txxx_tags[] = {
+ { "ALBUMARTISTSORT", TAG_ALBUM_ARTIST_SORT },
+ { "MusicBrainz Artist Id", TAG_MUSICBRAINZ_ARTISTID },
+ { "MusicBrainz Album Id", TAG_MUSICBRAINZ_ALBUMID },
+ { "MusicBrainz Album Artist Id",
+ TAG_MUSICBRAINZ_ALBUMARTISTID },
+ { "MusicBrainz Track Id", TAG_MUSICBRAINZ_TRACKID },
+ { NULL, TAG_NUM_OF_ITEM_TYPES }
};
- for (unsigned i = 0; i < G_N_ELEMENTS(musicbrainz_txxx); ++i)
- if (strcmp(name, musicbrainz_txxx[i].name) == 0)
- return musicbrainz_txxx[i].type;
-
- return TAG_NUM_OF_ITEM_TYPES;
+ return tag_table_lookup(txxx_tags, name);
}
/**
diff --git a/src/tag_table.h b/src/tag_table.h
index ecb3805d2..d87d4869a 100644
--- a/src/tag_table.h
+++ b/src/tag_table.h
@@ -31,6 +31,22 @@ struct tag_table {
};
/**
+ * Looks up a string in a tag translation table (case sensitive).
+ * Returns TAG_NUM_OF_ITEM_TYPES if the specified name was not found
+ * in the table.
+ */
+G_GNUC_PURE
+static inline enum tag_type
+tag_table_lookup(const struct tag_table *table, const char *name)
+{
+ for (; table->name != NULL; ++table)
+ if (strcmp(name, table->name) == 0)
+ return table->type;
+
+ return TAG_NUM_OF_ITEM_TYPES;
+}
+
+/**
* Looks up a string in a tag translation table (case insensitive).
* Returns TAG_NUM_OF_ITEM_TYPES if the specified name was not found
* in the table.