2008-01-30 19:32:13 +01:00
|
|
|
/*
|
|
|
|
|
2018-04-09 09:04:33 +02:00
|
|
|
Copyright (c) 2007-2018, Arvid Norberg
|
2008-01-30 19:32:13 +01:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-04-13 04:00:33 +02:00
|
|
|
#ifndef TORRENT_GZIP_HPP_INCLUDED
|
|
|
|
#define TORRENT_GZIP_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include "libtorrent/config.hpp"
|
2014-07-20 22:49:56 +02:00
|
|
|
#include "libtorrent/error_code.hpp"
|
|
|
|
|
2009-04-13 04:00:33 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2008-01-30 19:32:13 +01:00
|
|
|
namespace libtorrent
|
|
|
|
{
|
|
|
|
|
2014-07-20 22:49:56 +02:00
|
|
|
TORRENT_EXTRA_EXPORT void inflate_gzip(
|
2008-01-30 19:32:13 +01:00
|
|
|
char const* in, int size
|
|
|
|
, std::vector<char>& buffer
|
|
|
|
, int maximum_size
|
2014-07-20 22:49:56 +02:00
|
|
|
, error_code& error);
|
|
|
|
|
|
|
|
// get the ``error_category`` for zip errors
|
2016-10-04 01:32:40 +02:00
|
|
|
TORRENT_EXPORT boost::system::error_category& gzip_category();
|
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
TORRENT_DEPRECATED TORRENT_EXPORT
|
|
|
|
boost::system::error_category& get_gzip_category();
|
|
|
|
#endif
|
2014-07-20 22:49:56 +02:00
|
|
|
|
|
|
|
namespace gzip_errors
|
|
|
|
{
|
|
|
|
// libtorrent uses boost.system's ``error_code`` class to represent errors. libtorrent has
|
2016-03-15 01:43:52 +01:00
|
|
|
// its own error category get_gzip_category() with the error codes defined by error_code_enum.
|
2014-07-20 22:49:56 +02:00
|
|
|
enum error_code_enum
|
|
|
|
{
|
|
|
|
// Not an error
|
|
|
|
no_error = 0,
|
|
|
|
|
|
|
|
// the supplied gzip buffer has invalid header
|
|
|
|
invalid_gzip_header,
|
|
|
|
|
|
|
|
// the gzip buffer would inflate to more bytes than the specified
|
|
|
|
// maximum size, and was rejected.
|
|
|
|
inflated_data_too_large,
|
|
|
|
|
|
|
|
// available inflate data did not terminate
|
|
|
|
data_did_not_terminate,
|
|
|
|
|
|
|
|
// output space exhausted before completing inflate
|
|
|
|
space_exhausted,
|
|
|
|
|
|
|
|
// invalid block type (type == 3)
|
2015-06-06 08:10:53 +02:00
|
|
|
invalid_block_type,
|
2014-07-20 22:49:56 +02:00
|
|
|
|
|
|
|
// stored block length did not match one's complement
|
|
|
|
invalid_stored_block_length,
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2014-07-20 22:49:56 +02:00
|
|
|
// dynamic block code description: too many length or distance codes
|
|
|
|
too_many_length_or_distance_codes,
|
|
|
|
|
|
|
|
// dynamic block code description: code lengths codes incomplete
|
|
|
|
code_lengths_codes_incomplete,
|
|
|
|
|
|
|
|
// dynamic block code description: repeat lengths with no first length
|
|
|
|
repeat_lengths_with_no_first_length,
|
|
|
|
|
|
|
|
// dynamic block code description: repeat more than specified lengths
|
|
|
|
repeat_more_than_specified_lengths,
|
|
|
|
|
|
|
|
// dynamic block code description: invalid literal/length code lengths
|
|
|
|
invalid_literal_length_code_lengths,
|
|
|
|
|
|
|
|
// dynamic block code description: invalid distance code lengths
|
|
|
|
invalid_distance_code_lengths,
|
|
|
|
|
|
|
|
// invalid literal/length or distance code in fixed or dynamic block
|
|
|
|
invalid_literal_code_in_block,
|
|
|
|
|
|
|
|
// distance is too far back in fixed or dynamic block
|
|
|
|
distance_too_far_back_in_block,
|
|
|
|
|
|
|
|
// an unknown error occurred during gzip inflation
|
|
|
|
unknown_gzip_error,
|
|
|
|
|
|
|
|
// the number of error codes
|
|
|
|
error_code_max
|
|
|
|
};
|
|
|
|
|
|
|
|
// hidden
|
|
|
|
TORRENT_EXPORT boost::system::error_code make_error_code(error_code_enum e);
|
|
|
|
}
|
2008-01-30 19:32:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-20 22:49:56 +02:00
|
|
|
namespace boost { namespace system {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct is_error_code_enum<libtorrent::gzip_errors::error_code_enum>
|
2014-07-21 05:19:58 +02:00
|
|
|
{ static const bool value = true; };
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct is_error_condition_enum<libtorrent::gzip_errors::error_code_enum>
|
|
|
|
{ static const bool value = true; };
|
2014-07-20 22:49:56 +02:00
|
|
|
|
|
|
|
} }
|
|
|
|
|
2009-04-13 04:00:33 +02:00
|
|
|
#endif
|
|
|
|
|