]> granicus.if.org Git - php/commitdiff
@Added ob_get_length function (Stig)
authorStig Bakken <ssb@php.net>
Fri, 25 Aug 2000 03:10:42 +0000 (03:10 +0000)
committerStig Bakken <ssb@php.net>
Fri, 25 Aug 2000 03:10:42 +0000 (03:10 +0000)
Added ob_get_length() function (returns size of buffer)

ext/standard/basic_functions.c
ext/standard/output.c
ext/standard/php_output.h
main/output.c
main/php_output.h

index 1fa66fc1ca5ed79c2015265a8c01cc5eb1ad33fe..3061d0fabdc073bb098a8ff70d38ca9ce711d047 100644 (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)
 
index 2b3fb8efe7c90dc265b73ba555fca7bb0b8f9d1e..253b4294cf4b21f76a47952be8ae0d9e76ef8a04 100644 (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)
index 966d6dbe3508f09ab08c27ab95c244517d1d942a..cb43c8cb7f2ae8ff6f3147b9a7796fb0308ed2e7 100644 (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);
index 2b3fb8efe7c90dc265b73ba555fca7bb0b8f9d1e..253b4294cf4b21f76a47952be8ae0d9e76ef8a04 100644 (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)
index 966d6dbe3508f09ab08c27ab95c244517d1d942a..cb43c8cb7f2ae8ff6f3147b9a7796fb0308ed2e7 100644 (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);