cURL version/OS in question is 7.15 and Red Hat 5, these are set in stone though so cannot change them.
The actual progress function which is not being called at all
int CurlUtil::progressCallback(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
{
DEFN_METHOD_NAME( "progressCallback" );
EX_ENTRY_EXIT();
EX_DEBUG("Total downloaded " << dlnow << "/" << dltotal);
EX_DEBUG("Total uploaded " << ulnow << "/" << ultotal);
CurlUtil* curlUtil = (CurlUtil*)clientp;
// If you return anything but 0, curl will abort transfer
return (true == curlUtil->killed()) ? 1 : 0;
}
The setup code:
curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, CurlUtil::progressCallback);
curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, this)
Where CurlUtil is the class that the code exists in. The CURLOPT_DEBUGFUNCTION works fine and is set up in the exact same function in the same way.
the problem is with calling convention of the call back function. It needs to __cdecl or /Gd option for gcc compilers. Please check compiler options if the function is already static. C++ member functions are called with thiscall calling conventions. Look at the following link, it provided more cleaner way if you want to have class that is responsible for handling transfer status and statistics: How can I use a member function pointer in libcurl
PS: My edit was slower as I was cross verifying. Hence posting as an answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With