Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

unzip.cpp File Reference

#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "unzip.h"

Include dependency graph for unzip.cpp:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  inflate_blocks_state
struct  inflate_codes_state
struct  inflate_huft_s
struct  internal_state

Defines

#define ALLOC(size)   (malloc(size))
#define Assert(cond, msg)
#define BASE   65521L
#define bits   word.what.Bits
#define bits   word.what.Bits
#define bits   word.what.Bits
#define bits   word.what.Bits
#define BMAX   15
#define BUFREADCOMMENT   (0x400)
#define C0   *p++ = 0;
#define C2   C0 C0 C0 C0
#define C4   C2 C2 C2 C2
#define CASESENSITIVITYDEFAULT_NO
#define CASESENSITIVITYDEFAULTVALUE   2
#define DEF_MEM_LEVEL   8
#define DEF_WBITS   MAX_WBITS
#define deflateInit(strm, level)   deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
#define DO1(buf, i)   {s1 += buf[i]; s2 += s1;}
#define DO1(buf)   crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO16(buf)   DO8(buf,0); DO8(buf,8);
#define DO2(buf, i)   DO1(buf,i); DO1(buf,i+1);
#define DO2(buf)   DO1(buf); DO1(buf);
#define DO4(buf, i)   DO2(buf,i); DO2(buf,i+2);
#define DO4(buf)   DO2(buf); DO2(buf);
#define DO8(buf, i)   DO4(buf,i); DO4(buf,i+4);
#define DO8(buf)   DO4(buf); DO4(buf);
#define DUMPBITS(j)   {b>>=(j);k-=(j);}
#define DYN_TREES   2
#define ERR_MSG(err)   z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm, err)   return (strm->msg = (char*)ERR_MSG(err), (err))
#define exop   word.what.Exop
#define exop   word.what.Exop
#define exop   word.what.Exop
#define exop   word.what.Exop
#define F_OPEN(name, mode)   fopen((name), (mode))
#define FLUSH   {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
#define GRABBITS(j)   {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
#define iNEEDBYTE   {if(z->avail_in==0)return r;r=f;}
#define iNEXTBYTE   (z->avail_in--,z->total_in++,*z->next_in++)
#define inflateInit(strm)   inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
#define inflateInit2(strm, windowBits)   inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
#define LEAVE   {UPDATE return inflate_flush(s,z,r);}
#define LOAD   {LOADIN LOADOUT}
#define LOADIN   {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
#define LOADOUT   {q=s->write;m=(uInt)WAVAIL;}
#define MANY   1440
#define MAX_MATCH   258
#define MAX_MEM_LEVEL   9
#define MAX_WBITS   15
#define MIN_MATCH   3
#define NEEDBITS(j)   {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
#define NEEDBYTE   {if(n)r=Z_OK;else LEAVE}
#define NEEDOUT   {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
#define NEXTBYTE   (n--,*p++)
#define NMAX   5552
#define OF(args)   args
#define OS_CODE   0x03
#define OUTBYTE(a)   {*q++=(Byte)(a);m--;}
#define PRESET_DICT   0x20
#define SEEK_CUR   1
#define SEEK_END   2
#define SEEK_SET   0
#define SIZECENTRALDIRITEM   (0x2e)
#define SIZEZIPLOCALHEADER   (0x1e)
#define STATIC_TREES   1
#define STORED_BLOCK   0
#define STRCMPCASENOSENTIVEFUNCTION   strcmpcasenosensitive_internal
#define Trace(x)
#define Tracec(c, x)
#define Tracecv(c, x)
#define Tracev(x)
#define Tracevv(x)
#define TRY_FREE(s, p)   {if (p) ZFREE(s, p);}
#define TRYFREE(p)   {if (p) free(p);}
#define UNGRAB   {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
#define UNZ_BUFSIZE   (65536)
#define UNZ_MAXFILENAMEINZIP   (256)
#define UPDATE   {UPDBITS UPDIN UPDOUT}
#define UPDBITS   {s->bitb=b;s->bitk=k;}
#define UPDIN   {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
#define UPDOUT   {s->write=q;}
#define WAVAIL   (uInt)(q<s->read?s->read-q-1:s->end-q)
#define WRAP   {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
#define Z_ASCII   1
#define Z_BEST_COMPRESSION   9
#define Z_BEST_SPEED   1
#define Z_BINARY   0
#define Z_BUF_ERROR   (-5)
#define Z_DATA_ERROR   (-3)
#define Z_DEFAULT_COMPRESSION   (-1)
#define Z_DEFAULT_STRATEGY   0
#define Z_DEFLATED   8
#define Z_ERRNO   (-1)
#define Z_FILTERED   1
#define Z_FINISH   4
#define Z_FULL_FLUSH   3
#define Z_HUFFMAN_ONLY   2
#define Z_MEM_ERROR   (-4)
#define Z_NEED_DICT   2
#define Z_NO_COMPRESSION   0
#define Z_NO_FLUSH   0
#define Z_NULL   0
#define Z_OK   0
#define Z_PARTIAL_FLUSH   1
#define Z_STREAM_END   1
#define Z_STREAM_ERROR   (-2)
#define Z_SYNC_FLUSH   2
#define Z_UNKNOWN   2
#define Z_VERSION_ERROR   (-6)
#define ZALLOC(strm, items, size)   (*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr)   (*((strm)->zfree))((strm)->opaque, (voidp)(addr))
#define zlib_version   zlibVersion()
#define ZLIB_VERSION   "1.1.3"
#define zmemcmp   memcmp
#define zmemcpy   memcpy
#define zmemzero(dest, len)   memset(dest, 0, len)
#define zstrerror(errnum)   ""

