From 313e8bd621b2937377b4c7d66b3a125a5787d00a Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Sun, 13 Aug 2017 19:08:07 +0200 Subject: [PATCH 1/5] Require at least Windows 7 --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd4ce2c..78d3983 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.") From 31f0b5e19d2f90fd900540fa80cefef8aee8681f Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Sun, 13 Aug 2017 19:09:11 +0200 Subject: [PATCH 2/5] Make sure TBB and HWLOC paths are included --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d3983..99a06de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,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) From 2fc9098127ca04cd1f9bd4b35ad9524acb31f093 Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Sun, 13 Aug 2017 19:09:57 +0200 Subject: [PATCH 3/5] Do not use `not`keyword but use plain old `!` Visual Studio likes plain old stuff ;) --- include/httpp/http/Connection.hpp | 4 ++-- src/httpp/HttpServer.cpp | 4 ++-- src/httpp/http/Connection.cpp | 2 +- tests/server/pipeline.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) 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/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/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); From 95cd1c240f5a14b1540dd747c9fde68e94d71d21 Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Sun, 13 Aug 2017 19:10:14 +0200 Subject: [PATCH 4/5] Port string functions to Windows --- include/httpp/utils/SortedVectorKP.hpp | 6 ++++++ src/httpp/http/Protocol.cpp | 5 ++++- src/httpp/http/Utils.cpp | 4 ++++ src/httpp/http/helper/ReadWholeRequest.cpp | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) 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/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 From 5c45947be0d73ec63d2376dee2a5224f87d319d4 Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Sun, 13 Aug 2017 20:50:15 +0200 Subject: [PATCH 5/5] (Revert me: use 0x7f/commonpp#port-to-windows) --- .gitmodules | 2 +- third_party/commonpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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