1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-09-15 16:57:19 +02:00

Update libraries and make it build on windows.

Still gets some warnings because compilers have changed. But should work.
This commit is contained in:
Sandu Liviu Catalin
2025-06-25 22:34:23 +03:00
parent 520a5eacc5
commit f2b7499f85
3038 changed files with 251668 additions and 273857 deletions

35
cmake/FindWinSock.cmake Normal file
View File

@@ -0,0 +1,35 @@
# Try to find WinSock library and include path.
# Once done this will define
#
# WINSOCK_FOUND
# WINSOCK_INCLUDE_DIR
# WINSOCK_LIBRARIES
find_path(WINSOCK_INCLUDE_DIR WinSock2.h)
if(MSVC)
find_library(WINSOCK_LIBRARY mswsock.lib)
find_library(WINSOCK2_LIBRARY ws2_32.lib)
find_library(WINSOCK2_LIBRARY bcrypt.lib)
else()
find_library(WINSOCK_LIBRARY mswsock)
find_library(WINSOCK2_LIBRARY ws2_32)
find_library(WINSOCK2_LIBRARY bcrypt)
endif()
# Handle the REQUIRED argument and set WINSOCK_FOUND
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WinSock DEFAULT_MSG WINSOCK_LIBRARY WINSOCK2_LIBRARY WINSOCK_INCLUDE_DIR)
mark_as_advanced(WINSOCK_INCLUDE_DIR)
mark_as_advanced(WINSOCK_LIBRARY)
mark_as_advanced(WINSOCK2_LIBRARY)
if(WINSOCK_FOUND)
add_definitions(-DWINSOCK_SUPPORT)
set(WINSOCK_LIBRARIES ${WINSOCK_LIBRARY} ${WINSOCK2_LIBRARY})
endif()
if(MINGW)
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lwsock32 -lws2_32 -lbcrypt")
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lwsock32 -lws2_32 -lbcrypt")
endif()

View File

