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