From 6a09806ad4ab827ed8659b75650202a947455578 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 17 Aug 2005 22:59:21 +0000 Subject: [PATCH] *** empty log message *** --- docs/manual.html | 9 +++++--- docs/manual.rst | 8 ++++++-- docs/udp_tracker_protocol.html | 32 ++++++++++++++--------------- examples/dump_torrent.cpp | 2 ++ include/libtorrent/torrent_info.hpp | 3 +++ src/torrent_info.cpp | 29 ++++++++++---------------- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 6914a6202..db0f38c2f 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -59,7 +59,7 @@
  • trackers()
  • total_size() piece_length() piece_size() num_pieces()
  • hash_for_piece() info_hash()
  • -
  • name() comment() creation_date()
  • +
  • name() comment() creation_date() creator()
  • torrent_handle
    -

    introduction

    +

    introduction

    A tracker with the protocol "udp://" in its URI is supposed to be contacted using this protocol.

    This protocol is supported by @@ -57,9 +57,9 @@ the request. If no reply has been received after 60 seconds, stop retrying.

    -

    connecting

    +

    connecting

    -

    Client sends packet:

    +

    Client sends packet:

    @@ -91,7 +91,7 @@ identify the protocol.
    -

    Server replies with packet:

    +

    Server replies with packet:

    @@ -131,9 +131,9 @@ anymore.
    @@ -226,7 +226,7 @@ in the reply. Use -1 for default.
    -

    Server replies with packet:

    +

    Server replies with packet:

    @@ -420,10 +420,10 @@ leechers.
    @@ -457,7 +457,7 @@ describing the error.
    -

    actions

    +

    actions

    The action fields has the following encoding:

      @@ -469,7 +469,7 @@ describing the error.
    -

    extensions

    +

    extensions

    The extensions field is a bitmask. The following bits are assigned:

    @@ -478,7 +478,7 @@ bits are assigned:

    -

    authentication

    +

    authentication

    The packet will have an authentication part appended to it. It has the following format:

    @@ -518,7 +518,7 @@ from the 20 bytes hash calculated.
    -

    credits

    +

    credits

    Protocol designed by Olaf van der Spek

    diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index 2648d7fa0..047d604b0 100755 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -79,6 +79,8 @@ int main(int argc, char* argv[]) std::cout << "number of pieces: " << t.num_pieces() << "\n"; std::cout << "piece length: " << t.piece_length() << "\n"; std::cout << "info hash: " << t.info_hash() << "\n"; + std::cout << "comment: " << t.comment() << "\n"; + std::cout << "created_by: " << t.creator() << "\n"; std::cout << "files:\n"; for (torrent_info::file_iterator i = t.begin_files(); i != t.end_files(); ++i) diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index ca5382763..0e09ac082 100755 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -138,6 +138,9 @@ namespace libtorrent boost::optional creation_date() const; + const std::string& creator() const + { return m_created_by; } + const std::string& comment() const { return m_comment; } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index ae1f43c43..8374cc332 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -203,13 +203,9 @@ namespace libtorrent // extract file name (or the directory name if it's a multifile libtorrent) if (entry const* e = info.find_key("name.utf-8")) - { - m_name = e->string(); - } + { m_name = e->string(); } else - { - m_name = info["name"].string(); - } + { m_name = info["name"].string(); } path tmp = m_name; if (tmp.is_complete()) throw std::runtime_error("torrent contains " @@ -314,19 +310,16 @@ namespace libtorrent catch (type_error) {} // extract comment - try - { - m_comment = torrent_file["comment"].string(); - } - catch (type_error) {} - - // extract comment - try - { - m_created_by = torrent_file["created by"].string(); - } - catch (type_error) {} + if (entry const* e = torrent_file.find_key("comment.utf-8")) + { m_comment = e->string(); } + else if (entry const* e = torrent_file.find_key("comment")) + { m_comment = e->string(); } + if (entry const* e = torrent_file.find_key("created by.utf-8")) + { m_created_by = e->string(); } + else if (entry const* e = torrent_file.find_key("created by")) + { m_created_by = e->string(); } + parse_info_section(torrent_file["info"]); }