Typedefs

typedef unsigned char Byte
typedef voidp gzFile
typedef inflate_blocks_state inflate_blocks_statef
typedef inflate_codes_state inflate_codes_statef
typedef inflate_huft_s inflate_huft
typedef uLong check_func OF ((uLong check, const Byte *buf, uInt len))
typedef unsigned char uch
typedef unsigned int uInt
typedef unsigned long ulg
typedef unsigned long uLong
typedef unsigned short ush
typedef Bytevoidp

Enumerations

enum  inflate_block_mode {
  TYPE, LENS, STORED, TABLE,
  BTREE, DTREE, CODES, DRY,
  DONE, BAD
}
enum  inflate_codes_mode {
  START, LEN, LENEXT, DIST,
  DISTEXT, COPY, LIT, WASH,
  END, BADCODE
}
enum  inflate_mode {
  imMETHOD, imFLAG, imDICT4, imDICT3,
  imDICT2, imDICT1, imDICT0, imBLOCKS,
  imCHECK4, imCHECK3, imCHECK2, imCHECK1,
  imDONE, imBAD
}

Functions

float __BigFloat (float l)
int __BigLong (int l)
short __BigShort (short l)
float __LittleFloat (float l)
int __LittleLong (int l)
short __LittleShort (short l)
uLong adler32 (uLong adler, const Byte *buf, uInt len)
uLong crc32 (uLong crc, const Byte *buf, uInt len)
const uLongget_crc_table ()
int huft_build (uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inflate_huft **t, uInt *m, inflate_huft *hp, uInt *hn, uInt *v)
int inflate (z_streamp z, int f)
int inflate_blocks (inflate_blocks_statef *s, z_streamp z, int r)
int inflate_blocks_free (inflate_blocks_statef *s, z_streamp z)
inflate_blocks_statefinflate_blocks_new (z_streamp z, check_func c, uInt w)
void inflate_blocks_reset (inflate_blocks_statef *s, z_streamp z, uLong *c)
int inflate_blocks_sync_point (inflate_blocks_statef *s)
int inflate_codes (inflate_blocks_statef *s, z_streamp z, int r)
void inflate_codes_free (inflate_codes_statef *c, z_streamp z)
inflate_codes_statefinflate_codes_new (uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z)
int inflate_fast (uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)
int inflate_flush (inflate_blocks_statef *s, z_streamp z, int r)
void inflate_set_dictionary (inflate_blocks_statef *s, const Byte *d, uInt n)
int inflate_trees_bits (uInt *c, uInt *bb, inflate_huft **tb, inflate_huft *hp, z_streamp z)
int inflate_trees_dynamic (uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate_huft **tl, inflate_huft **td, inflate_huft *hp, z_streamp z)
int inflate_trees_fixed (uInt *bl, uInt *bd, inflate_huft **tl, inflate_huft **td, z_streamp z)
int inflateEnd (z_streamp z)
int inflateInit2_ (z_streamp z, int w, const char *version, int stream_size)
int inflateInit_ (z_streamp z, const char *version, int stream_size)
int inflateReset (z_streamp z)
int inflateSetDictionary (z_streamp z, const Byte *dictionary, uInt dictLength)
int inflateSync (z_streamp z)
int inflateSyncPoint (z_streamp z)
int huft_build OF ((uInt *, uInt, uInt, const uInt *, const uInt *, inflate_huft **, uInt *, inflate_huft *, uInt *, uInt *))
void inflate_codes_free OF ((inflate_codes_statef *, z_streamp))
inflate_codes_statef *inflate_codes_new OF ((uInt, uInt, inflate_huft *, inflate_huft *, z_streamp))
int inflate_trees_fixed OF ((uInt *, uInt *, inflate_huft **, inflate_huft **, z_streamp))
int inflate_trees_dynamic OF ((uInt, uInt, uInt *, uInt *, uInt *, inflate_huft **, inflate_huft **, inflate_huft *, z_streamp))
int inflate_trees_bits OF ((uInt *, uInt *, inflate_huft **, inflate_huft *, z_streamp))
int inflate_blocks_sync_point OF ((inflate_blocks_statef *s))
void inflate_set_dictionary OF ((inflate_blocks_statef *s, const Byte *d, uIntn))
int inflate_blocks_free OF ((inflate_blocks_statef *, z_streamp))
void inflate_blocks_reset OF ((inflate_blocks_statef *, z_streamp, uLong *))
int inflate_blocks OF ((inflate_blocks_statef *, z_streamp, int))
inflate_blocks_statef *inflate_blocks_new OF ((z_streamp z, check_func c, uInt w))
void zcfree OF ((voidp opaque, voidp ptr))
voidp zcalloc OF ((voidp opaque, unsigned items, unsigned size))
int inflateSyncPoint OF ((z_streamp z))
const char *zError OF ((int err))
int inflateInit2_ OF ((z_streamp strm, intwindowBits, const char *version, int stream_size))
int deflateInit2_ OF ((z_streamp strm, intlevel, intmethod, int windowBits, int memLevel, int strategy, const char *version, int stream_size))
int inflateInit_ OF ((z_streamp strm, const char *version, int stream_size))
int deflateInit_ OF ((z_streamp strm, int level, const char *version, int stream_size))
uLong crc32 OF ((uLong crc, const Byte *buf, uInt len))
uLong adler32 OF ((uLong adler, const Byte *buf, uInt len))
const char *gzerror OF ((gzFile file, int *errnum))
long gzseek OF ((gzFile file, long offset, int whence))
int gzflush OF ((gzFile file, int flush))
int gzgetc OF ((gzFile file))
int gzputc OF ((gzFile file, int c))
char *gzgets OF ((gzFile file, char *buf, int len))
int gzputs OF ((gzFile file, const char *s))
int gzprintf OF ((gzFile file, const char *format,...))
int gzread OF ((gzFile file, voidp buf, unsigned len))
int gzsetparams OF ((gzFile file, int level, int strategy))
gzFile gzdopen OF ((int fd, const char *mode))
gzFile gzopen OF ((const char *path, const char *mode))
int compress2 OF ((Byte *dest, uLong *destLen, const Byte *source, uLong sourceLen, int level))
int compress OF ((Byte *dest, uLong *destLen, const Byte *source, uLong sourceLen))
int deflateParams OF ((z_streamp strm, int level, int strategy))
int deflateCopy OF ((z_streamp dest, z_streamp source))
int deflateSetDictionary OF ((z_streamp strm, const Byte *dictionary, uIntdictLength))
int deflateEnd OF ((z_streamp strm))
int deflate OF ((z_streamp strm, int flush))
const char *zlibVersion OF ((void))
int strcmpcasenosensitive_internal (const char *fileName1, const char *fileName2)
int unzClose (unzFile file)
int unzCloseCurrentFile (unzFile file)
int unzeof (unzFile file)
int unzGetCurrentFileInfo (unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
int unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
int unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info)
int unzGetLocalExtrafield (unzFile file, void *buf, unsigned len)
int unzGoToFirstFile (unzFile file)
int unzGoToNextFile (unzFile file)
int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s, uInt *piSizeVar, uLong *poffset_local_extrafield, uInt *psize_local_extrafield)
void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm)
int unzlocal_GetCurrentFileInfoInternal (unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)
int unzlocal_getLong (FILE *fin, uLong *pX)
int unzlocal_getShort (FILE *fin, uLong *pX)
uLong unzlocal_SearchCentralDir (FILE *fin)
int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
unzFile unzOpen (const char *path)
int unzOpenCurrentFile (unzFile file)
int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
unzFile unzReOpen (const char *path, unzFile file)
int unzStringFileNameCompare (const char *fileName1, const char *fileName2, int iCaseSensitivity)
long unztell (unzFile file)
voidp zcalloc (voidp opaque, unsigned items, unsigned size)
void zcfree (voidp opaque, voidp ptr)

