1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_CHUNK_END_FUNCTION 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_CHUNK_BGN_FUNCTION (3) 9 - CURLOPT_WILDCARDMATCH (3) 10--- 11 12# NAME 13 14CURLOPT_CHUNK_END_FUNCTION - callback after a transfer with FTP wildcard match 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21long chunk_end_callback(void *ptr); 22 23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION, 24 chunk_end_callback); 25~~~ 26 27# DESCRIPTION 28 29Pass a pointer to your callback function, which should match the prototype 30shown above. 31 32This function gets called by libcurl as soon as a part of the stream has been 33transferred (or skipped). 34 35Return *CURL_CHUNK_END_FUNC_OK* if everything is fine or 36**CURL_CHUNK_END_FUNC_FAIL** to tell the lib to stop if some error occurred. 37 38# DEFAULT 39 40NULL 41 42# PROTOCOLS 43 44FTP 45 46# EXAMPLE 47 48~~~c 49#include <stdio.h> 50 51struct callback_data { 52 FILE *output; 53}; 54 55static long file_is_downloaded(struct callback_data *data) 56{ 57 if(data->output) { 58 fclose(data->output); 59 data->output = 0x0; 60 } 61 return CURL_CHUNK_END_FUNC_OK; 62} 63 64int main() 65{ 66 /* data for callback */ 67 struct callback_data callback_info; 68 69 CURL *curl = curl_easy_init(); 70 71 curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded); 72 curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info); 73} 74~~~ 75 76# AVAILABILITY 77 78Added in 7.21.0 79 80# RETURN VALUE 81 82Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 83