From 349539740b81ae4447f94c45c697e873c97072ea Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Mon, 28 Feb 2005 23:57:47 +0000 Subject: add "any" option for search and find, patch from Robert Andersson git-svn-id: https://svn.musicpd.org/mpd/trunk@2997 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/dbUtils.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dbUtils.c b/src/dbUtils.c index 5878e6f0f..b90aff217 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -10,6 +10,9 @@ #define LOCATE_TAG_FILE_TYPE TAG_NUM_OF_ITEM_TYPES+10 #define LOCATE_TAG_FILE_KEY "filename" +#define LOCATE_TAG_ANY_TYPE TAG_NUM_OF_ITEM_TYPES+20 +#define LOCATE_TAG_ANY_KEY "any" + typedef struct _ListCommandItem { mpd_sint8 tagType; @@ -29,6 +32,10 @@ int getLocateTagItemType(char * str) { return LOCATE_TAG_FILE_TYPE; } + if(0 == strcasecmp(str, LOCATE_TAG_ANY_KEY)) { + return LOCATE_TAG_ANY_TYPE; + } + for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) { if(0 == strcasecmp(str, mpdTagItemKeys[i])) return i; } @@ -127,17 +134,23 @@ static inline int strstrSearchTag(Song * song, int type, char * str) { char * dup; int ret = 0; - if(type == LOCATE_TAG_FILE_TYPE) { + if(type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) { dup = strDupToUpper(getSongUrl(song)); if(strstr(dup, str)) ret = 1; free(dup); - return ret; + if (ret == 1 || type == LOCATE_TAG_FILE_TYPE) { + return ret; + } } if(!song->tag) return 0; for(i = 0; i < song->tag->numOfItems && !ret; i++) { - if(song->tag->items[i].type != type) continue; + if(type != LOCATE_TAG_ANY_TYPE && + song->tag->items[i].type != type) + { + continue; + } dup = strDupToUpper(song->tag->items[i].value); if(strstr(dup, str)) ret = 1; -- cgit v1.2.3