1 /*---------------------------------------------------------------------------
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).
10 ---------------------------------------------------------------------------*/
13 #ifndef __unzip_h /* prevent multiple inclusions */
16 /*---------------------------------------------------------------------------
17 Predefined, machine-specific macros.
18 ---------------------------------------------------------------------------*/
20 #ifdef __GO32__ /* MS-DOS extender: NOT Unix */
32 #if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX))
36 #if (defined(unix) || defined(__unix) || defined(__unix__))
40 #endif /* unix || __unix || __unix__ */
41 #if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux))
45 #endif /* M_XENIX || COHERENT || __hpux */
46 #if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__))
50 #endif /* CONVEX || MINIX || _AIX || __QNX__ */
52 #if (defined(VM_CMS) || defined(MVS))
56 #if (defined(__OS2__) && !defined(OS2))
60 #if (defined(__TANDEM) && !defined(TANDEM))
64 #if (defined(__VMS) && !defined(VMS))
68 #if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32))
71 #if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32))
75 #ifdef __COMPILER_KCC__
80 #endif /* __COMPILER_KCC__ */
82 /* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */
87 # if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32))
92 /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
98 #if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */
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 */
107 #if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__))
111 #if (defined(linux) && !defined(LINUX))
119 #if (defined(THINK_C) || defined(MPW))
122 #if (defined(__MWERKS__) && defined(macintosh))
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.
130 #if (defined(__STDC__) || defined(MSDOS) || defined(WIN32) || defined(__EMX__))
138 #if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__))
146 #if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS))
154 /* Sequent running Dynix/ptx: non-modern compiler */
155 #if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX)))
163 #if (defined(CMS_MVS) || defined(__BEOS__)) /* || defined(CONVEX) */
172 /* turn off prototypes if requested */
173 #if (defined(NOPROTO) && defined(PROTO))
177 /* used to remove arguments in function prototypes for non-ANSI C */
184 /* enable the "const" keyword only if MODERN and if not otherwise instructed */
186 # if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST)))
187 # define ZCONST const
196 /*---------------------------------------------------------------------------
197 Grab system-specific public include headers.
198 ---------------------------------------------------------------------------*/
200 #ifdef POCKET_UNZIP /* WinCE port */
201 # include "wince/punzip.h" /* must appear before windows.h */
205 # include <windows.h>
206 # include "windll/structs.h"
209 /*---------------------------------------------------------------------------
210 Grab system-dependent definition of EXPENTRY for prototypes below.
211 ---------------------------------------------------------------------------*/
214 #if (defined(OS2) && !defined(FUNZIP))
215 # ifdef UNZIP_INTERNAL
218 # define INCL_DOSPROCESS
219 # define INCL_DOSDEVICES
220 # define INCL_DOSDEVIOCTL
221 # define INCL_DOSERRORS
222 # define INCL_DOSMISC
224 # define INCL_REXXSAA
225 # include <rexxsaa.h>
227 # endif /* UNZIP_INTERNAL */
229 # define UZ_EXP EXPENTRY
230 #endif /* OS2 && !FUNZIP */
233 #if (defined(OS2) && !defined(FUNZIP))
234 # if (defined(__IBMC__) || defined(__WATCOMC__))
235 # define UZ_EXP _System /* compiler keyword */
239 #endif /* OS2 && !FUNZIP */
241 #if (defined(WINDLL) || defined(USE_UNZIP_LIB))
243 # define UZ_EXP WINAPI
245 # define UZ_EXP EXPENTRY
254 /*---------------------------------------------------------------------------
256 ---------------------------------------------------------------------------*/
258 #ifndef _IZ_TYPES_DEFINED
262 # ifndef AOS_VS /* mostly modern? */
263 # ifndef VAXC /* not fully modern, but has knows 'void' */
266 # endif /* !AOS_VS */
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 */
275 /* InputFn is not yet used and is likely to change: */
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
,
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);
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
) ();
295 typedef struct _UzpBuffer
{ /* rxstr */
296 ulg strlength
; /* length of string */
297 char *strptr
; /* pointer to string */
300 typedef struct _UzpInit
{
301 ulg structlen
; /* length of the struct being passed */
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? */
308 UsrIniFn
*userfn
; /* user init function to be called after */
309 /* globals constructed and initialized */
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... */
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? */
328 /* the collection of general UnZip option flags and option arguments */
329 typedef struct _UzpOpts
{
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 */
336 int bflag
; /* -b: force fixed record format for binary files */
339 int B_flag
; /* -B: back up existing files by renaming to *~ first */
341 int cflag
; /* -c: output to stdout */
342 int C_flag
; /* -C: match filenames case-insensitively */
344 int E_flag
; /* -E: [MacOS] show Mac extra field during restoring */
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 */
350 int hflag
; /* -h: header line (zipinfo) */
352 int i_flag
; /* -i: [MacOS] ignore filenames stored in Mac e.f. */
355 int scanimage
; /* -I: scan image files */
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) */
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) */
365 int N_flag
; /* -N: restore comments as AmigaDOS filenotes */
367 int overwrite_all
; /* -o: OK to overwrite files without prompting */
369 int qflag
; /* -q: produce a lot less output */
371 #if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32))
372 int sflag
; /* -s: convert spaces in filenames to underscores */
374 #if (defined(MSDOS) || defined(OS2) || defined(WIN32))
375 int volflag
; /* -$: extract volume labels */
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 */
385 #if (defined(OS2) || defined(WIN32))
386 int X_flag
; /* -X: restore owner/protection or UID/GID or ACLs */
388 int zflag
; /* -z: display the zipfile comment (only, for unzip) */
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 */
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 */
407 _version_type zipinfo
;
408 _version_type os2dll
;
409 _version_type windll
;
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 */
420 _version_type zipinfo
;
421 _version_type os2dll
;
422 _version_type windll
;
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
;
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
;
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)
449 /*---------------------------------------------------------------------------
450 Return (and exit) values of the public UnZip API functions.
451 ---------------------------------------------------------------------------*/
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 */
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 */
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) */
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, ...) */
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
492 /* return values of status callback function */
493 #define UZ_ST_CONTINUE 0
494 #define UZ_ST_BREAK 1
497 /*---------------------------------------------------------------------------
498 Prototypes for public UnZip API (DLL) functions.
499 ---------------------------------------------------------------------------*/
501 #define UzpMatch match
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
));
508 int UZ_EXP UzpUnzipToMemory
OF((char *zip
, char *file
, UzpOpts
*optflgs
,
509 UzpCB
*UsrFunc
, UzpBuffer
*retstr
));
512 int UZ_EXP UzpGrep
OF((char *archive
, char *file
,
513 char *pattern
, int cmd
, int SkipBin
,
517 int UZ_EXP UzpFileTree
OF((char *name
, cbList(callBack
),
518 char *cpInclude
[], char *cpExclude
[]));
521 void UZ_EXP UzpVersion2
OF((UzpVer2
*version
));
522 int UZ_EXP UzpValidate
OF((char *archive
, int AllCodes
));
525 /* default I/O functions (can be swapped out via UzpAltMain() entry point): */
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
,
536 /*---------------------------------------------------------------------------
537 Remaining private stuff for UnZip compilation.
538 ---------------------------------------------------------------------------*/
540 #ifdef UNZIP_INTERNAL
541 # include "unzpriv.h"
544 int pipeit(char *format
, ...);
545 int pipeit2(char *format
, int flag
, ...);
546 int confirm(char *format
, ...);
548 #endif /* !__unzip_h */