#include "gzguts.h"
#include <io.h>
#include <direct.h>
Go to the source code of this file.
|
local int | gz_avail (gz_statep state) |
|
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_look (gz_statep state) |
|
local int | gz_skip (gz_statep state, z_off64_t len) |
|
int ZEXPORT | gzclose_r (gzFile file) |
|
int ZEXPORT | gzdirect (gzFile file) |
|
int ZEXPORT | gzgetc (gzFile file) |
|
int ZEXPORT | gzgetc_ (gzFile file) |
|
char *ZEXPORT | gzgets (gzFile file, char *buf, int len) |
|
int ZEXPORT | gzread (gzFile file, voidp buf, unsigned len) |
|
int ZEXPORT | gzungetc (int c, gzFile 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)) |
|
Definition at line 58 of file gzread.c.
66 if (state->eof == 0) {
68 unsigned char *p = state->in;
69 unsigned const char *q = strm->next_in;
70 unsigned n = strm->avail_in;
75 if (
gz_load(state, state->in + strm->avail_in,
76 state->size - strm->avail_in, &got) == -1)
78 strm->avail_in += got;
79 strm->next_in = state->in;
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
Definition at line 179 of file gzread.c.
187 had = strm->avail_out;
190 if (strm->avail_in == 0 &&
gz_avail(state) == -1)
192 if (strm->avail_in == 0) {
201 "internal error: inflate stream corrupt");
210 strm->msg ==
NULL ?
"compressed data error" : strm->msg);
216 state->x.have = had - strm->avail_out;
217 state->x.next = strm->next_out - state->x.have;
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
local int gz_avail(gz_statep state)
int ZEXPORT inflate(z_streamp strm, int flush)
Definition at line 233 of file gzread.c.
243 if (state->how ==
LOOK)
247 if (
gz_load(state, state->out, state->size << 1, &(state->x.have))
250 state->x.next = state->out;
253 strm->avail_out = state->size << 1;
254 strm->next_out = state->out;
258 }
while (state->x.have == 0 && (!state->eof || strm->avail_in));
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
local int gz_decomp(gz_statep state)
local int gz_look(gz_statep state)
local int gz_load |
( |
gz_statep |
state, |
|
|
unsigned char * |
buf, |
|
|
unsigned |
len, |
|
|
unsigned * |
have |
|
) |
| |
Definition at line 27 of file gzread.c.
37 ret = (int)read(state->fd, buf + *have, len - *have);
41 }
while (*have < len);
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
Definition at line 93 of file gzread.c.
99 if (state->size == 0) {
101 state->in = (
unsigned char *)
malloc(state->want);
102 state->out = (
unsigned char *)
malloc(state->want << 1);
103 if (state->in ==
NULL || state->out ==
NULL) {
104 if (state->out !=
NULL)
106 if (state->in !=
NULL)
111 state->size = state->want;
114 state->strm.zalloc =
Z_NULL;
115 state->strm.zfree =
Z_NULL;
116 state->strm.opaque =
Z_NULL;
117 state->strm.avail_in = 0;
118 state->strm.next_in =
Z_NULL;
129 if (strm->avail_in < 2) {
132 if (strm->avail_in == 0)
143 if (strm->avail_in > 1 &&
144 strm->next_in[0] == 31 && strm->next_in[1] == 139) {
153 if (state->direct == 0) {
163 state->x.next = state->out;
164 if (strm->avail_in) {
165 memcpy(state->x.next, strm->next_in, strm->avail_in);
166 state->x.have = strm->avail_in;
int ZEXPORT inflateReset(z_streamp strm)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
local int gz_avail(gz_statep state)
#define inflateInit2(strm, windowBits)
Definition at line 263 of file gzread.c.
274 (
unsigned)len : state->x.have;
282 else if (state->eof && state->strm.avail_in == 0)
local int gz_fetch(gz_statep state)
Definition at line 574 of file gzread.c.
598 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 554 of file gzread.c.
566 if (state->mode ==
GZ_READ && state->how ==
LOOK && state->x.have == 0)
570 return state->direct;
local int gz_look(gz_statep state)
Definition at line 394 of file gzread.c.
398 unsigned char buf[1];
415 return *(state->x.next)++;
419 ret =
gzread(file, buf, 1);
420 return ret < 1 ? -1 : buf[0];
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
Definition at line 423 of file gzread.c.
int ZEXPORT gzgetc(gzFile file)
Definition at line 490 of file gzread.c.
501 if (file ==
NULL || buf ==
NULL || len < 1)
513 if (
gz_skip(state, state->skip) == -1)
521 left = (unsigned)len - 1;
524 if (state->x.have == 0 &&
gz_fetch(state) == -1)
526 if (state->x.have == 0) {
532 n = state->x.have > left ? left : state->x.have;
533 eol = (
unsigned char *)memchr(state->x.next,
'\n', n);
535 n = (unsigned)(eol - state->x.next) + 1;
538 memcpy(buf, state->x.next, n);
544 }
while (left && eol ==
NULL);
local int gz_fetch(gz_statep state)
local int gz_skip(gz_statep state, z_off64_t len)
Definition at line 295 of file gzread.c.
308 strm = &(state->strm);
329 if (
gz_skip(state, state->skip) == -1)
338 n = state->x.have > len ? len : state->x.have;
339 memcpy(buf, state->x.next, n);
345 else if (state->eof && strm->avail_in == 0) {
352 else if (state->how ==
LOOK || len < (state->size << 1)) {
362 else if (state->how ==
COPY) {
363 if (
gz_load(state, (
unsigned char *)buf, len, &n) == -1)
369 strm->avail_out = len;
370 strm->next_out = (
unsigned char *)buf;
379 buf = (
char *)buf + n;
local int gz_fetch(gz_statep state)
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)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
local int gz_decomp(gz_statep state)
Definition at line 430 of file gzread.c.
449 if (
gz_skip(state, state->skip) == -1)
458 if (state->x.have == 0) {
460 state->x.next = state->out + (state->size << 1) - 1;
461 state->x.next[0] = c;
468 if (state->x.have == (state->size << 1)) {
474 if (state->x.next == state->out) {
475 unsigned char *src = state->out + state->x.have;
476 unsigned char *dest = state->out + (state->size << 1);
477 while (src > state->out)
479 state->x.next = dest;
483 state->x.next[0] = c;
local int gz_skip(gz_statep state, z_off64_t len)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)