debian/xz-utils: Remove old NEWS.Debian
[xz/debian.git] / src / liblzma / simple / simple_private.h
blob9d2c0fdd761849b649fe344b01168f0a7c1a614a
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file simple_private.h
4 /// \brief Private definitions for so called simple filters
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
11 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef LZMA_SIMPLE_PRIVATE_H
14 #define LZMA_SIMPLE_PRIVATE_H
16 #include "simple_coder.h"
19 typedef struct {
20 /// Next filter in the chain
21 lzma_next_coder next;
23 /// True if the next coder in the chain has returned LZMA_STREAM_END.
24 bool end_was_reached;
26 /// True if filter() should encode the data; false to decode.
27 /// Currently all simple filters use the same function for encoding
28 /// and decoding, because the difference between encoders and decoders
29 /// is very small.
30 bool is_encoder;
32 /// Pointer to filter-specific function, which does
33 /// the actual filtering.
34 size_t (*filter)(void *simple, uint32_t now_pos,
35 bool is_encoder, uint8_t *buffer, size_t size);
37 /// Pointer to filter-specific data, or NULL if filter doesn't need
38 /// any extra data.
39 void *simple;
41 /// The lowest 32 bits of the current position in the data. Most
42 /// filters need this to do conversions between absolute and relative
43 /// addresses.
44 uint32_t now_pos;
46 /// Size of the memory allocated for the buffer.
47 size_t allocated;
49 /// Flushing position in the temporary buffer. buffer[pos] is the
50 /// next byte to be copied to out[].
51 size_t pos;
53 /// buffer[filtered] is the first unfiltered byte. When pos is smaller
54 /// than filtered, there is unflushed filtered data in the buffer.
55 size_t filtered;
57 /// Total number of bytes (both filtered and unfiltered) currently
58 /// in the temporary buffer.
59 size_t size;
61 /// Temporary buffer
62 uint8_t buffer[];
63 } lzma_simple_coder;
66 extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
67 const lzma_allocator *allocator,
68 const lzma_filter_info *filters,
69 size_t (*filter)(void *simple, uint32_t now_pos,
70 bool is_encoder, uint8_t *buffer, size_t size),
71 size_t simple_size, size_t unfiltered_max,
72 uint32_t alignment, bool is_encoder);
74 #endif