BZ2_bzReadOpen

Function BZ2_bzReadOpen 

Source
#[unsafe(export_name = "BZ2_bzReadOpen")]
pub unsafe extern "C" fn BZ2_bzReadOpen( bzerror: *mut c_int, f: *mut FILE, verbosity: c_int, small: c_int, unused: *mut c_void, nUnused: c_int, ) -> *mut BZFILE
Expand description

Prepare to read compressed data from a file handle.

The file handle f should refer to a file which has been opened for reading, and for which the error indicator libc::ferror(f) is not set.

If small is 1, the library will try to decompress using less memory, at the expense of speed.

For reasons explained below, BZ2_bzRead will decompress the nUnused bytes starting at unused, before starting to read from the file f. At most BZ_MAX_UNUSED bytes may be supplied like this. If this facility is not required, you should pass NULL and 0 for unused and nUnused respectively.

For the meaning of parameters small, verbosity, see BZ2_bzDecompressInit.

Because the compression ratio of the compressed data cannot be known in advance, there is no easy way to guarantee that the output buffer will be big enough. You may of course make arrangements in your code to record the size of the uncompressed data, but such a mechanism is beyond the scope of this library.

§Returns

  • if *bzerror is BZ_OK, a valid pointer to an abstract BZFILE
  • otherwise NULL

§Possible assignments to bzerror

  • BZ_PARAM_ERROR if any of
    • (unused.is_null() && nUnused != 0)
    • (!unused.is_null() && !(0..=BZ_MAX_UNUSED).contains(&nUnused))
    • !(0..=1).contains(&small)
    • !(0..=4).contains(&verbosity)
  • BZ_CONFIG_ERROR if no default allocator is configured
  • BZ_IO_ERROR if libc::ferror(f) is nonzero
  • BZ_MEM_ERROR if insufficient memory is available
  • BZ_OK otherwise

§Safety

The caller must guarantee that

  • bzerror satisfies the requirements of pointer::as_mut
  • Either
    • unused is NULL
    • unused is readable for nUnused bytes