You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
709 B
30 lines
709 B
7 months ago
|
#pragma once
|
||
|
#include "MString.h"
|
||
|
#include <curl/curl.h>
|
||
|
#include <memory>
|
||
|
|
||
|
using michlib::MString;
|
||
|
|
||
|
class CURLRAIIDT
|
||
|
{
|
||
|
public:
|
||
|
// TODO: make static
|
||
|
void operator()(CURL* c) { curl_easy_cleanup(c); }
|
||
|
};
|
||
|
|
||
|
class CURLRAII: public std::unique_ptr<CURL, CURLRAIIDT>
|
||
|
{
|
||
|
public:
|
||
|
CURLRAII() { reset(curl_easy_init()); }
|
||
|
operator CURL*() const { return get(); }
|
||
|
};
|
||
|
|
||
|
// Curl writeback function, write to MString
|
||
|
size_t Write2String(char* ptr, size_t size, size_t n, void* data);
|
||
|
|
||
|
// Curl writeback function, write to file descriptor
|
||
|
size_t Write2File(char* ptr, size_t size, size_t n, void* data);
|
||
|
|
||
|
// Get content of url to MString
|
||
|
std::pair<MString, CURLcode> GetUrl(const CURLRAII& chandle, const MString& url);
|