diff options
Diffstat (limited to 'docs/examples/anyauthput.c')
-rw-r--r-- | docs/examples/anyauthput.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index cec9fede..b89dca2e 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2012, 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 <fcntl.h> #ifdef WIN32 @@ -14,7 +26,8 @@ #else # ifdef __VMS typedef int intptr_t; -# else +# endif +# if !defined(_AIX) && !defined(__sgi) && !defined(__osf__) # include <stdint.h> # endif # include <unistd.h> @@ -40,6 +53,12 @@ #define TRUE 1 #endif +#if defined(_AIX) || defined(__sgi) || defined(__osf__) +#ifndef intptr_t +#define intptr_t long +#endif +#endif + /* * This example shows a HTTP PUT operation with authentiction using "any" * type. It PUTs a file given as a command line argument to the URL also given @@ -77,12 +96,16 @@ static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t retcode; + curl_off_t nread; intptr_t fd = (intptr_t)stream; retcode = read(fd, ptr, size * nmemb); - fprintf(stderr, "*** We read %d bytes from file\n", retcode); + nread = (curl_off_t)retcode; + + fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T + " bytes from file\n", nread); return retcode; } @@ -147,6 +170,10 @@ int main(int argc, char **argv) /* Now run off and do what you've been told! */ 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); |