diff options
Diffstat (limited to 'libpng/gzio.c')
-rw-r--r-- | libpng/gzio.c | 102 |
1 files changed, 29 insertions, 73 deletions
diff --git a/libpng/gzio.c b/libpng/gzio.c index f7c336a..2723a0e 100644 --- a/libpng/gzio.c +++ b/libpng/gzio.c @@ -1,5 +1,5 @@ /* gzio.c -- IO on .gz files - * Copyright (C) 1995-1998 Jean-loup Gailly. + * Copyright (C) 1995-2002 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h * * Compile this file with -DNO_DEFLATE to avoid the compression code. @@ -70,10 +70,7 @@ local uLong getLong OF((gz_stream *s)); can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; +local gzFile gz_open (const char *path, const char *mode, int fd) { int err; int level = Z_DEFAULT_COMPRESSION; /* compression level */ @@ -180,9 +177,7 @@ local gzFile gz_open (path, mode, fd) /* =========================================================================== Opens a gzip (.gz) file for reading or writing. */ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; +gzFile ZEXPORT gzopen (const char *path, const char *mode) { return gz_open (path, mode, -1); } @@ -191,9 +186,7 @@ gzFile ZEXPORT gzopen (path, mode) Associate a gzFile with the file descriptor fd. fd is not dup'ed here to mimic the behavio(u)r of fdopen. */ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; +gzFile ZEXPORT gzdopen (int fd, const char *mode) { char name[20]; @@ -206,10 +199,7 @@ gzFile ZEXPORT gzdopen (fd, mode) /* =========================================================================== * Update the compression level and strategy */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; +int ZEXPORT gzsetparams (gzFile file, int level, int strategy) { gz_stream *s = (gz_stream*)file; @@ -233,8 +223,7 @@ int ZEXPORT gzsetparams (file, level, strategy) for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ -local int get_byte(s) - gz_stream *s; +local int get_byte(gz_stream *s) { if (s->z_eof) return EOF; if (s->stream.avail_in == 0) { @@ -260,8 +249,7 @@ local int get_byte(s) s->stream.avail_in is zero for the first time, but may be non-zero for concatenated .gz files. */ -local void check_header(s) - gz_stream *s; +local void check_header(gz_stream *s) { int method; /* method byte */ int flags; /* flags byte */ @@ -313,8 +301,7 @@ local void check_header(s) * Cleanup then free the given gz_stream. Return a zlib error code. Try freeing in the reverse order of allocations. */ -local int destroy (s) - gz_stream *s; +local int destroy (gz_stream *s) { int err = Z_OK; @@ -352,10 +339,7 @@ local int destroy (s) Reads the given number of uncompressed bytes from the compressed file. gzread returns the number of bytes actually read (0 for end of file). */ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; +int ZEXPORT gzread (gzFile file, voidp buf, unsigned int len) { gz_stream *s = (gz_stream*)file; Bytef *start = (Bytef*)buf; /* starting point for crc computation */ @@ -446,8 +430,7 @@ int ZEXPORT gzread (file, buf, len) Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ -int ZEXPORT gzgetc(file) - gzFile file; +int ZEXPORT gzgetc(gzFile file) { unsigned char c; @@ -464,10 +447,7 @@ int ZEXPORT gzgetc(file) The current implementation is not optimized at all. */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { char *b = buf; if (buf == Z_NULL || len <= 0) return Z_NULL; @@ -483,10 +463,7 @@ char * ZEXPORT gzgets(file, buf, len) Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of bytes actually written (0 in case of error). */ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - const voidp buf; - unsigned len; +int ZEXPORT gzwrite (gzFile file, const voidp buf, unsigned int len) { gz_stream *s = (gz_stream*)file; @@ -542,12 +519,11 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) } #else /* not ANSI C */ -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; +int ZEXPORTVA gzprintf (gzFile file, const char *format, + int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, + int a16, int a17, int a18, int a19, int a20) { char buf[Z_PRINTF_BUFSIZE]; int len; @@ -570,9 +546,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; +int ZEXPORT gzputc(gzFile file, int c) { unsigned char cc = (unsigned char) c; /* required for big endian systems */ @@ -585,9 +559,7 @@ int ZEXPORT gzputc(file, c) the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; +int ZEXPORT gzputs(gzFile file, const char *s) { return gzwrite(file, (char*)s, (unsigned)strlen(s)); } @@ -597,9 +569,7 @@ int ZEXPORT gzputs(file, s) Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. */ -local int do_flush (file, flush) - gzFile file; - int flush; +local int do_flush (gzFile file, int flush) { uInt len; int done = 0; @@ -636,9 +606,7 @@ local int do_flush (file, flush) return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; +int ZEXPORT gzflush (gzFile file, int flush) { gz_stream *s = (gz_stream*)file; int err = do_flush (file, flush); @@ -657,10 +625,7 @@ int ZEXPORT gzflush (file, flush) SEEK_END is not implemented, returns error. In this version of the library, gzseek can be extremely slow. */ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; +z_off_t ZEXPORT gzseek (gzFile file, long int offset, int whence) { gz_stream *s = (gz_stream*)file; @@ -738,8 +703,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) /* =========================================================================== Rewinds input file. */ -int ZEXPORT gzrewind (file) - gzFile file; +int ZEXPORT gzrewind (gzFile file) { gz_stream *s = (gz_stream*)file; @@ -765,8 +729,7 @@ int ZEXPORT gzrewind (file) given compressed file. This position represents a number of bytes in the uncompressed data stream. */ -z_off_t ZEXPORT gztell (file) - gzFile file; +z_off_t ZEXPORT gztell (gzFile file) { return gzseek(file, 0L, SEEK_CUR); } @@ -775,8 +738,7 @@ z_off_t ZEXPORT gztell (file) Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ -int ZEXPORT gzeof (file) - gzFile file; +int ZEXPORT gzeof (gzFile file) { gz_stream *s = (gz_stream*)file; @@ -786,9 +748,7 @@ int ZEXPORT gzeof (file) /* =========================================================================== Outputs a long in LSB order to the given file */ -local void putLong (file, x) - FILE *file; - uLong x; +local void putLong (FILE *file, uLong x) { int n; for (n = 0; n < 4; n++) { @@ -801,8 +761,7 @@ local void putLong (file, x) Reads a long in LSB order from the given gz_stream. Sets z_err in case of error. */ -local uLong getLong (s) - gz_stream *s; +local uLong getLong (gz_stream *s) { uLong x = (uLong)get_byte(s); int c; @@ -819,8 +778,7 @@ local uLong getLong (s) Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. */ -int ZEXPORT gzclose (file) - gzFile file; +int ZEXPORT gzclose (gzFile file) { int err; gz_stream *s = (gz_stream*)file; @@ -848,9 +806,7 @@ int ZEXPORT gzclose (file) errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. */ -const char* ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; +const char* ZEXPORT gzerror (gzFile file, int *errnum) { char *m; gz_stream *s = (gz_stream*)file; |