]> git.sesse.net Git - nageru/blobdiff - shared/httpd.h
Unbreak compilation with libmicrohttpd 0.9.71.
[nageru] / shared / httpd.h
index dae5cad627b7e056e41fe3f1901a51201f4fc066..8d2a05eb1df89f56e8577234ed8a00b460d8d620 100644 (file)
@@ -22,6 +22,8 @@ extern "C" {
 #include <libavutil/rational.h>
 }
 
+#include <microhttpd.h>
+
 #include "shared/shared_defs.h"
 
 struct MHD_Connection;
@@ -81,15 +83,23 @@ public:
        }
 
 private:
-       static int answer_to_connection_thunk(void *cls, MHD_Connection *connection,
-                                             const char *url, const char *method,
-                                             const char *version, const char *upload_data,
-                                             size_t *upload_data_size, void **con_cls);
-
-       int answer_to_connection(MHD_Connection *connection,
-                                const char *url, const char *method,
-                                const char *version, const char *upload_data,
-                                size_t *upload_data_size, void **con_cls);
+       // libmicrohttpd 0.9.71 broke the type of MHD_YES/MHD_NO, causing
+       // compilation errors for C++ and undefined behavior for C.
+#if MHD_VERSION >= 0x00097002
+       using MHD_Result = ::MHD_Result;
+#else
+       using MHD_Result = int;
+#endif
+
+       static MHD_Result answer_to_connection_thunk(void *cls, MHD_Connection *connection,
+                                                    const char *url, const char *method,
+                                                    const char *version, const char *upload_data,
+                                                    size_t *upload_data_size, void **con_cls);
+
+       MHD_Result answer_to_connection(MHD_Connection *connection,
+                                       const char *url, const char *method,
+                                       const char *version, const char *upload_data,
+                                       size_t *upload_data_size, void **con_cls);
 
        static void free_stream(void *cls);