From f37481f843c3ae7aa0c43591c9c7fc4a501c1f5b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 18 Nov 2014 14:31:27 +0100 Subject: DatabaseCommands: add "window" parameter to "search"/"find" --- src/command/DatabaseCommands.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/command') 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 @@ -70,6 +71,16 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case) { ConstBuffer args(argv + 1, argc - 1); + unsigned window_start = 0, window_end = std::numeric_limits::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); } -- cgit v1.2.3