examples: fix compilation issues
This commit is contained in:
parent
b908376bef
commit
23f8dca6fb
@ -27,7 +27,11 @@
|
|||||||
# ifdef __VMS
|
# ifdef __VMS
|
||||||
typedef int intptr_t;
|
typedef int intptr_t;
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(_AIX) || defined(__sgi) || defined(__osf)
|
||||||
|
typedef long intptr_t;
|
||||||
|
# else
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
# endif
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#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";
|
char ftpurl[] = "ftp://ftp.example.com/gnu/binutils/binutils-2.19.1.tar.bz2";
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
const time_t filetime;
|
long filetime = -1;
|
||||||
const double filesize;
|
double filesize = 0.0;
|
||||||
const char *filename = strrchr(ftpurl, '/') + 1;
|
const char *filename = strrchr(ftpurl, '/') + 1;
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
@ -67,10 +67,10 @@ int main(void)
|
|||||||
if(CURLE_OK == res) {
|
if(CURLE_OK == res) {
|
||||||
/* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */
|
/* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */
|
||||||
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
|
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
|
||||||
if((CURLE_OK == res) && filetime)
|
if((CURLE_OK == res) && (filetime >= 0))
|
||||||
printf("filetime %s: %s", filename, ctime(&filetime));
|
printf("filetime %s: %s", filename, ctime(&(time_t)filetime));
|
||||||
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize);
|
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);
|
printf("filesize %s: %0.0f bytes\n", filename, filesize);
|
||||||
} else {
|
} else {
|
||||||
/* we failed */
|
/* we failed */
|
||||||
|
@ -59,7 +59,7 @@ static int progress(void *p,
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res=0;
|
CURLcode res = CURLE_OK;
|
||||||
struct myprogress prog;
|
struct myprogress prog;
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
@ -74,7 +74,7 @@ int main(void)
|
|||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
if(res)
|
if(res != CURLE_OK)
|
||||||
fprintf(stderr, "%s\n", curl_easy_strerror(res));
|
fprintf(stderr, "%s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
/* always cleanup */
|
/* always cleanup */
|
||||||
|
Loading…
Reference in New Issue
Block a user