diff options
Diffstat (limited to 'gzio.c')
-rw-r--r-- | gzio.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* gzio.c -- IO on .gz files | 1 | /* gzio.c -- IO on .gz files |
2 | * Copyright (C) 1995-2004 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. |
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 | * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. | 5 | * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. |
@@ -264,7 +264,7 @@ local int get_byte(s) | |||
264 | if (s->z_eof) return EOF; | 264 | if (s->z_eof) return EOF; |
265 | if (s->stream.avail_in == 0) { | 265 | if (s->stream.avail_in == 0) { |
266 | errno = 0; | 266 | errno = 0; |
267 | s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); | 267 | s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); |
268 | if (s->stream.avail_in == 0) { | 268 | if (s->stream.avail_in == 0) { |
269 | s->z_eof = 1; | 269 | s->z_eof = 1; |
270 | if (ferror(s->file)) s->z_err = Z_ERRNO; | 270 | if (ferror(s->file)) s->z_err = Z_ERRNO; |
@@ -300,7 +300,7 @@ local void check_header(s) | |||
300 | if (len < 2) { | 300 | if (len < 2) { |
301 | if (len) s->inbuf[0] = s->stream.next_in[0]; | 301 | if (len) s->inbuf[0] = s->stream.next_in[0]; |
302 | errno = 0; | 302 | errno = 0; |
303 | len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); | 303 | len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); |
304 | if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; | 304 | if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; |
305 | s->stream.avail_in += len; | 305 | s->stream.avail_in += len; |
306 | s->stream.next_in = s->inbuf; | 306 | s->stream.next_in = s->inbuf; |
@@ -415,6 +415,7 @@ int ZEXPORT gzread (file, buf, len) | |||
415 | s->stream.avail_out--; | 415 | s->stream.avail_out--; |
416 | s->back = EOF; | 416 | s->back = EOF; |
417 | s->out++; | 417 | s->out++; |
418 | start++; | ||
418 | if (s->last) { | 419 | if (s->last) { |
419 | s->z_err = Z_STREAM_END; | 420 | s->z_err = Z_STREAM_END; |
420 | return 1; | 421 | return 1; |
@@ -436,8 +437,8 @@ int ZEXPORT gzread (file, buf, len) | |||
436 | s->stream.avail_in -= n; | 437 | s->stream.avail_in -= n; |
437 | } | 438 | } |
438 | if (s->stream.avail_out > 0) { | 439 | if (s->stream.avail_out > 0) { |
439 | s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, | 440 | s->stream.avail_out -= |
440 | s->file); | 441 | (uInt)fread(next_out, 1, s->stream.avail_out, s->file); |
441 | } | 442 | } |
442 | len -= s->stream.avail_out; | 443 | len -= s->stream.avail_out; |
443 | s->in += len; | 444 | s->in += len; |
@@ -448,17 +449,13 @@ int ZEXPORT gzread (file, buf, len) | |||
448 | if (s->stream.avail_in == 0 && !s->z_eof) { | 449 | if (s->stream.avail_in == 0 && !s->z_eof) { |
449 | 450 | ||
450 | errno = 0; | 451 | errno = 0; |
451 | s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); | 452 | s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); |
452 | if (s->stream.avail_in == 0) { | 453 | if (s->stream.avail_in == 0) { |
453 | s->z_eof = 1; | 454 | s->z_eof = 1; |
454 | if (ferror(s->file)) { | 455 | if (ferror(s->file)) { |
455 | s->z_err = Z_ERRNO; | 456 | s->z_err = Z_ERRNO; |
456 | break; | 457 | break; |
457 | } | 458 | } |
458 | if (feof(s->file)) { /* avoid error for empty file */ | ||
459 | s->z_err = Z_STREAM_END; | ||
460 | break; | ||
461 | } | ||
462 | } | 459 | } |
463 | s->stream.next_in = s->inbuf; | 460 | s->stream.next_in = s->inbuf; |
464 | } | 461 | } |
@@ -903,6 +900,18 @@ int ZEXPORT gzeof (file) | |||
903 | } | 900 | } |
904 | 901 | ||
905 | /* =========================================================================== | 902 | /* =========================================================================== |
903 | Returns 1 if reading and doing so transparently, otherwise zero. | ||
904 | */ | ||
905 | int ZEXPORT gzdirect (file) | ||
906 | gzFile file; | ||
907 | { | ||
908 | gz_stream *s = (gz_stream*)file; | ||
909 | |||
910 | if (s == NULL || s->mode != 'r') return 0; | ||
911 | return s->transparent; | ||
912 | } | ||
913 | |||
914 | /* =========================================================================== | ||
906 | Outputs a long in LSB order to the given file | 915 | Outputs a long in LSB order to the given file |
907 | */ | 916 | */ |
908 | local void putLong (file, x) | 917 | local void putLong (file, x) |