Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed complile issues with new versions of libmicrohttpd #2739

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions xmrstak/http/httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <string.h>
#include <string>

#include <microhttpd.h>

#ifdef _WIN32
#define strcasecmp _stricmp
#endif // _WIN32
Expand All @@ -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,
Expand All @@ -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;
}
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 11 additions & 1 deletion xmrstak/http/httpd.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#pragma once

#include <stdlib.h>
#include <microhttpd.h>
#if MHD_VERSION >= 0x00097002

#define MHD_RESULT enum MHD_Result

#else

#define MHD_RESULT int

#endif

struct MHD_Daemon;
struct MHD_Connection;
Expand All @@ -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,
Expand Down