aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-09 13:16:03 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-09 13:16:03 -0700
commit8ea40fae6181d788b0900aa6c77c3cdb1e9b5992 (patch)
treef4a76b53742e37f0c0b52c9f310fde6ee39c0f2d /src/dbUtils.c
parenteffee99748e4c269e3eaa41bc664eccd06fa2367 (diff)
parent09dccb79f611110a5a653030c7c21958eda95a03 (diff)
downloadmpd-8ea40fae6181d788b0900aa6c77c3cdb1e9b5992.tar.gz
mpd-8ea40fae6181d788b0900aa6c77c3cdb1e9b5992.tar.xz
mpd-8ea40fae6181d788b0900aa6c77c3cdb1e9b5992.zip
Merge branch 'mk/strset'
* mk/strset: use strset.h instead of tagTracker.h strset: fix duplicate values added string set library
Diffstat (limited to 'src/dbUtils.c')
-rw-r--r--src/dbUtils.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index d39c9908c..00fa1d441 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -24,7 +24,7 @@
#include "playlist.h"
#include "song.h"
#include "tag.h"
-#include "tagTracker.h"
+#include "strset.h"
#include "log.h"
#include "storedPlaylist.h"
@@ -254,7 +254,8 @@ static void freeListCommandItem(ListCommandItem * item)
free(item);
}
-static void visitTag(int fd, Song * song, enum tag_type tagType)
+static void visitTag(int fd, struct strset *set,
+ Song * song, enum tag_type tagType)
{
int i;
struct mpd_tag *tag = song->tag;
@@ -269,18 +270,25 @@ static void visitTag(int fd, Song * song, enum tag_type tagType)
for (i = 0; i < tag->numOfItems; i++) {
if (tag->items[i]->type == tagType) {
- visitInTagTracker(tagType, tag->items[i]->value);
+ strset_add(set, tag->items[i]->value);
}
}
}
-static int listUniqueTagsInDirectory(int fd, Song * song, void *data)
+struct list_tags_data {
+ int fd;
+ ListCommandItem *item;
+ struct strset *set;
+};
+
+static int listUniqueTagsInDirectory(int fd, Song * song, void *_data)
{
- ListCommandItem *item = data;
+ struct list_tags_data *data = _data;
+ ListCommandItem *item = data->item;
if (tagItemsFoundAndMatches(song, item->numConditionals,
item->conditionals)) {
- visitTag(fd, song, item->tagType);
+ visitTag(fd, data->set, song, item->tagType);
}
return 0;
@@ -290,18 +298,28 @@ int listAllUniqueTags(int fd, int type, int numConditionals,
LocateTagItem * conditionals)
{
int ret;
+ struct list_tags_data data;
ListCommandItem *item = newListCommandItem(type, numConditionals,
conditionals);
+ data.fd = fd;
+ data.item = item;
+
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
- resetVisitedFlagsInTagTracker(type);
+ data.set = strset_new();
}
- ret = traverseAllIn(fd, NULL, listUniqueTagsInDirectory, NULL,
- (void *)item);
+ ret = traverseAllIn(fd, NULL, listUniqueTagsInDirectory, NULL, &data);
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
- printVisitedInTagTracker(fd, type);
+ const char *value;
+
+ strset_rewind(data.set);
+
+ while ((value = strset_next(data.set)) != NULL)
+ fdprintf(fd, "%s: %s\n", mpdTagItemKeys[type], value);
+
+ strset_free(data.set);
}
freeListCommandItem(item);