GNURLOPT_CHUNK_END_FUNCTION(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸŽ€ GNURLOPT_CHUNK_END_FUNCTION(3) πŸŽ€

okay so you're on the curl_easy_setopt options manual page, and this particular icon is all about CURLOPT_CHUNK_END_FUNCTION. Bestie, it's the callback that happens after a transfer with FTP wildcardmatch. periodt. πŸ’…

πŸ’– NAME πŸ’–

CURLOPT_CHUNK_END_FUNCTION β€” callback after a transfer with FTP wildcardmatch. πŸ¦‹

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

long chunk_end_callback(void *ptr);

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION,
                          chunk_end_callback);

🌸 DESCRIPTION 🌸

okay so the whole thing is: you pass a pointer to your callback function, and it should match the prototype shown above. No cap.

libcurl calls this function as soon as a part of the stream has been transferred (or skipped). That's the moment. ⭐

When everything is fine, return CURL_CHUNK_END_FUNC_OK. If some error occurred and you need to tell the lib to stop, return CURL_CHUNK_END_FUNC_FAIL. That's the whole vibe check. πŸ’€

πŸŽ€ DEFAULT πŸŽ€

NULL β€” literally just NULL. No callback, no drama. πŸ™ˆ

🌈 PROTOCOLS 🌈

FTP β€” that's it, bestie. πŸ’œ

πŸ“ EXAMPLE πŸ“

Here's the example in all its code-glory, literal and exact:

static long file_is_downloaded(struct callback_data *data)
{
  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_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
  curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
}

πŸ‘‘ AVAILABILITY πŸ‘‘

Added in 7.21.0. She's been here a minute. ✨

🫢 RETURN VALUE 🫢

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Simple as that. πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹


peace out and happy wildcard matching, bestie πŸ’… β€” this page is from libcurl 7.37.0, dated 19 Jun 2014. 🫢

πŸ“¦ where this page comes from