]> git.saurik.com Git - wxWidgets.git/blob - utils/Install/inczip/unzip.h
draw the selected items in another colour when the control doesn't have focus, a...
[wxWidgets.git] / utils / Install / inczip / unzip.h
1 /*---------------------------------------------------------------------------
2
3 unzip.h (new)
4
5 This header file contains the public macros and typedefs required by
6 both the UnZip sources and by any application using the UnZip API. If
7 UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes,
8 prototypes and extern variables used by the actual UnZip sources).
9
10 ---------------------------------------------------------------------------*/
11
12
13 #ifndef __unzip_h /* prevent multiple inclusions */
14 #define __unzip_h
15
16 /*---------------------------------------------------------------------------
17 Predefined, machine-specific macros.
18 ---------------------------------------------------------------------------*/
19
20 #ifdef __GO32__ /* MS-DOS extender: NOT Unix */
21 # ifdef unix
22 # undef unix
23 # endif
24 # ifdef __unix
25 # undef __unix
26 # endif
27 # ifdef __unix__
28 # undef __unix__
29 # endif
30 #endif
31
32 #if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX))
33 # define CONVEX
34 #endif
35
36 #if (defined(unix) || defined(__unix) || defined(__unix__))
37 # ifndef UNIX
38 # define UNIX
39 # endif
40 #endif /* unix || __unix || __unix__ */
41 #if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux))
42 # ifndef UNIX
43 # define UNIX
44 # endif
45 #endif /* M_XENIX || COHERENT || __hpux */
46 #if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__))
47 # ifndef UNIX
48 # define UNIX
49 # endif
50 #endif /* CONVEX || MINIX || _AIX || __QNX__ */
51
52 #if (defined(VM_CMS) || defined(MVS))
53 # define CMS_MVS
54 #endif
55
56 #if (defined(__OS2__) && !defined(OS2))
57 # define OS2
58 #endif
59
60 #if (defined(__TANDEM) && !defined(TANDEM))
61 # define TANDEM
62 #endif
63
64 #if (defined(__VMS) && !defined(VMS))
65 # define VMS
66 #endif
67
68 #if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32))
69 # define WIN32
70 #endif
71 #if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32))
72 # define WIN32
73 #endif
74
75 #ifdef __COMPILER_KCC__
76 # include <c-env.h>
77 # ifdef SYS_T20
78 # define TOPS20
79 # endif
80 #endif /* __COMPILER_KCC__ */
81
82 /* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */
83 #ifdef __BORLANDC__
84 # ifndef __TURBOC__
85 # define __TURBOC__
86 # endif
87 # if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32))
88 # define __MSDOS__
89 # endif
90 #endif
91
92 /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
93 #ifdef __POWERC
94 # define __TURBOC__
95 # define MSDOS
96 #endif /* __POWERC */
97
98 #if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */
99 # define MSDOS
100 #endif
101
102 /* RSXNTDJ (at least up to v1.3) compiles for WIN32 (RSXNT) using a derivate
103 of the EMX environment, but defines MSDOS and __GO32__. ARG !!! */
104 #if (defined(MSDOS) && defined(WIN32))
105 # undef MSDOS /* WIN32 is >>>not<<< MSDOS */
106 #endif
107 #if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__))
108 # undef __GO32__
109 #endif
110
111 #if (defined(linux) && !defined(LINUX))
112 # define LINUX
113 #endif
114
115 #ifdef __riscos
116 # define RISCOS
117 #endif
118
119 #if (defined(THINK_C) || defined(MPW))
120 # define MACOS
121 #endif
122 #if (defined(__MWERKS__) && defined(macintosh))
123 # define MACOS
124 #endif
125
126 /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
127 * Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
128 * or Macintosh, or Windows NT, or Sequent, or Atari or IBM RS/6000.
129 */
130 #if (defined(__STDC__) || defined(MSDOS) || defined(WIN32) || defined(__EMX__))
131 # ifndef PROTO
132 # define PROTO
133 # endif
134 # ifndef MODERN
135 # define MODERN
136 # endif
137 #endif
138 #if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__))
139 # ifndef PROTO
140 # define PROTO
141 # endif
142 # ifndef MODERN
143 # define MODERN
144 # endif
145 #endif
146 #if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS))
147 # ifndef PROTO
148 # define PROTO
149 # endif
150 # ifndef MODERN
151 # define MODERN
152 # endif
153 #endif
154 /* Sequent running Dynix/ptx: non-modern compiler */
155 #if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX)))
156 # ifndef PROTO
157 # define PROTO
158 # endif
159 # ifndef MODERN
160 # define MODERN
161 # endif
162 #endif
163 #if (defined(CMS_MVS) || defined(__BEOS__)) /* || defined(CONVEX) */
164 # ifndef PROTO
165 # define PROTO
166 # endif
167 # ifndef MODERN
168 # define MODERN
169 # endif
170 #endif
171
172 /* turn off prototypes if requested */
173 #if (defined(NOPROTO) && defined(PROTO))
174 # undef PROTO
175 #endif
176
177 /* used to remove arguments in function prototypes for non-ANSI C */
178 #ifdef PROTO
179 # define OF(a) a
180 #else
181 # define OF(a) ()
182 #endif
183
184 /* enable the "const" keyword only if MODERN and if not otherwise instructed */
185 #ifdef MODERN
186 # if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST)))
187 # define ZCONST const
188 # endif
189 #endif
190
191 #ifndef ZCONST
192 # define ZCONST
193 #endif
194
195
196 /*---------------------------------------------------------------------------
197 Grab system-specific public include headers.
198 ---------------------------------------------------------------------------*/
199
200 #ifdef POCKET_UNZIP /* WinCE port */
201 # include "wince/punzip.h" /* must appear before windows.h */
202 #endif
203
204 #ifdef WINDLL
205 # include <windows.h>
206 # include "windll/structs.h"
207 #endif
208
209 /*---------------------------------------------------------------------------
210 Grab system-dependent definition of EXPENTRY for prototypes below.
211 ---------------------------------------------------------------------------*/
212
213 #if 0
214 #if (defined(OS2) && !defined(FUNZIP))
215 # ifdef UNZIP_INTERNAL
216 # define INCL_NOPM
217 # define INCL_DOSNLS
218 # define INCL_DOSPROCESS
219 # define INCL_DOSDEVICES
220 # define INCL_DOSDEVIOCTL
221 # define INCL_DOSERRORS
222 # define INCL_DOSMISC
223 # ifdef OS2DLL
224 # define INCL_REXXSAA
225 # include <rexxsaa.h>
226 # endif
227 # endif /* UNZIP_INTERNAL */
228 # include <os2.h>
229 # define UZ_EXP EXPENTRY
230 #endif /* OS2 && !FUNZIP */
231 #endif /* 0 */
232
233 #if (defined(OS2) && !defined(FUNZIP))
234 # if (defined(__IBMC__) || defined(__WATCOMC__))
235 # define UZ_EXP _System /* compiler keyword */
236 # else
237 # define UZ_EXP
238 # endif
239 #endif /* OS2 && !FUNZIP */
240
241 #if (defined(WINDLL) || defined(USE_UNZIP_LIB))
242 # ifndef EXPENTRY
243 # define UZ_EXP WINAPI
244 # else
245 # define UZ_EXP EXPENTRY
246 # endif
247 #endif
248
249 #ifndef UZ_EXP
250 # define UZ_EXP
251 #endif
252
253
254 /*---------------------------------------------------------------------------
255 Public typedefs.
256 ---------------------------------------------------------------------------*/
257
258 #ifndef _IZ_TYPES_DEFINED
259 #ifdef MODERN
260 typedef void zvoid;
261 #else /* !MODERN */
262 # ifndef AOS_VS /* mostly modern? */
263 # ifndef VAXC /* not fully modern, but has knows 'void' */
264 # define void int
265 # endif /* !VAXC */
266 # endif /* !AOS_VS */
267 typedef char zvoid;
268 #endif /* ?MODERN */
269 typedef unsigned char uch; /* code assumes unsigned bytes; these type- */
270 typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */
271 typedef unsigned long ulg; /* predefined on some systems) & match zip */
272 #define _IZ_TYPES_DEFINED
273 #endif /* !_IZ_TYPES_DEFINED */
274
275 /* InputFn is not yet used and is likely to change: */
276 #ifdef PROTO
277 typedef int (UZ_EXP MsgFn) (zvoid *pG, uch *buf, ulg size, int flag);
278 typedef int (UZ_EXP InputFn) (zvoid *pG, uch *buf, int *size, int flag);
279 typedef void (UZ_EXP PauseFn) (zvoid *pG, ZCONST char *prompt, int flag);
280 typedef int (UZ_EXP PasswdFn) (zvoid *pG, int *rcnt, char *pwbuf,
281 int size, ZCONST char *zfn,
282 ZCONST char *efn);
283 typedef int (UZ_EXP StatCBFn) (zvoid *pG, int fnflag, ZCONST char *zfn,
284 ZCONST char *efn, ZCONST zvoid *details);
285 typedef void (UZ_EXP UsrIniFn) (void);
286 #else /* !PROTO */
287 typedef int (UZ_EXP MsgFn) ();
288 typedef int (UZ_EXP InputFn) ();
289 typedef void (UZ_EXP PauseFn) ();
290 typedef int (UZ_EXP PasswdFn) ();
291 typedef int (UZ_EXP StatCBFn) ();
292 typedef void (UZ_EXP UsrIniFn) ();
293 #endif /* ?PROTO */
294
295 typedef struct _UzpBuffer { /* rxstr */
296 ulg strlength; /* length of string */
297 char *strptr; /* pointer to string */
298 } UzpBuffer;
299
300 typedef struct _UzpInit {
301 ulg structlen; /* length of the struct being passed */
302
303 /* GRR: can we assume that each of these is a 32-bit pointer? if not,
304 * does it matter? add "far" keyword to make sure? */
305 MsgFn *msgfn;
306 InputFn *inputfn;
307 PauseFn *pausefn;
308 UsrIniFn *userfn; /* user init function to be called after */
309 /* globals constructed and initialized */
310
311 /* pointer to program's environment area or something? */
312 /* hooks for performance testing? */
313 /* hooks for extra unzip -v output? (detect CPU or other hardware?) */
314 /* anything else? let me (Greg) know... */
315 } UzpInit;
316
317 typedef struct _UzpCB {
318 ulg structlen; /* length of the struct being passed */
319 /* GRR: can we assume that each of these is a 32-bit pointer? if not,
320 * does it matter? add "far" keyword to make sure? */
321 MsgFn *msgfn;
322 InputFn *inputfn;
323 PauseFn *pausefn;
324 PasswdFn *passwdfn;
325 StatCBFn *statrepfn;
326 } UzpCB;
327
328 /* the collection of general UnZip option flags and option arguments */
329 typedef struct _UzpOpts {
330 #ifndef FUNZIP
331 char *exdir; /* pointer to extraction root directory (-d option) */
332 char *pwdarg; /* pointer to command-line password (-P option) */
333 int zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */
334 int aflag; /* -a: do ASCII-EBCDIC and/or end-of-line translation */
335 #ifdef VMS
336 int bflag; /* -b: force fixed record format for binary files */
337 #endif
338 #ifdef UNIXBACKUP
339 int B_flag; /* -B: back up existing files by renaming to *~ first */
340 #endif
341 int cflag; /* -c: output to stdout */
342 int C_flag; /* -C: match filenames case-insensitively */
343 #ifdef MACOS
344 int E_flag; /* -E: [MacOS] show Mac extra field during restoring */
345 #endif
346 int fflag; /* -f: "freshen" (extract only newer files) */
347 #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
348 int acorn_nfs_ext; /* -F: RISC OS types & NFS filetype extensions */
349 #endif
350 int hflag; /* -h: header line (zipinfo) */
351 #ifdef MACOS
352 int i_flag; /* -i: [MacOS] ignore filenames stored in Mac e.f. */
353 #endif
354 #ifdef RISCOS
355 int scanimage; /* -I: scan image files */
356 #endif
357 int jflag; /* -j: junk pathnames (unzip) */
358 #if (defined(__BEOS__) || defined(MACOS))
359 int J_flag; /* -J: ignore BeOS/MacOS extra field info (unzip) */
360 #endif
361 int lflag; /* -12slmv: listing format (zipinfo) */
362 int L_flag; /* -L: convert filenames from some OSes to lowercase */
363 int overwrite_none; /* -n: never overwrite files (no prompting) */
364 #ifdef AMIGA
365 int N_flag; /* -N: restore comments as AmigaDOS filenotes */
366 #endif
367 int overwrite_all; /* -o: OK to overwrite files without prompting */
368 #endif /* !FUNZIP */
369 int qflag; /* -q: produce a lot less output */
370 #ifndef FUNZIP
371 #if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32))
372 int sflag; /* -s: convert spaces in filenames to underscores */
373 #endif
374 #if (defined(MSDOS) || defined(OS2) || defined(WIN32))
375 int volflag; /* -$: extract volume labels */
376 #endif
377 int tflag; /* -t: test (unzip) or totals line (zipinfo) */
378 int T_flag; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */
379 int uflag; /* -u: "update" (extract only newer/brand-new files) */
380 int vflag; /* -v: (verbosely) list directory */
381 int V_flag; /* -V: don't strip VMS version numbers */
382 #if (defined(TANDEM) || defined(UNIX) || defined(VMS) || defined(__BEOS__))
383 int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */
384 #endif
385 #if (defined(OS2) || defined(WIN32))
386 int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */
387 #endif
388 int zflag; /* -z: display the zipfile comment (only, for unzip) */
389 #endif /* !FUNZIP */
390 } UzpOpts;
391
392 /* intended to be a private struct: */
393 typedef struct _ver {
394 uch major; /* e.g., integer 5 */
395 uch minor; /* e.g., 2 */
396 uch patchlevel; /* e.g., 0 */
397 uch not_used;
398 } _version_type;
399
400 typedef struct _UzpVer {
401 ulg structlen; /* length of the struct being passed */
402 ulg flag; /* bit 0: is_beta bit 1: uses_zlib */
403 char *betalevel; /* e.g., "g BETA" or "" */
404 char *date; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
405 char *zlib_version; /* e.g., "0.95" or NULL */
406 _version_type unzip;
407 _version_type zipinfo;
408 _version_type os2dll;
409 _version_type windll;
410 } UzpVer;
411
412 /* for Visual BASIC access to Windows DLLs: */
413 typedef struct _UzpVer2 {
414 ulg structlen; /* length of the struct being passed */
415 ulg flag; /* bit 0: is_beta bit 1: uses_zlib */
416 char betalevel[10]; /* e.g., "g BETA" or "" */
417 char date[20]; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
418 char zlib_version[10]; /* e.g., "0.95" or NULL */
419 _version_type unzip;
420 _version_type zipinfo;
421 _version_type os2dll;
422 _version_type windll;
423 } UzpVer2;
424
425 typedef struct central_directory_file_header { /* CENTRAL */
426 uch version_made_by[2];
427 uch version_needed_to_extract[2];
428 ush general_purpose_bit_flag;
429 ush compression_method;
430 ulg last_mod_dos_datetime;
431 ulg crc32;
432 ulg csize;
433 ulg ucsize;
434 ush filename_length;
435 ush extra_field_length;
436 ush file_comment_length;
437 ush disk_number_start;
438 ush internal_file_attributes;
439 ulg external_file_attributes;
440 ulg relative_offset_local_header;
441 } cdir_file_hdr;
442
443
444 #define UZPINIT_LEN sizeof(UzpInit)
445 #define UZPVER_LEN sizeof(UzpVer)
446 #define cbList(func) int (* UZ_EXP func)(char *filename, cdir_file_hdr *crec)
447
448
449 /*---------------------------------------------------------------------------
450 Return (and exit) values of the public UnZip API functions.
451 ---------------------------------------------------------------------------*/
452
453 /* external return codes */
454 #define PK_OK 0 /* no error */
455 #define PK_COOL 0 /* no error */
456 #define PK_GNARLY 0 /* no error */
457 #define PK_WARN 1 /* warning error */
458 #define PK_ERR 2 /* error in zipfile */
459 #define PK_BADERR 3 /* severe error in zipfile */
460 #define PK_MEM 4 /* insufficient memory (during initialization) */
461 #define PK_MEM2 5 /* insufficient memory (password failure) */
462 #define PK_MEM3 6 /* insufficient memory (file decompression) */
463 #define PK_MEM4 7 /* insufficient memory (memory decompression) */
464 #define PK_MEM5 8 /* insufficient memory (not yet used) */
465 #define PK_NOZIP 9 /* zipfile not found */
466 #define PK_PARAM 10 /* bad or illegal parameters specified */
467 #define PK_FIND 11 /* no files found */
468 #define PK_DISK 50 /* disk full */
469 #define PK_EOF 51 /* unexpected EOF */
470
471 #define IZ_CTRLC 80 /* user hit ^C to terminate */
472 #define IZ_UNSUP 81 /* no files found: all unsup. compr/encrypt. */
473 #define IZ_BADPWD 82 /* no files found: all had bad password */
474
475 /* internal and DLL-only return codes */
476 #define IZ_DIR 76 /* potential zipfile is a directory */
477 #define IZ_CREATED_DIR 77 /* directory created: set time and permissions */
478 #define IZ_VOL_LABEL 78 /* volume label, but can't set on hard disk */
479 #define IZ_EF_TRUNC 79 /* local extra field truncated (PKZIP'd) */
480
481 /* return codes of password fetches (negative = user abort; positive = error) */
482 #define IZ_PW_ENTERED 0 /* got some password string; use/try it */
483 #define IZ_PW_CANCEL -1 /* no password available (for this entry) */
484 #define IZ_PW_CANCELALL -2 /* no password, skip any further pwd. request */
485 #define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */
486
487 /* flag values for status callback function */
488 #define UZ_ST_START_EXTRACT 1
489 #define UZ_ST_IN_PROGRESS 2
490 #define UZ_ST_FINISH_MEMBER 3
491
492 /* return values of status callback function */
493 #define UZ_ST_CONTINUE 0
494 #define UZ_ST_BREAK 1
495
496
497 /*---------------------------------------------------------------------------
498 Prototypes for public UnZip API (DLL) functions.
499 ---------------------------------------------------------------------------*/
500
501 #define UzpMatch match
502
503 int UZ_EXP UzpMain OF((int argc, char **argv));
504 int UZ_EXP UzpAltMain OF((int argc, char **argv, UzpInit *init));
505 UzpVer * UZ_EXP UzpVersion OF((void));
506 void UZ_EXP UzpFreeMemBuffer OF((UzpBuffer *retstr));
507 #ifndef WINDLL
508 int UZ_EXP UzpUnzipToMemory OF((char *zip, char *file, UzpOpts *optflgs,
509 UzpCB *UsrFunc, UzpBuffer *retstr));
510 #endif
511 #ifndef WINDLL
512 int UZ_EXP UzpGrep OF((char *archive, char *file,
513 char *pattern, int cmd, int SkipBin,
514 UzpCB *UsrFunc));
515 #endif
516 #ifdef OS2
517 int UZ_EXP UzpFileTree OF((char *name, cbList(callBack),
518 char *cpInclude[], char *cpExclude[]));
519 #endif
520
521 void UZ_EXP UzpVersion2 OF((UzpVer2 *version));
522 int UZ_EXP UzpValidate OF((char *archive, int AllCodes));
523
524
525 /* default I/O functions (can be swapped out via UzpAltMain() entry point): */
526
527 int UZ_EXP UzpMessagePrnt OF((zvoid *pG, uch *buf, ulg size, int flag));
528 int UZ_EXP UzpMessageNull OF((zvoid *pG, uch *buf, ulg size, int flag));
529 int UZ_EXP UzpInput OF((zvoid *pG, uch *buf, int *size, int flag));
530 void UZ_EXP UzpMorePause OF((zvoid *pG, ZCONST char *prompt, int flag));
531 int UZ_EXP UzpPassword OF((zvoid *pG, int *rcnt, char *pwbuf,
532 int size, ZCONST char *zfn,
533 ZCONST char *efn));
534
535
536 /*---------------------------------------------------------------------------
537 Remaining private stuff for UnZip compilation.
538 ---------------------------------------------------------------------------*/
539
540 #ifdef UNZIP_INTERNAL
541 # include "unzpriv.h"
542 #endif
543
544 int pipeit(char *format, ...);
545 int pipeit2(char *format, int flag, ...);
546 int confirm(char *format, ...);
547
548 #endif /* !__unzip_h */