Go to the source code of this file.
|
local int gz_load | OF ((gz_statep, unsigned char *, unsigned, unsigned *)) |
|
local int gz_avail | OF ((gz_statep)) |
|
local int gz_skip | OF ((gz_statep, z_off64_t)) |
|
local int | gz_load (gz_statep state, unsigned char *buf, unsigned len, unsigned *have) |
|
local int | gz_avail (gz_statep state) |
|
local int | gz_look (gz_statep state) |
|
local int | gz_decomp (gz_statep state) |
|
local int | gz_fetch (gz_statep state) |
|
local int | gz_skip (gz_statep state, z_off64_t len) |
|
int ZEXPORT | gzread (gzFile file, voidp buf, unsigned len) |
|
int ZEXPORT | gzgetc (gzFile file) |
|
int ZEXPORT | gzgetc_ (gzFile file) |
|
int ZEXPORT | gzungetc (int c, gzFile file) |
|
char *ZEXPORT | gzgets (gzFile file, char *buf, int len) |
|
int ZEXPORT | gzdirect (gzFile file) |
|
int ZEXPORT | gzclose_r (gzFile file) |
|
Definition at line 47 of file gzread.cc.
References gz_load(), n, Z_BUF_ERROR, and Z_OK.
Referenced by gz_decomp(), and gz_look().
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;
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
Definition at line 165 of file gzread.cc.
References gz_avail(), gz_error(), inflate(), LOOK, Z_BUF_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Z_NEED_DICT, Z_NO_FLUSH, Z_OK, Z_STREAM_END, and Z_STREAM_ERROR.
Referenced by gz_fetch(), and gzread().
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT inflate(z_streamp strm, int flush)
local int gz_avail(gz_statep state)
Definition at line 218 of file gzread.cc.
References COPY, gz_decomp(), gz_load(), gz_look(), GZIP, and LOOK.
Referenced by gz_skip(), gzgets(), and gzread().
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));
local int gz_decomp(gz_statep state)
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
local int gz_look(gz_statep state)
local int gz_load |
( |
gz_statep |
state, |
|
|
unsigned char * |
buf, |
|
|
unsigned |
len, |
|
|
unsigned * |
have |
|
) |
| |
Definition at line 80 of file gzread.cc.
References COPY, free(), gz_avail(), gz_error(), GZIP, inflateInit2, inflateReset(), malloc(), Z_MEM_ERROR, Z_NULL, and Z_OK.
Referenced by gz_fetch(), and gzdirect().
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
#define inflateInit2(strm, windowBits)
void * malloc(size_t __size)
local int gz_avail(gz_statep state)
int ZEXPORT inflateReset(z_streamp strm)
Definition at line 522 of file gzread.cc.
References gz_look(), GZ_READ, LOOK, and void().
533 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
537 return state->direct;
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
local int gz_look(gz_statep state)
char* ZEXPORT gzgets |
( |
gzFile |
file, |
|
|
char * |
buf, |
|
|
int |
len |
|
) |
| |
Definition at line 461 of file gzread.cc.
References gz_fetch(), GZ_READ, gz_skip(), gzFile_s::have, left, n, Z_BUF_ERROR, and Z_OK.
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);
local int gz_fetch(gz_statep state)
local int gz_skip(gz_statep state, z_off64_t len)
int ZEXPORT gzread |
( |
gzFile |
file, |
|
|
voidp |
buf, |
|
|
unsigned |
len |
|
) |
| |
Definition at line 277 of file gzread.cc.
References COPY, gz_decomp(), gz_error(), gz_fetch(), gz_load(), GZ_READ, gz_skip(), LOOK, n, Z_BUF_ERROR, Z_DATA_ERROR, and Z_OK.
Referenced by gzgetc().
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
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_skip(gz_statep state, z_off64_t len)
Definition at line 403 of file gzread.cc.
References test::c, gz_error(), GZ_READ, gz_skip(), gzFile_s::have, Z_BUF_ERROR, Z_DATA_ERROR, and Z_OK.
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
local int gz_skip(gz_statep state, z_off64_t len)