Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to windows #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions include/httpp/http/Connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Connection

size_t offset = 0;

if (not body_buffer_.empty())
if (!body_buffer_.empty())
{
if (size <= body_buffer_.size())
{
Expand Down Expand Up @@ -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())
{
Expand Down
6 changes: 6 additions & 0 deletions include/httpp/utils/SortedVectorKP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ struct case_insensitive
}
else if (left.size() == right.size())
{
#ifdef WIN32
# define strncasecmp(x, y, z) _strnicmp(x, y, z)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daedric what about introducing a utils header which includes this define or is it ok to have it multiple times all over the place?

#endif
return ::strncasecmp(left.data(), right.data(), left.size()) < 0;
#ifdef WIN32
# undef strncasecmp
#endif
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/httpp/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/httpp/http/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/httpp/http/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/httpp/http/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/httpp/http/helper/ReadWholeRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/server/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down