From d242214e18bee2c300c1888d5f8f80313fd60b11 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 Mar 2002 14:53:00 +0000 Subject: new example for libcurl 7.9.6 or later --- docs/examples/post-callback.c | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 docs/examples/post-callback.c (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c new file mode 100644 index 000000000..d4664a575 --- /dev/null +++ b/docs/examples/post-callback.c @@ -0,0 +1,89 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + * + * An example source code that issues a HTTP POST and we provide the actual + * data through a read callback. + * + * Please be aware of the fact that the size of the posted data MUST be + * specified before the transfer is being made (with CURLOPT_POSTFIELDSIZE). + * This requirement will change when libcurl starts supporting chunked-encoded + * sends. + * + * This example requires libcurl 7.9.6 or later. + */ +#include +#include +#include + +#if LIBCURL_VERSION_NUM < 0x070906 +#error this example source requires libcurl 7.9.6 or newer +#endif + +char data[]="this is what we post to the silly web server"; + +struct WriteThis { + char *readptr; + int sizeleft; +}; + +size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + + if(size*nmemb < 1) + return 0; + + if(pooh->sizeleft) { + *(char *)ptr = pooh->readptr[0]; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + pooh->sizeleft--; /* less data left */ + return 1; /* we return 1 byte at a time! */ + } + + return -1; /* no more data left to deliver */ +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + struct WriteThis pooh; + + pooh.readptr = data; + pooh.sizeleft = strlen(data); + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. */ + curl_easy_setopt(curl, CURLOPT_URL, + "http://receivingsite.com.pooh/index.cgi"); + /* Now specify we want to POST data */ + curl_easy_setopt(curl, CURLOPT_POST, TRUE); + + /* Set the expected POST size */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); + + /* we want to use our own read function */ + curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); + + /* pointer to pass to our read function */ + curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + + /* get verbose debug output please */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} -- cgit v1.2.1 From f68219ddaab9dab05a195a6fd126b4edb5ecccdc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2003 14:13:19 +0000 Subject: use the newer option names --- docs/examples/post-callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index d4664a575..eda878677 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -74,7 +74,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); /* pointer to pass to our read function */ - curl_easy_setopt(curl, CURLOPT_INFILE, &pooh); + curl_easy_setopt(curl, CURLOPT_READDATA, &pooh); /* get verbose debug output please */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); -- cgit v1.2.1 From 821302bcf3cb608b2f29dffc757f5152cbe63a39 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2003 14:14:26 +0000 Subject: removed old version checks --- docs/examples/post-callback.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index eda878677..76d1e1ba5 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -10,21 +10,11 @@ * An example source code that issues a HTTP POST and we provide the actual * data through a read callback. * - * Please be aware of the fact that the size of the posted data MUST be - * specified before the transfer is being made (with CURLOPT_POSTFIELDSIZE). - * This requirement will change when libcurl starts supporting chunked-encoded - * sends. - * - * This example requires libcurl 7.9.6 or later. */ #include #include #include -#if LIBCURL_VERSION_NUM < 0x070906 -#error this example source requires libcurl 7.9.6 or newer -#endif - char data[]="this is what we post to the silly web server"; struct WriteThis { -- cgit v1.2.1 From e8b295ff7d2d887b0a021914ec0d31c6f186200f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 23 Aug 2004 14:22:44 +0000 Subject: lost of more into on how to tweak some headers --- docs/examples/post-callback.c | 52 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 76d1e1ba5..ecffce303 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -1,8 +1,8 @@ /***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * $Id$ @@ -57,9 +57,6 @@ int main(void) /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, TRUE); - /* Set the expected POST size */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); - /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); @@ -69,6 +66,47 @@ int main(void) /* get verbose debug output please */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + /* + If you use POST to a HTTP 1.1 server, you can send data without knowing + the size before starting the POST if you use chunked encoding. You + enable this by adding a header like "Transfer-Encoding: chunked" with + CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you must + specify the size in the request. + */ +#ifdef USE_CHUNKED + { + curl_slist *chunk = NULL; + + chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked"); + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER); + /* use curl_slist_free_all() after the *perform() call to free this + list again */ + } +#else + /* Set the expected POST size. If you want to POST large amounts of data, + consider CURLOPT_POSTFIELDSIZE_LARGE */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); +#endif + +#ifdef DISABLE_EXPECT + /* + Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" + header. You can disable this header with CURLOPT_HTTPHEADER as usual. + NOTE: if you want chunked transfer too, you need to combine these two + since you can only set one list of headers with CURLOPT_HTTPHEADER. */ + + /* A less good option would be to enforce HTTP 1.0, but that might also + have other implications. */ + { + curl_slist *chunk = NULL; + + chunk = curl_slist_append(chunk, "Expect:"); + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER); + /* use curl_slist_free_all() after the *perform() call to free this + list again */ + } +#endif + /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); -- cgit v1.2.1 From 95330925115c073532160e6d480cec9ce433e043 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 14 Dec 2005 13:10:14 +0000 Subject: Rene Bernhardt's corrections --- docs/examples/post-callback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index ecffce303..1da88a8af 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -78,7 +78,7 @@ int main(void) curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked"); - res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER); + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); /* use curl_slist_free_all() after the *perform() call to free this list again */ } @@ -101,7 +101,7 @@ int main(void) curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Expect:"); - res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER); + res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); /* use curl_slist_free_all() after the *perform() call to free this list again */ } -- cgit v1.2.1 From 49ce3e5160a9576e797bf87cef012b09d1c54ecb Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 12 Jul 2007 21:11:10 +0000 Subject: Fixed some compile warnings and errors and improved portability in the examples. Removed ftp3rdparty.c since libcurl doesn't support 3rd party FTP transfers any longer. --- docs/examples/post-callback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 1da88a8af..a2c89873f 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -15,10 +15,10 @@ #include #include -char data[]="this is what we post to the silly web server"; +const char data[]="this is what we post to the silly web server"; struct WriteThis { - char *readptr; + const char *readptr; int sizeleft; }; @@ -55,7 +55,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_URL, "http://receivingsite.com.pooh/index.cgi"); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, TRUE); + curl_easy_setopt(curl, CURLOPT_POST, 1); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); -- cgit v1.2.1 From 4706a9334149f656eef9b5e8888da1ead23b0941 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Mon, 16 Jul 2007 21:22:12 +0000 Subject: Fixed some more simple compile warnings in the examples. --- docs/examples/post-callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index a2c89873f..531b68156 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -22,7 +22,7 @@ struct WriteThis { int sizeleft; }; -size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) +static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { struct WriteThis *pooh = (struct WriteThis *)userp; -- cgit v1.2.1 From f3c0afa5b8f1460020f3718e2b050d4940240a58 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 13 Mar 2008 12:36:22 +0000 Subject: fix code that is normally #ifdef'ed out --- docs/examples/post-callback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 531b68156..1a044808a 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -75,7 +75,7 @@ int main(void) */ #ifdef USE_CHUNKED { - curl_slist *chunk = NULL; + struct curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked"); res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); @@ -98,7 +98,7 @@ int main(void) /* A less good option would be to enforce HTTP 1.0, but that might also have other implications. */ { - curl_slist *chunk = NULL; + struct curl_slist *chunk = NULL; chunk = curl_slist_append(chunk, "Expect:"); res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); -- cgit v1.2.1 From 79300cdcd988e65c37bd3d9b391cd7a73ebefc6b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 12 Apr 2008 08:35:04 +0000 Subject: return 0 not -1 at end of data! --- docs/examples/post-callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 1a044808a..e3f37c4ae 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -36,7 +36,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) return 1; /* we return 1 byte at a time! */ } - return -1; /* no more data left to deliver */ + return 0; /* no more data left to deliver */ } int main(void) -- cgit v1.2.1 From e664cd5826d43930fcc5b5dbaedbec94af33184b Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 22 May 2008 21:20:07 +0000 Subject: Fixed a surprising number of example programs that were passing int arguments to curl_easy_setopt instead of long. --- docs/examples/post-callback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index e3f37c4ae..ed89cac2a 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -55,7 +55,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_URL, "http://receivingsite.com.pooh/index.cgi"); /* Now specify we want to POST data */ - curl_easy_setopt(curl, CURLOPT_POST, 1); + curl_easy_setopt(curl, CURLOPT_POST, 1L); /* we want to use our own read function */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); @@ -64,7 +64,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_READDATA, &pooh); /* get verbose debug output please */ - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* If you use POST to a HTTP 1.1 server, you can send data without knowing @@ -85,7 +85,7 @@ int main(void) #else /* Set the expected POST size. If you want to POST large amounts of data, consider CURLOPT_POSTFIELDSIZE_LARGE */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (curl_off_t)pooh.sizeleft); #endif #ifdef DISABLE_EXPECT -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- docs/examples/post-callback.c | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index ed89cac2a..1e688a1c8 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ * * An example source code that issues a HTTP POST and we provide the actual * data through a read callback. -- cgit v1.2.1 From 18e7b52e8e95f7204d8ef7ff0f0ff0043afe45a9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 5 Oct 2010 15:00:19 +0200 Subject: examples: use example.com in example URLs --- docs/examples/post-callback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 1e688a1c8..ae4f4db98 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -51,8 +51,8 @@ int main(void) curl = curl_easy_init(); if(curl) { /* First set the URL that is about to receive our POST. */ - curl_easy_setopt(curl, CURLOPT_URL, - "http://receivingsite.com.pooh/index.cgi"); + curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/index.cgi"); + /* Now specify we want to POST data */ curl_easy_setopt(curl, CURLOPT_POST, 1L); -- cgit v1.2.1 From 1aeb635cdd296c16acb375a4a83a78f13166ccab Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Mar 2011 11:48:02 +0100 Subject: sources: update source headers All C and H files now (should) feature the proper project curl source code header, which includes basic info, a copyright statement and some basic disclaimers. --- docs/examples/post-callback.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index ae4f4db98..bb99a8566 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -1,14 +1,26 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * - * An example source code that issues a HTTP POST and we provide the actual - * data through a read callback. + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +/* An example source code that issues a HTTP POST and we provide the actual + * data through a read callback. */ #include #include -- cgit v1.2.1 From 865893fb143540037ca34f6a4438ebe2e286ec5a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 13 Apr 2012 17:58:41 +0200 Subject: examples: fix compiler warnings --- docs/examples/post-callback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index bb99a8566..adadaf803 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,7 +30,7 @@ const char data[]="this is what we post to the silly web server"; struct WriteThis { const char *readptr; - int sizeleft; + long sizeleft; }; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) @@ -96,7 +96,7 @@ int main(void) #else /* Set the expected POST size. If you want to POST large amounts of data, consider CURLOPT_POSTFIELDSIZE_LARGE */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (curl_off_t)pooh.sizeleft); + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft); #endif #ifdef DISABLE_EXPECT -- cgit v1.2.1 From a3dbbcfd2ac7ab8f597e26e76935726279d3fa0c Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Wed, 4 Jul 2012 17:03:52 +0200 Subject: Added error checking for samples. --- docs/examples/post-callback.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index adadaf803..9736d8854 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -120,6 +120,10 @@ int main(void) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); -- cgit v1.2.1 From df5a47b8198ad51146390c80162d098a3c9b7ba5 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 12 Jul 2012 15:01:18 +0200 Subject: Added curl_global_* functions. --- docs/examples/post-callback.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index 9736d8854..fa0c4b686 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -60,6 +60,10 @@ int main(void) pooh.readptr = data; pooh.sizeleft = strlen(data); + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_DEFAULT); + + /* get a curl handle */ curl = curl_easy_init(); if(curl) { /* First set the URL that is about to receive our POST. */ @@ -128,5 +132,6 @@ int main(void) /* always cleanup */ curl_easy_cleanup(curl); } + curl_global_cleanup(); return 0; } -- cgit v1.2.1 From 6e3802a2cfde2edaabef902d494dea58d77f6d5b Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 12 Jul 2012 15:18:00 +0200 Subject: Added error checking for curl_global_init(). --- docs/examples/post-callback.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index fa0c4b686..f11fb983b 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -61,7 +61,13 @@ int main(void) pooh.sizeleft = strlen(data); /* In windows, this will init the winsock stuff */ - curl_global_init(CURL_GLOBAL_DEFAULT); + res = curl_global_init(CURL_GLOBAL_DEFAULT); + /* Check for errors */ + if(res != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed: %s\n", + curl_easy_strerror(res)); + return 1; + } /* get a curl handle */ curl = curl_easy_init(); -- cgit v1.2.1 From 7332a7cafba43c96893a8df9b08e5d15df4f3288 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 5 Dec 2012 11:43:40 +0100 Subject: examples: fix compilation issues - commit 23f8dca6fb follow-up --- docs/examples/post-callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/post-callback.c') diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index f11fb983b..3e1cfb060 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -58,7 +58,7 @@ int main(void) struct WriteThis pooh; pooh.readptr = data; - pooh.sizeleft = strlen(data); + pooh.sizeleft = (long)strlen(data); /* In windows, this will init the winsock stuff */ res = curl_global_init(CURL_GLOBAL_DEFAULT); -- cgit v1.2.1