@@ -493,7 +493,11 @@ Quaternion Quaternion::Abs() const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool Quaternion::IsNaN() const bool Quaternion::IsNaN() const
{ {
#if defined (__MINGW32__) || defined (__MINGW64__)
return _isnanf(w) || _isnanf(x) || _isnanf(y) || _isnanf(z);
#else
return isnanf(w) || isnanf(x) || isnanf(y) || isnanf(z); return isnanf(w) || isnanf(x) || isnanf(y) || isnanf(z);
#endif
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@@ -474,7 +474,11 @@ Vector3 Vector3::Abs() const
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool Vector3::IsNaN() const bool Vector3::IsNaN() const
{ {
#if defined (__MINGW32__) || defined (__MINGW64__)
return _isnanf(x) || _isnanf(y) || _isnanf(z);
#else
return isnanf(x) || isnanf(y) || isnanf(z); return isnanf(x) || isnanf(y) || isnanf(z);
#endif
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@@ -138,7 +138,7 @@ if(WIN32 OR MINGW)
target_link_libraries(SqModule wsock32 ws2_32 shlwapi) target_link_libraries(SqModule wsock32 ws2_32 shlwapi)
endif() endif()
# Link to base libraries # Link to base libraries
target_link_libraries(SqModule RPMalloc Squirrel fmt::fmt SimpleINI TinyDir xxHash ConcurrentQueue SAJSON CPR UTF8Lib PUGIXML CivetWeb inja maxminddb libzmq-static) target_link_libraries(SqModule Squirrel fmt::fmt SimpleINI TinyDir xxHash ConcurrentQueue SAJSON CPR UTF8Lib PUGIXML CivetWeb inja maxminddb libzmq-static)
# Link to POCO libraries # Link to POCO libraries
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net) target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net)
# Does POCO have SQLite support? # Does POCO have SQLite support?

View File

@@ -40,7 +40,6 @@
#include <sqratTable.h> #include <sqratTable.h>
#include <sqratUtil.h> #include <sqratUtil.h>
#include <fmt/core.h> #include <fmt/core.h>
#include <rpmalloc.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
@@ -272,93 +271,4 @@ SQMOD_NODISCARD SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx);
*/ */
SQMOD_NODISCARD bool SToB(const SQChar * str); SQMOD_NODISCARD bool SToB(const SQChar * str);
/* ------------------------------------------------------------------------------------------------
* RAII allocator initializer.
*/
struct RPMallocInit
{
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
RPMallocInit()
{
if (rpmalloc_initialize() != 0)
{
OutputError("Failed to initialize memory allocator");
}
}
/* --------------------------------------------------------------------------------------------
* Copy constructor (disabled).
*/
RPMallocInit(const RPMallocInit &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor (disabled).
*/
RPMallocInit(RPMallocInit &&) noexcept = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~RPMallocInit()
{
if (rpmalloc_is_thread_initialized()) rpmalloc_finalize();
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator (disabled).
*/
RPMallocInit & operator = (const RPMallocInit &) = delete;
/* --------------------------------------------------------------------------------------------
* Copy assignment operator (disabled).
*/
RPMallocInit & operator = (RPMallocInit &&) noexcept = delete;
};
/* ------------------------------------------------------------------------------------------------
* RAII allocator thread initializer.
*/
struct RPMallocThreadInit
{
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
RPMallocThreadInit()
{
rpmalloc_thread_initialize();
}
/* --------------------------------------------------------------------------------------------
* Copy constructor (disabled).
*/
RPMallocThreadInit(const RPMallocThreadInit &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor (disabled).
*/
RPMallocThreadInit(RPMallocThreadInit &&) noexcept = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~RPMallocThreadInit()
{
if (rpmalloc_is_thread_initialized()) rpmalloc_thread_finalize(1);
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator (disabled).
*/
RPMallocThreadInit & operator = (const RPMallocThreadInit &) = delete;
/* --------------------------------------------------------------------------------------------
* Copy assignment operator (disabled).
*/
RPMallocThreadInit & operator = (RPMallocThreadInit &&) noexcept = delete;
};
} // Namespace:: SqMod } // Namespace:: SqMod

View File

@@ -146,8 +146,6 @@ void ThreadPool::WorkerProc()
bool retry = false; bool retry = false;
// Pointer to the dequeued item // Pointer to the dequeued item
Item item; Item item;
// Initialize third-party allocator for this thread
auto rpmallocinit = std::make_unique< RPMallocThreadInit >();
// Constantly process items from the queue // Constantly process items from the queue
while (true) while (true)
{ {

View File

@@ -977,11 +977,6 @@ static void OnServerPerformanceReport(size_t /*entry_count*/, const char * * /*d
} // Namespace:: SqMod } // Namespace:: SqMod
/* ------------------------------------------------------------------------------------------------
* Automatically terminate the third-party allocator.
*/
static std::unique_ptr< SqMod::RPMallocInit > gsRPMallocInit;
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Plug-in initialization procedure. * Plug-in initialization procedure.
*/ */
@@ -1008,8 +1003,6 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMOD_HOST_NAME); std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMOD_HOST_NAME);
// Initialize CURL // Initialize CURL
curl_global_init(CURL_GLOBAL_DEFAULT); curl_global_init(CURL_GLOBAL_DEFAULT);
// Initialize third-party allocator
gsRPMallocInit = std::make_unique< RPMallocInit >();
// Attempt to initialize the logger before anything else // Attempt to initialize the logger before anything else
Logger::Get().Initialize(nullptr); Logger::Get().Initialize(nullptr);
// Attempt to initialize the plug-in core // Attempt to initialize the plug-in core

View File

@@ -41,7 +41,7 @@ SQMOD_DECL_TYPENAME(SqPcSqDataAsyncBuilder, _SC("SqSqDataAsyncBuilder"))
SQMOD_DECL_TYPENAME(SqPcDataStatementResult, _SC("SqDataStatementResult")) SQMOD_DECL_TYPENAME(SqPcDataStatementResult, _SC("SqDataStatementResult"))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
static const Poco::Data::NullData g_NullData{Poco::NULL_GENERIC}; static const Poco::Data::NullData g_NullData = std::nullopt;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void InitializePocoDataConnectors() void InitializePocoDataConnectors()

View File

@@ -1,7 +1,6 @@
add_subdirectory(ConcurrentQueue) add_subdirectory(ConcurrentQueue)
add_subdirectory(Fmt) add_subdirectory(Fmt)
add_subdirectory(xxHash) add_subdirectory(xxHash)
add_subdirectory(RPMalloc)
add_subdirectory(Squirrel) add_subdirectory(Squirrel)
add_subdirectory(SimpleIni) add_subdirectory(SimpleIni)
add_subdirectory(TinyDir) add_subdirectory(TinyDir)

View File

@@ -32,10 +32,21 @@ if (OPENSSL_FOUND)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR) list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_PATCH) list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_PATCH)
# Tell the library what SSL version to expect # Tell the library what SSL version to expect
target_compile_definitions(CivetWeb PRIVATE "OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}") if("${OPENSSL_VERSION_MAJOR}" STREQUAL "1")
message(STATUS "CivetWeb: OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}") if("${OPENSSL_VERSION_MINOR}" STREQUAL "1")
target_compile_definitions(CivetWeb PRIVATE OPENSSL_API_1_0=1)
message(STATUS "CivetWeb: OPENSSL_API_1_0")
else()
target_compile_definitions(CivetWeb PRIVATE OPENSSL_API_1_1=1)
message(STATUS "CivetWeb: OPENSSL_API_1_1")
endif()
else()
target_compile_definitions(CivetWeb PRIVATE OPENSSL_API_3_0=1)
message(STATUS "CivetWeb: OPENSSL_API_3_0")
endif()
else() else()
target_compile_definitions(CivetWeb PUBLIC NO_SSL=1) target_compile_definitions(CivetWeb PUBLIC NO_SSL=1)
message(STATUS "CivetWeb: OpenSSL was not found!")
endif() endif()
# Look for ZLib # Look for ZLib
find_package(ZLIB) find_package(ZLIB)
@@ -45,3 +56,15 @@ if (ZLIB_FOUND)
target_link_libraries(CivetWeb PUBLIC ZLIB::ZLIB) target_link_libraries(CivetWeb PUBLIC ZLIB::ZLIB)
target_compile_definitions(CivetWeb PUBLIC USE_ZLIB=1) target_compile_definitions(CivetWeb PUBLIC USE_ZLIB=1)
endif() endif()
# Need Windows sockets if available
if(MSVC OR MSYS OR MINGW)
find_package(WinSock)
if (WINSOCK_FOUND)
target_link_libraries(CivetWeb PUBLIC ${WINSOCK_LIBRARIES})
endif()
endif()
# We need threading
find_package(Threads)
target_link_libraries(CivetWeb PUBLIC ${CMAKE_THREAD_LIBS_INIT})
# Other configs
target_compile_definitions(CivetWeb PUBLIC USE_STACK_SIZE=102400)

View File

@@ -66,6 +66,10 @@ http://www.lua.org/license.html
> THE SOFTWARE. > THE SOFTWARE.
Additional components Copyright (C) Lua.org, PUC-Rio, with MIT license:
http://www.inf.puc-rio.br/~roberto/struct/
SQLite3 License SQLite3 License
------ ------

File diff suppressed because it is too large Load Diff

View File

@@ -162,14 +162,17 @@ search_boundary(const char *buf,
const char *boundary, const char *boundary,
size_t boundary_len) size_t boundary_len)
{ {
/* We must do a binary search here, not a string search, since the buffer char *boundary_start = "\r\n--";
* may contain '\x00' bytes, if binary data is transferred. */ size_t boundary_start_len = strlen(boundary_start);
int clen = (int)buf_len - (int)boundary_len - 4;
/* We must do a binary search here, not a string search, since the
* buffer may contain '\x00' bytes, if binary data is transferred. */
int clen = (int)buf_len - (int)boundary_len - boundary_start_len;
int i; int i;
for (i = 0; i <= clen; i++) { for (i = 0; i <= clen; i++) {
if (!memcmp(buf + i, "\r\n--", 4)) { if (!memcmp(buf + i, boundary_start, boundary_start_len)) {
if (!memcmp(buf + i + 4, boundary, boundary_len)) { if (!memcmp(buf + i + boundary_start_len, boundary, boundary_len)) {
return buf + i; return buf + i;
} }
} }
@@ -185,7 +188,7 @@ mg_handle_form_request(struct mg_connection *conn,
char path[512]; char path[512];
char buf[MG_BUF_LEN]; /* Must not be smaller than ~900 */ char buf[MG_BUF_LEN]; /* Must not be smaller than ~900 */
int field_storage; int field_storage;
int buf_fill = 0; size_t buf_fill = 0;
int r; int r;
int field_count = 0; int field_count = 0;
struct mg_file fstore = STRUCT_FILE_INITIALIZER; struct mg_file fstore = STRUCT_FILE_INITIALIZER;
@@ -394,10 +397,10 @@ mg_handle_form_request(struct mg_connection *conn,
int end_of_key_value_pair_found = 0; int end_of_key_value_pair_found = 0;
int get_block; int get_block;
if ((size_t)buf_fill < (sizeof(buf) - 1)) { if (buf_fill < (sizeof(buf) - 1)) {
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill; size_t to_read = sizeof(buf) - 1 - buf_fill;
r = mg_read(conn, buf + (size_t)buf_fill, to_read); r = mg_read(conn, buf + buf_fill, to_read);
if ((r < 0) || ((r == 0) && all_data_read)) { if ((r < 0) || ((r == 0) && all_data_read)) {
/* read error */ /* read error */
return -1; return -1;
@@ -526,11 +529,11 @@ mg_handle_form_request(struct mg_connection *conn,
buf + (size_t)used, buf + (size_t)used,
sizeof(buf) - (size_t)used); sizeof(buf) - (size_t)used);
next = buf; next = buf;
buf_fill -= (int)used; buf_fill -= used;
if ((size_t)buf_fill < (sizeof(buf) - 1)) { if (buf_fill < (sizeof(buf) - 1)) {
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill; size_t to_read = sizeof(buf) - 1 - buf_fill;
r = mg_read(conn, buf + (size_t)buf_fill, to_read); r = mg_read(conn, buf + buf_fill, to_read);
if ((r < 0) || ((r == 0) && all_data_read)) { if ((r < 0) || ((r == 0) && all_data_read)) {
#if !defined(NO_FILESYSTEMS) #if !defined(NO_FILESYSTEMS)
/* read error */ /* read error */
@@ -589,7 +592,7 @@ mg_handle_form_request(struct mg_connection *conn,
/* Proceed to next entry */ /* Proceed to next entry */
used = next - buf; used = next - buf;
memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used); memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);
buf_fill -= (int)used; buf_fill -= used;
} }
return field_count; return field_count;
@@ -624,6 +627,7 @@ mg_handle_form_request(struct mg_connection *conn,
} }
/* Copy boundary string to variable "boundary" */ /* Copy boundary string to variable "boundary" */
/* fbeg is pointer to start of value of boundary */
fbeg = content_type + bl + 9; fbeg = content_type + bl + 9;
bl = strlen(fbeg); bl = strlen(fbeg);
boundary = (char *)mg_malloc(bl + 1); boundary = (char *)mg_malloc(bl + 1);
@@ -678,12 +682,12 @@ mg_handle_form_request(struct mg_connection *conn,
for (part_no = 0;; part_no++) { for (part_no = 0;; part_no++) {
size_t towrite, fnlen, n; size_t towrite, fnlen, n;
int get_block; int get_block;
size_t to_read = sizeof(buf) - 1 - (size_t)buf_fill; size_t to_read = sizeof(buf) - 1 - buf_fill;
/* Unused without filesystems */ /* Unused without filesystems */
(void)n; (void)n;
r = mg_read(conn, buf + (size_t)buf_fill, to_read); r = mg_read(conn, buf + buf_fill, to_read);
if ((r < 0) || ((r == 0) && all_data_read)) { if ((r < 0) || ((r == 0) && all_data_read)) {
/* read error */ /* read error */
mg_free(boundary); mg_free(boundary);
@@ -701,43 +705,74 @@ mg_handle_form_request(struct mg_connection *conn,
return -1; return -1;
} }
/* @see https://www.rfc-editor.org/rfc/rfc2046.html#section-5.1.1
*
* multipart-body := [preamble CRLF]
* dash-boundary transport-padding CRLF
* body-part *encapsulation
* close-delimiter transport-padding
* [CRLF epilogue]
*/
if (part_no == 0) { if (part_no == 0) {
int d = 0; size_t preamble_length = 0;
while ((d < buf_fill) && (buf[d] != '-')) { /* skip over the preamble until we find a complete boundary
d++; * limit the preamble length to prevent abuse */
/* +2 for the -- preceding the boundary */
while (preamble_length < 1024
&& (preamble_length < buf_fill - bl)
&& strncmp(buf + preamble_length + 2, boundary, bl)) {
preamble_length++;
} }
if ((d > 0) && (buf[d] == '-')) { /* reset the start of buf to remove the preamble */
memmove(buf, buf + d, (unsigned)buf_fill - (unsigned)d); if (0 == strncmp(buf + preamble_length + 2, boundary, bl)) {
buf_fill -= d; memmove(buf,
buf + preamble_length,
(unsigned)buf_fill - (unsigned)preamble_length);
buf_fill -= preamble_length;
buf[buf_fill] = 0; buf[buf_fill] = 0;
} }
} }
if (buf[0] != '-' || buf[1] != '-') { /* either it starts with a boundary and it's fine, or it's malformed
* because:
* - the preamble was longer than accepted
* - couldn't find a boundary at all in the body
* - didn't have a terminating boundary */
if (buf_fill < (bl + 2) || strncmp(buf, "--", 2)
|| strncmp(buf + 2, boundary, bl)) {
/* Malformed request */ /* Malformed request */
mg_free(boundary); mg_free(boundary);
return -1; return -1;
} }
if (0 != strncmp(buf + 2, boundary, bl)) {
/* skip the -- */
char *boundary_start = buf + 2;
size_t transport_padding = 0;
while (boundary_start[bl + transport_padding] == ' '
|| boundary_start[bl + transport_padding] == '\t') {
transport_padding++;
}
char *boundary_end = boundary_start + bl + transport_padding;
/* after the transport padding, if the boundary isn't
* immediately followed by a \r\n then it is either... */
if (strncmp(boundary_end, "\r\n", 2)) {
/* ...the final boundary, and it is followed by --, (in which
* case it's the end of the request) or it's a malformed
* request */
if (strncmp(boundary_end, "--", 2)) {
/* Malformed request */ /* Malformed request */
mg_free(boundary); mg_free(boundary);
return -1; return -1;
} }
if (buf[bl + 2] != '\r' || buf[bl + 3] != '\n') { /* Ingore any epilogue here */
/* Every part must end with \r\n, if there is another part.
* The end of the request has an extra -- */
if (((size_t)buf_fill != (size_t)(bl + 6))
|| (strncmp(buf + bl + 2, "--\r\n", 4))) {
/* Malformed request */
mg_free(boundary);
return -1;
}
/* End of the request */
break; break;
} }
/* skip the \r\n */
hbuf = boundary_end + 2;
/* Next, we need to get the part header: Read until \r\n\r\n */ /* Next, we need to get the part header: Read until \r\n\r\n */
hbuf = buf + bl + 4;
hend = strstr(hbuf, "\r\n\r\n"); hend = strstr(hbuf, "\r\n\r\n");
if (!hend) { if (!hend) {
/* Malformed request */ /* Malformed request */
@@ -965,12 +1000,12 @@ mg_handle_form_request(struct mg_connection *conn,
#endif /* NO_FILESYSTEMS */ #endif /* NO_FILESYSTEMS */
memmove(buf, hend + towrite, bl + 4); memmove(buf, hend + towrite, bl + 4);
buf_fill = (int)(bl + 4); buf_fill = bl + 4;
hend = buf; hend = buf;
/* Read new data */ /* Read new data */
to_read = sizeof(buf) - 1 - (size_t)buf_fill; to_read = sizeof(buf) - 1 - buf_fill;
r = mg_read(conn, buf + (size_t)buf_fill, to_read); r = mg_read(conn, buf + buf_fill, to_read);
if ((r < 0) || ((r == 0) && all_data_read)) { if ((r < 0) || ((r == 0) && all_data_read)) {
#if !defined(NO_FILESYSTEMS) #if !defined(NO_FILESYSTEMS)
/* read error */ /* read error */
@@ -989,7 +1024,7 @@ mg_handle_form_request(struct mg_connection *conn,
/* buf_fill is at least 8 here */ /* buf_fill is at least 8 here */
/* Find boundary */ /* Find boundary */
next = search_boundary(buf, (size_t)buf_fill, boundary, bl); next = search_boundary(buf, buf_fill, boundary, bl);
if (!next && (r == 0)) { if (!next && (r == 0)) {
/* incomplete request */ /* incomplete request */
@@ -1064,7 +1099,7 @@ mg_handle_form_request(struct mg_connection *conn,
if (next) { if (next) {
used = next - buf + 2; used = next - buf + 2;
memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used); memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);
buf_fill -= (int)used; buf_fill -= used;
} else { } else {
buf_fill = 0; buf_fill = 0;
} }

View File

@@ -1442,7 +1442,7 @@ handle_http2(struct mg_connection *conn)
hpack_decode(buf, &i, (int)bytes_read, conn->phys_ctx); hpack_decode(buf, &i, (int)bytes_read, conn->phys_ctx);
CHECK_LEAK_HDR_ALLOC(key); CHECK_LEAK_HDR_ALLOC(key);
if (!key) { if (!key) {
DEBUG_TRACE("HTTP2 key decoding error"); DEBUG_TRACE("%s", "HTTP2 key decoding error");
goto clean_http2; goto clean_http2;
} }
} else if (/*(idx >= 15) &&*/ (idx <= 61)) { } else if (/*(idx >= 15) &&*/ (idx <= 61)) {
@@ -1509,7 +1509,7 @@ handle_http2(struct mg_connection *conn)
conn->phys_ctx); /* leak? */ conn->phys_ctx); /* leak? */
CHECK_LEAK_HDR_ALLOC(val); CHECK_LEAK_HDR_ALLOC(val);
if (!val) { if (!val) {
DEBUG_TRACE("HTTP2 value decoding error"); DEBUG_TRACE("%s", "HTTP2 value decoding error");
mg_free((void *)key); mg_free((void *)key);
goto clean_http2; goto clean_http2;
} }

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2013-2021 the Civetweb developers /* Copyright (c) 2013-2024 the Civetweb developers
* Copyright (c) 2004-2013 Sergey Lyubka * Copyright (c) 2004-2013 Sergey Lyubka
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,9 +23,9 @@
#ifndef CIVETWEB_HEADER_INCLUDED #ifndef CIVETWEB_HEADER_INCLUDED
#define CIVETWEB_HEADER_INCLUDED #define CIVETWEB_HEADER_INCLUDED
#define CIVETWEB_VERSION "1.16" #define CIVETWEB_VERSION "1.17"
#define CIVETWEB_VERSION_MAJOR (1) #define CIVETWEB_VERSION_MAJOR (1)
#define CIVETWEB_VERSION_MINOR (16) #define CIVETWEB_VERSION_MINOR (17)
#define CIVETWEB_VERSION_PATCH (0) #define CIVETWEB_VERSION_PATCH (0)
#ifndef CIVETWEB_API #ifndef CIVETWEB_API
@@ -714,8 +714,8 @@ struct mg_server_port {
int port; /* port number */ int port; /* port number */
int is_ssl; /* https port: 0 = no, 1 = yes */ int is_ssl; /* https port: 0 = no, 1 = yes */
int is_redirect; /* redirect all requests: 0 = no, 1 = yes */ int is_redirect; /* redirect all requests: 0 = no, 1 = yes */
int _reserved1; int is_optional; /* optional: 0 = no, 1 = yes */
int _reserved2; int is_bound; /* bound: 0 = no, 1 = yes, relevant for optional ports */
int _reserved3; int _reserved3;
int _reserved4; int _reserved4;
}; };
@@ -1208,7 +1208,7 @@ struct mg_form_data_handler {
* filename: Name of a file to upload, at the client computer. * filename: Name of a file to upload, at the client computer.
* Only set for input fields of type "file", otherwise NULL. * Only set for input fields of type "file", otherwise NULL.
* path: Output parameter: File name (incl. path) to store the file * path: Output parameter: File name (incl. path) to store the file
* at the server computer. Only used if FORM_FIELD_STORAGE_STORE * at the server computer. Only used if MG_FORM_FIELD_STORAGE_STORE
* is returned by this callback. Existing files will be * is returned by this callback. Existing files will be
* overwritten. * overwritten.
* pathlen: Length of the buffer for path. * pathlen: Length of the buffer for path.
@@ -1216,7 +1216,7 @@ struct mg_form_data_handler {
* *
* Return value: * Return value:
* The callback must return the intended storage for this field * The callback must return the intended storage for this field
* (See FORM_FIELD_STORAGE_*). * (See MG_FORM_FIELD_STORAGE_*).
*/ */
int (*field_found)(const char *key, int (*field_found)(const char *key,
const char *filename, const char *filename,
@@ -1224,7 +1224,7 @@ struct mg_form_data_handler {
size_t pathlen, size_t pathlen,
void *user_data); void *user_data);
/* If the "field_found" callback returned FORM_FIELD_STORAGE_GET, /* If the "field_found" callback returned MG_FORM_FIELD_STORAGE_GET,
* this callback will receive the field data. * this callback will receive the field data.
* *
* Parameters: * Parameters:
@@ -1241,7 +1241,7 @@ struct mg_form_data_handler {
size_t valuelen, size_t valuelen,
void *user_data); void *user_data);
/* If the "field_found" callback returned FORM_FIELD_STORAGE_STORE, /* If the "field_found" callback returned MG_FORM_FIELD_STORAGE_STORE,
* the data will be stored into a file. If the file has been written * the data will be stored into a file. If the file has been written
* successfully, this callback will be called. This callback will * successfully, this callback will be called. This callback will
* not be called for only partially uploaded files. The * not be called for only partially uploaded files. The

View File

@@ -47,8 +47,8 @@ mg_match_impl(const char *pat,
/* Advance as long as there are ? */ /* Advance as long as there are ? */
i_pat++; i_pat++;
i_str++; i_str++;
} while ((pat[i_pat] == '?') && (str[i_str] != '\0') } while ((i_pat < pat_len) && (pat[i_pat] == '?')
&& (str[i_str] != '/') && (i_pat < pat_len)); && (str[i_str] != '\0') && (str[i_str] != '/'));
/* If we have a match context, add the substring we just found */ /* If we have a match context, add the substring we just found */
if (mcx) { if (mcx) {
@@ -72,7 +72,7 @@ mg_match_impl(const char *pat,
ptrdiff_t ret; ptrdiff_t ret;
i_pat++; i_pat++;
if ((pat[i_pat] == '*') && (i_pat < pat_len)) { if ((i_pat < pat_len) && (pat[i_pat] == '*')) {
/* Pattern ** matches all */ /* Pattern ** matches all */
i_pat++; i_pat++;
len = strlen(str + i_str); len = strlen(str + i_str);
@@ -86,7 +86,7 @@ mg_match_impl(const char *pat,
if (mcx) { if (mcx) {
match_context_push(str + i_str, len, mcx); match_context_push(str + i_str, len, mcx);
} }
return (i_str + len); return ((ptrdiff_t)(i_str + len));
} }
/* This loop searches for the longest possible match */ /* This loop searches for the longest possible match */
@@ -102,7 +102,7 @@ mg_match_impl(const char *pat,
if (mcx) { if (mcx) {
match_context_push(str + i_str, len, mcx); match_context_push(str + i_str, len, mcx);
} }
return (i_str + ret + len); return ((ptrdiff_t)i_str + ret + (ptrdiff_t)len);
} }
return -1; return -1;

240
vendor/CivetWeb/mod_gnutls.inl vendored Normal file
View File

@@ -0,0 +1,240 @@
#if defined(USE_GNUTLS) // USE_GNUTLS used with NO_SSL
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
typedef struct {
gnutls_session_t sess;
} SSL;
typedef struct {
gnutls_certificate_credentials_t cred;
gnutls_priority_t prio;
} SSL_CTX;
/* public api */
CIVETWEB_API int gtls_sslctx_init(SSL_CTX *ctx, const char *crt);
CIVETWEB_API void gtls_sslctx_uninit(SSL_CTX *ctx);
CIVETWEB_API void gtls_ssl_close(SSL *ssl);
CIVETWEB_API int gtls_ssl_accept(SSL **ssl,
SSL_CTX *ssl_ctx,
int sock,
struct mg_context *phys_ctx);
CIVETWEB_API int gtls_ssl_read(SSL *ssl, unsigned char *buf, size_t len);
CIVETWEB_API int gtls_ssl_write(SSL *ssl, const unsigned char *buf, size_t len);
CIVETWEB_API int
gtls_sslctx_init(SSL_CTX *ctx, const char *crt)
{
int rc;
if (ctx == NULL || crt == NULL) {
return -1;
}
DEBUG_TRACE("%s", "Initializing GnuTLS SSL");
rc = gnutls_certificate_allocate_credentials(&ctx->cred);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("Failed to allocate credentials (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
rc = gnutls_priority_init(&ctx->prio, NULL, NULL);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("Failed to allocate priority cache (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
rc = gnutls_certificate_set_x509_key_file2(ctx->cred,
crt,
crt,
GNUTLS_X509_FMT_PEM,
NULL,
GNUTLS_PKCS_PLAIN
| GNUTLS_PKCS_NULL_PASSWORD);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("TLS parse crt/key file failed (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
return 0;
failed:
gtls_sslctx_uninit(ctx);
return -1;
}
CIVETWEB_API void
gtls_sslctx_uninit(SSL_CTX *ctx)
{
if (ctx != NULL) {
gnutls_certificate_free_credentials(ctx->cred);
gnutls_priority_deinit(ctx->prio);
ctx->cred = NULL;
ctx->prio = NULL;
}
}
CIVETWEB_API int
gtls_ssl_accept(SSL **ssl,
SSL_CTX *ssl_ctx,
int sock,
struct mg_context *phys_ctx)
{
int rc;
if (ssl == NULL || ssl_ctx == NULL) {
return -1;
}
DEBUG_TRACE("TLS accept processing %p", ssl);
*ssl = (SSL *)mg_calloc_ctx(1, sizeof(SSL), phys_ctx);
if (*ssl == NULL) {
DEBUG_TRACE("Failed to allocate memory for session %zu", sizeof(SSL));
return -1;
}
rc = gnutls_init(&(*ssl)->sess, GNUTLS_SERVER);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("Failed to initialize session (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
rc = gnutls_priority_set((*ssl)->sess, ssl_ctx->prio);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("TLS set priortities failed (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
rc = gnutls_credentials_set((*ssl)->sess,
GNUTLS_CRD_CERTIFICATE,
ssl_ctx->cred);
if (rc != GNUTLS_E_SUCCESS) {
DEBUG_TRACE("TLS set credentials failed (%d): %s",
rc,
gnutls_strerror(rc));
goto failed;
}
gnutls_certificate_send_x509_rdn_sequence((*ssl)->sess, 1);
gnutls_certificate_server_set_request((*ssl)->sess, GNUTLS_CERT_IGNORE);
gnutls_handshake_set_timeout((*ssl)->sess,
GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
gnutls_transport_set_int((*ssl)->sess, sock);
while ((rc = gnutls_handshake((*ssl)->sess)) != GNUTLS_E_SUCCESS) {
if (gnutls_error_is_fatal(rc)) {
if (rc == GNUTLS_E_FATAL_ALERT_RECEIVED) {
DEBUG_TRACE("TLS fatal alert received: %s",
gnutls_alert_get_name(
gnutls_alert_get((*ssl)->sess)));
} else {
DEBUG_TRACE("TLS handshake failed (%d): %s",
rc,
gnutls_strerror(rc));
}
goto failed;
}
}
DEBUG_TRACE("TLS connection %p accepted", *ssl);
return 0;
failed:
gnutls_deinit((*ssl)->sess);
mg_free(*ssl);
*ssl = NULL;
return -1;
}
CIVETWEB_API void
gtls_ssl_close(SSL *ssl)
{
int rc;
if (ssl == NULL) {
return;
}
while ((rc = gnutls_bye(ssl->sess, GNUTLS_SHUT_RDWR)) != GNUTLS_E_SUCCESS) {
switch (rc) {
case GNUTLS_E_AGAIN: /* fall through */
case GNUTLS_E_INTERRUPTED:
continue;
default: /* should actually never happen */
break;
}
}
DEBUG_TRACE("TLS connection %p closed", ssl);
gnutls_deinit(ssl->sess);
mg_free(ssl);
}
CIVETWEB_API int
gtls_ssl_read(SSL *ssl, unsigned char *buf, size_t len)
{
ssize_t rc;
if (ssl == NULL) {
return GNUTLS_E_INVALID_SESSION;
}
while ((rc = gnutls_record_recv(ssl->sess, buf, len)) < 0) {
switch (rc) {
case GNUTLS_E_AGAIN: /* fall through */
case GNUTLS_E_INTERRUPTED:
continue;
default:
break;
}
}
/* DEBUG_TRACE("gnutls_record_recv: %d", rc); */
return (int)rc;
}
CIVETWEB_API int
gtls_ssl_write(SSL *ssl, const unsigned char *buf, size_t len)
{
ssize_t rc;
if (ssl == NULL) {
return GNUTLS_E_INVALID_SESSION;
}
while ((rc = gnutls_record_send(ssl->sess, buf, len)) < 0) {
switch (rc) {
case GNUTLS_E_AGAIN: /* fall through */
case GNUTLS_E_INTERRUPTED:
continue;
default:
break;
}
}
/* DEBUG_TRACE("gnutls_record_send: %d", rc); */
return (int)rc;
}
#endif /* USE_GNUTLS */

View File

@@ -1,11 +1,19 @@
#if defined(USE_MBEDTLS) // USE_MBEDTLS used with NO_SSL #if defined(USE_MBEDTLS) // USE_MBEDTLS used with NO_SSL
#include "mbedtls/certs.h"
#include "mbedtls/ctr_drbg.h" #include "mbedtls/ctr_drbg.h"
#include "mbedtls/debug.h" #include "mbedtls/debug.h"
#include "mbedtls/entropy.h" #include "mbedtls/entropy.h"
#include "mbedtls/error.h" #include "mbedtls/error.h"
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
// The file include/mbedtls/net.h was removed in v3.0.0 because its only
// function was to include mbedtls/net_sockets.h which now should be included
// directly.
#include "mbedtls/net_sockets.h"
#else
#include "mbedtls/net.h" #include "mbedtls/net.h"
#endif
#include "mbedtls/pk.h" #include "mbedtls/pk.h"
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#include "mbedtls/ssl.h" #include "mbedtls/ssl.h"
@@ -80,6 +88,19 @@ mbed_sslctx_init(SSL_CTX *ctx, const char *crt)
mbedtls_ctr_drbg_init(&ctx->ctr); mbedtls_ctr_drbg_init(&ctx->ctr);
mbedtls_x509_crt_init(&ctx->cert); mbedtls_x509_crt_init(&ctx->cert);
#ifdef MBEDTLS_PSA_CRYPTO_C
/* Initialize PSA crypto (mandatory with TLS 1.3)
* This must be done before calling any other PSA Crypto
* functions or they will fail with PSA_ERROR_BAD_STATE
*/
const psa_status_t status = psa_crypto_init();
if (status != PSA_SUCCESS) {
DEBUG_TRACE("Failed to initialize PSA crypto, returned %d\n",
(int)status);
return -1;
}
#endif
rc = mbedtls_ctr_drbg_seed(&ctx->ctr, rc = mbedtls_ctr_drbg_seed(&ctx->ctr,
mbedtls_entropy_func, mbedtls_entropy_func,
&ctx->entropy, &ctx->entropy,
@@ -90,7 +111,17 @@ mbed_sslctx_init(SSL_CTX *ctx, const char *crt)
return -1; return -1;
} }
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
// mbedtls_pk_parse_keyfile() has changed in mbedTLS 3.0. You now need
// to pass a properly seeded, cryptographically secure RNG when calling
// these functions. It is used for blinding, a countermeasure against
// side-channel attacks.
// https://github.com/Mbed-TLS/mbedtls/blob/development/docs/3.0-migration-guide.md#some-functions-gained-an-rng-parameter
rc = mbedtls_pk_parse_keyfile(
&ctx->pkey, crt, NULL, mbedtls_ctr_drbg_random, &ctx->ctr);
#else
rc = mbedtls_pk_parse_keyfile(&ctx->pkey, crt, NULL); rc = mbedtls_pk_parse_keyfile(&ctx->pkey, crt, NULL);
#endif
if (rc != 0) { if (rc != 0) {
DEBUG_TRACE("TLS parse key file failed (%i)", rc); DEBUG_TRACE("TLS parse key file failed (%i)", rc);
return -1; return -1;
@@ -170,7 +201,13 @@ mbed_ssl_accept(mbedtls_ssl_context **ssl,
return -1; return -1;
} }
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
DEBUG_TRACE("TLS connection %p accepted, state: %d",
ssl,
(*ssl)->MBEDTLS_PRIVATE(state));
#else
DEBUG_TRACE("TLS connection %p accepted, state: %d", ssl, (*ssl)->state); DEBUG_TRACE("TLS connection %p accepted, state: %d", ssl, (*ssl)->state);
#endif
return 0; return 0;
} }
@@ -196,7 +233,13 @@ mbed_ssl_handshake(mbedtls_ssl_context *ssl)
} }
} }
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
DEBUG_TRACE("TLS handshake rc: %d, state: %d",
rc,
ssl->MBEDTLS_PRIVATE(state));
#else
DEBUG_TRACE("TLS handshake rc: %d, state: %d", rc, ssl->state); DEBUG_TRACE("TLS handshake rc: %d, state: %d", rc, ssl->state);
#endif
return rc; return rc;
} }

View File

@@ -14,32 +14,32 @@ mg_sort(void *data,
*/ */
/* We use ShellSort here with this gap sequence: https://oeis.org/A102549 */ /* We use ShellSort here with this gap sequence: https://oeis.org/A102549 */
int A102549[9] = {1, 4, 10, 23, 57, 132, 301, 701, 1750}; size_t A102549[9] = {1, 4, 10, 23, 57, 132, 301, 701, 1750};
int Aidx, gap, i, j, k; size_t gap, i, j, k;
int Aidx;
void *tmp = alloca(elemsize); void *tmp = alloca(elemsize);
for (Aidx = 8; Aidx >= 0; Aidx--) { for (Aidx = 8; Aidx >= 0; Aidx--) {
gap = A102549[Aidx]; gap = A102549[Aidx];
if (gap > ((int)elemcount / 2)) { if (gap > (elemcount / 2)) {
continue; continue;
} }
for (i = 0; i < gap; i++) { for (i = 0; i < gap; i++) {
for (j = i; j < (int)elemcount; j += gap) { for (j = i; j < elemcount; j += gap) {
memcpy(tmp, (void *)((ptrdiff_t)data + elemsize * j), elemsize); memcpy(tmp, (void *)((size_t)data + elemsize * j), elemsize);
for (k = j; k >= gap; k -= gap) { for (k = j; k >= gap; k -= gap) {
void *cmp = void *cmp = (void *)((size_t)data + elemsize * (k - gap));
(void *)((ptrdiff_t)data + elemsize * (k - gap));
int cmpres = compfunc(cmp, tmp, userarg); int cmpres = compfunc(cmp, tmp, userarg);
if (cmpres > 0) { if (cmpres > 0) {
memcpy((void *)((ptrdiff_t)data + elemsize * k), memcpy((void *)((size_t)data + elemsize * k),
cmp, cmp,
elemsize); elemsize);
} else { } else {
break; break;
} }
} }
memcpy((void *)((ptrdiff_t)data + elemsize * k), tmp, elemsize); memcpy((void *)((size_t)data + elemsize * k), tmp, elemsize);
} }
} }
} }

View File

@@ -39,13 +39,16 @@ TIMER_API double
timer_getcurrenttime(struct mg_context *ctx) timer_getcurrenttime(struct mg_context *ctx)
{ {
#if defined(_WIN32) #if defined(_WIN32)
uint64_t now_tick64 = 0;
#if defined(_WIN64)
now_tick64 = GetTickCount64();
#else
/* GetTickCount returns milliseconds since system start as /* GetTickCount returns milliseconds since system start as
* unsigned 32 bit value. It will wrap around every 49.7 days. * unsigned 32 bit value. It will wrap around every 49.7 days.
* We need to use a 64 bit counter (will wrap in 500 mio. years), * We need to use a 64 bit counter (will wrap in 500 mio. years),
* by adding the 32 bit difference since the last call to a * by adding the 32 bit difference since the last call to a
* 64 bit counter. This algorithm will only work, if this * 64 bit counter. This algorithm will only work, if this
* function is called at least once every 7 weeks. */ * function is called at least once every 7 weeks. */
uint64_t now_tick64 = 0;
DWORD now_tick = GetTickCount(); DWORD now_tick = GetTickCount();
if (ctx->timers) { if (ctx->timers) {
@@ -55,6 +58,7 @@ timer_getcurrenttime(struct mg_context *ctx)
ctx->timers->last_tick = now_tick; ctx->timers->last_tick = now_tick;
pthread_mutex_unlock(&ctx->timers->mutex); pthread_mutex_unlock(&ctx->timers->mutex);
} }
#endif
return (double)now_tick64 * 1.0E-3; return (double)now_tick64 * 1.0E-3;
#else #else
struct timespec now_ts; struct timespec now_ts;

View File

@@ -1,6 +1,7 @@
This license file applies to everything in this repository except that which This license file applies to everything in this repository except that which
is explicitly annotated as being written by other authors, i.e. the Boost is explicitly annotated as being written by other authors, i.e. the Boost
queue (included in the benchmarks for comparison), Intel's TBB library (ditto), queue (included in the benchmarks for comparison), Intel's TBB library (ditto),
dlib::pipe (ditto),
the CDSChecker tool (used for verification), the Relacy model checker (ditto), the CDSChecker tool (used for verification), the Relacy model checker (ditto),
and Jeff Preshing's semaphore implementation (used in the blocking queue) which and Jeff Preshing's semaphore implementation (used in the blocking queue) which
has a zlib license (embedded in lightweightsempahore.h). has a zlib license (embedded in lightweightsempahore.h).

View File

@@ -544,7 +544,7 @@ public:
// Returns true if the underlying atomic variables used by // Returns true if the underlying atomic variables used by
// the queue are lock-free (they should be on most platforms). // the queue are lock-free (they should be on most platforms).
// Thread-safe. // Thread-safe.
static bool is_lock_free() static constexpr bool is_lock_free()
{ {
return ConcurrentQueue::is_lock_free(); return ConcurrentQueue::is_lock_free();
} }

View File

@@ -31,7 +31,7 @@
#pragma once #pragma once
#if defined(__GNUC__) #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
// Disable -Wconversion warnings (spuriously triggered when Traits::size_t and // Disable -Wconversion warnings (spuriously triggered when Traits::size_t and
// Traits::index_t are set to < 32 bits, causing integer promotion, causing warnings // Traits::index_t are set to < 32 bits, causing integer promotion, causing warnings
// upon assigning any computed values) // upon assigning any computed values)
@@ -77,6 +77,7 @@
#include <climits> // for CHAR_BIT #include <climits> // for CHAR_BIT
#include <array> #include <array>
#include <thread> // partly for __WINPTHREADS_VERSION if on MinGW-w64 w/ POSIX threading #include <thread> // partly for __WINPTHREADS_VERSION if on MinGW-w64 w/ POSIX threading
#include <mutex> // used for thread exit synchronization
// Platform-specific definitions of a numeric thread ID type and an invalid value // Platform-specific definitions of a numeric thread ID type and an invalid value
namespace moodycamel { namespace details { namespace moodycamel { namespace details {
@@ -104,7 +105,7 @@ namespace moodycamel { namespace details {
static const thread_id_t invalid_thread_id2 = 0xFFFFFFFFU; // Not technically guaranteed to be invalid, but is never used in practice. Note that all Win32 thread IDs are presently multiples of 4. static const thread_id_t invalid_thread_id2 = 0xFFFFFFFFU; // Not technically guaranteed to be invalid, but is never used in practice. Note that all Win32 thread IDs are presently multiples of 4.
static inline thread_id_t thread_id() { return static_cast<thread_id_t>(::GetCurrentThreadId()); } static inline thread_id_t thread_id() { return static_cast<thread_id_t>(::GetCurrentThreadId()); }
} } } }
#elif defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || (defined(__APPLE__) && TARGET_OS_IPHONE) #elif defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || (defined(__APPLE__) && TARGET_OS_IPHONE) || defined(__MVS__) || defined(MOODYCAMEL_NO_THREAD_LOCAL)
namespace moodycamel { namespace details { namespace moodycamel { namespace details {
static_assert(sizeof(std::thread::id) == 4 || sizeof(std::thread::id) == 8, "std::thread::id is expected to be either 4 or 8 bytes"); static_assert(sizeof(std::thread::id) == 4 || sizeof(std::thread::id) == 8, "std::thread::id is expected to be either 4 or 8 bytes");
@@ -216,9 +217,9 @@ namespace moodycamel { namespace details {
// VS2013 doesn't support `thread_local`, and MinGW-w64 w/ POSIX threading has a crippling bug: http://sourceforge.net/p/mingw-w64/bugs/445 // VS2013 doesn't support `thread_local`, and MinGW-w64 w/ POSIX threading has a crippling bug: http://sourceforge.net/p/mingw-w64/bugs/445
// g++ <=4.7 doesn't support thread_local either. // g++ <=4.7 doesn't support thread_local either.
// Finally, iOS/ARM doesn't have support for it either, and g++/ARM allows it to compile but it's unconfirmed to actually work // Finally, iOS/ARM doesn't have support for it either, and g++/ARM allows it to compile but it's unconfirmed to actually work
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && (!defined(__MINGW32__) && !defined(__MINGW64__) || !defined(__WINPTHREADS_VERSION)) && (!defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && (!defined(__APPLE__) || !TARGET_OS_IPHONE) && !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && (!defined(__MINGW32__) && !defined(__MINGW64__) || !defined(__WINPTHREADS_VERSION)) && (!defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && (!defined(__APPLE__) || !TARGET_OS_IPHONE) && !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(__MVS__)
// Assume `thread_local` is fully supported in all other C++11 compilers/platforms // Assume `thread_local` is fully supported in all other C++11 compilers/platforms
//#define MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED // always disabled for now since several users report having problems with it on #define MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED // tentatively enabled for now; years ago several users report having problems with it on
#endif #endif
#endif #endif
#endif #endif
@@ -379,6 +380,13 @@ struct ConcurrentQueueDefaultTraits
// Only affects instances of the BlockingConcurrentQueue. // Only affects instances of the BlockingConcurrentQueue.
static const int MAX_SEMA_SPINS = 10000; static const int MAX_SEMA_SPINS = 10000;
// Whether to recycle dynamically-allocated blocks into an internal free list or
// not. If false, only pre-allocated blocks (controlled by the constructor
// arguments) will be recycled, and all others will be `free`d back to the heap.
// Note that blocks consumed by explicit producers are only freed on destruction
// of the queue (not following destruction of the token) regardless of this trait.
static const bool RECYCLE_ALLOCATED_BLOCKS = false;
#ifndef MCDBGQ_USE_RELACY #ifndef MCDBGQ_USE_RELACY
// Memory allocation can be customized if needed. // Memory allocation can be customized if needed.
@@ -468,15 +476,10 @@ namespace details
template<typename T> template<typename T>
static inline bool circular_less_than(T a, T b) static inline bool circular_less_than(T a, T b)
{ {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4554)
#endif
static_assert(std::is_integral<T>::value && !std::numeric_limits<T>::is_signed, "circular_less_than is intended to be used only with unsigned integer types"); static_assert(std::is_integral<T>::value && !std::numeric_limits<T>::is_signed, "circular_less_than is intended to be used only with unsigned integer types");
return static_cast<T>(a - b) > static_cast<T>(static_cast<T>(1) << static_cast<T>(sizeof(T) * CHAR_BIT - 1)); return static_cast<T>(a - b) > static_cast<T>(static_cast<T>(1) << (static_cast<T>(sizeof(T) * CHAR_BIT - 1)));
#ifdef _MSC_VER // Note: extra parens around rhs of operator<< is MSVC bug: https://developercommunity2.visualstudio.com/t/C4554-triggers-when-both-lhs-and-rhs-is/10034931
#pragma warning(pop) // silencing the bug requires #pragma warning(disable: 4554) around the calling code and has no effect when done here.
#endif
} }
template<typename U> template<typename U>
@@ -506,9 +509,9 @@ namespace details
template<typename T> template<typename T>
static inline void swap_relaxed(std::atomic<T>& left, std::atomic<T>& right) static inline void swap_relaxed(std::atomic<T>& left, std::atomic<T>& right)
{ {
T temp = std::move(left.load(std::memory_order_relaxed)); T temp = left.load(std::memory_order_relaxed);
left.store(std::move(right.load(std::memory_order_relaxed)), std::memory_order_relaxed); left.store(right.load(std::memory_order_relaxed), std::memory_order_relaxed);
right.store(std::move(temp), std::memory_order_relaxed); right.store(temp, std::memory_order_relaxed);
} }
template<typename T> template<typename T>
@@ -555,6 +558,8 @@ namespace details
typedef RelacyThreadExitListener ThreadExitListener; typedef RelacyThreadExitListener ThreadExitListener;
typedef RelacyThreadExitNotifier ThreadExitNotifier; typedef RelacyThreadExitNotifier ThreadExitNotifier;
#else #else
class ThreadExitNotifier;
struct ThreadExitListener struct ThreadExitListener
{ {
typedef void (*callback_t)(void*); typedef void (*callback_t)(void*);
@@ -562,22 +567,29 @@ namespace details
void* userData; void* userData;
ThreadExitListener* next; // reserved for use by the ThreadExitNotifier ThreadExitListener* next; // reserved for use by the ThreadExitNotifier
ThreadExitNotifier* chain; // reserved for use by the ThreadExitNotifier
}; };
class ThreadExitNotifier class ThreadExitNotifier
{ {
public: public:
static void subscribe(ThreadExitListener* listener) static void subscribe(ThreadExitListener* listener)
{ {
auto& tlsInst = instance(); auto& tlsInst = instance();
std::lock_guard<std::mutex> guard(mutex());
listener->next = tlsInst.tail; listener->next = tlsInst.tail;
listener->chain = &tlsInst;
tlsInst.tail = listener; tlsInst.tail = listener;
} }
static void unsubscribe(ThreadExitListener* listener) static void unsubscribe(ThreadExitListener* listener)
{ {
auto& tlsInst = instance(); std::lock_guard<std::mutex> guard(mutex());
if (!listener->chain) {
return; // race with ~ThreadExitNotifier
}
auto& tlsInst = *listener->chain;
listener->chain = nullptr;
ThreadExitListener** prev = &tlsInst.tail; ThreadExitListener** prev = &tlsInst.tail;
for (auto ptr = tlsInst.tail; ptr != nullptr; ptr = ptr->next) { for (auto ptr = tlsInst.tail; ptr != nullptr; ptr = ptr->next) {
if (ptr == listener) { if (ptr == listener) {
@@ -597,7 +609,9 @@ namespace details
{ {
// This thread is about to exit, let everyone know! // This thread is about to exit, let everyone know!
assert(this == &instance() && "If this assert fails, you likely have a buggy compiler! Change the preprocessor conditions such that MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED is no longer defined."); assert(this == &instance() && "If this assert fails, you likely have a buggy compiler! Change the preprocessor conditions such that MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED is no longer defined.");
std::lock_guard<std::mutex> guard(mutex());
for (auto ptr = tail; ptr != nullptr; ptr = ptr->next) { for (auto ptr = tail; ptr != nullptr; ptr = ptr->next) {
ptr->chain = nullptr;
ptr->callback(ptr->userData); ptr->callback(ptr->userData);
} }
} }
@@ -609,6 +623,13 @@ namespace details
return notifier; return notifier;
} }
static inline std::mutex& mutex()
{
// Must be static because the ThreadExitNotifier could be destroyed while unsubscribe is called
static std::mutex mutex;
return mutex;
}
private: private:
ThreadExitListener* tail; ThreadExitListener* tail;
}; };
@@ -789,7 +810,7 @@ public:
// queue is fully constructed before it starts being used by other threads (this // queue is fully constructed before it starts being used by other threads (this
// includes making the memory effects of construction visible, possibly with a // includes making the memory effects of construction visible, possibly with a
// memory barrier). // memory barrier).
explicit ConcurrentQueue(size_t capacity = 6 * BLOCK_SIZE) explicit ConcurrentQueue(size_t capacity = 32 * BLOCK_SIZE)
: producerListTail(nullptr), : producerListTail(nullptr),
producerCount(0), producerCount(0),
initialBlockPoolIndex(0), initialBlockPoolIndex(0),
@@ -1314,7 +1335,7 @@ public:
// Returns true if the underlying atomic variables used by // Returns true if the underlying atomic variables used by
// the queue are lock-free (they should be on most platforms). // the queue are lock-free (they should be on most platforms).
// Thread-safe. // Thread-safe.
static bool is_lock_free() static constexpr bool is_lock_free()
{ {
return return
details::static_is_lock_free<bool>::value == 2 && details::static_is_lock_free<bool>::value == 2 &&
@@ -1458,7 +1479,7 @@ private:
while (head != nullptr) { while (head != nullptr) {
auto prevHead = head; auto prevHead = head;
auto refs = head->freeListRefs.load(std::memory_order_relaxed); auto refs = head->freeListRefs.load(std::memory_order_relaxed);
if ((refs & REFS_MASK) == 0 || !head->freeListRefs.compare_exchange_strong(refs, refs + 1, std::memory_order_acquire, std::memory_order_relaxed)) { if ((refs & REFS_MASK) == 0 || !head->freeListRefs.compare_exchange_strong(refs, refs + 1, std::memory_order_acquire)) {
head = freeListHead.load(std::memory_order_acquire); head = freeListHead.load(std::memory_order_acquire);
continue; continue;
} }
@@ -1508,7 +1529,7 @@ private:
node->freeListRefs.store(1, std::memory_order_release); node->freeListRefs.store(1, std::memory_order_release);
if (!freeListHead.compare_exchange_strong(head, node, std::memory_order_release, std::memory_order_relaxed)) { if (!freeListHead.compare_exchange_strong(head, node, std::memory_order_release, std::memory_order_relaxed)) {
// Hmm, the add failed, but we can only try again when the refcount goes back to zero // Hmm, the add failed, but we can only try again when the refcount goes back to zero
if (node->freeListRefs.fetch_add(SHOULD_BE_ON_FREELIST - 1, std::memory_order_release) == 1) { if (node->freeListRefs.fetch_add(SHOULD_BE_ON_FREELIST - 1, std::memory_order_acq_rel) == 1) {
continue; continue;
} }
} }
@@ -1538,7 +1559,7 @@ private:
struct Block struct Block
{ {
Block() Block()
: next(nullptr), elementsCompletelyDequeued(0), freeListRefs(0), freeListNext(nullptr), shouldBeOnFreeList(false), dynamicallyAllocated(true) : next(nullptr), elementsCompletelyDequeued(0), freeListRefs(0), freeListNext(nullptr), dynamicallyAllocated(true)
{ {
#ifdef MCDBGQ_TRACKMEM #ifdef MCDBGQ_TRACKMEM
owner = nullptr; owner = nullptr;
@@ -1583,7 +1604,7 @@ private:
} }
else { else {
// Increment counter // Increment counter
auto prevVal = elementsCompletelyDequeued.fetch_add(1, std::memory_order_release); auto prevVal = elementsCompletelyDequeued.fetch_add(1, std::memory_order_acq_rel);
assert(prevVal < BLOCK_SIZE); assert(prevVal < BLOCK_SIZE);
return prevVal == BLOCK_SIZE - 1; return prevVal == BLOCK_SIZE - 1;
} }
@@ -1606,7 +1627,7 @@ private:
} }
else { else {
// Increment counter // Increment counter
auto prevVal = elementsCompletelyDequeued.fetch_add(count, std::memory_order_release); auto prevVal = elementsCompletelyDequeued.fetch_add(count, std::memory_order_acq_rel);
assert(prevVal + count <= BLOCK_SIZE); assert(prevVal + count <= BLOCK_SIZE);
return prevVal + count == BLOCK_SIZE; return prevVal + count == BLOCK_SIZE;
} }
@@ -1655,7 +1676,6 @@ private:
public: public:
std::atomic<std::uint32_t> freeListRefs; std::atomic<std::uint32_t> freeListRefs;
std::atomic<Block*> freeListNext; std::atomic<Block*> freeListNext;
std::atomic<bool> shouldBeOnFreeList;
bool dynamicallyAllocated; // Perhaps a better name for this would be 'isNotPartOfInitialBlockPool' bool dynamicallyAllocated; // Perhaps a better name for this would be 'isNotPartOfInitialBlockPool'
#ifdef MCDBGQ_TRACKMEM #ifdef MCDBGQ_TRACKMEM
@@ -1810,12 +1830,7 @@ private:
auto block = this->tailBlock; auto block = this->tailBlock;
do { do {
auto nextBlock = block->next; auto nextBlock = block->next;
if (block->dynamicallyAllocated) {
destroy(block);
}
else {
this->parent->add_block_to_free_list(block); this->parent->add_block_to_free_list(block);
}
block = nextBlock; block = nextBlock;
} while (block != this->tailBlock); } while (block != this->tailBlock);
} }
@@ -1998,7 +2013,7 @@ private:
// block size (in order to get a correct signed block count offset in all cases): // block size (in order to get a correct signed block count offset in all cases):
auto headBase = localBlockIndex->entries[localBlockIndexHead].base; auto headBase = localBlockIndex->entries[localBlockIndexHead].base;
auto blockBaseIndex = index & ~static_cast<index_t>(BLOCK_SIZE - 1); auto blockBaseIndex = index & ~static_cast<index_t>(BLOCK_SIZE - 1);
auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(blockBaseIndex - headBase) / BLOCK_SIZE); auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(blockBaseIndex - headBase) / static_cast<typename std::make_signed<index_t>::type>(BLOCK_SIZE));
auto block = localBlockIndex->entries[(localBlockIndexHead + offset) & (localBlockIndex->size - 1)].block; auto block = localBlockIndex->entries[(localBlockIndexHead + offset) & (localBlockIndex->size - 1)].block;
// Dequeue // Dequeue
@@ -2259,7 +2274,7 @@ private:
auto headBase = localBlockIndex->entries[localBlockIndexHead].base; auto headBase = localBlockIndex->entries[localBlockIndexHead].base;
auto firstBlockBaseIndex = firstIndex & ~static_cast<index_t>(BLOCK_SIZE - 1); auto firstBlockBaseIndex = firstIndex & ~static_cast<index_t>(BLOCK_SIZE - 1);
auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(firstBlockBaseIndex - headBase) / BLOCK_SIZE); auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(firstBlockBaseIndex - headBase) / static_cast<typename std::make_signed<index_t>::type>(BLOCK_SIZE));
auto indexIndex = (localBlockIndexHead + offset) & (localBlockIndex->size - 1); auto indexIndex = (localBlockIndexHead + offset) & (localBlockIndex->size - 1);
// Iterate the blocks and dequeue // Iterate the blocks and dequeue
@@ -2906,6 +2921,7 @@ private:
else if (!new_block_index()) { else if (!new_block_index()) {
return false; return false;
} }
else {
localBlockIndex = blockIndex.load(std::memory_order_relaxed); localBlockIndex = blockIndex.load(std::memory_order_relaxed);
newTail = (localBlockIndex->tail.load(std::memory_order_relaxed) + 1) & (localBlockIndex->capacity - 1); newTail = (localBlockIndex->tail.load(std::memory_order_relaxed) + 1) & (localBlockIndex->capacity - 1);
idxEntry = localBlockIndex->index[newTail]; idxEntry = localBlockIndex->index[newTail];
@@ -2914,6 +2930,7 @@ private:
localBlockIndex->tail.store(newTail, std::memory_order_release); localBlockIndex->tail.store(newTail, std::memory_order_release);
return true; return true;
} }
}
inline void rewind_block_index_tail() inline void rewind_block_index_tail()
{ {
@@ -2940,7 +2957,7 @@ private:
assert(tailBase != INVALID_BLOCK_BASE); assert(tailBase != INVALID_BLOCK_BASE);
// Note: Must use division instead of shift because the index may wrap around, causing a negative // Note: Must use division instead of shift because the index may wrap around, causing a negative
// offset, whose negativity we want to preserve // offset, whose negativity we want to preserve
auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(index - tailBase) / BLOCK_SIZE); auto offset = static_cast<size_t>(static_cast<typename std::make_signed<index_t>::type>(index - tailBase) / static_cast<typename std::make_signed<index_t>::type>(BLOCK_SIZE));
size_t idx = (tail + offset) & (localBlockIndex->capacity - 1); size_t idx = (tail + offset) & (localBlockIndex->capacity - 1);
assert(localBlockIndex->index[idx]->key.load(std::memory_order_relaxed) == index && localBlockIndex->index[idx]->value.load(std::memory_order_relaxed) != nullptr); assert(localBlockIndex->index[idx]->key.load(std::memory_order_relaxed) == index && localBlockIndex->index[idx]->value.load(std::memory_order_relaxed) != nullptr);
return idx; return idx;
@@ -3052,8 +3069,13 @@ private:
#ifdef MCDBGQ_TRACKMEM #ifdef MCDBGQ_TRACKMEM
block->owner = nullptr; block->owner = nullptr;
#endif #endif
if (!Traits::RECYCLE_ALLOCATED_BLOCKS && block->dynamicallyAllocated) {
destroy(block);
}
else {
freeList.add(block); freeList.add(block);
} }
}
inline void add_blocks_to_free_list(Block* block) inline void add_blocks_to_free_list(Block* block)
{ {
@@ -3203,12 +3225,6 @@ private:
////////////////////////////////// //////////////////////////////////
ProducerBase* recycle_or_create_producer(bool isExplicit) ProducerBase* recycle_or_create_producer(bool isExplicit)
{
bool recycled;
return recycle_or_create_producer(isExplicit, recycled);
}
ProducerBase* recycle_or_create_producer(bool isExplicit, bool& recycled)
{ {
#ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODHASH #ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODHASH
debug::DebugLock lock(implicitProdMutex); debug::DebugLock lock(implicitProdMutex);
@@ -3219,13 +3235,11 @@ private:
bool expected = true; bool expected = true;
if (ptr->inactive.compare_exchange_strong(expected, /* desired */ false, std::memory_order_acquire, std::memory_order_relaxed)) { if (ptr->inactive.compare_exchange_strong(expected, /* desired */ false, std::memory_order_acquire, std::memory_order_relaxed)) {
// We caught one! It's been marked as activated, the caller can have it // We caught one! It's been marked as activated, the caller can have it
recycled = true;
return ptr; return ptr;
} }
} }
} }
recycled = false;
return add_producer(isExplicit ? static_cast<ProducerBase*>(create<ExplicitProducer>(this)) : create<ImplicitProducer>(this)); return add_producer(isExplicit ? static_cast<ProducerBase*>(create<ExplicitProducer>(this)) : create<ImplicitProducer>(this));
} }
@@ -3396,7 +3410,7 @@ private:
// Look for the id in this hash // Look for the id in this hash
auto index = hashedId; auto index = hashedId;
while (true) { // Not an infinite loop because at least one slot is free in the hash table while (true) { // Not an infinite loop because at least one slot is free in the hash table
index &= hash->capacity - 1; index &= hash->capacity - 1u;
auto probedKey = hash->entries[index].key.load(std::memory_order_relaxed); auto probedKey = hash->entries[index].key.load(std::memory_order_relaxed);
if (probedKey == id) { if (probedKey == id) {
@@ -3409,15 +3423,14 @@ private:
if (hash != mainHash) { if (hash != mainHash) {
index = hashedId; index = hashedId;
while (true) { while (true) {
index &= mainHash->capacity - 1; index &= mainHash->capacity - 1u;
probedKey = mainHash->entries[index].key.load(std::memory_order_relaxed);
auto empty = details::invalid_thread_id; auto empty = details::invalid_thread_id;
#ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED #ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED
auto reusable = details::invalid_thread_id2; auto reusable = details::invalid_thread_id2;
if ((probedKey == empty && mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_relaxed, std::memory_order_relaxed)) || if (mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_seq_cst, std::memory_order_relaxed) ||
(probedKey == reusable && mainHash->entries[index].key.compare_exchange_strong(reusable, id, std::memory_order_acquire, std::memory_order_acquire))) { mainHash->entries[index].key.compare_exchange_strong(reusable, id, std::memory_order_seq_cst, std::memory_order_relaxed)) {
#else #else
if ((probedKey == empty && mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_relaxed, std::memory_order_relaxed))) { if (mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_seq_cst, std::memory_order_relaxed)) {
#endif #endif
mainHash->entries[index].value = value; mainHash->entries[index].value = value;
break; break;
@@ -3446,7 +3459,7 @@ private:
// locked block). // locked block).
mainHash = implicitProducerHash.load(std::memory_order_acquire); mainHash = implicitProducerHash.load(std::memory_order_acquire);
if (newCount >= (mainHash->capacity >> 1)) { if (newCount >= (mainHash->capacity >> 1)) {
auto newCapacity = mainHash->capacity << 1; size_t newCapacity = mainHash->capacity << 1;
while (newCount >= (newCapacity >> 1)) { while (newCount >= (newCapacity >> 1)) {
newCapacity <<= 1; newCapacity <<= 1;
} }
@@ -3479,15 +3492,11 @@ private:
// to finish being allocated by another thread (and if we just finished allocating above, the condition will // to finish being allocated by another thread (and if we just finished allocating above, the condition will
// always be true) // always be true)
if (newCount < (mainHash->capacity >> 1) + (mainHash->capacity >> 2)) { if (newCount < (mainHash->capacity >> 1) + (mainHash->capacity >> 2)) {
bool recycled; auto producer = static_cast<ImplicitProducer*>(recycle_or_create_producer(false));
auto producer = static_cast<ImplicitProducer*>(recycle_or_create_producer(false, recycled));
if (producer == nullptr) { if (producer == nullptr) {
implicitProducerHashCount.fetch_sub(1, std::memory_order_relaxed); implicitProducerHashCount.fetch_sub(1, std::memory_order_relaxed);
return nullptr; return nullptr;
} }
if (recycled) {
implicitProducerHashCount.fetch_sub(1, std::memory_order_relaxed);
}
#ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED #ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED
producer->threadExitListener.callback = &ConcurrentQueue::implicit_producer_thread_exited_callback; producer->threadExitListener.callback = &ConcurrentQueue::implicit_producer_thread_exited_callback;
@@ -3497,17 +3506,17 @@ private:
auto index = hashedId; auto index = hashedId;
while (true) { while (true) {
index &= mainHash->capacity - 1; index &= mainHash->capacity - 1u;
auto probedKey = mainHash->entries[index].key.load(std::memory_order_relaxed);
auto empty = details::invalid_thread_id; auto empty = details::invalid_thread_id;
#ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED #ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED
auto reusable = details::invalid_thread_id2; auto reusable = details::invalid_thread_id2;
if ((probedKey == empty && mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_relaxed, std::memory_order_relaxed)) || if (mainHash->entries[index].key.compare_exchange_strong(reusable, id, std::memory_order_seq_cst, std::memory_order_relaxed)) {
(probedKey == reusable && mainHash->entries[index].key.compare_exchange_strong(reusable, id, std::memory_order_acquire, std::memory_order_acquire))) { implicitProducerHashCount.fetch_sub(1, std::memory_order_relaxed); // already counted as a used slot
#else mainHash->entries[index].value = producer;
if ((probedKey == empty && mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_relaxed, std::memory_order_relaxed))) { break;
}
#endif #endif
if (mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order_seq_cst, std::memory_order_relaxed)) {
mainHash->entries[index].value = producer; mainHash->entries[index].value = producer;
break; break;
} }
@@ -3526,9 +3535,6 @@ private:
#ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED #ifdef MOODYCAMEL_CPP11_THREAD_LOCAL_SUPPORTED
void implicit_producer_thread_exited(ImplicitProducer* producer) void implicit_producer_thread_exited(ImplicitProducer* producer)
{ {
// Remove from thread exit listeners
details::ThreadExitNotifier::unsubscribe(&producer->threadExitListener);
// Remove from hash // Remove from hash
#ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODHASH #ifdef MCDBGQ_NOLOCKFREE_IMPLICITPRODHASH
debug::DebugLock lock(implicitProdMutex); debug::DebugLock lock(implicitProdMutex);
@@ -3544,10 +3550,9 @@ private:
for (; hash != nullptr; hash = hash->prev) { for (; hash != nullptr; hash = hash->prev) {
auto index = hashedId; auto index = hashedId;
do { do {
index &= hash->capacity - 1; index &= hash->capacity - 1u;
probedKey = hash->entries[index].key.load(std::memory_order_relaxed); probedKey = id;
if (probedKey == id) { if (hash->entries[index].key.compare_exchange_strong(probedKey, details::invalid_thread_id2, std::memory_order_seq_cst, std::memory_order_relaxed)) {
hash->entries[index].key.store(details::invalid_thread_id2, std::memory_order_release);
break; break;
} }
++index; ++index;
@@ -3737,6 +3742,6 @@ inline void swap(typename ConcurrentQueue<T, Traits>::ImplicitProducerKVP& a, ty
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

View File

@@ -24,8 +24,16 @@ extern "C" {
} }
#elif defined(__MACH__) #elif defined(__MACH__)
#include <mach/mach.h> #include <mach/mach.h>
#elif defined(__MVS__)
#include <zos-semaphore.h>
#elif defined(__unix__) #elif defined(__unix__)
#include <semaphore.h> #include <semaphore.h>
#if defined(__GLIBC_PREREQ) && defined(_GNU_SOURCE)
#if __GLIBC_PREREQ(2,30)
#define MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
#endif
#endif
#endif #endif
namespace moodycamel namespace moodycamel
@@ -159,9 +167,9 @@ public:
} }
} }
}; };
#elif defined(__unix__) #elif defined(__unix__) || defined(__MVS__)
//--------------------------------------------------------- //---------------------------------------------------------
// Semaphore (POSIX, Linux) // Semaphore (POSIX, Linux, zOS)
//--------------------------------------------------------- //---------------------------------------------------------
class Semaphore class Semaphore
{ {
@@ -209,7 +217,11 @@ public:
struct timespec ts; struct timespec ts;
const int usecs_in_1_sec = 1000000; const int usecs_in_1_sec = 1000000;
const int nsecs_in_1_sec = 1000000000; const int nsecs_in_1_sec = 1000000000;
#ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
clock_gettime(CLOCK_MONOTONIC, &ts);
#else
clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
#endif
ts.tv_sec += (time_t)(usecs / usecs_in_1_sec); ts.tv_sec += (time_t)(usecs / usecs_in_1_sec);
ts.tv_nsec += (long)(usecs % usecs_in_1_sec) * 1000; ts.tv_nsec += (long)(usecs % usecs_in_1_sec) * 1000;
// sem_timedwait bombs if you have more than 1e9 in tv_nsec // sem_timedwait bombs if you have more than 1e9 in tv_nsec
@@ -221,7 +233,11 @@ public:
int rc; int rc;
do { do {
#ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
rc = sem_clockwait(&m_sema, CLOCK_MONOTONIC, &ts);
#else
rc = sem_timedwait(&m_sema, &ts); rc = sem_timedwait(&m_sema, &ts);
#endif
} while (rc == -1 && errno == EINTR); } while (rc == -1 && errno == EINTR);
return rc == 0; return rc == 0;
} }

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.26) cmake_minimum_required(VERSION 3.10...3.26)
# Fallback for using newer policies on CMake <3.12. # Fallback for using newer policies on CMake <3.12.
if(${CMAKE_VERSION} VERSION_LESS 3.12) if(${CMAKE_VERSION} VERSION_LESS 3.12)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.25) cmake_minimum_required(VERSION 3.10...3.25)
project(fmt-test CXX) project(fmt-test CXX)

View File

@@ -1,6 +1,6 @@
# Test if compile errors are produced where necessary. # Test if compile errors are produced where necessary.
cmake_minimum_required(VERSION 3.8...3.25) cmake_minimum_required(VERSION 3.10...3.25)
project(compile-error-test CXX) project(compile-error-test CXX)
set(fmt_headers " set(fmt_headers "
@@ -64,7 +64,7 @@ function (run_tests)
") ")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/CMakeLists.txt" " file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/CMakeLists.txt" "
cmake_minimum_required(VERSION 3.8...3.25) cmake_minimum_required(VERSION 3.10...3.25)
project(tests CXX) project(tests CXX)
add_subdirectory(${FMT_DIR} fmt) add_subdirectory(${FMT_DIR} fmt)
${cmake_targets} ${cmake_targets}

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.25) cmake_minimum_required(VERSION 3.10...3.25)
project(fmt-test) project(fmt-test)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.25) cmake_minimum_required(VERSION 3.10...3.25)
project(fmt-link CXX) project(fmt-link CXX)

View File

@@ -2,7 +2,7 @@
# This is the LGPL libmariadb project. # This is the LGPL libmariadb project.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
INCLUDE(CheckFunctionExists) INCLUDE(CheckFunctionExists)
IF(COMMAND CMAKE_POLICY) IF(COMMAND CMAKE_POLICY)
SET(NEW_POLICIES CMP0003 CMP0022 CMP0023 CMP0077 CMP0069 CMP0075) SET(NEW_POLICIES CMP0003 CMP0022 CMP0023 CMP0077 CMP0069 CMP0075)

View File

@@ -2,6 +2,8 @@ name: "Code scanning - action"
on: on:
push: push:
branches-ignore:
- 'dependabot/**'
pull_request: pull_request:
schedule: schedule:
- cron: '0 7 * * 2' - cron: '0 7 * * 2'
@@ -11,14 +13,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
security-events: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v4
with: with:
# We must fetch at least the immediate parents so that if this is # We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head. # a pull request then we can checkout the head.
fetch-depth: 2 fetch-depth: 2
submodules: true submodules: true
persist-credentials: false
# If this run was triggered by a pull request event, then checkout # If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit. # the head of the pull request instead of the merge commit.
@@ -27,9 +33,9 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v3
- run: sudo apt install libipc-run3-perl libfile-slurp-perl libfile-which-perl pandoc - run: sudo apt install libipc-run3-perl pandoc
- run: | - run: |
./bootstrap ./bootstrap
./configure ./configure
@@ -37,4 +43,4 @@ jobs:
make safedist make safedist
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v3

View File

@@ -17,9 +17,10 @@ jobs:
CC: ${{ matrix.cc }} CC: ${{ matrix.cc }}
VERBOSE: 1 VERBOSE: 1
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
persist-credentials: false
- run: sudo apt install libipc-run3-perl - run: sudo apt install libipc-run3-perl
if: ${{ matrix.os == 'ubuntu-latest' }} if: ${{ matrix.os == 'ubuntu-latest' }}
- run: brew install autoconf automake libtool - run: brew install autoconf automake libtool
@@ -38,9 +39,10 @@ jobs:
name: CMake build on ${{matrix.os}} name: CMake build on ${{matrix.os}}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
persist-credentials: false
- run: cmake -DBUILD_TESTING=ON . - run: cmake -DBUILD_TESTING=ON .
- run: cmake --build . - run: cmake --build .
- run: ctest -V . - run: ctest -V . -C Debug

View File

@@ -18,6 +18,7 @@
/config.* /config.*
/configure /configure
/depcomp /depcomp
/generated
/include/maxminddb_config.h /include/maxminddb_config.h
/install-sh /install-sh
/libmaxminddb-* /libmaxminddb-*
@@ -43,3 +44,4 @@ Makefile
Makefile.in Makefile.in
Testing/ Testing/
install_manifest.txt install_manifest.txt
build/

View File

@@ -1,8 +1,8 @@
cmake_minimum_required (VERSION 3.9) cmake_minimum_required (VERSION 3.9...3.30)
project(maxminddb project(maxminddb
LANGUAGES C LANGUAGES C
VERSION 1.6.0 VERSION 1.12.2
) )
set(MAXMINDDB_SOVERSION 0.0.7) set(MAXMINDDB_SOVERSION 0.0.7)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
@@ -13,6 +13,11 @@ if (WIN32)
endif() endif()
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
option(BUILD_TESTING "Build test programs" ON) option(BUILD_TESTING "Build test programs" ON)
option(BUILD_FUZZING "Build with fuzzer" OFF)
option(MAXMINDDB_BUILD_BINARIES "Build binaries" ON)
option(MAXMINDDB_INSTALL "Generate the install target" ON)
include(GNUInstallDirs)
include(CheckTypeSize) include(CheckTypeSize)
check_type_size("unsigned __int128" UINT128) check_type_size("unsigned __int128" UINT128)
@@ -36,7 +41,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif() endif()
configure_file(${PROJECT_SOURCE_DIR}/include/maxminddb_config.h.cmake.in configure_file(${PROJECT_SOURCE_DIR}/include/maxminddb_config.h.cmake.in
${PROJECT_SOURCE_DIR}/include/maxminddb_config.h) ${CMAKE_CURRENT_BINARY_DIR}/generated/maxminddb_config.h)
add_library(maxminddb add_library(maxminddb
src/maxminddb.c src/maxminddb.c
@@ -46,7 +51,7 @@ add_library(maxminddb::maxminddb ALIAS maxminddb)
set_target_properties(maxminddb PROPERTIES VERSION ${MAXMINDDB_SOVERSION}) set_target_properties(maxminddb PROPERTIES VERSION ${MAXMINDDB_SOVERSION})
target_compile_definitions(maxminddb PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}") target_compile_definitions(maxminddb PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")
if(NOT IS_BIG_ENDIAN) if(NOT IS_BIG_ENDIAN)
target_compile_definitions(maxminddb PRIVATE MMDB_LITTLE_ENDIAN=1) target_compile_definitions(maxminddb PRIVATE MMDB_LITTLE_ENDIAN=1)
@@ -77,28 +82,87 @@ endif()
target_include_directories(maxminddb PUBLIC target_include_directories(maxminddb PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated/>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
set(MAXMINDB_HEADERS set(MAXMINDB_HEADERS
include/maxminddb.h include/maxminddb.h
include/maxminddb_config.h ${CMAKE_CURRENT_BINARY_DIR}/generated/maxminddb_config.h
) )
set_target_properties(maxminddb PROPERTIES PUBLIC_HEADER "${MAXMINDB_HEADERS}") set_target_properties(maxminddb PROPERTIES PUBLIC_HEADER "${MAXMINDB_HEADERS}")
#install(TARGETS maxminddb EXPORT maxminddb) if (MAXMINDDB_INSTALL)
install(TARGETS maxminddb
EXPORT maxminddb)
# This is required to work with FetchContent # This is required to work with FetchContent
# install(EXPORT maxminddb install(EXPORT maxminddb
# FILE maxminddb-config.cmake FILE maxminddb-config.cmake
# NAMESPACE maxminddb:: NAMESPACE maxminddb::
# DESTINATION lib/cmake/maxminddb) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/maxminddb)
endif()
# We always want to build mmdblookup if (MAXMINDDB_BUILD_BINARIES)
#add_subdirectory(bin) add_subdirectory(bin)
endif()
# Check if man pages exist, if not, generate them
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/man")
find_program(PERL perl)
if(PERL)
message(STATUS "Generating man pages")
execute_process(
COMMAND ${PERL} ${CMAKE_CURRENT_SOURCE_DIR}/dev-bin/make-man-pages.pl
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
else()
message(WARNING "Perl not found. Unable to generate man pages.")
endif()
endif()
# Install man pages if they exist
if(MAXMINDDB_INSTALL AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/man")
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/man/man1
DESTINATION ${CMAKE_INSTALL_MANDIR}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/man/man3
DESTINATION ${CMAKE_INSTALL_MANDIR}
)
endif()
if (BUILD_TESTING) if (BUILD_TESTING)
enable_testing() enable_testing()
add_subdirectory(t) add_subdirectory(t)
endif() endif()
# Generate libmaxminddb.pc file for pkg-config
# Set the required variables as same with autotools
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_INCLUDEDIR})
set(PACKAGE_VERSION ${maxminddb_VERSION})
if (MAXMINDDB_INSTALL)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmaxminddb.pc.in
${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmaxminddb.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
# uninstall target
# if(NOT TARGET uninstall)
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
# "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
# IMMEDIATE @ONLY)
# add_custom_target(uninstall
# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# endif()

View File

@@ -1,4 +1,94 @@
## 1.7.0 ## 1.12.2 - 2025-01-10
* `MMDB_get_entry_data_list()` now always sets the passed `entry_data_list`
parameter to either `NULL` or valid memory. This makes it safe for
callers to use `MMDB_free_entry_data_list()` on it even in case of error.
In 1.12.0 `MMDB_get_entry_data_list()` was changed to not set this
parameter to valid memory in additional error cases. That change caused
segfaults for certain libraries that assumed it was safe to free memory
on error. Doing so was never safe, but worked in some cases. This change
makes such calls safe. Reported by Petr Pisar. GitHub
maxmind/MaxMind-DB-Reader-XS#39.
## 1.12.1 - 2025-01-08
* Added missing `cmake_uninstall.cmake.in` to the source distribution. This
was missing from 1.12.0, causing CMake builds to fail. Reported by Marcel
Raad. GitHub #367.
## 1.12.0 - 2025-01-07
* Fixed memory leaks in `MMDB_open()`. These could happen with invalid
databases or in error situations such as failing to allocate memory. As
part of the fix, `MMDB_get_entry_data_list()` now frees memory it
allocates on additional errors. Previously it failed to clean up when
certain errors occurred. Pull request by pkillarjun. GitHub #356.
* There is now a build target to fuzz the library. Pull request by
pkillarjun. GitHub #357.
* Updated `cmake_minimum_required` to a version range to quiet deprecation
warnings on new CMake versions. Reported by gmou3. GitHub #359.
* The script for generating man pages no longer uses `autodie`. This
eliminates the dependency on `IPC::System::Simple`. Reported by gmou3.
GitHub #359.
* An uninstall target is now included for CMake. Pull request by gmou3.
GitHub #362.
## 1.11.0 - 2024-08-21
* When building with CMake, the man pages will now be generated and
installed. Requested by Thomas Klausner. GitHub #351.
* Removed unnecessary `$<INSTALL_INTERFACE:generated>` directory from
`target_include_directories` in the CMake build configuration. This is
a private build directory. Pull request by Ankur Verma. GitHub #354.
## 1.10.0 - 2024-06-10
* When building with CMake, it is now possible to disable the building
of binaries (e.g., `mmdblookup`) with the `MAXMINDDB_BUILD_BINARIES`
option and the install target generation with the `MAXMINDDB_INSTALL`
option. Pull request by Seena Fallah. GitHub #342.
* CMake now makes greater use of GNUInstallDirs. Pull request by Maximilian
Downey Twiss. GitHub #346.
* The reader can now look up records on a database with a search tree
that is greater than 4 gigabytes without sometimes returning erroneous
results due to an integer overflow.
## 1.9.1 - 2024-01-09
* `SSIZE_MAX` is now defined conditionally on Windows. The 1.9.0
release would cause a redefinition warning when compiled with MinGW.
Reported by Andreas Vögele. GitHub #338.
## 1.9.0 - 2024-01-09
* On very large databases, the calculation to determine the search tree
size could overflow. This was fixed and several additional guards
against overflows were added. Reported by Sami Salonen. GitHub #335.
* Removed `sa_family_t` typedef from the public header on Windows. Pull
request by Noah Treuhaft. GitHub #334.
* The CMake build was adjusted to allow running builds in parallel.
Pull request by Vladyslav Miachkov. GitHub #332.
## 1.8.0 - 2023-11-07
* `PACKAGE_VERSION` is now a private compile definition when building
with CMake. Pull request by bsergean. GitHub #308.
* `PACKAGE_VERSION` is no longer defined in `maxminddb.h` on
Windows.
* The feature test macro `_POSIX_C_SOURCE` is no longer set by
`maxminddb.h`. As discussed in GitHub #318, this should be set by
applications rather than by libraries.
* `assert()` is no longer used outside test code.
* The deprecated Visual Studio 12 project files in the `projects/`
directory have been removed. CMake should be used when building on
Windows.
## 1.7.1 - 2022-09-30
* The external symbols test now only runs on Linux. It assumes a Linux
environment. Reported by Carlo Cabrera. GitHub #304.
## 1.7.0 - 2022-09-28
* `FD_CLOEXEC` is now set on platforms that do not support `O_CLOEXEC`. * `FD_CLOEXEC` is now set on platforms that do not support `O_CLOEXEC`.
Reported by rittneje. GitHub #273. Reported by rittneje. GitHub #273.
@@ -6,6 +96,11 @@
CMake by setting `MSVC_STATIC_RUNTIME` to `ON`. Pull request by Rafael CMake by setting `MSVC_STATIC_RUNTIME` to `ON`. Pull request by Rafael
Santiago. GitHub #269. Santiago. GitHub #269.
* The CMake build now works on iOS. Pull request by SpaceIm. GitHub #271. * The CMake build now works on iOS. Pull request by SpaceIm. GitHub #271.
* The CMake build now uses the correct library directory on Linux systems
using alternate directory structures. Pull request by Satadru Pramanik.
GitHub #284.
* File size check now correctly compares the size to `SSIZE_MAX`. Reported
by marakew. GitHub #301.
## 1.6.0 - 2021-04-29 ## 1.6.0 - 2021-04-29
@@ -190,7 +285,7 @@
code to think it had found valid metadata when none existed. In addition, code to think it had found valid metadata when none existed. In addition,
this could lead to an attempt to read past the end of the database this could lead to an attempt to read past the end of the database
entirely. Finally, if there are multiple metadata markers in the database, entirely. Finally, if there are multiple metadata markers in the database,
we treat the final one as the start of the metdata, instead of the first. we treat the final one as the start of the metadata, instead of the first.
Implemented by Tobias Stoeckmann. GitHub #102. Implemented by Tobias Stoeckmann. GitHub #102.
* Don't attempt to mmap a file that is too large to be mmapped on the * Don't attempt to mmap a file that is too large to be mmapped on the
system. Implemented by Tobias Stoeckmann. GitHub #101. system. Implemented by Tobias Stoeckmann. GitHub #101.

View File

@@ -16,9 +16,9 @@ SUBDIRS += \
t t
endif endif
EXTRA_DIST = doc Changes.md LICENSE NOTICE README.md projects/VS12 projects/VS12-tests \ EXTRA_DIST = doc Changes.md LICENSE NOTICE README.md \
CMakeLists.txt t/CMakeLists.txt bin/CMakeLists.txt \ CMakeLists.txt t/CMakeLists.txt bin/CMakeLists.txt \
include/maxminddb_config.h.cmake.in cmake_uninstall.cmake.in include/maxminddb_config.h.cmake.in
dist-hook: dist-hook:
dev-bin/make-man-pages.pl $(distdir) dev-bin/make-man-pages.pl $(distdir)

View File

@@ -1,4 +1,4 @@
Copyright 2013-2021 MaxMind, Inc. Copyright 2013-2025 MaxMind, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@@ -52,8 +52,7 @@ some reason.
autoconf automake libtool git-buildpackage libfile-slurp-perl pandoc autoconf automake libtool git-buildpackage libfile-slurp-perl pandoc
dirmngr libfile-slurp-tiny-perl libdatetime-perl debhelper dh-autoreconf dirmngr libfile-slurp-tiny-perl libdatetime-perl debhelper dh-autoreconf
libipc-run3-perl libtest-output-perl devscripts libipc-run3-perl libtest-output-perl devscripts
* Install [hub](https://github.com/github/hub/releases). (Using `./install` * Install [gh](https://github.com/cli/cli/releases).
from the tarball is fine)
* GitHub ssh key (e.g. in `~/.ssh/id_rsa`) * GitHub ssh key (e.g. in `~/.ssh/id_rsa`)
* Git config (e.g. `~/.gitconfig`) * Git config (e.g. `~/.gitconfig`)
* Import your GPG secret key (or create one if you don't have a suitable * Import your GPG secret key (or create one if you don't have a suitable

41
vendor/MaxmindDB/README.fuzzing.md vendored Normal file
View File

@@ -0,0 +1,41 @@
# Fuzzing libmaxminddb
These tests are only meant to be run on GNU/Linux.
## Build maxminddb fuzzer using libFuzzer.
### Export flags for fuzzing.
Note that in `CFLAGS` and `CXXFLAGS`, any type of sanitizers can be added.
- [AddressSanitizer](https://clang.llvm.org/docs/AddressSanitizer.html),
[ThreadSanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html),
[MemorySanitizer](https://clang.llvm.org/docs/MemorySanitizer.html),
[UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html),
[LeakSanitizer](https://clang.llvm.org/docs/LeakSanitizer.html).
```shell
$ export CC=clang
$ export CXX=clang++
$ export CFLAGS="-g -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address,undefined -fsanitize=fuzzer-no-link"
$ export CXXFLAGS="-g -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address,undefined -fsanitize=fuzzer-no-link"
$ export LIB_FUZZING_ENGINE="-fsanitize=fuzzer"
```
### Build maxminddb for fuzzing.
```shell
$ mkdir -p build && cd build
$ cmake -DBUILD_FUZZING=ON ../.
$ cmake --build . -j$(nproc)
```
### Running fuzzer.
```shell
$ mkdir -p fuzz_mmdb_seed fuzz_mmdb_seed_corpus
$ find ../t/maxmind-db/test-data/ -type f -size -4k -exec cp {} ./fuzz_mmdb_seed_corpus/ \;
$ ./t/fuzz_mmdb fuzz_mmdb_seed/ fuzz_mmdb_seed_corpus/
```
Here is more information about [LibFuzzer](https://llvm.org/docs/LibFuzzer.html).

View File

@@ -6,10 +6,10 @@ designed to facilitate fast lookups of IP addresses while allowing for great
flexibility in the type of data associated with an address. flexibility in the type of data associated with an address.
The MaxMind DB format is an open format. The spec is available at The MaxMind DB format is an open format. The spec is available at
http://maxmind.github.io/MaxMind-DB/. This spec is licensed under the Creative https://maxmind.github.io/MaxMind-DB/. This spec is licensed under the
Commons Attribution-ShareAlike 3.0 Unported License. Creative Commons Attribution-ShareAlike 3.0 Unported License.
See http://dev.maxmind.com/ for more details about MaxMind's GeoIP2 products. See https://dev.maxmind.com/ for more details about MaxMind's GeoIP2 products.
# License # License
@@ -30,11 +30,13 @@ structure.
To install this code, run the following commands: To install this code, run the following commands:
$ ./configure ```bash
$ make ./configure
$ make check make
$ sudo make install make check
$ sudo ldconfig sudo make install
sudo ldconfig
```
You can skip the `make check` step but it's always good to know that tests are You can skip the `make check` step but it's always good to know that tests are
passing on your platform. passing on your platform.
@@ -47,8 +49,10 @@ you may need to add the `lib` directory in your `prefix` to your library path.
On most Linux distributions when using the default prefix (`/usr/local`), you On most Linux distributions when using the default prefix (`/usr/local`), you
can do this by running the following commands: can do this by running the following commands:
$ sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf" ```bash
$ ldconfig sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf"
ldconfig
```
## From a GitHub "Source Code" Archive / Git Repo Clone (Achtung!) ## From a GitHub "Source Code" Archive / Git Repo Clone (Achtung!)
@@ -65,7 +69,9 @@ in addition to `make` and a compiler.
You can clone this repository and build it by running: You can clone this repository and build it by running:
$ git clone --recursive https://github.com/maxmind/libmaxminddb ```bash
git clone --recursive https://github.com/maxmind/libmaxminddb
```
After cloning, run `./bootstrap` from the `libmaxminddb` directory and then After cloning, run `./bootstrap` from the `libmaxminddb` directory and then
follow the instructions for installing from a named release tarball as follow the instructions for installing from a named release tarball as
@@ -77,62 +83,80 @@ We provide a CMake build script. This is primarily targeted at Windows users,
but it can be used in other circumstances where the Autotools script does not but it can be used in other circumstances where the Autotools script does not
work. work.
$ cmake --build . ```bash
$ ctest -V . cmake -B build
$ cmake --build . --target install cd build/
cmake --build .
ctest -V .
cmake --build . --target install
```
When building with Visual Studio, you may build a multithreaded (MT/MTd) When building with Visual Studio, you may build a multithreaded (MT/MTd)
runtime library, using the `MSVC_STATIC_RUNTIME` setting: runtime library, using the `MSVC_STATIC_RUNTIME` setting:
$ cmake -DMSVC_STATIC_RUNTIME=ON -DBUILD_SHARED_LIBS=OFF .. ```bash
cmake -DMSVC_STATIC_RUNTIME=ON -DBUILD_SHARED_LIBS=OFF ..
```
We also include a CMake `uninstall` target:
```bash
cmake --build . --target uninstall
```
## On Ubuntu via PPA ## On Ubuntu via PPA
MaxMind provides a PPA for recent version of Ubuntu. To add the PPA to your MaxMind provides a PPA for recent version of Ubuntu. To add the PPA to your
APT sources, run: APT sources, run:
$ sudo add-apt-repository ppa:maxmind/ppa ```bash
sudo add-apt-repository ppa:maxmind/ppa
```
Then install the packages by running: Then install the packages by running:
$ sudo apt update ```bash
$ sudo apt install libmaxminddb0 libmaxminddb-dev mmdb-bin sudo apt update
sudo apt install libmaxminddb0 libmaxminddb-dev mmdb-bin
```
## On OS X via Homebrew ## On macOS via Homebrew or MacPorts
If you are on OS X and you have homebrew (see http://brew.sh/) you can install You can install libmaxminddb on macOS using [Homebrew](https://brew.sh):
libmaxminddb via brew.
$ brew install libmaxminddb ```bash
brew install libmaxminddb
```
Or with [MacPorts](https://ports.macports.org/port/libmaxminddb):
```bash
sudo port install libmaxminddb
```
# Requirements
libmaxminddb requires a minimum of POSIX.1-2001 support. If not specified
at compilation time, it defaults to requesting POSIX.1-2008 support.
# Bug Reports # Bug Reports
Please report bugs by filing an issue with our GitHub issue tracker at Please report bugs by filing an issue with our GitHub issue tracker at
https://github.com/maxmind/libmaxminddb/issues https://github.com/maxmind/libmaxminddb/issues
# Dev Tools
We have a few development tools under the `dev-bin` directory to make
development easier. These are written in Perl or shell. They are:
* `uncrustify-all.sh` - This runs `uncrustify` on all the code. Please run
this before submitting patches.
* `valgrind-all.pl` - This runs Valgrind on the tests and `mmdblookup` to
check for memory leaks.
# Creating a Release Tarball # Creating a Release Tarball
Use `make safedist` to check the resulting tarball. Use `make safedist` to check the resulting tarball.
# Copyright and License # Copyright and License
Copyright 2013-2021 MaxMind, Inc. Copyright 2013-2025 MaxMind, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -1,13 +1,24 @@
# getopt is required by mmdblookup which is not available by default on Windows # getopt is required by mmdblookup which is not available by default on Windows
if(NOT WIN32) # but available in mingw-64 toolchain by-default.
if(NOT MSVC)
add_executable(mmdblookup add_executable(mmdblookup
mmdblookup.c mmdblookup.c
) )
# Otherwise 'undefined reference to WinMain' linker error happen due to wmain()
if(MINGW)
target_link_options(mmdblookup PRIVATE "-municode")
endif()
target_compile_definitions(mmdblookup PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")
target_link_libraries(mmdblookup maxminddb pthread) target_link_libraries(mmdblookup maxminddb pthread)
if (MAXMINDDB_INSTALL)
install( install(
TARGETS mmdblookup TARGETS mmdblookup
DESTINATION bin DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
endif() endif()
endif()

View File

@@ -4,6 +4,10 @@ AM_LDFLAGS = $(top_builddir)/src/libmaxminddb.la
bin_PROGRAMS = mmdblookup bin_PROGRAMS = mmdblookup
if WINDOWS
AM_LDFLAGS += -municode
endif
if !WINDOWS if !WINDOWS
AM_CPPFLAGS += -pthread AM_CPPFLAGS += -pthread
AM_LDFLAGS += -pthread AM_LDFLAGS += -pthread

View File

@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
@@ -7,6 +11,7 @@
#ifndef _WIN32 #ifndef _WIN32
#include <pthread.h> #include <pthread.h>
#endif #endif
#include <limits.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -139,7 +144,7 @@ int main(int argc, char **argv) {
free((void *)lookup_path); free((void *)lookup_path);
srand((int)time(NULL)); srand((unsigned int)time(NULL));
#ifndef _WIN32 #ifndef _WIN32
if (thread_count > 0) { if (thread_count > 0) {
@@ -223,6 +228,14 @@ static const char **get_options(int argc,
static int help = 0; static int help = 0;
static int version = 0; static int version = 0;
#ifdef _WIN32
char *program = alloca(strlen(argv[0]));
_splitpath(argv[0], NULL, NULL, program, NULL);
_splitpath(argv[0], NULL, NULL, NULL, program + strlen(program));
#else
char *program = basename(argv[0]);
#endif
while (1) { while (1) {
static struct option options[] = { static struct option options[] = {
{"file", required_argument, 0, 'f'}, {"file", required_argument, 0, 'f'},
@@ -259,24 +272,24 @@ static const char **get_options(int argc,
} else if ('n' == opt_char) { } else if ('n' == opt_char) {
version = 1; version = 1;
} else if ('b' == opt_char) { } else if ('b' == opt_char) {
*iterations = strtol(optarg, NULL, 10); long const i = strtol(optarg, NULL, 10);
if (i > INT_MAX) {
usage(program, 1, "iterations exceeds maximum value");
}
*iterations = (int)i;
} else if ('h' == opt_char || '?' == opt_char) { } else if ('h' == opt_char || '?' == opt_char) {
help = 1; help = 1;
} else if (opt_char == 't') { } else if (opt_char == 't') {
*thread_count = strtol(optarg, NULL, 10); long const i = strtol(optarg, NULL, 10);
if (i > INT_MAX) {
usage(program, 1, "thread count exceeds maximum value");
}
*thread_count = (int)i;
} else if (opt_char == 'I') { } else if (opt_char == 'I') {
*ip_file = optarg; *ip_file = optarg;
} }
} }
#ifdef _WIN32
char *program = alloca(strlen(argv[0]));
_splitpath(argv[0], NULL, NULL, program, NULL);
_splitpath(argv[0], NULL, NULL, NULL, program + strlen(program));
#else
char *program = basename(argv[0]);
#endif
if (help) { if (help) {
usage(program, 0, NULL); usage(program, 0, NULL);
} }
@@ -295,7 +308,7 @@ static const char **get_options(int argc,
} }
const char **lookup_path = const char **lookup_path =
calloc((argc - optind) + 1, sizeof(const char *)); calloc((size_t)(argc - optind) + 1, sizeof(const char *));
if (!lookup_path) { if (!lookup_path) {
fprintf(stderr, "calloc(): %s\n", strerror(errno)); fprintf(stderr, "calloc(): %s\n", strerror(errno));
exit(1); exit(1);
@@ -452,12 +465,12 @@ static bool lookup_from_file(MMDB_s *const mmdb,
if (dump) { if (dump) {
fprintf(stdout, "%s:\n", buf); fprintf(stdout, "%s:\n", buf);
int const status = int const status2 =
MMDB_dump_entry_data_list(stderr, entry_data_list, 0); MMDB_dump_entry_data_list(stderr, entry_data_list, 0);
if (status != MMDB_SUCCESS) { if (status2 != MMDB_SUCCESS) {
fprintf(stderr, fprintf(stderr,
"MMDB_dump_entry_data_list(): %s\n", "MMDB_dump_entry_data_list(): %s\n",
MMDB_strerror(status)); MMDB_strerror(status2));
fclose(fh); fclose(fh);
MMDB_free_entry_data_list(entry_data_list); MMDB_free_entry_data_list(entry_data_list);
return false; return false;
@@ -472,10 +485,10 @@ static bool lookup_from_file(MMDB_s *const mmdb,
fprintf( fprintf(
stdout, stdout,
"Looked up %llu addresses in %.2f seconds. %.2f lookups per second.\n", "Looked up %llu addresses in %.2f seconds. %.2Lf lookups per second.\n",
i, i,
seconds, seconds,
i / seconds); (long double)i / seconds);
return true; return true;
} }
@@ -594,15 +607,15 @@ static MMDB_lookup_result_s lookup_or_die(MMDB_s *mmdb, const char *ipstr) {
MMDB_lookup_string(mmdb, ipstr, &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, ipstr, &gai_error, &mmdb_error);
if (0 != gai_error) { if (0 != gai_error) {
#ifdef _WIN32
char const *const strerr = gai_strerrorA(gai_error);
#else
char const *const strerr = gai_strerror(gai_error);
#endif
fprintf(stderr, fprintf(stderr,
"\n Error from call to getaddrinfo for %s - %s\n\n", "\n Error from call to getaddrinfo for %s - %s\n\n",
ipstr, ipstr,
#ifdef _WIN32 strerr);
gai_strerrorA(gai_error)
#else
gai_strerror(gai_error)
#endif
);
exit(3); exit(3);
} }
@@ -643,7 +656,7 @@ static bool start_threaded_benchmark(MMDB_s *const mmdb,
int const thread_count, int const thread_count,
int const iterations) { int const iterations) {
struct thread_info *const tinfo = struct thread_info *const tinfo =
calloc(thread_count, sizeof(struct thread_info)); calloc((size_t)thread_count, sizeof(struct thread_info));
if (!tinfo) { if (!tinfo) {
fprintf(stderr, "calloc(): %s\n", strerror(errno)); fprintf(stderr, "calloc(): %s\n", strerror(errno));
return false; return false;
@@ -685,7 +698,8 @@ static bool start_threaded_benchmark(MMDB_s *const mmdb,
} }
long double const elapsed = end_time - start_time; long double const elapsed = end_time - start_time;
unsigned long long const total_ips = iterations * thread_count; unsigned long long const total_ips =
(unsigned long long)(iterations * thread_count);
long double rate = total_ips; long double rate = total_ips;
if (elapsed != 0) { if (elapsed != 0) {
rate = total_ips / elapsed; rate = total_ips / elapsed;
@@ -717,7 +731,7 @@ static long double get_time(void) {
fprintf(stderr, "clock_gettime(): %s\n", strerror(errno)); fprintf(stderr, "clock_gettime(): %s\n", strerror(errno));
return -1; return -1;
} }
return tp.tv_sec + ((float)tp.tv_nsec / 1e9); return (long double)tp.tv_sec + ((float)tp.tv_nsec / 1e9);
#else #else
time_t t = time(NULL); time_t t = time(NULL);
if (t == (time_t)-1) { if (t == (time_t)-1) {

View File

@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63]) AC_PREREQ([2.63])
AC_INIT([libmaxminddb], [1.6.0], [support@maxmind.com]) AC_INIT([libmaxminddb], [1.12.2], [support@maxmind.com])
AC_CONFIG_SRCDIR([include/maxminddb.h]) AC_CONFIG_SRCDIR([include/maxminddb.h])
AC_CONFIG_HEADERS([config.h include/maxminddb_config.h]) AC_CONFIG_HEADERS([config.h include/maxminddb_config.h])

View File

@@ -2,13 +2,10 @@
use strict; use strict;
use warnings; use warnings;
use autodie qw( :all );
use FindBin qw( $Bin ); use FindBin qw( $Bin );
use File::Path qw( mkpath ); use File::Path qw( mkpath );
use File::Slurp qw( edit_file read_file );
use File::Which qw( which );
sub main { sub main {
my $target = shift || "$Bin/.."; my $target = shift || "$Bin/..";
@@ -16,7 +13,7 @@ sub main {
my @translators = qw ( lowdown pandoc ); my @translators = qw ( lowdown pandoc );
my $translator; my $translator;
foreach my $p (@translators) { foreach my $p (@translators) {
if ( defined which($p) ) { if ( _which($p) ) {
$translator = $p; $translator = $p;
last; last;
} }
@@ -33,6 +30,14 @@ sub main {
_make_man( $translator, $target, 'mmdblookup', 1 ); _make_man( $translator, $target, 'mmdblookup', 1 );
} }
sub _which {
my $program = shift;
for my $path ( split /:/, $ENV{PATH} ) {
return 1 if -x "$path/$program";
}
return 0;
}
sub _make_man { sub _make_man {
my $translator = shift; my $translator = shift;
my $target = shift; my $target = shift;
@@ -54,7 +59,7 @@ sub _make_man {
'-M', "section:$section", '-M', "section:$section",
$input, $input,
'-o', $output, '-o', $output,
); ) == 0 or die "Failed to run pandoc: $?";
_pandoc_postprocess($output); _pandoc_postprocess($output);
} }
elsif ( $translator eq 'lowdown' ) { elsif ( $translator eq 'lowdown' ) {
@@ -67,18 +72,27 @@ sub _make_man {
'-M', "section:$section", '-M', "section:$section",
$input, $input,
'-o', $output, '-o', $output,
); ) == 0 or die "Failed to run lowdown: $?";
} }
} }
sub _make_lib_man_links { sub _make_lib_man_links {
my $target = shift; my $target = shift;
my $header = read_file("$Bin/../include/maxminddb.h"); open my $header_fh, '<', "$Bin/../include/maxminddb.h"
or die "Failed to open header file: $!";
my $header = do { local $/; <$header_fh> };
die "Error reading file header file: $!" unless defined $header;
close $header_fh or die "Failed to close header file: $!";
for my $proto ( $header =~ /^ *extern.+?(MMDB_\w+)\(/gsm ) { for my $proto ( $header =~ /^ *extern.+?(MMDB_\w+)\(/gsm ) {
open my $fh, '>', "$target/man/man3/$proto.3"; open my $fh, '>', "$target/man/man3/$proto.3"
print {$fh} ".so man3/libmaxminddb.3\n"; or die "Failed to open file: $!";
close $fh; print {$fh} ".so man3/libmaxminddb.3\n"
or die "Failed to write to file: $!";
close $fh or die "Failed to close file: $!";
} }
} }
@@ -87,13 +101,20 @@ sub _make_lib_man_links {
sub _pandoc_postprocess { sub _pandoc_postprocess {
my $file = shift; my $file = shift;
edit_file( open my $fh, '<', $file or die "Failed to open man file for reading: $!";
sub { my @lines = <$fh>;
s/^\.IP\n\.nf/.IP "" 4\n.nf/gm; die "Error when reading man page: $!" if $!;
s/(Automatically generated by Pandoc)(.+)$/$1/m;
}, close $fh or die "Failed to close file: $!";
$file
); for my $line (@lines) {
$line =~ s/^\.IP\n\.nf/.IP "" 4\n.nf/gm;
$line =~ s/(Automatically generated by Pandoc)(.+)$/$1/m;
}
open $fh, '>', $file or die "Failed to open file for writing: $!";
print $fh @lines or die "Failed to write to file: $!";
close $fh or die "Failed to close file: $!";
} }
main(shift); main(shift);

View File

@@ -1,54 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin qw( $Bin );
use Data::UUID;
use File::Slurp qw( read_file write_file );
use Path::Iterator::Rule;
sub main {
my $rule = Path::Iterator::Rule->new;
$rule->file->name(qr/_t.c$/);
my $ug = Data::UUID->new;
my $template = read_file("$Bin/../projects/test.vcxproj.template");
my @names;
for my $file ( $rule->all("$Bin/../t/") ) {
my ($name) = $file =~ /(\w*)_t.c$/;
next unless $name;
next if $name eq 'threads';
push @names, $name;
my $project = $template;
$project =~ s/%TESTNAME%/$name/g;
my $uuid = $ug->to_string( $ug->create );
$project =~ s/%UUID%/$uuid/g;
write_file( "$Bin/../projects/VS12-tests/$name.vcxproj", $project );
}
_modify_yml(@names);
}
sub _modify_yml {
my @names = @_;
my $exe_block = join "\n",
map { " - .\\projects\\VS12\\Debug\\test_${_}.exe" } @names;
my $file = "$Bin/../appveyor.yml";
my $config = read_file($file);
$config =~ s/(#EXES).*?(#ENDEXES)/$1\n$exe_block\n $2/s;
write_file( $file, $config );
}
main();

View File

@@ -115,8 +115,4 @@ popd
git push git push
message="$version gh release create --target "$(git branch --show-current)" -t "$version" -n "$notes" "$version" "$dist"
$notes"
hub release create -a "$dist" -m "$message" "$version"

View File

@@ -93,11 +93,11 @@ typedef struct MMDB_entry_data_list_s {
# DESCRIPTION # DESCRIPTION
The libmaxminddb library provides functions for working MaxMind DB files. See The libmaxminddb library provides functions for working MaxMind DB files. See
http://maxmind.github.io/MaxMind-DB/ for the MaxMind DB format specification. https://maxmind.github.io/MaxMind-DB/ for the MaxMind DB format
The database and results are all represented by different data structures. specification. The database and results are all represented by different
Databases are opened by calling `MMDB_open()`. You can look up IP addresses as data structures. Databases are opened by calling `MMDB_open()`. You can
a string with `MMDB_lookup_string()` or as a pointer to a `sockaddr` look up IP addresses as a string with `MMDB_lookup_string()` or as a
structure with `MMDB_lookup_sockaddr()`. pointer to a `sockaddr` structure with `MMDB_lookup_sockaddr()`.
If the lookup finds the IP address in the database, it returns a If the lookup finds the IP address in the database, it returns a
`MMDB_lookup_result_s` structure. If that structure indicates that the database `MMDB_lookup_result_s` structure. If that structure indicates that the database
@@ -851,6 +851,11 @@ int main(int argc, char **argv)
} }
``` ```
# REQUIREMENTS
libmaxminddb requires a minimum of POSIX.1-2001 support. If not specified
at compilation time, it defaults to requesting POSIX.1-2008 support.
# THREAD SAFETY # THREAD SAFETY
This library is thread safe when compiled and linked with a thread-safe This library is thread safe when compiled and linked with a thread-safe
@@ -878,13 +883,13 @@ Rolsky (drolsky@maxmind.com).
# COPYRIGHT AND LICENSE # COPYRIGHT AND LICENSE
Copyright 2013-2014 MaxMind, Inc. Copyright 2013-2025 MaxMind, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -9,8 +9,10 @@ mmdblookup --file [FILE PATH] --ip [IP ADDRESS] [DATA PATH]
# DESCRIPTION # DESCRIPTION
`mmdblookup` looks up an IP address in the specified MaxMind DB file. The `mmdblookup` looks up an IP address in the specified MaxMind DB file. The
record for the IP address is displayed in a JSON-like structure with type record for the IP address is displayed with `{}` to denote maps and `[]` to
annotations. denote arrays. The values are followed by type annotations. This output is
_not_ JSON and is not intended to be used as such. If you need JSON, please
see [`mmdbinspect`](https://github.com/maxmind/mmdbinspect).
If an IP's data entry resolves to a map or array, you can provide a lookup If an IP's data entry resolves to a map or array, you can provide a lookup
path to only show part of that data. path to only show part of that data.
@@ -84,13 +86,13 @@ Rolsky (drolsky@maxmind.com).
# COPYRIGHT AND LICENSE # COPYRIGHT AND LICENSE
Copyright 2013-2014 MaxMind, Inc. Copyright 2013-2025 MaxMind, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -5,18 +5,6 @@ extern "C" {
#ifndef MAXMINDDB_H #ifndef MAXMINDDB_H
#define MAXMINDDB_H #define MAXMINDDB_H
/* Request POSIX.1-2008. However, we want to remain compatible with
* POSIX.1-2001 (since we have been historically and see no reason to drop
* compatibility). By requesting POSIX.1-2008, we can conditionally use
* features provided by that standard if the implementation provides it. We can
* check for what the implementation provides by checking the _POSIX_VERSION
* macro after including unistd.h. If a feature is in POSIX.1-2008 but not
* POSIX.1-2001, check that macro before using the feature (or check for the
* feature directly if possible). */
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#include "maxminddb_config.h" #include "maxminddb_config.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
@@ -28,9 +16,6 @@ extern "C" {
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
/* libmaxminddb package version from configure */ /* libmaxminddb package version from configure */
#define PACKAGE_VERSION "1.6.0"
typedef ADDRESS_FAMILY sa_family_t;
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* MSVC doesn't define signed size_t, copy it from configure */ /* MSVC doesn't define signed size_t, copy it from configure */

View File

@@ -2,7 +2,7 @@
#define MAXMINDDB_CONFIG_H #define MAXMINDDB_CONFIG_H
#ifndef MMDB_UINT128_USING_MODE #ifndef MMDB_UINT128_USING_MODE
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */ /* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
#cmakedefine MMDB_UINT128_USING_MODE @MMDB_UINT128_USING_MODE@ #cmakedefine MMDB_UINT128_USING_MODE @MMDB_UINT128_USING_MODE@
#endif #endif

View File

@@ -2,7 +2,7 @@
#define MAXMINDDB_CONFIG_H #define MAXMINDDB_CONFIG_H
#ifndef MMDB_UINT128_USING_MODE #ifndef MMDB_UINT128_USING_MODE
/* Define as 1 if we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */ /* Define as 1 if we use unsigned int __attribute__ ((__mode__(TI))) for uint128 values */
#define MMDB_UINT128_USING_MODE 0 #define MMDB_UINT128_USING_MODE 0
#endif #endif

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B19839F4-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>bad_pointers</RootNamespace>
<ProjectName>test_bad_pointers</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\bad_pointers_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1983C10-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>basic_lookup</RootNamespace>
<ProjectName>test_basic_lookup</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\basic_lookup_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1983E90-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>data_entry_list</RootNamespace>
<ProjectName>test_data_entry_list</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\data_entry_list_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B198400C-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>data_types</RootNamespace>
<ProjectName>test_data_types</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\data_types_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984188-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dump</RootNamespace>
<ProjectName>test_dump</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\dump_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984480-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>get_value</RootNamespace>
<ProjectName>test_get_value</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\get_value_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984304-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>get_value_pointer_bug</RootNamespace>
<ProjectName>test_get_value_pointer_bug</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\get_value_pointer_bug_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B198466A-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ipv4_start_cache</RootNamespace>
<ProjectName>test_ipv4_start_cache</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\ipv4_start_cache_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984872-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ipv6_lookup_in_ipv4</RootNamespace>
<ProjectName>test_ipv6_lookup_in_ipv4</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\ipv6_lookup_in_ipv4_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libtap</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/Z7 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\t\libtap\tap.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\t\libtap\tap.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleApplication1</RootNamespace>
<ProjectName>test_maxminddb_test_helper</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\..\t\libtap\libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\t\maxminddb_test_helper.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\t\maxminddb_test_helper.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984C6E-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>metadata</RootNamespace>
<ProjectName>test_metadata</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\metadata_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B19849D0-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>metadata_pointers</RootNamespace>
<ProjectName>test_metadata_pointers</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\metadata_pointers_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B1984EC6-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>no_map_get_value</RootNamespace>
<ProjectName>test_no_map_get_value</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\no_map_get_value_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B198504C-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>read_node</RootNamespace>
<ProjectName>test_read_node</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\read_node_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,104 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleApplication1</RootNamespace>
<ProjectName>test_maxminddb_test_helper</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\t\maxminddb_test_helper.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\t\maxminddb_test_helper.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,103 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8E11E9FC-7B63-11E4-AE98-6B41E8A9DDB2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>threads</RootNamespace>
<ProjectName>test_threads</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\threads_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B19851FA-376C-11E7-A95B-48C58C130AD6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>version</RootNamespace>
<ProjectName>test_version</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\version_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,64 +0,0 @@
# Deprecated
*These files are deprecated and will be removed in a future release.
Please use CMake instead.*
# Project Notes
DO NOT modify project settings for each configuration and/or platform
on a per-project basis. Use property sheets to set shared configuration
properties. The rule of thumb - if you set same value for the same
property in more than one configuration or platform, you did it wrong.
## libmaxminddb.props
This is the base property sheet for libMaxMindDB project. It contains
settings that are shared between all configurations, such as compiler
warning level, not using link-time code generation, etc.
In order to minimize the number of property sheet files, this propery
sheet also contains settings for Win32 and Debug configurations, which
are overridden by the x64 and Release property sheets described below.
## libmaxminddb-release.props
This property sheet contains all Release settings and is shared between
Win32 and x64 release builds. It must be located higher than the base
property sheet in the property Manager window for each configuration
where it's used (i.e. Release|Win32 and Release|x64).
## libmaxminddb-x64.props
This property sheet contains all x64 settings and is shared between all
Debug and Release x64 configurations. It must be located higher than the
base property sheet in the property Manager window for each configuration
where it's used (i.e. Debug|x64 and Release|x64).
## Adding More Projects
If you want to add more projects into this solution, follow the same logic
and create their own property sheets. Do not use libmaxminddb property
sheets in those projects because it will interfere with their intermediate
directories. Instead, copy and rename libmaxminddb property sheets as a
starting point.
DO NOT add libmaxminddb.lib to the Additional Dependencies box of command
line tools or any other libraries you built, for that matter. This box is
only for standard Windows libraries. Instead, add libmaxminddb as a reference
to all command line tool projects. Do the same for any other library projects
you added to this solutionn.
For external 3rd-party .lib files, create a solution folder called Libraries
and add Debug, Debug64, Release, Release64 subfolders, then drag and drop all
versinos of .lib to their respective folders and use Exclude From Build in
each library file's property to assign them to the proper build confguration.
Unused libraries will be shown with a traffic stop sign in each configuration.
If you have a lot of projects, it might be easier to do this by editing .vcxproj
and .vcxproj.filters in a text editor.
# Tests
To use the tests, you must download the `libtap` and `maxmind-db` submodules.
This can be done by running `git submodule update --init --recursive` from
the Git checkout. Each test source file has a separate project. Once compiled,
the tests must be run from the base directory of the checkout.

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IntDir>$(SolutionDir)$(Platform)\$(Configuration)\obj\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<Lib>
<TargetMachine>MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IntDir>$(SolutionDir)$(Configuration)\obj\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
<ExceptionHandling>false</ExceptionHandling>
<ProgramDataBaseFileName>$(OutDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<OmitFramePointers>false</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>
<PreBuildEvent>
<Command>if NOT EXIST (..\..\include\maxminddb_config.h) (
copy maxminddb_config.h ..\..\include\maxminddb_config.h
)</Command>
</PreBuildEvent>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@@ -1,150 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmaxminddb", "libmaxminddb.vcxproj", "{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_basic_lookup", "..\VS12-tests\basic_lookup.vcxproj", "{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_data_entry_list", "..\VS12-tests\data_entry_list.vcxproj", "{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_data_types", "..\VS12-tests\data_types.vcxproj", "{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_dump", "..\VS12-tests\dump.vcxproj", "{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_get_value", "..\VS12-tests\get_value.vcxproj", "{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_get_value_pointer_bug", "..\VS12-tests\get_value_pointer_bug.vcxproj", "{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_ipv4_start_cache", "..\VS12-tests\ipv4_start_cache.vcxproj", "{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_ipv6_lookup_in_ipv4", "..\VS12-tests\ipv6_lookup_in_ipv4.vcxproj", "{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtap", "..\VS12-tests\libtap.vcxproj", "{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_metadata", "..\VS12-tests\metadata.vcxproj", "{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_no_map_get_value", "..\VS12-tests\no_map_get_value.vcxproj", "{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_read_node", "..\VS12-tests\read_node.vcxproj", "{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_maxminddb_test_helper", "..\VS12-tests\shared.vcxproj", "{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_version", "..\VS12-tests\version.vcxproj", "{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_bad_pointers", "..\VS12-tests\bad_pointers.vcxproj", "{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_metadata_pointers", "..\VS12-tests\metadata_pointers.vcxproj", "{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Debug|Win32.ActiveCfg = Debug|Win32
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Debug|Win32.Build.0 = Debug|Win32
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Debug|x64.ActiveCfg = Debug|x64
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Debug|x64.Build.0 = Debug|x64
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Release|Win32.ActiveCfg = Release|Win32
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Release|Win32.Build.0 = Release|Win32
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Release|x64.ActiveCfg = Release|x64
{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}.Release|x64.Build.0 = Release|x64
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11C512-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11C882-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11CBD4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11CEEA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11D5E8-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11D2AA-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11D930-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11DC64-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Debug|Win32.ActiveCfg = Debug|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Debug|Win32.Build.0 = Debug|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Debug|x64.ActiveCfg = Debug|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Release|Win32.ActiveCfg = Release|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Release|Win32.Build.0 = Release|Win32
{4DFC985A-83D7-4E61-85FE-C6EA6E43E3AA}.Release|x64.ActiveCfg = Release|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11DFC0-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11E33A-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11E68C-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Debug|Win32.ActiveCfg = Debug|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Debug|Win32.Build.0 = Debug|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Debug|x64.ActiveCfg = Debug|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Release|Win32.ActiveCfg = Release|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Release|Win32.Build.0 = Release|Win32
{A8F568F6-5507-4EC2-A834-F2C0A3C635A5}.Release|x64.ActiveCfg = Release|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11ED26-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|Win32.Build.0 = Debug|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Debug|x64.ActiveCfg = Debug|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.ActiveCfg = Release|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|Win32.Build.0 = Release|Win32
{8E11BAF4-7B63-11E4-AE98-6B41E8A9DDB2}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,143 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\maxminddb.c" />
<ClCompile Include="..\..\src\data-pool.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\maxminddb.h" />
<ClInclude Include="..\..\src\data-pool.h" />
</ItemGroup>
<ItemGroup>
<None Include="README" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{82953BDA-2960-4ADA-A6D5-92E65CCB4A3D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libmaxminddb</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libmaxminddb.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libmaxminddb.props" />
<Import Project="libmaxminddb-x64.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libmaxminddb.props" />
<Import Project="libmaxminddb-release.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="libmaxminddb.props" />
<Import Project="libmaxminddb-x64.props" />
<Import Project="libmaxminddb-release.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>$(ProjectName)d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>$(ProjectName)d</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent />
<Lib />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent />
<Lib />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent />
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\maxminddb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\data-pool.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\maxminddb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\data-pool.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="README" />
</ItemGroup>
</Project>

View File

@@ -1,14 +0,0 @@
#ifndef MAXMINDDB_CONFIG_H
#define MAXMINDDB_CONFIG_H
#ifndef MMDB_UINT128_USING_MODE
/* Define as 1 if we we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
#define MMDB_UINT128_USING_MODE 0
#endif
#ifndef MMDB_UINT128_IS_BYTE_ARRAY
/* Define as 1 if we don't have an unsigned __int128 type */
#define MMDB_UINT128_IS_BYTE_ARRAY 1
#endif
#endif /* MAXMINDDB_CONFIG_H */

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{%UUID%}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>%TESTNAME%</RootNamespace>
<ProjectName>test_%TESTNAME%</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\t\libtap;$(SolutionDir)\..\..\src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\t\%TESTNAME%_t.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="libtap.vcxproj">
<Project>{4dfc985a-83d7-4e61-85fe-c6ea6e43e3aa}</Project>
</ProjectReference>
<ProjectReference Include="..\VS12\libmaxminddb.vcxproj">
<Project>{82953bda-2960-4ada-a6d5-92e65ccb4a3d}</Project>
</ProjectReference>
<ProjectReference Include="maxminddb_test_helper.vcxproj">
<Project>{a8f568f6-5507-4ec2-a834-f2c0a3c635a5}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -5,6 +5,10 @@ lib_LTLIBRARIES = libmaxminddb.la
libmaxminddb_la_SOURCES = maxminddb.c maxminddb-compat-util.h \ libmaxminddb_la_SOURCES = maxminddb.c maxminddb-compat-util.h \
data-pool.c data-pool.h data-pool.c data-pool.h
libmaxminddb_la_LDFLAGS = -version-info 0:7:0 -export-symbols-regex '^MMDB_.*' libmaxminddb_la_LDFLAGS = -version-info 0:7:0 -export-symbols-regex '^MMDB_.*'
if WINDOWS
libmaxminddb_la_LDFLAGS += -no-undefined
endif
include_HEADERS = $(top_srcdir)/include/maxminddb.h include_HEADERS = $(top_srcdir)/include/maxminddb.h
pkgconfig_DATA = libmaxminddb.pc pkgconfig_DATA = libmaxminddb.pc

View File

@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#include "data-pool.h" #include "data-pool.h"
#include "maxminddb.h" #include "maxminddb.h"
@@ -5,8 +9,6 @@
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
static bool can_multiply(size_t const, size_t const, size_t const);
// Allocate an MMDB_data_pool_s. It initially has space for size // Allocate an MMDB_data_pool_s. It initially has space for size
// MMDB_entry_data_list_s structs. // MMDB_entry_data_list_s structs.
MMDB_data_pool_s *data_pool_new(size_t const size) { MMDB_data_pool_s *data_pool_new(size_t const size) {
@@ -39,7 +41,7 @@ MMDB_data_pool_s *data_pool_new(size_t const size) {
// the given max. max will typically be SIZE_MAX. // the given max. max will typically be SIZE_MAX.
// //
// We want to know if we'll wrap around. // We want to know if we'll wrap around.
static bool can_multiply(size_t const max, size_t const m, size_t const n) { bool can_multiply(size_t const max, size_t const m, size_t const n) {
if (m == 0) { if (m == 0) {
return false; return false;
} }
@@ -156,9 +158,13 @@ int main(void) {
} }
static void test_can_multiply(void) { static void test_can_multiply(void) {
{ ok(can_multiply(SIZE_MAX, 1, SIZE_MAX), "1*SIZE_MAX is ok"); } {
ok(can_multiply(SIZE_MAX, 1, SIZE_MAX), "1*SIZE_MAX is ok");
}
{ ok(!can_multiply(SIZE_MAX, 2, SIZE_MAX), "2*SIZE_MAX is not ok"); } {
ok(!can_multiply(SIZE_MAX, 2, SIZE_MAX), "2*SIZE_MAX is not ok");
}
{ {
ok(can_multiply(SIZE_MAX, 10240, sizeof(MMDB_entry_data_list_s)), ok(can_multiply(SIZE_MAX, 10240, sizeof(MMDB_entry_data_list_s)),

View File

@@ -44,6 +44,7 @@ typedef struct MMDB_data_pool_s {
MMDB_entry_data_list_s *blocks[DATA_POOL_NUM_BLOCKS]; MMDB_entry_data_list_s *blocks[DATA_POOL_NUM_BLOCKS];
} MMDB_data_pool_s; } MMDB_data_pool_s;
bool can_multiply(size_t const, size_t const, size_t const);
MMDB_data_pool_s *data_pool_new(size_t const); MMDB_data_pool_s *data_pool_new(size_t const);
void data_pool_destroy(MMDB_data_pool_s *const); void data_pool_destroy(MMDB_data_pool_s *const);
MMDB_entry_data_list_s *data_pool_alloc(MMDB_data_pool_s *const); MMDB_entry_data_list_s *data_pool_alloc(MMDB_data_pool_s *const);

View File

@@ -5,7 +5,7 @@ includedir=@includedir@
Name: libmaxminddb Name: libmaxminddb
Description: C library for the MaxMind DB file format Description: C library for the MaxMind DB file format
URL: http://maxmind.github.io/libmaxminddb/ URL: https://maxmind.github.io/libmaxminddb/
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lmaxminddb Libs: -L${libdir} -lmaxminddb
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@@ -42,9 +42,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
static void * static const void *
mmdb_memmem(const void *l, size_t l_len, const void *s, size_t s_len) { mmdb_memmem(const void *l, size_t l_len, const void *s, size_t s_len) {
register char *cur, *last; const char *cur, *last;
const char *cl = (const char *)l; const char *cl = (const char *)l;
const char *cs = (const char *)s; const char *cs = (const char *)s;
@@ -61,9 +61,9 @@ mmdb_memmem(const void *l, size_t l_len, const void *s, size_t s_len) {
return memchr(l, (int)*cs, l_len); return memchr(l, (int)*cs, l_len);
/* the last position where its possible to find "s" in "l" */ /* the last position where its possible to find "s" in "l" */
last = (char *)cl + l_len - s_len; last = cl + l_len - s_len;
for (cur = (char *)cl; cur <= last; cur++) for (cur = cl; cur <= last; cur++)
if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0) if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
return cur; return cur;

View File

@@ -1,13 +1,17 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include "data-pool.h" #include "data-pool.h"
#include "maxminddb-compat-util.h" #include "maxminddb-compat-util.h"
#include "maxminddb.h" #include "maxminddb.h"
#include <assert.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h> #include <inttypes.h>
#include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -19,6 +23,10 @@
#endif #endif
#include <windows.h> #include <windows.h>
#include <ws2ipdef.h> #include <ws2ipdef.h>
#ifndef SSIZE_MAX
#define SSIZE_MAX INTPTR_MAX
#endif
typedef ADDRESS_FAMILY sa_family_t;
#else #else
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/mman.h> #include <sys/mman.h>
@@ -152,7 +160,7 @@ static int populate_description_metadata(MMDB_s *mmdb,
MMDB_entry_s *metadata_start); MMDB_entry_s *metadata_start);
static int resolve_any_address(const char *ipstr, struct addrinfo **addresses); static int resolve_any_address(const char *ipstr, struct addrinfo **addresses);
static int find_address_in_search_tree(const MMDB_s *const mmdb, static int find_address_in_search_tree(const MMDB_s *const mmdb,
uint8_t *address, uint8_t const *address,
sa_family_t address_family, sa_family_t address_family,
MMDB_lookup_result_s *result); MMDB_lookup_result_s *result);
static record_info_s record_info_for_database(const MMDB_s *const mmdb); static record_info_s record_info_for_database(const MMDB_s *const mmdb);
@@ -162,7 +170,7 @@ static uint32_t get_left_28_bit_record(const uint8_t *record);
static uint32_t get_right_28_bit_record(const uint8_t *record); static uint32_t get_right_28_bit_record(const uint8_t *record);
static uint32_t data_section_offset_for_record(const MMDB_s *const mmdb, static uint32_t data_section_offset_for_record(const MMDB_s *const mmdb,
uint64_t record); uint64_t record);
static int path_length(va_list va_path); static size_t path_length(va_list va_path);
static int lookup_path_in_array(const char *path_elem, static int lookup_path_in_array(const char *path_elem,
const MMDB_s *const mmdb, const MMDB_s *const mmdb,
MMDB_entry_data_s *entry_data); MMDB_entry_data_s *entry_data);
@@ -201,7 +209,7 @@ dump_entry_data_list(FILE *stream,
int indent, int indent,
int *status); int *status);
static void print_indentation(FILE *stream, int i); static void print_indentation(FILE *stream, int i);
static char *bytes_to_hex(uint8_t *bytes, uint32_t size); static char *bytes_to_hex(uint8_t const *bytes, uint32_t size);
#define CHECKED_DECODE_ONE(mmdb, offset, entry_data) \ #define CHECKED_DECODE_ONE(mmdb, offset, entry_data) \
do { \ do { \
@@ -284,18 +292,29 @@ int MMDB_open(const char *const filename, uint32_t flags, MMDB_s *const mmdb) {
goto cleanup; goto cleanup;
} }
uint32_t search_tree_size = if (!can_multiply(SSIZE_MAX,
mmdb->metadata.node_count * mmdb->full_record_byte_size; mmdb->metadata.node_count,
mmdb->full_record_byte_size)) {
mmdb->data_section =
mmdb->file_content + search_tree_size + MMDB_DATA_SECTION_SEPARATOR;
if (search_tree_size + MMDB_DATA_SECTION_SEPARATOR >
(uint32_t)mmdb->file_size) {
status = MMDB_INVALID_METADATA_ERROR; status = MMDB_INVALID_METADATA_ERROR;
goto cleanup; goto cleanup;
} }
mmdb->data_section_size = (uint32_t)mmdb->file_size - search_tree_size - ssize_t search_tree_size = (ssize_t)mmdb->metadata.node_count *
MMDB_DATA_SECTION_SEPARATOR; (ssize_t)mmdb->full_record_byte_size;
mmdb->data_section =
mmdb->file_content + search_tree_size + MMDB_DATA_SECTION_SEPARATOR;
if (mmdb->file_size < MMDB_DATA_SECTION_SEPARATOR ||
search_tree_size > mmdb->file_size - MMDB_DATA_SECTION_SEPARATOR) {
status = MMDB_INVALID_METADATA_ERROR;
goto cleanup;
}
ssize_t data_section_size =
mmdb->file_size - search_tree_size - MMDB_DATA_SECTION_SEPARATOR;
if (data_section_size > UINT32_MAX || data_section_size <= 0) {
status = MMDB_INVALID_METADATA_ERROR;
goto cleanup;
}
mmdb->data_section_size = (uint32_t)data_section_size;
// Although it is likely not possible to construct a database with valid // Although it is likely not possible to construct a database with valid
// valid metadata, as parsed above, and a data_section_size less than 3, // valid metadata, as parsed above, and a data_section_size less than 3,
@@ -406,7 +425,6 @@ cleanup:;
#else // _WIN32 #else // _WIN32
static int map_file(MMDB_s *const mmdb) { static int map_file(MMDB_s *const mmdb) {
ssize_t size;
int status = MMDB_SUCCESS; int status = MMDB_SUCCESS;
int o_flags = O_RDONLY; int o_flags = O_RDONLY;
@@ -432,14 +450,14 @@ static int map_file(MMDB_s *const mmdb) {
goto cleanup; goto cleanup;
} }
size = s.st_size; off_t size = s.st_size;
if (size < 0 || size != s.st_size) { if (size < 0 || size > SSIZE_MAX) {
status = MMDB_OUT_OF_MEMORY_ERROR; status = MMDB_OUT_OF_MEMORY_ERROR;
goto cleanup; goto cleanup;
} }
uint8_t *file_content = uint8_t *file_content =
(uint8_t *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); (uint8_t *)mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED, fd, 0);
if (MAP_FAILED == file_content) { if (MAP_FAILED == file_content) {
if (ENOMEM == errno) { if (ENOMEM == errno) {
status = MMDB_OUT_OF_MEMORY_ERROR; status = MMDB_OUT_OF_MEMORY_ERROR;
@@ -449,7 +467,7 @@ static int map_file(MMDB_s *const mmdb) {
goto cleanup; goto cleanup;
} }
mmdb->file_size = size; mmdb->file_size = (ssize_t)size;
mmdb->file_content = file_content; mmdb->file_content = file_content;
cleanup:; cleanup:;
@@ -471,12 +489,16 @@ static const uint8_t *find_metadata(const uint8_t *file_content,
ssize_t max_size = file_size > METADATA_BLOCK_MAX_SIZE ssize_t max_size = file_size > METADATA_BLOCK_MAX_SIZE
? METADATA_BLOCK_MAX_SIZE ? METADATA_BLOCK_MAX_SIZE
: file_size; : file_size;
if (max_size < 0) {
return NULL;
}
uint8_t *search_area = (uint8_t *)(file_content + (file_size - max_size)); uint8_t const *search_area = (file_content + (file_size - max_size));
uint8_t *start = search_area; uint8_t const *start = search_area;
uint8_t *tmp; uint8_t const *tmp;
do { do {
tmp = mmdb_memmem(search_area, max_size, METADATA_MARKER, marker_len); tmp = mmdb_memmem(
search_area, (size_t)max_size, METADATA_MARKER, marker_len);
if (NULL != tmp) { if (NULL != tmp) {
max_size -= tmp - search_area; max_size -= tmp - search_area;
@@ -683,7 +705,7 @@ value_for_key_as_string(MMDB_entry_s *start, char *key, char const **value) {
type_num_to_name(entry_data.type)); type_num_to_name(entry_data.type));
return MMDB_INVALID_METADATA_ERROR; return MMDB_INVALID_METADATA_ERROR;
} }
*value = mmdb_strndup((char *)entry_data.utf8_string, entry_data.data_size); *value = mmdb_strndup(entry_data.utf8_string, entry_data.data_size);
if (NULL == *value) { if (NULL == *value) {
return MMDB_OUT_OF_MEMORY_ERROR; return MMDB_OUT_OF_MEMORY_ERROR;
} }
@@ -722,20 +744,22 @@ static int populate_languages_metadata(MMDB_s *mmdb,
mmdb->metadata.languages.count = 0; mmdb->metadata.languages.count = 0;
mmdb->metadata.languages.names = calloc(array_size, sizeof(char *)); mmdb->metadata.languages.names = calloc(array_size, sizeof(char *));
if (NULL == mmdb->metadata.languages.names) { if (NULL == mmdb->metadata.languages.names) {
MMDB_free_entry_data_list(first_member);
return MMDB_OUT_OF_MEMORY_ERROR; return MMDB_OUT_OF_MEMORY_ERROR;
} }
for (uint32_t i = 0; i < array_size; i++) { for (uint32_t i = 0; i < array_size; i++) {
member = member->next; member = member->next;
if (MMDB_DATA_TYPE_UTF8_STRING != member->entry_data.type) { if (MMDB_DATA_TYPE_UTF8_STRING != member->entry_data.type) {
MMDB_free_entry_data_list(first_member);
return MMDB_INVALID_METADATA_ERROR; return MMDB_INVALID_METADATA_ERROR;
} }
mmdb->metadata.languages.names[i] = mmdb->metadata.languages.names[i] = mmdb_strndup(
mmdb_strndup((char *)member->entry_data.utf8_string, member->entry_data.utf8_string, member->entry_data.data_size);
member->entry_data.data_size);
if (NULL == mmdb->metadata.languages.names[i]) { if (NULL == mmdb->metadata.languages.names[i]) {
MMDB_free_entry_data_list(first_member);
return MMDB_OUT_OF_MEMORY_ERROR; return MMDB_OUT_OF_MEMORY_ERROR;
} }
// We assign this as we go so that if we fail a calloc and need to // We assign this as we go so that if we fail a calloc and need to
@@ -815,9 +839,8 @@ static int populate_description_metadata(MMDB_s *mmdb,
goto cleanup; goto cleanup;
} }
mmdb->metadata.description.descriptions[i]->language = mmdb->metadata.description.descriptions[i]->language = mmdb_strndup(
mmdb_strndup((char *)member->entry_data.utf8_string, member->entry_data.utf8_string, member->entry_data.data_size);
member->entry_data.data_size);
if (NULL == mmdb->metadata.description.descriptions[i]->language) { if (NULL == mmdb->metadata.description.descriptions[i]->language) {
status = MMDB_OUT_OF_MEMORY_ERROR; status = MMDB_OUT_OF_MEMORY_ERROR;
@@ -831,9 +854,8 @@ static int populate_description_metadata(MMDB_s *mmdb,
goto cleanup; goto cleanup;
} }
mmdb->metadata.description.descriptions[i]->description = mmdb->metadata.description.descriptions[i]->description = mmdb_strndup(
mmdb_strndup((char *)member->entry_data.utf8_string, member->entry_data.utf8_string, member->entry_data.data_size);
member->entry_data.data_size);
if (NULL == mmdb->metadata.description.descriptions[i]->description) { if (NULL == mmdb->metadata.description.descriptions[i]->description) {
status = MMDB_OUT_OF_MEMORY_ERROR; status = MMDB_OUT_OF_MEMORY_ERROR;
@@ -891,22 +913,24 @@ MMDB_lookup_result_s MMDB_lookup_sockaddr(const MMDB_s *const mmdb,
.netmask = 0, .netmask = 0,
.entry = {.mmdb = mmdb, .offset = 0}}; .entry = {.mmdb = mmdb, .offset = 0}};
uint8_t mapped_address[16], *address; uint8_t mapped_address[16];
uint8_t const *address;
if (mmdb->metadata.ip_version == 4) { if (mmdb->metadata.ip_version == 4) {
if (sockaddr->sa_family == AF_INET6) { if (sockaddr->sa_family == AF_INET6) {
*mmdb_error = MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR; *mmdb_error = MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR;
return result; return result;
} }
address = (uint8_t *)&((struct sockaddr_in *)sockaddr)->sin_addr.s_addr; address = (uint8_t const *)&((struct sockaddr_in const *)sockaddr)
->sin_addr.s_addr;
} else { } else {
if (sockaddr->sa_family == AF_INET6) { if (sockaddr->sa_family == AF_INET6) {
address = (uint8_t *)&((struct sockaddr_in6 *)sockaddr) address = (uint8_t const *)&((struct sockaddr_in6 const *)sockaddr)
->sin6_addr.s6_addr; ->sin6_addr.s6_addr;
} else { } else {
address = mapped_address; address = mapped_address;
memset(address, 0, 12); memset(mapped_address, 0, 12);
memcpy(address + 12, memcpy(mapped_address + 12,
&((struct sockaddr_in *)sockaddr)->sin_addr.s_addr, &((struct sockaddr_in const *)sockaddr)->sin_addr.s_addr,
4); 4);
} }
} }
@@ -918,15 +942,15 @@ MMDB_lookup_result_s MMDB_lookup_sockaddr(const MMDB_s *const mmdb,
} }
static int find_address_in_search_tree(const MMDB_s *const mmdb, static int find_address_in_search_tree(const MMDB_s *const mmdb,
uint8_t *address, uint8_t const *address,
sa_family_t address_family, sa_family_t address_family,
MMDB_lookup_result_s *result) { MMDB_lookup_result_s *result) {
record_info_s record_info = record_info_for_database(mmdb); record_info_s record_info = record_info_for_database(mmdb);
if (0 == record_info.right_record_offset) { if (record_info.right_record_offset == 0) {
return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR; return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR;
} }
uint32_t value = 0; uint64_t value = 0;
uint16_t current_bit = 0; uint16_t current_bit = 0;
if (mmdb->metadata.ip_version == 6 && address_family == AF_INET) { if (mmdb->metadata.ip_version == 6 && address_family == AF_INET) {
value = mmdb->ipv4_start_node.node_value; value = mmdb->ipv4_start_node.node_value;
@@ -940,6 +964,7 @@ static int find_address_in_search_tree(const MMDB_s *const mmdb,
uint8_t bit = uint8_t bit =
1U & (address[current_bit >> 3] >> (7 - (current_bit % 8))); 1U & (address[current_bit >> 3] >> (7 - (current_bit % 8)));
// Note that value*record_info.record_length can be larger than 2**32
record_pointer = &search_tree[value * record_info.record_length]; record_pointer = &search_tree[value * record_info.record_length];
if (record_pointer + record_info.record_length > mmdb->data_section) { if (record_pointer + record_info.record_length > mmdb->data_section) {
return MMDB_CORRUPT_SEARCH_TREE_ERROR; return MMDB_CORRUPT_SEARCH_TREE_ERROR;
@@ -986,10 +1011,11 @@ static record_info_s record_info_for_database(const MMDB_s *const mmdb) {
record_info.left_record_getter = &get_uint32; record_info.left_record_getter = &get_uint32;
record_info.right_record_getter = &get_uint32; record_info.right_record_getter = &get_uint32;
record_info.right_record_offset = 4; record_info.right_record_offset = 4;
} else {
assert(false);
} }
// Callers must check that right_record_offset is non-zero in case none of
// the above conditions matched.
return record_info; return record_info;
} }
@@ -1002,6 +1028,9 @@ static int find_ipv4_start_node(MMDB_s *const mmdb) {
} }
record_info_s record_info = record_info_for_database(mmdb); record_info_s record_info = record_info_for_database(mmdb);
if (record_info.right_record_offset == 0) {
return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR;
}
const uint8_t *search_tree = mmdb->file_content; const uint8_t *search_tree = mmdb->file_content;
uint32_t node_value = 0; uint32_t node_value = 0;
@@ -1052,7 +1081,7 @@ static uint8_t record_type(const MMDB_s *const mmdb, uint64_t record) {
static uint32_t get_left_28_bit_record(const uint8_t *record) { static uint32_t get_left_28_bit_record(const uint8_t *record) {
return record[0] * 65536 + record[1] * 256 + record[2] + return record[0] * 65536 + record[1] * 256 + record[2] +
((record[3] & 0xf0) << 20); (uint32_t)((record[3] & 0xf0) << 20);
} }
static uint32_t get_right_28_bit_record(const uint8_t *record) { static uint32_t get_right_28_bit_record(const uint8_t *record) {
@@ -1064,7 +1093,7 @@ int MMDB_read_node(const MMDB_s *const mmdb,
uint32_t node_number, uint32_t node_number,
MMDB_search_node_s *const node) { MMDB_search_node_s *const node) {
record_info_s record_info = record_info_for_database(mmdb); record_info_s record_info = record_info_for_database(mmdb);
if (0 == record_info.right_record_offset) { if (record_info.right_record_offset == 0) {
return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR; return MMDB_UNKNOWN_DATABASE_FORMAT_ERROR;
} }
@@ -1116,13 +1145,13 @@ int MMDB_get_value(MMDB_entry_s *const start,
int MMDB_vget_value(MMDB_entry_s *const start, int MMDB_vget_value(MMDB_entry_s *const start,
MMDB_entry_data_s *const entry_data, MMDB_entry_data_s *const entry_data,
va_list va_path) { va_list va_path) {
int length = path_length(va_path); size_t length = path_length(va_path);
const char *path_elem; const char *path_elem;
int i = 0; int i = 0;
MAYBE_CHECK_SIZE_OVERFLOW(length, if (length == SIZE_MAX) {
SIZE_MAX / sizeof(const char *) - 1, return MMDB_INVALID_METADATA_ERROR;
MMDB_INVALID_METADATA_ERROR); }
const char **path = calloc(length + 1, sizeof(const char *)); const char **path = calloc(length + 1, sizeof(const char *));
if (NULL == path) { if (NULL == path) {
@@ -1137,18 +1166,17 @@ int MMDB_vget_value(MMDB_entry_s *const start,
int status = MMDB_aget_value(start, entry_data, path); int status = MMDB_aget_value(start, entry_data, path);
free((char **)path); free(path);
return status; return status;
} }
static int path_length(va_list va_path) { static size_t path_length(va_list va_path) {
int i = 0; size_t i = 0;
const char *ignore;
va_list path_copy; va_list path_copy;
va_copy(path_copy, va_path); va_copy(path_copy, va_path);
while (NULL != (ignore = va_arg(path_copy, char *))) { while (NULL != va_arg(path_copy, char *)) {
i++; i++;
} }
@@ -1221,7 +1249,7 @@ static int lookup_path_in_array(const char *path_elem,
int saved_errno = errno; int saved_errno = errno;
errno = 0; errno = 0;
int array_index = strtol(path_elem, &first_invalid, 10); long array_index = strtol(path_elem, &first_invalid, 10);
if (ERANGE == errno) { if (ERANGE == errno) {
errno = saved_errno; errno = saved_errno;
return MMDB_INVALID_LOOKUP_PATH_ERROR; return MMDB_INVALID_LOOKUP_PATH_ERROR;
@@ -1236,11 +1264,11 @@ static int lookup_path_in_array(const char *path_elem,
} }
} }
if (*first_invalid || (uint32_t)array_index >= size) { if (*first_invalid || (unsigned long)array_index >= size) {
return MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR; return MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR;
} }
for (int i = 0; i < array_index; i++) { for (long i = 0; i < array_index; i++) {
/* We don't want to follow a pointer here. If the next element is a /* We don't want to follow a pointer here. If the next element is a
* pointer we simply skip it and keep going */ * pointer we simply skip it and keep going */
CHECKED_DECODE_ONE(mmdb, entry_data->offset_to_next, entry_data); CHECKED_DECODE_ONE(mmdb, entry_data->offset_to_next, entry_data);
@@ -1406,7 +1434,7 @@ static int decode_one(const MMDB_s *const mmdb,
DEBUG_MSGF("Extended type: %i (%s)", type, type_num_to_name(type)); DEBUG_MSGF("Extended type: %i (%s)", type, type_num_to_name(type));
} }
entry_data->type = type; entry_data->type = (uint32_t)type;
if (type == MMDB_DATA_TYPE_POINTER) { if (type == MMDB_DATA_TYPE_POINTER) {
uint8_t psize = ((ctrl >> 3) & 3) + 1; uint8_t psize = ((ctrl >> 3) & 3) + 1;
@@ -1462,6 +1490,7 @@ static int decode_one(const MMDB_s *const mmdb,
} }
size = 65821 + get_uint24(&mem[offset]); size = 65821 + get_uint24(&mem[offset]);
offset += 3; offset += 3;
break;
default: default:
break; break;
} }
@@ -1497,28 +1526,28 @@ static int decode_one(const MMDB_s *const mmdb,
DEBUG_MSGF("uint16 of size %d", size); DEBUG_MSGF("uint16 of size %d", size);
return MMDB_INVALID_DATA_ERROR; return MMDB_INVALID_DATA_ERROR;
} }
entry_data->uint16 = (uint16_t)get_uintX(&mem[offset], size); entry_data->uint16 = (uint16_t)get_uintX(&mem[offset], (int)size);
DEBUG_MSGF("uint16 value: %u", entry_data->uint16); DEBUG_MSGF("uint16 value: %u", entry_data->uint16);
} else if (type == MMDB_DATA_TYPE_UINT32) { } else if (type == MMDB_DATA_TYPE_UINT32) {
if (size > 4) { if (size > 4) {
DEBUG_MSGF("uint32 of size %d", size); DEBUG_MSGF("uint32 of size %d", size);
return MMDB_INVALID_DATA_ERROR; return MMDB_INVALID_DATA_ERROR;
} }
entry_data->uint32 = (uint32_t)get_uintX(&mem[offset], size); entry_data->uint32 = (uint32_t)get_uintX(&mem[offset], (int)size);
DEBUG_MSGF("uint32 value: %u", entry_data->uint32); DEBUG_MSGF("uint32 value: %u", entry_data->uint32);
} else if (type == MMDB_DATA_TYPE_INT32) { } else if (type == MMDB_DATA_TYPE_INT32) {
if (size > 4) { if (size > 4) {
DEBUG_MSGF("int32 of size %d", size); DEBUG_MSGF("int32 of size %d", size);
return MMDB_INVALID_DATA_ERROR; return MMDB_INVALID_DATA_ERROR;
} }
entry_data->int32 = get_sintX(&mem[offset], size); entry_data->int32 = get_sintX(&mem[offset], (int)size);
DEBUG_MSGF("int32 value: %i", entry_data->int32); DEBUG_MSGF("int32 value: %i", entry_data->int32);
} else if (type == MMDB_DATA_TYPE_UINT64) { } else if (type == MMDB_DATA_TYPE_UINT64) {
if (size > 8) { if (size > 8) {
DEBUG_MSGF("uint64 of size %d", size); DEBUG_MSGF("uint64 of size %d", size);
return MMDB_INVALID_DATA_ERROR; return MMDB_INVALID_DATA_ERROR;
} }
entry_data->uint64 = get_uintX(&mem[offset], size); entry_data->uint64 = get_uintX(&mem[offset], (int)size);
DEBUG_MSGF("uint64 value: %" PRIu64, entry_data->uint64); DEBUG_MSGF("uint64 value: %" PRIu64, entry_data->uint64);
} else if (type == MMDB_DATA_TYPE_UINT128) { } else if (type == MMDB_DATA_TYPE_UINT128) {
if (size > 16) { if (size > 16) {
@@ -1531,7 +1560,7 @@ static int decode_one(const MMDB_s *const mmdb,
memcpy(entry_data->uint128 + 16 - size, &mem[offset], size); memcpy(entry_data->uint128 + 16 - size, &mem[offset], size);
} }
#else #else
entry_data->uint128 = get_uint128(&mem[offset], size); entry_data->uint128 = get_uint128(&mem[offset], (int)size);
#endif #endif
} else if (type == MMDB_DATA_TYPE_FLOAT) { } else if (type == MMDB_DATA_TYPE_FLOAT) {
if (size != 4) { if (size != 4) {
@@ -1550,7 +1579,7 @@ static int decode_one(const MMDB_s *const mmdb,
entry_data->double_value = get_ieee754_double(&mem[offset]); entry_data->double_value = get_ieee754_double(&mem[offset]);
DEBUG_MSGF("double value: %f", entry_data->double_value); DEBUG_MSGF("double value: %f", entry_data->double_value);
} else if (type == MMDB_DATA_TYPE_UTF8_STRING) { } else if (type == MMDB_DATA_TYPE_UTF8_STRING) {
entry_data->utf8_string = size == 0 ? "" : (char *)&mem[offset]; entry_data->utf8_string = size == 0 ? "" : (char const *)&mem[offset];
entry_data->data_size = size; entry_data->data_size = size;
#ifdef MMDB_DEBUG #ifdef MMDB_DEBUG
char *string = char *string =
@@ -1578,13 +1607,15 @@ get_ptr_from(uint8_t ctrl, uint8_t const *const ptr, int ptr_size) {
uint32_t new_offset; uint32_t new_offset;
switch (ptr_size) { switch (ptr_size) {
case 1: case 1:
new_offset = ((ctrl & 7) << 8) + ptr[0]; new_offset = (uint32_t)((ctrl & 7) << 8) + ptr[0];
break; break;
case 2: case 2:
new_offset = 2048 + ((ctrl & 7) << 16) + (ptr[0] << 8) + ptr[1]; new_offset = 2048 + (uint32_t)((ctrl & 7) << 16) +
(uint32_t)(ptr[0] << 8) + ptr[1];
break; break;
case 3: case 3:
new_offset = 2048 + 524288 + ((ctrl & 7) << 24) + get_uint24(ptr); new_offset =
2048 + 524288 + (uint32_t)((ctrl & 7) << 24) + get_uint24(ptr);
break; break;
case 4: case 4:
default: default:
@@ -1605,6 +1636,8 @@ int MMDB_get_metadata_as_entry_data_list(
int MMDB_get_entry_data_list(MMDB_entry_s *start, int MMDB_get_entry_data_list(MMDB_entry_s *start,
MMDB_entry_data_list_s **const entry_data_list) { MMDB_entry_data_list_s **const entry_data_list) {
*entry_data_list = NULL;
MMDB_data_pool_s *const pool = data_pool_new(MMDB_POOL_INIT_SIZE); MMDB_data_pool_s *const pool = data_pool_new(MMDB_POOL_INIT_SIZE);
if (!pool) { if (!pool) {
return MMDB_OUT_OF_MEMORY_ERROR; return MMDB_OUT_OF_MEMORY_ERROR;
@@ -1618,6 +1651,10 @@ int MMDB_get_entry_data_list(MMDB_entry_s *start,
int const status = int const status =
get_entry_data_list(start->mmdb, start->offset, list, pool, 0); get_entry_data_list(start->mmdb, start->offset, list, pool, 0);
if (MMDB_SUCCESS != status) {
data_pool_destroy(pool);
return status;
}
*entry_data_list = data_pool_to_list(pool); *entry_data_list = data_pool_to_list(pool);
if (!*entry_data_list) { if (!*entry_data_list) {
@@ -1732,7 +1769,7 @@ static int get_entry_data_list(const MMDB_s *const mmdb,
static float get_ieee754_float(const uint8_t *restrict p) { static float get_ieee754_float(const uint8_t *restrict p) {
volatile float f; volatile float f;
uint8_t *q = (void *)&f; volatile uint8_t *q = (volatile void *)&f;
/* Windows builds don't use autoconf but we can assume they're all /* Windows builds don't use autoconf but we can assume they're all
* little-endian. */ * little-endian. */
#if MMDB_LITTLE_ENDIAN || _WIN32 #if MMDB_LITTLE_ENDIAN || _WIN32
@@ -1748,7 +1785,7 @@ static float get_ieee754_float(const uint8_t *restrict p) {
static double get_ieee754_double(const uint8_t *restrict p) { static double get_ieee754_double(const uint8_t *restrict p) {
volatile double d; volatile double d;
uint8_t *q = (void *)&d; volatile uint8_t *q = (volatile void *)&d;
#if MMDB_LITTLE_ENDIAN || _WIN32 #if MMDB_LITTLE_ENDIAN || _WIN32
q[7] = p[0]; q[7] = p[0];
q[6] = p[1]; q[6] = p[1];
@@ -1803,7 +1840,16 @@ static void free_mmdb_struct(MMDB_s *const mmdb) {
} }
if (NULL != mmdb->filename) { if (NULL != mmdb->filename) {
#if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
FREE_AND_SET_NULL(mmdb->filename); FREE_AND_SET_NULL(mmdb->filename);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} }
if (NULL != mmdb->file_content) { if (NULL != mmdb->file_content) {
#ifdef _WIN32 #ifdef _WIN32
@@ -1812,12 +1858,30 @@ static void free_mmdb_struct(MMDB_s *const mmdb) {
* to cleanup then. */ * to cleanup then. */
WSACleanup(); WSACleanup();
#else #else
munmap((void *)mmdb->file_content, mmdb->file_size); #if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
munmap((void *)mmdb->file_content, (size_t)mmdb->file_size);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif #endif
} }
if (NULL != mmdb->metadata.database_type) { if (NULL != mmdb->metadata.database_type) {
#if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
FREE_AND_SET_NULL(mmdb->metadata.database_type); FREE_AND_SET_NULL(mmdb->metadata.database_type);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} }
free_languages_metadata(mmdb); free_languages_metadata(mmdb);
@@ -1830,7 +1894,16 @@ static void free_languages_metadata(MMDB_s *mmdb) {
} }
for (size_t i = 0; i < mmdb->metadata.languages.count; i++) { for (size_t i = 0; i < mmdb->metadata.languages.count; i++) {
#if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
FREE_AND_SET_NULL(mmdb->metadata.languages.names[i]); FREE_AND_SET_NULL(mmdb->metadata.languages.names[i]);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} }
FREE_AND_SET_NULL(mmdb->metadata.languages.names); FREE_AND_SET_NULL(mmdb->metadata.languages.names);
} }
@@ -1843,14 +1916,32 @@ static void free_descriptions_metadata(MMDB_s *mmdb) {
for (size_t i = 0; i < mmdb->metadata.description.count; i++) { for (size_t i = 0; i < mmdb->metadata.description.count; i++) {
if (NULL != mmdb->metadata.description.descriptions[i]) { if (NULL != mmdb->metadata.description.descriptions[i]) {
if (NULL != mmdb->metadata.description.descriptions[i]->language) { if (NULL != mmdb->metadata.description.descriptions[i]->language) {
#if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
FREE_AND_SET_NULL( FREE_AND_SET_NULL(
mmdb->metadata.description.descriptions[i]->language); mmdb->metadata.description.descriptions[i]->language);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} }
if (NULL != if (NULL !=
mmdb->metadata.description.descriptions[i]->description) { mmdb->metadata.description.descriptions[i]->description) {
#if defined(__clang__)
// This is a const char * that we need to free, which isn't valid. However it
// would mean changing the public API to fix this.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
FREE_AND_SET_NULL( FREE_AND_SET_NULL(
mmdb->metadata.description.descriptions[i]->description); mmdb->metadata.description.descriptions[i]->description);
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} }
FREE_AND_SET_NULL(mmdb->metadata.description.descriptions[i]); FREE_AND_SET_NULL(mmdb->metadata.description.descriptions[i]);
} }
@@ -1891,8 +1982,8 @@ dump_entry_data_list(FILE *stream,
*status = MMDB_INVALID_DATA_ERROR; *status = MMDB_INVALID_DATA_ERROR;
return NULL; return NULL;
} }
char *key = mmdb_strndup( char *key =
(char *)entry_data_list->entry_data.utf8_string, mmdb_strndup(entry_data_list->entry_data.utf8_string,
entry_data_list->entry_data.data_size); entry_data_list->entry_data.data_size);
if (NULL == key) { if (NULL == key) {
*status = MMDB_OUT_OF_MEMORY_ERROR; *status = MMDB_OUT_OF_MEMORY_ERROR;
@@ -1938,8 +2029,7 @@ dump_entry_data_list(FILE *stream,
fprintf(stream, "]\n"); fprintf(stream, "]\n");
} break; } break;
case MMDB_DATA_TYPE_UTF8_STRING: { case MMDB_DATA_TYPE_UTF8_STRING: {
char *string = char *string = mmdb_strndup(entry_data_list->entry_data.utf8_string,
mmdb_strndup((char *)entry_data_list->entry_data.utf8_string,
entry_data_list->entry_data.data_size); entry_data_list->entry_data.data_size);
if (NULL == string) { if (NULL == string) {
*status = MMDB_OUT_OF_MEMORY_ERROR; *status = MMDB_OUT_OF_MEMORY_ERROR;
@@ -1952,7 +2042,7 @@ dump_entry_data_list(FILE *stream,
} break; } break;
case MMDB_DATA_TYPE_BYTES: { case MMDB_DATA_TYPE_BYTES: {
char *hex_string = char *hex_string =
bytes_to_hex((uint8_t *)entry_data_list->entry_data.bytes, bytes_to_hex(entry_data_list->entry_data.bytes,
entry_data_list->entry_data.data_size); entry_data_list->entry_data.data_size);
if (NULL == hex_string) { if (NULL == hex_string) {
@@ -2044,12 +2134,12 @@ dump_entry_data_list(FILE *stream,
static void print_indentation(FILE *stream, int i) { static void print_indentation(FILE *stream, int i) {
char buffer[1024]; char buffer[1024];
int size = i >= 1024 ? 1023 : i; int size = i >= 1024 ? 1023 : i;
memset(buffer, 32, size); memset(buffer, 32, (size_t)size);
buffer[size] = '\0'; buffer[size] = '\0';
fputs(buffer, stream); fputs(buffer, stream);
} }
static char *bytes_to_hex(uint8_t *bytes, uint32_t size) { static char *bytes_to_hex(uint8_t const *bytes, uint32_t size) {
char *hex_string; char *hex_string;
MAYBE_CHECK_SIZE_OVERFLOW(size, SIZE_MAX / 2 - 1, NULL); MAYBE_CHECK_SIZE_OVERFLOW(size, SIZE_MAX / 2 - 1, NULL);

View File

@@ -29,10 +29,18 @@ if(UNIX) # or if (NOT WIN32)
find_package(Threads) find_package(Threads)
endif() endif()
if(WIN32)
# 4244, 4267 - libtap causes a significant number of conversion warning in
# our tests on Windows.
# 4996 - vsprintf used by libtap is unsafe.
add_definitions("/wd4244 /wd4267 /wd4996")
endif(WIN32)
foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES}) foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
add_executable(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}.c maxminddb_test_helper.c) add_executable(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}.c maxminddb_test_helper.c)
target_include_directories(${TEST_TARGET_NAME} PRIVATE ../src) target_include_directories(${TEST_TARGET_NAME} PRIVATE ../src)
target_link_libraries(${TEST_TARGET_NAME} maxminddb tap) target_link_libraries(${TEST_TARGET_NAME} maxminddb tap)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE PACKAGE_VERSION="${PROJECT_VERSION}")
if(UNIX) if(UNIX)
target_link_libraries(${TEST_TARGET_NAME} m) target_link_libraries(${TEST_TARGET_NAME} m)
@@ -42,5 +50,11 @@ foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
target_link_libraries(${TEST_TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${TEST_TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME}) add_test( NAME ${TEST_TARGET_NAME} COMMAND ${TEST_TARGET_NAME} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/t)
endforeach() endforeach()
if(BUILD_FUZZING)
add_executable(fuzz_mmdb fuzz_mmdb.c)
target_include_directories(fuzz_mmdb PRIVATE ../src)
target_link_libraries(fuzz_mmdb maxminddb $ENV{LIB_FUZZING_ENGINE})
endif()

View File

@@ -2,9 +2,9 @@
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-broken-pointers-24.mmdb"; const char *filename = "MaxMind-DB-test-broken-pointers-24.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
{ {
const char *ip = "1.1.1.16"; const char *ip = "1.1.1.16";
@@ -29,6 +29,9 @@ void run_tests(int mode, const char *mode_desc) {
"MMDB_get_entry_data_list returns MMDB_INVALID_DATA_ERROR for " "MMDB_get_entry_data_list returns MMDB_INVALID_DATA_ERROR for "
"bad pointer in data section"); "bad pointer in data section");
// This is not necessary as on error we should not need to free
// anything. However test that it is safe to do so. See change in
// 1.12.2.
MMDB_free_entry_data_list(entry_data_list); MMDB_free_entry_data_list(entry_data_list);
} }
@@ -36,7 +39,6 @@ void run_tests(int mode, const char *mode_desc) {
const char *ip = "1.1.1.32"; const char *ip = "1.1.1.32";
int gai_error, mmdb_error; int gai_error, mmdb_error;
MMDB_lookup_result_s UNUSED(result) =
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
cmp_ok(mmdb_error, cmp_ok(mmdb_error,

View File

@@ -36,7 +36,7 @@ void test_one_result(MMDB_s *mmdb,
} else { } else {
// When looking up IPv4 addresses in a mixed DB the result will be // When looking up IPv4 addresses in a mixed DB the result will be
// something like "::1.2.3.4", not just "1.2.3.4". // something like "::1.2.3.4", not just "1.2.3.4".
int maxlen = strlen(expect) + 3; size_t maxlen = strlen(expect) + 3;
real_expect = malloc(maxlen); real_expect = malloc(maxlen);
if (!real_expect) { if (!real_expect) {
BAIL_OUT("could not allocate memory"); BAIL_OUT("could not allocate memory");
@@ -77,12 +77,12 @@ void run_ipX_tests(const char *filename,
int missing_ips_length, int missing_ips_length,
const char *pairs[][2], const char *pairs[][2],
int pairs_rows) { int pairs_rows) {
const char *path = test_database_path(filename); char *path = test_database_path(filename);
int mode = Current_Mode; int mode = Current_Mode;
const char *mode_desc = Current_Mode_Description; const char *mode_desc = Current_Mode_Description;
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
char desc_suffix[500]; char desc_suffix[500];
snprintf(desc_suffix, 500, "%s - %s", filename, mode_desc); snprintf(desc_suffix, 500, "%s - %s", filename, mode_desc);
@@ -180,12 +180,12 @@ void all_record_sizes(int mode, const char *description) {
static void test_big_lookup(void) { static void test_big_lookup(void) {
const char *const db_filename = "GeoIP2-Precision-Enterprise-Test.mmdb"; const char *const db_filename = "GeoIP2-Precision-Enterprise-Test.mmdb";
const char *const db_path = test_database_path(db_filename); char *db_path = test_database_path(db_filename);
ok(db_path != NULL, "got database path"); ok(db_path != NULL, "got database path");
MMDB_s *const mmdb = open_ok(db_path, MMDB_MODE_MMAP, "mmap mode"); MMDB_s *const mmdb = open_ok(db_path, MMDB_MODE_MMAP, "mmap mode");
ok(mmdb != NULL, "opened MMDB"); ok(mmdb != NULL, "opened MMDB");
free((char *)db_path); free(db_path);
int gai_err = 0, mmdb_err = 0; int gai_err = 0, mmdb_err = 0;
const char *const ip_address = "81.2.69.160"; const char *const ip_address = "81.2.69.160";

View File

@@ -28,7 +28,11 @@ int main(int argc, char *argv[])
{ {
const char *fname = "$test_db"; const char *fname = "$test_db";
MMDB_s mmdb; MMDB_s mmdb;
return MMDB_open(fname, MMDB_MODE_MMAP, &mmdb); if (MMDB_open(fname, MMDB_MODE_MMAP, &mmdb) != MMDB_SUCCESS) {
return 1;
}
MMDB_close(&mmdb);
return 0;
} }
EOF EOF
@@ -45,8 +49,17 @@ my $include_dir = abs_path("$Bin/../include");
my $lib_dir = abs_path("$Bin/../src/.libs"); my $lib_dir = abs_path("$Bin/../src/.libs");
my $cxx = $ENV{CXX} || 'c++'; my $cxx = $ENV{CXX} || 'c++';
my @cxxflags = $ENV{CXXFLAGS} ? ( split ' ', $ENV{CXXFLAGS} ) : ();
_test_cmd( _test_cmd(
[ $cxx, $file, "-I$include_dir", "-L$lib_dir", "-lmaxminddb", "-o$exe" ], [
$cxx,
$file,
@cxxflags,
"-I$include_dir",
"-L$lib_dir",
"-lmaxminddb",
"-o$exe",
],
qr/^$/, qr/^$/,
q{}, q{},
0, 0,

View File

@@ -43,7 +43,9 @@ static void test_data_pool_new(void) {
} }
static void test_data_pool_destroy(void) { static void test_data_pool_destroy(void) {
{ data_pool_destroy(NULL); } {
data_pool_destroy(NULL);
}
{ {
MMDB_data_pool_s *const pool = data_pool_new(512); MMDB_data_pool_s *const pool = data_pool_new(512);

View File

@@ -161,7 +161,7 @@ test_mapX_key_value_pair(MMDB_entry_data_list_s *entry_data_list) {
"==", "==",
MMDB_DATA_TYPE_UTF8_STRING, MMDB_DATA_TYPE_UTF8_STRING,
"found a map key in 'map{mapX}'"); "found a map key in 'map{mapX}'");
const char *mapX_key_name = dup_entry_string_or_bail(mapX_key->entry_data); char *mapX_key_name = dup_entry_string_or_bail(mapX_key->entry_data);
if (strcmp(mapX_key_name, "utf8_stringX") == 0) { if (strcmp(mapX_key_name, "utf8_stringX") == 0) {
MMDB_entry_data_list_s *mapX_value = entry_data_list = MMDB_entry_data_list_s *mapX_value = entry_data_list =
@@ -170,18 +170,18 @@ test_mapX_key_value_pair(MMDB_entry_data_list_s *entry_data_list) {
"==", "==",
MMDB_DATA_TYPE_UTF8_STRING, MMDB_DATA_TYPE_UTF8_STRING,
"'map{mapX}{utf8_stringX}' type is utf8_string"); "'map{mapX}{utf8_stringX}' type is utf8_string");
const char *utf8_stringX_value = char *utf8_stringX_value =
dup_entry_string_or_bail(mapX_value->entry_data); dup_entry_string_or_bail(mapX_value->entry_data);
ok(strcmp(utf8_stringX_value, "hello") == 0, ok(strcmp(utf8_stringX_value, "hello") == 0,
"map{mapX}{utf8_stringX} value is 'hello'"); "map{mapX}{utf8_stringX} value is 'hello'");
free((void *)utf8_stringX_value); free(utf8_stringX_value);
} else if (strcmp(mapX_key_name, "arrayX") == 0) { } else if (strcmp(mapX_key_name, "arrayX") == 0) {
entry_data_list = test_arrayX_value(entry_data_list); entry_data_list = test_arrayX_value(entry_data_list);
} else { } else {
ok(0, "unknown key found in map{mapX} - %s", mapX_key_name); ok(0, "unknown key found in map{mapX} - %s", mapX_key_name);
} }
free((void *)mapX_key_name); free(mapX_key_name);
return entry_data_list; return entry_data_list;
} }
@@ -203,10 +203,9 @@ test_map_value(MMDB_entry_data_list_s *entry_data_list) {
"==", "==",
MMDB_DATA_TYPE_UTF8_STRING, MMDB_DATA_TYPE_UTF8_STRING,
"found a map key in 'map'"); "found a map key in 'map'");
const char *map_key_1_name = char *map_key_1_name = dup_entry_string_or_bail(map_key_1->entry_data);
dup_entry_string_or_bail(map_key_1->entry_data);
ok(strcmp(map_key_1_name, "mapX") == 0, "key name is mapX"); ok(strcmp(map_key_1_name, "mapX") == 0, "key name is mapX");
free((void *)map_key_1_name); free(map_key_1_name);
MMDB_entry_data_list_s *mapX = entry_data_list = entry_data_list->next; MMDB_entry_data_list_s *mapX = entry_data_list = entry_data_list->next;
cmp_ok(mapX->entry_data.type, cmp_ok(mapX->entry_data.type,
@@ -312,7 +311,7 @@ test_utf8_string_value(MMDB_entry_data_list_s *entry_data_list) {
"==", "==",
MMDB_DATA_TYPE_UTF8_STRING, MMDB_DATA_TYPE_UTF8_STRING,
"'utf8_string' key's value is a string"); "'utf8_string' key's value is a string");
const char *utf8_string = dup_entry_string_or_bail(value->entry_data); char *utf8_string = dup_entry_string_or_bail(value->entry_data);
// This is hex for "unicode! ☯ - ♫" as bytes // This is hex for "unicode! ☯ - ♫" as bytes
char expect[19] = {0x75, char expect[19] = {0x75,
0x6e, 0x6e,
@@ -323,29 +322,29 @@ test_utf8_string_value(MMDB_entry_data_list_s *entry_data_list) {
0x65, 0x65,
0x21, 0x21,
0x20, 0x20,
0xe2, (char)0xe2,
0x98, (char)0x98,
0xaf, (char)0xaf,
0x20, 0x20,
0x2d, 0x2d,
0x20, 0x20,
0xe2, (char)0xe2,
0x99, (char)0x99,
0xab, (char)0xab,
0x00}; 0x00};
is(utf8_string, expect, "got expected value for utf8_string key"); is(utf8_string, expect, "got expected value for utf8_string key");
free((void *)utf8_string); free(utf8_string);
return entry_data_list; return entry_data_list;
} }
void run_tests(int mode, const char *description) { void run_tests(int mode, const char *description) {
const char *filename = "MaxMind-DB-test-decoder.mmdb"; const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, description); MMDB_s *mmdb = open_ok(path, mode, description);
free((void *)path); free(path);
char *ip = "1.1.1.1"; char *ip = "1.1.1.1";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =
@@ -385,7 +384,7 @@ void run_tests(int mode, const char *description) {
MMDB_DATA_TYPE_UTF8_STRING, MMDB_DATA_TYPE_UTF8_STRING,
"found a map key"); "found a map key");
const char *key_name = dup_entry_string_or_bail(key->entry_data); char *key_name = dup_entry_string_or_bail(key->entry_data);
if (strcmp(key_name, "array") == 0) { if (strcmp(key_name, "array") == 0) {
entry_data_list = test_array_value(entry_data_list); entry_data_list = test_array_value(entry_data_list);
} else if (strcmp(key_name, "boolean") == 0) { } else if (strcmp(key_name, "boolean") == 0) {
@@ -414,7 +413,7 @@ void run_tests(int mode, const char *description) {
ok(0, "unknown key found in map - %s", key_name); ok(0, "unknown key found in map - %s", key_name);
} }
free((void *)key_name); free(key_name);
} }
MMDB_free_entry_data_list(first); MMDB_free_entry_data_list(first);

View File

@@ -14,7 +14,7 @@ void test_all_data_types(MMDB_lookup_result_s *result,
description, description,
"utf8_string", "utf8_string",
NULL); NULL);
const char *string = mmdb_strndup(data.utf8_string, data.data_size); char *string = mmdb_strndup(data.utf8_string, data.data_size);
// This is hex for "unicode! ☯ - ♫" as bytes // This is hex for "unicode! ☯ - ♫" as bytes
char expect[19] = {0x75, char expect[19] = {0x75,
0x6e, 0x6e,
@@ -25,19 +25,19 @@ void test_all_data_types(MMDB_lookup_result_s *result,
0x65, 0x65,
0x21, 0x21,
0x20, 0x20,
0xe2, (char)0xe2,
0x98, (char)0x98,
0xaf, (char)0xaf,
0x20, 0x20,
0x2d, 0x2d,
0x20, 0x20,
0xe2, (char)0xe2,
0x99, (char)0x99,
0xab, (char)0xab,
0x00}; 0x00};
is(string, expect, "got expected utf8_string value"); is(string, expect, "got expected utf8_string value");
free((char *)string); free(string);
} }
{ {
@@ -67,7 +67,7 @@ void test_all_data_types(MMDB_lookup_result_s *result,
MMDB_entry_data_s data = MMDB_entry_data_s data =
data_ok(result, MMDB_DATA_TYPE_BYTES, description, "bytes", NULL); data_ok(result, MMDB_DATA_TYPE_BYTES, description, "bytes", NULL);
uint8_t expect[] = {0x00, 0x00, 0x00, 0x2a}; uint8_t expect[] = {0x00, 0x00, 0x00, 0x2a};
ok(memcmp((uint8_t *)data.bytes, expect, 4) == 0, ok(memcmp(data.bytes, expect, 4) == 0,
"bytes field has expected value"); "bytes field has expected value");
} }
@@ -204,9 +204,9 @@ void test_all_data_types(MMDB_lookup_result_s *result,
"mapX", "mapX",
"utf8_stringX", "utf8_stringX",
NULL); NULL);
const char *string = mmdb_strndup(data.utf8_string, data.data_size); char *string = mmdb_strndup(data.utf8_string, data.data_size);
is(string, "hello", "map{mapX}{utf8_stringX} is 'hello'"); is(string, "hello", "map{mapX}{utf8_stringX} is 'hello'");
free((char *)string); free(string);
snprintf( snprintf(
description, 500, "map{mapX}{arrayX} for %s - %s", ip, mode_desc); description, 500, "map{mapX}{arrayX} for %s - %s", ip, mode_desc);
@@ -417,7 +417,7 @@ void test_all_data_types_as_zero(MMDB_lookup_result_s *result,
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-decoder.mmdb"; const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
// All of the remaining tests require an open mmdb // All of the remaining tests require an open mmdb
@@ -426,7 +426,7 @@ void run_tests(int mode, const char *mode_desc) {
return; return;
} }
free((void *)path); free(path);
{ {
const char *ip = "not an ip"; const char *ip = "not an ip";

View File

@@ -1,12 +1,13 @@
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#include "maxminddb_test_helper.h" #include "maxminddb_test_helper.h"
#ifdef HAVE_OPEN_MEMSTREAM #ifdef HAVE_OPEN_MEMSTREAM
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-decoder.mmdb"; const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
const char *ip = "1.1.1.1"; const char *ip = "1.1.1.1";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =

View File

@@ -5,12 +5,20 @@ use warnings;
use FindBin qw( $Bin ); use FindBin qw( $Bin );
_skip_tests_if_not_linux();
_skip_tests_if_required_modules_are_not_present(); _skip_tests_if_required_modules_are_not_present();
_skip_tests_if_nm_is_not_present(); _skip_tests_if_nm_is_not_present();
_test_libs_external_symbols(); _test_libs_external_symbols();
done_testing(); done_testing();
sub _skip_tests_if_not_linux {
return if $^O eq 'linux';
print "1..0 # skip all tests skipped - this test requires Linux.\n";
exit 0;
}
sub _skip_tests_if_required_modules_are_not_present { sub _skip_tests_if_required_modules_are_not_present {
eval <<'EOF'; eval <<'EOF';
use Test::More 0.88; use Test::More 0.88;

34
vendor/MaxmindDB/t/fuzz_mmdb.c vendored Normal file
View File

@@ -0,0 +1,34 @@
#include "maxminddb-compat-util.h"
#include "maxminddb.h"
#include <unistd.h>
#define kMinInputLength 2
#define kMaxInputLength 4048
extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
int status;
FILE *fp;
MMDB_s mmdb;
char filename[256];
if (size < kMinInputLength || size > kMaxInputLength)
return 0;
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
fp = fopen(filename, "wb");
if (!fp)
return 0;
fwrite(data, size, sizeof(uint8_t), fp);
fclose(fp);
status = MMDB_open(filename, MMDB_MODE_MMAP, &mmdb);
if (status == MMDB_SUCCESS)
MMDB_close(&mmdb);
unlink(filename);
return 0;
}

View File

@@ -47,9 +47,9 @@ void test_one_ip(MMDB_s *mmdb,
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "GeoIP2-City-Test.mmdb"; const char *filename = "GeoIP2-City-Test.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
/* This exercises a bug where the entire top-level value is a pointer to /* This exercises a bug where the entire top-level value is a pointer to
* another part of the data section. */ * another part of the data section. */

View File

@@ -77,9 +77,9 @@ int call_vget_value(MMDB_entry_s *entry, MMDB_entry_data_s *entry_data, ...) {
void test_simple_structure(int mode, const char *mode_desc) { void test_simple_structure(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-decoder.mmdb"; const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
const char *ip = "1.1.1.1"; const char *ip = "1.1.1.1";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =
@@ -242,9 +242,9 @@ void test_no_result(int status,
void test_nested_structure(int mode, const char *mode_desc) { void test_nested_structure(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-nested.mmdb"; const char *filename = "MaxMind-DB-test-nested.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
const char *ip = "1.1.1.1"; const char *ip = "1.1.1.1";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =

View File

@@ -18,9 +18,9 @@ void test_one_ip(MMDB_s *mmdb,
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-no-ipv4-search-tree.mmdb"; const char *filename = "MaxMind-DB-no-ipv4-search-tree.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
test_one_ip(mmdb, "1.1.1.1", filename, mode_desc); test_one_ip(mmdb, "1.1.1.1", filename, mode_desc);
test_one_ip(mmdb, "255.255.255.255", filename, mode_desc); test_one_ip(mmdb, "255.255.255.255", filename, mode_desc);

View File

@@ -2,13 +2,12 @@
void run_tests(int mode, const char *mode_desc) { void run_tests(int mode, const char *mode_desc) {
const char *filename = "MaxMind-DB-test-ipv4-28.mmdb"; const char *filename = "MaxMind-DB-test-ipv4-28.mmdb";
const char *path = test_database_path(filename); char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free(path);
const char *ip = "::abcd"; const char *ip = "::abcd";
int gai_error, mmdb_error; int gai_error, mmdb_error;
MMDB_lookup_result_s UNUSED(result) =
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error); MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
cmp_ok(mmdb_error, cmp_ok(mmdb_error,

Some files were not shown because too many files have changed in this diff Show More