NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
zip.cpp File Reference
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "zip.h"
Include dependency graph for zip.cpp:

Go to the source code of this file.

Classes

struct  config
 
struct  ct_data
 
struct  tree_desc
 
class  TTreeState
 
class  TBitState
 
class  TDeflateState
 
struct  iztimes
 
struct  zlist
 
struct  TState
 
class  TZip
 
struct  TZipHandleData
 

Macros

#define EOF   (-1)
 
#define ZE_MISS   -1
 
#define ZE_OK   0
 
#define ZE_EOF   2
 
#define ZE_FORM   3
 
#define ZE_MEM   4
 
#define ZE_LOGIC   5
 
#define ZE_BIG   6
 
#define ZE_NOTE   7
 
#define ZE_TEST   8
 
#define ZE_ABORT   9
 
#define ZE_TEMP   10
 
#define ZE_READ   11
 
#define ZE_NONE   12
 
#define ZE_NAME   13
 
#define ZE_WRITE   14
 
#define ZE_CREAT   15
 
#define ZE_PARMS   16
 
#define ZE_OPEN   18
 
#define ZE_MAXERR   18
 
#define UNKNOWN   (-1)
 
#define BINARY   0
 
#define ASCII   1
 
#define BEST   -1
 
#define STORE   0
 
#define DEFLATE   8
 
#define CRCVAL_INITIAL   0L
 
#define MSDOS_HIDDEN_ATTR   0x02
 
#define MSDOS_DIR_ATTR   0x10
 
#define LOCHEAD   26
 
#define CENHEAD   42
 
#define ENDHEAD   18
 
#define EB_HEADSIZE   4 /* length of a extra field block header */
 
#define EB_LEN   2 /* offset of data length field in header */
 
#define EB_UT_MINLEN   1 /* minimal UT field contains Flags byte */
 
#define EB_UT_FLAGS   0 /* byte offset of Flags field */
 
#define EB_UT_TIME1   1 /* byte offset of 1st time value */
 
#define EB_UT_FL_MTIME   (1 << 0) /* mtime present */
 
#define EB_UT_FL_ATIME   (1 << 1) /* atime present */
 
#define EB_UT_FL_CTIME   (1 << 2) /* ctime present */
 
#define EB_UT_LEN(n)   (EB_UT_MINLEN + 4 * (n))
 
#define EB_L_UT_SIZE   (EB_HEADSIZE + EB_UT_LEN(3))
 
#define EB_C_UT_SIZE   (EB_HEADSIZE + EB_UT_LEN(1))
 
#define PUTSH(a, f)   {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);}
 
#define PUTLG(a, f)   {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))}
 
#define LOCSIG   0x04034b50L
 
#define CENSIG   0x02014b50L
 
#define ENDSIG   0x06054b50L
 
#define EXTLOCSIG   0x08074b50L
 
#define MIN_MATCH   3
 
#define MAX_MATCH   258
 
#define WSIZE   (0x8000)
 
#define MIN_LOOKAHEAD   (MAX_MATCH+MIN_MATCH+1)
 
#define MAX_DIST   (WSIZE-MIN_LOOKAHEAD)
 
#define ZIP_HANDLE   1
 
#define ZIP_FILENAME   2
 
#define ZIP_MEMORY   3
 
#define ZIP_FOLDER   4
 
#define MAX_BITS   15
 
#define MAX_BL_BITS   7
 
#define LENGTH_CODES   29
 
#define LITERALS   256
 
#define END_BLOCK   256
 
#define L_CODES   (LITERALS+1+LENGTH_CODES)
 
#define D_CODES   30
 
#define BL_CODES   19
 
#define STORED_BLOCK   0
 
#define STATIC_TREES   1
 
#define DYN_TREES   2
 
#define LIT_BUFSIZE   0x8000
 
#define DIST_BUFSIZE   LIT_BUFSIZE
 
#define REP_3_6   16
 
#define REPZ_3_10   17
 
#define REPZ_11_138   18
 
#define HEAP_SIZE   (2*L_CODES+1)
 
#define Buf_size   (8 * 2*sizeof(char))
 
#define PUTSHORT(state, w)
 
#define PUTBYTE(state, b)
 
#define HASH_BITS   15
 
#define HASH_SIZE   (unsigned)(1<<HASH_BITS)
 
#define HASH_MASK   (HASH_SIZE-1)
 
#define WMASK   (WSIZE-1)
 
#define NIL   0
 
#define FAST   4
 
#define SLOW   2
 
#define TOO_FAR   4096
 
#define EQUAL   0
 
#define H_SHIFT   ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
 
#define max_insert_length   max_lazy_match
 
#define send_code(state, c, tree)   send_bits(state, tree[c].fc.code, tree[c].dl.len)
 
#define d_code(dist)   ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)])
 
#define Max(a, b)   (a >= b ? a : b)
 
#define SMALLEST   1
 
#define pqremove(tree, top)
 
#define smaller(tree, n, m)
 
#define UPDATE_HASH(h, c)   (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
 
#define INSERT_STRING(s, match_head)
 
#define check_match(state, start, match, length)
 
#define FLUSH_BLOCK(state, eof)
 
#define CRC32(c, b)   (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
 
#define DO1(buf)   crc = CRC32(crc, *buf++)
 
#define DO2(buf)   DO1(buf); DO1(buf)
 
#define DO4(buf)   DO2(buf); DO2(buf)
 
#define DO8(buf)   DO4(buf); DO4(buf)
 

