-New function ob_list_handlers

@- Added ob_list_handlers() which returns an array of all active output
@  handlers. (marcus)
This commit is contained in:
Marcus Boerger 2002-08-05 03:09:42 +00:00
parent 16357dc2af
commit fd26a5c0a9
3 changed files with 38 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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;