mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 06:02:31 +00:00
* Bind udp and http tracker requests to the bind address.
* Allow the torrent's priority to be changed with '+'. * More work on the variables thing. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@625 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -36,10 +36,25 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "variable_generic.h"
|
||||
|
||||
namespace utils {
|
||||
|
||||
VariableAny::~VariableAny() {
|
||||
}
|
||||
|
||||
const torrent::Bencode&
|
||||
VariableAny::get() {
|
||||
return m_variable;
|
||||
}
|
||||
|
||||
void
|
||||
VariableAny::set(const torrent::Bencode& arg) {
|
||||
m_variable = arg;
|
||||
}
|
||||
|
||||
VariableValue::~VariableValue() {
|
||||
}
|
||||
|
||||
@@ -50,7 +65,32 @@ VariableValue::get() {
|
||||
|
||||
void
|
||||
VariableValue::set(const torrent::Bencode& arg) {
|
||||
m_variable = arg;
|
||||
uint64_t value;
|
||||
const char* first;
|
||||
char* last;
|
||||
|
||||
switch (arg.get_type()) {
|
||||
case torrent::Bencode::TYPE_NONE:
|
||||
m_variable = (int64_t)0;
|
||||
break;
|
||||
|
||||
case torrent::Bencode::TYPE_VALUE:
|
||||
m_variable = arg;
|
||||
break;
|
||||
|
||||
case torrent::Bencode::TYPE_STRING:
|
||||
first = arg.as_string().c_str();
|
||||
value = std::strtoll(first, &last, 0);
|
||||
|
||||
if (last == first || *last != '\0')
|
||||
throw torrent::input_error("Could not convert string to value.");
|
||||
|
||||
m_variable = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw torrent::input_error("VariableValue unsupported type restriction.");
|
||||
}
|
||||
}
|
||||
|
||||
VariableBool::~VariableBool() {
|
||||
|
||||
@@ -49,9 +49,22 @@
|
||||
|
||||
namespace utils {
|
||||
|
||||
class VariableAny : public Variable {
|
||||
public:
|
||||
VariableAny(const torrent::Bencode& v = torrent::Bencode()) :
|
||||
m_variable(v) {}
|
||||
virtual ~VariableAny();
|
||||
|
||||
virtual const torrent::Bencode& get();
|
||||
virtual void set(const torrent::Bencode& arg);
|
||||
|
||||
private:
|
||||
torrent::Bencode m_variable;
|
||||
};
|
||||
|
||||
class VariableValue : public Variable {
|
||||
public:
|
||||
VariableValue(const torrent::Bencode& v = torrent::Bencode()) : m_variable(v) {}
|
||||
VariableValue(int64_t v) : m_variable(v) {}
|
||||
virtual ~VariableValue();
|
||||
|
||||
virtual const torrent::Bencode& get();
|
||||
|
||||
Reference in New Issue
Block a user