summaryrefslogtreecommitdiffstats
path: root/cpukit/zlib/gzio.c
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2011-03-18 10:10:55 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2011-03-18 10:10:55 +0000
commit8198f694f52b6a6284069a37b44bcce5847acdf2 (patch)
tree37d98345fa38b6c25ca6e1b0658ffd45c31cbfcd /cpukit/zlib/gzio.c
parentImport from zlib-1.2.5 (diff)
downloadrtems-8198f694f52b6a6284069a37b44bcce5847acdf2.tar.bz2
Import zlib-1.2.3
Diffstat (limited to 'cpukit/zlib/gzio.c')
-rw-r--r--cpukit/zlib/gzio.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/cpukit/zlib/gzio.c b/cpukit/zlib/gzio.c
index 217a4cc410..7e90f4928f 100644
--- a/cpukit/zlib/gzio.c
+++ b/cpukit/zlib/gzio.c
@@ -1,5 +1,5 @@
/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2004 Jean-loup Gailly.
+ * Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
@@ -264,7 +264,7 @@ local int get_byte(s)
if (s->z_eof) return EOF;
if (s->stream.avail_in == 0) {
errno = 0;
- s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
+ s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
s->z_eof = 1;
if (ferror(s->file)) s->z_err = Z_ERRNO;
@@ -300,7 +300,7 @@ local void check_header(s)
if (len < 2) {
if (len) s->inbuf[0] = s->stream.next_in[0];
errno = 0;
- len = fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
+ len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
s->stream.avail_in += len;
s->stream.next_in = s->inbuf;
@@ -415,6 +415,7 @@ int ZEXPORT gzread (file, buf, len)
s->stream.avail_out--;
s->back = EOF;
s->out++;
+ start++;
if (s->last) {
s->z_err = Z_STREAM_END;
return 1;
@@ -436,8 +437,8 @@ int ZEXPORT gzread (file, buf, len)
s->stream.avail_in -= n;
}
if (s->stream.avail_out > 0) {
- s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
- s->file);
+ s->stream.avail_out -=
+ (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
}
len -= s->stream.avail_out;
s->in += len;
@@ -448,17 +449,13 @@ int ZEXPORT gzread (file, buf, len)
if (s->stream.avail_in == 0 && !s->z_eof) {
errno = 0;
- s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
+ s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
s->z_eof = 1;
if (ferror(s->file)) {
s->z_err = Z_ERRNO;
break;
}
- if (feof(s->file)) { /* avoid error for empty file */
- s->z_err = Z_STREAM_END;
- break;
- }
}
s->stream.next_in = s->inbuf;
}
@@ -492,6 +489,9 @@ int ZEXPORT gzread (file, buf, len)
}
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
+ if (len == s->stream.avail_out &&
+ (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
+ return -1;
return (int)(len - s->stream.avail_out);
}
@@ -903,6 +903,18 @@ int ZEXPORT gzeof (file)
}
/* ===========================================================================
+ Returns 1 if reading and doing so transparently, otherwise zero.
+*/
+int ZEXPORT gzdirect (file)
+ gzFile file;
+{
+ gz_stream *s = (gz_stream*)file;
+
+ if (s == NULL || s->mode != 'r') return 0;
+ return s->transparent;
+}
+
+/* ===========================================================================
Outputs a long in LSB order to the given file
*/
local void putLong (file, x)
@@ -966,9 +978,9 @@ int ZEXPORT gzclose (file)
#endif
/* ===========================================================================
- Returns the error message for the last error which occured on the
+ Returns the error message for the last error which occurred on the
given compressed file. errnum is set to zlib error number. If an
- error occured in the file system and not in the compression library,
+ error occurred in the file system and not in the compression library,
errnum is set to Z_ERRNO and the application may consult errno
to get the exact error code.
*/