|
||||
File indexing completed on 2025-01-18 09:29:37
0001 // 0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/beast 0008 // 0009 // This is a derivative work based on Zlib, copyright below: 0010 /* 0011 Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler 0012 0013 This software is provided 'as-is', without any express or implied 0014 warranty. In no event will the authors be held liable for any damages 0015 arising from the use of this software. 0016 0017 Permission is granted to anyone to use this software for any purpose, 0018 including commercial applications, and to alter it and redistribute it 0019 freely, subject to the following restrictions: 0020 0021 1. The origin of this software must not be misrepresented; you must not 0022 claim that you wrote the original software. If you use this software 0023 in a product, an acknowledgment in the product documentation would be 0024 appreciated but is not required. 0025 2. Altered source versions must be plainly marked as such, and must not be 0026 misrepresented as being the original software. 0027 3. This notice may not be removed or altered from any source distribution. 0028 0029 Jean-loup Gailly Mark Adler 0030 jloup@gzip.org madler@alumni.caltech.edu 0031 0032 The data format used by the zlib library is described by RFCs (Request for 0033 Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 0034 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). 0035 */ 0036 0037 #ifndef BOOST_BEAST_ZLIB_ZLIB_HPP 0038 #define BOOST_BEAST_ZLIB_ZLIB_HPP 0039 0040 #include <boost/beast/core/detail/config.hpp> 0041 #include <cstdint> 0042 #include <cstdlib> 0043 0044 namespace boost { 0045 namespace beast { 0046 namespace zlib { 0047 0048 #if !defined(__MACTYPES__) 0049 using Byte = unsigned char; // 8 bits 0050 #endif 0051 using uInt = unsigned int; // 16 bits or more 0052 0053 /* Possible values of the data_type field (though see inflate()) */ 0054 enum kind 0055 { 0056 binary = 0, 0057 text = 1, 0058 unknown = 2 0059 }; 0060 0061 /** Deflate codec parameters. 0062 0063 Objects of this type are filled in by callers and provided to the 0064 deflate codec to define the input and output areas for the next 0065 compress or decompress operation. 0066 0067 The application must update next_in and avail_in when avail_in has dropped 0068 to zero. It must update next_out and avail_out when avail_out has dropped 0069 to zero. The application must initialize zalloc, zfree and opaque before 0070 calling the init function. All other fields are set by the compression 0071 library and must not be updated by the application. 0072 0073 The fields total_in and total_out can be used for statistics or progress 0074 reports. After compression, total_in holds the total size of the 0075 uncompressed data and may be saved for use in the decompressor (particularly 0076 if the decompressor wants to decompress everything in a single step). 0077 */ 0078 struct z_params 0079 { 0080 /** A pointer to the next input byte. 0081 0082 If there is no more input, this may be set to `nullptr`. 0083 0084 The application must update `next_in` and `avail_in` when 0085 `avail_in` has dropped to zero. 0086 */ 0087 void const* next_in; 0088 0089 /** The number of bytes of input available at `next_in`. 0090 0091 If there is no more input, this should be set to zero. 0092 0093 The application must update `next_in` and `avail_in` when 0094 `avail_in` has dropped to zero. 0095 */ 0096 std::size_t avail_in; 0097 0098 /** The total number of input bytes read so far. 0099 0100 This field is set by the compression library and must 0101 not be updated by the application. 0102 0103 This field can also be used for statistics or progress 0104 reports. 0105 0106 After compression, total_in holds the total size of the 0107 uncompressed data and may be saved for use by the 0108 decompressor (particularly if the decompressor wants 0109 to decompress everything in a single step). 0110 0111 */ 0112 std::size_t total_in = 0; 0113 0114 /** A pointer to the next output byte. 0115 0116 The application must update `next_out` and `avail_out` 0117 when avail_out has dropped to zero. 0118 */ 0119 void* next_out; 0120 0121 /** The remaining bytes of space at `next_out`. 0122 0123 The application must update `next_out` and `avail_out` 0124 when avail_out has dropped to zero. 0125 */ 0126 std::size_t avail_out; 0127 0128 /** The total number of bytes output so far. 0129 0130 This field is set by the compression library and must 0131 not be updated by the application. 0132 0133 This field can also be used for statistics or progress 0134 reports. 0135 */ 0136 std::size_t total_out = 0; 0137 0138 /** Best guess about the data type: binary or text 0139 0140 This represents binary or text for deflate, or 0141 the decoding state for inflate. 0142 */ 0143 int data_type = unknown; 0144 }; 0145 0146 /** Flush option. 0147 0148 The allowed flush values for the @ref deflate_stream::write 0149 and @ref inflate_stream::write functions. 0150 0151 Please refer to @ref deflate_stream::write and 0152 @ref inflate_stream::write for details. 0153 0154 @see 0155 deflate_stream::write, 0156 inflate_stream::write 0157 0158 */ 0159 enum class Flush 0160 { 0161 // order matters 0162 0163 /// No policy 0164 none, 0165 0166 /// Flush all pending output on a bit boundary and hold up to seven bits 0167 block, 0168 0169 /// Flush all pending output on a bit boundary 0170 partial, 0171 0172 /// Flush all pending output on a byte boundary 0173 sync, 0174 0175 /// Flush all pending output on a byte boundary and reset state 0176 full, 0177 0178 /// Compress the input left in a single step 0179 finish, 0180 0181 /// Flush output as in Flush::block or at the end of each deflate block header 0182 trees 0183 }; 0184 0185 /** Compression levels. 0186 0187 The compression levels go from 0 and 9: 1 gives best speed, 9 gives 0188 best compression. 0189 0190 Compression level 0 gives no compression at all. The input data is 0191 simply copied a block at a time. 0192 0193 A compression level 6 is usually a default compromise between 0194 speed and compression. 0195 0196 */ 0197 enum compression 0198 { 0199 none = 0, 0200 best_speed = 1, 0201 best_size = 9, 0202 default_size = -1 0203 }; 0204 0205 /** Compression strategy. 0206 0207 These are used when compressing streams. 0208 */ 0209 enum class Strategy 0210 { 0211 /** Default strategy. 0212 0213 This is suitable for general purpose compression, and works 0214 well in the majority of cases. 0215 */ 0216 normal, 0217 0218 /** Filtered strategy. 0219 0220 This strategy should be used when the data be compressed 0221 is produced by a filter or predictor. 0222 */ 0223 filtered, 0224 0225 /** Huffman-only strategy. 0226 0227 This strategy only performs Huffman encoding, without doing 0228 any string matching. 0229 */ 0230 huffman, 0231 0232 /** Run Length Encoding strategy. 0233 0234 This strategy limits match distances to one, making it 0235 equivalent to run length encoding. This can give better 0236 performance for things like PNG image data. 0237 */ 0238 rle, 0239 0240 /** Fixed table strategy. 0241 0242 This strategy prevents the use of dynamic Huffman codes, 0243 allowing for a simpler decoder for special applications. 0244 */ 0245 fixed 0246 }; 0247 0248 } // zlib 0249 } // beast 0250 } // boost 0251 0252 #endif 0253
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |