cvs: php4 /ext/standard basic_functions.c /main output.c php_output.h
| From: | Marcus B�rger | Date: | Mon, 05 Aug 2002 03:09:43 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c /main output.c php_output.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-13128@lists.php.net to get a copy of this message | ||
helly Sun Aug 4 23:09:43 2002 EDT
Modified files:
/php4/ext/standard basic_functions.c
/php4/main output.c php_output.h
Log:
-New function ob_list_handlers
@- Added ob_list_handlers() which returns an array of all active output
@ handlers. (marcus)
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.489 php4/ext/standard/basic_functions.c:1.490
--- php4/ext/standard/basic_functions.c:1.489 Fri Aug 2 06:08:53 2002
+++ php4/ext/standard/basic_functions.c Sun Aug 4 23:09:42 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.489 2002/08/02 10:08:53 hholzgra Exp $ */
+/* $Id: basic_functions.c,v 1.490 2002/08/05 03:09:42 helly Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -731,6 +731,7 @@
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: php4/main/output.c
diff -u php4/main/output.c:1.103 php4/main/output.c:1.104
--- php4/main/output.c:1.103 Sun May 12 18:17:58 2002
+++ php4/main/output.c Sun Aug 4 23:09:42 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: output.c,v 1.103 2002/05/12 22:17:58 zeev Exp $ */
+/* $Id: output.c,v 1.104 2002/08/05 03:09:42 helly Exp $ */
#include "php.h"
#include "ext/standard/head.h"
@@ -364,6 +364,42 @@
OG(active_ob_buffer).handler_name = estrdup("default output handler");
}
OG(active_ob_buffer).erase = erase;
+}
+/* }}} */
+
+/* {{{ 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);
+ }
}
/* }}} */
Index: php4/main/php_output.h
diff -u php4/main/php_output.h:1.37 php4/main/php_output.h:1.38
--- php4/main/php_output.h:1.37 Sat May 4 14:33:13 2002
+++ php4/main/php_output.h Sun Aug 4 23:09:42 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_output.h,v 1.37 2002/05/04 18:33:13 sas Exp $ */
+/* $Id: php_output.h,v 1.38 2002/08/05 03:09:42 helly Exp $ */
#ifndef PHP_OUTPUT_H
#define PHP_OUTPUT_H
@@ -50,6 +50,7 @@
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;