#include "../client/client.h"
#include "unzip.h"
Include dependency graph for unzip.c:

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 Byte * | voidp |
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_statef * | inflate_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_statef * | inflate_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] |
|
|
Definition at line 1067 of file unzip.c. Referenced by unzlocal_SearchCentralDir(), unzOpen(), unzOpenCurrentFile(), and unzReOpen(). |
|
|
Definition at line 1033 of file unzip.c. Referenced by inflate_codes(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 3005 of file unzip.c. Referenced by huft_build(). |
|
|
Definition at line 1227 of file unzip.c. Referenced by unzlocal_SearchCentralDir(). |
|
|
|
|
|
|
|
|
Referenced by huft_build(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 975 of file unzip.c. Referenced by inflateInit_(). |
|
|
|
|
|
Value: deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
(strategy), ZLIB_VERSION, sizeof(z_stream))
|
|
|
Definition at line 3872 of file unzip.c. Referenced by crc32(). |
|
|
Definition at line 3876 of file unzip.c. Referenced by adler32(). |
|
|
|
|
|
|
|
|
Definition at line 3875 of file unzip.c. Referenced by crc32(). |
|
|
Definition at line 2463 of file unzip.c. Referenced by inflate_blocks(), inflate_codes(), and inflate_fast(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 2468 of file unzip.c. Referenced by inflate_blocks(), and inflate_codes(). |
|
|
Definition at line 3469 of file unzip.c. Referenced by inflate_fast(). |
|
|
Definition at line 4073 of file unzip.c. Referenced by inflate(). |
|
|
Definition at line 4074 of file unzip.c. Referenced by inflate(). |
|
|
|
|
|
Definition at line 951 of file unzip.c. Referenced by unzOpenCurrentFile(). |
|
|
Definition at line 2457 of file unzip.c. Referenced by inflate_blocks(), and inflate_codes(). |
|
|
Definition at line 2472 of file unzip.c. Referenced by gen(), inflate_blocks(), inflate_codes(), inflate_fast(), main(), prelabel(), and rtarget(). |
|
|
|
|
|
|
|
|
Definition at line 2333 of file unzip.c. Referenced by inflate_blocks_new(). |
|
|
|
|
|
|
|
|
Definition at line 107 of file unzip.c. Referenced by unzOpenCurrentFile(). |
|
|
|
|
|
Definition at line 2462 of file unzip.c. Referenced by inflate_blocks(), and inflate_codes(). |
|
|
|
|
|
Definition at line 2469 of file unzip.c. Referenced by inflate_blocks(), and inflate_codes(). |
|
|
|
|
|
Definition at line 3864 of file unzip.c. Referenced by adler32(). |
|
|
|
|
|
|
|
|
Definition at line 2470 of file unzip.c. Referenced by inflate_codes(). |
|
|
|
|
|
Definition at line 136 of file unzip.c. Referenced by LoadBMP(), ReadQuakeFile(), and unzlocal_GetCurrentFileInfoInternal(). |
|
|
Definition at line 137 of file unzip.c. Referenced by filelength(), FileLength(), FS_CopyFile(), FS_filelength(), Q_filelength(), and unzlocal_SearchCentralDir(). |
|
|
|
|
|
Definition at line 1073 of file unzip.c. Referenced by unzGoToNextFile(). |
|
|
Definition at line 1074 of file unzip.c. Referenced by unzlocal_CheckCurrentFileCoherencyHeader(), and unzOpenCurrentFile(). |
|
|
|
|
|
|
|
|
Definition at line 1204 of file unzip.c. Referenced by unzStringFileNameCompare(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1035 of file unzip.c. Referenced by inflate(), inflate_blocks(), inflate_blocks_free(), inflate_blocks_new(), inflate_blocks_reset(), inflate_codes_free(), inflate_codes_new(), inflateEnd(), inflateInit2_(), and inflateReset(). |
|
|
Definition at line 1036 of file unzip.c. Referenced by inflate_codes(), and inflate_fast(). |
|
|
|
|
|
Definition at line 1070 of file unzip.c. Referenced by unzClose(), unzCloseCurrentFile(), unzlocal_SearchCentralDir(), and unzOpenCurrentFile(). |
|
|
Definition at line 3470 of file unzip.c. Referenced by inflate_fast(). |
|
|
Definition at line 1059 of file unzip.c. Referenced by unzOpenCurrentFile(). |
|
|
Definition at line 1063 of file unzip.c. Referenced by unzLocateFile(). |
|
|
Definition at line 2456 of file unzip.c. Referenced by inflate_blocks(), inflate_codes(), and inflate_fast(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 213 of file unzip.c. Referenced by huft_build(), inflate(), and inflate_trees_bits(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 203 of file unzip.c. Referenced by inflate(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 238 of file unzip.c. Referenced by inflate(), inflate_blocks_free(), inflate_blocks_new(), inflate_trees_bits(), inflateEnd(), inflateInit2_(), inflateReset(), inflateSetDictionary(), inflateSync(), and inflateSyncPoint(). |
|
|
Definition at line 206 of file unzip.c. Referenced by inflate_trees_dynamic(). |
|
|
|
|
|
Definition at line 207 of file unzip.c. Referenced by inflate_codes(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1046 of file unzip.c. Referenced by inflate_blocks(), inflate_blocks_new(), inflate_codes_new(), inflate_trees_bits(), inflate_trees_dynamic(), and inflateInit2_(). |
|
|
Definition at line 1048 of file unzip.c. Referenced by inflate_blocks(), inflate_blocks_free(), inflate_blocks_new(), inflate_blocks_reset(), inflate_codes_free(), inflate_trees_bits(), inflate_trees_dynamic(), and inflateEnd(). |
|
|
|
|
|
Definition at line 142 of file unzip.c. Referenced by inflateInit2_(). |
|
|
|
|
|
Definition at line 1018 of file unzip.c. Referenced by inflate_blocks(), inflate_flush(), and inflate_set_dictionary(). |
|
|
|
|
|
|
|
|
Definition at line 129 of file unzip.c. Referenced by inflate_blocks(), inflate_blocks_new(), inflate_blocks_reset(), inflate_codes(), inflate_fast(), inflate_flush(), inflateSync(), and unzReadCurrentFile(). |
|
|
|
|
|
Definition at line 2262 of file unzip.c. Referenced by inflate_blocks_new(). |
|
|
Definition at line 2372 of file unzip.c. Referenced by inflate_blocks(), inflate_codes(), and inflate_codes_new(). |
|
|
Definition at line 2314 of file unzip.c. Referenced by huft_build(), inflate_blocks(), inflate_blocks_new(), inflate_codes(), and inflate_fast(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 132 of file unzip.c. Referenced by zcalloc(). |
|
|
Definition at line 2401 of file unzip.c. 02401 {
02402 TYPE, /* get type bits (3, including end bit) */
02403 LENS, /* get lengths for stored */
02404 STORED, /* processing stored block */
02405 TABLE, /* get table lengths */
02406 BTREE, /* get bit lengths tree for a dynamic block */
02407 DTREE, /* get length, distance trees for a dynamic block */
02408 CODES, /* processing fixed or dynamic block */
02409 DRY, /* output remaining window bytes */
02410 DONE, /* finished last block, done */
02411 BAD} /* got a data error--stuck here */
|
|
|
Definition at line 3625 of file unzip.c. 03625 { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
03626 START, /* x: set up for LEN */
03627 LEN, /* i: get length/literal/eob next */
03628 LENEXT, /* i: getting length extra (have base) */
03629 DIST, /* i: get distance next */
03630 DISTEXT, /* i: getting distance extra */
03631 COPY, /* o: copying bytes in window, waiting for space */
03632 LIT, /* o: got literal, waiting for output space */
03633 WASH, /* o: got eob, possibly still output waiting */
03634 END, /* x: got eob and all data flushed */
03635 BADCODE} /* x: got error */
|
|
|
Definition at line 3945 of file unzip.c. 03945 {
03946 imMETHOD, /* waiting for method byte */
03947 imFLAG, /* waiting for flag byte */
03948 imDICT4, /* four dictionary check bytes to go */
03949 imDICT3, /* three dictionary check bytes to go */
03950 imDICT2, /* two dictionary check bytes to go */
03951 imDICT1, /* one dictionary check byte to go */
03952 imDICT0, /* waiting for inflateSetDictionary */
03953 imBLOCKS, /* decompressing blocks */
03954 imCHECK4, /* four check bytes to go */
03955 imCHECK3, /* three check bytes to go */
03956 imCHECK2, /* two check bytes to go */
03957 imCHECK1, /* one check byte to go */
03958 imDONE, /* finished check, done */
03959 imBAD} /* got an error--stay here */
|
|
||||||||||||||||
|
Definition at line 3879 of file unzip.c. References DO16, k, NMAX, and uLong. Referenced by inflateInit2_(). 03880 {
03881 unsigned long s1 = adler & 0xffff;
03882 unsigned long s2 = (adler >> 16) & 0xffff;
03883 int k;
03884
03885 if (buf == Z_NULL) return 1L;
03886
03887 while (len > 0) {
03888 k = len < NMAX ? len : NMAX;
03889 len -= k;
03890 while (k >= 16) {
03891 DO16(buf);
03892 buf += 16;
03893 k -= 16;
03894 }
03895 if (k != 0) do {
03896 s1 += *buf++;
03897 s2 += s1;
03898 } while (--k);
03899 s1 %= BASE;
03900 s2 %= BASE;
03901 }
03902 return (s2 << 16) | s1;
03903 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 3007 of file unzip.c. References a, inflate_huft_s::base, BMAX, c, C4, d, e, f, g(), h(), i, inflate_huft, j, k, l, m, mask, n, p, q, r, t, uInt, v, w, x, y, z, and Z_BUF_ERROR. 03013 : starting table */ 03014 //uInt *m; /* maximum lookup bits, returns actual */ 03015 //inflate_huft *hp; /* space for trees */ 03016 //uInt *hn; /* hufts used in space */ 03017 //uInt *v; /* working area: values in order of bit length */ 03018 /* Given a list of code lengths and a maximum table size, make a set of 03019 tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR 03020 if the given code set is incomplete (the tables are still built in this 03021 case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of 03022 lengths), or Z_MEM_ERROR if not enough memory. */ 03023 { 03024 03025 uInt a; /* counter for codes of length k */ 03026 uInt c[BMAX+1]; /* bit length count table */ 03027 uInt f; /* i repeats in table every f entries */ 03028 int g; /* maximum code length */ 03029 int h; /* table level */ 03030 register uInt i; /* counter, current code */ 03031 register uInt j; /* counter */ 03032 register int k; /* number of bits in current code */ 03033 int l; /* bits per table (returned in m) */ 03034 uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ 03035 register uInt *p; /* pointer into c[], b[], or v[] */ 03036 inflate_huft *q; /* points to current table */ 03037 struct inflate_huft_s r; /* table entry for structure assignment */ 03038 inflate_huft *u[BMAX]; /* table stack */ 03039 register int w; /* bits before this table == (l * h) */ 03040 uInt x[BMAX+1]; /* bit offsets, then code stack */ 03041 uInt *xp; /* pointer into x */ 03042 int y; /* number of dummy codes added */ 03043 uInt z; /* number of entries in current table */ 03044 03045 03046 /* Generate counts for each bit length */ 03047 p = c; 03048 #define C0 *p++ = 0; 03049 #define C2 C0 C0 C0 C0 03050 #define C4 C2 C2 C2 C2 03051 C4 /* clear c[]--assume BMAX+1 is 16 */ 03052 p = b; i = n; 03053 do { 03054 c[*p++]++; /* assume all entries <= BMAX */ 03055 } while (--i); 03056 if (c[0] == n) /* null input--all zero length codes */ 03057 { 03058 *t = (inflate_huft *)Z_NULL; 03059 *m = 0; 03060 return Z_OK; 03061 } 03062 03063 03064 /* Find minimum and maximum length, bound *m by those */ 03065 l = *m; 03066 for (j = 1; j <= BMAX; j++) 03067 if (c[j]) 03068 break; 03069 k = j; /* minimum code length */ 03070 if ((uInt)l < j) 03071 l = j; 03072 for (i = BMAX; i; i--) 03073 if (c[i]) 03074 break; 03075 g = i; /* maximum code length */ 03076 if ((uInt)l > i) 03077 l = i; 03078 *m = l; 03079 03080 03081 /* Adjust last length count to fill out codes, if needed */ 03082 for (y = 1 << j; j < i; j++, y <<= 1) 03083 if ((y -= c[j]) < 0) 03084 return Z_DATA_ERROR; 03085 if ((y -= c[i]) < 0) 03086 return Z_DATA_ERROR; 03087 c[i] += y; 03088 03089 03090 /* Generate starting offsets into the value table for each length */ 03091 x[1] = j = 0; 03092 p = c + 1; xp = x + 2; 03093 while (--i) { /* note that i == g from above */ 03094 *xp++ = (j += *p++); 03095 } 03096 03097 03098 /* Make a table of values in order of bit lengths */ 03099 p = b; i = 0; 03100 do { 03101 if ((j = *p++) != 0) 03102 v[x[j]++] = i; 03103 } while (++i < n); 03104 n = x[g]; /* set n to length of v */ 03105 03106 03107 /* Generate the Huffman codes and for each, make the table entries */ 03108 x[0] = i = 0; /* first Huffman code is zero */ 03109 p = v; /* grab values in bit order */ 03110 h = -1; /* no tables yet--level -1 */ 03111 w = -l; /* bits decoded == (l * h) */ 03112 u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ 03113 q = (inflate_huft *)Z_NULL; /* ditto */ 03114 z = 0; /* ditto */ 03115 03116 /* go through the bit lengths (k already is bits in shortest code) */ 03117 for (; k <= g; k++) 03118 { 03119 a = c[k]; 03120 while (a--) 03121 { 03122 /* here i is the Huffman code of length k bits for value *p */ 03123 /* make tables up to required level */ 03124 while (k > w + l) 03125 { 03126 h++; 03127 w += l; /* previous table always l bits */ 03128 03129 /* compute minimum size table less than or equal to l bits */ 03130 z = g - w; 03131 z = z > (uInt)l ? l : z; /* table size upper limit */ 03132 if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ 03133 { /* too few codes for k-w bit table */ 03134 f -= a + 1; /* deduct codes from patterns left */ 03135 xp = c + k; 03136 if (j < z) 03137 while (++j < z) /* try smaller tables up to z bits */ 03138 { 03139 if ((f <<= 1) <= *++xp) 03140 break; /* enough codes to use up j bits */ 03141 f -= *xp; /* else deduct codes from patterns */ 03142 } 03143 } 03144 z = 1 << j; /* table entries for j-bit table */ 03145 03146 /* allocate new table */ 03147 if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ 03148 return Z_MEM_ERROR; /* not enough memory */ 03149 u[h] = q = hp + *hn; 03150 *hn += z; 03151 03152 /* connect to last table, if there is one */ 03153 if (h) 03154 { 03155 x[h] = i; /* save pattern for backing up */ 03156 r.bits = (Byte)l; /* bits to dump before this table */ 03157 r.exop = (Byte)j; /* bits in this table */ 03158 j = i >> (w - l); 03159 r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ 03160 u[h-1][j] = r; /* connect to last table */ 03161 } 03162 else 03163 *t = q; /* first table is returned result */ 03164 } 03165 03166 /* set up table entry in r */ 03167 r.bits = (Byte)(k - w); 03168 if (p >= v + n) 03169 r.exop = 128 + 64; /* out of values--invalid code */ 03170 else if (*p < s) 03171 { 03172 r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ 03173 r.base = *p++; /* simple code is just the value */ 03174 } 03175 else 03176 { 03177 r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ 03178 r.base = d[*p++ - s]; 03179 } 03180 03181 /* fill code-like entries with r */ 03182 f = 1 << (k - w); 03183 for (j = i >> w; j < z; j += f) 03184 q[j] = r; 03185 03186 /* backwards increment the k-bit code i */ 03187 for (j = 1 << (k - 1); i & j; j >>= 1) 03188 i ^= j; 03189 i ^= j; 03190 03191 /* backup over finished tables */ 03192 mask = (1 << w) - 1; /* needed on HP, cc -O bug */ 03193 while ((i & mask) != x[h]) 03194 { 03195 h--; /* don't need to update q */ 03196 w -= l; 03197 mask = (1 << w) - 1; 03198 } 03199 } 03200 } 03201 03202 03203 /* Return Z_BUF_ERROR if we were given an incomplete table */ 03204 return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; 03205 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 4076 of file unzip.c. References z_stream_s::adler, b, internal_state::blocks, internal_state::check, f, imBAD, imBLOCKS, imCHECK1, imCHECK2, imCHECK3, imCHECK4, imDICT0, imDICT1, imDICT2, imDICT3, imDICT4, imDONE, imFLAG, imMETHOD, iNEEDBYTE, iNEXTBYTE, inflate_blocks(), inflate_blocks_reset(), internal_state::marker, internal_state::method, internal_state::mode, z_stream_s::msg, internal_state::need, z_stream_s::next_in, internal_state::nowrap, r, z_stream_s::state, internal_state::sub, Tracev, uInt, internal_state::was, internal_state::wbits, z, Z_BUF_ERROR, Z_FINISH, Z_NULL, and z_streamp. 04077 {
04078 int r;
04079 uInt b;
04080
04081 if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
04082 return Z_STREAM_ERROR;
04083 f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
04084 r = Z_BUF_ERROR;
04085 while (1) switch (z->state->mode)
04086 {
04087 case imMETHOD:
04088 iNEEDBYTE
04089 if (((z->state->sub.method = iNEXTBYTE) & 0xf) != Z_DEFLATED)
04090 {
04091 z->state->mode = imBAD;
04092 z->msg = (char*)"unknown compression method";
04093 z->state->sub.marker = 5; /* can't try inflateSync */
04094 break;
04095 }
04096 if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
04097 {
04098 z->state->mode = imBAD;
04099 z->msg = (char*)"invalid window size";
04100 z->state->sub.marker = 5; /* can't try inflateSync */
04101 break;
04102 }
04103 z->state->mode = imFLAG;
04104 case imFLAG:
04105 iNEEDBYTE
04106 b = iNEXTBYTE;
04107 if (((z->state->sub.method << 8) + b) % 31)
04108 {
04109 z->state->mode = imBAD;
04110 z->msg = (char*)"incorrect header check";
04111 z->state->sub.marker = 5; /* can't try inflateSync */
04112 break;
04113 }
04114 Tracev(("inflate: zlib header ok\n"));
04115 if (!(b & PRESET_DICT))
04116 {
04117 z->state->mode = imBLOCKS;
04118 break;
04119 }
04120 z->state->mode = imDICT4;
04121 case imDICT4:
04122 iNEEDBYTE
04123 z->state->sub.check.need = (uLong)iNEXTBYTE << 24;
04124 z->state->mode = imDICT3;
04125 case imDICT3:
04126 iNEEDBYTE
04127 z->state->sub.check.need += (uLong)iNEXTBYTE << 16;
04128 z->state->mode = imDICT2;
04129 case imDICT2:
04130 iNEEDBYTE
04131 z->state->sub.check.need += (uLong)iNEXTBYTE << 8;
04132 z->state->mode = imDICT1;
04133 case imDICT1:
04134 iNEEDBYTE
04135 z->state->sub.check.need += (uLong)iNEXTBYTE;
04136 z->adler = z->state->sub.check.need;
04137 z->state->mode = imDICT0;
04138 return Z_NEED_DICT;
04139 case imDICT0:
04140 z->state->mode = imBAD;
04141 z->msg = (char*)"need dictionary";
04142 z->state->sub.marker = 0; /* can try inflateSync */
04143 return Z_STREAM_ERROR;
04144 case imBLOCKS:
04145 r = inflate_blocks(z->state->blocks, z, r);
04146 if (r == Z_DATA_ERROR)
04147 {
04148 z->state->mode = imBAD;
04149 z->state->sub.marker = 0; /* can try inflateSync */
04150 break;
04151 }
04152 if (r == Z_OK)
04153 r = f;
04154 if (r != Z_STREAM_END)
04155 return r;
04156 r = f;
04157 inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
04158 if (z->state->nowrap)
04159 {
04160 z->state->mode = imDONE;
04161 break;
04162 }
04163 z->state->mode = imCHECK4;
04164 case imCHECK4:
04165 iNEEDBYTE
04166 z->state->sub.check.need = (uLong)iNEXTBYTE << 24;
04167 z->state->mode = imCHECK3;
04168 case imCHECK3:
04169 iNEEDBYTE
04170 z->state->sub.check.need += (uLong)iNEXTBYTE << 16;
04171 z->state->mode = imCHECK2;
04172 case imCHECK2:
04173 iNEEDBYTE
04174 z->state->sub.check.need += (uLong)iNEXTBYTE << 8;
04175 z->state->mode = imCHECK1;
04176 case imCHECK1:
04177 iNEEDBYTE
04178 z->state->sub.check.need += (uLong)iNEXTBYTE;
04179
04180 if (z->state->sub.check.was != z->state->sub.check.need)
04181 {
04182 z->state->mode = imBAD;
04183 z->msg = (char*)"incorrect data check";
04184 z->state->sub.marker = 5; /* can't try inflateSync */
04185 break;
04186 }
04187 Tracev(("inflate: zlib check ok\n"));
04188 z->state->mode = imDONE;
04189 case imDONE:
04190 return Z_STREAM_END;
04191 case imBAD:
04192 return Z_DATA_ERROR;
04193 default:
04194 return Z_STREAM_ERROR;
04195 }
04196 #ifdef NEED_DUMMY_RETURN
04197 return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
04198 #endif
04199 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2578 of file unzip.c. References b, BAD, inflate_huft_s::base, inflate_blocks_state::bb, inflate_blocks_state::blens, border, BTREE, Byte, c, CODES, inflate_blocks_state::codes, inflate_blocks_state::decode, DONE, DRY, DTREE, DUMPBITS, inflate_blocks_state::end, FLUSH, h(), inflate_blocks_state::hufts, i, inflate_blocks_state::index, inflate_codes(), inflate_codes_free(), inflate_codes_new(), inflate_codes_statef, inflate_flush(), inflate_huft, inflate_mask, inflate_trees_bits(), inflate_trees_dynamic(), inflate_trees_fixed(), j, k, inflate_blocks_state::last, LEAVE, inflate_blocks_state::left, LENS, LOAD, m, inflate_blocks_state::mode, z_stream_s::msg, n, NEEDBITS, NEEDOUT, p, q, r, inflate_blocks_state::read, s, STORED, inflate_blocks_state::sub, t, inflate_blocks_state::table, TABLE, inflate_blocks_state::tb, z_stream_s::total_out, Tracev, inflate_blocks_state::trees, TYPE, uInt, uLong, UPDATE, inflate_blocks_state::window, inflate_blocks_state::write, z, z_streamp, ZALLOC, ZFREE, and zmemcpy. 02579 {
02580 uInt t; /* temporary storage */
02581 uLong b; /* bit buffer */
02582 uInt k; /* bits in bit buffer */
02583 Byte *p; /* input data pointer */
02584 uInt n; /* bytes available there */
02585 Byte *q; /* output window write pointer */
02586 uInt m; /* bytes to end of window or read pointer */
02587
02588 /* copy input/output information to locals (UPDATE macro restores) */
02589 LOAD
02590
02591 /* process input based on current state */
02592 while (1) switch (s->mode)
02593 {
02594 case TYPE:
02595 NEEDBITS(3)
02596 t = (uInt)b & 7;
02597 s->last = t & 1;
02598 switch (t >> 1)
02599 {
02600 case 0: /* stored */
02601 Tracev(("inflate: stored block%s\n",
02602 s->last ? " (last)" : ""));
02603 DUMPBITS(3)
02604 t = k & 7; /* go to byte boundary */
02605 DUMPBITS(t)
02606 s->mode = LENS; /* get length of stored block */
02607 break;
02608 case 1: /* fixed */
02609 Tracev(("inflate: fixed codes block%s\n",
02610 s->last ? " (last)" : ""));
02611 {
02612 uInt bl, bd;
02613 inflate_huft *tl, *td;
02614 inflate_trees_fixed(&bl, &bd, &tl, &td, z);
02615 s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
02616 if (s->sub.decode.codes == Z_NULL)
02617 {
02618 r = Z_MEM_ERROR;
02619 LEAVE
02620 }
02621 }
02622 DUMPBITS(3)
02623 s->mode = CODES;
02624 break;
02625 case 2: /* dynamic */
02626 Tracev(("inflate: dynamic codes block%s\n",
02627 s->last ? " (last)" : ""));
02628 DUMPBITS(3)
02629 s->mode = TABLE;
02630 break;
02631 case 3: /* illegal */
02632 DUMPBITS(3)
02633 s->mode = BAD;
02634 z->msg = (char*)"invalid block type";
02635 r = Z_DATA_ERROR;
02636 LEAVE
02637 }
02638 break;
02639 case LENS:
02640 NEEDBITS(32)
02641 if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
02642 {
02643 s->mode = BAD;
02644 z->msg = (char*)"invalid stored block lengths";
02645 r = Z_DATA_ERROR;
02646 LEAVE
02647 }
02648 s->sub.left = (uInt)b & 0xffff;
02649 b = k = 0; /* dump bits */
02650 Tracev(("inflate: stored length %u\n", s->sub.left));
02651 s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
02652 break;
02653 case STORED:
02654 if (n == 0)
02655 LEAVE
02656 NEEDOUT
02657 t = s->sub.left;
02658 if (t > n) t = n;
02659 if (t > m) t = m;
02660 zmemcpy(q, p, t);
02661 p += t; n -= t;
02662 q += t; m -= t;
02663 if ((s->sub.left -= t) != 0)
02664 break;
02665 Tracev(("inflate: stored end, %lu total out\n",
02666 z->total_out + (q >= s->read ? q - s->read :
02667 (s->end - s->read) + (q - s->window))));
02668 s->mode = s->last ? DRY : TYPE;
02669 break;
02670 case TABLE:
02671 NEEDBITS(14)
02672 s->sub.trees.table = t = (uInt)b & 0x3fff;
02673 #ifndef PKZIP_BUG_WORKAROUND
02674 if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
02675 {
02676 s->mode = BAD;
02677 z->msg = (char*)"too many length or distance symbols";
02678 r = Z_DATA_ERROR;
02679 LEAVE
02680 }
02681 #endif
02682 t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
02683 if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
02684 {
02685 r = Z_MEM_ERROR;
02686 LEAVE
02687 }
02688 DUMPBITS(14)
02689 s->sub.trees.index = 0;
02690 Tracev(("inflate: table sizes ok\n"));
02691 s->mode = BTREE;
02692 case BTREE:
02693 while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
02694 {
02695 NEEDBITS(3)
02696 s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
02697 DUMPBITS(3)
02698 }
02699 while (s->sub.trees.index < 19)
02700 s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
02701 s->sub.trees.bb = 7;
02702 t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
02703 &s->sub.trees.tb, s->hufts, z);
02704 if (t != Z_OK)
02705 {
02706 ZFREE(z, s->sub.trees.blens);
02707 r = t;
02708 if (r == Z_DATA_ERROR)
02709 s->mode = BAD;
02710 LEAVE
02711 }
02712 s->sub.trees.index = 0;
02713 Tracev(("inflate: bits tree ok\n"));
02714 s->mode = DTREE;
02715 case DTREE:
02716 while (t = s->sub.trees.table,
02717 s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
02718 {
02719 inflate_huft *h;
02720 uInt i, j, c;
02721
02722 t = s->sub.trees.bb;
02723 NEEDBITS(t)
02724 h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
02725 t = h->bits;
02726 c = h->base;
02727 if (c < 16)
02728 {
02729 DUMPBITS(t)
02730 s->sub.trees.blens[s->sub.trees.index++] = c;
02731 }
02732 else /* c == 16..18 */
02733 {
02734 i = c == 18 ? 7 : c - 14;
02735 j = c == 18 ? 11 : 3;
02736 NEEDBITS(t + i)
02737 DUMPBITS(t)
02738 j += (uInt)b & inflate_mask[i];
02739 DUMPBITS(i)
02740 i = s->sub.trees.index;
02741 t = s->sub.trees.table;
02742 if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
02743 (c == 16 && i < 1))
02744 {
02745 ZFREE(z, s->sub.trees.blens);
02746 s->mode = BAD;
02747 z->msg = (char*)"invalid bit length repeat";
02748 r = Z_DATA_ERROR;
02749 LEAVE
02750 }
02751 c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
02752 do {
02753 s->sub.trees.blens[i++] = c;
02754 } while (--j);
02755 s->sub.trees.index = i;
02756 }
02757 }
02758 s->sub.trees.tb = Z_NULL;
02759 {
02760 uInt bl, bd;
02761 inflate_huft *tl, *td;
02762 inflate_codes_statef *c;
02763
02764 tl = NULL;
02765 td = NULL;
02766 bl = 9; /* must be <= 9 for lookahead assumptions */
02767 bd = 6; /* must be <= 9 for lookahead assumptions */
02768 t = s->sub.trees.table;
02769 t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
02770 s->sub.trees.blens, &bl, &bd, &tl, &td,
02771 s->hufts, z);
02772 ZFREE(z, s->sub.trees.blens);
02773 if (t != Z_OK)
02774 {
02775 if (t == (uInt)Z_DATA_ERROR)
02776 s->mode = BAD;
02777 r = t;
02778 LEAVE
02779 }
02780 Tracev(("inflate: trees ok\n"));
02781 if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
02782 {
02783 r = Z_MEM_ERROR;
02784 LEAVE
02785 }
02786 s->sub.decode.codes = c;
02787 }
02788 s->mode = CODES;
02789 case CODES:
02790 UPDATE
02791 if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
02792 return inflate_flush(s, z, r);
02793 r = Z_OK;
02794 inflate_codes_free(s->sub.decode.codes, z);
02795 LOAD
02796 Tracev(("inflate: codes end, %lu total out\n",
02797 z->total_out + (q >= s->read ? q - s->read :
02798 (s->end - s->read) + (q - s->window))));
02799 if (!s->last)
02800 {
02801 s->mode = TYPE;
02802 break;
02803 }
02804 s->mode = DRY;
02805 case DRY:
02806 FLUSH
02807 if (s->read != s->write)
02808 LEAVE
02809 s->mode = DONE;
02810 case DONE:
02811 r = Z_STREAM_END;
02812 LEAVE
02813 case BAD:
02814 r = Z_DATA_ERROR;
02815 LEAVE
02816 default:
02817 r = Z_STREAM_ERROR;
02818 LEAVE
02819 }
02820 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2823 of file unzip.c. References inflate_blocks_state::hufts, inflate_blocks_reset(), s, Tracev, inflate_blocks_state::window, z, Z_NULL, z_streamp, and ZFREE. 02824 {
02825 inflate_blocks_reset(s, z, Z_NULL);
02826 ZFREE(z, s->window);
02827 ZFREE(z, s->hufts);
02828 ZFREE(z, s);
02829 Tracev(("inflate: blocks freed\n"));
02830 return Z_OK;
02831 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2550 of file unzip.c. References Byte, inflate_blocks_state::checkfn, inflate_blocks_state::end, inflate_blocks_state::hufts, inflate_blocks_reset(), inflate_blocks_statef, inflate_huft, MANY, inflate_blocks_state::mode, s, Tracev, w, inflate_blocks_state::window, z, Z_NULL, z_streamp, ZALLOC, and ZFREE. 02551 {
02552 inflate_blocks_statef *s;
02553
02554 if ((s = (inflate_blocks_statef *)ZALLOC
02555 (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
02556 return s;
02557 if ((s->hufts =
02558 (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
02559 {
02560 ZFREE(z, s);
02561 return Z_NULL;
02562 }
02563 if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL)
02564 {
02565 ZFREE(z, s->hufts);
02566 ZFREE(z, s);
02567 return Z_NULL;
02568 }
02569 s->end = s->window + w;
02570 s->checkfn = c;
02571 s->mode = TYPE;
02572 Tracev(("inflate: blocks allocated\n"));
02573 inflate_blocks_reset(s, z, Z_NULL);
02574 return s;
02575 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2532 of file unzip.c. References z_stream_s::adler, inflate_blocks_state::bitb, inflate_blocks_state::bitk, inflate_blocks_state::blens, BTREE, Byte, c, inflate_blocks_state::check, inflate_blocks_state::checkfn, inflate_blocks_state::codes, inflate_blocks_state::decode, inflate_codes_free(), inflate_blocks_state::mode, inflate_blocks_state::read, s, inflate_blocks_state::sub, Tracev, inflate_blocks_state::trees, inflate_blocks_state::window, inflate_blocks_state::write, z, z_streamp, and ZFREE. 02533 {
02534 if (c != Z_NULL)
02535 *c = s->check;
02536 if (s->mode == BTREE || s->mode == DTREE)
02537 ZFREE(z, s->sub.trees.blens);
02538 if (s->mode == CODES)
02539 inflate_codes_free(s->sub.decode.codes, z);
02540 s->mode = TYPE;
02541 s->bitk = 0;
02542 s->bitb = 0;
02543 s->read = s->write = s->window;
02544 if (s->checkfn != Z_NULL)
02545 z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0);
02546 Tracev(("inflate: blocks reset\n"));
02547 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 3685 of file unzip.c. References Assert, b, BADCODE, inflate_huft_s::base, Byte, c, inflate_codes_state::code, inflate_blocks_state::codes, COPY, inflate_codes_state::copy, inflate_codes_state::dbits, inflate_blocks_state::decode, inflate_codes_state::dist, DIST, DISTEXT, inflate_codes_state::dtree, DUMPBITS, e, END, inflate_blocks_state::end, f, FLUSH, inflate_codes_state::get, inflate_codes_statef, inflate_fast(), inflate_huft, inflate_mask, j, k, inflate_codes_state::lbits, LEAVE, inflate_codes_state::len, LEN, LENEXT, LIT, inflate_codes_state::lit, LOAD, inflate_codes_state::ltree, m, inflate_codes_state::mode, z_stream_s::msg, n, inflate_codes_state::need, NEEDBITS, NEEDOUT, OUTBYTE, p, q, r, inflate_blocks_state::read, s, START, inflate_codes_state::sub, inflate_blocks_state::sub, t, Tracevv, inflate_codes_state::tree, uInt, uLong, UPDATE, WASH, inflate_blocks_state::window, inflate_blocks_state::write, z, Z_STREAM_END, and z_streamp. 03686 {
03687 uInt j; /* temporary storage */
03688 inflate_huft *t; /* temporary pointer */
03689 uInt e; /* extra bits or operation */
03690 uLong b; /* bit buffer */
03691 uInt k; /* bits in bit buffer */
03692 Byte *p; /* input data pointer */
03693 uInt n; /* bytes available there */
03694 Byte *q; /* output window write pointer */
03695 uInt m; /* bytes to end of window or read pointer */
03696 Byte *f; /* pointer to copy strings from */
03697 inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
03698
03699 /* copy input/output information to locals (UPDATE macro restores) */
03700 LOAD
03701
03702 /* process input and output based on current state */
03703 while (1) switch (c->mode)
03704 { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
03705 case START: /* x: set up for LEN */
03706 #ifndef SLOW
03707 if (m >= 258 && n >= 10)
03708 {
03709 UPDATE
03710 r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
03711 LOAD
03712 if (r != Z_OK)
03713 {
03714 c->mode = r == Z_STREAM_END ? WASH : BADCODE;
03715 break;
03716 }
03717 }
03718 #endif /* !SLOW */
03719 c->sub.code.need = c->lbits;
03720 c->sub.code.tree = c->ltree;
03721 c->mode = LEN;
03722 case LEN: /* i: get length/literal/eob next */
03723 j = c->sub.code.need;
03724 NEEDBITS(j)
03725 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
03726 DUMPBITS(t->bits)
03727 e = (uInt)(t->exop);
03728 if (e == 0) /* literal */
03729 {
03730 c->sub.lit = t->base;
03731 Tracevv((t->base >= 0x20 && t->base < 0x7f ?
03732 "inflate: literal '%c'\n" :
03733 "inflate: literal 0x%02x\n", t->base));
03734 c->mode = LIT;
03735 break;
03736 }
03737 if (e & 16) /* length */
03738 {
03739 c->sub.copy.get = e & 15;
03740 c->len = t->base;
03741 c->mode = LENEXT;
03742 break;
03743 }
03744 if ((e & 64) == 0) /* next table */
03745 {
03746 c->sub.code.need = e;
03747 c->sub.code.tree = t + t->base;
03748 break;
03749 }
03750 if (e & 32) /* end of block */
03751 {
03752 Tracevv(("inflate: end of block\n"));
03753 c->mode = WASH;
03754 break;
03755 }
03756 c->mode = BADCODE; /* invalid code */
03757 z->msg = (char*)"invalid literal/length code";
03758 r = Z_DATA_ERROR;
03759 LEAVE
03760 case LENEXT: /* i: getting length extra (have base) */
03761 j = c->sub.copy.get;
03762 NEEDBITS(j)
03763 c->len += (uInt)b & inflate_mask[j];
03764 DUMPBITS(j)
03765 c->sub.code.need = c->dbits;
03766 c->sub.code.tree = c->dtree;
03767 Tracevv(("inflate: length %u\n", c->len));
03768 c->mode = DIST;
03769 case DIST: /* i: get distance next */
03770 j = c->sub.code.need;
03771 NEEDBITS(j)
03772 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
03773 DUMPBITS(t->bits)
03774 e = (uInt)(t->exop);
03775 if (e & 16) /* distance */
03776 {
03777 c->sub.copy.get = e & 15;
03778 c->sub.copy.dist = t->base;
03779 c->mode = DISTEXT;
03780 break;
03781 }
03782 if ((e & 64) == 0) /* next table */
03783 {
03784 c->sub.code.need = e;
03785 c->sub.code.tree = t + t->base;
03786 break;
03787 }
03788 c->mode = BADCODE; /* invalid code */
03789 z->msg = (char*)"invalid distance code";
03790 r = Z_DATA_ERROR;
03791 LEAVE
03792 case DISTEXT: /* i: getting distance extra */
03793 j = c->sub.copy.get;
03794 NEEDBITS(j)
03795 c->sub.copy.dist += (uInt)b & inflate_mask[j];
03796 DUMPBITS(j)
03797 Tracevv(("inflate: distance %u\n", c->sub.copy.dist));
03798 c->mode = COPY;
03799 case COPY: /* o: copying bytes in window, waiting for space */
03800 #ifndef __TURBOC__ /* Turbo C bug for following expression */
03801 f = (uInt)(q - s->window) < c->sub.copy.dist ?
03802 s->end - (c->sub.copy.dist - (q - s->window)) :
03803 q - c->sub.copy.dist;
03804 #else
03805 f = q - c->sub.copy.dist;
03806 if ((uInt)(q - s->window) < c->sub.copy.dist)
03807 f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
03808 #endif
03809 while (c->len)
03810 {
03811 NEEDOUT
03812 OUTBYTE(*f++)
03813 if (f == s->end)
03814 f = s->window;
03815 c->len--;
03816 }
03817 c->mode = START;
03818 break;
03819 case LIT: /* o: got literal, waiting for output space */
03820 NEEDOUT
03821 OUTBYTE(c->sub.lit)
03822 c->mode = START;
03823 break;
03824 case WASH: /* o: got eob, possibly more output */
03825 if (k > 7) /* return unused byte, if any */
03826 {
03827 Assert(k < 16, "inflate_codes grabbed too many bytes")
03828 k -= 8;
03829 n++;
03830 p--; /* can always return one */
03831 }
03832 FLUSH
03833 if (s->read != s->write)
03834 LEAVE
03835 c->mode = END;
03836 case END:
03837 r = Z_STREAM_END;
03838 LEAVE
03839 case BADCODE: /* x: got error */
03840 r = Z_DATA_ERROR;
03841 LEAVE
03842 default:
03843 r = Z_STREAM_ERROR;
03844 LEAVE
03845 }
03846 #ifdef NEED_DUMMY_RETURN
03847 return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
03848 #endif
03849 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 3852 of file unzip.c. References c, Tracev, z, z_streamp, and ZFREE.
|
|
||||||||||||||||||||||||
|
Definition at line 3667 of file unzip.c. References c, inflate_codes_state::dbits, inflate_codes_state::dtree, inflate_codes_statef, inflate_codes_state::lbits, inflate_codes_state::ltree, inflate_codes_state::mode, Tracev, z, z_streamp, and ZALLOC. 03668 {
03669 inflate_codes_statef *c;
03670
03671 if ((c = (inflate_codes_statef *)
03672 ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
03673 {
03674 c->mode = START;
03675 c->lbits = (Byte)bl;
03676 c->dbits = (Byte)bd;
03677 c->ltree = tl;
03678 c->dtree = td;
03679 Tracev(("inflate: codes new\n"));
03680 }
03681 return c;
03682 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 3477 of file unzip.c. References b, inflate_huft_s::base, Byte, c, d, DUMPBITS, e, inflate_blocks_state::end, GRABBITS, inflate_huft, inflate_mask, LOAD, m, z_stream_s::msg, n, q, r, s, t, Tracevv, uInt, uLong, UNGRAB, UPDATE, inflate_blocks_state::window, z, and z_streamp. 03478 {
03479 inflate_huft *t; /* temporary pointer */
03480 uInt e; /* extra bits or operation */
03481 uLong b; /* bit buffer */
03482 uInt k; /* bits in bit buffer */
03483 Byte *p; /* input data pointer */
03484 uInt n; /* bytes available there */
03485 Byte *q; /* output window write pointer */
03486 uInt m; /* bytes to end of window or read pointer */
03487 uInt ml; /* mask for literal/length tree */
03488 uInt md; /* mask for distance tree */
03489 uInt c; /* bytes to copy */
03490 uInt d; /* distance back to copy from */
03491 Byte *r; /* copy source pointer */
03492
03493 /* load input, output, bit values */
03494 LOAD
03495
03496 /* initialize masks */
03497 ml = inflate_mask[bl];
03498 md = inflate_mask[bd];
03499
03500 /* do until not enough input or output space for fast loop */
03501 do { /* assume called with m >= 258 && n >= 10 */
03502 /* get literal/length code */
03503 GRABBITS(20) /* max bits for literal/length code */
03504 if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
03505 {
03506 DUMPBITS(t->bits)
03507 Tracevv((t->base >= 0x20 && t->base < 0x7f ?
03508 "inflate: * literal '%c'\n" :
03509 "inflate: * literal 0x%02x\n", t->base));
03510 *q++ = (Byte)t->base;
03511 m--;
03512 continue;
03513 }
03514 do {
03515 DUMPBITS(t->bits)
03516 if (e & 16)
03517 {
03518 /* get extra bits for length */
03519 e &= 15;
03520 c = t->base + ((uInt)b & inflate_mask[e]);
03521 DUMPBITS(e)
03522 Tracevv(("inflate: * length %u\n", c));
03523
03524 /* decode distance base of block to copy */
03525 GRABBITS(15); /* max bits for distance code */
03526 e = (t = td + ((uInt)b & md))->exop;
03527 do {
03528 DUMPBITS(t->bits)
03529 if (e & 16)
03530 {
03531 /* get extra bits to add to distance base */
03532 e &= 15;
03533 GRABBITS(e) /* get extra bits (up to 13) */
03534 d = t->base + ((uInt)b & inflate_mask[e]);
03535 DUMPBITS(e)
03536 Tracevv(("inflate: * distance %u\n", d));
03537
03538 /* do the copy */
03539 m -= c;
03540 if ((uInt)(q - s->window) >= d) /* offset before dest */
03541 { /* just copy */
03542 r = q - d;
03543 *q++ = *r++; c--; /* minimum count is three, */
03544 *q++ = *r++; c--; /* so unroll loop a little */
03545 }
03546 else /* else offset after destination */
03547 {
03548 e = d - (uInt)(q - s->window); /* bytes from offset to end */
03549 r = s->end - e; /* pointer to offset */
03550 if (c > e) /* if source crosses, */
03551 {
03552 c -= e; /* copy to end of window */
03553 do {
03554 *q++ = *r++;
03555 } while (--e);
03556 r = s->window; /* copy rest from start of window */
03557 }
03558 }
03559 do { /* copy all or what's left */
03560 *q++ = *r++;
03561 } while (--c);
03562 break;
03563 }
03564 else if ((e & 64) == 0)
03565 {
03566 t += t->base;
03567 e = (t += ((uInt)b & inflate_mask[e]))->exop;
03568 }
03569 else
03570 {
03571 z->msg = (char*)"invalid distance code";
03572 UNGRAB
03573 UPDATE
03574 return Z_DATA_ERROR;
03575 }
03576 } while (1);
03577 break;
03578 }
03579 if ((e & 64) == 0)
03580 {
03581 t += t->base;
03582 if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
03583 {
03584 DUMPBITS(t->bits)
03585 Tracevv((t->base >= 0x20 && t->base < 0x7f ?
03586 "inflate: * literal '%c'\n" :
03587 "inflate: * literal 0x%02x\n", t->base));
03588 *q++ = (Byte)t->base;
03589 m--;
03590 break;
03591 }
03592 }
03593 else if (e & 32)
03594 {
03595 Tracevv(("inflate: * end of block\n"));
03596 UNGRAB
03597 UPDATE
03598 return Z_STREAM_END;
03599 }
03600 else
03601 {
03602 z->msg = (char*)"invalid literal/length code";
03603 UNGRAB
03604 UPDATE
03605 return Z_DATA_ERROR;
03606 }
03607 } while (1);
03608 } while (m >= 258 && n >= 10);
03609
03610 /* not enough input or output--restore pointers and return */
03611 UNGRAB
03612 UPDATE
03613 return Z_OK;
03614 }
|
|
||||||||||||||||
|
Definition at line 2860 of file unzip.c. References z_stream_s::adler, z_stream_s::avail_out, Byte, inflate_blocks_state::check, inflate_blocks_state::checkfn, inflate_blocks_state::end, n, z_stream_s::next_out, p, q, r, inflate_blocks_state::read, s, z_stream_s::total_out, uInt, inflate_blocks_state::window, inflate_blocks_state::write, z, z_streamp, and zmemcpy. 02861 {
02862 uInt n;
02863 Byte *p;
02864 Byte *q;
02865
02866 /* static copies of source and destination pointers */
02867 p = z->next_out;
02868 q = s->read;
02869
02870 /* compute number of bytes to copy as as end of window */
02871 n = (uInt)((q <= s->write ? s->write : s->end) - q);
02872 if (n > z->avail_out) n = z->avail_out;
02873 if (n && r == Z_BUF_ERROR) r = Z_OK;
02874
02875 /* update counters */
02876 z->avail_out -= n;
02877 z->total_out += n;
02878
02879 /* update check information */
02880 if (s->checkfn != Z_NULL)
02881 z->adler = s->check = (*s->checkfn)(s->check, q, n);
02882
02883 /* copy as as end of window */
02884 zmemcpy(p, q, n);
02885 p += n;
02886 q += n;
02887
02888 /* see if more to copy at beginning of window */
02889 if (q == s->end)
02890 {
02891 /* wrap pointers */
02892 q = s->window;
02893 if (s->write == s->end)
02894 s->write = s->window;
02895
02896 /* compute bytes to copy */
02897 n = (uInt)(s->write - q);
02898 if (n > z->avail_out) n = z->avail_out;
02899 if (n && r == Z_BUF_ERROR) r = Z_OK;
02900
02901 /* update counters */
02902 z->avail_out -= n;
02903 z->total_out += n;
02904
02905 /* update check information */
02906 if (s->checkfn != Z_NULL)
02907 z->adler = s->check = (*s->checkfn)(s->check, q, n);
02908
02909 /* copy */
02910 zmemcpy(p, q, n);
02911 p += n;
02912 q += n;
02913 }
02914
02915 /* update pointers */
02916 z->next_out = p;
02917 s->read = q;
02918
02919 /* done */
02920 return r;
02921 }
|
|
||||||||||||||||||||||||
|
Definition at line 3208 of file unzip.c. References c, huft_build(), z_stream_s::msg, r, uInt, v, z, Z_BUF_ERROR, Z_NULL, z_streamp, ZALLOC, and ZFREE. 03214 {
03215 int r;
03216 uInt hn = 0; /* hufts used in space */
03217 uInt *v; /* work area for huft_build */
03218
03219 if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
03220 return Z_MEM_ERROR;
03221 r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,
03222 tb, bb, hp, &hn, v);
03223 if (r == Z_DATA_ERROR)
03224 z->msg = (char*)"oversubscribed dynamic bit lengths tree";
03225 else if (r == Z_BUF_ERROR || *bb == 0)
03226 {
03227 z->msg = (char*)"incomplete dynamic bit lengths tree";
03228 r = Z_DATA_ERROR;
03229 }
03230 ZFREE(z, v);
03231 return r;
03232 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 3235 of file unzip.c. References c, cpdext, cpdist, cplens, cplext, huft_build(), z_stream_s::msg, r, uInt, v, z, Z_OK, z_streamp, ZALLOC, and ZFREE. 03245 {
03246 int r;
03247 uInt hn = 0; /* hufts used in space */
03248 uInt *v; /* work area for huft_build */
03249
03250 /* allocate work area */
03251 if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
03252 return Z_MEM_ERROR;
03253
03254 /* build literal/length tree */
03255 r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
03256 if (r != Z_OK || *bl == 0)
03257 {
03258 if (r == Z_DATA_ERROR)
03259 z->msg = (char*)"oversubscribed literal/length tree";
03260 else if (r != Z_MEM_ERROR)
03261 {
03262 z->msg = (char*)"incomplete literal/length tree";
03263 r = Z_DATA_ERROR;
03264 }
03265 ZFREE(z, v);
03266 return r;
03267 }
03268
03269 /* build distance tree */
03270 r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
03271 if (r != Z_OK || (*bd == 0 && nl > 257))
03272 {
03273 if (r == Z_DATA_ERROR)
03274 z->msg = (char*)"oversubscribed distance tree";
03275 else if (r == Z_BUF_ERROR) {
03276 #ifdef PKZIP_BUG_WORKAROUND
03277 r = Z_OK;
03278 }
03279 #else
03280 z->msg = (char*)"incomplete distance tree";
03281 r = Z_DATA_ERROR;
03282 }
03283 else if (r != Z_MEM_ERROR)
03284 {
03285 z->msg = (char*)"empty distance tree with lengths";
03286 r = Z_DATA_ERROR;
03287 }
03288 ZFREE(z, v);
03289 return r;
03290 #endif
03291 }
03292
03293 /* done */
03294 ZFREE(z, v);
03295 return Z_OK;
03296 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 3450 of file unzip.c. References z_streamp. 03456 {
03457 *bl = fixed_bl;
03458 *bd = fixed_bd;
03459 *tl = fixed_tl;
03460 *td = fixed_td;
03461 return Z_OK;
03462 }
|
|
|
Definition at line 4000 of file unzip.c. References internal_state::blocks, inflate_blocks_free(), z_stream_s::state, Tracev, z, Z_NULL, z_streamp, ZFREE, and z_stream_s::zfree. 04001 {
04002 if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
04003 return Z_STREAM_ERROR;
04004 if (z->state->blocks != Z_NULL)
04005 inflate_blocks_free(z->state->blocks, z);
04006 ZFREE(z, z->state);
04007 z->state = Z_NULL;
04008 Tracev(("inflate: end\n"));
04009 return Z_OK;
04010 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 4014 of file unzip.c. References adler32(), internal_state::blocks, inflate_blocks_new(), inflateEnd(), inflateReset(), z_stream_s::msg, internal_state::nowrap, z_stream_s::opaque, z_stream_s::state, Tracev, uInt, void(), w, internal_state::wbits, z, Z_NULL, z_stream, z_streamp, ZALLOC, z_stream_s::zalloc, z_stream_s::zfree, and ZLIB_VERSION. 04015 {
04016 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
04017 stream_size != sizeof(z_stream))
04018 return Z_VERSION_ERROR;
04019
04020 /* initialize state */
04021 if (z == Z_NULL)
04022 return Z_STREAM_ERROR;
04023 z->msg = Z_NULL;
04024 if (z->zalloc == Z_NULL)
04025 {
04026 z->zalloc = (void *(*)(void *, unsigned, unsigned))zcalloc;
04027 z->opaque = (voidp)0;
04028 }
04029 if (z->zfree == Z_NULL) z->zfree = (void (*)(void *, void *))zcfree;
04030 if ((z->state = (struct internal_state *)
04031 ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
04032 return Z_MEM_ERROR;
04033 z->state->blocks = Z_NULL;
04034
04035 /* handle undocumented nowrap option (no zlib header or check) */
04036 z->state->nowrap = 0;
04037 if (w < 0)
04038 {
04039 w = - w;
04040 z->state->nowrap = 1;
04041 }
04042
04043 /* set window size */
04044 if (w < 8 || w > 15)
04045 {
04046 inflateEnd(z);
04047 return Z_STREAM_ERROR;
04048 }
04049 z->state->wbits = (uInt)w;
04050
04051 /* create inflate_blocks state */
04052 if ((z->state->blocks =
04053 inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
04054 == Z_NULL)
04055 {
04056 inflateEnd(z);
04057 return Z_MEM_ERROR;
04058 }
04059 Tracev(("inflate: allocated\n"));
04060
04061 /* reset state */
04062 inflateReset(z);
04063 return Z_OK;
04064 }
|
Here is the call graph for this function:

|
|
Definition at line 3987 of file unzip.c. References internal_state::blocks, imBLOCKS, inflate_blocks_reset(), internal_state::mode, z_stream_s::msg, internal_state::nowrap, z_stream_s::state, z_stream_s::total_in, z_stream_s::total_out, Tracev, z, Z_NULL, and z_streamp. 03988 {
03989 if (z == Z_NULL || z->state == Z_NULL)
03990 return Z_STREAM_ERROR;
03991 z->total_in = z->total_out = 0;
03992 z->msg = Z_NULL;
03993 z->state->mode = z->state->nowrap ? imBLOCKS : imMETHOD;
03994 inflate_blocks_reset(z->state->blocks, z, Z_NULL);
03995 Tracev(("inflate: reset\n"));
03996 return Z_OK;
03997 }
|
Here is the call graph for this function:

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 1175 of file unzip.c. 01176 {
01177 for (;;)
01178 {
01179 char c1=*(fileName1++);
01180 char c2=*(fileName2++);
01181 if ((c1>='a') && (c1<='z'))
01182 c1 -= 0x20;
01183 if ((c2>='a') && (c2<='z'))
01184 c2 -= 0x20;
01185 if (c1=='\0')
01186 return ((c2=='\0') ? 0 : -1);
01187 if (c2=='\0')
01188 return 1;
01189 if (c1<c2)
01190 return -1;
01191 if (c1>c2)
01192 return 1;
01193 }
01194 }
|
|
|
Definition at line 1408 of file unzip.c. 01409 {
01410 unz_s* s;
01411 if (file==NULL)
01412 return UNZ_PARAMERROR;
01413 s=(unz_s*)file;
01414
01415 if (s->pfile_in_zip_read!=NULL)
01416 unzCloseCurrentFile(file);
01417
01418 fclose(s->file);
01419 TRYFREE(s);
01420 return UNZ_OK;
01421 }
|
|
|
Definition at line 2183 of file unzip.c. 02184 {
02185 int err=UNZ_OK;
02186
02187 unz_s* s;
02188 file_in_zip_read_info_s* pfile_in_zip_read_info;
02189 if (file==NULL)
02190 return UNZ_PARAMERROR;
02191 s=(unz_s*)file;
02192 pfile_in_zip_read_info=s->pfile_in_zip_read;
02193
02194 if (pfile_in_zip_read_info==NULL)
02195 return UNZ_PARAMERROR;
02196
02197 /*
02198 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
02199 {
02200 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
02201 err=UNZ_CRCERROR;
02202 }
02203 */
02204
02205 TRYFREE(pfile_in_zip_read_info->read_buffer);
02206 pfile_in_zip_read_info->read_buffer = NULL;
02207 if (pfile_in_zip_read_info->stream_initialised)
02208 inflateEnd(&pfile_in_zip_read_info->stream);
02209
02210 pfile_in_zip_read_info->stream_initialised = 0;
02211 TRYFREE(pfile_in_zip_read_info);
02212
02213 s->pfile_in_zip_read=NULL;
02214
02215 return err;
02216 }
|
|
|
Definition at line 2107 of file unzip.c. 02108 {
02109 unz_s* s;
02110 file_in_zip_read_info_s* pfile_in_zip_read_info;
02111 if (file==NULL)
02112 return UNZ_PARAMERROR;
02113 s=(unz_s*)file;
02114 pfile_in_zip_read_info=s->pfile_in_zip_read;
02115
02116 if (pfile_in_zip_read_info==NULL)
02117 return UNZ_PARAMERROR;
02118
02119 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
02120 return 1;
02121 else
02122 return 0;
02123 }
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 1622 of file unzip.c. References file, NULL, unz_file_info, and unzlocal_GetCurrentFileInfoInternal(). 01626 {
01627 return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
01628 szFileName,fileNameBufferSize,
01629 extraField,extraFieldBufferSize,
01630 szComment,commentBufferSize);
01631 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1686 of file unzip.c. References file, unz_s::pos_in_central_dir, and s. Referenced by FS_LoadZipFile(). 01687 {
01688 unz_s* s;
01689
01690 if (file==NULL)
01691 return UNZ_PARAMERROR;
01692 s=(unz_s*)file;
01693
01694 *pos = s->pos_in_central_dir;
01695 return UNZ_OK;
01696 }
|
|
||||||||||||||||
|
Definition at line 2224 of file unzip.c. References unz_s::central_pos, unz_s::file, file, fread(), fseek(), unz_s::gi, s, SEEK_SET, unz_global_info_s::size_comment, uInt, and uLong. 02225 {
02226 unz_s* s;
02227 uLong uReadThis ;
02228 if (file==NULL)
02229 return UNZ_PARAMERROR;
02230 s=(unz_s*)file;
02231
02232 uReadThis = uSizeBuf;
02233 if (uReadThis>s->gi.size_comment)
02234 uReadThis = s->gi.size_comment;
02235
02236 if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
02237 return UNZ_ERRNO;
02238
02239 if (uReadThis>0)
02240 {
02241 *szComment='\0';
02242 if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
02243 return UNZ_ERRNO;
02244 }
02245
02246 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
02247 *(szComment+s->gi.size_comment)='\0';
02248 return (int)uReadThis;
02249 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1428 of file unzip.c. 01429 {
01430 unz_s* s;
01431 if (file==NULL)
01432 return UNZ_PARAMERROR;
01433 s=(unz_s*)file;
01434 *pglobal_info=s->gi;
01435 return UNZ_OK;
01436 }
|
|
||||||||||||||||
|
Definition at line 2139 of file unzip.c. 02140 {
02141 unz_s* s;
02142 file_in_zip_read_info_s* pfile_in_zip_read_info;
02143 uInt read_now;
02144 uLong size_to_read;
02145
02146 if (file==NULL)
02147 return UNZ_PARAMERROR;
02148 s=(unz_s*)file;
02149 pfile_in_zip_read_info=s->pfile_in_zip_read;
02150
02151 if (pfile_in_zip_read_info==NULL)
02152 return UNZ_PARAMERROR;
02153
02154 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
02155 pfile_in_zip_read_info->pos_local_extrafield);
02156
02157 if (buf==NULL)
02158 return (int)size_to_read;
02159
02160 if (len>size_to_read)
02161 read_now = (uInt)size_to_read;
02162 else
02163 read_now = (uInt)len ;
02164
02165 if (read_now==0)
02166 return 0;
02167
02168 if (fseek(pfile_in_zip_read_info->file,
02169 pfile_in_zip_read_info->offset_local_extrafield +
02170 pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
02171 return UNZ_ERRNO;
02172
02173 if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
02174 return UNZ_ERRNO;
02175
02176 return (int)read_now;
02177 }
|
|
|
Definition at line 1637 of file unzip.c. 01638 {
01639 int err=UNZ_OK;
01640 unz_s* s;
01641 if (file==NULL)
01642 return UNZ_PARAMERROR;
01643 s=(unz_s*)file;
01644 s->pos_in_central_dir=s->offset_central_dir;
01645 s->num_file=0;
01646 err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
01647 &s->cur_file_info_internal,
01648 NULL,0,NULL,0,NULL,0);
01649 s->current_file_ok = (err == UNZ_OK);
01650 return err;
01651 }
|
|
|
Definition at line 1659 of file unzip.c. 01660 {
01661 unz_s* s;
01662 int err;
01663
01664 if (file==NULL)
01665 return UNZ_PARAMERROR;
01666 s=(unz_s*)file;
01667 if (!s->current_file_ok)
01668 return UNZ_END_OF_LIST_OF_FILE;
01669 if (s->num_file+1==s->gi.number_entry)
01670 return UNZ_END_OF_LIST_OF_FILE;
01671
01672 s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
01673 s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
01674 s->num_file++;
01675 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
01676 &s->cur_file_info_internal,
01677 NULL,0,NULL,0,NULL,0);
01678 s->current_file_ok = (err == UNZ_OK);
01679 return err;
01680 }
|
|
||||||||||||||||||||
|
Definition at line 1777 of file unzip.c. References unz_s::byte_before_the_zipfile, unz_file_info_s::compressed_size, unz_file_info_s::compression_method, unz_file_info_s::crc, unz_s::cur_file_info, unz_s::cur_file_info_internal, err(), unz_s::file, fseek(), unz_file_info_internal_s::offset_curfile, s, SEEK_SET, unz_file_info_s::size_filename, SIZEZIPLOCALHEADER, uLong, unz_file_info_s::uncompressed_size, unzlocal_getLong(), and unzlocal_getShort(). 01780 {
01781 uLong uMagic,uData,uFlags;
01782 uLong size_filename;
01783 uLong size_extra_field;
01784 int err=UNZ_OK;
01785
01786 *piSizeVar = 0;
01787 *poffset_local_extrafield = 0;
01788 *psize_local_extrafield = 0;
01789
01790 if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
01791 s->byte_before_the_zipfile,SEEK_SET)!=0)
01792 return UNZ_ERRNO;
01793
01794
01795 if (err==UNZ_OK) {
01796 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
01797 err=UNZ_ERRNO;
01798 else if (uMagic!=0x04034b50)
01799 err=UNZ_BADZIPFILE;
01800 }
01801 if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
01802 err=UNZ_ERRNO;
01803 /*
01804 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
01805 err=UNZ_BADZIPFILE;
01806 */
01807 if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
01808 err=UNZ_ERRNO;
01809
01810 if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
01811 err=UNZ_ERRNO;
01812 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
01813 err=UNZ_BADZIPFILE;
01814
01815 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
01816 (s->cur_file_info.compression_method!=Z_DEFLATED))
01817 err=UNZ_BADZIPFILE;
01818
01819 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
01820 err=UNZ_ERRNO;
01821
01822 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
01823 err=UNZ_ERRNO;
01824 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
01825 ((uFlags & 8)==0))
01826 err=UNZ_BADZIPFILE;
01827
01828 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
01829 err=UNZ_ERRNO;
01830 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
01831 ((uFlags & 8)==0))
01832 err=UNZ_BADZIPFILE;
01833
01834 if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
01835 err=UNZ_ERRNO;
01836 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
01837 ((uFlags & 8)==0))
01838 err=UNZ_BADZIPFILE;
01839
01840
01841 if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
01842 err=UNZ_ERRNO;
01843 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
01844 err=UNZ_BADZIPFILE;
01845
01846 *piSizeVar += (uInt)size_filename;
01847
01848 if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
01849 err=UNZ_ERRNO;
01850 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
01851 SIZEZIPLOCALHEADER + size_filename;
01852 *psize_local_extrafield = (uInt)size_extra_field;
01853
01854 *piSizeVar += (uInt)size_extra_field;
01855
01856 return err;
01857 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1442 of file unzip.c. References tm_unz_s::tm_hour, tm_unz_s::tm_mday, tm_unz_s::tm_min, tm_unz_s::tm_mon, tm_unz_s::tm_sec, tm_unz, tm_unz_s::tm_year, and uLong. 01443 {
01444 uLong uDate;
01445 uDate = (uLong)(ulDosDate>>16);
01446 ptm->tm_mday = (uInt)(uDate&0x1f) ;
01447 ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
01448 ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
01449
01450 ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
01451 ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
01452 ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
01453 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 1458 of file unzip.c. References unz_s::byte_before_the_zipfile, unz_file_info_s::compressed_size, unz_file_info_s::compression_method, unz_file_info_s::crc, unz_file_info_s::disk_num_start, unz_file_info_s::dosDate, err(), unz_file_info_s::external_fa, unz_s::file, file, unz_file_info_s::flag, fread(), fseek(), unz_file_info_s::internal_fa, unz_file_info_internal_s::offset_curfile, unz_s::pos_in_central_dir, s, SEEK_CUR, SEEK_SET, unz_file_info_s::size_file_comment, unz_file_info_s::size_file_extra, unz_file_info_s::size_filename, unz_file_info_s::tmu_date, uInt, uLong, unz_file_info_s::uncompressed_size, unz_file_info, unz_file_info_internal, unzlocal_DosDateToTmuDate(), unzlocal_getLong(), unzlocal_getShort(), unz_file_info_s::version, and unz_file_info_s::version_needed. 01468 {
01469 unz_s* s;
01470 unz_file_info file_info;
01471 unz_file_info_internal file_info_internal;
01472 int err=UNZ_OK;
01473 uLong uMagic;
01474 long lSeek=0;
01475
01476 if (file==NULL)
01477 return UNZ_PARAMERROR;
01478 s=(unz_s*)file;
01479 if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
01480 err=UNZ_ERRNO;
01481
01482
01483 /* we check the magic */
01484 if (err==UNZ_OK) {
01485 if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
01486 err=UNZ_ERRNO;
01487 else if (uMagic!=0x02014b50)
01488 err=UNZ_BADZIPFILE;
01489 }
01490 if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
01491 err=UNZ_ERRNO;
01492
01493 if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
01494 err=UNZ_ERRNO;
01495
01496 if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
01497 err=UNZ_ERRNO;
01498
01499 if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
01500 err=UNZ_ERRNO;
01501
01502 if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
01503 err=UNZ_ERRNO;
01504
01505 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
01506
01507 if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
01508 err=UNZ_ERRNO;
01509
01510 if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
01511 err=UNZ_ERRNO;
01512
01513 if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
01514 err=UNZ_ERRNO;
01515
01516 if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
01517 err=UNZ_ERRNO;
01518
01519 if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
01520 err=UNZ_ERRNO;
01521
01522 if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
01523 err=UNZ_ERRNO;
01524
01525 if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
01526 err=UNZ_ERRNO;
01527
01528 if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
01529 err=UNZ_ERRNO;
01530
01531 if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
01532 err=UNZ_ERRNO;
01533
01534 if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
01535 err=UNZ_ERRNO;
01536
01537 lSeek+=file_info.size_filename;
01538 if ((err==UNZ_OK) && (szFileName!=NULL))
01539 {
01540 uLong uSizeRead ;
01541 if (file_info.size_filename<fileNameBufferSize)
01542 {
01543 *(szFileName+file_info.size_filename)='\0';
01544 uSizeRead = file_info.size_filename;
01545 }
01546 else
01547 uSizeRead = fileNameBufferSize;
01548
01549 if ((file_info.size_filename>0) && (fileNameBufferSize>0))
01550 if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
01551 err=UNZ_ERRNO;
01552 lSeek -= uSizeRead;
01553 }
01554
01555
01556 if ((err==UNZ_OK) && (extraField!=NULL))
01557 {
01558 uLong uSizeRead ;
01559 if (file_info.size_file_extra<extraFieldBufferSize)
01560 uSizeRead = file_info.size_file_extra;
01561 else
01562 uSizeRead = extraFieldBufferSize;
01563
01564 if (lSeek!=0) {
01565 if (fseek(s->file,lSeek,SEEK_CUR)==0)
01566 lSeek=0;
01567 else
01568 err=UNZ_ERRNO;
01569 }
01570 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) {
01571 if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
01572 err=UNZ_ERRNO;
01573 }
01574 lSeek += file_info.size_file_extra - uSizeRead;
01575 }
01576 else
01577 lSeek+=file_info.size_file_extra;
01578
01579
01580 if ((err==UNZ_OK) && (szComment!=NULL))
01581 {
01582 uLong uSizeRead ;
01583 if (file_info.size_file_comment<commentBufferSize)
01584 {
01585 *(szComment+file_info.size_file_comment)='\0';
01586 uSizeRead = file_info.size_file_comment;
01587 }
01588 else
01589 uSizeRead = commentBufferSize;
01590
01591 if (lSeek!=0) {
01592 if (fseek(s->file,lSeek,SEEK_CUR)==0)
01593 lSeek=0;
01594 else
01595 err=UNZ_ERRNO;
01596 }
01597 if ((file_info.size_file_comment>0) && (commentBufferSize>0)) {
01598 if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
01599 err=UNZ_ERRNO;
01600 }
01601 lSeek+=file_info.size_file_comment - uSizeRead;
01602 }
01603 else
01604 lSeek+=file_info.size_file_comment;
01605
01606 if ((err==UNZ_OK) && (pfile_info!=NULL))
01607 *pfile_info=file_info;
01608
01609 if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
01610 *pfile_info_internal=file_info_internal;
01611
01612 return err;
01613 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1136 of file unzip.c. References fread(), LittleLong(), and v. 01137 {
01138 int v;
01139
01140 fread( &v, sizeof(v), 1, fin );
01141
01142 *pX = LittleLong( v);
01143 return UNZ_OK;
01144
01145 /*
01146 uLong x ;
01147 int i;
01148 int err;
01149
01150 err = unzlocal_getByte(fin,&i);
01151 x = (uLong)i;
01152
01153 if (err==UNZ_OK)
01154 err = unzlocal_getByte(fin,&i);
01155 x += ((uLong)i)<<8;
01156
01157 if (err==UNZ_OK)
01158 err = unzlocal_getByte(fin,&i);
01159 x += ((uLong)i)<<16;
01160
01161 if (err==UNZ_OK)
01162 err = unzlocal_getByte(fin,&i);
01163 x += ((uLong)i)<<24;
01164
01165 if (err==UNZ_OK)
01166 *pX = x;
01167 else
01168 *pX = 0;
01169 return err;
01170 */
01171 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1107 of file unzip.c. References fread(), LittleShort(), and v. 01108 {
01109 short v;
01110
01111 fread( &v, sizeof(v), 1, fin );
01112
01113 *pX = LittleShort( v);
01114 return UNZ_OK;
01115
01116 /*
01117 uLong x ;
01118 int i;
01119 int err;
01120
01121 err = unzlocal_getByte(fin,&i);
01122 x = (uLong)i;
01123
01124 if (err==UNZ_OK)
01125 err = unzlocal_getByte(fin,&i);
01126 x += ((uLong)i)<<8;
01127
01128 if (err==UNZ_OK)
01129 *pX = x;
01130 else
01131 *pX = 0;
01132 return err;
01133 */
01134 }
|
Here is the call graph for this function:

|
|
Definition at line 1233 of file unzip.c. References ALLOC, BUFREADCOMMENT, fread(), fseek(), ftell(), i, SEEK_END, SEEK_SET, TRYFREE, uInt, and uLong. 01234 {
01235 unsigned char* buf;
01236 uLong uSizeFile;
01237 uLong uBackRead;
01238 uLong uMaxBack=0xffff; /* maximum size of global comment */
01239 uLong uPosFound=0;
01240
01241 if (fseek(fin,0,SEEK_END) != 0)
01242 return 0;
01243
01244
01245 uSizeFile = ftell( fin );
01246
01247 if (uMaxBack>uSizeFile)
01248 uMaxBack = uSizeFile;
01249
01250 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
01251 if (buf==NULL)
01252 return 0;
01253
01254 uBackRead = 4;
01255 while (uBackRead<uMaxBack)
01256 {
01257 uLong uReadSize,uReadPos ;
01258 int i;
01259 if (uBackRead+BUFREADCOMMENT>uMaxBack)
01260 uBackRead = uMaxBack;
01261 else
01262 uBackRead+=BUFREADCOMMENT;
01263 uReadPos = uSizeFile-uBackRead ;
01264
01265 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
01266 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
01267 if (fseek(fin,uReadPos,SEEK_SET)!=0)
01268 break;
01269
01270 if (fread(buf,(uInt)uReadSize,1,fin)!=1)
01271 break;
01272
01273 for (i=(int)uReadSize-3; (i--)>0;)
01274 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
01275 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
01276 {
01277 uPosFound = uReadPos+i;
01278 break;
01279 }
01280
01281 if (uPosFound!=0)
01282 break;
01283 }
01284 TRYFREE(buf);
01285 return uPosFound;
01286 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1727 of file unzip.c. 01728 {
01729 unz_s* s;
01730 int err;
01731
01732
01733 uLong num_fileSaved;
01734 uLong pos_in_central_dirSaved;
01735
01736
01737 if (file==NULL)
01738 return UNZ_PARAMERROR;
01739
01740 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
01741 return UNZ_PARAMERROR;
01742
01743 s=(unz_s*)file;
01744 if (!s->current_file_ok)
01745 return UNZ_END_OF_LIST_OF_FILE;
01746
01747 num_fileSaved = s->num_file;
01748 pos_in_central_dirSaved = s->pos_in_central_dir;
01749
01750 err = unzGoToFirstFile(file);
01751
01752 while (err == UNZ_OK)
01753 {
01754 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
01755 unzGetCurrentFileInfo(file,NULL,
01756 szCurrentFileName,sizeof(szCurrentFileName)-1,
01757 NULL,0,NULL,0);
01758 if (unzStringFileNameCompare(szCurrentFileName,
01759 szFileName,iCaseSensitivity)==0)
01760 return UNZ_OK;
01761 err = unzGoToNextFile(file);
01762 }
01763
01764 s->num_file = num_fileSaved ;
01765 s->pos_in_central_dir = pos_in_central_dirSaved ;
01766 return err;
01767 }
|
|
|
Definition at line 1313 of file unzip.c. 01314 {
01315 unz_s us;
01316 unz_s *s;
01317 uLong central_pos,uL;
01318 FILE * fin ;
01319
01320 uLong number_disk; /* number of the current dist, used for
01321 spaning ZIP, unsupported, always 0*/
01322 uLong number_disk_with_CD; /* number the the disk with central dir, used
01323 for spaning ZIP, unsupported, always 0*/
01324 uLong number_entry_CD; /* total number of entries in
01325 the central dir
01326 (same than number_entry on nospan) */
01327
01328 int err=UNZ_OK;
01329
01330 fin=fopen(path,"rb");
01331 if (fin==NULL)
01332 return NULL;
01333
01334 central_pos = unzlocal_SearchCentralDir(fin);
01335 if (central_pos==0)
01336 err=UNZ_ERRNO;
01337
01338 if (fseek(fin,central_pos,SEEK_SET)!=0)
01339 err=UNZ_ERRNO;
01340
01341 /* the signature, already checked */
01342 if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
01343 err=UNZ_ERRNO;
01344
01345 /* number of this disk */
01346 if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
01347 err=UNZ_ERRNO;
01348
01349 /* number of the disk with the start of the central directory */
01350 if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
01351 err=UNZ_ERRNO;
01352
01353 /* total number of entries in the central dir on this disk */
01354 if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
01355 err=UNZ_ERRNO;
01356
01357 /* total number of entries in the central dir */
01358 if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
01359 err=UNZ_ERRNO;
01360
01361 if ((number_entry_CD!=us.gi.number_entry) ||
01362 (number_disk_with_CD!=0) ||
01363 (number_disk!=0))
01364 err=UNZ_BADZIPFILE;
01365
01366 /* size of the central directory */
01367 if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
01368 err=UNZ_ERRNO;
01369
01370 /* offset of start of central directory with respect to the
01371 starting disk number */
01372 if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
01373 err=UNZ_ERRNO;
01374
01375 /* zipfile comment length */
01376 if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
01377 err=UNZ_ERRNO;
01378
01379 if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
01380 (err==UNZ_OK))
01381 err=UNZ_BADZIPFILE;
01382
01383 if (err!=UNZ_OK)
01384 {
01385 fclose(fin);
01386 return NULL;
01387 }
01388
01389 us.file=fin;
01390 us.byte_before_the_zipfile = central_pos -
01391 (us.offset_central_dir+us.size_central_dir);
01392 us.central_pos = central_pos;
01393 us.pfile_in_zip_read = NULL;
01394
01395
01396 s=(unz_s*)ALLOC(sizeof(unz_s));
01397 *s=us;
01398 // unzGoToFirstFile((unzFile)s);
01399 return (unzFile)s;
01400 }
|
|
|
Definition at line 1863 of file unzip.c. 01864 {
01865 int err=UNZ_OK;
01866 int Store;
01867 uInt iSizeVar;
01868 unz_s* s;
01869 file_in_zip_read_info_s* pfile_in_zip_read_info;
01870 uLong offset_local_extrafield; /* offset of the static extra field */
01871 uInt size_local_extrafield; /* size of the static extra field */
01872
01873 if (file==NULL)
01874 return UNZ_PARAMERROR;
01875 s=(unz_s*)file;
01876 if (!s->current_file_ok)
01877 return UNZ_PARAMERROR;
01878
01879 if (s->pfile_in_zip_read != NULL)
01880 unzCloseCurrentFile(file);
01881
01882 if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
01883 &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
01884 return UNZ_BADZIPFILE;
01885
01886 pfile_in_zip_read_info = (file_in_zip_read_info_s*)
01887 ALLOC(sizeof(file_in_zip_read_info_s));
01888 if (pfile_in_zip_read_info==NULL)
01889 return UNZ_INTERNALERROR;
01890
01891 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
01892 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
01893 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
01894 pfile_in_zip_read_info->pos_local_extrafield=0;
01895
01896 if (pfile_in_zip_read_info->read_buffer==NULL)
01897 {
01898 TRYFREE(pfile_in_zip_read_info);
01899 return UNZ_INTERNALERROR;
01900 }
01901
01902 pfile_in_zip_read_info->stream_initialised=0;
01903
01904 if ((s->cur_file_info.compression_method!=0) &&
01905 (s->cur_file_info.compression_method!=Z_DEFLATED))
01906 err=UNZ_BADZIPFILE;
01907 Store = s->cur_file_info.compression_method==0;
01908
01909 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
01910 pfile_in_zip_read_info->crc32=0;
01911 pfile_in_zip_read_info->compression_method =
01912 s->cur_file_info.compression_method;
01913 pfile_in_zip_read_info->file=s->file;
01914 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
01915
01916 pfile_in_zip_read_info->stream.total_out = 0;
01917
01918 if (!Store)
01919 {
01920 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
01921 pfile_in_zip_read_info->stream.zfree = (free_func)0;
01922 pfile_in_zip_read_info->stream.opaque = (voidp)0;
01923
01924 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
01925 if (err == Z_OK)
01926 pfile_in_zip_read_info->stream_initialised=1;
01927 /* windowBits is passed < 0 to tell that there is no zlib header.
01928 * Note that in this case inflate *requires* an extra "dummy" byte
01929 * after the compressed stream in order to complete decompression and
01930 * return Z_STREAM_END.
01931 * In unzip, i don't wait absolutely Z_STREAM_END because I known the
01932 * size of both compressed and uncompressed data
01933 */
01934 }
01935 pfile_in_zip_read_info->rest_read_compressed =
01936 s->cur_file_info.compressed_size ;
01937 pfile_in_zip_read_info->rest_read_uncompressed =
01938 s->cur_file_info.uncompressed_size ;
01939
01940
01941 pfile_in_zip_read_info->pos_in_zipfile =
01942 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
01943 iSizeVar;
01944
01945 pfile_in_zip_read_info->stream.avail_in = (uInt)0;
01946
01947
01948 s->pfile_in_zip_read = pfile_in_zip_read_info;
01949 return UNZ_OK;
01950 }
|
|
||||||||||||||||
|
Definition at line 1963 of file unzip.c. 01964 {
01965 int err=UNZ_OK;
01966 uInt iRead = 0;
01967 unz_s* s;
01968 file_in_zip_read_info_s* pfile_in_zip_read_info;
01969 if (file==NULL)
01970 return UNZ_PARAMERROR;
01971 s=(unz_s*)file;
01972 pfile_in_zip_read_info=s->pfile_in_zip_read;
01973
01974 if (pfile_in_zip_read_info==NULL)
01975 return UNZ_PARAMERROR;
01976
01977
01978 if ((pfile_in_zip_read_info->read_buffer == NULL))
01979 return UNZ_END_OF_LIST_OF_FILE;
01980 if (len==0)
01981 return 0;
01982
01983 pfile_in_zip_read_info->stream.next_out = (Byte*)buf;
01984
01985 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
01986
01987 if (len>pfile_in_zip_read_info->rest_read_uncompressed)
01988 pfile_in_zip_read_info->stream.avail_out =
01989 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
01990
01991 while (pfile_in_zip_read_info->stream.avail_out>0)
01992 {
01993 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
01994 (pfile_in_zip_read_info->rest_read_compressed>0))
01995 {
01996 uInt uReadThis = UNZ_BUFSIZE;
01997 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
01998 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
01999 if (uReadThis == 0)
02000 return UNZ_EOF;
02001 if (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed)
02002 if (fseek(pfile_in_zip_read_info->file,
02003 pfile_in_zip_read_info->pos_in_zipfile +
02004 pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
02005 return UNZ_ERRNO;
02006 if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
02007 pfile_in_zip_read_info->file)!=1)
02008 return UNZ_ERRNO;
02009 pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
02010
02011 pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
02012
02013 pfile_in_zip_read_info->stream.next_in =
02014 (Byte*)pfile_in_zip_read_info->read_buffer;
02015 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
02016 }
02017
02018 if (pfile_in_zip_read_info->compression_method==0)
02019 {
02020 uInt uDoCopy,i ;
02021 if (pfile_in_zip_read_info->stream.avail_out <
02022 pfile_in_zip_read_info->stream.avail_in)
02023 uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
02024 else
02025 uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
02026
02027 for (i=0;i<uDoCopy;i++)
02028 *(pfile_in_zip_read_info->stream.next_out+i) =
02029 *(pfile_in_zip_read_info->stream.next_in+i);
02030
02031 // pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
02032 // pfile_in_zip_read_info->stream.next_out,
02033 // uDoCopy);
02034 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
02035 pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
02036 pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
02037 pfile_in_zip_read_info->stream.next_out += uDoCopy;
02038 pfile_in_zip_read_info->stream.next_in += uDoCopy;
02039 pfile_in_zip_read_info->stream.total_out += uDoCopy;
02040 iRead += uDoCopy;
02041 }
02042 else
02043 {
02044 uLong uTotalOutBefore,uTotalOutAfter;
02045 const Byte *bufBefore;
02046 uLong uOutThis;
02047 int flush=Z_SYNC_FLUSH;
02048
02049 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
02050 bufBefore = pfile_in_zip_read_info->stream.next_out;
02051
02052 /*
02053 if ((pfile_in_zip_read_info->rest_read_uncompressed ==
02054 pfile_in_zip_read_info->stream.avail_out) &&
02055 (pfile_in_zip_read_info->rest_read_compressed == 0))
02056 flush = Z_FINISH;
02057 */
02058 err=inflate(&pfile_in_zip_read_info->stream,flush);
02059
02060 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
02061 uOutThis = uTotalOutAfter-uTotalOutBefore;
02062
02063 // pfile_in_zip_read_info->crc32 =
02064 // crc32(pfile_in_zip_read_info->crc32,bufBefore,
02065 // (uInt)(uOutThis));
02066
02067 pfile_in_zip_read_info->rest_read_uncompressed -=
02068 uOutThis;
02069
02070 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
02071
02072 if (err==Z_STREAM_END)
02073 return (iRead==0) ? UNZ_EOF : iRead;
02074 if (err!=Z_OK)
02075 break;
02076 }
02077 }
02078
02079 if (err==Z_OK)
02080 return iRead;
02081 return err;
02082 }
|
|
||||||||||||
|
Definition at line 1288 of file unzip.c. 01289 {
01290 unz_s *s;
01291 FILE * fin;
01292
01293 fin=fopen(path,"rb");
01294 if (fin==NULL)
01295 return NULL;
01296
01297 s=(unz_s*)ALLOC(sizeof(unz_s));
01298 Com_Memcpy(s, (unz_s*)file, sizeof(unz_s));
01299
01300 s->file = fin;
01301 return (unzFile)s;
01302 }
|
|
||||||||||||
|
Definition at line 1702 of file unzip.c. References unz_s::cur_file_info, unz_s::cur_file_info_internal, unz_s::current_file_ok, err(), file, NULL, unz_s::pos_in_central_dir, s, and unzlocal_GetCurrentFileInfoInternal(). Referenced by FS_FOpenFileRead(), and FS_Seek(). 01703 {
01704 unz_s* s;
01705 int err;
01706
01707 if (file==NULL)
01708 return UNZ_PARAMERROR;
01709 s=(unz_s*)file;
01710
01711 s->pos_in_central_dir = pos;
01712 err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
01713 &s->cur_file_info_internal,
01714 NULL,0,NULL,0,NULL,0);
01715 s->current_file_ok = (err == UNZ_OK);
01716 return UNZ_OK;
01717 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1216 of file unzip.c. 01217 {
01218 if (iCaseSensitivity==0)
01219 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
01220
01221 if (iCaseSensitivity==1)
01222 return strcmp(fileName1,fileName2);
01223
01224 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
01225 }
|
|
|
Definition at line 2088 of file unzip.c. 02089 {
02090 unz_s* s;
02091 file_in_zip_read_info_s* pfile_in_zip_read_info;
02092 if (file==NULL)
02093 return UNZ_PARAMERROR;
02094 s=(unz_s*)file;
02095 pfile_in_zip_read_info=s->pfile_in_zip_read;
02096
02097 if (pfile_in_zip_read_info==NULL)
02098 return UNZ_PARAMERROR;
02099
02100 return (long)pfile_in_zip_read_info->stream.total_out;
02101 }
|
|
||||||||||||||||
|
Definition at line 4287 of file unzip.c. References voidp, and Z_Malloc(). 04288 {
04289 if (opaque) items += size - size; /* make compiler happy */
04290 return (voidp)Z_Malloc(items*size);
04291 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 4293 of file unzip.c. References ptr(), and Z_Free(). 04294 {
04295 Z_Free(ptr);
04296 if (opaque) return; /* make compiler happy */
04297 }
|
Here is the call graph for this function:

|
|
Initial value: {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}
Definition at line 2298 of file unzip.c. Referenced by inflate_blocks(). |
|
|
Initial value: {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13}
Definition at line 2966 of file unzip.c. Referenced by inflate_trees_dynamic(). |
|
|
Initial value: {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577}
Definition at line 2962 of file unzip.c. Referenced by inflate_trees_dynamic(). |
|
|
Initial value: {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}
Definition at line 2955 of file unzip.c. Referenced by inflate_trees_dynamic(). |
|
|
Initial value: {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}
Definition at line 2959 of file unzip.c. Referenced by inflate_trees_dynamic(). |
|
|
|
|
|
|
|
|
Initial value: {
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
}
|
|
|
|
|
|
Initial value:
" inflate 1.1.3 Copyright 1995-1998 Mark Adler "
|
|
|
Initial value: {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
}
Definition at line 2852 of file unzip.c. Referenced by inflate_blocks(), inflate_codes(), and inflate_fast(). |
1.3.9.1