Files
xahaud/include/beast/zlib/zlib.hpp
Vinnie Falco 8b60ef9db4 Squashed 'src/beast/' changes from 06f74f0..9f10b11
9f10b11 Set version to 1.0.0-b28
195f974 Fix HTTP split parse edge case:
264fd41 Restyle async result constructions
572a0eb Split out and rename test stream classes
95b6646 Tidy up some WebSocket javadocs
f6938d3 Set version to 1.0.0-b27
a6120cd Update copyright dates
c7bfe7d Add documentation building instructions
f6c91ce Tidy up tests and docs:
f03985f Move basic_streambuf to streambuf.hpp (API Change):
b8639a7 Invoke callback on pings and pongs (API Change):

git-subtree-dir: src/beast
git-subtree-split: 9f10b11eff58aeb793b673c8a8cb6e2bee3db621
2017-02-24 12:42:36 -05:00

179 lines
4.8 KiB
C++

//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This is a derivative work based on Zlib, copyright below:
/*
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
*/
#ifndef BEAST_ZLIB_ZLIB_HPP
#define BEAST_ZLIB_ZLIB_HPP
#include <cstdint>
#include <cstdlib>
namespace beast {
namespace zlib {
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
/* Possible values of the data_type field (though see inflate()) */
enum z_Type
{
Z_BINARY = 0,
Z_TEXT = 1,
Z_UNKNOWN = 2
};
/** Deflate codec parameters.
Objects of this type are filled in by callers and provided to the
deflate codec to define the input and output areas for the next
compress or decompress operation.
The application must update next_in and avail_in when avail_in has dropped
to zero. It must update next_out and avail_out when avail_out has dropped
to zero. The application must initialize zalloc, zfree and opaque before
calling the init function. All other fields are set by the compression
library and must not be updated by the application.
The fields total_in and total_out can be used for statistics or progress
reports. After compression, total_in holds the total size of the
uncompressed data and may be saved for use in the decompressor (particularly
if the decompressor wants to decompress everything in a single step).
*/
struct z_params
{
/** A pointer to the next input byte.
If there is no more input, this may be set to `nullptr`.
*/
void const* next_in;
/** The number of bytes of input available at `next_in`.
If there is no more input, this should be set to zero.
*/
std::size_t avail_in;
/** The total number of input bytes read so far.
*/
std::size_t total_in = 0;
/** A pointer to the next output byte.
*/
void* next_out;
/** The remaining bytes of space at `next_out`.
*/
std::size_t avail_out;
/** The total number of bytes output so far.
*/
std::size_t total_out = 0;
int data_type = Z_UNKNOWN; // best guess about the data type: binary or text
};
/** Flush option.
*/
enum class Flush
{
// order matters
none,
block,
partial,
sync,
full,
finish,
trees
};
/* compression levels */
enum z_Compression
{
Z_NO_COMPRESSION = 0,
Z_BEST_SPEED = 1,
Z_BEST_COMPRESSION = 9,
Z_DEFAULT_COMPRESSION = -1
};
/** Compression strategy.
These are used when compressing streams.
*/
enum class Strategy
{
/** Default strategy.
This is suitable for general purpose compression, and works
well in the majority of cases.
*/
normal,
/** Filtered strategy.
This strategy should be used when the data be compressed
is produced by a filter or predictor.
*/
filtered,
/** Huffman-only strategy.
This strategy only performs Huffman encoding, without doing
any string matching.
*/
huffman,
/** Run Length Encoding strategy.
This strategy limits match distances to one, making it
equivalent to run length encoding. This can give better
performance for things like PNG image data.
*/
rle,
/** Fixed table strategy.
This strategy prevents the use of dynamic Huffman codes,
allowing for a simpler decoder for special applications.
*/
fixed
};
} // zlib
} // beast
#endif