Back to index

php5  5.3.10
php_curl.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Author: Sterling Hughes <sterling@php.net>                           |
00016    |         Wez Furlong <wez@thebrainroom.com>                           |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: php_curl.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef _PHP_CURL_H
00023 #define _PHP_CURL_H
00024 
00025 #include "php.h"
00026 #include "ext/standard/php_smart_str.h"
00027 
00028 #ifdef COMPILE_DL_CURL
00029 #undef HAVE_CURL
00030 #define HAVE_CURL 1
00031 #endif
00032 
00033 #if HAVE_CURL
00034 
00035 #define PHP_CURL_DEBUG 0
00036 
00037 #include <curl/curl.h>
00038 #include <curl/multi.h>
00039 
00040 extern zend_module_entry curl_module_entry;
00041 #define curl_module_ptr &curl_module_entry
00042 
00043 #define CURLOPT_RETURNTRANSFER 19913
00044 #define CURLOPT_BINARYTRANSFER 19914
00045 #define PHP_CURL_STDOUT 0
00046 #define PHP_CURL_FILE   1
00047 #define PHP_CURL_USER   2
00048 #define PHP_CURL_DIRECT 3
00049 #define PHP_CURL_RETURN 4
00050 #define PHP_CURL_ASCII  5
00051 #define PHP_CURL_BINARY 6
00052 #define PHP_CURL_IGNORE 7
00053 
00054 extern int  le_curl;
00055 #define le_curl_name "cURL handle"
00056 extern int  le_curl_multi_handle;
00057 #define le_curl_multi_handle_name "cURL Multi Handle"
00058 
00059 PHP_MINIT_FUNCTION(curl);
00060 PHP_MSHUTDOWN_FUNCTION(curl);
00061 PHP_MINFO_FUNCTION(curl);
00062 PHP_FUNCTION(curl_version);
00063 PHP_FUNCTION(curl_init);
00064 PHP_FUNCTION(curl_copy_handle);
00065 PHP_FUNCTION(curl_setopt);
00066 PHP_FUNCTION(curl_setopt_array);
00067 PHP_FUNCTION(curl_exec);
00068 PHP_FUNCTION(curl_getinfo);
00069 PHP_FUNCTION(curl_error);
00070 PHP_FUNCTION(curl_errno);
00071 PHP_FUNCTION(curl_close);
00072 PHP_FUNCTION(curl_multi_init);
00073 PHP_FUNCTION(curl_multi_add_handle);
00074 PHP_FUNCTION(curl_multi_remove_handle);
00075 PHP_FUNCTION(curl_multi_select);
00076 PHP_FUNCTION(curl_multi_exec);
00077 PHP_FUNCTION(curl_multi_getcontent);
00078 PHP_FUNCTION(curl_multi_info_read);
00079 PHP_FUNCTION(curl_multi_close);
00080 void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
00081 
00082 typedef struct {
00083        zval            *func_name;
00084        zend_fcall_info_cache fci_cache;
00085        FILE            *fp;
00086        smart_str       buf;
00087        int             method;
00088        int             type;
00089        zval          *stream;
00090 } php_curl_write;
00091 
00092 typedef struct {
00093        zval            *func_name;
00094        zend_fcall_info_cache fci_cache;
00095        FILE            *fp;
00096        long            fd;
00097        int             method;
00098        zval          *stream;
00099 } php_curl_read;
00100 
00101 typedef struct {
00102        zval          *func_name;
00103        zend_fcall_info_cache fci_cache;
00104        int                   method;
00105 } php_curl_progress;
00106 
00107 typedef struct {
00108        php_curl_write *write;
00109        php_curl_write *write_header;
00110        php_curl_read  *read;
00111        zval           *passwd;
00112        zval           *std_err;
00113        php_curl_progress *progress;
00114 } php_curl_handlers;
00115 
00116 struct _php_curl_error  {
00117        char str[CURL_ERROR_SIZE + 1];
00118        int  no;
00119 };
00120 
00121 struct _php_curl_send_headers {
00122        char *str;
00123        size_t str_len;
00124 };
00125 
00126 struct _php_curl_free {
00127        zend_llist str;
00128        zend_llist post;
00129        zend_llist slist;
00130 };
00131 
00132 typedef struct {
00133        struct _php_curl_error   err;
00134        struct _php_curl_free    *to_free;
00135        struct _php_curl_send_headers header;
00136        void ***thread_ctx;
00137        CURL                    *cp;
00138        php_curl_handlers       *handlers;
00139        long                     id;
00140        unsigned int             uses;
00141        zend_bool                in_callback;
00142        zval                     *clone;
00143 } php_curl;
00144 
00145 typedef struct {
00146        int    still_running;
00147        CURLM *multi;
00148        zend_llist easyh;
00149 } php_curlm;
00150 
00151 void _php_curl_cleanup_handle(php_curl *);
00152 void _php_curl_multi_cleanup_list(void *data);
00153 int  _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC);
00154 
00155 /* streams support */
00156 
00157 extern php_stream_ops php_curl_stream_ops;
00158 #define PHP_STREAM_IS_CURL  &php_curl_stream_ops
00159 
00160 php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename, char *mode,
00161               int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
00162 
00163 extern php_stream_wrapper php_curl_wrapper;
00164 
00165 struct php_curl_buffer {
00166        off_t readpos, writepos;
00167        php_stream *buf;
00168 };
00169 
00170 typedef struct {
00171        CURL   *curl;
00172        CURLM  *multi;
00173        char *url;
00174        struct php_curl_buffer readbuffer; /* holds downloaded data */
00175        struct php_curl_buffer writebuffer; /* holds data to upload */
00176 
00177        fd_set readfds, writefds, excfds;
00178        int maxfd;
00179        
00180        char errstr[CURL_ERROR_SIZE + 1];
00181        CURLMcode mcode;
00182        int pending;
00183        zval *headers;
00184 } php_curl_stream;
00185 
00186 
00187 #else
00188 #define curl_module_ptr NULL
00189 #endif /* HAVE_CURL */
00190 #define phpext_curl_ptr curl_module_ptr
00191 #endif  /* _PHP_CURL_H */