CURLOPT_CHUNK_END_FUNCTION.3 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. .\" generated by cd2nroff 0.1 from CURLOPT_CHUNK_END_FUNCTION.md
  2. .TH CURLOPT_CHUNK_END_FUNCTION 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_CHUNK_END_FUNCTION \- callback after a transfer with FTP wildcard match
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. long chunk_end_callback(void *ptr);
  9. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_END_FUNCTION,
  10. chunk_end_callback);
  11. .fi
  12. .SH DESCRIPTION
  13. Pass a pointer to your callback function, which should match the prototype
  14. shown above.
  15. This function gets called by libcurl as soon as a part of the stream has been
  16. transferred (or skipped).
  17. Return \fICURL_CHUNK_END_FUNC_OK\fP if everything is fine or
  18. \fBCURL_CHUNK_END_FUNC_FAIL\fP to tell the lib to stop if some error occurred.
  19. .SH DEFAULT
  20. NULL
  21. .SH PROTOCOLS
  22. This functionality affects ftp only
  23. .SH EXAMPLE
  24. .nf
  25. #include <stdio.h>
  26. struct callback_data {
  27. FILE *output;
  28. };
  29. static long file_is_downloaded(struct callback_data *data)
  30. {
  31. if(data->output) {
  32. fclose(data->output);
  33. data->output = 0x0;
  34. }
  35. return CURL_CHUNK_END_FUNC_OK;
  36. }
  37. int main()
  38. {
  39. /* data for callback */
  40. struct callback_data callback_info;
  41. CURL *curl = curl_easy_init();
  42. curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
  43. curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
  44. }
  45. .fi
  46. .SH AVAILABILITY
  47. Added in curl 7.21.0
  48. .SH RETURN VALUE
  49. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  50. .SH SEE ALSO
  51. .BR CURLOPT_CHUNK_BGN_FUNCTION (3),
  52. .BR CURLOPT_WILDCARDMATCH (3)