now builds and runs with GnuTLS-built libcurls too
This commit is contained in:
parent
6982ed4db7
commit
3154f04fb9
@ -8,20 +8,26 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* A multi-threaded example that uses pthreads and fetches 4 remote files at
|
* A multi-threaded example that uses pthreads and fetches 4 remote files at
|
||||||
* once over HTTPS. The lock callbacks and stuff assume OpenSSL so far.
|
* once over HTTPS. The lock callbacks and stuff assume OpenSSL or GnuTLS
|
||||||
* Should be expanded to do optional GnuTLS style locking.
|
* (libgcrypt) so far.
|
||||||
*
|
*
|
||||||
* OpenSSL docs for this: http://www.openssl.org/docs/crypto/threads.html
|
* OpenSSL docs for this:
|
||||||
|
* http://www.openssl.org/docs/crypto/threads.html
|
||||||
|
* gcrypt docs for this:
|
||||||
|
* http://gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define USE_OPENSSL /* or USE_GNUTLS accordingly */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <openssl/crypto.h>
|
|
||||||
|
|
||||||
/* we have this global to let the callback get easy access to it */
|
/* we have this global to let the callback get easy access to it */
|
||||||
static pthread_mutex_t *lockarray;
|
static pthread_mutex_t *lockarray;
|
||||||
|
|
||||||
|
#ifdef USE_OPENSSL
|
||||||
|
#include <openssl/crypto.h>
|
||||||
static void lock_callback(int mode, int type, char *file, int line)
|
static void lock_callback(int mode, int type, char *file, int line)
|
||||||
{
|
{
|
||||||
(void)file;
|
(void)file;
|
||||||
@ -66,6 +72,21 @@ static void kill_locks(void)
|
|||||||
|
|
||||||
OPENSSL_free(lockarray);
|
OPENSSL_free(lockarray);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_GNUTLS
|
||||||
|
#include <gcrypt.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
||||||
|
|
||||||
|
void init_locks(void)
|
||||||
|
{
|
||||||
|
gcry_control(GCRYCTL_SET_THREAD_CBS);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define kill_locks()
|
||||||
|
#endif
|
||||||
|
|
||||||
/* List of URLs to fetch.*/
|
/* List of URLs to fetch.*/
|
||||||
const char *urls[]= {
|
const char *urls[]= {
|
||||||
|
Loading…
Reference in New Issue
Block a user