1CURLOPT_PROGRESSFUNCTION(3)curl_easy_setopt optionsCURLOPT_PROGRESSFUNCTION(3)
2
3
4

NAME

6       CURLOPT_PROGRESSFUNCTION - progress meter callback
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       int progress_callback(void *clientp,
12                             double dltotal,
13                             double dlnow,
14                             double ultotal,
15                             double ulnow);
16
17       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION,
18                                 progress_callback);
19

DESCRIPTION

21       Pass a pointer to your callback function, which should match the proto‐
22       type shown above.
23
24       We encourage users to use  the  newer  CURLOPT_XFERINFOFUNCTION(3)  in‐
25       stead, if you can.
26
27       This function gets called by libcurl instead of its internal equivalent
28       with a frequent interval. While data is being transferred  it  will  be
29       called  frequently,  and during slow periods like when nothing is being
30       transferred it can slow down to about one call per second.
31
32       clientp is the pointer set with CURLOPT_PROGRESSDATA(3), it is not used
33       by  libcurl  but is only passed along from the application to the call‐
34       back.
35
36       The callback gets told how much data  libcurl  will  transfer  and  has
37       transferred,  in  number of bytes. dltotal is the total number of bytes
38       libcurl expects to download in this transfer. dlnow is  the  number  of
39       bytes  downloaded  so far. ultotal is the total number of bytes libcurl
40       expects to upload in this transfer. ulnow is the number  of  bytes  up‐
41       loaded so far.
42
43       Unknown/unused  argument  values  passed to the callback will be set to
44       zero (like if you only download data, the upload size will  remain  0).
45       Many  times the callback will be called one or more times first, before
46       it knows the data sizes so a program must be made to handle that.
47
48       If your callback function returns  CURL_PROGRESSFUNC_CONTINUE  it  will
49       cause libcurl to continue executing the default progress function.
50
51       Returning  any  other  non-zero  value  from  this  callback will cause
52       libcurl to abort the transfer and return CURLE_ABORTED_BY_CALLBACK.
53
54       If you transfer data with the multi interface, this function  will  not
55       be  called  during  periods of idleness unless you call the appropriate
56       libcurl function that performs transfers.
57
58       CURLOPT_NOPROGRESS(3) must be set to 0 to make this  function  actually
59       get called.
60

DEFAULT

62       By  default,  libcurl  has  an  internal progress meter. That is rarely
63       wanted by users.
64

PROTOCOLS

66       All
67

EXAMPLE

69        struct progress {
70          char *private;
71          size_t size;
72        };
73
74        static size_t progress_callback(void *clientp,
75                                        double dltotal,
76                                        double dlnow,
77                                        double ultotal,
78                                        double ulnow)
79        {
80          struct progress *memory = (struct progress *)clientp;
81
82          /* use the values */
83
84          return 0; /* all is good */
85        }
86
87        struct progress data;
88
89        /* pass struct to callback  */
90        curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, &data);
91
92        curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
93

AVAILABILITY

95       Always
96

RETURN VALUE

98       Returns CURLE_OK.
99

SEE ALSO

101       CURLOPT_VERBOSE(3), CURLOPT_NOPROGRESS(3),
102
103
104
105libcurl 7.85.0                   May 17, 2022      CURLOPT_PROGRESSFUNCTION(3)
Impressum