about summary refs log tree commit diff homepage
path: root/inflateGetHeader.3
blob: 748c33460d0a2b674b29ffc3756303da627c7e9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
.Dd November 11, 2018
.Dt INFLATEGETHEADER 3
.Os
.
.Sh NAME
.Nm inflateGetHeader
.Nd get gzip header
.
.Sh LIBRARY
.Lb libz
.
.Sh SYNOPSIS
.In zlib.h
.Ft int
.Fn inflateGetHeader "z_streamp strm" "gz_headerp head"
.
.Sh DESCRIPTION
.Fn inflateGetHeader
requests that gzip header information
be stored in the provided
.Vt gz_header
structure.
.Fn inflateGetHeader
may be called after
.Xr inflateInit2 3
or
.Xr inflateReset 3 ,
and before the first call of
.Xr inflate 3 .
As
.Xr inflate 3
processes the gzip stream,
.Fa head->done
is zero until the header is completed,
at which time
.Fa head->done
is set to one.
If a zlib stream is being decoded,
then
.Fa head->done
is set to -1 to indicate that
 there will be no gzip header information forthcoming.
Note that
.Dv Z_BLOCK
or
.Dv Z_TREES
can be used to force
.Xr inflate 3
to return immediately after
header processing is complete
and before any actual data is decompressed.
.
.Pp
The
.Fa text ,
.Fa time ,
.Fa xflags ,
and
.Fa os
fields are filled in with the gzip header contents.
.Fa hcrc
is set to true if there is a header CRC.
.Po
The header CRC was valid if
.Fa done
is set to one.
.Pc \&
If
.Fa extra
is not
.Dv Z_NULL ,
then
.Fa extra_max
contains the maximum number of bytes to write to
.Fa extra .
Once
.Fa done
is true,
.Fa extra_len
contains the actual extra field length,
and
.Fa extra
contains the extra field,
or that field truncated if
.Fa extra_max
is less than
.Fa extra_len .
If
.Fa name
is not
.Dv Z_NULL ,
then up to
.Fa name_max
characters are written there,
terminated with a zero
unless the length is greater than
.Fa name_max .
If
.Fa comment
is not
.Dv Z_NULL ,
then up to
.Fa comm_max
characters are written there,
terminated with a zero
unless the length is greater than
.Fa comm_max .
When any of
.Fa extra ,
.Fa name ,
or
.Fa comment
are not
.Dv Z_NULL
and the respective field
is not present in the header,
then that field is set to
.Dv Z_NULL
to signal its absence.
This allows the use of
.Xr deflateSetHeader 3
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 feed.
.
.Pp
If
.Fn inflateGetHeader
is not used,
then the header information is simply discarded.
The header is always checked for validity,
including the header CRC if present.
.Xr inflateReset 3
will reset the process to discard the header information.
The application would need to call
.Fn inflateGetHeader
again to retrieve the header from the next gzip stream.
.
.Pp
The
.Vt gz_headerp
type is documented in
.Xr deflateSetHeader 3 .
.
.Sh RETURN VALUES
.Fn inflateGetHeader
returns
.Dv Z_OK
if success,
or
.Dv Z_STREAM_ERROR
if the source stream state was inconsistent.