change array_list API
[m6w6/ext-http] / php_http_misc.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-2011, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13 #ifndef PHP_HTTP_MISC_H
14 #define PHP_HTTP_MISC_H
15
16 /* DEFAULTS */
17
18 /* DATE FORMAT RFC1123 */
19 #define PHP_HTTP_DATE_FORMAT "D, d M Y H:i:s \\G\\M\\T"
20
21 /* CR LF */
22 #define PHP_HTTP_CRLF "\r\n"
23
24 /* default cache control */
25 #define PHP_HTTP_DEFAULT_CACHECONTROL "private, must-revalidate, max-age=0"
26
27 /* max URL length */
28 #define PHP_HTTP_URL_MAXLEN 4096
29
30 /* max request method length */
31 #define PHP_HTTP_REQUEST_METHOD_MAXLEN 31
32
33 /* def URL arg separator */
34 #define PHP_HTTP_URL_ARGSEP "&"
35
36 /* send buffer size */
37 #define PHP_HTTP_SENDBUF_SIZE 40960
38
39 /* CURL buffer size */
40 #define PHP_HTTP_CURLBUF_SIZE 16384
41
42 /* SLEEP */
43
44 #define PHP_HTTP_DIFFSEC (0.001)
45 #define PHP_HTTP_MLLISEC (1000)
46 #define PHP_HTTP_MCROSEC (1000 * 1000)
47 #define PHP_HTTP_NANOSEC (1000 * 1000 * 1000)
48 #define PHP_HTTP_MSEC(s) ((long)(s * PHP_HTTP_MLLISEC))
49 #define PHP_HTTP_USEC(s) ((long)(s * PHP_HTTP_MCROSEC))
50 #define PHP_HTTP_NSEC(s) ((long)(s * PHP_HTTP_NANOSEC))
51
52 PHP_HTTP_API void php_http_sleep(double s);
53
54 /* STRING UTILITIES */
55
56 #define PHP_HTTP_CHECK_CONTENT_TYPE(ct, action) \
57 if (!strchr((ct), '/')) { \
58 php_http_error(HE_WARNING, PHP_HTTP_E_INVALID_PARAM, \
59 "Content type \"%s\" does not seem to contain a primary and a secondary part", (ct)); \
60 action; \
61 }
62
63
64 #ifndef STR_SET
65 # define STR_SET(STR, SET) \
66 { \
67 STR_FREE(STR); \
68 STR = SET; \
69 }
70 #endif
71
72 #define STR_PTR(s) (s?s:"")
73
74 #define lenof(S) (sizeof(S) - 1)
75
76 #define PHP_HTTP_MATCH_LOOSE 0
77 #define PHP_HTTP_MATCH_CASE 0x01
78 #define PHP_HTTP_MATCH_WORD 0x10
79 #define PHP_HTTP_MATCH_FULL 0x20
80 #define PHP_HTTP_MATCH_STRICT (PHP_HTTP_MATCH_CASE|PHP_HTTP_MATCH_FULL)
81
82 int php_http_match(const char *haystack, const char *needle, int flags);
83 char *php_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
84 size_t php_http_boundary(char *buf, size_t len TSRMLS_DC);
85 int php_http_select_str(const char *cmp, int argc, ...);
86
87 static inline const char *php_http_locate_str(const char *h, size_t h_len, const char *n, size_t n_len)
88 {
89 const char *p, *e;
90
91 if (n_len && h_len) {
92 e = h + h_len;
93 do {
94 if (*h == *n) {
95 for (p = n; *p == h[p-n]; ++p) {
96 if (p == n+n_len-1) {
97 return h;
98 }
99 }
100 }
101 } while (h++ != e);
102 }
103
104 return NULL;
105 }
106
107 static inline const char *php_http_locate_body(const char *message)
108 {
109 const char *body = NULL, *msg = message;
110
111 while (*msg) {
112 if (*msg == '\n') {
113 if (*(msg+1) == '\n') {
114 body = msg + 2;
115 break;
116 } else if (*(msg+1) == '\r' && *(msg+2) == '\n') {
117 body = msg + 3;
118 break;
119 }
120 }
121 ++msg;
122 }
123 return body;
124 }
125
126 static inline const char *php_http_locate_eol(const char *line, int *eol_len)
127 {
128 const char *eol = strpbrk(line, "\r\n");
129
130 if (eol_len) {
131 *eol_len = eol ? ((eol[0] == '\r' && eol[1] == '\n') ? 2 : 1) : 0;
132 }
133 return eol;
134 }
135
136 static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, int *eol_len)
137 {
138 const char *eol;
139
140 for (eol = bin; eol - bin <= len; ++eol) {
141 if (*eol == '\r' || *eol == '\n') {
142 if (eol_len) {
143 *eol_len = ((eol[0] == '\r' && eol[1] == '\n') ? 2 : 1);
144 }
145 return eol;
146 }
147 }
148
149 return NULL;
150 }
151
152 /* ZEND */
153
154 #if PHP_VERSION_ID < 50400
155 # define object_properties_init(o, ce) zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*))
156 # define PHP_HTTP_ZEND_LITERAL_DC
157 # define PHP_HTTP_ZEND_LITERAL_CC
158 # define PHP_HTTP_ZEND_LITERAL_CCN
159 # define ZVAL_COPY_VALUE(zv, arr) do { \
160 (zv)->value = (arr)->value; \
161 Z_TYPE_P(zv) = Z_TYPE_P(arr); \
162 } while (0)
163 #else
164 # define PHP_HTTP_ZEND_LITERAL_DC , const zend_literal *literal_key
165 # define PHP_HTTP_ZEND_LITERAL_CC , (literal_key)
166 # define PHP_HTTP_ZEND_LITERAL_CCN , NULL
167 #endif
168
169 #define INIT_PZVAL_ARRAY(zv, ht) \
170 { \
171 INIT_PZVAL((zv)); \
172 Z_TYPE_P(zv) = IS_ARRAY; \
173 Z_ARRVAL_P(zv) = (ht); \
174 }
175
176 static inline zval *php_http_ztyp(int type, zval *z)
177 {
178 SEPARATE_ARG_IF_REF(z);
179 if (Z_TYPE_P(z) != type) {
180 switch (type) {
181 case IS_NULL: convert_to_null_ex(&z); break;
182 case IS_BOOL: convert_to_boolean_ex(&z); break;
183 case IS_LONG: convert_to_long_ex(&z); break;
184 case IS_DOUBLE: convert_to_double_ex(&z); break;
185 case IS_STRING: convert_to_string_ex(&z); break;
186 case IS_ARRAY: convert_to_array_ex(&z); break;
187 case IS_OBJECT: convert_to_object_ex(&z); break;
188 }
189 }
190 return z;
191 }
192
193 static inline zval *php_http_zsep(zend_bool add_ref, int type, zval *z)
194 {
195 if (add_ref) {
196 Z_ADDREF_P(z);
197 }
198 if (Z_TYPE_P(z) != type) {
199 switch (type) {
200 case IS_NULL: convert_to_null_ex(&z); break;
201 case IS_BOOL: convert_to_boolean_ex(&z); break;
202 case IS_LONG: convert_to_long_ex(&z); break;
203 case IS_DOUBLE: convert_to_double_ex(&z); break;
204 case IS_STRING: convert_to_string_ex(&z); break;
205 case IS_ARRAY: convert_to_array_ex(&z); break;
206 case IS_OBJECT: convert_to_object_ex(&z); break;
207 }
208 } else {
209 SEPARATE_ZVAL_IF_NOT_REF(&z);
210 }
211 return z;
212 }
213
214 static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, const char **value_str, size_t *value_len, zend_bool orig TSRMLS_DC)
215 {
216 zend_ini_entry *ini_entry;
217
218 if (SUCCESS == zend_hash_find(EG(ini_directives), name_str, name_len + 1, (void *) &ini_entry)) {
219 if (orig && ini_entry->modified) {
220 *value_str = ini_entry->orig_value;
221 *value_len = (size_t) ini_entry->orig_value_length;
222 } else {
223 *value_str = ini_entry->value;
224 *value_len = (size_t) ini_entry->value_length;
225 }
226 return SUCCESS;
227 }
228 return FAILURE;
229 }
230
231 /* return bool (v == SUCCESS) */
232 #define RETVAL_SUCCESS(v) RETVAL_BOOL(SUCCESS == (v))
233 #define RETURN_SUCCESS(v) RETURN_BOOL(SUCCESS == (v))
234 /* return object(values) */
235 #define RETVAL_OBJECT(o, addref) \
236 RETVAL_OBJVAL((o)->value.obj, addref)
237 #define RETURN_OBJECT(o, addref) \
238 RETVAL_OBJECT(o, addref); \
239 return
240 #define RETVAL_OBJVAL(ov, addref) \
241 ZVAL_OBJVAL(return_value, ov, addref)
242 #define RETURN_OBJVAL(ov, addref) \
243 RETVAL_OBJVAL(ov, addref); \
244 return
245 #define ZVAL_OBJVAL(zv, ov, addref) \
246 (zv)->type = IS_OBJECT; \
247 (zv)->value.obj = (ov);\
248 if (addref && Z_OBJ_HT_P(zv)->add_ref) { \
249 Z_OBJ_HT_P(zv)->add_ref((zv) TSRMLS_CC); \
250 }
251 /* return property */
252 #define RETVAL_PROP(CE, n) RETVAL_PROP_EX(CE, getThis(), n)
253 #define RETURN_PROP(CE, n) RETURN_PROP_EX(CE, getThis(), n)
254 #define RETVAL_PROP_EX(CE, this, n) \
255 { \
256 zval *__prop = zend_read_property(CE, this, ZEND_STRL(n), 0 TSRMLS_CC); \
257 RETVAL_ZVAL(__prop, 1, 0); \
258 }
259 #define RETURN_PROP_EX(CE, this, n) \
260 { \
261 zval *__prop = zend_read_property(CE, this, ZEND_STRL(n), 0 TSRMLS_CC); \
262 RETURN_ZVAL(__prop, 1, 0); \
263 }
264 #define RETVAL_SPROP(CE, n) \
265 { \
266 zval *__prop = zend_read_static_property(CE, ZEND_STRL(n), 0 TSRMLS_CC); \
267 RETVAL_ZVAL(__prop, 1, 0); \
268 }
269 #define RETURN_SPROP(CE, n) \
270 { \
271 zval *__prop = zend_read_static_property(CE, ZEND_STRL(n), 0 TSRMLS_CC); \
272 RETURN_ZVAL(__prop, 1, 0); \
273 }
274
275 #define Z_OBJ_DELREF(z) \
276 if (Z_OBJ_HT(z)->del_ref) { \
277 Z_OBJ_HT(z)->del_ref(&(z) TSRMLS_CC); \
278 }
279 #define Z_OBJ_ADDREF(z) \
280 if (Z_OBJ_HT(z)->add_ref) { \
281 Z_OBJ_HT(z)->add_ref(&(z) TSRMLS_CC); \
282 }
283 #define Z_OBJ_DELREF_P(z) \
284 if (Z_OBJ_HT_P(z)->del_ref) { \
285 Z_OBJ_HT_P(z)->del_ref((z) TSRMLS_CC); \
286 }
287 #define Z_OBJ_ADDREF_P(z) \
288 if (Z_OBJ_HT_P(z)->add_ref) { \
289 Z_OBJ_HT_P(z)->add_ref((z) TSRMLS_CC); \
290 }
291 #define Z_OBJ_DELREF_PP(z) \
292 if (Z_OBJ_HT_PP(z)->del_ref) { \
293 Z_OBJ_HT_PP(z)->del_ref(*(z) TSRMLS_CC); \
294 }
295 #define Z_OBJ_ADDREF_PP(z) \
296 if (Z_OBJ_HT_PP(z)->add_ref) { \
297 Z_OBJ_HT_PP(z)->add_ref(*(z) TSRMLS_CC); \
298 }
299
300 #define PHP_HTTP_BEGIN_ARGS_EX(class, method, ret_ref, req_args) ZEND_BEGIN_ARG_INFO_EX(args_for_ ##class## _ ##method , 0, ret_ref, req_args)
301 #define PHP_HTTP_BEGIN_ARGS_AR(class, method, ret_ref, req_args) ZEND_BEGIN_ARG_INFO_EX(args_for_ ##class## _ ##method , 1, ret_ref, req_args)
302 #define PHP_HTTP_END_ARGS }
303 #define PHP_HTTP_EMPTY_ARGS_EX(class, method, ret_ref) PHP_HTTP_BEGIN_ARGS_EX(class, method, ret_ref, 0) PHP_HTTP_END_ARGS
304 #define PHP_HTTP_ARGS(class, method) args_for_ ##class## _ ##method
305 #define PHP_HTTP_ARG_VAL(name, pass_ref) ZEND_ARG_INFO(pass_ref, name)
306 #define PHP_HTTP_ARG_OBJ(class, name, allow_null) ZEND_ARG_OBJ_INFO(0, name, class, allow_null)
307 #define PHP_HTTP_ARG_ARR(name, allow_null, pass_ref) ZEND_ARG_ARRAY_INFO(pass_ref, name, allow_null)
308
309 #define EMPTY_FUNCTION_ENTRY {NULL, NULL, NULL, 0, 0}
310
311 #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
312 #define PHP_RINIT_CALL(func) PHP_RINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
313 #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
314 #define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
315
316
317 #define PHP_HTTP_INI_ENTRY(entry, default, scope, updater, global) \
318 STD_PHP_INI_ENTRY(entry, default, scope, updater, global, zend_php_http_globals, php_http_globals)
319 #define PHP_HTTP_INI_ENTRY_EX(entry, default, scope, updater, displayer, global) \
320 STD_PHP_INI_ENTRY_EX(entry, default, scope, updater, global, zend_php_http_globals, php_http_globals, displayer)
321
322 #define PHP_HTTP_REGISTER_CLASS(ns, classname, name, parent, flags) \
323 { \
324 zend_class_entry ce; \
325 memset(&ce, 0, sizeof(zend_class_entry)); \
326 INIT_NS_CLASS_ENTRY(ce, #ns, #classname, php_ ##name## _method_entry); \
327 php_ ##name## _class_entry = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
328 php_ ##name## _class_entry->ce_flags |= flags; \
329 php_http_register_class(php_ ##name## _get_class_entry); \
330 }
331
332 #define PHP_HTTP_REGISTER_INTERFACE(ns, ifacename, name, flags) \
333 { \
334 zend_class_entry ce; \
335 memset(&ce, 0, sizeof(zend_class_entry)); \
336 INIT_NS_CLASS_ENTRY(ce, #ns, #ifacename, php_ ##name## _method_entry); \
337 php_ ##name## _class_entry = zend_register_internal_interface(&ce TSRMLS_CC); \
338 php_ ##name## _class_entry->ce_flags |= flags; \
339 php_http_register_class(php_ ##name## _get_class_entry); \
340 }
341
342 #define PHP_HTTP_REGISTER_EXCEPTION(classname, cename, parent) \
343 { \
344 zend_class_entry ce; \
345 memset(&ce, 0, sizeof(zend_class_entry)); \
346 INIT_NS_CLASS_ENTRY(ce, "http", #classname, NULL); \
347 ce.create_object = NULL; \
348 cename = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \
349 }
350
351 #define ACC_PROP_PRIVATE(ce, flags) ((flags & ZEND_ACC_PRIVATE) && (EG(scope) && ce == EG(scope))
352 #define ACC_PROP_PROTECTED(ce, flags) ((flags & ZEND_ACC_PROTECTED) && (zend_check_protected(ce, EG(scope))))
353 #define ACC_PROP_PUBLIC(flags) (flags & ZEND_ACC_PUBLIC)
354 #define ACC_PROP(ce, flags) (ACC_PROP_PUBLIC(flags) || ACC_PROP_PRIVATE(ce, flags) || ACC_PROP_PROTECTED(ce, flags))
355
356 #ifdef PHP_HTTP_HAVE_CURL
357 # define PHP_HTTP_DECLARE_ARG_PASS_INFO() \
358 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
359 ZEND_ARG_PASS_INFO(0) \
360 ZEND_ARG_PASS_INFO(1) \
361 ZEND_END_ARG_INFO(); \
362 \
363 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
364 ZEND_ARG_PASS_INFO(0) \
365 ZEND_ARG_PASS_INFO(0) \
366 ZEND_ARG_PASS_INFO(1) \
367 ZEND_END_ARG_INFO(); \
368 \
369 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
370 ZEND_ARG_PASS_INFO(0) \
371 ZEND_ARG_PASS_INFO(0) \
372 ZEND_ARG_PASS_INFO(0) \
373 ZEND_ARG_PASS_INFO(1) \
374 ZEND_END_ARG_INFO(); \
375 \
376 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_5, 0) \
377 ZEND_ARG_PASS_INFO(0) \
378 ZEND_ARG_PASS_INFO(0) \
379 ZEND_ARG_PASS_INFO(0) \
380 ZEND_ARG_PASS_INFO(0) \
381 ZEND_ARG_PASS_INFO(1) \
382 ZEND_END_ARG_INFO();
383
384 #else
385 # define PHP_HTTP_DECLARE_ARG_PASS_INFO() \
386 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
387 ZEND_ARG_PASS_INFO(0) \
388 ZEND_ARG_PASS_INFO(1) \
389 ZEND_END_ARG_INFO(); \
390 \
391 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
392 ZEND_ARG_PASS_INFO(0) \
393 ZEND_ARG_PASS_INFO(0) \
394 ZEND_ARG_PASS_INFO(1) \
395 ZEND_END_ARG_INFO(); \
396 \
397 ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
398 ZEND_ARG_PASS_INFO(0) \
399 ZEND_ARG_PASS_INFO(0) \
400 ZEND_ARG_PASS_INFO(0) \
401 ZEND_ARG_PASS_INFO(1) \
402 ZEND_END_ARG_INFO();
403 #endif /* PHP_HTTP_HAVE_CURL */
404
405 /* ARRAYS */
406 PHP_HTTP_API unsigned php_http_array_list(HashTable *ht TSRMLS_DC, unsigned argc, ...);
407
408 typedef struct php_http_array_hashkey {
409 char *str;
410 uint len;
411 ulong num;
412 uint dup:1;
413 uint type:31;
414 } php_http_array_hashkey_t;
415 #define php_http_array_hashkey_init(dup) {NULL, 0, 0, (dup), 0}
416
417 static inline void php_http_array_hashkey_stringify(php_http_array_hashkey_t *key)
418 {
419 if (key->type != HASH_KEY_IS_STRING) {
420 key->len = spprintf(&key->str, 0, "%lu", key->num) + 1;
421 }
422 }
423
424 static inline void php_http_array_hashkey_stringfree(php_http_array_hashkey_t *key)
425 {
426 if (key->type != HASH_KEY_IS_STRING || key->dup) {
427 STR_FREE(key->str);
428 }
429 }
430
431 typedef void (*php_http_array_visitor_t)(void *visitor_arg, php_http_array_hashkey_t *key, zval **val TSRMLS_DC);
432 PHP_HTTP_API void php_http_array_visit(HashTable *ht, php_http_array_visitor_t visitor_func, void *visitor_arg TSRMLS_DC);
433
434 #define FOREACH_VAL(pos, array, val) FOREACH_HASH_VAL(pos, HASH_OF(array), val)
435 #define FOREACH_HASH_VAL(pos, hash, val) \
436 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
437 zend_hash_get_current_data_ex(hash, (void *) &val, &pos) == SUCCESS; \
438 zend_hash_move_forward_ex(hash, &pos))
439
440 #define FOREACH_KEY(pos, array, key) FOREACH_HASH_KEY(pos, HASH_OF(array), key)
441 #define FOREACH_HASH_KEY(pos, hash, _key) \
442 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
443 ((_key).type = zend_hash_get_current_key_ex(hash, &(_key).str, &(_key).len, &(_key).num, (zend_bool) (_key).dup, &pos)) != HASH_KEY_NON_EXISTANT; \
444 zend_hash_move_forward_ex(hash, &pos)) \
445
446 #define FOREACH_KEYVAL(pos, array, key, val) FOREACH_HASH_KEYVAL(pos, HASH_OF(array), key, val)
447 #define FOREACH_HASH_KEYVAL(pos, hash, _key, val) \
448 for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \
449 ((_key).type = zend_hash_get_current_key_ex(hash, &(_key).str, &(_key).len, &(_key).num, (zend_bool) (_key).dup, &pos)) != HASH_KEY_NON_EXISTANT && \
450 zend_hash_get_current_data_ex(hash, (void *) &val, &pos) == SUCCESS; \
451 zend_hash_move_forward_ex(hash, &pos))
452
453 #define array_copy(src, dst) zend_hash_copy(dst, src, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *))
454 #define ARRAY_JOIN_STRONLY 1
455 #define ARRAY_JOIN_PRETTIFY 2
456 #define array_join(src, dst, append, flags) zend_hash_apply_with_arguments(src TSRMLS_CC, (append)?php_http_array_apply_append_func:php_http_array_apply_merge_func, 2, dst, (int)flags)
457
458 int php_http_array_apply_append_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);
459 int php_http_array_apply_merge_func(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key);
460
461 /* PASS CALLBACK */
462
463 typedef size_t (*php_http_pass_callback_t)(void *cb_arg, const char *str, size_t len);
464 typedef size_t (*php_http_pass_php_http_buffer_callback_t)(void *cb_arg, php_http_buffer_t *str);
465
466 typedef struct php_http_pass_callback_arg {
467 size_t (*cb_zts)(void *cb_arg, const char *str, size_t len TSRMLS_DC);
468 void *cb_arg;
469 } php_http_pass_callback_arg_t;
470
471 PHP_HTTP_API size_t php_http_pass_wrapper(php_http_pass_callback_arg_t *cb_arg, const char *str, size_t len);
472
473 typedef struct php_http_pass_fcall_arg {
474 zval *fcz;
475 zend_fcall_info fci;
476 zend_fcall_info_cache fcc;
477 #ifdef ZTS
478 void ***ts;
479 #endif
480 } php_http_pass_fcall_arg_t;
481
482 PHP_HTTP_API size_t php_http_pass_fcall_callback(void *cb_arg, const char *str, size_t len);
483
484 /* ERROR */
485
486 extern void php_http_error(long type TSRMLS_DC, long code, const char *format, ...);
487
488 #define with_error_handling(eh, ec) \
489 { \
490 zend_error_handling __eh; \
491 zend_replace_error_handling((eh), (ec), &__eh TSRMLS_CC);
492
493 #define end_error_handling() \
494 zend_restore_error_handling(&__eh TSRMLS_CC); \
495 }
496
497 #ifndef E_THROW
498 # define E_THROW -1
499 #endif
500 #define HE_THROW E_THROW TSRMLS_CC
501 #define HE_NOTICE E_NOTICE TSRMLS_CC
502 #define HE_WARNING E_WARNING TSRMLS_CC
503 #define HE_ERROR E_ERROR TSRMLS_CC
504
505 typedef enum php_http_error {
506 PHP_HTTP_E_UNKNOWN = 0,
507 PHP_HTTP_E_RUNTIME,
508 PHP_HTTP_E_INVALID_PARAM,
509 PHP_HTTP_E_HEADER,
510 PHP_HTTP_E_MALFORMED_HEADERS,
511 PHP_HTTP_E_REQUEST_METHOD,
512 PHP_HTTP_E_MESSAGE,
513 PHP_HTTP_E_MESSAGE_TYPE,
514 PHP_HTTP_E_MESSAGE_BODY,
515 PHP_HTTP_E_ENCODING,
516 PHP_HTTP_E_CLIENT,
517 PHP_HTTP_E_CLIENT_POOL,
518 PHP_HTTP_E_CLIENT_DATASHARE,
519 PHP_HTTP_E_REQUEST_FACTORY,
520 PHP_HTTP_E_SOCKET,
521 PHP_HTTP_E_RESPONSE,
522 PHP_HTTP_E_URL,
523 PHP_HTTP_E_QUERYSTRING,
524 PHP_HTTP_E_COOKIE,
525 } php_http_error_t;
526
527 #endif
528 /*
529 * Local variables:
530 * tab-width: 4
531 * c-basic-offset: 4
532 * End:
533 * vim600: noet sw=4 ts=4 fdm=marker
534 * vim<600: noet sw=4 ts=4
535 */