examples: fix compilation issues
This commit is contained in:
parent
b908376bef
commit
23f8dca6fb
@ -27,7 +27,11 @@
|
||||
# ifdef __VMS
|
||||
typedef int intptr_t;
|
||||
# endif
|
||||
# if defined(_AIX) || defined(__sgi) || defined(__osf)
|
||||
typedef long intptr_t;
|
||||
# else
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user