diff options
Diffstat (limited to 'gzio.c')
-rw-r--r-- | gzio.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -13,8 +13,16 @@ | |||
13 | 13 | ||
14 | struct internal_state {int dummy;}; /* for buggy compilers */ | 14 | struct internal_state {int dummy;}; /* for buggy compilers */ |
15 | 15 | ||
16 | #define Z_BUFSIZE 16384 | 16 | #ifndef Z_BUFSIZE |
17 | #define Z_PRINTF_BUFSIZE 4096 | 17 | # ifdef MAXSEG_64K |
18 | # define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ | ||
19 | # else | ||
20 | # define Z_BUFSIZE 16384 | ||
21 | # endif | ||
22 | #endif | ||
23 | #ifndef Z_PRINTF_BUFSIZE | ||
24 | # define Z_PRINTF_BUFSIZE 4096 | ||
25 | #endif | ||
18 | 26 | ||
19 | #define ALLOC(size) malloc(size) | 27 | #define ALLOC(size) malloc(size) |
20 | #define TRYFREE(p) {if (p) free(p);} | 28 | #define TRYFREE(p) {if (p) free(p);} |
@@ -132,8 +140,12 @@ local gzFile gz_open (path, mode, fd) | |||
132 | s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); | 140 | s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); |
133 | 141 | ||
134 | err = inflateInit2(&(s->stream), -MAX_WBITS); | 142 | err = inflateInit2(&(s->stream), -MAX_WBITS); |
135 | /* windowBits is passed < 0 to tell that there is no zlib header */ | 143 | /* windowBits is passed < 0 to tell that there is no zlib header. |
136 | 144 | * Note that in this case inflate *requires* an extra "dummy" byte | |
145 | * after the compressed stream in order to complete decompression and | ||
146 | * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are | ||
147 | * present after the compressed stream. | ||
148 | */ | ||
137 | if (err != Z_OK || s->inbuf == Z_NULL) { | 149 | if (err != Z_OK || s->inbuf == Z_NULL) { |
138 | return destroy(s), (gzFile)Z_NULL; | 150 | return destroy(s), (gzFile)Z_NULL; |
139 | } | 151 | } |
@@ -379,6 +391,7 @@ int ZEXPORT gzread (file, buf, len) | |||
379 | len -= s->stream.avail_out; | 391 | len -= s->stream.avail_out; |
380 | s->stream.total_in += (uLong)len; | 392 | s->stream.total_in += (uLong)len; |
381 | s->stream.total_out += (uLong)len; | 393 | s->stream.total_out += (uLong)len; |
394 | if (len == 0) s->z_eof = 1; | ||
382 | return (int)len; | 395 | return (int)len; |
383 | } | 396 | } |
384 | if (s->stream.avail_in == 0 && !s->z_eof) { | 397 | if (s->stream.avail_in == 0 && !s->z_eof) { |
@@ -572,7 +585,7 @@ int ZEXPORT gzputs(file, s) | |||
572 | gzFile file; | 585 | gzFile file; |
573 | const char *s; | 586 | const char *s; |
574 | { | 587 | { |
575 | return gzwrite(file, (const voidp)s, (unsigned)strlen(s)); | 588 | return gzwrite(file, (char*)s, (unsigned)strlen(s)); |
576 | } | 589 | } |
577 | 590 | ||
578 | 591 | ||