converted MpdTagItem.type to an enum

Don't use CPP macros when you can use C enum... this also allows
better type checking.
This commit is contained in:
Max Kellermann 2008-08-26 08:27:09 +02:00
parent e754ed01a7
commit 0fc2422cd0
5 changed files with 28 additions and 22 deletions

View File

@ -413,6 +413,8 @@ static void copyTagToVorbisComment(ShoutData * sd)
case TAG_ITEM_TITLE:
addTag(sd, "TITLE", sd->tag->items[i].value);
break;
default:
break;
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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])
{

View File

@ -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))