CURLOPT_PROGRESSFUNCTION what these parameters mea

2019-06-13 14:57发布

问题:

In libcurl, what the parameters mean in the function called by setting CURLOPT_PROGRESSFUNCTION?

int function(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);

Its a lame question I know but the website doesn't seem to describe, or I wasn't able to find :(

回答1:

This example might help. To summarize:

int function(
  void *clientp,  // this is an unchanged pointer as set with CURLOPT_PROGRESSDATA
  double dltotal, // the total bytes to be downloaded (or 0 if not downloading)
  double dlnow,   // the current download bytecount (or 0 if not downloading)
  double ultotal, // the total bytes to be uploaded (or 0 if not uploading)
  double ulnow);  // the current upload bytecount (or 0 if not uploading)

See CURLOPT_PROGRESSDATA for clientp. If you return any value other than 0 from the callback, the transfer will be cancelled.



标签: c++ libcurl