Skip to content

Commit f51911c

Browse files
committed
Modified some code to get as much working on MSVC 10 as possible. There is still a compiler error in protocol/http/algorithms/linearize.hpp.
1 parent e975db2 commit f51911c

File tree

4 files changed

+61
-42
lines changed

4 files changed

+61
-42
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ if (Boost_FOUND)
1717
set(Boost_USE_STATIC_LIBS ON)
1818
set(Boost_USE_MULTI_THREADED ON)
1919
include_directories(${Boost_INCLUDE_DIRS})
20-
endif()
20+
endif(Boost_FOUND)
21+
if (MSVC)
22+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
23+
endif(MSVC)
24+
if (WIN32)
25+
add_definitions(-D_WIN32_WINNT=0x0501)
26+
endif(WIN32)
2127
enable_testing()
2228

2329
if (OPENSSL_FOUND)
@@ -26,6 +32,8 @@ endif()
2632

2733
add_subdirectory(libs/network/src)
2834
add_subdirectory(libs/network/test)
29-
add_subdirectory(libs/mime/test)
35+
if (NOT MSVC)
36+
add_subdirectory(libs/mime/test)
37+
endif(NOT_MSVC)
3038
add_subdirectory(libs/network/example)
3139

boost/network/protocol/http/policies/simple_connection.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace boost { namespace network { namespace http {
3030
typedef function<void(iterator_range<char const *> const &, system::error_code const &)> body_callback_function_type;
3131

3232
struct connection_impl {
33-
connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & hostname, string_type const & port, resolver_function_type resolve, bool https, optional<string_type> const & certificate_filename = optional<string_type>(), optional<string_type> const & verify_path = optional<string_type>())
33+
connection_impl(resolver_type & resolver, bool follow_redirect, string_type const & hostname, string_type const & port, resolver_function_type resolve, bool https, optional<string_type> const & certificate_filename = optional<string_type>(), optional<string_type> const & verify_path = optional<string_type>())
3434
: pimpl()
35-
, follow_redirect_(follow_redirect)
35+
, follow_redirect_(follow_redirect)
3636
{
3737
pimpl.reset(impl::sync_connection_base<Tag,version_major,version_minor>::new_connection(resolver, resolve, https, certificate_filename, verify_path));
3838
}
@@ -55,7 +55,7 @@ namespace boost { namespace network { namespace http {
5555
boost::uint16_t status = response_.status();
5656
if (status >= 300 && status <= 307) {
5757
typename headers_range<http::basic_response<Tag> >::type location_range = headers(response_)["Location"];
58-
typename range_iterator<typename headers_range<http::basic_request<Tag> >::type>::type location_header = boost::begin(location_range);
58+
typename range_iterator<typename headers_range<http::basic_response<Tag> >::type>::type location_header = boost::begin(location_range);
5959
if (location_header != boost::end(location_range)) {
6060
request_.uri(location_header->second);
6161
} else throw std::runtime_error("Location header not defined in redirect response.");
@@ -98,7 +98,7 @@ namespace boost { namespace network { namespace http {
9898

9999
void cleanup() { }
100100

101-
simple_connection_policy(bool cache_resolved, bool follow_redirect)
101+
simple_connection_policy(bool cache_resolved, bool follow_redirect)
102102
: resolver_base(cache_resolved), follow_redirect_(follow_redirect) {}
103103

104104
// member variables

libs/network/example/CMakeLists.txt

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,43 @@ find_package( OpenSSL )
99
find_package( Threads )
1010

1111
if (Boost_FOUND)
12-
set(Boost_USE_STATIC_LIBS ON)
13-
set(Boost_USE_MULTITHREADED ON)
12+
set(Boost_USE_STATIC_LIBS ON)
13+
set(Boost_USE_MULTITHREADED ON)
1414
endif (Boost_FOUND)
1515

1616
if (OPENSSL_FOUND)
17-
include_directories(${OPENSSL_INCLUDE_DIR})
17+
include_directories(${OPENSSL_INCLUDE_DIR})
1818
endif (OPENSSL_FOUND)
1919

20-
add_executable(http_client http_client.cpp)
21-
add_executable(simple_wget simple_wget.cpp)
22-
add_executable(hello_world_server http/hello_world_server.cpp)
23-
add_executable(fileserver http/fileserver.cpp)
24-
add_executable(uri uri.cpp)
25-
add_executable(uri_builder uri_builder.cpp)
26-
add_dependencies(http_client cppnetlib-uri-parsers)
27-
add_dependencies(simple_wget cppnetlib-uri-parsers)
28-
add_dependencies(uri cppnetlib-uri-parsers)
29-
target_link_libraries(http_client ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
30-
target_link_libraries(simple_wget ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
31-
target_link_libraries(hello_world_server ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
32-
target_link_libraries(fileserver ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
33-
target_link_libraries(uri cppnetlib-uri-parsers)
34-
target_link_libraries(uri_builder cppnetlib-uri-parsers)
35-
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
36-
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
37-
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
38-
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
39-
set_target_properties(uri PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
40-
set_target_properties(uri_builder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
20+
if (Boost_FOUND)
21+
add_executable(http_client http_client.cpp)
22+
add_dependencies(http_client cppnetlib-uri-parsers)
23+
target_link_libraries(http_client ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
24+
set_target_properties(http_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
25+
26+
add_executable(simple_wget simple_wget.cpp)
27+
add_dependencies(simple_wget cppnetlib-uri-parsers)
28+
target_link_libraries(simple_wget ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri-parsers)
29+
set_target_properties(simple_wget PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
30+
31+
add_executable(hello_world_server http/hello_world_server.cpp)
32+
target_link_libraries(hello_world_server ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
33+
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
34+
35+
if (UNIX)
36+
add_executable(fileserver http/fileserver.cpp)
37+
target_link_libraries(fileserver ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
38+
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
39+
endif (UNIX)
40+
41+
add_executable(uri uri.cpp)
42+
add_dependencies(uri cppnetlib-uri-parsers)
43+
target_link_libraries(uri cppnetlib-uri-parsers)
44+
set_target_properties(uri PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
45+
46+
add_executable(uri_builder uri_builder.cpp)
47+
add_dependencies(uri_builder cppnetlib-uri-parsers)
48+
target_link_libraries(uri_builder cppnetlib-uri-parsers)
49+
set_target_properties(uri_builder PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
50+
51+
endif()

libs/network/test/http/http_test_server.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright Kim Grasman 2008.
33
// Distributed under the Boost Software License, Version 1.0.
44
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,14 +16,14 @@
1616
#include <windows.h>
1717

1818
// ShellExecuteEx
19-
#include <shellapi.h>
19+
#include <shellapi.h>
2020
#pragma comment( lib, "shell32" )
2121
#else
2222
#include <unistd.h> // fork, execlp etc.
2323
#include <sys/types.h>
2424
#include <sys/wait.h> // for waitpid
2525
#include <sys/stat.h> // for chmod
26-
#include <signal.h> // for kill
26+
#include <signal.h> // for kill
2727
#endif
2828

2929
struct http_test_server
@@ -61,7 +61,7 @@ struct http_test_server
6161
boost::filesystem::path get_server_path(const boost::filesystem::path& base_path) {
6262
using namespace boost::filesystem;
6363

64-
const path script_name =
64+
const path script_name =
6565
#if defined(HTTPS_SERVER_TEST)
6666
"https_test_server.py"
6767
#else
@@ -84,17 +84,17 @@ struct http_test_server
8484
script_handle_t launch_python_script(const boost::filesystem::path& python_script_path) {
8585
using namespace boost::filesystem;
8686

87-
path::string_type script_name = python_script_path.filename().string();
88-
path::string_type script_dir = python_script_path.parent_path().string();
87+
path::string_type script_name = python_script_path.filename().native();
88+
path::string_type script_dir = python_script_path.parent_path().native();
8989

9090
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
9191
SHELLEXECUTEINFOA sei = {0};
9292
sei.cbSize = sizeof(sei);
9393
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
9494
sei.lpVerb = "open";
9595
sei.lpFile = "python.exe";
96-
sei.lpParameters = script_name.c_str();
97-
sei.lpDirectory = script_dir.c_str();
96+
sei.lpParameters = reinterpret_cast<LPCSTR>(script_name.c_str());
97+
sei.lpDirectory = reinterpret_cast<LPCSTR>(script_dir.c_str());
9898
sei.nShow = SW_SHOWNOACTIVATE;
9999

100100
if (!ShellExecuteExA(&sei))
@@ -107,16 +107,16 @@ struct http_test_server
107107
if (child_process < 0)
108108
return false;
109109

110-
if (child_process == 0) {
110+
if (child_process == 0) {
111111
// child process
112-
112+
113113
// cd into script dir and launch python script
114114
current_path(script_dir);
115115

116116
if (execlp("python", "python", script_name.c_str(), (char*)NULL) == -1)
117117
return 0;
118-
}
119-
else {
118+
}
119+
else {
120120
// parent
121121
sleep(1);
122122
}

0 commit comments

Comments
 (0)