/回调函数/
static int add_constant_info(zend_constant *constant, void *arg TSRMLS_DC)
{
zval *name_array = (zval *)arg; //重新copy一个zval,防止破坏原数据
zval *const_val;
MAKE_STD_ZVAL(const_val);
*const_val = constant->value;
zval_copy_ctor(const_val);
INIT_PZVAL(const_val);
add_assoc_zval_ex(name_array, constant->name, constant->name_len, const_val);
return 0;
}
ZEND_FUNCTION(get_mickel_constants)
{
array_init(return_value);
zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t) add_constant_info, return_value TSRMLS_CC);
}
void zend_hash_apply_with_argument(HashTable *ht,apply_func_arg_t apply_func, void *data TSRMLS_DC);