added the ability to build libtorrent as a shared library. Fixed bugs with deleting of incomplete types (replaced auto_ptr with scoped_ptr). Made the string converter fall back on windows local code page if utf-8 decoding failed.

This commit is contained in:
Arvid Norberg 2005-11-01 18:30:39 +00:00
parent 0c1c9d375d
commit 3f36dd0395
40 changed files with 409 additions and 210 deletions

View File

@ -1,9 +1,12 @@
* strings that are invalid utf-8 strings are now decoded with the
local codepage on windows
* added the ability to build libtorrent both as a shared library
* client_test can now monitor a directory for torrent files and automatically
start and stop downloads while running
* fixed problem with file_size() when building on windows with unicode support
* added a new torrent state, allocating
* added a new alert, metadata_failed_alert
* changed the interface to session::add_torrent for soem speed optimizations.
* changed the interface to session::add_torrent for some speed optimizations.
* greatly improved the command line control of the example client_test.
* fixed bug where upload rate limit was not being applied.
* files that are being checked will no longer stall files that don't need

View File

@ -32,10 +32,10 @@ project torrent
<library>/boost/thread//boost_thread/<link>static
<library>/boost/filesystem//boost_filesystem/<link>static
<library>/boost/date_time//boost_date_time/<link>static
<link>static
<threading>multi
<toolset>msvc:<cxxflags>/Zc:wchar_t
<toolset>msvc:<cxxflags>/Zc:forScope
<link>shared:<define>TORRENT_BUILDING_SHARED
: usage-requirements
@ -43,6 +43,7 @@ project torrent
<include>$(BOOST_ROOT)
<variant>release:<define>NDEBUG
<define>BOOST_ALL_NO_LIB
<link>shared:<define>TORRENT_LINKING_SHARED
;

View File

@ -1,14 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.8: http://docutils.sourceforge.net/" />
<title>libtorrent manual</title>
<meta name="author" content="Arvid Norberg, arvid&#64;rasterbar.com" />
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Rasterbar Software | Products | libtorrent</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="../../css/base.css" />
<link rel="stylesheet" type="text/css" href="../../css/rst.css" />
<style type="text/css">
/* Hides from IE-mac \*/
* html pre { height: 1%; }
/* End hide from IE-mac */
</style>
</head>
<body>
<div id="container">
<div id="headerNav">
<ul>
<li class="first"><a href="/">Home</a></li>
<li><a href="../../products.html">Products</a></li>
<li><a href="../../contact.html">Contact</a></li>
<!-- <li><a href="/about.html">About</a></li> -->
</ul>
</div>
<div id="header">
<h1><span>Rasterbar Software</span></h1>
<h2><span>Software developement and consulting</span></h2>
<span>
</span>
</div>
<div id="main">
<div class="document" id="libtorrent-manual">
<h1 class="title">libtorrent manual</h1>
<table class="docinfo" frame="void" rules="none">
@ -198,7 +225,7 @@ to the other party.</li>
<li>fast resume support, a way to get rid of the costly piece check at the
start of a resumed torrent. Saves the storage state, piece_picker state
as well as all local peers in a separate fast-resume file.</li>
<li>supports the extension protocol <a class="reference" href="http://nolar.com/azureus/extended.htm">specified by Nolar</a>. See <a class="reference" href="#extensions">extensions</a>.</li>
<li>supports an <a class="reference" href="extension_protocol.html">extension protocol</a>. See <a class="reference" href="#extensions">extensions</a>.</li>
<li>supports files &gt; 2 gigabytes.</li>
<li>supports the <tt class="docutils literal"><span class="pre">no_peer_id=1</span></tt> extension that will ease the load off trackers.</li>
<li>supports the <a class="reference" href="udp_tracker_protocol.html">udp-tracker protocol</a> by Olaf van der Spek.</li>
@ -322,8 +349,9 @@ files found. So, set this to <tt class="docutils literal"><span class="pre">c:\b
a specific toolset to use (compiler) you can just add that to the commandline.
For example:</p>
<pre class="literal-block">
bjam msvc-7.1
bjam gcc-3.3
bjam msvc-7.1 link=static
bjam gcc-3.3 link=static
bjam darwin-4.0 link=static
</pre>
<p>To build different versions you can also just add the name of the build
variant. Some default build variants in BBv2 are <tt class="docutils literal"><span class="pre">release</span></tt>, <tt class="docutils literal"><span class="pre">debug</span></tt>,
@ -331,6 +359,13 @@ variant. Some default build variants in BBv2 are <tt class="docutils literal"><s
<p>If you're building on a platform where dlls share the same heap, you can build
libtorrent as a dll too, by typing <tt class="docutils literal"><span class="pre">link=shared</span></tt>, or <tt class="docutils literal"><span class="pre">link=static</span></tt> to
explicitly build a static library.</p>
<p>If you want to explicitly say how to link against the runtime library, you
can set the <tt class="docutils literal"><span class="pre">runtime-link</span></tt> feature on the commandline, either to <tt class="docutils literal"><span class="pre">shared</span></tt>
or <tt class="docutils literal"><span class="pre">static</span></tt>. Most operating systems will only allow linking shared against
the runtime, but on windows you can do both. Example:</p>
<pre class="literal-block">
bjam msvc-7.1 link=static runtime-link=staitc
</pre>
<p>The build targets are put in a directory called bin, and under it they are
sorted in directories depending on the toolset and build variant used.</p>
<p>To build the examples, just change directory to the examples directory and
@ -346,7 +381,7 @@ windows format (<tt class="docutils literal"><span class="pre">c:/boost_1_33_0</
<p>The <tt class="docutils literal"><span class="pre">Jamfile</span></tt> will define <tt class="docutils literal"><span class="pre">NDEBUG</span></tt> when it's building a release build.
There are two other build variants available in the <tt class="docutils literal"><span class="pre">Jamfile</span></tt>. debug_log
and release_log, these two variants inherits from the debug and release
variants respectively, but adds extra logging (<tt class="docutils literal"><span class="pre">TORRENT_VERBOSE_LOGGIN</span></tt>).
variants respectively, but adds extra logging (<tt class="docutils literal"><span class="pre">TORRENT_VERBOSE_LOGGING</span></tt>).
For more build configuration flags see <a class="reference" href="#build-configurations">Build configurations</a>.</p>
<p>The <tt class="docutils literal"><span class="pre">Jamfile</span></tt> has the following build variants:</p>
<blockquote>
@ -506,6 +541,25 @@ GCC) both little-endian and big-endian versions
will be built and the correct code will be
chosen at run-time.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">TORRENT_LINKING_SHARED</span></tt></td>
<td>If this is defined when including the
libtorrent headers, the classes and functions
will be tagged with <tt class="docutils literal"><span class="pre">__declspec(dllimport)</span></tt>
on msvc and default visibility on GCC 4 and
later. Set this in your project if you're
linking against libtorrent as a shared library.
(This is set by the Jamfile when
<tt class="docutils literal"><span class="pre">link=shared</span></tt> is set).</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">TORRENT_BUILDING_SHARED</span></tt></td>
<td>If this is defined, the functions and classes
in libtorrent are marked with
<tt class="docutils literal"><span class="pre">__declspec(dllexport)</span></tt> on msvc, or with
default visibility on GCC 4 and later. This
should be defined when building libtorrent as
a shared library. (This is set by the Jamfile
when <tt class="docutils literal"><span class="pre">link=shared</span></tt> is set).</td>
</tr>
</tbody>
</table>
<p>If you experience that libtorrent uses unreasonable amounts of cpu, it will
@ -1795,7 +1849,7 @@ any combination of the enums above. The following table describes each flag:</p>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">support_extensions</span></tt></td>
<td>means that this peer supports the
<a class="reference" href="http://nolar.com/azureus/extended.htm">extension protocol</a>.</td>
<a class="reference" href="extension_protocol.html">extension protocol</a>.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">local_connection</span></tt></td>
<td>The connection was initiated by us, the peer has a
@ -2964,6 +3018,8 @@ drawbacks of this mode are:</p>
<li>It will take longer to start the torrent, since it will need to fill the files
with zeroes. This delay is linearly dependent on the size of the download.</li>
<li>The download will occupy unnecessary disk space between download sessions.</li>
<li>Disk caches usually perform extremely poorly with random access to large files
and may slow down a download considerably.</li>
</ul>
</blockquote>
<p>The benefit of thise mode are:</p>
@ -2993,6 +3049,8 @@ download has all its pieces in the correct place). So, the main drawbacks are:</
<ul class="simple">
<li>No startup delay, since the files doesn't need allocating.</li>
<li>The download will not use unnecessary disk space.</li>
<li>Disk caches perform much better than in full allocation and raises the download
speed limit imposed by the disk.</li>
</ul>
</blockquote>
<p>The algorithm that is used when allocating pieces and slots isn't very complicated.
@ -3023,7 +3081,7 @@ contain any piece), return that slot index.</li>
</div>
<div class="section" id="extensions">
<h1><a name="extensions">extensions</a></h1>
<p>These extensions all operates within the <a class="reference" href="http://nolar.com/azureus/extended.html">extension protocol</a>. The
<p>These extensions all operates within the <a class="reference" href="extension_protocol.html">extension protocol</a>. The
name of the extension is the name used in the extension-list packets,
and the payload is the data in the extended message (not counting the
length-prefix, message-id nor extension-id).</p>
@ -3208,5 +3266,13 @@ scripts.</p>
<p><a class="reference" href="http://sourceforge.net"><img alt="sf_logo" src="http://sourceforge.net/sflogo.php?group_id=7994" /></a></p>
</div>
</div>
</div>
<div id="footer">
<span>Copyright &copy; 2005 Rasterbar Software.</span>
</div>
</div>
</body>
</html>

