yohgaki Wed Oct 2 21:36:44 2002 EDT
Modified files:
/php4/ext/standard basic_functions.c
/php4/main output.c php_output.h
Log:
Added ob_get_clean() and ob_get_flush().
Someone requested this feature before.
@ Added ob_get_clean() and og_get_flush(). (Yasuo)
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.516
php4/ext/standard/basic_functions.c:1.517
--- php4/ext/standard/basic_functions.c:1.516 Sun Sep 29 23:02:51 2002
+++ php4/ext/standard/basic_functions.c Wed Oct 2 21:36:43 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.516 2002/09/30 03:02:51 jon Exp $ */
+/* $Id: basic_functions.c,v 1.517 2002/10/03 01:36:43 yohgaki Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -750,6 +750,8 @@
PHP_FE(ob_clean,
NULL)
PHP_FE(ob_end_flush,
NULL)
PHP_FE(ob_end_clean,
NULL)
+ PHP_FE(ob_get_flush,
+ NULL)
+ PHP_FE(ob_get_clean,
+ NULL)
PHP_FE(ob_get_length,
NULL)
PHP_FE(ob_get_level,
NULL)
PHP_FE(ob_get_status,
NULL)
Index: php4/main/output.c
diff -u php4/main/output.c:1.128 php4/main/output.c:1.129
--- php4/main/output.c:1.128 Wed Oct 2 11:36:29 2002
+++ php4/main/output.c Wed Oct 2 21:36:44 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: output.c,v 1.128 2002/10/02 15:36:29 helly Exp $ */
+/* $Id: output.c,v 1.129 2002/10/03 01:36:44 yohgaki Exp $ */
#include "php.h"
#include "ext/standard/head.h"
@@ -818,6 +818,56 @@
php_end_ob_buffer(0, 0 TSRMLS_CC);
RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool ob_get_flush(void)
+ Get current buffer contents, flush (send) the output buffer, and delete current
+output buffer */
+PHP_FUNCTION(ob_get_flush)
+{
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT;
+
+ /* get contents */
+ if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+ RETURN_FALSE;
+ }
+ /* error checks */
+ if (!OG(ob_nesting_level)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to
+delete and flush buffer. No buffer to delete or flush.");
+ RETURN_FALSE;
+ }
+ if (OG(ob_nesting_level) && !OG(active_ob_buffer).status &&
+!OG(active_ob_buffer).erase) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to
+delete buffer %s.", OG(active_ob_buffer).handler_name);
+ RETURN_FALSE;
+ }
+ /* flush */
+ php_end_ob_buffer(1, 0 TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool ob_get_clean(void)
+ Get current buffer contents and delete current output buffer */
+PHP_FUNCTION(ob_get_clean)
+{
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT;
+
+ /* get contents */
+ if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+ RETURN_FALSE;
+ }
+ /* error checks */
+ if (!OG(ob_nesting_level)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to
+delete buffer. No buffer to delete.");
+ RETURN_FALSE;
+ }
+ if (OG(ob_nesting_level) && !OG(active_ob_buffer).status &&
+!OG(active_ob_buffer).erase) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to
+delete buffer %s.", OG(active_ob_buffer).handler_name);
+ RETURN_FALSE;
+ }
+ /* delete buffer */
+ php_end_ob_buffer(0, 0 TSRMLS_CC);
}
/* }}} */
Index: php4/main/php_output.h
diff -u php4/main/php_output.h:1.43 php4/main/php_output.h:1.44
--- php4/main/php_output.h:1.43 Sun Sep 1 07:33:19 2002
+++ php4/main/php_output.h Wed Oct 2 21:36:44 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_output.h,v 1.43 2002/09/01 11:33:19 sebastian Exp $ */
+/* $Id: php_output.h,v 1.44 2002/10/03 01:36:44 yohgaki Exp $ */
#ifndef PHP_OUTPUT_H
#define PHP_OUTPUT_H
@@ -47,6 +47,8 @@
PHP_FUNCTION(ob_clean);
PHP_FUNCTION(ob_end_flush);
PHP_FUNCTION(ob_end_clean);
+PHP_FUNCTION(ob_get_flush);
+PHP_FUNCTION(ob_get_clean);
PHP_FUNCTION(ob_get_contents);
PHP_FUNCTION(ob_get_length);
PHP_FUNCTION(ob_get_level);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php