CURLOPT_CHUNK_DATA.3 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.haxx.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_CHUNK_DATA 3 "May 31, 2017" "libcurl 7.61.1" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_CHUNK_DATA \- custom pointer to the FTP chunk callbacks
  26. .SH SYNOPSIS
  27. #include <curl/curl.h>
  28. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void *pointer);
  29. .SH DESCRIPTION
  30. Pass a \fIpointer\fP that will be untouched by libcurl and passed as the ptr
  31. argument to the \fICURLOPT_CHUNK_BGN_FUNCTION(3)\fP and
  32. \fICURLOPT_CHUNK_END_FUNCTION(3)\fP.
  33. .SH DEFAULT
  34. NULL
  35. .SH PROTOCOLS
  36. FTP
  37. .SH EXAMPLE
  38. .nf
  39. static long file_is_coming(struct curl_fileinfo *finfo,
  40. struct callback_data *data,
  41. int remains)
  42. {
  43. printf("%3d %40s %10luB ", remains, finfo->filename,
  44. (unsigned long)finfo->size);
  45. switch(finfo->filetype) {
  46. case CURLFILETYPE_DIRECTORY:
  47. printf(" DIR\n");
  48. break;
  49. case CURLFILETYPE_FILE:
  50. printf("FILE ");
  51. break;
  52. default:
  53. printf("OTHER\n");
  54. break;
  55. }
  56. if(finfo->filetype == CURLFILETYPE_FILE) {
  57. /* do not transfer files >= 50B */
  58. if(finfo->size > 50) {
  59. printf("SKIPPED\n");
  60. return CURL_CHUNK_BGN_FUNC_SKIP;
  61. }
  62. data->output = fopen(finfo->filename, "wb");
  63. if(!data->output) {
  64. return CURL_CHUNK_BGN_FUNC_FAIL;
  65. }
  66. }
  67. return CURL_CHUNK_BGN_FUNC_OK;
  68. }
  69. int main()
  70. {
  71. /* data for callback */
  72. struct callback_data callback_info;
  73. /* callback is called before download of concrete file started */
  74. curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
  75. curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
  76. }
  77. .fi
  78. .SH AVAILABILITY
  79. Added in 7.21.0
  80. .SH RETURN VALUE
  81. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  82. .SH "SEE ALSO"
  83. .BR CURLOPT_CHUNK_BGN_FUNCTION "(3), " CURLOPT_WILDCARDMATCH "(3), "