2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2006, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
15 #if defined(ZTS) && defined(HTTP_HAVE_SSL)
17 # define HTTP_NEED_OPENSSL_TSL
18 # include <openssl/crypto.h>
19 # else /* !PHP_WIN32 */
20 # if defined(HTTP_HAVE_OPENSSL)
21 # if defined(HAVE_OPENSSL_CRYPTO_H)
22 # define HTTP_NEED_OPENSSL_TSL
23 # include <openssl/crypto.h>
26 "libcurl was compiled with OpenSSL support, but configure could not find " \
27 "openssl/crypto.h; thus no SSL crypto locking callbacks will be set, which may " \
28 "cause random crashes on SSL requests"
30 # elif defined(HTTP_HAVE_GNUTLS)
31 # if defined(HAVE_GCRYPT_H)
32 # define HTTP_NEED_GNUTLS_TSL
36 "libcurl was compiled with GnuTLS support, but configure could not find " \
37 "gcrypt.h; thus no SSL crypto locking callbacks will be set, which may " \
38 "cause random crashes on SSL requests"
42 "libcurl was compiled with SSL support, but configure could not determine which" \
43 "library was used; thus no SSL crypto locking callbacks will be set, which may " \
44 "cause random crashes on SSL requests"
45 # endif /* HTTP_HAVE_OPENSSL || HTTP_HAVE_GNUTLS */
46 # endif /* PHP_WIN32 */
47 #endif /* ZTS && HTTP_HAVE_SSL */
49 #ifndef HAVE_CURL_EASY_STRERROR
50 # define curl_easy_strerror(dummy) "unknown error"
53 #define HTTP_CURL_INFO(I) \
56 HTTP_CURL_INFO_EX(I, N+lenof("CURLINFO_")); \
58 #define HTTP_CURL_INFO_EX(I, X) \
59 switch (I & ~CURLINFO_MASK) \
61 case CURLINFO_STRING: \
64 if (CURLE_OK == curl_easy_getinfo(request->ch, I, &c)) { \
65 char *key = estrndup(X, strlen(X)); \
66 add_assoc_string(&array, pretty_key(key, strlen(X), 0, 0), c ? c : "", 1); \
72 case CURLINFO_DOUBLE: \
75 if (CURLE_OK == curl_easy_getinfo(request->ch, I, &d)) { \
76 char *key = estrndup(X, strlen(X)); \
77 add_assoc_double(&array, pretty_key(key, strlen(X), 0, 0), d); \
86 if (CURLE_OK == curl_easy_getinfo(request->ch, I, &l)) { \
87 char *key = estrndup(X, strlen(X)); \
88 add_assoc_long(&array, pretty_key(key, strlen(X), 0, 0), l); \
94 case CURLINFO_SLIST: \
96 struct curl_slist *l, *p; \
97 if (CURLE_OK == curl_easy_getinfo(request->ch, I, &l)) { \
99 char *key = estrndup(X, strlen(X)); \
100 MAKE_STD_ZVAL(subarray); \
101 array_init(subarray); \
102 for (p = l; p; p = p->next) { \
103 add_next_index_string(subarray, p->data, 1); \
105 add_assoc_zval(&array, pretty_key(key, strlen(X), 0, 0), subarray); \
106 curl_slist_free_all(l); \
112 #define HTTP_CURL_OPT(OPTION, p) HTTP_CURL_OPT_EX(request->ch, OPTION, (p))
113 #define HTTP_CURL_OPT_EX(ch, OPTION, p) curl_easy_setopt((ch), OPTION, (p))
115 #define HTTP_CURL_OPT_STRING(OPTION, ldiff, obdc) \
118 HTTP_CURL_OPT_STRING_EX(K+lenof("CURLOPT_KEY")+ldiff, OPTION, obdc); \
120 #define HTTP_CURL_OPT_STRING_EX(keyname, optname, obdc) \
121 if (!strcasecmp(key, keyname)) { \
122 zval *copy = http_request_option_cache_ex(request, keyname, strlen(keyname)+1, 0, zval_copy(IS_STRING, *param)); \
124 HTTP_CHECK_OPEN_BASEDIR(Z_STRVAL_P(copy), return FAILURE); \
126 HTTP_CURL_OPT(optname, Z_STRVAL_P(copy)); \
130 #define HTTP_CURL_OPT_LONG(OPTION, ldiff) \
133 HTTP_CURL_OPT_LONG_EX(K+lenof("CURLOPT_KEY")+ldiff, OPTION); \
135 #define HTTP_CURL_OPT_LONG_EX(keyname, optname) \
136 if (!strcasecmp(key, keyname)) { \
137 zval *copy = zval_copy(IS_LONG, *param); \
138 HTTP_CURL_OPT(optname, Z_LVAL_P(copy)); \
149 * vim600: noet sw=4 ts=4 fdm=marker
150 * vim<600: noet sw=4 ts=4