mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
-New function ob_list_handlers
@- Added ob_list_handlers() which returns an array of all active output @ handlers. (marcus)
This commit is contained in:
parent
16357dc2af
commit
fd26a5c0a9
@ -731,6 +731,7 @@ function_entry basic_functions[] = {
|
||||
PHP_FE(ob_get_status, NULL)
|
||||
PHP_FE(ob_get_contents, NULL)
|
||||
PHP_FE(ob_implicit_flush, NULL)
|
||||
PHP_FE(ob_list_handlers, NULL)
|
||||
|
||||
/* functions from array.c */
|
||||
PHP_FE(ksort, first_arg_force_ref)
|
||||
|
@ -367,6 +367,42 @@ static void php_ob_init(uint initial_size, uint block_size, zval *output_handler
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_ob_list_each
|
||||
*/
|
||||
|
||||
static int php_ob_list_each(php_ob_buffer *ob_buffer, zval *ob_handler_array)
|
||||
{
|
||||
if (!strcmp(ob_buffer->handler_name, "zlib output compression") && ob_buffer->internal_output_handler) {
|
||||
add_next_index_string(ob_handler_array, "ob_gzhandler", 1);
|
||||
} else {
|
||||
add_next_index_string(ob_handler_array, ob_buffer->handler_name, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array ob_list_handlers()
|
||||
List all output_buffers in an array */
|
||||
PHP_FUNCTION(ob_list_handlers)
|
||||
{
|
||||
if (ZEND_NUM_ARGS()!=0) {
|
||||
WRONG_PARAM_COUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
php_error(E_ERROR, "%s(): Unable to initialize array", get_active_function_name(TSRMLS_C));
|
||||
return;
|
||||
}
|
||||
if (OG(ob_nesting_level)) {
|
||||
if (OG(ob_nesting_level)>1) {
|
||||
zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_ob_list_each, return_value);
|
||||
}
|
||||
php_ob_list_each(&OG(active_ob_buffer), return_value);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_ob_append
|
||||
*/
|
||||
static void php_ob_append(const char *text, uint text_length TSRMLS_DC)
|
||||
|
@ -50,6 +50,7 @@ PHP_FUNCTION(ob_get_length);
|
||||
PHP_FUNCTION(ob_get_level);
|
||||
PHP_FUNCTION(ob_get_status);
|
||||
PHP_FUNCTION(ob_implicit_flush);
|
||||
PHP_FUNCTION(ob_list_handlers);
|
||||
|
||||
typedef struct _php_ob_buffer {
|
||||
char *buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user