Subversion Repositories autosfx

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 daniel-mar 1
#ifndef DelZip_H
2
#define DelZip_H
3
/*
4
 delzip.h -
5
 
6
************************************************************************
7
 Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht,
8
      Eric W. Engler and Chris Vleghert.
9
 
10
   This file is part of TZipMaster Version 1.9.
11
 
12
    TZipMaster is free software: you can redistribute it and/or modify
13
    it under the terms of the GNU Lesser General Public License as published by
14
    the Free Software Foundation, either version 3 of the License, or
15
    (at your option) any later version.
16
 
17
    TZipMaster is distributed in the hope that it will be useful,
18
    but WITHOUT ANY WARRANTY; without even the implied warranty of
19
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
    GNU Lesser General Public License for more details.
21
 
22
    You should have received a copy of the GNU Lesser General Public License
23
    along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
24
 
25
    contact: problems@delphizip.org (include ZipMaster in the subject).
26
    updates: http://www.delphizip.org
27
    DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
28
************************************************************************/
29
 
30
// revised order
31
enum ActionCodes
32
{
33
    zacTick, zacItem, zacProgress, zacEndOfBatch,
34
    zacCount, zacSize, zacXItem, zacXProgress, zacMessage,
35
    zacNewName, zacPassword, zacCRCError, zacOverwrite, zacSkipped,
36
    zacComment, zacData, zacExtName, zacNone,
37
    zacKey, zacArg, zacWinErr
38
};
39
 
40
enum WinOps
41
{   zwoCreate, zwoOpen, zwoRead, zwoWrite, zwoSeek, zwoClose,
42
    zwoFind, zwoRename, zwoDelete, zwoGetAttrs, zwoSetAttrs, zwoGetDate,
43
    zwoSetDate, zwoMakeDir, zwoRemoveDir, zwoChangeDir
44
};    
45
 
46
enum StreamActions
47
{
48
    zsaIdentify, zsaCreate, zsaClose, zsaPosition, zsaRead, zsaWrite
49
};
50
 
51
 
52
enum  CBArgs
53
{
54
    zcbFilename, zcbPassword, zcbRootDir, zcbExtractDir, zcbComment,
55
    zcbFSpecArgs, zcbFSpecArgsExcl, zcbSpecials, zcbTempPath
56
};
57
 
58
#pragma pack(push, 1)
59
struct ZSStats
60
{
61
    __int64 Size;
62
    DWORD   Date;
63
    DWORD   Attrs;
64
};
65
#pragma pack(pop)
66
 
67
/*
68
the EncodeAs values (writing) -
69
 seoUPATH - convert to 'safe' but have UTF8 proper name in data
70
                                         [FAT 30 need 20 | NTFS 30 need 30]
71
 zeoUTF  - convert to UTF8 [FAT 20 need 20 | FAT 30? need 30?]
72
 zeoOEM  - convert to 'safe' (substitute '_' for undesirables) [FAT 20 need 20]
73
 zeoNone - store 'as is' (Ansi on Windows) [FAT 20 need 20 | NTFS 20 need 20]
74
 zeoAuto - zeoUTF
75
 
76
[without extended | with extended] version made, version need
77
 
78
'Safe' is 0x20 to 0x7e without 'reserved'.
79
Encoded (reading)
80
 zeoUPATH - assume has UTF8 name in data
81
 zeoUTF  - assume name is UTF8 - convert to Ansi/Unicode
82
 zeoOEM  - assume name is OEM - convert to Ansi/Unicode
83
 zeoNone - assume name is Ansi - convert to Ansi/Unicode
84
 zeoAuto - unless flags/versions say otherwise, or it has UTF8 name in data,
85
             treat it as OEM (FAT) / Ansi (NTFS)
86
*/
87
enum Encodings
88
{
89
    zeoAuto, zeoNone, zeoOEM, zeoUTF8, zeoUPATH
90
};
91
 
