]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/zlib/zlib.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / beast / zlib / zlib.hpp
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
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 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9 // This is a derivative work based on Zlib, copyright below:
10 /*
11 Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
12
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.
16
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:
20
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.
28
29 Jean-loup Gailly Mark Adler
30 jloup@gzip.org madler@alumni.caltech.edu
31
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).
35 */
36
37 #ifndef BOOST_BEAST_ZLIB_ZLIB_HPP
38 #define BOOST_BEAST_ZLIB_ZLIB_HPP
39
40 #include <boost/beast/core/detail/config.hpp>
41 #include <cstdint>
42 #include <cstdlib>
43
44 namespace boost {
45 namespace beast {
46 namespace zlib {
47
48 #if !defined(__MACTYPES__)
49 using Byte = unsigned char; // 8 bits
50 #endif
51 using uInt = unsigned int; // 16 bits or more
52
53 /* Possible values of the data_type field (though see inflate()) */
54 enum kind
55 {
56 binary = 0,
57 text = 1,
58 unknown = 2
59 };
60
61 /** Deflate codec parameters.
62
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.
66
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.
72
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).
77 */
78 struct z_params
79 {
80 /** A pointer to the next input byte.
81
82 If there is no more input, this may be set to `nullptr`.
83 */
84 void const* next_in;
85
86 /** The number of bytes of input available at `next_in`.
87
88 If there is no more input, this should be set to zero.
89 */
90 std::size_t avail_in;
91
92 /** The total number of input bytes read so far.
93 */
94 std::size_t total_in = 0;
95
96 /** A pointer to the next output byte.
97 */
98 void* next_out;
99
100 /** The remaining bytes of space at `next_out`.
101 */
102 std::size_t avail_out;
103
104 /** The total number of bytes output so far.
105 */
106 std::size_t total_out = 0;
107
108 int data_type = unknown; // best guess about the data type: binary or text
109 };
110
111 /** Flush option.
112 */
113 enum class Flush
114 {
115 // order matters
116
117 none,
118 block,
119 partial,
120 sync,
121 full,
122 finish,
123 trees
124 };
125
126 /* compression levels */
127 enum compression
128 {
129 none = 0,
130 best_speed = 1,
131 best_size = 9,
132 default_size = -1
133 };
134
135 /** Compression strategy.
136
137 These are used when compressing streams.
138 */
139 enum class Strategy
140 {
141 /** Default strategy.
142
143 This is suitable for general purpose compression, and works
144 well in the majority of cases.
145 */
146 normal,
147
148 /** Filtered strategy.
149
150 This strategy should be used when the data be compressed
151 is produced by a filter or predictor.
152 */
153 filtered,
154
155 /** Huffman-only strategy.
156
157 This strategy only performs Huffman encoding, without doing
158 any string matching.
159 */
160 huffman,
161
162 /** Run Length Encoding strategy.
163
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.
167 */
168 rle,
169
170 /** Fixed table strategy.
171
172 This strategy prevents the use of dynamic Huffman codes,
173 allowing for a simpler decoder for special applications.
174 */
175 fixed
176 };
177
178 } // zlib
179 } // beast
180 } // boost
181
182 #endif
183