diff options
Diffstat (limited to 'ext/zlib')
-rw-r--r-- | ext/zlib/config.w32 | 2 | ||||
-rw-r--r-- | ext/zlib/config0.m4 | 2 | ||||
-rw-r--r-- | ext/zlib/php_zlib.h | 4 | ||||
-rw-r--r-- | ext/zlib/zlib.c | 145 | ||||
-rw-r--r-- | ext/zlib/zlib_filter.c | 56 | ||||
-rw-r--r-- | ext/zlib/zlib_fopen_wrapper.c | 18 |
6 files changed, 116 insertions, 111 deletions
diff --git a/ext/zlib/config.w32 b/ext/zlib/config.w32 index 000b1ccabb..1a57aa6110 100644 --- a/ext/zlib/config.w32 +++ b/ext/zlib/config.w32 @@ -7,7 +7,7 @@ if (PHP_ZLIB == "yes") { if (CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_ZLIB) && CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) { - EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", null, "/D ZLIB_EXPORTS"); + EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", null, "/D ZLIB_EXPORTS /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_ZLIB", 1, "ZLIB support"); if (!PHP_ZLIB_SHARED) { diff --git a/ext/zlib/config0.m4 b/ext/zlib/config0.m4 index ebf67cc001..ab94c15fe0 100644 --- a/ext/zlib/config0.m4 +++ b/ext/zlib/config0.m4 @@ -9,7 +9,7 @@ PHP_ARG_WITH(zlib-dir,if the location of ZLIB install directory is defined, [ --with-zlib-dir=<DIR> Define the location of zlib install directory], no, no) if test "$PHP_ZLIB" != "no" || test "$PHP_ZLIB_DIR" != "no"; then - PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared) + PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(ZLIB_SHARED_LIBADD) if test "$PHP_ZLIB" != "yes" -a "$PHP_ZLIB" != "no"; then diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index ba829b5888..a93e46d339 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -58,7 +58,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zlib) int compression_coding; ZEND_END_MODULE_GLOBALS(zlib); -php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); +php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); extern php_stream_ops php_stream_gzio_ops; extern php_stream_wrapper php_stream_gzip_wrapper; extern php_stream_filter_factory php_zlib_filter_factory; @@ -68,7 +68,7 @@ extern zend_module_entry php_zlib_module_entry; #ifdef ZTS # include "TSRM.h" -# define ZLIBG(v) TSRMG(zlib_globals_id, zend_zlib_globals *, v) +# define ZLIBG(v) ZEND_TSRMG(zlib_globals_id, zend_zlib_globals *, v) #else # define ZLIBG(v) (zlib_globals.v) #endif diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index c3548eae53..3f66ed106d 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -62,13 +62,13 @@ static void php_zlib_free(voidpf opaque, voidpf address) /* }}} */ /* {{{ php_zlib_output_conflict_check() */ -static int php_zlib_output_conflict_check(const char *handler_name, size_t handler_name_len TSRMLS_DC) +static int php_zlib_output_conflict_check(const char *handler_name, size_t handler_name_len) { - if (php_output_get_level(TSRMLS_C) > 0) { - if (php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME) TSRMLS_CC) - || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("ob_gzhandler") TSRMLS_CC) - || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("mb_output_handler") TSRMLS_CC) - || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("URL-Rewriter") TSRMLS_CC)) { + if (php_output_get_level() > 0) { + if (php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME)) + || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("ob_gzhandler")) + || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("mb_output_handler")) + || php_output_handler_conflict(handler_name, handler_name_len, ZEND_STRL("URL-Rewriter"))) { return FAILURE; } } @@ -77,13 +77,13 @@ static int php_zlib_output_conflict_check(const char *handler_name, size_t handl /* }}} */ /* {{{ php_zlib_output_encoding() */ -static int php_zlib_output_encoding(TSRMLS_D) +static int php_zlib_output_encoding(void) { zval *enc; if (!ZLIBG(compression_coding)) { zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); - zend_is_auto_global(name TSRMLS_CC); + zend_is_auto_global(name); zend_string_release(name); if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && (enc = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING") - 1))) { @@ -191,7 +191,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o php_zlib_context *ctx = *(php_zlib_context **) handler_context; PHP_OUTPUT_TSRMLS(output_context); - if (!php_zlib_output_encoding(TSRMLS_C)) { + if (!php_zlib_output_encoding()) { /* "Vary: Accept-Encoding" header sent along uncompressed content breaks caching in MSIE, so let's just send it with successfully compressed content or unless the complete buffer gets discarded, see http://bugs.php.net/40325; @@ -205,7 +205,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o if ((output_context->op & PHP_OUTPUT_HANDLER_START) && (output_context->op != (PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CLEAN|PHP_OUTPUT_HANDLER_FINAL)) ) { - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0); } return FAILURE; } @@ -217,7 +217,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) { int flags; - if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags TSRMLS_CC)) { + if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags)) { /* only run this once */ if (!(flags & PHP_OUTPUT_HANDLER_STARTED)) { if (SG(headers_sent) || !ZLIBG(output_compression)) { @@ -226,17 +226,17 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o } switch (ZLIBG(compression_coding)) { case PHP_ZLIB_ENCODING_GZIP: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1); break; case PHP_ZLIB_ENCODING_DEFLATE: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1); break; default: deflateEnd(&ctx->Z); return FAILURE; } - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); - php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0); + php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL); } } } @@ -246,7 +246,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o /* }}} */ /* {{{ php_zlib_output_handler_context_init() */ -static php_zlib_context *php_zlib_output_handler_context_init(TSRMLS_D) +static php_zlib_context *php_zlib_output_handler_context_init(void) { php_zlib_context *ctx = (php_zlib_context *) ecalloc(1, sizeof(php_zlib_context)); ctx->Z.zalloc = php_zlib_alloc; @@ -256,7 +256,7 @@ static php_zlib_context *php_zlib_output_handler_context_init(TSRMLS_D) /* }}} */ /* {{{ php_zlib_output_handler_context_dtor() */ -static void php_zlib_output_handler_context_dtor(void *opaq TSRMLS_DC) +static void php_zlib_output_handler_context_dtor(void *opaq) { php_zlib_context *ctx = (php_zlib_context *) opaq; @@ -270,7 +270,7 @@ static void php_zlib_output_handler_context_dtor(void *opaq TSRMLS_DC) /* }}} */ /* {{{ php_zlib_output_handler_init() */ -static php_output_handler *php_zlib_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC) +static php_output_handler *php_zlib_output_handler_init(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags) { php_output_handler *h = NULL; @@ -280,8 +280,8 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name ZLIBG(handler_registered) = 1; - if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags TSRMLS_CC))) { - php_output_handler_set_context(h, php_zlib_output_handler_context_init(TSRMLS_C), php_zlib_output_handler_context_dtor TSRMLS_CC); + if ((h = php_output_handler_create_internal(handler_name, handler_name_len, php_zlib_output_handler, chunk_size, flags))) { + php_output_handler_set_context(h, php_zlib_output_handler_context_init(), php_zlib_output_handler_context_dtor); } return h; @@ -289,7 +289,7 @@ static php_output_handler *php_zlib_output_handler_init(const char *handler_name /* }}} */ /* {{{ php_zlib_output_compression_start() */ -static void php_zlib_output_compression_start(TSRMLS_D) +static void php_zlib_output_compression_start(void) { zval zoh; php_output_handler *h; @@ -301,12 +301,12 @@ static void php_zlib_output_compression_start(TSRMLS_D) ZLIBG(output_compression) = PHP_OUTPUT_HANDLER_DEFAULT_SIZE; /* break omitted intentionally */ default: - if ( php_zlib_output_encoding(TSRMLS_C) && - (h = php_zlib_output_handler_init(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC)) && - (SUCCESS == php_output_handler_start(h TSRMLS_CC))) { + if ( php_zlib_output_encoding() && + (h = php_zlib_output_handler_init(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS)) && + (SUCCESS == php_output_handler_start(h))) { if (ZLIBG(output_handler) && *ZLIBG(output_handler)) { ZVAL_STRING(&zoh, ZLIBG(output_handler)); - php_output_start_user(&zoh, ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC); + php_output_start_user(&zoh, ZLIBG(output_compression), PHP_OUTPUT_HANDLER_STDFLAGS); zval_ptr_dtor(&zoh); } } @@ -316,7 +316,7 @@ static void php_zlib_output_compression_start(TSRMLS_D) /* }}} */ /* {{{ php_zlib_encode() */ -static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encoding, int level TSRMLS_DC) +static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encoding, int level) { int status; z_stream Z; @@ -347,7 +347,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod } } - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", zError(status)); + php_error_docref(NULL, E_WARNING, "%s", zError(status)); return NULL; } /* }}} */ @@ -402,7 +402,7 @@ static inline int php_zlib_inflate_rounds(z_stream *Z, size_t max, char **buf, s /* }}} */ /* {{{ php_zlib_decode() */ -static int php_zlib_decode(const char *in_buf, size_t in_len, char **out_buf, size_t *out_len, int encoding, size_t max_len TSRMLS_DC) +static int php_zlib_decode(const char *in_buf, size_t in_len, char **out_buf, size_t *out_len, int encoding, size_t max_len) { int status = Z_DATA_ERROR; z_stream Z; @@ -438,17 +438,17 @@ retry_raw_inflate: *out_buf = NULL; *out_len = 0; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", zError(status)); + php_error_docref(NULL, E_WARNING, "%s", zError(status)); return FAILURE; } /* }}} */ /* {{{ php_zlib_cleanup_ob_gzhandler_mess() */ -static void php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_D) +static void php_zlib_cleanup_ob_gzhandler_mess(void) { if (ZLIBG(ob_gzhandler)) { deflateEnd(&(ZLIBG(ob_gzhandler)->Z)); - php_zlib_output_handler_context_dtor(ZLIBG(ob_gzhandler) TSRMLS_CC); + php_zlib_output_handler_context_dtor(ZLIBG(ob_gzhandler)); ZLIBG(ob_gzhandler) = NULL; } } @@ -472,31 +472,30 @@ static PHP_FUNCTION(ob_gzhandler) * - OG(running) is not set or set to any other output handler * - we have to mess around with php_output_context */ - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &in_str, &in_len, &flags)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "sl", &in_str, &in_len, &flags)) { RETURN_FALSE; } - if (!(encoding = php_zlib_output_encoding(TSRMLS_C))) { + if (!(encoding = php_zlib_output_encoding())) { RETURN_FALSE; } if (flags & PHP_OUTPUT_HANDLER_START) { switch (encoding) { case PHP_ZLIB_ENCODING_GZIP: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Content-Encoding: gzip"), 1, 1); break; case PHP_ZLIB_ENCODING_DEFLATE: - sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1); break; } - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0); } if (!ZLIBG(ob_gzhandler)) { - ZLIBG(ob_gzhandler) = php_zlib_output_handler_context_init(TSRMLS_C); + ZLIBG(ob_gzhandler) = php_zlib_output_handler_context_init(); } - TSRMLS_SET_CTX(ctx.tsrm_ls); ctx.op = flags; ctx.in.data = in_str; ctx.in.used = in_len; @@ -507,7 +506,7 @@ static PHP_FUNCTION(ob_gzhandler) if (ctx.out.data && ctx.out.free) { efree(ctx.out.data); } - php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C); + php_zlib_cleanup_ob_gzhandler_mess(); RETURN_FALSE; } @@ -552,7 +551,7 @@ static PHP_FUNCTION(gzfile) zend_long use_include_path = 0; php_stream *stream; - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &use_include_path)) { + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &filename, &filename_len, &use_include_path)) { return; } @@ -561,7 +560,7 @@ static PHP_FUNCTION(gzfile) } /* using a stream here is a bit more efficient (resource wise) than php_gzopen_wrapper */ - stream = php_stream_gzopen(NULL, filename, "rb", flags, NULL, NULL STREAMS_CC TSRMLS_CC); + stream = php_stream_gzopen(NULL, filename, "rb", flags, NULL, NULL STREAMS_CC); if (!stream) { /* Error reporting is already done by stream code */ @@ -592,7 +591,7 @@ static PHP_FUNCTION(gzopen) php_stream *stream; zend_long use_include_path = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) { return; } @@ -600,7 +599,7 @@ static PHP_FUNCTION(gzopen) flags |= USE_PATH; } - stream = php_stream_gzopen(NULL, filename, mode, flags, NULL, NULL STREAMS_CC TSRMLS_CC); + stream = php_stream_gzopen(NULL, filename, mode, flags, NULL, NULL STREAMS_CC); if (!stream) { RETURN_FALSE; @@ -620,7 +619,7 @@ static PHP_FUNCTION(readgzfile) size_t size; zend_long use_include_path = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &use_include_path) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &filename, &filename_len, &use_include_path) == FAILURE) { return; } @@ -628,7 +627,7 @@ static PHP_FUNCTION(readgzfile) flags |= USE_PATH; } - stream = php_stream_gzopen(NULL, filename, "rb", flags, NULL, NULL STREAMS_CC TSRMLS_CC); + stream = php_stream_gzopen(NULL, filename, "rb", flags, NULL, NULL STREAMS_CC); if (!stream) { RETURN_FALSE; @@ -646,16 +645,16 @@ static PHP_FUNCTION(name) \ zend_long level = -1; \ zend_long encoding = default_encoding; \ if (default_encoding) { \ - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|ll", &in, &level, &encoding)) { \ + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|ll", &in, &level, &encoding)) { \ return; \ } \ } else { \ - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|l", &in, &encoding, &level)) { \ + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "Sl|l", &in, &encoding, &level)) { \ return; \ } \ } \ if (level < -1 || level > 9) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "compression level (%pd) must be within -1..9", level); \ + php_error_docref(NULL, E_WARNING, "compression level (%pd) must be within -1..9", level); \ RETURN_FALSE; \ } \ switch (encoding) { \ @@ -664,10 +663,10 @@ static PHP_FUNCTION(name) \ case PHP_ZLIB_ENCODING_DEFLATE: \ break; \ default: \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); \ + php_error_docref(NULL, E_WARNING, "encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); \ RETURN_FALSE; \ } \ - if ((out = php_zlib_encode(in->val, in->len, encoding, level TSRMLS_CC)) == NULL) { \ + if ((out = php_zlib_encode(in->val, in->len, encoding, level)) == NULL) { \ RETURN_FALSE; \ } \ RETURN_STR(out); \ @@ -680,14 +679,14 @@ static PHP_FUNCTION(name) \ size_t in_len; \ size_t out_len; \ zend_long max_len = 0; \ - if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &in_buf, &in_len, &max_len)) { \ + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &in_buf, &in_len, &max_len)) { \ return; \ } \ if (max_len < 0) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "length (%pd) must be greater or equal zero", max_len); \ + php_error_docref(NULL, E_WARNING, "length (%pd) must be greater or equal zero", max_len); \ RETURN_FALSE; \ } \ - if (SUCCESS != php_zlib_decode(in_buf, in_len, &out_buf, &out_len, encoding, max_len TSRMLS_CC)) { \ + if (SUCCESS != php_zlib_decode(in_buf, in_len, &out_buf, &out_len, encoding, max_len)) { \ RETURN_FALSE; \ } \ RETVAL_STRINGL(out_buf, out_len); \ @@ -736,6 +735,9 @@ PHP_ZLIB_DECODE_FUNC(gzuncompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ #ifdef COMPILE_DL_ZLIB +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(php_zlib) #endif @@ -900,13 +902,13 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0); if (ini_value && *ini_value && int_value) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_CORE_ERROR, "Cannot use both zlib.output_compression and output_handler together!!"); + php_error_docref("ref.outcontrol", E_CORE_ERROR, "Cannot use both zlib.output_compression and output_handler together!!"); return FAILURE; } if (stage == PHP_INI_STAGE_RUNTIME) { - int status = php_output_get_status(TSRMLS_C); + int status = php_output_get_status(); if (status & PHP_OUTPUT_SENT) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "Cannot change zlib.output_compression - headers already sent"); + php_error_docref("ref.outcontrol", E_WARNING, "Cannot change zlib.output_compression - headers already sent"); return FAILURE; } } @@ -916,8 +918,8 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) ZLIBG(output_compression) = ZLIBG(output_compression_default); if (stage == PHP_INI_STAGE_RUNTIME && int_value) { - if (!php_output_handler_started(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME) TSRMLS_CC)) { - php_zlib_output_compression_start(TSRMLS_C); + if (!php_output_handler_started(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME))) { + php_zlib_output_compression_start(); } } @@ -928,12 +930,12 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) /* {{{ OnUpdate_zlib_output_handler */ static PHP_INI_MH(OnUpdate_zlib_output_handler) { - if (stage == PHP_INI_STAGE_RUNTIME && (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "Cannot change zlib.output_handler - headers already sent"); + if (stage == PHP_INI_STAGE_RUNTIME && (php_output_get_status() & PHP_OUTPUT_SENT)) { + php_error_docref("ref.outcontrol", E_WARNING, "Cannot change zlib.output_handler - headers already sent"); return FAILURE; } - return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } /* }}} */ @@ -949,12 +951,12 @@ PHP_INI_END() /* {{{ PHP_MINIT_FUNCTION */ static PHP_MINIT_FUNCTION(zlib) { - php_register_url_stream_wrapper("compress.zlib", &php_stream_gzip_wrapper TSRMLS_CC); - php_stream_filter_register_factory("zlib.*", &php_zlib_filter_factory TSRMLS_CC); + php_register_url_stream_wrapper("compress.zlib", &php_stream_gzip_wrapper); + php_stream_filter_register_factory("zlib.*", &php_zlib_filter_factory); - php_output_handler_alias_register(ZEND_STRL("ob_gzhandler"), php_zlib_output_handler_init TSRMLS_CC); - php_output_handler_conflict_register(ZEND_STRL("ob_gzhandler"), php_zlib_output_conflict_check TSRMLS_CC); - php_output_handler_conflict_register(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), php_zlib_output_conflict_check TSRMLS_CC); + php_output_handler_alias_register(ZEND_STRL("ob_gzhandler"), php_zlib_output_handler_init); + php_output_handler_conflict_register(ZEND_STRL("ob_gzhandler"), php_zlib_output_conflict_check); + php_output_handler_conflict_register(ZEND_STRL(PHP_ZLIB_OUTPUT_HANDLER_NAME), php_zlib_output_conflict_check); REGISTER_LONG_CONSTANT("FORCE_GZIP", PHP_ZLIB_ENCODING_GZIP, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FORCE_DEFLATE", PHP_ZLIB_ENCODING_DEFLATE, CONST_CS|CONST_PERSISTENT); @@ -970,8 +972,8 @@ static PHP_MINIT_FUNCTION(zlib) /* {{{ PHP_MSHUTDOWN_FUNCTION */ static PHP_MSHUTDOWN_FUNCTION(zlib) { - php_unregister_url_stream_wrapper("zlib" TSRMLS_CC); - php_stream_filter_unregister_factory("zlib.*" TSRMLS_CC); + php_unregister_url_stream_wrapper("zlib"); + php_stream_filter_unregister_factory("zlib.*"); UNREGISTER_INI_ENTRIES(); @@ -985,7 +987,7 @@ static PHP_RINIT_FUNCTION(zlib) ZLIBG(compression_coding) = 0; if (!ZLIBG(handler_registered)) { ZLIBG(output_compression) = ZLIBG(output_compression_default); - php_zlib_output_compression_start(TSRMLS_C); + php_zlib_output_compression_start(); } return SUCCESS; @@ -995,7 +997,7 @@ static PHP_RINIT_FUNCTION(zlib) /* {{{ PHP_RSHUTDOWN_FUNCTION */ static PHP_RSHUTDOWN_FUNCTION(zlib) { - php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_C); + php_zlib_cleanup_ob_gzhandler_mess(); ZLIBG(handler_registered) = 0; return SUCCESS; @@ -1020,6 +1022,9 @@ static PHP_MINFO_FUNCTION(zlib) /* {{{ ZEND_MODULE_GLOBALS_CTOR */ static PHP_GINIT_FUNCTION(zlib) { +#if defined(COMPILE_DL_ZLIB) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif zlib_globals->ob_gzhandler = NULL; zlib_globals->handler_registered = 0; } diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index 2f0d1f7706..6f7a872788 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -58,7 +58,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags - TSRMLS_DC) + ) { php_zlib_filter_data *data; php_stream_bucket *bucket; @@ -76,7 +76,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( while (buckets_in->head) { size_t bin = 0, desired; - bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC); + bucket = php_stream_bucket_make_writeable(buckets_in->head); while (bin < (unsigned int) bucket->buflen) { @@ -98,7 +98,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( data->finished = '\1'; } else if (status != Z_OK) { /* Something bad happened */ - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket); /* reset these because despite the error the filter may be used again */ data->strm.next_in = data->inbuf; data->strm.avail_in = 0; @@ -112,20 +112,20 @@ static php_stream_filter_status_t php_zlib_inflate_filter( if (data->strm.avail_out < data->outbuf_len) { php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm.avail_out; - out_bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0 TSRMLS_CC); - php_stream_bucket_append(buckets_out, out_bucket TSRMLS_CC); + out_bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0); + php_stream_bucket_append(buckets_out, out_bucket); data->strm.avail_out = data->outbuf_len; data->strm.next_out = data->outbuf; exit_status = PSFS_PASS_ON; } else if (status == Z_STREAM_END && data->strm.avail_out >= data->outbuf_len) { /* no more data to decompress, and nothing was spat out */ - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket); return PSFS_PASS_ON; } } consumed += bucket->buflen; - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket); } if (!data->finished && flags & PSFS_FLAG_FLUSH_CLOSE) { @@ -136,8 +136,8 @@ static php_stream_filter_status_t php_zlib_inflate_filter( if (data->strm.avail_out < data->outbuf_len) { size_t bucketlen = data->outbuf_len - data->strm.avail_out; - bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0 TSRMLS_CC); - php_stream_bucket_append(buckets_out, bucket TSRMLS_CC); + bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0); + php_stream_bucket_append(buckets_out, bucket); data->strm.avail_out = data->outbuf_len; data->strm.next_out = data->outbuf; exit_status = PSFS_PASS_ON; @@ -152,7 +152,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter( return exit_status; } -static void php_zlib_inflate_dtor(php_stream_filter *thisfilter TSRMLS_DC) +static void php_zlib_inflate_dtor(php_stream_filter *thisfilter) { if (thisfilter && Z_PTR(thisfilter->abstract)) { php_zlib_filter_data *data = Z_PTR(thisfilter->abstract); @@ -181,7 +181,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter( php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags - TSRMLS_DC) + ) { php_zlib_filter_data *data; php_stream_bucket *bucket; @@ -201,7 +201,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter( bucket = buckets_in->head; - bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC); + bucket = php_stream_bucket_make_writeable(bucket); while (bin < (unsigned int) bucket->buflen) { desired = bucket->buflen - bin; @@ -214,7 +214,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter( status = deflate(&(data->strm), flags & PSFS_FLAG_FLUSH_CLOSE ? Z_FULL_FLUSH : (flags & PSFS_FLAG_FLUSH_INC ? Z_SYNC_FLUSH : Z_NO_FLUSH)); if (status != Z_OK) { /* Something bad happened */ - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket); return PSFS_ERR_FATAL; } desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */ @@ -226,15 +226,15 @@ static php_stream_filter_status_t php_zlib_deflate_filter( php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm.avail_out; - out_bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0 TSRMLS_CC); - php_stream_bucket_append(buckets_out, out_bucket TSRMLS_CC); + out_bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0); + php_stream_bucket_append(buckets_out, out_bucket); data->strm.avail_out = data->outbuf_len; data->strm.next_out = data->outbuf; exit_status = PSFS_PASS_ON; } } consumed += bucket->buflen; - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket); } if (flags & PSFS_FLAG_FLUSH_CLOSE) { @@ -245,8 +245,8 @@ static php_stream_filter_status_t php_zlib_deflate_filter( if (data->strm.avail_out < data->outbuf_len) { size_t bucketlen = data->outbuf_len - data->strm.avail_out; - bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0 TSRMLS_CC); - php_stream_bucket_append(buckets_out, bucket TSRMLS_CC); + bucket = php_stream_bucket_new(stream, estrndup(data->outbuf, bucketlen), bucketlen, 1, 0); + php_stream_bucket_append(buckets_out, bucket); data->strm.avail_out = data->outbuf_len; data->strm.next_out = data->outbuf; exit_status = PSFS_PASS_ON; @@ -261,7 +261,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter( return exit_status; } -static void php_zlib_deflate_dtor(php_stream_filter *thisfilter TSRMLS_DC) +static void php_zlib_deflate_dtor(php_stream_filter *thisfilter) { if (thisfilter && Z_PTR(thisfilter->abstract)) { php_zlib_filter_data *data = Z_PTR(thisfilter->abstract); @@ -282,7 +282,7 @@ static php_stream_filter_ops php_zlib_deflate_ops = { /* {{{ zlib.* common factory */ -static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *filterparams, int persistent TSRMLS_DC) +static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *filterparams, int persistent) { php_stream_filter_ops *fops = NULL; php_zlib_filter_data *data; @@ -291,7 +291,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* Create this filter */ data = pecalloc(1, sizeof(php_zlib_filter_data), persistent); if (!data) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data)); + php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data)); return NULL; } @@ -303,14 +303,14 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f data->strm.avail_out = data->outbuf_len = data->inbuf_len = 0x8000; data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent); if (!data->inbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len); + php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len); pefree(data, persistent); return NULL; } data->strm.avail_in = 0; data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent); if (!data->outbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len); + php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len); pefree(data->inbuf, persistent); pefree(data, persistent); return NULL; @@ -332,7 +332,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f ZVAL_DUP(&tmp, tmpzval); convert_to_long(&tmp); if (Z_LVAL(tmp) < -MAX_WBITS || Z_LVAL(tmp) > MAX_WBITS + 32) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp)); + php_error_docref(NULL, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp)); } else { windowBits = Z_LVAL(tmp); } @@ -365,7 +365,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* Memory Level (1 - 9) */ if (Z_LVAL(tmp) < 1 || Z_LVAL(tmp) > MAX_MEM_LEVEL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for memory level. (%pd)", Z_LVAL(tmp)); + php_error_docref(NULL, E_WARNING, "Invalid parameter give for memory level. (%pd)", Z_LVAL(tmp)); } else { memLevel = Z_LVAL(tmp); } @@ -377,7 +377,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* log-2 base of history window (9 - 15) */ if (Z_LVAL(tmp) < -MAX_WBITS || Z_LVAL(tmp) > MAX_WBITS + 16) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp)); + php_error_docref(NULL, E_WARNING, "Invalid parameter give for window size. (%pd)", Z_LVAL(tmp)); } else { windowBits = Z_LVAL(tmp); } @@ -400,13 +400,13 @@ factory_setlevel: /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */ if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%pd)", Z_LVAL(tmp)); + php_error_docref(NULL, E_WARNING, "Invalid compression level specified. (%pd)", Z_LVAL(tmp)); } else { level = Z_LVAL(tmp); } break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored"); + php_error_docref(NULL, E_WARNING, "Invalid filter parameter, ignored"); } } status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0); diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c index 796b8a54e0..329180bc3b 100644 --- a/ext/zlib/zlib_fopen_wrapper.c +++ b/ext/zlib/zlib_fopen_wrapper.c @@ -32,7 +32,7 @@ struct php_gz_stream_data_t { php_stream *stream; }; -static size_t php_gziop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) +static size_t php_gziop_read(php_stream *stream, char *buf, size_t count) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract; int read; @@ -47,7 +47,7 @@ static size_t php_gziop_read(php_stream *stream, char *buf, size_t count TSRMLS_ return (size_t)((read < 0) ? 0 : read); } -static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) +static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract; int wrote; @@ -58,14 +58,14 @@ static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count return (size_t)((wrote < 0) ? 0 : wrote); } -static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs TSRMLS_DC) +static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffs) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract; assert(self != NULL); if (whence == SEEK_END) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "SEEK_END is not supported"); + php_error_docref(NULL, E_WARNING, "SEEK_END is not supported"); return -1; } *newoffs = gzseek(self->gz_file, offset, whence); @@ -73,7 +73,7 @@ static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zen return (*newoffs < 0) ? -1 : 0; } -static int php_gziop_close(php_stream *stream, int close_handle TSRMLS_DC) +static int php_gziop_close(php_stream *stream, int close_handle) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract; int ret = EOF; @@ -93,7 +93,7 @@ static int php_gziop_close(php_stream *stream, int close_handle TSRMLS_DC) return ret; } -static int php_gziop_flush(php_stream *stream TSRMLS_DC) +static int php_gziop_flush(php_stream *stream) { struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *) stream->abstract; @@ -111,7 +111,7 @@ php_stream_ops php_stream_gzio_ops = { }; php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) + char **opened_path, php_stream_context *context STREAMS_DC) { struct php_gz_stream_data_t *self; php_stream *stream = NULL, *innerstream = NULL; @@ -119,7 +119,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, con /* sanity check the stream: it can be either read-only or write-only */ if (strchr(mode, '+')) { if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot open a zlib stream for reading and writing at the same time!"); + php_error_docref(NULL, E_WARNING, "cannot open a zlib stream for reading and writing at the same time!"); } return NULL; } @@ -152,7 +152,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, con efree(self); if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "gzopen failed"); + php_error_docref(NULL, E_WARNING, "gzopen failed"); } } |