diff options
Diffstat (limited to 'docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3')
-rw-r--r-- | docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 b/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 index 9d3387877..09e4526e3 100644 --- a/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 +++ b/docs/libcurl/opts/CURLOPT_PROGRESSFUNCTION.3 @@ -5,11 +5,11 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. +.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms -.\" * are also available at https://curl.haxx.se/docs/copyright.html. +.\" * are also available at https://curl.se/docs/copyright.html. .\" * .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell .\" * copies of the Software, and permit persons to whom the Software is @@ -20,11 +20,12 @@ .\" * .\" ************************************************************************** .\" -.TH CURLOPT_PROGRESSFUNCTION 3 "March 23, 2020" "libcurl 7.73.0" "curl_easy_setopt options" +.TH CURLOPT_PROGRESSFUNCTION 3 "November 26, 2021" "libcurl 7.81.0" "curl_easy_setopt options" .SH NAME -CURLOPT_PROGRESSFUNCTION \- callback to progress meter function +CURLOPT_PROGRESSFUNCTION \- progress meter callback .SH SYNOPSIS +.nf #include <curl/curl.h> int progress_callback(void *clientp, @@ -33,7 +34,9 @@ int progress_callback(void *clientp, double ultotal, double ulnow); -CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION, progress_callback); +CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION, + progress_callback); +.fi .SH DESCRIPTION Pass a pointer to your callback function, which should match the prototype shown above. @@ -42,7 +45,7 @@ We encourage users to use the newer \fICURLOPT_XFERINFOFUNCTION(3)\fP instead, if you can. This function gets called by libcurl instead of its internal equivalent with a -frequent interval. While data is being transferred it will be called very +frequent interval. While data is being transferred it will be called frequently, and during slow periods like when nothing is being transferred it can slow down to about one call per second. @@ -74,12 +77,37 @@ function that performs transfers. \fICURLOPT_NOPROGRESS(3)\fP must be set to 0 to make this function actually get called. .SH DEFAULT -By default, libcurl has an internal progress meter. That's rarely wanted by +By default, libcurl has an internal progress meter. That is rarely wanted by users. .SH PROTOCOLS All .SH EXAMPLE -https://curl.haxx.se/libcurl/c/progressfunc.html +.nf + struct progress { + char *private; + size_t size; + }; + + static size_t progress_callback(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow) + { + struct memory *progress = (struct progress *)userp; + + /* use the values */ + + return 0; /* all is good */ + } + + struct progress data; + + /* pass struct to callback */ + curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, &data); + + curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback); +.fi .SH AVAILABILITY Always .SH RETURN VALUE |