+#ifdef ZEND_ENGINE_2
+# define with_error_handling(eh, ec) \
+ { \
+ error_handling_t __eh = PG(error_handling); \
+ zend_class_entry *__ec= PG(exception_class); \
+ php_set_error_handling(eh, ec TSRMLS_CC);
+# define end_error_handling() \
+ php_set_error_handling(__eh, __ec TSRMLS_CC); \
+ }
+#else
+# define with_error_handling(eh, ec)
+# define end_error_handling()
+#endif
+
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION > 5
+# define ZEND_EXCEPTION_GET_DEFAULT() zend_exception_get_default(TSRMLS_C)
+#else
+# define ZEND_EXCEPTION_GET_DEFAULT() zend_exception_get_default()
+#endif
+
+#ifndef E_THROW
+# define E_THROW 0
+#endif
+#ifdef ZEND_ENGINE_2
+# define HE_THROW E_THROW TSRMLS_CC
+# define HE_NOTICE (HTTP_G->only_exceptions ? E_THROW : E_NOTICE) TSRMLS_CC
+# define HE_WARNING (HTTP_G->only_exceptions ? E_THROW : E_WARNING) TSRMLS_CC
+# define HE_ERROR (HTTP_G->only_exceptions ? E_THROW : E_ERROR) TSRMLS_CC
+#else
+# define HE_THROW E_WARNING TSRMLS_CC
+# define HE_NOTICE E_NOTICE TSRMLS_CC
+# define HE_WARNING E_WARNING TSRMLS_CC
+# define HE_ERROR E_ERROR TSRMLS_CC
+#endif
+
+#define HTTP_E_RUNTIME 1L
+#define HTTP_E_INVALID_PARAM 2L
+#define HTTP_E_HEADER 3L
+#define HTTP_E_MALFORMED_HEADERS 4L
+#define HTTP_E_REQUEST_METHOD 5L
+#define HTTP_E_MESSAGE_TYPE 6L
+#define HTTP_E_ENCODING 7L
+#define HTTP_E_REQUEST 8L
+#define HTTP_E_REQUEST_POOL 9L
+#define HTTP_E_SOCKET 10L
+#define HTTP_E_RESPONSE 11L
+#define HTTP_E_URL 12L
+#define HTTP_E_QUERYSTRING 13L
+
+#ifdef ZEND_ENGINE_2
+# 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)
+# 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)
+# define HTTP_END_ARGS }
+# define HTTP_EMPTY_ARGS_EX(class, method, ret_ref) HTTP_BEGIN_ARGS_EX(class, method, ret_ref, 0) HTTP_END_ARGS
+# define HTTP_ARGS(class, method) args_for_ ##class## _ ##method
+# define HTTP_ARG_VAL(name, pass_ref) ZEND_ARG_INFO(pass_ref, name)
+# define HTTP_ARG_OBJ(class, name, allow_null) ZEND_ARG_OBJ_INFO(0, name, class, allow_null)
+#endif
+
+#ifdef ZEND_ENGINE_2
+# define EMPTY_FUNCTION_ENTRY {NULL, NULL, NULL, 0, 0}
+#else
+# define EMPTY_FUNCTION_ENTRY {NULL, NULL, NULL}
+#endif
+
+#ifdef HTTP_HAVE_CURL
+# ifdef ZEND_ENGINE_2
+# define HTTP_DECLARE_ARG_PASS_INFO() \
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO(); \
+ \
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO(); \
+ \
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO(); \
+ \
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_5, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO();
+
+# else
+# define HTTP_DECLARE_ARG_PASS_INFO() \
+ static unsigned char http_arg_pass_ref_2[] = {2, BYREF_NONE, BYREF_FORCE}; \
+ static unsigned char http_arg_pass_ref_3[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE}; \
+ static unsigned char http_arg_pass_ref_4[] = {4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE}; \
+ static unsigned char http_arg_pass_ref_5[] = {5, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE};
+# endif /* ZEND_ENGINE_2 */
+#else
+# ifdef ZEND_ENGINE_2
+# define HTTP_DECLARE_ARG_PASS_INFO() \
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_2, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO(); \
+\
+ static \
+ ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(0) \
+ ZEND_ARG_PASS_INFO(1) \
+ ZEND_END_ARG_INFO();
+# else
+# define HTTP_DECLARE_ARG_PASS_INFO() \
+ static unsigned char http_arg_pass_ref_2[] = {2, BYREF_NONE, BYREF_FORCE}; \
+ static unsigned char http_arg_pass_ref_4[] = {4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE};
+# endif /* ZEND_ENGINE_2 */
+#endif /* HTTP_HAVE_CURL */
+
+
+#ifndef HAVE_CURL_SHARE_STRERROR
+# define curl_share_strerror(dummy) "unknown error"
+#endif
+#ifndef HAVE_CURL_EASY_STRERROR
+# define curl_easy_strerror(dummy) "unknown error"
+#endif
+#ifndef HAVE_CURL_MULTI_STRERROR
+# define curl_multi_strerror(dummy) "unknown error"
+#endif
+
+#define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_RINIT_CALL(func) PHP_RINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
+#define PHP_RSHUTDOWN_CALL(func) PHP_RSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
+
+#define Z_OBJ_DELREF(z) \
+ if (Z_OBJ_HT(z)->del_ref) { \
+ Z_OBJ_HT(z)->del_ref(&(z) TSRMLS_CC); \
+ }
+#define Z_OBJ_ADDREF(z) \
+ if (Z_OBJ_HT(z)->add_ref) { \
+ Z_OBJ_HT(z)->add_ref(&(z) TSRMLS_CC); \
+ }
+#define Z_OBJ_DELREF_P(z) \
+ if (Z_OBJ_HT_P(z)->del_ref) { \
+ Z_OBJ_HT_P(z)->del_ref((z) TSRMLS_CC); \
+ }
+#define Z_OBJ_ADDREF_P(z) \
+ if (Z_OBJ_HT_P(z)->add_ref) { \
+ Z_OBJ_HT_P(z)->add_ref((z) TSRMLS_CC); \
+ }
+#define Z_OBJ_DELREF_PP(z) \
+ if (Z_OBJ_HT_PP(z)->del_ref) { \
+ Z_OBJ_HT_PP(z)->del_ref(*(z) TSRMLS_CC); \
+ }
+#define Z_OBJ_ADDREF_PP(z) \
+ if (Z_OBJ_HT_PP(z)->add_ref) { \
+ Z_OBJ_HT_PP(z)->add_ref(*(z) TSRMLS_CC); \
+ }