1#![allow(bad_style)]
2#![doc(html_root_url = "https://docs.rs/lzma-sys/0.1")]
3
4use libc::{c_char, c_uchar, c_void, size_t};
5use std::u64;
6
7#[cfg(target_env = "msvc")]
8#[doc(hidden)]
9pub type __enum_ty = libc::c_int;
10#[cfg(not(target_env = "msvc"))]
11#[doc(hidden)]
12pub type __enum_ty = libc::c_uint;
13pub type lzma_bool = c_uchar;
14pub type lzma_ret = __enum_ty;
15pub type lzma_action = __enum_ty;
16type lzma_reserved_enum = __enum_ty;
17pub type lzma_check = __enum_ty;
18pub type lzma_vli = u64;
19pub type lzma_mode = __enum_ty;
20pub type lzma_match_finder = __enum_ty;
21
22pub const LZMA_OK: lzma_ret = 0;
23pub const LZMA_STREAM_END: lzma_ret = 1;
24pub const LZMA_NO_CHECK: lzma_ret = 2;
25pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3;
26pub const LZMA_GET_CHECK: lzma_ret = 4;
27pub const LZMA_MEM_ERROR: lzma_ret = 5;
28pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6;
29pub const LZMA_FORMAT_ERROR: lzma_ret = 7;
30pub const LZMA_OPTIONS_ERROR: lzma_ret = 8;
31pub const LZMA_DATA_ERROR: lzma_ret = 9;
32pub const LZMA_BUF_ERROR: lzma_ret = 10;
33pub const LZMA_PROG_ERROR: lzma_ret = 11;
34
35pub const LZMA_RUN: lzma_action = 0;
36pub const LZMA_SYNC_FLUSH: lzma_action = 1;
37pub const LZMA_FULL_FLUSH: lzma_action = 2;
38pub const LZMA_FULL_BARRIER: lzma_action = 4;
39pub const LZMA_FINISH: lzma_action = 3;
40
41pub const LZMA_CHECK_NONE: lzma_check = 0;
42pub const LZMA_CHECK_CRC32: lzma_check = 1;
43pub const LZMA_CHECK_CRC64: lzma_check = 4;
44pub const LZMA_CHECK_SHA256: lzma_check = 10;
45
46pub const LZMA_MODE_FAST: lzma_mode = 1;
47pub const LZMA_MODE_NORMAL: lzma_mode = 2;
48
49pub const LZMA_MF_HC3: lzma_match_finder = 0x03;
50pub const LZMA_MF_HC4: lzma_match_finder = 0x04;
51pub const LZMA_MF_BT2: lzma_match_finder = 0x12;
52pub const LZMA_MF_BT3: lzma_match_finder = 0x13;
53pub const LZMA_MF_BT4: lzma_match_finder = 0x14;
54
55pub const LZMA_TELL_NO_CHECK: u32 = 0x01;
56pub const LZMA_TELL_UNSUPPORTED_CHECK: u32 = 0x02;
57pub const LZMA_TELL_ANY_CHECK: u32 = 0x04;
58pub const LZMA_IGNORE_CHECK: u32 = 0x10;
59pub const LZMA_CONCATENATED: u32 = 0x08;
60
61pub const LZMA_PRESET_DEFAULT: u32 = 6;
62pub const LZMA_PRESET_LEVEL_MASK: u32 = 0x1f;
63pub const LZMA_PRESET_EXTREME: u32 = 1 << 31;
64
65pub const LZMA_DICT_SIZE_MIN: u32 = 4096;
66pub const LZMA_DICT_SIZE_DEFAULT: u32 = 1 << 23;
67
68pub const LZMA_LCLP_MIN: u32 = 0;
69pub const LZMA_LCLP_MAX: u32 = 4;
70pub const LZMA_LC_DEFAULT: u32 = 3;
71
72pub const LZMA_LP_DEFAULT: u32 = 0;
73
74pub const LZMA_PB_MIN: u32 = 0;
75pub const LZMA_PB_MAX: u32 = 4;
76pub const LZMA_PB_DEFAULT: u32 = 2;
77
78pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = 4;
79pub const LZMA_BACKWARD_SIZE_MAX: lzma_vli = 1 << 34;
80
81pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2;
82pub const LZMA_VLI_UNKNOWN: lzma_vli = u64::MAX;
83pub const LZMA_VLI_BYTES_MAX: usize = 9;
84
85pub const LZMA_FILTER_X86: lzma_vli = 0x04;
86pub const LZMA_FILTER_POWERPC: lzma_vli = 0x05;
87pub const LZMA_FILTER_IA64: lzma_vli = 0x06;
88pub const LZMA_FILTER_ARM: lzma_vli = 0x07;
89pub const LZMA_FILTER_ARMTHUMB: lzma_vli = 0x08;
90pub const LZMA_FILTER_SPARC: lzma_vli = 0x09;
91pub const LZMA_FILTER_LZMA1: lzma_vli = 0x4000000000000001;
92pub const LZMA_FILTER_LZMA2: lzma_vli = 0x21;
93
94#[repr(C)]
95pub struct lzma_allocator {
96 pub alloc: Option<extern "C" fn(*mut c_void, size_t, size_t) -> *mut c_void>,
97 pub free: Option<extern "C" fn(*mut c_void, *mut c_void)>,
98 pub opaque: *mut c_void,
99}
100
101pub enum lzma_internal {}
102
103#[repr(C)]
104pub struct lzma_stream {
105 pub next_in: *const u8,
106 pub avail_in: size_t,
107 pub total_in: u64,
108 pub next_out: *mut u8,
109 pub avail_out: size_t,
110 pub total_out: u64,
111 pub allocator: *const lzma_allocator,
112
113 internal: *mut lzma_internal,
114 reserved_ptr1: *mut c_void,
115 reserved_ptr2: *mut c_void,
116 reserved_ptr3: *mut c_void,
117 reserved_ptr4: *mut c_void,
118 reserved_int1: u64,
119 reserved_int2: u64,
120 reserved_int3: size_t,
121 reserved_int4: size_t,
122 reserved_enum1: lzma_reserved_enum,
123 reserved_enum2: lzma_reserved_enum,
124}
125
126#[repr(C)]
127pub struct lzma_filter {
128 pub id: lzma_vli,
129 pub options: *mut c_void,
130}
131
132#[repr(C)]
133pub struct lzma_mt {
134 pub flags: u32,
135 pub threads: u32,
136 pub block_size: u64,
137 pub timeout: u32,
138 pub preset: u32,
139 pub filters: *const lzma_filter,
140 pub check: lzma_check,
141
142 reserved_enum1: lzma_reserved_enum,
143 reserved_enum2: lzma_reserved_enum,
144 reserved_enum3: lzma_reserved_enum,
145 reserved_int1: u32,
146 reserved_int2: u32,
147 reserved_int3: u32,
148 reserved_int4: u32,
149 reserved_int5: u64,
150 reserved_int6: u64,
151 reserved_int7: u64,
152 reserved_int8: u64,
153 reserved_ptr1: *mut c_void,
154 reserved_ptr2: *mut c_void,
155 reserved_ptr3: *mut c_void,
156 reserved_ptr4: *mut c_void,
157}
158
159#[repr(C)]
160#[derive(Copy, Clone)]
161pub struct lzma_options_lzma {
162 pub dict_size: u32,
163 pub preset_dict: *const u8,
164 pub preset_dict_size: u32,
165 pub lc: u32,
166 pub lp: u32,
167 pub pb: u32,
168 pub mode: lzma_mode,
169 pub nice_len: u32,
170 pub mf: lzma_match_finder,
171 pub depth: u32,
172
173 reserved_int1: u32,
174 reserved_int2: u32,
175 reserved_int3: u32,
176 reserved_int4: u32,
177 reserved_int5: u32,
178 reserved_int6: u32,
179 reserved_int7: u32,
180 reserved_int8: u32,
181 reserved_enum1: lzma_reserved_enum,
182 reserved_enum2: lzma_reserved_enum,
183 reserved_enum3: lzma_reserved_enum,
184 reserved_enum4: lzma_reserved_enum,
185 reserved_ptr1: *mut c_void,
186 reserved_ptr2: *mut c_void,
187}
188
189#[repr(C)]
190pub struct lzma_stream_flags {
191 pub version: u32,
192 pub backward_size: lzma_vli,
193 pub check: lzma_check,
194
195 reserved_enum1: lzma_reserved_enum,
196 reserved_enum2: lzma_reserved_enum,
197 reserved_enum3: lzma_reserved_enum,
198 reserved_enum4: lzma_reserved_enum,
199 reserved_bool1: lzma_bool,
200 reserved_bool2: lzma_bool,
201 reserved_bool3: lzma_bool,
202 reserved_bool4: lzma_bool,
203 reserved_bool5: lzma_bool,
204 reserved_bool6: lzma_bool,
205 reserved_bool7: lzma_bool,
206 reserved_bool8: lzma_bool,
207 reserved_int1: u32,
208 reserved_int2: u32,
209}
210
211#[repr(C)]
212pub struct lzma_options_bcj {
213 pub start_offset: u32,
214}
215
216extern "C" {
217 pub fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret;
218 pub fn lzma_end(strm: *mut lzma_stream);
219 pub fn lzma_get_progress(strm: *mut lzma_stream, progress_in: *mut u64, progress_out: *mut u64);
220 pub fn lzma_memusage(strm: *const lzma_stream) -> u64;
221 pub fn lzma_memlimit_get(strm: *const lzma_stream) -> u64;
222 pub fn lzma_memlimit_set(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret;
223
224 pub fn lzma_easy_encoder_memusage(preset: u32) -> u64;
225 pub fn lzma_easy_decoder_memusage(preset: u32) -> u64;
226 pub fn lzma_easy_encoder(strm: *mut lzma_stream, preset: u32, check: lzma_check) -> lzma_ret;
227 pub fn lzma_easy_buffer_encode(
228 preset: u32,
229 check: lzma_check,
230 allocator: *const lzma_allocator,
231 input: *const u8,
232 in_size: size_t,
233 out: *mut u8,
234 out_pos: *mut size_t,
235 out_size: size_t,
236 ) -> lzma_ret;
237
238 pub fn lzma_stream_encoder(
239 strm: *mut lzma_stream,
240 filters: *const lzma_filter,
241 check: lzma_check,
242 ) -> lzma_ret;
243 pub fn lzma_stream_encoder_mt_memusage(options: *const lzma_mt) -> u64;
244 pub fn lzma_stream_encoder_mt(strm: *mut lzma_stream, options: *const lzma_mt) -> lzma_ret;
245
246 pub fn lzma_alone_encoder(
247 strm: *mut lzma_stream,
248 options: *const lzma_options_lzma,
249 ) -> lzma_ret;
250
251 pub fn lzma_stream_buffer_bound(uncompressed_size: size_t) -> size_t;
252 pub fn lzma_stream_buffer_encode(
253 filters: *mut lzma_filter,
254 check: lzma_check,
255 allocator: *const lzma_allocator,
256 input: *const u8,
257 in_size: size_t,
258 out: *mut u8,
259 out_pos: *mut size_t,
260 out_size: size_t,
261 ) -> lzma_ret;
262
263 pub fn lzma_stream_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret;
264 pub fn lzma_auto_decoder(strm: *mut lzma_stream, memlimit: u64, flags: u32) -> lzma_ret;
265 pub fn lzma_alone_decoder(strm: *mut lzma_stream, memlimit: u64) -> lzma_ret;
266 pub fn lzma_stream_buffer_decode(
267 memlimit: *mut u64,
268 flags: u32,
269 allocator: *const lzma_allocator,
270 input: *const u8,
271 in_pos: *mut size_t,
272 in_size: size_t,
273 out: *mut u8,
274 out_pos: *mut size_t,
275 out_size: size_t,
276 ) -> lzma_ret;
277
278 pub fn lzma_check_is_supported(check: lzma_check) -> lzma_bool;
279 pub fn lzma_check_size(check: lzma_check) -> u32;
280
281 pub fn lzma_crc32(buf: *const u8, size: size_t, crc: u32) -> u32;
282 pub fn lzma_crc64(buf: *const u8, size: size_t, crc: u64) -> u64;
283 pub fn lzma_get_check(strm: *const lzma_stream) -> lzma_check;
284
285 pub fn lzma_filter_encoder_is_supported(id: lzma_vli) -> lzma_bool;
286 pub fn lzma_filter_decoder_is_supported(id: lzma_vli) -> lzma_bool;
287 pub fn lzma_filters_copy(
288 src: *const lzma_filter,
289 dest: *mut lzma_filter,
290 allocator: *const lzma_allocator,
291 ) -> lzma_ret;
292 pub fn lzma_raw_encoder_memusage(filters: *const lzma_filter) -> u64;
293 pub fn lzma_raw_decoder_memusage(filters: *const lzma_filter) -> u64;
294 pub fn lzma_raw_encoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret;
295 pub fn lzma_raw_decoder(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret;
296 pub fn lzma_filters_update(strm: *mut lzma_stream, filters: *const lzma_filter) -> lzma_ret;
297 pub fn lzma_raw_buffer_encode(
298 filters: *const lzma_filter,
299 allocator: *const lzma_allocator,
300 input: *const u8,
301 in_size: size_t,
302 out: *mut u8,
303 out_pos: *mut size_t,
304 out_size: size_t,
305 ) -> lzma_ret;
306 pub fn lzma_raw_buffer_decode(
307 filters: *const lzma_filter,
308 allocator: *const lzma_allocator,
309 input: *const u8,
310 in_pos: *mut size_t,
311 in_size: size_t,
312 out: *mut u8,
313 out_pos: *mut size_t,
314 out_size: size_t,
315 ) -> lzma_ret;
316 pub fn lzma_properties_size(size: *mut u32, filter: *const lzma_filter) -> lzma_ret;
317 pub fn lzma_properties_encode(filter: *const lzma_filter, props: *mut u8) -> lzma_ret;
318 pub fn lzma_properties_decode(
319 filter: *mut lzma_filter,
320 allocator: *const lzma_allocator,
321 props: *const u8,
322 props_size: size_t,
323 ) -> lzma_ret;
324 pub fn lzma_physmem() -> u64;
325 pub fn lzma_cputhreads() -> u32;
326
327 pub fn lzma_stream_header_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret;
328 pub fn lzma_stream_footer_encode(options: *const lzma_stream_flags, out: *mut u8) -> lzma_ret;
329 pub fn lzma_stream_header_decode(options: *mut lzma_stream_flags, input: *const u8)
330 -> lzma_ret;
331 pub fn lzma_stream_footer_decode(options: *mut lzma_stream_flags, input: *const u8)
332 -> lzma_ret;
333 pub fn lzma_stream_flags_compare(
334 a: *const lzma_stream_flags,
335 b: *const lzma_stream_flags,
336 ) -> lzma_ret;
337
338 pub fn lzma_version_number() -> u32;
339 pub fn lzma_version_string() -> *const c_char;
340
341 pub fn lzma_vli_encode(
342 vli: lzma_vli,
343 vli_pos: *mut size_t,
344 out: *mut u8,
345 out_pos: *mut size_t,
346 out_size: size_t,
347 ) -> lzma_ret;
348 pub fn lzma_vli_decode(
349 vli: *mut lzma_vli,
350 vli_pos: *mut size_t,
351 input: *const u8,
352 in_pos: *mut size_t,
353 in_size: size_t,
354 ) -> lzma_ret;
355 pub fn lzma_vli_size(vli: lzma_vli) -> u32;
356
357 pub fn lzma_lzma_preset(options: *mut lzma_options_lzma, preset: u32) -> lzma_bool;
358 pub fn lzma_mf_is_supported(mf: lzma_match_finder) -> lzma_bool;
359}
360