|
| 1 | +/* |
| 2 | + +----------------------------------------------------------------------+ |
| 3 | + | Copyright (c) The PHP Group | |
| 4 | + +----------------------------------------------------------------------+ |
| 5 | + | This source file is subject to version 3.01 of the PHP license, | |
| 6 | + | that is bundled with this package in the file LICENSE, and is | |
| 7 | + | available through the world-wide-web at the following url: | |
| 8 | + | http://www.php.net/license/3_01.txt | |
| 9 | + | If you did not receive a copy of the PHP license and are unable to | |
| 10 | + | obtain it through the world-wide-web, please send a note to | |
| 11 | + | license@php.net so we can mail you a copy immediately. | |
| 12 | + +----------------------------------------------------------------------+ |
| 13 | + | Author: Sterling Hughes <sterling@php.net> | |
| 14 | + | Wez Furlong <wez@thebrainroom.com> | |
| 15 | + +----------------------------------------------------------------------+ |
| 16 | +*/ |
| 17 | + |
| 18 | +#ifndef _PHP_CURL_PRIVATE_H |
| 19 | +#define _PHP_CURL_PRIVATE_H |
| 20 | + |
| 21 | +#include "php_curl.h" |
| 22 | + |
| 23 | +#define PHP_CURL_DEBUG 0 |
| 24 | + |
| 25 | +#include "php_version.h" |
| 26 | +#define PHP_CURL_VERSION PHP_VERSION |
| 27 | + |
| 28 | +#include <curl/curl.h> |
| 29 | +#include <curl/multi.h> |
| 30 | + |
| 31 | +#define CURLOPT_RETURNTRANSFER 19913 |
| 32 | +#define CURLOPT_BINARYTRANSFER 19914 /* For Backward compatibility */ |
| 33 | +#define PHP_CURL_STDOUT 0 |
| 34 | +#define PHP_CURL_FILE 1 |
| 35 | +#define PHP_CURL_USER 2 |
| 36 | +#define PHP_CURL_DIRECT 3 |
| 37 | +#define PHP_CURL_RETURN 4 |
| 38 | +#define PHP_CURL_IGNORE 7 |
| 39 | + |
| 40 | +#define SAVE_CURL_ERROR(__handle, __err) \ |
| 41 | + do { (__handle)->err.no = (int) __err; } while (0) |
| 42 | + |
| 43 | +PHP_MINIT_FUNCTION(curl); |
| 44 | +PHP_MSHUTDOWN_FUNCTION(curl); |
| 45 | +PHP_MINFO_FUNCTION(curl); |
| 46 | + |
| 47 | +typedef struct { |
| 48 | + zval func_name; |
| 49 | + zend_fcall_info_cache fci_cache; |
| 50 | + FILE *fp; |
| 51 | + smart_str buf; |
| 52 | + int method; |
| 53 | + zval stream; |
| 54 | +} php_curl_write; |
| 55 | + |
| 56 | +typedef struct { |
| 57 | + zval func_name; |
| 58 | + zend_fcall_info_cache fci_cache; |
| 59 | + FILE *fp; |
| 60 | + zend_resource *res; |
| 61 | + int method; |
| 62 | + zval stream; |
| 63 | +} php_curl_read; |
| 64 | + |
| 65 | +typedef struct { |
| 66 | + zval func_name; |
| 67 | + zend_fcall_info_cache fci_cache; |
| 68 | + int method; |
| 69 | +} php_curl_progress, php_curl_fnmatch, php_curlm_server_push; |
| 70 | + |
| 71 | +typedef struct { |
| 72 | + php_curl_write *write; |
| 73 | + php_curl_write *write_header; |
| 74 | + php_curl_read *read; |
| 75 | + zval std_err; |
| 76 | + php_curl_progress *progress; |
| 77 | +#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ |
| 78 | + php_curl_fnmatch *fnmatch; |
| 79 | +#endif |
| 80 | +} php_curl_handlers; |
| 81 | + |
| 82 | +struct _php_curl_error { |
| 83 | + char str[CURL_ERROR_SIZE + 1]; |
| 84 | + int no; |
| 85 | +}; |
| 86 | + |
| 87 | +struct _php_curl_send_headers { |
| 88 | + zend_string *str; |
| 89 | +}; |
| 90 | + |
| 91 | +struct _php_curl_free { |
| 92 | + zend_llist str; |
| 93 | + zend_llist post; |
| 94 | + zend_llist stream; |
| 95 | + HashTable *slist; |
| 96 | +}; |
| 97 | + |
| 98 | +typedef struct { |
| 99 | + CURL *cp; |
| 100 | + php_curl_handlers *handlers; |
| 101 | + struct _php_curl_free *to_free; |
| 102 | + struct _php_curl_send_headers header; |
| 103 | + struct _php_curl_error err; |
| 104 | + zend_bool in_callback; |
| 105 | + uint32_t* clone; |
| 106 | + zval postfields; |
| 107 | + zend_object std; |
| 108 | +} php_curl; |
| 109 | + |
| 110 | +#define CURLOPT_SAFE_UPLOAD -1 |
| 111 | + |
| 112 | +typedef struct { |
| 113 | + php_curlm_server_push *server_push; |
| 114 | +} php_curlm_handlers; |
| 115 | + |
| 116 | +typedef struct { |
| 117 | + int still_running; |
| 118 | + CURLM *multi; |
| 119 | + zend_llist easyh; |
| 120 | + php_curlm_handlers *handlers; |
| 121 | + struct { |
| 122 | + int no; |
| 123 | + } err; |
| 124 | + zend_object std; |
| 125 | +} php_curlm; |
| 126 | + |
| 127 | +typedef struct { |
| 128 | + CURLSH *share; |
| 129 | + struct { |
| 130 | + int no; |
| 131 | + } err; |
| 132 | + zend_object std; |
| 133 | +} php_curlsh; |
| 134 | + |
| 135 | +php_curl *init_curl_handle_into_zval(zval *curl); |
| 136 | +void init_curl_handle(php_curl *ch); |
| 137 | +void _php_curl_cleanup_handle(php_curl *); |
| 138 | +void _php_curl_multi_cleanup_list(void *data); |
| 139 | +void _php_curl_verify_handlers(php_curl *ch, int reporterror); |
| 140 | +void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source); |
| 141 | + |
| 142 | +static inline php_curl *curl_from_obj(zend_object *obj) { |
| 143 | + return (php_curl *)((char *)(obj) - XtOffsetOf(php_curl, std)); |
| 144 | +} |
| 145 | + |
| 146 | +#define Z_CURL_P(zv) curl_from_obj(Z_OBJ_P(zv)) |
| 147 | + |
| 148 | +static inline php_curlsh *curl_share_from_obj(zend_object *obj) { |
| 149 | + return (php_curlsh *)((char *)(obj) - XtOffsetOf(php_curlsh, std)); |
| 150 | +} |
| 151 | + |
| 152 | +#define Z_CURL_SHARE_P(zv) curl_share_from_obj(Z_OBJ_P(zv)) |
| 153 | + |
| 154 | +void curl_multi_register_class(const zend_function_entry *method_entries); |
| 155 | +void curl_share_register_class(const zend_function_entry *method_entries); |
| 156 | +void curlfile_register_class(void); |
| 157 | +int curl_cast_object(zend_object *obj, zval *result, int type); |
| 158 | + |
| 159 | +#endif /* _PHP_CURL_PRIVATE_H */ |
0 commit comments