1 #![doc(html_root_url = "https://docs.rs/libz-sys/1.0")] 2 #![allow(non_camel_case_types)] 3 4 use std::os::raw::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; 5 6 pub type alloc_func = unsafe extern "C" fn(voidpf, uInt, uInt) -> voidpf; 7 pub type Bytef = u8; 8 pub type free_func = unsafe extern "C" fn(voidpf, voidpf); 9 #[cfg(feature = "libc")] 10 pub type gzFile = *mut gzFile_s; 11 pub type in_func = unsafe extern "C" fn(*mut c_void, *mut *const c_uchar) -> c_uint; 12 pub type out_func = unsafe extern "C" fn(*mut c_void, *mut c_uchar, c_uint) -> c_int; 13 pub type uInt = c_uint; 14 pub type uLong = c_ulong; 15 pub type uLongf = c_ulong; 16 pub type voidp = *mut c_void; 17 pub type voidpc = *const c_void; 18 pub type voidpf = *mut c_void; 19 20 #[cfg(feature = "libc")] 21 pub enum gzFile_s {} 22 pub enum internal_state {} 23 24 #[cfg(feature = "libc")] 25 pub type z_off_t = libc::off_t; 26 27 #[repr(C)] 28 #[derive(Copy, Clone)] 29 pub struct gz_header { 30 pub text: c_int, 31 pub time: uLong, 32 pub xflags: c_int, 33 pub os: c_int, 34 pub extra: *mut Bytef, 35 pub extra_len: uInt, 36 pub extra_max: uInt, 37 pub name: *mut Bytef, 38 pub name_max: uInt, 39 pub comment: *mut Bytef, 40 pub comm_max: uInt, 41 pub hcrc: c_int, 42 pub done: c_int, 43 } 44 pub type gz_headerp = *mut gz_header; 45 46 #[repr(C)] 47 #[derive(Copy, Clone)] 48 pub struct z_stream { 49 pub next_in: *mut Bytef, 50 pub avail_in: uInt, 51 pub total_in: uLong, 52 pub next_out: *mut Bytef, 53 pub avail_out: uInt, 54 pub total_out: uLong, 55 pub msg: *mut c_char, 56 pub state: *mut internal_state, 57 pub zalloc: alloc_func, 58 pub zfree: free_func, 59 pub opaque: voidpf, 60 pub data_type: c_int, 61 pub adler: uLong, 62 pub reserved: uLong, 63 } 64 pub type z_streamp = *mut z_stream; 65 66 extern "C" { adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong67 pub fn adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong; crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong68 pub fn crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong; deflate(strm: z_streamp, flush: c_int) -> c_int69 pub fn deflate(strm: z_streamp, flush: c_int) -> c_int; deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong70 pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; deflateCopy(dest: z_streamp, source: z_streamp) -> c_int71 pub fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int; deflateEnd(strm: z_streamp) -> c_int72 pub fn deflateEnd(strm: z_streamp) -> c_int; deflateInit_(strm: z_streamp, level: c_int, version: *const c_char, stream_size: c_int) -> c_int73 pub fn deflateInit_(strm: z_streamp, level: c_int, 74 version: *const c_char, 75 stream_size: c_int) -> c_int; deflateInit2_(strm: z_streamp, level: c_int, method: c_int, windowBits: c_int, memLevel: c_int, strategy: c_int, version: *const c_char, stream_size: c_int) -> c_int76 pub fn deflateInit2_(strm: z_streamp, 77 level: c_int, 78 method: c_int, 79 windowBits: c_int, 80 memLevel: c_int, 81 strategy: c_int, 82 version: *const c_char, 83 stream_size: c_int) -> c_int; deflateParams(strm: z_streamp, level: c_int, strategy: c_int) -> c_int84 pub fn deflateParams(strm: z_streamp, 85 level: c_int, 86 strategy: c_int) -> c_int; deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int87 pub fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; deflateReset(strm: z_streamp) -> c_int88 pub fn deflateReset(strm: z_streamp) -> c_int; deflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, dictLength: uInt) -> c_int89 pub fn deflateSetDictionary(strm: z_streamp, 90 dictionary: *const Bytef, 91 dictLength: uInt) -> c_int; deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int92 pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int; deflateTune(strm: z_streamp, good_length: c_int, max_lazy: c_int, nice_length: c_int, max_chain: c_int) -> c_int93 pub fn deflateTune(strm: z_streamp, 94 good_length: c_int, 95 max_lazy: c_int, 96 nice_length: c_int, 97 max_chain: c_int) -> c_int; inflate(strm: z_streamp, flush: c_int) -> c_int98 pub fn inflate(strm: z_streamp, flush: c_int) -> c_int; inflateBack(strm: z_streamp, _in: in_func, in_desc: *mut c_void, out: out_func, out_desc: *mut c_void) -> c_int99 pub fn inflateBack(strm: z_streamp, 100 _in: in_func, 101 in_desc: *mut c_void, 102 out: out_func, 103 out_desc: *mut c_void) -> c_int; inflateBackEnd(strm: z_streamp) -> c_int104 pub fn inflateBackEnd(strm: z_streamp) -> c_int; inflateBackInit_(strm: z_streamp, windowBits: c_int, window: *mut c_uchar, version: *const c_char, stream_size: c_int) -> c_int105 pub fn inflateBackInit_(strm: z_streamp, 106 windowBits: c_int, 107 window: *mut c_uchar, 108 version: *const c_char, 109 stream_size: c_int) -> c_int; inflateCopy(dest: z_streamp, source: z_streamp) -> c_int110 pub fn inflateCopy(dest: z_streamp, source: z_streamp) -> c_int; inflateEnd(strm: z_streamp) -> c_int111 pub fn inflateEnd(strm: z_streamp) -> c_int; inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int112 pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int; inflateInit_(strm: z_streamp, version: *const c_char, stream_size: c_int) -> c_int113 pub fn inflateInit_(strm: z_streamp, 114 version: *const c_char, 115 stream_size: c_int) -> c_int; inflateInit2_(strm: z_streamp, windowBits: c_int, version: *const c_char, stream_size: c_int) -> c_int116 pub fn inflateInit2_(strm: z_streamp, 117 windowBits: c_int, 118 version: *const c_char, 119 stream_size: c_int) -> c_int; inflateMark(strm: z_streamp) -> c_long120 pub fn inflateMark(strm: z_streamp) -> c_long; inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int121 pub fn inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; inflateReset(strm: z_streamp) -> c_int122 pub fn inflateReset(strm: z_streamp) -> c_int; inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int123 pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int; inflateSetDictionary(strm: z_streamp, dictionary: *const Bytef, dictLength: uInt) -> c_int124 pub fn inflateSetDictionary(strm: z_streamp, 125 dictionary: *const Bytef, 126 dictLength: uInt) -> c_int; inflateSync(strm: z_streamp) -> c_int127 pub fn inflateSync(strm: z_streamp) -> c_int; zlibCompileFlags() -> uLong128 pub fn zlibCompileFlags() -> uLong; zlibVersion() -> *const c_char129 pub fn zlibVersion() -> *const c_char; 130 131 132 // The above set of functions currently target 1.2.3.4 (what's present on Ubuntu 133 // 12.04, but there's some other APIs that were added later. Should figure out 134 // how to expose them... 135 // 136 // Added in 1.2.5.1 137 // 138 // pub fn deflatePending(strm: z_streamp, 139 // pending: *mut c_uint, 140 // bits: *mut c_int) -> c_int; 141 // 142 // Addedin 1.2.7.1 143 // pub fn inflateGetDictionary(strm: z_streamp, 144 // dictionary: *mut Bytef, 145 // dictLength: *mut uInt) -> c_int; 146 // 147 // Added in 1.2.3.5 148 // pub fn gzbuffer(file: gzFile, size: c_uint) -> c_int; 149 // pub fn gzclose_r(file: gzFile) -> c_int; 150 // pub fn gzclose_w(file: gzFile) -> c_int; 151 // pub fn gzoffset(file: gzFile) -> z_off_t; 152 } 153 154 #[cfg(feature = "libc")] 155 extern "C" { adler32_combine(adler1: uLong, adler2: uLong, len2: z_off_t) -> uLong156 pub fn adler32_combine(adler1: uLong, adler2: uLong, len2: z_off_t) -> uLong; compress(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong) -> c_int157 pub fn compress(dest: *mut Bytef, destLen: *mut uLongf, 158 source: *const Bytef, sourceLen: uLong) -> c_int; compress2(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong, level: c_int) -> c_int159 pub fn compress2(dest: *mut Bytef, destLen: *mut uLongf, 160 source: *const Bytef, sourceLen: uLong, 161 level: c_int) -> c_int; compressBound(sourceLen: uLong) -> uLong162 pub fn compressBound(sourceLen: uLong) -> uLong; crc32_combine(crc1: uLong, crc2: uLong, len2: z_off_t) -> uLong163 pub fn crc32_combine(crc1: uLong, crc2: uLong, len2: z_off_t) -> uLong; gzdirect(file: gzFile) -> c_int164 pub fn gzdirect(file: gzFile) -> c_int; gzdopen(fd: c_int, mode: *const c_char) -> gzFile165 pub fn gzdopen(fd: c_int, mode: *const c_char) -> gzFile; gzclearerr(file: gzFile)166 pub fn gzclearerr(file: gzFile); gzclose(file: gzFile) -> c_int167 pub fn gzclose(file: gzFile) -> c_int; gzeof(file: gzFile) -> c_int168 pub fn gzeof(file: gzFile) -> c_int; gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char169 pub fn gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char; gzflush(file: gzFile, flush: c_int) -> c_int170 pub fn gzflush(file: gzFile, flush: c_int) -> c_int; gzgetc(file: gzFile) -> c_int171 pub fn gzgetc(file: gzFile) -> c_int; gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char172 pub fn gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char; gzopen(path: *const c_char, mode: *const c_char) -> gzFile173 pub fn gzopen(path: *const c_char, mode: *const c_char) -> gzFile; gzputc(file: gzFile, c: c_int) -> c_int174 pub fn gzputc(file: gzFile, c: c_int) -> c_int; gzputs(file: gzFile, s: *const c_char) -> c_int175 pub fn gzputs(file: gzFile, s: *const c_char) -> c_int; gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int176 pub fn gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int; gzrewind(file: gzFile) -> c_int177 pub fn gzrewind(file: gzFile) -> c_int; gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t178 pub fn gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t; gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int179 pub fn gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int; gztell(file: gzFile) -> z_off_t180 pub fn gztell(file: gzFile) -> z_off_t; gzungetc(c: c_int, file: gzFile) -> c_int181 pub fn gzungetc(c: c_int, file: gzFile) -> c_int; gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int182 pub fn gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int; uncompress(dest: *mut Bytef, destLen: *mut uLongf, source: *const Bytef, sourceLen: uLong) -> c_int183 pub fn uncompress(dest: *mut Bytef, 184 destLen: *mut uLongf, 185 source: *const Bytef, 186 sourceLen: uLong) -> c_int; 187 } 188 189 pub const Z_NO_FLUSH: c_int = 0; 190 pub const Z_PARTIAL_FLUSH: c_int = 1; 191 pub const Z_SYNC_FLUSH: c_int = 2; 192 pub const Z_FULL_FLUSH: c_int = 3; 193 pub const Z_FINISH: c_int = 4; 194 pub const Z_BLOCK: c_int = 5; 195 pub const Z_TREES: c_int = 6; 196 197 pub const Z_OK: c_int = 0; 198 pub const Z_STREAM_END: c_int = 1; 199 pub const Z_NEED_DICT: c_int = 2; 200 pub const Z_ERRNO: c_int = -1; 201 pub const Z_STREAM_ERROR: c_int = -2; 202 pub const Z_DATA_ERROR: c_int = -3; 203 pub const Z_MEM_ERROR: c_int = -4; 204 pub const Z_BUF_ERROR: c_int = -5; 205 pub const Z_VERSION_ERROR: c_int = -6; 206 207 pub const Z_NO_COMPRESSION: c_int = 0; 208 pub const Z_BEST_SPEED: c_int = 1; 209 pub const Z_BEST_COMPRESSION: c_int = 9; 210 pub const Z_DEFAULT_COMPRESSION: c_int = -1; 211 212 pub const Z_FILTERED: c_int = 1; 213 pub const Z_HUFFMAN_ONLY: c_int = 2; 214 pub const Z_RLE: c_int = 3; 215 pub const Z_FIXED: c_int = 4; 216 pub const Z_DEFAULT_STRATEGY: c_int = 0; 217 218 pub const Z_BINARY: c_int = 0; 219 pub const Z_TEXT: c_int = 1; 220 pub const Z_ASCII: c_int = Z_TEXT; 221 pub const Z_UNKNOWN: c_int = 2; 222 223 pub const Z_DEFLATED: c_int = 8; 224