Variables

const uInt border []
const uInt cpdext [30]
const uInt cpdist [30]
const uInt cplens [31]
const uInt cplext [31]
const uLong crc_table [256]
uInt fixed_bd = 5
uInt fixed_bl = 9
inflate_huft fixed_td []
inflate_huft fixed_tl []
const char inflate_copyright []
uInt inflate_mask [17]
const char * z_errmsg [10]


Define Documentation

#define ALLOC size   )     (malloc(size))
 

Definition at line 1203 of file unzip.cpp.

#define Assert cond,
msg   ) 
 

Definition at line 1169 of file unzip.cpp.

#define BASE   65521L
 

Definition at line 4112 of file unzip.cpp.

#define bits   word.what.Bits
 

Definition at line 3872 of file unzip.cpp.

#define bits   word.what.Bits
 

Definition at line 3872 of file unzip.cpp.

#define bits   word.what.Bits
 

Definition at line 3872 of file unzip.cpp.

#define bits   word.what.Bits
 

Definition at line 3872 of file unzip.cpp.

#define BMAX   15
 

Definition at line 3254 of file unzip.cpp.

#define BUFREADCOMMENT   (0x400)
 

Definition at line 1363 of file unzip.cpp.

#define C0   *p++ = 0;
 

#define C2   C0 C0 C0 C0
 

