diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 56b9d3ff99b21c..6f194c33f2cd6c 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -83,7 +83,7 @@ stages: - script: ./buildconf && ./configure --enable-warnings --enable-werror $(configure) displayName: 'configure $(name)' - - script: make V=1 && cd tests && make V=1 + - script: make V=1 && make V=1 examples && cd tests && make V=1 displayName: 'compile' env: MAKEFLAGS: "-j 2" @@ -191,7 +191,7 @@ stages: - script: $(container_cmd) -l -c "cd $(echo '%cd%') && ./buildconf && ./configure $(configure)" displayName: 'configure $(name)' - - script: $(container_cmd) -l -c "cd $(echo '%cd%') && make V=1 && cd tests && make V=1" + - script: $(container_cmd) -l -c "cd $(echo '%cd%') && make V=1 && make V=1 examples && cd tests && make V=1" displayName: 'compile' env: MAKEFLAGS: "-j 2" diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c0ad67c80fac8..fd0ef0fb6ab1bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,6 +36,7 @@ commands: build: steps: - run: make V=1 + - run: make V=1 examples test: steps: diff --git a/.cirrus.yml b/.cirrus.yml index a719f8c76d6904..c1d7fdaee26feb 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -57,7 +57,7 @@ freebsd_task: # esac - ./configure --prefix="${HOME}"/install --enable-debug --with-openssl --with-libssh2 --with-brotli --with-gssapi --with-libidn2 --enable-manual --enable-ldap --enable-ldaps --with-librtmp --with-libpsl --with-nghttp2 || { tail -300 config.log; false; } compile_script: - - make V=1 && cd tests && make V=1 + - make V=1 && make V=1 examples && cd tests && make V=1 test_script: # blackhole? - sysctl net.inet.tcp.blackhole @@ -122,7 +122,7 @@ windows_task: configure_script: | %container_cmd% -l -c "cd $(echo '%cd%') && ./buildconf && ./configure %configure%" compile_script: | - %container_cmd% -l -c "cd $(echo '%cd%') && make V=1 && cd tests && make V=1" + %container_cmd% -l -c "cd $(echo '%cd%') && make V=1 && make V=1 examples && cd tests && make V=1" install_script: | %container_cmd% -l -c "cd $(echo '%cd%') && make V=1 install && PATH=/usr/bin:/bin find . -type f -path '*/.libs/*.exe' -print -execdir mv -t .. {} \;" test_script: | diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index cbb9633907a9dc..f5db702f551a21 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -81,17 +81,17 @@ static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp) static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) { ssize_t retcode; - curl_off_t nread; + unsigned long nread; int *fdp = (int *)stream; int fd = *fdp; retcode = read(fd, ptr, (READ_3RD_ARG)(size * nmemb)); - nread = (curl_off_t)retcode; - - fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T - " bytes from file\n", nread); + if(retcode > 0) { + nread = (unsigned long)retcode; + fprintf(stderr, "*** We read %lu bytes from file\n", nread); + } return retcode; } diff --git a/docs/examples/chkspeed.c b/docs/examples/chkspeed.c index bc5387d778f4c5..4c7136bf5ce722 100644 --- a/docs/examples/chkspeed.c +++ b/docs/examples/chkspeed.c @@ -170,32 +170,32 @@ int main(int argc, char *argv[]) /* check for bytes downloaded */ res = curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val); + printf("Data downloaded: %lu bytes.\n", (unsigned long)val); /* check for total download time */ res = curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Total download time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", - (val / 1000000), (long)(val % 1000000)); + printf("Total download time: %lu.%06lu sec.\n", + (unsigned long)(val / 1000000), (unsigned long)(val % 1000000)); /* check for average download speed */ res = curl_easy_getinfo(curl_handle, CURLINFO_SPEED_DOWNLOAD_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Average download speed: %" CURL_FORMAT_CURL_OFF_T - " kbyte/sec.\n", val / 1024); + printf("Average download speed: %lu kbyte/sec.\n", + (unsigned long)(val / 1024)); if(prtall) { /* check for name resolution time */ res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Name lookup time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", - (val / 1000000), (long)(val % 1000000)); + printf("Name lookup time: %lu.%06lu sec.\n", + (unsigned long)(val / 1000000), (unsigned long)(val % 1000000)); /* check for connect time */ res = curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Connect time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", - (val / 1000000), (long)(val % 1000000)); + printf("Connect time: %lu.%06lu sec.\n", + (unsigned long)(val / 1000000), (unsigned long)(val % 1000000)); } } else { diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c index afea64316a023f..81914b2c97a687 100644 --- a/docs/examples/fileupload.c +++ b/docs/examples/fileupload.c @@ -68,18 +68,16 @@ int main(void) if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); - } else { /* now extract transfer info */ curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed_upload); curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total_time); - fprintf(stderr, "Speed: %" CURL_FORMAT_CURL_OFF_T " bytes/sec during %" - CURL_FORMAT_CURL_OFF_T ".%06ld seconds\n", - speed_upload, - (total_time / 1000000), (long)(total_time % 1000000)); - + fprintf(stderr, "Speed: %lu bytes/sec during %lu.%06lu seconds\n", + (unsigned long)speed_upload, + (unsigned long)(total_time / 1000000), + (unsigned long)(total_time % 1000000)); } /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 1b7bbf26a42424..75356d86a3d68d 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -50,16 +50,17 @@ variable's memory when passed in to it from an app like this. */ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) { - curl_off_t nread; + unsigned long nread; /* in real-world cases, this would probably get this data differently as this fread() stuff is exactly what the library already would do by default internally */ size_t retcode = fread(ptr, size, nmemb, stream); - nread = (curl_off_t)retcode; + if(retcode > 0) { + nread = (unsigned long)retcode; + fprintf(stderr, "*** We read %lu bytes from file\n", nread); + } - fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T - " bytes from file\n", nread); return retcode; } @@ -69,7 +70,7 @@ int main(void) CURLcode res; FILE *hd_src; struct stat file_info; - curl_off_t fsize; + unsigned long fsize; struct curl_slist *headerlist = NULL; static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS; @@ -80,9 +81,9 @@ int main(void) printf("Couldn't open '%s': %s\n", LOCAL_FILE, strerror(errno)); return 1; } - fsize = (curl_off_t)file_info.st_size; + fsize = (unsigned long)file_info.st_size; - printf("Local file size: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", fsize); + printf("Local file size: %lu bytes.\n", fsize); /* get a FILE * of the same file */ hd_src = fopen(LOCAL_FILE, "rb"); diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c index 90749da2dd1406..7fd02781957206 100644 --- a/docs/examples/httpput.c +++ b/docs/examples/httpput.c @@ -41,17 +41,17 @@ static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream) { size_t retcode; - curl_off_t nread; + unsigned long nread; /* in real-world cases, this would probably get this data differently as this fread() stuff is exactly what the library already would do by default internally */ retcode = fread(ptr, size, nmemb, stream); - nread = (curl_off_t)retcode; - - fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T - " bytes from file\n", nread); + if(retcode > 0) { + nread = (unsigned long)retcode; + fprintf(stderr, "*** We read %lu bytes from file\n", nread); + } return retcode; } diff --git a/docs/examples/imap-append.c b/docs/examples/imap-append.c index 78ecc8d01640c3..e36cb10c0b2205 100644 --- a/docs/examples/imap-append.c +++ b/docs/examples/imap-append.c @@ -89,7 +89,8 @@ int main(void) curl = curl_easy_init(); if(curl) { - long infilesize; + size_t filesize; + long infilesize = LONG_MAX; struct upload_status upload_ctx = { 0 }; /* Set username and password */ @@ -108,7 +109,9 @@ int main(void) curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - infilesize = strlen(payload_text); + filesize = strlen(payload_text); + if(filesize <= LONG_MAX) + infilesize = (long)filesize; curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize); /* Perform the append */ diff --git a/docs/examples/progressfunc.c b/docs/examples/progressfunc.c index df783119efa812..56889df668cef2 100644 --- a/docs/examples/progressfunc.c +++ b/docs/examples/progressfunc.c @@ -51,14 +51,14 @@ static int xferinfo(void *p, be used */ if((curtime - myp->lastruntime) >= MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL) { myp->lastruntime = curtime; - fprintf(stderr, "TOTAL TIME: %" CURL_FORMAT_CURL_OFF_T ".%06ld\r\n", - (curtime / 1000000), (long)(curtime % 1000000)); + fprintf(stderr, "TOTAL TIME: %lu.%06lu\r\n", + (unsigned long)(curtime / 1000000), + (unsigned long)(curtime % 1000000)); } - fprintf(stderr, "UP: %" CURL_FORMAT_CURL_OFF_T " of %" CURL_FORMAT_CURL_OFF_T - " DOWN: %" CURL_FORMAT_CURL_OFF_T " of %" CURL_FORMAT_CURL_OFF_T - "\r\n", - ulnow, ultotal, dlnow, dltotal); + fprintf(stderr, "UP: %lu of %lu DOWN: %lu of %lu\r\n", + (unsigned long)ulnow, (unsigned long)ultotal, + (unsigned long)dlnow, (unsigned long)dltotal); if(dlnow > STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES) return 1; diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c index 44741aeba8072c..d8158466bb45ac 100644 --- a/docs/examples/sendrecv.c +++ b/docs/examples/sendrecv.c @@ -120,8 +120,7 @@ int main(void) return 1; } - printf("Sent %" CURL_FORMAT_CURL_OFF_T " bytes.\n", - (curl_off_t)nsent); + printf("Sent %lu bytes.\n", (unsigned long)nsent); } while(nsent_total < request_len); @@ -151,8 +150,7 @@ int main(void) break; } - printf("Received %" CURL_FORMAT_CURL_OFF_T " bytes.\n", - (curl_off_t)nread); + printf("Received %lu bytes.\n", (unsigned long)nread); } /* always cleanup */ diff --git a/docs/examples/sftpuploadresume.c b/docs/examples/sftpuploadresume.c index e2aa37392818d7..da2a4102c4c773 100644 --- a/docs/examples/sftpuploadresume.c +++ b/docs/examples/sftpuploadresume.c @@ -66,7 +66,7 @@ static curl_off_t sftpGetRemoteFileSize(const char *i_remoteFile) &remoteFileSizeByte); if(result) return -1; - printf("filesize: %" CURL_FORMAT_CURL_OFF_T "\n", remoteFileSizeByte); + printf("filesize: %lu\n", (unsigned long)remoteFileSizeByte); } curl_easy_cleanup(curlHandlePtr);