aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-09 01:38:09 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-09 01:38:09 -0700
commitbb59a92bdb4f5b832a75ef9ff2c42aae58bdd7e9 (patch)
treeb4be9458914ea9e1272feba2b52505e38e9f0863 /src/dbUtils.c
parentd5187ce694cca1c5bd05bd562d9494e7387a86d0 (diff)
parent09dccb79f611110a5a653030c7c21958eda95a03 (diff)
downloadmpd-bb59a92bdb4f5b832a75ef9ff2c42aae58bdd7e9.tar.gz
mpd-bb59a92bdb4f5b832a75ef9ff2c42aae58bdd7e9.tar.xz
mpd-bb59a92bdb4f5b832a75ef9ff2c42aae58bdd7e9.zip
Merge branch 'mk/strset' into mk/playlist
* mk/strset: use strset.h instead of tagTracker.h strset: fix duplicate values added string set library Conflicts: src/dbUtils.c src/tagTracker.c
Diffstat (limited to 'src/dbUtils.c')
-rw-r--r--src/dbUtils.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index e447bc5ad..0eb485f1e 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"
@@ -278,7 +278,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;
@@ -293,7 +294,7 @@ 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);
}
}
}
@@ -301,6 +302,7 @@ static void visitTag(int fd, Song * song, enum tag_type tagType)
struct list_tags_data {
int fd;
ListCommandItem *item;
+ struct strset *set;
};
static int listUniqueTagsInDirectory(Song * song, void *_data)
@@ -310,7 +312,7 @@ static int listUniqueTagsInDirectory(Song * song, void *_data)
if (tagItemsFoundAndMatches(song, item->numConditionals,
item->conditionals)) {
- visitTag(data->fd, song, item->tagType);
+ visitTag(data->fd, data->set, song, item->tagType);
}
return 0;
@@ -320,22 +322,26 @@ int listAllUniqueTags(int fd, int type, int numConditionals,
LocateTagItem * conditionals)
{
int ret;
+ struct list_tags_data data;
ListCommandItem *item = newListCommandItem(type, numConditionals,
conditionals);
- struct list_tags_data data = {
- .fd = fd,
- .item = item,
- };
+ data.item = item;
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
- resetVisitedFlagsInTagTracker(type);
+ data.set = strset_new();
}
- ret = traverseAllIn(NULL, listUniqueTagsInDirectory, NULL,
- &data);
+ ret = traverseAllIn(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);