26 ret = read(state->fd, buf + *have, len - *have);
30 }
while (*have < len);
54 if (state->eof == 0) {
56 unsigned char *
p = state->in, *q = strm->next_in;
57 unsigned n = strm->avail_in;
62 if (
gz_load(state, state->in + strm->avail_in,
63 state->size - strm->avail_in, &got) == -1)
65 strm->avail_in += got;
66 strm->next_in = state->in;
85 if (state->size == 0) {
87 state->in = (
unsigned char *)
malloc(state->want);
88 state->out = (
unsigned char *)
malloc(state->want << 1);
89 if (state->in == NULL || state->out == NULL) {
90 if (state->out != NULL)
92 if (state->in != NULL)
97 state->size = state->want;
100 state->strm.zalloc =
Z_NULL;
101 state->strm.zfree =
Z_NULL;
102 state->strm.opaque =
Z_NULL;
103 state->strm.avail_in = 0;
104 state->strm.next_in =
Z_NULL;
115 if (strm->avail_in < 2) {
118 if (strm->avail_in == 0)
129 if (strm->avail_in > 1 &&
130 strm->next_in[0] == 31 && strm->next_in[1] == 139) {
139 if (state->direct == 0) {
149 state->x.next = state->out;
150 if (strm->avail_in) {
151 memcpy(state->x.next, strm->next_in, strm->avail_in);
152 state->x.have = strm->avail_in;
172 had = strm->avail_out;
175 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
177 if (strm->avail_in == 0) {
186 "internal error: inflate stream corrupt");
195 strm->msg == NULL ?
"compressed data error" : strm->msg);
201 state->x.have = had - strm->avail_out;
202 state->x.next = strm->next_out - state->x.have;
227 if (state->how ==
LOOK)
231 if (
gz_load(state, state->out, state->size << 1, &(state->x.have))
234 state->x.next = state->out;
237 strm->avail_out = state->size << 1;
238 strm->next_out = state->out;
242 }
while (state->x.have == 0 && (!state->eof || strm->avail_in));
255 n =
GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
256 (
unsigned)len : state->x.have;
264 else if (state->eof && state->strm.avail_in == 0)
287 strm = &(state->strm);
308 if (
gz_skip(state, state->skip) == -1)
317 n = state->x.have > len ? len : state->x.have;
318 memcpy(buf, state->x.next, n);
324 else if (state->eof && strm->avail_in == 0) {
331 else if (state->how ==
LOOK || len < (state->size << 1)) {
341 else if (state->how ==
COPY) {
342 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
348 strm->avail_out =
len;
349 strm->next_out = (Bytef *)buf;
358 buf = (
char *)buf + n;
372 unsigned char buf[1];
389 return *(state->x.next)++;
393 ret =
gzread(file, buf, 1);
394 return ret < 1 ? -1 : buf[0];
420 if (
gz_skip(state, state->skip) == -1)
429 if (state->x.have == 0) {
431 state->x.next = state->out + (state->size << 1) - 1;
432 state->x.next[0] =
c;
439 if (state->x.have == (state->size << 1)) {
445 if (state->x.next == state->out) {
446 unsigned char *src = state->out + state->x.have;
447 unsigned char *dest = state->out + (state->size << 1);
448 while (src > state->out)
450 state->x.next = dest;
454 state->x.next[0] =
c;
469 if (file == NULL || buf == NULL || len < 1)
481 if (
gz_skip(state, state->skip) == -1)
489 left = (unsigned)len - 1;
492 if (state->x.have == 0 &&
gz_fetch(state) == -1)
494 if (state->x.have == 0) {
500 n = state->x.
have > left ? left : state->x.have;
501 eol = (
unsigned char *)memchr(state->x.next,
'\n', n);
503 n = (unsigned)(eol - state->x.next) + 1;
506 memcpy(buf, state->x.next, n);
512 }
while (left && eol == NULL);
533 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
537 return state->direct;
564 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)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
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)
void * malloc(size_t __size)
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)