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