don't include base32encode in the build when i2p is disabled

This commit is contained in:
arvidn 2017-03-30 21:04:48 -04:00 committed by Arvid Norberg
parent 990756ca38
commit 6584423737
3 changed files with 6 additions and 0 deletions

View File

@ -78,8 +78,10 @@ namespace libtorrent
// encodes a string using the base64 scheme
TORRENT_EXTRA_EXPORT std::string base64encode(std::string const& s);
#if TORRENT_USE_I2P
// encodes a string using the base32 scheme
TORRENT_EXTRA_EXPORT std::string base32encode(string_view s, int flags = 0);
#endif
TORRENT_EXTRA_EXPORT std::string base32decode(string_view s);
TORRENT_EXTRA_EXPORT string_view url_has_argument(

View File

@ -338,6 +338,7 @@ namespace libtorrent
return ret;
}
#if TORRENT_USE_I2P
std::string base32encode(string_view s, int flags)
{
static char const base32_table_canonical[] =
@ -401,6 +402,7 @@ namespace libtorrent
}
return ret;
}
#endif // TORRENT_USE_I2P
std::string base32decode(string_view s)
{

View File

@ -143,6 +143,7 @@ TORRENT_TEST(base64)
TEST_CHECK(base64encode("foobar") == "Zm9vYmFy");
}
#if TORRENT_USE_I2P
TORRENT_TEST(base32)
{
// base32 test vectors from http://www.faqs.org/rfcs/rfc4648.html
@ -159,6 +160,7 @@ TORRENT_TEST(base32)
TEST_CHECK(base32encode("fo", string::no_padding) == "MZXQ");
TEST_CHECK(base32encode("foob", string::i2p) == "mzxw6yq");
TEST_CHECK(base32encode("foobar", string::lowercase) == "mzxw6ytboi======");
#endif // TORRENT_USE_I2P
TEST_CHECK(base32decode("") == "");
TEST_CHECK(base32decode("MY======") == "f");