/* start of entropy_init_mutex() */
static void entropy_init_mutex(entropy_context *ctx)
{
- /* lock 0 = entropy_init_mutex() */
- polarsslthreadlock_lock_function(0);
- if(entropy_init_initialized == 0)
- {
- entropy_init(ctx);
- entropy_init_initialized = 1;
- }
- polarsslthreadlock_unlock_function(0);
+ /* lock 0 = entropy_init_mutex() */
+ polarsslthreadlock_lock_function(0);
+ if(entropy_init_initialized == 0) {
+ entropy_init(ctx);
+ entropy_init_initialized = 1;
+ }
+ polarsslthreadlock_unlock_function(0);
}
/* end of entropy_init_mutex() */
static int entropy_func_mutex(void *data, unsigned char *output, size_t len)
{
int ret;
- /* lock 1 = entropy_func_mutex() */
+ /* lock 1 = entropy_func_mutex() */
polarsslthreadlock_lock_function(1);
ret = entropy_func(data, output, len);
polarsslthreadlock_unlock_function(1);
-
- return ret;
+
+ return ret;
}
/* end of entropy_func_mutex() */
entropy_init_mutex(&entropy);
if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func_mutex, &entropy,
- connssl->ssn.id, connssl->ssn.length)) != 0)
- {
+ connssl->ssn.id, connssl->ssn.length)) != 0) {
#ifdef POLARSSL_ERROR_C
error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
- failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n", -ret, errorbuf);
+ failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
+ -ret, errorbuf);
}
#else
entropy_init(&connssl->entropy);
if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func, &connssl->entropy,
- connssl->ssn.id, connssl->ssn.length)) != 0)
- {
+ connssl->ssn.id, connssl->ssn.length)) != 0) {
#ifdef POLARSSL_ERROR_C
error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
- failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n", -ret, errorbuf);
+ failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
+ -ret, errorbuf);
}
#endif /* THREADING_SUPPORT */
#endif /* POLARSSL_VERSION_NUMBER<0x01010000 */
else if(ret != POLARSSL_ERR_NET_WANT_READ &&
ret != POLARSSL_ERR_NET_WANT_WRITE) {
#ifdef POLARSSL_ERROR_C
- error_strerror(ret, errorbuf, sizeof(errorbuf));
+ error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
- failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s", -ret, errorbuf);
+ failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s",
+ -ret, errorbuf);
- return CURLE_SSL_CONNECT_ERROR;
+ return CURLE_SSL_CONNECT_ERROR;
}
else {
if(ret == POLARSSL_ERR_NET_WANT_READ) {
return polarsslthreadlock_thread_setup();
#else /* THREADING_SUPPORT */
return 1;
-#endif /* THREADING_SUPPORT */
+#endif /* THREADING_SUPPORT */
}
void polarssl_cleanup(void)
#include <stdio.h>
#include "curl_setup.h"
-#if defined(USE_POLARSSL) && (defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32))
+#if defined(USE_POLARSSL) && \
+ (defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32))
#if defined(USE_THREADS_POSIX)
#ifdef HAVE_PTHREAD_H
int ret;
mutex_buf = malloc(NUMT * sizeof(MUTEX_TYPE));
- if (!mutex_buf)
+ if(!mutex_buf)
return 0; /* error, no number of threads defined */
#ifdef HAVE_PTHREAD_H
- for (i = 0; i < NUMT; i++)
- {
+ for(i = 0; i < NUMT; i++) {
ret = pthread_mutex_init(&mutex_buf[i], NULL);
- if(ret)
- return 0; /* pthread_mutex_init failed */
+ if(ret)
+ return 0; /* pthread_mutex_init failed */
}
#elif defined(HAVE_PROCESS_H)
- for (i = 0; i < NUMT; i++)
- {
+ for(i = 0; i < NUMT; i++) {
mutex_buf[i] = CreateMutex(0, FALSE, 0);
- if(mutex_buf[i] == 0)
- return 0; /* CreateMutex failed */
- }
+ if(mutex_buf[i] == 0)
+ return 0; /* CreateMutex failed */
+ }
#endif /* HAVE_PTHREAD_H */
return 1; /* OK */
{
int i;
int ret;
-
- if (!mutex_buf)
+
+ if(!mutex_buf)
return 0; /* error, no threads locks defined */
#ifdef HAVE_PTHREAD_H
- for (i = 0; i < NUMT; i++)
- {
+ for(i = 0; i < NUMT; i++) {
ret = pthread_mutex_destroy(&mutex_buf[i]);
- if(ret)
- return 0; /* pthread_mutex_destroy failed */
+ if(ret)
+ return 0; /* pthread_mutex_destroy failed */
}
#elif defined(HAVE_PROCESS_H)
- for (i = 0; i < NUMT; i++)
+ for(i = 0; i < NUMT; i++) {
ret = CloseHandle(mutex_buf[i]);
if(!ret)
- return 0; /* CloseHandle failed */
+ return 0; /* CloseHandle failed */
+ }
#endif /* HAVE_PTHREAD_H */
free(mutex_buf);
mutex_buf = NULL;
{
int ret;
#ifdef HAVE_PTHREAD_H
- if(n < NUMT)
- {
+ if(n < NUMT) {
ret = pthread_mutex_lock(&mutex_buf[n]);
- if(ret)
- {
- DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_lock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: polarsslthreadlock_lock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
}
#elif defined(HAVE_PROCESS_H)
- if(n < NUMT)
- {
+ if(n < NUMT) {
ret = (WaitForSingleObject(mutex_buf[n], INFINITE)==WAIT_FAILED?1:0);
- if(ret)
- {
- DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_lock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
- }
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: polarsslthreadlock_lock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
+ }
#endif /* HAVE_PTHREAD_H */
return 1; /* OK */
}
{
int ret;
#ifdef HAVE_PTHREAD_H
- if(n < NUMT)
- {
+ if(n < NUMT) {
ret = pthread_mutex_unlock(&mutex_buf[n]);
- if(ret)
- {
- DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_unlock_function failed\n"));
- return 0; /* pthread_mutex_unlock failed */
- }
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: polarsslthreadlock_unlock_function failed\n"));
+ return 0; /* pthread_mutex_unlock failed */
+ }
}
#elif defined(HAVE_PROCESS_H)
- if(n < NUMT)
- {
+ if(n < NUMT) {
ret = ReleaseMutex(mutex_buf[n]);
- if(!ret)
- {
- DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_unlock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
+ if(!ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: polarsslthreadlock_unlock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
}
#endif /* HAVE_PTHREAD_H */
return 1; /* OK */