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
@@ -941,6 +941,7 @@ public:
sha1_hash const& info_hash() const;
std::stirng const& name() const;
std::string const& comment() const;
+ std::string const& creator() const;
boost::optional<boost::posix_time::ptime>
creation_date() const;
@@ -1117,8 +1118,8 @@ sha1_hash const& hash_for_piece(unsigned int index) const;
piece and info_hash() returns the 20-bytes sha1-hash for the info-section of the
torrent file. For more information on the sha1_hash, see the big_number class.
-
diff --git a/docs/manual.rst b/docs/manual.rst
index 4a4a3d2ee..d976c9390 100755
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -849,6 +849,7 @@ The ``torrent_info`` has the following synopsis::
sha1_hash const& info_hash() const;
std::stirng const& name() const;
std::string const& comment() const;
+ std::string const& creator() const;
boost::optional
creation_date() const;
@@ -1047,8 +1048,8 @@ piece and ``info_hash()`` returns the 20-bytes sha1-hash for the info-section of
torrent file. For more information on the ``sha1_hash``, see the big_number_ class.
-name() comment() creation_date()
---------------------------------
+name() comment() creation_date() creator()
+------------------------------------------
::
@@ -1063,6 +1064,9 @@ it will return an empty string. ``creation_date()`` returns a `boost::posix_time
object, representing the time when this torrent file was created. If there's no timestamp
in the torrent file, this will return a date of january 1:st 1970.
+``cretor()`` returns the creator string in the torrent. If there is no creator string
+it will return an empty string.
+
__ http://www.boost.org/libs/date_time/doc/class_ptime.html
diff --git a/docs/udp_tracker_protocol.html b/docs/udp_tracker_protocol.html
index 1ea495d5b..794fc8350 100644
--- a/docs/udp_tracker_protocol.html
+++ b/docs/udp_tracker_protocol.html
@@ -42,7 +42,7 @@
-
+
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.
-
+
-
+
@@ -91,7 +91,7 @@ identify the protocol.
-
+
@@ -131,9 +131,9 @@ anymore.
-
+
-
+
@@ -226,7 +226,7 @@ in the reply. Use -1 for default.
-
+
@@ -297,9 +297,9 @@ seeding.
-
+
-
+
@@ -360,7 +360,7 @@ follow.
-
+
@@ -420,10 +420,10 @@ leechers.
-
+
In case of a tracker error,
-
+
@@ -457,7 +457,7 @@ describing the error.
-
+
The action fields has the following encoding:
@@ -469,7 +469,7 @@ describing the error.
-
+
The extensions field is a bitmask. The following
bits are assigned:
@@ -478,7 +478,7 @@ bits are assigned:
-
+
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.
-
+
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"]);
}