diff --git a/xmrstak/http/httpd.cpp b/xmrstak/http/httpd.cpp index b4f0f547e..dfa4313cc 100644 --- a/xmrstak/http/httpd.cpp +++ b/xmrstak/http/httpd.cpp @@ -35,7 +35,7 @@ #include #include -#include + #ifdef _WIN32 #define strcasecmp _stricmp #endif // _WIN32 @@ -46,7 +46,7 @@ httpd::httpd() { } -int httpd::req_handler(void* cls, +MHD_RESULT httpd::req_handler(void* cls, MHD_Connection* connection, const char* url, const char* method, @@ -63,25 +63,25 @@ int httpd::req_handler(void* cls, if(strlen(jconf::inst()->GetHttpUsername()) != 0) { char* username; - int ret; + MHD_RESULT result; username = MHD_digest_auth_get_username(connection); if(username == NULL) { rsp = MHD_create_response_from_buffer(sHtmlAccessDeniedSize, (void*)sHtmlAccessDenied, MHD_RESPMEM_PERSISTENT); - ret = MHD_queue_auth_fail_response(connection, sHttpAuthRealm, sHttpAuthOpaque, rsp, MHD_NO); + result = MHD_queue_auth_fail_response(connection, sHttpAuthRealm, sHttpAuthOpaque, rsp, MHD_NO); MHD_destroy_response(rsp); - return ret; + return result; } free(username); - ret = MHD_digest_auth_check(connection, sHttpAuthRealm, jconf::inst()->GetHttpUsername(), jconf::inst()->GetHttpPassword(), 300); - if(ret == MHD_INVALID_NONCE || ret == MHD_NO) + int ret = MHD_digest_auth_check(connection, sHttpAuthRealm, jconf::inst()->GetHttpUsername(), jconf::inst()->GetHttpPassword(), 300); + if(ret == MHD_INVALID_NONCE || result == MHD_NO) { rsp = MHD_create_response_from_buffer(sHtmlAccessDeniedSize, (void*)sHtmlAccessDenied, MHD_RESPMEM_PERSISTENT); - ret = MHD_queue_auth_fail_response(connection, sHttpAuthRealm, sHttpAuthOpaque, rsp, (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO); + result = MHD_queue_auth_fail_response(connection, sHttpAuthRealm, sHttpAuthOpaque, rsp, (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO); MHD_destroy_response(rsp); - return ret; + return result; } } @@ -95,7 +95,7 @@ int httpd::req_handler(void* cls, { //Cache hit rsp = MHD_create_response_from_buffer(0, nullptr, MHD_RESPMEM_PERSISTENT); - int ret = MHD_queue_response(connection, MHD_HTTP_NOT_MODIFIED, rsp); + MHD_RESULT ret = MHD_queue_response(connection, MHD_HTTP_NOT_MODIFIED, rsp); MHD_destroy_response(rsp); return ret; } @@ -144,13 +144,13 @@ int httpd::req_handler(void* cls, snprintf(loc_path, sizeof(loc_path), "/h"); rsp = MHD_create_response_from_buffer(0, nullptr, MHD_RESPMEM_PERSISTENT); - int ret = MHD_queue_response(connection, MHD_HTTP_TEMPORARY_REDIRECT, rsp); + MHD_RESULT ret = MHD_queue_response(connection, MHD_HTTP_TEMPORARY_REDIRECT, rsp); MHD_add_response_header(rsp, "Location", loc_path); MHD_destroy_response(rsp); return ret; } - int ret = MHD_queue_response(connection, MHD_HTTP_OK, rsp); + MHD_RESULT ret = MHD_queue_response(connection, MHD_HTTP_OK, rsp); MHD_destroy_response(rsp); return ret; } diff --git a/xmrstak/http/httpd.hpp b/xmrstak/http/httpd.hpp index dfad082ca..387437906 100644 --- a/xmrstak/http/httpd.hpp +++ b/xmrstak/http/httpd.hpp @@ -1,6 +1,16 @@ #pragma once #include +#include +#if MHD_VERSION >= 0x00097002 + +#define MHD_RESULT enum MHD_Result + +#else + +#define MHD_RESULT int + +#endif struct MHD_Daemon; struct MHD_Connection; @@ -21,7 +31,7 @@ class httpd httpd(); static httpd* oInst; - static int req_handler(void* cls, + static MHD_RESULT req_handler(void* cls, MHD_Connection* connection, const char* url, const char* method,