Typedefs

typedef unsigned char uch
 
typedef unsigned short ush
 
typedef unsigned long ulg
 
typedef size_t extent
 
typedef unsigned Pos
 
typedef unsigned IPos
 
typedef struct config config
 
typedef struct ct_data ct_data
 
typedef struct tree_desc tree_desc
 
typedef __int64 lutime_t
 
typedef struct iztimes iztimes
 
typedef struct zlist TZipFileInfo
 
typedef unsigned(* READFUNC) (TState &state, char *buf, unsigned size)
 
typedef unsigned(* FLUSHFUNC) (void *param, const char *buf, unsigned *size)
 
typedef unsigned(* WRITEFUNC) (void *param, const char *buf, unsigned size)
 

Functions

void Assert (TState &state, bool cond, const char *msg)
 
void __cdecl Trace (const char *x,...)
 
void __cdecl Tracec (bool, const char *x,...)
 
void init_block (TState &)
 
void pqdownheap (TState &, ct_data *tree, int k)
 
void gen_bitlen (TState &, tree_desc *desc)
 
void gen_codes (TState &state, ct_data *tree, int max_code)
 
void build_tree (TState &, tree_desc *desc)
 
void scan_tree (TState &, ct_data *tree, int max_code)
 
void send_tree (TState &state, ct_data *tree, int max_code)
 
int build_bl_tree (TState &)
 
void send_all_trees (TState &state, int lcodes, int dcodes, int blcodes)
 
void compress_block (TState &state, ct_data *ltree, ct_data *dtree)
 
void set_file_type (TState &)
 
void send_bits (TState &state, int value, int length)
 
unsigned bi_reverse (unsigned code, int len)
 
void bi_windup (TState &state)
 
void copy_block (TState &state, char *buf, unsigned len, int header)
 
void ct_init (TState &state, ush *attr)
 
ulg flush_block (TState &state, char *buf, ulg stored_len, int eof)
 
int ct_tally (TState &state, int dist, int lc)
 
void bi_init (TState &state, char *tgt_buf, unsigned tgt_size, int flsh_allowed)
 
void fill_window (TState &state)
 
ulg deflate_fast (TState &state)
 
int longest_match (TState &state, IPos cur_match)
 
void lm_init (TState &state, int pack_level, ush *flags)
 
ulg deflate (TState &state)
 
int putlocal (struct zlist far *z, WRITEFUNC wfunc, void *param)
 
int putextended (struct zlist far *z, WRITEFUNC wfunc, void *param)
 
int putcentral (struct zlist far *z, WRITEFUNC wfunc, void *param)
 
int putend (int n, ulg s, ulg c, extent m, char *z, WRITEFUNC wfunc, void *param)
 
ulg crc32 (ulg crc, const uch *buf, extent len)
 
void update_keys (unsigned long *keys, char c)
 
char decrypt_byte (unsigned long *keys)
 
char zencode (unsigned long *keys, char c)
 
bool HasZipSuffix (const TCHAR *fn)
 
lutime_t filetime2timet (const FILETIME ft)
 
void filetime2dosdatetime (const FILETIME ft, WORD *dosdate, WORD *dostime)
 
ZRESULT GetFileInfo (HANDLE hf, ulg *attr, long *size, iztimes *times, ulg *timestamp)
 
unsigned int FormatZipMessageZ (ZRESULT code, char *buf, unsigned int len)
 
HZIP CreateZipInternal (void *z, unsigned int len, DWORD flags, const char *password)
 
HZIP CreateZipHandle (HANDLE h, const char *password)
 
HZIP CreateZip (const TCHAR *fn, const char *password)
 
HZIP CreateZip (void *z, unsigned int len, const char *password)
 
ZRESULT ZipAddInternal (HZIP hz, const TCHAR *dstzn, void *src, unsigned int len, DWORD flags)
 
ZRESULT ZipAdd (HZIP hz, const TCHAR *dstzn, const TCHAR *fn)
 
ZRESULT ZipAdd (HZIP hz, const TCHAR *dstzn, void *src, unsigned int len)
 
ZRESULT ZipAddHandle (HZIP hz, const TCHAR *dstzn, HANDLE h)
 
ZRESULT ZipAddHandle (HZIP hz, const TCHAR *dstzn, HANDLE h, unsigned int len)
 
ZRESULT ZipAddFolder (HZIP hz, const TCHAR *dstzn)
 
ZRESULT ZipGetMemory (HZIP hz, void **buf, unsigned long *len)
 
ZRESULT CloseZipZ (HZIP hz)
 
bool IsZipHandleZ (HZIP hz)
 

Variables

const int extra_lbits [LENGTH_CODES] = {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}
 
const int extra_dbits [D_CODES] = {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}
 
const int extra_blbits [BL_CODES] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7}
 
const uch bl_order [BL_CODES] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}
 
const config configuration_table [10]
 
const ulg crc_table [256]
 
bool has_seeded = false
 
ZRESULT lasterrorZ = ZR_OK
 

Macro Definition Documentation

◆ ASCII

#define ASCII   1

Definition at line 107 of file zip.cpp.

◆ BEST

#define BEST   -1

Definition at line 109 of file zip.cpp.

◆ BINARY

#define BINARY   0

Definition at line 106 of file zip.cpp.

◆ BL_CODES

#define BL_CODES   19

Definition at line 205 of file zip.cpp.

◆ Buf_size

