2000-07-17 03:37:33 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-09 01:33:29 +08:00
|
|
|
| PHP Version 5 |
|
2000-07-17 03:37:33 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2014-01-03 11:06:16 +08:00
|
|
|
| Copyright (c) 1997-2014 The PHP Group |
|
2000-07-17 03:37:33 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-07-17 03:37:33 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-07-17 03:37:33 +08: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 |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2001-02-16 00:20:13 +08:00
|
|
|
| Author: Sterling Hughes <sterling@php.net> |
|
2002-11-14 06:25:33 +08:00
|
|
|
| Wez Furlong <wez@thebrainroom.com> |
|
2000-07-17 03:37:33 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef _PHP_CURL_H
|
|
|
|
#define _PHP_CURL_H
|
|
|
|
|
2001-04-30 22:36:19 +08:00
|
|
|
#include "php.h"
|
|
|
|
#include "ext/standard/php_smart_str.h"
|
|
|
|
|
2000-07-17 03:37:33 +08:00
|
|
|
#ifdef COMPILE_DL_CURL
|
|
|
|
#undef HAVE_CURL
|
|
|
|
#define HAVE_CURL 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_CURL
|
|
|
|
|
2002-11-14 06:25:33 +08:00
|
|
|
#define PHP_CURL_DEBUG 0
|
2000-08-28 06:53:33 +08:00
|
|
|
|
2013-01-29 14:22:59 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
# define PHP_CURL_API __declspec(dllexport)
|
|
|
|
#elif defined(__GNUC__) && __GNUC__ >= 4
|
|
|
|
# define PHP_CURL_API __attribute__ ((visibility("default")))
|
|
|
|
#else
|
|
|
|
# define PHP_CURL_API
|
|
|
|
#endif
|
|
|
|
|
2002-11-14 06:25:33 +08:00
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <curl/multi.h>
|
2001-04-30 22:36:19 +08:00
|
|
|
|
2000-07-17 03:37:33 +08:00
|
|
|
extern zend_module_entry curl_module_entry;
|
|
|
|
#define curl_module_ptr &curl_module_entry
|
|
|
|
|
2000-09-30 11:09:54 +08:00
|
|
|
#define CURLOPT_RETURNTRANSFER 19913
|
2011-11-23 01:13:26 +08:00
|
|
|
#define CURLOPT_BINARYTRANSFER 19914 /* For Backward compatibility */
|
2002-11-14 06:25:33 +08:00
|
|
|
#define PHP_CURL_STDOUT 0
|
|
|
|
#define PHP_CURL_FILE 1
|
|
|
|
#define PHP_CURL_USER 2
|
|
|
|
#define PHP_CURL_DIRECT 3
|
|
|
|
#define PHP_CURL_RETURN 4
|
|
|
|
#define PHP_CURL_IGNORE 7
|
|
|
|
|
2005-07-16 00:47:48 +08:00
|
|
|
extern int le_curl;
|
2002-11-14 06:25:33 +08:00
|
|
|
#define le_curl_name "cURL handle"
|
2005-07-16 00:47:48 +08:00
|
|
|
extern int le_curl_multi_handle;
|
2002-11-14 06:25:33 +08:00
|
|
|
#define le_curl_multi_handle_name "cURL Multi Handle"
|
2011-12-02 05:48:07 +08:00
|
|
|
extern int le_curl_share_handle;
|
|
|
|
#define le_curl_share_handle_name "cURL Share Handle"
|
2000-09-30 11:09:54 +08:00
|
|
|
|
2000-08-14 03:32:09 +08:00
|
|
|
PHP_MINIT_FUNCTION(curl);
|
2001-09-23 00:56:21 +08:00
|
|
|
PHP_MSHUTDOWN_FUNCTION(curl);
|
2000-08-14 03:32:09 +08:00
|
|
|
PHP_MINFO_FUNCTION(curl);
|
2012-12-24 03:05:04 +08:00
|
|
|
|
|
|
|
PHP_FUNCTION(curl_close);
|
2004-03-13 02:37:55 +08:00
|
|
|
PHP_FUNCTION(curl_copy_handle);
|
2012-12-24 03:05:04 +08:00
|
|
|
PHP_FUNCTION(curl_errno);
|
|
|
|
PHP_FUNCTION(curl_error);
|
2000-08-14 03:32:09 +08:00
|
|
|
PHP_FUNCTION(curl_exec);
|
2000-10-20 12:57:14 +08:00
|
|
|
PHP_FUNCTION(curl_getinfo);
|
2012-12-24 03:05:04 +08:00
|
|
|
PHP_FUNCTION(curl_init);
|
|
|
|
PHP_FUNCTION(curl_setopt);
|
|
|
|
PHP_FUNCTION(curl_setopt_array);
|
|
|
|
PHP_FUNCTION(curl_version);
|
2011-12-02 05:48:07 +08:00
|
|
|
|
2002-11-14 06:25:33 +08:00
|
|
|
PHP_FUNCTION(curl_multi_add_handle);
|
2012-12-24 03:05:04 +08:00
|
|
|
PHP_FUNCTION(curl_multi_close);
|
2002-11-14 06:25:33 +08:00
|
|
|
PHP_FUNCTION(curl_multi_exec);
|
|
|
|
PHP_FUNCTION(curl_multi_getcontent);
|
|
|
|
PHP_FUNCTION(curl_multi_info_read);
|
2012-12-24 03:05:04 +08:00
|
|
|
PHP_FUNCTION(curl_multi_init);
|
|
|
|
PHP_FUNCTION(curl_multi_remove_handle);
|
|
|
|
PHP_FUNCTION(curl_multi_select);
|
|
|
|
|
2011-12-02 05:48:07 +08:00
|
|
|
PHP_FUNCTION(curl_share_close);
|
2012-12-24 03:05:04 +08:00
|
|
|
PHP_FUNCTION(curl_share_init);
|
2011-12-02 05:48:07 +08:00
|
|
|
PHP_FUNCTION(curl_share_setopt);
|
|
|
|
|
2012-12-24 04:45:39 +08:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
|
|
|
|
PHP_FUNCTION(curl_strerror);
|
|
|
|
PHP_FUNCTION(curl_multi_strerror);
|
|
|
|
#endif
|
|
|
|
|
2011-12-02 05:48:07 +08:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
|
|
|
|
PHP_FUNCTION(curl_reset);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
|
|
|
|
PHP_FUNCTION(curl_escape);
|
|
|
|
PHP_FUNCTION(curl_unescape);
|
2012-12-24 03:59:41 +08:00
|
|
|
|
|
|
|
PHP_FUNCTION(curl_multi_setopt);
|
2011-12-02 05:48:07 +08:00
|
|
|
#endif
|
|
|
|
|
2012-12-24 06:13:49 +08:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */
|
|
|
|
PHP_FUNCTION(curl_pause);
|
|
|
|
#endif
|
2013-01-29 14:22:59 +08:00
|
|
|
PHP_FUNCTION(curl_file_create);
|
|
|
|
|
2012-12-24 06:13:49 +08:00
|
|
|
|
2003-06-20 07:13:28 +08:00
|
|
|
void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
|
2011-12-02 05:48:07 +08:00
|
|
|
void _php_curl_share_close(zend_rsrc_list_entry * TSRMLS_DC);
|
2000-07-17 03:37:33 +08:00
|
|
|
|
2000-08-28 06:53:33 +08:00
|
|
|
typedef struct {
|
2003-08-05 18:29:03 +08:00
|
|
|
zval *func_name;
|
2003-08-06 07:50:59 +08:00
|
|
|
zend_fcall_info_cache fci_cache;
|
2003-08-05 18:29:03 +08:00
|
|
|
FILE *fp;
|
|
|
|
smart_str buf;
|
|
|
|
int method;
|
2009-09-30 10:34:17 +08:00
|
|
|
zval *stream;
|
2001-04-30 22:36:19 +08:00
|
|
|
} php_curl_write;
|
|
|
|
|
|
|
|
typedef struct {
|
2003-08-05 18:29:03 +08:00
|
|
|
zval *func_name;
|
2003-08-06 07:50:59 +08:00
|
|
|
zend_fcall_info_cache fci_cache;
|
2003-08-05 18:29:03 +08:00
|
|
|
FILE *fp;
|
|
|
|
long fd;
|
|
|
|
int method;
|
2009-09-30 10:34:17 +08:00
|
|
|
zval *stream;
|
2001-04-30 22:36:19 +08:00
|
|
|
} php_curl_read;
|
|
|
|
|
2009-05-03 22:59:46 +08:00
|
|
|
typedef struct {
|
|
|
|
zval *func_name;
|
|
|
|
zend_fcall_info_cache fci_cache;
|
|
|
|
int method;
|
2011-12-04 08:19:12 +08:00
|
|
|
} php_curl_progress, php_curl_fnmatch;
|
2009-05-03 22:59:46 +08:00
|
|
|
|
2001-04-30 22:36:19 +08:00
|
|
|
typedef struct {
|
2001-05-04 12:20:38 +08:00
|
|
|
php_curl_write *write;
|
2001-06-25 23:14:20 +08:00
|
|
|
php_curl_write *write_header;
|
2001-05-04 12:20:38 +08:00
|
|
|
php_curl_read *read;
|
2013-01-02 10:12:02 +08:00
|
|
|
#if CURLOPT_PASSWDFUNCTION != 0
|
2001-05-04 12:20:38 +08:00
|
|
|
zval *passwd;
|
2013-01-02 10:12:02 +08:00
|
|
|
#endif
|
2009-05-28 06:35:26 +08:00
|
|
|
zval *std_err;
|
2009-05-03 22:59:46 +08:00
|
|
|
php_curl_progress *progress;
|
2011-12-04 08:19:12 +08:00
|
|
|
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
|
|
|
|
php_curl_fnmatch *fnmatch;
|
|
|
|
#endif
|
2001-04-30 22:36:19 +08:00
|
|
|
} php_curl_handlers;
|
|
|
|
|
|
|
|
struct _php_curl_error {
|
|
|
|
char str[CURL_ERROR_SIZE + 1];
|
|
|
|
int no;
|
|
|
|
};
|
|
|
|
|
2006-01-25 04:11:14 +08:00
|
|
|
struct _php_curl_send_headers {
|
|
|
|
char *str;
|
|
|
|
size_t str_len;
|
|
|
|
};
|
|
|
|
|
2001-04-30 22:36:19 +08:00
|
|
|
struct _php_curl_free {
|
|
|
|
zend_llist str;
|
|
|
|
zend_llist post;
|
2013-08-20 02:58:57 +08:00
|
|
|
HashTable *slist;
|
2001-04-30 22:36:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
struct _php_curl_error err;
|
2011-11-22 13:19:37 +08:00
|
|
|
struct _php_curl_free *to_free;
|
2006-01-25 04:11:14 +08:00
|
|
|
struct _php_curl_send_headers header;
|
2003-04-28 06:15:19 +08:00
|
|
|
void ***thread_ctx;
|
2002-11-14 06:25:33 +08:00
|
|
|
CURL *cp;
|
|
|
|
php_curl_handlers *handlers;
|
2001-04-30 22:36:19 +08:00
|
|
|
long id;
|
2005-06-03 05:04:12 +08:00
|
|
|
zend_bool in_callback;
|
2009-07-22 04:32:32 +08:00
|
|
|
zval *clone;
|
2013-01-29 14:22:59 +08:00
|
|
|
zend_bool safe_upload;
|
2000-08-28 06:53:33 +08:00
|
|
|
} php_curl;
|
2000-08-17 10:14:41 +08:00
|
|
|
|
2013-01-29 14:22:59 +08:00
|
|
|
#define CURLOPT_SAFE_UPLOAD -1
|
|
|
|
|
2002-11-14 06:25:33 +08:00
|
|
|
typedef struct {
|
|
|
|
int still_running;
|
|
|
|
CURLM *multi;
|
2004-03-11 08:11:18 +08:00
|
|
|
zend_llist easyh;
|
2002-11-14 06:25:33 +08:00
|
|
|
} php_curlm;
|
|
|
|
|
2011-12-02 05:48:07 +08:00
|
|
|
typedef struct {
|
|
|
|
CURLSH *share;
|
|
|
|
} php_curlsh;
|
|
|
|
|
2002-11-14 06:25:33 +08:00
|
|
|
void _php_curl_cleanup_handle(php_curl *);
|
2006-10-05 23:06:40 +08:00
|
|
|
void _php_curl_multi_cleanup_list(void *data);
|
2013-11-18 12:06:27 +08:00
|
|
|
void _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC);
|
2002-11-14 06:25:33 +08:00
|
|
|
|
2013-01-29 14:22:59 +08:00
|
|
|
void curlfile_register_class(TSRMLS_D);
|
|
|
|
PHP_CURL_API extern zend_class_entry *curl_CURLFile_class;
|
2000-10-20 12:57:14 +08:00
|
|
|
|
2000-07-17 03:37:33 +08:00
|
|
|
#else
|
|
|
|
#define curl_module_ptr NULL
|
|
|
|
#endif /* HAVE_CURL */
|
|
|
|
#define phpext_curl_ptr curl_module_ptr
|
2000-07-26 06:15:26 +08:00
|
|
|
#endif /* _PHP_CURL_H */
|