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;
69 state->size - strm->
avail_in, &got) == -1)
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;
146 if (state->direct == 0) {
156 state->x.next = state->out;
194 "internal error: inflate stream corrupt");
203 strm->
msg == NULL ?
"compressed data error" : strm->
msg);
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;
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);
331 n = state->
x.
have > len ? len : state->
x.
have;
332 memcpy(buf, state->
x.
next, n);
345 else if (state->
how ==
LOOK || len < (state->
size << 1)) {
356 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
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];
451 if (state->
x.
have == 0) {
454 state->
x.
next[0] = c;
461 if (state->
x.
have == (state->
size << 1)) {
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)
514 left = (unsigned)len - 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);
591 ret = close(state->
fd);
char * gzgets(gzFile file, char *buf, int len)
int gzread(gzFile file, voidp buf, unsigned len)
int gzungetc(int c, gzFile file)
int gzdirect(gzFile file)
int gzclose_r(gzFile file)
#define inflateInit2(strm, windowBits)
int read(izstream &zs, T *x, Items items)
int inflateReset(z_streamp strm)
int inflateEnd(z_streamp strm)
int inflate(z_streamp strm, int flush)