static LZ_FAST : c_int = 0x1; // LZ with only one probe
static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best"
+static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum
pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
do bytes.as_imm_buf |b, len| {
}
}
-pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] {
+fn inflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] {
do bytes.as_imm_buf |b, len| {
unsafe {
let mut outsz : size_t = 0;
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
len as size_t,
&mut outsz,
- 0);
+ flags);
assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8,
outsz as uint);
}
}
+pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] {
+ inflate_bytes_(bytes, 0)
+}
+
+pub fn inflate_bytes_zlib(bytes: &[u8]) -> ~[u8] {
+ inflate_bytes_(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER)
+}
+
#[cfg(test)]
mod tests {
use super::*;