* Added 'd.get_hash' and 'get_hostname' commands.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@958 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-08-18 23:44:59 +00:00
parent f117b9dd16
commit 5ec7790aa9
4 changed files with 29 additions and 3 deletions
+16
View File
@@ -38,6 +38,7 @@
#include <fcntl.h>
#include <functional>
#include <unistd.h>
#include <rak/path.h>
#include <torrent/torrent.h>
#include <torrent/chunk_manager.h>
@@ -78,6 +79,19 @@ apply_execute_log(const torrent::Object& rawArgs) {
return torrent::Object();
}
torrent::Object
apply_get_hostname() {
char buffer[1024];
if (gethostname(buffer, 1023) == -1)
throw torrent::input_error("Unable to read hostname.");
// if (shorten)
// *std::find(buffer, buffer + 1023, '.') = '\0';
return std::string(buffer);
}
void
initialize_command_local() {
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
@@ -87,6 +101,8 @@ initialize_command_local() {
ADD_VARIABLE_C_STRING("client_version", PACKAGE_VERSION);
ADD_VARIABLE_C_STRING("library_version", torrent::version());
ADD_COMMAND_VOID("get_hostname", rak::ptr_fun(&apply_get_hostname));
ADD_VARIABLE_VALUE("max_file_size", -1);
ADD_VARIABLE_VALUE("split_file_size", -1);
ADD_VARIABLE_STRING("split_suffix", ".part");