X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_request_pool_api.h;h=2c066e312fb79b78d17808bd92c4160e7ee4fd33;hp=986c9ed0b7df954bea531bd9779dc7474ab6a74d;hb=bdcc6697f7dd2a636efe363d7208e3832692b1ec;hpb=32e91737086db53bb1fd9ed9f79d693c43ec459f diff --git a/php_http_request_pool_api.h b/php_http_request_pool_api.h index 986c9ed..2c066e3 100644 --- a/php_http_request_pool_api.h +++ b/php_http_request_pool_api.h @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2006, Michael Wallner | + | Copyright (c) 2004-2007, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -15,40 +15,22 @@ #ifndef PHP_HTTP_REQUEST_POOL_API_H #define PHP_HTTP_REQUEST_POOL_API_H #ifdef HTTP_HAVE_CURL +#ifdef ZEND_ENGINE_2 -typedef struct { +typedef struct _http_request_pool_t { CURLM *ch; zend_llist finished; zend_llist handles; int unfinished; } http_request_pool; -#define http_request_pool_responsehandler _http_request_pool_responsehandler -extern void _http_request_pool_responsehandler(zval **req, CURL *ch TSRMLS_DC); - -#define http_request_pool_try \ - { \ - zval *old_exception = EG(exception); \ - EG(exception) = NULL; -#define http_request_pool_catch() \ - if (EG(exception)) { \ - http_request_pool_wrap_exception(old_exception, EG(exception)); \ - } else { \ - EG(exception) = old_exception; \ - } \ - } -#define http_request_pool_final() \ - if (EG(exception)) { \ - zval *exception; \ - http_request_pool_wrap_exception(NULL, EG(exception)); \ - exception = EG(exception); \ - EG(exception) = NULL; \ - zend_throw_exception_object(exception TSRMLS_CC); \ - } - -#define http_request_pool_wrap_exception(o, n) _http_request_pool_wrap_exception((o), (n) TSRMLS_CC) -extern void _http_request_pool_wrap_exception(zval *old_exception, zval *new_exception TSRMLS_DC); +typedef int (*http_request_pool_apply_func)(http_request_pool *pool, zval *request TSRMLS_DC); +typedef int (*http_request_pool_apply_with_arg_func)(http_request_pool *pool, zval *request, void *arg TSRMLS_DC); +PHP_MINIT_FUNCTION(http_request_pool); + +#define http_request_pool_responsehandler(p, r, c) _http_request_pool_responsehandler((p), (r), (c) TSRMLS_CC) +extern int _http_request_pool_responsehandler(http_request_pool *pool, zval *req, void *ch TSRMLS_DC); #define http_request_pool_init(p) _http_request_pool_init((p) TSRMLS_CC) PHP_HTTP_API http_request_pool *_http_request_pool_init(http_request_pool *pool TSRMLS_DC); @@ -59,6 +41,12 @@ PHP_HTTP_API STATUS _http_request_pool_attach(http_request_pool *pool, zval *req #define http_request_pool_detach(p, r) _http_request_pool_detach((p), (r) TSRMLS_CC) PHP_HTTP_API STATUS _http_request_pool_detach(http_request_pool *pool, zval *request TSRMLS_DC); +#define http_request_pool_apply(p, f) _http_request_pool_apply((p), (f) TSRMLS_CC) +PHP_HTTP_API void _http_request_pool_apply(http_request_pool *pool, http_request_pool_apply_func cb TSRMLS_DC); + +#define http_request_pool_apply_with_arg(p, f, a) _http_request_pool_apply_with_arg((p), (f), (a) TSRMLS_CC) +PHP_HTTP_API void _http_request_pool_apply_with_arg(http_request_pool *pool, http_request_pool_apply_with_arg_func cb, void *arg TSRMLS_DC); + #define http_request_pool_detach_all(p) _http_request_pool_detach_all((p) TSRMLS_CC) PHP_HTTP_API void _http_request_pool_detach_all(http_request_pool *pool TSRMLS_DC); @@ -74,6 +62,7 @@ PHP_HTTP_API int _http_request_pool_perform(http_request_pool *pool TSRMLS_DC); #define http_request_pool_dtor(p) _http_request_pool_dtor((p) TSRMLS_CC) PHP_HTTP_API void _http_request_pool_dtor(http_request_pool *pool TSRMLS_DC); +#endif #endif #endif