0001-Compatibility-with-libmicrohttpd-0.9.71.patch 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. From cfcd8a8f73aa337e8f45d287a79cd9b8e5c51dcd Mon Sep 17 00:00:00 2001
  2. From: Bernd Kuhls <bernd.kuhls@t-online.de>
  3. Date: Sun, 5 Jul 2020 11:42:23 +0200
  4. Subject: [PATCH] Compatibility with libmicrohttpd 0.9.71
  5. From the libmicrohttpd 0.9.71 release notes:
  6. Furthermore, the release introduces an 'enum MHD_Result' instead of
  7. defines for MHD_YES/MHD_NO. This is intended to make it easier to check
  8. for certain API misuse bugs by providing better types (not everything is
  9. an 'int'). While this does NOT change the binary API, this change
  10. _will_ cause compiler warnings for all legacy code -- until 'int' is
  11. replaced with 'enum MHD_Result'
  12. Patch sent upstream: https://github.com/etr/libhttpserver/pull/199
  13. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  14. ---
  15. src/http_request.cpp | 6 +++---
  16. src/httpserver/http_request.hpp | 6 +++---
  17. src/httpserver/http_utils.hpp | 4 ++++
  18. src/httpserver/webserver.hpp | 14 +++++++-------
  19. src/webserver.cpp | 22 +++++++++++++---------
  20. 5 files changed, 30 insertions(+), 22 deletions(-)
  21. diff --git a/src/http_request.cpp b/src/http_request.cpp
  22. index 5703663..be342c7 100644
  23. --- a/src/http_request.cpp
  24. +++ b/src/http_request.cpp
  25. @@ -88,7 +88,7 @@ const std::string http_request::get_connection_value(const std::string& key, enu
  26. return header_c;
  27. }
  28. -int http_request::build_request_header(
  29. +MHD_Result http_request::build_request_header(
  30. void *cls,
  31. enum MHD_ValueKind kind,
  32. const char *key,
  33. @@ -189,7 +189,7 @@ const std::string http_request::get_querystring() const
  34. return querystring;
  35. }
  36. -int http_request::build_request_args(
  37. +MHD_Result http_request::build_request_args(
  38. void *cls,
  39. enum MHD_ValueKind kind,
  40. const char *key,
  41. @@ -204,7 +204,7 @@ int http_request::build_request_args(
  42. return MHD_YES;
  43. }
  44. -int http_request::build_request_querystring(
  45. +MHD_Result http_request::build_request_querystring(
  46. void *cls,
  47. enum MHD_ValueKind kind,
  48. const char *key,
  49. diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp
  50. index 139272b..62e5275 100644
  51. --- a/src/httpserver/http_request.hpp
  52. +++ b/src/httpserver/http_request.hpp
  53. @@ -247,15 +247,15 @@ class http_request
  54. unescaper_ptr unescaper = 0x0;
  55. - static int build_request_header(void *cls, enum MHD_ValueKind kind,
  56. + static MHD_Result build_request_header(void *cls, enum MHD_ValueKind kind,
  57. const char *key, const char *value
  58. );
  59. - static int build_request_args(void *cls, enum MHD_ValueKind kind,
  60. + static MHD_Result build_request_args(void *cls, enum MHD_ValueKind kind,
  61. const char *key, const char *value
  62. );
  63. - static int build_request_querystring(void *cls, enum MHD_ValueKind kind,
  64. + static MHD_Result build_request_querystring(void *cls, enum MHD_ValueKind kind,
  65. const char *key, const char *value
  66. );
  67. diff --git a/src/httpserver/http_utils.hpp b/src/httpserver/http_utils.hpp
  68. index 9ad89b4..a812197 100644
  69. --- a/src/httpserver/http_utils.hpp
  70. +++ b/src/httpserver/http_utils.hpp
  71. @@ -53,6 +53,10 @@
  72. #define DEFAULT_MASK_VALUE 0xFFFF
  73. +#if MHD_VERSION < 0x00097002
  74. +typedef int MHD_Result;
  75. +#endif
  76. +
  77. namespace httpserver {
  78. typedef void(*unescaper_ptr)(std::string&);
  79. diff --git a/src/httpserver/webserver.hpp b/src/httpserver/webserver.hpp
  80. index 1ff472b..661b6ee 100644
  81. --- a/src/httpserver/webserver.hpp
  82. +++ b/src/httpserver/webserver.hpp
  83. @@ -195,14 +195,14 @@ class webserver
  84. enum MHD_RequestTerminationCode toe
  85. );
  86. - static int answer_to_connection
  87. + static MHD_Result answer_to_connection
  88. (
  89. void* cls, MHD_Connection* connection,
  90. const char* url, const char* method,
  91. const char* version, const char* upload_data,
  92. size_t* upload_data_size, void** con_cls
  93. );
  94. - static int post_iterator
  95. + static MHD_Result post_iterator
  96. (
  97. void *cls,
  98. enum MHD_ValueKind kind,
  99. @@ -219,25 +219,25 @@ class webserver
  100. void **con_cls, int upgrade_socket
  101. );
  102. - int requests_answer_first_step(MHD_Connection* connection,
  103. + MHD_Result requests_answer_first_step(MHD_Connection* connection,
  104. struct details::modded_request* mr
  105. );
  106. - int requests_answer_second_step(MHD_Connection* connection,
  107. + MHD_Result requests_answer_second_step(MHD_Connection* connection,
  108. const char* method, const char* version, const char* upload_data,
  109. size_t* upload_data_size, struct details::modded_request* mr
  110. );
  111. - int finalize_answer(MHD_Connection* connection,
  112. + MHD_Result finalize_answer(MHD_Connection* connection,
  113. struct details::modded_request* mr, const char* method
  114. );
  115. - int complete_request(MHD_Connection* connection,
  116. + MHD_Result complete_request(MHD_Connection* connection,
  117. struct details::modded_request* mr,
  118. const char* version, const char* method
  119. );
  120. - friend int policy_callback (void *cls,
  121. + friend MHD_Result policy_callback (void *cls,
  122. const struct sockaddr* addr, socklen_t addrlen
  123. );
  124. friend void error_log(void* cls, const char* fmt, va_list ap);
  125. diff --git a/src/webserver.cpp b/src/webserver.cpp
  126. index a3104e9..3340eb0 100644
  127. --- a/src/webserver.cpp
  128. +++ b/src/webserver.cpp
  129. @@ -75,6 +75,10 @@
  130. #define SOCK_CLOEXEC 02000000
  131. #endif
  132. +#if MHD_VERSION < 0x00097002
  133. +typedef int MHD_Result;
  134. +#endif
  135. +
  136. using namespace std;
  137. namespace httpserver
  138. @@ -82,7 +86,7 @@ namespace httpserver
  139. using namespace http;
  140. -int policy_callback (void *, const struct sockaddr*, socklen_t);
  141. +MHD_Result policy_callback (void *, const struct sockaddr*, socklen_t);
  142. void error_log(void*, const char*, va_list);
  143. void* uri_log(void*, const char*);
  144. void access_log(webserver*, string);
  145. @@ -421,7 +425,7 @@ void webserver::disallow_ip(const string& ip)
  146. allowances.erase(ip);
  147. }
  148. -int policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
  149. +MHD_Result policy_callback (void *cls, const struct sockaddr* addr, socklen_t addrlen)
  150. {
  151. if(!(static_cast<webserver*>(cls))->ban_system_enabled) return MHD_YES;
  152. @@ -468,7 +472,7 @@ size_t unescaper_func(void * cls, struct MHD_Connection *c, char *s)
  153. return std::string(s).size();
  154. }
  155. -int webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
  156. +MHD_Result webserver::post_iterator (void *cls, enum MHD_ValueKind kind,
  157. const char *key,
  158. const char *filename,
  159. const char *content_type,
  160. @@ -522,7 +526,7 @@ const std::shared_ptr<http_response> webserver::internal_error_page(details::mod
  161. }
  162. }
  163. -int webserver::requests_answer_first_step(
  164. +MHD_Result webserver::requests_answer_first_step(
  165. MHD_Connection* connection,
  166. struct details::modded_request* mr
  167. )
  168. @@ -574,7 +578,7 @@ int webserver::requests_answer_first_step(
  169. return MHD_YES;
  170. }
  171. -int webserver::requests_answer_second_step(
  172. +MHD_Result webserver::requests_answer_second_step(
  173. MHD_Connection* connection, const char* method,
  174. const char* version, const char* upload_data,
  175. size_t* upload_data_size, struct details::modded_request* mr
  176. @@ -597,7 +601,7 @@ int webserver::requests_answer_second_step(
  177. return MHD_YES;
  178. }
  179. -int webserver::finalize_answer(
  180. +MHD_Result webserver::finalize_answer(
  181. MHD_Connection* connection,
  182. struct details::modded_request* mr,
  183. const char* method
  184. @@ -731,10 +735,10 @@ int webserver::finalize_answer(
  185. mr->dhrs->decorate_response(raw_response);
  186. to_ret = mr->dhrs->enqueue_response(connection, raw_response);
  187. MHD_destroy_response(raw_response);
  188. - return to_ret;
  189. + return (MHD_Result) to_ret;
  190. }
  191. -int webserver::complete_request(
  192. +MHD_Result webserver::complete_request(
  193. MHD_Connection* connection,
  194. struct details::modded_request* mr,
  195. const char* version,
  196. @@ -750,7 +754,7 @@ int webserver::complete_request(
  197. return finalize_answer(connection, mr, method);
  198. }
  199. -int webserver::answer_to_connection(void* cls, MHD_Connection* connection,
  200. +MHD_Result webserver::answer_to_connection(void* cls, MHD_Connection* connection,
  201. const char* url, const char* method,
  202. const char* version, const char* upload_data,
  203. size_t* upload_data_size, void** con_cls
  204. --
  205. 2.26.2