2016-03-09 00:00:52 +01:00
|
|
|
/*
|
2020-04-30 14:24:03 +02:00
|
|
|
FastLZ - Byte-aligned LZ77 compression library
|
|
|
|
Copyright (C) 2005-2020 Ariya Hidayat <ariya.hidayat@gmail.com>
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FASTLZ_H
|
|
|
|
#define FASTLZ_H
|
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
#define FASTLZ_VERSION 0x000500
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
#define FASTLZ_VERSION_MAJOR 0
|
|
|
|
#define FASTLZ_VERSION_MINOR 5
|
|
|
|
#define FASTLZ_VERSION_REVISION 0
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
#define FASTLZ_VERSION_STRING "0.5.0"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
#if defined(__cplusplus)
|
2014-02-10 02:10:30 +01:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2016-03-09 00:00:52 +01:00
|
|
|
Compress a block of data in the input buffer and returns the size of
|
|
|
|
compressed block. The size of input buffer is specified by length. The
|
2014-02-10 02:10:30 +01:00
|
|
|
minimum input buffer size is 16.
|
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
The output buffer must be at least 5% larger than the input buffer
|
2014-02-10 02:10:30 +01:00
|
|
|
and can not be smaller than 66 bytes.
|
|
|
|
|
|
|
|
If the input is not compressible, the return value might be larger than
|
|
|
|
length (input buffer size).
|
|
|
|
|
|
|
|
The input buffer and the output buffer can not overlap.
|
2020-04-30 14:24:03 +02:00
|
|
|
|
|
|
|
Compression level can be specified in parameter level. At the moment,
|
|
|
|
only level 1 and level 2 are supported.
|
|
|
|
Level 1 is the fastest compression and generally useful for short data.
|
|
|
|
Level 2 is slightly slower but it gives better compression ratio.
|
|
|
|
|
|
|
|
Note that the compressed data, regardless of the level, can always be
|
|
|
|
decompressed using the function fastlz_decompress below.
|
2014-02-10 02:10:30 +01:00
|
|
|
*/
|
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
int fastlz_compress_level(int level, const void* input, int length,
|
|
|
|
void* output);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
/**
|
2016-03-09 00:00:52 +01:00
|
|
|
Decompress a block of compressed data and returns the size of the
|
|
|
|
decompressed block. If error occurs, e.g. the compressed data is
|
|
|
|
corrupted or the output buffer is not large enough, then 0 (zero)
|
2014-02-10 02:10:30 +01:00
|
|
|
will be returned instead.
|
|
|
|
|
|
|
|
The input buffer and the output buffer can not overlap.
|
|
|
|
|
|
|
|
Decompression is memory safe and guaranteed not to write the output buffer
|
|
|
|
more than what is specified in maxout.
|
2020-04-30 14:24:03 +02:00
|
|
|
|
|
|
|
Note that the decompression will always work, regardless of the
|
|
|
|
compression level specified in fastlz_compress_level above (when
|
|
|
|
producing the compressed block).
|
2014-02-10 02:10:30 +01:00
|
|
|
*/
|
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
int fastlz_decompress(const void* input, int length, void* output, int maxout);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
/**
|
2020-04-30 14:24:03 +02:00
|
|
|
DEPRECATED.
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
This is similar to fastlz_compress_level above, but with the level
|
|
|
|
automatically chosen.
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
This function is deprecated and it will be completely removed in some future
|
|
|
|
version.
|
2016-03-09 00:00:52 +01:00
|
|
|
*/
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
int fastlz_compress(const void* input, int length, void* output);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-30 14:24:03 +02:00
|
|
|
#if defined(__cplusplus)
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* FASTLZ_H */
|