CURLOPT_CHUNK_DATA.3 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_CHUNK_DATA 3 "19 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_CHUNK_DATA \- pointer passed to the FTP chunk callbacks
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CHUNK_DATA, void *pointer);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a \fIpointer\fP that will be untouched by libcurl and passed as the ptr
  35. argument to the \fICURLOPT_CHUNK_BGN_FUNCTION(3)\fP and
  36. \fICURLOPT_CHUNK_END_FUNCTION(3)\fP.
  37. .SH DEFAULT
  38. NULL
  39. .SH PROTOCOLS
  40. FTP
  41. .SH EXAMPLE
  42. .nf
  43. static long file_is_coming(struct curl_fileinfo *finfo,
  44. struct callback_data *data,
  45. int remains)
  46. {
  47. printf("%3d %40s %10luB ", remains, finfo->filename,
  48. (unsigned long)finfo->size);
  49. switch(finfo->filetype) {
  50. case CURLFILETYPE_DIRECTORY:
  51. printf(" DIR\\n");
  52. break;
  53. case CURLFILETYPE_FILE:
  54. printf("FILE ");
  55. break;
  56. default:
  57. printf("OTHER\\n");
  58. break;
  59. }
  60. if(finfo->filetype == CURLFILETYPE_FILE) {
  61. /* do not transfer files >= 50B */
  62. if(finfo->size > 50) {
  63. printf("SKIPPED\\n");
  64. return CURL_CHUNK_BGN_FUNC_SKIP;
  65. }
  66. data->output = fopen(finfo->filename, "wb");
  67. if(!data->output) {
  68. return CURL_CHUNK_BGN_FUNC_FAIL;
  69. }
  70. }
  71. return CURL_CHUNK_BGN_FUNC_OK;
  72. }
  73. int main()
  74. {
  75. /* data for callback */
  76. struct callback_data callback_info;
  77. /* callback is called before download of concrete file started */
  78. curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
  79. curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
  80. }
  81. .fi
  82. .SH AVAILABILITY
  83. Added in 7.21.0
  84. .SH RETURN VALUE
  85. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  86. .SH "SEE ALSO"
  87. .BR CURLOPT_CHUNK_BGN_FUNCTION "(3), " CURLOPT_WILDCARDMATCH "(3), "