diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:09 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:09 +0200 |
commit | 0fc2422cd098223642f12eecfc3fcd93d9f495d2 (patch) | |
tree | ce00468b373eb49f449c3743d9d240867daa7927 | |
parent | e754ed01a77a0dfb5039148cd4990a669ea9024c (diff) | |
download | mpd-0fc2422cd098223642f12eecfc3fcd93d9f495d2.tar.gz mpd-0fc2422cd098223642f12eecfc3fcd93d9f495d2.tar.xz mpd-0fc2422cd098223642f12eecfc3fcd93d9f495d2.zip |
converted MpdTagItem.type to an enum
Don't use CPP macros when you can use C enum... this also allows
better type checking.
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 2 | ||||
-rw-r--r-- | src/dbUtils.c | 2 | ||||
-rw-r--r-- | src/locate.c | 4 | ||||
-rw-r--r-- | src/tag.c | 8 | ||||
-rw-r--r-- | src/tag.h | 34 |
5 files changed, 28 insertions, 22 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 9ed5b4e7e..49d69eebd 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -413,6 +413,8 @@ static void copyTagToVorbisComment(ShoutData * sd) case TAG_ITEM_TITLE: addTag(sd, "TITLE", sd->tag->items[i].value); break; + default: + break; } } } diff --git a/src/dbUtils.c b/src/dbUtils.c index 5d070e588..519c1802d 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -254,7 +254,7 @@ static void freeListCommandItem(ListCommandItem * item) free(item); } -static void visitTag(int fd, Song * song, int tagType) +static void visitTag(int fd, Song * song, enum tag_type tagType) { int i; MpdTag *tag = song->tag; diff --git a/src/locate.c b/src/locate.c index d97097f37..f68afdedb 100644 --- a/src/locate.c +++ b/src/locate.c @@ -121,7 +121,7 @@ void freeLocateTagItem(LocateTagItem * item) free(item); } -static int strstrSearchTag(Song * song, int type, char *str) +static int strstrSearchTag(Song * song, enum tag_type type, char *str) { int i; char *duplicate; @@ -169,7 +169,7 @@ int strstrSearchTags(Song * song, int numItems, LocateTagItem * items) return 1; } -static int tagItemFoundAndMatches(Song * song, int type, char *str) +static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str) { int i; @@ -606,7 +606,7 @@ static void deleteItem(MpdTag * tag, int idx) } } -void clearItemsFromMpdTag(MpdTag * tag, int type) +void clearItemsFromMpdTag(MpdTag * tag, enum tag_type type) { int i; @@ -697,7 +697,8 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2) } \ } -static void appendToTagItems(MpdTag * tag, int type, char *value, int len) +static void appendToTagItems(MpdTag * tag, enum tag_type type, + char *value, int len) { int i = tag->numOfItems; char *duplicated = xmalloc(len + 1); @@ -717,7 +718,8 @@ static void appendToTagItems(MpdTag * tag, int type, char *value, int len) free(duplicated); } -void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char *value, int len) +void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType, + char *value, int len) { if (ignoreTagItems[itemType]) { @@ -27,24 +27,25 @@ #include <id3tag.h> #endif -#define TAG_ITEM_ARTIST 0 -#define TAG_ITEM_ALBUM 1 -#define TAG_ITEM_TITLE 2 -#define TAG_ITEM_TRACK 3 -#define TAG_ITEM_NAME 4 -#define TAG_ITEM_GENRE 5 -#define TAG_ITEM_DATE 6 -#define TAG_ITEM_COMPOSER 7 -#define TAG_ITEM_PERFORMER 8 -#define TAG_ITEM_COMMENT 9 -#define TAG_ITEM_DISC 10 - -#define TAG_NUM_OF_ITEM_TYPES 11 +enum tag_type { + TAG_ITEM_ARTIST, + TAG_ITEM_ALBUM, + TAG_ITEM_TITLE, + TAG_ITEM_TRACK, + TAG_ITEM_NAME, + TAG_ITEM_GENRE, + TAG_ITEM_DATE, + TAG_ITEM_COMPOSER, + TAG_ITEM_PERFORMER, + TAG_ITEM_COMMENT, + TAG_ITEM_DISC, + TAG_NUM_OF_ITEM_TYPES +}; extern const char *mpdTagItemKeys[]; typedef struct _MpdTagItem { - mpd_sint8 type; + enum tag_type type; char *value; } MpdTagItem; @@ -66,11 +67,12 @@ MpdTag *newMpdTag(void); void initTagConfig(void); -void clearItemsFromMpdTag(MpdTag * tag, int itemType); +void clearItemsFromMpdTag(MpdTag * tag, enum tag_type itemType); void freeMpdTag(MpdTag * tag); -void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char *value, int len); +void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType, + char *value, int len); #define addItemToMpdTag(tag, itemType, value) \ addItemToMpdTagWithLen(tag, itemType, value, strlen(value)) |