X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_api.c;h=ace6b4eb7e4347bcd522e150f95aa70b816187d6;hp=b16957c6491f5a01c54d387e612c8383a4860b6d;hb=656d8e1b62f2fd578b2b0943e6a09ac13bab4f70;hpb=03848def2b38db9a52ab905405d9ea9ffd130e85 diff --git a/http_request_api.c b/http_request_api.c index b16957c..ace6b4e 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -1,16 +1,13 @@ /* - +----------------------------------------------------------------------+ - | PECL :: http | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.0 of the PHP license, that | - | is bundled with this package in the file LICENSE, and is available | - | through the world-wide-web at http://www.php.net/license/3_0.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Copyright (c) 2004-2005 Michael Wallner | - +----------------------------------------------------------------------+ + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2005, Michael Wallner | + +--------------------------------------------------------------------+ */ /* $Id$ */ @@ -40,18 +37,16 @@ #include -/* - * cruft for thread safe SSL crypto locks - */ +/* {{{ cruft for thread safe SSL crypto locks */ #if defined(ZTS) && defined(HTTP_HAVE_SSL) # ifdef PHP_WIN32 # define HTTP_NEED_SSL_TSL # define HTTP_NEED_OPENSSL_TSL # include # else /* !PHP_WIN32 */ -# define HTTP_NEED_SSL_TSL # if defined(HTTP_HAVE_OPENSSL) # if defined(HAVE_OPENSSL_CRYPTO_H) +# define HTTP_NEED_SSL_TSL # define HTTP_NEED_OPENSSL_TSL # include # else @@ -62,6 +57,7 @@ # endif # elif defined(HTTP_HAVE_GNUTLS) # if defined(HAVE_GCRYPT_H) +# define HTTP_NEED_SSL_TSL # define HTTP_NEED_GNUTLS_TSL # include # else @@ -78,6 +74,7 @@ # endif /* HTTP_HAVE_OPENSSL || HTTP_HAVE_GNUTLS */ # endif /* PHP_WIN32 */ #endif /* ZTS && HTTP_HAVE_SSL */ +/* }}} */ ZEND_EXTERN_MODULE_GLOBALS(http); @@ -898,15 +895,15 @@ static inline zval *_http_curl_getopt_ex(HashTable *options, char *key, size_t k /* }}} */ #ifdef HTTP_NEED_OPENSSL_TSL - -static MUTEX_T *http_ssl_mutex = NULL; +/* {{{ */ +static MUTEX_T *http_openssl_tsl = NULL; static void http_ssl_lock(int mode, int n, const char * file, int line) { if (mode & CRYPTO_LOCK) { - tsrm_mutex_lock(http_ssl_mutex[n]); + tsrm_mutex_lock(http_openssl_tsl[n]); } else { - tsrm_mutex_unlock(http_ssl_mutex[n]); + tsrm_mutex_unlock(http_openssl_tsl[n]); } } @@ -919,10 +916,10 @@ static inline void http_ssl_init(void) { int i, c = CRYPTO_num_locks(); - http_ssl_mutex = malloc(c * sizeof(MUTEX_T)); + http_openssl_tsl = malloc(c * sizeof(MUTEX_T)); for (i = 0; i < c; ++i) { - http_ssl_mutex[i] = tsrm_mutex_alloc(); + http_openssl_tsl[i] = tsrm_mutex_alloc(); } CRYPTO_set_id_callback(http_ssl_id); @@ -931,27 +928,28 @@ static inline void http_ssl_init(void) static inline void http_ssl_cleanup(void) { - if (http_ssl_mutex) { + if (http_openssl_tsl) { int i, c = CRYPTO_num_locks(); CRYPTO_set_id_callback(NULL); CRYPTO_set_locking_callback(NULL); for (i = 0; i < c; ++i) { - tsrm_mutex_free(http_ssl_mutex[i]); + tsrm_mutex_free(http_openssl_tsl[i]); } - free(http_ssl_mutex); - http_ssl_mutex = NULL; + free(http_openssl_tsl); + http_openssl_tsl = NULL; } } #endif /* HTTP_NEED_OPENSSL_TSL */ +/* }}} */ #ifdef HTTP_NEED_GNUTLS_TSL - +/* {{{ */ static int http_ssl_mutex_create(void **m) { - if (*((MUTEX_T **) m) = tsrm_mutex_alloc()) { + if (*((MUTEX_T *) m) = tsrm_mutex_alloc()) { return SUCCESS; } else { return FAILURE; @@ -960,21 +958,21 @@ static int http_ssl_mutex_create(void **m) static int http_ssl_mutex_destroy(void **m) { - tsrm_mutex_free(*((MUTEX_T **) m)); + tsrm_mutex_free(*((MUTEX_T *) m)); return SUCCESS; } static int http_ssl_mutex_lock(void **m) { - return tsrm_mutex_lock(*((MUTEX_T **) m)); + return tsrm_mutex_lock(*((MUTEX_T *) m)); } static int http_ssl_mutex_unlock(void **m) { - return tsrm_mutex_unlock(*((MUTEX_T **) m)); + return tsrm_mutex_unlock(*((MUTEX_T *) m)); } -static struct gcry_thread_cbs http_ssl_callbacks = { +static struct gcry_thread_cbs http_gnutls_tsl = { GCRY_THREAD_OPTIONS_USER, NULL, http_ssl_mutex_create, @@ -985,16 +983,17 @@ static struct gcry_thread_cbs http_ssl_callbacks = { static inline void http_ssl_init(void) { - gcry_control(GCRYCTL_SET_THREAD_CBS, &http_ssl_callbacks); + gcry_control(GCRYCTL_SET_THREAD_CBS, &http_gnutls_tsl); } static inline void http_ssl_cleanup(void) { return; } - #endif /* HTTP_NEED_GNUTLS_TSL */ +/* }}} */ +/* {{{ http_curl_defaults(CURL *) */ static inline void _http_curl_defaults(CURL *ch) { HTTP_CURL_OPT(URL, NULL); @@ -1051,6 +1050,7 @@ static inline void _http_curl_defaults(CURL *ch) HTTP_CURL_OPT(READDATA, NULL); HTTP_CURL_OPT(INFILESIZE, 0); } +/* }}} */ #endif /* HTTP_HAVE_CURL */