X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_api.h;h=325378c4d0ec3d2e167d6efaafa8c36ccc196ca4;hp=a7349b21d8bde8853f09bce4d354404de201b803;hb=9676c81efbb8f180fa189d71a7ecb50dde4f5646;hpb=1bb903f3aad484c7adf638af3365cb7c668d3281 diff --git a/php_http_api.h b/php_http_api.h index a7349b2..325378c 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -38,6 +38,29 @@ extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend #define http_error_ex _http_error_ex extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...); + +#ifdef ZEND_ENGINE_2 +#define http_exception_wrap(o, n, ce) _http_exception_wrap((o), (n), (ce) TSRMLS_CC) +extern zval *_http_exception_wrap(zval *old_exception, zval *new_exception, zend_class_entry *ce TSRMLS_DC); + +#define http_try \ +{ \ + zval *old_exception = EG(exception); \ + EG(exception) = NULL; +#define http_catch(ex_ce) \ + if (EG(exception) && old_exception) { \ + EG(exception) = http_exception_wrap(old_exception, EG(exception), ex_ce); \ + } \ +} +#define http_final(ex_ce) \ + if (EG(exception)) { \ + zval *exception = http_exception_wrap(EG(exception), NULL, ex_ce); \ + EG(exception) = NULL; \ + zend_throw_exception_object(exception TSRMLS_CC); \ + } +#endif /* ZEND_ENGINE_2 */ + + #define HTTP_CHECK_CURL_INIT(ch, init, action) \ if ((!(ch)) && (!((ch) = init))) { \ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not initialize curl"); \