diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 564ffbb15..78a789c4d 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -294,7 +294,7 @@ int main(int argc, char* argv[]) while (a.get()) { if (events.size() >= 10) events.pop_front(); - events.push_front(a->msg()); + events.push_back(a->msg()); a = ses.pop_alert(); } diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 00cf280b4..1138ea1bd 100755 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -175,7 +175,7 @@ namespace libtorrent using namespace boost::posix_time; return p.connection == 0 - && second_clock::local_time() - p.connected > seconds(30*60); + && second_clock::local_time() - p.connected > minutes(30); } }; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 4fbf7f478..e83c02063 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -60,6 +60,7 @@ namespace libtorrent #endif std::string escape_string(const char* str, int len); + std::string unescape_string(std::string const& s); struct tracker_alert: alert { diff --git a/src/torrent.cpp b/src/torrent.cpp index 25e127b08..1e7ceeb54 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -180,6 +180,34 @@ namespace namespace libtorrent { + std::string unescape_string(std::string const& s) + { + std::string ret; + for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) + { + if (*i != '%') ret += *i; + else + { + if (i == s.end()) + throw std::runtime_error("invalid escaped string"); + ++i; + + int high = *i - '0'; + if (i == s.end()) + throw std::runtime_error("invalid escaped string"); + ++i; + + int low = *i - '0'; + if (high >= 16 || low >= 16 || high < 0 || low < 0) + throw std::runtime_error("invalid escaped string"); + + ret += char(high * 16 + low); + } + } + return ret; + } + + std::string escape_string(const char* str, int len) { static const char special_chars[] = "$-_.+!*'(),";