#define Buf_size   (8 * 2*sizeof(char))

Definition at line 254 of file zip.cpp.

◆ CENHEAD

#define CENHEAD   42

Definition at line 121 of file zip.cpp.

◆ CENSIG

#define CENSIG   0x02014b50L

Definition at line 146 of file zip.cpp.

◆ check_match

#define check_match (   state,
  start,
  match,
  length 
)

Definition at line 1808 of file zip.cpp.

◆ CRC32

#define CRC32 (   c,
 
)    (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))

Definition at line 2283 of file zip.cpp.

◆ CRCVAL_INITIAL

#define CRCVAL_INITIAL   0L

Definition at line 113 of file zip.cpp.

◆ d_code

#define d_code (   dist)    ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)])

Definition at line 676 of file zip.cpp.

◆ D_CODES

#define D_CODES   30

Definition at line 202 of file zip.cpp.

◆ DEFLATE

#define DEFLATE   8

Definition at line 111 of file zip.cpp.

◆ DIST_BUFSIZE

#define DIST_BUFSIZE   LIT_BUFSIZE

Definition at line 215 of file zip.cpp.

◆ DO1

#define DO1 (   buf)    crc = CRC32(crc, *buf++)

Definition at line 2284 of file zip.cpp.

◆ DO2

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

Definition at line 2285 of file zip.cpp.

◆ DO4

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

Definition at line 2286 of file zip.cpp.

◆ DO8

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

Definition at line 2287 of file zip.cpp.

◆ DYN_TREES

#define DYN_TREES   2

Definition at line 211 of file zip.cpp.

◆ EB_C_UT_SIZE

#define EB_C_UT_SIZE   (EB_HEADSIZE + EB_UT_LEN(1))

Definition at line 135 of file zip.cpp.

◆ EB_HEADSIZE

#define EB_HEADSIZE   4 /* length of a extra field block header */

Definition at line 125 of file zip.cpp.

◆ EB_L_UT_SIZE

#define EB_L_UT_SIZE   (EB_HEADSIZE + EB_UT_LEN(3))

Definition at line 134 of file zip.cpp.

◆ EB_LEN

#define EB_LEN   2 /* offset of data length field in header */

Definition at line 126 of file zip.cpp.

◆ EB_UT_FL_ATIME

#define EB_UT_FL_ATIME   (1 << 1) /* atime present */

Definition at line 131 of file zip.cpp.

◆ EB_UT_FL_CTIME

#define EB_UT_FL_CTIME   (1 << 2) /* ctime present */

Definition at line 132 of file zip.cpp.

◆ EB_UT_FL_MTIME

#define EB_UT_FL_MTIME   (1 << 0) /* mtime present */

Definition at line 130 of file zip.cpp.

◆ EB_UT_FLAGS

#define EB_UT_FLAGS   0 /* byte offset of Flags field */

Definition at line 128 of file zip.cpp.

◆ EB_UT_LEN

#define EB_UT_LEN (   n)    (EB_UT_MINLEN + 4 * (n))

Definition at line 133 of file zip.cpp.

◆ EB_UT_MINLEN

#define EB_UT_MINLEN   1 /* minimal UT field contains Flags byte */

Definition at line 127 of file zip.cpp.

◆ EB_UT_TIME1

#define EB_UT_TIME1   1 /* byte offset of 1st time value */

Definition at line 129 of file zip.cpp.

◆ END_BLOCK

#define END_BLOCK   256

Definition at line 196 of file zip.cpp.

◆ ENDHEAD

#define ENDHEAD   18

Definition at line 122 of file zip.cpp.

◆ ENDSIG

#define ENDSIG   0x06054b50L

Definition at line 147 of file zip.cpp.

◆ EOF

#define EOF   (-1)

Definition at line 76 of file zip.cpp.

◆ EQUAL

#define EQUAL   0

Definition at line 294 of file zip.cpp.

◆ EXTLOCSIG

#define EXTLOCSIG   0x08074b50L

Definition at line 148 of file zip.cpp.

◆ FAST

#define FAST   4

Definition at line 285 of file zip.cpp.

◆ FLUSH_BLOCK

#define FLUSH_BLOCK (   state,
  eof 
)
Value:
flush_block(state,state.ds.block_start >= 0L ? (char*)&state.ds.window[(unsigned)state.ds.block_start] : \
(char*)NULL, (long)state.ds.strstart - state.ds.block_start, (eof))
ulg flush_block(TState &state, char *buf, ulg stored_len, int eof)
Definition: zip.cpp:1265

Definition at line 1918 of file zip.cpp.

◆ H_SHIFT

#define H_SHIFT   ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)

Definition at line 301 of file zip.cpp.

◆ HASH_BITS

#define HASH_BITS   15

Definition at line 274 of file zip.cpp.

◆ HASH_MASK

#define HASH_MASK   (HASH_SIZE-1)

Definition at line 278 of file zip.cpp.

◆ HASH_SIZE

#define HASH_SIZE   (unsigned)(1<<HASH_BITS)

Definition at line 277 of file zip.cpp.

◆ HEAP_SIZE

#define HEAP_SIZE   (2*L_CODES+1)

Definition at line 246 of file zip.cpp.

◆ INSERT_STRING

