X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_encoding.c;h=286f2b5751eac1b703c44b0fa2063716d431582f;hp=3c5393bcbd7c945cc576ea38a41c6c91404ce80f;hb=refs%2Fheads%2Fv2.4.x;hpb=87db9817d428282792c8146d9c2ae9748ebf6f1e diff --git a/php_http_encoding.c b/php_http_encoding.c index 3c5393b..286f2b5 100644 --- a/php_http_encoding.c +++ b/php_http_encoding.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2013, Michael Wallner | + | Copyright (c) 2004-2014, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -53,7 +53,6 @@ const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, c php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Data does not seem to be chunked encoded"); memcpy(*decoded, encoded, encoded_len); *decoded_len = encoded_len; - decoded[*decoded_len] = '\0'; return encoded + encoded_len; } else { efree(*decoded); @@ -149,7 +148,7 @@ static inline int php_http_inflate_rounds(z_stream *Z, int flush, char **buf, si return status; } -STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC) +ZEND_RESULT_CODE php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC) { int status, level, wbits, strategy; z_stream Z; @@ -181,7 +180,7 @@ STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, c (*encoded)[*encoded_len = Z.total_out] = '\0'; return SUCCESS; } else { - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; } } @@ -190,7 +189,7 @@ STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, c return FAILURE; } -STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC) +ZEND_RESULT_CODE php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC) { z_stream Z; int status, wbits = PHP_HTTP_WINDOW_BITS_ANY; @@ -291,7 +290,7 @@ php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stre return NULL; } -STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s) +ZEND_RESULT_CODE php_http_encoding_stream_reset(php_http_encoding_stream_t **s) { php_http_encoding_stream_t *ss; if ((*s)->ops->dtor) { @@ -304,7 +303,7 @@ STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s) return FAILURE; } -STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len) +ZEND_RESULT_CODE php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len) { if (!s->ops->update) { return FAILURE; @@ -312,7 +311,7 @@ STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char return s->ops->update(s, in_str, in_len, out_str, out_len); } -STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) +ZEND_RESULT_CODE php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) { if (!s->ops->flush) { *out_str = NULL; @@ -330,7 +329,7 @@ zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s) return s->ops->done(s); } -STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) +ZEND_RESULT_CODE php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len) { if (!s->ops->finish) { *out_str = NULL; @@ -479,7 +478,7 @@ static php_http_encoding_stream_t *dechunk_copy(php_http_encoding_stream_t *from return NULL; } -static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len) +static ZEND_RESULT_CODE deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len) { int status; z_streamp ctx = s->ctx; @@ -514,13 +513,13 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to update deflate stream: %s", zError(status)); return FAILURE; } -static STATUS inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len) +static ZEND_RESULT_CODE inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len) { int status; z_streamp ctx = s->ctx; @@ -559,7 +558,7 @@ retry_raw_inflate: return FAILURE; } -static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len) +static ZEND_RESULT_CODE dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len) { php_http_buffer_t tmp; struct dechunk_ctx *ctx = s->ctx; @@ -687,7 +686,7 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si return SUCCESS; } -static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len) +static ZEND_RESULT_CODE deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len) { int status; z_streamp ctx = s->ctx; @@ -710,13 +709,13 @@ static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_ return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to flush deflate stream: %s", zError(status)); return FAILURE; } -static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len) +static ZEND_RESULT_CODE dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len) { struct dechunk_ctx *ctx = s->ctx; @@ -736,7 +735,7 @@ static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_ return SUCCESS; } -static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len) +static ZEND_RESULT_CODE deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len) { int status; z_streamp ctx = s->ctx; @@ -767,13 +766,13 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size return SUCCESS; } - STR_SET(*encoded, NULL); + PTR_SET(*encoded, NULL); *encoded_len = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish deflate stream: %s", zError(status)); return FAILURE; } -static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len) +static ZEND_RESULT_CODE inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len) { int status; z_streamp ctx = s->ctx; @@ -806,7 +805,7 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size return SUCCESS; } - STR_SET(*decoded, NULL); + PTR_SET(*decoded, NULL); *decoded_len = 0; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish inflate stream: %s", zError(status)); return FAILURE; @@ -1072,7 +1071,7 @@ static PHP_METHOD(HttpEncodingStream, finish) RETURN_EMPTY_STRING(); } } else { - STR_FREE(encoded_str); + PTR_FREE(encoded_str); } } }