92
// yy::Extract=01, Add=02, either=03  zz::skip reason  yyzz
93
#define SKIPPED_ON_FRESHEN                              0x0101
94
#define SKIPPED_NO_OVERWRITE                            0x0102
95
#define SKIPPED_FILE_EXISTS                             0x0103
96
#define SKIPPED_BAD_PASSWORD                            0x0104
97
//#define SKIPPED_NO_ENCRYPTION                           0x0105
98
#define SKIPPED_BAD_NAME                                0x0105
99
#define SKIPPED_COMPRESSION_UNKNOWN                     0x0106
100
#define SKIPPED_UNKNOWN_ZIPHOST                         0x0107
101
#define SKIPPED_FILEFORMAT_WRONG                        0x0108
102
#define SKIPPED_EXTRACT_ERROR                           0x0109
103
#define SKIPPED_USER                                    0x010A
104
#define SKIPPED_CANNOTDO                                0x010B
105
#define SKIPPED_NO_FILES                                0x030C
106
#define SKIPPED_NO_SHARE                                0x020D
107
#define SKIPPED_NO_ACCESS                               0x020E
108
#define SKIPPED_NO_OPEN                                 0x020F
109
#define SKIPPED_DUP_NAME                                                                0x0210
110
#define SKIPPED_READ_ERROR                                                              0x0211
111
#define SKIPPED_SIZE_CHANGE                                                             0x0212
112
 
113
//Callbackstructs-------------------------------------------------------------
114
 
115
/* All the items in the CallBackStruct are passed to the BCB
116
 * program from the DLL.  Note that the "Caller" value returned
117
 * here is the same one specified earlier in ZipParms by the
118
 * BCB program. */
119
 
120
#define CALLBACK_CHECK  0x0707
121
#define STREAM_CHECK 0x070B
122
//ALL interface structures BYTE ALIGNED
123
/* stream operation arg usage
124
   zacStIdentify,
125
      IN MsgP = name
126
     OUT FileSize = size, Arg1 = Date, Arg2 = Attrs
127
   zacStCreate,
128
      IN MsgP = name
129
     OUT StrmP = stream
130
   zacStClose,
131
      IN StrmP = stream
132
     OUT StrmP = stream (= NULL)
133
   zacStPosition,
134
      IN StrmP = stream, FileSize = offset, Arg3 = from
135
     OUT FileSize = position
136
   zacStRead,
137
      IN StrmP = stream, MsgP = buf, Arg3 = count
138
     OUT Arg3 = bytes read
139
   zacStWrite
140
      IN StrmP = stream, MsgP = buf, Arg3 = count
141
     OUT Arg3 = bytes written
142
*/
143
#pragma pack(push, 1)
144
struct ZCallBackStruct
145
{
146
    void  *Caller;          // 'this' reference of the ZipBuilder class
147
    long   Version;         // version no. of DLL.
148
    BOOL   IsOperationZip;  // true=zip, false=unzip
149
    int    ActionCode;      // returns <0 if result valid
150
    int    HaveWide;        // wide string passed
151
    const void *MsgP;       // pointer to text/data
152
    const void *MsgP2;      // additional text
153
    __int64 FileSize;       // file size
154
    __int64 Written;        // number of bytes written
155
    long   Arg1;            // ErrorCode;
156
    unsigned Arg2;          // additional arg
157
    int Arg3;               // 'older'
158
    unsigned check;
159
};
160
#pragma pack(pop)
161
 
162
typedef struct ZCallBackStruct CB_Rec;
163
 
164
typedef struct ZCallBackStruct *PZCallBackStruct;
165
/* Declare a function pointer type for the BCB/Delphi callback function, to
166
 * be called by the DLL to pass updated status info back to BCB/Delphi.*/
167
 
168
typedef int(__stdcall *ZFunctionPtrType)(PZCallBackStruct ZCallbackRec);
169
 
170
#pragma pack(push, 1)
171
typedef struct
172
{
173
    DWORD  Method;   // low word = method, hi word nz=encrypt
174
    DWORD CRC;       // IN init encrypt crc OUT crc
175
    __int64 Size;
176
    void  *fSSInput;
177
    void  *fSSOutput;
178
}ZSSArgs;      // used stream-stream
179
#pragma pack(pop)
180
 