View File

@ -47,7 +47,7 @@ following features:
* fast resume support, a way to get rid of the costly piece check at the
start of a resumed torrent. Saves the storage state, piece_picker state
as well as all local peers in a separate fast-resume file.
* supports the extension protocol `specified by Nolar`__. See extensions_.
* supports an `extension protocol`__. See extensions_.
* supports files > 2 gigabytes.
* supports the ``no_peer_id=1`` extension that will ease the load off trackers.
* supports the `udp-tracker protocol`__ by Olaf van der Spek.
@ -65,7 +65,7 @@ following features:
__ http://home.elp.rr.com/tur/multitracker-spec.txt
.. _Azureus: http://azureus.sourceforge.net
__ http://nolar.com/azureus/extended.htm
__ extension_protocol.html
__ udp_tracker_protocol.html
@ -200,8 +200,9 @@ Then the only thing left is simply to invoke ``bjam``. If you want to specify
a specific toolset to use (compiler) you can just add that to the commandline.
For example::
bjam msvc-7.1
bjam gcc-3.3
bjam msvc-7.1 link=static
bjam gcc-3.3 link=static
bjam darwin-4.0 link=static
To build different versions you can also just add the name of the build
variant. Some default build variants in BBv2 are ``release``, ``debug``,
@ -211,6 +212,13 @@ If you're building on a platform where dlls share the same heap, you can build
libtorrent as a dll too, by typing ``link=shared``, or ``link=static`` to
explicitly build a static library.
If you want to explicitly say how to link against the runtime library, you
can set the ``runtime-link`` feature on the commandline, either to ``shared``
or ``static``. Most operating systems will only allow linking shared against
the runtime, but on windows you can do both. Example::
bjam msvc-7.1 link=static runtime-link=staitc
The build targets are put in a directory called bin, and under it they are
sorted in directories depending on the toolset and build variant used.
@ -229,7 +237,7 @@ windows format (``c:/boost_1_33_0``).
The ``Jamfile`` will define ``NDEBUG`` when it's building a release build.
There are two other build variants available in the ``Jamfile``. debug_log
and release_log, these two variants inherits from the debug and release
variants respectively, but adds extra logging (``TORRENT_VERBOSE_LOGGIN``).
variants respectively, but adds extra logging (``TORRENT_VERBOSE_LOGGING``).
For more build configuration flags see `Build configurations`_.
The ``Jamfile`` has the following build variants:
@ -386,6 +394,23 @@ defines you can use to control the build.
| | will be built and the correct code will be |
| | chosen at run-time. |
+--------------------------------+-------------------------------------------------+
| ``TORRENT_LINKING_SHARED`` | If this is defined when including the |
| | libtorrent headers, the classes and functions |
| | will be tagged with ``__declspec(dllimport)`` |
| | on msvc and default visibility on GCC 4 and |
| | later. Set this in your project if you're |
| | linking against libtorrent as a shared library. |
| | (This is set by the Jamfile when |
| | ``link=shared`` is set). |
+--------------------------------+-------------------------------------------------+
| ``TORRENT_BUILDING_SHARED`` | If this is defined, the functions and classes |
| | in libtorrent are marked with |
| | ``__declspec(dllexport)`` on msvc, or with |
| | default visibility on GCC 4 and later. This |
| | should be defined when building libtorrent as |
| | a shared library. (This is set by the Jamfile |
| | when ``link=shared`` is set). |
+--------------------------------+-------------------------------------------------+
If you experience that libtorrent uses unreasonable amounts of cpu, it will
@ -1768,7 +1793,7 @@ any combination of the enums above. The following table describes each flag:
| | us. |
+-------------------------+-------------------------------------------------------+
__ http://nolar.com/azureus/extended.htm
__ extension_protocol.html
The ``ip`` field is the IP-address to this peer. Its type is a wrapper around the
actual address and the port number. See address_ class.
@ -3035,6 +3060,9 @@ drawbacks of this mode are:
* The download will occupy unnecessary disk space between download sessions.
* Disk caches usually perform extremely poorly with random access to large files
and may slow down a download considerably.
The benefit of thise mode are:
* Downloaded pieces are written directly to their final place in the files and the
@ -3062,6 +3090,9 @@ The benefits though, are:
* The download will not use unnecessary disk space.
* Disk caches perform much better than in full allocation and raises the download
speed limit imposed by the disk.
The algorithm that is used when allocating pieces and slots isn't very complicated.
For the interested, a description follows.
@ -3096,7 +3127,7 @@ name of the extension is the name used in the extension-list packets,
and the payload is the data in the extended message (not counting the
length-prefix, message-id nor extension-id).
__ http://nolar.com/azureus/extended.html
__ extension_protocol.html
Note that since this protocol relies on one of the reserved bits in the
handshake, it may be incompatible with future versions of the mainline

