1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_XFERINFODATA 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_NOPROGRESS (3) 9 - CURLOPT_VERBOSE (3) 10 - CURLOPT_XFERINFOFUNCTION (3) 11Protocol: 12 - All 13--- 14 15# NAME 16 17CURLOPT_XFERINFODATA - pointer passed to the progress callback 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFODATA, void *pointer); 25~~~ 26 27# DESCRIPTION 28 29Pass a *pointer* that is untouched by libcurl and passed as the first 30argument in the progress callback set with CURLOPT_XFERINFOFUNCTION(3). 31 32This is an alias for CURLOPT_PROGRESSDATA(3). 33 34# DEFAULT 35 36The default value of this parameter is NULL. 37 38# EXAMPLE 39 40~~~c 41struct progress { 42 char *private; 43 size_t size; 44}; 45 46static size_t progress_cb(void *clientp, 47 curl_off_t dltotal, 48 curl_off_t dlnow, 49 curl_off_t ultotal, 50 curl_off_t ulnow) 51{ 52 struct progress *memory = clientp; 53 printf("private ptr: %p\n", memory->private); 54 /* use the values */ 55 56 return 0; /* all is good */ 57} 58 59int main(void) 60{ 61 CURL *curl = curl_easy_init(); 62 if(curl) { 63 struct progress data; 64 65 /* pass struct to callback */ 66 curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &data); 67 curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_cb); 68 } 69} 70~~~ 71 72# AVAILABILITY 73 74Added in 7.32.0 75 76# RETURN VALUE 77 78Returns CURLE_OK 79