#[export_name = "inflateGetHeader"]
pub unsafe extern "C-unwind" fn inflateGetHeader(
strm: z_streamp,
head: gz_headerp,
) -> c_int
Expand 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
, andos
fields are filled in with the gzip header contents. hcrc
is set to true if there is a header CRC. (The header CRC was valid if done is set to one.)- If
extra
is notNULL
, thenextra_max
contains the maximum number of bytes to write to extra. Oncedone
istrue
,extra_len
contains the actual extra field length, andextra
contains the extra field, or that field truncated ifextra_max
is less thanextra_len
. - If
name
is notNULL
, then up toname_max
characters are written there, terminated with a zero unless the length is greater thanname_max
. - If
comment
is notNULL
, then up tocomm_max
characters 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_OK
if successZ_STREAM_ERROR
if the source stream state was inconsistent (such as zalloc being NULL)
§Safety
- Either
strm
isNULL
strm
satisfies the requirements of&mut *strm
and was initialized withinflateInit_
or similar
- Either
head
isNULL
head
satisfies the requirements of&mut *head
- If
head
is notNULL
:- if
head.extra
is not NULL, it must be writable for at leasthead.extra_max
bytes - if
head.name
is not NULL, it must be writable for at leasthead.name_max
bytes - if
head.comment
is not NULL, it must be writable for at leasthead.comm_max
bytes
- if