iliaa           Mon Dec 30 14:41:01 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/main  output.c 
    /php4/ext/zlib      zlib.c php_zlib.h 
  Log:
  MFH
  
  
Index: php4/main/output.c
diff -u php4/main/output.c:1.142 php4/main/output.c:1.142.2.1
--- php4/main/output.c:1.142    Mon Oct  7 07:21:06 2002
+++ php4/main/output.c  Mon Dec 30 14:40:59 2002
@@ -18,12 +18,15 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: output.c,v 1.142 2002/10/07 11:21:06 zeev Exp $ */
+/* $Id: output.c,v 1.142.2.1 2002/12/30 19:40:59 iliaa Exp $ */
 
 #include "php.h"
 #include "ext/standard/head.h"
 #include "ext/standard/basic_functions.h"
 #include "ext/standard/url_scanner_ex.h"
+#ifdef HAVE_ZLIB
+#include "ext/zlib/php_zlib.h"
+#endif
 #include "SAPI.h"
 
 #define OB_DEFAULT_HANDLER_NAME "default output handler"
@@ -405,6 +408,11 @@
 static int php_ob_init_named(uint initial_size, uint block_size, char *handler_name, 
zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
 {
        if (OG(ob_nesting_level)>0) {
+#ifdef HAVE_ZLIB
+               if (!strncmp(handler_name, "ob_gzhandler", sizeof("ob_gzhandler")) && 
+php_ob_gzhandler_check(TSRMLS_CC)) {
+                       return FAILURE;
+               }
+#endif
                if (OG(ob_nesting_level)==1) { /* initialize stack */
                        zend_stack_init(&OG(ob_buffers));
                }
@@ -420,7 +428,7 @@
        OG(active_ob_buffer).status = 0;
        OG(active_ob_buffer).internal_output_handler = NULL;
        OG(active_ob_buffer).handler_name = 
estrdup(handler_name&&handler_name[0]?handler_name:OB_DEFAULT_HANDLER_NAME);
-       OG(active_ob_buffer).erase = erase;     
+       OG(active_ob_buffer).erase = erase;
        OG(php_body_write) = php_b_body_write;
        return SUCCESS;
 }
@@ -445,22 +453,20 @@
  */
 static int php_ob_init(uint initial_size, uint block_size, zval *output_handler, uint 
chunk_size, zend_bool erase TSRMLS_DC)
 {
-       int res, result, len;
+       int result, len;
        char *handler_name, *next_handler_name;
        HashPosition pos;
        zval **tmp;
        zval *handler_zval;
 
        if (output_handler && output_handler->type == IS_STRING) {
-               result = 0;
                handler_name = Z_STRVAL_P(output_handler);
                while ((next_handler_name=strchr(handler_name, ',')) != NULL) {
                        len = next_handler_name-handler_name;
                        next_handler_name = estrndup(handler_name, len);
                        handler_zval = php_ob_handler_from_string(next_handler_name 
TSRMLS_CC);
-                       res = php_ob_init_named(initial_size, block_size, 
next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
-                       result &= res;
-                       if (!res==SUCCESS) {
+                       result = php_ob_init_named(initial_size, block_size, 
+next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+                       if (result != SUCCESS) {
                                zval_dtor(handler_zval);
                                FREE_ZVAL(handler_zval);
                        }
@@ -468,15 +474,12 @@
                        efree(next_handler_name);
                }
                handler_zval = php_ob_handler_from_string(handler_name TSRMLS_CC);
-               res = php_ob_init_named(initial_size, block_size, handler_name, 
handler_zval, chunk_size, erase TSRMLS_CC);
-               result &= res;
-               if (!res==SUCCESS) {
+               result = php_ob_init_named(initial_size, block_size, handler_name, 
+handler_zval, chunk_size, erase TSRMLS_CC);
+               if (result != SUCCESS) {
                        zval_dtor(handler_zval);
                        FREE_ZVAL(handler_zval);
                }
-               result = result ? SUCCESS : FAILURE;
        } else if (output_handler && output_handler->type == IS_ARRAY) {
-               result = 0;
                /* do we have array(object,method) */
                if (zend_is_callable(output_handler, 1, &handler_name)) {
                        SEPARATE_ZVAL(&output_handler);
@@ -487,11 +490,10 @@
                        /* init all array elements recursively */
                        
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(output_handler), &pos);
                        while 
(zend_hash_get_current_data_ex(Z_ARRVAL_P(output_handler), (void **)&tmp, &pos) == 
SUCCESS) {
-                               result &= php_ob_init(initial_size, block_size, *tmp, 
chunk_size, erase TSRMLS_CC);
+                               result = php_ob_init(initial_size, block_size, *tmp, 
+chunk_size, erase TSRMLS_CC);
                                zend_hash_move_forward_ex(Z_ARRVAL_P(output_handler), 
&pos);
                        }
                }
-               result = result ? SUCCESS : FAILURE;
        } else if (output_handler && output_handler->type == IS_OBJECT) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "No method name given: use 
ob_start(array($object,'method')) to specify instance $object and the name of a method 
of class %s to use as output handler", Z_OBJCE_P(output_handler)->name);
                result = FAILURE;
Index: php4/ext/zlib/zlib.c
diff -u php4/ext/zlib/zlib.c:1.153.2.1 php4/ext/zlib/zlib.c:1.153.2.2
--- php4/ext/zlib/zlib.c:1.153.2.1      Mon Nov 18 06:03:38 2002
+++ php4/ext/zlib/zlib.c        Mon Dec 30 14:41:00 2002
@@ -18,7 +18,7 @@
    |          Jade Nicoletti <[EMAIL PROTECTED]>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: zlib.c,v 1.153.2.1 2002/11/18 11:03:38 wez Exp $ */
+/* $Id: zlib.c,v 1.153.2.2 2002/12/30 19:41:00 iliaa Exp $ */
 #define IS_EXT_MODULE
 
 #ifdef HAVE_CONFIG_H
@@ -890,6 +890,34 @@
 }
 /* }}} */
 
+/* {{{ php_ob_gzhandler_check
+ */
+int php_ob_gzhandler_check(TSRMLS_DC)
+{
+       /* check for wrong usages */
+       if (OG(ob_nesting_level>0)) {
+               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 FAILURE;
+               }
+               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 FAILURE;
+               }
+               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 FAILURE;
+               }
+               if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" 
+TSRMLS_CC)) {
+                       return FAILURE;
+               }
+       }
+
+       return SUCCESS;
+}
+
+/* }}} */
+
 /* {{{ proto string ob_gzhandler(string str, int mode)
    Encode str based on accept-encoding setting - designed to be called from 
ob_start() */
 PHP_FUNCTION(ob_gzhandler)
@@ -902,24 +930,6 @@
 
        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/ext/zlib/php_zlib.h
diff -u php4/ext/zlib/php_zlib.h:1.32 php4/ext/zlib/php_zlib.h:1.32.4.1
--- php4/ext/zlib/php_zlib.h:1.32       Fri Aug  9 18:29:58 2002
+++ php4/ext/zlib/php_zlib.h    Mon Dec 30 14:41:00 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zlib.h,v 1.32 2002/08/09 22:29:58 helly Exp $ */
+/* $Id: php_zlib.h,v 1.32.4.1 2002/12/30 19:41:00 iliaa Exp $ */
 
 #ifndef PHP_ZLIB_H
 #define PHP_ZLIB_H
@@ -54,6 +54,7 @@
 PHP_FUNCTION(ob_gzhandler);
 
 int php_enable_output_compression(int buffer_size TSRMLS_DC);
+int php_ob_gzhandler_check(TSRMLS_DC);
 
 php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, 
int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
 extern php_stream_ops php_stream_gzio_ops;



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

Reply via email to