diff --git a/.gitmodules b/.gitmodules index 728623d..a94fcb4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "third_party/commonpp"] path = third_party/commonpp - url = https://github.com/daedric/commonpp.git + url = https://github.com/0x7f/commonpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index bd4ce2c..99a06de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) #CMAKE_POLICY(SET CMP0005 NEW) +# Require at least Windows 7 +# See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx +if(WIN32) + add_definitions(-D_WIN32_WINNT=0x0601) + add_definitions(-DNTDDI_VERSION=0x06010000) +endif() + # Set a default build type if none was specified if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) MESSAGE(STATUS "Setting cmake build type to 'Release' as none was specified.") @@ -198,12 +205,19 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIR}) FIND_PACKAGE(CURL REQUIRED) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${HWLOC_INCLUDE_DIR}) +include_directories(${TBB_INCLUDE_DIRS}) +link_directories(${TBB_LIBRARY_DIRS}) +link_directories(${TBB_DEBUG_LIBRARY_DIRS}) + SET(HTTPP_DEPS ${commonpp_LIBRARIES} ${Boost_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${OPENSSL_LIBRARIES}) + ${OPENSSL_LIBRARIES} + ${HWLOC_PROCESS_LIBS} + ${TBB_LIBRARIES}) IF (UNIX AND NOT APPLE) SET (HTTPP_DEPS ${HTTPP_DEPS} rt) diff --git a/include/httpp/http/Connection.hpp b/include/httpp/http/Connection.hpp index 8c790b5..fb300f4 100644 --- a/include/httpp/http/Connection.hpp +++ b/include/httpp/http/Connection.hpp @@ -88,7 +88,7 @@ class Connection size_t offset = 0; - if (not body_buffer_.empty()) + if (!body_buffer_.empty()) { if (size <= body_buffer_.size()) { @@ -134,7 +134,7 @@ class Connection throw std::logic_error("Invalid connection state"); } - if (not body_buffer_.empty()) + if (!body_buffer_.empty()) { if (body_size <= body_buffer_.size()) { diff --git a/include/httpp/utils/SortedVectorKP.hpp b/include/httpp/utils/SortedVectorKP.hpp index b6685e0..45209df 100644 --- a/include/httpp/utils/SortedVectorKP.hpp +++ b/include/httpp/utils/SortedVectorKP.hpp @@ -31,7 +31,13 @@ struct case_insensitive } else if (left.size() == right.size()) { +#ifdef WIN32 +# define strncasecmp(x, y, z) _strnicmp(x, y, z) +#endif return ::strncasecmp(left.data(), right.data(), left.size()) < 0; +#ifdef WIN32 +# undef strncasecmp +#endif } else { diff --git a/src/httpp/HttpServer.cpp b/src/httpp/HttpServer.cpp index e801c83..041332f 100644 --- a/src/httpp/HttpServer.cpp +++ b/src/httpp/HttpServer.cpp @@ -161,7 +161,7 @@ void HttpServer::stop() void HttpServer::bind(const std::string& address, const std::string& port) { - if (not running_) + if (!running_) { throw std::logic_error( "Http server must be started before bind is called"); @@ -179,7 +179,7 @@ void HttpServer::bind(const std::string& address, SSLContext ctx, const std::string& port) { - if (not running_) + if (!running_) { throw std::logic_error( "Http server must be started before bind is called"); diff --git a/src/httpp/http/Connection.cpp b/src/httpp/http/Connection.cpp index e847cc6..e6aceb9 100644 --- a/src/httpp/http/Connection.cpp +++ b/src/httpp/http/Connection.cpp @@ -151,7 +151,7 @@ void Connection::start() // Maybe we have the beginning of the next request in the // body_buffer_ - if (not body_buffer_.empty()) + if (!body_buffer_.empty()) { request_buffer_.swap(body_buffer_); size_ = request_buffer_.size(); diff --git a/src/httpp/http/Protocol.cpp b/src/httpp/http/Protocol.cpp index a01eea5..0718f5e 100644 --- a/src/httpp/http/Protocol.cpp +++ b/src/httpp/http/Protocol.cpp @@ -66,10 +66,13 @@ Method method_from(const std::string& str) Method method_from(const char* str) { +#ifdef WIN32 +#define my_strlen ::strlen +#else #define my_strlen(str) \ (__extension__(__builtin_constant_p(str) ? __builtin_strlen(str) \ : ::strlen(str))) - +#endif #define fn(name, e) \ if (::strncmp(#name, str, my_strlen(#name)) == 0) \ return Method::e; diff --git a/src/httpp/http/Utils.cpp b/src/httpp/http/Utils.cpp index c57c271..f06f735 100644 --- a/src/httpp/http/Utils.cpp +++ b/src/httpp/http/Utils.cpp @@ -10,6 +10,10 @@ #include "httpp/http/Utils.hpp" +#ifdef WIN32 +#define strncasecmp(x,y,z) _strnicmp(x,y,z) +#endif + namespace HTTPP { namespace HTTP diff --git a/src/httpp/http/helper/ReadWholeRequest.cpp b/src/httpp/http/helper/ReadWholeRequest.cpp index 621f002..9a53259 100644 --- a/src/httpp/http/helper/ReadWholeRequest.cpp +++ b/src/httpp/http/helper/ReadWholeRequest.cpp @@ -5,6 +5,10 @@ #include "httpp/http/Connection.hpp" +#ifdef WIN32 +#define strncasecmp(x,y,z) _strnicmp(x,y,z) +#endif + namespace HTTPP { namespace HTTP diff --git a/tests/server/pipeline.cpp b/tests/server/pipeline.cpp index 0743ed8..d251cbb 100644 --- a/tests/server/pipeline.cpp +++ b/tests/server/pipeline.cpp @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(pipeline) } //std::cout << i << std::endl; - } while (not is.eof() || i < 3); + } while (!is.eof() || i < 3); } } @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(pipeline_with_body) } //std::cout << i << std::endl; - } while (not is.eof() || i < 3); + } while (!is.eof() || i < 3); } BOOST_CHECK_EQUAL(total_size, BODY.size() * 3); diff --git a/third_party/commonpp b/third_party/commonpp index 8584bab..e7785d3 160000 --- a/third_party/commonpp +++ b/third_party/commonpp @@ -1 +1 @@ -Subproject commit 8584bab675e361a37bb6c582d912f24ce62ea853 +Subproject commit e7785d3a10bd118efff54c8e7f807bf863983505