#include "gzguts.h"
#if defined(_WIN32) && !defined(__BORLANDC__)
#define LSEEK …
#define OPEN …
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
#define LSEEK …
#define OPEN …
#else
#define LSEEK …
#define OPEN …
#endif
#endif
#if defined UNDER_CE
char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
static char buf[1024];
wchar_t *msgbuf;
DWORD lasterr = GetLastError();
DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL,
error,
0,
(LPVOID)&msgbuf,
0,
NULL);
if (chars != 0) {
if (chars >= 2
&& msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
chars -= 2;
msgbuf[chars] = 0;
}
if (chars > sizeof (buf) - 1) {
chars = sizeof (buf) - 1;
msgbuf[chars] = 0;
}
wcstombs(buf, msgbuf, chars + 1);
LocalFree(msgbuf);
}
else {
sprintf(buf, "unknown win32 error (%ld)", error);
}
SetLastError(lasterr);
return buf;
}
#endif
local void gz_reset(gz_statep state) { … }
local gzFile gz_open(const void *path, int fd, const char *mode) { … }
gzFile ZEXPORT gzopen(const char *path, const char *mode) { … }
gzFile ZEXPORT gzopen64(const char *path, const char *mode) { … }
gzFile ZEXPORT gzdopen(int fd, const char *mode) { … }
#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
return gz_open(path, -2, mode);
}
#endif
int ZEXPORT gzbuffer(gzFile file, unsigned size) { … }
int ZEXPORT gzrewind(gzFile file) { … }
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { … }
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { … }
z_off64_t ZEXPORT gztell64(gzFile file) { … }
z_off_t ZEXPORT gztell(gzFile file) { … }
z_off64_t ZEXPORT gzoffset64(gzFile file) { … }
z_off_t ZEXPORT gzoffset(gzFile file) { … }
int ZEXPORT gzeof(gzFile file) { … }
const char * ZEXPORT gzerror(gzFile file, int *errnum) { … }
void ZEXPORT gzclearerr(gzFile file) { … }
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { … }
#ifndef INT_MAX
unsigned ZLIB_INTERNAL gz_intmax(void) {
unsigned p, q;
p = 1;
do {
q = p;
p <<= 1;
p++;
} while (p > q);
return q >> 1;
}
#endif