1CURLOPT_CHUNK_DATA(3)      curl_easy_setopt options      CURLOPT_CHUNK_DATA(3)
2
3
4

NAME

6       CURLOPT_CHUNK_DATA - pointer passed to the FTP chunk callbacks
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void *pointer);
12

DESCRIPTION

14       Pass  a pointer that will be untouched by libcurl and passed as the ptr
15       argument    to    the    CURLOPT_CHUNK_BGN_FUNCTION(3)     and     CUR‐
16       LOPT_CHUNK_END_FUNCTION(3).
17

DEFAULT

19       NULL
20

PROTOCOLS

22       FTP
23

EXAMPLE

25       static long file_is_coming(struct curl_fileinfo *finfo,
26                                  struct callback_data *data,
27                                  int remains)
28       {
29         printf("%3d %40s %10luB ", remains, finfo->filename,
30                (unsigned long)finfo->size);
31
32         switch(finfo->filetype) {
33         case CURLFILETYPE_DIRECTORY:
34           printf(" DIR\n");
35           break;
36         case CURLFILETYPE_FILE:
37           printf("FILE ");
38           break;
39         default:
40           printf("OTHER\n");
41           break;
42         }
43
44         if(finfo->filetype == CURLFILETYPE_FILE) {
45           /* do not transfer files >= 50B */
46           if(finfo->size > 50) {
47             printf("SKIPPED\n");
48             return CURL_CHUNK_BGN_FUNC_SKIP;
49           }
50
51           data->output = fopen(finfo->filename, "wb");
52           if(!data->output) {
53             return CURL_CHUNK_BGN_FUNC_FAIL;
54           }
55         }
56
57         return CURL_CHUNK_BGN_FUNC_OK;
58       }
59
60       int main()
61       {
62         /* data for callback */
63         struct callback_data callback_info;
64
65         /* callback is called before download of concrete file started */
66         curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
67         curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
68       }
69

AVAILABILITY

71       Added in 7.21.0
72

RETURN VALUE

74       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
75       if not.
76

SEE ALSO

78       CURLOPT_CHUNK_BGN_FUNCTION(3), CURLOPT_WILDCARDMATCH(3),
79
80
81
82libcurl 7.85.0                   May 17, 2022            CURLOPT_CHUNK_DATA(3)
Impressum