1CURLOPT_CHUNK_DATA(3) curl_easy_setopt options CURLOPT_CHUNK_DATA(3)
2
3
4
6 CURLOPT_CHUNK_DATA - custom pointer to the FTP chunk callbacks
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void
12 *pointer);
13
15 Pass a pointer that will be untouched by libcurl and passed as the ptr
16 argument to the CURLOPT_CHUNK_BGN_FUNCTION(3) and CUR‐
17 LOPT_CHUNK_END_FUNCTION(3).
18
20 NULL
21
23 FTP
24
26 static long file_is_coming(struct curl_fileinfo *finfo,
27 struct callback_data *data,
28 int remains)
29 {
30 printf("%3d %40s %10luB ", remains, finfo->filename,
31 (unsigned long)finfo->size);
32
33 switch(finfo->filetype) {
34 case CURLFILETYPE_DIRECTORY:
35 printf(" DIR\n");
36 break;
37 case CURLFILETYPE_FILE:
38 printf("FILE ");
39 break;
40 default:
41 printf("OTHER\n");
42 break;
43 }
44
45 if(finfo->filetype == CURLFILETYPE_FILE) {
46 /* do not transfer files >= 50B */
47 if(finfo->size > 50) {
48 printf("SKIPPED\n");
49 return CURL_CHUNK_BGN_FUNC_SKIP;
50 }
51
52 data->output = fopen(finfo->filename, "wb");
53 if(!data->output) {
54 return CURL_CHUNK_BGN_FUNC_FAIL;
55 }
56 }
57
58 return CURL_CHUNK_BGN_FUNC_OK;
59 }
60
61 int main()
62 {
63 /* data for callback */
64 struct callback_data callback_info;
65
66 /* callback is called before download of concrete file started */
67 curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
68 curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
69 }
70
72 Added in 7.21.0
73
75 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
76 if not.
77
79 CURLOPT_CHUNK_BGN_FUNCTION(3), CURLOPT_WILDCARDMATCH(3),
80
81
82
83libcurl 7.64.0 November 07, 2018 CURLOPT_CHUNK_DATA(3)