diff options
Diffstat (limited to '')
| -rw-r--r-- | inftest.c | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/inftest.c b/inftest.c deleted file mode 100644 index d711bfa..0000000 --- a/inftest.c +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include "zutil.h" | ||
| 4 | |||
| 5 | void main __P((void)); | ||
| 6 | |||
| 7 | /* This test is in honor of Ed Hamrick who suggested that the interface | ||
| 8 | to inflate be a byte at a time--this implements that, and is, of course, | ||
| 9 | monumentally slow. It has the virtue though of stressing the push-pull | ||
| 10 | interface for testing purposes. */ | ||
| 11 | |||
| 12 | void main() | ||
| 13 | { | ||
| 14 | int a, r; | ||
| 15 | char c; | ||
| 16 | z_stream z; | ||
| 17 | |||
| 18 | z.zalloc = Z_NULL; | ||
| 19 | z.zfree = Z_NULL; | ||
| 20 | r = inflateInit(&z); | ||
| 21 | if (r != Z_OK) | ||
| 22 | fprintf(stderr, "init error: %s\n", z_errmsg[1 - r]); | ||
| 23 | while ((a = getchar()) != EOF) | ||
| 24 | { | ||
| 25 | /* feed one byte of input */ | ||
| 26 | z.avail_out = 0; | ||
| 27 | c = (char)a; | ||
| 28 | z.next_in = (Byte*)&c; | ||
| 29 | z.avail_in = 1; | ||
| 30 | r = inflate(&z, 0); | ||
| 31 | if (r == Z_STREAM_END) | ||
| 32 | break; | ||
| 33 | if (r != Z_OK) | ||
| 34 | { | ||
| 35 | fprintf(stderr, "inflate error: %s\n", z_errmsg[1 - r]); | ||
| 36 | break; | ||
| 37 | } | ||
| 38 | if (z.avail_in != 0) | ||
| 39 | { | ||
| 40 | fprintf(stderr, "inflate didn't eat byte and didn't say buf err!\n"); | ||
| 41 | break; | ||
| 42 | } | ||
| 43 | |||
| 44 | /* empty output one byte at a time */ | ||
| 45 | while (1) | ||
| 46 | { | ||
| 47 | z.next_out = (Byte*)&c; | ||
| 48 | z.avail_out = 1; | ||
| 49 | r = inflate(&z, 0); | ||
| 50 | if (r == Z_STREAM_END) | ||
| 51 | break; | ||
| 52 | if (r != Z_OK && r != Z_BUF_ERROR) | ||
| 53 | { | ||
| 54 | fprintf(stderr, "inflate error: %s\n", z_errmsg[1 - r]); | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | if (z.avail_out == 0) | ||
| 58 | putchar(c); | ||
| 59 | else | ||
| 60 | break; | ||
| 61 | } | ||
| 62 | if (r != Z_OK && r != Z_BUF_ERROR) | ||
| 63 | break; | ||
| 64 | } | ||
| 65 | inflateEnd(&z); | ||
| 66 | fprintf(stderr, "%ld bytes in, %ld bytes out\n", z.total_in, z.total_out); | ||
| 67 | if (z.msg != NULL) | ||
| 68 | fprintf(stderr, "msg is <%s>\n", z.msg); | ||
| 69 | } | ||