#define INSERT_STRING (   s,
  match_head 
)
Value:
(UPDATE_HASH(state.ds.ins_h, state.ds.window[(s) + (MIN_MATCH-1)]), \
state.ds.prev[(s) & WMASK] = match_head = state.ds.head[state.ds.ins_h], \
state.ds.head[state.ds.ins_h] = (s))
#define MIN_MATCH
Definition: zip.cpp:151
#define UPDATE_HASH(h, c)
Definition: zip.cpp:1623
#define WMASK
Definition: zip.cpp:279

Definition at line 1633 of file zip.cpp.

◆ L_CODES

#define L_CODES   (LITERALS+1+LENGTH_CODES)

Definition at line 199 of file zip.cpp.

◆ LENGTH_CODES

#define LENGTH_CODES   29

Definition at line 190 of file zip.cpp.

◆ LIT_BUFSIZE

#define LIT_BUFSIZE   0x8000

Definition at line 214 of file zip.cpp.

◆ LITERALS

#define LITERALS   256

Definition at line 193 of file zip.cpp.

◆ LOCHEAD

#define LOCHEAD   26

Definition at line 120 of file zip.cpp.

◆ LOCSIG

#define LOCSIG   0x04034b50L

Definition at line 145 of file zip.cpp.

◆ Max

#define Max (   a,
 
)    (a >= b ? a : b)

Definition at line 680 of file zip.cpp.

◆ MAX_BITS

#define MAX_BITS   15

Definition at line 184 of file zip.cpp.

◆ MAX_BL_BITS

#define MAX_BL_BITS   7

Definition at line 187 of file zip.cpp.

◆ MAX_DIST

#define MAX_DIST   (WSIZE-MIN_LOOKAHEAD)

Definition at line 167 of file zip.cpp.

◆ max_insert_length

#define max_insert_length   max_lazy_match

Definition at line 307 of file zip.cpp.

◆ MAX_MATCH

#define MAX_MATCH   258

Definition at line 152 of file zip.cpp.

◆ MIN_LOOKAHEAD

#define MIN_LOOKAHEAD   (MAX_MATCH+MIN_MATCH+1)

Definition at line 162 of file zip.cpp.

◆ MIN_MATCH

#define MIN_MATCH   3

Definition at line 151 of file zip.cpp.

◆ MSDOS_DIR_ATTR

#define MSDOS_DIR_ATTR   0x10

Definition at line 117 of file zip.cpp.

◆ MSDOS_HIDDEN_ATTR

#define MSDOS_HIDDEN_ATTR   0x02

Definition at line 116 of file zip.cpp.

◆ NIL

#define NIL   0

Definition at line 282 of file zip.cpp.

◆ pqremove

#define pqremove (   tree,
  top 
)
Value:
{\
top = state.ts.heap[SMALLEST]; \
state.ts.heap[SMALLEST] = state.ts.heap[state.ts.heap_len--]; \
pqdownheap(state,tree, SMALLEST); \
}
#define SMALLEST
Definition: zip.cpp:785

Definition at line 793 of file zip.cpp.

◆ PUTBYTE

#define PUTBYTE (   state,
 
)
Value:
{ if (state.bs.out_offset >= state.bs.out_size) \
state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \
state.bs.out_buf[state.bs.out_offset++] = (char) (b); \
}

Definition at line 266 of file zip.cpp.

◆ PUTLG

#define PUTLG (   a,
 
)    {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))}

Definition at line 140 of file zip.cpp.

◆ PUTSH

#define PUTSH (   a,
 
)    {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);}

Definition at line 139 of file zip.cpp.

◆ PUTSHORT

#define PUTSHORT (   state,
 
)
Value:
{ if (state.bs.out_offset >= state.bs.out_size-1) \
state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \
state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \
state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \
}
unsigned short ush
Definition: unzip.cpp:477

Definition at line 259 of file zip.cpp.

◆ REP_3_6

#define REP_3_6   16

Definition at line 237 of file zip.cpp.

◆ REPZ_11_138

#define REPZ_11_138   18

Definition at line 243 of file zip.cpp.

◆ REPZ_3_10

#define REPZ_3_10   17

Definition at line 240 of file zip.cpp.

◆ send_code

#define send_code (   state,
  c,
  tree 
)    send_bits(state, tree[c].fc.code, tree[c].dl.len)

Definition at line 668 of file zip.cpp.

◆ SLOW

#define SLOW   2

Definition at line 286 of file zip.cpp.

◆ smaller

#define smaller (   tree,
  n,
 
)
Value:
(tree[n].fc.freq < tree[m].fc.freq || \
(tree[n].fc.freq == tree[m].fc.freq && state.ts.depth[n] <= state.ts.depth[m]))

Definition at line 804 of file zip.cpp.

◆ SMALLEST

#define SMALLEST   1

Definition at line 785 of file zip.cpp.

◆ STATIC_TREES

#define STATIC_TREES   1

Definition at line 210 of file zip.cpp.

◆ STORE

#define STORE   0

Definition at line 110 of file zip.cpp.

◆ STORED_BLOCK

#define STORED_BLOCK   0

Definition at line 209 of file zip.cpp.

◆ TOO_FAR

#define TOO_FAR   4096

Definition at line 289 of file zip.cpp.

◆ UNKNOWN

#define UNKNOWN   (-1)

Definition at line 105 of file zip.cpp.

◆ UPDATE_HASH

#define UPDATE_HASH (   h,
 
)    (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)

Definition at line 1623 of file zip.cpp.

◆ WMASK

#define WMASK   (WSIZE-1)

Definition at line 279 of file zip.cpp.

◆ WSIZE

#define WSIZE   (0x8000)

