diff options
Diffstat (limited to 'docs/examples/ftpgetresp.c')
| -rw-r--r-- | docs/examples/ftpgetresp.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/docs/examples/ftpgetresp.c b/docs/examples/ftpgetresp.c index 2122c4f6..dcb296ad 100644 --- a/docs/examples/ftpgetresp.c +++ b/docs/examples/ftpgetresp.c @@ -1,17 +1,27 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, 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 + * 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 <stdio.h> #include <curl/curl.h> -#include <curl/types.h> -#include <curl/easy.h> /* * Similar to ftpget.c but this also stores the received response-lines @@ -27,7 +37,7 @@ write_response(void *ptr, size_t size, size_t nmemb, void *data) return fwrite(ptr, size, nmemb, writehere); } -int main(int argc, char **argv) +int main(void) { CURL *curl; CURLcode res; @@ -48,8 +58,12 @@ int main(int argc, char **argv) /* If you intend to use this on windows with a libcurl DLL, you must use CURLOPT_WRITEFUNCTION as well */ curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_response); - curl_easy_setopt(curl, CURLOPT_WRITEHEADER, respfile); + curl_easy_setopt(curl, CURLOPT_HEADERDATA, respfile); 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); |
