RTEMS 6.1-rc1
xz.h
1/*
2 * XZ decompressor
3 *
4 * Authors: Lasse Collin <lasse.collin@tukaani.org>
5 * Igor Pavlov <http://7-zip.org/>
6 *
7 * This file has been put into the public domain.
8 * You can do whatever you want with this file.
9 */
10
11#ifndef XZ_H
12#define XZ_H
13
14#ifdef __KERNEL__
15# include <linux/stddef.h>
16# include <linux/types.h>
17#else
18# include <stddef.h>
19# include <stdint.h>
20#endif
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* In Linux, this is used to make extern functions static when needed. */
27#ifndef XZ_EXTERN
28# define XZ_EXTERN extern
29#endif
30
56enum xz_mode {
57 XZ_SINGLE,
58 XZ_PREALLOC,
59 XZ_DYNALLOC
60};
61
112enum xz_ret {
113 XZ_OK,
114 XZ_STREAM_END,
115 XZ_UNSUPPORTED_CHECK,
116 XZ_MEM_ERROR,
117 XZ_MEMLIMIT_ERROR,
118 XZ_FORMAT_ERROR,
119 XZ_OPTIONS_ERROR,
120 XZ_DATA_ERROR,
121 XZ_BUF_ERROR
122};
123
140struct xz_buf {
141 const uint8_t *in;
142 size_t in_pos;
143 size_t in_size;
144
145 uint8_t *out;
146 size_t out_pos;
147 size_t out_size;
148};
149
153struct xz_dec;
154
198XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
199
218XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
219
231XZ_EXTERN void xz_dec_reset(struct xz_dec *s);
232
238XZ_EXTERN void xz_dec_end(struct xz_dec *s);
239
240/*
241 * Standalone build (userspace build or in-kernel build for boot time use)
242 * needs a CRC32 implementation. For normal in-kernel use, kernel's own
243 * CRC32 module is used instead, and users of this module don't need to
244 * care about the functions below.
245 */
246#ifndef XZ_INTERNAL_CRC32
247# ifdef __KERNEL__
248# define XZ_INTERNAL_CRC32 0
249# else
250# define XZ_INTERNAL_CRC32 1
251# endif
252#endif
253
254/*
255 * If CRC64 support has been enabled with XZ_USE_CRC64, a CRC64
256 * implementation is needed too.
257 */
258#ifndef XZ_USE_CRC64
259# undef XZ_INTERNAL_CRC64
260# define XZ_INTERNAL_CRC64 0
261#endif
262#ifndef XZ_INTERNAL_CRC64
263# ifdef __KERNEL__
264# error Using CRC64 in the kernel has not been implemented.
265# else
266# define XZ_INTERNAL_CRC64 1
267# endif
268#endif
269
270#if XZ_INTERNAL_CRC32
271/*
272 * This must be called before any other xz_* function to initialize
273 * the CRC32 lookup table.
274 */
275XZ_EXTERN void xz_crc32_init(void);
276
277/*
278 * Update CRC32 value using the polynomial from IEEE-802.3. To start a new
279 * calculation, the third argument must be zero. To continue the calculation,
280 * the previously returned value is passed as the third argument.
281 */
282XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
283#endif
284
285#if XZ_INTERNAL_CRC64
286/*
287 * This must be called before any other xz_* function (except xz_crc32_init())
288 * to initialize the CRC64 lookup table.
289 */
290XZ_EXTERN void xz_crc64_init(void);
291
292/*
293 * Update CRC64 value using the polynomial from ECMA-182. To start a new
294 * calculation, the third argument must be zero. To continue the calculation,
295 * the previously returned value is passed as the third argument.
296 */
297XZ_EXTERN uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc);
298#endif
299
300#ifdef __cplusplus
301}
302#endif
303
304#endif
Definition: xz.h:140
Definition: xz_dec_stream.c:26
unsigned size
Definition: tte.h:1