Definition at line 156 of file zip.cpp.

◆ ZE_ABORT

#define ZE_ABORT   9

Definition at line 92 of file zip.cpp.

◆ ZE_BIG

#define ZE_BIG   6

Definition at line 89 of file zip.cpp.

◆ ZE_CREAT

#define ZE_CREAT   15

Definition at line 98 of file zip.cpp.

◆ ZE_EOF

#define ZE_EOF   2

Definition at line 85 of file zip.cpp.

◆ ZE_FORM

#define ZE_FORM   3

Definition at line 86 of file zip.cpp.

◆ ZE_LOGIC

#define ZE_LOGIC   5

Definition at line 88 of file zip.cpp.

◆ ZE_MAXERR

#define ZE_MAXERR   18

Definition at line 101 of file zip.cpp.

◆ ZE_MEM

#define ZE_MEM   4

Definition at line 87 of file zip.cpp.

◆ ZE_MISS

#define ZE_MISS   -1

Definition at line 83 of file zip.cpp.

◆ ZE_NAME

#define ZE_NAME   13

Definition at line 96 of file zip.cpp.

◆ ZE_NONE

#define ZE_NONE   12

Definition at line 95 of file zip.cpp.

◆ ZE_NOTE

#define ZE_NOTE   7

Definition at line 90 of file zip.cpp.

◆ ZE_OK

#define ZE_OK   0

Definition at line 84 of file zip.cpp.

◆ ZE_OPEN

#define ZE_OPEN   18

Definition at line 100 of file zip.cpp.

◆ ZE_PARMS

#define ZE_PARMS   16

Definition at line 99 of file zip.cpp.

◆ ZE_READ

#define ZE_READ   11

Definition at line 94 of file zip.cpp.

◆ ZE_TEMP

#define ZE_TEMP   10

Definition at line 93 of file zip.cpp.

◆ ZE_TEST

#define ZE_TEST   8

Definition at line 91 of file zip.cpp.

◆ ZE_WRITE

#define ZE_WRITE   14

Definition at line 97 of file zip.cpp.

◆ ZIP_FILENAME

#define ZIP_FILENAME   2

Definition at line 174 of file zip.cpp.

◆ ZIP_FOLDER

#define ZIP_FOLDER   4

Definition at line 176 of file zip.cpp.

◆ ZIP_HANDLE

#define ZIP_HANDLE   1

Definition at line 173 of file zip.cpp.

◆ ZIP_MEMORY

#define ZIP_MEMORY   3

Definition at line 175 of file zip.cpp.

Typedef Documentation

◆ config

typedef struct config config

◆ ct_data

typedef struct ct_data ct_data

◆ extent

typedef size_t extent

Definition at line 71 of file zip.cpp.

◆ FLUSHFUNC

typedef unsigned(* FLUSHFUNC) (void *param, const char *buf, unsigned *size)

Definition at line 602 of file zip.cpp.

◆ IPos

typedef unsigned IPos

Definition at line 73 of file zip.cpp.

◆ iztimes

typedef struct iztimes iztimes

◆ lutime_t

typedef __int64 lutime_t

Definition at line 573 of file zip.cpp.

◆ Pos

typedef unsigned Pos

Definition at line 72 of file zip.cpp.

◆ READFUNC

typedef unsigned(* READFUNC) (TState &state, char *buf, unsigned size)

Definition at line 601 of file zip.cpp.

◆ tree_desc

typedef struct tree_desc tree_desc

◆ TZipFileInfo

typedef struct zlist TZipFileInfo

◆ uch

typedef unsigned char uch

Definition at line 68 of file zip.cpp.

◆ ulg

typedef unsigned long ulg

Definition at line 70 of file zip.cpp.

◆ ush

typedef unsigned short ush

Definition at line 69 of file zip.cpp.

◆ WRITEFUNC

typedef unsigned(* WRITEFUNC) (void *param, const char *buf, unsigned size)

Definition at line 603 of file zip.cpp.

Function Documentation

◆ Assert()

void Assert ( TState state,
bool  cond,
const char *  msg 
)

◆ bi_init()

void bi_init ( TState state,
char *  tgt_buf,
unsigned  tgt_size,
int  flsh_allowed 
)

◆ bi_reverse()

unsigned bi_reverse ( unsigned  code,
int  len 
)

Definition at line 1534 of file zip.cpp.

Referenced by ct_init(), and gen_codes().

◆ bi_windup()

◆ build_bl_tree()

int build_bl_tree ( TState state)

Definition at line 1200 of file zip.cpp.

References BL_CODES, TTreeState::bl_desc, bl_order, TTreeState::bl_tree, build_tree(), TTreeState::d_desc, ct_data::dl, TTreeState::dyn_dtree, TTreeState::dyn_ltree, TTreeState::l_desc, ct_data::len, tree_desc::max_code, TTreeState::opt_len, scan_tree(), TTreeState::static_len, Trace(), and TState::ts.

Referenced by flush_block().

Here is the call graph for this function:

◆ build_tree()

void build_tree ( TState state,
tree_desc desc 
)

Definition at line 979 of file zip.cpp.

References ct_data::dad, TTreeState::depth, ct_data::dl, tree_desc::dyn_tree, tree_desc::elems, ct_data::fc, ct_data::freq, gen_bitlen(), gen_codes(), TTreeState::heap, TTreeState::heap_len, TTreeState::heap_max, HEAP_SIZE, ct_data::len, Max, tree_desc::max_code, TTreeState::opt_len, pqdownheap(), pqremove, SMALLEST, TTreeState::static_len, tree_desc::static_tree, and TState::ts.

