cvs: php4 /ext/zlib php_zlib.h zlib.c

From: Date: Fri, 05 Apr 2002 13:07:43 +0000
Subject: cvs: php4 /ext/zlib php_zlib.h zlib.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10900@lists.php.net to get a copy of this message
ssb Fri Apr 5 08:07:43 2002 EDT Modified files: /php4/ext/zlib php_zlib.h zlib.c Log: @Add zlib.output_compression_level option (Stig) Index: php4/ext/zlib/php_zlib.h diff -u php4/ext/zlib/php_zlib.h:1.28 php4/ext/zlib/php_zlib.h:1.29 --- php4/ext/zlib/php_zlib.h:1.28 Sun Mar 24 13:04:55 2002 +++ php4/ext/zlib/php_zlib.h Fri Apr 5 08:07:43 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zlib.h,v 1.28 2002/03/24 18:04:55 wez Exp $ */ +/* $Id: php_zlib.h,v 1.29 2002/04/05 13:07:43 ssb Exp $ */ #ifndef PHP_ZLIB_H #define PHP_ZLIB_H @@ -26,12 +26,13 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) /* variables for transparent gzip encoding */ - int compression_coding; - z_stream stream; - uLong crc; + int compression_coding; + z_stream stream; + uLong crc; int ob_gzhandler_status; int ob_gzip_coding; int output_compression; + int output_compression_level; ZEND_END_MODULE_GLOBALS(zlib) extern zend_module_entry php_zlib_module_entry; @@ -66,3 +67,11 @@ #define phpext_zlib_ptr zlib_module_ptr #endif /* PHP_ZLIB_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.122 php4/ext/zlib/zlib.c:1.123 --- php4/ext/zlib/zlib.c:1.122 Fri Apr 5 06:51:37 2002 +++ php4/ext/zlib/zlib.c Fri Apr 5 08:07:43 2002 @@ -18,7 +18,7 @@ | Jade Nicoletti <nicoletti@nns.ch> | +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.122 2002/04/05 11:51:37 zeev Exp $ */ +/* $Id: zlib.c,v 1.123 2002/04/05 13:07:43 ssb Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -122,7 +122,7 @@ PHP_RINIT(zlib), NULL, PHP_MINFO(zlib), - NO_VERSION_YET, + "1.1", STANDARD_MODULE_PROPERTIES }; /* }}} */ @@ -151,9 +151,21 @@ } /* }}} */ +/* {{{ OnUpdate_zlib_output_compression_level */ +static PHP_INI_MH(OnUpdate_zlib_output_compression_level) +{ + char *ini_value; + + OnUpdateInt(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + + return SUCCESS; +} +/* }}} */ + PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("zlib.output_compression", "0", PHP_INI_ALL, OnUpdate_zlib_output_compression, output_compression, zend_zlib_globals, zlib_globals) + STD_PHP_INI_ENTRY("zlib.output_compression_level", "-1", PHP_INI_ALL, OnUpdate_zlib_output_compression_level, output_compression_level, zend_zlib_globals, zlib_globals) PHP_INI_END() /* {{{ phpi_destructor_gzclose @@ -690,7 +702,7 @@ /* {{{ php_deflate_string */ -int php_deflate_string(const char *str, uint str_length, char **newstr, uint *new_length, int coding, zend_bool do_start, zend_bool do_end TSRMLS_DC) +int php_deflate_string(const char *str, uint str_length, char **newstr, uint *new_length, int coding, zend_bool do_start, zend_bool do_end, int compression_level TSRMLS_DC) { int err; @@ -703,7 +715,7 @@ switch (coding) { case CODING_GZIP: /* windowBits is passed < 0 to suppress zlib header & trailer */ - if (deflateInit2(&ZLIBG(stream), Z_DEFAULT_COMPRESSION, Z_DEFLATED, + if (deflateInit2(&ZLIBG(stream), compression_level, Z_DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK) { /* TODO: print out error */ @@ -713,7 +725,7 @@ ZLIBG(crc) = crc32(0L, Z_NULL, 0); break; case CODING_DEFLATE: - if (deflateInit(&ZLIBG(stream), Z_DEFAULT_COMPRESSION) != Z_OK) { + if (deflateInit(&ZLIBG(stream), compression_level) != Z_OK) { /* TODO: print out error */ return FAILURE; } @@ -905,7 +917,7 @@ do_end = ((Z_LVAL_PP(zv_mode) & PHP_OUTPUT_HANDLER_END) ? 1 : 0); Z_STRVAL_P(return_value) = NULL; Z_STRLEN_P(return_value) = 0; - if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, do_start, do_end TSRMLS_CC)==SUCCESS) { + if (php_deflate_string(Z_STRVAL_PP(zv_string), Z_STRLEN_PP(zv_string), &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), coding, do_start, do_end, ZLIBG(output_compression_level) TSRMLS_CC)==SUCCESS) { Z_TYPE_P(return_value) = IS_STRING; if (do_start) { switch (coding) { @@ -959,7 +971,7 @@ do_start = (mode & PHP_OUTPUT_HANDLER_START ? 1 : 0); do_end = (mode & PHP_OUTPUT_HANDLER_END ? 1 : 0); - if (php_deflate_string(output, output_len, handled_output, handled_output_len, ZLIBG(ob_gzip_coding), do_start, do_end TSRMLS_CC)!=SUCCESS) { + if (php_deflate_string(output, output_len, handled_output, handled_output_len, ZLIBG(ob_gzip_coding), do_start, do_end, ZLIBG(output_compression_level) TSRMLS_CC)!=SUCCESS) { zend_error(E_ERROR, "Compression failed"); } }

« previous php.cvs (#10900) next »