mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
6d5547a Set version to 1.0.0-b34 6fab138 Fix and tidy up CMake build scripts: ccefa54 Set version to 1.0.0-b33 32afe41 Set internal state correctly when writing frames: fe3e20b Add write_frames unit test 578dcd0 Add decorator unit test aaa3733 Use fwrite return value in file_body df66165 Require Visual Studio 2015 Update 3 or later b8e5a21 Set version to 1.0.0-b32 ffb1758 Update CMake scripts for finding packages: b893749 Remove http Writer suspend and resume feature (API Change): 27864fb Add io_service completion invariants tests eba05a7 Set version to 1.0.0-b31 484bcef Fix badge markdown in README.md 5663bea Add missing dynabuf_readstream member 0d7a551 Tidy up build settings 0fd4030 Move the handler, don't copy it git-subtree-dir: src/beast git-subtree-split: 6d5547a32c50ec95832c4779311502555ab0ee1f
180 lines
4.8 KiB
C++
180 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 <beast/config.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
|
|
|