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