summaryrefslogtreecommitdiff
path: root/deps/zlib/gzlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/zlib/gzlib.c')
-rw-r--r--deps/zlib/gzlib.c108
1 files changed, 79 insertions, 29 deletions
diff --git a/deps/zlib/gzlib.c b/deps/zlib/gzlib.c
index 487862cad7..dddaf26873 100644
--- a/deps/zlib/gzlib.c
+++ b/deps/zlib/gzlib.c
@@ -16,8 +16,8 @@
#endif
/* Local functions */
-local void gz_reset(gz_statep);
-local gzFile gz_open(const void *, int, const char *);
+local void gz_reset OF((gz_statep));
+local gzFile gz_open OF((const void *, int, const char *));
#if defined UNDER_CE
@@ -30,7 +30,9 @@ local gzFile gz_open(const void *, int, const char *);
The gz_strwinerror function does not change the current setting of
GetLastError. */
-char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
+char ZLIB_INTERNAL *gz_strwinerror (error)
+ DWORD error;
+{
static char buf[1024];
wchar_t *msgbuf;
@@ -70,7 +72,9 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
#endif /* UNDER_CE */
/* Reset gzip file state */
-static void gz_reset(gz_statep state) {
+local void gz_reset(state)
+ gz_statep state;
+{
state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */
state->eof = 0; /* not at end of file */
@@ -86,7 +90,10 @@ static void gz_reset(gz_statep state) {
}
/* Open a gzip file either by name or file descriptor. */
-static gzFile gz_open(const void *path, int fd, const char *mode)
+local gzFile gz_open(path, fd, mode)
+ const void *path;
+ int fd;
+ const char *mode;
{
gz_statep state;
z_size_t len;
@@ -183,7 +190,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode)
}
/* save the path name for error messages */
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
if (len == (z_size_t)-1)
@@ -197,7 +204,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode)
free(state);
return NULL;
}
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
@@ -234,7 +241,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode)
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
-#ifdef _WIN32
+#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
@@ -262,17 +269,26 @@ static gzFile gz_open(const void *path, int fd, const char *mode)
}
/* -- see zlib.h -- */
-gzFile ZEXPORT gzopen(const char *path, const char *mode) {
+gzFile ZEXPORT gzopen(path, mode)
+ const char *path;
+ const char *mode;
+{
return gz_open(path, -1, mode);
}
/* -- see zlib.h -- */
-gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
+gzFile ZEXPORT gzopen64(path, mode)
+ const char *path;
+ const char *mode;
+{
return gz_open(path, -1, mode);
}
/* -- see zlib.h -- */
-gzFile ZEXPORT gzdopen(int fd, const char *mode) {
+gzFile ZEXPORT gzdopen(fd, mode)
+ int fd;
+ const char *mode;
+{
char *path; /* identifier for error messages */
gzFile gz;
@@ -289,15 +305,20 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) {
}
/* -- see zlib.h -- */
-#ifdef _WIN32
-gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode)
+#ifdef WIDECHAR
+gzFile ZEXPORT gzopen_w(path, mode)
+ const wchar_t *path;
+ const char *mode;
{
return gz_open(path, -2, mode);
}
#endif
/* -- see zlib.h -- */
-int ZEXPORT gzbuffer(gzFile file, unsigned size) {
+int ZEXPORT gzbuffer(file, size)
+ gzFile file;
+ unsigned size;
+{
gz_statep state;
/* get internal structure and check integrity */
@@ -314,14 +335,16 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size) {
/* check and set requested size */
if ((size << 1) < size)
return -1; /* need to be able to double it */
- if (size < 8)
- size = 8; /* needed to behave well with flushing */
+ if (size < 2)
+ size = 2; /* need two bytes to check magic header */
state->want = size;
return 0;
}
/* -- see zlib.h -- */
-int ZEXPORT gzrewind(gzFile file) {
+int ZEXPORT gzrewind(file)
+ gzFile file;
+{
gz_statep state;
/* get internal structure */
@@ -342,7 +365,11 @@ int ZEXPORT gzrewind(gzFile file) {
}
/* -- see zlib.h -- */
-z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
+z_off64_t ZEXPORT gzseek64(file, offset, whence)
+ gzFile file;
+ z_off64_t offset;
+ int whence;
+{
unsigned n;
z_off64_t ret;
gz_statep state;
@@ -415,7 +442,11 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
}
/* -- see zlib.h -- */
-z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
+z_off_t ZEXPORT gzseek(file, offset, whence)
+ gzFile file;
+ z_off_t offset;
+ int whence;
+{
z_off64_t ret;
ret = gzseek64(file, (z_off64_t)offset, whence);
@@ -423,7 +454,9 @@ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
}
/* -- see zlib.h -- */
-z_off64_t ZEXPORT gztell64(gzFile file) {
+z_off64_t ZEXPORT gztell64(file)
+ gzFile file;
+{
gz_statep state;
/* get internal structure and check integrity */
@@ -438,7 +471,9 @@ z_off64_t ZEXPORT gztell64(gzFile file) {
}
/* -- see zlib.h -- */
-z_off_t ZEXPORT gztell(gzFile file) {
+z_off_t ZEXPORT gztell(file)
+ gzFile file;
+{
z_off64_t ret;
ret = gztell64(file);
@@ -446,7 +481,9 @@ z_off_t ZEXPORT gztell(gzFile file) {
}
/* -- see zlib.h -- */
-z_off64_t ZEXPORT gzoffset64(gzFile file) {
+z_off64_t ZEXPORT gzoffset64(file)
+ gzFile file;
+{
z_off64_t offset;
gz_statep state;
@@ -467,7 +504,9 @@ z_off64_t ZEXPORT gzoffset64(gzFile file) {
}
/* -- see zlib.h -- */
-z_off_t ZEXPORT gzoffset(gzFile file) {
+z_off_t ZEXPORT gzoffset(file)
+ gzFile file;
+{
z_off64_t ret;
ret = gzoffset64(file);
@@ -475,7 +514,9 @@ z_off_t ZEXPORT gzoffset(gzFile file) {
}
/* -- see zlib.h -- */
-int ZEXPORT gzeof(gzFile file) {
+int ZEXPORT gzeof(file)
+ gzFile file;
+{
gz_statep state;
/* get internal structure and check integrity */
@@ -490,7 +531,10 @@ int ZEXPORT gzeof(gzFile file) {
}
/* -- see zlib.h -- */
-const char * ZEXPORT gzerror(gzFile file, int *errnum) {
+const char * ZEXPORT gzerror(file, errnum)
+ gzFile file;
+ int *errnum;
+{
gz_statep state;
/* get internal structure and check integrity */
@@ -508,7 +552,9 @@ const char * ZEXPORT gzerror(gzFile file, int *errnum) {
}
/* -- see zlib.h -- */
-void ZEXPORT gzclearerr(gzFile file) {
+void ZEXPORT gzclearerr(file)
+ gzFile file;
+{
gz_statep state;
/* get internal structure and check integrity */
@@ -532,7 +578,11 @@ void ZEXPORT gzclearerr(gzFile file) {
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
-void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
+void ZLIB_INTERNAL gz_error(state, err, msg)
+ gz_statep state;
+ int err;
+ const char *msg;
+{
/* free previously allocated message and clear */
if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR)
@@ -567,7 +617,6 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
strcat(state->msg, ": ");
strcat(state->msg, msg);
#endif
- return;
}
#ifndef INT_MAX
@@ -575,7 +624,8 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
-unsigned ZLIB_INTERNAL gz_intmax(void) {
+unsigned ZLIB_INTERNAL gz_intmax()
+{
unsigned p, q;
p = 1;