yohgaki         Wed Oct  2 23:58:12 2002 EDT

  Modified files:              
    /php4/ext/zlib      zlib.c 
    /php4/main  output.c php_output.h 
  Log:
  Move wrong output buffer usage check to ob_gzhandler init.
  Export some output buffer functions.
  
  
Index: php4/ext/zlib/zlib.c
diff -u php4/ext/zlib/zlib.c:1.151 php4/ext/zlib/zlib.c:1.152
--- php4/ext/zlib/zlib.c:1.151  Wed Oct  2 11:02:16 2002
+++ php4/ext/zlib/zlib.c        Wed Oct  2 23:58:12 2002
@@ -18,7 +18,7 @@
    |          Jade Nicoletti <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: zlib.c,v 1.151 2002/10/02 15:02:16 helly Exp $ */
+/* $Id: zlib.c,v 1.152 2002/10/03 03:58:12 yohgaki Exp $ */
 #define IS_EXT_MODULE
 
 #ifdef HAVE_CONFIG_H
@@ -903,6 +903,24 @@
 
        if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &zv_string, 
&zv_mode)==FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
+       }
+
+       /* check for wrong usages */
+       if (OG(ob_nesting_level>1)) {
+               if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) {
+                       php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, 
+"output handler 'ob_gzhandler' cannot be used twice");
+                       RETURN_FALSE;
+               }
+               if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
+                       php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, 
+"output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'");
+                       RETURN_FALSE;
+               }
+               if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) {
+                       php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, 
+"output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'");
+                       RETURN_FALSE;
+               }
+               if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" 
+TSRMLS_CC))
+                       RETURN_FALSE;
        }
 
        if (ZLIBG(ob_gzhandler_status)==-1
Index: php4/main/output.c
diff -u php4/main/output.c:1.130 php4/main/output.c:1.131
--- php4/main/output.c:1.130    Wed Oct  2 22:55:19 2002
+++ php4/main/output.c  Wed Oct  2 23:58:12 2002
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: output.c,v 1.130 2002/10/03 02:55:19 yohgaki Exp $ */
+/* $Id: output.c,v 1.131 2002/10/03 03:58:12 yohgaki Exp $ */
 
 #include "php.h"
 #include "ext/standard/head.h"
@@ -370,7 +370,7 @@
 /* {{{ php_ob_init_conflict
  * Returns 1 if handler_set is already used and generates error message
  */
-static int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
+PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
 {
        if (php_ob_handler_used(handler_set TSRMLS_CC))
        {
@@ -387,26 +387,6 @@
 {
        int   handler_gz, handler_mb, handler_ic;
 
-       if (OG(ob_nesting_level>1)) {
-               /* check for specific handlers where rules apply */
-               handler_gz = strcmp(handler_name, "ob_gzhandler");
-               handler_mb = strcmp(handler_name, "mb_output_handler");
-               handler_ic = strcmp(handler_name, "ob_iconv_handler");
-               /* apply rules */
-               if (!handler_gz || !handler_mb || !handler_ic) {
-                       if (php_ob_handler_used(handler_name TSRMLS_CC)) {
-                               php_error_docref("ref.outcontrol" TSRMLS_CC, 
E_WARNING, "output handler '%s' cannot be used twice", handler_name);
-                               return FAILURE;
-                       }
-                       if (!handler_gz && php_ob_init_conflict(handler_name, "zlib 
output compression" TSRMLS_CC))
-                               return FAILURE;
-                       if (!handler_mb && php_ob_init_conflict(handler_name, 
"ob_iconv_handler" TSRMLS_CC))
-                               return FAILURE;
-                       if (!handler_ic && php_ob_init_conflict(handler_name, 
"mb_output_handler" TSRMLS_CC))
-                               return FAILURE;
-               }
-       }
-       
        if (OG(ob_nesting_level)>0) {
                if (OG(ob_nesting_level)==1) { /* initialize stack */
                        zend_stack_init(&OG(ob_buffers));
@@ -635,7 +615,7 @@
 
 /* {{{ php_ob_get_buffer
  * Return the current output buffer */
-static int php_ob_get_buffer(zval *p TSRMLS_DC)
+PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC)
 {
        if (OG(ob_nesting_level)==0) {
                return FAILURE;
@@ -647,7 +627,7 @@
 
 /* {{{ php_ob_get_length
  * Return the size of the current output buffer */
-static int php_ob_get_length(zval *p TSRMLS_DC)
+PHPAPI int php_ob_get_length(zval *p TSRMLS_DC)
 {
        if (OG(ob_nesting_level) == 0) {
                return FAILURE;
Index: php4/main/php_output.h
diff -u php4/main/php_output.h:1.44 php4/main/php_output.h:1.45
--- php4/main/php_output.h:1.44 Wed Oct  2 21:36:44 2002
+++ php4/main/php_output.h      Wed Oct  2 23:58:12 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_output.h,v 1.44 2002/10/03 01:36:44 yohgaki Exp $ */
+/* $Id: php_output.h,v 1.45 2002/10/03 03:58:12 yohgaki Exp $ */
 
 #ifndef PHP_OUTPUT_H
 #define PHP_OUTPUT_H
@@ -41,6 +41,9 @@
 PHPAPI int php_get_output_start_lineno(TSRMLS_D);
 PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t 
internal_output_handler, uint buffer_size, char *handler_name, zend_bool erase 
TSRMLS_DC);
 PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
+PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC);
+PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
+PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
 
 PHP_FUNCTION(ob_start);
 PHP_FUNCTION(ob_flush);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to