Subversion Repositories autosfx

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 daniel-mar 1
#ifndef UnzInfH
2
#define UnzInfH
3
/*
4
 
5
Copyright (c) 1990-2007 Info-ZIP.  All rights reserved.
6
 
7
See the accompanying file LICENSE, version 2007-Mar-4 or later
8
(the contents of which are also included in zip.h) for terms of use.
9
If, for some reason, all these files are missing, the Info-ZIP license
10
also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
11
 
12
parts Copyright (C) 1997 Mike White, Eric W. Engler
13
 ************************************************************************
14
Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
15
 
16
This file is part of TZipMaster Version 1.9.
17
 
18
TZipMaster is free software: you can redistribute it and/or modify
19
it under the terms of the GNU Lesser General Public License as published by
20
the Free Software Foundation, either version 3 of the License, or
21
(at your option) any later version.
22
 
23
TZipMaster is distributed in the hope that it will be useful,
24
but WITHOUT ANY WARRANTY; without even the implied warranty of
25
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
GNU Lesser General Public License for more details.
27
 
28
You should have received a copy of the GNU Lesser General Public License
29
along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
30
 
31
contact: problems@delphizip.org (include ZipMaster in the subject).
32
updates: http://www.delphizip.org
33
DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
34
 *********************************************************************** */
35
#include "dzoper.h"
36
#include "unzsup.h"
37
#include "crypt.h"
38
 
39
#define INBUFSIZ  0x8000L // larger buffers for real OSes
40
 
41
// #ifndef WSIZE                   /* default is 32K */
42
#    define UWSIZE   65536L       // 64K for Inflate64
43
#  define wsize UWSIZE           /* wsize is a constant */
44
 
45
#define OUTBUFSIZ   0x8000      // EWE: 32K (for unshrink.c)
46
typedef int shrint;
47
 
48
extern const ush mask_bits[];
49
 
50
/* Huffman code lookup table entry--this entry is four bytes for machines
51
 * that have 16-bit pointers (e.g. PC's in the small or medium model).
52
 * Valid extra bits are 0..13.  e == 15 is EOB (end of block), e == 16
53
 * means that v is a literal, 16 < e < 32 means that v is a pointer to
54
 * the next table, which codes e - 16 bits, and lastly e == 99 indicates
55
 * an unused code.  If a code with e == 99 is looked up, this implies an
56
 * error in the data. */
57
 
58
#pragma pack(push, 4)
59
 
60
struct huft
61
{
62
        uch e; /* number of extra bits or operation */
63
        uch b;
64
        /* number of bits in this code or subcode */
65
        union
66
        {
67
                ush n; /* literal, length base, or distance base */
68
                struct huft *t; /* pointer to next level of table */
69
        }
70
 
71
        v;
72
};
73
#pragma pack(pop)
74
 
75
#pragma pack(push, 1)
76
typedef struct local_file_header
77
{ /* LOCAL */
78
        uch version_needed_to_extract[2];
79
        ush general_purpose_bit_flag;
80
        ush compression_method;
81
        ush last_mod_file_time;
82
        ush last_mod_file_date;
83
        ulg crc32;
84
        ZInt64 csize;
85
        ZInt64 ucsize;
86
        ush filename_length;
87
        ush extra_field_length;
88
}local_file_hdr;
89
#pragma pack(pop)
90
 
91
#define CRCVAL_INITIAL  0L
92
 
93
class UnzInf : public UnzSup
94
{
95
private:
96
        UnzInf(void);
97
        UnzInf(const UnzInf&);
98
        UnzInf& operator = (const UnzInf&);
99
 
100
protected:
101
        int fP_flag; /* -P: give password on command line (ARGH!) */
102
        int fnopwd; /* crypt static */
103
        const char *fkey; /* crypt static: decryption password or NULL */
104
        DZStrA fpwdarg;
105
        uch Slide[UWSIZE]; /* explode(), inflate(), unreduce() */
106
 
107
        unsigned fhufts; /* track memory usage */
108
 
109
        struct huft *ffixed_tl; /* inflate static */
110
        struct huft *ffixed_td; /* inflate static */
111
        int ffixed_bl; /* inflate static */
112
        int ffixed_bd; /* inflate static */
113
        struct huft *ffixed_tl64; /* inflate static */
114
        struct huft *ffixed_td64; /* inflate static */
115
        unsigned ffixed_bl64, ffixed_bd64; /* inflate static */
116
        struct huft *ffixed_tl32; /* inflate static */
117
        struct huft *ffixed_td32; /* inflate static */
118
        unsigned ffixed_bl32, ffixed_bd32; /* inflate static */
119
        const ush *fcplens; /* inflate static */
120
        const uch *fcplext; /* inflate static */
121
        const uch *fcpdext; /* inflate static */
122
        unsigned fwp; /* inflate static: current position in slide */
123
        ulg fbb; /* inflate static: bit buffer */
124
        unsigned fbk; /* inflate static: bits in bit buffer */
125
        local_file_hdr flrec; /* used in unzip.c, extract.c */
126
        int fPwdReqCount;
127
        int fnewzip;
128
 
129
        /* used in extract.c, crypt.c, zipinfo.c */
130
public:
131
        UnzInf(const DllCommands *C);
132
        ~UnzInf(void);
133
        int inflate(bool defl64);
134
        int inflate_free(void);
135
        int explode(void);
136
 
137
protected:
138
        int decrypt(ulg crc);
139
 
140
private:
141
        int inflate_codes(struct huft *tl, struct huft *td, int bl, int bd);
142
        int huft_build(unsigned *b, unsigned n, unsigned s, const ush * d,
143
                const uch * e, struct huft **t, int *m);
144
        int inflate_stored(void);
145
        int inflate_fixed(void);
146
        int inflate_dynamic(void);
147
        int inflate_block(int *e);
148
        int get_tree(unsigned * l, unsigned n);
149
        int explode_lit8(struct huft * tb, struct huft * tl, struct huft * td,
150
                int bb, int bl, int bd);
151
        int explode_lit4(struct huft * tb, struct huft * tl, struct huft * td,
152
                int bb, int bl, int bd);
153
        int explode_nolit8(struct huft * tl, struct huft * td, int bl, int bd);
154
        int explode_nolit4(struct huft * tl, struct huft * td, int bl, int bd);
155
        int testkey(const char *h, const char *key, ulg crc);
156
};
157
 
158
int huft_free(struct huft * t);
159
#endif