cvs: php4 /ext/standard basic_functions.c output.c php_output.h

From: Date: Fri, 25 Aug 2000 03:10:42 +0000
Subject: cvs: php4 /ext/standard basic_functions.c output.c php_output.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1379@lists.php.net to get a copy of this message
ssb Thu Aug 24 20:10:42 2000 EDT Modified files: /php4/ext/standard basic_functions.c output.c php_output.h Log: @Added ob_get_length function (Stig) Added ob_get_length() function (returns size of buffer) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.240 php4/ext/standard/basic_functions.c:1.241 --- php4/ext/standard/basic_functions.c:1.240 Thu Aug 24 11:49:48 2000 +++ php4/ext/standard/basic_functions.c Thu Aug 24 20:10:42 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.240 2000/08/24 18:49:48 zeev Exp $ */ +/* $Id: basic_functions.c,v 1.241 2000/08/25 03:10:42 ssb Exp $ */ #include "php.h" #include "php_main.h" @@ -479,6 +479,7 @@ PHP_FE(ob_start, NULL) PHP_FE(ob_end_flush, NULL) PHP_FE(ob_end_clean, NULL) + PHP_FE(ob_get_length, NULL) PHP_FE(ob_get_contents, NULL) PHP_FE(ob_implicit_flush, NULL) Index: php4/ext/standard/output.c diff -u php4/ext/standard/output.c:1.26 php4/ext/standard/output.c:1.27 --- php4/ext/standard/output.c:1.26 Sat Jul 29 07:46:08 2000 +++ php4/ext/standard/output.c Thu Aug 24 20:10:42 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.26 2000/07/29 14:46:08 zeev Exp $ */ +/* $Id: output.c,v 1.27 2000/08/25 03:10:42 ssb Exp $ */ #include "php.h" #include "ext/standard/head.h" @@ -269,6 +269,19 @@ } +/* Return the size of the current output buffer */ +int php_ob_get_length(pval *p) +{ + OLS_FETCH(); + + if (OG(nesting_level) == 0) { + return FAILURE; + } + p->type = IS_LONG; + p->value.lval = OG(active_ob_buffer).text_length; + return SUCCESS; +} + /* * Wrapper functions - implementation */ @@ -377,6 +390,17 @@ PHP_FUNCTION(ob_get_contents) { if (php_ob_get_buffer(return_value)==FAILURE) { + RETURN_FALSE; + } +} +/* }}} */ + + +/* {{{ proto string ob_get_length(void) + Return the length of the output buffer */ +PHP_FUNCTION(ob_get_length) +{ + if (php_ob_get_length(return_value)==FAILURE) { RETURN_FALSE; } } Index: php4/ext/standard/php_output.h diff -u php4/ext/standard/php_output.h:1.13 php4/ext/standard/php_output.h:1.14 --- php4/ext/standard/php_output.h:1.13 Sat Jul 29 07:46:08 2000 +++ php4/ext/standard/php_output.h Thu Aug 24 20:10:42 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h,v 1.13 2000/07/29 14:46:08 zeev Exp $ */ +/* $Id: php_output.h,v 1.14 2000/08/25 03:10:42 ssb Exp $ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H @@ -30,6 +30,7 @@ PHPAPI void php_end_ob_buffer(int send_buffer); PHPAPI void php_end_ob_buffers(int send_buffer); PHPAPI int php_ob_get_buffer(pval *p); +PHPAPI int php_ob_get_length(pval *p); PHPAPI void php_start_implicit_flush(void); PHPAPI void php_end_implicit_flush(void); PHPAPI char *php_get_output_start_filename(void); @@ -39,6 +40,7 @@ PHP_FUNCTION(ob_end_flush); PHP_FUNCTION(ob_end_clean); PHP_FUNCTION(ob_get_contents); +PHP_FUNCTION(ob_get_length); PHP_FUNCTION(ob_implicit_flush); PHP_GINIT_FUNCTION(output);

« previous php.cvs (#1379) next »