lt sync 3273

This commit is contained in:
Andrew Resch 2009-02-18 06:15:15 +00:00
parent cc272d8dc0
commit d9e67bcebe
8 changed files with 27 additions and 33 deletions

View file

@ -205,7 +205,8 @@ namespace libtorrent
{
static char const* state_str[] =
{"checking (q)", "checking", "dl metadata"
, "downloading", "finished", "seeding", "allocating"};
, "downloading", "finished", "seeding", "allocating"
, "checking (r)"};
return torrent_alert::message() + ": state changed to: "
+ state_str[state];

View file

@ -80,17 +80,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#if defined(_MSC_VER)
namespace std
{
using ::isdigit;
using ::atoi;
};
#define for if (false) {} else for
#endif
#include "libtorrent/escape_string.hpp"
namespace libtorrent
{
@ -341,7 +331,7 @@ namespace libtorrent
// ----------------------------------------------
// string
default:
if (isdigit((unsigned char)*in))
if (is_digit((unsigned char)*in))
{
std::string len_s = read_until(in, end, ':', err);
if (err)

View file

@ -42,7 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
boost::array<char, 3 + std::numeric_limits<size_type>::digits10> to_string(size_type n);
boost::array<char, 3 + std::numeric_limits<size_type>::digits10> TORRENT_EXPORT to_string(size_type n);
bool TORRENT_EXPORT is_digit(char c);
bool TORRENT_EXPORT isprint(char c);
std::string TORRENT_EXPORT unescape_string(std::string const& s);
std::string TORRENT_EXPORT escape_string(const char* str, int len);

View file

@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/escape_string.hpp"
namespace libtorrent
{
@ -168,8 +169,6 @@ namespace libtorrent
inline std::istream& operator>>(std::istream& is, big_number& peer)
{
using namespace std;
for (big_number::iterator i = peer.begin();
i != peer.end(); ++i)
{
@ -182,11 +181,11 @@ namespace libtorrent
|| ((c[1] < '0' || c[1] > '9') && (c[1] < 'a' || c[1] > 'f'))
|| is.fail())
{
is.setstate(ios_base::failbit);
is.setstate(std::ios_base::failbit);
return is;
}
*i = ((isdigit(c[0])?c[0]-'0':c[0]-'a'+10) << 4)
+ (isdigit(c[1])?c[1]-'0':c[1]-'a'+10);
*i = ((is_digit(c[0])?c[0]-'0':c[0]-'a'+10) << 4)
+ (is_digit(c[1])?c[1]-'0':c[1]-'a'+10);
}
return is;
}

View file

@ -69,6 +69,16 @@ namespace libtorrent
return ret;
}
bool is_digit(char c)
{
return c >= '0' && c <= '9';
}
bool isprint(char c)
{
return c >= 32 && c < 127;
}
std::string unescape_string(std::string const& s)
{
std::string ret;

View file

@ -48,28 +48,19 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/identify_client.hpp"
#include "libtorrent/fingerprint.hpp"
#include "libtorrent/escape_string.hpp"
namespace
{
using namespace libtorrent;
bool is_digit(char c)
{
return c >= '0' && c <= '9';
}
int decode_digit(char c)
{
if (is_digit(c)) return c - '0';
return unsigned(c) - 'A' + 10;
}
bool isprint(char c)
{
return c >= 32 && c < 127;
}
// takes a peer id and returns a valid boost::optional
// object if the peer id matched the azureus style encoding
// the returned fingerprint contains information about the

View file

@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/lazy_entry.hpp"
#include "libtorrent/escape_string.hpp"
#include <iostream>
#include <iomanip>
#include <cstring>
@ -58,8 +59,7 @@ namespace libtorrent
{
while (start < end && *start != delimiter)
{
using namespace std;
if (!isdigit(*start)) { return 0; }
if (!is_digit(*start)) { return 0; }
val *= 10;
val += *start - '0';
++start;
@ -154,8 +154,7 @@ namespace libtorrent
}
default:
{
using namespace std;
if (!isdigit(t)) return fail_bdecode(ret);
if (!is_digit(t)) return fail_bdecode(ret);
boost::int64_t len = t - '0';
start = parse_int(start, end, ':', len);

View file

@ -658,6 +658,7 @@ void upnp::update_map(rootdevice& d, int i)
m_log << time_now_string() << " *** mapping (" << i
<< ") does not need update, skipping" << std::endl;
#endif
m.action = mapping_t::action_none;
next(d, i);
return;
}
@ -673,6 +674,7 @@ void upnp::update_map(rootdevice& d, int i)
{
if (m.failcount > 5)
{
m.action = mapping_t::action_none;
// giving up
next(d, i);
return;