xref: /PHP-7.4/ext/zlib/php_zlib.h (revision 92ac598a)
12c0ad3eeSStig Bakken /*
22c0ad3eeSStig Bakken    +----------------------------------------------------------------------+
3d0cb7153SJohannes Schlüter    | PHP Version 7                                                        |
42c0ad3eeSStig Bakken    +----------------------------------------------------------------------+
5*0cf7de1cSZeev Suraski    | Copyright (c) The PHP Group                                          |
62c0ad3eeSStig Bakken    +----------------------------------------------------------------------+
75bd93221Sfoobar    | This source file is subject to version 3.01 of the PHP license,      |
883513d95SDavid Croft    | that is bundled with this package in the file LICENSE, and is        |
9f68c7ff2SJames Cox    | available through the world-wide-web at the following url:           |
105bd93221Sfoobar    | http://www.php.net/license/3_01.txt                                  |
1183513d95SDavid Croft    | If you did not receive a copy of the PHP license and are unable to   |
1283513d95SDavid Croft    | obtain it through the world-wide-web, please send a note to          |
1383513d95SDavid Croft    | license@php.net so we can mail you a copy immediately.               |
142c0ad3eeSStig Bakken    +----------------------------------------------------------------------+
152c0ad3eeSStig Bakken    | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca>                       |
16e665e01eSStanislav Malyshev    |          Stefan R�hrich <sr@linux.de>                                |
1711d24c15SMichael Wallner    |          Michael Wallner <mike@php.net>                              |
182c0ad3eeSStig Bakken    +----------------------------------------------------------------------+
1983513d95SDavid Croft */
202c0ad3eeSStig Bakken 
2116017f6dSSascha Schumann #ifndef PHP_ZLIB_H
2216017f6dSSascha Schumann #define PHP_ZLIB_H
232c0ad3eeSStig Bakken 
24663074b6SAnatol Belski #include "php_version.h"
25663074b6SAnatol Belski #define PHP_ZLIB_VERSION PHP_VERSION
26663074b6SAnatol Belski 
270f7f5c2cSZeev Suraski #include <zlib.h>
280f7f5c2cSZeev Suraski 
2911d24c15SMichael Wallner #define PHP_ZLIB_ENCODING_RAW		-0xf
3011d24c15SMichael Wallner #define PHP_ZLIB_ENCODING_GZIP		0x1f
3111d24c15SMichael Wallner #define PHP_ZLIB_ENCODING_DEFLATE	0x0f
3211d24c15SMichael Wallner 
3311d24c15SMichael Wallner #define PHP_ZLIB_ENCODING_ANY		0x2f
3411d24c15SMichael Wallner 
3511d24c15SMichael Wallner #define PHP_ZLIB_OUTPUT_HANDLER_NAME "zlib output compression"
3611d24c15SMichael Wallner #define PHP_ZLIB_BUFFER_SIZE_GUESS(in_len) (((size_t) ((double) in_len * (double) 1.015)) + 10 + 8 + 4 + 1)
3711d24c15SMichael Wallner 
3811d24c15SMichael Wallner typedef struct _php_zlib_buffer {
3911d24c15SMichael Wallner 	char *data;
4011d24c15SMichael Wallner 	char *aptr;
4111d24c15SMichael Wallner 	size_t used;
4211d24c15SMichael Wallner 	size_t free;
4311d24c15SMichael Wallner 	size_t size;
4411d24c15SMichael Wallner } php_zlib_buffer;
45af49e58fSJani Taskinen 
4611d24c15SMichael Wallner typedef struct _php_zlib_context {
4711d24c15SMichael Wallner 	z_stream Z;
48dd17e18fSBob Weinand 	char *inflateDict;
4907c7445dSAnatol Belski 	int status;
50dd17e18fSBob Weinand 	size_t inflateDictlen;
5111d24c15SMichael Wallner 	php_zlib_buffer buffer;
5211d24c15SMichael Wallner } php_zlib_context;
53af49e58fSJani Taskinen 
54e665e01eSStanislav Malyshev ZEND_BEGIN_MODULE_GLOBALS(zlib)
55e665e01eSStanislav Malyshev 	/* variables for transparent gzip encoding */
56c3e3c98eSAnatol Belski 	zend_long output_compression;
57c3e3c98eSAnatol Belski 	zend_long output_compression_level;
58e665e01eSStanislav Malyshev 	char *output_handler;
59e665e01eSStanislav Malyshev 	php_zlib_context *ob_gzhandler;
60c3e3c98eSAnatol Belski 	zend_long output_compression_default;
61dd17e18fSBob Weinand 	zend_bool handler_registered;
6258177c27SAnatol Belski 	int compression_coding;
63e665e01eSStanislav Malyshev ZEND_END_MODULE_GLOBALS(zlib);
64e665e01eSStanislav Malyshev 
654e66cce8SAnatol Belski #define ZLIBG(v) ZEND_MODULE_GLOBALS_ACCESSOR(zlib, v)
664e66cce8SAnatol Belski 
672fa8d67aSDmitry Stogov 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);
6883e495e0SDmitry Stogov extern const php_stream_ops php_stream_gzio_ops;
690f06df31SDmitry Stogov extern const php_stream_wrapper php_stream_gzip_wrapper;
7083e495e0SDmitry Stogov extern const php_stream_filter_factory php_zlib_filter_factory;
7111d24c15SMichael Wallner extern zend_module_entry php_zlib_module_entry;
7211d24c15SMichael Wallner #define zlib_module_ptr &php_zlib_module_entry
7311d24c15SMichael Wallner #define phpext_zlib_ptr zlib_module_ptr
74cedb39eeSHartmut Holzgraefe 
7516017f6dSSascha Schumann #endif /* PHP_ZLIB_H */
76