-
Notifications
You must be signed in to change notification settings - Fork 2
/
lz4.h
127 lines (115 loc) · 3.42 KB
/
lz4.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* blz4 - Example of LZ4 compression with BriefLZ algorithms
*
* C/C++ header file
*
* Copyright (c) 2018-2020 Joergen Ibsen
*
* 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.
*/
#ifndef LZ4_H_INCLUDED
#define LZ4_H_INCLUDED
#include <stddef.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LZ4_VER_MAJOR 0 /**< Major version number */
#define LZ4_VER_MINOR 1 /**< Minor version number */
#define LZ4_VER_PATCH 0 /**< Patch version number */
#define LZ4_VER_STRING "0.2.0" /**< Version number as a string */
#ifdef LZ4_DLL
# if defined(_WIN32) || defined(__CYGWIN__)
# ifdef LZ4_DLL_EXPORTS
# define LZ4_API __declspec(dllexport)
# else
# define LZ4_API __declspec(dllimport)
# endif
# define LZ4_LOCAL
# else
# if __GNUC__ >= 4
# define LZ4_API __attribute__ ((visibility ("default")))
# define LZ4_LOCAL __attribute__ ((visibility ("hidden")))
# else
# define LZ4_API
# define LZ4_LOCAL
# endif
# endif
#else
# define LZ4_API
# define LZ4_LOCAL
#endif
/**
* Return value on error.
*/
#ifndef LZ4_ERROR
# define LZ4_ERROR ((unsigned long) (-1))
#endif
/**
* Get bound on compressed data size.
*
* @see lz4_pack_level
*
* @param src_size number of bytes to compress
* @return maximum size of compressed data
*/
LZ4_API unsigned long
lz4_max_packed_size(unsigned long src_size);
/**
* Get required size of `workmem` buffer.
*
* @see lz4_pack_level
*
* @param src_size number of bytes to compress
* @param level compression level
* @return required size in bytes of `workmem` buffer
*/
LZ4_API size_t
lz4_workmem_size_level(size_t src_size, int level);
/**
* Compress `src_size` bytes of data from `src` to `dst`.
*
* Compression levels between 5 and 9 offer a trade-off between
* time/space and ratio. Level 10 is optimal but very slow.
*
* @param src pointer to data
* @param dst pointer to where to place compressed data
* @param src_size number of bytes to compress
* @param workmem pointer to memory for temporary use
* @param level compression level
* @return size of compressed data
*/
LZ4_API unsigned long
lz4_pack_level(const void *src, void *dst, unsigned long src_size,
void *workmem, int level);
/**
* Decompress data from `src` to `dst`.
*
* @param src pointer to compressed data
* @param dst pointer to where to place decompressed data
* @param packed_size size of compressed data
* @return size of decompressed data
*/
LZ4_API unsigned long
lz4_depack(const void *src, void *dst, unsigned long packed_size);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* LZ4_H_INCLUDED */