[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 107/220: CURLOPT_READFUNCTION.3: provide inline exa
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 107/220: CURLOPT_READFUNCTION.3: provide inline example |
Date: |
Thu, 12 Sep 2019 17:27:47 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit f88d865bf4612ee9ce6b311952ae6d2f2bbf05c0
Author: Daniel Stenberg <address@hidden>
AuthorDate: Mon Aug 12 09:20:04 2019 +0200
CURLOPT_READFUNCTION.3: provide inline example
... instead of mentioning one in another place
---
docs/libcurl/opts/CURLOPT_READFUNCTION.3 | 33 ++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/docs/libcurl/opts/CURLOPT_READFUNCTION.3
b/docs/libcurl/opts/CURLOPT_READFUNCTION.3
index df6681c38..30b0925eb 100644
--- a/docs/libcurl/opts/CURLOPT_READFUNCTION.3
+++ b/docs/libcurl/opts/CURLOPT_READFUNCTION.3
@@ -69,8 +69,37 @@ The default internal read callback is fread().
.SH PROTOCOLS
This is used for all protocols when doing uploads.
.SH EXAMPLE
-Here's an example setting a read callback for reading that to upload to an FTP
-site: https://curl.haxx.se/libcurl/c/ftpupload.html
+.nf
+size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+ FILE *readhere = (FILE *)userdata;
+ curl_off_t nread;
+
+ /* copy as much data as possible into the 'ptr' buffer, but no more than
+ 'size' * 'nmemb' bytes! */
+ size_t retcode = fread(ptr, size, nmemb, readhere);
+
+ nread = (curl_off_t)retcode;
+
+ fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
+ " bytes from file\\n", nread);
+ return retcode;
+}
+
+void setup(char *uploadthis)
+{
+ FILE *file = fopen("rb", uploadthis);
+ CURLcode result;
+
+ /* set callback to use */
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+
+ /* pass in suitable argument to callback */
+ curl_easy_setopt(curl, CURLOPT_READDATA, uploadthis);
+
+ result = curl_easy_perform(curl);
+}
+.fi
.SH AVAILABILITY
CURL_READFUNC_PAUSE return code was added in 7.18.0 and CURL_READFUNC_ABORT
was added in 7.12.1.
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [gnurl] 119/220: examples: add http3.c, altsvc.c and http3-present.c, (continued)
- [GNUnet-SVN] [gnurl] 119/220: examples: add http3.c, altsvc.c and http3-present.c, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 127/220: multi: getsock improvements for QUIC connecting, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 86/220: docs/EXPERIMENTAL: explain what it means and what's experimental now, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 73/220: tests: Fix the line endings for the SASL alt-auth tests, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 84/220: curl: use CURLINFO_PROTOCOL to check for HTTP(s), gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 72/220: examples: Added SASL PLAIN authorisation identity (authzid) examples, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 90/220: http3: fix the HTTP/3 in the request, make alt-svc set right versions, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 88/220: CURLOPT_HTTP_VERSION: seting this to 3 forces HTTP/3 use directly, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 104/220: nghttp3: required when ngtcp2 is used for QUIC, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 106/220: ngtcp2: send HTTP/3 request with nghttp3, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 107/220: CURLOPT_READFUNCTION.3: provide inline example,
gnunet <=
- [GNUnet-SVN] [gnurl] 111/220: ngtcp2: initial h3 request work, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 128/220: ngtcp2: don't reinitialize SSL on Retry, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 124/220: ngtcp2: do QUIC connections happy-eyeballs friendly, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 135/220: tests: Replace outdated test case numbering documentation, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 133/220: configure: use -lquiche to link to quiche, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 144/220: quiche: register debug callback once and earlier, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 138/220: RELEASE-NOTES: synced, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 140/220: vssh: create directory for SSH backend code, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 145/220: ngtcp2: move the h3 initing to immediately after the rx key, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 130/220: ngtcp2: deal with stream close, gnunet, 2019/09/12