From c17f9d6b17daa6121ec1ef0284d701cd3d1387b2 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 27 Jun 2025 19:08:39 +0200 Subject: download: Use new CURLOPT_XFERINFOFUNCTION for libcurl >= 7.32 --- src/download.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/download.c b/src/download.c index d9fac45..2f3a836 100644 --- a/src/download.c +++ b/src/download.c @@ -86,9 +86,13 @@ int download_to_buffer(const char* url, char** buf, uint32_t* length) return res; } +#if LIBCURL_VERSION_NUM >= 0x072000 +static int download_progress(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +#else static int download_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +#endif { - double p = (dlnow / dltotal); + double p = ((double)dlnow / (double)dltotal); set_progress('DNLD', p); @@ -125,7 +129,11 @@ int download_to_file(const char* url, const char* filename, int enable_progress) if (enable_progress > 0) { register_progress('DNLD', "Downloading"); +#if LIBCURL_VERSION_NUM >= 0x072000 + curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, (curl_progress_callback)&download_progress); +#else curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&download_progress); +#endif } curl_easy_setopt(handle, CURLOPT_NOPROGRESS, enable_progress > 0 ? 0: 1); -- cgit v1.1-32-gdbae