#define C4   C2 C2 C2 C2
 

#define CASESENSITIVITYDEFAULT_NO
 

Definition at line 1190 of file unzip.cpp.

#define CASESENSITIVITYDEFAULTVALUE   2
 

Definition at line 1334 of file unzip.cpp.

#define DEF_MEM_LEVEL   8
 

Definition at line 1116 of file unzip.cpp.

#define DEF_WBITS   MAX_WBITS
 

Definition at line 1111 of file unzip.cpp.

#define deflateInit strm,
level   )     deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
 

Definition at line 1080 of file unzip.cpp.

#define deflateInit2 strm,
level,
method,
windowBits,
memLevel,
strategy   ) 
 

Value:

deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
                      (strategy),           ZLIB_VERSION, sizeof(z_stream))

Definition at line 1084 of file unzip.cpp.

#define DO1 buf,
i   )     {s1 += buf[i]; s2 += s1;}
 

Definition at line 4121 of file unzip.cpp.

#define DO1 buf   )     crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
 

Definition at line 4121 of file unzip.cpp.

#define DO16 buf   )     DO8(buf,0); DO8(buf,8);
 

Definition at line 4125 of file unzip.cpp.

#define DO2 buf,
i   )     DO1(buf,i); DO1(buf,i+1);
 

