Imported Upstream version 7.40.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_XFERINFOFUNCTION.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2014, 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 http://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_XFERINFOFUNCTION 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
24 .SH NAME
25 CURLOPT_XFERINFOFUNCTION \- callback to progress meter function
26 .SH SYNOPSIS
27 #include <curl/curl.h>
28
29 int progress_callback(void *clientp,
30                       curl_off_t dltotal,
31                       curl_off_t dlnow,
32                       curl_off_t ultotal,
33                       curl_off_t ulnow);
34
35 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_XFERINFOFUNCTION, progress_callback);
36 .SH DESCRIPTION
37 Pass a pointer to your callback function, which should match the prototype
38 shown above.
39
40 This function gets called by libcurl instead of its internal equivalent with a
41 frequent interval. While data is being transferred it will be called very
42 frequently, and during slow periods like when nothing is being transferred it
43 can slow down to about one call per second.
44
45 \fIclientp\fP is the pointer set with \fICURLOPT_XFERINFODATA(3)\fP, it is not
46 used by libcurl but is only passed along from the application to the callback.
47
48 The callback gets told how much data libcurl will transfer and has
49 transferred, in number of bytes. \fIdltotal\fP is the total number of bytes
50 libcurl expects to download in this transfer. \fIdlnow\fP is the number of
51 bytes downloaded so far. \fIultotal\fP is the total number of bytes libcurl
52 expects to upload in this transfer. \fIulnow\fP is the number of bytes
53 uploaded so far.
54
55 Unknown/unused argument values passed to the callback will be set to zero
56 (like if you only download data, the upload size will remain 0). Many times
57 the callback will be called one or more times first, before it knows the data
58 sizes so a program must be made to handle that.
59
60 Returning a non-zero value from this callback will cause libcurl to abort the
61 transfer and return \fICURLE_ABORTED_BY_CALLBACK\fP.
62
63 If you transfer data with the multi interface, this function will not be
64 called during periods of idleness unless you call the appropriate libcurl
65 function that performs transfers.
66
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's rarely wanted by
71 users.
72 .SH PROTOCOLS
73 All
74 .SH EXAMPLE
75 http://curl.haxx.se/libcurl/c/progressfunc.html
76 .SH AVAILABILITY
77 Added in 7.32.0. This callback replaces \fICURLOPT_PROGRESSFUNCTION(3)\fP
78 .SH RETURN VALUE
79 Returns CURLE_OK.
80 .SH "SEE ALSO"
81 .BR CURLOPT_XFERINFODATA "(3), " CURLOPT_NOPROGRESS "(3), "