fix to previous dht fix. removed some deprication warnings on msvc-8. various fixes

This commit is contained in:
Arvid Norberg 2007-03-02 01:16:59 +00:00
parent 8e844494a3
commit 83c2039ff7
6 changed files with 20 additions and 11 deletions

View File

@ -35,6 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iterator>
#include <exception>
#include "libtorrent/config.hpp"
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
@ -75,9 +77,9 @@ using boost::bind;
bool sleep_and_input(char* c)
{
Sleep(500);
if (kbhit())
if (_kbhit())
{
*c = getch();
*c = _getch();
return true;
}
return false;

View File

@ -363,7 +363,7 @@ namespace libtorrent
boost::posix_time::ptime m_last_tick;
#ifndef TORRENT_DISABLE_DHT
boost::shared_ptr<dht::dht_tracker> m_dht;
boost::intrusive_ptr<dht::dht_tracker> m_dht;
dht_settings m_dht_settings;
#endif
// the timer used to fire the second_tick

View File

@ -36,6 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iterator>
#include <cstdlib>
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -51,7 +53,7 @@ namespace libtorrent
while (m < n)
{
if ((rand() / (RAND_MAX + 1.f)) * (N - t) >= n - m)
if ((std::rand() / (RAND_MAX + 1.f)) * (N - t) >= n - m)
{
++start;
++t;

View File

@ -26,6 +26,7 @@
#include <string>
#include <iterator>
#include <stdexcept>
#include <cwchar>
namespace libtorrent {
namespace detail {
@ -132,7 +133,7 @@ OutputIterator wchar_utf8(InputIterator first, InputIterator last, OutputIterato
inline void utf8_wchar(const std::string &utf8, std::wstring &wide)
{
wide.clear();
detail::utf8_wchar(utf8.begin(), utf8.end(), std::insert_iterator<std::wstring>(wide, wide.end()));
detail::utf8_wchar(utf8.begin(), utf8.end(), std::back_inserter(wide));
}
inline std::wstring utf8_wchar(const std::string &str)
@ -145,7 +146,7 @@ inline std::wstring utf8_wchar(const std::string &str)
inline void wchar_utf8(const std::wstring &wide, std::string &utf8)
{
utf8.clear();
detail::wchar_utf8(wide.begin(), wide.end(), std::insert_iterator<std::string>(utf8, utf8.end()));
detail::wchar_utf8(wide.begin(), wide.end(), std::back_inserter(utf8));
}
inline std::string wchar_utf8(const std::wstring &str)

View File

@ -35,7 +35,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include "libtorrent/config.hpp"
#include "zlib.h"
#ifdef _MSC_VER
@ -98,6 +100,8 @@ namespace
return url.find(argument, i)
!= std::string::npos;
}
char to_lower(char c) { return std::tolower(c); }
}
namespace libtorrent
@ -186,7 +190,7 @@ namespace libtorrent
}
std::string name = line.substr(0, separator);
transform(name.begin(), name.end(), name.begin(), (int(*)(int))std::tolower);
std::transform(name.begin(), name.end(), name.begin(), &to_lower);
std::string value = line.substr(separator + 2, std::string::npos);
m_header.insert(std::make_pair(name, value));

View File

@ -1510,18 +1510,18 @@ namespace libtorrent { namespace detail
if (m_dht)
{
m_dht->stop();
m_dht.reset();
m_dht = 0;
}
m_dht.reset(new dht::dht_tracker(m_io_service
m_dht = new dht::dht_tracker(m_io_service
, m_dht_settings, m_listen_interface.address()
, startup_state));
, startup_state);
}
void session_impl::stop_dht()
{
mutex_t::scoped_lock l(m_mutex);
m_dht->stop();
m_dht.reset();
m_dht = 0;
}
void session_impl::set_dht_settings(dht_settings const& settings)