Referenced by build_bl_tree(), and flush_block().

Here is the call graph for this function:

◆ CloseZipZ()

ZRESULT CloseZipZ ( HZIP  hz)

Definition at line 3323 of file zip.cpp.

References TZip::Close(), TZipHandleData::flag, lasterrorZ, TZipHandleData::zip, ZR_ARGS, and ZR_ZMODE.

Here is the call graph for this function:

◆ compress_block()

void compress_block ( TState state,
ct_data ltree,
ct_data dtree 
)

Definition at line 1423 of file zip.cpp.

References Assert(), TTreeState::base_dist, TTreeState::base_length, TTreeState::d_buf, d_code, D_CODES, END_BLOCK, extra_dbits, extra_lbits, TTreeState::flag_buf, TTreeState::l_buf, TTreeState::last_lit, TTreeState::length_code, LITERALS, send_bits(), send_code, and TState::ts.

Referenced by flush_block().

Here is the call graph for this function:

◆ copy_block()

void copy_block ( TState state,
char *  buf,
unsigned  len,
int  header 
)

Definition at line 1572 of file zip.cpp.

References Assert(), bi_windup(), TBitState::bits_sent, TState::bs, TBitState::flush_flg, TState::flush_outbuf, TBitState::out_buf, TBitState::out_offset, TBitState::out_size, TState::param, and PUTSHORT.

Referenced by flush_block().

Here is the call graph for this function:

◆ crc32()

ulg crc32 ( ulg  crc,
const uch buf,
extent  len 
)

Definition at line 2289 of file zip.cpp.

References DO1, and DO8.

Referenced by TZip::read().

◆ CreateZip() [1/2]

HZIP CreateZip ( const TCHAR *  fn,
const char *  password 
)

Definition at line 3253 of file zip.cpp.

References CreateZipInternal(), and ZIP_FILENAME.

Referenced by Zipfile::open().

Here is the call graph for this function:

◆ CreateZip() [2/2]

HZIP CreateZip ( void *  z,
unsigned int  len,
const char *  password 
)

Definition at line 3257 of file zip.cpp.

References CreateZipInternal(), and ZIP_MEMORY.

Here is the call graph for this function:

◆ CreateZipHandle()

HZIP CreateZipHandle ( HANDLE  h,
const char *  password 
)

Definition at line 3249 of file zip.cpp.

References CreateZipInternal(), and ZIP_HANDLE.

Here is the call graph for this function:

◆ CreateZipInternal()

HZIP CreateZipInternal ( void *  z,
unsigned int  len,
DWORD  flags,
const char *  password 
)

Definition at line 3235 of file zip.cpp.

References TZip::Create(), TZipHandleData::flag, lasterrorZ, TZipHandleData::zip, and ZR_OK.

Referenced by CreateZip(), and CreateZipHandle().

Here is the call graph for this function:

◆ ct_init()

void ct_init ( TState state,
ush attr 
)

◆ ct_tally()

int ct_tally ( TState state,
int  dist,
int  lc 
)

◆ decrypt_byte()

char decrypt_byte ( unsigned long *  keys)

Definition at line 2314 of file zip.cpp.

Referenced by zencode().

◆ deflate()

ulg deflate ( TState state)

◆ deflate_fast()

ulg deflate_fast ( TState state)

Definition at line 1928 of file zip.cpp.

References Assert(), TDeflateState::block_start, check_match, ct_tally(), TState::ds, fill_window(), FLUSH_BLOCK, TDeflateState::ins_h, INSERT_STRING, longest_match(), TDeflateState::lookahead, TDeflateState::match_start, MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, TDeflateState::nice_match, NIL, TDeflateState::prev_length, TDeflateState::strstart, UPDATE_HASH, and TDeflateState::window.

Referenced by deflate().

Here is the call graph for this function:

◆ filetime2dosdatetime()

void filetime2dosdatetime ( const FILETIME  ft,
WORD *  dosdate,
WORD *  dostime 
)

Definition at line 2355 of file zip.cpp.

Referenced by GetFileInfo(), TZip::open_dir(), TZip::open_handle(), and TZip::open_mem().

◆ filetime2timet()

lutime_t filetime2timet ( const FILETIME  ft)

Definition at line 2349 of file zip.cpp.

Referenced by GetFileInfo(), TZip::open_dir(), TZip::open_handle(), and TZip::open_mem().

◆ fill_window()

void fill_window ( TState state)

Definition at line 1834 of file zip.cpp.

References Assert(), TDeflateState::block_start, TState::ds, EOF, TDeflateState::eofile, HASH_SIZE, TDeflateState::head, TDeflateState::lookahead, TDeflateState::match_start, MAX_DIST, MIN_LOOKAHEAD, NIL, TDeflateState::prev, TState::readfunc, TDeflateState::sliding, TDeflateState::strstart, TDeflateState::window, TDeflateState::window_size, and WSIZE.

Referenced by deflate(), deflate_fast(), and lm_init().

Here is the call graph for this function:

◆ flush_block()

◆ FormatZipMessageZ()

unsigned int FormatZipMessageZ ( ZRESULT  code,
char *  buf,
unsigned int  len 
)

◆ gen_bitlen()

void gen_bitlen ( TState state,
tree_desc desc 
)

Definition at line 849 of file zip.cpp.

References bits, TTreeState::bl_count, ct_data::dad, ct_data::dl, tree_desc::dyn_tree, tree_desc::extra_base, tree_desc::extra_bits, ct_data::fc, for(), ct_data::freq, TTreeState::heap, TTreeState::heap_max, HEAP_SIZE, ct_data::len, MAX_BITS, tree_desc::max_code, tree_desc::max_length, TTreeState::opt_len, TTreeState::static_len, tree_desc::static_tree, Trace(), and TState::ts.

Referenced by build_tree().

Here is the call graph for this function:

◆ gen_codes()

void gen_codes ( TState state,
ct_data tree,
int  max_code 
)

Definition at line 939 of file zip.cpp.

References Assert(), bi_reverse(), bits, TTreeState::bl_count, ct_data::code, ct_data::dl, ct_data::fc, ct_data::len, MAX_BITS, Trace(), and TState::ts.

Referenced by build_tree(), and ct_init().

Here is the call graph for this function:

◆ GetFileInfo()

ZRESULT GetFileInfo ( HANDLE  hf,
ulg attr,
long *  size,
iztimes times,
ulg timestamp 
)

Definition at line 2370 of file zip.cpp.

References iztimes::atime, iztimes::ctime, filetime2dosdatetime(), filetime2timet(), iztimes::mtime, ZR_NOFILE, and ZR_OK.

Referenced by TZip::open_handle().

Here is the call graph for this function:

◆ HasZipSuffix()

bool HasZipSuffix ( const TCHAR *  fn)

Definition at line 2332 of file zip.cpp.

References _T.

Referenced by TZip::Add().

◆ init_block()

void init_block ( TState state)

Definition at line 769 of file zip.cpp.

References BL_CODES, TTreeState::bl_tree, D_CODES, TTreeState::dyn_dtree, TTreeState::dyn_ltree, END_BLOCK, ct_data::fc, TTreeState::flag_bit, TTreeState::flags, for(), ct_data::freq, L_CODES, TTreeState::last_dist, TTreeState::last_flags, TTreeState::last_lit, TTreeState::opt_len, TTreeState::static_len, and TState::ts.

Referenced by ct_init(), and flush_block().

Here is the call graph for this function:

◆ IsZipHandleZ()

bool IsZipHandleZ ( HZIP  hz)

Definition at line 3343 of file zip.cpp.

References TZipHandleData::flag.

◆ lm_init()

◆ longest_match()

int longest_match ( TState state,
IPos  cur_match 
)

Definition at line 1722 of file zip.cpp.

References Assert(), TState::ds, TDeflateState::good_match, HASH_BITS, TDeflateState::match_start, TDeflateState::max_chain_length, MAX_DIST, MAX_MATCH, MIN_LOOKAHEAD, TDeflateState::nice_match, NIL, TDeflateState::prev, TDeflateState::prev_length, TDeflateState::strstart, TDeflateState::window, TDeflateState::window_size, and WMASK.

Referenced by deflate(), and deflate_fast().

Here is the call graph for this function:

◆ pqdownheap()

void pqdownheap ( TState state,
ct_data tree,
int  k 
)

Definition at line 814 of file zip.cpp.

References TTreeState::heap, TTreeState::heap_len, smaller, and TState::ts.

Referenced by build_tree().

◆ putcentral()

int putcentral ( struct zlist far *  z,
WRITEFUNC  wfunc,
void *  param 
)

Definition at line 2179 of file zip.cpp.

References CENSIG, PUTLG, PUTSH, ZE_OK, and ZE_TEMP.

Referenced by TZip::AddCentral().

◆ putend()

int putend ( int  n,
ulg  s,
ulg  c,
extent  m,
char *  z,
WRITEFUNC  wfunc,
void *  param 
)

Definition at line 2206 of file zip.cpp.

References ENDSIG, PUTLG, PUTSH, ZE_OK, and ZE_TEMP.

Referenced by TZip::AddCentral().

◆ putextended()

int putextended ( struct zlist far *  z,
WRITEFUNC  wfunc,
void *  param 
)

Definition at line 2169 of file zip.cpp.

References EXTLOCSIG, PUTLG, and ZE_OK.

Referenced by TZip::Add().

◆ putlocal()

int putlocal ( struct zlist far *  z,
WRITEFUNC  wfunc,
void *  param 
)

Definition at line 2146 of file zip.cpp.

References LOCSIG, PUTLG, PUTSH, ZE_OK, and ZE_TEMP.

Referenced by TZip::Add().

◆ scan_tree()

void scan_tree ( TState state,
ct_data tree,
int  max_code 
)

◆ send_all_trees()

void send_all_trees ( TState state,
int  lcodes,
int  dcodes,
int  blcodes 
)

Definition at line 1234 of file zip.cpp.

References Assert(), TBitState::bits_sent, BL_CODES, bl_order, TTreeState::bl_tree, TState::bs, D_CODES, ct_data::dl, TTreeState::dyn_dtree, TTreeState::dyn_ltree, L_CODES, ct_data::len, send_bits(), send_tree(), Trace(), and TState::ts.

Referenced by flush_block().

Here is the call graph for this function:

◆ send_bits()

void send_bits ( TState state,
int  value,
int  length 
)

Definition at line 1510 of file zip.cpp.

References Assert(), TBitState::bi_buf, TBitState::bi_valid, TBitState::bits_sent, TState::bs, Buf_size, and PUTSHORT.