View File

@ -1,48 +1,69 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.8: http://docutils.sourceforge.net/" />
<title>Bittorrent udp-tracker protocol extension</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Rasterbar Software | Products | libtorrent</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="../../css/base.css" />
<link rel="stylesheet" type="text/css" href="../../css/rst.css" />
<style type="text/css">
/* Hides from IE-mac \*/
* html pre { height: 1%; }
/* End hide from IE-mac */
</style>
</head>
<body>
<div id="container">
<div id="headerNav">
<ul>
<li class="first"><a href="/">Home</a></li>
<li><a href="../../products.html">Products</a></li>
<li><a href="../../contact.html">Contact</a></li>
<!-- <li><a href="/about.html">About</a></li> -->
</ul>
</div>
<div id="header">
<h1><span>Rasterbar Software</span></h1>
<h2><span>Software developement and consulting</span></h2>
<span>
</span>
</div>
<div id="main">
<div class="document" id="bittorrent-udp-tracker-protocol-extension">
<h1 class="title">Bittorrent udp-tracker protocol extension</h1>
<div class="contents topic" id="contents">
<p class="topic-title first"><a name="contents">Contents</a></p>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Arvid Norberg, <a class="last reference" href="mailto:arvid&#64;rasterbar.com">arvid&#64;rasterbar.com</a></td></tr>
</tbody>
</table>
<div class="contents topic" id="table-of-contents">
<p class="topic-title first"><a name="table-of-contents">Table of contents</a></p>
<ul class="simple">
<li><a class="reference" href="#introduction" id="id6" name="id6">introduction</a></li>
<li><a class="reference" href="#connecting" id="id7" name="id7">connecting</a><ul>
<li><a class="reference" href="#client-sends-packet" id="id8" name="id8">Client sends packet:</a></li>
<li><a class="reference" href="#server-replies-with-packet" id="id9" name="id9">Server replies with packet:</a></li>
<li><a class="reference" href="#introduction" id="id2" name="id2">introduction</a></li>
<li><a class="reference" href="#connecting" id="id3" name="id3">connecting</a></li>
<li><a class="reference" href="#announcing" id="id4" name="id4">announcing</a></li>
<li><a class="reference" href="#scraping" id="id5" name="id5">scraping</a></li>
<li><a class="reference" href="#errors" id="id6" name="id6">errors</a></li>
<li><a class="reference" href="#actions" id="id7" name="id7">actions</a></li>
<li><a class="reference" href="#extensions" id="id8" name="id8">extensions</a><ul>
<li><a class="reference" href="#authentication" id="id9" name="id9">authentication</a></li>
</ul>
</li>
<li><a class="reference" href="#announcing" id="id10" name="id10">announcing</a><ul>
<li><a class="reference" href="#id2" id="id11" name="id11">Client sends packet:</a></li>
<li><a class="reference" href="#id3" id="id12" name="id12">Server replies with packet:</a></li>
</ul>
</li>
<li><a class="reference" href="#scraping" id="id13" name="id13">scraping</a><ul>
<li><a class="reference" href="#id4" id="id14" name="id14">Client sends packet:</a></li>
<li><a class="reference" href="#id5" id="id15" name="id15">Server replies with packet:</a></li>
</ul>
</li>
<li><a class="reference" href="#errors" id="id16" name="id16">errors</a><ul>
<li><a class="reference" href="#server-replies-packet" id="id17" name="id17">server replies packet:</a></li>
</ul>
</li>
<li><a class="reference" href="#actions" id="id18" name="id18">actions</a></li>
<li><a class="reference" href="#extensions" id="id19" name="id19">extensions</a><ul>
<li><a class="reference" href="#authentication" id="id20" name="id20">authentication</a></li>
</ul>
</li>
<li><a class="reference" href="#credits" id="id21" name="id21">credits</a></li>
<li><a class="reference" href="#credits" id="id10" name="id10">credits</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id6" name="introduction">introduction</a></h1>
<h1><a name="introduction">introduction</a></h1>
<p>A tracker with the protocol &quot;udp://&quot; in its URI
is supposed to be contacted using this protocol.</p>
<p>This protocol is supported by
@ -57,9 +78,8 @@ the request. If no reply has been received after 60 seconds, stop
retrying.</p>
</div>
<div class="section" id="connecting">
<h1><a class="toc-backref" href="#id7" name="connecting">connecting</a></h1>
<div class="section" id="client-sends-packet">
<h2><a class="toc-backref" href="#id8" name="client-sends-packet">Client sends packet:</a></h2>
<h1><a name="connecting">connecting</a></h1>
<p>Client sends packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -89,9 +109,7 @@ identify the protocol.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="server-replies-with-packet">
<h2><a class="toc-backref" href="#id9" name="server-replies-with-packet">Server replies with packet:</a></h2>
<p>Server replies with packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -129,11 +147,9 @@ anymore.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="announcing">
<h1><a class="toc-backref" href="#id10" name="announcing">announcing</a></h1>
<div class="section" id="id2">
<h2><a class="toc-backref" href="#id11" name="id2">Client sends packet:</a></h2>
<h1><a name="announcing">announcing</a></h1>
<p>Client sends packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -224,9 +240,7 @@ in the reply. Use -1 for default.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id12" name="id3">Server replies with packet:</a></h2>
<p>Server replies with packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -295,11 +309,9 @@ seeding.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="scraping">
<h1><a class="toc-backref" href="#id13" name="scraping">scraping</a></h1>
<div class="section" id="id4">
<h2><a class="toc-backref" href="#id14" name="id4">Client sends packet:</a></h2>
<h1><a name="scraping">scraping</a></h1>
<p>Client sends packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -358,9 +370,7 @@ follow.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id5">
<h2><a class="toc-backref" href="#id15" name="id5">Server replies with packet:</a></h2>
<p>Server replies with packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -418,12 +428,10 @@ leechers.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="errors">
<h1><a class="toc-backref" href="#id16" name="errors">errors</a></h1>
<h1><a name="errors">errors</a></h1>
<p>In case of a tracker error,</p>
<div class="section" id="server-replies-packet">
<h2><a class="toc-backref" href="#id17" name="server-replies-packet">server replies packet:</a></h2>
<p>server replies packet:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
@ -455,9 +463,8 @@ describing the error.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="actions">
<h1><a class="toc-backref" href="#id18" name="actions">actions</a></h1>
<h1><a name="actions">actions</a></h1>
<p>The action fields has the following encoding:</p>
<blockquote>
<ul class="simple">
@ -469,7 +476,7 @@ describing the error.</td>
</blockquote>
</div>
<div class="section" id="extensions">
<h1><a class="toc-backref" href="#id19" name="extensions">extensions</a></h1>
<h1><a name="extensions">extensions</a></h1>
<p>The extensions field is a bitmask. The following
bits are assigned:</p>
<blockquote>
@ -478,7 +485,7 @@ bits are assigned:</p>
</ul>
</blockquote>
<div class="section" id="authentication">
<h2><a class="toc-backref" href="#id20" name="authentication">authentication</a></h2>
<h2><a name="authentication">authentication</a></h2>
<p>The packet will have an authentication part
appended to it. It has the following format:</p>
<table border="1" class="docutils">
@ -518,9 +525,17 @@ from the 20 bytes hash calculated.</td>
</div>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id21" name="credits">credits</a></h1>
<h1><a name="credits">credits</a></h1>
<p>Protocol designed by Olaf van der Spek</p>
</div>
</div>
</div>
<div id="footer">
<span>Copyright &copy; 2005 Rasterbar Software.</span>
</div>
</div>
</body>
</html>

