forked from premiere/premiere-libtorrent
windows build fixes (and one msvc warning fix)
This commit is contained in:
parent
c0b83375bf
commit
310b9d0e51
|
@ -36,8 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <stdio.h> // for snprintf
|
#include <stdio.h> // for snprintf
|
||||||
#include <stdlib.h> // for _TRUNCATE (windows)
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define __STDC_FORMAT_MACROS
|
#define __STDC_FORMAT_MACROS
|
||||||
|
@ -128,12 +126,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// this is the maximum number of characters in a
|
// this is the maximum number of characters in a
|
||||||
// path element / filename on windows
|
// path element / filename on windows
|
||||||
#define NAME_MAX 255
|
#define NAME_MAX 255
|
||||||
|
|
||||||
inline int snprintf(char* buf, int len, char const* fmt, ...)
|
inline int snprintf(char* buf, int len, char const* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list lp;
|
va_list lp;
|
||||||
va_start(lp, fmt);
|
va_start(lp, fmt);
|
||||||
return vsnprintf_s(buf, len, _TRUNCATE, fmt, lp);
|
int ret = _vsnprintf(buf, len, fmt, lp);
|
||||||
|
va_end(lp);
|
||||||
|
if (ret < 0) { buf[len-1] = 0; ret = len-1; }
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define strtoll _strtoi64
|
#define strtoll _strtoi64
|
||||||
#else
|
#else
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace libtorrent { namespace dht
|
||||||
TORRENT_DECLARE_LOG(node);
|
TORRENT_DECLARE_LOG(node);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct traversal_algorithm;
|
class traversal_algorithm;
|
||||||
|
|
||||||
// this is the entry for every peer
|
// this is the entry for every peer
|
||||||
// the timestamp is there to make it possible
|
// the timestamp is there to make it possible
|
||||||
|
|
|
@ -85,7 +85,7 @@ tuple<int, int, bool> feed_bytes(http_parser& parser, char const* str)
|
||||||
tie(payload, protocol) = parser.incoming(recv_buf, error);
|
tie(payload, protocol) = parser.incoming(recv_buf, error);
|
||||||
ret.get<0>() += payload;
|
ret.get<0>() += payload;
|
||||||
ret.get<1>() += protocol;
|
ret.get<1>() += protocol;
|
||||||
ret.get<2>() += error;
|
ret.get<2>() |= error;
|
||||||
// std::cerr << payload << ", " << protocol << ", " << chunk_size << std::endl;
|
// std::cerr << payload << ", " << protocol << ", " << chunk_size << std::endl;
|
||||||
TORRENT_ASSERT(payload + protocol == chunk_size);
|
TORRENT_ASSERT(payload + protocol == chunk_size);
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,12 @@ int test_main()
|
||||||
{
|
{
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
// test snprintf
|
||||||
|
|
||||||
|
char msg[10];
|
||||||
|
snprintf(msg, sizeof(msg), "too %s format string", "long");
|
||||||
|
TEST_CHECK(strcmp(msg, "too long ") == 0);
|
||||||
|
|
||||||
// test maybe_url_encode
|
// test maybe_url_encode
|
||||||
|
|
||||||
TEST_CHECK(maybe_url_encode("http://test:test@abc.com/abc<>abc") == "http://test:test@abc.com:80/abc%3c%3eabc");
|
TEST_CHECK(maybe_url_encode("http://test:test@abc.com/abc<>abc") == "http://test:test@abc.com:80/abc%3c%3eabc");
|
||||||
|
|
Loading…
Reference in New Issue