⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zipdate.h

📁 zip解压源码.
💻 H
字号:

#ifndef SEEK_END
#  define SEEK_END 2
#endif

//////////////////////////////////////////////////
#ifdef SMALL_MEM
#   define HASH_BITS  13  /* Number of bits used to hash strings */
#endif
#ifdef MEDIUM_MEM
#   define HASH_BITS  14
#endif
#ifndef HASH_BITS
#   define HASH_BITS  15
#endif

#if (WSIZE<<1) > (1<<BITS)
   error: cannot overlay window with tab_suffix and prev with tab_prefix0
#endif
#if HASH_BITS > BITS-1
   error: cannot overlay head with tab_prefix1
#endif

#define HASH_SIZE (unsigned)(1<<HASH_BITS)
#define HASH_MASK (HASH_SIZE-1)
#define WMASK     (WSIZE-1)
/* HASH_SIZE and WSIZE must be powers of two */

#define NIL 0
/* Tail of hash chains */

#ifndef TOO_FAR
#  define TOO_FAR 4096
#endif
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */

/* ===========================================================================
 * Local data used by the "longest match" routines.
 */
typedef ush Pos;
typedef unsigned IPos;



///////////////////////////////////////////////////
//tree.h

#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 REP_3_6      16
#define REPZ_3_10    17
#define REPZ_11_138  18
#define HEAP_SIZE (2*L_CODES+1)

#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES    2
/* The three kinds of block type */

#ifndef LIT_BUFSIZE
#  ifdef SMALL_MEM
#    define LIT_BUFSIZE  0x2000
#  else
#  ifdef MEDIUM_MEM
#    define LIT_BUFSIZE  0x4000
#  else
#    define LIT_BUFSIZE  0x8000
#  endif
#  endif
#endif
#ifndef DIST_BUFSIZE
#  define DIST_BUFSIZE  LIT_BUFSIZE
#endif

#if LIT_BUFSIZE > INBUFSIZ
    error cannot overlay l_buf and inbuf
#endif



/* Data structure describing a single value and its code string. */
typedef struct ct_data {
    union {
        ush  freq;       /* frequency count */
        ush  code;       /* bit string */
    } fc;
    union {
        ush  dad;        /* father node in Huffman tree */
        ush  len;        /* length of bit string */
    } dl;
} ct_data;
typedef struct tree_desc {
    ct_data *dyn_tree;      /* the dynamic tree */
    ct_data *static_tree;   /* corresponding static tree or NULL */
    int     *extra_bits;    /* extra bits for each code or NULL */
    int     extra_base;          /* base index for extra_bits */
    int     elems;               /* max number of elements in the tree */
    int     max_length;          /* max bit length for the codes */
    int     max_code;            /* largest code with non zero frequency */
} tree_desc;

typedef struct ZipDate
{
    BYTE *source1,*dest1;
	DWORD sourceLen1,destLen1,inSize,outSize;
	int errorNumber;

	ulg crc;       /* crc on uncompressed file data */
	ulg static_crc;	

	long header_bytes;   /* number of bytes in gzip header */
	int verbose;	// = 0;      /* be verbose (-v) */
	int level;		// = 6;        /* compression level */
	long bytes_in, bytes_out;	/* number of input bytes *//* number of output bytes */
	unsigned insize;           /* valid bytes in inbuf */
	unsigned inptr;            /* index of next byte to be processed in inbuf */
	unsigned outcnt;           /* bytes in output buffer */

	DECLARE(uch, inbuf,  INBUFSIZ +INBUF_EXTRA);
	DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
	DECLARE(ush, d_buf,  DIST_BUFSIZE);
	DECLARE(uch, window, 2L*WSIZE);
#ifndef MAXSEG_64K
    DECLARE(ush, tab_prefix, 1L<<BITS);
#else
    DECLARE(ush, tab_prefix0, 1L<<(BITS-1));
    DECLARE(ush, tab_prefix1, 1L<<(BITS-1));
#endif
	
////////////////
//bits
	unsigned short bi_buf;
	int bi_valid;

//tree

	ush file_type;
	ush bl_count[MAX_BITS+1];
	uch bl_order[BL_CODES];//  = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
	int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
	int heap_len;               /* number of elements in the heap */
	int heap_max;               /* element of largest frequency */
	uch depth[2*L_CODES+1];
	uch length_code[MAX_MATCH-MIN_MATCH+1];
	uch dist_code[512];
	int base_length[LENGTH_CODES];
	int base_dist[D_CODES];

	uch flag_buf[(LIT_BUFSIZE/8)];
	unsigned last_lit;    /* running index in l_buf */
	unsigned last_dist;   /* running index in d_buf */
	unsigned last_flags;  /* running index in flag_buf */
	uch flags;            /* current flags not yet saved in flag_buf */
	uch flag_bit;         /* current bit used in flags */
	ulg opt_len;        /* bit length of current block with optimal trees */
	ulg static_len;     /* bit length of current block with static trees */
	ulg compressed_len; /* total bit length of compressed file */
	ulg input_len;      /* total byte length of input file */

	ct_data dyn_ltree[HEAP_SIZE];   /* literal and length tree */
	ct_data dyn_dtree[2*D_CODES+1]; /* distance tree */
	ct_data static_ltree[L_CODES+2];
	ct_data static_dtree[D_CODES];
	ct_data bl_tree[2*BL_CODES+1];

	tree_desc l_desc;// ={dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
	tree_desc d_desc;// ={dyn_dtree, static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS, 0};
	tree_desc bl_desc;// ={bl_tree, (ct_data near *)0, extra_blbits, 0,      BL_CODES, MAX_BL_BITS, 0};

////////////////////////
//deflate
	long block_start;
	unsigned strstart;      /* start of string to insert */
	ulg window_size;// = (ulg)2*WSIZE;
	int nice_match; /* Stop searching when current match exceeds this */
	unsigned match_start;   /* start of matching string */
	unsigned int prev_length;
	unsigned max_chain_length;
	unsigned good_match;

	unsigned ins_h;  /* hash index of string to be inserted */
	int           eofile;        /* flag set at end of input file */
	unsigned      lookahead;     /* number of valid bytes ahead in window */
	unsigned int max_lazy_match;

}ZipDate;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -