}
/* }}} */
-/* call request shutdown for all modules */
-static int module_registry_cleanup(zval *zv) /* {{{ */
-{
- zend_module_entry *module = Z_PTR_P(zv);
-
- if (module->request_shutdown_func) {
-#if 0
- zend_printf("%s: Request shutdown\n", module->name);
-#endif
- module->request_shutdown_func(module->type, module->module_number);
- }
- return 0;
-}
-/* }}} */
-
ZEND_API void zend_deactivate_modules(void) /* {{{ */
{
EG(current_execute_data) = NULL; /* we're no longer executing anything */
zend_try {
if (EG(full_tables_cleanup)) {
- zend_hash_reverse_apply(&module_registry, module_registry_cleanup);
+ zend_module_entry *module;
+
+ ZEND_HASH_REVERSE_FOREACH_PTR(&module_registry, module) {
+ if (module->request_shutdown_func) {
+#if 0
+ zend_printf("%s: Request shutdown\n", module->name);
+#endif
+ module->request_shutdown_func(module->type, module->module_number);
+ }
+ } ZEND_HASH_FOREACH_END();
} else {
zend_module_entry **p = module_request_shutdown_handlers;
}
/* }}} */
-int module_registry_unload_temp(const zend_module_entry *module) /* {{{ */
-{
- return (module->type == MODULE_TEMPORARY) ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_STOP;
-}
-/* }}} */
-
-static int module_registry_unload_temp_wrapper(zval *el) /* {{{ */
-{
- zend_module_entry *module = (zend_module_entry *)Z_PTR_P(el);
- return module_registry_unload_temp((const zend_module_entry *)module);
-}
-/* }}} */
-
-static int exec_done_cb(zval *el) /* {{{ */
-{
- zend_module_entry *module = (zend_module_entry *)Z_PTR_P(el);
- if (module->post_deactivate_func) {
- module->post_deactivate_func();
- }
- return 0;
-}
-/* }}} */
-
ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
{
if (EG(full_tables_cleanup)) {
- zend_hash_apply(&module_registry, exec_done_cb);
- zend_hash_reverse_apply(&module_registry, module_registry_unload_temp_wrapper);
+ zend_module_entry *module;
+
+ ZEND_HASH_FOREACH_PTR(&module_registry, module) {
+ if (module->post_deactivate_func) {
+ module->post_deactivate_func();
+ }
+ } ZEND_HASH_FOREACH_END();
+ ZEND_HASH_REVERSE_FOREACH_PTR(&module_registry, module) {
+ if (module->type != MODULE_TEMPORARY) {
+ break;
+ }
+ } ZEND_HASH_FOREACH_END_DEL();
} else {
zend_module_entry **p = module_post_deactivate_handlers;
}
/* }}} */
-static int copy_class_or_interface_name(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
-{
- zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
- zval *array = va_arg(args, zval *);
- uint32_t mask = va_arg(args, uint32_t);
- uint32_t comply = va_arg(args, uint32_t);
- uint32_t comply_mask = (comply)? mask:0;
-
- if ((hash_key->key && ZSTR_VAL(hash_key->key)[0] != 0)
- && (comply_mask == (ce->ce_flags & mask))) {
- if ((ce->refcount > 1 || (ce->ce_flags & ZEND_ACC_IMMUTABLE)) &&
- !same_name(hash_key->key, ce->name)) {
- add_next_index_str(array, zend_string_copy(hash_key->key));
- } else {
- add_next_index_str(array, zend_string_copy(ce->name));
- }
+static void copy_class_or_interface_name(zval *array, zend_string *key, zend_class_entry *ce) /* {{{ */
+{
+ if ((ce->refcount == 1 && !(ce->ce_flags & ZEND_ACC_IMMUTABLE)) ||
+ same_name(key, ce->name)) {
+ key = ce->name;
}
- return ZEND_HASH_APPLY_KEEP;
+ add_next_index_str(array, zend_string_copy(key));
}
/* }}} */
Returns an array of all declared traits. */
ZEND_FUNCTION(get_declared_traits)
{
- uint32_t mask = ZEND_ACC_TRAIT;
- uint32_t comply = 1;
+ zend_string *key;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
- zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) {
+ if (key
+ && ZSTR_VAL(key)[0] != 0
+ && (ce->ce_flags & ZEND_ACC_TRAIT)) {
+ copy_class_or_interface_name(return_value, key, ce);
+ }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
Returns an array of all declared classes. */
ZEND_FUNCTION(get_declared_classes)
{
- uint32_t mask = ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT;
- uint32_t comply = 0;
+ zend_string *key;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
- zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) {
+ if (key
+ && ZSTR_VAL(key)[0] != 0
+ && !(ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT))) {
+ copy_class_or_interface_name(return_value, key, ce);
+ }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
Returns an array of all declared interfaces. */
ZEND_FUNCTION(get_declared_interfaces)
{
- uint32_t mask = ZEND_ACC_INTERFACE;
- uint32_t comply = 1;
+ zend_string *key;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
- zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
-}
-/* }}} */
-
-static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
-{
- zend_function *func = Z_PTR_P(zv);
- zval *internal_ar = va_arg(args, zval *),
- *user_ar = va_arg(args, zval *);
- zend_bool *exclude_disabled = va_arg(args, zend_bool *);
-
- if (hash_key->key == NULL || ZSTR_VAL(hash_key->key)[0] == 0) {
- return 0;
- }
-
- if (func->type == ZEND_INTERNAL_FUNCTION) {
- char *disable_functions = INI_STR("disable_functions");
-
- if ((*exclude_disabled == 1) && (disable_functions != NULL)) {
- if (strstr(disable_functions, func->common.function_name->val) == NULL) {
- add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
- }
- } else {
- add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) {
+ if (key
+ && ZSTR_VAL(key)[0] != 0
+ && (ce->ce_flags & ZEND_ACC_INTERFACE)) {
+ copy_class_or_interface_name(return_value, key, ce);
}
- } else if (func->type == ZEND_USER_FUNCTION) {
- add_next_index_str(user_ar, zend_string_copy(hash_key->key));
- }
-
- return 0;
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
ZEND_FUNCTION(get_defined_functions)
{
zval internal, user;
+ zend_string *key;
+ zend_function *func;
zend_bool exclude_disabled = 0;
+ char *disable_functions = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &exclude_disabled) == FAILURE) {
return;
array_init(&user);
array_init(return_value);
- zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 3, &internal, &user, &exclude_disabled);
+ if (exclude_disabled) {
+ disable_functions = INI_STR("disable_functions");
+ }
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(function_table), key, func) {
+ if (key && ZSTR_VAL(key)[0] != 0) {
+ if (func->type == ZEND_INTERNAL_FUNCTION) {
+ if (disable_functions != NULL) {
+ if (strstr(disable_functions, func->common.function_name->val) == NULL) {
+ add_next_index_str(&internal, zend_string_copy(key));
+ }
+ } else {
+ add_next_index_str(&internal, zend_string_copy(key));
+ }
+ } else if (func->type == ZEND_USER_FUNCTION) {
+ add_next_index_str(&user, zend_string_copy(key));
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user);
}
/* }}} */
-static int add_extension_info(zval *item, void *arg) /* {{{ */
-{
- zval *name_array = (zval *)arg;
- zend_module_entry *module = (zend_module_entry*)Z_PTR_P(item);
- add_next_index_string(name_array, module->name);
- return 0;
-}
-/* }}} */
-
static int add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
{
zval *name_array = (zval *)arg;
}
/* }}} */
-static int add_constant_info(zval *item, void *arg) /* {{{ */
-{
- zval *name_array = (zval *)arg;
- zend_constant *constant = (zend_constant*)Z_PTR_P(item);
- zval const_val;
-
- if (!constant->name) {
- /* skip special constants */
- return 0;
- }
-
- ZVAL_COPY_OR_DUP(&const_val, &constant->value);
- zend_hash_add_new(Z_ARRVAL_P(name_array), constant->name, &const_val);
- return 0;
-}
-/* }}} */
-
/* {{{ proto array get_loaded_extensions([bool zend_extensions])
Return an array containing names of loaded extensions */
ZEND_FUNCTION(get_loaded_extensions)
if (zendext) {
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t)add_zendext_info, return_value);
} else {
- zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value);
+ zend_module_entry *module;
+
+ ZEND_HASH_FOREACH_PTR(&module_registry, module) {
+ add_next_index_string(return_value, module->name);
+ } ZEND_HASH_FOREACH_END();
}
}
/* }}} */
efree(module_names);
efree(modules);
} else {
- zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value);
+ zend_constant *constant;
+ zval const_val;
+
+ ZEND_HASH_FOREACH_PTR(EG(zend_constants), constant) {
+ if (!constant->name) {
+ /* skip special constants */
+ continue;
+ }
+ ZVAL_COPY_OR_DUP(&const_val, &constant->value);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), constant->name, &const_val);
+ } ZEND_HASH_FOREACH_END();
}
}
/* }}} */
}
/* }}} */
-static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, zend_class_entry *ce, HashTable **overridden, HashTable *exclude_table, zend_class_entry **aliases) /* {{{ */
+static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, zend_class_entry *ce, HashTable **overridden, HashTable *exclude_table, zend_class_entry **aliases) /* {{{ */
{
zend_trait_alias *alias, **alias_ptr;
zend_string *lcname;
zend_add_trait_method(ce, ZSTR_VAL(fn->common.function_name), fnname, &fn_copy, overridden);
}
-
- return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
}
/* }}} */
-static int zend_restore_ini_entry_wrapper(zval *el) /* {{{ */
-{
- zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
- zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE);
- return 1;
-}
-/* }}} */
-
static void free_ini_entry(zval *zv) /* {{{ */
{
zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);
ZEND_API int zend_ini_deactivate(void) /* {{{ */
{
if (EG(modified_ini_directives)) {
- zend_hash_apply(EG(modified_ini_directives), zend_restore_ini_entry_wrapper);
+ zend_ini_entry *ini_entry;
+
+ ZEND_HASH_FOREACH_PTR(EG(modified_ini_directives), ini_entry) {
+ zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE);
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(EG(modified_ini_directives));
FREE_HASHTABLE(EG(modified_ini_directives));
EG(modified_ini_directives) = NULL;
/* }}} */
#ifdef ZTS
-static int zend_ini_refresh_cache(zval *el, void *arg) /* {{{ */
-{
- zend_ini_entry *p = (zend_ini_entry *)Z_PTR_P(el);
- int stage = (int)(zend_intptr_t)arg;
-
- if (p->on_modify) {
- p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
- }
- return 0;
-}
-/* }}} */
-
ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */
{
- zend_hash_apply_with_argument(EG(ini_directives), zend_ini_refresh_cache, (void *)(zend_intptr_t) stage);
+ zend_ini_entry *p;
+
+ ZEND_HASH_FOREACH_PTR(EG(ini_directives), p) {
+ if (p->on_modify) {
+ p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
+ }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
#endif
}
-static int zend_close_rsrc(zval *zv)
-{
- zend_resource *res = Z_PTR_P(zv);
-
- if (res->type >= 0) {
- zend_resource_dtor(res);
- }
- return ZEND_HASH_APPLY_KEEP;
-}
-
-
void zend_close_rsrc_list(HashTable *ht)
{
- zend_hash_reverse_apply(ht, zend_close_rsrc);
+ zend_resource *res;
+
+ ZEND_HASH_REVERSE_FOREACH_PTR(ht, res) {
+ if (res->type >= 0) {
+ zend_resource_dtor(res);
+ }
+ } ZEND_HASH_FOREACH_END();
}
// return 0;
//}
-static int zend_update_parent_ce(zval *zv)
+static void zend_update_parent_ce(zend_class_entry *ce)
{
- zend_class_entry *ce = Z_PTR_P(zv);
-
if (ce->ce_flags & ZEND_ACC_LINKED) {
if (ce->parent) {
int i, end;
ce->__debugInfo = tmp;
}
}
-// zend_hash_apply(&ce->properties_info, (apply_func_t) zend_update_property_info_ce);
- return 0;
}
static void zend_accel_persist_class_table(HashTable *class_table)
{
+ zend_class_entry *ce;
+
zend_hash_persist(class_table, zend_persist_class_entry);
- zend_hash_apply(class_table, (apply_func_t) zend_update_parent_ce);
+ ZEND_HASH_FOREACH_PTR(class_table, ce) {
+ zend_update_parent_ce(ce);
+ } ZEND_HASH_FOREACH_END();
}
zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, const char **key, unsigned int key_length, int for_shm)
}
/* }}} */
-int spl_build_class_list_string(zval *entry, char **list) /* {{{ */
+static void spl_build_class_list_string(zval *entry, char **list) /* {{{ */
{
char *res;
spprintf(&res, 0, "%s, %s", *list, Z_STRVAL_P(entry));
efree(*list);
*list = res;
- return ZEND_HASH_APPLY_KEEP;
} /* }}} */
/* {{{ PHP_MINFO(spl)
*/
PHP_MINFO_FUNCTION(spl)
{
- zval list;
+ zval list, *zv;
char *strg;
php_info_print_table_start();
array_init(&list);
SPL_LIST_CLASSES(&list, 0, 1, ZEND_ACC_INTERFACE)
strg = estrdup("");
- zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&list), zv) {
+ spl_build_class_list_string(zv, &strg);
+ } ZEND_HASH_FOREACH_END();
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Interfaces", strg + 2);
efree(strg);
array_init(&list);
SPL_LIST_CLASSES(&list, 0, -1, ZEND_ACC_INTERFACE)
strg = estrdup("");
- zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&list), zv) {
+ spl_build_class_list_string(zv, &strg);
+ } ZEND_HASH_FOREACH_END();
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Classes", strg + 2);
efree(strg);
}
/* }}} */
-/* {{{ add_config_entry_cb
+/* {{{ add_config_entry
*/
-static int add_config_entry_cb(zval *entry, int num_args, va_list args, zend_hash_key *hash_key)
+static void add_config_entry(zend_ulong h, zend_string *key, zval *entry, zval *retval)
{
- zval *retval = (zval *)va_arg(args, zval*);
- zval tmp;
-
if (Z_TYPE_P(entry) == IS_STRING) {
- if (hash_key->key) {
- add_assoc_str_ex(retval, ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key), zend_string_copy(Z_STR_P(entry)));
+ if (key) {
+ add_assoc_str_ex(retval, ZSTR_VAL(key), ZSTR_LEN(key), zend_string_copy(Z_STR_P(entry)));
} else {
- add_index_str(retval, hash_key->h, zend_string_copy(Z_STR_P(entry)));
+ add_index_str(retval, h, zend_string_copy(Z_STR_P(entry)));
}
} else if (Z_TYPE_P(entry) == IS_ARRAY) {
+ zend_ulong h;
+ zend_string *key;
+ zval *zv, tmp;
+
array_init(&tmp);
- zend_hash_apply_with_arguments(Z_ARRVAL_P(entry), add_config_entry_cb, 1, tmp);
- zend_hash_update(Z_ARRVAL_P(retval), hash_key->key, &tmp);
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(entry), h, key, zv)
+ add_config_entry(h, key, zv, &tmp);
+ ZEND_HASH_FOREACH_END();
+ zend_hash_update(Z_ARRVAL_P(retval), key, &tmp);
}
- return 0;
+}
+/* }}} */
+
+/* {{{ add_config_entries
+ */
+static void add_config_entries(HashTable *hash, zval *return_value) /* {{{ */
+{
+ zend_ulong h;
+ zend_string *key;
+ zval *zv;
+
+ ZEND_HASH_FOREACH_KEY_VAL(hash, h, key, zv)
+ add_config_entry(h, key, zv, return_value);
+ ZEND_HASH_FOREACH_END();
}
/* }}} */
if (retval) {
if (Z_TYPE_P(retval) == IS_ARRAY) {
array_init(return_value);
- zend_hash_apply_with_arguments(Z_ARRVAL_P(retval), add_config_entry_cb, 1, return_value);
+ add_config_entries(Z_ARRVAL_P(retval), return_value);
return;
} else {
RETURN_STRING(Z_STRVAL_P(retval));
}
/* }}} */
-static int php_ini_get_option(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
-{
- zend_ini_entry *ini_entry = Z_PTR_P(zv);
- zval *ini_array = va_arg(args, zval *);
- int module_number = va_arg(args, int);
- int details = va_arg(args, int);
- zval option;
-
- if (module_number != 0 && ini_entry->module_number != module_number) {
- return 0;
- }
-
- if (hash_key->key == NULL ||
- ZSTR_VAL(hash_key->key)[0] != 0
- ) {
- if (details) {
- array_init(&option);
-
- if (ini_entry->orig_value) {
- add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->orig_value));
- } else if (ini_entry->value) {
- add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->value));
- } else {
- add_assoc_null(&option, "global_value");
- }
-
- if (ini_entry->value) {
- add_assoc_str(&option, "local_value", zend_string_copy(ini_entry->value));
- } else {
- add_assoc_null(&option, "local_value");
- }
-
- add_assoc_long(&option, "access", ini_entry->modifiable);
-
- zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &option);
- } else {
- if (ini_entry->value) {
- zval zv;
-
- ZVAL_STR_COPY(&zv, ini_entry->value);
- zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &zv);
- } else {
- zend_symtable_update(Z_ARRVAL_P(ini_array), ini_entry->name, &EG(uninitialized_zval));
- }
- }
- }
- return 0;
-}
-/* }}} */
-
/* {{{ proto array ini_get_all([string extension[, bool details = true]])
Get all configuration options */
PHP_FUNCTION(ini_get_all)
{
char *extname = NULL;
- size_t extname_len = 0, extnumber = 0;
+ size_t extname_len = 0, module_number = 0;
zend_module_entry *module;
zend_bool details = 1;
+ zend_string *key;
+ zend_ini_entry *ini_entry;
+
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
php_error_docref(NULL, E_WARNING, "Unable to find extension '%s'", extname);
RETURN_FALSE;
}
- extnumber = module->module_number;
+ module_number = module->module_number;
}
array_init(return_value);
- zend_hash_apply_with_arguments(EG(ini_directives), php_ini_get_option, 2, return_value, extnumber, details);
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(ini_directives), key, ini_entry) {
+ zval option;
+
+ if (module_number != 0 && ini_entry->module_number != module_number) {
+ continue;
+ }
+
+ if (key == NULL || ZSTR_VAL(key)[0] != 0) {
+ if (details) {
+ array_init(&option);
+
+ if (ini_entry->orig_value) {
+ add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->orig_value));
+ } else if (ini_entry->value) {
+ add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->value));
+ } else {
+ add_assoc_null(&option, "global_value");
+ }
+
+ if (ini_entry->value) {
+ add_assoc_str(&option, "local_value", zend_string_copy(ini_entry->value));
+ } else {
+ add_assoc_null(&option, "local_value");
+ }
+
+ add_assoc_long(&option, "access", ini_entry->modifiable);
+
+ zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &option);
+ } else {
+ if (ini_entry->value) {
+ zval zv;
+
+ ZVAL_STR_COPY(&zv, ini_entry->value);
+ zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &zv);
+ } else {
+ zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &EG(uninitialized_zval));
+ }
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
HashTable *hash = php_ini_get_configuration_hash();
array_init(return_value);
- zend_hash_apply_with_arguments(hash, add_config_entry_cb, 1, return_value);
+ add_config_entries(hash, return_value);
}
/* }}} */
#endif
return len;
}
-static int browser_reg_compare(
- zval *entry_zv, int num_args, va_list args, zend_hash_key *key) /* {{{ */
+static int browser_reg_compare(browscap_entry *entry, zend_string *agent_name, browscap_entry **found_entry_ptr) /* {{{ */
{
- browscap_entry *entry = Z_PTR_P(entry_zv);
- zend_string *agent_name = va_arg(args, zend_string *);
- browscap_entry **found_entry_ptr = va_arg(args, browscap_entry **);
browscap_entry *found_entry = *found_entry_ptr;
ALLOCA_FLAG(use_heap)
zend_string *pattern_lc, *regex;
if (zend_string_equals(agent_name, pattern_lc)) {
*found_entry_ptr = entry;
ZSTR_ALLOCA_FREE(pattern_lc, use_heap);
- return ZEND_HASH_APPLY_STOP;
+ return 1;
}
regex = browscap_convert_pattern(entry->pattern, 0);
lookup_browser_name = zend_string_tolower(agent_name);
found_entry = zend_hash_find_ptr(bdata->htab, lookup_browser_name);
if (found_entry == NULL) {
- zend_hash_apply_with_arguments(bdata->htab, browser_reg_compare, 2, lookup_browser_name, &found_entry);
+ browscap_entry *entry;
+
+ ZEND_HASH_FOREACH_PTR(bdata->htab, entry) {
+ if (browser_reg_compare(entry, lookup_browser_name, &found_entry)) {
+ break;
+ }
+ } ZEND_HASH_FOREACH_END();
if (found_entry == NULL) {
found_entry = zend_hash_str_find_ptr(bdata->htab,
}
/* }}} */
-static int _display_module_info_func(zval *el) /* {{{ */
-{
- zend_module_entry *module = (zend_module_entry*)Z_PTR_P(el);
- if (module->info_func || module->version) {
- php_info_print_module(module);
- }
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-static int _display_module_info_def(zval *el) /* {{{ */
-{
- zend_module_entry *module = (zend_module_entry*)Z_PTR_P(el);
- if (!module->info_func && !module->version) {
- php_info_print_module(module);
- }
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
/* {{{ php_print_gpcse_array
*/
static void php_print_gpcse_array(char *name, uint32_t name_length)
if (flag & PHP_INFO_MODULES) {
HashTable sorted_registry;
+ zend_module_entry *module;
zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, module_name_cmp, 0);
- zend_hash_apply(&sorted_registry, _display_module_info_func);
+ ZEND_HASH_FOREACH_PTR(&sorted_registry, module) {
+ if (module->info_func || module->version) {
+ php_info_print_module(module);
+ }
+ } ZEND_HASH_FOREACH_END();
SECTION("Additional Modules");
php_info_print_table_start();
php_info_print_table_header(1, "Module Name");
- zend_hash_apply(&sorted_registry, _display_module_info_def);
+ ZEND_HASH_FOREACH_PTR(&sorted_registry, module) {
+ if (!module->info_func && !module->version) {
+ php_info_print_module(module);
+ }
+ } ZEND_HASH_FOREACH_END();
php_info_print_table_end();
zend_hash_destroy(&sorted_registry);
}
/* }}} */
-/* {{{ php_ini_displayer
- */
-static int php_ini_displayer(zval *el, void *arg)
-{
- zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el);
- int module_number = *(int *)arg;
-
- if (ini_entry->module_number != module_number) {
- return 0;
- }
- if (!sapi_module.phpinfo_as_text) {
- PUTS("<tr>");
- PUTS("<td class=\"e\">");
- PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("</td></tr>\n");
- } else {
- PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("\n");
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ php_ini_available
- */
-static int php_ini_available(zval *el, void *arg)
-{
- zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
- int *module_number_available = (int *)arg;
- if (ini_entry->module_number == *(int *)module_number_available) {
- *(int *)module_number_available = -1;
- return ZEND_HASH_APPLY_STOP;
- } else {
- return ZEND_HASH_APPLY_KEEP;
- }
-}
-/* }}} */
-
/* {{{ display_ini_entries
*/
PHPAPI void display_ini_entries(zend_module_entry *module)
{
- int module_number, module_number_available;
+ int module_number;
+ zend_ini_entry *ini_entry;
+ zend_bool first = 1;
if (module) {
module_number = module->module_number;
} else {
module_number = 0;
}
- module_number_available = module_number;
- zend_hash_apply_with_argument(EG(ini_directives), php_ini_available, &module_number_available);
- if (module_number_available == -1) {
- php_info_print_table_start();
- php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
- zend_hash_apply_with_argument(EG(ini_directives), php_ini_displayer, (void *)&module_number);
+
+ ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
+ if (ini_entry->module_number != module_number) {
+ continue;
+ }
+ if (first) {
+ php_info_print_table_start();
+ php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
+ first = 0;
+ }
+ if (!sapi_module.phpinfo_as_text) {
+ PUTS("<tr>");
+ PUTS("<td class=\"e\">");
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
+ PUTS("</td><td class=\"v\">");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
+ PUTS("</td><td class=\"v\">");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
+ PUTS("</td></tr>\n");
+ } else {
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
+ PUTS(" => ");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
+ PUTS(" => ");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
+ PUTS("\n");
+ }
+ } ZEND_HASH_FOREACH_END();
+ if (!first) {
php_info_print_table_end();
}
}
}
/* }}} */
-static int unlink_filename(zval *el) /* {{{ */
-{
- zend_string *filename = Z_STR_P(el);
- VCWD_UNLINK(ZSTR_VAL(filename));
- return 0;
-}
-/* }}} */
-
-
static void free_filename(zval *el) {
zend_string *filename = Z_STR_P(el);
zend_string_release_ex(filename, 0);
PHPAPI void destroy_uploaded_files_hash(void) /* {{{ */
{
- zend_hash_apply(SG(rfc1867_uploaded_files), unlink_filename);
+ zval *el;
+
+ ZEND_HASH_FOREACH_VAL(SG(rfc1867_uploaded_files), el) {
+ zend_string *filename = Z_STR_P(el);
+ VCWD_UNLINK(ZSTR_VAL(filename));
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(SG(rfc1867_uploaded_files));
FREE_HASHTABLE(SG(rfc1867_uploaded_files));
}
PHP_RSHUTDOWN_FUNCTION(streams)
{
- zend_hash_apply(&EG(persistent_list), forget_persistent_resource_id_numbers);
+ zval *el;
+
+ ZEND_HASH_FOREACH_VAL(&EG(persistent_list), el) {
+ forget_persistent_resource_id_numbers(el);
+ } ZEND_HASH_FOREACH_END();
return SUCCESS;
}
}
#endif
-static int print_module_info(zval *element)
-{
- zend_module_entry *module = Z_PTR_P(element);
- php_printf("%s\n", module->name);
- return ZEND_HASH_APPLY_KEEP;
-}
-
static int module_name_cmp(const void *a, const void *b)
{
Bucket *f = (Bucket *) a;
static void print_modules(void)
{
HashTable sorted_registry;
+ zend_module_entry *module;
zend_hash_init(&sorted_registry, 64, NULL, NULL, 1);
zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, module_name_cmp, 0);
- zend_hash_apply(&sorted_registry, print_module_info);
+ ZEND_HASH_FOREACH_PTR(&sorted_registry, module) {
+ php_printf("%s\n", module->name);
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&sorted_registry);
}
{'-', 0, NULL} /* end of args */
};
-static int print_module_info(zval *element) /* {{{ */
-{
- zend_module_entry *module = (zend_module_entry*)Z_PTR_P(element);
- php_printf("%s\n", module->name);
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
static int module_name_cmp(const void *a, const void *b) /* {{{ */
{
Bucket *f = (Bucket *) a;
static void print_modules(void) /* {{{ */
{
HashTable sorted_registry;
+ zend_module_entry *module;
zend_hash_init(&sorted_registry, 50, NULL, NULL, 0);
zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, module_name_cmp, 0);
- zend_hash_apply(&sorted_registry, print_module_info);
+ ZEND_HASH_FOREACH_PTR(&sorted_registry, module) {
+ php_printf("%s\n", module->name);
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&sorted_registry);
}
/* }}} */
#define CGIG(v) (php_cgi_globals.v)
#endif
-static int print_module_info(zval *zv) /* {{{ */
-{
- zend_module_entry *module = Z_PTR_P(zv);
- php_printf("%s\n", module->name);
- return 0;
-}
-/* }}} */
-
static int module_name_cmp(const void *a, const void *b) /* {{{ */
{
Bucket *f = (Bucket *) a;
static void print_modules(void) /* {{{ */
{
HashTable sorted_registry;
+ zend_module_entry *module;
zend_hash_init(&sorted_registry, 50, NULL, NULL, 1);
zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, module_name_cmp, 0);
- zend_hash_apply(&sorted_registry, print_module_info);
+ ZEND_HASH_FOREACH_PTR(&sorted_registry, module) {
+ php_printf("%s\n", module->name);
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&sorted_registry);
}
/* }}} */