Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions liblzma-sys/src/manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ pub const LZMA_FILTER_RISCV: lzma_vli = 0x0B;
pub const LZMA_FILTER_LZMA1: lzma_vli = 0x4000000000000001;
pub const LZMA_FILTER_LZMA2: lzma_vli = 0x21;

// Size of the LZMA/XZ stream header/footer in bytes.
pub const LZMA_STREAM_HEADER_SIZE: u32 = 12;

#[repr(C)]
pub struct lzma_allocator {
pub alloc: Option<extern "C" fn(*mut c_void, size_t, size_t) -> *mut c_void>,
Expand Down Expand Up @@ -215,6 +218,12 @@ pub struct lzma_options_bcj {
pub start_offset: u32,
}

#[repr(C)]
pub struct lzma_index_s {
_unused: [u8; 0],
}
pub type lzma_index = lzma_index_s;

extern "C" {
pub fn lzma_code(strm: *mut lzma_stream, action: lzma_action) -> lzma_ret;
pub fn lzma_end(strm: *mut lzma_stream);
Expand Down Expand Up @@ -344,6 +353,18 @@ extern "C" {
b: *const lzma_stream_flags,
) -> lzma_ret;

// Index parsing and querying used by high-level helpers.
pub fn lzma_index_buffer_decode(
i: *mut *mut lzma_index,
memlimit: *mut u64,
allocator: *const lzma_allocator,
input: *const u8,
in_pos: *mut usize,
in_size: usize,
) -> lzma_ret;
pub fn lzma_index_uncompressed_size(i: *const lzma_index) -> lzma_vli;
pub fn lzma_index_end(i: *mut lzma_index, allocator: *const lzma_allocator);

pub fn lzma_version_number() -> u32;
pub fn lzma_version_string() -> *const c_char;

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ pub fn copy_decode<R: Read, W: Write>(source: R, mut destination: W) -> io::Resu
}

/// Find the size in bytes of uncompressed data from xz file.
#[cfg(feature = "bindgen")]
pub fn uncompressed_size<R: Read + Seek>(mut source: R) -> io::Result<u64> {
use std::mem::MaybeUninit;
let mut footer = [0u8; liblzma_sys::LZMA_STREAM_HEADER_SIZE as usize];
Expand Down Expand Up @@ -197,7 +196,6 @@ mod tests {
}

#[test]
#[cfg(feature = "bindgen")]
fn size() {
quickcheck(test as fn(_) -> _);

Expand Down
Loading