181
//ALL interface structures BYTE ALIGNED
182
/* stream operation arg usage
183
   zacStIdentify,
184
//      IN BufP = name
185
      IN Number = number
186
     OUT ArgLL = size, ArgD = Date, ArgA = Attrs
187
   zacStCreate,
188
//      IN BufP = name
189
      IN Number = number
190
     OUT StrmP = stream
191
   zacStClose,
192
      IN Number = number
193
      IN StrmP = stream
194
     OUT StrmP = stream (= NULL)
195
   zacStPosition,
196
      IN Number = number
197
      IN StrmP = stream, ArgLL = offset, ArgI = from
198
     OUT ArgLL = position
199
   zacStRead,
200
      IN Number = number
201
      IN StrmP = stream, BufP = buf, ArgI = count
202
     OUT ArgI = bytes read
203
   zacStWrite
204
      IN Number = number
205
      IN StrmP = stream, BufP = buf, ArgI = count
206
     OUT ArgI = bytes written
207
*/
208
#pragma pack(push, 1)
209
struct ZStreamRec
210
{
211
    void *Caller;           // "self" reference of the Delphi form }
212
    int Version;            // version no. of DLL }
213
    void *StrmP;            // pointer to 'tstream'
214
    int  Number;            // stream number
215
    int  OpCode;            // TZStreamActions
216
    unsigned char *BufP;    // pointer to stream src/dst
217
    __int64  ArgLL;         // file size or stream position offset
218
    int  ArgI;              // stream cnt or from
219
    unsigned ArgD;          // date
220
    unsigned ArgA;          // attribs
221
    unsigned Check;         // ZStream_Check;
222
};
223
#pragma pack(pop)
224
 
225
typedef struct ZStreamRec ZS_Rec;
226
 
227
typedef struct ZStreamRec *PZStreamRec;
228
/* Declare a function pointer type for the BCB/Delphi callback function, to
229
 * be called by the DLL to pass updated status info back to BCB/Delphi.*/
230
 
231
typedef int(__stdcall *ZStreamFuncPtrType)(PZStreamRec StreamRec);
232
 
233
// callback error return values
234
//#define  CALLBACK_FALSE      0
235
#define  CALLBACK_UNHANDLED  0
236
#define  CALLBACK_TRUE       1
237
#define  CALLBACK_2    2
238
#define  CALLBACK_3    3
239
#define  CALLBACK_4    4
240
#define  CALLBACK_IGNORED   -1  // unhandled ActionCode
241
#define  CALLBACK_CANCEL    -2  // user cancel
242
#define  CALLBACK_ABORT     -3
243
#define  CALLBACK_EXCEPTION -4  // handled exception
244
#define  CALLBACK_ERROR     -5  // unknown error
245
 
246
#define  ZPasswordFollows _T('<')
247
#define  ZSwitchFollows _T('|')
248
#define  ZForceNoRecurse _T('|')
249
#define  ZForceRecurse _T('>')
250
 
