Skip to main content

miniz_sys/
lib.rs

1#![doc(html_root_url = "https://docs.rs/miniz-sys/0.1")]
2#![allow(bad_style)]
3#![cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
4
5extern crate libc;
6use libc::*;
7
8pub const MZ_NO_FLUSH: c_int = 0;
9pub const MZ_PARTIAL_FLUSH: c_int = 1;
10pub const MZ_SYNC_FLUSH: c_int = 2;
11pub const MZ_FULL_FLUSH: c_int = 3;
12pub const MZ_FINISH: c_int = 4;
13pub const MZ_BLOCK: c_int = 5;
14
15pub const MZ_OK: c_int = 0;
16pub const MZ_STREAM_END: c_int = 1;
17pub const MZ_NEED_DICT: c_int = 2;
18pub const MZ_ERRNO: c_int = -1;
19pub const MZ_STREAM_ERROR: c_int = -2;
20pub const MZ_DATA_ERROR: c_int = -3;
21pub const MZ_MEM_ERROR: c_int = -4;
22pub const MZ_BUF_ERROR: c_int = -5;
23pub const MZ_VERSION_ERROR: c_int = -6;
24pub const MZ_PARAM_ERROR: c_int = -10000;
25
26pub const MZ_DEFLATED: c_int = 8;
27pub const MZ_DEFAULT_WINDOW_BITS: c_int = 15;
28pub const MZ_DEFAULT_STRATEGY: c_int = 0;
29
30#[repr(C)]
31pub struct mz_stream {
32    pub next_in: *const u8,
33    pub avail_in: c_uint,
34    pub total_in: c_ulong,
35
36    pub next_out: *mut u8,
37    pub avail_out: c_uint,
38    pub total_out: c_ulong,
39
40    pub msg: *const c_char,
41    pub state: *mut mz_internal_state,
42
43    pub zalloc: Option<mz_alloc_func>,
44    pub zfree: Option<mz_free_func>,
45    pub opaque: *mut c_void,
46
47    pub data_type: c_int,
48    pub adler: c_ulong,
49    pub reserved: c_ulong,
50}
51
52pub enum mz_internal_state {}
53
54pub type mz_alloc_func = extern "C" fn(*mut c_void, size_t, size_t) -> *mut c_void;
55pub type mz_free_func = extern "C" fn(*mut c_void, *mut c_void);
56
57extern "C" {
58    pub fn mz_deflateInit2(
59        stream: *mut mz_stream,
60        level: c_int,
61        method: c_int,
62        window_bits: c_int,
63        mem_level: c_int,
64        strategy: c_int,
65    ) -> c_int;
66    pub fn mz_deflate(stream: *mut mz_stream, flush: c_int) -> c_int;
67    pub fn mz_deflateEnd(stream: *mut mz_stream) -> c_int;
68    pub fn mz_deflateReset(stream: *mut mz_stream) -> c_int;
69
70    pub fn mz_inflateInit2(stream: *mut mz_stream, window_bits: c_int) -> c_int;
71    pub fn mz_inflate(stream: *mut mz_stream, flush: c_int) -> c_int;
72    pub fn mz_inflateEnd(stream: *mut mz_stream) -> c_int;
73
74    pub fn mz_crc32(crc: c_ulong, ptr: *const u8, len: size_t) -> c_ulong;
75}