Skip to content

Commit af16844

Browse files
author
Sebastiano Merlino
committed
Added support to c++0x
1 parent 0ae88e0 commit af16844

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ else
138138
AM_CXXFLAGS="$AM_CXXFLAGS -O3"
139139
fi
140140

141+
AC_MSG_CHECKING([whether to use c++0x std classes])
142+
AC_ARG_ENABLE([cpp0x],
143+
[AS_HELP_STRING([--enable-cpp0x],
144+
[enable c++0x std classes (def=no)])],
145+
[cpp0x="$enableval"],
146+
[cpp0x=no])
147+
AC_MSG_RESULT([$cpp0x])
148+
149+
if test x"$cpp0x" = x"yes"; then
150+
AC_DEFINE([CPP0X],[],[c++0x Mode])
151+
AM_CXXFLAGS="$AM_CXXFLAGS -DUSE_CPP_ZEROX -std=c++0x"
152+
else
153+
AC_DEFINE([NCPP0X],[],[standard Mode])
154+
fi
155+
141156
AM_CONDITIONAL([PYTHON], [test x$python = xtrue])
142157
AM_CONDITIONAL([JAVA], [test x$java = xtrue])
143158
AM_CONDITIONAL([PHP], [test x$php = xtrue])
@@ -363,4 +378,5 @@ AC_MSG_NOTICE([Configuration Summary:
363378
License : LGPL only
364379
Languages : ${LANGUAGES}
365380
Debug : ${debugit}
381+
C++0x : ${cpp0x}
366382
])

src/HttpRequest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ const std::vector<std::pair<std::string, std::string> > HttpRequest::getHeaders(
225225
std::vector<std::pair<std::string, std::string> > toRet;
226226
map<string, string, HeaderComparator>::const_iterator it;
227227
for(it = headers.begin(); it != headers.end(); it++)
228+
#ifdef USE_CPP_ZEROX
229+
toRet.push_back(make_pair((*it).first,(*it).second));
230+
#else
228231
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
232+
#endif
229233
return toRet;
230234
}
231235

@@ -234,7 +238,11 @@ const std::vector<std::pair<std::string, std::string> > HttpRequest::getCookies(
234238
std::vector<std::pair<std::string, std::string> > toRet;
235239
map<string, string, HeaderComparator>::const_iterator it;
236240
for(it = cookies.begin(); it != cookies.end(); it++)
241+
#ifdef USE_CPP_ZEROX
242+
toRet.push_back(make_pair((*it).first,(*it).second));
243+
#else
237244
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
245+
#endif
238246
return toRet;
239247
}
240248

@@ -243,7 +251,11 @@ const std::vector<std::pair<std::string, std::string> > HttpRequest::getFooters(
243251
std::vector<std::pair<std::string, std::string> > toRet;
244252
map<string, string, HeaderComparator>::const_iterator it;
245253
for(it = footers.begin(); it != footers.end(); it++)
254+
#ifdef USE_CPP_ZEROX
255+
toRet.push_back(make_pair((*it).first,(*it).second));
256+
#else
246257
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
258+
#endif
247259
return toRet;
248260
}
249261

@@ -252,7 +264,11 @@ const std::vector<std::pair<std::string, std::string> > HttpRequest::getArgs() c
252264
std::vector<std::pair<std::string, std::string> > toRet;
253265
map<string, string, ArgComparator>::const_iterator it;
254266
for(it = args.begin(); it != args.end(); it++)
267+
#ifdef USE_CPP_ZEROX
268+
toRet.push_back(make_pair((*it).first,(*it).second));
269+
#else
255270
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
271+
#endif
256272
return toRet;
257273
}
258274

src/HttpResponse.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ const std::vector<std::pair<std::string, std::string> > HttpResponse::getHeaders
134134
std::vector<std::pair<std::string, std::string> > toRet;
135135
map<string, string, HeaderComparator>::const_iterator it;
136136
for(it = headers.begin(); it != headers.end(); it++)
137+
#ifdef USE_CPP_ZEROX
138+
toRet.push_back(make_pair((*it).first,(*it).second));
139+
#else
137140
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
141+
#endif
138142
return toRet;
139143
}
140144

@@ -143,7 +147,11 @@ const std::vector<std::pair<std::string, std::string> > HttpResponse::getFooters
143147
std::vector<std::pair<std::string, std::string> > toRet;
144148
map<string, string, ArgComparator>::const_iterator it;
145149
for(it = footers.begin(); it != footers.end(); it++)
150+
#ifdef USE_CPP_ZEROX
151+
toRet.push_back(make_pair((*it).first,(*it).second));
152+
#else
146153
toRet.push_back(make_pair<string, string>((*it).first,(*it).second));
154+
#endif
147155
return toRet;
148156
}
149157

src/Webserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ int policyCallback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
449449
if(((Webserver*)cls)->bans.count(get_ip_str(addr, addrlen)))
450450
return MHD_NO;
451451
#ifdef DEBUG
452-
cout << get_ip_str(addr, addrlen) << endl;
452+
cout << "IP: " << get_ip_str(addr, addrlen) << " - " << "IP-LEN: " << addrlen << endl;
453453
#endif
454454
return MHD_YES;
455455
}

src/httpserver/HttpRequest.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <map>
2424
#include <vector>
2525
#include <string>
26+
#include <utility>
2627

2728
namespace httpserver
2829
{

src/httpserver/Webserver.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
#include <cstring>
3737
#include <map>
3838
#include <vector>
39+
#ifdef USE_CPP_ZEROX
40+
#include <unordered_set>
41+
#else
3942
#include <set>
43+
#endif
4044
#include <string>
4145
#include <utility>
4246
#include <memory>
@@ -240,7 +244,11 @@ class Webserver
240244
bool running;
241245

242246
std::map<HttpEndpoint, HttpResource* > registeredResources;
247+
#ifdef USE_CPP_ZEROX
248+
std::unordered_set<std::string> bans;
249+
#else
243250
std::set<std::string> bans;
251+
#endif
244252
struct MHD_Daemon *daemon;
245253
static int not_found_page
246254
(

0 commit comments

Comments
 (0)