aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbUtils.c15
-rw-r--r--src/tagTracker.c43
-rw-r--r--src/tagTracker.h4
3 files changed, 42 insertions, 20 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 60344a291..dd698789c 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -213,7 +213,7 @@ void freeListCommandItem(ListCommandItem * item) {
free(item);
}
-void printUnvisitedTags(FILE * fp, Song * song, int tagType) {
+void visitTag(FILE * fp, Song * song, int tagType) {
int i;
MpdTag * tag = song->tag;
@@ -225,11 +225,8 @@ void printUnvisitedTags(FILE * fp, Song * song, int tagType) {
if(!tag) return;
for(i = 0; i < tag->numOfItems; i++) {
- if(tag->items[i].type == tagType &&
- !wasVisitedInTagTracker(tagType, tag->items[i].value))
- {
- myfprintf(fp, "%s: %s\n", mpdTagItemKeys[tagType],
- tag->items[i].value);
+ if(tag->items[i].type == tagType) {
+ visitInTagTracker(tagType, tag->items[i].value);
}
}
}
@@ -246,7 +243,7 @@ int listUniqueTagsInDirectory(FILE * fp, Song * song, void * data) {
}
}
- printUnvisitedTags(fp, song, item->tagType);
+ visitTag(fp, song, item->tagType);
return 0;
}
@@ -265,6 +262,10 @@ int listAllUniqueTags(FILE * fp, int type, int numConditionals,
ret = traverseAllIn(fp, NULL, listUniqueTagsInDirectory, NULL,
(void *)item);
+ if(type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
+ printVisitedInTagTracker(fp, type);
+ }
+
freeListCommandItem(item);
return ret;
diff --git a/src/tagTracker.c b/src/tagTracker.c
index b7608ed97..e2594341d 100644
--- a/src/tagTracker.c
+++ b/src/tagTracker.c
@@ -24,8 +24,6 @@ typedef struct tagTrackerItem {
char * getTagItemString(int type, char * string) {
ListNode * node;
- if(type == TAG_ITEM_TITLE) return strdup(string);
-
if(tagLists[type] == NULL) {
tagLists[type] = makeList(free, 1);
}
@@ -48,11 +46,6 @@ void removeTagItemString(int type, char * string) {
assert(string);
- if(type == TAG_ITEM_TITLE) {
- free(string);
- return;
- }
-
assert(tagLists[type]);
if(tagLists[type] == NULL) return;
@@ -124,9 +117,7 @@ void resetVisitedFlagsInTagTracker(int type) {
}
int wasVisitedInTagTracker(int type, char * str) {
- int ret;
ListNode * node;
- TagTrackerItem * item;
if(!tagLists[type]) return 0;
@@ -134,9 +125,35 @@ int wasVisitedInTagTracker(int type, char * str) {
if(!node) return 0;
- item = node->data;
- ret = item->visited;
- item->visited = 1;
+ return ((TagTrackerItem *)node->data)->visited;
+}
+
+void visitInTagTracker(int type, char * str) {
+ ListNode * node;
+
+ if(!tagLists[type]) return;
+
+ node = findNodeInList(tagLists[type], str);
- return ret;
+ if(!node) return;
+
+ ((TagTrackerItem *)node->data)->visited = 1;
}
+
+void printVisitedInTagTracker(FILE * fp, int type) {
+ ListNode * node;
+ TagTrackerItem * item;
+
+ if(!tagLists[type]) return;
+
+ node = tagLists[type]->firstNode;
+
+ while(node) {
+ item = node->data;
+ if(item->visited) {
+ myfprintf(fp, "%s: %s\n", mpdTagItemKeys[type],
+ node->key);
+ }
+ node = node->nextNode;
+ }
+
diff --git a/src/tagTracker.h b/src/tagTracker.h
index 7c9740c64..60713b0da 100644
--- a/src/tagTracker.h
+++ b/src/tagTracker.h
@@ -17,4 +17,8 @@ void resetVisitedFlagsInTagTracker(int type);
int wasVisitedInTagTracker(int type, char * str);
+void visitInTagTracker(int type, char * str);
+
+void printVisitedInTagTracker(FILE * fp, int type);
+
#endif