forked from premiere/premiere-libtorrent
modified fix for #431 to make it actually build and work
This commit is contained in:
parent
7b8663fa8b
commit
f6a9e44523
|
@ -87,12 +87,21 @@
|
||||||
bit mask & shift operations.
|
bit mask & shift operations.
|
||||||
------------------------------------------------------------------------ */
|
------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#include <boost/cstdint.hpp>
|
#ifdef __cplusplus
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
// these are standard C types, but they might
|
||||||
|
// not be available in c++
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
typedef boost::uint32_t uint32_t;
|
||||||
|
typedef boost::uint16_t uint16_t;
|
||||||
|
typedef boost::uint8_t uint8_t;
|
||||||
|
#else
|
||||||
|
#define TORRENT_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef boost::uint32_t UTF32; /* at least 32 bits */
|
typedef uint32_t UTF32; /* at least 32 bits */
|
||||||
typedef boost::uint16_t UTF16; /* at least 16 bits */
|
typedef uint16_t UTF16; /* at least 16 bits */
|
||||||
typedef boost::uint8_t UTF8; /* typically 8 bits */
|
typedef uint8_t UTF8; /* typically 8 bits */
|
||||||
typedef unsigned char Boolean; /* 0 or 1 */
|
typedef unsigned char Boolean; /* 0 or 1 */
|
||||||
|
|
||||||
/* Some fundamental constants */
|
/* Some fundamental constants */
|
||||||
|
|
29
src/GeoIP.c
29
src/GeoIP.c
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "libtorrent/GeoIP.h"
|
#include "libtorrent/GeoIP.h"
|
||||||
|
|
||||||
|
#include "libtorrent/ConvertUTF.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -345,7 +347,16 @@ int _check_mtime(GeoIP *gi) {
|
||||||
/* refresh filehandle */
|
/* refresh filehandle */
|
||||||
fclose(gi->GeoIPDatabase);
|
fclose(gi->GeoIPDatabase);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
gi->GeoIPDatabase = _wfopen(libtorrent::safe_convert(gi->file_path).c_str(),L"rb");
|
assert(sizeof(wchar_t) == 2);
|
||||||
|
int name_len = strlen(gi->file_path);
|
||||||
|
wchar_t* wfilename = malloc((name_len + 1) * sizeof(wchar_t));
|
||||||
|
wchar_t const* dst_start = wfilename;
|
||||||
|
char const* src_start = gi->file_path;
|
||||||
|
ret = ConvertUTF8toUTF16((const UTF8**)&src_start, (const UTF8*)src_start
|
||||||
|
+ name_len, (UTF16**)&dst_start, (UTF16*)dst_start + name_len + 1
|
||||||
|
, lenientConversion);
|
||||||
|
gi->GeoIPDatabase = _wfopen(wfilename,L"rb");
|
||||||
|
free(wfilename);
|
||||||
#else
|
#else
|
||||||
gi->GeoIPDatabase = fopen(gi->file_path,"rb");
|
gi->GeoIPDatabase = fopen(gi->file_path,"rb");
|
||||||
#endif
|
#endif
|
||||||
|
@ -529,11 +540,6 @@ GeoIP* GeoIP_new (int flags) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
std::wstring safe_convert(std::string const& s);
|
|
||||||
}
|
|
||||||
|
|
||||||
GeoIP* GeoIP_open (const char * filename, int flags) {
|
GeoIP* GeoIP_open (const char * filename, int flags) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
GeoIP * gi;
|
GeoIP * gi;
|
||||||
|
@ -550,7 +556,16 @@ GeoIP* GeoIP_open (const char * filename, int flags) {
|
||||||
}
|
}
|
||||||
strncpy(gi->file_path, filename, len);
|
strncpy(gi->file_path, filename, len);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
gi->GeoIPDatabase = _wfopen(libtorrent::safe_convert(filename).c_str(),L"rb");
|
assert(sizeof(wchar_t) == 2);
|
||||||
|
int name_len = strlen(filename);
|
||||||
|
wchar_t* wfilename = malloc((name_len + 1) * sizeof(wchar_t));
|
||||||
|
wchar_t const* dst_start = wfilename;
|
||||||
|
char const* src_start = filename;
|
||||||
|
ret = ConvertUTF8toUTF16((const UTF8**)&src_start, (const UTF8*)src_start
|
||||||
|
+ name_len, (UTF16**)&dst_start, (UTF16*)dst_start + name_len + 1
|
||||||
|
, lenientConversion);
|
||||||
|
gi->GeoIPDatabase = _wfopen(wfilename,L"rb");
|
||||||
|
free(wfilename);
|
||||||
#else
|
#else
|
||||||
gi->GeoIPDatabase = fopen(filename,"rb");
|
gi->GeoIPDatabase = fopen(filename,"rb");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,6 +76,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/kademlia/dht_tracker.hpp"
|
#include "libtorrent/kademlia/dht_tracker.hpp"
|
||||||
#include "libtorrent/enum_net.hpp"
|
#include "libtorrent/enum_net.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
#include "libtorrent/utf8.hpp"
|
||||||
|
|
||||||
#ifndef TORRENT_WINDOWS
|
#ifndef TORRENT_WINDOWS
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
@ -347,7 +348,7 @@ namespace aux {
|
||||||
if (m_asnum_db) GeoIP_delete(m_asnum_db);
|
if (m_asnum_db) GeoIP_delete(m_asnum_db);
|
||||||
std::string utf8;
|
std::string utf8;
|
||||||
wchar_utf8(file, utf8);
|
wchar_utf8(file, utf8);
|
||||||
m_asnum_db = GeoIP_open(utf8, GEOIP_STANDARD);
|
m_asnum_db = GeoIP_open(utf8.c_str(), GEOIP_STANDARD);
|
||||||
return m_asnum_db;
|
return m_asnum_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +366,7 @@ namespace aux {
|
||||||
if (m_country_db) GeoIP_delete(m_country_db);
|
if (m_country_db) GeoIP_delete(m_country_db);
|
||||||
std::string utf8;
|
std::string utf8;
|
||||||
wchar_utf8(file, utf8);
|
wchar_utf8(file, utf8);
|
||||||
m_country_db = GeoIP_open(utf8, GEOIP_STANDARD);
|
m_country_db = GeoIP_open(utf8.c_str(), GEOIP_STANDARD);
|
||||||
return m_country_db;
|
return m_country_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue