fix for newer libcurl

This commit is contained in:
GetAway
2023-01-12 21:08:40 +01:00
parent 0f0c3eb5ff
commit 2a219b342e
5 changed files with 38 additions and 7 deletions

View File

@@ -98,7 +98,11 @@ int CLuaInstCurl::CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow
double dlSpeed;
long responseCode = 0;
#if CURL_AT_LEAST_VERSION( 7,55,0 )
curl_easy_getinfo(_pgd->curl, CURLINFO_SPEED_DOWNLOAD_T, &dlSpeed);
#else
curl_easy_getinfo(_pgd->curl, CURLINFO_SPEED_DOWNLOAD, &dlSpeed);
#endif
curl_easy_getinfo(_pgd->curl, CURLINFO_RESPONSE_CODE, &responseCode);
uint32_t MUL = 0x7FFF;
@@ -124,7 +128,7 @@ int CLuaInstCurl::CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow
return 0;
}
#if LIBCURL_VERSION_NUM < 0x072000
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
int CLuaInstCurl::CurlProgressFunc_old(void *p, double dltotal, double dlnow, double ultotal, double ulnow)
{
return CurlProgressFunc(p, (curl_off_t)dltotal, (curl_off_t)dlnow, (curl_off_t)ultotal, (curl_off_t)ulnow);
@@ -324,7 +328,7 @@ Example:
if (!silent) {
pgd.curl = curl_handle;
pgd.last_dlnow = -1;
#if LIBCURL_VERSION_NUM >= 0x072000
#if CURL_AT_LEAST_VERSION( 7,32,0 )
curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, CLuaInstCurl::CurlProgressFunc);
curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, &pgd);
#else
@@ -349,7 +353,11 @@ Example:
if (!silent) {
double dsize, dtime;
char *dredirect=NULL, *deffektive=NULL;
#if CURL_AT_LEAST_VERSION( 7,55,0 )
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &dsize);
#else
curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &dsize);
#endif
curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &dtime);
CURLcode res1 = curl_easy_getinfo(curl_handle, CURLINFO_EFFECTIVE_URL, &deffektive);
CURLcode res2 = curl_easy_getinfo(curl_handle, CURLINFO_REDIRECT_URL, &dredirect);

View File

@@ -53,7 +53,7 @@ class CLuaInstCurl
static CLuaCurl *CurlCheckData(lua_State *L, int n);
static int CurlNew(lua_State *L);
static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data);
#if LIBCURL_VERSION_NUM < 0x072000
#if !CURL_AT_LEAST_VERSION( 7,32,0 )
static int CurlProgressFunc_old(void *p, double dltotal, double dlnow, double ultotal, double ulnow);
#endif
static int CurlProgressFunc(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);