1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | 14 | Stefan R�hrich <sr@linux.de> | 15 | Michael Wallner <mike@php.net> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 #ifndef PHP_ZLIB_H 20 #define PHP_ZLIB_H 21 22 #include "php_version.h" 23 #define PHP_ZLIB_VERSION PHP_VERSION 24 25 #include <zlib.h> 26 27 #define PHP_ZLIB_ENCODING_RAW -0xf 28 #define PHP_ZLIB_ENCODING_GZIP 0x1f 29 #define PHP_ZLIB_ENCODING_DEFLATE 0x0f 30 31 #define PHP_ZLIB_ENCODING_ANY 0x2f 32 33 #define PHP_ZLIB_OUTPUT_HANDLER_NAME "zlib output compression" 34 #define PHP_ZLIB_BUFFER_SIZE_GUESS(in_len) (((size_t) ((double) in_len * (double) 1.015)) + 10 + 8 + 4 + 1) 35 36 typedef struct _php_zlib_buffer { 37 char *data; 38 char *aptr; 39 size_t used; 40 size_t free; 41 size_t size; 42 } php_zlib_buffer; 43 44 typedef struct _php_zlib_context { 45 z_stream Z; 46 char *inflateDict; 47 int status; 48 size_t inflateDictlen; 49 php_zlib_buffer buffer; 50 zend_object std; 51 } php_zlib_context; 52 53 ZEND_BEGIN_MODULE_GLOBALS(zlib) 54 /* variables for transparent gzip encoding */ 55 zend_long output_compression; 56 zend_long output_compression_level; 57 char *output_handler; 58 php_zlib_context *ob_gzhandler; 59 zend_long output_compression_default; 60 bool handler_registered; 61 int compression_coding; 62 ZEND_END_MODULE_GLOBALS(zlib); 63 64 #define ZLIBG(v) ZEND_MODULE_GLOBALS_ACCESSOR(zlib, v) 65 66 php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); 67 extern const php_stream_ops php_stream_gzio_ops; 68 extern const php_stream_wrapper php_stream_gzip_wrapper; 69 extern const php_stream_filter_factory php_zlib_filter_factory; 70 extern zend_module_entry php_zlib_module_entry; 71 #define zlib_module_ptr &php_zlib_module_entry 72 #define phpext_zlib_ptr zlib_module_ptr 73 74 #endif /* PHP_ZLIB_H */ 75