* 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:
rakshasa
2007-08-12 13:41:50 +00:00
parent 781e1ca7dc
commit 788b496241
9 changed files with 207 additions and 78 deletions
+27
View File
@@ -36,7 +36,9 @@
#include "config.h"
#include <fcntl.h>
#include <functional>
#include <rak/path.h>
#include <torrent/torrent.h>
#include <torrent/chunk_manager.h>
@@ -53,6 +55,29 @@
typedef torrent::ChunkManager CM_t;
torrent::Object
apply_execute_log(const torrent::Object& rawArgs) {
if (rpc::execFile.log_fd() != -1) {
::close(rpc::execFile.log_fd());
rpc::execFile.set_log_fd(-1);
}
if (rawArgs.is_string() && !rawArgs.as_string().empty()) {
int logFd = open(rak::path_expand(rawArgs.as_string()).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
if (logFd < 0)
throw torrent::input_error("Could not open execute log file.");
rpc::execFile.set_log_fd(logFd);
control->core()->push_log("Opened execute log file.");
} else {
control->core()->push_log("Closed execute log file.");
}
return torrent::Object();
}
void
initialize_command_local() {
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
@@ -87,4 +112,6 @@ initialize_command_local() {
ADD_COMMAND_LIST("execute_nothrow", rak::bind2_mem_fn(&rpc::execFile, &rpc::ExecFile::execute_object, rpc::ExecFile::flag_expand_tilde));
ADD_COMMAND_LIST("execute_raw", rak::bind2_mem_fn(&rpc::execFile, &rpc::ExecFile::execute_object, rpc::ExecFile::flag_throw));
ADD_COMMAND_LIST("execute_raw_nothrow", rak::bind2_mem_fn(&rpc::execFile, &rpc::ExecFile::execute_object, 0));
ADD_COMMAND_STRING_UN("execute_log", std::ptr_fun(&apply_execute_log));
}