mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-25 09:11:09 +02:00
Fix msvc compile
This commit is contained in:
@@ -85,6 +85,14 @@ namespace http
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Request::WriteDataHandler(char *ptr, size_t size, size_t count, void *userdata)
|
||||||
|
{
|
||||||
|
Request *req = (Request *)userdata;
|
||||||
|
auto actual_size = size * count;
|
||||||
|
req->response_body.append(ptr, actual_size);
|
||||||
|
return actual_size;
|
||||||
|
}
|
||||||
|
|
||||||
// start the request thread
|
// start the request thread
|
||||||
void Request::Start()
|
void Request::Start()
|
||||||
{
|
{
|
||||||
@@ -121,12 +129,7 @@ namespace http
|
|||||||
curl_easy_setopt(easy, CURLOPT_NOSIGNAL, 1L);
|
curl_easy_setopt(easy, CURLOPT_NOSIGNAL, 1L);
|
||||||
|
|
||||||
curl_easy_setopt(easy, CURLOPT_WRITEDATA, (void *)this);
|
curl_easy_setopt(easy, CURLOPT_WRITEDATA, (void *)this);
|
||||||
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, (size_t (*)(char *ptr, size_t size, size_t count, void *userdata))([](char *ptr, size_t size, size_t count, void *userdata) -> size_t {
|
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, Request::WriteDataHandler);
|
||||||
Request *req = (Request *)userdata;
|
|
||||||
auto actual_size = size * count;
|
|
||||||
req->response_body.append(ptr, actual_size);
|
|
||||||
return actual_size;
|
|
||||||
})); // curl_easy_setopt does something really ugly with parameters; I have to cast the lambda explicitly to the right kind of function pointer for some reason
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&rm_mutex);
|
pthread_mutex_lock(&rm_mutex);
|
||||||
|
@@ -2,8 +2,11 @@
|
|||||||
#define REQUEST_H
|
#define REQUEST_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "common/tpt-minmax.h" // for MSVC, ensures windows.h doesn't cause compile errors by defining min/max
|
||||||
|
#include "common/tpt-thread.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
|
#undef GetUserName // pthreads (included by curl) defines this, breaks stuff
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
@@ -30,6 +33,8 @@ namespace http
|
|||||||
|
|
||||||
pthread_cond_t done_cv;
|
pthread_cond_t done_cv;
|
||||||
|
|
||||||
|
static size_t WriteDataHandler(char * ptr, size_t size, size_t count, void * userdata);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Request(ByteString uri);
|
Request(ByteString uri);
|
||||||
virtual ~Request();
|
virtual ~Request();
|
||||||
|
@@ -1,12 +1,14 @@
|
|||||||
#ifndef REQUESTMANAGER_H
|
#ifndef REQUESTMANAGER_H
|
||||||
#define REQUESTMANAGER_H
|
#define REQUESTMANAGER_H
|
||||||
|
|
||||||
|
#include "common/tpt-minmax.h" // for MSVC, ensures windows.h doesn't cause compile errors by defining min/max
|
||||||
#include "common/tpt-thread.h"
|
#include "common/tpt-thread.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "common/Singleton.h"
|
#include "common/Singleton.h"
|
||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
|
#undef GetUserName // pthreads (included by curl) defines this, breaks stuff
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user