From 35aa363587f8169f9b1ceec22f5e8f8ebd9da91e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Sep 2000 22:32:08 +0000 Subject: new libcurl example code stuff --- docs/examples/simple.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/examples/simple.c (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c new file mode 100644 index 000000000..e6138c4e1 --- /dev/null +++ b/docs/examples/simple.c @@ -0,0 +1,26 @@ +#include + +#include +#include +#include + +int main(int argc, char **argv) +{ + CURL *curl; + CURLcode res; + FILE *headerfile; + + headerfile = fopen("dumpit", "w"); + + curl = curl_easy_init(); + if(curl) { + /* what call to write: */ + curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); + curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile); + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} -- cgit v1.2.1 From ada9bc2b24ecb73c78e07aed933dc99f1d44ed3c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Feb 2001 13:56:38 +0000 Subject: win32sockets.c is now added with winsock init/cleanup example functions --- docs/examples/simple.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index e6138c4e1..907d5e8e4 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -1,9 +1,22 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + #include #include #include #include +/* to make this work under windows, use the win32-functions from the + win32socket.c file as well */ + int main(int argc, char **argv) { CURL *curl; -- cgit v1.2.1 From fd1799f3bbd10981bbd470d5623363e6b7a91e2c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Jan 2002 13:22:03 +0000 Subject: Cleaned up this example to make it even simpler. --- docs/examples/simple.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 907d5e8e4..186d493bd 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -9,27 +9,17 @@ */ #include - #include -#include -#include - -/* to make this work under windows, use the win32-functions from the - win32socket.c file as well */ int main(int argc, char **argv) { CURL *curl; CURLcode res; - FILE *headerfile; - - headerfile = fopen("dumpit", "w"); curl = curl_easy_init(); if(curl) { /* what call to write: */ curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); - curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile); res = curl_easy_perform(curl); /* always cleanup */ -- cgit v1.2.1 From 5bd6d631c62f5e21dbad4ac1af7193235bbb7c63 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Jan 2002 13:22:31 +0000 Subject: cut off argc and argv as well --- docs/examples/simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 186d493bd..d591f9607 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -11,7 +11,7 @@ #include #include -int main(int argc, char **argv) +int main(void) { CURL *curl; CURLcode res; -- cgit v1.2.1 From bec0ebacf10d1e6e4712a41e832f161d858894f1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Jan 2002 13:23:01 +0000 Subject: bad comment begone --- docs/examples/simple.c | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index d591f9607..1b93dd83b 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -18,7 +18,6 @@ int main(void) curl = curl_easy_init(); if(curl) { - /* what call to write: */ curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); res = curl_easy_perform(curl); -- cgit v1.2.1 From d736ac51c047119c8d82df9f18b127cbcecc86c6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 23 Aug 2004 14:22:52 +0000 Subject: stripped trailing whitespace --- docs/examples/simple.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 1b93dd83b..baee2ce0d 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -1,8 +1,8 @@ /***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * $Id$ -- 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/simple.c | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index baee2ce0d..582c62426 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include -- 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/simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 582c62426..351cf729b 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -17,7 +17,7 @@ int main(void) curl = curl_easy_init(); if(curl) { - curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); + curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); res = curl_easy_perform(curl); /* always cleanup */ -- 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/simple.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 351cf729b..55877f8b2 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, 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 + * 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. + * + ***************************************************************************/ #include #include -- 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/simple.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs/examples/simple.c') diff --git a/docs/examples/simple.c b/docs/examples/simple.c index 55877f8b2..cb23b7ae3 100644 --- a/docs/examples/simple.c +++ b/docs/examples/simple.c @@ -30,7 +30,13 @@ int main(void) curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); + + /* 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