CURLOPT_CH...D_FUNCTION(3)
π CURLOPT_CH...D_FUNCTION(3) π
ok so quick vibe check: this is a Library Functions Manual page, bestie β specifically CURLOPT_CH...D_FUNCTION(3). yes the title is literally truncated with dots, that's just how it's printed, don't come for me π
β¨ NAME β¨
CURLOPT_CHUNK_END_FUNCTION β the callback that fires after a transfer with FTP wildcard match π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
long chunk_end_callback(void *ptr);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION,
chunk_end_callback);
πΈ DESCRIPTION πΈ
So you pass in a pointer to your callback function, and it's gotta match the prototype up there β¬οΈ β long chunk_end_callback(void *ptr), no notes, periodt.
libcurl calls this function the literal second a part of the stream has been transferred (or skipped). it's giving "wrap-up era" β like the callback that shows up at the end of the group hang to make sure everyone got home safe π«Ά
Your return value is the whole vibe check:
- return
CURL_CHUNK_END_FUNC_OKif everything is, in fact, fine π - return
CURL_CHUNK_END_FUNC_FAILto tell the lib to stop if some error occurred π
π DEFAULT π
NULL
(no callback, no drama, iconic behaviour honestly)
π PROTOCOLS π
This functionality affects ftp only β FTP girlies only, everyone else sit this one out π
π§ EXAMPLE π§
#include <stdio.h>
struct callback_data {
FILE *output;
};
static long file_is_downloaded(void *ptr)
{
struct callback_data *data = ptr;
if(data->output) {
fclose(data->output);
data->output = 0x0;
}
return CURL_CHUNK_END_FUNC_OK;
}
int main()
{
/* data for callback */
struct callback_data callback_info;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
}
look at her go β closes the file, nulls the pointer to 0x0, returns CURL_CHUNK_END_FUNC_OK. main character energy, truly π
β AVAILABILITY β
Added in curl 7.21.0 β a classic, lowkey vintage, we stan a legacy icon π°οΈ
π₯ RETURN VALUE π₯
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK(0) means everything was OK β slay β- non-zero means an error occurred β not slay β
(see libcurl-errors(3) for the full list of what went wrong, iykyk)
π SEE ALSO π
ok that's the whole page, go be a wildcard-matching legend π
libcurl Β· 2026-10-12 Β· CURLOPT_CH...D_FUNCTION(3) β mwah, bye bestie, see u in the manpages πβ¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms