1 /*---------------------------------------------------------------------------
5 Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
7 This header file contains the public macros and typedefs required by
8 both the UnZip sources and by any application using the UnZip API. If
9 UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes,
10 prototypes and extern variables used by the actual UnZip sources).
12 ---------------------------------------------------------------------------*/
13 /*---------------------------------------------------------------------------
14 This is version 2000-Apr-09 of the Info-ZIP copyright and license.
15 The definitive version of this document should be available at
16 ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely.
19 Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
21 For the purposes of this copyright and license, "Info-ZIP" is defined as
22 the following set of individuals:
24 Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
25 Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase,
26 Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum,
27 Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller,
28 Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel,
29 Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen,
30 Paul von Behren, Rich Wales, Mike White
32 This software is provided "as is," without warranty of any kind, express
33 or implied. In no event shall Info-ZIP or its contributors be held liable
34 for any direct, indirect, incidental, special or consequential damages
35 arising out of the use of or inability to use this software.
37 Permission is granted to anyone to use this software for any purpose,
38 including commercial applications, and to alter it and redistribute it
39 freely, subject to the following restrictions:
41 1. Redistributions of source code must retain the above copyright notice,
42 definition, disclaimer, and this list of conditions.
44 2. Redistributions in binary form must reproduce the above copyright
45 notice, definition, disclaimer, and this list of conditions in
46 documentation and/or other materials provided with the distribution.
48 3. Altered versions--including, but not limited to, ports to new operating
49 systems, existing ports with new graphical interfaces, and dynamic,
50 shared, or static library versions--must be plainly marked as such
51 and must not be misrepresented as being the original source. Such
52 altered versions also must not be misrepresented as being Info-ZIP
53 releases--including, but not limited to, labeling of the altered
54 versions with the names "Info-ZIP" (or any variation thereof, including,
55 but not limited to, different capitalizations), "Pocket UnZip," "WiZ"
56 or "MacZip" without the explicit permission of Info-ZIP. Such altered
57 versions are further prohibited from misrepresentative use of the
58 Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
60 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
61 "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and
63 ---------------------------------------------------------------------------*/
65 #ifndef __unzip_h /* prevent multiple inclusions */
68 /*---------------------------------------------------------------------------
69 Predefined, machine-specific macros.
70 ---------------------------------------------------------------------------*/
72 #ifdef __GO32__ /* MS-DOS extender: NOT Unix */
87 #if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX))
91 #if (defined(unix) || defined(_unix) || defined(__unix) || defined(__unix__))
95 #endif /* unix || _unix || __unix || __unix__ */
96 #if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux))
100 #endif /* M_XENIX || COHERENT || __hpux */
101 #if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__))
105 #endif /* CONVEX || MINIX || _AIX || __QNX__ */
106 #if (defined(__APPLE__))
110 #endif /* __APPLE__ */
112 #if (defined(VM_CMS) || defined(MVS))
116 #if (defined(__OS2__) && !defined(OS2))
120 #if (defined(__TANDEM) && !defined(TANDEM))
124 #if (defined(__VMS) && !defined(VMS))
128 #if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32))
131 #if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32))
135 #ifdef __COMPILER_KCC__
140 #endif /* __COMPILER_KCC__ */
142 /* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */
147 # if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32))
152 /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
156 #endif /* __POWERC */
158 #if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */
162 /* RSXNTDJ (at least up to v1.3) compiles for WIN32 (RSXNT) using a derivate
163 of the EMX environment, but defines MSDOS and __GO32__. ARG !!! */
164 #if (defined(MSDOS) && defined(WIN32))
165 # undef MSDOS /* WIN32 is >>>not<<< MSDOS */
167 #if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__))
171 #if (defined(linux) && !defined(LINUX))
179 #if (defined(THINK_C) || defined(MPW))
182 #if (defined(__MWERKS__) && defined(macintosh))
186 /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
187 * Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
188 * or Macintosh, or Windows NT, or Sequent, or Atari or IBM RS/6000.
190 #if (defined(__STDC__) || defined(MSDOS) || defined(WIN32) || defined(__EMX__))
198 #if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__))
206 #if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS) || defined(THEOS))
214 /* Sequent running Dynix/ptx: non-modern compiler */
215 #if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX)))
223 #if (defined(CMS_MVS) || (defined(__BEOS__) || defined(__HAIKU__))) /* || defined(CONVEX) */
232 /* turn off prototypes if requested */
233 #if (defined(NOPROTO) && defined(PROTO))
237 /* used to remove arguments in function prototypes for non-ANSI C */
244 /* enable the "const" keyword only if MODERN and if not otherwise instructed */
246 # if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST)))
247 # define ZCONST const
256 /*---------------------------------------------------------------------------
257 Grab system-specific public include headers.
258 ---------------------------------------------------------------------------*/
260 #ifdef POCKET_UNZIP /* WinCE port */
261 # include "wince/punzip.h" /* must appear before windows.h */
265 /* for UnZip, the "basic" part of the win32 api is sufficient */
266 # ifndef WIN32_LEAN_AND_MEAN
267 # define WIN32_LEAN_AND_MEAN
268 # define IZ_HASDEFINED_WIN32LEAN
270 # include <windows.h>
271 # include "windll/structs.h"
272 # ifdef IZ_HASDEFINEd_WIN32LEAN
273 # undef WIN32_LEAN_AND_MEAN
274 # undef IZ_HASDEFINED_WIN32LEAN
278 /*---------------------------------------------------------------------------
279 Grab system-dependent definition of EXPENTRY for prototypes below.
280 ---------------------------------------------------------------------------*/
283 #if (defined(OS2) && !defined(FUNZIP))
284 # ifdef UNZIP_INTERNAL
287 # define INCL_DOSPROCESS
288 # define INCL_DOSDEVICES
289 # define INCL_DOSDEVIOCTL
290 # define INCL_DOSERRORS
291 # define INCL_DOSMISC
293 # define INCL_REXXSAA
294 # include <rexxsaa.h>
296 # endif /* UNZIP_INTERNAL */
298 # define UZ_EXP EXPENTRY
299 #endif /* OS2 && !FUNZIP */
302 #if (defined(OS2) && !defined(FUNZIP))
303 # if (defined(__IBMC__) || defined(__WATCOMC__))
304 # define UZ_EXP _System /* compiler keyword */
308 #endif /* OS2 && !FUNZIP */
310 #if (defined(WINDLL) || defined(USE_UNZIP_LIB))
312 # define UZ_EXP WINAPI
314 # define UZ_EXP EXPENTRY
323 /*---------------------------------------------------------------------------
325 ---------------------------------------------------------------------------*/
327 #ifndef _IZ_TYPES_DEFINED
331 # ifndef AOS_VS /* mostly modern? */
332 # ifndef VAXC /* not fully modern, but has knows 'void' */
335 # endif /* !AOS_VS */
338 typedef unsigned char uch
; /* code assumes unsigned bytes; these type- */
339 typedef unsigned short ush
; /* defs replace byte/UWORD/ULONG (which are */
340 typedef unsigned long ulg
; /* predefined on some systems) & match zip */
341 #define _IZ_TYPES_DEFINED
342 #endif /* !_IZ_TYPES_DEFINED */
344 /* InputFn is not yet used and is likely to change: */
346 typedef int (UZ_EXP MsgFn
) (zvoid
*pG
, uch
*buf
, ulg size
, int flag
);
347 typedef int (UZ_EXP InputFn
) (zvoid
*pG
, uch
*buf
, int *size
, int flag
);
348 typedef void (UZ_EXP PauseFn
) (zvoid
*pG
, ZCONST
char *prompt
, int flag
);
349 typedef int (UZ_EXP PasswdFn
) (zvoid
*pG
, int *rcnt
, char *pwbuf
,
350 int size
, ZCONST
char *zfn
,
352 typedef int (UZ_EXP StatCBFn
) (zvoid
*pG
, int fnflag
, ZCONST
char *zfn
,
353 ZCONST
char *efn
, ZCONST zvoid
*details
);
354 typedef void (UZ_EXP UsrIniFn
) (void);
356 typedef int (UZ_EXP MsgFn
) ();
357 typedef int (UZ_EXP InputFn
) ();
358 typedef void (UZ_EXP PauseFn
) ();
359 typedef int (UZ_EXP PasswdFn
) ();
360 typedef int (UZ_EXP StatCBFn
) ();
361 typedef void (UZ_EXP UsrIniFn
) ();
364 typedef struct _UzpBuffer
{ /* rxstr */
365 ulg strlength
; /* length of string */
366 char *strptr
; /* pointer to string */
369 typedef struct _UzpInit
{
370 ulg structlen
; /* length of the struct being passed */
372 /* GRR: can we assume that each of these is a 32-bit pointer? if not,
373 * does it matter? add "far" keyword to make sure? */
377 UsrIniFn
*userfn
; /* user init function to be called after */
378 /* globals constructed and initialized */
380 /* pointer to program's environment area or something? */
381 /* hooks for performance testing? */
382 /* hooks for extra unzip -v output? (detect CPU or other hardware?) */
383 /* anything else? let me (Greg) know... */
386 typedef struct _UzpCB
{
387 ulg structlen
; /* length of the struct being passed */
388 /* GRR: can we assume that each of these is a 32-bit pointer? if not,
389 * does it matter? add "far" keyword to make sure? */
397 /* the collection of general UnZip option flags and option arguments */
398 typedef struct _UzpOpts
{
400 char *exdir
; /* pointer to extraction root directory (-d option) */
401 char *pwdarg
; /* pointer to command-line password (-P option) */
402 int zipinfo_mode
; /* behave like ZipInfo or like normal UnZip? */
403 int aflag
; /* -a: do ASCII-EBCDIC and/or end-of-line translation */
405 int bflag
; /* -b: force fixed record format for binary files */
408 int bflag
; /* -b: create text files in 'C' format (180)*/
411 int B_flag
; /* -B: back up existing files by renaming to *~ first */
413 int cflag
; /* -c: output to stdout */
414 int C_flag
; /* -C: match filenames case-insensitively */
416 int E_flag
; /* -E: [MacOS] show Mac extra field during restoring */
418 int fflag
; /* -f: "freshen" (extract only newer files) */
419 #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
420 int acorn_nfs_ext
; /* -F: RISC OS types & NFS filetype extensions */
422 int hflag
; /* -h: header line (zipinfo) */
424 int i_flag
; /* -i: [MacOS] ignore filenames stored in Mac e.f. */
427 int scanimage
; /* -I: scan image files */
429 int jflag
; /* -j: junk pathnames (unzip) */
430 #if ((defined(__BEOS__) || defined(__HAIKU__)) || defined(MACOS) || defined(HAS_JUNK_EXTRA_FIELD_OPTION))
431 int J_flag
; /* -J: ignore BeOS/MacOS extra field info (unzip) */
433 int lflag
; /* -12slmv: listing format (zipinfo) */
434 int L_flag
; /* -L: convert filenames from some OSes to lowercase */
435 int overwrite_none
; /* -n: never overwrite files (no prompting) */
437 int N_flag
; /* -N: restore comments as AmigaDOS filenotes */
439 int overwrite_all
; /* -o: OK to overwrite files without prompting */
441 int qflag
; /* -q: produce a lot less output */
443 #if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32))
444 int sflag
; /* -s: convert spaces in filenames to underscores */
447 int sflag
; /* -s: convert spaces in filenames to underscores */
449 #if (defined(MSDOS) || defined(__human68k__) || defined(OS2) || defined(WIN32))
450 int volflag
; /* -$: extract volume labels */
452 int tflag
; /* -t: test (unzip) or totals line (zipinfo) */
453 int T_flag
; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */
454 int uflag
; /* -u: "update" (extract only newer/brand-new files) */
455 int vflag
; /* -v: (verbosely) list directory */
456 int V_flag
; /* -V: don't strip VMS version numbers */
457 #if ((defined(__BEOS__) || defined(__HAIKU__)) || defined(TANDEM) || defined(THEOS) || defined(UNIX))
458 int X_flag
; /* -X: restore owner/protection or UID/GID or ACLs */
460 #if (defined(OS2) || defined(VMS) || defined(WIN32))
461 int X_flag
; /* -X: restore owner/protection or UID/GID or ACLs */
463 int zflag
; /* -z: display the zipfile comment (only, for unzip) */
464 #if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
465 int ddotflag
; /* -:: don't skip over "../" path elements */
470 /* intended to be a private struct: */
471 typedef struct _ver
{
472 uch major
; /* e.g., integer 5 */
473 uch minor
; /* e.g., 2 */
474 uch patchlevel
; /* e.g., 0 */
478 typedef struct _UzpVer
{
479 ulg structlen
; /* length of the struct being passed */
480 ulg flag
; /* bit 0: is_beta bit 1: uses_zlib */
481 char *betalevel
; /* e.g., "g BETA" or "" */
482 char *date
; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
483 char *zlib_version
; /* e.g., "0.95" or NULL */
485 _version_type zipinfo
;
486 _version_type os2dll
;
487 _version_type windll
;
490 /* for Visual BASIC access to Windows DLLs: */
491 typedef struct _UzpVer2
{
492 ulg structlen
; /* length of the struct being passed */
493 ulg flag
; /* bit 0: is_beta bit 1: uses_zlib */
494 char betalevel
[10]; /* e.g., "g BETA" or "" */
495 char date
[20]; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
496 char zlib_version
[10]; /* e.g., "0.95" or NULL */
498 _version_type zipinfo
;
499 _version_type os2dll
;
500 _version_type windll
;
503 typedef struct central_directory_file_header
{ /* CENTRAL */
504 uch version_made_by
[2];
505 uch version_needed_to_extract
[2];
506 ush general_purpose_bit_flag
;
507 ush compression_method
;
508 ulg last_mod_dos_datetime
;
513 ush extra_field_length
;
514 ush file_comment_length
;
515 ush disk_number_start
;
516 ush internal_file_attributes
;
517 ulg external_file_attributes
;
518 ulg relative_offset_local_header
;
522 #define UZPINIT_LEN sizeof(UzpInit)
523 #define UZPVER_LEN sizeof(UzpVer)
524 #define cbList(func) int (* UZ_EXP func)(char *filename, cdir_file_hdr *crec)
527 /*---------------------------------------------------------------------------
528 Return (and exit) values of the public UnZip API functions.
529 ---------------------------------------------------------------------------*/
531 /* external return codes */
532 #define PK_OK 0 /* no error */
533 #define PK_COOL 0 /* no error */
534 #define PK_WARN 1 /* warning error */
535 #define PK_ERR 2 /* error in zipfile */
536 #define PK_BADERR 3 /* severe error in zipfile */
537 #define PK_MEM 4 /* insufficient memory (during initialization) */
538 #define PK_MEM2 5 /* insufficient memory (password failure) */
539 #define PK_MEM3 6 /* insufficient memory (file decompression) */
540 #define PK_MEM4 7 /* insufficient memory (memory decompression) */
541 #define PK_MEM5 8 /* insufficient memory (not yet used) */
542 #define PK_NOZIP 9 /* zipfile not found */
543 #define PK_PARAM 10 /* bad or illegal parameters specified */
544 #define PK_FIND 11 /* no files found */
545 #define PK_DISK 50 /* disk full */
546 #define PK_EOF 51 /* unexpected EOF */
548 #define IZ_CTRLC 80 /* user hit ^C to terminate */
549 #define IZ_UNSUP 81 /* no files found: all unsup. compr/encrypt. */
550 #define IZ_BADPWD 82 /* no files found: all had bad password */
552 /* return codes of password fetches (negative = user abort; positive = error) */
553 #define IZ_PW_ENTERED 0 /* got some password string; use/try it */
554 #define IZ_PW_CANCEL -1 /* no password available (for this entry) */
555 #define IZ_PW_CANCELALL -2 /* no password, skip any further pwd. request */
556 #define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */
558 /* flag values for status callback function */
559 #define UZ_ST_START_EXTRACT 1 /* no details */
560 #define UZ_ST_IN_PROGRESS 2 /* no details */
561 #define UZ_ST_FINISH_MEMBER 3 /* 'details': extracted size */
563 /* return values of status callback function */
564 #define UZ_ST_CONTINUE 0
565 #define UZ_ST_BREAK 1
568 /*---------------------------------------------------------------------------
569 Prototypes for public UnZip API (DLL) functions.
570 ---------------------------------------------------------------------------*/
572 #define UzpMatch match
574 int UZ_EXP UzpMain
OF((int argc
, char **argv
));
575 int UZ_EXP UzpAltMain
OF((int argc
, char **argv
, UzpInit
*init
));
576 UzpVer
* UZ_EXP UzpVersion
OF((void));
577 void UZ_EXP UzpFreeMemBuffer
OF((UzpBuffer
*retstr
));
579 int UZ_EXP UzpUnzipToMemory
OF((char *zip
, char *file
, UzpOpts
*optflgs
,
580 UzpCB
*UsrFunc
, UzpBuffer
*retstr
));
581 int UZ_EXP UzpGrep
OF((char *archive
, char *file
,
582 char *pattern
, int cmd
, int SkipBin
,
586 int UZ_EXP UzpFileTree
OF((char *name
, cbList(callBack
),
587 char *cpInclude
[], char *cpExclude
[]));
590 void UZ_EXP UzpVersion2
OF((UzpVer2
*version
));
591 int UZ_EXP UzpValidate
OF((char *archive
, int AllCodes
));
594 /* default I/O functions (can be swapped out via UzpAltMain() entry point): */
596 int UZ_EXP UzpMessagePrnt
OF((zvoid
*pG
, uch
*buf
, ulg size
, int flag
));
597 int UZ_EXP UzpMessageNull
OF((zvoid
*pG
, uch
*buf
, ulg size
, int flag
));
598 int UZ_EXP UzpInput
OF((zvoid
*pG
, uch
*buf
, int *size
, int flag
));
599 void UZ_EXP UzpMorePause
OF((zvoid
*pG
, ZCONST
char *prompt
, int flag
));
600 int UZ_EXP UzpPassword
OF((zvoid
*pG
, int *rcnt
, char *pwbuf
,
601 int size
, ZCONST
char *zfn
,
605 /*---------------------------------------------------------------------------
606 Remaining private stuff for UnZip compilation.
607 ---------------------------------------------------------------------------*/
609 #ifdef UNZIP_INTERNAL
610 # include "unzpriv.h"
614 #endif /* !__unzip_h */