00001
00002
00003
00004
00005
00007
00008
00009
00010
00011
00012
00013
00014
00016 #if !defined (__UNZIP_HH__)
00017 #define __UNZIP_HH__
00018
00019 #define COUNT(x) (sizeof(x) / sizeof(x[0])) // item count
00020 #define NOT ! // shorthand logical
00021 #define UINT unsigned int // unsigned integer
00022 #define BYTE unsigned char // ..and unsigned character
00023 #define ULONG unsigned long // ..and unsigned long
00024 #define MAX_PATH_ZIPINFO 79 // maximum path length
00025 #define LAST(s) s[strlen(s) - 1] // last character in string
00026 #define TRUE 1 // true value
00027 #define FALSE 0 // false value
00028 #define BUFFER_SIZE 32768L // dictionary/output buffer size
00029 #define COPY_BUFFER 16384 // copy buffer size
00030 #define FILE_ATTR _A_NORMAL | _A_RDONLY // file attrib to search on
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 struct lf
00041 {
00042
00043 ULONG lf_sig;
00044 WORD lf_extract,
00045 lf_flag,
00046 lf_cm,
00047 lf_time,
00048 lf_date;
00049 ULONG lf_crc,
00050 lf_csize,
00051 lf_size;
00052 WORD lf_fn_len,
00053 lf_ef_len;
00054 };
00055
00056
00057
00058 struct dd
00059 {
00060 ULONG dd_crc,
00061 dd_csize,
00062 dd_size;
00063 };
00064
00065
00066
00067 struct fh
00068 {
00069
00070 ULONG fh_sig;
00071 WORD fh_made,
00072 fh_extract,
00073 fh_flag,
00074 fh_cm,
00075 fh_time,
00076 fh_date;
00077 ULONG fh_crc,
00078 fh_csize,
00079 fh_size;
00080 WORD fh_fn_len,
00081 fh_ef_len,
00082 fh_fc_len,
00083 fh_disk,
00084 fh_attr;
00085 ULONG fh_eattr,
00086 fh_offset;
00087 };
00088
00089
00090
00091 struct ed
00092 {
00093
00094 ULONG ed_sig;
00095 WORD ed_disk,
00096 ed_cdisk,
00097 ed_current,
00098 ed_total;
00099 ULONG ed_size,
00100 ed_offset;
00101
00102 WORD ed_zc_len;
00103 };
00104
00105
00106 typedef struct lf LF;
00107 typedef struct fh FH;
00108 typedef struct dd DD;
00109 typedef struct ed ED;
00110
00111
00112 #define LF_SIG 0x0403 // local file header signature
00113 #define FH_SIG 0x0201 // file header signature
00114 #define ED_SIG 0x0605 // end of central dir signature
00115
00116
00117 #define LH_FLAG_ENCRYPT 0x01 // file is encrypted
00118
00119
00120 #define LF_FLAG_8K 0x02 // use 8k dictionary vs 4k
00121 #define LF_FLAG_3SF 0x04 // use 3 S-F trees vs 2
00122
00123
00124 #define LF_FLAG_NORM 0x00 // normal compression
00125 #define LF_FLAG_MAX 0x02 // maximum compression
00126 #define LF_FLAG_FAST 0x04 // fast compression
00127 #define LF_FLAG_SUPER 0x06 // super fast compression
00128 #define LF_FLAG_DDREC 0x08 // use data descriptor record
00129
00130
00131 #define LF_CM_STORED 0x00 // stored
00132 #define LF_CM_SHRUNK 0x01 // shrunk
00133 #define LF_CM_REDUCED1 0x02 // reduced with factor 1
00134 #define LF_CM_REDUCED2 0x03 // reduced with factor 2
00135 #define LF_CM_REDUCED3 0x04 // reduced with factor 3
00136 #define LF_CM_REDUCED4 0x05 // reduced with factor 4
00137 #define LF_CM_IMPLODED 0x06 // imploded
00138 #define LF_CM_TOKENIZED 0x07 // tokenized (not used)
00139 #define LF_CM_DEFLATED 0x08 // deflated
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 #define TABLE_SIZE 0x2001 // dictionary table size
00150 #define FREE 0xffff // free entry value
00151
00152
00153 struct dictionary
00154 {
00155
00156 WORD parent_c;
00157
00158 char c;
00159 };
00160
00161 typedef struct dictionary SD;
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 #define EXPLODE_DLE 144 // escape character
00172 #define EXPAND_BUFF 4096 // sliding buffer size
00173
00174
00175 struct follower_set
00176 {
00177 BYTE set_len,
00178 set[32];
00179 };
00180
00181 typedef struct follower_set FS;
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 struct shannon_fano_tree
00193 {
00194 BYTE blen,
00195 value;
00196
00197 WORD code;
00198 };
00199
00200 typedef struct shannon_fano_tree SFT;
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 struct huffman_tree
00212 {
00213 BYTE eb,
00214 blen;
00215 union
00216 {
00217 int code;
00218 struct huffman_tree *table;
00219 } v;
00220 };
00221
00222 typedef struct huffman_tree HUFF;
00223
00224
00225 #endif