Definition at line 4122 of file unzip.cpp.

#define DO2 buf   )     DO1(buf); DO1(buf);
 

Definition at line 4122 of file unzip.cpp.

#define DO4 buf,
i   )     DO2(buf,i); DO2(buf,i+2);
 

Definition at line 4123 of file unzip.cpp.

#define DO4 buf   )     DO2(buf); DO2(buf);
 

Definition at line 4123 of file unzip.cpp.

#define DO8 buf,
i   )     DO4(buf,i); DO4(buf,i+4);
 

Definition at line 4124 of file unzip.cpp.

#define DO8 buf   )     DO4(buf); DO4(buf);
 

Definition at line 4124 of file unzip.cpp.

#define DUMPBITS j   )     {b>>=(j);k-=(j);}
 

Definition at line 2713 of file unzip.cpp.

#define DYN_TREES   2
 

Definition at line 1124 of file unzip.cpp.

#define ERR_MSG err   )     z_errmsg[Z_NEED_DICT-(err)]
 

Definition at line 1102 of file unzip.cpp.

#define ERR_RETURN strm,
err   )     return (strm->msg = (char*)ERR_MSG(err), (err))
 

Definition at line 1104 of file unzip.cpp.

#define exop   word.what.Exop
 

Definition at line 3871 of file unzip.cpp.

#define exop   word.what.Exop
 

Definition at line 3871 of file unzip.cpp.

#define exop   word.what.Exop
 

Definition at line 3871 of file unzip.cpp.

#define exop   word.what.Exop
 

Definition at line 3871 of file unzip.cpp.

#define F_OPEN name,
mode   )     fopen((name), (mode))
 

Definition at line 1142 of file unzip.cpp.

#define FLUSH   {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
 

Definition at line 2718 of file unzip.cpp.

#define GRABBITS j   )     {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
 

Definition at line 3718 of file unzip.cpp.

#define iNEEDBYTE   {if(z->avail_in==0)return r;r=f;}
 

Definition at line 4321 of file unzip.cpp.

#define iNEXTBYTE   (z->avail_in--,z->total_in++,*z->next_in++)
 

Definition at line 4322 of file unzip.cpp.

#define inflateInit strm   )     inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
 

Definition at line 1082 of file unzip.cpp.

#define inflateInit2 strm,
windowBits   )     inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
 

Definition at line 1087 of file unzip.cpp.

#define LEAVE   {UPDATE return inflate_flush(s,z,r);}
 

Definition at line 2707 of file unzip.cpp.

#define LOAD   {LOADIN LOADOUT}
 

Definition at line 2722 of file unzip.cpp.

#define LOADIN   {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
 

Definition at line 2709 of file unzip.cpp.

#define LOADOUT   {q=s->write;m=(uInt)WAVAIL;}
 

Definition at line 2716 of file unzip.cpp.

#define MANY   1440
 

Definition at line 2583 of file unzip.cpp.

#define MAX_MATCH   258
 

Definition at line 1128 of file unzip.cpp.

#define MAX_MEM_LEVEL   9
 

Definition at line 105 of file unzip.cpp.

#define MAX_WBITS   15
 

Definition at line 115 of file unzip.cpp.

#define MIN_MATCH   3
 

Definition at line 1127 of file unzip.cpp.

#define NEEDBITS j   )     {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
 

Definition at line 2712 of file unzip.cpp.

#define NEEDBYTE   {if(n)r=Z_OK;else LEAVE}
 

Definition at line 2710 of file unzip.cpp.

#define NEEDOUT   {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
 

Definition at line 2719 of file unzip.cpp.

#define NEXTBYTE   (n--,*p++)
 

Definition at line 2711</