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

unzip.c File Reference

#include "../client/client.h"
#include "unzip.h"

Include dependency graph for unzip.c:

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)   (Z_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 DO16(buf)   DO8(buf,0); DO8(buf,8);
#define DO2(buf, i)   DO1(buf,i); DO1(buf,i+1);
#define DO4(buf, i)   DO2(buf,i); DO2(buf,i+2);
#define DO8(buf, i)   DO4(buf,i); DO4(buf,i+4);
#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) Z_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   Com_Memcpy
#define zmemzero(dest, len)   Com_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

uLong adler32 (uLong adler, const Byte *buf, uInt len)
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_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)
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 inflateReset (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_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 inflateInit2_ OF ((z_streamp strm, intwindowBits, const char *version, int stream_size))
uLong adler32 OF ((uLong adler, const Byte *buf, uInt len))
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 QDECL 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 inflateEnd OF ((z_streamp strm))
int inflate OF ((z_streamp strm, int flush))
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 unzGetCurrentFileInfoPosition (unzFile file, unsigned long *pos)
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 unzSetCurrentFileInfoPosition (unzFile file, unsigned long pos)
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]
uInt fixed_bd = 5
uInt fixed_bl = 9
inflate_huft fixed_td []
inflate_huft fixed_tl []
const char inflate_copyright []
uInt inflate_mask [17]


Define Documentation

#define ALLOC size   )     (Z_Malloc(size))
 

Definition at line 1067 of file unzip.c.

Referenced by unzlocal_SearchCentralDir(), unzOpen(), unzOpenCurrentFile(), and unzReOpen().

#define Assert cond,
msg   ) 
 

Definition at line 1033 of file unzip.c.

Referenced by inflate_codes().

#define BASE   65521L
 

Definition at line 3863 of file unzip.c.

#define bits   word.what.Bits
 

Definition at line 3623 of file unzip.c.

#define bits   word.what.Bits
 

Definition at line 3623 of file unzip.c.

#define bits   word.what.Bits
 

Definition at line 3623 of file unzip.c.

#define bits   word.what.Bits
 

Definition at line 3623 of file unzip.c.

Referenced by add_huff_table(), CG_DrawWeaponSelect(), CL_PlayCinematic_f(), CM_SignbitsForNormal(), CMod_LoadPlanes(), CountBits(), G_AddEvent(), GametypeBits(), get_dht(), initfields(), jpeg_gen_optimal_table(), MD4Final(), MSG_ReadBits(), MSG_ReadDelta(), MSG_ReadDeltaKey(), MSG_ReadDeltaPlayerstate(), MSG_WriteBits(), MSG_WriteDelta(), MSG_WriteDeltaKey(), R_LoadPlanes(), SetPlaneSignbits(), and trap_CIN_PlayCinematic().

#define BMAX   15
 

Definition at line 3005 of file unzip.c.

Referenced by huft_build().

#define BUFREADCOMMENT   (0x400)
 

Definition at line 1227 of file unzip.c.

Referenced by unzlocal_SearchCentralDir().

#define C0   *p++ = 0;
 

#define C2   C0 C0 C0 C0
 

#define C4   C2 C2 C2 C2
 

Referenced by huft_build().

#define CASESENSITIVITYDEFAULT_NO
 

Definition at line 1054 of file unzip.c.

#define CASESENSITIVITYDEFAULTVALUE   2
 

Definition at line 1198 of file unzip.c.

#define DEF_MEM_LEVEL   8
 

Definition at line 980 of file unzip.c.

#define DEF_WBITS   MAX_WBITS
 

Definition at line 975 of file unzip.c.

Referenced by inflateInit_().

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

Definition at line 944 of file unzip.c.

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

Value:

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

Definition at line 948 of file unzip.c.

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

Definition at line 3872 of file unzip.c.

Referenced by crc32().

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

Definition at line 3876 of file unzip.c.

Referenced by adler32().

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

Definition at line 3873 of file unzip.c.

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

Definition at line 3874 of file unzip.c.

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

Definition at line 3875 of file unzip.c.

Referenced by crc32().

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

Definition at line 2463 of file unzip.c.

