[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 140/264: CURLOPT_WRITEFUNCTION.3: add inline example and new see
From: |
gnunet |
Subject: |
[gnurl] 140/264: CURLOPT_WRITEFUNCTION.3: add inline example and new see-also |
Date: |
Thu, 30 Apr 2020 16:07:23 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 946a71a14f8b397972bf07f446881c2faa25a926
Author: Daniel Stenberg <address@hidden>
AuthorDate: Mon Apr 6 18:14:10 2020 +0200
CURLOPT_WRITEFUNCTION.3: add inline example and new see-also
Closes #5192
---
docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3 | 37 +++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
index 11edeb2e9..254246ec1 100644
--- a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
+++ b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
+.\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <address@hidden>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -76,8 +76,37 @@ Support for the CURL_WRITEFUNC_PAUSE return code was added
in version 7.18.0.
.SH RETURN VALUE
This will return CURLE_OK.
.SH EXAMPLE
-A common technique is to use this callback to store the incoming data into a
-dynamically growing allocated buffer. Like in the getinmemory example:
-https://curl.haxx.se/libcurl/c/getinmemory.html
+.NF
+ struct memory {
+ char *response;
+ size_t size;
+ };
+
+ static size_t cb(void *data, size_t size, size_t nmemb, void *userp)
+ {
+ size_t realsize = size * nmemb;
+ struct memory *mem = (struct memory *)userp;
+
+ char *ptr = realloc(mem->response, mem->size + realsize + 1);
+ if(ptr == NULL)
+ return 0; /* out of memory! */
+
+ mem->response = ptr;
+ memcpy(&(mem->response[mem->size]), data, realsize);
+ mem->size += realsize;
+ mem->response[mem->size] = 0;
+
+ return realsize;
+ }
+
+ struct memory chunk;
+
+ /* send all data to this function */
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, cb);
+
+ /* we pass our 'chunk' struct to the callback function */
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
+.FI
.SH "SEE ALSO"
.BR CURLOPT_WRITEDATA "(3), " CURLOPT_READFUNCTION "(3), "
+.BR CURLOPT_HEADERFUNCTION "(3), "
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 15/264: tests: remove python_dependencies for smbserver from our tree, (continued)
- [gnurl] 15/264: tests: remove python_dependencies for smbserver from our tree, gnunet, 2020/04/30
- [gnurl] 94/264: curl.h: remnove CURL_VERSION_ESNI. Never supported nor documented, gnunet, 2020/04/30
- [gnurl] 96/264: dist: add tests/version-scan.pl to tarball, gnunet, 2020/04/30
- [gnurl] 99/264: ngtcp2: update to git master for the key installation API change, gnunet, 2020/04/30
- [gnurl] 129/264: lib670: use the same Win32 API check as all other lib tests, gnunet, 2020/04/30
- [gnurl] 102/264: cleanup: insert newline after if() conditions, gnunet, 2020/04/30
- [gnurl] 87/264: mailmap: fixup a few author names/fields, gnunet, 2020/04/30
- [gnurl] 86/264: version: add 'cainfo' and 'capath' to version info struct, gnunet, 2020/04/30
- [gnurl] 100/264: cmake: add CMAKE_MSVC_RUNTIME_LIBRARY, gnunet, 2020/04/30
- [gnurl] 135/264: dist: add missing setup-win32.h, gnunet, 2020/04/30
- [gnurl] 140/264: CURLOPT_WRITEFUNCTION.3: add inline example and new see-also,
gnunet <=
- [gnurl] 106/264: examples/sessioninfo.c: add include to fix compiler warning, gnunet, 2020/04/30
- [gnurl] 142/264: tests/README: update the port numbers list, gnunet, 2020/04/30
- [gnurl] 105/264: misc: copyright year updates, gnunet, 2020/04/30
- [gnurl] 108/264: CI: add build with ngtcp2 + gnutls on Travis CI, gnunet, 2020/04/30
- [gnurl] 77/264: CI: bring GitHub Actions fuzzing job in line with macOS jobs, gnunet, 2020/04/30
- [gnurl] 80/264: dist: add mail-rcpt-allowfails.d to the tarball, gnunet, 2020/04/30
- [gnurl] 83/264: sockfilt: add logmsg output to select_ws_wait_thread on Windows, gnunet, 2020/04/30
- [gnurl] 107/264: vquic: add support for GnuTLS backend of ngtcp2, gnunet, 2020/04/30
- [gnurl] 112/264: ftpserver.pl: log before and after data connection is closed, gnunet, 2020/04/30
- [gnurl] 113/264: runtests.pl: log host OS as detected by Perl environment, gnunet, 2020/04/30