- (non-)ZTS fixes
[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-2006, 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_EXT_HTTP_VERSION "1.3.0dev"
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 #endif
61
62 #if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
63 # if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
64 # define USE_MAGIC_STATIC
65 # endif
66 # include <magic.h>
67 #endif
68
69 #if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
70 # include <zlib.h>
71 #endif
72
73 #include <ctype.h>
74
75 extern zend_module_entry http_module_entry;
76 #define phpext_http_ptr &http_module_entry
77
78 extern int http_module_number;
79
80 ZEND_BEGIN_MODULE_GLOBALS(http)
81
82 struct _http_globals_etag {
83 char *mode;
84 void *ctx;
85 zend_bool started;
86 } etag;
87
88 struct _http_globals_log {
89 char *cache;
90 char *redirect;
91 char *not_found;
92 char *allowed_methods;
93 char *composite;
94 } log;
95
96 struct _http_globals_send {
97 double throttle_delay;
98 size_t buffer_size;
99 char *content_type;
100 char *unquoted_etag;
101 time_t last_modified;
102 struct _http_globals_send_deflate {
103 zend_bool start_auto;
104 long start_flags;
105 int encoding;
106 void *stream;
107 } deflate;
108 struct _http_globals_send_inflate {
109 zend_bool start_auto;
110 long start_flags;
111 void *stream;
112 } inflate;
113 zend_bool not_found_404;
114 } send;
115
116 struct _http_globals_request {
117 time_t time;
118 struct _http_globals_request_methods {
119 char *allowed;
120 struct _http_globals_request_methods_custom {
121 char *ini;
122 int count;
123 void *entries;
124 } custom;
125 } methods;
126 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
127 struct _http_globals_request_datashare {
128 zend_llist handles;
129 zend_bool cookie;
130 zend_bool dns;
131 zend_bool ssl;
132 zend_bool connect;
133 } datashare;
134 #endif
135 } request;
136
137 #ifdef ZEND_ENGINE_2
138 zend_bool only_exceptions;
139 #endif
140
141 zend_bool force_exit;
142 zend_bool read_post_data;
143
144 ZEND_END_MODULE_GLOBALS(http)
145
146 ZEND_EXTERN_MODULE_GLOBALS(http);
147
148 #ifdef ZTS
149 # include "TSRM.h"
150 # define HTTP_G ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
151 #else
152 # define HTTP_G (&http_globals)
153 #endif
154
155 #if defined(HAVE_ICONV) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
156 # define HTTP_HAVE_ICONV
157 #endif
158
159 #if defined(HAVE_PHP_SESSION) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_SESSION))
160 # define HTTP_HAVE_SESSION
161 #endif
162
163 #if defined(HAVE_HASH_EXT) && (HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(HTTP_HAVE_PHP_HASH_H)
164 # define HTTP_HAVE_HASH
165 #endif
166
167 #if defined(HAVE_SPL)
168 # define HTTP_HAVE_SPL
169 #endif
170
171 PHP_FUNCTION(http_test);
172 PHP_FUNCTION(http_date);
173 PHP_FUNCTION(http_build_url);
174 PHP_FUNCTION(http_build_str);
175 PHP_FUNCTION(http_negotiate_language);
176 PHP_FUNCTION(http_negotiate_charset);
177 PHP_FUNCTION(http_negotiate_content_type);
178 PHP_FUNCTION(http_redirect);
179 PHP_FUNCTION(http_throttle);
180 PHP_FUNCTION(http_send_status);
181 PHP_FUNCTION(http_send_last_modified);
182 PHP_FUNCTION(http_send_content_type);
183 PHP_FUNCTION(http_send_content_disposition);
184 PHP_FUNCTION(http_match_modified);
185 PHP_FUNCTION(http_match_etag);
186 PHP_FUNCTION(http_cache_last_modified);
187 PHP_FUNCTION(http_cache_etag);
188 PHP_FUNCTION(http_send_data);
189 PHP_FUNCTION(http_send_file);
190 PHP_FUNCTION(http_send_stream);
191 PHP_FUNCTION(http_chunked_decode);
192 PHP_FUNCTION(http_parse_message);
193 PHP_FUNCTION(http_parse_headers);
194 PHP_FUNCTION(http_parse_cookie);
195 PHP_FUNCTION(http_build_cookie);
196 PHP_FUNCTION(http_parse_params);
197 PHP_FUNCTION(http_get_request_headers);
198 PHP_FUNCTION(http_get_request_body);
199 PHP_FUNCTION(http_get_request_body_stream);
200 PHP_FUNCTION(http_match_request_header);
201 #ifdef HTTP_HAVE_CURL
202 PHP_FUNCTION(http_get);
203 PHP_FUNCTION(http_head);
204 PHP_FUNCTION(http_post_data);
205 PHP_FUNCTION(http_post_fields);
206 PHP_FUNCTION(http_put_data);
207 PHP_FUNCTION(http_put_file);
208 PHP_FUNCTION(http_put_stream);
209 PHP_FUNCTION(http_request);
210 PHP_FUNCTION(http_request_body_encode);
211 #endif /* HTTP_HAVE_CURL */
212 PHP_FUNCTION(http_request_method_register);
213 PHP_FUNCTION(http_request_method_unregister);
214 PHP_FUNCTION(http_request_method_exists);
215 PHP_FUNCTION(http_request_method_name);
216 PHP_FUNCTION(ob_etaghandler);
217 #ifdef HTTP_HAVE_ZLIB
218 PHP_FUNCTION(http_deflate);
219 PHP_FUNCTION(http_inflate);
220 PHP_FUNCTION(ob_deflatehandler);
221 PHP_FUNCTION(ob_inflatehandler);
222 #endif
223 PHP_FUNCTION(http_support);
224
225 #endif /* PHP_HTTP_H */
226
227 /*
228 * Local variables:
229 * tab-width: 4
230 * c-basic-offset: 4
231 * End:
232 * vim600: noet sw=4 ts=4 fdm=marker
233 * vim<600: noet sw=4 ts=4
234 */
235