#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc/util/abc_global.h"
#include "gzguts.h"
Go to the source code of this file.
|  | 
| ABC_NAMESPACE_IMPL_START local int gz_load
 | OF ((gz_statep, unsigned char *, unsigned, unsigned *)) | 
|  | 
| local int gz_avail | OF ((gz_statep)) | 
|  | 
| local int gz_next4 | OF ((gz_statep, unsigned long *)) | 
|  | 
| 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_next4 (gz_statep state, unsigned long *ret) | 
|  | 
| local int | gz_head (gz_statep state) | 
|  | 
| local int | gz_decomp (gz_statep state) | 
|  | 
| local int | gz_make (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 | 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) | 
|  | 
Value:((strm->avail_in == 0 && 
gz_avail(state) == -1) ? -1 : \
                (strm->avail_in == 0 ? -1 : \
                 (strm->avail_in--, *(strm->next_in)++)))
local int gz_avail(gz_statep state)
Definition at line 69 of file gzread.c.
 
 
Definition at line 53 of file gzread.c.
   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;
 
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
 
 
 
Definition at line 232 of file gzread.c.
  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)) {
 
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
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)
 
 
 
Definition at line 104 of file gzread.c.
  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;
 
int ZEXPORT inflateReset(z_streamp strm)
#define inflateInit2(strm, windowBits)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
local int gz_avail(gz_statep state)
 
 
 
      
        
          | local int gz_load | ( | gz_statep | state, | 
        
          |  |  | unsigned char * | buf, | 
        
          |  |  | unsigned | len, | 
        
          |  |  | unsigned * | have | 
        
          |  | ) |  |  | 
      
 
Definition at line 28 of file gzread.c.
   34         ret = read(state->fd, buf + *have, len - *have);
 
   38     } 
while (*have < len);
 
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
 
 
 
Definition at line 302 of file gzread.c.
  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;
 
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
local int gz_head(gz_statep state)
local int gz_decomp(gz_statep state)
 
 
 
Definition at line 75 of file gzread.c.
   82     val += (unsigned)
NEXT() << 8;
 
   83     val += (
unsigned long)
NEXT() << 16;
 
   87     val += (
unsigned long)ch << 24;
 
 
 
 
Definition at line 327 of file gzread.c.
  336                 (
unsigned)len : state->have;
 
  344         else if (state->eof && state->strm.avail_in == 0)
 
local int gz_make(gz_statep state)
 
 
 
Definition at line 612 of file gzread.c.
  634     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 589 of file gzread.c.
  604     if (state->how == 
LOOK && state->have == 0)
 
  608     return state->direct;
 
local int gz_head(gz_statep state)
 
 
 
Definition at line 445 of file gzread.c.
  448     unsigned char buf[1];
 
  464         return *(state->next)++;
 
  468     ret = 
gzread(file, buf, 1);
 
  469     return ret < 1 ? -1 : buf[0];
 
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
 
 
 
Definition at line 528 of file gzread.c.
  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);
 
local int gz_skip(gz_statep state, z_off64_t len)
local int gz_make(gz_statep state)
 
 
 
Definition at line 357 of file gzread.c.
  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;
 
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)
local int gz_make(gz_statep state)
 
 
 
Definition at line 473 of file gzread.c.
  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)
 
local int gz_skip(gz_statep state, z_off64_t len)
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)