2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
9 // This is a derivative work based on Zlib, copyright below:
11 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
13 This software is provided 'as-is', without any express or implied
14 warranty. In no event will the authors be held liable for any damages
15 arising from the use of this software.
17 Permission is granted to anyone to use this software for any purpose,
18 including commercial applications, and to alter it and redistribute it
19 freely, subject to the following restrictions:
21 1. The origin of this software must not be misrepresented; you must not
22 claim that you wrote the original software. If you use this software
23 in a product, an acknowledgment in the product documentation would be
24 appreciated but is not required.
25 2. Altered source versions must be plainly marked as such, and must not be
26 misrepresented as being the original software.
27 3. This notice may not be removed or altered from any source distribution.
29 Jean-loup Gailly Mark Adler
30 jloup@gzip.org madler@alumni.caltech.edu
32 The data format used by the zlib library is described by RFCs (Request for
33 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
34 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
37 #ifndef BOOST_BEAST_ZLIB_ZLIB_HPP
38 #define BOOST_BEAST_ZLIB_ZLIB_HPP
40 #include <boost/beast/core/detail/config.hpp>
48 #if !defined(__MACTYPES__)
49 using Byte = unsigned char; // 8 bits
51 using uInt = unsigned int; // 16 bits or more
53 /* Possible values of the data_type field (though see inflate()) */
61 /** Deflate codec parameters.
63 Objects of this type are filled in by callers and provided to the
64 deflate codec to define the input and output areas for the next
65 compress or decompress operation.
67 The application must update next_in and avail_in when avail_in has dropped
68 to zero. It must update next_out and avail_out when avail_out has dropped
69 to zero. The application must initialize zalloc, zfree and opaque before
70 calling the init function. All other fields are set by the compression
71 library and must not be updated by the application.
73 The fields total_in and total_out can be used for statistics or progress
74 reports. After compression, total_in holds the total size of the
75 uncompressed data and may be saved for use in the decompressor (particularly
76 if the decompressor wants to decompress everything in a single step).
80 /** A pointer to the next input byte.
82 If there is no more input, this may be set to `nullptr`.
86 /** The number of bytes of input available at `next_in`.
88 If there is no more input, this should be set to zero.
92 /** The total number of input bytes read so far.
94 std::size_t total_in = 0;
96 /** A pointer to the next output byte.
100 /** The remaining bytes of space at `next_out`.
102 std::size_t avail_out;
104 /** The total number of bytes output so far.
106 std::size_t total_out = 0;
108 int data_type = unknown; // best guess about the data type: binary or text
126 /* compression levels */
135 /** Compression strategy.
137 These are used when compressing streams.
141 /** Default strategy.
143 This is suitable for general purpose compression, and works
144 well in the majority of cases.
148 /** Filtered strategy.
150 This strategy should be used when the data be compressed
151 is produced by a filter or predictor.
155 /** Huffman-only strategy.
157 This strategy only performs Huffman encoding, without doing
162 /** Run Length Encoding strategy.
164 This strategy limits match distances to one, making it
165 equivalent to run length encoding. This can give better
166 performance for things like PNG image data.
170 /** Fixed table strategy.
172 This strategy prevents the use of dynamic Huffman codes,
173 allowing for a simpler decoder for special applications.