34 ret = read(state->fd, buf + *have, len - *have);
38 }
while (*have < len);
57 if (state->err !=
Z_OK)
59 if (state->eof == 0) {
60 if (
gz_load(state, state->in, state->size,
61 (
unsigned *)&(strm->avail_in)) == -1)
63 strm->next_in = state->in;
69 #define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
70 (strm->avail_in == 0 ? -1 : \
71 (strm->avail_in--, *(strm->next_in)++)))
82 val += (unsigned)
NEXT() << 8;
83 val += (
unsigned long)
NEXT() << 16;
87 val += (
unsigned long)ch << 24;
111 if (state->size == 0) {
113 state->in = (
unsigned char *)
malloc(state->want);
114 state->out = (
unsigned char *)
malloc(state->want << 1);
115 if (state->in == NULL || state->out == NULL) {
116 if (state->out != NULL)
118 if (state->in != NULL)
123 state->size = state->want;
126 state->strm.zalloc =
Z_NULL;
127 state->strm.zfree =
Z_NULL;
128 state->strm.opaque =
Z_NULL;
129 state->strm.avail_in = 0;
130 state->strm.next_in =
Z_NULL;
141 if (strm->avail_in == 0) {
144 if (strm->avail_in == 0)
149 if (strm->next_in[0] == 31) {
152 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
154 if (strm->avail_in && strm->next_in[0] == 139) {
176 len = (unsigned)
NEXT();
177 len += (unsigned)
NEXT() << 8;
212 state->raw = state->pos;
213 state->next = state->out;
214 if (strm->avail_in) {
215 memcpy(state->next + state->have, strm->next_in, strm->avail_in);
216 state->have += strm->avail_in;
236 unsigned long crc, len;
240 had = strm->avail_out;
243 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
245 if (strm->avail_in == 0) {
254 "internal error: inflate stream corrupt");
263 strm->msg == NULL ?
"compressed data error" : strm->msg);
269 state->have = had - strm->avail_out;
270 state->next = strm->next_out - state->have;
271 strm->adler =
crc32(strm->adler, state->next, state->have);
279 if (crc != strm->adler) {
283 if (len != (strm->total_out & 0xffffffffL)) {
306 if (state->how ==
LOOK) {
312 if (state->how ==
COPY) {
313 if (
gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
315 state->next = state->out;
317 else if (state->how ==
GZIP) {
318 strm->avail_out = state->size << 1;
319 strm->next_out = state->out;
336 (
unsigned)len : state->have;
344 else if (state->eof && state->strm.avail_in == 0)
367 strm = &(state->strm);
387 if (
gz_skip(state, state->skip) == -1)
396 n = state->have > len ? len : state->have;
397 memcpy(buf, state->next, n);
403 else if (state->eof && strm->avail_in == 0)
408 else if (state->how ==
LOOK || len < (state->size << 1)) {
418 else if (state->how ==
COPY) {
419 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
425 strm->avail_out = len;
426 strm->next_out = (
unsigned char *)buf;
435 buf = (
char *)buf + n;
448 unsigned char buf[1];
464 return *(state->next)++;
468 ret =
gzread(file, buf, 1);
469 return ret < 1 ? -1 : buf[0];
489 if (
gz_skip(state, state->skip) == -1)
498 if (state->have == 0) {
500 state->next = state->out + (state->size << 1) - 1;
507 if (state->have == (state->size << 1)) {
513 if (state->next == state->out) {
514 unsigned char *src = state->out + state->have;
515 unsigned char *dest = state->out + (state->size << 1);
516 while (src > state->out)
536 if (file == NULL || buf == NULL || len < 1)
547 if (
gz_skip(state, state->skip) == -1)
555 left = (unsigned)len - 1;
558 if (state->have == 0) {
561 if (state->have == 0) {
569 n = state->have > left ? left : state->have;
570 eol = (
unsigned char *)
memchr(state->next,
'\n', n);
572 n = (unsigned)(eol - state->next) + 1;
575 memcpy(buf, state->next, n);
581 }
while (left && eol == NULL);
604 if (state->how ==
LOOK && state->have == 0)
608 return state->direct;
634 ret = close(state->fd);
int ZEXPORT gzdirect(gzFile file)
int ZEXPORT inflateReset(z_streamp strm)
local int gz_skip(gz_statep state, z_off64_t len)
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
local int gz_head(gz_statep state)
int ZEXPORT gzungetc(int c, gzFile file)
#define inflateInit2(strm, windowBits)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT gzclose_r(gzFile file)
#define ABC_NAMESPACE_IMPL_END
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
local int gz_decomp(gz_statep state)
char *ZEXPORT gzgets(gzFile file, char *buf, int len)
local int gz_make(gz_statep state)
#define ABC_NAMESPACE_IMPL_START
int ZEXPORT gzgetc(gzFile file)
local int gz_avail(gz_statep state)
int ZEXPORT inflate(z_streamp strm, int flush)
local int gz_next4(gz_statep state, unsigned long *ret)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
ABC_NAMESPACE_IMPL_START local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *))
int ZEXPORT inflateEnd(z_streamp strm)