26 ret = read(state->fd, buf + *have, len - *have);
30 }
while (*have < len);
54 if (state->eof == 0) {
56 unsigned char *
p = state->in;
57 unsigned const char *q = strm->next_in;
58 unsigned n = strm->avail_in;
63 if (
gz_load(state, state->in + strm->avail_in,
64 state->size - strm->avail_in, &got) == -1)
66 strm->avail_in += got;
67 strm->next_in = state->in;
86 if (state->size == 0) {
88 state->in = (
unsigned char *)malloc(state->want);
89 state->out = (
unsigned char *)malloc(state->want << 1);
90 if (state->in == NULL || state->out == NULL) {
91 if (state->out != NULL)
93 if (state->in != NULL)
98 state->size = state->want;
101 state->strm.zalloc =
Z_NULL;
102 state->strm.zfree =
Z_NULL;
103 state->strm.opaque =
Z_NULL;
104 state->strm.avail_in = 0;
105 state->strm.next_in =
Z_NULL;
116 if (strm->avail_in < 2) {
119 if (strm->avail_in == 0)
130 if (strm->avail_in > 1 &&
131 strm->next_in[0] == 31 && strm->next_in[1] == 139) {
140 if (state->direct == 0) {
150 state->x.next = state->out;
151 if (strm->avail_in) {
152 memcpy(state->x.next, strm->next_in, strm->avail_in);
153 state->x.have = strm->avail_in;
173 had = strm->avail_out;
176 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
178 if (strm->avail_in == 0) {
187 "internal error: inflate stream corrupt");
196 strm->msg == NULL ?
"compressed data error" : strm->msg);
202 state->x.have = had - strm->avail_out;
203 state->x.next = strm->next_out - state->x.have;
228 if (state->how ==
LOOK)
232 if (
gz_load(state, state->out, state->size << 1, &(state->x.have))
235 state->x.next = state->out;
238 strm->avail_out = state->size << 1;
239 strm->next_out = state->out;
243 }
while (state->x.have == 0 && (!state->eof || strm->avail_in));
256 n =
GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
257 (
unsigned)len : state->x.have;
265 else if (state->eof && state->strm.avail_in == 0)
288 strm = &(state->strm);
309 if (
gz_skip(state, state->skip) == -1)
318 n = state->x.have > len ? len : state->x.have;
319 memcpy(buf, state->x.next, n);
325 else if (state->eof && strm->avail_in == 0) {
332 else if (state->how ==
LOOK || len < (state->size << 1)) {
342 else if (state->how ==
COPY) {
343 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
349 strm->avail_out =
len;
350 strm->next_out = (
unsigned char *)buf;
359 buf = (
char *)buf + n;
377 unsigned char buf[1];
394 return *(state->x.next)++;
398 ret =
gzread(file, buf, 1);
399 return ret < 1 ? -1 : buf[0];
425 if (
gz_skip(state, state->skip) == -1)
434 if (state->x.have == 0) {
436 state->x.next = state->out + (state->size << 1) - 1;
437 state->x.next[0] =
c;
444 if (state->x.have == (state->size << 1)) {
450 if (state->x.next == state->out) {
451 unsigned char *src = state->out + state->x.have;
452 unsigned char *dest = state->out + (state->size << 1);
453 while (src > state->out)
455 state->x.next = dest;
459 state->x.next[0] =
c;
474 if (file == NULL || buf == NULL || len < 1)
486 if (
gz_skip(state, state->skip) == -1)
494 left = (unsigned)len - 1;
497 if (state->x.have == 0 &&
gz_fetch(state) == -1)
499 if (state->x.have == 0) {
505 n = state->x.
have > left ? left : state->x.have;
506 eol = (
unsigned char *)memchr(state->x.next,
'\n', n);
508 n = (unsigned)(eol - state->x.next) + 1;
511 memcpy(buf, state->x.next, n);
517 }
while (left && eol == NULL);
538 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
542 return state->direct;
569 ret = close(state->fd);
int ZEXPORT gzgetc(gzFile file)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT gzungetc(int c, gzFile file)
local int gz_decomp(gz_statep state)
local int gz_fetch(gz_statep state)
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
local int gz_look(gz_statep state)
#define inflateInit2(strm, windowBits)
char *ZEXPORT gzgets(gzFile file, char *buf, int len)
int ZEXPORT gzdirect(gzFile file)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT gzgetc_(gzFile file)
local int gz_skip(gz_statep state, z_off64_t len)
int ZEXPORT inflateEnd(z_streamp strm)
int ZEXPORT gzclose_r(gzFile file)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
int ZEXPORT inflate(z_streamp strm, int flush)
local int gz_avail(gz_statep state)
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))
int ZEXPORT inflateReset(z_streamp strm)