3c98bd0cda94d31fd1e522641e58462be1c23833
[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 "0.22.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 "php_http_std_defs.h"
30 #include "phpstr/phpstr.h"
31 #include "missing.h"
32
33 #ifdef HTTP_WANT_SAPI
34 # if PHP_API_VERSION > 20041225
35 # define HTTP_HAVE_SAPI_RTIME
36 # define HTTP_GET_REQUEST_TIME() sapi_get_request_time(TSRMLS_C)
37 # else
38 # define HTTP_GET_REQUEST_TIME() HTTP_G(request_time)
39 # endif
40 # include "SAPI.h"
41 #endif
42
43 #ifdef HTTP_WANT_NETDB
44 # ifdef PHP_WIN32
45 # define HTTP_HAVE_NETDB
46 # include <winsock2.h>
47 # elif defined(HAVE_NETDB_H)
48 # define HTTP_HAVE_NETDB
49 # include <netdb.h>
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 #endif
60
61 #if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)
62 # if defined(PHP_WIN32) && !defined(USE_MAGIC_DLL) && !defined(USE_MAGIC_STATIC)
63 # define USE_MAGIC_STATIC
64 # endif
65 # include <magic.h>
66 #endif
67
68 #if defined(HTTP_WANT_ZLIB) && defined(HTTP_HAVE_ZLIB)
69 # include <zlib.h>
70 #endif
71
72 #include <ctype.h>
73
74 extern zend_module_entry http_module_entry;
75 #define phpext_http_ptr &http_module_entry
76
77 extern int http_module_number;
78
79 ZEND_BEGIN_MODULE_GLOBALS(http)
80
81 struct _http_globals_etag {
82 char *mode;
83 void *ctx;
84 zend_bool started;
85 } etag;
86
87 struct _http_globals_log {
88 char *cache;
89 char *redirect;
90 char *allowed_methods;
91 char *composite;
92 } log;
93
94 struct _http_globals_send {
95 double throttle_delay;
96 size_t buffer_size;
97 char *content_type;
98 char *unquoted_etag;
99 time_t last_modified;
100 struct _http_globals_send_deflate {
101 zend_bool start_auto;
102 long start_flags;
103 int encoding;
104 void *stream;
105 } deflate;
106 struct _http_globals_send_inflate {
107 zend_bool start_auto;
108 long start_flags;
109 void *stream;
110 } inflate;
111 } send;
112
113 struct _http_globals_request {
114 struct _http_globals_request_methods {
115 char *allowed;
116 struct _http_globals_request_methods_custom {
117 int count;
118 void *entries;
119 } custom;
120 } methods;
121 } request;
122
123 #ifndef HTTP_HAVE_SAPI_RTIME
124 time_t request_time;
125 #endif
126 #ifdef ZEND_ENGINE_2
127 zend_bool only_exceptions;
128 #endif
129
130 zend_bool force_exit;
131 zend_bool read_post_data;
132
133 ZEND_END_MODULE_GLOBALS(http)
134
135 ZEND_EXTERN_MODULE_GLOBALS(http);
136
137 #ifdef ZTS
138 # include "TSRM.h"
139 # define HTTP_G(v) TSRMG(http_globals_id, zend_http_globals *, v)
140 # define HTTP_GLOBALS ((zend_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(http_globals_id)])
141 #else
142 # define HTTP_G(v) (http_globals.v)
143 # define HTTP_GLOBALS (&http_globals)
144 #endif
145 #define getGlobals(G) zend_http_globals *G = HTTP_GLOBALS
146
147 PHP_FUNCTION(http_test);
148 PHP_FUNCTION(http_date);
149 PHP_FUNCTION(http_build_url);
150 PHP_FUNCTION(http_negotiate_language);
151 PHP_FUNCTION(http_negotiate_charset);
152 PHP_FUNCTION(http_negotiate_content_type);
153 PHP_FUNCTION(http_redirect);
154 PHP_FUNCTION(http_throttle);
155 PHP_FUNCTION(http_send_status);
156 PHP_FUNCTION(http_send_last_modified);
157 PHP_FUNCTION(http_send_content_type);
158 PHP_FUNCTION(http_send_content_disposition);
159 PHP_FUNCTION(http_match_modified);
160 PHP_FUNCTION(http_match_etag);
161 PHP_FUNCTION(http_cache_last_modified);
162 PHP_FUNCTION(http_cache_etag);
163 PHP_FUNCTION(http_send_data);
164 PHP_FUNCTION(http_send_file);
165 PHP_FUNCTION(http_send_stream);
166 PHP_FUNCTION(http_chunked_decode);
167 PHP_FUNCTION(http_parse_message);
168 PHP_FUNCTION(http_parse_headers);
169 PHP_FUNCTION(http_parse_cookie);
170 PHP_FUNCTION(http_get_request_headers);
171 PHP_FUNCTION(http_get_request_body);
172 PHP_FUNCTION(http_get_request_body_stream);
173 PHP_FUNCTION(http_match_request_header);
174 #ifdef HTTP_HAVE_CURL
175 PHP_FUNCTION(http_get);
176 PHP_FUNCTION(http_head);
177 PHP_FUNCTION(http_post_data);
178 PHP_FUNCTION(http_post_fields);
179 PHP_FUNCTION(http_put_file);
180 PHP_FUNCTION(http_put_stream);
181 #endif /* HTTP_HAVE_CURL */
182 PHP_FUNCTION(http_request_method_register);
183 PHP_FUNCTION(http_request_method_unregister);
184 PHP_FUNCTION(http_request_method_exists);
185 PHP_FUNCTION(http_request_method_name);
186 #ifndef ZEND_ENGINE_2
187 PHP_FUNCTION(http_build_query);
188 #endif /* ZEND_ENGINE_2 */
189 PHP_FUNCTION(ob_etaghandler);
190 #ifdef HTTP_HAVE_ZLIB
191 PHP_FUNCTION(http_deflate);
192 PHP_FUNCTION(http_inflate);
193 PHP_FUNCTION(ob_deflatehandler);
194 PHP_FUNCTION(ob_inflatehandler);
195 #endif
196 PHP_FUNCTION(http_support);
197
198 PHP_MINIT_FUNCTION(http);
199 PHP_MSHUTDOWN_FUNCTION(http);
200 PHP_RINIT_FUNCTION(http);
201 PHP_RSHUTDOWN_FUNCTION(http);
202 PHP_MINFO_FUNCTION(http);
203
204 #endif /* PHP_HTTP_H */
205
206 /*
207 * Local variables:
208 * tab-width: 4
209 * c-basic-offset: 4
210 * End:
211 * vim600: noet sw=4 ts=4 fdm=marker
212 * vim<600: noet sw=4 ts=4
213 */
214