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.
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;
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
Definition at line 166 of file gzread.cc.
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;
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 219 of file gzread.cc.
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));
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 20 of file gzread.cc.
26 ret = read(state->fd, buf + *have,
len - *have);
30 }
while (*have <
len);
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition at line 81 of file gzread.cc.
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
#define inflateInit2(strm, windowBits)
local int gz_avail(gz_statep state)
int ZEXPORT inflateReset(z_streamp strm)
Definition at line 248 of file gzread.cc.
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)
local int gz_fetch(gz_statep state)
Definition at line 546 of file gzread.cc.
569 ret = close(state->fd);
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
int ZEXPORT inflateEnd(z_streamp strm)
Definition at line 527 of file gzread.cc.
538 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
542 return state->direct;
local int gz_look(gz_statep state)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
Definition at line 374 of file gzread.cc.
377 unsigned char buf[1];
394 return *(state->x.next)++;
398 ret =
gzread(file, buf, 1);
399 return ret < 1 ? -1 : buf[0];
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
Definition at line 402 of file gzread.cc.
int ZEXPORT gzgetc(gzFile file)
char* ZEXPORT gzgets |
( |
gzFile |
file, |
|
|
char * |
buf, |
|
|
int |
len |
|
) |
| |
Definition at line 466 of file gzread.cc.
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);
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 278 of file gzread.cc.
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;
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 408 of file gzread.cc.
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;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
local int gz_skip(gz_statep state, z_off64_t len)