30 ret =
read(state->fd, buf + *have, len - *have);
34 }
while (*have < len);
59 if (state->eof == 0) {
61 unsigned char *
p = state->in;
62 unsigned const char *
q = strm->next_in;
63 unsigned n = strm->avail_in;
68 if (
gz_load(state, state->in + strm->avail_in,
69 state->size - strm->avail_in, &got) == -1)
71 strm->avail_in += got;
72 strm->next_in = state->in;
92 if (state->size == 0) {
94 state->in = (
unsigned char *)
malloc(state->want);
95 state->out = (
unsigned char *)
malloc(state->want << 1);
96 if (state->in ==
NULL || state->out ==
NULL) {
97 if (state->out !=
NULL)
99 if (state->in !=
NULL)
104 state->size = state->want;
107 state->strm.zalloc =
Z_NULL;
108 state->strm.zfree =
Z_NULL;
109 state->strm.opaque =
Z_NULL;
110 state->strm.avail_in = 0;
111 state->strm.next_in =
Z_NULL;
122 if (strm->avail_in < 2) {
125 if (strm->avail_in == 0)
136 if (strm->avail_in > 1 &&
137 strm->next_in[0] == 31 && strm->next_in[1] == 139) {
146 if (state->direct == 0) {
156 state->x.next = state->out;
157 if (strm->avail_in) {
158 memcpy(state->x.next, strm->next_in, strm->avail_in);
159 state->x.have = strm->avail_in;
180 had = strm->avail_out;
183 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
185 if (strm->avail_in == 0) {
194 "internal error: inflate stream corrupt");
203 strm->msg ==
NULL ?
"compressed data error" : strm->msg);
209 state->x.have = had - strm->avail_out;
210 state->x.next = strm->next_out - state->x.have;
236 if (state->how ==
LOOK)
240 if (
gz_load(state, state->out, state->size << 1, &(state->x.have))
243 state->x.next = state->out;
246 strm->avail_out = state->size << 1;
247 strm->next_out = state->out;
251 }
while (state->x.have == 0 && (!state->eof || strm->avail_in));
267 (
unsigned)
len : state->x.have;
275 else if (state->eof && state->strm.avail_in == 0)
301 strm = &(state->strm);
322 if (
gz_skip(state, state->skip) == -1)
331 n = state->x.have > len ?
len : state->x.have;
332 memcpy(buf, state->x.next, n);
338 else if (state->eof && strm->avail_in == 0) {
345 else if (state->how ==
LOOK || len < (state->size << 1)) {
355 else if (state->how ==
COPY) {
356 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
362 strm->avail_out =
len;
363 strm->next_out = (
unsigned char *)buf;
372 buf = (
char *)buf + n;
391 unsigned char buf[1];
408 return *(state->x.next)++;
412 ret =
gzread(file, buf, 1);
413 return ret < 1 ? -1 : buf[0];
442 if (
gz_skip(state, state->skip) == -1)
451 if (state->x.have == 0) {
453 state->x.next = state->out + (state->size << 1) - 1;
454 state->x.next[0] =
c;
461 if (state->x.have == (state->size << 1)) {
467 if (state->x.next == state->out) {
468 unsigned char *
src = state->out + state->x.have;
469 unsigned char *dest = state->out + (state->size << 1);
470 while (src > state->out)
472 state->x.next = dest;
476 state->x.next[0] =
c;
494 if (file ==
NULL || buf ==
NULL || len < 1)
506 if (
gz_skip(state, state->skip) == -1)
514 left = (unsigned)len - 1;
517 if (state->x.have == 0 &&
gz_fetch(state) == -1)
519 if (state->x.have == 0) {
525 n = state->x.have > left ?
left : state->x.have;
526 eol = (
unsigned char *)memchr(state->x.next,
'\n', n);
528 n = (unsigned)(eol - state->x.next) + 1;
531 memcpy(buf, state->x.next, n);
537 }
while (left && eol ==
NULL);
559 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
563 return state->direct;
591 ret =
close(state->fd);
int ZEXPORT gzdirect(gzFile file)
local int gz_fetch(gz_statep state)
int read(int fd, char *buf, int nbytes)
local int gz_skip(gz_statep state, z_off64_t len)
GLdouble GLdouble GLdouble GLdouble q
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
int ZEXPORT inflateReset(z_streamp strm)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
#define inflateInit2(strm, windowBits)
GLenum GLuint GLenum GLsizei const GLchar * buf
int ZEXPORT gzgetc_(gzFile file)
int ZEXPORT gzungetc(int c, gzFile file)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT inflate(z_streamp strm, int flush)
int ZEXPORT gzclose_r(gzFile file)
local int gz_decomp(gz_statep state)
char *ZEXPORT gzgets(gzFile file, char *buf, int len)
int ZEXPORT gzgetc(gzFile file)
local int gz_avail(gz_statep state)
local int gz_look(gz_statep state)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT inflateEnd(z_streamp strm)
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *))
#define zstrerror(errnum)