Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from measurement-kit/release/v0.2.0
Browse files Browse the repository at this point in the history
Release v0.2.0
  • Loading branch information
bassosimone committed Nov 2, 2018
2 parents 5fed6f2 + a49296c commit 4ec22a2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ environment:
- CMAKE_GENERATOR: "Visual Studio 15 2017"
build_script:
- cmd: git submodule update --init --recursive
- cmd: .\.ci\common\script\appveyor.bat "%CMAKE_GENERATOR%"
- cmd: cmake -G "%CMAKE_GENERATOR%"
- cmd: cmake --build . -- /nologo /property:Configuration=Release
- cmd: ctest --output-on-failure -C Release -a
2 changes: 1 addition & 1 deletion .ci/common
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ if (("${MKMMDB_HAVE_MAXMINDDB_H}" STREQUAL "") OR
endif()
list(APPEND MKMMDB_LIBS "${LIBMAXMINDDB_LIBRARY}")

find_package(CURL REQUIRED)

# Compiler flags
# --------------

Expand All @@ -39,19 +37,22 @@ MkSetCompilerFlags()
# ------------------

set(MKMMDB_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CURL_INCLUDE_DIRS} ${CMAKE_REQUIRED_INCLUDES})
${CMAKE_REQUIRED_INCLUDES})

include_directories(${MKMMDB_INCLUDES})

add_library(mkmmdb mkmmdb.cpp)
add_executable(mkmmdb-client mkmmdb-client.cpp)
target_include_directories(mkmmdb-client PUBLIC ${MKMMDB_INCLUDES})
if("${WIN32}" OR "${MINGW}")
list(APPEND MKMMDB_LIBS "ws2_32")
if ("${MINGW}")
list(APPEND MKMMDB_LIBS -static-libgcc -static-libstdc++)
endif()
endif()
list(APPEND MKMMDB_LIBS Threads::Threads)
target_link_libraries(mkmmdb-client "${MKMMDB_LIBS}" mkmmdb)
link_libraries("${MKMMDB_LIBS}")

add_library(mkmmdb mkmmdb.cpp)
add_executable(mkmmdb-client mkmmdb-client.cpp)
target_link_libraries(mkmmdb-client mkmmdb)

# Testing
# -------
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules
Submodule Modules updated 2 files
+20 −4 MkUtils.cmake
+14 −0 README.md
4 changes: 2 additions & 2 deletions mkmmdb-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char **argv) {
}
std::string ip = argv[1];
{
mkmmdb_uptr db{mkmmdb_open("country.mmdb")};
mkmmdb_uptr db{mkmmdb_open_nonnull("country.mmdb")};
if (!mkmmdb_good(db.get())) {
std::clog << "Cannot open country.mmdb" << std::endl;
// FALLTHROUGH
Expand All @@ -24,7 +24,7 @@ int main(int argc, char **argv) {
std::clog << "CC: " << s << std::endl;
}
{
mkmmdb_uptr db{mkmmdb_open("asn.mmdb")};
mkmmdb_uptr db{mkmmdb_open_nonnull("asn.mmdb")};
if (!mkmmdb_good(db.get())) {
std::clog << "Cannot open asn.mmdb" << std::endl;
// FALLTHROUGH
Expand Down
22 changes: 11 additions & 11 deletions mkmmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ extern "C" {
/// mkmmdb_t is a MMDB database.
typedef struct mkmmdb mkmmdb_t;

/// mkmmdb_open opens a database pointing to @p path. It always returns a
/// valid pointer. Call mkmmdb_good to understand whether the database was
/// successfully openned or not. This function will call std::abort when
/// mkmmdb_open_nonnull opens a database pointing to @p path. It always returns
/// a valid pointer. Call mkmmdb_good to understand whether the database was
/// successfully openned or not. This function will call abort when
/// the @p path argument is a null pointer.
mkmmdb_t *mkmmdb_open(const char *path);
mkmmdb_t *mkmmdb_open_nonnull(const char *path);

/// mkmmdb_good returns true if the database has been successfully open
/// and false otherwise. This function aborts if @p mmdb is null.
Expand All @@ -28,24 +28,24 @@ int64_t mkmmdb_good(mkmmdb_t *mmdb);
/// @p mmdb database, or the empty string on failure. The returned string
/// will be valid until @p mmdb is valid _and_ you don't call other
/// functions using the same @p mmdb instance. This function calls
/// std::abort if passed null parameters.
/// abort if passed null parameters.
const char *mkmmdb_lookup_cc(mkmmdb_t *mmdb, const char *ip);

/// mkmmdb_lookup_asn is like mkmmdb_lookup_cc but returns
/// the ASN on success and zero on failure. Also this function
/// calls std::abort if passed null parameters.
/// calls abort if passed null parameters.
int64_t mkmmdb_lookup_asn(mkmmdb_t *mmdb, const char *ip);

/// mkmmdb_lookup_org is like mkmmdb_lookup_cc but returns
/// the organization bound to @p ip on success, the empty string on
/// failure. The returned string will be valid until @p mmdb is
/// valid _and_ you don't call other lookup APIs using the
/// same @p mmdb instance. This function calls std::abort if
/// same @p mmdb instance. This function calls abort if
/// passed a null @p mmdb or a null @p ip.
const char *mkmmdb_lookup_org(mkmmdb_t *mmdb, const char *ip);

/// mkmmdb_get_last_lookup_logs returns the logs of the last lookup
/// or an empty string. Calls std::abort if @p mmdb is null.
/// or an empty string. Calls abort if @p mmdb is null.
const char *mkmmdb_get_last_lookup_logs(mkmmdb_t *mmdb);

/// mkmmdb_close closes @p mmdb. Note that @p mmdb MAY be null.
Expand Down Expand Up @@ -109,11 +109,11 @@ struct mkmmdb {
#endif

#ifndef MKMMDB_ABORT
// MKMMDB_ABORT allows to mock std::abort
#define MKMMDB_ABORT std::abort
// MKMMDB_ABORT allows to mock abort
#define MKMMDB_ABORT abort
#endif

mkmmdb_t *mkmmdb_open(const char *path) {
mkmmdb_t *mkmmdb_open_nonnull(const char *path) {
if (path == nullptr) {
MKMMDB_ABORT();
}
Expand Down

0 comments on commit 4ec22a2

Please sign in to comment.