31 ret = read(state->fd, buf + *have, len - *have);
35 }
while (*have < len);
55 if (state->err !=
Z_OK)
57 if (state->eof == 0) {
58 if (
gz_load(state, state->in, state->size,
59 (
unsigned *)&(strm->avail_in)) == -1)
61 strm->next_in = state->in;
67 #define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
68 (strm->avail_in == 0 ? -1 : \
69 (strm->avail_in--, *(strm->next_in)++)))
82 val += (unsigned)
NEXT() << 8;
83 val += (
unsigned long)
NEXT() << 16;
87 val += (
unsigned long)ch << 24;
112 if (state->size == 0) {
114 state->in =
malloc(state->want);
115 state->out =
malloc(state->want << 1);
116 if (state->in ==
NULL || state->out ==
NULL) {
117 if (state->out !=
NULL)
119 if (state->in !=
NULL)
124 state->size = state->want;
127 state->strm.zalloc =
Z_NULL;
128 state->strm.zfree =
Z_NULL;
129 state->strm.opaque =
Z_NULL;
130 state->strm.avail_in = 0;
131 state->strm.next_in =
Z_NULL;
142 if (strm->avail_in == 0) {
145 if (strm->avail_in == 0)
150 if (strm->next_in[0] == 31) {
153 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
155 if (strm->avail_in && strm->next_in[0] == 139) {
177 len = (unsigned)
NEXT();
178 len += (unsigned)
NEXT() << 8;
213 state->raw = state->pos;
214 state->next = state->out;
215 if (strm->avail_in) {
216 memcpy(state->next + state->have, strm->next_in, strm->avail_in);
217 state->have += strm->avail_in;
238 unsigned long crc,
len;
242 had = strm->avail_out;
245 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
247 if (strm->avail_in == 0) {
256 "internal error: inflate stream corrupt");
265 strm->msg ==
NULL ?
"compressed data error" : strm->msg);
271 state->have = had - strm->avail_out;
272 state->next = strm->next_out - state->have;
273 strm->adler =
crc32(strm->adler, state->next, state->have);
281 if (crc != strm->adler) {
285 if (len != (strm->total_out & 0xffffffffL)) {
309 if (state->how ==
LOOK) {
315 if (state->how ==
COPY) {
316 if (
gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
318 state->next = state->out;
320 else if (state->how ==
GZIP) {
321 strm->avail_out = state->size << 1;
322 strm->next_out = state->out;
341 (
unsigned)len : state->have;
349 else if (state->eof && state->strm.avail_in == 0)
375 strm = &(state->strm);
395 if (
gz_skip(state, state->skip) == -1)
404 n = state->have > len ? len : state->have;
405 memcpy(buf, state->next, n);
411 else if (state->eof && strm->avail_in == 0)
416 else if (state->how ==
LOOK || len < (state->size << 1)) {
426 else if (state->how ==
COPY) {
427 if (
gz_load(state, buf, len, &n) == -1)
433 strm->avail_out =
len;
434 strm->next_out =
buf;
443 buf = (
char *)buf + n;
457 unsigned char buf[1];
473 return *(state->next)++;
477 ret =
gzread(file, buf, 1);
478 return ret < 1 ? -1 : buf[0];
500 if (
gz_skip(state, state->skip) == -1)
509 if (state->have == 0) {
511 state->next = state->out + (state->size << 1) - 1;
518 if (state->have == (state->size << 1)) {
524 if (state->next == state->out) {
525 unsigned char *
src = state->out + state->have;
526 unsigned char *dest = state->out + (state->size << 1);
527 while (src > state->out)
550 if (file ==
NULL || buf ==
NULL || len < 1)
561 if (
gz_skip(state, state->skip) == -1)
569 left = (unsigned)len - 1;
572 if (state->have == 0) {
575 if (state->have == 0) {
583 n = state->have > left ? left : state->have;
584 eol = memchr(state->next,
'\n', n);
586 n = (unsigned)(eol - state->next) + 1;
589 memcpy(buf, state->next, n);
595 }
while (left && eol ==
NULL);
619 if (state->how ==
LOOK && state->have == 0)
623 return state->direct;
650 ret = close(state->fd);
int ZEXPORT gzgetc(gzFile file)
GLuint const GLfloat * val
char *ZEXPORT gzgets(gzFile file, char *buf, int len)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
local int gz_skip(gz_statep state, z_off64_t len)
int ZEXPORT inflateEnd(z_streamp strm)
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
local int gz_head(gz_statep state)
int ZEXPORT gzungetc(int c, gzFile file)
#define zstrerror(errnum)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT gzclose_r(gzFile file)
#define inflateInit2(strm, windowBits)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
int ZEXPORT inflate(z_streamp strm, int flush)
local int gz_decomp(gz_statep state)
int ZEXPORT inflateReset(z_streamp strm)
local int gz_make(gz_statep state)
local int gz_avail(gz_statep state)
int ZEXPORT gzdirect(gzFile file)
GLenum GLuint GLsizei const GLchar * buf
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
local int gz_next4(gz_statep state, unsigned long *ret)