From f139621c4c5a29e80c69cdb3fd0725ddceab28b6 Mon Sep 17 00:00:00 2001 From: rakshasa Date: Wed, 20 Apr 2005 14:20:09 +0000 Subject: [PATCH] Switched from tracker dump in bencode to std::istream*. Various *BSD port fixes. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@406 e378c898-3ddf-0310-93e7-cc216c733640 --- src/core/manager.cc | 9 ++++++--- src/core/manager.h | 4 +++- src/core/poll.cc | 1 + src/display/utils.cc | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/manager.cc b/src/core/manager.cc index c8d6ebd5..3b7ca688 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -186,16 +186,19 @@ Manager::create_final(std::istream* s) { } void -Manager::receive_debug_tracker(torrent::Bencode& bencode) { +Manager::receive_debug_tracker(std::istream* s) { std::stringstream filename; filename << "./tracker_dump." << m_debugTracker++; std::fstream out(filename.str().c_str(), std::ios::out | std::ios::trunc); - if (!out.good()) + if (!out.is_open()) return; + + s->seekg(0); - out << bencode; + std::copy(std::istream_iterator(*s), std::istream_iterator(), + std::ostream_iterator(out)); } } diff --git a/src/core/manager.h b/src/core/manager.h index f2fff943..5f03723c 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -23,6 +23,8 @@ #ifndef RTORRENT_CORE_MANAGER_H #define RTORRENT_CORE_MANAGER_H +#include + #include "download_list.h" #include "download_store.h" #include "hash_queue.h" @@ -81,7 +83,7 @@ private: iterator create_final(std::istream* s); - void receive_debug_tracker(torrent::Bencode& bencode); + void receive_debug_tracker(std::istream* s); DownloadList m_downloadList; DownloadStore m_downloadStore; diff --git a/src/core/poll.cc b/src/core/poll.cc index faf8d2e5..f18074dc 100644 --- a/src/core/poll.cc +++ b/src/core/poll.cc @@ -23,6 +23,7 @@ #include "config.h" #include +#include #include #include #include diff --git a/src/display/utils.cc b/src/display/utils.cc index c455ebd9..13ee9f51 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -54,7 +54,8 @@ print_download_status(core::Download* d) { std::string print_hhmmss(utils::Timer t) { - std::tm *u = std::localtime(&(time_t)t.tval().tv_sec); + time_t tv_sec = static_cast(t.tval().tv_sec); + std::tm *u = std::localtime(&tv_sec); if (u == NULL) return "inv_time";