From 23f8dca6fb91329fe78bb5a00527286692d2a357 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 5 Dec 2012 00:37:57 +0100 Subject: examples: fix compilation issues --- docs/examples/anyauthput.c | 6 +++++- docs/examples/ftpgetinfo.c | 10 +++++----- docs/examples/progressfunc.c | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'docs/examples') diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index 5dac0e779..54e5f1aff 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -27,7 +27,11 @@ # ifdef __VMS typedef int intptr_t; # endif -# include +# if defined(_AIX) || defined(__sgi) || defined(__osf) + typedef long intptr_t; +# else +# include +# endif # include #endif #include diff --git a/docs/examples/ftpgetinfo.c b/docs/examples/ftpgetinfo.c index f0746693b..7063d89b9 100644 --- a/docs/examples/ftpgetinfo.c +++ b/docs/examples/ftpgetinfo.c @@ -43,8 +43,8 @@ int main(void) char ftpurl[] = "ftp://ftp.example.com/gnu/binutils/binutils-2.19.1.tar.bz2"; CURL *curl; CURLcode res; - const time_t filetime; - const double filesize; + long filetime = -1; + double filesize = 0.0; const char *filename = strrchr(ftpurl, '/') + 1; curl_global_init(CURL_GLOBAL_DEFAULT); @@ -67,10 +67,10 @@ int main(void) if(CURLE_OK == res) { /* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */ res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); - if((CURLE_OK == res) && filetime) - printf("filetime %s: %s", filename, ctime(&filetime)); + if((CURLE_OK == res) && (filetime >= 0)) + printf("filetime %s: %s", filename, ctime(&(time_t)filetime)); res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize); - if((CURLE_OK == res) && (filesize>0)) + if((CURLE_OK == res) && (filesize>0.0)) printf("filesize %s: %0.0f bytes\n", filename, filesize); } else { /* we failed */ diff --git a/docs/examples/progressfunc.c b/docs/examples/progressfunc.c index a49806028..51a9c9b5e 100644 --- a/docs/examples/progressfunc.c +++ b/docs/examples/progressfunc.c @@ -59,7 +59,7 @@ static int progress(void *p, int main(void) { CURL *curl; - CURLcode res=0; + CURLcode res = CURLE_OK; struct myprogress prog; curl = curl_easy_init(); @@ -74,7 +74,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); res = curl_easy_perform(curl); - if(res) + if(res != CURLE_OK) fprintf(stderr, "%s\n", curl_easy_strerror(res)); /* always cleanup */ -- cgit v1.2.3