Fix version.sh compatiblity with Solaris
[xz/debian.git] / src / liblzma / simple / simple_private.h
blob7aa360ff49e8ae9882779d04a2c265e6993c36d5
1 // SPDX-License-Identifier: 0BSD
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 /// \file simple_private.h
6 /// \brief Private definitions for so called simple filters
7 //
8 // Author: Lasse Collin
9 //
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef LZMA_SIMPLE_PRIVATE_H
13 #define LZMA_SIMPLE_PRIVATE_H
15 #include "simple_coder.h"
18 typedef struct {
19 /// Next filter in the chain
20 lzma_next_coder next;
22 /// True if the next coder in the chain has returned LZMA_STREAM_END.
23 bool end_was_reached;
25 /// True if filter() should encode the data; false to decode.
26 /// Currently all simple filters use the same function for encoding
27 /// and decoding, because the difference between encoders and decoders
28 /// is very small.
29 bool is_encoder;
31 /// Pointer to filter-specific function, which does
32 /// the actual filtering.
33 size_t (*filter)(void *simple, uint32_t now_pos,
34 bool is_encoder, uint8_t *buffer, size_t size);
36 /// Pointer to filter-specific data, or NULL if filter doesn't need
37 /// any extra data.
38 void *simple;
40 /// The lowest 32 bits of the current position in the data. Most
41 /// filters need this to do conversions between absolute and relative
42 /// addresses.
43 uint32_t now_pos;
45 /// Size of the memory allocated for the buffer.
46 size_t allocated;
48 /// Flushing position in the temporary buffer. buffer[pos] is the
49 /// next byte to be copied to out[].
50 size_t pos;
52 /// buffer[filtered] is the first unfiltered byte. When pos is smaller
53 /// than filtered, there is unflushed filtered data in the buffer.
54 size_t filtered;
56 /// Total number of bytes (both filtered and unfiltered) currently
57 /// in the temporary buffer.
58 size_t size;
60 /// Temporary buffer
61 uint8_t buffer[];
62 } lzma_simple_coder;
65 extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
66 const lzma_allocator *allocator,
67 const lzma_filter_info *filters,
68 size_t (*filter)(void *simple, uint32_t now_pos,
69 bool is_encoder, uint8_t *buffer, size_t size),
70 size_t simple_size, size_t unfiltered_max,
71 uint32_t alignment, bool is_encoder);
73 #endif