Referenced by compress_block(), flush_block(), send_all_trees(), and send_tree().

Here is the call graph for this function:

◆ send_tree()

void send_tree ( TState state,
ct_data tree,
int  max_code 
)

Definition at line 1126 of file zip.cpp.

References Assert(), TTreeState::bl_tree, ct_data::dl, ct_data::len, REP_3_6, REPZ_11_138, REPZ_3_10, send_bits(), send_code, and TState::ts.

Referenced by send_all_trees().

Here is the call graph for this function:

◆ set_file_type()

void set_file_type ( TState state)

◆ Trace()

void __cdecl Trace ( const char *  x,
  ... 
)

Definition at line 630 of file zip.cpp.

Referenced by build_bl_tree(), ct_tally(), flush_block(), gen_bitlen(), gen_codes(), and send_all_trees().

◆ Tracec()

void __cdecl Tracec ( bool  ,
const char *  x,
  ... 
)

Definition at line 637 of file zip.cpp.

◆ update_keys()

void update_keys ( unsigned long *  keys,
char  c 
)

Definition at line 2307 of file zip.cpp.

References CRC32.

Referenced by TZip::Add(), and zencode().

◆ zencode()

char zencode ( unsigned long *  keys,
char  c 
)

Definition at line 2319 of file zip.cpp.

References decrypt_byte(), and update_keys().

Referenced by TZip::Add(), and TZip::write().

Here is the call graph for this function:

◆ ZipAdd() [1/2]

ZRESULT ZipAdd ( HZIP  hz,
const TCHAR *  dstzn,
const TCHAR *  fn 
)

Definition at line 3280 of file zip.cpp.

References ZIP_FILENAME, and ZipAddInternal().

Referenced by Zipfile::addFile().

Here is the call graph for this function:

◆ ZipAdd() [2/2]

ZRESULT ZipAdd ( HZIP  hz,
const TCHAR *  dstzn,
void *  src,
unsigned int  len 
)

Definition at line 3284 of file zip.cpp.

References ZIP_MEMORY, and ZipAddInternal().

Here is the call graph for this function:

◆ ZipAddFolder()

ZRESULT ZipAddFolder ( HZIP  hz,
const TCHAR *  dstzn 
)

Definition at line 3296 of file zip.cpp.

References ZIP_FOLDER, and ZipAddInternal().

Here is the call graph for this function:

◆ ZipAddHandle() [1/2]

ZRESULT ZipAddHandle ( HZIP  hz,
const TCHAR *  dstzn,
HANDLE  h 
)

Definition at line 3288 of file zip.cpp.

References ZIP_HANDLE, and ZipAddInternal().

Here is the call graph for this function:

◆ ZipAddHandle() [2/2]

ZRESULT ZipAddHandle ( HZIP  hz,
const TCHAR *  dstzn,
HANDLE  h,
unsigned int  len 
)

Definition at line 3292 of file zip.cpp.

References ZIP_HANDLE, and ZipAddInternal().

Here is the call graph for this function:

◆ ZipAddInternal()

ZRESULT ZipAddInternal ( HZIP  hz,
const TCHAR *  dstzn,
void *  src,
unsigned int  len,
DWORD  flags 
)

Definition at line 3263 of file zip.cpp.

References TZip::Add(), TZipHandleData::flag, lasterrorZ, TZipHandleData::zip, ZR_ARGS, and ZR_ZMODE.

Referenced by ZipAdd(), ZipAddFolder(), and ZipAddHandle().

Here is the call graph for this function:

◆ ZipGetMemory()

ZRESULT ZipGetMemory ( HZIP  hz,
void **  buf,
unsigned long *  len 
)

Definition at line 3303 of file zip.cpp.

References TZipHandleData::flag, TZip::GetMemory(), lasterrorZ, TZipHandleData::zip, ZR_ARGS, and ZR_ZMODE.

Here is the call graph for this function:

Variable Documentation

◆ bl_order

const uch bl_order[BL_CODES] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}

Definition at line 323 of file zip.cpp.

Referenced by build_bl_tree(), and send_all_trees().

◆ configuration_table

const config configuration_table[10]
Initial value:
=
{
{0, 0, 0, 0},
{4, 4, 8, 4},
{4, 5, 16, 8},
{4, 6, 32, 32},
{4, 4, 16, 16},
{8, 16, 32, 32},
{8, 16, 128, 128},
{8, 32, 128, 256},
{32, 128, 258, 1024},
{32, 258, 258, 4096}
}

Definition at line 342 of file zip.cpp.

Referenced by lm_init().

◆ crc_table

const ulg crc_table[256]

Definition at line 2227 of file zip.cpp.

◆ extra_blbits

const int extra_blbits[BL_CODES] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7}

Definition at line 320 of file zip.cpp.

Referenced by TTreeState::TTreeState().

◆ extra_dbits

const int extra_dbits[D_CODES] = {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 317 of file zip.cpp.

Referenced by compress_block(), ct_init(), ct_tally(), and TTreeState::TTreeState().

◆ extra_lbits

const int extra_lbits[LENGTH_CODES] = {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}

Definition at line 314 of file zip.cpp.

Referenced by compress_block(), ct_init(), and TTreeState::TTreeState().

◆ has_seeded

bool has_seeded = false

Definition at line 2915 of file zip.cpp.

Referenced by TZip::Add().

◆ lasterrorZ

ZRESULT lasterrorZ = ZR_OK