CURLOPT_PROGRESSFUNCTION.3 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_PROGRESSFUNCTION 3 "17 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_PROGRESSFUNCTION \- progress meter callback
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. int progress_callback(void *clientp,
  32. double dltotal,
  33. double dlnow,
  34. double ultotal,
  35. double ulnow);
  36. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION,
  37. progress_callback);
  38. .fi
  39. .SH DESCRIPTION
  40. Pass a pointer to your callback function, which should match the prototype
  41. shown above.
  42. This option is deprecated and we encourage users to use the
  43. newer \fICURLOPT_XFERINFOFUNCTION(3)\fP instead, if you can.
  44. This function gets called by libcurl instead of its internal equivalent with a
  45. frequent interval. While data is being transferred it will be called
  46. frequently, and during slow periods like when nothing is being transferred it
  47. can slow down to about one call per second.
  48. \fIclientp\fP is the pointer set with \fICURLOPT_PROGRESSDATA(3)\fP, it is not
  49. used by libcurl but is only passed along from the application to the callback.
  50. The callback gets told how much data libcurl will transfer and has
  51. transferred, in number of bytes. \fIdltotal\fP is the total number of bytes
  52. libcurl expects to download in this transfer. \fIdlnow\fP is the number of
  53. bytes downloaded so far. \fIultotal\fP is the total number of bytes libcurl
  54. expects to upload in this transfer. \fIulnow\fP is the number of bytes
  55. uploaded so far.
  56. Unknown/unused argument values passed to the callback will be set to zero
  57. (like if you only download data, the upload size will remain 0). Many times
  58. the callback will be called one or more times first, before it knows the data
  59. sizes so a program must be made to handle that.
  60. If your callback function returns CURL_PROGRESSFUNC_CONTINUE it will cause
  61. libcurl to continue executing the default progress function.
  62. Returning any other non-zero value from this callback will cause libcurl to
  63. abort the transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
  64. If you transfer data with the multi interface, this function will not be
  65. called during periods of idleness unless you call the appropriate libcurl
  66. function that performs transfers.
  67. \fICURLOPT_NOPROGRESS(3)\fP must be set to 0 to make this function actually
  68. get called.
  69. .SH DEFAULT
  70. By default, libcurl has an internal progress meter. That is rarely wanted by
  71. users.
  72. .SH PROTOCOLS
  73. All
  74. .SH EXAMPLE
  75. .nf
  76. struct progress {
  77. char *private;
  78. size_t size;
  79. };
  80. static size_t progress_callback(void *clientp,
  81. double dltotal,
  82. double dlnow,
  83. double ultotal,
  84. double ulnow)
  85. {
  86. struct progress *memory = (struct progress *)clientp;
  87. /* use the values */
  88. return 0; /* all is good */
  89. }
  90. struct progress data;
  91. /* pass struct to callback */
  92. curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, &data);
  93. curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
  94. .fi
  95. .SH AVAILABILITY
  96. Deprecated since 7.32.0.
  97. .SH RETURN VALUE
  98. Returns CURLE_OK.
  99. .SH "SEE ALSO"
  100. .BR CURLOPT_VERBOSE "(3), " CURLOPT_NOPROGRESS "(3), "
  101. .BR CURLOPT_XFERINFOFUNCTION "(3)"