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 193 len = wcstombs(NULL, path, 0);
194 if (len == (
size_t)-1)
199 len = strlen((
const char *)path);
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) {
264 return (gzFile)state;
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);
305 gzFile
ZEXPORT gzopen_w(path, mode)
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;
395 state->
x.
pos + offset >= 0) {
405 state->
x.
pos += offset;
413 offset += state->
x.
pos;
423 (
unsigned)offset : state->
x.
have;
433 state->
skip = offset;
435 return state->
x.
pos + offset;
543 *errnum = state->
err;
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);
long gzseek(gzFile file, long offset, int whence)
long gzoffset(gzFile file)
int gzbuffer(gzFile file, unsigned size)
gzFile gzopen(char *path, char *mode)
long gzseek64(gzFile file, long offset, int whence)
void gzclearerr(gzFile file)
gzFile gzopen64(char *path, char *mode)
long gztell64(gzFile file)
void error(const char *msg)
void gz_error(gz_statep state, int err, char *msg)
gzFile gzdopen(int fd, char *mode)
int gzrewind(gzFile file)
#define Z_DEFAULT_STRATEGY
char * gzerror(gzFile file, int *errnum)
#define Z_DEFAULT_COMPRESSION
long gzoffset64(gzFile file)