aboutsummaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:19:21 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:19:21 -0700
commitb8c9ecb0765fc39423c07613d909c5193378bdfd (patch)
treec2a2964d00dcfee6c7426ffcdf8e8060727bc2bf /inflate.c
parent6759211ad8a5006689216a86c3267bb503bfccc1 (diff)
downloadzlib-b8c9ecb0765fc39423c07613d909c5193378bdfd.tar.gz
zlib-b8c9ecb0765fc39423c07613d909c5193378bdfd.tar.bz2
zlib-b8c9ecb0765fc39423c07613d909c5193378bdfd.zip
zlib 1.0.9v1.0.9
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/inflate.c b/inflate.c
index 3cff366..7b9bc3b 100644
--- a/inflate.c
+++ b/inflate.c
@@ -50,7 +50,7 @@ struct internal_state {
50}; 50};
51 51
52 52
53int EXPORT inflateReset(z) 53int ZEXPORT inflateReset(z)
54z_streamp z; 54z_streamp z;
55{ 55{
56 if (z == Z_NULL || z->state == Z_NULL) 56 if (z == Z_NULL || z->state == Z_NULL)
@@ -64,7 +64,7 @@ z_streamp z;
64} 64}
65 65
66 66
67int EXPORT inflateEnd(z) 67int ZEXPORT inflateEnd(z)
68z_streamp z; 68z_streamp z;
69{ 69{
70 if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) 70 if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
@@ -78,7 +78,7 @@ z_streamp z;
78} 78}
79 79
80 80
81int EXPORT inflateInit2_(z, w, version, stream_size) 81int ZEXPORT inflateInit2_(z, w, version, stream_size)
82z_streamp z; 82z_streamp z;
83int w; 83int w;
84const char *version; 84const char *version;
@@ -135,7 +135,7 @@ int stream_size;
135} 135}
136 136
137 137
138int EXPORT inflateInit_(z, version, stream_size) 138int ZEXPORT inflateInit_(z, version, stream_size)
139z_streamp z; 139z_streamp z;
140const char *version; 140const char *version;
141int stream_size; 141int stream_size;
@@ -144,18 +144,19 @@ int stream_size;
144} 144}
145 145
146 146
147#define NEEDBYTE {if(z->avail_in==0)return r; if (f != Z_FINISH) r = Z_OK;} 147#define NEEDBYTE {if(z->avail_in==0)return r;r=f;}
148#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) 148#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
149 149
150int EXPORT inflate(z, f) 150int ZEXPORT inflate(z, f)
151z_streamp z; 151z_streamp z;
152int f; 152int f;
153{ 153{
154 int r; 154 int r;
155 uInt b; 155 uInt b;
156 156
157 if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0) 157 if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
158 return Z_STREAM_ERROR; 158 return Z_STREAM_ERROR;
159 f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
159 r = Z_BUF_ERROR; 160 r = Z_BUF_ERROR;
160 while (1) switch (z->state->mode) 161 while (1) switch (z->state->mode)
161 { 162 {
@@ -190,7 +191,7 @@ int f;
190 if (!(b & PRESET_DICT)) 191 if (!(b & PRESET_DICT))
191 { 192 {
192 z->state->mode = BLOCKS; 193 z->state->mode = BLOCKS;
193 break; 194 break;
194 } 195 }
195 z->state->mode = DICT4; 196 z->state->mode = DICT4;
196 case DICT4: 197 case DICT4:
@@ -224,9 +225,10 @@ int f;
224 z->state->sub.marker = 0; /* can try inflateSync */ 225 z->state->sub.marker = 0; /* can try inflateSync */
225 break; 226 break;
226 } 227 }
228 if (r == Z_OK)
229 r = f;
227 if (r != Z_STREAM_END) 230 if (r != Z_STREAM_END)
228 return f == Z_FINISH && r == Z_OK ? Z_BUF_ERROR : r; 231 return r;
229 r = Z_OK;
230 inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); 232 inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
231 if (z->state->nowrap) 233 if (z->state->nowrap)
232 { 234 {
@@ -234,7 +236,6 @@ int f;
234 break; 236 break;
235 } 237 }
236 z->state->mode = CHECK4; 238 z->state->mode = CHECK4;
237 if (f == Z_FINISH) r = Z_BUF_ERROR;
238 case CHECK4: 239 case CHECK4:
239 NEEDBYTE 240 NEEDBYTE
240 z->state->sub.check.need = (uLong)NEXTBYTE << 24; 241 z->state->sub.check.need = (uLong)NEXTBYTE << 24;
@@ -273,7 +274,7 @@ int f;
273} 274}
274 275
275 276
276int EXPORT inflateSetDictionary(z, dictionary, dictLength) 277int ZEXPORT inflateSetDictionary(z, dictionary, dictLength)
277z_streamp z; 278z_streamp z;
278const Bytef *dictionary; 279const Bytef *dictionary;
279uInt dictLength; 280uInt dictLength;
@@ -297,7 +298,7 @@ uInt dictLength;
297} 298}
298 299
299 300
300int EXPORT inflateSync(z) 301int ZEXPORT inflateSync(z)
301z_streamp z; 302z_streamp z;
302{ 303{
303 uInt n; /* number of bytes to look at */ 304 uInt n; /* number of bytes to look at */
@@ -321,8 +322,7 @@ z_streamp z;
321 /* search */ 322 /* search */
322 while (n && m < 4) 323 while (n && m < 4)
323 { 324 {
324 static const Byte mark[4] = {0, 0, 0xff, 0xff}; 325 if (*p == (Byte)(m < 2 ? 0 : (Byte)0xff))
325 if (*p == mark[m])
326 m++; 326 m++;
327 else if (*p) 327 else if (*p)
328 m = 0; 328 m = 0;
@@ -355,7 +355,7 @@ z_streamp z;
355 * decompressing, PPP checks that at the end of input packet, inflate is 355 * decompressing, PPP checks that at the end of input packet, inflate is
356 * waiting for these length bytes. 356 * waiting for these length bytes.
357 */ 357 */
358int EXPORT inflateSyncPoint(z) 358int ZEXPORT inflateSyncPoint(z)
359z_streamp z; 359z_streamp z;
360{ 360{
361 if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) 361 if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)