aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:09 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 18:36:18 -0700
commit29eba419627437fb6f20714bb553d39a58305c5e (patch)
tree88e8987dfc3582cfff15d76637cf63716d7237eb /src
parent554c708450dd5008c310902f67702b9727b944d3 (diff)
downloadmpd-29eba419627437fb6f20714bb553d39a58305c5e.tar.gz
mpd-29eba419627437fb6f20714bb553d39a58305c5e.tar.xz
mpd-29eba419627437fb6f20714bb553d39a58305c5e.zip
converted MpdTagItem.type to an enum
Don't use CPP macros when you can use C enum... this also allows better type checking.
Diffstat (limited to 'src')
-rw-r--r--src/audioOutputs/audioOutput_shout.c2
-rw-r--r--src/dbUtils.c2
-rw-r--r--src/locate.c4
-rw-r--r--src/tag.c8
-rw-r--r--src/tag.h34
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;
diff --git a/src/tag.c b/src/tag.c
index 5023a58cb..fc85a6ff9 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -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])
{
diff --git a/src/tag.h b/src/tag.h
index 363ad98aa..99b32653c 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -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))