summaryrefslogtreecommitdiff
path: root/infblock.c
diff options
context:
space:
mode:
Diffstat (limited to 'infblock.c')
-rw-r--r--infblock.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/infblock.c b/infblock.c
index 9c6e6a8..733e983 100644
--- a/infblock.c
+++ b/infblock.c
@@ -1,5 +1,5 @@
1/* infblock.c -- interpret and process block types to last block 1/* infblock.c -- interpret and process block types to last block
2 * Copyright (C) 1995 Mark Adler 2 * Copyright (C) 1995-1996 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -81,7 +81,7 @@ uLongf *c;
81 s->bitb = 0; 81 s->bitb = 0;
82 s->read = s->write = s->window; 82 s->read = s->write = s->window;
83 if (s->checkfn != Z_NULL) 83 if (s->checkfn != Z_NULL)
84 s->check = (*s->checkfn)(0L, Z_NULL, 0); 84 z->adler = s->check = (*s->checkfn)(0L, Z_NULL, 0);
85 Trace((stderr, "inflate: blocks reset\n")); 85 Trace((stderr, "inflate: blocks reset\n"));
86} 86}
87 87
@@ -110,6 +110,9 @@ uInt w;
110} 110}
111 111
112 112
113#ifdef DEBUG
114 extern uInt inflate_hufts;
115#endif
113int inflate_blocks(s, z, r) 116int inflate_blocks(s, z, r)
114inflate_blocks_statef *s; 117inflate_blocks_statef *s;
115z_stream *z; 118z_stream *z;
@@ -172,7 +175,7 @@ int r;
172 case 3: /* illegal */ 175 case 3: /* illegal */
173 DUMPBITS(3) 176 DUMPBITS(3)
174 s->mode = BAD; 177 s->mode = BAD;
175 z->msg = "invalid block type"; 178 z->msg = (char*)"invalid block type";
176 r = Z_DATA_ERROR; 179 r = Z_DATA_ERROR;
177 LEAVE 180 LEAVE
178 } 181 }
@@ -182,14 +185,14 @@ int r;
182 if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) 185 if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
183 { 186 {
184 s->mode = BAD; 187 s->mode = BAD;
185 z->msg = "invalid stored block lengths"; 188 z->msg = (char*)"invalid stored block lengths";
186 r = Z_DATA_ERROR; 189 r = Z_DATA_ERROR;
187 LEAVE 190 LEAVE
188 } 191 }
189 s->sub.left = (uInt)b & 0xffff; 192 s->sub.left = (uInt)b & 0xffff;
190 b = k = 0; /* dump bits */ 193 b = k = 0; /* dump bits */
191 Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); 194 Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
192 s->mode = s->sub.left ? STORED : TYPE; 195 s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
193 break; 196 break;
194 case STORED: 197 case STORED:
195 if (n == 0) 198 if (n == 0)
@@ -215,7 +218,7 @@ int r;
215 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) 218 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
216 { 219 {
217 s->mode = BAD; 220 s->mode = BAD;
218 z->msg = "too many length or distance symbols"; 221 z->msg = (char*)"too many length or distance symbols";
219 r = Z_DATA_ERROR; 222 r = Z_DATA_ERROR;
220 LEAVE 223 LEAVE
221 } 224 }
@@ -285,7 +288,7 @@ int r;
285 (c == 16 && i < 1)) 288 (c == 16 && i < 1))
286 { 289 {
287 s->mode = BAD; 290 s->mode = BAD;
288 z->msg = "invalid bit length repeat"; 291 z->msg = (char*)"invalid bit length repeat";
289 r = Z_DATA_ERROR; 292 r = Z_DATA_ERROR;
290 LEAVE 293 LEAVE
291 } 294 }
@@ -306,6 +309,9 @@ int r;
306 bl = 9; /* must be <= 9 for lookahead assumptions */ 309 bl = 9; /* must be <= 9 for lookahead assumptions */
307 bd = 6; /* must be <= 9 for lookahead assumptions */ 310 bd = 6; /* must be <= 9 for lookahead assumptions */
308 t = s->sub.trees.table; 311 t = s->sub.trees.table;
312#ifdef DEBUG
313 inflate_hufts = 0;
314#endif
309 t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), 315 t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
310 s->sub.trees.blens, &bl, &bd, &tl, &td, z); 316 s->sub.trees.blens, &bl, &bd, &tl, &td, z);
311 if (t != Z_OK) 317 if (t != Z_OK)
@@ -315,7 +321,8 @@ int r;
315 r = t; 321 r = t;
316 LEAVE 322 LEAVE
317 } 323 }
318 Tracev((stderr, "inflate: trees ok\n")); 324 Tracev((stderr, "inflate: trees ok, %d * %d bytes used\n",
325 inflate_hufts, sizeof(inflate_huft)));
319 if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) 326 if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
320 { 327 {
321 inflate_trees_free(td, z); 328 inflate_trees_free(td, z);
@@ -383,3 +390,13 @@ uLongf *c;
383 Trace((stderr, "inflate: blocks freed\n")); 390 Trace((stderr, "inflate: blocks freed\n"));
384 return Z_OK; 391 return Z_OK;
385} 392}
393
394
395void inflate_set_dictionary(s, d, n)
396inflate_blocks_statef *s;
397const Bytef *d;
398uInt n;
399{
400 zmemcpy((charf *)s->window, d, n);
401 s->read = s->write = s->window + n;
402}