=========================================================================== * Test inflateSync() */
(compr, comprLen, uncompr, uncomprLen)
| 428 | * Test inflateSync() |
| 429 | */ |
| 430 | void test_sync(compr, comprLen, uncompr, uncomprLen) |
| 431 | Byte *compr, *uncompr; |
| 432 | uLong comprLen, uncomprLen; |
| 433 | { |
| 434 | int err; |
| 435 | z_stream d_stream; /* decompression stream */ |
| 436 | |
| 437 | strcpy((char*)uncompr, "garbage"); |
| 438 | |
| 439 | d_stream.zalloc = zalloc; |
| 440 | d_stream.zfree = zfree; |
| 441 | d_stream.opaque = (voidpf)0; |
| 442 | |
| 443 | d_stream.next_in = compr; |
| 444 | d_stream.avail_in = 2; /* just read the zlib header */ |
| 445 | |
| 446 | err = inflateInit(&d_stream); |
| 447 | CHECK_ERR(err, "inflateInit"); |
| 448 | |
| 449 | d_stream.next_out = uncompr; |
| 450 | d_stream.avail_out = (uInt)uncomprLen; |
| 451 | |
| 452 | inflate(&d_stream, Z_NO_FLUSH); |
| 453 | CHECK_ERR(err, "inflate"); |
| 454 | |
| 455 | d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ |
| 456 | err = inflateSync(&d_stream); /* but skip the damaged part */ |
| 457 | CHECK_ERR(err, "inflateSync"); |
| 458 | |
| 459 | err = inflate(&d_stream, Z_FINISH); |
| 460 | if (err != Z_DATA_ERROR) { |
| 461 | fprintf(stderr, "inflate should report DATA_ERROR\n"); |
| 462 | /* Because of incorrect adler32 */ |
| 463 | exit(1); |
| 464 | } |
| 465 | err = inflateEnd(&d_stream); |
| 466 | CHECK_ERR(err, "inflateEnd"); |
| 467 | |
| 468 | printf("after inflateSync(): hel%s\n", (char *)uncompr); |
| 469 | } |
| 470 | |
| 471 | /* =========================================================================== |
| 472 | * Test deflate() with preset dictionary |