]> granicus.if.org Git - php/commitdiff
-New function ob_list_handlers
authorMarcus Boerger <helly@php.net>
Mon, 5 Aug 2002 03:09:42 +0000 (03:09 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 5 Aug 2002 03:09:42 +0000 (03:09 +0000)
@- Added ob_list_handlers() which returns an array of all active output
@  handlers. (marcus)

ext/standard/basic_functions.c
main/output.c
main/php_output.h

index 24df4bf049fe4219a0abcfcc32f70458f6d8442a..6d30b50e048248789a02f2fa068735cad959540b 100644 (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)
index 1461b370802ce9ff78071db9d1ea80483999f9d7..025a0aeeec619894f5cb911cb15142caa35093ca 100644 (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)
index 48f9bde31d5615845fe935fd63d0f60297ac5839..977c217d65829fc584f30510e4fa462150d98cbf 100644 (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;