summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2000-08-25 03:10:42 +0000
committerStig Bakken <ssb@php.net>2000-08-25 03:10:42 +0000
commit03471b21ee419e00bdcafe1f3c9d7da254539a16 (patch)
tree6a22f5f36262268e6b507eb8d0c964968b3d72b8
parent6cbdaf985fb9e06e493ca740f886a92663aaac57 (diff)
downloadphp-git-03471b21ee419e00bdcafe1f3c9d7da254539a16.tar.gz
@Added ob_get_length function (Stig)
Added ob_get_length() function (returns size of buffer)
-rw-r--r--ext/standard/basic_functions.c1
-rw-r--r--ext/standard/output.c24
-rw-r--r--ext/standard/php_output.h2
-rw-r--r--main/output.c24
-rw-r--r--main/php_output.h2
5 files changed, 53 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 1fa66fc1ca..3061d0fabd 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -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)
diff --git a/ext/standard/output.c b/ext/standard/output.c
index 2b3fb8efe7..253b4294cf 100644
--- a/ext/standard/output.c
+++ b/ext/standard/output.c
@@ -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)
diff --git a/ext/standard/php_output.h b/ext/standard/php_output.h
index 966d6dbe35..cb43c8cb7f 100644
--- a/ext/standard/php_output.h
+++ b/ext/standard/php_output.h
@@ -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);
diff --git a/main/output.c b/main/output.c
index 2b3fb8efe7..253b4294cf 100644
--- a/main/output.c
+++ b/main/output.c
@@ -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)
diff --git a/main/php_output.h b/main/php_output.h
index 966d6dbe35..cb43c8cb7f 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -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);