root/ext/curl/php_curl.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 7                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 3.01 of the PHP license,      |
   8    | that is bundled with this package in the file LICENSE, and is        |
   9    | available through the world-wide-web at the following url:           |
  10    | http://www.php.net/license/3_01.txt                                  |
  11    | If you did not receive a copy of the PHP license and are unable to   |
  12    | obtain it through the world-wide-web, please send a note to          |
  13    | license@php.net so we can mail you a copy immediately.               |
  14    +----------------------------------------------------------------------+
  15    | Author: Sterling Hughes <sterling@php.net>                           |
  16    |         Wez Furlong <wez@thebrainroom.com>                           |
  17    +----------------------------------------------------------------------+
  18 */
  19 
  20 /* $Id$ */
  21 
  22 #ifndef _PHP_CURL_H
  23 #define _PHP_CURL_H
  24 
  25 #include "php.h"
  26 #include "zend_smart_str.h"
  27 
  28 #ifdef COMPILE_DL_CURL
  29 #undef HAVE_CURL
  30 #define HAVE_CURL 1
  31 #endif
  32 
  33 #if HAVE_CURL
  34 
  35 #define PHP_CURL_DEBUG 0
  36 
  37 #ifdef PHP_WIN32
  38 # define PHP_CURL_API __declspec(dllexport)
  39 #elif defined(__GNUC__) && __GNUC__ >= 4
  40 # define PHP_CURL_API __attribute__ ((visibility("default")))
  41 #else
  42 # define PHP_CURL_API
  43 #endif
  44 
  45 #include "php_version.h"
  46 #define PHP_CURL_VERSION PHP_VERSION
  47 
  48 #include <curl/curl.h>
  49 #include <curl/multi.h>
  50 
  51 extern zend_module_entry curl_module_entry;
  52 #define curl_module_ptr &curl_module_entry
  53 
  54 #define CURLOPT_RETURNTRANSFER 19913
  55 #define CURLOPT_BINARYTRANSFER 19914 /* For Backward compatibility */
  56 #define PHP_CURL_STDOUT 0
  57 #define PHP_CURL_FILE   1
  58 #define PHP_CURL_USER   2
  59 #define PHP_CURL_DIRECT 3
  60 #define PHP_CURL_RETURN 4
  61 #define PHP_CURL_IGNORE 7
  62 
  63 extern int  le_curl;
  64 #define le_curl_name "cURL handle"
  65 extern int  le_curl_multi_handle;
  66 #define le_curl_multi_handle_name "cURL Multi Handle"
  67 extern int  le_curl_share_handle;
  68 #define le_curl_share_handle_name "cURL Share Handle"
  69 
  70 PHP_MINIT_FUNCTION(curl);
  71 PHP_MSHUTDOWN_FUNCTION(curl);
  72 PHP_MINFO_FUNCTION(curl);
  73 
  74 PHP_FUNCTION(curl_close);
  75 PHP_FUNCTION(curl_copy_handle);
  76 PHP_FUNCTION(curl_errno);
  77 PHP_FUNCTION(curl_error);
  78 PHP_FUNCTION(curl_exec);
  79 PHP_FUNCTION(curl_getinfo);
  80 PHP_FUNCTION(curl_init);
  81 PHP_FUNCTION(curl_setopt);
  82 PHP_FUNCTION(curl_setopt_array);
  83 PHP_FUNCTION(curl_version);
  84 
  85 PHP_FUNCTION(curl_multi_add_handle);
  86 PHP_FUNCTION(curl_multi_close);
  87 PHP_FUNCTION(curl_multi_exec);
  88 PHP_FUNCTION(curl_multi_getcontent);
  89 PHP_FUNCTION(curl_multi_info_read);
  90 PHP_FUNCTION(curl_multi_init);
  91 PHP_FUNCTION(curl_multi_remove_handle);
  92 PHP_FUNCTION(curl_multi_select);
  93 
  94 PHP_FUNCTION(curl_share_close);
  95 PHP_FUNCTION(curl_share_init);
  96 PHP_FUNCTION(curl_share_setopt);
  97 
  98 #if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
  99 PHP_FUNCTION(curl_strerror);
 100 PHP_FUNCTION(curl_multi_strerror);
 101 #endif
 102 
 103 #if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
 104 PHP_FUNCTION(curl_reset);
 105 #endif
 106 
 107 #if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
 108 PHP_FUNCTION(curl_escape);
 109 PHP_FUNCTION(curl_unescape);
 110 
 111 PHP_FUNCTION(curl_multi_setopt);
 112 #endif
 113 
 114 #if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */
 115 PHP_FUNCTION(curl_pause);
 116 #endif
 117 PHP_FUNCTION(curl_file_create);
 118 
 119 
 120 void _php_curl_multi_close(zend_resource *);
 121 void _php_curl_share_close(zend_resource *);
 122 
 123 typedef struct {
 124         zval                  func_name;
 125         zend_fcall_info_cache fci_cache;
 126         FILE                 *fp;
 127         smart_str             buf;
 128         int                   method;
 129         zval                                    stream;
 130 } php_curl_write;
 131 
 132 typedef struct {
 133         zval                  func_name;
 134         zend_fcall_info_cache fci_cache;
 135         FILE                 *fp;
 136         zend_resource        *res;
 137         int                   method;
 138         zval                  stream;
 139 } php_curl_read;
 140 
 141 typedef struct {
 142         zval                  func_name;
 143         zend_fcall_info_cache fci_cache;
 144         int                   method;
 145 } php_curl_progress, php_curl_fnmatch;
 146 
 147 typedef struct {
 148         php_curl_write    *write;
 149         php_curl_write    *write_header;
 150         php_curl_read     *read;
 151 #if CURLOPT_PASSWDFUNCTION != 0
 152         zval               passwd;
 153 #endif
 154         zval               std_err;
 155         php_curl_progress *progress;
 156 #if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
 157         php_curl_fnmatch  *fnmatch;
 158 #endif
 159 } php_curl_handlers;
 160 
 161 struct _php_curl_error  {
 162         char str[CURL_ERROR_SIZE + 1];
 163         int  no;
 164 };
 165 
 166 struct _php_curl_send_headers {
 167         zend_string *str;
 168 };
 169 
 170 struct _php_curl_free {
 171         zend_llist str;
 172         zend_llist post;
 173         HashTable *slist;
 174 };
 175 
 176 typedef struct {
 177         CURL                         *cp;
 178         php_curl_handlers            *handlers;
 179         zend_resource                *res;
 180         struct _php_curl_free        *to_free;
 181         struct _php_curl_send_headers header;
 182         struct _php_curl_error        err;
 183         zend_bool                     in_callback;
 184         uint32_t*                     clone;
 185 } php_curl;
 186 
 187 #define CURLOPT_SAFE_UPLOAD -1
 188 
 189 typedef struct {
 190         int         still_running;
 191         CURLM      *multi;
 192         zend_llist  easyh;
 193 } php_curlm;
 194 
 195 typedef struct {
 196         CURLSH                   *share;
 197 } php_curlsh;
 198 
 199 void _php_curl_cleanup_handle(php_curl *);
 200 void _php_curl_multi_cleanup_list(void *data);
 201 void _php_curl_verify_handlers(php_curl *ch, int reporterror);
 202 
 203 void curlfile_register_class(void);
 204 PHP_CURL_API extern zend_class_entry *curl_CURLFile_class;
 205 
 206 #else
 207 #define curl_module_ptr NULL
 208 #endif /* HAVE_CURL */
 209 #define phpext_curl_ptr curl_module_ptr
 210 #endif  /* _PHP_CURL_H */

/* [<][>][^][v][top][bottom][index][help] */