X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..2fe212b0336512aac9eace69fab09ce856b0bf4b:/src/zlib/gzio.c diff --git a/src/zlib/gzio.c b/src/zlib/gzio.c index e29198ac7a..b780cfef4d 100644 --- a/src/zlib/gzio.c +++ b/src/zlib/gzio.c @@ -70,10 +70,14 @@ 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). */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local gzFile gz_open (const char* path, const char* mode, int fd) +#else local gzFile gz_open (path, mode, fd) const char *path; const char *mode; int fd; +#endif { int err; int level = Z_DEFAULT_COMPRESSION; /* compression level */ @@ -122,7 +126,7 @@ local gzFile gz_open (path, mode, fd) } } while (*p++ && m != fmode + sizeof(fmode)); if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - + if (s->mode == 'w') { #ifdef NO_DEFLATE err = Z_STREAM_ERROR; @@ -173,16 +177,20 @@ local gzFile gz_open (path, mode, fd) check_header(s); /* skip the .gz header */ s->startpos = (ftell(s->file) - s->stream.avail_in); } - + return (gzFile)s; } /* =========================================================================== Opens a gzip (.gz) file for reading or writing. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +gzFile ZEXPORT gzopen (const char* path, const char* mode) +#else gzFile ZEXPORT gzopen (path, mode) const char *path; const char *mode; +#endif { return gz_open (path, mode, -1); } @@ -191,9 +199,13 @@ 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. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +gzFile ZEXPORT gzdopen (int fd, const char* mode) +#else gzFile ZEXPORT gzdopen (fd, mode) int fd; const char *mode; +#endif { char name[20]; @@ -206,10 +218,14 @@ gzFile ZEXPORT gzdopen (fd, mode) /* =========================================================================== * Update the compression level and strategy */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzsetparams (gzFile file, int level, int strategy) +#else int ZEXPORT gzsetparams (file, level, strategy) gzFile file; int level; int strategy; +#endif { gz_stream *s = (gz_stream*)file; @@ -233,8 +249,12 @@ int ZEXPORT gzsetparams (file, level, strategy) for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local int get_byte(gz_stream* s) +#else local int get_byte(s) gz_stream *s; +#endif { if (s->z_eof) return EOF; if (s->stream.avail_in == 0) { @@ -260,8 +280,12 @@ local int get_byte(s) s->stream.avail_in is zero for the first time, but may be non-zero for concatenated .gz files. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local void check_header(gz_stream* s) +#else local void check_header(s) gz_stream *s; +#endif { int method; /* method byte */ int flags; /* flags byte */ @@ -313,8 +337,12 @@ 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. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local int destroy (gz_stream* s) +#else local int destroy (s) gz_stream *s; +#endif { int err = Z_OK; @@ -352,10 +380,14 @@ 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). */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzread (gzFile file, voidp buf, unsigned len) +#else int ZEXPORT gzread (file, buf, len) gzFile file; voidp buf; unsigned len; +#endif { gz_stream *s = (gz_stream*)file; Bytef *start = (Bytef*)buf; /* starting point for crc computation */ @@ -442,8 +474,12 @@ 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. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzgetc(gzFile file) +#else int ZEXPORT gzgetc(file) gzFile file; +#endif { unsigned char c; @@ -460,10 +496,14 @@ int ZEXPORT gzgetc(file) The current implementation is not optimized at all. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +char* ZEXPORT gzgets(gzFile file, char* buf, int len) +#else char * ZEXPORT gzgets(file, buf, len) gzFile file; char *buf; int len; +#endif { char *b = buf; if (buf == Z_NULL || len <= 0) return Z_NULL; @@ -479,10 +519,14 @@ 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). */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzwrite (gzFile file, const voidp buf, unsigned len) +#else int ZEXPORT gzwrite (file, buf, len) gzFile file; const voidp buf; unsigned len; +#endif { gz_stream *s = (gz_stream*)file; @@ -538,12 +582,18 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) } #else /* not ANSI C */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +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) +#else 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; +#endif { char buf[Z_PRINTF_BUFSIZE]; int len; @@ -566,9 +616,13 @@ 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. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzputc(gzFile file, int c) +#else int ZEXPORT gzputc(file, c) gzFile file; int c; +#endif { unsigned char cc = (unsigned char) c; /* required for big endian systems */ @@ -581,9 +635,13 @@ int ZEXPORT gzputc(file, c) the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzputs(gzFile file, const char* s) +#else int ZEXPORT gzputs(file, s) gzFile file; const char *s; +#endif { return gzwrite(file, (char*)s, (unsigned)strlen(s)); } @@ -593,9 +651,13 @@ int ZEXPORT gzputs(file, s) Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local int do_flush (gzFile file, int flush) +#else local int do_flush (file, flush) gzFile file; int flush; +#endif { uInt len; int done = 0; @@ -623,18 +685,22 @@ local int do_flush (file, flush) if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: + * all the available space in the output buffer: */ done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; } return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzflush (gzFile file, int flush) +#else int ZEXPORT gzflush (file, flush) gzFile file; int flush; +#endif { gz_stream *s = (gz_stream*)file; int err = do_flush (file, flush); @@ -653,10 +719,14 @@ int ZEXPORT gzflush (file, flush) SEEK_END is not implemented, returns error. In this version of the library, gzseek can be extremely slow. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +z_off_t ZEXPORT gzseek (gzFile file, z_off_t offset, int whence) +#else z_off_t ZEXPORT gzseek (file, offset, whence) gzFile file; z_off_t offset; int whence; +#endif { gz_stream *s = (gz_stream*)file; @@ -664,7 +734,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { return -1L; } - + if (s->mode == 'w') { #ifdef NO_DEFLATE return -1L; @@ -732,13 +802,17 @@ z_off_t ZEXPORT gzseek (file, offset, whence) } /* =========================================================================== - Rewinds input file. + Rewinds input file. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzrewind (gzFile file) +#else int ZEXPORT gzrewind (file) gzFile file; +#endif { gz_stream *s = (gz_stream*)file; - + if (s == NULL || s->mode != 'r') return -1; s->z_err = Z_OK; @@ -760,8 +834,12 @@ int ZEXPORT gzrewind (file) given compressed file. This position represents a number of bytes in the uncompressed data stream. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +z_off_t ZEXPORT gztell (gzFile file) +#else z_off_t ZEXPORT gztell (file) gzFile file; +#endif { return gzseek(file, 0L, SEEK_CUR); } @@ -770,20 +848,28 @@ z_off_t ZEXPORT gztell (file) Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzeof (gzFile file) +#else int ZEXPORT gzeof (file) gzFile file; +#endif { gz_stream *s = (gz_stream*)file; - + return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; } /* =========================================================================== Outputs a long in LSB order to the given file */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local void putLong (FILE* file, uLong x) +#else local void putLong (file, x) FILE *file; uLong x; +#endif { int n; for (n = 0; n < 4; n++) { @@ -793,10 +879,14 @@ local void putLong (file, x) } /* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets + Reads a long in LSB order from the given gz_stream. Sets */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +local uLong getLong (gz_stream* s) +#else local uLong getLong (s) gz_stream *s; +#endif { uLong x = (uLong)get_byte(s); int c; @@ -813,8 +903,12 @@ local uLong getLong (s) Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +int ZEXPORT gzclose (gzFile file) +#else int ZEXPORT gzclose (file) gzFile file; +#endif { int err; gz_stream *s = (gz_stream*)file; @@ -842,9 +936,13 @@ int ZEXPORT gzclose (file) errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. */ +#if defined(__VISAGECPP__) /* Visualage can't handle this antiquated interface */ +const char* ZEXPORT gzerror (gzFile file, int* errnum) +#else const char* ZEXPORT gzerror (file, errnum) gzFile file; int *errnum; +#endif { char *m; gz_stream *s = (gz_stream*)file;