examples: fix build issues in 'complicated' examples
No binary (build failed)
—
(log yok)
| @@ -34,6 +34,17 @@ | |
| #if defined(__GNUC__) || defined(__clang__) | |
| #pragma GCC diagnostic ignored "-Woverlength-strings" | |
| #endif | |
| + | /* Silence warning when calling sk_X509_INFO_pop_free() */ |
| + | #if defined(__clang__) && __clang_major__ >= 16 |
| + | #pragma clang diagnostic push |
| + | #pragma clang diagnostic ignored "-Wcast-function-type-strict" |
| + | #endif |
| + | |
| + | #if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) |
| + | typedef size_t ossl_valsize_t; |
| + | #else |
| + | typedef int ossl_valsize_t; |
| + | #endif |
| static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| @@ -68,8 +79,8 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer) | |
| "-----END CERTIFICATE-----\n"; | |
| BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem)); | |
| - | X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); |
| - | int i; |
| + | X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); |
| + | ossl_valsize_t i; |
| STACK_OF(X509_INFO) *inf; | |
| (void)curl; | |
| @@ -167,9 +167,9 @@ static void on_uv_timeout(uv_timer_t *req) | |
| } | |
| /* callback from libcurl to update the timeout expiry */ | |
| - | static int cb_timeout(CURLM *multi, long timeout_ms, |
| - | struct datauv *uv) |
| + | static int cb_timeout(CURLM *multi, long timeout_ms, void *userp) |
| { | |
| + | struct datauv *uv = (struct datauv *)userp; |
| (void)multi; | |
| if(timeout_ms < 0) | |
| uv_timer_stop(&uv->timeout); | |
| @@ -185,9 +185,9 @@ static int cb_timeout(CURLM *multi, long timeout_ms, | |
| /* callback from libcurl to update socket activity to wait for */ | |
| static int cb_socket(CURL *easy, curl_socket_t s, int action, | |
| - | struct datauv *uv, |
| - | void *socketp) |
| + | void *userp, void *socketp) |
| { | |
| + | struct datauv *uv = (struct datauv *)userp; |
| struct curl_context *curl_context; | |
| int events = 0; | |
| (void)easy; | |
| @@ -48,12 +48,13 @@ static const char * const urls[NUMT]= { | |
| "www.example" | |
| }; | |
| - | static void *pull_one_url(void *url) |
| + | static void *pull_one_url(void *pindex) |
| { | |
| + | int i = *(int *)pindex; |
| CURL *curl; | |
| curl = curl_easy_init(); | |
| - | curl_easy_setopt(curl, CURLOPT_URL, url); |
| + | curl_easy_setopt(curl, CURLOPT_URL, urls[i]); |
| curl_easy_perform(curl); /* ignores error */ | |
| curl_easy_cleanup(curl); | |
| @@ -79,7 +80,7 @@ int main(void) | |
| int error = pthread_create(&tid[i], | |
| NULL, /* default attributes please */ | |
| pull_one_url, | |
| - | (void *)urls[i]); |
| + | (void *)&i); |
| if(error) | |
| fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); | |
| else | |
| @@ -29,6 +29,10 @@ | |
| /* Note that this example currently requires curl to be linked against | |
| GnuTLS (and this program must also be linked against -lgnutls). */ | |
| + | #ifndef CURL_DISABLE_DEPRECATION |
| + | #define CURL_DISABLE_DEPRECATION |
| + | #endif |
| + | |
| #include <stdio.h> | |
| #include <curl/curl.h> | |
| @@ -47,8 +51,7 @@ static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) | |
| (void)stream; | |
| (void)ptr; | |
| - | res = CURL_IGNORE_DEPRECATION( |
| - | curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &info)); |
| + | res = curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &info); |
| if(!res) { | |
| switch(info->backend) { | |
| @@ -52,12 +52,13 @@ static const char * const urls[]= { | |
| "https://www4.example.com/", | |
| }; | |
| - | static void *pull_one_url(void *url) |
| + | static void *pull_one_url(void *pindex) |
| { | |
| + | int i = *(int *)pindex; |
| CURL *curl; | |
| curl = curl_easy_init(); | |
| - | curl_easy_setopt(curl, CURLOPT_URL, url); |
| + | curl_easy_setopt(curl, CURLOPT_URL, urls[i]); |
| /* this example does not verify the server's certificate, which means we | |
| might be downloading stuff from an impostor */ | |
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | |
| @@ -82,7 +83,7 @@ int main(int argc, char **argv) | |
| int error = pthread_create(&tid[i], | |
| NULL, /* default attributes please */ | |
| pull_one_url, | |
| - | (void *)urls[i]); |
| + | (void *)&i); |
| if(error) | |
| fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); | |
| else | |
| @@ -22,7 +22,7 @@ | |
| * | |
| ***************************************************************************/ | |
| /* <DESC> | |
| - | * Use an in-memory user certificate and RSA key and retrieve an https page. |
| + | * Use an in-memory user certificate and RSA key and retrieve an HTTPS page. |
| * </DESC> | |
| */ | |
| /* Written by Ishan SinghLevett, based on Theo Borm's cacertinmem.c. | |
| @@ -47,7 +47,7 @@ | |
| static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | fwrite(ptr, size, nmemb, stream); |
| + | fwrite(ptr, size, nmemb, (FILE *)stream); |
| return nmemb * size; | |
| } | |
| @@ -179,12 +179,10 @@ int main(void) | |
| /* first try: retrieve page without user certificate and key -> fails */ | |
| rv = curl_easy_perform(ch); | |
| - | if(rv == CURLE_OK) { |
| + | if(rv == CURLE_OK) |
| printf("*** transfer succeeded ***\n"); | |
| - | } |
| - | else { |
| + | else |
| printf("*** transfer failed ***\n"); | |
| - | } |
| /* second try: retrieve page using user certificate and key -> succeeds | |
| * load the certificate and key by installing a function doing the necessary | |
| @@ -192,12 +190,10 @@ int main(void) | |
| */ | |
| curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, sslctx_function); | |
| rv = curl_easy_perform(ch); | |
| - | if(rv == CURLE_OK) { |
| + | if(rv == CURLE_OK) |
| printf("*** transfer succeeded ***\n"); | |
| - | } |
| - | else { |
| + | else |
| printf("*** transfer failed ***\n"); | |
| - | } |
| curl_easy_cleanup(ch); | |
| curl_global_cleanup(); | |