From: Michael Wallner Date: Wed, 12 Dec 2012 11:41:59 +0000 (+0000) Subject: change array_list API X-Git-Tag: RELEASE_2_1_0_RC3~10^2^2~83 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=7b028d0cbb030f9610084314f67b77907d8474a2;p=m6w6%2Fext-http change array_list API --- diff --git a/php_http_curl_client.c b/php_http_curl_client.c index 83640a3..640f3bb 100644 --- a/php_http_curl_client.c +++ b/php_http_curl_client.c @@ -526,7 +526,7 @@ static STATUS php_http_curl_client_option_set_range(php_http_option_t *opt, zval FOREACH_VAL(pos, val, rr) { if (Z_TYPE_PP(rr) == IS_ARRAY) { - if (2 == php_http_array_list(*rr TSRMLS_CC, 2, &rb, &re)) { + if (2 == php_http_array_list(Z_ARRVAL_PP(rr) TSRMLS_CC, 2, &rb, &re)) { if ( ((Z_TYPE_PP(rb) == IS_LONG) || ((Z_TYPE_PP(rb) == IS_STRING) && is_numeric_string(Z_STRVAL_PP(rb), Z_STRLEN_PP(rb), NULL, NULL, 1))) && ((Z_TYPE_PP(re) == IS_LONG) || ((Z_TYPE_PP(re) == IS_STRING) && is_numeric_string(Z_STRVAL_PP(re), Z_STRLEN_PP(re), NULL, NULL, 1)))) { zval *rbl = php_http_ztyp(IS_LONG, *rb); @@ -614,7 +614,7 @@ static STATUS php_http_curl_client_option_set_portrange(php_http_option_t *opt, if (val && Z_TYPE_P(val) != IS_NULL) { zval **z_port_start, *zps_copy = NULL, **z_port_end, *zpe_copy = NULL; - switch (php_http_array_list(val TSRMLS_CC, 2, &z_port_start, &z_port_end)) { + switch (php_http_array_list(Z_ARRVAL_P(val) TSRMLS_CC, 2, &z_port_start, &z_port_end)) { case 2: zps_copy = php_http_ztyp(IS_LONG, *z_port_start); zpe_copy = php_http_ztyp(IS_LONG, *z_port_end); diff --git a/php_http_misc.c b/php_http_misc.c index 4115042..f14354a 100644 --- a/php_http_misc.c +++ b/php_http_misc.c @@ -142,16 +142,15 @@ int php_http_select_str(const char *cmp, int argc, ...) /* ARRAYS */ -PHP_HTTP_API unsigned php_http_array_list(zval *hash TSRMLS_DC, unsigned argc, ...) +PHP_HTTP_API unsigned php_http_array_list(HashTable *ht TSRMLS_DC, unsigned argc, ...) { - HashTable *ht = HASH_OF(hash); HashPosition pos; unsigned argl = 0; va_list argv; va_start(argv, argc); for ( zend_hash_internal_pointer_reset_ex(ht, &pos); - zend_hash_has_more_elements_ex(ht, &pos) && (argl < argc); + SUCCESS == zend_hash_has_more_elements_ex(ht, &pos) && (argl < argc); zend_hash_move_forward_ex(ht, &pos)) { zval **data, ***argp = (zval ***) va_arg(argv, zval ***); @@ -230,12 +229,6 @@ int php_http_array_apply_merge_func(void *pDest TSRMLS_DC, int num_args, va_list /* PASS CALLBACK */ -PHP_HTTP_API size_t php_http_pass_wrapper(php_http_pass_callback_arg_t *cb, const char *str, size_t len) -{ - TSRMLS_FETCH(); - return cb->cb_zts(cb->cb_arg, str, len TSRMLS_CC); -} - PHP_HTTP_API size_t php_http_pass_fcall_callback(void *cb_arg, const char *str, size_t len) { php_http_pass_fcall_arg_t *fcd = cb_arg; diff --git a/php_http_misc.h b/php_http_misc.h index 2ee38e1..67fc711 100644 --- a/php_http_misc.h +++ b/php_http_misc.h @@ -326,6 +326,7 @@ static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, c INIT_NS_CLASS_ENTRY(ce, #ns, #classname, php_ ##name## _method_entry); \ php_ ##name## _class_entry = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \ php_ ##name## _class_entry->ce_flags |= flags; \ + php_http_register_class(php_ ##name## _get_class_entry); \ } #define PHP_HTTP_REGISTER_INTERFACE(ns, ifacename, name, flags) \ @@ -335,6 +336,7 @@ static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, c INIT_NS_CLASS_ENTRY(ce, #ns, #ifacename, php_ ##name## _method_entry); \ php_ ##name## _class_entry = zend_register_internal_interface(&ce TSRMLS_CC); \ php_ ##name## _class_entry->ce_flags |= flags; \ + php_http_register_class(php_ ##name## _get_class_entry); \ } #define PHP_HTTP_REGISTER_EXCEPTION(classname, cename, parent) \ @@ -401,8 +403,7 @@ static inline STATUS php_http_ini_entry(const char *name_str, size_t name_len, c #endif /* PHP_HTTP_HAVE_CURL */ /* ARRAYS */ - -PHP_HTTP_API unsigned php_http_array_list(zval *hash TSRMLS_DC, unsigned argc, ...); +PHP_HTTP_API unsigned php_http_array_list(HashTable *ht TSRMLS_DC, unsigned argc, ...); typedef struct php_http_array_hashkey { char *str; @@ -427,6 +428,9 @@ static inline void php_http_array_hashkey_stringfree(php_http_array_hashkey_t *k } } +typedef void (*php_http_array_visitor_t)(void *visitor_arg, php_http_array_hashkey_t *key, zval **val TSRMLS_DC); +PHP_HTTP_API void php_http_array_visit(HashTable *ht, php_http_array_visitor_t visitor_func, void *visitor_arg TSRMLS_DC); + #define FOREACH_VAL(pos, array, val) FOREACH_HASH_VAL(pos, HASH_OF(array), val) #define FOREACH_HASH_VAL(pos, hash, val) \ for ( zend_hash_internal_pointer_reset_ex(hash, &pos); \