View File

@ -1,12 +1,15 @@
=========================================
Bittorrent udp-tracker protocol extension
=========================================
.. contents::
:Author: Arvid Norberg, arvid@rasterbar.com
.. contents:: Table of contents
:depth: 2
:backlinks: none
introduction
++++++++++++
------------
A tracker with the protocol "udp://" in its URI
is supposed to be contacted using this protocol.
@ -32,10 +35,9 @@ retrying.
connecting
++++++++++
----------
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -50,7 +52,6 @@ Client sends packet:
+-------------+---------------------+----------------------------------------+
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -73,10 +74,9 @@ Server replies with packet:
announcing
++++++++++
----------
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -127,7 +127,6 @@ Client sends packet:
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -163,11 +162,9 @@ The rest of the server reply is a variable number of the following structure:
scraping
++++++++
--------
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -196,7 +193,6 @@ The following structure is repeated ``num_info_hashes`` times:
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -225,12 +221,11 @@ you asked in the scrape request.
errors
++++++
------
In case of a tracker error,
server replies packet:
----------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -247,7 +242,7 @@ server replies packet:
actions
+++++++
-------
The action fields has the following encoding:
@ -258,7 +253,7 @@ The action fields has the following encoding:
extensions
++++++++++
----------
The extensions field is a bitmask. The following
bits are assigned:
@ -268,7 +263,7 @@ bits are assigned:
authentication
--------------
~~~~~~~~~~~~~~
The packet will have an authentication part
appended to it. It has the following format:
@ -292,7 +287,7 @@ appended to it. It has the following format:
credits
+++++++
-------
Protocol designed by Olaf van der Spek

