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