mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 06:32:31 +00:00
* Fix the use of strlcpy.
* Allow lists as arguments in commands by using '{' and '}'. The list
will be recursed and all '$' will be called, while '~' will only be
expanded when in the first element in the list. E.g "execute =
touch,{~/tmp/,$get_client_version=}"
* Added rak::path_expand that works on char buffers.
* Fixed RequestList::calculate_pipe_size so it doesn't request too
many pieces from fast peers.
* Added 'execute_log' for logging the result of calls to 'execute'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@952 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+18
-16
@@ -77,6 +77,23 @@ parse_count_escaped(const char* first, const char* last) {
|
||||
return escaped;
|
||||
}
|
||||
|
||||
// Replace any strings starting with '$' with the result of the
|
||||
// result of the command.
|
||||
//
|
||||
// Find a better name.
|
||||
void
|
||||
parse_command_execute(core::Download* download, torrent::Object* object) {
|
||||
if (object->is_list()) {
|
||||
for (torrent::Object::list_type::iterator itr = object->as_list().begin(), last = object->as_list().end(); itr != last; itr++)
|
||||
parse_command_execute(download, &*itr);
|
||||
|
||||
} else if (*object->as_string().c_str() == '$') {
|
||||
const std::string& str = object->as_string();
|
||||
|
||||
*object = parse_command_d_single(download, str.c_str() + 1, str.c_str() + str.size());
|
||||
}
|
||||
}
|
||||
|
||||
// Set 'download' to NULL to call the generic functions, thus reusing
|
||||
// the code below for both cases.
|
||||
std::pair<torrent::Object, const char*>
|
||||
@@ -110,22 +127,7 @@ parse_command(core::Download* download, const char* first, const char* last) {
|
||||
|
||||
// Replace any strings starting with '$' with the result of the
|
||||
// following command.
|
||||
if (args.is_list()) {
|
||||
for (torrent::Object::list_type::iterator itr = args.as_list().begin(), last = args.as_list().end(); itr != last; itr++) {
|
||||
if (!itr->is_string())
|
||||
continue;
|
||||
|
||||
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());
|
||||
}
|
||||
parse_command_execute(download, &args);
|
||||
|
||||
return std::make_pair(commands.call_command_d(key.c_str(), download, args), first);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user