aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/DatabaseCommands.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-11-18 14:31:27 +0100
committerMax Kellermann <max@duempel.org>2014-11-18 14:31:27 +0100
commitf37481f843c3ae7aa0c43591c9c7fc4a501c1f5b (patch)
treed49da92d9bd96cf7ad9c5d7c1ebbd4d3a1cbd8d2 /src/command/DatabaseCommands.cxx
parentc3f6502be277ea7a9eb42babc4dc44ab2abf59e2 (diff)
downloadmpd-f37481f843c3ae7aa0c43591c9c7fc4a501c1f5b.tar.gz
mpd-f37481f843c3ae7aa0c43591c9c7fc4a501c1f5b.tar.xz
mpd-f37481f843c3ae7aa0c43591c9c7fc4a501c1f5b.zip
DatabaseCommands: add "window" parameter to "search"/"find"
Diffstat (limited to 'src/command/DatabaseCommands.cxx')
-rw-r--r--src/command/DatabaseCommands.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index a3ea8d0ae..988542f44 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -32,6 +32,7 @@
#include "util/Error.hxx"
#include "SongFilter.hxx"
#include "protocol/Result.hxx"
+#include "protocol/ArgParser.hxx"
#include "BulkEdit.hxx"
#include <string.h>
@@ -70,6 +71,16 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case)
{
ConstBuffer<const char *> args(argv + 1, argc - 1);
+ unsigned window_start = 0, window_end = std::numeric_limits<int>::max();
+ if (args.size >= 2 && strcmp(args[args.size - 2], "window") == 0) {
+ if (!check_range(client, &window_start, &window_end,
+ args.back()))
+ return CommandResult::ERROR;
+
+ args.pop_back();
+ args.pop_back();
+ }
+
SongFilter filter;
if (!filter.Parse(args, fold_case)) {
command_error(client, ACK_ERROR_ARG, "incorrect arguments");
@@ -79,7 +90,8 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case)
const DatabaseSelection selection("", true, &filter);
Error error;
- return db_selection_print(client, selection, true, false, error)
+ return db_selection_print(client, selection, true, false,
+ window_start, window_end, error)
? CommandResult::OK
: print_error(client, error);
}