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