diff --git a/scripts/checks.m4 b/scripts/checks.m4 index 4909a8cd..8a3de3a5 100644 --- a/scripts/checks.m4 +++ b/scripts/checks.m4 @@ -176,13 +176,9 @@ AC_DEFUN([TORRENT_CHECK_FALLOCATE], [ AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [ AC_MSG_CHECKING(for posix_fallocate) - AC_COMPILE_IFELSE( - [[#include - int main() { - posix_fallocate(0, 0, 0); - return 0; - } - ]], + AC_TRY_LINK([#include + ],[ posix_fallocate(0, 0, 0); + ], [ AC_DEFINE(USE_POSIX_FALLOCATE, 1, posix_fallocate supported.) AC_MSG_RESULT(yes) diff --git a/src/command_local.cc b/src/command_local.cc index 5b5b9537..54c095af 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,27 @@ apply_log(const torrent::Object::string_type& arg, int logType) { return torrent::Object(); } +torrent::Object +apply_log_libtorrent(const torrent::Object::list_type& args) { + if (args.empty() || args.size() > 2) + throw torrent::input_error("Invalid argument count."); + + torrent::log_file* log_file = torrent::find_log_file(args.front().as_string().c_str()); + + if (log_file == NULL) + throw torrent::input_error("Invalid log name."); + + if (args.size() == 1) { + log_file->close(); + return torrent::Object(); + } + + if (!log_file->open_file(args.back().as_string().c_str())) + throw torrent::input_error("Could not open log file."); + + return torrent::Object(); +} + torrent::Object system_hostname() { char buffer[1024]; @@ -301,6 +323,8 @@ initialize_command_local() { CMD2_ANY_STRING ("log.vmmap.dump", std::tr1::bind(&log_vmmap_dump, std::tr1::placeholders::_2)); CMD2_ANY_STRING_V("log.xmlrpc", std::tr1::bind(&ThreadWorker::set_xmlrpc_log, worker_thread, std::tr1::placeholders::_2)); + CMD2_ANY_LIST ("log.libtorrent", std::tr1::bind(&apply_log_libtorrent, std::tr1::placeholders::_2)); + // TODO: Convert to new command types: *rpc::command_base::argument(0) = "placeholder.0"; *rpc::command_base::argument(1) = "placeholder.1";