2023-01-26 19:54:38 +01:00
|
|
|
#ifndef TIER2_CURLUTILS_H
|
|
|
|
#define TIER2_CURLUTILS_H
|
|
|
|
|
2023-07-26 20:37:58 +02:00
|
|
|
struct CURLProgress
|
|
|
|
{
|
2023-07-28 14:47:20 +02:00
|
|
|
CURLProgress()
|
|
|
|
: curl(nullptr)
|
|
|
|
, name(nullptr)
|
|
|
|
, cust(nullptr)
|
|
|
|
, size(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
CURL* curl;
|
|
|
|
const char* name;
|
|
|
|
void* cust; // custom pointer to anything.
|
2023-07-26 20:37:58 +02:00
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2023-07-28 14:47:20 +02:00
|
|
|
struct CURLParams
|
|
|
|
{
|
|
|
|
CURLParams()
|
|
|
|
: writeFunction(nullptr)
|
|
|
|
, statusFunction(nullptr)
|
|
|
|
, timeout(0)
|
|
|
|
, verifyPeer(false)
|
2023-08-01 02:20:53 +02:00
|
|
|
, followRedirect(false)
|
2023-07-28 14:47:20 +02:00
|
|
|
, verbose(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void* writeFunction;
|
|
|
|
void* statusFunction;
|
|
|
|
|
|
|
|
int timeout;
|
|
|
|
bool verifyPeer;
|
2023-08-01 02:20:53 +02:00
|
|
|
bool followRedirect;
|
2023-07-28 14:47:20 +02:00
|
|
|
bool verbose;
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t CURLWriteStringCallback(char* contents, const size_t size, const size_t nmemb, string* userp);
|
|
|
|
size_t CURLWriteFileCallback(void* data, const size_t size, const size_t nmemb, FILE* userp);
|
|
|
|
|
|
|
|
bool CURLDownloadFile(const char* remote, const char* savePath, const char* fileName,
|
2023-08-01 02:20:53 +02:00
|
|
|
const char* options, curl_off_t dataSize, void* customPointer, const CURLParams& params);
|
2023-07-28 14:47:20 +02:00
|
|
|
|
2023-08-01 02:20:53 +02:00
|
|
|
CURL* CURLInitRequest(const char* remote, const char* request, string& outResponse,
|
|
|
|
curl_slist*& slist, const CURLParams& params);
|
2023-01-26 19:54:38 +01:00
|
|
|
|
2023-02-09 22:56:13 +01:00
|
|
|
CURLcode CURLSubmitRequest(CURL* curl, curl_slist*& slist);
|
2023-01-26 19:54:38 +01:00
|
|
|
CURLINFO CURLRetrieveInfo(CURL* curl);
|
|
|
|
|
2023-06-02 00:05:23 +02:00
|
|
|
bool CURLHandleError(CURL* curl, const CURLcode res, string& outMessage, const bool logError);
|
2023-04-25 22:51:06 +02:00
|
|
|
void CURLFormatUrl(string& outUrl, const char* host, const char* api);
|
2023-01-26 19:54:38 +01:00
|
|
|
|
|
|
|
#endif // !TIER2_CURLUTILS_H
|