251
const DLL_OPT_OpIsZip           = 0x0000001;
252
const DLL_OPT_OpIsDelete        = 0x0000002; // delete - not used?
253
const DLL_OPT_OpIsUnz           = 0x0000004;
254
const DLL_OPT_OpIsTest          = 0x0000008;
255
/*
256
const DLL_OPT_CanWide           = 0x0000010;
257
const DLL_OPT_Quiet             = 0x0000020;
258
const DLL_OPT_NoSkip            = 0x0000040;
259
const DLL_OPT_Update            = 0x0000080;
260
const DLL_OPT_Freshen           = 0x0000100;
261
const DLL_OPT_Directories       = 0x0000200; // extract directories
262
const DLL_OPT_Overwrite         = 0x0000400; // overwrite all
263
const DLL_OPT_NoDirEntries      = 0x0000800;
264
const DLL_OPT_JunkDir           = 0x0001000;
265
const DLL_OPT_Recurse           = 0x0002000;
266
const DLL_OPT_Grow              = 0x0004000;
267
const DLL_OPT_Force             = 0x0008000; // Force to DOS 8.3 *** not used
268
const DLL_OPT_Move              = 0x0010000;
269
const DLL_OPT_System            = 0x0020000;
270
const DLL_OPT_JunkSFX           = 0x0040000; // remove sfx stub
271
const DLL_OPT_LatestTime        = 0x0080000; // set zip to latest file
272
const DLL_OPT_ArchiveFilesOnly  = 0x0100000; // zip when archive bit set
273
const DLL_OPT_ResetArchiveBit   = 0x0200000; // reset the archive bit after successfull zip
274
const DLL_OPT_Versioning        = 0x0400000; // rename old version instead of replace
275
const DLL_OPT_HowToMove         = 0x0800000;
276
const DLL_OPT_NoPrecalc         = 0x1000000; // don't precalc crc when encrypt
277
const DLL_OPT_Encrypt           = 0x2000000; // General encrypt, if not superseded
278
const DLL_OPT_Volume            = 0x4000000;
279
const DLL_OPT_NTFSStamps        = 0x8000000; // Generate or use NTFS time stamps
280
//const DLL_OPT_NoSkip            = 0x10000000; // Generate or use NTFS time stamps
281
*/
282
struct DllOptions
283
{
284
  union
285
  {
286
      unsigned opts;
287
      struct
288
      {
289
        unsigned OpIsZip          :1;
290
        unsigned OpIsDelete       :1; // delete - not used?
291
        unsigned OpIsUnz          :1;
292
        unsigned OpIsTest         :1;
293
        unsigned CanWide          :1;
294
        unsigned Quiet            :1;
295
        unsigned NotUsedNoSkip    :1;
296
        unsigned Update           :1;
297
        unsigned Freshen          :1;
298
        unsigned Directories      :1; // extract directories
299
        unsigned Overwrite        :1; // overwrite all
300
        unsigned NoDirEntries     :1;
301
        unsigned JunkDir          :1;
302
        unsigned Recurse          :1;
303
        unsigned Grow             :1;
304
        unsigned Forcexx            :1; // Force to DOS 8.3
305
        unsigned Move             :1;
306
        unsigned System           :1;
307
        unsigned JunkSFX          :1; // remove sfx stub
308
        unsigned LatestTime       :1; // set zip to latest file
309
        unsigned ArchiveFilesOnly :1; // zip when archive bit set
310
        unsigned ResetArchiveBit  :1; // reset the archive bit after successfull zip
311
        unsigned Versioning       :1; // rename old version instead of replace
312
        unsigned HowToMove        :1;
313
        unsigned NoPrecalc        :1; // don't precalc crc when encrypt
314
        unsigned Encrypt          :1; // General encrypt, if not superseded
315
        unsigned Volume           :1;
316
        unsigned NTFSStamps       :1; // generate or use NTFS time stamps
317
      };
318
  };
319
};
320
#pragma pack(push, 1)
321
typedef struct
322
{
323
    HWND                        fHandle;        // *
324
    void                        *fCaller;       // *
325
    long                        fVersion;       // *
326
    ZFunctionPtrType            ZCallbackFunc;  // *
327
    ZStreamFuncPtrType          ZStreamFunc;    // *
328
    int                         fVerbosity;     // ?
329
    unsigned                    fEncodedAs;     // Assume names encoded as
330
    ZSSArgs                     *fSS;           // used stream-stream
331
    unsigned long               fFromPage;      // country to use
332
    DllOptions                              fOptions;   // DLL_OPT_?
333
    // PasswordRequestCount, How many times a password will be asked per file
334
    unsigned long               fPwdReqCount;
335
    unsigned long               fEncodeAs;    // encode names as
336
    int                         fLevel;
337
    // General Date, if not superseded by FileData.fDate
338
    unsigned long               fDate;
339
    long                        fNotUsed[4];
340
    long                        fCheck;
341
}DllCommands;
342
#pragma pack(pop)           
343
#define DLLCOMMANDCHECK 0x03070505
344
 
345
#define OUR_VEM 30
346
#define Def_VER 20
347
 
348
#ifdef __cplusplus
349
extern "C"
350
{
351
#endif
352
    extern BOOL WINAPI  DllEntryPoint(HINSTANCE hinstDll, DWORD fdwRreason,
353
                                          LPVOID plvReserved);
354
    long WINAPI DZ_Exec(const DllCommands * C);
355
    long WINAPI DZ_Abort(void * C);
356
    long WINAPI DZ_Version(void);        
357
    long WINAPI DZ_PrivVersion(void);
358
    long WINAPI DZ_Name(void* buf, int bufsiz, int wide);
359
    const char* WINAPI DZ_Path(void);
360
    const char* WINAPI DZ_Banner(void);
361
#ifdef __cplusplus
362
}
363
 
364
#endif
365
 
366
#endif
367
 
368
 
369
 
370
 
371