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