1.1 --- a/extensions/curl/curl-src/docs/examples/anyauthput.c Sun Mar 17 22:05:33 2013 +0000
1.2 +++ b/extensions/curl/curl-src/docs/examples/anyauthput.c Sun Mar 17 22:23:20 2013 +0000
1.3 @@ -1,19 +1,35 @@
1.4 -/*****************************************************************************
1.5 +/***************************************************************************
1.6 * _ _ ____ _
1.7 * Project ___| | | | _ \| |
1.8 * / __| | | | |_) | |
1.9 * | (__| |_| | _ <| |___
1.10 * \___|\___/|_| \_\_____|
1.11 *
1.12 - * $Id: anyauthput.c,v 1.7 2008-08-31 12:12:35 yangtse Exp $
1.13 - */
1.14 -
1.15 + * Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
1.16 + *
1.17 + * This software is licensed as described in the file COPYING, which
1.18 + * you should have received as part of this distribution. The terms
1.19 + * are also available at http://curl.haxx.se/docs/copyright.html.
1.20 + *
1.21 + * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1.22 + * copies of the Software, and permit persons to whom the Software is
1.23 + * furnished to do so, under the terms of the COPYING file.
1.24 + *
1.25 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1.26 + * KIND, either express or implied.
1.27 + *
1.28 + ***************************************************************************/
1.29 #include <stdio.h>
1.30 #include <fcntl.h>
1.31 #ifdef WIN32
1.32 # include <io.h>
1.33 #else
1.34 -# include <stdint.h>
1.35 +# ifdef __VMS
1.36 + typedef int intptr_t;
1.37 +# endif
1.38 +# if !defined(_AIX) && !defined(__sgi) && !defined(__osf__)
1.39 +# include <stdint.h>
1.40 +# endif
1.41 # include <unistd.h>
1.42 #endif
1.43 #include <sys/types.h>
1.44 @@ -37,6 +53,12 @@
1.45 #define TRUE 1
1.46 #endif
1.47
1.48 +#if defined(_AIX) || defined(__sgi) || defined(__osf__)
1.49 +#ifndef intptr_t
1.50 +#define intptr_t long
1.51 +#endif
1.52 +#endif
1.53 +
1.54 /*
1.55 * This example shows a HTTP PUT operation with authentiction using "any"
1.56 * type. It PUTs a file given as a command line argument to the URL also given
1.57 @@ -74,12 +96,16 @@
1.58 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
1.59 {
1.60 size_t retcode;
1.61 + curl_off_t nread;
1.62
1.63 intptr_t fd = (intptr_t)stream;
1.64
1.65 retcode = read(fd, ptr, size * nmemb);
1.66
1.67 - fprintf(stderr, "*** We read %d bytes from file\n", retcode);
1.68 + nread = (curl_off_t)retcode;
1.69 +
1.70 + fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
1.71 + " bytes from file\n", nread);
1.72
1.73 return retcode;
1.74 }
1.75 @@ -132,7 +158,7 @@
1.76 /* and give the size of the upload, this supports large file sizes
1.77 on systems that have general support for it */
1.78 curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
1.79 - (curl_off_t)file_info.st_size);
1.80 + (curl_off_t)file_info.st_size);
1.81
1.82 /* tell libcurl we can use "any" auth, which lets the lib pick one, but it
1.83 also costs one extra round-trip and possibly sending of all the PUT
1.84 @@ -144,6 +170,10 @@
1.85
1.86 /* Now run off and do what you've been told! */
1.87 res = curl_easy_perform(curl);
1.88 + /* Check for errors */
1.89 + if(res != CURLE_OK)
1.90 + fprintf(stderr, "curl_easy_perform() failed: %s\n",
1.91 + curl_easy_strerror(res));
1.92
1.93 /* always cleanup */
1.94 curl_easy_cleanup(curl);