8 #if defined(_WIN32) && !defined(__BORLANDC__) 9 # define LSEEK _lseeki64 11 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 12 # define LSEEK lseek64 36 static char buf[1024];
39 DWORD lasterr = GetLastError();
40 DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
41 | FORMAT_MESSAGE_ALLOCATE_BUFFER,
51 && msgbuf[chars - 2] ==
'\r' && msgbuf[chars - 1] ==
'\n') {
56 if (chars >
sizeof (buf) - 1) {
57 chars =
sizeof (
buf) - 1;
61 wcstombs(buf, msgbuf, chars + 1);
65 sprintf(buf,
"unknown win32 error (%ld)", error);
68 SetLastError(lasterr);
87 state->strm.avail_in = 0;
124 if (*mode >=
'0' && *mode <=
'9')
125 state->level = *mode -
'0';
131 #ifndef NO_GZCOMPRESS 161 state->strategy =
Z_RLE;
193 len = wcstombs(
NULL, path, 0);
194 if (len == (
size_t)-1)
199 len = strlen((
const char *)path);
200 state->path = (
char *)
malloc(len + 1);
201 if (state->path ==
NULL) {
208 wcstombs(state->path, path, len + 1);
213 #if !defined(NO_snprintf) && !defined(NO_vsnprintf) 214 snprintf(state->path, len + 1,
"%s", (
const char *)path);
216 strcpy(state->path, path);
228 (cloexec ? O_CLOEXEC : 0) |
232 (O_WRONLY | O_CREAT |
234 (exclusive ? O_EXCL : 0) |
241 state->fd = fd > -1 ? fd : (
243 fd == -2 ? _wopen(path, oflag, 0666) :
245 open((
const char *)path, oflag, 0666));
246 if (state->fd == -1) {
257 if (state->start == -1) state->start = 0;
272 return gz_open(path, -1, mode);
280 return gz_open(path, -1, mode);
291 if (fd == -1 || (path = (
char *)
malloc(7 + 3 *
sizeof(
int))) ==
NULL)
293 #if !defined(NO_snprintf) && !defined(NO_vsnprintf) 294 snprintf(path, 7 + 3 *
sizeof(
int),
"<fd:%d>", fd);
296 sprintf(path,
"<fd:%d>", fd);
309 return gz_open(path, -2, mode);
328 if (state->size != 0)
388 offset -= state->x.pos;
389 else if (state->seek)
390 offset += state->skip;
394 if (state->mode ==
GZ_READ && state->how ==
COPY &&
395 state->x.pos + offset >= 0) {
404 state->strm.avail_in = 0;
413 offset += state->x.pos;
423 (
unsigned)
offset : state->x.have;
435 return state->x.pos +
offset;
464 return state->x.
pos + (state->seek ? state->skip : 0);
496 offset -= state->strm.avail_in;
524 return state->mode ==
GZ_READ ? state->past : 0;
543 *errnum = state->err;
544 return state->err ==
Z_MEM_ERROR ?
"out of memory" :
545 (state->msg ==
NULL ?
"" : state->msg);
581 if (state->msg !=
NULL) {
601 if ((state->msg = (
char *)
malloc(strlen(state->path) + strlen(msg) + 3)) ==
606 #if !defined(NO_snprintf) && !defined(NO_vsnprintf) 607 snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
608 "%s%s%s", state->path,
": ", msg);
610 strcpy(state->msg, state->path);
611 strcat(state->msg,
": ");
612 strcat(state->msg, msg);
GLdouble GLdouble GLdouble GLdouble q
int ZEXPORT gzeof(gzFile file)
z_off64_t ZEXPORT gzoffset64(gzFile file)
local gzFile gz_open(void *path, int fd, const char *mode) const
#define Z_DEFAULT_COMPRESSION
z_off_t ZEXPORT gztell(gzFile file)
GLenum GLuint GLenum GLsizei const GLchar * buf
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)
GLsizei const GLchar ** path
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)
#define Z_DEFAULT_STRATEGY
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
int open(const char *name, int flags, int mode)
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)
local void gz_reset OF((gz_statep))