2 // Copyright (c) 2013-2017 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 // This is a derivative work based on Zlib, copyright below:
9 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
11 This software is provided 'as-is', without any express or implied
12 warranty. In no event will the authors be held liable for any damages
13 arising from the use of this software.
15 Permission is granted to anyone to use this software for any purpose,
16 including commercial applications, and to alter it and redistribute it
17 freely, subject to the following restrictions:
19 1. The origin of this software must not be misrepresented; you must not
20 claim that you wrote the original software. If you use this software
21 in a product, an acknowledgment in the product documentation would be
22 appreciated but is not required.
23 2. Altered source versions must be plainly marked as such, and must not be
24 misrepresented as being the original software.
25 3. This notice may not be removed or altered from any source distribution.
27 Jean-loup Gailly Mark Adler
28 jloup@gzip.org madler@alumni.caltech.edu
30 The data format used by the zlib library is described by RFCs (Request for
31 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
32 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
35 #ifndef BEAST_ZLIB_ZLIB_HPP
36 #define BEAST_ZLIB_ZLIB_HPP
38 #include <beast/config.hpp>
45 #if !defined(__MACTYPES__)
46 typedef unsigned char Byte; /* 8 bits */
48 typedef unsigned int uInt; /* 16 bits or more */
50 /* Possible values of the data_type field (though see inflate()) */
58 /** Deflate codec parameters.
60 Objects of this type are filled in by callers and provided to the
61 deflate codec to define the input and output areas for the next
62 compress or decompress operation.
64 The application must update next_in and avail_in when avail_in has dropped
65 to zero. It must update next_out and avail_out when avail_out has dropped
66 to zero. The application must initialize zalloc, zfree and opaque before
67 calling the init function. All other fields are set by the compression
68 library and must not be updated by the application.
70 The fields total_in and total_out can be used for statistics or progress
71 reports. After compression, total_in holds the total size of the
72 uncompressed data and may be saved for use in the decompressor (particularly
73 if the decompressor wants to decompress everything in a single step).
77 /** A pointer to the next input byte.
79 If there is no more input, this may be set to `nullptr`.
83 /** The number of bytes of input available at `next_in`.
85 If there is no more input, this should be set to zero.
89 /** The total number of input bytes read so far.
91 std::size_t total_in = 0;
93 /** A pointer to the next output byte.
97 /** The remaining bytes of space at `next_out`.
99 std::size_t avail_out;
101 /** The total number of bytes output so far.
103 std::size_t total_out = 0;
105 int data_type = Z_UNKNOWN; // best guess about the data type: binary or text
123 /* compression levels */
126 Z_NO_COMPRESSION = 0,
128 Z_BEST_COMPRESSION = 9,
129 Z_DEFAULT_COMPRESSION = -1
132 /** Compression strategy.
134 These are used when compressing streams.
138 /** Default strategy.
140 This is suitable for general purpose compression, and works
141 well in the majority of cases.
145 /** Filtered strategy.
147 This strategy should be used when the data be compressed
148 is produced by a filter or predictor.
152 /** Huffman-only strategy.
154 This strategy only performs Huffman encoding, without doing
159 /** Run Length Encoding strategy.
161 This strategy limits match distances to one, making it
162 equivalent to run length encoding. This can give better
163 performance for things like PNG image data.
167 /** Fixed table strategy.
169 This strategy prevents the use of dynamic Huffman codes,
170 allowing for a simpler decoder for special applications.