1 | #![allow (bad_style)] |
2 | #![doc (html_root_url = "https://docs.rs/lzma-sys/0.1" )] |
3 | |
4 | use libc::{c_char, c_uchar, c_void, size_t}; |
5 | use std::u64; |
6 | |
7 | #[cfg (target_env = "msvc" )] |
8 | #[doc (hidden)] |
9 | pub type __enum_ty = libc::c_int; |
10 | #[cfg (not(target_env = "msvc" ))] |
11 | #[doc (hidden)] |
12 | pub type __enum_ty = libc::c_uint; |
13 | pub type lzma_bool = c_uchar; |
14 | pub type lzma_ret = __enum_ty; |
15 | pub type lzma_action = __enum_ty; |
16 | type lzma_reserved_enum = __enum_ty; |
17 | pub type lzma_check = __enum_ty; |
18 | pub type lzma_vli = u64; |
19 | pub type lzma_mode = __enum_ty; |
20 | pub type lzma_match_finder = __enum_ty; |
21 | |
22 | pub const LZMA_OK: lzma_ret = 0; |
23 | pub const LZMA_STREAM_END: lzma_ret = 1; |
24 | pub const LZMA_NO_CHECK: lzma_ret = 2; |
25 | pub const LZMA_UNSUPPORTED_CHECK: lzma_ret = 3; |
26 | pub const LZMA_GET_CHECK: lzma_ret = 4; |
27 | pub const LZMA_MEM_ERROR: lzma_ret = 5; |
28 | pub const LZMA_MEMLIMIT_ERROR: lzma_ret = 6; |
29 | pub const LZMA_FORMAT_ERROR: lzma_ret = 7; |
30 | pub const LZMA_OPTIONS_ERROR: lzma_ret = 8; |
31 | pub const LZMA_DATA_ERROR: lzma_ret = 9; |
32 | pub const LZMA_BUF_ERROR: lzma_ret = 10; |
33 | pub const LZMA_PROG_ERROR: lzma_ret = 11; |
34 | |
35 | pub const LZMA_RUN: lzma_action = 0; |
36 | pub const LZMA_SYNC_FLUSH: lzma_action = 1; |
37 | pub const LZMA_FULL_FLUSH: lzma_action = 2; |
38 | pub const LZMA_FULL_BARRIER: lzma_action = 4; |
39 | pub const LZMA_FINISH: lzma_action = 3; |
40 | |
41 | pub const LZMA_CHECK_NONE: lzma_check = 0; |
42 | pub const LZMA_CHECK_CRC32: lzma_check = 1; |
43 | pub const LZMA_CHECK_CRC64: lzma_check = 4; |
44 | pub const LZMA_CHECK_SHA256: lzma_check = 10; |
45 | |
46 | pub const LZMA_MODE_FAST: lzma_mode = 1; |
47 | pub const LZMA_MODE_NORMAL: lzma_mode = 2; |
48 | |
49 | pub const LZMA_MF_HC3: lzma_match_finder = 0x03; |
50 | pub const LZMA_MF_HC4: lzma_match_finder = 0x04; |
51 | pub const LZMA_MF_BT2: lzma_match_finder = 0x12; |
52 | pub const LZMA_MF_BT3: lzma_match_finder = 0x13; |
53 | pub const LZMA_MF_BT4: lzma_match_finder = 0x14; |
54 | |
55 | pub const LZMA_TELL_NO_CHECK: u32 = 0x01; |
56 | pub const LZMA_TELL_UNSUPPORTED_CHECK: u32 = 0x02; |
57 | pub const LZMA_TELL_ANY_CHECK: u32 = 0x04; |
58 | pub const LZMA_IGNORE_CHECK: u32 = 0x10; |
59 | pub const LZMA_CONCATENATED: u32 = 0x08; |
60 | |
61 | pub const LZMA_PRESET_DEFAULT: u32 = 6; |
62 | pub const LZMA_PRESET_LEVEL_MASK: u32 = 0x1f; |
63 | pub const LZMA_PRESET_EXTREME: u32 = 1 << 31; |
64 | |
65 | pub const LZMA_DICT_SIZE_MIN: u32 = 4096; |
66 | pub const LZMA_DICT_SIZE_DEFAULT: u32 = 1 << 23; |
67 | |
68 | pub const LZMA_LCLP_MIN: u32 = 0; |
69 | pub const LZMA_LCLP_MAX: u32 = 4; |
70 | pub const LZMA_LC_DEFAULT: u32 = 3; |
71 | |
72 | pub const LZMA_LP_DEFAULT: u32 = 0; |
73 | |
74 | pub const LZMA_PB_MIN: u32 = 0; |
75 | pub const LZMA_PB_MAX: u32 = 4; |
76 | pub const LZMA_PB_DEFAULT: u32 = 2; |
77 | |
78 | pub const LZMA_BACKWARD_SIZE_MIN: lzma_vli = 4; |
79 | pub const LZMA_BACKWARD_SIZE_MAX: lzma_vli = 1 << 34; |
80 | |
81 | pub const LZMA_VLI_MAX: lzma_vli = u64::MAX / 2; |
82 | pub const LZMA_VLI_UNKNOWN: lzma_vli = u64::MAX; |
83 | pub const LZMA_VLI_BYTES_MAX: usize = 9; |
84 | |
85 | pub const LZMA_FILTER_X86: lzma_vli = 0x04; |
86 | pub const LZMA_FILTER_POWERPC: lzma_vli = 0x05; |
87 | pub const LZMA_FILTER_IA64: lzma_vli = 0x06; |
88 | pub const LZMA_FILTER_ARM: lzma_vli = 0x07; |
89 | pub const LZMA_FILTER_ARMTHUMB: lzma_vli = 0x08; |
90 | pub const LZMA_FILTER_SPARC: lzma_vli = 0x09; |
91 | pub const LZMA_FILTER_LZMA1: lzma_vli = 0x4000000000000001; |
92 | pub const LZMA_FILTER_LZMA2: lzma_vli = 0x21; |
93 | |
94 | #[repr (C)] |
95 | pub 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 | |
101 | pub enum lzma_internal {} |
102 | |
103 | #[repr (C)] |
104 | pub 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)] |
127 | pub struct lzma_filter { |
128 | pub id: lzma_vli, |
129 | pub options: *mut c_void, |
130 | } |
131 | |
132 | #[repr (C)] |
133 | pub 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)] |
161 | pub 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)] |
190 | pub 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)] |
212 | pub struct lzma_options_bcj { |
213 | pub start_offset: u32, |
214 | } |
215 | |
216 | extern "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 | |