mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 13:12:32 +00:00
* Allow returning torrent::Object map type's with XMLRPC. Patch by Josef Drexler.
* Commands that pass through rpc::parse_command_* now support inline commands that start with a '$'. E.g 'print="$get_ip="'. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@933 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+21
-29
@@ -75,40 +75,17 @@ parse_command_name(const char* first, const char* last, std::string* dest) {
|
||||
return first;
|
||||
}
|
||||
|
||||
const char*
|
||||
void
|
||||
parse_command_single(const char* first) {
|
||||
return parse_command_single(first, first + std::strlen(first));
|
||||
parse_command_single(first, first + std::strlen(first));
|
||||
}
|
||||
|
||||
const char*
|
||||
parse_command_single(const char* first, const char* last) {
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
|
||||
if (first == last || *first == '#')
|
||||
return last;
|
||||
|
||||
// Avoid using a string here?
|
||||
std::string key;
|
||||
first = parse_command_name(first, last, &key);
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
|
||||
if (first == last || *first != '=')
|
||||
throw torrent::input_error("Could not find '='.");
|
||||
|
||||
torrent::Object args;
|
||||
parse_whole_list(first + 1, last, &args);
|
||||
|
||||
commands.call_command(key.c_str(), args);
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
const char*
|
||||
torrent::Object
|
||||
parse_command_d_single(core::Download* download, const char* first, const char* last) {
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
|
||||
if (first == last || *first == '#')
|
||||
return last;
|
||||
return torrent::Object();
|
||||
|
||||
std::string key;
|
||||
first = parse_command_name(first, last, &key);
|
||||
@@ -120,9 +97,24 @@ parse_command_d_single(core::Download* download, const char* first, const char*
|
||||
torrent::Object args;
|
||||
parse_whole_list(first + 1, last, &args);
|
||||
|
||||
commands.call_command_d(key.c_str(), download, args);
|
||||
if (args.is_list()) {
|
||||
for (torrent::Object::list_type::iterator itr = args.as_list().begin(), last = args.as_list().begin(); itr != last; itr++) {
|
||||
if (!itr->is_string())
|
||||
continue;
|
||||
|
||||
return last;
|
||||
const std::string& str = itr->as_string();
|
||||
|
||||
if (*str.c_str() == '$')
|
||||
*itr = parse_command_d_single(download, str.c_str() + 1, str.c_str() + str.size());
|
||||
}
|
||||
|
||||
} else if (*args.as_string().c_str() == '$') {
|
||||
const std::string& str = args.as_string();
|
||||
|
||||
args = parse_command_d_single(download, str.c_str() + 1, str.c_str() + str.size());
|
||||
}
|
||||
|
||||
return commands.call_command_d(key.c_str(), download, args);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user