summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-27 20:42:31 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-27 20:57:54 (GMT)
commitb2fe717a49dc9ca8a7514d7c64392c727dce969b (patch)
tree40f16c64e60fc3c37ccc4da3a84862271ac77087
parent1cd38de47f47624b5dbf33d4543033a8cfe609ab (diff)
downloadCMake-b2fe717a49dc9ca8a7514d7c64392c727dce969b.zip
CMake-b2fe717a49dc9ca8a7514d7c64392c727dce969b.tar.gz
CMake-b2fe717a49dc9ca8a7514d7c64392c727dce969b.tar.bz2
file: Avoid using deprecated curl progress callback
-rw-r--r--Source/cmFileCommand.cxx30
-rw-r--r--Utilities/IWYU/mapping.imp1
2 files changed, 22 insertions, 9 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index dfce033..00a68a8 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -1629,6 +1629,14 @@ int cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
return 0;
}
+# if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM >= 0x072000
+const CURLoption CM_CURLOPT_XFERINFOFUNCTION = CURLOPT_XFERINFOFUNCTION;
+using cm_curl_off_t = curl_off_t;
+# else
+const CURLoption CM_CURLOPT_XFERINFOFUNCTION = CURLOPT_PROGRESSFUNCTION;
+using cm_curl_off_t = double;
+# endif
+
class cURLProgressHelper
{
public:
@@ -1638,12 +1646,14 @@ public:
{
}
- bool UpdatePercentage(double value, double total, std::string& status)
+ bool UpdatePercentage(cm_curl_off_t value, cm_curl_off_t total,
+ std::string& status)
{
long OldPercentage = this->CurrentPercentage;
- if (total > 0.0) {
- this->CurrentPercentage = std::lround(value / total * 100.0);
+ if (total > 0) {
+ this->CurrentPercentage = std::lround(
+ static_cast<double>(value) / static_cast<double>(total) * 100.0);
if (this->CurrentPercentage > 100) {
// Avoid extra progress reports for unexpected data beyond total.
this->CurrentPercentage = 100;
@@ -1668,8 +1678,9 @@ private:
std::string Text;
};
-int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+int cmFileDownloadProgressCallback(void* clientp, cm_curl_off_t dltotal,
+ cm_curl_off_t dlnow, cm_curl_off_t ultotal,
+ cm_curl_off_t ulnow)
{
cURLProgressHelper* helper = reinterpret_cast<cURLProgressHelper*>(clientp);
@@ -1685,8 +1696,9 @@ int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow,
return 0;
}
-int cmFileUploadProgressCallback(void* clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+int cmFileUploadProgressCallback(void* clientp, cm_curl_off_t dltotal,
+ cm_curl_off_t dlnow, cm_curl_off_t ultotal,
+ cm_curl_off_t ulnow)
{
cURLProgressHelper* helper = reinterpret_cast<cURLProgressHelper*>(clientp);
@@ -2062,7 +2074,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
check_curl_result(res, "DOWNLOAD cannot set noprogress value: ");
- res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
+ res = ::curl_easy_setopt(curl, CM_CURLOPT_XFERINFOFUNCTION,
cmFileDownloadProgressCallback);
check_curl_result(res, "DOWNLOAD cannot set progress function: ");
@@ -2376,7 +2388,7 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
check_curl_result(res, "UPLOAD cannot set noprogress value: ");
- res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
+ res = ::curl_easy_setopt(curl, CM_CURLOPT_XFERINFOFUNCTION,
cmFileUploadProgressCallback);
check_curl_result(res, "UPLOAD cannot set progress function: ");
diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp
index b0ed911..b4fb76e 100644
--- a/Utilities/IWYU/mapping.imp
+++ b/Utilities/IWYU/mapping.imp
@@ -101,6 +101,7 @@
# Wrappers for 3rd-party libraries
{ include: [ "@<.*curl/curlver.h>", private, "<cm3p/curl/curl.h>", public ] },
+ { include: [ "@<.*curl/system.h>", private, "<cm3p/curl/curl.h>", public ] },
{ include: [ "@<.*json/config.h>", private, "<cm3p/json/value.h>", public ] },
{ include: [ "@<.*json/forwards.h>", private, "<cm3p/json/value.h>", public ] },
{ include: [ "@<.*uv/.+\\.h>", private, "<cm3p/uv.h>", public ] },