aboutsummaryrefslogtreecommitdiff
path: root/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3
diff options
context:
space:
mode:
Diffstat (limited to 'docs/libcurl/opts/CURLOPT_CHUNK_DATA.3')
-rw-r--r--docs/libcurl/opts/CURLOPT_CHUNK_DATA.349
1 files changed, 47 insertions, 2 deletions
diff --git a/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3 b/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3
index 1ceb2cea2..6a734e58c 100644
--- a/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3
+++ b/docs/libcurl/opts/CURLOPT_CHUNK_DATA.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -36,7 +36,52 @@ NULL
.SH PROTOCOLS
FTP
.SH EXAMPLE
-TODO
+.nf
+static long file_is_coming(struct curl_fileinfo *finfo,
+ struct callback_data *data,
+ int remains)
+{
+ printf("%3d %40s %10luB ", remains, finfo->filename,
+ (unsigned long)finfo->size);
+
+ switch(finfo->filetype) {
+ case CURLFILETYPE_DIRECTORY:
+ printf(" DIR\n");
+ break;
+ case CURLFILETYPE_FILE:
+ printf("FILE ");
+ break;
+ default:
+ printf("OTHER\n");
+ break;
+ }
+
+ if(finfo->filetype == CURLFILETYPE_FILE) {
+ /* do not transfer files >= 50B */
+ if(finfo->size > 50) {
+ printf("SKIPPED\n");
+ return CURL_CHUNK_BGN_FUNC_SKIP;
+ }
+
+ data->output = fopen(finfo->filename, "wb");
+ if(!data->output) {
+ return CURL_CHUNK_BGN_FUNC_FAIL;
+ }
+ }
+
+ return CURL_CHUNK_BGN_FUNC_OK;
+}
+
+int main()
+{
+ /* data for callback */
+ struct callback_data callback_info;
+
+ /* callback is called before download of concrete file started */
+ curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
+ curl_easy_setopt(curl, CURLOPT_CHUNK_DATA, &callback_info);
+}
+.fi
.SH AVAILABILITY
Added in 7.21.0
.SH RETURN VALUE