From 5cde50ee015f9997c0cea38d24facc94620ab07e Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 1 Jan 2004 23:23:17 +0000 Subject: [PATCH] *** empty log message *** --- include/libtorrent/session.hpp | 10 ++++++++-- include/libtorrent/socket.hpp | 17 ----------------- src/torrent.cpp | 19 ++++++++++++++++--- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 8f2080b20..8711c2fad 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -59,6 +59,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/fingerprint.hpp" #include "libtorrent/debug.hpp" +#if defined(_MSC_VER) && !defined(NDEBUG) + +#include + +#endif // TODO: if we're a seed and the peer is a seed, close the connections @@ -71,12 +76,13 @@ namespace libtorrent // hardware exceptions that makes // it hard to debug stuff #if defined(_MSC_VER) && !defined(NDEBUG) + struct eh_initializer { eh_initializer() - { _set_se_translator(straight_to_debugger); } + { ::_set_se_translator(straight_to_debugger); } - static void straight_to_debugger(unsigned int, EXCEPTION_POINTERS*) + static void straight_to_debugger(unsigned int, _EXCEPTION_POINTERS*) { throw; } }; #else diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index d5761c977..ab772e096 100755 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -33,23 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SOCKET_HPP_INCLUDED #define TORRENT_SOCKET_HPP_INCLUDED -// TODO: remove the dependency of -// platform specific headers here. -// sockaddr_in is hard to get rid of in a nice way - -#if defined(_WIN32) - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include -#endif - #include #include #include diff --git a/src/torrent.cpp b/src/torrent.cpp index 88864fe6f..65bbf7995 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -121,13 +121,26 @@ namespace std::string escape_string(const char* str, int len) { + static const char special_chars[] = "$-_.+!*'(),"; + std::stringstream ret; ret << std::hex << std::setfill('0'); for (int i = 0; i < len; ++i) { - // TODO: should alnum() be replaced with printable()? - if (std::isalnum(static_cast(*str))) ret << *str; - else ret << "%" << std::setw(2) << (int)static_cast(*str); + if (std::isalnum(static_cast(*str)) + || std::find( + special_chars + , special_chars+sizeof(special_chars)-1 + , *str)) + { + ret << *str; + } + else + { + ret << "%" + << std::setw(2) + << (int)static_cast(*str); + } ++str; } return ret.str();