1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PROGRESSDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_PROGRESSFUNCTION (3)
9  - CURLOPT_XFERINFOFUNCTION (3)
10Protocol:
11  - All
12Added-in: 7.1
13---
14
15# NAME
16
17CURLOPT_PROGRESSDATA - 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_PROGRESSDATA, 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_PROGRESSFUNCTION(3).
31
32# DEFAULT
33
34NULL
35
36# %PROTOCOLS%
37
38# EXAMPLE
39
40~~~c
41struct progress {
42  char *private;
43  size_t size;
44};
45
46static size_t progress_callback(void *clientp,
47                                double dltotal,
48                                double dlnow,
49                                double ultotal,
50                                double ulnow)
51{
52  struct progress *memory = clientp;
53  printf("private: %p\n", memory->private);
54
55  /* use the values */
56
57  return 0; /* all is good */
58}
59
60int main(void)
61{
62  CURL *curl = curl_easy_init();
63  if(curl) {
64    struct progress data;
65
66    /* pass struct to callback  */
67    curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
68    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
69
70    curl_easy_perform(curl);
71  }
72}
73~~~
74
75# %AVAILABILITY%
76
77# RETURN VALUE
78
79Returns CURLE_OK
80