/*1FastLZ - Byte-aligned LZ77 compression library2Copyright (C) 2005-2020 Ariya Hidayat <[email protected]>34Permission is hereby granted, free of charge, to any person obtaining a copy5of this software and associated documentation files (the "Software"), to deal6in the Software without restriction, including without limitation the rights7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8copies of the Software, and to permit persons to whom the Software is9furnished to do so, subject to the following conditions:1011The above copyright notice and this permission notice shall be included in12all copies or substantial portions of the Software.1314THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN20THE SOFTWARE.21*/2223#ifndef FASTLZ_H24#define FASTLZ_H2526#define FASTLZ_VERSION 0x0005002728#define FASTLZ_VERSION_MAJOR 029#define FASTLZ_VERSION_MINOR 530#define FASTLZ_VERSION_REVISION 03132#define FASTLZ_VERSION_STRING "0.5.0"3334#if defined(__cplusplus)35extern "C" {36#endif3738/**39Compress a block of data in the input buffer and returns the size of40compressed block. The size of input buffer is specified by length. The41minimum input buffer size is 16.4243The output buffer must be at least 5% larger than the input buffer44and can not be smaller than 66 bytes.4546If the input is not compressible, the return value might be larger than47length (input buffer size).4849The input buffer and the output buffer can not overlap.5051Compression level can be specified in parameter level. At the moment,52only level 1 and level 2 are supported.53Level 1 is the fastest compression and generally useful for short data.54Level 2 is slightly slower but it gives better compression ratio.5556Note that the compressed data, regardless of the level, can always be57decompressed using the function fastlz_decompress below.58*/5960int fastlz_compress_level(int level, const void* input, int length,61void* output);6263/**64Decompress a block of compressed data and returns the size of the65decompressed block. If error occurs, e.g. the compressed data is66corrupted or the output buffer is not large enough, then 0 (zero)67will be returned instead.6869The input buffer and the output buffer can not overlap.7071Decompression is memory safe and guaranteed not to write the output buffer72more than what is specified in maxout.7374Note that the decompression will always work, regardless of the75compression level specified in fastlz_compress_level above (when76producing the compressed block).77*/7879int fastlz_decompress(const void* input, int length, void* output, int maxout);8081/**82DEPRECATED.8384This is similar to fastlz_compress_level above, but with the level85automatically chosen.8687This function is deprecated and it will be completely removed in some future88version.89*/9091int fastlz_compress(const void* input, int length, void* output);9293#if defined(__cplusplus)94}95#endif9697#endif /* FASTLZ_H */9899100