2000-07-16 19:37:33 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 08:18:22 +00:00
| PHP Version 5 |
2000-07-16 19:37:33 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2012-01-01 13:15:04 +00:00
| Copyright ( c ) 1997 - 2012 The PHP Group |
2000-07-16 19:37:33 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2006-01-01 12:51:34 +00:00
| This source file is subject to version 3.01 of the PHP license , |
2000-07-16 19:37:33 +00:00
| that is bundled with this package in the file LICENSE , and is |
2003-06-10 20:04:29 +00:00
| available through the world - wide - web at the following url : |
2006-01-01 12:51:34 +00:00
| http : //www.php.net/license/3_01.txt |
2000-07-16 19:37:33 +00:00
| 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 |
2010-04-26 23:53:30 +00:00
| license @ php . net so we can mail you 6 copy immediately . |
2000-07-16 19:37:33 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2001-02-15 16:20:13 +00:00
| Author : Sterling Hughes < sterling @ php . net > |
2000-07-16 19:37:33 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
/* $Id$ */
2003-02-25 07:19:44 +00:00
# define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
2001-05-24 10:07:29 +00:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
2000-07-16 19:37:33 +00:00
# include "php.h"
# if HAVE_CURL
# include <stdio.h>
2000-09-30 03:09:54 +00:00
# include <string.h>
2000-08-15 16:50:14 +00:00
# ifdef PHP_WIN32
2003-02-16 03:48:49 +00:00
# include <winsock2.h>
2000-08-20 08:28:00 +00:00
# include <sys/types.h>
2000-08-15 16:50:14 +00:00
# endif
2000-09-30 03:09:54 +00:00
2000-07-16 19:37:33 +00:00
# include <curl/curl.h>
# include <curl/easy.h>
2000-09-30 03:09:54 +00:00
2004-03-22 18:42:03 +00:00
/* As of curl 7.11.1 this is no longer defined inside curl.h */
# ifndef HttpPost
# define HttpPost curl_httppost
# endif
2005-10-25 14:32:33 +00:00
/* {{{ cruft for thread safe SSL crypto locks */
# if defined(ZTS) && defined(HAVE_CURL_SSL)
2005-10-26 11:33:25 +00:00
# ifdef PHP_WIN32
# define PHP_CURL_NEED_OPENSSL_TSL
# include <openssl / crypto.h>
# else /* !PHP_WIN32 */
# if defined(HAVE_CURL_OPENSSL)
# if defined(HAVE_OPENSSL_CRYPTO_H)
# define PHP_CURL_NEED_OPENSSL_TSL
# include <openssl / crypto.h>
# else
# warning \
" libcurl was compiled with OpenSSL support, but configure could not find " \
" openssl/crypto.h; thus no SSL crypto locking callbacks will be set, which may " \
" cause random crashes on SSL requests "
# endif
# elif defined(HAVE_CURL_GNUTLS)
# if defined(HAVE_GCRYPT_H)
# define PHP_CURL_NEED_GNUTLS_TSL
# include <gcrypt.h>
# else
# warning \
" libcurl was compiled with GnuTLS support, but configure could not find " \
" gcrypt.h; thus no SSL crypto locking callbacks will be set, which may " \
" cause random crashes on SSL requests "
# endif
# else
# warning \
" libcurl was compiled with SSL support, but configure could not determine which " \
" library was used; thus no SSL crypto locking callbacks will be set, which may " \
" cause random crashes on SSL requests "
# endif /* HAVE_CURL_OPENSSL || HAVE_CURL_GNUTLS */
# endif /* PHP_WIN32 */
2005-10-25 14:32:33 +00:00
# endif /* ZTS && HAVE_CURL_SSL */
/* }}} */
2001-08-02 19:28:33 +00:00
# define SMART_STR_PREALLOC 4096
# include "ext/standard/php_smart_str.h"
2000-07-16 19:37:33 +00:00
# include "ext/standard/info.h"
2000-11-23 15:57:24 +00:00
# include "ext/standard/file.h"
2005-03-14 09:02:23 +00:00
# include "ext/standard/url.h"
2000-07-16 19:37:33 +00:00
# include "php_curl.h"
2005-07-15 16:47:48 +00:00
int le_curl ;
int le_curl_multi_handle ;
2011-12-01 21:48:07 +00:00
int le_curl_share_handle ;
2005-07-15 16:47:48 +00:00
2006-01-26 13:23:33 +00:00
# ifdef PHP_CURL_NEED_OPENSSL_TSL /* {{{ */
static MUTEX_T * php_curl_openssl_tsl = NULL ;
static void php_curl_ssl_lock ( int mode , int n , const char * file , int line )
{
if ( mode & CRYPTO_LOCK ) {
tsrm_mutex_lock ( php_curl_openssl_tsl [ n ] ) ;
} else {
tsrm_mutex_unlock ( php_curl_openssl_tsl [ n ] ) ;
}
}
static unsigned long php_curl_ssl_id ( void )
{
return ( unsigned long ) tsrm_thread_id ( ) ;
}
2005-10-25 14:32:33 +00:00
# endif
2006-01-26 13:23:33 +00:00
/* }}} */
# ifdef PHP_CURL_NEED_GNUTLS_TSL /* {{{ */
static int php_curl_ssl_mutex_create ( void * * m )
{
if ( * ( ( MUTEX_T * ) m ) = tsrm_mutex_alloc ( ) ) {
return SUCCESS ;
} else {
return FAILURE ;
}
}
static int php_curl_ssl_mutex_destroy ( void * * m )
{
tsrm_mutex_free ( * ( ( MUTEX_T * ) m ) ) ;
return SUCCESS ;
}
static int php_curl_ssl_mutex_lock ( void * * m )
{
return tsrm_mutex_lock ( * ( ( MUTEX_T * ) m ) ) ;
}
static int php_curl_ssl_mutex_unlock ( void * * m )
{
return tsrm_mutex_unlock ( * ( ( MUTEX_T * ) m ) ) ;
}
static struct gcry_thread_cbs php_curl_gnutls_tsl = {
GCRY_THREAD_OPTION_USER ,
NULL ,
php_curl_ssl_mutex_create ,
php_curl_ssl_mutex_destroy ,
php_curl_ssl_mutex_lock ,
php_curl_ssl_mutex_unlock
} ;
# endif
/* }}} */
2005-10-25 14:32:33 +00:00
2009-05-18 10:31:08 +00:00
static void _php_curl_close_ex ( php_curl * ch TSRMLS_DC ) ;
2001-07-31 05:44:11 +00:00
static void _php_curl_close ( zend_rsrc_list_entry * rsrc TSRMLS_DC ) ;
2001-04-30 14:36:19 +00:00
2011-09-12 09:16:04 +00:00
2001-04-30 14:36:19 +00:00
# define SAVE_CURL_ERROR(__handle, __err) (__handle)->err.no = (int) __err;
2000-09-30 03:09:54 +00:00
2002-11-08 17:58:43 +00:00
# define CAAL(s, v) add_assoc_long_ex(return_value, s, sizeof(s), (long) v);
# define CAAD(s, v) add_assoc_double_ex(return_value, s, sizeof(s), (double) v);
2007-12-18 13:46:07 +00:00
# define CAAS(s, v) add_assoc_string_ex(return_value, s, sizeof(s), (char *) (v ? v : ""), 1);
2002-11-08 17:58:43 +00:00
# define CAAZ(s, v) add_assoc_zval_ex(return_value, s, sizeof(s), (zval *) v);
2006-12-26 16:55:56 +00:00
# if defined(PHP_WIN32) || defined(__GNUC__)
2009-05-18 12:51:05 +00:00
# define php_curl_ret(__ret) RETVAL_FALSE; return __ret;
2006-12-26 16:55:56 +00:00
# else
2009-05-18 12:51:05 +00:00
# define php_curl_ret(__ret) RETVAL_FALSE; return;
2006-12-26 16:55:56 +00:00
# endif
2010-04-13 11:02:15 +00:00
static int php_curl_option_url ( php_curl * ch , const char * url , const int len TSRMLS_DC ) /* { { { */
2009-05-18 12:51:05 +00:00
{
CURLcode error = CURLE_OK ;
2009-05-18 10:31:08 +00:00
# if LIBCURL_VERSION_NUM < 0x071100
char * copystr = NULL ;
# endif
2010-04-26 23:53:30 +00:00
/* Disable file:// if open_basedir are used */
if ( PG ( open_basedir ) & & * PG ( open_basedir ) ) {
2009-05-18 10:31:08 +00:00
# if LIBCURL_VERSION_NUM >= 0x071304
error = curl_easy_setopt ( ch - > cp , CURLOPT_PROTOCOLS , CURLPROTO_ALL & ~ CURLPROTO_FILE ) ;
# else
php_url * uri ;
if ( ! ( uri = php_url_parse_ex ( url , len ) ) ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Invalid URL '%s' " , url ) ;
return 0 ;
}
2009-08-26 22:24:10 +00:00
if ( uri - > scheme & & ! strncasecmp ( " file " , uri - > scheme , sizeof ( " file " ) ) ) {
2009-05-18 10:31:08 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Protocol 'file' disabled in cURL " ) ;
php_url_free ( uri ) ;
return 0 ;
}
php_url_free ( uri ) ;
# endif
2005-03-14 09:02:23 +00:00
}
2009-05-18 10:31:08 +00:00
/* Strings passed to libcurl as 'char *' arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
# if LIBCURL_VERSION_NUM >= 0x071100
error = curl_easy_setopt ( ch - > cp , CURLOPT_URL , url ) ;
# else
copystr = estrndup ( url , len ) ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_URL , copystr ) ;
2011-11-22 05:19:37 +00:00
zend_llist_add_element ( & ch - > to_free - > str , & copystr ) ;
2009-05-18 10:31:08 +00:00
# endif
return ( error = = CURLE_OK ? 1 : 0 ) ;
}
2009-05-18 12:51:05 +00:00
/* }}} */
2005-03-14 09:02:23 +00:00
2011-09-12 09:16:04 +00:00
int _php_curl_verify_handlers ( php_curl * ch , int reporterror TSRMLS_DC ) /* { { { */
{
php_stream * stream ;
if ( ! ch | | ! ch - > handlers ) {
return 0 ;
}
if ( ch - > handlers - > std_err ) {
stream = ( php_stream * ) zend_fetch_resource ( & ch - > handlers - > std_err TSRMLS_CC , - 1 , NULL , NULL , 2 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
if ( stream = = NULL ) {
if ( reporterror ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLOPT_STDERR resource has gone away, resetting to stderr " ) ;
}
zval_ptr_dtor ( & ch - > handlers - > std_err ) ;
ch - > handlers - > std_err = NULL ;
curl_easy_setopt ( ch - > cp , CURLOPT_STDERR , stderr ) ;
}
}
if ( ch - > handlers - > read & & ch - > handlers - > read - > stream ) {
stream = ( php_stream * ) zend_fetch_resource ( & ch - > handlers - > read - > stream TSRMLS_CC , - 1 , NULL , NULL , 2 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
if ( stream = = NULL ) {
if ( reporterror ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLOPT_INFILE resource has gone away, resetting to default " ) ;
}
zval_ptr_dtor ( & ch - > handlers - > read - > stream ) ;
ch - > handlers - > read - > fd = 0 ;
ch - > handlers - > read - > fp = 0 ;
ch - > handlers - > read - > stream = NULL ;
curl_easy_setopt ( ch - > cp , CURLOPT_INFILE , ( void * ) ch ) ;
}
}
if ( ch - > handlers - > write_header & & ch - > handlers - > write_header - > stream ) {
stream = ( php_stream * ) zend_fetch_resource ( & ch - > handlers - > write_header - > stream TSRMLS_CC , - 1 , NULL , NULL , 2 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
if ( stream = = NULL ) {
if ( reporterror ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLOPT_WRITEHEADER resource has gone away, resetting to default " ) ;
}
zval_ptr_dtor ( & ch - > handlers - > write_header - > stream ) ;
ch - > handlers - > write_header - > fp = 0 ;
ch - > handlers - > write_header - > stream = NULL ;
ch - > handlers - > write_header - > method = PHP_CURL_IGNORE ;
curl_easy_setopt ( ch - > cp , CURLOPT_WRITEHEADER , ( void * ) ch ) ;
}
}
if ( ch - > handlers - > write & & ch - > handlers - > write - > stream ) {
stream = ( php_stream * ) zend_fetch_resource ( & ch - > handlers - > write - > stream TSRMLS_CC , - 1 , NULL , NULL , 2 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
if ( stream = = NULL ) {
if ( reporterror ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLOPT_FILE resource has gone away, resetting to default " ) ;
}
zval_ptr_dtor ( & ch - > handlers - > write - > stream ) ;
ch - > handlers - > write - > fp = 0 ;
ch - > handlers - > write - > stream = NULL ;
ch - > handlers - > write - > method = PHP_CURL_STDOUT ;
curl_easy_setopt ( ch - > cp , CURLOPT_FILE , ( void * ) ch ) ;
}
}
return 1 ;
}
/* }}} */
2006-06-11 01:42:17 +00:00
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_version , 0 , 0 , 0 )
ZEND_ARG_INFO ( 0 , version )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_init , 0 , 0 , 0 )
ZEND_ARG_INFO ( 0 , url )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_copy_handle , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_setopt , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_ARG_INFO ( 0 , option )
ZEND_ARG_INFO ( 0 , value )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_setopt_array , 0 )
ZEND_ARG_INFO ( 0 , ch )
2009-05-18 12:01:44 +00:00
ZEND_ARG_ARRAY_INFO ( 0 , options , 0 )
2006-06-11 01:42:17 +00:00
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_exec , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_getinfo , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_ARG_INFO ( 0 , option )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_error , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_errno , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_close , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
ZEND_BEGIN_ARG_INFO ( arginfo_curl_reset , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
# endif
# if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
ZEND_BEGIN_ARG_INFO ( arginfo_curl_escape , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_ARG_INFO ( 0 , str )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_unescape , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_ARG_INFO ( 0 , str )
ZEND_END_ARG_INFO ( )
# endif
2006-06-11 01:42:17 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_curl_multi_init , 0 )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_multi_add_handle , 0 )
ZEND_ARG_INFO ( 0 , mh )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_multi_remove_handle , 0 )
ZEND_ARG_INFO ( 0 , mh )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_multi_select , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , mh )
ZEND_ARG_INFO ( 0 , timeout )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_multi_exec , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , mh )
ZEND_ARG_INFO ( 1 , still_running )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_multi_getcontent , 0 )
ZEND_ARG_INFO ( 0 , ch )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_curl_multi_info_read , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , mh )
2009-06-11 09:43:59 +00:00
ZEND_ARG_INFO ( 1 , msgs_in_queue )
2006-06-11 01:42:17 +00:00
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_multi_close , 0 )
ZEND_ARG_INFO ( 0 , mh )
ZEND_END_ARG_INFO ( )
2011-12-01 21:48:07 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_curl_share_init , 0 )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_share_close , 0 )
ZEND_ARG_INFO ( 0 , sh )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_curl_share_setopt , 0 )
ZEND_ARG_INFO ( 0 , sh )
ZEND_ARG_INFO ( 0 , option )
ZEND_ARG_INFO ( 0 , value )
ZEND_END_ARG_INFO ( )
2006-06-11 01:42:17 +00:00
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ curl_functions[]
*/
2007-09-27 18:00:48 +00:00
const zend_function_entry curl_functions [ ] = {
2006-06-11 01:42:17 +00:00
PHP_FE ( curl_init , arginfo_curl_init )
PHP_FE ( curl_copy_handle , arginfo_curl_copy_handle )
PHP_FE ( curl_version , arginfo_curl_version )
PHP_FE ( curl_setopt , arginfo_curl_setopt )
PHP_FE ( curl_setopt_array , arginfo_curl_setopt_array )
PHP_FE ( curl_exec , arginfo_curl_exec )
PHP_FE ( curl_getinfo , arginfo_curl_getinfo )
PHP_FE ( curl_error , arginfo_curl_error )
PHP_FE ( curl_errno , arginfo_curl_errno )
PHP_FE ( curl_close , arginfo_curl_close )
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
PHP_FE ( curl_reset , arginfo_curl_reset )
# endif
# if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
PHP_FE ( curl_escape , arginfo_curl_escape )
PHP_FE ( curl_unescape , arginfo_curl_unescape )
# endif
2006-06-11 01:42:17 +00:00
PHP_FE ( curl_multi_init , arginfo_curl_multi_init )
PHP_FE ( curl_multi_add_handle , arginfo_curl_multi_add_handle )
PHP_FE ( curl_multi_remove_handle , arginfo_curl_multi_remove_handle )
PHP_FE ( curl_multi_select , arginfo_curl_multi_select )
PHP_FE ( curl_multi_exec , arginfo_curl_multi_exec )
PHP_FE ( curl_multi_getcontent , arginfo_curl_multi_getcontent )
PHP_FE ( curl_multi_info_read , arginfo_curl_multi_info_read )
PHP_FE ( curl_multi_close , arginfo_curl_multi_close )
2011-12-01 21:48:07 +00:00
PHP_FE ( curl_share_init , arginfo_curl_share_init )
PHP_FE ( curl_share_close , arginfo_curl_share_close )
PHP_FE ( curl_share_setopt , arginfo_curl_share_setopt )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2000-07-16 19:37:33 +00:00
} ;
2001-06-05 13:12:10 +00:00
/* }}} */
2000-07-16 19:37:33 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ curl_module_entry
*/
2000-07-16 19:37:33 +00:00
zend_module_entry curl_module_entry = {
2001-10-11 23:33:59 +00:00
STANDARD_MODULE_HEADER ,
2000-07-16 19:37:33 +00:00
" curl " ,
curl_functions ,
PHP_MINIT ( curl ) ,
2001-09-22 00:38:59 +00:00
PHP_MSHUTDOWN ( curl ) ,
2000-08-17 02:14:41 +00:00
NULL ,
2000-07-16 19:37:33 +00:00
NULL ,
PHP_MINFO ( curl ) ,
2001-12-10 13:22:48 +00:00
NO_VERSION_YET ,
2000-07-16 19:37:33 +00:00
STANDARD_MODULE_PROPERTIES
} ;
2001-06-05 13:12:10 +00:00
/* }}} */
2000-07-16 19:37:33 +00:00
# ifdef COMPILE_DL_CURL
ZEND_GET_MODULE ( curl )
# endif
2011-04-01 17:10:52 +00:00
/* {{{ PHP_INI_BEGIN */
PHP_INI_BEGIN ( )
PHP_INI_ENTRY ( " curl.cainfo " , " " , PHP_INI_SYSTEM , NULL )
PHP_INI_END ( )
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ PHP_MINFO_FUNCTION
*/
2000-07-16 19:37:33 +00:00
PHP_MINFO_FUNCTION ( curl )
{
2008-11-11 12:26:04 +00:00
curl_version_info_data * d ;
char * * p ;
char str [ 1024 ] ;
size_t n = 0 ;
d = curl_version_info ( CURLVERSION_NOW ) ;
2000-08-13 19:32:09 +00:00
php_info_print_table_start ( ) ;
2006-09-09 20:04:50 +00:00
php_info_print_table_row ( 2 , " cURL support " , " enabled " ) ;
2008-11-11 12:26:04 +00:00
php_info_print_table_row ( 2 , " cURL Information " , d - > version ) ;
sprintf ( str , " %d " , d - > age ) ;
php_info_print_table_row ( 2 , " Age " , str ) ;
2009-01-25 17:12:36 +00:00
/* To update on each new cURL release using src/main.c in cURL sources */
2009-05-18 12:51:05 +00:00
if ( d - > features ) {
2009-01-25 17:12:36 +00:00
struct feat {
const char * name ;
int bitmask ;
} ;
2008-11-11 12:26:04 +00:00
2009-01-25 17:12:36 +00:00
unsigned int i ;
2008-11-11 12:26:04 +00:00
2009-01-25 17:12:36 +00:00
static const struct feat feats [ ] = {
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */
2009-01-25 17:12:36 +00:00
{ " AsynchDNS " , CURL_VERSION_ASYNCHDNS } ,
2008-11-11 12:26:04 +00:00
# endif
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
{ " CharConv " , CURL_VERSION_CONV } ,
# endif
# if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
2009-01-25 17:12:36 +00:00
{ " Debug " , CURL_VERSION_DEBUG } ,
{ " GSS-Negotiate " , CURL_VERSION_GSSNEGOTIATE } ,
2008-11-11 12:26:04 +00:00
# endif
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
2009-01-25 17:12:36 +00:00
{ " IDN " , CURL_VERSION_IDN } ,
2008-11-11 12:26:04 +00:00
# endif
2009-01-25 17:12:36 +00:00
{ " IPv6 " , CURL_VERSION_IPV6 } ,
2011-12-03 21:24:19 +00:00
{ " krb4 " , CURL_VERSION_KERBEROS4 } ,
# if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */
2009-01-25 17:12:36 +00:00
{ " Largefile " , CURL_VERSION_LARGEFILE } ,
2008-11-11 12:26:04 +00:00
# endif
2011-12-03 21:24:19 +00:00
{ " libz " , CURL_VERSION_LIBZ } ,
# if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
2009-01-25 17:12:36 +00:00
{ " NTLM " , CURL_VERSION_NTLM } ,
# endif
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */
{ " NTLMWB " , CURL_VERSION_NTLM_WB } ,
# endif
# if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */
2009-01-25 17:12:36 +00:00
{ " SPNEGO " , CURL_VERSION_SPNEGO } ,
# endif
{ " SSL " , CURL_VERSION_SSL } ,
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */
2009-01-25 17:12:36 +00:00
{ " SSPI " , CURL_VERSION_SSPI } ,
# endif
2011-12-03 21:24:19 +00:00
# if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */
{ " TLS-SRP " , CURL_VERSION_TLSAUTH_SRP } ,
2008-11-11 12:26:04 +00:00
# endif
2009-01-26 15:19:55 +00:00
{ NULL , 0 }
2009-01-25 17:12:36 +00:00
} ;
php_info_print_table_row ( 1 , " Features " ) ;
for ( i = 0 ; i < sizeof ( feats ) / sizeof ( feats [ 0 ] ) ; i + + ) {
if ( feats [ i ] . name ) {
php_info_print_table_row ( 2 , feats [ i ] . name , d - > features & feats [ i ] . bitmask ? " Yes " : " No " ) ;
}
}
2008-11-11 12:26:04 +00:00
}
2009-01-25 17:12:36 +00:00
2008-11-11 12:26:04 +00:00
n = 0 ;
p = ( char * * ) d - > protocols ;
while ( * p ! = NULL ) {
n + = sprintf ( str + n , " %s%s " , * p , * ( p + 1 ) ! = NULL ? " , " : " " ) ;
p + + ;
}
php_info_print_table_row ( 2 , " Protocols " , str ) ;
php_info_print_table_row ( 2 , " Host " , d - > host ) ;
if ( d - > ssl_version ) {
php_info_print_table_row ( 2 , " SSL Version " , d - > ssl_version ) ;
}
if ( d - > libz_version ) {
php_info_print_table_row ( 2 , " ZLib Version " , d - > libz_version ) ;
}
# if defined(CURLVERSION_SECOND) && CURLVERSION_NOW >= CURLVERSION_SECOND
if ( d - > ares ) {
php_info_print_table_row ( 2 , " ZLib Version " , d - > ares ) ;
}
# endif
# if defined(CURLVERSION_THIRD) && CURLVERSION_NOW >= CURLVERSION_THIRD
if ( d - > libidn ) {
php_info_print_table_row ( 2 , " libIDN Version " , d - > libidn ) ;
}
# endif
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
# if LIBCURL_VERSION_NUM >= 0x071300
2008-11-11 12:26:04 +00:00
if ( d - > iconv_ver_num ) {
php_info_print_table_row ( 2 , " IconV Version " , d - > iconv_ver_num ) ;
}
if ( d - > libssh_version ) {
php_info_print_table_row ( 2 , " libSSH Version " , d - > libssh_version ) ;
}
# endif
2000-08-13 19:32:09 +00:00
php_info_print_table_end ( ) ;
2000-07-16 19:37:33 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-07-16 19:37:33 +00:00
2001-09-22 00:38:59 +00:00
# define REGISTER_CURL_CONSTANT(__c) REGISTER_LONG_CONSTANT(#__c, __c, CONST_CS | CONST_PERSISTENT)
2001-04-30 14:36:19 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ PHP_MINIT_FUNCTION
*/
2000-07-16 19:37:33 +00:00
PHP_MINIT_FUNCTION ( curl )
{
2000-10-25 17:44:02 +00:00
le_curl = zend_register_list_destructors_ex ( _php_curl_close , NULL , " curl " , module_number ) ;
2009-06-12 20:48:28 +00:00
le_curl_multi_handle = zend_register_list_destructors_ex ( _php_curl_multi_close , NULL , " curl_multi " , module_number ) ;
2011-12-01 21:48:07 +00:00
le_curl_share_handle = zend_register_list_destructors_ex ( _php_curl_share_close , NULL , " curl_share " , module_number ) ;
2009-05-03 15:16:10 +00:00
2011-04-01 17:10:52 +00:00
REGISTER_INI_ENTRIES ( ) ;
2009-05-04 14:11:45 +00:00
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
2009-05-26 15:49:15 +00:00
or curl src / docs / libcurl / symbols - in - versions for a ( almost ) complete list
2009-05-04 14:11:45 +00:00
of options and which version they were introduced */
2000-08-15 16:50:14 +00:00
/* Constants for curl_setopt() */
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_AUTOREFERER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_BINARYTRANSFER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_BUFFERSIZE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CAINFO ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CAPATH ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CLOSEPOLICY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CONNECTTIMEOUT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_COOKIE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_COOKIEFILE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_COOKIEJAR ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_COOKIESESSION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CRLF ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CUSTOMREQUEST ) ;
2002-07-31 22:10:58 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_DNS_CACHE_TIMEOUT ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_DNS_USE_GLOBAL_CACHE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_EGDSOCKET ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_ENCODING ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FAILONERROR ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FILE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FILETIME ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FOLLOWLOCATION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FORBID_REUSE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FRESH_CONNECT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTPAPPEND ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTPLISTONLY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTPPORT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_USE_EPRT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_USE_EPSV ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_HEADER ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_HEADERFUNCTION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_HTTP200ALIASES ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_HTTPGET ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_HTTPHEADER ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_HTTPPROXYTUNNEL ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_HTTP_VERSION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_INFILE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_INFILESIZE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_INTERFACE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_KRB4LEVEL ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_LOW_SPEED_LIMIT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_LOW_SPEED_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAXCONNECTS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAXREDIRS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_NETRC ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_NOBODY ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_NOPROGRESS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_NOSIGNAL ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PORT ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_POST ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_POSTFIELDS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_POSTQUOTE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PREQUOTE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PRIVATE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROGRESSFUNCTION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYPORT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYTYPE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYUSERPWD ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_PUT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_QUOTE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RANDOM_FILE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_RANGE ) ;
2012-09-22 14:04:51 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_READDATA ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_READFUNCTION ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_REFERER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RESUME_FROM ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_RETURNTRANSFER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SHARE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_SSLCERT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLCERTPASSWD ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_SSLCERTTYPE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLENGINE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLENGINE_DEFAULT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLKEY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLKEYPASSWD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSLKEYTYPE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_SSLVERSION ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_SSL_CIPHER_LIST ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSL_VERIFYHOST ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSL_VERIFYPEER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_STDERR ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_TIMECONDITION ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_TIMEOUT ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_TIMEVALUE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TRANSFERTEXT ) ;
2003-06-19 22:12:21 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_UNRESTRICTED_AUTH ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_UPLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_URL ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_USERAGENT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_USERPWD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_VERBOSE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_WRITEFUNCTION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_WRITEHEADER ) ;
2004-08-18 21:27:24 +00:00
2011-12-01 21:48:07 +00:00
/* Constants effecting the way CURLOPT_CLOSEPOLICY works */
REGISTER_CURL_CONSTANT ( CURLCLOSEPOLICY_CALLBACK ) ;
REGISTER_CURL_CONSTANT ( CURLCLOSEPOLICY_LEAST_RECENTLY_USED ) ;
REGISTER_CURL_CONSTANT ( CURLCLOSEPOLICY_LEAST_TRAFFIC ) ;
REGISTER_CURL_CONSTANT ( CURLCLOSEPOLICY_OLDEST ) ;
REGISTER_CURL_CONSTANT ( CURLCLOSEPOLICY_SLOWEST ) ;
2004-08-18 21:27:24 +00:00
2011-12-01 21:48:07 +00:00
/* */
REGISTER_CURL_CONSTANT ( CURLE_ABORTED_BY_CALLBACK ) ;
REGISTER_CURL_CONSTANT ( CURLE_BAD_CALLING_ORDER ) ;
REGISTER_CURL_CONSTANT ( CURLE_BAD_CONTENT_ENCODING ) ;
2012-08-25 05:21:17 +00:00
REGISTER_CURL_CONSTANT ( CURLE_BAD_DOWNLOAD_RESUME ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_BAD_FUNCTION_ARGUMENT ) ;
REGISTER_CURL_CONSTANT ( CURLE_BAD_PASSWORD_ENTERED ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_COULDNT_CONNECT ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_COULDNT_RESOLVE_HOST ) ;
REGISTER_CURL_CONSTANT ( CURLE_COULDNT_RESOLVE_PROXY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FAILED_INIT ) ;
REGISTER_CURL_CONSTANT ( CURLE_FILE_COULDNT_READ_FILE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_ACCESS_DENIED ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_BAD_DOWNLOAD_RESUME ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_CANT_GET_HOST ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_CANT_RECONNECT ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_GET_SIZE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_RETR_FILE ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_SET_ASCII ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_SET_BINARY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_STOR_FILE ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_COULDNT_USE_REST ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_FTP_PORT_FAILED ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_QUOTE_ERROR ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_USER_PASSWORD_INCORRECT ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WEIRD_227_FORMAT ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WEIRD_PASS_REPLY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WEIRD_PASV_REPLY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WEIRD_SERVER_REPLY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WEIRD_USER_REPLY ) ;
REGISTER_CURL_CONSTANT ( CURLE_FTP_WRITE_ERROR ) ;
REGISTER_CURL_CONSTANT ( CURLE_FUNCTION_NOT_FOUND ) ;
REGISTER_CURL_CONSTANT ( CURLE_GOT_NOTHING ) ;
REGISTER_CURL_CONSTANT ( CURLE_HTTP_NOT_FOUND ) ;
REGISTER_CURL_CONSTANT ( CURLE_HTTP_PORT_FAILED ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_HTTP_POST_ERROR ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_HTTP_RANGE_ERROR ) ;
2012-08-25 05:21:17 +00:00
REGISTER_CURL_CONSTANT ( CURLE_HTTP_RETURNED_ERROR ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_LDAP_CANNOT_BIND ) ;
REGISTER_CURL_CONSTANT ( CURLE_LDAP_SEARCH_FAILED ) ;
REGISTER_CURL_CONSTANT ( CURLE_LIBRARY_NOT_FOUND ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_MALFORMAT_USER ) ;
2001-09-22 00:38:59 +00:00
REGISTER_CURL_CONSTANT ( CURLE_OBSOLETE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_OK ) ;
2012-08-25 05:21:17 +00:00
REGISTER_CURL_CONSTANT ( CURLE_OPERATION_TIMEDOUT ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_OPERATION_TIMEOUTED ) ;
REGISTER_CURL_CONSTANT ( CURLE_OUT_OF_MEMORY ) ;
REGISTER_CURL_CONSTANT ( CURLE_PARTIAL_FILE ) ;
REGISTER_CURL_CONSTANT ( CURLE_READ_ERROR ) ;
2004-04-29 16:25:42 +00:00
REGISTER_CURL_CONSTANT ( CURLE_RECV_ERROR ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SEND_ERROR ) ;
2004-04-29 16:25:42 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SHARE_IN_USE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SSL_CACERT ) ;
2004-04-29 16:25:42 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SSL_CERTPROBLEM ) ;
REGISTER_CURL_CONSTANT ( CURLE_SSL_CIPHER ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SSL_CONNECT_ERROR ) ;
REGISTER_CURL_CONSTANT ( CURLE_SSL_ENGINE_NOTFOUND ) ;
REGISTER_CURL_CONSTANT ( CURLE_SSL_ENGINE_SETFAILED ) ;
REGISTER_CURL_CONSTANT ( CURLE_SSL_PEER_CERTIFICATE ) ;
REGISTER_CURL_CONSTANT ( CURLE_TELNET_OPTION_SYNTAX ) ;
REGISTER_CURL_CONSTANT ( CURLE_TOO_MANY_REDIRECTS ) ;
REGISTER_CURL_CONSTANT ( CURLE_UNKNOWN_TELNET_OPTION ) ;
REGISTER_CURL_CONSTANT ( CURLE_UNSUPPORTED_PROTOCOL ) ;
REGISTER_CURL_CONSTANT ( CURLE_URL_MALFORMAT ) ;
REGISTER_CURL_CONSTANT ( CURLE_URL_MALFORMAT_USER ) ;
REGISTER_CURL_CONSTANT ( CURLE_WRITE_ERROR ) ;
/* cURL info constants */
REGISTER_CURL_CONSTANT ( CURLINFO_CONNECT_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_CONTENT_LENGTH_DOWNLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_CONTENT_LENGTH_UPLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_CONTENT_TYPE ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_EFFECTIVE_URL ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_FILETIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_HEADER_OUT ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_HEADER_SIZE ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_HTTP_CODE ) ;
2012-08-25 05:21:17 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_LASTONE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_NAMELOOKUP_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_PRETRANSFER_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_PRIVATE ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_REDIRECT_COUNT ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_REDIRECT_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_REQUEST_SIZE ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SIZE_DOWNLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SIZE_UPLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SPEED_DOWNLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SPEED_UPLOAD ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SSL_VERIFYRESULT ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_STARTTRANSFER_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_TOTAL_TIME ) ;
/* Other */
REGISTER_CURL_CONSTANT ( CURLMSG_DONE ) ;
REGISTER_CURL_CONSTANT ( CURLVERSION_NOW ) ;
/* Curl Multi Constants */
REGISTER_CURL_CONSTANT ( CURLM_BAD_EASY_HANDLE ) ;
REGISTER_CURL_CONSTANT ( CURLM_BAD_HANDLE ) ;
REGISTER_CURL_CONSTANT ( CURLM_CALL_MULTI_PERFORM ) ;
REGISTER_CURL_CONSTANT ( CURLM_INTERNAL_ERROR ) ;
REGISTER_CURL_CONSTANT ( CURLM_OK ) ;
REGISTER_CURL_CONSTANT ( CURLM_OUT_OF_MEMORY ) ;
/* Curl proxy constants */
2002-11-13 22:25:33 +00:00
REGISTER_CURL_CONSTANT ( CURLPROXY_HTTP ) ;
2009-05-18 11:18:59 +00:00
REGISTER_CURL_CONSTANT ( CURLPROXY_SOCKS4 ) ;
2002-11-13 22:25:33 +00:00
REGISTER_CURL_CONSTANT ( CURLPROXY_SOCKS5 ) ;
2011-12-01 21:48:07 +00:00
/* Curl Share constants */
2012-08-26 13:03:45 +00:00
REGISTER_CURL_CONSTANT ( CURLSHOPT_NONE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLSHOPT_SHARE ) ;
REGISTER_CURL_CONSTANT ( CURLSHOPT_UNSHARE ) ;
2002-11-09 13:52:00 +00:00
2011-12-01 21:48:07 +00:00
/* Curl Http Version constants (CURLOPT_HTTP_VERSION) */
2002-11-09 13:52:00 +00:00
REGISTER_CURL_CONSTANT ( CURL_HTTP_VERSION_1_0 ) ;
REGISTER_CURL_CONSTANT ( CURL_HTTP_VERSION_1_1 ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURL_HTTP_VERSION_NONE ) ;
2009-05-03 15:16:10 +00:00
2011-12-01 21:48:07 +00:00
/* Curl Lock constants */
REGISTER_CURL_CONSTANT ( CURL_LOCK_DATA_COOKIE ) ;
REGISTER_CURL_CONSTANT ( CURL_LOCK_DATA_DNS ) ;
REGISTER_CURL_CONSTANT ( CURL_LOCK_DATA_SSL_SESSION ) ;
2002-11-13 22:25:33 +00:00
2011-12-01 21:48:07 +00:00
/* Curl NETRC constants (CURLOPT_NETRC) */
REGISTER_CURL_CONSTANT ( CURL_NETRC_IGNORED ) ;
REGISTER_CURL_CONSTANT ( CURL_NETRC_OPTIONAL ) ;
REGISTER_CURL_CONSTANT ( CURL_NETRC_REQUIRED ) ;
/* Curl SSL Version constants (CURLOPT_SSLVERSION) */
REGISTER_CURL_CONSTANT ( CURL_SSLVERSION_DEFAULT ) ;
REGISTER_CURL_CONSTANT ( CURL_SSLVERSION_SSLv2 ) ;
REGISTER_CURL_CONSTANT ( CURL_SSLVERSION_SSLv3 ) ;
REGISTER_CURL_CONSTANT ( CURL_SSLVERSION_TLSv1 ) ;
/* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */
REGISTER_CURL_CONSTANT ( CURL_TIMECOND_IFMODSINCE ) ;
REGISTER_CURL_CONSTANT ( CURL_TIMECOND_IFUNMODSINCE ) ;
REGISTER_CURL_CONSTANT ( CURL_TIMECOND_LASTMOD ) ;
2012-08-26 13:03:45 +00:00
REGISTER_CURL_CONSTANT ( CURL_TIMECOND_NONE ) ;
2011-12-01 21:48:07 +00:00
/* Curl version constants */
REGISTER_CURL_CONSTANT ( CURL_VERSION_IPV6 ) ;
REGISTER_CURL_CONSTANT ( CURL_VERSION_KERBEROS4 ) ;
REGISTER_CURL_CONSTANT ( CURL_VERSION_LIBZ ) ;
REGISTER_CURL_CONSTANT ( CURL_VERSION_SSL ) ;
# if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
REGISTER_CURL_CONSTANT ( CURLOPT_HTTPAUTH ) ;
/* http authentication options */
REGISTER_CURL_CONSTANT ( CURLAUTH_ANY ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_ANYSAFE ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_BASIC ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_DIGEST ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_GSSNEGOTIATE ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_NONE ) ;
REGISTER_CURL_CONSTANT ( CURLAUTH_NTLM ) ;
# endif
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
REGISTER_CURL_CONSTANT ( CURLINFO_HTTP_CONNECTCODE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_CREATE_MISSING_DIRS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYAUTH ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
REGISTER_CURL_CONSTANT ( CURLE_FILESIZE_EXCEEDED ) ;
REGISTER_CURL_CONSTANT ( CURLE_LDAP_INVALID_URL ) ;
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_HTTPAUTH_AVAIL ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_RESPONSE_CODE ) ;
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_PROXYAUTH_AVAIL ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_RESPONSE_TIMEOUT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_IPRESOLVE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAXFILESIZE ) ;
REGISTER_CURL_CONSTANT ( CURL_IPRESOLVE_V4 ) ;
REGISTER_CURL_CONSTANT ( CURL_IPRESOLVE_V6 ) ;
REGISTER_CURL_CONSTANT ( CURL_IPRESOLVE_WHATEVER ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
REGISTER_CURL_CONSTANT ( CURLE_FTP_SSL_FAILED ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_ALL ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_CONTROL ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_NONE ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_TRY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_SSL ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_NETRC_FILE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT ( CURLFTPAUTH_DEFAULT ) ;
REGISTER_CURL_CONSTANT ( CURLFTPAUTH_SSL ) ;
REGISTER_CURL_CONSTANT ( CURLFTPAUTH_TLS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_FTPSSLAUTH ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_ACCOUNT ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
REGISTER_CURL_CONSTANT ( CURLOPT_TCP_NODELAY ) ;
# endif
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT ( CURLINFO_OS_ERRNO ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
REGISTER_CURL_CONSTANT ( CURLINFO_NUM_CONNECTS ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_SSL_ENGINES ) ;
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_COOKIELIST ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_COOKIELIST ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_IGNORE_CONTENT_LENGTH ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_SKIP_PASV_IP ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_FILEMETHOD ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
REGISTER_CURL_CONSTANT ( CURLOPT_CONNECT_ONLY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_LOCALPORT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_LOCALPORTRANGE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */
REGISTER_CURL_CONSTANT ( CURLFTPMETHOD_MULTICWD ) ;
REGISTER_CURL_CONSTANT ( CURLFTPMETHOD_NOCWD ) ;
REGISTER_CURL_CONSTANT ( CURLFTPMETHOD_SINGLECWD ) ;
# endif
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >- 0x070f04 /* Available since 7.15.4 */
REGISTER_CURL_CONSTANT ( CURLINFO_FTP_ENTRY_PATH ) ;
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_ALTERNATIVE_TO_USER ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAX_RECV_SPEED_LARGE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAX_SEND_SPEED_LARGE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_SSL_SESSIONID_CACHE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
2012-08-24 22:04:16 +00:00
REGISTER_CURL_CONSTANT ( CURLE_SSH ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_SSL_CCC ) ;
2012-08-24 22:04:16 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_SSH_AUTH_TYPES ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSH_PRIVATE_KEYFILE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SSH_PUBLIC_KEYFILE ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLFTPSSL_CCC_ACTIVE ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_CCC_NONE ) ;
REGISTER_CURL_CONSTANT ( CURLFTPSSL_CCC_PASSIVE ) ;
# endif
2004-11-14 20:00:16 +00:00
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
REGISTER_CURL_CONSTANT ( CURLOPT_CONNECTTIMEOUT_MS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_HTTP_CONTENT_DECODING ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_HTTP_TRANSFER_DECODING ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TIMEOUT_MS ) ;
2004-11-14 20:00:16 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
REGISTER_CURL_CONSTANT ( CURLOPT_KRBLEVEL ) ;
2012-08-24 22:04:16 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_NEW_DIRECTORY_PERMS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_NEW_FILE_PERMS ) ;
2006-09-18 16:11:50 +00:00
# endif
2011-12-01 21:48:07 +00:00
2011-11-22 17:33:48 +00:00
# if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_APPEND ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_DIRLISTONLY ) ;
2011-11-22 17:33:48 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_USE_SSL ) ;
2011-12-01 21:48:07 +00:00
/* Curl SSL Constants */
REGISTER_CURL_CONSTANT ( CURLUSESSL_ALL ) ;
REGISTER_CURL_CONSTANT ( CURLUSESSL_CONTROL ) ;
2011-11-22 17:33:48 +00:00
REGISTER_CURL_CONSTANT ( CURLUSESSL_NONE ) ;
REGISTER_CURL_CONSTANT ( CURLUSESSL_TRY ) ;
# endif
2009-09-24 18:20:49 +00:00
2012-08-24 22:04:16 +00:00
# if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */
REGISTER_CURL_CONSTANT ( CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 ) ;
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_PROXY_TRANSFER_MODE ) ;
2009-09-15 15:47:06 +00:00
# endif
2006-09-18 16:11:50 +00:00
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
2011-12-23 21:01:05 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_REDIRECT_URL ) ;
2011-12-01 21:48:07 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_APPCONNECT_TIME ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_PRIMARY_IP ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_ADDRESS_SCOPE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CRLFILE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_ISSUERCERT ) ;
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_KEYPASSWD ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_ANY ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_DEFAULT ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_HOST ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_KEYBOARD ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_NONE ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_PASSWORD ) ;
REGISTER_CURL_CONSTANT ( CURLSSH_AUTH_PUBLICKEY ) ;
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
REGISTER_CURL_CONSTANT ( CURLINFO_CERTINFO ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_CERTINFO ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PASSWORD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_POSTREDIR ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYPASSWORD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_PROXYUSERNAME ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_USERNAME ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071303 /* Available since 7.19.3 */
REGISTER_CURL_CONSTANT ( CURLAUTH_DIGEST_IE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_CONDITION_UNMET ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_NOPROXY ) ;
2009-03-13 19:39:49 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_PROTOCOLS ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_REDIR_PROTOCOLS ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SOCKS5_GSSAPI_NEC ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_SOCKS5_GSSAPI_SERVICE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TFTP_BLKSIZE ) ;
2011-12-03 20:16:32 +00:00
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_ALL ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_DICT ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_FILE ) ;
2009-03-13 19:39:49 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_FTP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_FTPS ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_HTTP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_HTTPS ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_LDAP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_LDAPS ) ;
2009-03-13 19:39:49 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_SCP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_SFTP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_TELNET ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_TFTP ) ;
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
REGISTER_CURL_CONSTANT ( CURLOPT_SSH_KNOWNHOSTS ) ;
2009-07-17 00:25:54 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_RTSP_CLIENT_CSEQ ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_RTSP_CSEQ_RECV ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_RTSP_SERVER_CSEQ ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_RTSP_SESSION_ID ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FTP_USE_PRET ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAIL_FROM ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_MAIL_RCPT ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_CLIENT_CSEQ ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_REQUEST ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_SERVER_CSEQ ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_SESSION_ID ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_STREAM_URI ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RTSP_TRANSPORT ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_IMAP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_IMAPS ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_POP3 ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_POP3S ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_RTSP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_SMTP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_SMTPS ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_ANNOUNCE ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_DESCRIBE ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_GET_PARAMETER ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_OPTIONS ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_PAUSE ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_PLAY ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_RECEIVE ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_RECORD ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_SETUP ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_SET_PARAMETER ) ;
REGISTER_CURL_CONSTANT ( CURL_RTSPREQ_TEARDOWN ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
2011-12-03 20:16:32 +00:00
REGISTER_CURL_CONSTANT ( CURLINFO_LOCAL_IP ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_LOCAL_PORT ) ;
REGISTER_CURL_CONSTANT ( CURLINFO_PRIMARY_PORT ) ;
2011-12-04 00:19:12 +00:00
REGISTER_CURL_CONSTANT ( CURLOPT_FNMATCH_FUNCTION ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_WILDCARDMATCH ) ;
2011-12-01 21:48:07 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMP ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMPE ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMPS ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMPT ) ;
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMPTE ) ;
2011-12-04 00:19:12 +00:00
REGISTER_CURL_CONSTANT ( CURLPROTO_RTMPTS ) ;
REGISTER_CURL_CONSTANT ( CURL_FNMATCHFUNC_FAIL ) ;
REGISTER_CURL_CONSTANT ( CURL_FNMATCHFUNC_MATCH ) ;
REGISTER_CURL_CONSTANT ( CURL_FNMATCHFUNC_NOMATCH ) ;
2011-12-01 21:48:07 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */
REGISTER_CURL_CONSTANT ( CURLPROTO_GOPHER ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
REGISTER_CURL_CONSTANT ( CURLAUTH_ONLY ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_RESOLVE ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
REGISTER_CURL_CONSTANT ( CURLOPT_TLSAUTH_PASSWORD ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TLSAUTH_TYPE ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TLSAUTH_USERNAME ) ;
REGISTER_CURL_CONSTANT ( CURL_TLSAUTH_SRP ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
REGISTER_CURL_CONSTANT ( CURLOPT_ACCEPT_ENCODING ) ;
REGISTER_CURL_CONSTANT ( CURLOPT_TRANSFER_ENCODING ) ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_DNS_SERVERS ) ;
# endif
2012-05-27 07:21:08 +00:00
# if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
REGISTER_CURL_CONSTANT ( CURLOPT_MAIL_AUTH ) ;
# endif
2011-12-01 21:48:07 +00:00
# if CURLOPT_FTPASCII != 0
REGISTER_CURL_CONSTANT ( CURLOPT_FTPASCII ) ;
# endif
# if CURLOPT_MUTE != 0
REGISTER_CURL_CONSTANT ( CURLOPT_MUTE ) ;
# endif
# if CURLOPT_PASSWDFUNCTION != 0
REGISTER_CURL_CONSTANT ( CURLOPT_PASSWDFUNCTION ) ;
2009-05-04 14:09:28 +00:00
# endif
2006-01-26 13:23:33 +00:00
# ifdef PHP_CURL_NEED_OPENSSL_TSL
2006-12-19 21:41:25 +00:00
if ( ! CRYPTO_get_id_callback ( ) ) {
2006-01-26 13:23:33 +00:00
int i , c = CRYPTO_num_locks ( ) ;
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
php_curl_openssl_tsl = malloc ( c * sizeof ( MUTEX_T ) ) ;
2011-07-28 10:31:34 +00:00
if ( ! php_curl_openssl_tsl ) {
return FAILURE ;
}
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
for ( i = 0 ; i < c ; + + i ) {
php_curl_openssl_tsl [ i ] = tsrm_mutex_alloc ( ) ;
}
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
CRYPTO_set_id_callback ( php_curl_ssl_id ) ;
CRYPTO_set_locking_callback ( php_curl_ssl_lock ) ;
}
2005-10-25 14:32:33 +00:00
# endif
2006-01-26 13:23:33 +00:00
# ifdef PHP_CURL_NEED_GNUTLS_TSL
gcry_control ( GCRYCTL_SET_THREAD_CBS , & php_curl_gnutls_tsl ) ;
# endif
2009-05-03 15:16:10 +00:00
2002-01-27 06:11:50 +00:00
if ( curl_global_init ( CURL_GLOBAL_SSL ) ! = CURLE_OK ) {
2001-09-22 00:38:59 +00:00
return FAILURE ;
}
2002-08-12 15:56:13 +00:00
# ifdef PHP_CURL_URL_WRAPPERS
2002-11-14 11:41:24 +00:00
{
curl_version_info_data * info = curl_version_info ( CURLVERSION_NOW ) ;
char * * p = ( char * * ) info - > protocols ;
while ( * p ! = NULL ) {
2009-07-25 20:44:19 +00:00
/* Do not enable cURL "file" protocol and make sure cURL is always used when --with-curlwrappers is enabled */
if ( strncasecmp ( * p , " file " , sizeof ( " file " ) - 1 ) ! = 0 ) {
2009-07-26 23:44:59 +00:00
php_unregister_url_stream_wrapper ( * p TSRMLS_CC ) ;
2009-07-25 20:44:19 +00:00
php_register_url_stream_wrapper ( * p , & php_curl_wrapper TSRMLS_CC ) ;
}
( void ) * p + + ;
2002-11-14 11:41:24 +00:00
}
}
2002-08-12 15:56:13 +00:00
# endif
2009-05-03 15:16:10 +00:00
2001-09-22 00:38:59 +00:00
return SUCCESS ;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION ( curl )
{
2002-08-12 15:56:13 +00:00
# ifdef PHP_CURL_URL_WRAPPERS
2011-12-14 04:02:56 +00:00
{
curl_version_info_data * info = curl_version_info ( CURLVERSION_NOW ) ;
char * * p = ( char * * ) info - > protocols ;
while ( * p ! = NULL ) {
/* Do not enable cURL "file" protocol and make sure cURL is always used when --with-curlwrappers is enabled */
if ( strncasecmp ( * p , " file " , sizeof ( " file " ) - 1 ) ! = 0 ) {
php_unregister_url_stream_wrapper ( * p TSRMLS_CC ) ;
}
( void ) * p + + ;
}
}
2002-08-12 15:56:13 +00:00
# endif
2001-09-22 00:38:59 +00:00
curl_global_cleanup ( ) ;
2006-01-26 13:23:33 +00:00
# ifdef PHP_CURL_NEED_OPENSSL_TSL
if ( php_curl_openssl_tsl ) {
int i , c = CRYPTO_num_locks ( ) ;
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
CRYPTO_set_id_callback ( NULL ) ;
CRYPTO_set_locking_callback ( NULL ) ;
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
for ( i = 0 ; i < c ; + + i ) {
tsrm_mutex_free ( php_curl_openssl_tsl [ i ] ) ;
}
2009-05-03 15:16:10 +00:00
2006-01-26 13:23:33 +00:00
free ( php_curl_openssl_tsl ) ;
php_curl_openssl_tsl = NULL ;
}
2005-10-25 14:32:33 +00:00
# endif
2011-04-01 17:10:52 +00:00
UNREGISTER_INI_ENTRIES ( ) ;
2000-10-22 17:29:33 +00:00
return SUCCESS ;
2000-08-15 16:50:14 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-08-15 16:50:14 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ curl_write
*/
2001-10-18 19:24:51 +00:00
static size_t curl_write ( char * data , size_t size , size_t nmemb , void * ctx )
2001-04-30 14:36:19 +00:00
{
php_curl * ch = ( php_curl * ) ctx ;
2001-05-04 04:20:38 +00:00
php_curl_write * t = ch - > handlers - > write ;
2001-04-30 14:36:19 +00:00
size_t length = size * nmemb ;
2003-04-27 22:15:19 +00:00
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
2001-04-30 14:36:19 +00:00
2002-11-13 22:25:33 +00:00
# if PHP_CURL_DEBUG
fprintf ( stderr , " curl_write() called \n " ) ;
2003-03-17 15:06:11 +00:00
fprintf ( stderr , " data = %s, size = %d, nmemb = %d, ctx = %x \n " , data , size , nmemb , ctx ) ;
2002-11-13 22:25:33 +00:00
# endif
2009-05-03 15:16:10 +00:00
2001-04-30 14:36:19 +00:00
switch ( t - > method ) {
2003-03-17 15:06:11 +00:00
case PHP_CURL_STDOUT :
2003-05-17 14:12:36 +00:00
PHPWRITE ( data , length ) ;
2003-03-17 15:06:11 +00:00
break ;
case PHP_CURL_FILE :
return fwrite ( data , size , nmemb , t - > fp ) ;
case PHP_CURL_RETURN :
2007-02-23 20:51:02 +00:00
if ( length > 0 ) {
smart_str_appendl ( & t - > buf , data , ( int ) length ) ;
}
2003-03-17 15:06:11 +00:00
break ;
case PHP_CURL_USER : {
2003-05-21 23:15:28 +00:00
zval * * argv [ 2 ] ;
zval * retval_ptr = NULL ;
zval * handle = NULL ;
zval * zdata = NULL ;
2003-03-17 15:06:11 +00:00
int error ;
2003-08-05 10:29:03 +00:00
zend_fcall_info fci ;
2001-04-30 14:36:19 +00:00
2003-05-21 23:15:28 +00:00
MAKE_STD_ZVAL ( handle ) ;
ZVAL_RESOURCE ( handle , ch - > id ) ;
2003-03-17 15:06:11 +00:00
zend_list_addref ( ch - > id ) ;
2003-05-21 23:15:28 +00:00
argv [ 0 ] = & handle ;
2009-05-03 15:16:10 +00:00
2003-05-21 23:15:28 +00:00
MAKE_STD_ZVAL ( zdata ) ;
ZVAL_STRINGL ( zdata , data , length , 1 ) ;
argv [ 1 ] = & zdata ;
2003-03-17 15:06:11 +00:00
2003-08-05 10:29:03 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
2008-11-27 19:01:23 +00:00
fci . object_ptr = NULL ;
2003-08-05 10:29:03 +00:00
fci . function_name = t - > func_name ;
fci . retval_ptr_ptr = & retval_ptr ;
fci . param_count = 2 ;
fci . params = argv ;
fci . no_separation = 0 ;
fci . symbol_table = NULL ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 1 ;
2003-08-05 10:29:03 +00:00
error = zend_call_function ( & fci , & t - > fci_cache TSRMLS_CC ) ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 0 ;
2003-03-17 15:06:11 +00:00
if ( error = = FAILURE ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not call the CURLOPT_WRITEFUNCTION " ) ;
length = - 1 ;
2005-06-02 21:04:12 +00:00
} else if ( retval_ptr ) {
2004-03-12 17:31:10 +00:00
if ( Z_TYPE_P ( retval_ptr ) ! = IS_LONG ) {
convert_to_long_ex ( & retval_ptr ) ;
}
2003-05-21 23:15:28 +00:00
length = Z_LVAL_P ( retval_ptr ) ;
2005-06-02 21:04:12 +00:00
zval_ptr_dtor ( & retval_ptr ) ;
2003-03-17 15:06:11 +00:00
}
2003-05-21 23:15:28 +00:00
zval_ptr_dtor ( argv [ 0 ] ) ;
zval_ptr_dtor ( argv [ 1 ] ) ;
2003-03-17 15:06:11 +00:00
break ;
}
2001-04-30 14:36:19 +00:00
}
return length ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-04-30 14:36:19 +00:00
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
/* {{{ curl_fnmatch
*/
static int curl_fnmatch ( void * ctx , const char * pattern , const char * string )
{
php_curl * ch = ( php_curl * ) ctx ;
php_curl_fnmatch * t = ch - > handlers - > fnmatch ;
int rval = CURL_FNMATCHFUNC_FAIL ;
switch ( t - > method ) {
case PHP_CURL_USER : {
zval * * argv [ 3 ] ;
zval * zhandle = NULL ;
zval * zpattern = NULL ;
zval * zstring = NULL ;
zval * retval_ptr ;
int error ;
zend_fcall_info fci ;
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
MAKE_STD_ZVAL ( zhandle ) ;
MAKE_STD_ZVAL ( zpattern ) ;
MAKE_STD_ZVAL ( zstring ) ;
ZVAL_RESOURCE ( zhandle , ch - > id ) ;
zend_list_addref ( ch - > id ) ;
ZVAL_STRING ( zpattern , pattern , 1 ) ;
ZVAL_STRING ( zstring , string , 1 ) ;
argv [ 0 ] = & zhandle ;
argv [ 1 ] = & zpattern ;
argv [ 2 ] = & zstring ;
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
fci . function_name = t - > func_name ;
fci . object_ptr = NULL ;
fci . retval_ptr_ptr = & retval_ptr ;
fci . param_count = 3 ;
fci . params = argv ;
fci . no_separation = 0 ;
fci . symbol_table = NULL ;
ch - > in_callback = 1 ;
error = zend_call_function ( & fci , & t - > fci_cache TSRMLS_CC ) ;
ch - > in_callback = 0 ;
if ( error = = FAILURE ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Cannot call the CURLOPT_FNMATCH_FUNCTION " ) ;
} else if ( retval_ptr ) {
if ( Z_TYPE_P ( retval_ptr ) ! = IS_LONG ) {
convert_to_long_ex ( & retval_ptr ) ;
}
rval = Z_LVAL_P ( retval_ptr ) ;
zval_ptr_dtor ( & retval_ptr ) ;
}
zval_ptr_dtor ( argv [ 0 ] ) ;
zval_ptr_dtor ( argv [ 1 ] ) ;
zval_ptr_dtor ( argv [ 2 ] ) ;
break ;
}
}
return rval ;
}
/* }}} */
# endif
2009-05-03 14:59:46 +00:00
/* {{{ curl_progress
*/
2009-05-18 12:51:05 +00:00
static size_t curl_progress ( void * clientp , double dltotal , double dlnow , double ultotal , double ulnow )
2009-05-03 14:59:46 +00:00
{
php_curl * ch = ( php_curl * ) clientp ;
php_curl_progress * t = ch - > handlers - > progress ;
size_t rval = 0 ;
# if PHP_CURL_DEBUG
fprintf ( stderr , " curl_progress() called \n " ) ;
fprintf ( stderr , " clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f \n " , clientp , dltotal , dlnow , ultotal , ulnow ) ;
# endif
switch ( t - > method ) {
case PHP_CURL_USER : {
2011-12-03 23:53:27 +00:00
zval * * argv [ 5 ] ;
zval * handle = NULL ;
2009-05-03 14:59:46 +00:00
zval * zdltotal = NULL ;
zval * zdlnow = NULL ;
zval * zultotal = NULL ;
zval * zulnow = NULL ;
zval * retval_ptr ;
int error ;
zend_fcall_info fci ;
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
2011-12-03 23:53:27 +00:00
MAKE_STD_ZVAL ( handle ) ;
2009-05-03 14:59:46 +00:00
MAKE_STD_ZVAL ( zdltotal ) ;
MAKE_STD_ZVAL ( zdlnow ) ;
MAKE_STD_ZVAL ( zultotal ) ;
MAKE_STD_ZVAL ( zulnow ) ;
2009-05-03 15:16:10 +00:00
2011-12-03 23:53:27 +00:00
ZVAL_RESOURCE ( handle , ch - > id ) ;
zend_list_addref ( ch - > id ) ;
2009-05-19 18:08:57 +00:00
ZVAL_LONG ( zdltotal , ( long ) dltotal ) ;
ZVAL_LONG ( zdlnow , ( long ) dlnow ) ;
ZVAL_LONG ( zultotal , ( long ) ultotal ) ;
ZVAL_LONG ( zulnow , ( long ) ulnow ) ;
2009-05-03 14:59:46 +00:00
2011-12-03 23:53:27 +00:00
argv [ 0 ] = & handle ;
argv [ 1 ] = & zdltotal ;
argv [ 2 ] = & zdlnow ;
argv [ 3 ] = & zultotal ;
argv [ 4 ] = & zulnow ;
2009-05-03 14:59:46 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
fci . function_name = t - > func_name ;
fci . object_ptr = NULL ;
fci . retval_ptr_ptr = & retval_ptr ;
2011-12-03 23:53:27 +00:00
fci . param_count = 5 ;
2009-05-03 14:59:46 +00:00
fci . params = argv ;
fci . no_separation = 0 ;
fci . symbol_table = NULL ;
ch - > in_callback = 1 ;
error = zend_call_function ( & fci , & t - > fci_cache TSRMLS_CC ) ;
ch - > in_callback = 0 ;
if ( error = = FAILURE ) {
2009-05-03 15:16:10 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Cannot call the CURLOPT_PROGRESSFUNCTION " ) ;
2009-05-03 14:59:46 +00:00
} else if ( retval_ptr ) {
if ( Z_TYPE_P ( retval_ptr ) ! = IS_LONG ) {
convert_to_long_ex ( & retval_ptr ) ;
}
2009-05-18 12:51:05 +00:00
if ( 0 ! = Z_LVAL_P ( retval_ptr ) ) {
2009-05-03 14:59:46 +00:00
rval = 1 ;
2009-05-18 12:51:05 +00:00
}
2009-05-03 14:59:46 +00:00
zval_ptr_dtor ( & retval_ptr ) ;
}
zval_ptr_dtor ( argv [ 0 ] ) ;
zval_ptr_dtor ( argv [ 1 ] ) ;
zval_ptr_dtor ( argv [ 2 ] ) ;
zval_ptr_dtor ( argv [ 3 ] ) ;
2011-12-03 23:53:27 +00:00
zval_ptr_dtor ( argv [ 4 ] ) ;
2009-05-03 14:59:46 +00:00
break ;
}
}
return rval ;
}
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ curl_read
*/
2001-05-04 04:20:38 +00:00
static size_t curl_read ( char * data , size_t size , size_t nmemb , void * ctx )
2001-04-30 14:36:19 +00:00
{
php_curl * ch = ( php_curl * ) ctx ;
2001-05-04 04:20:38 +00:00
php_curl_read * t = ch - > handlers - > read ;
2008-07-12 21:16:50 +00:00
int length = 0 ;
2001-04-30 14:36:19 +00:00
switch ( t - > method ) {
2003-03-17 15:06:11 +00:00
case PHP_CURL_DIRECT :
if ( t - > fp ) {
length = fread ( data , size , nmemb , t - > fp ) ;
}
break ;
case PHP_CURL_USER : {
2003-05-21 23:27:12 +00:00
zval * * argv [ 3 ] ;
zval * handle = NULL ;
zval * zfd = NULL ;
zval * zlength = NULL ;
zval * retval_ptr ;
2003-03-17 15:06:11 +00:00
int error ;
2003-08-05 10:29:03 +00:00
zend_fcall_info fci ;
2003-04-27 22:15:19 +00:00
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
2001-04-30 14:36:19 +00:00
2003-05-21 23:27:12 +00:00
MAKE_STD_ZVAL ( handle ) ;
MAKE_STD_ZVAL ( zfd ) ;
MAKE_STD_ZVAL ( zlength ) ;
2003-03-17 15:06:11 +00:00
2003-05-21 23:27:12 +00:00
ZVAL_RESOURCE ( handle , ch - > id ) ;
2003-03-17 15:06:11 +00:00
zend_list_addref ( ch - > id ) ;
2003-05-21 23:27:12 +00:00
ZVAL_RESOURCE ( zfd , t - > fd ) ;
2003-03-17 15:06:11 +00:00
zend_list_addref ( t - > fd ) ;
2003-05-21 23:27:12 +00:00
ZVAL_LONG ( zlength , ( int ) size * nmemb ) ;
2003-03-17 15:06:11 +00:00
2003-05-21 23:27:12 +00:00
argv [ 0 ] = & handle ;
argv [ 1 ] = & zfd ;
argv [ 2 ] = & zlength ;
2003-08-05 10:29:03 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
fci . function_name = t - > func_name ;
2008-11-27 19:01:23 +00:00
fci . object_ptr = NULL ;
2003-08-05 10:29:03 +00:00
fci . retval_ptr_ptr = & retval_ptr ;
fci . param_count = 3 ;
fci . params = argv ;
fci . no_separation = 0 ;
fci . symbol_table = NULL ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 1 ;
2003-08-05 10:29:03 +00:00
error = zend_call_function ( & fci , & t - > fci_cache TSRMLS_CC ) ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 0 ;
2003-03-17 15:06:11 +00:00
if ( error = = FAILURE ) {
2009-05-03 15:16:10 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Cannot call the CURLOPT_READFUNCTION " ) ;
2008-07-12 21:16:50 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
length = CURL_READFUNC_ABORT ;
# endif
2005-06-02 21:04:12 +00:00
} else if ( retval_ptr ) {
2004-03-12 16:36:30 +00:00
if ( Z_TYPE_P ( retval_ptr ) = = IS_STRING ) {
2009-05-19 18:08:57 +00:00
length = MIN ( ( int ) ( size * nmemb ) , Z_STRLEN_P ( retval_ptr ) ) ;
2004-03-12 17:31:10 +00:00
memcpy ( data , Z_STRVAL_P ( retval_ptr ) , length ) ;
2004-03-12 16:08:11 +00:00
}
2005-06-02 21:04:12 +00:00
zval_ptr_dtor ( & retval_ptr ) ;
2003-03-17 15:06:11 +00:00
}
2003-05-21 23:27:12 +00:00
zval_ptr_dtor ( argv [ 0 ] ) ;
zval_ptr_dtor ( argv [ 1 ] ) ;
zval_ptr_dtor ( argv [ 2 ] ) ;
2003-03-17 15:06:11 +00:00
break ;
}
2001-04-30 14:36:19 +00:00
}
return length ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-04-30 14:36:19 +00:00
2001-06-25 15:14:20 +00:00
/* {{{ curl_write_header
2001-06-05 13:12:10 +00:00
*/
2001-10-18 19:24:51 +00:00
static size_t curl_write_header ( char * data , size_t size , size_t nmemb , void * ctx )
2001-04-30 14:36:19 +00:00
{
2001-06-25 15:14:20 +00:00
php_curl * ch = ( php_curl * ) ctx ;
php_curl_write * t = ch - > handlers - > write_header ;
2002-03-24 10:40:21 +00:00
size_t length = size * nmemb ;
2003-04-27 22:15:19 +00:00
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
2009-05-03 15:16:10 +00:00
2001-06-25 15:14:20 +00:00
switch ( t - > method ) {
2002-07-03 12:02:17 +00:00
case PHP_CURL_STDOUT :
/* Handle special case write when we're returning the entire transfer
*/
2007-02-23 20:51:02 +00:00
if ( ch - > handlers - > write - > method = = PHP_CURL_RETURN & & length > 0 ) {
2002-07-03 12:02:17 +00:00
smart_str_appendl ( & ch - > handlers - > write - > buf , data , ( int ) length ) ;
2003-03-17 15:06:11 +00:00
} else {
2003-05-17 14:12:36 +00:00
PHPWRITE ( data , length ) ;
2003-03-17 15:06:11 +00:00
}
2002-07-03 12:02:17 +00:00
break ;
case PHP_CURL_FILE :
return fwrite ( data , size , nmemb , t - > fp ) ;
case PHP_CURL_USER : {
2003-05-21 23:27:12 +00:00
zval * * argv [ 2 ] ;
zval * handle = NULL ;
zval * zdata = NULL ;
zval * retval_ptr ;
2002-07-03 12:02:17 +00:00
int error ;
2003-08-05 10:29:03 +00:00
zend_fcall_info fci ;
2002-07-03 12:02:17 +00:00
2003-05-21 23:27:12 +00:00
MAKE_STD_ZVAL ( handle ) ;
MAKE_STD_ZVAL ( zdata ) ;
2002-07-03 12:02:17 +00:00
2003-05-21 23:27:12 +00:00
ZVAL_RESOURCE ( handle , ch - > id ) ;
2002-07-03 12:02:17 +00:00
zend_list_addref ( ch - > id ) ;
2003-05-21 23:27:12 +00:00
ZVAL_STRINGL ( zdata , data , length , 1 ) ;
2002-07-03 12:02:17 +00:00
2003-05-21 23:27:12 +00:00
argv [ 0 ] = & handle ;
argv [ 1 ] = & zdata ;
2003-08-05 10:29:03 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
fci . function_name = t - > func_name ;
fci . symbol_table = NULL ;
2008-11-27 19:01:23 +00:00
fci . object_ptr = NULL ;
2003-08-05 10:29:03 +00:00
fci . retval_ptr_ptr = & retval_ptr ;
fci . param_count = 2 ;
fci . params = argv ;
fci . no_separation = 0 ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 1 ;
2003-08-05 23:50:59 +00:00
error = zend_call_function ( & fci , & t - > fci_cache TSRMLS_CC ) ;
2005-06-02 21:04:12 +00:00
ch - > in_callback = 0 ;
2002-07-03 12:02:17 +00:00
if ( error = = FAILURE ) {
2003-03-17 15:06:11 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not call the CURLOPT_HEADERFUNCTION " ) ;
2002-07-03 12:02:17 +00:00
length = - 1 ;
2005-06-02 21:04:12 +00:00
} else if ( retval_ptr ) {
2004-03-12 17:31:10 +00:00
if ( Z_TYPE_P ( retval_ptr ) ! = IS_LONG ) {
convert_to_long_ex ( & retval_ptr ) ;
}
2003-05-21 23:27:12 +00:00
length = Z_LVAL_P ( retval_ptr ) ;
2005-06-02 21:04:12 +00:00
zval_ptr_dtor ( & retval_ptr ) ;
2002-07-03 12:02:17 +00:00
}
2003-05-21 23:27:12 +00:00
zval_ptr_dtor ( argv [ 0 ] ) ;
zval_ptr_dtor ( argv [ 1 ] ) ;
2002-07-03 12:02:17 +00:00
break ;
2001-06-25 15:14:20 +00:00
}
2004-03-12 17:31:10 +00:00
2002-07-03 12:02:17 +00:00
case PHP_CURL_IGNORE :
return length ;
2004-03-12 17:31:10 +00:00
default :
return - 1 ;
2001-04-30 14:36:19 +00:00
}
2003-03-17 15:06:11 +00:00
2001-04-30 14:36:19 +00:00
return length ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-04-30 14:36:19 +00:00
2007-12-04 08:56:07 +00:00
static int curl_debug ( CURL * cp , curl_infotype type , char * buf , size_t buf_len , void * ctx ) /* { { { */
2006-01-24 20:11:14 +00:00
{
php_curl * ch = ( php_curl * ) ctx ;
if ( type = = CURLINFO_HEADER_OUT ) {
if ( ch - > header . str_len ) {
2009-05-03 15:16:10 +00:00
efree ( ch - > header . str ) ;
2006-01-24 20:11:14 +00:00
}
if ( buf_len > 0 ) {
ch - > header . str = estrndup ( buf , buf_len ) ;
ch - > header . str_len = buf_len ;
}
}
return 0 ;
}
2007-12-04 08:56:07 +00:00
/* }}} */
2006-01-24 20:11:14 +00:00
2004-03-22 18:42:03 +00:00
# if CURLOPT_PASSWDFUNCTION != 0
2001-06-25 15:14:20 +00:00
/* {{{ curl_passwd
2001-06-05 13:12:10 +00:00
*/
2001-06-25 15:14:20 +00:00
static size_t curl_passwd ( void * ctx , char * prompt , char * buf , int buflen )
2001-04-30 14:36:19 +00:00
{
php_curl * ch = ( php_curl * ) ctx ;
zval * func = ch - > handlers - > passwd ;
zval * argv [ 3 ] ;
2001-10-18 17:46:57 +00:00
zval * retval = NULL ;
2001-04-30 14:36:19 +00:00
int error ;
2004-03-12 17:31:10 +00:00
int ret = - 1 ;
2003-04-27 22:15:19 +00:00
TSRMLS_FETCH_FROM_CTX ( ch - > thread_ctx ) ;
2001-04-30 14:36:19 +00:00
MAKE_STD_ZVAL ( argv [ 0 ] ) ;
MAKE_STD_ZVAL ( argv [ 1 ] ) ;
MAKE_STD_ZVAL ( argv [ 2 ] ) ;
ZVAL_RESOURCE ( argv [ 0 ] , ch - > id ) ;
zend_list_addref ( ch - > id ) ;
ZVAL_STRING ( argv [ 1 ] , prompt , 1 ) ;
ZVAL_LONG ( argv [ 2 ] , buflen ) ;
2003-03-17 15:06:11 +00:00
error = call_user_function ( EG ( function_table ) , NULL , func , retval , 2 , argv TSRMLS_CC ) ;
2001-04-30 14:36:19 +00:00
if ( error = = FAILURE ) {
2003-03-17 15:06:11 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not call the CURLOPT_PASSWDFUNCTION " ) ;
2004-03-12 17:37:04 +00:00
} else if ( Z_TYPE_P ( retval ) = = IS_STRING ) {
if ( Z_STRLEN_P ( retval ) > buflen ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Returned password is too long for libcurl to handle " ) ;
2003-03-17 15:06:11 +00:00
} else {
2004-03-12 17:37:04 +00:00
strlcpy ( buf , Z_STRVAL_P ( retval ) , Z_STRLEN_P ( retval ) ) ;
2001-06-25 15:14:20 +00:00
}
2004-03-12 17:37:04 +00:00
} else {
2007-10-13 11:34:43 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " User handler '%s' did not return a string " , Z_STRVAL_P ( func ) ) ;
2001-04-30 14:36:19 +00:00
}
2009-05-03 15:16:10 +00:00
2001-04-30 14:36:19 +00:00
zval_ptr_dtor ( & argv [ 0 ] ) ;
zval_ptr_dtor ( & argv [ 1 ] ) ;
zval_ptr_dtor ( & argv [ 2 ] ) ;
zval_ptr_dtor ( & retval ) ;
2001-06-25 15:14:20 +00:00
return ret ;
2001-04-30 14:36:19 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2004-03-22 18:42:03 +00:00
# endif
2001-04-30 14:36:19 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ curl_free_string
*/
2001-04-30 14:36:19 +00:00
static void curl_free_string ( void * * string )
{
2000-11-23 16:31:58 +00:00
efree ( * string ) ;
2009-05-03 15:16:10 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2000-08-15 16:50:14 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ curl_free_post
*/
2001-04-30 14:36:19 +00:00
static void curl_free_post ( void * * post )
{
curl_formfree ( ( struct HttpPost * ) * post ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-04-30 14:36:19 +00:00
2001-06-05 13:12:10 +00:00
/* {{{ curl_free_slist
*/
2001-04-30 14:36:19 +00:00
static void curl_free_slist ( void * * slist )
{
curl_slist_free_all ( ( struct curl_slist * ) * slist ) ;
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-04-30 14:36:19 +00:00
2002-11-13 22:25:33 +00:00
/* {{{ proto array curl_version([int version])
2002-11-08 17:58:43 +00:00
Return cURL version information . */
2000-10-20 04:57:14 +00:00
PHP_FUNCTION ( curl_version )
2000-07-25 22:15:26 +00:00
{
2002-11-13 22:25:33 +00:00
curl_version_info_data * d ;
2009-05-18 11:48:31 +00:00
long uversion = CURLVERSION_NOW ;
2002-11-13 22:25:33 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " |l " , & uversion ) = = FAILURE ) {
return ;
}
d = curl_version_info ( uversion ) ;
if ( d = = NULL ) {
RETURN_FALSE ;
2001-08-13 07:55:39 +00:00
}
2001-08-13 06:43:47 +00:00
2002-11-13 22:25:33 +00:00
array_init ( return_value ) ;
CAAL ( " version_number " , d - > version_num ) ;
CAAL ( " age " , d - > age ) ;
CAAL ( " features " , d - > features ) ;
CAAL ( " ssl_version_number " , d - > ssl_version_num ) ;
CAAS ( " version " , d - > version ) ;
CAAS ( " host " , d - > host ) ;
CAAS ( " ssl_version " , d - > ssl_version ) ;
CAAS ( " libz_version " , d - > libz_version ) ;
/* Add an array of protocols */
{
char * * p = ( char * * ) d - > protocols ;
zval * protocol_list = NULL ;
MAKE_STD_ZVAL ( protocol_list ) ;
array_init ( protocol_list ) ;
while ( * p ! = NULL ) {
2009-05-20 09:26:12 +00:00
add_next_index_string ( protocol_list , * p , 1 ) ;
p + + ;
2002-11-13 22:25:33 +00:00
}
CAAZ ( " protocols " , protocol_list ) ;
}
2000-07-25 22:15:26 +00:00
}
/* }}} */
2001-06-05 13:12:10 +00:00
/* {{{ alloc_curl_handle
*/
2001-05-14 21:02:31 +00:00
static void alloc_curl_handle ( php_curl * * ch )
2001-05-06 22:24:25 +00:00
{
2003-03-17 15:06:11 +00:00
* ch = emalloc ( sizeof ( php_curl ) ) ;
2011-11-22 05:19:37 +00:00
( * ch ) - > to_free = ecalloc ( 1 , sizeof ( struct _php_curl_free ) ) ;
2003-03-17 15:06:11 +00:00
( * ch ) - > handlers = ecalloc ( 1 , sizeof ( php_curl_handlers ) ) ;
( * ch ) - > handlers - > write = ecalloc ( 1 , sizeof ( php_curl_write ) ) ;
2001-06-25 15:14:20 +00:00
( * ch ) - > handlers - > write_header = ecalloc ( 1 , sizeof ( php_curl_write ) ) ;
2003-03-17 15:06:11 +00:00
( * ch ) - > handlers - > read = ecalloc ( 1 , sizeof ( php_curl_read ) ) ;
2011-12-03 23:43:44 +00:00
( * ch ) - > handlers - > progress = NULL ;
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
( * ch ) - > handlers - > fnmatch = NULL ;
# endif
2003-03-17 15:06:11 +00:00
2005-06-02 21:04:12 +00:00
( * ch ) - > in_callback = 0 ;
2006-01-24 20:11:14 +00:00
( * ch ) - > header . str_len = 0 ;
2009-05-03 15:16:10 +00:00
2001-07-02 12:08:21 +00:00
memset ( & ( * ch ) - > err , 0 , sizeof ( ( * ch ) - > err ) ) ;
2011-11-21 02:29:24 +00:00
( * ch ) - > handlers - > write - > stream = NULL ;
( * ch ) - > handlers - > write_header - > stream = NULL ;
( * ch ) - > handlers - > read - > stream = NULL ;
2009-05-03 15:16:10 +00:00
2011-11-22 05:19:37 +00:00
zend_llist_init ( & ( * ch ) - > to_free - > str , sizeof ( char * ) , ( llist_dtor_func_t ) curl_free_string , 0 ) ;
zend_llist_init ( & ( * ch ) - > to_free - > slist , sizeof ( struct curl_slist ) , ( llist_dtor_func_t ) curl_free_slist , 0 ) ;
zend_llist_init ( & ( * ch ) - > to_free - > post , sizeof ( struct HttpPost ) , ( llist_dtor_func_t ) curl_free_post , 0 ) ;
2001-05-06 22:24:25 +00:00
}
2001-06-05 13:12:10 +00:00
/* }}} */
2001-05-06 22:24:25 +00:00
2012-08-26 13:03:45 +00:00
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
2009-09-15 15:47:06 +00:00
/* {{{ split_certinfo
*/
static void split_certinfo ( char * string , zval * hash )
{
char * org = estrdup ( string ) ;
char * s = org ;
char * split ;
if ( org ) {
2011-12-23 21:01:05 +00:00
do {
2009-09-15 15:47:06 +00:00
char * key ;
char * val ;
char * tmp ;
2011-12-23 21:01:05 +00:00
split = strstr ( s , " ; " ) ;
if ( split )
* split = ' \0 ' ;
2009-09-15 15:47:06 +00:00
key = s ;
tmp = memchr ( key , ' = ' , 64 ) ;
if ( tmp ) {
* tmp = ' \0 ' ;
val = tmp + 1 ;
add_assoc_string ( hash , key , val , 1 ) ;
}
s = split + 2 ;
} while ( split ) ;
efree ( org ) ;
}
}
2011-09-12 09:16:04 +00:00
/* }}} */
2009-09-15 15:47:06 +00:00
/* {{{ create_certinfo
*/
2009-09-16 18:01:10 +00:00
static void create_certinfo ( struct curl_certinfo * ci , zval * listcode TSRMLS_DC )
2009-09-15 15:47:06 +00:00
{
int i ;
if ( ci ) {
zval * certhash = NULL ;
for ( i = 0 ; i < ci - > num_of_certs ; i + + ) {
struct curl_slist * slist ;
MAKE_STD_ZVAL ( certhash ) ;
array_init ( certhash ) ;
for ( slist = ci - > certinfo [ i ] ; slist ; slist = slist - > next ) {
int len ;
char s [ 64 ] ;
char * tmp ;
strncpy ( s , slist - > data , 64 ) ;
tmp = memchr ( s , ' : ' , 64 ) ;
if ( tmp ) {
* tmp = ' \0 ' ;
len = strlen ( s ) ;
if ( ! strcmp ( s , " Subject " ) | | ! strcmp ( s , " Issuer " ) ) {
zval * hash ;
MAKE_STD_ZVAL ( hash ) ;
array_init ( hash ) ;
split_certinfo ( & slist - > data [ len + 1 ] , hash ) ;
add_assoc_zval ( certhash , s , hash ) ;
} else {
add_assoc_string ( certhash , s , & slist - > data [ len + 1 ] , 1 ) ;
}
} else {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not extract hash key from certificate info " ) ;
}
}
add_next_index_zval ( listcode , certhash ) ;
}
}
}
/* }}} */
# endif
2011-12-01 21:48:07 +00:00
/* {{{ _php_curl_set_default_options()
Set default options for a handle */
static void _php_curl_set_default_options ( php_curl * ch )
{
char * cainfo ;
curl_easy_setopt ( ch - > cp , CURLOPT_NOPROGRESS , 1 ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_VERBOSE , 0 ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_ERRORBUFFER , ch - > err . str ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_WRITEFUNCTION , curl_write ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_FILE , ( void * ) ch ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_READFUNCTION , curl_read ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_INFILE , ( void * ) ch ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_HEADERFUNCTION , curl_write_header ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_WRITEHEADER , ( void * ) ch ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_DNS_USE_GLOBAL_CACHE , 1 ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_DNS_CACHE_TIMEOUT , 120 ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_MAXREDIRS , 20 ) ; /* prevent infinite redirects */
cainfo = INI_STR ( " curl.cainfo " ) ;
if ( cainfo & & strlen ( cainfo ) > 0 ) {
curl_easy_setopt ( ch - > cp , CURLOPT_CAINFO , cainfo ) ;
}
# if defined(ZTS)
curl_easy_setopt ( ch - > cp , CURLOPT_NOSIGNAL , 1 ) ;
# endif
}
/* }}} */
2002-03-23 01:43:38 +00:00
/* {{{ proto resource curl_init([string url])
2006-09-09 20:04:50 +00:00
Initialize a cURL session */
2000-08-13 19:32:09 +00:00
PHP_FUNCTION ( curl_init )
2000-07-16 19:37:33 +00:00
{
2009-05-18 12:51:05 +00:00
php_curl * ch ;
CURL * cp ;
2009-07-21 20:32:32 +00:00
zval * clone ;
2009-05-18 12:51:05 +00:00
char * url = NULL ;
int url_len = 0 ;
2001-04-30 14:36:19 +00:00
2008-02-07 02:08:45 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " |s " , & url , & url_len ) = = FAILURE ) {
return ;
2000-07-16 19:37:33 +00:00
}
2000-11-22 15:46:13 +00:00
2004-03-12 18:41:19 +00:00
cp = curl_easy_init ( ) ;
if ( ! cp ) {
2003-03-17 15:06:11 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not initialize a new cURL handle " ) ;
2000-07-16 19:37:33 +00:00
RETURN_FALSE ;
}
2004-03-12 18:41:19 +00:00
alloc_curl_handle ( & ch ) ;
TSRMLS_SET_CTX ( ch - > thread_ctx ) ;
ch - > cp = cp ;
2009-05-03 15:16:10 +00:00
2001-05-04 04:20:38 +00:00
ch - > handlers - > write - > method = PHP_CURL_STDOUT ;
ch - > handlers - > read - > method = PHP_CURL_DIRECT ;
2001-07-18 10:47:54 +00:00
ch - > handlers - > write_header - > method = PHP_CURL_IGNORE ;
2001-04-30 14:36:19 +00:00
2003-05-09 01:10:18 +00:00
ch - > uses = 0 ;
2009-07-21 20:32:32 +00:00
MAKE_STD_ZVAL ( clone ) ;
ch - > clone = clone ;
2011-12-01 21:48:07 +00:00
_php_curl_set_default_options ( ch ) ;
2002-07-31 22:10:58 +00:00
2008-02-07 02:08:45 +00:00
if ( url ) {
2010-04-13 11:02:15 +00:00
if ( ! php_curl_option_url ( ch , url , url_len TSRMLS_CC ) ) {
2009-05-18 10:31:08 +00:00
_php_curl_close_ex ( ch TSRMLS_CC ) ;
RETURN_FALSE ;
}
2000-07-16 19:37:33 +00:00
}
2000-09-30 03:09:54 +00:00
2001-04-30 14:36:19 +00:00
ZEND_REGISTER_RESOURCE ( return_value , ch , le_curl ) ;
ch - > id = Z_LVAL_P ( return_value ) ;
2000-07-16 19:37:33 +00:00
}
/* }}} */
2004-03-12 18:37:55 +00:00
/* {{{ proto resource curl_copy_handle(resource ch)
Copy a cURL handle along with all of it ' s preferences */
PHP_FUNCTION ( curl_copy_handle )
{
2009-05-18 12:51:05 +00:00
CURL * cp ;
zval * zid ;
php_curl * ch , * dupch ;
2004-03-12 18:37:55 +00:00
2008-06-21 21:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
2004-03-12 18:37:55 +00:00
}
2009-05-18 12:51:05 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2004-03-12 18:37:55 +00:00
cp = curl_easy_duphandle ( ch - > cp ) ;
if ( ! cp ) {
2005-04-21 21:11:23 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Cannot duplicate cURL handle " ) ;
2004-03-12 18:37:55 +00:00
RETURN_FALSE ;
}
alloc_curl_handle ( & dupch ) ;
2006-08-29 17:10:40 +00:00
TSRMLS_SET_CTX ( dupch - > thread_ctx ) ;
2004-03-12 18:37:55 +00:00
dupch - > cp = cp ;
2008-12-09 17:17:27 +00:00
dupch - > uses = 0 ;
2011-09-12 09:16:04 +00:00
ch - > uses + + ;
2009-09-30 02:34:17 +00:00
if ( ch - > handlers - > write - > stream ) {
2012-08-16 18:48:44 +00:00
Z_ADDREF_P ( ch - > handlers - > write - > stream ) ;
2009-09-30 02:34:17 +00:00
}
2012-08-16 18:48:44 +00:00
dupch - > handlers - > write - > stream = ch - > handlers - > write - > stream ;
2004-03-12 18:37:55 +00:00
dupch - > handlers - > write - > method = ch - > handlers - > write - > method ;
2009-09-30 02:34:17 +00:00
if ( ch - > handlers - > read - > stream ) {
Z_ADDREF_P ( ch - > handlers - > read - > stream ) ;
}
dupch - > handlers - > read - > stream = ch - > handlers - > read - > stream ;
2004-03-12 18:37:55 +00:00
dupch - > handlers - > read - > method = ch - > handlers - > read - > method ;
dupch - > handlers - > write_header - > method = ch - > handlers - > write_header - > method ;
2009-09-30 02:34:17 +00:00
if ( ch - > handlers - > write_header - > stream ) {
Z_ADDREF_P ( ch - > handlers - > write_header - > stream ) ;
}
dupch - > handlers - > write_header - > stream = ch - > handlers - > write_header - > stream ;
2004-03-12 18:37:55 +00:00
2006-08-29 17:10:40 +00:00
dupch - > handlers - > write - > fp = ch - > handlers - > write - > fp ;
dupch - > handlers - > write_header - > fp = ch - > handlers - > write_header - > fp ;
dupch - > handlers - > read - > fp = ch - > handlers - > read - > fp ;
dupch - > handlers - > read - > fd = ch - > handlers - > read - > fd ;
2006-11-03 14:53:14 +00:00
# if CURLOPT_PASSWDDATA != 0
2006-08-29 17:10:40 +00:00
if ( ch - > handlers - > passwd ) {
zval_add_ref ( & ch - > handlers - > passwd ) ;
dupch - > handlers - > passwd = ch - > handlers - > passwd ;
curl_easy_setopt ( ch - > cp , CURLOPT_PASSWDDATA , ( void * ) dupch ) ;
}
2006-11-03 14:53:14 +00:00
# endif
2006-08-29 17:10:40 +00:00
if ( ch - > handlers - > write - > func_name ) {
zval_add_ref ( & ch - > handlers - > write - > func_name ) ;
dupch - > handlers - > write - > func_name = ch - > handlers - > write - > func_name ;
}
if ( ch - > handlers - > read - > func_name ) {
zval_add_ref ( & ch - > handlers - > read - > func_name ) ;
dupch - > handlers - > read - > func_name = ch - > handlers - > read - > func_name ;
}
if ( ch - > handlers - > write_header - > func_name ) {
zval_add_ref ( & ch - > handlers - > write_header - > func_name ) ;
dupch - > handlers - > write_header - > func_name = ch - > handlers - > write_header - > func_name ;
}
curl_easy_setopt ( dupch - > cp , CURLOPT_ERRORBUFFER , dupch - > err . str ) ;
curl_easy_setopt ( dupch - > cp , CURLOPT_FILE , ( void * ) dupch ) ;
curl_easy_setopt ( dupch - > cp , CURLOPT_INFILE , ( void * ) dupch ) ;
curl_easy_setopt ( dupch - > cp , CURLOPT_WRITEHEADER , ( void * ) dupch ) ;
2011-12-04 01:16:17 +00:00
if ( ch - > handlers - > progress ) {
dupch - > handlers - > progress = ecalloc ( 1 , sizeof ( php_curl_progress ) ) ;
if ( ch - > handlers - > progress - > func_name ) {
zval_add_ref ( & ch - > handlers - > progress - > func_name ) ;
dupch - > handlers - > progress - > func_name = ch - > handlers - > progress - > func_name ;
}
dupch - > handlers - > progress - > method = ch - > handlers - > progress - > method ;
curl_easy_setopt ( dupch - > cp , CURLOPT_PROGRESSDATA , ( void * ) dupch ) ;
}
2011-12-06 15:57:43 +00:00
/* Available since 7.21.0 */
# if LIBCURL_VERSION_NUM >= 0x071500
2011-12-04 01:16:17 +00:00
if ( ch - > handlers - > fnmatch ) {
dupch - > handlers - > fnmatch = ecalloc ( 1 , sizeof ( php_curl_fnmatch ) ) ;
if ( ch - > handlers - > fnmatch - > func_name ) {
zval_add_ref ( & ch - > handlers - > fnmatch - > func_name ) ;
dupch - > handlers - > fnmatch - > func_name = ch - > handlers - > fnmatch - > func_name ;
}
dupch - > handlers - > fnmatch - > method = ch - > handlers - > fnmatch - > method ;
curl_easy_setopt ( dupch - > cp , CURLOPT_FNMATCH_DATA , ( void * ) dupch ) ;
}
2011-12-06 16:09:06 +00:00
# endif
2011-12-04 01:16:17 +00:00
2011-11-22 05:19:37 +00:00
efree ( dupch - > to_free ) ;
dupch - > to_free = ch - > to_free ;
2006-08-29 17:10:40 +00:00
2009-07-21 20:32:32 +00:00
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
Z_ADDREF_P ( ch - > clone ) ;
dupch - > clone = ch - > clone ;
2004-03-12 18:37:55 +00:00
ZEND_REGISTER_RESOURCE ( return_value , dupch , le_curl ) ;
dupch - > id = Z_LVAL_P ( return_value ) ;
}
/* }}} */
2007-12-04 08:56:07 +00:00
static int _php_curl_setopt ( php_curl * ch , long option , zval * * zvalue , zval * return_value TSRMLS_DC ) /* { { { */
2000-07-16 19:37:33 +00:00
{
2002-07-26 22:57:14 +00:00
CURLcode error = CURLE_OK ;
2001-04-30 14:36:19 +00:00
switch ( option ) {
2011-12-01 21:48:07 +00:00
/* Long options */
2012-10-25 04:47:47 +00:00
case CURLOPT_SSL_VERIFYHOST :
if ( Z_TYPE_PP ( zvalue ) = = IS_BOOL & & Z_BVAL_PP ( zvalue ) ) {
php_error_docref ( NULL TSRMLS_CC , E_NOTICE , " CURLOPT_SSL_VERIFYHOST set to true which disables common name validation (setting CURLOPT_SSL_VERIFYHOST to 2 enables common name validation) " ) ;
}
2011-12-01 21:48:07 +00:00
case CURLOPT_AUTOREFERER :
case CURLOPT_BUFFERSIZE :
2002-07-31 22:10:58 +00:00
case CURLOPT_CLOSEPOLICY :
case CURLOPT_CONNECTTIMEOUT :
2011-12-01 21:48:07 +00:00
case CURLOPT_COOKIESESSION :
case CURLOPT_CRLF :
case CURLOPT_DNS_CACHE_TIMEOUT :
2002-07-31 22:10:58 +00:00
case CURLOPT_DNS_USE_GLOBAL_CACHE :
2011-12-01 21:48:07 +00:00
case CURLOPT_FAILONERROR :
case CURLOPT_FILETIME :
case CURLOPT_FORBID_REUSE :
case CURLOPT_FRESH_CONNECT :
case CURLOPT_FTP_USE_EPRT :
case CURLOPT_FTP_USE_EPSV :
case CURLOPT_HEADER :
2002-11-09 13:52:00 +00:00
case CURLOPT_HTTPGET :
2011-12-01 21:48:07 +00:00
case CURLOPT_HTTPPROXYTUNNEL :
2002-11-09 13:52:00 +00:00
case CURLOPT_HTTP_VERSION :
2011-12-01 21:48:07 +00:00
case CURLOPT_INFILESIZE :
case CURLOPT_LOW_SPEED_LIMIT :
case CURLOPT_LOW_SPEED_TIME :
case CURLOPT_MAXCONNECTS :
case CURLOPT_MAXREDIRS :
case CURLOPT_NETRC :
case CURLOPT_NOBODY :
case CURLOPT_NOPROGRESS :
case CURLOPT_NOSIGNAL :
case CURLOPT_PORT :
case CURLOPT_POST :
2003-06-19 22:12:21 +00:00
case CURLOPT_PROXYPORT :
2011-12-01 21:48:07 +00:00
case CURLOPT_PROXYTYPE :
case CURLOPT_PUT :
case CURLOPT_RESUME_FROM :
case CURLOPT_SSLVERSION :
case CURLOPT_SSL_VERIFYPEER :
case CURLOPT_TIMECONDITION :
case CURLOPT_TIMEOUT :
case CURLOPT_TIMEVALUE :
case CURLOPT_TRANSFERTEXT :
case CURLOPT_UNRESTRICTED_AUTH :
case CURLOPT_UPLOAD :
case CURLOPT_VERBOSE :
# if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
2003-06-19 22:12:21 +00:00
case CURLOPT_HTTPAUTH :
2004-08-18 21:27:24 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
2007-04-23 14:36:56 +00:00
case CURLOPT_FTP_CREATE_MISSING_DIRS :
2011-12-01 21:48:07 +00:00
case CURLOPT_PROXYAUTH :
2003-06-19 22:12:21 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
case CURLOPT_FTP_RESPONSE_TIMEOUT :
case CURLOPT_IPRESOLVE :
case CURLOPT_MAXFILESIZE :
2006-09-18 16:11:50 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
2007-01-09 23:13:05 +00:00
case CURLOPT_TCP_NODELAY :
2009-03-13 19:39:49 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
case CURLOPT_FTPSSLAUTH :
2007-01-19 18:03:33 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
case CURLOPT_IGNORE_CONTENT_LENGTH :
2009-05-08 03:33:06 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
2010-01-23 01:37:32 +00:00
case CURLOPT_FTP_SKIP_PASV_IP :
2009-09-15 15:47:06 +00:00
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
case CURLOPT_FTP_FILEMETHOD :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
case CURLOPT_CONNECT_ONLY :
case CURLOPT_LOCALPORT :
case CURLOPT_LOCALPORTRANGE :
# endif
# if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
case CURLOPT_SSL_SESSIONID_CACHE :
# endif
# if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
case CURLOPT_FTP_SSL_CCC :
2012-08-24 22:04:16 +00:00
case CURLOPT_SSH_AUTH_TYPES :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
2011-12-01 21:48:07 +00:00
case CURLOPT_CONNECTTIMEOUT_MS :
2011-11-22 17:33:48 +00:00
case CURLOPT_HTTP_CONTENT_DECODING :
2011-12-01 21:48:07 +00:00
case CURLOPT_HTTP_TRANSFER_DECODING :
case CURLOPT_TIMEOUT_MS :
# endif
2012-08-24 22:04:16 +00:00
# if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
case CURLOPT_NEW_DIRECTORY_PERMS :
case CURLOPT_NEW_FILE_PERMS :
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
case CURLOPT_USE_SSL :
# elif LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
case CURLOPT_FTP_SSL :
# endif
# if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
case CURLOPT_APPEND :
case CURLOPT_DIRLISTONLY :
# else
case CURLOPT_FTPAPPEND :
case CURLOPT_FTPLISTONLY :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
case CURLOPT_PROXY_TRANSFER_MODE :
# endif
# if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
case CURLOPT_ADDRESS_SCOPE :
2011-12-01 21:48:07 +00:00
# endif
# if LIBCURL_VERSION_NUM > 0x071301 /* Available since 7.19.1 */
case CURLOPT_CERTINFO :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
case CURLOPT_NOPROXY :
2011-12-01 21:48:07 +00:00
case CURLOPT_PROTOCOLS :
case CURLOPT_REDIR_PROTOCOLS :
2011-11-22 17:33:48 +00:00
case CURLOPT_SOCKS5_GSSAPI_NEC :
case CURLOPT_TFTP_BLKSIZE :
# endif
# if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
case CURLOPT_FTP_USE_PRET :
case CURLOPT_RTSP_CLIENT_CSEQ :
case CURLOPT_RTSP_REQUEST :
2011-12-01 21:48:07 +00:00
case CURLOPT_RTSP_SERVER_CSEQ :
# endif
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_WILDCARDMATCH :
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
case CURLOPT_TLSAUTH_TYPE :
# endif
# if CURLOPT_MUTE != 0
case CURLOPT_MUTE :
2011-11-22 17:33:48 +00:00
# endif
2002-07-31 22:10:58 +00:00
convert_to_long_ex ( zvalue ) ;
2009-05-18 10:31:08 +00:00
# if LIBCURL_VERSION_NUM >= 0x71304
2009-09-23 02:08:19 +00:00
if ( ( option = = CURLOPT_PROTOCOLS | | option = = CURLOPT_REDIR_PROTOCOLS ) & &
2010-04-26 23:53:30 +00:00
( PG ( open_basedir ) & & * PG ( open_basedir ) ) & & ( Z_LVAL_PP ( zvalue ) & CURLPROTO_FILE ) ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLPROTO_FILE cannot be activated when an open_basedir is set " ) ;
2009-05-18 10:31:08 +00:00
RETVAL_FALSE ;
return 1 ;
}
# endif
2002-07-31 22:10:58 +00:00
error = curl_easy_setopt ( ch - > cp , option , Z_LVAL_PP ( zvalue ) ) ;
break ;
2011-12-01 21:48:07 +00:00
/* String options */
case CURLOPT_CAINFO :
case CURLOPT_CAPATH :
case CURLOPT_COOKIE :
case CURLOPT_CUSTOMREQUEST :
case CURLOPT_EGDSOCKET :
case CURLOPT_FTPPORT :
case CURLOPT_INTERFACE :
2007-07-04 13:34:23 +00:00
case CURLOPT_PRIVATE :
2002-07-31 22:10:58 +00:00
case CURLOPT_PROXY :
case CURLOPT_PROXYUSERPWD :
case CURLOPT_RANGE :
case CURLOPT_REFERER :
2011-12-01 21:48:07 +00:00
case CURLOPT_SSLCERTTYPE :
2009-05-03 15:16:10 +00:00
case CURLOPT_SSLENGINE :
2003-02-02 20:56:51 +00:00
case CURLOPT_SSLENGINE_DEFAULT :
2011-12-01 21:48:07 +00:00
case CURLOPT_SSLKEY :
case CURLOPT_SSLKEYPASSWD :
case CURLOPT_SSLKEYTYPE :
case CURLOPT_SSL_CIPHER_LIST :
case CURLOPT_URL :
case CURLOPT_USERAGENT :
case CURLOPT_USERPWD :
2011-11-22 17:33:48 +00:00
# if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
case CURLOPT_FTP_ACCOUNT :
# endif
# if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
case CURLOPT_COOKIELIST :
# endif
# if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
case CURLOPT_FTP_ALTERNATIVE_TO_USER :
# endif
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
case CURLOPT_KRBLEVEL :
# else
case CURLOPT_KRB4LEVEL :
# endif
2012-08-24 22:04:16 +00:00
# if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */
2011-12-01 21:48:07 +00:00
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 :
# endif
2011-11-22 17:33:48 +00:00
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLOPT_PASSWORD :
case CURLOPT_PROXYPASSWORD :
2011-12-01 21:48:07 +00:00
case CURLOPT_PROXYUSERNAME :
case CURLOPT_USERNAME :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
case CURLOPT_SOCKS5_GSSAPI_SERVICE :
2011-12-01 21:48:07 +00:00
# endif
2011-11-22 17:33:48 +00:00
# if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
case CURLOPT_MAIL_FROM :
case CURLOPT_RTSP_SESSION_ID :
case CURLOPT_RTSP_STREAM_URI :
2011-12-01 21:48:07 +00:00
case CURLOPT_RTSP_TRANSPORT :
# endif
# if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
case CURLOPT_TLSAUTH_PASSWORD :
case CURLOPT_TLSAUTH_USERNAME :
# endif
# if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
case CURLOPT_ACCEPT_ENCODING :
case CURLOPT_TRANSFER_ENCODING :
# else
case CURLOPT_ENCODING :
2011-11-22 17:33:48 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
case CURLOPT_DNS_SERVERS :
2011-12-01 21:48:07 +00:00
# endif
2012-05-27 07:02:53 +00:00
# if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
2012-05-27 22:39:45 +00:00
case CURLOPT_MAIL_AUTH :
2012-05-27 07:02:53 +00:00
# endif
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
{
2002-07-31 22:10:58 +00:00
convert_to_string_ex ( zvalue ) ;
2009-05-18 10:31:08 +00:00
if ( option = = CURLOPT_URL ) {
2010-04-13 11:02:15 +00:00
if ( ! php_curl_option_url ( ch , Z_STRVAL_PP ( zvalue ) , Z_STRLEN_PP ( zvalue ) TSRMLS_CC ) ) {
2009-05-18 10:31:08 +00:00
RETVAL_FALSE ;
return 1 ;
}
} else {
2010-11-30 13:40:02 +00:00
if ( option = = CURLOPT_PRIVATE ) {
char * copystr ;
# if LIBCURL_VERSION_NUM < 0x071100
string_copy :
# endif
copystr = estrndup ( Z_STRVAL_PP ( zvalue ) , Z_STRLEN_PP ( zvalue ) ) ;
error = curl_easy_setopt ( ch - > cp , option , copystr ) ;
2011-11-22 05:19:37 +00:00
zend_llist_add_element ( & ch - > to_free - > str , & copystr ) ;
2010-11-30 13:40:02 +00:00
} else {
2008-12-17 14:13:40 +00:00
# if LIBCURL_VERSION_NUM >= 0x071100
2010-11-30 13:40:02 +00:00
/* Strings passed to libcurl as ’ char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
error = curl_easy_setopt ( ch - > cp , option , Z_STRVAL_PP ( zvalue ) ) ;
# else
goto string_copy ;
2008-12-17 14:13:40 +00:00
# endif
2010-11-30 13:40:02 +00:00
}
2009-05-18 10:31:08 +00:00
}
2002-07-31 22:10:58 +00:00
break ;
2001-11-20 11:29:54 +00:00
}
2011-12-01 21:48:07 +00:00
/* Curl file handle options */
2001-06-25 15:14:20 +00:00
case CURLOPT_FILE :
2009-05-03 15:16:10 +00:00
case CURLOPT_INFILE :
2011-12-01 21:48:07 +00:00
case CURLOPT_STDERR :
case CURLOPT_WRITEHEADER : {
2002-07-31 22:10:58 +00:00
FILE * fp = NULL ;
int type ;
void * what ;
- MFH
- [DOC] Add support for SSH via libssh2
- new constants: CURLE_SSH, CURLSSH_AUTH_NONE, CURLSSH_AUTH_PUBLICKEY, CURLSSH_AUTH_PASSWORD, CURLSSH_AUTH_HOST, CURLSSH_AUTH_KEYBOARD, CURLSSH_AUTH_DEFAULT, CURLOPT_SSH_AUTH_TYPES, CURLOPT_KEYPASSWD, CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html fortheir roles or usages
2009-01-25 16:28:18 +00:00
2010-11-29 14:40:59 +00:00
what = zend_fetch_resource ( zvalue TSRMLS_CC , - 1 , " File-Handle " , & type , 1 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
2006-11-20 19:04:21 +00:00
if ( ! what ) {
RETVAL_FALSE ;
return 1 ;
}
2001-04-30 14:36:19 +00:00
2003-03-17 15:06:11 +00:00
if ( FAILURE = = php_stream_cast ( ( php_stream * ) what , PHP_STREAM_AS_STDIO , ( void * ) & fp , REPORT_ERRORS ) ) {
2006-07-04 20:12:38 +00:00
RETVAL_FALSE ;
return 1 ;
2002-07-31 22:10:58 +00:00
}
2001-04-30 14:36:19 +00:00
2002-07-31 22:10:58 +00:00
if ( ! fp ) {
2006-07-04 20:12:38 +00:00
RETVAL_FALSE ;
return 1 ;
2002-07-31 22:10:58 +00:00
}
error = CURLE_OK ;
switch ( option ) {
case CURLOPT_FILE :
2009-07-02 13:42:16 +00:00
if ( ( ( php_stream * ) what ) - > mode [ 0 ] ! = ' r ' | | ( ( php_stream * ) what ) - > mode [ 1 ] = = ' + ' ) {
2011-11-21 02:29:24 +00:00
if ( ch - > handlers - > write - > stream ) {
Z_DELREF_P ( ch - > handlers - > write - > stream ) ;
}
2009-09-30 02:34:17 +00:00
Z_ADDREF_PP ( zvalue ) ;
2009-05-21 12:52:05 +00:00
ch - > handlers - > write - > fp = fp ;
ch - > handlers - > write - > method = PHP_CURL_FILE ;
2009-09-30 02:34:17 +00:00
ch - > handlers - > write - > stream = * zvalue ;
2009-05-21 12:52:05 +00:00
} else {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " the provided file handle is not writable " ) ;
RETVAL_FALSE ;
return 1 ;
}
2002-07-31 22:10:58 +00:00
break ;
case CURLOPT_WRITEHEADER :
2009-07-02 13:42:16 +00:00
if ( ( ( php_stream * ) what ) - > mode [ 0 ] ! = ' r ' | | ( ( php_stream * ) what ) - > mode [ 1 ] = = ' + ' ) {
2011-11-21 02:29:24 +00:00
if ( ch - > handlers - > write_header - > stream ) {
Z_DELREF_P ( ch - > handlers - > write_header - > stream ) ;
}
2009-09-30 02:34:17 +00:00
Z_ADDREF_PP ( zvalue ) ;
2009-05-21 12:52:05 +00:00
ch - > handlers - > write_header - > fp = fp ;
ch - > handlers - > write_header - > method = PHP_CURL_FILE ;
2009-09-30 02:34:17 +00:00
ch - > handlers - > write_header - > stream = * zvalue ;
2009-05-21 12:52:05 +00:00
} else {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " the provided file handle is not writable " ) ;
RETVAL_FALSE ;
return 1 ;
}
2002-07-31 22:10:58 +00:00
break ;
case CURLOPT_INFILE :
2011-11-21 02:29:24 +00:00
if ( ch - > handlers - > read - > stream ) {
Z_DELREF_P ( ch - > handlers - > read - > stream ) ;
}
2009-09-30 02:34:17 +00:00
Z_ADDREF_PP ( zvalue ) ;
2002-07-31 22:10:58 +00:00
ch - > handlers - > read - > fp = fp ;
ch - > handlers - > read - > fd = Z_LVAL_PP ( zvalue ) ;
2009-09-30 02:34:17 +00:00
ch - > handlers - > read - > stream = * zvalue ;
2002-07-31 22:10:58 +00:00
break ;
2009-05-26 15:49:15 +00:00
case CURLOPT_STDERR :
2009-07-02 13:42:16 +00:00
if ( ( ( php_stream * ) what ) - > mode [ 0 ] ! = ' r ' | | ( ( php_stream * ) what ) - > mode [ 1 ] = = ' + ' ) {
2009-05-27 22:35:26 +00:00
if ( ch - > handlers - > std_err ) {
zval_ptr_dtor ( & ch - > handlers - > std_err ) ;
2009-05-26 15:49:15 +00:00
}
zval_add_ref ( zvalue ) ;
2009-05-27 22:35:26 +00:00
ch - > handlers - > std_err = * zvalue ;
2009-05-26 15:49:15 +00:00
} else {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " the provided file handle is not writable " ) ;
RETVAL_FALSE ;
return 1 ;
}
/* break omitted intentionally */
2002-07-31 22:10:58 +00:00
default :
error = curl_easy_setopt ( ch - > cp , option , fp ) ;
break ;
}
break ;
2002-07-26 22:57:14 +00:00
}
2002-07-31 22:10:58 +00:00
2011-12-01 21:48:07 +00:00
/* Curl linked list options */
case CURLOPT_HTTP200ALIASES :
case CURLOPT_HTTPHEADER :
case CURLOPT_POSTQUOTE :
case CURLOPT_PREQUOTE :
case CURLOPT_QUOTE :
# if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
case CURLOPT_MAIL_RCPT :
# endif
# if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
case CURLOPT_RESOLVE :
# endif
{
zval * * current ;
HashTable * ph ;
struct curl_slist * slist = NULL ;
ph = HASH_OF ( * zvalue ) ;
if ( ! ph ) {
char * name ;
switch ( option ) {
case CURLOPT_HTTPHEADER :
name = " CURLOPT_HTTPHEADER " ;
break ;
case CURLOPT_QUOTE :
name = " CURLOPT_QUOTE " ;
break ;
case CURLOPT_HTTP200ALIASES :
name = " CURLOPT_HTTP200ALIASES " ;
break ;
case CURLOPT_POSTQUOTE :
name = " CURLOPT_POSTQUOTE " ;
break ;
case CURLOPT_PREQUOTE :
name = " CURLOPT_PREQUOTE " ;
break ;
# if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
case CURLOPT_MAIL_RCPT :
name = " CURLOPT_MAIL_RCPT " ;
break ;
# endif
# if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
case CURLOPT_RESOLVE :
name = " CURLOPT_RESOLVE " ;
break ;
# endif
}
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " You must pass either an object or an array with the %s argument " , name ) ;
RETVAL_FALSE ;
return 1 ;
}
for ( zend_hash_internal_pointer_reset ( ph ) ;
zend_hash_get_current_data ( ph , ( void * * ) & current ) = = SUCCESS ;
zend_hash_move_forward ( ph )
) {
SEPARATE_ZVAL ( current ) ;
convert_to_string_ex ( current ) ;
slist = curl_slist_append ( slist , Z_STRVAL_PP ( current ) ) ;
if ( ! slist ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Could not build curl_slist " ) ;
RETVAL_FALSE ;
return 1 ;
}
2000-09-30 03:09:54 +00:00
}
2011-12-01 21:48:07 +00:00
zend_llist_add_element ( & ch - > to_free - > slist , & slist ) ;
error = curl_easy_setopt ( ch - > cp , option , slist ) ;
2002-07-31 22:10:58 +00:00
break ;
2011-12-01 21:48:07 +00:00
}
2002-07-31 22:10:58 +00:00
case CURLOPT_BINARYTRANSFER :
2011-11-22 17:13:26 +00:00
/* Do nothing, just backward compatibility */
2002-07-31 22:10:58 +00:00
break ;
2011-12-01 21:48:07 +00:00
case CURLOPT_FOLLOWLOCATION :
convert_to_long_ex ( zvalue ) ;
if ( PG ( open_basedir ) & & * PG ( open_basedir ) ) {
if ( Z_LVAL_PP ( zvalue ) ! = 0 ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set " ) ;
RETVAL_FALSE ;
return 1 ;
}
2009-05-03 14:59:46 +00:00
}
2011-12-01 21:48:07 +00:00
error = curl_easy_setopt ( ch - > cp , option , Z_LVAL_PP ( zvalue ) ) ;
2009-05-03 14:59:46 +00:00
break ;
2011-12-01 21:48:07 +00:00
2002-07-31 22:10:58 +00:00
case CURLOPT_HEADERFUNCTION :
2003-05-21 23:15:28 +00:00
if ( ch - > handlers - > write_header - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > write_header - > func_name ) ;
2008-07-29 10:42:44 +00:00
ch - > handlers - > write_header - > fci_cache = empty_fcall_info_cache ;
2002-11-08 17:58:43 +00:00
}
2002-07-31 22:10:58 +00:00
zval_add_ref ( zvalue ) ;
2003-05-21 23:15:28 +00:00
ch - > handlers - > write_header - > func_name = * zvalue ;
2002-07-31 22:10:58 +00:00
ch - > handlers - > write_header - > method = PHP_CURL_USER ;
break ;
2011-12-01 21:48:07 +00:00
2002-07-31 22:10:58 +00:00
case CURLOPT_POSTFIELDS :
if ( Z_TYPE_PP ( zvalue ) = = IS_ARRAY | | Z_TYPE_PP ( zvalue ) = = IS_OBJECT ) {
zval * * current ;
HashTable * postfields ;
struct HttpPost * first = NULL ;
struct HttpPost * last = NULL ;
postfields = HASH_OF ( * zvalue ) ;
2009-05-18 11:48:31 +00:00
if ( ! postfields ) {
2009-05-03 15:16:10 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Couldn't get HashTable in CURLOPT_POSTFIELDS " ) ;
2006-07-04 20:12:38 +00:00
RETVAL_FALSE ;
return 1 ;
2002-07-31 22:10:58 +00:00
}
2000-09-30 03:09:54 +00:00
2002-07-31 22:10:58 +00:00
for ( zend_hash_internal_pointer_reset ( postfields ) ;
2003-03-17 15:06:11 +00:00
zend_hash_get_current_data ( postfields , ( void * * ) & current ) = = SUCCESS ;
zend_hash_move_forward ( postfields )
) {
2011-09-23 15:19:48 +00:00
char * postval ;
char * string_key = NULL ;
uint string_key_len ;
ulong num_key ;
2011-11-21 02:44:28 +00:00
int numeric_key ;
2002-07-31 22:10:58 +00:00
SEPARATE_ZVAL ( current ) ;
convert_to_string_ex ( current ) ;
2000-12-22 12:57:09 +00:00
2003-03-17 15:06:11 +00:00
zend_hash_get_current_key_ex ( postfields , & string_key , & string_key_len , & num_key , 0 , NULL ) ;
2009-05-03 15:16:10 +00:00
2011-09-23 13:16:37 +00:00
/* Pretend we have a string_key here */
if ( ! string_key ) {
spprintf ( & string_key , 0 , " %ld " , num_key ) ;
string_key_len = strlen ( string_key ) + 1 ;
2011-11-21 02:44:28 +00:00
numeric_key = 1 ;
} else {
numeric_key = 0 ;
2011-09-23 13:16:37 +00:00
}
2002-07-31 22:10:58 +00:00
postval = Z_STRVAL_PP ( current ) ;
2005-01-05 21:33:56 +00:00
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
* must be explicitly cast to long in curl_formadd
* use since curl needs a long not an int . */
2002-07-31 22:10:58 +00:00
if ( * postval = = ' @ ' ) {
2009-07-21 15:56:08 +00:00
char * type , * filename ;
2005-10-05 14:35:30 +00:00
+ + postval ;
2008-11-27 17:00:04 +00:00
2009-07-19 14:36:16 +00:00
if ( ( type = php_memnstr ( postval , " ;type= " , sizeof ( " ;type= " ) - 1 , postval + Z_STRLEN_PP ( current ) ) ) ) {
2008-11-27 17:00:04 +00:00
* type = ' \0 ' ;
}
2009-07-21 15:56:08 +00:00
if ( ( filename = php_memnstr ( postval , " ;filename= " , sizeof ( " ;filename= " ) - 1 , postval + Z_STRLEN_PP ( current ) ) ) ) {
* filename = ' \0 ' ;
}
2010-04-26 23:53:30 +00:00
/* open_basedir check */
if ( php_check_open_basedir ( postval TSRMLS_CC ) ) {
2006-07-04 20:12:38 +00:00
RETVAL_FALSE ;
return 1 ;
2005-10-05 14:35:30 +00:00
}
2009-07-21 15:56:08 +00:00
error = curl_formadd ( & first , & last ,
CURLFORM_COPYNAME , string_key ,
CURLFORM_NAMELENGTH , ( long ) string_key_len - 1 ,
2009-10-26 12:57:01 +00:00
CURLFORM_FILENAME , filename ? filename + sizeof ( " ;filename= " ) - 1 : postval ,
2009-07-21 15:56:08 +00:00
CURLFORM_CONTENTTYPE , type ? type + sizeof ( " ;type= " ) - 1 : " application/octet-stream " ,
CURLFORM_FILE , postval ,
CURLFORM_END ) ;
2008-11-27 17:00:04 +00:00
if ( type ) {
2009-01-26 15:19:55 +00:00
* type = ' ; ' ;
2009-07-21 15:56:08 +00:00
}
if ( filename ) {
* filename = ' ; ' ;
2008-11-27 17:00:04 +00:00
}
2003-03-17 15:06:11 +00:00
} else {
2009-05-03 15:16:10 +00:00
error = curl_formadd ( & first , & last ,
2002-07-31 22:10:58 +00:00
CURLFORM_COPYNAME , string_key ,
2005-01-05 21:33:56 +00:00
CURLFORM_NAMELENGTH , ( long ) string_key_len - 1 ,
2009-05-03 15:16:10 +00:00
CURLFORM_COPYCONTENTS , postval ,
2005-01-05 21:33:56 +00:00
CURLFORM_CONTENTSLENGTH , ( long ) Z_STRLEN_PP ( current ) ,
2002-07-31 22:10:58 +00:00
CURLFORM_END ) ;
}
2011-11-21 02:44:28 +00:00
if ( numeric_key ) {
efree ( string_key ) ;
}
2001-12-03 09:19:14 +00:00
}
2002-07-31 22:10:58 +00:00
SAVE_CURL_ERROR ( ch , error ) ;
if ( error ! = CURLE_OK ) {
2010-04-20 12:50:02 +00:00
RETVAL_FALSE ;
2006-07-04 20:12:38 +00:00
return 1 ;
2001-12-03 09:19:14 +00:00
}
2001-04-30 14:36:19 +00:00
2011-11-22 05:19:37 +00:00
zend_llist_add_element ( & ch - > to_free - > post , & first ) ;
2002-07-31 22:10:58 +00:00
error = curl_easy_setopt ( ch - > cp , CURLOPT_HTTPPOST , first ) ;
2003-03-17 15:06:11 +00:00
} else {
2008-12-17 14:13:40 +00:00
# if LIBCURL_VERSION_NUM >= 0x071101
2009-03-16 15:08:56 +00:00
convert_to_string_ex ( zvalue ) ;
2008-12-17 14:13:40 +00:00
/* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */
error = curl_easy_setopt ( ch - > cp , CURLOPT_POSTFIELDSIZE , Z_STRLEN_PP ( zvalue ) ) ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_COPYPOSTFIELDS , Z_STRVAL_PP ( zvalue ) ) ;
# else
2002-07-31 22:10:58 +00:00
char * post = NULL ;
2001-04-30 14:36:19 +00:00
2002-07-31 22:10:58 +00:00
convert_to_string_ex ( zvalue ) ;
post = estrndup ( Z_STRVAL_PP ( zvalue ) , Z_STRLEN_PP ( zvalue ) ) ;
2011-11-22 05:19:37 +00:00
zend_llist_add_element ( & ch - > to_free - > str , & post ) ;
2001-04-30 14:36:19 +00:00
2002-07-31 22:10:58 +00:00
error = curl_easy_setopt ( ch - > cp , CURLOPT_POSTFIELDS , post ) ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_POSTFIELDSIZE , Z_STRLEN_PP ( zvalue ) ) ;
2008-12-17 14:13:40 +00:00
# endif
2002-07-31 22:10:58 +00:00
}
break ;
2011-12-01 21:48:07 +00:00
case CURLOPT_PROGRESSFUNCTION :
curl_easy_setopt ( ch - > cp , CURLOPT_PROGRESSFUNCTION , curl_progress ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_PROGRESSDATA , ch ) ;
2011-12-04 00:19:12 +00:00
if ( ch - > handlers - > progress = = NULL ) {
2011-12-03 23:43:44 +00:00
ch - > handlers - > progress = ecalloc ( 1 , sizeof ( php_curl_progress ) ) ;
} else if ( ch - > handlers - > progress - > func_name ) {
2011-12-01 21:48:07 +00:00
zval_ptr_dtor ( & ch - > handlers - > progress - > func_name ) ;
ch - > handlers - > progress - > fci_cache = empty_fcall_info_cache ;
2002-07-31 22:10:58 +00:00
}
2011-12-01 21:48:07 +00:00
zval_add_ref ( zvalue ) ;
ch - > handlers - > progress - > func_name = * zvalue ;
ch - > handlers - > progress - > method = PHP_CURL_USER ;
break ;
2001-04-30 14:36:19 +00:00
2011-12-01 21:48:07 +00:00
case CURLOPT_READFUNCTION :
if ( ch - > handlers - > read - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > read - > func_name ) ;
ch - > handlers - > read - > fci_cache = empty_fcall_info_cache ;
}
zval_add_ref ( zvalue ) ;
ch - > handlers - > read - > func_name = * zvalue ;
ch - > handlers - > read - > method = PHP_CURL_USER ;
break ;
2001-04-30 14:36:19 +00:00
2011-12-01 21:48:07 +00:00
case CURLOPT_RETURNTRANSFER :
convert_to_long_ex ( zvalue ) ;
if ( Z_LVAL_PP ( zvalue ) ) {
ch - > handlers - > write - > method = PHP_CURL_RETURN ;
} else {
ch - > handlers - > write - > method = PHP_CURL_STDOUT ;
2000-10-20 04:57:14 +00:00
}
2011-12-01 21:48:07 +00:00
break ;
2001-04-30 14:36:19 +00:00
2011-12-01 21:48:07 +00:00
case CURLOPT_WRITEFUNCTION :
if ( ch - > handlers - > write - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > write - > func_name ) ;
ch - > handlers - > write - > fci_cache = empty_fcall_info_cache ;
}
zval_add_ref ( zvalue ) ;
ch - > handlers - > write - > func_name = * zvalue ;
ch - > handlers - > write - > method = PHP_CURL_USER ;
break ;
2001-04-30 14:36:19 +00:00
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
case CURLOPT_MAX_RECV_SPEED_LARGE :
case CURLOPT_MAX_SEND_SPEED_LARGE :
convert_to_long_ex ( zvalue ) ;
error = curl_easy_setopt ( ch - > cp , option , ( curl_off_t ) Z_LVAL_PP ( zvalue ) ) ;
2003-06-19 22:12:21 +00:00
break ;
2011-12-01 21:48:07 +00:00
# endif
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLOPT_POSTREDIR :
convert_to_long_ex ( zvalue ) ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_POSTREDIR , Z_LVAL_PP ( zvalue ) & CURL_REDIR_POST_ALL ) ;
break ;
# endif
# if CURLOPT_PASSWDFUNCTION != 0
case CURLOPT_PASSWDFUNCTION :
if ( ch - > handlers - > passwd ) {
zval_ptr_dtor ( & ch - > handlers - > passwd ) ;
}
zval_add_ref ( zvalue ) ;
ch - > handlers - > passwd = * zvalue ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_PASSWDFUNCTION , curl_passwd ) ;
error = curl_easy_setopt ( ch - > cp , CURLOPT_PASSWDDATA , ( void * ) ch ) ;
break ;
# endif
2010-04-26 23:53:30 +00:00
/* the following options deal with files, therefore the open_basedir check
* is required .
2003-06-19 22:12:21 +00:00
*/
2011-12-01 21:48:07 +00:00
case CURLOPT_COOKIEFILE :
2003-06-19 22:12:21 +00:00
case CURLOPT_COOKIEJAR :
case CURLOPT_RANDOM_FILE :
2011-12-01 21:48:07 +00:00
case CURLOPT_SSLCERT :
# if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
2011-11-22 17:33:48 +00:00
case CURLOPT_NETRC_FILE :
# endif
2012-08-24 22:04:16 +00:00
# if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
case CURLOPT_SSH_PRIVATE_KEYFILE :
case CURLOPT_SSH_PUBLIC_KEYFILE :
# endif
2011-11-22 17:33:48 +00:00
# if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
case CURLOPT_CRLFILE :
case CURLOPT_ISSUERCERT :
# endif
# if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
case CURLOPT_SSH_KNOWNHOSTS :
# endif
{
2008-12-17 14:13:40 +00:00
# if LIBCURL_VERSION_NUM < 0x071100
2003-06-19 22:12:21 +00:00
char * copystr = NULL ;
2008-12-17 14:13:40 +00:00
# endif
2003-06-19 22:12:21 +00:00
convert_to_string_ex ( zvalue ) ;
2012-07-09 00:38:03 +00:00
if ( Z_STRLEN_PP ( zvalue ) & & php_check_open_basedir ( Z_STRVAL_PP ( zvalue ) TSRMLS_CC ) ) {
2006-07-04 20:12:38 +00:00
RETVAL_FALSE ;
return 1 ;
2003-06-19 22:12:21 +00:00
}
2008-12-17 14:13:40 +00:00
# if LIBCURL_VERSION_NUM >= 0x071100
error = curl_easy_setopt ( ch - > cp , option , Z_STRVAL_PP ( zvalue ) ) ;
# else
2003-06-19 22:12:21 +00:00
copystr = estrndup ( Z_STRVAL_PP ( zvalue ) , Z_STRLEN_PP ( zvalue ) ) ;
error = curl_easy_setopt ( ch - > cp , option , copystr ) ;
2011-11-22 05:19:37 +00:00
zend_llist_add_element ( & ch - > to_free - > str , & copystr ) ;
2008-12-17 14:13:40 +00:00
# endif
2002-07-31 22:10:58 +00:00
break ;
}
2011-12-01 21:48:07 +00:00
2006-01-24 20:11:14 +00:00
case CURLINFO_HEADER_OUT :
convert_to_long_ex ( zvalue ) ;
if ( Z_LVAL_PP ( zvalue ) = = 1 ) {
curl_easy_setopt ( ch - > cp , CURLOPT_DEBUGFUNCTION , curl_debug ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_DEBUGDATA , ( void * ) ch ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_VERBOSE , 1 ) ;
} else {
curl_easy_setopt ( ch - > cp , CURLOPT_DEBUGFUNCTION , NULL ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_DEBUGDATA , NULL ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_VERBOSE , 0 ) ;
}
break ;
2011-12-01 21:48:07 +00:00
case CURLOPT_SHARE :
{
php_curlsh * sh = NULL ;
2012-08-27 11:56:54 +00:00
ZEND_FETCH_RESOURCE_NO_RETURN ( sh , php_curlsh * , zvalue , - 1 , le_curl_share_handle_name , le_curl_share_handle ) ;
2011-12-01 21:48:07 +00:00
if ( sh ) {
curl_easy_setopt ( ch - > cp , CURLOPT_SHARE , sh - > share ) ;
}
}
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION :
curl_easy_setopt ( ch - > cp , CURLOPT_FNMATCH_FUNCTION , curl_fnmatch ) ;
curl_easy_setopt ( ch - > cp , CURLOPT_FNMATCH_DATA , ch ) ;
if ( ch - > handlers - > fnmatch = = NULL ) {
ch - > handlers - > fnmatch = ecalloc ( 1 , sizeof ( php_curl_fnmatch ) ) ;
} else if ( ch - > handlers - > fnmatch - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > fnmatch - > func_name ) ;
ch - > handlers - > fnmatch - > fci_cache = empty_fcall_info_cache ;
}
zval_add_ref ( zvalue ) ;
ch - > handlers - > fnmatch - > func_name = * zvalue ;
ch - > handlers - > fnmatch - > method = PHP_CURL_USER ;
break ;
# endif
2000-09-30 03:09:54 +00:00
}
2002-04-03 23:59:36 +00:00
SAVE_CURL_ERROR ( ch , error ) ;
2001-04-30 14:36:19 +00:00
if ( error ! = CURLE_OK ) {
2006-01-24 20:11:14 +00:00
return 1 ;
2000-09-30 03:09:54 +00:00
} else {
2006-01-24 20:11:14 +00:00
return 0 ;
}
}
2007-12-04 08:56:07 +00:00
/* }}} */
2006-01-24 20:11:14 +00:00
/* {{{ proto bool curl_setopt(resource ch, int option, mixed value)
2006-09-09 20:04:50 +00:00
Set an option for a cURL transfer */
2006-01-24 20:11:14 +00:00
PHP_FUNCTION ( curl_setopt )
{
2009-05-18 11:48:31 +00:00
zval * zid , * * zvalue ;
2009-05-18 12:51:05 +00:00
long options ;
php_curl * ch ;
2006-01-24 20:11:14 +00:00
2009-05-18 12:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " rlZ " , & zid , & options , & zvalue ) = = FAILURE ) {
2008-06-21 21:51:05 +00:00
return ;
2006-01-24 20:11:14 +00:00
}
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2006-01-24 20:11:14 +00:00
2010-03-02 12:54:23 +00:00
if ( options < = 0 ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Invalid curl configuration option " ) ;
RETURN_FALSE ;
}
2009-05-18 12:51:05 +00:00
if ( ! _php_curl_setopt ( ch , options , zvalue , return_value TSRMLS_CC ) ) {
2000-09-30 03:09:54 +00:00
RETURN_TRUE ;
2006-01-24 20:11:14 +00:00
} else {
RETURN_FALSE ;
2000-09-30 03:09:54 +00:00
}
2000-07-16 19:37:33 +00:00
}
/* }}} */
2006-01-24 20:11:14 +00:00
/* {{{ proto bool curl_setopt_array(resource ch, array options)
2006-09-09 20:04:50 +00:00
Set an array of option for a cURL transfer */
2006-01-24 20:11:14 +00:00
PHP_FUNCTION ( curl_setopt_array )
{
zval * zid , * arr , * * entry ;
php_curl * ch ;
2009-05-18 12:51:05 +00:00
ulong option ;
2006-01-24 20:11:14 +00:00
HashPosition pos ;
2009-05-18 12:51:05 +00:00
char * string_key ;
uint str_key_len ;
2006-01-24 20:11:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " za " , & zid , & arr ) = = FAILURE ) {
2009-05-18 12:51:05 +00:00
return ;
2006-01-24 20:11:14 +00:00
}
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
zend_hash_internal_pointer_reset_ex ( Z_ARRVAL_P ( arr ) , & pos ) ;
while ( zend_hash_get_current_data_ex ( Z_ARRVAL_P ( arr ) , ( void * * ) & entry , & pos ) = = SUCCESS ) {
2009-05-18 12:51:05 +00:00
if ( zend_hash_get_current_key_ex ( Z_ARRVAL_P ( arr ) , & string_key , & str_key_len , & option , 0 , & pos ) ! = HASH_KEY_IS_LONG ) {
2009-05-03 15:16:10 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Array keys must be CURLOPT constants or equivalent integer values " ) ;
2006-01-24 20:11:14 +00:00
RETURN_FALSE ;
}
2009-05-18 12:51:05 +00:00
if ( _php_curl_setopt ( ch , ( long ) option , entry , return_value TSRMLS_CC ) ) {
2006-01-24 20:11:14 +00:00
RETURN_FALSE ;
}
zend_hash_move_forward_ex ( Z_ARRVAL_P ( arr ) , & pos ) ;
}
RETURN_TRUE ;
}
/* }}} */
2009-05-03 15:16:10 +00:00
/* {{{ _php_curl_cleanup_handle(ch)
2002-11-08 17:58:43 +00:00
Cleanup an execution phase */
2003-03-17 15:06:11 +00:00
void _php_curl_cleanup_handle ( php_curl * ch )
2002-11-08 17:58:43 +00:00
{
2005-07-18 13:47:33 +00:00
if ( ch - > handlers - > write - > buf . len > 0 ) {
2006-04-13 11:26:10 +00:00
smart_str_free ( & ch - > handlers - > write - > buf ) ;
2002-11-08 17:58:43 +00:00
}
2006-01-24 20:11:14 +00:00
if ( ch - > header . str_len ) {
efree ( ch - > header . str ) ;
ch - > header . str_len = 0 ;
}
2002-11-08 17:58:43 +00:00
memset ( ch - > err . str , 0 , CURL_ERROR_SIZE + 1 ) ;
ch - > err . no = 0 ;
}
/* }}} */
2002-03-18 18:00:24 +00:00
/* {{{ proto bool curl_exec(resource ch)
2006-09-09 20:04:50 +00:00
Perform a cURL session */
2000-08-27 22:53:33 +00:00
PHP_FUNCTION ( curl_exec )
2000-07-16 19:37:33 +00:00
{
2009-05-18 12:51:05 +00:00
CURLcode error ;
zval * zid ;
php_curl * ch ;
2001-04-30 14:36:19 +00:00
2008-06-21 21:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
2000-07-16 19:37:33 +00:00
}
2003-03-17 15:06:11 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2000-08-27 22:53:33 +00:00
2011-09-12 09:16:04 +00:00
_php_curl_verify_handlers ( ch , 1 TSRMLS_CC ) ;
2002-11-13 22:25:33 +00:00
_php_curl_cleanup_handle ( ch ) ;
2009-05-03 15:16:10 +00:00
2001-04-30 14:36:19 +00:00
error = curl_easy_perform ( ch - > cp ) ;
2002-04-03 23:59:36 +00:00
SAVE_CURL_ERROR ( ch , error ) ;
2004-02-23 19:50:07 +00:00
/* CURLE_PARTIAL_FILE is returned by HEAD requests */
if ( error ! = CURLE_OK & & error ! = CURLE_PARTIAL_FILE ) {
2002-11-08 17:58:43 +00:00
if ( ch - > handlers - > write - > buf . len > 0 ) {
2001-07-10 20:09:56 +00:00
smart_str_free ( & ch - > handlers - > write - > buf ) ;
2002-11-08 17:58:43 +00:00
}
2001-04-30 14:36:19 +00:00
RETURN_FALSE ;
2000-08-17 02:14:41 +00:00
}
2000-09-30 03:09:54 +00:00
2011-09-12 09:16:04 +00:00
if ( ch - > handlers - > std_err ) {
php_stream * stream ;
stream = ( php_stream * ) zend_fetch_resource ( & ch - > handlers - > std_err TSRMLS_CC , - 1 , NULL , NULL , 2 , php_file_le_stream ( ) , php_file_le_pstream ( ) ) ;
if ( stream ) {
php_stream_flush ( stream ) ;
}
}
2001-12-24 13:58:03 +00:00
if ( ch - > handlers - > write - > method = = PHP_CURL_RETURN & & ch - > handlers - > write - > buf . len > 0 ) {
2006-04-13 11:26:10 +00:00
smart_str_0 ( & ch - > handlers - > write - > buf ) ;
RETURN_STRINGL ( ch - > handlers - > write - > buf . c , ch - > handlers - > write - > buf . len , 1 ) ;
2000-08-27 22:53:33 +00:00
}
2009-06-15 12:37:37 +00:00
2009-06-28 09:50:14 +00:00
/* flush the file handle, so any remaining data is synched to disk */
if ( ch - > handlers - > write - > method = = PHP_CURL_FILE & & ch - > handlers - > write - > fp ) {
fflush ( ch - > handlers - > write - > fp ) ;
}
if ( ch - > handlers - > write_header - > method = = PHP_CURL_FILE & & ch - > handlers - > write_header - > fp ) {
fflush ( ch - > handlers - > write_header - > fp ) ;
}
2006-10-10 23:12:59 +00:00
if ( ch - > handlers - > write - > method = = PHP_CURL_RETURN ) {
RETURN_EMPTY_STRING ( ) ;
} else {
RETURN_TRUE ;
}
2000-07-16 19:37:33 +00:00
}
/* }}} */
2006-06-11 01:42:17 +00:00
/* {{{ proto mixed curl_getinfo(resource ch [, int option])
2000-10-20 04:57:14 +00:00
Get information regarding a specific transfer */
PHP_FUNCTION ( curl_getinfo )
{
2009-05-18 12:51:05 +00:00
zval * zid ;
php_curl * ch ;
long option = 0 ;
2001-04-30 14:36:19 +00:00
2009-05-18 11:58:04 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r|l " , & zid , & option ) = = FAILURE ) {
2008-06-21 21:51:05 +00:00
return ;
2000-10-20 04:57:14 +00:00
}
2003-03-17 15:06:11 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2000-10-20 04:57:14 +00:00
2009-05-18 11:58:04 +00:00
if ( ZEND_NUM_ARGS ( ) < 2 ) {
2002-11-08 17:58:43 +00:00
char * s_code ;
2001-04-30 14:36:19 +00:00
long l_code ;
double d_code ;
2009-09-23 00:18:32 +00:00
# if LIBCURL_VERSION_NUM > 0x071301
2009-09-15 15:47:06 +00:00
struct curl_certinfo * ci = NULL ;
zval * listcode ;
# endif
2000-10-20 04:57:14 +00:00
array_init ( return_value ) ;
2003-02-28 07:34:45 +00:00
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_EFFECTIVE_URL , & s_code ) = = CURLE_OK ) {
CAAS ( " url " , s_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CONTENT_TYPE , & s_code ) = = CURLE_OK ) {
if ( s_code ! = NULL ) {
CAAS ( " content_type " , s_code ) ;
2008-12-04 13:13:22 +00:00
} else {
2009-05-03 15:16:10 +00:00
zval * retnull ;
2008-12-04 13:13:22 +00:00
MAKE_STD_ZVAL ( retnull ) ;
ZVAL_NULL ( retnull ) ;
CAAZ ( " content_type " , retnull ) ;
2003-02-28 07:34:45 +00:00
}
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_HTTP_CODE , & l_code ) = = CURLE_OK ) {
CAAL ( " http_code " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_HEADER_SIZE , & l_code ) = = CURLE_OK ) {
CAAL ( " header_size " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_REQUEST_SIZE , & l_code ) = = CURLE_OK ) {
CAAL ( " request_size " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_FILETIME , & l_code ) = = CURLE_OK ) {
CAAL ( " filetime " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_SSL_VERIFYRESULT , & l_code ) = = CURLE_OK ) {
CAAL ( " ssl_verify_result " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_REDIRECT_COUNT , & l_code ) = = CURLE_OK ) {
CAAL ( " redirect_count " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_TOTAL_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " total_time " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_NAMELOOKUP_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " namelookup_time " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CONNECT_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " connect_time " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_PRETRANSFER_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " pretransfer_time " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_SIZE_UPLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " size_upload " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_SIZE_DOWNLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " size_download " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_SPEED_DOWNLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " speed_download " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_SPEED_UPLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " speed_upload " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CONTENT_LENGTH_DOWNLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " download_content_length " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CONTENT_LENGTH_UPLOAD , & d_code ) = = CURLE_OK ) {
CAAD ( " upload_content_length " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_STARTTRANSFER_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " starttransfer_time " , d_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_REDIRECT_TIME , & d_code ) = = CURLE_OK ) {
CAAD ( " redirect_time " , d_code ) ;
}
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_REDIRECT_URL , & s_code ) = = CURLE_OK ) {
CAAS ( " redirect_url " , s_code ) ;
}
# endif
# if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_PRIMARY_IP , & s_code ) = = CURLE_OK ) {
CAAS ( " primary_ip " , s_code ) ;
}
# endif
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
2009-09-15 15:47:06 +00:00
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CERTINFO , & ci ) = = CURLE_OK ) {
MAKE_STD_ZVAL ( listcode ) ;
array_init ( listcode ) ;
2009-09-16 18:01:10 +00:00
create_certinfo ( ci , listcode TSRMLS_CC ) ;
2009-09-15 15:47:06 +00:00
CAAZ ( " certinfo " , listcode ) ;
}
2010-12-10 01:45:55 +00:00
# endif
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
2010-12-10 01:45:55 +00:00
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_PRIMARY_PORT , & l_code ) = = CURLE_OK ) {
CAAL ( " primary_port " , l_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_LOCAL_IP , & s_code ) = = CURLE_OK ) {
CAAS ( " local_ip " , s_code ) ;
}
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_LOCAL_PORT , & l_code ) = = CURLE_OK ) {
CAAL ( " local_port " , l_code ) ;
}
2009-09-15 15:47:06 +00:00
# endif
2006-01-24 20:11:14 +00:00
if ( ch - > header . str_len > 0 ) {
CAAS ( " request_header " , ch - > header . str ) ;
}
2000-10-20 04:57:14 +00:00
} else {
2001-04-30 14:36:19 +00:00
switch ( option ) {
2006-01-24 20:11:14 +00:00
case CURLINFO_HEADER_OUT :
if ( ch - > header . str_len > 0 ) {
RETURN_STRINGL ( ch - > header . str , ch - > header . str_len , 1 ) ;
} else {
RETURN_FALSE ;
}
2011-12-03 20:16:32 +00:00
# if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
2009-09-15 15:47:06 +00:00
case CURLINFO_CERTINFO : {
struct curl_certinfo * ci = NULL ;
array_init ( return_value ) ;
if ( curl_easy_getinfo ( ch - > cp , CURLINFO_CERTINFO , & ci ) = = CURLE_OK ) {
2009-09-16 18:01:10 +00:00
create_certinfo ( ci , return_value TSRMLS_CC ) ;
2009-09-15 15:47:06 +00:00
} else {
RETURN_FALSE ;
}
break ;
}
# endif
2011-12-03 20:16:32 +00:00
default : {
int type = CURLINFO_TYPEMASK & option ;
switch ( type ) {
case CURLINFO_STRING :
{
char * s_code = NULL ;
if ( curl_easy_getinfo ( ch - > cp , option , & s_code ) = = CURLE_OK & & s_code ) {
RETURN_STRING ( s_code , 1 ) ;
} else {
RETURN_FALSE ;
}
break ;
}
case CURLINFO_LONG :
{
long code = 0 ;
if ( curl_easy_getinfo ( ch - > cp , option , & code ) = = CURLE_OK ) {
RETURN_LONG ( code ) ;
} else {
RETURN_FALSE ;
}
break ;
}
case CURLINFO_DOUBLE :
{
double code = 0.0 ;
if ( curl_easy_getinfo ( ch - > cp , option , & code ) = = CURLE_OK ) {
RETURN_DOUBLE ( code ) ;
} else {
RETURN_FALSE ;
}
break ;
}
case CURLINFO_SLIST :
{
struct curl_slist * slist ;
array_init ( return_value ) ;
if ( curl_easy_getinfo ( ch - > cp , option , & slist ) = = CURLE_OK ) {
while ( slist ) {
add_next_index_string ( return_value , slist - > data , 1 ) ;
slist = slist - > next ;
}
2011-12-05 22:23:19 +00:00
curl_slist_free_all ( slist ) ;
2011-12-03 20:16:32 +00:00
} else {
RETURN_FALSE ;
}
break ;
}
default :
RETURN_FALSE ;
}
}
2000-10-20 04:57:14 +00:00
}
2003-03-17 15:06:11 +00:00
}
2000-10-20 04:57:14 +00:00
}
/* }}} */
2002-03-18 18:00:24 +00:00
/* {{{ proto string curl_error(resource ch)
2000-09-30 03:09:54 +00:00
Return a string contain the last error for the current session */
PHP_FUNCTION ( curl_error )
2000-07-16 19:37:33 +00:00
{
2009-05-18 12:51:05 +00:00
zval * zid ;
php_curl * ch ;
2009-05-03 15:16:10 +00:00
2008-06-21 21:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
2000-07-16 19:37:33 +00:00
}
2003-03-17 15:06:11 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2001-03-03 01:06:55 +00:00
2001-07-02 12:08:21 +00:00
ch - > err . str [ CURL_ERROR_SIZE ] = 0 ;
2001-09-10 11:06:15 +00:00
RETURN_STRING ( ch - > err . str , 1 ) ;
2000-07-16 19:37:33 +00:00
}
/* }}} */
2002-03-18 18:00:24 +00:00
/* {{{ proto int curl_errno(resource ch)
2000-09-30 03:09:54 +00:00
Return an integer containing the last error number */
PHP_FUNCTION ( curl_errno )
{
2009-05-18 12:51:05 +00:00
zval * zid ;
php_curl * ch ;
2001-04-30 14:36:19 +00:00
2008-06-21 21:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
2000-09-30 03:09:54 +00:00
}
2003-03-17 15:06:11 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2001-04-30 14:36:19 +00:00
RETURN_LONG ( ch - > err . no ) ;
2000-09-30 03:09:54 +00:00
}
/* }}} */
2000-08-13 19:32:09 +00:00
2002-03-18 18:00:24 +00:00
/* {{{ proto void curl_close(resource ch)
2006-09-09 20:04:50 +00:00
Close a cURL session */
2000-10-20 04:57:14 +00:00
PHP_FUNCTION ( curl_close )
2000-08-13 19:32:09 +00:00
{
2009-05-18 12:51:05 +00:00
zval * zid ;
php_curl * ch ;
2001-04-30 14:36:19 +00:00
2008-06-21 21:51:05 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
2000-08-13 19:32:09 +00:00
}
2003-03-17 15:06:11 +00:00
2008-06-21 21:51:05 +00:00
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2005-06-02 21:04:12 +00:00
if ( ch - > in_callback ) {
2006-09-09 20:04:50 +00:00
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Attempt to close cURL handle from a callback " ) ;
2005-06-02 21:04:12 +00:00
return ;
}
2009-05-03 15:16:10 +00:00
if ( ch - > uses ) {
2004-03-11 00:11:18 +00:00
ch - > uses - - ;
} else {
2008-06-21 21:51:05 +00:00
zend_list_delete ( Z_LVAL_P ( zid ) ) ;
2004-03-11 00:11:18 +00:00
}
2000-08-13 19:32:09 +00:00
}
2000-09-30 03:09:54 +00:00
/* }}} */
2000-08-13 19:32:09 +00:00
2000-09-30 03:09:54 +00:00
/* {{{ _php_curl_close()
List destructor for curl handles */
2009-05-18 10:31:08 +00:00
static void _php_curl_close_ex ( php_curl * ch TSRMLS_DC )
2000-08-15 16:50:14 +00:00
{
2002-11-13 22:25:33 +00:00
# if PHP_CURL_DEBUG
fprintf ( stderr , " DTOR CALLED, ch = %x \n " , ch ) ;
# endif
2009-05-03 15:16:10 +00:00
2011-09-12 09:16:04 +00:00
_php_curl_verify_handlers ( ch , 0 TSRMLS_CC ) ;
2001-04-30 14:36:19 +00:00
curl_easy_cleanup ( ch - > cp ) ;
2009-07-21 20:32:32 +00:00
/* cURL destructors should be invoked only by last curl handle */
if ( Z_REFCOUNT_P ( ch - > clone ) < = 1 ) {
2011-11-22 05:19:37 +00:00
zend_llist_clean ( & ch - > to_free - > str ) ;
zend_llist_clean ( & ch - > to_free - > slist ) ;
zend_llist_clean ( & ch - > to_free - > post ) ;
efree ( ch - > to_free ) ;
2009-07-25 20:39:01 +00:00
FREE_ZVAL ( ch - > clone ) ;
2009-07-21 20:32:32 +00:00
} else {
Z_DELREF_P ( ch - > clone ) ;
}
2001-04-30 14:36:19 +00:00
2006-04-13 11:26:10 +00:00
if ( ch - > handlers - > write - > buf . len > 0 ) {
smart_str_free ( & ch - > handlers - > write - > buf ) ;
}
2003-05-21 23:15:28 +00:00
if ( ch - > handlers - > write - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > write - > func_name ) ;
2003-03-17 15:06:11 +00:00
}
2003-05-21 23:15:28 +00:00
if ( ch - > handlers - > read - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > read - > func_name ) ;
2003-03-17 15:06:11 +00:00
}
2003-05-21 23:15:28 +00:00
if ( ch - > handlers - > write_header - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > write_header - > func_name ) ;
2003-03-17 15:06:11 +00:00
}
if ( ch - > handlers - > passwd ) {
2002-11-08 17:58:43 +00:00
zval_ptr_dtor ( & ch - > handlers - > passwd ) ;
2003-03-17 15:06:11 +00:00
}
2009-05-27 22:35:26 +00:00
if ( ch - > handlers - > std_err ) {
zval_ptr_dtor ( & ch - > handlers - > std_err ) ;
2009-05-26 15:49:15 +00:00
}
2006-01-24 20:11:14 +00:00
if ( ch - > header . str_len > 0 ) {
efree ( ch - > header . str ) ;
}
2009-05-03 15:16:10 +00:00
2009-09-30 02:34:17 +00:00
if ( ch - > handlers - > write_header - > stream ) {
zval_ptr_dtor ( & ch - > handlers - > write_header - > stream ) ;
}
if ( ch - > handlers - > write - > stream ) {
zval_ptr_dtor ( & ch - > handlers - > write - > stream ) ;
}
if ( ch - > handlers - > read - > stream ) {
zval_ptr_dtor ( & ch - > handlers - > read - > stream ) ;
}
2001-05-04 04:20:38 +00:00
efree ( ch - > handlers - > write ) ;
2001-06-25 15:14:20 +00:00
efree ( ch - > handlers - > write_header ) ;
2001-05-04 04:20:38 +00:00
efree ( ch - > handlers - > read ) ;
2011-12-03 23:43:44 +00:00
if ( ch - > handlers - > progress ) {
if ( ch - > handlers - > progress - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > progress - > func_name ) ;
}
efree ( ch - > handlers - > progress ) ;
}
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if ( ch - > handlers - > fnmatch ) {
if ( ch - > handlers - > fnmatch - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > fnmatch - > func_name ) ;
}
efree ( ch - > handlers - > fnmatch ) ;
}
# endif
2001-04-30 14:36:19 +00:00
efree ( ch - > handlers ) ;
efree ( ch ) ;
2009-05-03 15:16:10 +00:00
}
2000-09-30 03:09:54 +00:00
/* }}} */
2000-08-15 16:50:14 +00:00
2009-05-18 10:31:08 +00:00
/* {{{ _php_curl_close()
List destructor for curl handles */
static void _php_curl_close ( zend_rsrc_list_entry * rsrc TSRMLS_DC )
{
php_curl * ch = ( php_curl * ) rsrc - > ptr ;
_php_curl_close_ex ( ch TSRMLS_CC ) ;
}
/* }}} */
2011-12-01 21:48:07 +00:00
# if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
/* {{{ _php_curl_reset_handlers()
Reset all handlers of a given php_curl */
2012-08-27 11:56:54 +00:00
static void _php_curl_reset_handlers ( php_curl * ch )
2011-12-01 21:48:07 +00:00
{
if ( ch - > handlers - > write - > stream ) {
Z_DELREF_P ( ch - > handlers - > write - > stream ) ;
ch - > handlers - > write - > stream = NULL ;
}
ch - > handlers - > write - > fp = NULL ;
ch - > handlers - > write - > method = PHP_CURL_STDOUT ;
if ( ch - > handlers - > write_header - > stream ) {
Z_DELREF_P ( ch - > handlers - > write_header - > stream ) ;
ch - > handlers - > write_header - > stream = NULL ;
}
ch - > handlers - > write_header - > fp = NULL ;
ch - > handlers - > write_header - > method = PHP_CURL_IGNORE ;
if ( ch - > handlers - > read - > stream ) {
Z_DELREF_P ( ch - > handlers - > read - > stream ) ;
ch - > handlers - > read - > stream = NULL ;
}
ch - > handlers - > read - > fp = NULL ;
ch - > handlers - > read - > fd = NULL ;
ch - > handlers - > read - > method = PHP_CURL_DIRECT ;
if ( ch - > handlers - > std_err ) {
zval_ptr_dtor ( & ch - > handlers - > std_err ) ;
ch - > handlers - > std_err = NULL ;
}
2011-12-03 23:43:44 +00:00
if ( ch - > handlers - > progress ) {
if ( ch - > handlers - > progress - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > progress - > func_name ) ;
}
efree ( ch - > handlers - > progress ) ;
ch - > handlers - > progress = NULL ;
2011-12-01 21:48:07 +00:00
}
2011-12-04 00:19:12 +00:00
# if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if ( ch - > handlers - > fnmatch ) {
if ( ch - > handlers - > fnmatch - > func_name ) {
zval_ptr_dtor ( & ch - > handlers - > fnmatch - > func_name ) ;
2011-12-23 21:01:05 +00:00
}
2011-12-04 00:19:12 +00:00
efree ( ch - > handlers - > fnmatch ) ;
ch - > handlers - > fnmatch = NULL ;
}
# endif
2011-12-01 21:48:07 +00:00
}
/* }}} */
/* {{{ proto void curl_reset(resource ch)
Reset all options of a libcurl session handle */
PHP_FUNCTION ( curl_reset )
{
zval * zid ;
php_curl * ch ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " r " , & zid ) = = FAILURE ) {
return ;
}
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
if ( ch - > in_callback ) {
php_error_docref ( NULL TSRMLS_CC , E_WARNING , " Attempt to reset cURL handle from a callback " ) ;
return ;
}
curl_easy_reset ( ch - > cp ) ;
_php_curl_reset_handlers ( ch ) ;
_php_curl_set_default_options ( ch ) ;
}
/* }}} */
# endif
# if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
/* {{{ proto void curl_escape(resource ch, string str)
URL encodes the given string */
PHP_FUNCTION ( curl_escape )
{
char * str = NULL , * res = NULL ;
int str_len = 0 ;
zval * zid ;
php_curl * ch ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " rs " , & zid , & str , & str_len ) = = FAILURE ) {
return ;
}
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2012-08-27 11:56:54 +00:00
if ( ( res = curl_easy_escape ( ch - > cp , str , str_len ) ) ) {
2011-12-01 21:48:07 +00:00
RETVAL_STRING ( res , 1 ) ;
free ( res ) ;
} else {
RETURN_FALSE ;
}
}
/* }}} */
/* {{{ proto void curl_unescape(resource ch, string str)
URL decodes the given string */
PHP_FUNCTION ( curl_unescape )
{
char * str = NULL , * out = NULL ;
int str_len = 0 , out_len ;
zval * zid ;
php_curl * ch ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , " rs " , & zid , & str , & str_len ) = = FAILURE ) {
return ;
}
ZEND_FETCH_RESOURCE ( ch , php_curl * , & zid , - 1 , le_curl_name , le_curl ) ;
2012-08-27 11:56:54 +00:00
if ( ( out = curl_easy_unescape ( ch - > cp , str , str_len , & out_len ) ) ) {
2011-12-01 21:48:07 +00:00
RETVAL_STRINGL ( out , out_len , 1 ) ;
free ( out ) ;
} else {
RETURN_FALSE ;
}
}
# endif
/* }}} */
2005-10-25 14:32:33 +00:00
# endif /* HAVE_CURL */
2001-06-05 13:12:10 +00:00
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* End :
2002-10-21 22:35:59 +00:00
* vim600 : fdm = marker
* vim : noet sw = 4 ts = 4
2001-06-05 13:12:10 +00:00
*/