summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib.c
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2014-09-16 13:45:06 +0100
committerAndrea Faulds <ajf@ajf.me>2014-09-16 13:45:06 +0100
commitdb72160e5ac2b267b9ffa23ad84e62e609382a44 (patch)
tree6e50c2826f98308d500cc826934a503751d4d566 /ext/zlib/zlib.c
parentbe88d0e5d4ab5fdf775f3e38cf054aa0451f0d36 (diff)
parentf469dc7429f2257aac6f46228302408608fbd62f (diff)
downloadphp-git-db72160e5ac2b267b9ffa23ad84e62e609382a44.tar.gz
Merge branch 'master' into integer_semantics
Conflicts: Zend/zend_operators.h
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r--ext/zlib/zlib.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index c38d6eca2c..8e7bd6c40c 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -70,9 +70,9 @@ static int php_zlib_output_encoding(TSRMLS_D)
zval *enc;
if (!ZLIBG(compression_coding)) {
- zend_string *name = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
zend_is_auto_global(name TSRMLS_CC);
- STR_RELEASE(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))) {
convert_to_string(enc);
@@ -315,7 +315,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
Z.zfree = php_zlib_free;
if (Z_OK == (status = deflateInit2(&Z, level, Z_DEFLATED, encoding, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY))) {
- out = STR_ALLOC(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0);
+ out = zend_string_alloc(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0);
Z.next_in = (Bytef *) in_buf;
Z.next_out = (Bytef *) out->val;
@@ -327,11 +327,11 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod
if (Z_STREAM_END == status) {
/* size buffer down to actual length */
- out = STR_REALLOC(out, Z.total_out, 0);
+ out = zend_string_realloc(out, Z.total_out, 0);
out->val[out->len] = '\0';
return out;
} else {
- STR_FREE(out);
+ zend_string_free(out);
}
}
@@ -447,8 +447,8 @@ static void php_zlib_cleanup_ob_gzhandler_mess(TSRMLS_D)
static PHP_FUNCTION(ob_gzhandler)
{
char *in_str;
- int in_len;
- long flags = 0;
+ size_t in_len;
+ zend_long flags = 0;
php_output_context ctx = {0};
int encoding, rv;
@@ -533,11 +533,11 @@ static PHP_FUNCTION(zlib_get_coding_type)
static PHP_FUNCTION(gzfile)
{
char *filename;
- int filename_len;
+ size_t filename_len;
int flags = REPORT_ERRORS;
char buf[8192] = {0};
register int i = 0;
- long use_include_path = 0;
+ 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)) {
@@ -575,10 +575,10 @@ static PHP_FUNCTION(gzopen)
{
char *filename;
char *mode;
- int filename_len, mode_len;
+ size_t filename_len, mode_len;
int flags = REPORT_ERRORS;
php_stream *stream;
- long use_include_path = 0;
+ 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) {
return;
@@ -602,11 +602,11 @@ static PHP_FUNCTION(gzopen)
static PHP_FUNCTION(readgzfile)
{
char *filename;
- int filename_len;
+ size_t filename_len;
int flags = REPORT_ERRORS;
php_stream *stream;
- int size;
- long use_include_path = 0;
+ 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) {
return;
@@ -631,8 +631,8 @@ static PHP_FUNCTION(readgzfile)
static PHP_FUNCTION(name) \
{ \
zend_string *in, *out; \
- long level = -1; \
- long encoding = default_encoding; \
+ 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)) { \
return; \
@@ -643,7 +643,7 @@ static PHP_FUNCTION(name) \
} \
} \
if (level < -1 || level > 9) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "compression level (%ld) must be within -1..9", level); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "compression level (%pd) must be within -1..9", level); \
RETURN_FALSE; \
} \
switch (encoding) { \
@@ -665,14 +665,14 @@ static PHP_FUNCTION(name) \
static PHP_FUNCTION(name) \
{ \
char *in_buf, *out_buf; \
- int in_len; \
+ size_t in_len; \
size_t out_len; \
- long max_len = 0; \
+ zend_long max_len = 0; \
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &in_buf, &in_len, &max_len)) { \
return; \
} \
if (max_len < 0) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "length (%ld) must be greater or equal zero", max_len); \
+ php_error_docref(NULL TSRMLS_CC, 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)) { \
@@ -863,22 +863,28 @@ static const zend_function_entry php_zlib_functions[] = {
/* {{{ OnUpdate_zlib_output_compression */
static PHP_INI_MH(OnUpdate_zlib_output_compression)
{
- int status, int_value;
+ int int_value;
char *ini_value;
+ zend_long *p;
+#ifndef ZTS
+ char *base = (char *) mh_arg2;
+#else
+ char *base;
+
+ base = (char *) ts_resource(*((int *) mh_arg2));
+#endif
if (new_value == NULL) {
return FAILURE;
}
- if (!strncasecmp(new_value, "off", sizeof("off"))) {
- new_value = "0";
- new_value_length = sizeof("0");
- } else if (!strncasecmp(new_value, "on", sizeof("on"))) {
- new_value = "1";
- new_value_length = sizeof("1");
+ if (!strncasecmp(new_value->val, "off", sizeof("off"))) {
+ int_value = 0;
+ } else if (!strncasecmp(new_value->val, "on", sizeof("on"))) {
+ int_value = 1;
+ } else {
+ int_value = zend_atoi(new_value->val, new_value->len);
}
-
- int_value = zend_atoi(new_value, new_value_length);
ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0);
if (ini_value && *ini_value && int_value) {
@@ -886,14 +892,15 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression)
return FAILURE;
}
if (stage == PHP_INI_STAGE_RUNTIME) {
- status = php_output_get_status(TSRMLS_C);
+ int status = php_output_get_status(TSRMLS_C);
if (status & PHP_OUTPUT_SENT) {
php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "Cannot change zlib.output_compression - headers already sent");
return FAILURE;
}
}
- status = OnUpdateLong(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ p = (zend_long *) (base+(size_t) mh_arg1);
+ *p = int_value;
ZLIBG(output_compression) = ZLIBG(output_compression_default);
if (stage == PHP_INI_STAGE_RUNTIME && int_value) {
@@ -902,7 +909,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression)
}
}
- return status;
+ return SUCCESS;
}
/* }}} */
@@ -914,7 +921,7 @@ static PHP_INI_MH(OnUpdate_zlib_output_handler)
return FAILURE;
}
- return OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
/* }}} */
@@ -999,7 +1006,7 @@ static PHP_MINFO_FUNCTION(zlib)
/* }}} */
/* {{{ ZEND_MODULE_GLOBALS_CTOR */
-static ZEND_MODULE_GLOBALS_CTOR_D(zlib)
+static PHP_GINIT_FUNCTION(zlib)
{
zlib_globals->ob_gzhandler = NULL;
zlib_globals->handler_registered = 0;
@@ -1018,7 +1025,7 @@ zend_module_entry php_zlib_module_entry = {
PHP_MINFO(zlib),
"2.0",
PHP_MODULE_GLOBALS(zlib),
- ZEND_MODULE_GLOBALS_CTOR_N(zlib),
+ PHP_GINIT(zlib),
NULL,
NULL,
STANDARD_MODULE_PROPERTIES_EX