Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_CHUNK_DATA.3
index 1ceb2ce..9636a11 100644 (file)
@@ -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
@@ -20,7 +20,8 @@
 .\" *
 .\" **************************************************************************
 .\"
-.TH CURLOPT_CHUNK_DATA 3 "19 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
+.TH CURLOPT_CHUNK_DATA 3 "May 31, 2017" "libcurl 7.59.0" "curl_easy_setopt options"
+
 .SH NAME
 CURLOPT_CHUNK_DATA \- custom pointer to the FTP chunk callbacks
 .SH SYNOPSIS
@@ -36,7 +37,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