- Fixed build on php-trunk
[m6w6/ext-http] / php_http.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2010, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 /* $Id$ */
14
15 #ifndef PHP_EXT_HTTP_H
16 #define PHP_EXT_HTTP_H
17
18 #define PHP_HTTP_VERSION "1.7.0"
19
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #else
23 # ifndef PHP_WIN32
24 # include "php_config.h"
25 # endif
26 #endif
27
28 #include "php.h"
29 #include "missing.h"
30 #include "php_http_std_defs.h"
31 #include "phpstr/phpstr.h"
32
33 #ifdef HTTP_WANT_SAPI
34 # if PHP_API_VERSION > 20041225
35 # define HTTP_HAVE_SAPI_RTIME
36 # endif
37 # include "SAPI.h"
38 #endif
39
40 #ifdef HTTP_WANT_NETDB
41 # ifdef PHP_WIN32
42 # define HTTP_HAVE_NETDB
43 # include <winsock2.h>
44 # elif defined(HAVE_NETDB_H)
45 # define HTTP_HAVE_NETDB
46 # include <netdb.h>
47 # ifdef HAVE_UNISTD_H
48 # include <unistd.h>
49 # endif
50 # endif
51 #endif
52
53 #if defined(HTTP_WANT_CURL) && defined(HTTP_HAVE_CURL)
54 # ifdef PHP_WIN32
55 # include <winsock2.h>
56 # define CURL_STATICLIB
57 # endif
58 # include <curl/curl.h>
59 # define HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z)))
60 #
61 # if defined(HTTP_WANT_EVENT) && defined(HTTP_HAVE_EVENT)
62 # include <event.h>
63 # endif
64 #endif
65
66 #if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
67 # if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
68 # define USE_MAGIC_STATIC
69 # endif
70 # include <magic.h>
71 #endif
72
73 #if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
74 # include <zlib.h>
75 #endif
76
77 #include <ctype.h>
78 #define HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
79 #define HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
80
81 extern zend_module_entry http_module_entry;
82 #define phpext_http_ptr &http_module_entry
83
84 extern int http_module_number;
85
86 ZEND_BEGIN_MODULE_GLOBALS(http)
87
88 struct _http_globals_etag {
89 char *mode;
90 void *ctx;
91 zend_bool started;
92 } etag;
93
94 struct _http_globals_log {
95 char *cache;
96 char *redirect;
97 char *not_found;
98 char *allowed_methods;
99 char *composite;
100 } log;
101
102 struct _http_globals_send {
103 double throttle_delay;
104 size_t buffer_size;
105 char *content_type;
106 char *unquoted_etag;
107 time_t last_modified;
108 struct _http_globals_send_deflate {
109 zend_bool response;
110 zend_bool start_auto;
111 long start_flags;
112 int encoding;
113 void *stream;
114 } deflate;
115 struct _http_globals_send_inflate {
116 zend_bool start_auto;
117 long start_flags;
118 void *stream;
119 } inflate;
120 zend_bool not_found_404;
121 } send;
122
123 struct _http_globals_request {
124 time_t time;
125 HashTable *headers;
126 struct _http_globals_request_methods {
127 HashTable registered;
128 char *allowed;
129 char *custom;
130 } methods;
131 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
132 struct _http_globals_request_datashare {
133 zend_llist handles;
134 zend_bool cookie;
135 zend_bool dns;
136 zend_bool ssl;
137 zend_bool connect;
138 } datashare;
139 #endif
140 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_EVENT)
141 struct _http_globals_request_pool {
142 struct _http_globals_request_pool_event {
143 void *base;
144 } event;
145 } pool;
146 #endif
147 } request;
148
149 struct _http_globals_persistent {
150 struct _http_globals_persistent_handles {
151 ulong limit;
152 struct _http_globals_persistent_handles_ident {
153 ulong h;
154 char *s;
155 size_t l;
156 } ident;
157 } handles;
158 } persistent;
159
160 #ifdef ZEND_ENGINE_2
161 zend_bool only_exceptions;
162 #endif
163
164 zend_bool force_exit;
165 zend_bool read_post_data;
166 zval *server_var;
167
168 ZEND_END_MODULE_GLOBALS(http)
169
170 ZEND_EXTERN_MODULE_GLOBALS(http);
171
172 #ifdef ZTS
173 # include "TSRM.h"
174 # define HTTP_G ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
175 #else
176 # define HTTP_G (&http_globals)
177 #endif
178
179 #if defined(HAVE_ICONV) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
180 # define HTTP_HAVE_ICONV
181 #endif
182
183 #if defined(HAVE_PHP_SESSION) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_SESSION))
184 # define HTTP_HAVE_SESSION
185 #endif
186
187 #if defined(HAVE_HASH_EXT) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(HTTP_HAVE_PHP_HASH_H)
188 # define HTTP_HAVE_HASH
189 #endif
190
191 #if defined(HAVE_SPL)
192 # define HTTP_HAVE_SPL
193 #endif
194
195 PHP_FUNCTION(http_date);
196 PHP_FUNCTION(http_build_url);
197 PHP_FUNCTION(http_build_str);
198 PHP_FUNCTION(http_negotiate_language);
199 PHP_FUNCTION(http_negotiate_charset);
200 PHP_FUNCTION(http_negotiate_content_type);
201 PHP_FUNCTION(http_redirect);
202 PHP_FUNCTION(http_throttle);
203 PHP_FUNCTION(http_send_status);
204 PHP_FUNCTION(http_send_last_modified);
205 PHP_FUNCTION(http_send_content_type);
206 PHP_FUNCTION(http_send_content_disposition);
207 PHP_FUNCTION(http_match_modified);
208 PHP_FUNCTION(http_match_etag);
209 PHP_FUNCTION(http_cache_last_modified);
210 PHP_FUNCTION(http_cache_etag);
211 PHP_FUNCTION(http_send_data);
212 PHP_FUNCTION(http_send_file);
213 PHP_FUNCTION(http_send_stream);
214 PHP_FUNCTION(http_chunked_decode);
215 PHP_FUNCTION(http_parse_message);
216 PHP_FUNCTION(http_parse_headers);
217 PHP_FUNCTION(http_parse_cookie);
218 PHP_FUNCTION(http_build_cookie);
219 PHP_FUNCTION(http_parse_params);
220 PHP_FUNCTION(http_get_request_headers);
221 PHP_FUNCTION(http_get_request_body);
222 PHP_FUNCTION(http_get_request_body_stream);
223 PHP_FUNCTION(http_match_request_header);
224 PHP_FUNCTION(http_persistent_handles_count);
225 PHP_FUNCTION(http_persistent_handles_clean);
226 PHP_FUNCTION(http_persistent_handles_ident);
227 #ifdef HTTP_HAVE_CURL
228 PHP_FUNCTION(http_get);
229 PHP_FUNCTION(http_head);
230 PHP_FUNCTION(http_post_data);
231 PHP_FUNCTION(http_post_fields);
232 PHP_FUNCTION(http_put_data);
233 PHP_FUNCTION(http_put_file);
234 PHP_FUNCTION(http_put_stream);
235 PHP_FUNCTION(http_request);
236 PHP_FUNCTION(http_request_body_encode);
237 #endif /* HTTP_HAVE_CURL */
238 PHP_FUNCTION(http_request_method_register);
239 PHP_FUNCTION(http_request_method_unregister);
240 PHP_FUNCTION(http_request_method_exists);
241 PHP_FUNCTION(http_request_method_name);
242 PHP_FUNCTION(ob_etaghandler);
243 #ifdef HTTP_HAVE_ZLIB
244 PHP_FUNCTION(http_deflate);
245 PHP_FUNCTION(http_inflate);
246 PHP_FUNCTION(ob_deflatehandler);
247 PHP_FUNCTION(ob_inflatehandler);
248 #endif
249 PHP_FUNCTION(http_support);
250
251 #endif /* PHP_HTTP_H */
252
253 /*
254 * Local variables:
255 * tab-width: 4
256 * c-basic-offset: 4
257 * End:
258 * vim600: noet sw=4 ts=4 fdm=marker
259 * vim<600: noet sw=4 ts=4
260 */
261