1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at https://curl.haxx.se/docs/copyright.html.
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" **************************************************************************
23 .TH CURLOPT_CHUNK_BGN_FUNCTION 3 "May 31, 2017" "libcurl 7.59.0" "curl_easy_setopt options"
26 CURLOPT_CHUNK_BGN_FUNCTION \- callback before a transfer with FTP wildcardmatch
29 #include <curl/curl.h>
31 long chunk_bgn_callback(const void *transfer_info, void *ptr,
34 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_BGN_FUNCTION,
37 Pass a pointer to your callback function, which should match the prototype
40 This callback function gets called by libcurl before a part of the stream is
41 going to be transferred (if the transfer supports chunks).
43 The \fItransfer_info\fP pointer will point to a struct curl_fileinfo with
44 details about the file that is about to get transferred.
46 This callback makes sense only when using the \fICURLOPT_WILDCARDMATCH(3)\fP
49 The target of transfer_info parameter is a "feature depended" structure. For
50 the FTP wildcard download, the target is curl_fileinfo structure (see
51 \fIcurl/curl.h\fP). The parameter \fIptr\fP is a pointer given by
52 \fICURLOPT_CHUNK_DATA(3)\fP. The parameter remains contains number of chunks
53 remaining per the transfer. If the feature is not available, the parameter has
56 Return \fICURL_CHUNK_BGN_FUNC_OK\fP if everything is fine,
57 \fICURL_CHUNK_BGN_FUNC_SKIP\fP if you want to skip the concrete chunk or
58 \fICURL_CHUNK_BGN_FUNC_FAIL\fP to tell libcurl to stop if some error occurred.
65 static long file_is_coming(struct curl_fileinfo *finfo,
66 struct callback_data *data,
69 printf("%3d %40s %10luB ", remains, finfo->filename,
70 (unsigned long)finfo->size);
72 switch(finfo->filetype) {
73 case CURLFILETYPE_DIRECTORY:
76 case CURLFILETYPE_FILE:
84 if(finfo->filetype == CURLFILETYPE_FILE) {
85 /* do not transfer files >= 50B */
86 if(finfo->size > 50) {
88 return CURL_CHUNK_BGN_FUNC_SKIP;
91 data->output = fopen(finfo->filename, "wb");
93 return CURL_CHUNK_BGN_FUNC_FAIL;
97 return CURL_CHUNK_BGN_FUNC_OK;
102 /* data for callback */
103 struct callback_data callback_info;
105 /* callback is called before download of concrete file started */
106 curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
107 curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
111 This was added in 7.21.0
113 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
115 .BR CURLOPT_CHUNK_END_FUNCTION "(3), " CURLOPT_WILDCARDMATCH "(3), "