- CS
[m6w6/ext-http] / php_http_std_defs.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_HTTP_STD_DEFS_H
16 #define PHP_HTTP_STD_DEFS_H
17
18 #if defined(PHP_WIN32)
19 # if defined(HTTP_EXPORTS)
20 # define PHP_HTTP_API __declspec(dllexport)
21 # elif defined(COMPILE_DL_HTTP)
22 # define PHP_HTTP_API __declspec(dllimport)
23 # else
24 # define PHP_HTTP_API
25 # endif
26 #else
27 # define PHP_HTTP_API
28 #endif
29
30 /* make functions that return SUCCESS|FAILURE more obvious */
31 typedef int STATUS;
32
33 /* lenof() */
34 #define lenof(S) (sizeof(S) - 1)
35
36 #ifndef MIN
37 # define MIN(a,b) (a<b?a:b)
38 #endif
39 #ifndef MAX
40 # define MAX(a,b) (a>b?a:b)
41 #endif
42
43 /* STR_SET() */
44 #ifndef STR_SET
45 # define STR_SET(STR, SET) \
46 { \
47 STR_FREE(STR); \
48 STR = SET; \
49 }
50 #endif
51
52 #define INIT_ZARR(zv, ht) \
53 { \
54 INIT_PZVAL(&(zv)); \
55 Z_TYPE(zv) = IS_ARRAY; \
56 Z_ARRVAL(zv) = (ht); \
57 }
58
59 /* return bool (v == SUCCESS) */
60 #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v))
61 #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v))
62 /* return object(values) */
63 #define RETVAL_OBJECT(o, addref) \
64 RETVAL_OBJVAL((o)->value.obj, addref)
65 #define RETURN_OBJECT(o, addref) \
66 RETVAL_OBJECT(o, addref); \
67 return
68 #define RETVAL_OBJVAL(ov, addref) \
69 ZVAL_OBJVAL(return_value, ov, addref)
70 #define RETURN_OBJVAL(ov, addref) \
71 RETVAL_OBJVAL(ov, addref); \
72 return
73 #define ZVAL_OBJVAL(zv, ov, addref) \
74 (zv)->type = IS_OBJECT; \
75 (zv)->value.obj = (ov);\
76 if (addref && Z_OBJ_HT_P(zv)->add_ref) { \
77 Z_OBJ_HT_P(zv)->add_ref((zv) TSRMLS_CC); \
78 }
79 /* return property */
80 #define RETVAL_PROP(n) RETVAL_PROP_EX(getThis(), n)
81 #define RETURN_PROP(n) RETURN_PROP_EX(getThis(), n)
82 #define RETVAL_PROP_EX(this, n) \
83 { \
84 zval *__prop = GET_PROP_EX(this, n); \
85 RETVAL_ZVAL(__prop, 1, 0); \
86 }
87 #define RETURN_PROP_EX(this, n) \
88 { \
89 zval *__prop = GET_PROP_EX(this, n); \
90 RETURN_ZVAL(__prop, 1, 0); \
91 }
92
93 /* function accepts no args */
94 #define NO_ARGS \
95 if (ZEND_NUM_ARGS()) { \
96 zend_error(E_NOTICE, "Wrong parameter count for %s()", get_active_function_name(TSRMLS_C)); \
97 }
98
99 /* CR LF */
100 #define HTTP_CRLF "\r\n"
101
102 /* default cache control */
103 #define HTTP_DEFAULT_CACHECONTROL "private, must-revalidate, max-age=0"
104
105 /* max URL length */
106 #define HTTP_URL_MAXLEN 4096
107
108 /* def URL arg separator */
109 #define HTTP_URL_ARGSEP "&"
110
111 /* send buffer size */
112 #define HTTP_SENDBUF_SIZE 40960
113
114 /* CURL buffer size */
115 #define HTTP_CURLBUF_SIZE 16384
116
117 /* known methods */
118 #define HTTP_KNOWN_METHODS \
119 /* HTTP 1.1 */ \
120 "GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT, " \
121 /* WebDAV - RFC 2518 */ \
122 "PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, " \
123 /* WebDAV Versioning - RFC 3253 */ \
124 "VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, " \
125 "MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, " \
126 /* WebDAV Access Control - RFC 3744 */ \
127 "ACL, " \
128 /* END */
129
130 #ifdef ZEND_ENGINE_2
131 # include "ext/standard/file.h"
132 # define HTTP_DEFAULT_STREAM_CONTEXT FG(default_context)
133 #else
134 # define HTTP_DEFAULT_STREAM_CONTEXT NULL
135 #endif
136
137 #define HTTP_PHP_INI_ENTRY(entry, default, scope, updater, global) \
138 STD_PHP_INI_ENTRY(entry, default, scope, updater, global, zend_http_globals, http_globals)
139 #define HTTP_PHP_INI_ENTRY_EX(entry, default, scope, updater, displayer, global) \
140 STD_PHP_INI_ENTRY_EX(entry, default, scope, updater, global, zend_http_globals, http_globals, displayer)
141
142 /* {{{ arrays */
143 #define FOREACH_VAL(pos, array, val) FOREACH_HASH_VAL(pos, Z_ARRVAL_P(array), val)
144 #define FOREACH_HASH_VAL(pos, hash, val) \
145 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
146 zend_hash_get_current_data_ex(hash, (void *) &val, &pos) == SUCCESS; \
147 zend_hash_move_forward_ex(hash, &pos))
148
149 #define FOREACH_KEY(pos, array, strkey, numkey) FOREACH_HASH_KEY(pos, Z_ARRVAL_P(array), strkey, numkey)
150 #define FOREACH_HASH_KEY(pos, hash, strkey, numkey) \
151 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
152 zend_hash_get_current_key_ex(hash, &strkey, NULL, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT; \
153 zend_hash_move_forward_ex(hash, &pos)) \
154
155 #define FOREACH_KEYLEN(pos, array, strkey, keylen, numkey) FOREACH_HASH_KEYLEN(pos, Z_ARRVAL_P(array), strkey, keylen, numkey)
156 #define FOREACH_HASH_KEYLEN(pos, hash, strkey, keylen, numkey) \
157 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
158 zend_hash_get_current_key_ex(hash, &strkey, &keylen, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT; \
159 zend_hash_move_forward_ex(hash, &pos)) \
160
161 #define FOREACH_KEYVAL(pos, array, strkey, numkey, val) FOREACH_HASH_KEYVAL(pos, Z_ARRVAL_P(array), strkey, numkey, val)
162 #define FOREACH_HASH_KEYVAL(pos, hash, strkey, numkey, val) \
163 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
164 zend_hash_get_current_key_ex(hash, &strkey, NULL, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT && \
165 zend_hash_get_current_data_ex(hash, (void *) &val, &pos) == SUCCESS; \
166 zend_hash_move_forward_ex(hash, &pos))
167
168 #define FOREACH_KEYLENVAL(pos, array, strkey, keylen, numkey, val) FOREACH_HASH_KEYLENVAL(pos, Z_ARRVAL_P(array), strkey, keylen, numkey, val)
169 #define FOREACH_HASH_KEYLENVAL(pos, hash, strkey, keylen, numkey, val) \
170 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
171 zend_hash_get_current_key_ex(hash, &strkey, &keylen, &numkey, 0, &pos) != HASH_KEY_NON_EXISTANT && \
172 zend_hash_get_current_data_ex(hash, (void *) &val, &pos) == SUCCESS; \
173 zend_hash_move_forward_ex(hash, &pos))
174
175 #define array_copy(src, dst) zend_hash_copy(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *))
176 #define array_merge(src, dst) zend_hash_merge(Z_ARRVAL_P(dst), Z_ARRVAL_P(src), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *), 1)
177 #define array_append(src, dst) \
178 { \
179 ulong idx; \
180 uint klen; \
181 char *key = NULL; \
182 zval **data; \
183 HashPosition pos; \
184 \
185 for ( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(src), &pos); \
186 zend_hash_get_current_key_ex(Z_ARRVAL_P(src), &key, &klen, &idx, 0, &pos) != HASH_KEY_NON_EXISTANT && \
187 zend_hash_get_current_data_ex(Z_ARRVAL_P(src), (void *) &data, &pos) == SUCCESS; \
188 zend_hash_move_forward_ex(Z_ARRVAL_P(src), &pos)) \
189 { \
190 if (key) { \
191 zval **tmp; \
192 \
193 if (SUCCESS == zend_hash_find(Z_ARRVAL_P(dst), key, klen, (void *) &tmp)) { \
194 if (Z_TYPE_PP(tmp) != IS_ARRAY) { \
195 convert_to_array_ex(tmp); \
196 } \
197 ZVAL_ADDREF(*data); \
198 add_next_index_zval(*tmp, *data); \
199 } else { \
200 ZVAL_ADDREF(*data); \
201 add_assoc_zval(dst, key, *data); \
202 } \
203 key = NULL; \
204 } \
205 } \
206 }
207 /* }}} */
208
209 #define HTTP_LONG_CONSTANT(name, const) REGISTER_LONG_CONSTANT(name, const, CONST_CS | CONST_PERSISTENT)
210
211 /* {{{ objects & properties */
212 #ifdef ZEND_ENGINE_2
213
214 # define HTTP_STATIC_ME_ALIAS(me, al, ai) ZEND_FENTRY(me, ZEND_FN(al), ai, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
215
216 # define HTTP_REGISTER_CLASS_EX(classname, name, parent, flags) \
217 { \
218 zend_class_entry ce; \
219 memset(&ce, 0, sizeof(zend_class_entry)); \
220 INIT_CLASS_ENTRY(ce, #classname, name## _fe); \
221 ce.create_object = _ ##name## _new; \
222 name## _ce = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
223 name## _ce->ce_flags |= flags; \
224 memcpy(& name## _handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \
225 }
226
227 # define HTTP_REGISTER_CLASS(classname, name, parent, flags) \
228 { \
229 zend_class_entry ce; \
230 memset(&ce, 0, sizeof(zend_class_entry)); \
231 INIT_CLASS_ENTRY(ce, #classname, name## _fe); \
232 ce.create_object = NULL; \
233 name## _ce = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
234 name## _ce->ce_flags |= flags; \
235 }
236
237 # define HTTP_REGISTER_EXCEPTION(classname, cename, parent) \
238 { \
239 zend_class_entry ce; \
240 memset(&ce, 0, sizeof(zend_class_entry)); \
241 INIT_CLASS_ENTRY(ce, #classname, NULL); \
242 ce.create_object = NULL; \
243 cename = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
244 }
245
246 # define getObject(t, o) getObjectEx(t, o, getThis())
247 # define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC))
248 # define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) _ ##t## _free, NULL TSRMLS_CC);
249 # ifndef WONKY
250 # define freeObject(o) \
251 if (OBJ_GUARDS(o)) { \
252 zend_hash_destroy(OBJ_GUARDS(o)); \
253 FREE_HASHTABLE(OBJ_GUARDS(o)); \
254 } \
255 if (OBJ_PROP(o)) { \
256 zend_hash_destroy(OBJ_PROP(o)); \
257 FREE_HASHTABLE(OBJ_PROP(o)); \
258 } \
259 efree(o);
260 # else
261 # define freeObject(o) \
262 if (OBJ_PROP(o)) { \
263 zend_hash_destroy(OBJ_PROP(o)); \
264 FREE_HASHTABLE(OBJ_PROP(o)); \
265 } \
266 efree(o);
267 # endif
268 # define OBJ_PROP(o) (o)->zo.properties
269 # define OBJ_GUARDS(o) (o)->zo.guards
270
271 # define DCL_STATIC_PROP(a, t, n, v) zend_declare_property_ ##t(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
272 # define DCL_STATIC_PROP_Z(a, n, v) zend_declare_property(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
273 # define DCL_STATIC_PROP_N(a, n) zend_declare_property_null(OBJ_PROP_CE, (#n), sizeof(#n)-1, (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)
274 # define GET_STATIC_PROP_EX(ce, n) zend_std_get_static_property(ce, (#n), sizeof(#n)-1, 0 TSRMLS_CC)
275 # define UPD_STATIC_PROP_EX(ce, t, n, v) zend_update_static_property_ ##t(ce, #n, sizeof(#n)-1, (v) TSRMLS_CC)
276 # define UPD_STATIC_STRL_EX(ce, n, v, l) zend_update_static_property_stringl(ce, #n, sizeof(#n)-1, (v), (l) TSRMLS_CC)
277 # define SET_STATIC_PROP_EX(ce, n, v) zend_update_static_property(ce, #n, sizeof(#n)-1, v TSRMLS_CC)
278 # define GET_STATIC_PROP(n) *GET_STATIC_PROP_EX(OBJ_PROP_CE, n)
279 # define UPD_STATIC_PROP(t, n, v) UPD_STATIC_PROP_EX(OBJ_PROP_CE, t, n, v)
280 # define SET_STATIC_PROP(n, v) SET_STATIC_PROP_EX(OBJ_PROP_CE, n, v)
281 # define UPD_STATIC_STRL(n, v, l) UPD_STATIC_STRL_EX(OBJ_PROP_CE, n, v, l)
282
283 # define DCL_PROP(a, t, n, v) zend_declare_property_ ##t(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a) TSRMLS_CC)
284 # define DCL_PROP_Z(a, n, v) zend_declare_property(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a) TSRMLS_CC)
285 # define DCL_PROP_N(a, n) zend_declare_property_null(OBJ_PROP_CE, (#n), sizeof(#n)-1, (ZEND_ACC_ ##a) TSRMLS_CC)
286 # define UPD_PROP(t, n, v) UPD_PROP_EX(getThis(), t, n, v)
287 # define UPD_PROP_EX(this, t, n, v) zend_update_property_ ##t(OBJ_PROP_CE, this, (#n), sizeof(#n)-1, (v) TSRMLS_CC)
288 # define UPD_STRL(n, v, l) zend_update_property_stringl(OBJ_PROP_CE, getThis(), (#n), sizeof(#n)-1, (v), (l) TSRMLS_CC)
289 # define SET_PROP(n, z) SET_PROP_EX(getThis(), n, z)
290 # define SET_PROP_EX(this, n, z) zend_update_property(OBJ_PROP_CE, this, (#n), sizeof(#n)-1, (z) TSRMLS_CC)
291 # define GET_PROP(n) GET_PROP_EX(getThis(), n)
292 # define GET_PROP_EX(this, n) zend_read_property(OBJ_PROP_CE, this, (#n), sizeof(#n)-1, 0 TSRMLS_CC)
293
294 # define DCL_CONST(t, n, v) zend_declare_class_constant_ ##t(OBJ_PROP_CE, (n), sizeof(n)-1, (v) TSRMLS_CC)
295
296 # define ACC_PROP_PRIVATE(ce, flags) ((flags & ZEND_ACC_PRIVATE) && (EG(scope) && ce == EG(scope))
297 # define ACC_PROP_PROTECTED(ce, flags) ((flags & ZEND_ACC_PROTECTED) && (zend_check_protected(ce, EG(scope))))
298 # define ACC_PROP_PUBLIC(flags) (flags & ZEND_ACC_PUBLIC)
299 # define ACC_PROP(ce, flags) (ACC_PROP_PUBLIC(flags) || ACC_PROP_PRIVATE(ce, flags) || ACC_PROP_PROTECTED(ce, flags))
300
301 # define SET_EH_THROW() SET_EH_THROW_EX(zend_exception_get_default())
302 # define SET_EH_THROW_HTTP() SET_EH_THROW_EX(http_exception_get_default())
303 # define SET_EH_THROW_EX(ex) php_set_error_handling(EH_THROW, ex TSRMLS_CC)
304 # define SET_EH_NORMAL() php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC)
305
306 #endif /* ZEND_ENGINE_2 */
307 /* }}} */
308
309 #ifdef ZEND_ENGINE_2
310 # define with_error_handling(eh, ec) \
311 { \
312 error_handling_t __eh = PG(error_handling); \
313 zend_class_entry *__ec= PG(exception_class); \
314 php_set_error_handling(eh, ec TSRMLS_CC);
315 # define end_error_handling() \
316 php_set_error_handling(__eh, __ec TSRMLS_CC); \
317 }
318 #else
319 # define with_error_handling(eh, ec)
320 # define end_error_handling()
321 #endif
322
323 #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION > 5
324 # define ZEND_EXCEPTION_GET_DEFAULT() zend_exception_get_default(TSRMLS_C)
325 #else
326 # define ZEND_EXCEPTION_GET_DEFAULT() zend_exception_get_default()
327 #endif
328
329 #ifndef E_THROW
330 # define E_THROW 0
331 #endif
332 #ifdef ZEND_ENGINE_2
333 # define HE_THROW E_THROW TSRMLS_CC
334 # define HE_NOTICE (HTTP_G->only_exceptions ? E_THROW : E_NOTICE) TSRMLS_CC
335 # define HE_WARNING (HTTP_G->only_exceptions ? E_THROW : E_WARNING) TSRMLS_CC
336 # define HE_ERROR (HTTP_G->only_exceptions ? E_THROW : E_ERROR) TSRMLS_CC
337 #else
338 # define HE_THROW E_WARNING TSRMLS_CC
339 # define HE_NOTICE E_NOTICE TSRMLS_CC
340 # define HE_WARNING E_WARNING TSRMLS_CC
341 # define HE_ERROR E_ERROR TSRMLS_CC
342 #endif
343
344 #define HTTP_E_RUNTIME 1L
345 #define HTTP_E_INVALID_PARAM 2L
346 #define HTTP_E_HEADER 3L
347 #define HTTP_E_MALFORMED_HEADERS 4L
348 #define HTTP_E_REQUEST_METHOD 5L
349 #define HTTP_E_MESSAGE_TYPE 6L
350 #define HTTP_E_ENCODING 7L
351 #define HTTP_E_REQUEST 8L
352 #define HTTP_E_REQUEST_POOL 9L
353 #define HTTP_E_SOCKET 10L
354 #define HTTP_E_RESPONSE 11L
355 #define HTTP_E_URL 12L
356 #define HTTP_E_QUERYSTRING 13L
357
358 #ifdef ZEND_ENGINE_2
359 # define HTTP_BEGIN_ARGS_EX(class, method, ret_ref, req_args) static ZEND_BEGIN_ARG_INFO_EX(args_for_ ##class## _ ##method , 0, ret_ref, req_args)
360 # define HTTP_BEGIN_ARGS_AR(class, method, ret_ref, req_args) static ZEND_BEGIN_ARG_INFO_EX(args_for_ ##class## _ ##method , 1, ret_ref, req_args)
361 # define HTTP_END_ARGS }
362 # define HTTP_EMPTY_ARGS_EX(class, method, ret_ref) HTTP_BEGIN_ARGS_EX(class, method, ret_ref, 0) HTTP_END_ARGS
363 # define HTTP_ARGS(class, method) args_for_ ##class## _ ##method
364 # define HTTP_ARG_VAL(name, pass_ref) ZEND_ARG_INFO(pass_ref, name)
365 # define HTTP_ARG_OBJ(class, name, allow_null) ZEND_ARG_OBJ_INFO(0, name, class, allow_null)
366 #endif
367
368 #ifdef ZEND_ENGINE_2
369 # define EMPTY_FUNCTION_ENTRY {NULL, NULL, NULL, 0, 0}
370 #else
371 # define EMPTY_FUNCTION_ENTRY {NULL, NULL, NULL}
372 #endif
373
374 #ifdef HTTP_HAVE_CURL
375 # ifdef ZEND_ENGINE_2
376 # define HTTP_DECLARE_ARG_PASS_INFO() \
377 static \
378 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
379 ZEND_ARG_PASS_INFO(0) \
380 ZEND_ARG_PASS_INFO(1) \
381 ZEND_END_ARG_INFO(); \
382 \
383 static \
384 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
385 ZEND_ARG_PASS_INFO(0) \
386 ZEND_ARG_PASS_INFO(0) \
387 ZEND_ARG_PASS_INFO(1) \
388 ZEND_END_ARG_INFO(); \
389 \
390 static \
391 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
392 ZEND_ARG_PASS_INFO(0) \
393 ZEND_ARG_PASS_INFO(0) \
394 ZEND_ARG_PASS_INFO(0) \
395 ZEND_ARG_PASS_INFO(1) \
396 ZEND_END_ARG_INFO(); \
397 \
398 static \
399 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_5, 0) \
400 ZEND_ARG_PASS_INFO(0) \
401 ZEND_ARG_PASS_INFO(0) \
402 ZEND_ARG_PASS_INFO(0) \
403 ZEND_ARG_PASS_INFO(0) \
404 ZEND_ARG_PASS_INFO(1) \
405 ZEND_END_ARG_INFO();
406
407 # else
408 # define HTTP_DECLARE_ARG_PASS_INFO() \
409 static unsigned char http_arg_pass_ref_2[] = {2, BYREF_NONE, BYREF_FORCE}; \
410 static unsigned char http_arg_pass_ref_3[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE}; \
411 static unsigned char http_arg_pass_ref_4[] = {4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE}; \
412 static unsigned char http_arg_pass_ref_5[] = {5, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE};
413 # endif /* ZEND_ENGINE_2 */
414 #else
415 # ifdef ZEND_ENGINE_2
416 # define HTTP_DECLARE_ARG_PASS_INFO() \
417 static \
418 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
419 ZEND_ARG_PASS_INFO(0) \
420 ZEND_ARG_PASS_INFO(1) \
421 ZEND_END_ARG_INFO(); \
422 \
423 static \
424 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
425 ZEND_ARG_PASS_INFO(0) \
426 ZEND_ARG_PASS_INFO(0) \
427 ZEND_ARG_PASS_INFO(0) \
428 ZEND_ARG_PASS_INFO(1) \
429 ZEND_END_ARG_INFO();
430 # else
431 # define HTTP_DECLARE_ARG_PASS_INFO() \
432 static unsigned char http_arg_pass_ref_2[] = {2, BYREF_NONE, BYREF_FORCE}; \
433 static unsigned char http_arg_pass_ref_4[] = {4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE};
434 # endif /* ZEND_ENGINE_2 */
435 #endif /* HTTP_HAVE_CURL */
436
437
438 #ifndef TSRMLS_FETCH_FROM_CTX
439 # ifdef ZTS
440 # define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx
441 # else
442 # define TSRMLS_FETCH_FROM_CTX(ctx)
443 # endif
444 #endif
445
446 #ifndef TSRMLS_SET_CTX
447 # ifdef ZTS
448 # define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls
449 # else
450 # define TSRMLS_SET_CTX(ctx)
451 # endif
452 #endif
453
454 #ifndef ZVAL_ZVAL
455 #define ZVAL_ZVAL(z, zv, copy, dtor) { \
456 int is_ref, refcount; \
457 is_ref = (z)->is_ref; \
458 refcount = (z)->refcount; \
459 *(z) = *(zv); \
460 if (copy) { \
461 zval_copy_ctor(z); \
462 } \
463 if (dtor) { \
464 if (!copy) { \
465 ZVAL_NULL(zv); \
466 } \
467 zval_ptr_dtor(&zv); \
468 } \
469 (z)->is_ref = is_ref; \
470 (z)->refcount = refcount; \
471 }
472 #endif
473 #ifndef RETVAL_ZVAL
474 #define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
475 #endif
476 #ifndef RETURN_ZVAL
477 #define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
478 #endif
479
480 #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
481 #define PHP_RINIT_CALL(func) PHP_RINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
482 #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
483 #define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
484
485 #define Z_OBJ_DELREF(z) \
486 if (Z_OBJ_HT(z)->del_ref) { \
487 Z_OBJ_HT(z)->del_ref(&(z) TSRMLS_CC); \
488 }
489 #define Z_OBJ_ADDREF(z) \
490 if (Z_OBJ_HT(z)->add_ref) { \
491 Z_OBJ_HT(z)->add_ref(&(z) TSRMLS_CC); \
492 }
493 #define Z_OBJ_DELREF_P(z) \
494 if (Z_OBJ_HT_P(z)->del_ref) { \
495 Z_OBJ_HT_P(z)->del_ref((z) TSRMLS_CC); \
496 }
497 #define Z_OBJ_ADDREF_P(z) \
498 if (Z_OBJ_HT_P(z)->add_ref) { \
499 Z_OBJ_HT_P(z)->add_ref((z) TSRMLS_CC); \
500 }
501 #define Z_OBJ_DELREF_PP(z) \
502 if (Z_OBJ_HT_PP(z)->del_ref) { \
503 Z_OBJ_HT_PP(z)->del_ref(*(z) TSRMLS_CC); \
504 }
505 #define Z_OBJ_ADDREF_PP(z) \
506 if (Z_OBJ_HT_PP(z)->add_ref) { \
507 Z_OBJ_HT_PP(z)->add_ref(*(z) TSRMLS_CC); \
508 }
509
510 #endif /* PHP_HTTP_STD_DEFS_H */
511
512 /*
513 * Local variables:
514 * tab-width: 4
515 * c-basic-offset: 4
516 * End:
517 * vim600: noet sw=4 ts=4 fdm=marker
518 * vim<600: noet sw=4 ts=4
519 */
520