8#if defined(_WIN32) && !defined(__BORLANDC__)
9# define LSEEK _lseeki64
11#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
30 static char buf[1024];
33 DWORD lasterr = GetLastError();
34 DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
35 | FORMAT_MESSAGE_ALLOCATE_BUFFER,
45 && msgbuf[chars - 2] ==
'\r' && msgbuf[chars - 1] ==
'\n') {
50 if (chars >
sizeof (buf) - 1) {
51 chars =
sizeof (buf) - 1;
55 wcstombs(buf, msgbuf, chars + 1);
59 sprintf(buf,
"unknown win32 error (%ld)", error);
62 SetLastError(lasterr);
81 state->strm.avail_in = 0;
114 if (*mode >=
'0' && *mode <=
'9')
115 state->level = *mode -
'0';
151 state->strategy =
Z_RLE;
183 len = wcstombs(NULL, path, 0);
184 if (len == (z_size_t)-1)
189 len = strlen((
const char *)path);
190 state->path = (
char *)
malloc(len + 1);
191 if (state->path == NULL) {
198 wcstombs(state->path, path, len + 1);
203#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
204 (void)snprintf(state->path, len + 1,
"%s", (
const char *)path);
206 strcpy(state->path, path);
218 (cloexec ? O_CLOEXEC : 0) |
222 (O_WRONLY | O_CREAT |
224 (exclusive ? O_EXCL : 0) |
231 state->fd = fd > -1 ? fd : (
233 fd == -2 ? _wopen(path, oflag, 0666) :
235 open((
const char *)path, oflag, 0666));
236 if (state->fd == -1) {
242 LSEEK(state->fd, 0, SEEK_END);
248 state->start =
LSEEK(state->fd, 0, SEEK_CUR);
249 if (state->start == -1) state->start = 0;
261 return gz_open(path, -1, mode);
266 return gz_open(path, -1, mode);
274 if (fd == -1 || (path = (
char *)
malloc(7 + 3 *
sizeof(
int))) == NULL)
276#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
277 (void)snprintf(path, 7 + 3 *
sizeof(
int),
"<fd:%d>", fd);
279 sprintf(path,
"<fd:%d>", fd);
288gzFile ZEXPORT gzopen_w(
const wchar_t *path,
const char *mode) {
289 return gz_open(path, -2, mode);
305 if (state->size != 0)
309 if ((size << 1) < size)
332 if (
LSEEK(state->fd, state->start, SEEK_SET) == -1)
356 if (whence != SEEK_SET && whence != SEEK_CUR)
360 if (whence == SEEK_SET)
362 else if (state->seek)
367 if (state->mode ==
GZ_READ && state->how ==
COPY &&
368 state->x.pos +
offset >= 0) {
369 ret =
LSEEK(state->fd,
offset - (z_off64_t)state->x.have, SEEK_CUR);
377 state->strm.avail_in = 0;
395 n =
GT_OFF(state->x.have) || (z_off64_t)state->x.have >
offset ?
396 (
unsigned)
offset : state->x.have;
408 return state->x.pos +
offset;
416 return ret == (z_off_t)ret ? (z_off_t)ret : -1;
431 return state->x.
pos + (state->seek ? state->skip : 0);
439 return ret == (z_off_t)ret ? (z_off_t)ret : -1;
459 offset -= state->strm.avail_in;
468 return ret == (z_off_t)ret ? (z_off_t)ret : -1;
483 return state->mode ==
GZ_READ ? state->past : 0;
499 *errnum = state->err;
500 return state->err ==
Z_MEM_ERROR ?
"out of memory" :
501 (state->msg == NULL ?
"" : state->msg);
531 if (state->msg != NULL) {
551 if ((state->msg = (
char *)
malloc(strlen(state->path) + strlen(msg) + 3)) ==
556#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
557 (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
558 "%s%s%s", state->path,
": ", msg);
560 strcpy(state->msg, state->path);
561 strcat(state->msg,
": ");
562 strcat(state->msg, msg);
G4ThreadLocal T * G4GeomSplitter< T >::offset
void ZEXPORT gzclearerr(gzFile file)
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
local gzFile gz_open(const void *path, int fd, const char *mode)
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)
gzFile ZEXPORT gzopen64(const char *path, const char *mode)
int ZEXPORT gzeof(gzFile file)
gzFile ZEXPORT gzdopen(int fd, const char *mode)
z_off64_t ZEXPORT gzoffset64(gzFile file)
const char *ZEXPORT gzerror(gzFile file, int *errnum)
z_off_t ZEXPORT gzoffset(gzFile file)
unsigned ZLIB_INTERNAL gz_intmax(void)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
gzFile ZEXPORT gzopen(const char *path, const char *mode)
z_off_t ZEXPORT gztell(gzFile file)
int ZEXPORT gzbuffer(gzFile file, unsigned size)
local void gz_reset(gz_statep state)
#define Z_DEFAULT_STRATEGY
#define Z_DEFAULT_COMPRESSION