aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-12 01:44:27 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-12 01:44:27 +0000
commit1f118ea90dd0a22bd40e76a96900ffb36aa93134 (patch)
treef1600bdb9ef3d4b9f79091f06bfb9f05e7f6a9bb /src/command.c
parent18a2d5ab5a5fc005ddd4549807d083cd33f5b98f (diff)
downloadmpd-1f118ea90dd0a22bd40e76a96900ffb36aa93134.tar.gz
mpd-1f118ea90dd0a22bd40e76a96900ffb36aa93134.tar.xz
mpd-1f118ea90dd0a22bd40e76a96900ffb36aa93134.zip
now more flexible list, search, find, where you can enter pairs of
"conditionals". Note that logical and is implied. git-svn-id: https://svn.musicpd.org/mpd/trunk@2624 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/command.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/command.c b/src/command.c
index e2bf84460..248fa1542 100644
--- a/src/command.c
+++ b/src/command.c
@@ -444,17 +444,18 @@ int handleFind(FILE * fp, unsigned int * permission, int argArrayLength,
{
int ret;
- LocateTagItem * item = newLocateTagItem(argArray[1], argArray[2]);
+ LocateTagItem * items;
+ int numItems = newLocateTagItemArrayFromArgArray(argArray+1,
+ argArrayLength-1, &items);
- if(!item) {
- commandError(fp, ACK_ERROR_ARG, "\%s\" isn't recognized",
- argArray[1]);
+ if(numItems <= 0) {
+ commandError(fp, ACK_ERROR_ARG, "incorrect ags", NULL);
return -1;
}
- ret = findSongsIn(fp, NULL, item);
+ ret = findSongsIn(fp, NULL, numItems, items);
- freeLocateTagItem(item);
+ freeLocateTagItemArray(numItems, items);
return ret;
}
@@ -464,17 +465,18 @@ int handleSearch(FILE * fp, unsigned int * permission, int argArrayLength,
{
int ret;
- LocateTagItem * item = newLocateTagItem(argArray[1], argArray[2]);
+ LocateTagItem * items;
+ int numItems = newLocateTagItemArrayFromArgArray(argArray+1,
+ argArrayLength-1, &items);
- if(!item) {
- commandError(fp, ACK_ERROR_ARG, "\%s\" isn't recognized",
- argArray[1]);
+ if(numItems <= 0) {
+ commandError(fp, ACK_ERROR_ARG, "incorrect ags", NULL);
return -1;
}
- ret = searchForSongsIn(fp, NULL, item);
+ ret = searchForSongsIn(fp, NULL, numItems, items);
- freeLocateTagItem(item);
+ freeLocateTagItemArray(numItems, items);
return ret;
}
@@ -636,10 +638,20 @@ int handleList(FILE * fp, unsigned int * permission, int argArrayLength,
argArray[2]);
numConditionals = 1;
}
+ else {
+ numConditionals = newLocateTagItemArrayFromArgArray(argArray+2,
+ argArrayLength-2, &conditionals);
+
+ if(numConditionals < 0) {
+ commandError(fp, ACK_ERROR_ARG,
+ "not able to parse args", NULL);
+ return -1;
+ }
+ }
ret = listAllUniqueTags(fp, tagType, numConditionals,conditionals);
- if(conditionals) free(conditionals);
+ if(conditionals) freeLocateTagItemArray(numConditionals, conditionals);
return ret;
}
@@ -904,8 +916,8 @@ void initCommands() {
addCommand(COMMAND_LSINFO ,PERMISSION_READ, 0, 1,handleLsInfo,NULL);
addCommand(COMMAND_RM ,PERMISSION_CONTROL, 1, 1,handleRm,NULL);
addCommand(COMMAND_PLAYLISTINFO,PERMISSION_READ, 0, 1,handlePlaylistInfo,NULL);
- addCommand(COMMAND_FIND ,PERMISSION_READ, 2, 2,handleFind,NULL);
- addCommand(COMMAND_SEARCH ,PERMISSION_READ, 2, 2,handleSearch,NULL);
+ addCommand(COMMAND_FIND ,PERMISSION_READ, 2,-1,handleFind,NULL);
+ addCommand(COMMAND_SEARCH ,PERMISSION_READ, 2,-1,handleSearch,NULL);
addCommand(COMMAND_UPDATE ,PERMISSION_ADMIN, 0, 1,handleUpdate,listHandleUpdate);
addCommand(COMMAND_NEXT ,PERMISSION_CONTROL, 0, 0,handleNext,NULL);
addCommand(COMMAND_PREVIOUS ,PERMISSION_CONTROL, 0, 0,handlePrevious,NULL);
@@ -915,7 +927,7 @@ void initCommands() {
addCommand(COMMAND_RANDOM ,PERMISSION_CONTROL, 1, 1,handleRandom,NULL);
addCommand(COMMAND_STATS ,PERMISSION_READ, 0, 0,handleStats,NULL);
addCommand(COMMAND_CLEAR_ERROR ,PERMISSION_CONTROL, 0, 0,handleClearError,NULL);
- addCommand(COMMAND_LIST ,PERMISSION_READ, 1, 2,handleList,NULL);
+ addCommand(COMMAND_LIST ,PERMISSION_READ, 1,-1,handleList,NULL);
addCommand(COMMAND_MOVE ,PERMISSION_CONTROL, 2, 2,handleMove,NULL);
addCommand(COMMAND_MOVEID ,PERMISSION_CONTROL, 2, 2,handleMoveId,NULL);
addCommand(COMMAND_SWAP ,PERMISSION_CONTROL, 2, 2,handleSwap,NULL);