Skip to content

Commit 51b343c

Browse files
authored
Compatibility with libmicrohttpd 0.9.71 (etr#199)
From the libmicrohttpd 0.9.71 release notes: The release introduces an 'enum MHD_Result' instead of for certain API misuse bugs by providing better types (not everything is an 'int'). While this does NOT change the binary API, this change _will_ cause compiler warnings for all legacy code -- until 'int' is replaced with 'enum MHD_Result'.
1 parent 91467ee commit 51b343c

File tree

5 files changed

+30
-22
lines changed

5 files changed

+30
-22
lines changed

src/http_request.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const std::string http_request::get_connection_value(const std::string& key, enu
8888
return header_c;
8989
}
9090

91-
int http_request::build_request_header(
91+
MHD_Result http_request::build_request_header(
9292
void *cls,
9393
enum MHD_ValueKind kind,
9494
const char *key,
@@ -189,7 +189,7 @@ const std::string http_request::get_querystring() const
189189
return querystring;
190190
}
191191

192-
int http_request::build_request_args(
192+
MHD_Result http_request::build_request_args(
193193
void *cls,
194194
enum MHD_ValueKind kind,
195195
const char *key,
@@ -204,7 +204,7 @@ int http_request::build_request_args(
204204
return MHD_YES;
205205
}
206206

207-
int http_request::build_request_querystring(
207+
MHD_Result http_request::build_request_querystring(
208208
void *cls,
209209
enum MHD_ValueKind kind,
210210
const char *key,

src/httpserver/http_request.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ class http_request
247247

248248
unescaper_ptr unescaper = 0x0;
249249

250-
static int build_request_header(void *cls, enum MHD_ValueKind kind,
250+
static MHD_Result build_request_header(void *cls, enum MHD_ValueKind kind,
251251
const char *key, const char *value
252252
);
253253

254-
static int build_request_args(void *cls, enum MHD_ValueKind kind,
254+
static MHD_Result build_request_args(void *cls, enum MHD_ValueKind kind,
255255
const char *key, const char *value
256256
);
257257

258-
static int build_request_querystring(void *cls, enum MHD_ValueKind kind,
258+
static MHD_Result build_request_querystring(void *cls, enum MHD_ValueKind kind,
259259
const char *key, const char *value
260260
);
261261

src/httpserver/http_utils.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353

5454
#define DEFAULT_MASK_VALUE 0xFFFF
5555

56+
#if MHD_VERSION < 0x00097002
57+
typedef int MHD_Result;
58+
#endif
59+
5660
namespace httpserver {
5761

5862
typedef void(*unescaper_ptr)(std::string&);

src/httpserver/webserver.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,14 @@ class webserver
195195
enum MHD_RequestTerminationCode toe
196196
);
197197

198-
static int answer_to_connection
198+
static MHD_Result answer_to_connection
199199
(
200200
void* cls, MHD_Connection* connection,
201201
const char* url, const char* method,
202202
const char* version, const char* upload_data,
203203
size_t* upload_data_size, void** con_cls
204204
);
205-
static int post_iterator
205+
static MHD_Result post_iterator
206206
(
207207
void *cls,
208208
enum MHD_ValueKind kind,
@@ -219,25 +219,25 @@ class webserver
219219
void **con_cls, int upgrade_socket
220220
);
221221

222-
int requests_answer_first_step(MHD_Connection* connection,
222+
MHD_Result requests_answer_first_step(MHD_Connection* connection,
223223
struct details::modded_request* mr
224224
);
225225

226-
int requests_answer_second_step(MHD_Connection* connection,
226+
MHD_Result requests_answer_second_step(MHD_Connection* connection,
227227
const char* method, const char* version, const char* upload_data,
228228
size_t* upload_data_size, struct details::modded_request* mr
229229
);
230230

231-
int finalize_answer(MHD_Connection* connection,
231+
MHD_Result finalize_answer(MHD_Connection* connection,
232232
struct details::modded_request* mr, const char* method
233233
);
234234

235-
int complete_request(MHD_Connection* connection,
235+
MHD_Result complete_request(MHD_Connection* connection,
236236
struct details::modded_request* mr,
237237
const char* version, const char* method
238238
);
239239

240-
friend int policy_callback (void *cls,
240+
friend MHD_Result policy_callback (void *cls,
241241
const struct sockaddr* addr, socklen_t addrlen
242242
);
243243
friend void error_log(void* cls, const char* fmt, va_list ap);

src/webserver.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,18 @@
7575
#define SOCK_CLOEXEC 02000000
7676
#endif
7777

78+
#if MHD_VERSION < 0x00097002
79+
typedef int MHD_Result;
80+
#endif
81+
7882
using namespace std;
7983

8084
namespace httpserver
8185
{
8286

8387
using namespace http;
8488

85-
int policy_callback (void *, const struct sockaddr*, socklen_t);
89+
MHD_Result policy_callback (void *, const struct sockaddr*, socklen_t);
8690
void error_log(void*, const char*, va_list);
8791
void* uri_log(void*, const char*);
8892
void access_log(webserver*, string);
@@ -421,7 +425,7 @@ void webserver::disallow_ip(const string& ip)
421425
allowances.erase(ip);
422426
}
423427

424-
int policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
428+
MHD_Result policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
425429
{
426430
if(!(static_cast<webserver*>(cls))->ban_system_enabled) return MHD_YES;
427431

@@ -468,7 +472,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s)
468472
return std::string(s).size();
469473
}
470474

471-
int webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
475+
MHD_Result webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
472476
const char *key,
473477
const char *filename,
474478
const char *content_type,
@@ -522,7 +526,7 @@ const std::shared_ptr<http_response> webserver::internal_error_page(details::mod
522526
}
523527
}
524528

525-
int webserver::requests_answer_first_step(
529+
MHD_Result webserver::requests_answer_first_step(
526530
MHD_Connection* connection,
527531
struct details::modded_request* mr
528532
)
@@ -574,7 +578,7 @@ int webserver::requests_answer_first_step(
574578
return MHD_YES;
575579
}
576580

577-
int webserver::requests_answer_second_step(
581+
MHD_Result webserver::requests_answer_second_step(
578582
MHD_Connection* connection, const char* method,
579583
const char* version, const char* upload_data,
580584
size_t* upload_data_size, struct details::modded_request* mr
@@ -597,7 +601,7 @@ int webserver::requests_answer_second_step(
597601
return MHD_YES;
598602
}
599603

600-
int webserver::finalize_answer(
604+
MHD_Result webserver::finalize_answer(
601605
MHD_Connection* connection,
602606
struct details::modded_request* mr,
603607
const char* method
@@ -731,10 +735,10 @@ int webserver::finalize_answer(
731735
mr->dhrs->decorate_response(raw_response);
732736
to_ret = mr->dhrs->enqueue_response(connection, raw_response);
733737
MHD_destroy_response(raw_response);
734-
return to_ret;
738+
return (MHD_Result) to_ret;
735739
}
736740

737-
int webserver::complete_request(
741+
MHD_Result webserver::complete_request(
738742
MHD_Connection* connection,
739743
struct details::modded_request* mr,
740744
const char* version,
@@ -750,7 +754,7 @@ int webserver::complete_request(
750754
return finalize_answer(connection, mr, method);
751755
}
752756

753-
int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
757+
MHD_Result webserver::answer_to_connection(void* cls, MHD_Connection* connection,
754758
const char* url, const char* method,
755759
const char* version, const char* upload_data,
756760
size_t* upload_data_size, void** con_cls

0 commit comments

Comments
 (0)