#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)
{
"-----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;
}
/* 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);
/* 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;
"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);
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
/* 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>
(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) {
"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);
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
*
***************************************************************************/
/* <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.
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;
}
/* 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
*/
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();