1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PROGRESSDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_PROGRESSFUNCTION (3)
9  - CURLOPT_XFERINFOFUNCTION (3)
10---
11
12# NAME
13
14CURLOPT_PROGRESSDATA - pointer passed to the progress callback
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSDATA, void *pointer);
22~~~
23
24# DESCRIPTION
25
26Pass a *pointer* that is untouched by libcurl and passed as the first
27argument in the progress callback set with CURLOPT_PROGRESSFUNCTION(3).
28
29# DEFAULT
30
31The default value of this parameter is NULL.
32
33# PROTOCOLS
34
35All
36
37# EXAMPLE
38
39~~~c
40struct progress {
41  char *private;
42  size_t size;
43};
44
45static size_t progress_callback(void *clientp,
46                                double dltotal,
47                                double dlnow,
48                                double ultotal,
49                                double ulnow)
50{
51  struct progress *memory = clientp;
52  printf("private: %p\n", memory->private);
53
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_PROGRESSDATA, &data);
67    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
68
69    curl_easy_perform(curl);
70  }
71}
72~~~
73
74# AVAILABILITY
75
76Always
77
78# RETURN VALUE
79
80Returns CURLE_OK
81