X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_filter.c;h=2c5335848910682695489a3a8576d52e3dad9016;hp=1a57399071f0dbb79bca68245c4bed71c7ab2c91;hb=2769c041b77a0aaba7acbee4ae469571eaeb2b0a;hpb=06b1391fadd8ae765cdc70d519afc832e63b6f64 diff --git a/php_http_filter.c b/php_http_filter.c index 1a57399..2c53358 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -6,13 +6,11 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2010, Michael Wallner | + | Copyright (c) 2004-2011, Michael Wallner | +--------------------------------------------------------------------+ */ -/* $Id: http_filter_api.c 292841 2009-12-31 08:48:57Z mike $ */ - -#include "php_http.h" +#include "php_http_api.h" PHP_MINIT_FUNCTION(http_filter) { @@ -297,7 +295,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) } if (ptr->buflen) { - php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -317,7 +315,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) char *encoded = NULL; size_t encoded_len = 0; - php_http_encoding_stream_flush(buffer, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_flush(buffer, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -331,7 +329,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) char *encoded = NULL; size_t encoded_len = 0; - php_http_encoding_stream_finish(buffer, &encoded, &encoded_len TSRMLS_CC); + php_http_encoding_stream_finish(buffer, &encoded, &encoded_len); if (encoded) { if (encoded_len) { out_avail = 1; @@ -346,7 +344,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib) static PHP_HTTP_FILTER_DESTRUCTOR(zlib) { PHP_HTTP_FILTER_BUFFER(zlib) *buffer = (PHP_HTTP_FILTER_BUFFER(zlib) *) this->abstract; - php_http_encoding_stream_free(&buffer TSRMLS_CC); + php_http_encoding_stream_free(&buffer); } static PHP_HTTP_FILTER_OPS(deflate) = { @@ -365,7 +363,28 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int { zval **tmp = ¶ms; php_stream_filter *f = NULL; + int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; + if (params) { + switch (Z_TYPE_P(params)) { + case IS_ARRAY: + case IS_OBJECT: + if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { + break; + } + /* no break */ + default: + { + zval *num = php_http_ztyp(IS_LONG, *tmp); + + flags |= (Z_LVAL_P(num) & 0x0fffffff); + zval_ptr_dtor(&num); + + } + break; + } + } + if (!strcasecmp(name, "http.chunked_decode")) { PHP_HTTP_FILTER_BUFFER(chunked_decode) *b = NULL; @@ -382,39 +401,21 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int } else if (!strcasecmp(name, "http.inflate")) { - int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL; if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), flags TSRMLS_CC))) { if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(inflate), b, p))) { - php_http_encoding_stream_free(&b TSRMLS_CC); + php_http_encoding_stream_free(&b); } } } else if (!strcasecmp(name, "http.deflate")) { - int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0; PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL; - if (params) { - switch (Z_TYPE_P(params)) { - case IS_ARRAY: - case IS_OBJECT: - if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { - break; - } - default: - { - zval *num = php_http_ztyp(IS_LONG, *tmp); - - flags |= (Z_LVAL_P(num) & 0x0fffffff); - zval_ptr_dtor(&num); - } - } - } if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), flags TSRMLS_CC))) { if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(deflate), b, p))) { - php_http_encoding_stream_free(&b TSRMLS_CC); + php_http_encoding_stream_free(&b); } } }