@Added ob_get_length function (Stig)

Added ob_get_length() function (returns size of buffer)
This commit is contained in:
Stig Bakken 2000-08-25 03:10:42 +00:00
parent 6cbdaf985f
commit 03471b21ee
5 changed files with 53 additions and 0 deletions

View File

@ -479,6 +479,7 @@ function_entry basic_functions[] = {
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)

View File

@ -269,6 +269,19 @@ int php_ob_get_buffer(pval *p)
}
/* 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
*/
@ -383,6 +396,17 @@ PHP_FUNCTION(ob_get_contents)
/* }}} */
/* {{{ 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;
}
}
/* }}} */
/* {{{ proto void ob_implicit_flush([int flag])
Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)

View File

@ -30,6 +30,7 @@ PHPAPI void php_start_ob_buffer(void);
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_start);
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);

View File

@ -269,6 +269,19 @@ int php_ob_get_buffer(pval *p)
}
/* 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
*/
@ -383,6 +396,17 @@ PHP_FUNCTION(ob_get_contents)
/* }}} */
/* {{{ 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;
}
}
/* }}} */
/* {{{ proto void ob_implicit_flush([int flag])
Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)

View File

@ -30,6 +30,7 @@ PHPAPI void php_start_ob_buffer(void);
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_start);
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);