]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/beast/zlib/zlib.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / beast / zlib / zlib.hpp
CommitLineData
7c673cae 1//
b32b8144 2// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
7c673cae
FG
3//
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)
6//
b32b8144
FG
7// Official repository: https://github.com/boostorg/beast
8//
9
10#ifndef BOOST_BEAST_ZLIB_ZLIB_HPP
11#define BOOST_BEAST_ZLIB_ZLIB_HPP
12
13#include <boost/beast/core/detail/config.hpp>
14#include <cstdint>
15#include <cstdlib>
16
7c673cae
FG
17// This is a derivative work based on Zlib, copyright below:
18/*
19 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
20
21 This software is provided 'as-is', without any express or implied
22 warranty. In no event will the authors be held liable for any damages
23 arising from the use of this software.
24
25 Permission is granted to anyone to use this software for any purpose,
26 including commercial applications, and to alter it and redistribute it
27 freely, subject to the following restrictions:
28
29 1. The origin of this software must not be misrepresented; you must not
30 claim that you wrote the original software. If you use this software
31 in a product, an acknowledgment in the product documentation would be
32 appreciated but is not required.
33 2. Altered source versions must be plainly marked as such, and must not be
34 misrepresented as being the original software.
35 3. This notice may not be removed or altered from any source distribution.
36
37 Jean-loup Gailly Mark Adler
38 jloup@gzip.org madler@alumni.caltech.edu
39
40 The data format used by the zlib library is described by RFCs (Request for
41 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
42 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
43*/
44
b32b8144 45namespace boost {
7c673cae
FG
46namespace beast {
47namespace zlib {
48
49#if !defined(__MACTYPES__)
b32b8144 50using Byte = unsigned char; // 8 bits
7c673cae 51#endif
b32b8144 52using uInt = unsigned int; // 16 bits or more
7c673cae
FG
53
54/* Possible values of the data_type field (though see inflate()) */
b32b8144 55enum kind
7c673cae 56{
b32b8144
FG
57 binary = 0,
58 text = 1,
59 unknown = 2
7c673cae
FG
60};
61
62/** Deflate codec parameters.
63
64 Objects of this type are filled in by callers and provided to the
65 deflate codec to define the input and output areas for the next
66 compress or decompress operation.
67
68 The application must update next_in and avail_in when avail_in has dropped
69 to zero. It must update next_out and avail_out when avail_out has dropped
70 to zero. The application must initialize zalloc, zfree and opaque before
71 calling the init function. All other fields are set by the compression
72 library and must not be updated by the application.
73
74 The fields total_in and total_out can be used for statistics or progress
75 reports. After compression, total_in holds the total size of the
76 uncompressed data and may be saved for use in the decompressor (particularly
77 if the decompressor wants to decompress everything in a single step).
78*/
79struct z_params
80{
81 /** A pointer to the next input byte.
82
83 If there is no more input, this may be set to `nullptr`.
84 */
85 void const* next_in;
86
87 /** The number of bytes of input available at `next_in`.
88
89 If there is no more input, this should be set to zero.
90 */
91 std::size_t avail_in;
92
93 /** The total number of input bytes read so far.
94 */
95 std::size_t total_in = 0;
96
97 /** A pointer to the next output byte.
98 */
99 void* next_out;
100
101 /** The remaining bytes of space at `next_out`.
102 */
103 std::size_t avail_out;
104
105 /** The total number of bytes output so far.
106 */
107 std::size_t total_out = 0;
108
b32b8144 109 int data_type = unknown; // best guess about the data type: binary or text
7c673cae
FG
110};
111
112/** Flush option.
113*/
114enum class Flush
115{
116 // order matters
117
118 none,
119 block,
120 partial,
121 sync,
122 full,
123 finish,
124 trees
125};
126
127/* compression levels */
b32b8144 128enum compression
7c673cae 129{
b32b8144
FG
130 none = 0,
131 best_speed = 1,
132 best_size = 9,
133 default_size = -1
7c673cae
FG
134};
135
136/** Compression strategy.
137
138 These are used when compressing streams.
139*/
140enum class Strategy
141{
142 /** Default strategy.
143
144 This is suitable for general purpose compression, and works
145 well in the majority of cases.
146 */
147 normal,
148
149 /** Filtered strategy.
150
151 This strategy should be used when the data be compressed
152 is produced by a filter or predictor.
153 */
154 filtered,
155
156 /** Huffman-only strategy.
157
158 This strategy only performs Huffman encoding, without doing
159 any string matching.
160 */
161 huffman,
162
163 /** Run Length Encoding strategy.
164
165 This strategy limits match distances to one, making it
166 equivalent to run length encoding. This can give better
167 performance for things like PNG image data.
168 */
169 rle,
170
171 /** Fixed table strategy.
172
173 This strategy prevents the use of dynamic Huffman codes,
174 allowing for a simpler decoder for special applications.
175 */
176 fixed
177};
178
179} // zlib
180} // beast
b32b8144 181} // boost
7c673cae
FG
182
183#endif
184