diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 21:48:08 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 21:48:08 +0000 |
commit | 021a0915c2bc6e62bda3e45a89c95266f3b2da47 (patch) | |
tree | c789eb800bfb04d5934728a327c5dd90c569e21c | |
parent | 0337ec851c643503afd2287f03ca42b5adf5cad7 (diff) | |
download | mpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.tar.gz mpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.tar.xz mpd-021a0915c2bc6e62bda3e45a89c95266f3b2da47.zip |
ok, list is now reimplemented, should be ready to go, this branch is now
compatible with trunk mpd again, time merge
git-svn-id: https://svn.musicpd.org/mpd/branches/r2562-metadata-handling-rewrite@2587 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | src/command.c | 32 | ||||
-rw-r--r-- | src/tagTracker.c | 53 | ||||
-rw-r--r-- | src/tagTracker.h | 4 |
3 files changed, 77 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c index 35045b472..5b3616a40 100644 --- a/src/command.c +++ b/src/command.c @@ -613,11 +613,35 @@ int handleClearError(FILE * fp, unsigned int * permission, int argArrayLength, int handleList(FILE * fp, unsigned int * permission, int argArrayLength, char ** argArray) { - char * arg1 = NULL; + int numConditionals = 0; + LocateTagItem * conditionals = NULL; + int tagType = getLocateTagItemType(argArray[1]); + int ret; - if(argArrayLength==3) arg1 = argArray[2]; - //return printAllKeysOfTable(fp,argArray[1],arg1); - return 0; + if(tagType < 0) { + commandError(fp, ACK_ERROR_ARG, + "\"%s\" is not known", argArray[1]); + return -1; + } + + /* for compatibility with < 0.12.0 */ + if(argArrayLength==3) { + if(tagType != TAG_ITEM_ALBUM) { + commandError(fp, ACK_ERROR_ARG, + "should be \"%s\" for 3 arguments", + mpdTagItemKeys[TAG_ITEM_ALBUM]); + return -1; + } + conditionals = newLocateTagItem(mpdTagItemKeys[TAG_ITEM_ARTIST], + argArray[2]); + numConditionals = 1; + } + + ret = listAllUniqueTags(fp, tagType, numConditionals,conditionals); + + if(conditionals) free(conditionals); + + return ret; } int handleMove(FILE * fp, unsigned int * permission, int argArrayLength, diff --git a/src/tagTracker.c b/src/tagTracker.c index cea02f471..30ae7641b 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -16,6 +16,11 @@ static List * tagLists[TAG_NUM_OF_ITEM_TYPES] = NULL }; +typedef struct tagTrackerItem { + int count; + mpd_sint8 visited; +} TagTrackerItem; + char * getTagItemString(int type, char * string) { ListNode * node; @@ -26,12 +31,13 @@ char * getTagItemString(int type, char * string) { } if((node = findNodeInList(tagLists[type], string))) { - (*((int *)node->data))++; + ((TagTrackerItem *)node->data)->count++; } else { - int * intPtr = malloc(sizeof(int)); - *intPtr = 1; - node = insertInList(tagLists[type], string, intPtr); + TagTrackerItem * item = malloc(sizeof(TagTrackerItem)); + item->count = 1; + item->visited = 0; + node = insertInList(tagLists[type], string, item); } return node->key; @@ -53,9 +59,9 @@ void removeTagItemString(int type, char * string) { node = findNodeInList(tagLists[type], string); assert(node); if(node) { - int * countPtr = node->data; - (*countPtr)--; - if(*countPtr <= 0) deleteNodeFromList(tagLists[type], node); + TagTrackerItem * item = node->data; + item->count--; + if(item->count <= 0) deleteNodeFromList(tagLists[type], node); } if(tagLists[type]->numberOfNodes == 0) { @@ -84,7 +90,7 @@ void printMemorySavedByTagTracker() { while(node != NULL) { sum -= sizeof(ListNode); - sum -= sizeof(int); + sum -= sizeof(TagTrackerItem); sum -= sizeof(node->key); sum += (strlen(node->key)+1)*(*((int *)node->data)); node = node->nextNode; @@ -103,3 +109,34 @@ void sortTagTrackerInfo() { sortList(tagLists[i]); } } + +void resetVisitedFlagsInTagTracker(int type) { + ListNode * node; + + if(!tagLists[type]) return; + + node = tagLists[type]->firstNode; + + while(node) { + ((TagTrackerItem *)node->data)->visited = 0; + node = node->nextNode; + } +} + +int wasVisitedInTagTracker(int type, char * str) { + int ret; + ListNode * node; + TagTrackerItem * item; + + if(!tagLists[type]) return 0; + + node = findNodeInList(tagLists[type], str); + + if(!node) return 0; + + item = node->data; + ret = item->visited; + item->visited = 1; + + return ret; +} diff --git a/src/tagTracker.h b/src/tagTracker.h index fcafde736..7c9740c64 100644 --- a/src/tagTracker.h +++ b/src/tagTracker.h @@ -13,4 +13,8 @@ void printMemorySavedByTagTracker(); void sortTagTrackerInfo(); +void resetVisitedFlagsInTagTracker(int type); + +int wasVisitedInTagTracker(int type, char * str); + #endif |