cvs: php4 /main output.c php_output.h

From: Date: Wed, 21 Aug 2002 03:04:17 +0000
Subject: cvs: php4 /main output.c php_output.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13518@lists.php.net to get a copy of this message
helly Tue Aug 20 23:04:17 2002 EDT Modified files: /php4/main output.c php_output.h Log: full decopling of size parameters of ob_start() and internal buffer handlers #intended behaviour is now fully implemented, Index: php4/main/output.c diff -u php4/main/output.c:1.113 php4/main/output.c:1.114 --- php4/main/output.c:1.113 Tue Aug 20 21:00:56 2002 +++ php4/main/output.c Tue Aug 20 23:04:17 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.113 2002/08/21 01:00:56 helly Exp $ */ +/* $Id: output.c,v 1.114 2002/08/21 03:04:17 helly Exp $ */ #include "php.h" #include "ext/standard/head.h" @@ -135,28 +135,42 @@ php_error_docref("ref.outcontrol" TSRMLS_CC, E_ERROR, "Cannot use output buffering in output buffering display handlers"); return FAILURE; } - if (OG(ob_nesting_level)==0 && PG(double_buffering) && chunk_size) { + if (OG(ob_nesting_level)==0 && PG(double_buffering)) { initial_chunk_size = php_ob_default_buffer_size(TSRMLS_C); initial_size = 4*initial_chunk_size; block_size = initial_chunk_size; php_ob_init(initial_size, block_size, NULL, initial_chunk_size, erase TSRMLS_CC); } - if (chunk_size==0) { - initial_size = 40*1024; - block_size = 10*1024; - } else { - if (chunk_size==1) { - chunk_size = php_ob_default_buffer_size(TSRMLS_C); - } - initial_size = chunk_size; - block_size = chunk_size; + if (chunk_size<2) { + chunk_size = php_ob_default_buffer_size(TSRMLS_C); } - initial_size = chunk_size; block_size = chunk_size; + initial_size = block_size; return php_ob_init(initial_size, block_size, output_handler, chunk_size, erase TSRMLS_CC); } /* }}} */ +/* {{{ php_start_ob_buffer_nc + * Start output buffering */ +PHPAPI int php_start_ob_buffer_ibc(zval *output_handler, uint initial_size, uint block_size, uint chunk_size, zend_bool erase TSRMLS_DC) +{ + if (OG(ob_lock)) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_ERROR, "Cannot use output buffering in output buffering display handlers"); + return FAILURE; + } + if (chunk_size==0) { + block_size = 10*1024; + initial_size = 4*block_size; + } else if (chunk_size==1) { + chunk_size = php_ob_default_buffer_size(TSRMLS_C); + } + if (!block_size) + block_size = chunk_size; + if (!initial_size) + initial_size = block_size; + return php_ob_init(initial_size, block_size, output_handler, chunk_size, erase TSRMLS_CC); +} +/* }}} */ /* {{{ php_start_ob_buffer_named * Start output buffering */ @@ -360,6 +374,7 @@ OG(active_ob_buffer).internal_output_handler = internal_output_handler; OG(active_ob_buffer).internal_output_handler_buffer = (char *) emalloc(buffer_size); OG(active_ob_buffer).internal_output_handler_buffer_size = buffer_size; + OG(active_ob_buffer).chunk_size = buffer_size; if (OG(active_ob_buffer).handler_name) efree(OG(active_ob_buffer).handler_name); OG(active_ob_buffer).handler_name = estrdup(handler_name); @@ -733,7 +748,7 @@ &chunk_size, &erase) == FAILURE) RETURN_FALSE; - if (php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC)==FAILURE) { + if (php_start_ob_buffer_ibc(output_handler, 0, 0, chunk_size, erase TSRMLS_CC)==FAILURE) { RETURN_FALSE; } RETURN_TRUE; Index: php4/main/php_output.h diff -u php4/main/php_output.h:1.41 php4/main/php_output.h:1.42 --- php4/main/php_output.h:1.41 Tue Aug 20 15:49:37 2002 +++ php4/main/php_output.h Tue Aug 20 23:04:17 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h,v 1.41 2002/08/20 19:49:37 helly Exp $ */ +/* $Id: php_output.h,v 1.42 2002/08/21 03:04:17 helly Exp $ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H @@ -31,6 +31,7 @@ PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC); PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC); PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC); +PHPAPI int php_start_ob_buffer_ibc(zval *output_handler, uint initial_size, uint block_size, uint chunk_size, zend_bool erase TSRMLS_DC); PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC); PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC); PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);

« previous php.cvs (#13518) next »