#[unsafe(export_name = "inflateGetHeader")]pub unsafe extern "C-unwind" fn inflateGetHeader(
strm: *mut z_stream,
head: *mut gz_header,
) -> i32Expand description
Requests that gzip header information be stored in the provided gz_header structure.
The inflateGetHeader function may be called after inflateInit2_ or inflateReset, and before the first call of inflate.
As inflate processes the gzip stream, head.done is zero until the header is completed, at which time head.done is set to one.
If a zlib stream is being decoded, then head.done is set to -1 to indicate that there will be no gzip header information forthcoming.
Note that Z_BLOCK can be used to force inflate to return immediately after header processing is complete and before any actual data is decompressed.
- The
text,time,xflags, andosfields are filled in with the gzip header contents. hcrcis set to true if there is a header CRC. (The header CRC was valid if done is set to one.)- If
extrais notNULL, thenextra_maxcontains the maximum number of bytes to write to extra. Oncedoneistrue,extra_lencontains the actual extra field length, andextracontains the extra field, or that field truncated ifextra_maxis less thanextra_len. - If
nameis notNULL, then up toname_maxcharacters are written there, terminated with a zero unless the length is greater thanname_max. - If
commentis notNULL, then up tocomm_maxcharacters are written there, terminated with a zero unless the length is greater thancomm_max.
When any of extra, name, or comment are not NULL and the respective field is not present in the header, then that field is set to NULL to signal its absence.
This allows the use of deflateSetHeader with the returned structure to duplicate the header. However if those fields are set to allocated memory,
then the application will need to save those pointers elsewhere so that they can be eventually freed.
If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present.
inflateReset will reset the process to discard the header information.
The application would need to call inflateGetHeader again to retrieve the header from the next gzip stream.
§Returns
Z_OKif successZ_STREAM_ERRORif the source stream state was inconsistent (such as zalloc being NULL)
§Safety
- Either
strmisNULLstrmsatisfies the requirements of&mut *strmand was initialized withinflateInit_or similar
- Either
headisNULLheadsatisfies the requirements of&mut *head
- If
headis notNULL:- if
head.extrais not NULL, it must be writable for at leasthead.extra_maxbytes - if
head.nameis not NULL, it must be writable for at leasthead.name_maxbytes - if
head.commentis not NULL, it must be writable for at leasthead.comm_maxbytes
- if