Referenced by inflate_blocks(), inflate_codes(), and inflate_fast().

#define DYN_TREES   2
 

Definition at line 988 of file unzip.c.

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

Definition at line 966 of file unzip.c.

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

Definition at line 968 of file unzip.c.

#define exop   word.what.Exop
 

Definition at line 3622 of file unzip.c.

#define exop   word.what.Exop
 

Definition at line 3622 of file unzip.c.

#define exop   word.what.Exop
 

Definition at line 3622 of file unzip.c.

#define exop   word.what.Exop
 

Definition at line 3622 of file unzip.c.

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

Definition at line 1006 of file unzip.c.

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

Definition at line 2468 of file unzip.c.

Referenced by inflate_blocks(), and inflate_codes().

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

Definition at line 3469 of file unzip.c.

Referenced by inflate_fast().

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

Definition at line 4073 of file unzip.c.

Referenced by inflate().

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

Definition at line 4074 of file unzip.c.

Referenced by inflate().

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

Definition at line 946 of file unzip.c.

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

Definition at line 951 of file unzip.c.

Referenced by unzOpenCurrentFile().

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

Definition at line 2457 of file unzip.c.

Referenced by inflate_blocks(), and inflate_codes().

LOAD   {LOADIN LOADOUT}
 

Definition at line 2472 of file unzip.c.

Referenced by gen(), inflate_blocks(), inflate_codes(), inflate_fast(), main(), prelabel(), and rtarget().

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

Definition at line 2459 of file unzip.c.

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

Definition at line 2466 of file unzip.c.

#define MANY   1440
 

Definition at line 2333 of file unzip.c.

Referenced by inflate_blocks_new().

#define MAX_MATCH   258
 

Definition at line 992 of file unzip.c.

#define MAX_MEM_LEVEL   9
 

Definition at line 97 of file unzip.c.

#define MAX_WBITS   15
 

Definition at line 107 of file unzip.c.

Referenced by unzOpenCurrentFile().

#define MIN_MATCH   3
 

Definition at line 991 of file unzip.c.

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

Definition at line 2462 of file unzip.c.

Referenced by inflate_blocks(), and inflate_codes().

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

Definition at line 2460 of file unzip.c.

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

Definition at line 2469 of file unzip.c.

Referenced by inflate_blocks(), and inflate_codes().

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

Definition at line 2461 of file unzip.c.

#define NMAX   5552
 

Definition at line 3864 of file unzip.c.

Referenced by adler32().

#define OF args   )     args
 

Definition at line 126 of file unzip.c.

#define OS_CODE   0x03
 

Definition at line 1002 of file unzip.c.

#define OUTBYTE  )     {*q++=(Byte)(a);m--;}
 

Definition at line 2470 of file unzip.c.

Referenced by inflate_codes().

#define PRESET_DICT   0x20
 

Definition at line 995 of file unzip.c.

#define SEEK_CUR   1
 

Definition at line 136 of file unzip.c.

Referenced by LoadBMP(), ReadQuakeFile(), and unzlocal_GetCurrentFileInfoInternal().

#define SEEK_END   2
 

Definition at line 137 of file unzip.c.

Referenced by filelength(), FileLength(), FS_CopyFile(), FS_filelength(), Q_filelength(), and unzlocal_SearchCentralDir().

#define SEEK_SET   0
 

Definition at line 135 of file unzip.c.

#define SIZECENTRALDIRITEM   (0x2e)
 

Definition at line 1073 of file unzip.c.

Referenced by unzGoToNextFile().

#define SIZEZIPLOCALHEADER   (0x1e)
 

Definition at line 1074 of file unzip.c.

Referenced by unzlocal_CheckCurrentFileCoherencyHeader(), and unzOpenCurrentFile().

#define STATIC_TREES   1
 

Definition at line 987 of file unzip.c.

#define STORED_BLOCK   0
 

Definition at line 986 of file unzip.c.

#define STRCMPCASENOSENTIVEFUNCTION   strcmpcasenosensitive_internal
 

Definition at line 1204 of file unzip.c.

Referenced by unzStringFileNameCompare().

#define Trace  ) 
 

Definition at line 1034 of file unzip.c.