Adding count command. It's usage is identical to find, but instead of
returning a list of matching songs, the number of results and total play time of the results are returned. git-svn-id: https://svn.musicpd.org/mpd/trunk@5950 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
#define COMMAND_PLAYLISTFIND "playlistfind"
|
||||
#define COMMAND_PLAYLISTSEARCH "playlistsearch"
|
||||
#define COMMAND_TAGTYPES "tagtypes"
|
||||
#define COMMAND_COUNT "count"
|
||||
|
||||
#define COMMAND_STATUS_VOLUME "volume"
|
||||
#define COMMAND_STATUS_STATE "state"
|
||||
@@ -518,6 +519,27 @@ static int handleSearch(int fd, int *permission, int argc, char *argv[])
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int handleCount(int fd, int *permission, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
LocateTagItem *items;
|
||||
int numItems = newLocateTagItemArrayFromArgArray(argv + 1,
|
||||
argc - 1,
|
||||
&items);
|
||||
|
||||
if (numItems <= 0) {
|
||||
commandError(fd, ACK_ERROR_ARG, "incorrect arguments");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = searchStatsForSongsIn(fd, NULL, numItems, items);
|
||||
|
||||
freeLocateTagItemArray(numItems, items);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int handlePlaylistFind(int fd, int *permission, int argc, char *argv[])
|
||||
{
|
||||
LocateTagItem *items;
|
||||
@@ -1051,6 +1073,7 @@ void initCommands(void)
|
||||
addCommand(COMMAND_PLAYLISTFIND, PERMISSION_READ, 2, -1, handlePlaylistFind, NULL);
|
||||
addCommand(COMMAND_PLAYLISTSEARCH, PERMISSION_READ, 2, -1, handlePlaylistSearch, NULL);
|
||||
addCommand(COMMAND_TAGTYPES, PERMISSION_READ, 0, 0, handleTagTypes, NULL);
|
||||
addCommand(COMMAND_COUNT, PERMISSION_READ, 2, -1, handleCount, NULL);
|
||||
|
||||
sortList(commandList);
|
||||
}
|
||||
|
Reference in New Issue
Block a user