8 #if defined(_WIN32) && !defined(__BORLANDC__)
9 # define LSEEK _lseeki64
11 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
12 # define LSEEK lseek64
18 #if !defined(__GNUC__) && !defined(_WIN32_WCE)
44 static char buf[1024];
47 DWORD lasterr = GetLastError();
48 DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
49 | FORMAT_MESSAGE_ALLOCATE_BUFFER,
59 && msgbuf[chars - 2] ==
'\r' && msgbuf[chars - 1] ==
'\n') {
64 if (chars >
sizeof (buf) - 1) {
65 chars =
sizeof (buf) - 1;
69 wcstombs(buf, msgbuf, chars + 1);
73 sprintf(buf,
"unknown win32 error (%ld)", error);
76 SetLastError(lasterr);
95 state->strm.avail_in = 0;
132 if (*mode >=
'0' && *mode <=
'9')
133 state->level = *mode -
'0';
139 #ifndef NO_GZCOMPRESS
169 state->strategy =
Z_RLE;
201 len = wcstombs(
NULL, path, 0);
202 if (len == (
size_t)-1)
207 len = strlen((
const char *)path);
208 state->path = (
char *)
malloc(len + 1);
209 if (state->path ==
NULL) {
216 wcstombs(state->path, path, len + 1);
221 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
222 snprintf(state->path, len + 1,
"%s", (
const char *)path);
224 strcpy(state->path, path);
236 (cloexec ? O_CLOEXEC : 0) |
240 (O_WRONLY | O_CREAT |
242 (exclusive ? O_EXCL : 0) |
249 state->fd = fd > -1 ? fd : (
251 fd == -2 ? _wopen(path, oflag, 0666) :
253 open((
const char *)path, oflag, 0666));
254 if (state->fd == -1) {
265 if (state->start == -1) state->start = 0;
280 return gz_open(path, -1, mode);
288 return gz_open(path, -1, mode);
299 if (fd == -1 || (path = (
char *)
malloc(7 + 3 *
sizeof(
int))) ==
NULL)
301 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
302 snprintf(path, 7 + 3 *
sizeof(
int),
"<fd:%d>", fd);
304 sprintf(path,
"<fd:%d>", fd);
317 return gz_open(path, -2, mode);
336 if (state->size != 0)
396 offset -= state->x.pos;
397 else if (state->seek)
398 offset += state->skip;
402 if (state->mode ==
GZ_READ && state->how ==
COPY &&
403 state->x.pos + offset >= 0) {
412 state->strm.avail_in = 0;
413 state->x.pos += offset;
421 offset += state->x.pos;
431 (
unsigned)offset : state->x.have;
441 state->skip = offset;
443 return state->x.pos + offset;
472 return state->x.
pos + (state->seek ? state->skip : 0);
504 offset -= state->strm.avail_in;
532 return state->mode ==
GZ_READ ? state->past : 0;
551 *errnum = state->err;
552 return state->err ==
Z_MEM_ERROR ?
"out of memory" :
553 (state->msg ==
NULL ?
"" : state->msg);
589 if (state->msg !=
NULL) {
609 if ((state->msg = (
char *)
malloc(strlen(state->path) + strlen(msg) + 3)) ==
614 #if !defined(NO_snprintf) && !defined(NO_vsnprintf)
615 snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
616 "%s%s%s", state->path,
": ", msg);
618 strcpy(state->msg, state->path);
619 strcat(state->msg,
": ");
620 strcat(state->msg, msg);
#define Z_DEFAULT_COMPRESSION
int ZEXPORT gzeof(gzFile file)
z_off64_t ZEXPORT gzoffset64(gzFile file)
local gzFile gz_open(void *path, int fd, const char *mode) const
z_off_t ZEXPORT gztell(gzFile file)
int ZEXPORT gzrewind(gzFile file)
z_off64_t ZEXPORT gztell64(gzFile file)
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
void error(const char *msg)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT gzbuffer(gzFile file, unsigned size)
gzFile ZEXPORT gzdopen(int fd, const char *mode)
z_off_t ZEXPORT gzoffset(gzFile file)
const char *ZEXPORT gzerror(gzFile file, int *errnum)
local void gz_reset(gz_statep state)
void ZEXPORT gzclearerr(gzFile file)
gzFile ZEXPORT gzopen64(char *path, const char *mode) const
gzFile ZEXPORT gzopen(char *path, const char *mode) const
unsigned ZLIB_INTERNAL gz_intmax()
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
#define Z_DEFAULT_STRATEGY