View File

@ -55,10 +55,11 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma warning(pop)
#endif
#include "libtorrent/config.hpp"
namespace libtorrent {
class alert
class TORRENT_EXPORT alert
{
public:
enum severity_t { debug, info, warning, critical, fatal, none };
@ -81,7 +82,7 @@ namespace libtorrent {
boost::posix_time::ptime m_timestamp;
};
class alert_manager
class TORRENT_EXPORT alert_manager
{
public:
alert_manager();
@ -100,7 +101,7 @@ namespace libtorrent {
mutable boost::mutex m_mutex;
};
struct unhandled_alert : std::exception
struct TORRENT_EXPORT unhandled_alert : std::exception
{
unhandled_alert() {}
};
@ -145,7 +146,7 @@ namespace libtorrent {
template<
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(5, class T, detail::void_)
>
struct handle_alert
struct TORRENT_EXPORT handle_alert
{
template<class Handler>
handle_alert(

View File

@ -37,10 +37,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct tracker_alert: alert
struct TORRENT_EXPORT tracker_alert: alert
{
tracker_alert(torrent_handle const& h
, int times
@ -60,7 +61,7 @@ namespace libtorrent
int status_code;
};
struct tracker_warning_alert: alert
struct TORRENT_EXPORT tracker_warning_alert: alert
{
tracker_warning_alert(torrent_handle const& h
, std::string const& msg)
@ -76,7 +77,7 @@ namespace libtorrent
struct tracker_reply_alert: alert
struct TORRENT_EXPORT tracker_reply_alert: alert
{
tracker_reply_alert(torrent_handle const& h
, std::string const& msg)
@ -90,7 +91,7 @@ namespace libtorrent
torrent_handle handle;
};
struct tracker_announce_alert: alert
struct TORRENT_EXPORT tracker_announce_alert: alert
{
tracker_announce_alert(torrent_handle const& h, std::string const& msg)
: alert(alert::info, msg)
@ -103,7 +104,7 @@ namespace libtorrent
torrent_handle handle;
};
struct hash_failed_alert: alert
struct TORRENT_EXPORT hash_failed_alert: alert
{
hash_failed_alert(
torrent_handle const& h
@ -121,7 +122,7 @@ namespace libtorrent
int piece_index;
};
struct peer_ban_alert: alert
struct TORRENT_EXPORT peer_ban_alert: alert
{
peer_ban_alert(address const& pip, torrent_handle h, std::string const& msg)
: alert(alert::info, msg)
@ -136,7 +137,7 @@ namespace libtorrent
torrent_handle handle;
};
struct peer_error_alert: alert
struct TORRENT_EXPORT peer_error_alert: alert
{
peer_error_alert(address const& pip, peer_id const& pid, std::string const& msg)
: alert(alert::debug, msg)
@ -151,7 +152,7 @@ namespace libtorrent
peer_id id;
};
struct chat_message_alert: alert
struct TORRENT_EXPORT chat_message_alert: alert
{
chat_message_alert(
const torrent_handle& h
@ -169,7 +170,7 @@ namespace libtorrent
address ip;
};
struct invalid_request_alert: alert
struct TORRENT_EXPORT invalid_request_alert: alert
{
invalid_request_alert(
peer_request const& r
@ -193,7 +194,7 @@ namespace libtorrent
peer_id id;
};
struct torrent_finished_alert: alert
struct TORRENT_EXPORT torrent_finished_alert: alert
{
torrent_finished_alert(
const torrent_handle& h
@ -208,7 +209,7 @@ namespace libtorrent
torrent_handle handle;
};
struct file_error_alert: alert
struct TORRENT_EXPORT file_error_alert: alert
{
file_error_alert(
const torrent_handle& h
@ -223,7 +224,7 @@ namespace libtorrent
torrent_handle handle;
};
struct metadata_failed_alert: alert
struct TORRENT_EXPORT metadata_failed_alert: alert
{
metadata_failed_alert(
const torrent_handle& h
@ -238,7 +239,7 @@ namespace libtorrent
torrent_handle handle;
};
struct metadata_received_alert: alert
struct TORRENT_EXPORT metadata_received_alert: alert
{
metadata_received_alert(
const torrent_handle& h
@ -253,7 +254,7 @@ namespace libtorrent
torrent_handle handle;
};
struct listen_failed_alert: alert
struct TORRENT_EXPORT listen_failed_alert: alert
{
listen_failed_alert(
const std::string& msg)
@ -264,7 +265,7 @@ namespace libtorrent
{ return std::auto_ptr<alert>(new listen_failed_alert(*this)); }
};
struct fastresume_rejected_alert: alert
struct TORRENT_EXPORT fastresume_rejected_alert: alert
{
fastresume_rejected_alert(torrent_handle const& h
, std::string const& msg)

View File

@ -77,6 +77,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "libtorrent/entry.hpp"
#include "libtorrent/config.hpp"
#if defined(_MSC_VER)
namespace std
@ -92,7 +93,7 @@ namespace std
namespace libtorrent
{
struct invalid_encoding: std::exception
struct TORRENT_EXPORT invalid_encoding: std::exception
{
virtual const char* what() const throw() { return "invalid bencoding"; }
};
@ -106,7 +107,7 @@ namespace libtorrent
std::copy(val.begin(), end, out);
}
char const* integer_to_str(char* buf, int size, entry::integer_type val);
TORRENT_EXPORT char const* integer_to_str(char* buf, int size, entry::integer_type val);
template <class OutIt>
void write_integer(OutIt& out, entry::integer_type val)

62
include/libtorrent/config.hpp Executable file
View File

@ -0,0 +1,62 @@
/*
Copyright (c) 2005, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_CONFIG_HPP_INCLUDED
#define TORRENT_CONFIG_HPP_INCLUDED
#include <boost/config.hpp>
#if defined(__GNUC__) && __GNUC__ >= 4
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
# define TORRENT_EXPORT __attribute__ ((visibility("default")))
# else
# define TORRENT_EXPORT
# endif
#elif defined(BOOST_MSVC)
# if defined(TORRENT_BUILDING_SHARED)
# define TORRENT_EXPORT __declspec(dllexport)
# elif defined(TORRENT_LINKING_SHARED)
# define TORRENT_EXPORT __declspec(dllimport)
# else
# define TORRENT_EXPORT
# endif
#else
# define TORRENT_EXPORT
#endif
#endif // TORRENT_CONFIG_HPP_INCLUDED

View File

@ -67,11 +67,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cassert>
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct type_error: std::runtime_error
struct TORRENT_EXPORT type_error: std::runtime_error
{
type_error(const char* error): std::runtime_error(error) {}
};
@ -104,7 +105,7 @@ namespace libtorrent
class entry;
class entry
class TORRENT_EXPORT entry
{
public:

View File

@ -34,11 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_ESCAPE_STRING_HPP_INCLUDED
#include <string>
#include "libtorrent/config.hpp"
namespace libtorrent
{
std::string unescape_string(std::string const& s);
std::string escape_string(const char* str, int len);
std::string TORRENT_EXPORT unescape_string(std::string const& s);
std::string TORRENT_EXPORT escape_string(const char* str, int len);
}
#endif // TORRENT_ESCAPE_STRING_HPP_INCLUDED

View File

@ -48,16 +48,17 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct file_error: std::runtime_error
struct TORRENT_EXPORT file_error: std::runtime_error
{
file_error(std::string const& msg): std::runtime_error(msg) {}
};
class file: public boost::noncopyable
class TORRENT_EXPORT file: public boost::noncopyable
{
public:

View File

@ -37,18 +37,19 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/cstdint.hpp>
#include "libtorrent/peer_id.hpp"
#include "libtorrent/config.hpp"
// from sha1.cpp
struct SHA1_CTX
struct TORRENT_EXPORT SHA1_CTX
{
boost::uint32_t state[5];
boost::uint32_t count[2];
boost::uint8_t buffer[64];
};
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, boost::uint8_t const* data, boost::uint32_t len);
void SHA1Final(SHA1_CTX* context, boost::uint8_t* digest);
TORRENT_EXPORT void SHA1Init(SHA1_CTX* context);
TORRENT_EXPORT void SHA1Update(SHA1_CTX* context, boost::uint8_t const* data, boost::uint32_t len);
TORRENT_EXPORT void SHA1Final(SHA1_CTX* context, boost::uint8_t* digest);
extern "C"
{

View File

@ -57,11 +57,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer.hpp"
#include "libtorrent/tracker_manager.hpp"
#include "libtorrent/async_gethostbyname.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
class http_tracker_connection: public tracker_connection
class TORRENT_EXPORT http_tracker_connection: public tracker_connection
{
friend class tracker_manager;
public:

View File

@ -34,11 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
#include "libtorrent/peer_id.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
std::string identify_client(const peer_id& p);
TORRENT_EXPORT std::string identify_client(const peer_id& p);
}

View File

@ -34,13 +34,14 @@ POSSIBILITY OF SUCH DAMAGE.
#define IP_FILTER_HPP
#include "libtorrent/socket.hpp"
#include "libtorrent/config.hpp"
#include <set>
#include <iostream>
namespace libtorrent
{
class ip_filter
class TORRENT_EXPORT ip_filter
{
public:

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct peer_entry
struct TORRENT_EXPORT peer_entry
{
std::string ip;
int port;

View File

@ -66,6 +66,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/allocate_resources.hpp"
#include "libtorrent/peer_request.hpp"
#include "libtorrent/piece_block_progress.hpp"
#include "libtorrent/config.hpp"
// TODO: each time a block is 'taken over'
// from another peer. That peer must be given
@ -80,12 +81,12 @@ namespace libtorrent
struct session_impl;
}
struct protocol_error: std::runtime_error
struct TORRENT_EXPORT protocol_error: std::runtime_error
{
protocol_error(const std::string& msg): std::runtime_error(msg) {};
};
class peer_connection: public boost::noncopyable
class TORRENT_EXPORT peer_connection: public boost::noncopyable
{
friend class invariant_access;
public:

View File

@ -39,10 +39,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <algorithm>
#include "libtorrent/config.hpp"
namespace libtorrent
{
class big_number
class TORRENT_EXPORT big_number
{
// private type
struct private_pointer {};

View File

@ -38,10 +38,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct peer_info
struct TORRENT_EXPORT peer_info
{
enum
{

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct peer_request
struct TORRENT_EXPORT peer_request
{
int piece;
int start;

View File

@ -33,9 +33,11 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_PIECE_BLOCK_PROGRESS_HPP_INCLUDED
#define TORRENT_PIECE_BLOCK_PROGRESS_HPP_INCLUDED
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct piece_block_progress
struct TORRENT_EXPORT piece_block_progress
{
// the piece and block index
// determines exactly which

View File

@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -57,7 +58,7 @@ namespace libtorrent
class address;
class peer_connection;
struct piece_block
struct TORRENT_EXPORT piece_block
{
piece_block(int p_index, int b_index)
: piece_index(p_index)
@ -81,7 +82,7 @@ namespace libtorrent
};
class piece_picker
class TORRENT_EXPORT piece_picker
{
public:
@ -335,3 +336,4 @@ namespace libtorrent
}
#endif // TORRENT_PIECE_PICKER_HPP_INCLUDED

View File

@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/size_type.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -71,7 +72,7 @@ namespace libtorrent
};
class policy
class TORRENT_EXPORT policy
{
public:
@ -239,3 +240,4 @@ namespace libtorrent
}
#endif // TORRENT_POLICY_HPP_INCLUDED

View File

@ -43,9 +43,11 @@ POSSIBILITY OF SUCH DAMAGE.
#undef max
#endif
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct resource_request
struct TORRENT_EXPORT resource_request
{
resource_request()
: used(0)

View File

@ -68,6 +68,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_request.hpp"
#include "libtorrent/piece_block_progress.hpp"
#include "libtorrent/ip_filter.hpp"
#include "libtorrent/config.hpp"
#if !defined(NDEBUG) && defined(_MSC_VER)
# include <float.h>
@ -281,7 +282,7 @@ namespace libtorrent
struct http_settings;
struct session_status
struct TORRENT_EXPORT session_status
{
bool has_incoming_connections;
@ -300,7 +301,7 @@ namespace libtorrent
int num_peers;
};
class session: public boost::noncopyable, detail::eh_initializer
class TORRENT_EXPORT session: public boost::noncopyable, detail::eh_initializer
{
public:
@ -403,3 +404,4 @@ namespace libtorrent
}
#endif // TORRENT_SESSION_HPP_INCLUDED

View File

@ -51,12 +51,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <exception>
#include <string>
// TODO: support ToS
#include "libtorrent/config.hpp"
namespace libtorrent
{
class network_error : public std::exception
class TORRENT_EXPORT network_error : public std::exception
{
public:
network_error(int error_code): m_error_code(error_code) {}
@ -69,7 +69,7 @@ namespace libtorrent
class socket;
class address
class TORRENT_EXPORT address
{
friend class socket;
public:
@ -109,7 +109,7 @@ namespace libtorrent
unsigned int m_ip;
};
class socket: public boost::noncopyable
class TORRENT_EXPORT socket: public boost::noncopyable
{
friend class address;
friend class selector;
@ -228,7 +228,7 @@ namespace libtorrent
class selector
class TORRENT_EXPORT selector
{
public:

View File

@ -39,11 +39,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/size_type.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
class stat
class TORRENT_EXPORT stat
{
friend class invariant_access;
enum { history = 10 };

View File

@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -61,17 +62,20 @@ namespace libtorrent
class session;
std::vector<std::pair<size_type, std::time_t> > get_filesizes(
TORRENT_EXPORT std::wstring safe_convert(std::string const& s);
TORRENT_EXPORT std::vector<std::pair<size_type, std::time_t> > get_filesizes(
torrent_info const& t
, boost::filesystem::path p);
bool match_filesizes(
TORRENT_EXPORT bool match_filesizes(
torrent_info const& t
, boost::filesystem::path p
, std::vector<std::pair<size_type, std::time_t> > const& sizes
, std::string* error = 0);
struct file_allocation_failed: std::exception
struct TORRENT_EXPORT file_allocation_failed: std::exception
{
file_allocation_failed(const char* error_msg): m_msg(error_msg) {}
virtual const char* what() const throw() { return m_msg.c_str(); }
@ -79,7 +83,7 @@ namespace libtorrent
std::string m_msg;
};
class storage
class TORRENT_EXPORT storage
{
public:
storage(
@ -112,7 +116,7 @@ namespace libtorrent
boost::shared_ptr<impl> m_pimpl;
};
class piece_manager : boost::noncopyable
class TORRENT_EXPORT piece_manager : boost::noncopyable
{
public:

View File

@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/scoped_ptr.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
@ -63,6 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert.hpp"
#include "libtorrent/resource_request.hpp"
#include "libtorrent/piece_picker.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -89,7 +91,7 @@ namespace libtorrent
// a torrent is a class that holds information
// for a specific download. It updates itself against
// the tracker
class torrent: public request_callback
class TORRENT_EXPORT torrent: public request_callback
, public boost::enable_shared_from_this<torrent>
{
public:
@ -435,7 +437,7 @@ namespace libtorrent
// if this pointer is 0, the torrent is in
// a state where the metadata hasn't been
// received yet.
std::auto_ptr<piece_manager> m_storage;
boost::scoped_ptr<piece_manager> m_storage;
// the time of next tracker request
boost::posix_time::ptime m_next_request;
@ -473,7 +475,7 @@ namespace libtorrent
detail::session_impl& m_ses;
detail::checker_impl& m_checker;
std::auto_ptr<piece_picker> m_picker;
boost::scoped_ptr<piece_picker> m_picker;
std::vector<announce_entry> m_trackers;
// this is an index into m_torrent_file.trackers()

View File

@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_info.hpp"
#include "libtorrent/piece_picker.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -58,19 +59,19 @@ namespace libtorrent
struct checker_impl;
}
struct duplicate_torrent: std::exception
struct TORRENT_EXPORT duplicate_torrent: std::exception
{
virtual const char* what() const throw()
{ return "torrent already exists in session"; }
};
struct invalid_handle: std::exception
struct TORRENT_EXPORT invalid_handle: std::exception
{
virtual const char* what() const throw()
{ return "invalid torrent handle used"; }
};
struct torrent_status
struct TORRENT_EXPORT torrent_status
{
torrent_status()
: state(queued_for_checking)
@ -188,7 +189,7 @@ namespace libtorrent
int block_size;
};
struct partial_piece_info
struct TORRENT_EXPORT partial_piece_info
{
enum { max_blocks_per_piece = piece_picker::max_blocks_per_piece };
int piece_index;
@ -199,7 +200,7 @@ namespace libtorrent
int num_downloads[max_blocks_per_piece];
};
struct torrent_handle
struct TORRENT_EXPORT torrent_handle
{
friend class invariant_access;
friend class session;

View File

@ -54,25 +54,25 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
struct file_entry
struct TORRENT_EXPORT file_entry
{
boost::filesystem::path path;
size_type size;
};
struct announce_entry
struct TORRENT_EXPORT announce_entry
{
announce_entry(std::string const& u): url(u), tier(0) {}
std::string url;
int tier;
};
struct invalid_torrent_file: std::exception
struct TORRENT_EXPORT invalid_torrent_file: std::exception
{
virtual const char* what() const throw() { return "invalid torrent file"; }
};
@ -82,7 +82,7 @@ namespace libtorrent
// also add a filename converter function that will transform
// invalid filenames to valid filenames on the current platform
class torrent_info
class TORRENT_EXPORT torrent_info
{
public:

View File

@ -56,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_settings.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/peer.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
@ -65,12 +66,12 @@ namespace libtorrent
// address parse_url(std::string const& url);
// encodes a string using the base64 scheme
std::string base64encode(const std::string& s);
TORRENT_EXPORT std::string base64encode(const std::string& s);
// returns -1 if gzip header is invalid or the header size in bytes
int gzip_header(const char* buf, int size);
TORRENT_EXPORT int gzip_header(const char* buf, int size);
struct tracker_request
struct TORRENT_EXPORT tracker_request
{
tracker_request()
: kind(announce_request)
@ -105,7 +106,7 @@ namespace libtorrent
int num_want;
};
struct request_callback
struct TORRENT_EXPORT request_callback
{
friend class tracker_manager;
request_callback(): m_manager(0) {}
@ -133,13 +134,13 @@ namespace libtorrent
tracker_manager* m_manager;
};
bool inflate_gzip(
TORRENT_EXPORT bool inflate_gzip(
std::vector<char>& buffer
, tracker_request const& req
, request_callback* requester
, int maximum_tracker_response_length);
struct tracker_connection: boost::noncopyable
struct TORRENT_EXPORT tracker_connection: boost::noncopyable
{
tracker_connection(boost::weak_ptr<request_callback> r)
: m_requester(r)
@ -158,7 +159,7 @@ namespace libtorrent
};
class tracker_manager: boost::noncopyable
class TORRENT_EXPORT tracker_manager: boost::noncopyable
{
public:

View File

@ -57,10 +57,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer.hpp"
#include "libtorrent/tracker_manager.hpp"
#include "libtorrent/async_gethostbyname.hpp"
#include "libtorrent/config.hpp"
namespace libtorrent
{
class udp_tracker_connection: public tracker_connection
class TORRENT_EXPORT udp_tracker_connection: public tracker_connection
{
friend class tracker_manager;
public:
@ -110,3 +111,4 @@ namespace libtorrent
}
#endif // TORRENT_UDP_TRACKER_CONNECTION_HPP_INCLUDED

View File

@ -155,21 +155,6 @@ inline std::string wchar_utf8(const std::wstring &str)
return ret;
}
inline std::wstring safe_convert(std::string const& s)
{
try
{
return utf8_wchar(s);
}
catch (std::exception)
{
std::wstring ret;
for (const char* i = &*s.begin(); i < &*s.end(); ++i)
ret += *i;
return ret;
}
}
}
#endif

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
#include "libtorrent/entry.hpp"
#include "libtorrent/config.hpp"
#include <boost/bind.hpp>
#include <boost/next_prior.hpp>
@ -70,7 +71,7 @@ namespace libtorrent
{
namespace detail
{
char const* integer_to_str(char* buf, int size, entry::integer_type val)
TORRENT_EXPORT char const* integer_to_str(char* buf, int size, entry::integer_type val)
{
int sign = 0;
if (val < 0)

View File

@ -21,16 +21,18 @@ changelog at the end of the file.
using boost::uint32_t;
using boost::uint8_t;
struct SHA1_CTX
#include "libtorrent/config.hpp"
struct TORRENT_EXPORT SHA1_CTX
{
uint32_t state[5];
uint32_t count[2];
uint8_t buffer[64];
};
void SHA1Init(SHA1_CTX* context);
void SHA1Update(SHA1_CTX* context, uint8_t const* data, uint32_t len);
void SHA1Final(SHA1_CTX* context, uint8_t* digest);
TORRENT_EXPORT void SHA1Init(SHA1_CTX* context);
TORRENT_EXPORT void SHA1Update(SHA1_CTX* context, uint8_t const* data, uint32_t len);
TORRENT_EXPORT void SHA1Final(SHA1_CTX* context, uint8_t* digest);
namespace
{

View File

@ -79,7 +79,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/exception.hpp>
#include "libtorrent/utf8.hpp"
namespace
namespace libtorrent
{
std::wstring safe_convert(std::string const& s)
{
@ -100,7 +100,11 @@ namespace
return ret;
}
}
}
namespace
{
using libtorrent::safe_convert;
using namespace boost::filesystem;
// based on code from Boost.Fileystem
@ -1223,8 +1227,7 @@ namespace libtorrent
// that hasn't already been assigned
int other_piece = -1;
for (std::vector<int>::iterator i = matching_pieces.begin();
i != matching_pieces.end();
++i)
i != matching_pieces.end(); ++i)
{
if (have_pieces[*i] || *i == piece_index) continue;
other_piece = *i;
@ -1412,7 +1415,7 @@ namespace libtorrent
// first, create all missing directories
path last_path;
for (torrent_info::file_iterator file_iter = m_info.begin_files(),
end_iter = m_info.end_files(); file_iter != end_iter; ++file_iter)
end_iter = m_info.end_files(); file_iter != end_iter; ++file_iter)
{
path dir = (m_save_path / file_iter->path).branch_path();
if (dir == last_path) continue;

View File

@ -354,9 +354,9 @@ namespace libtorrent
assert(m_torrent_file.total_size() >= 0);
m_have_pieces.resize(m_torrent_file.num_pieces(), false);
m_storage = std::auto_ptr<piece_manager>(new piece_manager(m_torrent_file, m_save_path));
m_storage.reset(new piece_manager(m_torrent_file, m_save_path));
m_block_size = calculate_block_size(m_torrent_file, m_default_block_size);
m_picker = std::auto_ptr<piece_picker>(new piece_picker(
m_picker.reset(new piece_picker(
static_cast<int>(m_torrent_file.piece_length() / m_block_size)
, static_cast<int>((m_torrent_file.total_size()+m_block_size-1)/m_block_size)));
}