home *** CD-ROM | disk | FTP | other *** search
- From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Newsgroups: comp.sources.misc
- Subject: v44i066: unzip - Info-ZIP portable UnZip, version 5.12, Part01/20
- Date: 18 Sep 1994 23:13:54 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <csm-v44i066=unzip.231310@sparky.sterling.com>
- X-Md4-Signature: f600743db4d0e93c2e2c1466fdb4f456
-
- Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Posting-number: Volume 44, Issue 66
- Archive-name: unzip/part01
- Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT, AMIGA?, ATARI TOS, SGI, DEC, Cray, Convex, Amdahl, Sun
- Supersedes: unzip50: Volume 31, Issue 104-117
-
- UnZip is an extraction utility for archives compressed in .zip format (also
- called "zipfiles"). Although highly compatible both with PKWARE's PKZIP
- and PKUNZIP utilities for MS-DOS and with Info-ZIP's own Zip program, our
- primary objectives have been portability and non-MSDOS functionality.
-
- This version of UnZip has been ported to a wide array of hardware--from
- micros to supercomputers--and operating systems: Unix (many flavors),
- VMS, OS/2, MSDOS (+ Windows), NT, TOPS-20 (partly), AmigaDOS, Atari TOS,
- Macintosh and Human68k. UnZip features not found in PKUNZIP include source
- code; default extraction of directory trees (with a switch to defeat this,
- rather than the reverse); VMS, Macintosh and OS/2 extended file attributes;
- and, of course, the ability to run under most of your favorite operating
- systems. Plus, it's free. :-)
-
- For source distributions, see the main Contents file for a list of what's
- included, and read INSTALL for instructions on compiling (including OS-
- specific comments). The individual operating systems' Contents files (for
- example, vms/Contents) may list important compilation info in addition to
- explaining what files are what, so be sure to read them. Some of the ports
- have their own, special README files, so be sure to look for those, too.
-
- See unzip.1 or unzip.doc for usage (or the corresponding UnZipSFX, ZipInfo
- and fUnZip docs). For VMS, unzip_def.rnh or unzip_cli.help may be compiled
- into unzip.hlp and installed as a normal VMS help entry; see vms/descrip.mms.
-
- CHANGES AND NEW FEATURES
- ------------------------
- The 5.12 release mainly fixes some bugs in 5.11, including a silly pointer
- error in unzipsfx. The only new features are fairly minor:
-
- - ZipInfo check for dead space inside archives (PKZIP/Netware bug)
- - SFX_EXDIR compilation option to allow -d <exdir> with UnZipSFX
- - "unzip -vqqqq" prints just the version number (e.g., "512")
-
- Since neither 5.11 nor 5.1 was posted to Usenet, here's a summary of their
- new features. In UnZip 5.11:
-
- - UnZipSFX, a self-extraction stub for prepending to (new-style) zipfiles
- (tested under Unix, VMS, MS-DOS, OS/2, etc.; NOT portable *across* OSes)
- - unshrink() rewritten to avoid copyright problems; 32-bit version only
- - strings moved to far memory in MS-DOS: can use small model again (MSC)
- - numerous customization options (see INSTALL)
- - diagnostic screen with -v option and no zipfile (i.e., "unzip -v")
- - -C option for case-insensitive filename matching (esp. for MS-DOS, OS/2)
- - more bad-zipfile "intelligence" (can sometimes even extract concatenated
- multi-part archives)
- - former -U behavior is now the default; new -L option to provide what was
- the default behavior (auto-conversion of uppercase-OS filenames to lower
- case)
- - ZipInfo -T option to print times in decimal format (yymmdd.hhmmss) for
- piping into sort(1)
- - performance tweaks for listing archive contents
- - improved/expanded documentation, esp. man pages (*.doc files) and INSTALL
-
- In UnZip 5.1:
-
- - wildcard zipfiles (e.g., "unzip -tq \*.zip")
- - extract to a directory other than the current one (-d <exdir> option)
- - auto-conversion of text files
- - ANSI sequences disabled in comments and filenames (avoid "ANSI bombs")
- - ZipInfo incorporated into UnZip (-Z option)
- - full Amiga, Atari, Mac, NT and Human68K support (partial TOPS-20)
- - performance tuning for 35-70% faster extraction (depends on compression
- method)
-
- Note that, according to one tester, the 32-bit MS-DOS version is now *faster*
- than PKUNZIP on most archives! Cool.
-
- DISTRIBUTION
- ------------
- If you have a question regarding redistribution of Info-ZIP software,
- either as-is, as packaging for a commercial product, or as an integral
- part of a commercial product, read the Frequently Asked Questions (FAQ)
- section of the included COPYING file.
-
- Insofar as C compilers are rare on some platforms and the authors only
- have direct access to Unix, VMS, OS/2, MS-DOS, Mac, Amiga and Atari
- systems, others may wish to provide ready-to-run executables for new
- systems. In general there is no problem with this; we require only that
- such distributions include this README file, the Where file, the COPYING
- file (contains copyright/redistribution information), and the appropriate
- documentation files (unzip.doc and/or unzip.1 for UnZip, etc.). If the
- local system provides a way to make self-extracting archives in which both
- the executables and text files may be stored together, that is best (in
- particular, use UnZipSFX if at all possible, even if it's a few kilobytes
- bigger than the alternatives); otherwise we suggest a bare UnZip executable
- and a separate zipfile containing the remaining text and binary files. If
- another archiving method is in common use on the target system (for example,
- Zoo or LHa), that may also be used.
-
- BUGS AND NEW PORTS: CONTACTING INFO-ZIP
- ----------------------------------------
- All bug reports and patches (context diffs only, please!) should go to
- zip-bugs@wkuvx1.wku.edu, which is the e-mail address for the Info-ZIP
- authors. "Dumb questions" which aren't adequately answered in the docu-
- mentation should also be directed here rather than to a global forum such
- as Usenet. (Kindly make certain that your questions *isn't* answered by
- the documentation, however--a great deal of effort has gone into making
- it clear and complete.) Suggestions for new features can be sent to
- info-zip@wkuvx1.wku.edu, a mailing list for the Info-ZIP beta testers,
- for discussion (the authors hang out here as well, of course), although
- we don't promise to act on all suggestions. If it is something which is
- manifestly useful, sending the required patches to zip-bugs directly (as
- per the instructions in the ZipPorts file) is likely to produce a quicker
- response than asking us to do it--the authors are always somewhat short
- on time. (Please do NOT send patches or encoded zipfiles to the info-zip
- address.)
-
- If you are considering a port, not only should you read the ZipPorts file,
- but also please check in with zip-bugs BEFORE getting started, since the
- code is constantly being updated behind the scenes. For example, an Acorn/
- Archimedes port is already almost complete, as is an OS/2 dynamic link lib-
- rary (DLL) version; VMOS, VM/CMS, Netware, QDOS and NT DLL ports are claimed
- to be under construction, although we have yet to see any up-to-date patches.
- We will arrange to send you the latest sources. The alternative is the pos-
- sibility that your hard work will be tucked away in a sub-archive and mostly
- ignored, or completely ignored if someone else has already done the port
- (and you'd be surprised how often this has happened). IBM mainframe ports
- (VM/CMS and/or MVS) would be particularly welcome. (It can't be *that* hard,
- folks...the VMS filesystem is similar in many ways.)
-
-
- BETA TESTING: JOINING INFO-ZIP
- -------------------------------
- If you'd like to keep up to date with our UnZip (and companion Zip utility)
- development, join the ranks of beta testers, add your own thoughts and con-
- tributions, etc., send a two-line mail message containing the commands HELP
- and LIST (on separate lines in the body of the message, not on the subject
- line) to mxserver@wkuvx1.wku.edu. You'll receive two messages listing the
- various Info-ZIP mailing-list formats which are available (and also various
- unrelated lists) and instructions on how to subscribe to one or more of them
- (courtesy of Hunter Goatley). As of mid-1994, subscribing to the announce-
- ments list requires a command of the form
-
- SUBSCRIBE Info-ZIP-announce "Joe Isuzu"
-
- The discussion list is called either Info-ZIP or Info-ZIP-digest, depending
- on one's preference for delivery.
-
- -- Greg Roelofs (Cave Newt), UnZip maintainer/container/explainer and
- developer guy, with inspiration from David Kirschbaum
- ----------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: unzip-5.12 unzip-5.12/amiga unzip-5.12/atari
- # unzip-5.12/human68k unzip-5.12/mac unzip-5.12/msdos
- # unzip-5.12/msdos/README unzip-5.12/nt unzip-5.12/os2
- # unzip-5.12/tops20 unzip-5.12/unix unzip-5.12/unzip.h
- # unzip-5.12/vms
- # Wrapped by kent@sparky on Sat Sep 17 23:33:34 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 20)."'
- if test ! -d 'unzip-5.12' ; then
- echo shar: Creating directory \"'unzip-5.12'\"
- mkdir 'unzip-5.12'
- fi
- if test ! -d 'unzip-5.12/amiga' ; then
- echo shar: Creating directory \"'unzip-5.12/amiga'\"
- mkdir 'unzip-5.12/amiga'
- fi
- if test ! -d 'unzip-5.12/atari' ; then
- echo shar: Creating directory \"'unzip-5.12/atari'\"
- mkdir 'unzip-5.12/atari'
- fi
- if test ! -d 'unzip-5.12/human68k' ; then
- echo shar: Creating directory \"'unzip-5.12/human68k'\"
- mkdir 'unzip-5.12/human68k'
- fi
- if test ! -d 'unzip-5.12/mac' ; then
- echo shar: Creating directory \"'unzip-5.12/mac'\"
- mkdir 'unzip-5.12/mac'
- fi
- if test ! -d 'unzip-5.12/msdos' ; then
- echo shar: Creating directory \"'unzip-5.12/msdos'\"
- mkdir 'unzip-5.12/msdos'
- fi
- if test -f 'unzip-5.12/msdos/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/msdos/README'\"
- else
- echo shar: Extracting \"'unzip-5.12/msdos/README'\" \(4906 characters\)
- sed "s/^X//" >'unzip-5.12/msdos/README' <<'END_OF_FILE'
- XNotes about MS-DOS executables and compilers:
- X
- X - Borland start-up code is reported to switch the screen mode auto-
- X matically if it's not 80 columns (or possibly 40) and either 25, 43
- X or 50 lines. In particular, extended modes such as 100x40 are not
- X retained.
- X
- X - Borland start-up code also uses interrupt 1Ah, causing incorrect
- X behavior (including lock-ups) on some Japanese MS-DOS machines such
- X as the Fujitsu FMR series, which lack this interrupt.
- X
- X - Some(?) Borland compilers are apparently incapable of putting static
- X data into far memory; this means all of UnZip's strings are in near
- X memory, and there is not enough room to enable ZipInfo in the small
- X memory model. Even if strings are in far memory, the *code* segment
- X produced by Borland compilers is now too big for one segment. The
- X large memory model is therefore the default for Borland compilers, but
- X it may be possible to compile in the medium model as well (not tested).
- X
- X - Older Borland compilers do not understand source files with Unix
- X line-endings (LF rather than CR/LF). Use "flip" or a similar utility
- X to convert the line endings before compiling, or take a look at the
- X Borland.fix file in the UnZip source distribution.
- X
- X - Microsoft C 5.1 large-model code is more than an order of magnitude
- X slower than the identical code compiled with MSC 6 or 7 (a factor of
- X 15 in our tests, actually). This may be due to a lousy optimizer or
- X lousy libraries; regardless, since UnZip is hovering at the doorstep
- X of the large memory model, we recommend upgrading to a later version
- X of the compiler.
- X
- XFor these reasons, Info-ZIP's distributed versions of the 16-bit MS-DOS
- Xexecutables are compiled with MSC 6 or 7.
- X
- X - The default wildcard ("globbing") behavior of djgpp/go32 is disabled
- X by default in UnZip, but this can be overridden if the GO32 environment
- X variable is set to "glob". This will cause UnZip to fail with various
- X odd errors about "filename not matched" and the like; to avoid this, set
- X the GO32 variable to "noglob" or unset it altogether. (The documented
- X method of avoiding this by quoting wildcards with single quotes was
- X buggy in djgpp 1.11 but is reported fixed in 1.12; not tested.)
- X
- X - djgpp's handling of timezones, necessary for the correct conversion of
- X MS-DOS filetimes to those used in the Unix-like C library, is completely
- X broken in djgpp 1.12 and probably earlier versions as well. It is fixed
- X (or very close to it) in the most recent 1.12m1 beta, so be sure to up-
- X grade to 1.12m1 before compiling. Otherwise UnZip's -f and -u (freshen/
- X update) functions will not work correctly.
- X
- X - emx+gcc's DOS extender does not understand DPMI, and while there is an
- X alternative extender called RSX available (found in dpmigcc4.zip as of
- X August 1994), its setup is somewhat kludgy when the local memory manager
- X supports both DPMI and VCPI (or something else). It's also not yet as
- X widely known or available as djgpp.
- X
- XFor these reasons Info-ZIP's distributed 32-bit MS-DOS executables are com-
- Xpiled with djgpp 1.12m1. These are stand-alone programs; the "go32" DOS
- Xextender is included inside the executables. They generally run up to twice
- Xas fast as the 16-bit versions, but they only work on 386's and above. In
- Xsome cases they're actually slower. If this is the case for you, first try
- Xrunning under plain DOS, after removing any memory manager in your config.sys
- Xand rebooting, to check if the slowdown is due to your memory manager. (Ac-
- Xcording to notes found in another package, there was a known conflict between
- Xthe go32 extender and QEMM's DPMI; this was apparently just fixed in QEMM
- X7.04/QDPMI 1.05, but if you still have an older version (1.03 or 1.01), add
- X"set GO32=nodpmi" to your autoexec.bat to avoid the conflict.) There may
- Xalso be a problem with the time spent by the djgpp runtime creating and de-
- Xleting a swap file. If you use SMARTDRV or another disk cache, make sure
- Xthat writes are also cached.
- X
- XIf you already have djgpp 1.12m1 or later (or, more specifically, go32.exe
- X1.12m1 or later somewhere in your PATH), you can remove go32.exe from
- Xunzip386.exe to get a smaller executable:
- X
- X exe2coff unzip386.exe
- X coff2exe unzip386
- X del unzip386
- X
- XAs noted above, go32/djgpp has its own wildcard-expansion routines which
- Xare disabled in UnZip by default because of incompatibilities with UnZip's
- Xown wildcards. Stripping the go32 extender may cause go32's wildcards to
- Xbe re-enabled; in this case you must set GO32 as follows for UnZip to work
- Xcorrectly:
- X
- X set GO32=noglob
- X
- XWith this setting unzip386.exe behaves just like unzip.exe.
- X
- XFor other problems related to DJGPP, read the documentation provided in
- Xoak.oakland.edu:/pub/msdos/djgpp/djdev112.zip. If a problem occurs with
- Xunzip386.exe, check first if it also occurs with unzip.exe before reporting
- Xit.
- X
- X
- XGRR 940828
- END_OF_FILE
- if test 4906 -ne `wc -c <'unzip-5.12/msdos/README'`; then
- echo shar: \"'unzip-5.12/msdos/README'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/msdos/README'
- fi
- if test ! -d 'unzip-5.12/nt' ; then
- echo shar: Creating directory \"'unzip-5.12/nt'\"
- mkdir 'unzip-5.12/nt'
- fi
- if test ! -d 'unzip-5.12/os2' ; then
- echo shar: Creating directory \"'unzip-5.12/os2'\"
- mkdir 'unzip-5.12/os2'
- fi
- if test ! -d 'unzip-5.12/tops20' ; then
- echo shar: Creating directory \"'unzip-5.12/tops20'\"
- mkdir 'unzip-5.12/tops20'
- fi
- if test ! -d 'unzip-5.12/unix' ; then
- echo shar: Creating directory \"'unzip-5.12/unix'\"
- mkdir 'unzip-5.12/unix'
- fi
- if test -f 'unzip-5.12/unzip.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/unzip.h'\"
- else
- echo shar: Extracting \"'unzip-5.12/unzip.h'\" \(59872 characters\)
- sed "s/^X//" >'unzip-5.12/unzip.h' <<'END_OF_FILE'
- X/*---------------------------------------------------------------------------
- X
- X unzip.h
- X
- X This header file is used by all of the UnZip source files. Its contents
- X are divided into seven more-or-less separate sections: predefined macros,
- X OS-dependent includes, (mostly) OS-independent defines, typedefs, function
- X prototypes (or "forward declarations," in the case of non-ANSI compilers),
- X macros, and global-variable declarations.
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X
- X#ifndef __unzip_h /* prevent multiple inclusions */
- X#define __unzip_h
- X
- X/*****************************************/
- X/* Predefined, Machine-specific Macros */
- X/*****************************************/
- X
- X#if defined(__GO32__) && defined(unix) /* MS-DOS extender: NOT Unix */
- X# undef unix
- X#endif
- X#if (defined(__convex__) && !defined(__convexc__))
- X# define __convexc__
- X#endif
- X
- X#if defined(unix) || defined(M_XENIX) || defined(COHERENT) || defined(__hpux)
- X# ifndef UNIX
- X# define UNIX
- X# endif
- X#endif /* unix || M_XENIX || COHERENT || __hpux */
- X#if defined(__convexc__) || defined(MINIX)
- X# ifndef UNIX
- X# define UNIX
- X# endif
- X#endif /* __convexc__ || MINIX */
- X
- X#ifdef __COMPILER_KCC__
- X# include <c-env.h>
- X# ifdef SYS_T20
- X# define TOPS20
- X# endif
- X#endif /* __COMPILER_KCC__ */
- X
- X/* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
- X#ifdef __POWERC
- X# define __TURBOC__
- X# define MSDOS
- X#endif /* __POWERC */
- X#if defined(__MSDOS__) && (!defined(MSDOS)) /* just to make sure */
- X# define MSDOS
- X#endif
- X
- X#if defined(linux) && (!defined(LINUX))
- X# define LINUX
- X#endif
- X
- X/* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
- X * Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
- X * or Macintosh, or Windows NT, or Sequent, or Atari.
- X */
- X#if defined(__STDC__) || defined(MSDOS) || defined(sgi)
- X# ifndef PROTO
- X# define PROTO
- X# endif
- X# define MODERN
- X#endif
- X#if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__)
- X# ifndef PROTO
- X# define PROTO
- X# endif
- X# define MODERN
- X#endif
- X#if defined(THINK_C) || defined(MPW) || defined(WIN32) || defined(_SEQUENT_)
- X# ifndef PTX /* Sequent running Dynix/ptx: non-modern compiler */
- X# ifndef PROTO
- X# define PROTO
- X# endif
- X# define MODERN
- X# endif
- X#endif
- X#if defined(ATARI_ST) || defined(__BORLANDC__) /* || defined(__convexc__) */
- X# ifndef PROTO
- X# define PROTO
- X# endif
- X# define MODERN
- X#endif
- X
- X/* turn off prototypes if requested */
- X#if defined(NOPROTO) && defined(PROTO)
- X# undef PROTO
- X#endif
- X
- X/* used to remove arguments in function prototypes for non-ANSI C */
- X#ifdef PROTO
- X# define OF(a) a
- X#else
- X# define OF(a) ()
- X#endif
- X
- X/* bad or (occasionally?) missing stddef.h: */
- X#if defined(M_XENIX) || defined(DNIX)
- X# define NO_STDDEF_H
- X#endif
- X
- X#if defined(apollo) /* defines __STDC__ */
- X# define NO_STDLIB_H
- X#endif /* apollo */
- X
- X#ifdef DNIX
- X# define SYSV
- X# define SHORT_NAMES /* 14-char limitation on path components */
- X/* # define FILENAME_MAX 14 */
- X# define FILENAME_MAX NAME_MAX /* GRR: experiment */
- X#endif
- X
- X#if (defined(__SYSTEM_FIVE) || defined(M_SYSV) || defined(M_SYS5))
- X# ifndef SYSV
- X# define SYSV
- X# endif
- X#endif /* __SYSTEM_FIVE || M_SYSV || M_SYS5 */
- X
- X#if (defined(ultrix) || defined(bsd4_2) || defined(sun) || defined(pyr))
- X# if (!defined(BSD) && !defined(SYSV))
- X# define BSD
- X# endif
- X#endif /* ultrix || bsd4_2 || sun || pyr */
- X#if defined(__convexc__)
- X# if (!defined(BSD) && !defined(SYSV))
- X# define BSD
- X# endif
- X#endif /* __convexc__ */
- X
- X#ifdef pyr /* Pyramid */
- X# ifdef BSD
- X# define pyr_bsd
- X# define USE_STRINGS_H /* instead of more common string.h */
- X# endif
- X# define ZMEM /* should ZMEM only be for BSD universe...? */
- X# define DECLARE_ERRNO /* (AT&T memcpy was claimed to be very slow) */
- X#endif /* pyr */
- X
- X#if (defined(CRAY) && defined(ZMEM))
- X# undef ZMEM
- X#endif
- X
- X/* stat() bug for Borland, Watcom, VAX C (also GNU?), and Atari ST MiNT on
- X * TOS filesystems: returns 0 for wildcards! (returns 0xffffffff on Minix
- X * filesystem or U: drive under Atari MiNT) */
- X#if (defined(__TURBOC__) || defined(__WATCOMC__) || defined(VMS))
- X# define WILD_STAT_BUG
- X#endif
- X#if (defined(__MINT__))
- X# define WILD_STAT_BUG
- X#endif
- X
- X#ifdef WILD_STAT_BUG
- X# define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf))
- X#else
- X# define SSTAT stat
- X#endif
- X
- X#ifdef REGULUS /* returns the inode number on success(!)...argh argh argh */
- X# define stat(p,s) zstat(p,s)
- X#endif
- X
- X#define STRNICMP zstrnicmp
- X
- X
- X
- X
- X
- X
- X/***************************/
- X/* OS-Dependent Includes */
- X/***************************/
- X
- X#ifndef MINIX /* Minix needs it after all the other includes (?) */
- X# include <stdio.h>
- X#endif
- X#include <ctype.h> /* skip for VMS, to use tolower() function? */
- X#include <errno.h> /* used in mapname() */
- X#ifdef USE_STRINGS_H
- X# include <strings.h> /* strcpy, strcmp, memcpy, index/rindex, etc. */
- X#else
- X# include <string.h> /* strcpy, strcmp, memcpy, strchr/strrchr, etc. */
- X#endif
- X#ifdef MODERN
- X# include <limits.h> /* GRR: EXPERIMENTAL! (can be deleted) */
- X#endif
- X
- X#ifdef EFT
- X# define LONGINT off_t /* Amdahl UTS nonsense ("extended file types") */
- X#else
- X# define LONGINT long
- X#endif
- X
- X#ifdef MODERN
- X# ifndef NO_STDDEF_H
- X# include <stddef.h>
- X# endif
- X# ifndef NO_STDLIB_H
- X# include <stdlib.h> /* standard library prototypes, malloc(), etc. */
- X# endif
- X typedef size_t extent;
- X typedef void voidp;
- X#else /* !MODERN */
- X LONGINT lseek();
- X# ifdef VAXC /* not fully modern, but does have stdlib.h */
- X# include <stdlib.h>
- X# else
- X char *malloc();
- X# endif
- X typedef unsigned int extent;
- X typedef char voidp;
- X# define void int
- X#endif /* ?MODERN */
- X
- X/* this include must be down here for SysV.4, for some reason... */
- X#include <signal.h> /* used in unzip.c, file_io.c */
- X
- X/*---------------------------------------------------------------------------
- X Amiga section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef AMIGA
- X# include "amiga/amiga.h"
- X# ifndef AZTEC_C
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X# endif
- X# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 1
- X# define PutNativeEOL *q++ = native(LF);
- X/* # define USE_FWRITE if write() returns 16-bit int */
- X# define PIPE_ERROR (errno == 9999) /* always false */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Atari ST section:
- X ---------------------------------------------------------------------------*/
- X
- X#if (defined(ATARI_ST) || defined(__MINT__)) /* comments by [cjh] */
- X# ifdef __TURBOC__
- X# include <ext.h> /* stat() */
- X# include <tos.h> /* OS-specific functions (Fdup) */
- X# endif
- X# include <time.h>
- X# ifndef __MINT__
- X# define dup Fdup
- X# define mkdir Dcreate
- X# define DIR_END '\\'
- X# else
- X# include <sys/types.h> /* didn't we include this already? */
- X# include <sys/stat.h>
- X# include <fcntl.h> /* O_BINARY */
- X# include <unistd.h> /* dup proto & unix system calls live here */
- X# include <time.h>
- X# include <stdio.h> /* didn't we include this already? */
- X# define dup dup
- X# define mkdir mkdir
- X# define DIR_END '/' /* much sexier than DOS filenames... */
- X# define timezone _timezone /* oops */
- X# define DIRENT
- X# define SYMLINKS
- X# ifdef S_ISLNK /* WARNING: horrible kludge!!!! */
- X# undef S_ISLNK /* MiNTlibs & POSIX don't define S_ISLNK */
- X# define S_ISLNK(a) (((a) & 0xa000) == 0xa000)
- X# endif
- X# ifdef SHORT_NAMES /* library will truncate weird names on TOS fs */
- X# undef SHORT_NAMES
- X# endif
- X# ifndef ZMEM
- X# define ZMEM /* we have bcopy, etc., ifndef __STRICT_ANSI__ */
- X# endif
- X# endif /* __MINT__ */
- X# ifndef S_IFMT
- X# define S_IFMT (S_IFCHR | S_IFREG | S_IFDIR)
- X# endif
- X# define DATE_FORMAT DF_MDY
- X# ifndef lenEOL
- X# define lenEOL 2 /* DOS convention; MiNT doesn't really care */
- X# endif
- X# ifndef PutNativeEOL
- X# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- X# endif
- X# define EXE_EXTENSION ".tos" /* or .ttp instead?? */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Human68k/X68000 section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef __human68k__ /* DO NOT DEFINE DOS_OS2 HERE! If Human68k is so much */
- X# include <time.h> /* like MS-DOS and/or OS/2, create DOS_HUM_OS2 macro. */
- X# include <fcntl.h>
- X# include <io.h>
- X# include <conio.h>
- X# include <jctype.h>
- X# include <sys/stat.h>
- X# define DATE_FORMAT DF_YMD /* Japanese standard */
- X /* GRR: these EOL macros are guesses */
- X# define lenEOL 2
- X# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- X# define EXE_EXTENSION ".exe" /* just a guess... */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Mac section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef THINK_C
- X# define MACOS
- X# ifndef __STDC__ /* if Think C hasn't defined __STDC__ ... */
- X# define __STDC__ 1 /* make sure it's defined: it needs it */
- X# else
- X# if !__STDC__ /* sometimes __STDC__ is defined as 0; */
- X# undef __STDC__ /* it needs to be 1 or required header */
- X# define __STDC__ 1 /* files are not properly included. */
- X# endif /* !__STDC__ */
- X# endif
- X# define CREATOR 'KAHL'
- X# define MAIN unzip
- X#endif /* THINK_C */
- X
- X#ifdef MPW
- X# define MACOS
- X# include <Errors.h>
- X# include <Files.h>
- X# include <Memory.h>
- X# include <Quickdraw.h>
- X# include <ToolUtils.h>
- X# ifdef fileno
- X# undef fileno
- X# endif
- X# ifdef MCH_MACINTOSH
- X# define CREATOR 'Manx'
- X# else
- X# define CREATOR 'MPS '
- X# endif
- X#endif /* MPW */
- X
- X#ifdef MACOS
- X# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- X# define fileno(x) ((x) == stdout ? 1 : (short)(x))
- X# define open(x,y) macopen((x), (y), gnVRefNum, glDirID)
- X# define fopen(x,y) macfopen((x), (y), gnVRefNum, glDirID)
- X# define close macclose
- X# define fclose(x) macclose(fileno((x)))
- X# define read macread
- X# define write macwrite
- X# define lseek maclseek
- X# define creat(x,y) maccreat((x), gnVRefNum, glDirID, gostCreator, gostType)
- X# define stat(x,y) macstat((x), (y), gnVRefNum, glDirID)
- X# define dup
- X# ifndef MCH_MACINTOSH
- X# define NO_STRNICMP
- X# endif
- X# define DIR_END ':'
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 1
- X# define PutNativeEOL *q++ = native(CR);
- X# define MALLOC_WORK
- X
- X# ifdef THINK_C
- X# define fgets wfgets
- X# define fflush(f)
- X# define fprintf wfprintf
- X# define fputs(s,f) wfprintf((f), "%s", (s))
- X# define printf wprintf
- X# ifdef putc
- X# undef putc
- X# endif
- X# define putc(c,f) wfprintf((f), "%c", (c))
- X# define getenv macgetenv
- X# endif
- X
- X# ifndef isascii
- X# define isascii(c) ((unsigned char)(c) <= 0x3F)
- X# endif
- X
- X# include "macstat.h"
- X# include "macdir.h"
- X
- X# ifdef CR
- X# undef CR
- X# endif
- X
- Xtypedef struct _ZipExtraHdr {
- X unsigned short header; /* 2 bytes */
- X unsigned short data; /* 2 bytes */
- X} ZIP_EXTRA_HEADER;
- X
- Xtypedef struct _MacInfoMin {
- X unsigned short header; /* 2 bytes */
- X unsigned short data; /* 2 bytes */
- X unsigned long signature; /* 4 bytes */
- X FInfo finfo; /* 16 bytes */
- X unsigned long lCrDat; /* 4 bytes */
- X unsigned long lMdDat; /* 4 bytes */
- X unsigned long flags ; /* 4 bytes */
- X unsigned long lDirID; /* 4 bytes */
- X /*------------*/
- X} MACINFOMIN; /* = 40 bytes for size of data */
- X
- Xtypedef struct _MacInfo {
- X unsigned short header; /* 2 bytes */
- X unsigned short data; /* 2 bytes */
- X unsigned long signature; /* 4 bytes */
- X FInfo finfo; /* 16 bytes */
- X unsigned long lCrDat; /* 4 bytes */
- X unsigned long lMdDat; /* 4 bytes */
- X unsigned long flags ; /* 4 bytes */
- X unsigned long lDirID; /* 4 bytes */
- X char rguchVolName[28]; /* 28 bytes */
- X /*------------*/
- X} MACINFO; /* = 68 bytes for size of data */
- X#endif /* MACOS */
- X
- X/*---------------------------------------------------------------------------
- X MS-DOS and OS/2 section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MSDOS
- X# include <dos.h> /* for REGS macro (TC) or _dos_setftime (MSC) */
- X# ifdef __TURBOC__ /* includes Power C */
- X# include <sys/timeb.h> /* for structure ftime */
- X# ifndef __BORLANDC__ /* there appears to be a bug (?) in Borland's */
- X# include <mem.h> /* MEM.H related to __STDC__ and far poin- */
- X# endif /* ters. (dpk) [mem.h included for memcpy] */
- X# endif
- X#endif /* MSDOS */
- X
- X#ifdef __IBMC__
- X# define S_IFMT 0xF000
- X# define timezone _timezone
- X# define PIPE_ERROR (errno == EERRSET || errno == EOS2ERR)
- X#endif
- X
- X#ifdef __WATCOMC__
- X# define __32BIT__
- X# undef far
- X# define far
- X# undef near
- X# define near
- X# define PIPE_ERROR (errno == -1)
- X#endif
- X
- X#ifdef __EMX__
- X# ifndef __32BIT__
- X# define __32BIT__
- X# endif
- X# define far
- X#endif
- X
- X#ifdef __GO32__ /* note: MS-DOS compiler, not OS/2 */
- X# ifndef __32BIT__
- X# define __32BIT__
- X# endif
- X# include <sys/timeb.h> /* for structure ftime */
- X int setmode(int, int); /* not in djgpp's include files */
- X#endif
- X
- X#if defined(_MSC_VER) && (!defined(MSC))
- X# define MSC /* for old versions, MSC must be set explicitly */
- X#endif
- X
- X#if 0 /* GRR 930907: MSC 5.1 does declare errno but doesn't define _MSC_VER */
- X#ifdef MSC
- X# ifndef _MSC_VER /* new with 5.1 or 6.0 ... */
- X# define DECLARE_ERRNO /* not declared in errno.h in 5.0 or earlier? */
- X# endif
- X#endif
- X#endif /* 0 */
- X
- X#if defined(MSDOS) || defined(OS2)
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X# include <io.h> /* lseek(), open(), setftime(), dup(), creat() */
- X# include <time.h> /* localtime() */
- X# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- X# ifdef __GO32__
- X# define DIR_END '/'
- X# else
- X# define DIR_END '\\'
- X# endif
- X# if (defined(M_I86CM) || defined(M_I86LM))
- X# define MED_MEM
- X# endif
- X# if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
- X# define MED_MEM
- X# endif
- X# ifndef __32BIT__
- X# ifndef MED_MEM
- X# define SMALL_MEM
- X# endif
- X/* # define USE_FWRITE write() *can* write up to 65534 bytes after all */
- X# endif
- X# define DATE_FORMAT dateformat()
- X# define lenEOL 2
- X# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- X#endif
- X
- X#ifdef OS2 /* defined for all OS/2 compilers */
- X# ifdef MSDOS
- X# undef MSDOS
- X# endif
- X# ifdef isupper
- X# undef isupper
- X# endif
- X# ifdef tolower
- X# undef tolower
- X# endif
- X# define isupper(x) IsUpperNLS((unsigned char)(x))
- X# define tolower(x) ToLowerNLS((unsigned char)(x))
- X#endif
- X
- X#ifdef MSDOS
- X# define EXE_EXTENSION ".exe" /* OS/2 has GetLoadPath() function instead */
- X#endif
- X
- X#if defined(MSWIN) && defined(FILE_IO_C)
- X# include "wizunzip.h"
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X MTS section (piggybacks UNIX, I think):
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MTS
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X# include <sys/file.h> /* MTS uses this instead of fcntl.h */
- X# include <timeb.h>
- X# include <time.h>
- X# include <unix.h> /* some important non-ANSI routines */
- X# define mkdir(s,n) (-1) /* no "make directory" capability */
- X# define EBCDIC /* set EBCDIC conversion on */
- X# define NO_STRNICMP /* unzip's is as good the one in MTS */
- X# define USE_FWRITE
- X# define close_outfile() fclose(outfile) /* can't set time on files */
- X# define umask(n) /* Don't have umask() on MTS */
- X# define FOPWT "w" /* Open file for writing in TEXT mode */
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 1
- X# define PutNativeEOL *q++ = native(LF);
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X NT section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef WIN32 /* NT */
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X# include <io.h> /* read(), open(), etc. */
- X# include <time.h>
- X# include <memory.h>
- X# include <direct.h> /* mkdir() */
- X# include <fcntl.h>
- X# if defined(FILE_IO_C)
- X# include <conio.h>
- X# include <sys\types.h>
- X# include <sys\utime.h>
- X# include <windows.h>
- X# endif
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 2
- X# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- X# define NT
- X# if (defined(_MSC_VER) && !defined(MSC))
- X# define MSC
- X# endif
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X TOPS-20 section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef TOPS20
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X# include <sys/param.h>
- X# include <sys/time.h>
- X# include <sys/timeb.h>
- X/* # include <utime.h> GRR: not used, I suspect... */
- X# include <sys/file.h>
- X# include <timex.h>
- X# include <monsym.h> /* get amazing monsym() macro */
- X extern int open(), close(), read();
- X extern int stat(), unlink(), jsys(), fcntl();
- X extern long lseek(), dup(), creat();
- X# define strchr index /* GRR: necessary? */
- X# define strrchr rindex
- X# define REALLY_SHORT_SYMS
- X# define NO_MKDIR
- X# define DIR_BEG '<'
- X# define DIR_END '>'
- X# define DIR_EXT ".directory"
- X# define DATE_FORMAT DF_MDY
- X# define EXE_EXTENSION ".exe" /* just a guess... */
- X#endif /* TOPS20 */
- X
- X/*---------------------------------------------------------------------------
- X Unix section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef UNIX
- X# include <sys/types.h> /* off_t, time_t, dev_t, ... */
- X# include <sys/stat.h>
- X
- X# ifndef COHERENT
- X# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- X# else /* COHERENT */
- X# ifdef _I386
- X# include <fcntl.h> /* Coherent 4.0.x, Mark Williams C */
- X# else
- X# include <sys/fcntl.h> /* Coherent 3.10, Mark Williams C */
- X# endif
- X# define SHORT_SYMS
- X# ifndef __COHERENT__ /* Coherent 4.2 has tzset() */
- X# define tzset settz
- X# endif
- X# endif /* ?COHERENT */
- X
- X# ifndef NO_PARAM_H
- X# ifdef NGROUPS_MAX
- X# undef NGROUPS_MAX /* SCO bug: defined again in <sys/param.h> */
- X# endif
- X# ifdef BSD
- X# define TEMP_BSD /* may be defined again in <sys/param.h> */
- X# undef BSD
- X# endif
- X# include <sys/param.h> /* conflict with <sys/types.h>, some systems? */
- X# ifdef TEMP_BSD
- X# undef TEMP_BSD
- X# ifndef BSD
- X# define BSD
- X# endif
- X# endif
- X# endif /* !NO_PARAM_H */
- X
- X# ifdef __osf__
- X# define DIRENT
- X# ifdef BSD
- X# undef BSD
- X# endif
- X# endif /* __osf__ */
- X
- X# ifdef BSD
- X# include <sys/time.h>
- X# include <sys/timeb.h>
- X# ifdef _AIX
- X# include <time.h>
- X# endif
- X# else
- X# include <time.h>
- X struct tm *gmtime(), *localtime();
- X# endif
- X
- X# if defined(BSD4_4) || defined(LINUX) || (defined(SYSV) && defined(MODERN))
- X# include <unistd.h> /* this includes utime.h, at least on SGIs */
- X# endif
- X
- X# if defined(BSD4_4) || defined(_POSIX_SOURCE) || defined(sgi) || defined(_AIX)
- X# include <utime.h> /* NeXT, at least, does NOT define utimbuf in here */
- X# else
- X struct utimbuf {
- X time_t actime; /* new access time */
- X time_t modtime; /* new modification time */
- X };
- X# endif /* ?(BSD4_4 || _POSIX_SOURCE || sgi || _AIX) */
- X
- X# if (defined(V7) || defined(pyr_bsd))
- X# define strchr index
- X# define strrchr rindex
- X# endif
- X# ifdef V7
- X# define O_RDONLY 0
- X# define O_WRONLY 1
- X# define O_RDWR 2
- X# endif
- X
- X# ifdef MINIX
- X# include <stdio.h>
- X# endif
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 1
- X# define PutNativeEOL *q++ = native(LF);
- X#endif /* UNIX */
- X
- X/*---------------------------------------------------------------------------
- X VMS section:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef VMS
- X# include <types.h> /* GRR: experimenting... */
- X# include <stat.h>
- X# include <time.h> /* the usual non-BSD time functions */
- X# include <file.h> /* same things as fcntl.h has */
- X# include <unixio.h>
- X# include <rms.h>
- X# define _MAX_PATH NAM$C_MAXRSS /* to define FILNAMSIZ below */
- X# define RETURN return_VMS /* VMS interprets return codes incorrectly */
- X# define DIR_BEG '['
- X# define DIR_END ']'
- X# define DIR_EXT ".dir"
- X# define DATE_FORMAT DF_MDY
- X# define lenEOL 1
- X# define PutNativeEOL *q++ = native(LF);
- X#endif /* VMS */
- X
- X
- X
- X
- X
- X/*************/
- X/* Defines */
- X/*************/
- X
- X#define UNZIP
- X#define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */
- X#define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */
- X
- X#if defined(MSDOS) || defined(NT) || defined(OS2)
- X# define DOS_NT_OS2
- X#endif
- X
- X#if defined(MSDOS) || defined(OS2)
- X# define DOS_OS2
- X#endif
- X
- X#if defined(MSDOS) || defined(OS2) || defined(ATARI_ST)
- X# define DOS_OS2_TOS
- X#endif
- X
- X#if defined(MSDOS) || defined(ATARI_ST)
- X# define DOS_TOS
- X#endif
- X
- X#if defined(MSDOS) || defined(TOPS20) || defined(VMS)
- X# define DOS_T20_VMS
- X#endif
- X
- X#if defined(TOPS20) || defined(VMS)
- X# define T20_VMS
- X#endif
- X
- X/* clean up with a few defaults */
- X#ifndef DIR_END
- X# define DIR_END '/' /* last char before program name (or filename) */
- X#endif
- X#ifndef RETURN
- X# define RETURN return /* only used in main() */
- X#endif
- X#ifndef PRINTF
- X# define PRINTF printf
- X#endif
- X#ifndef FPRINTF
- X# define FPRINTF fprintf
- X#endif
- X#ifndef PUTC
- X# define PUTC putc /* putchar() not used: use PUTC(c,stdout) instead */
- X#endif
- X
- X#define DIR_BLKSIZ 64 /* number of directory entries per block
- X * (should fit in 4096 bytes, usually) */
- X#ifndef WSIZE
- X# define WSIZE 0x8000 /* window size--must be a power of two, and */
- X#endif /* at least 32K for zip's deflate method */
- X
- X#ifndef INBUFSIZ
- X# if (defined(MED_MEM) || defined(SMALL_MEM))
- X# define INBUFSIZ 2048 /* works for MS-DOS small model */
- X# else
- X# define INBUFSIZ 8192 /* larger buffers for real OSes */
- X# endif
- X#endif
- X
- X/* GRR: NT defines MSDOS?? */
- X#if (!defined(MSDOS) && !defined(__IBMC__)) || defined(NT)
- X# define near
- X# define far
- X#endif
- X#if defined(__GO32__) || defined(__EMX__)
- X# define near
- X# define far
- X#endif
- X
- X/* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048,
- X * OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes
- X * and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5
- X * chars/line, smaller than estimated 35-70 characters per line for C source
- X * and normal text. Hence difference is sufficient for most "average" files.
- X * (Argument scales for larger OUTBUFSIZ.)
- X */
- X#ifdef SMALL_MEM /* i.e., 16-bit OS's: MS-DOS, OS/2 1.x, etc. */
- X# ifndef Far
- X# define Far far /* __far only works for MSC 6.00, not 6.0a or Borland */
- X# endif
- X# define OUTBUFSIZ INBUFSIZ
- X# if (lenEOL == 1)
- X# define RAWBUFSIZ (OUTBUFSIZ>>1)
- X# else
- X# define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7))
- X# endif
- X# define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ)
- X#else
- X# define LoadFarString(x) x
- X# define LoadFarStringSmall(x) x
- X# define LoadFarStringSmall2(x) x
- X# ifdef MED_MEM
- X# define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */
- X# define TRANSBUFSIZ 0xFF80
- X# else
- X# define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */
- X# define TRANSBUFSIZ (lenEOL*OUTBUFSIZ)
- X# define NEW_UNSHRINK
- X# endif
- X# define RAWBUFSIZ OUTBUFSIZ
- X#endif /* ?SMALL_MEM */
- X
- X#ifndef Far
- X# define Far /* GRR: should combine this with near/far above */
- X#endif
- X
- X#ifndef MAIN
- X# define MAIN main
- X#endif
- X
- X#if (defined(SFX) && !defined(NO_ZIPINFO))
- X# define NO_ZIPINFO
- X#endif
- X
- X#ifndef O_BINARY
- X# define O_BINARY 0
- X#endif
- X
- X#ifndef PIPE_ERROR
- X# define PIPE_ERROR (errno == EPIPE)
- X#endif
- X
- X/* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
- X#ifdef VMS
- X# define FOPR "r","ctx=stm"
- X# define FOPM "r+","ctx=stm","rfm=fix","mrs=512"
- X# define FOPW "w","ctx=stm","rfm=fix","mrs=512"
- X#else /* !VMS */
- X# if defined(MODERN) || defined(AMIGA)
- X# define FOPR "rb"
- X# define FOPM "r+b"
- X# ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */
- X# define FOPW "w8"
- X# else
- X# define FOPW "wb"
- X# endif
- X# else /* !MODERN */
- X# define FOPR "r"
- X# define FOPM "r+"
- X# define FOPW "w"
- X# endif /* ?MODERN */
- X#endif /* VMS */
- X
- X/*
- X * If <limits.h> exists on most systems, should include that, since it may
- X * define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
- X * _POSIX_PATH_MAX.
- X */
- X#ifdef DOS_OS2_TOS
- X# include <limits.h>
- X#endif
- X
- X#ifndef PATH_MAX
- X# ifdef MAXPATHLEN
- X# define PATH_MAX MAXPATHLEN /* in <sys/param.h> on some systems */
- X# else
- X# ifdef _MAX_PATH
- X# define PATH_MAX _MAX_PATH
- X# else
- X# if FILENAME_MAX > 255
- X# define PATH_MAX FILENAME_MAX /* used like PATH_MAX on some systems */
- X# else
- X# define PATH_MAX 1024
- X# endif
- X# endif /* ?_MAX_PATH */
- X# endif /* ?MAXPATHLEN */
- X#endif /* !PATH_MAX */
- X
- X#define FILNAMSIZ (PATH_MAX+1)
- X
- X#ifdef SHORT_SYMS /* Mark Williams C, ...? */
- X# define extract_or_test_files xtr_or_tst_files
- X# define extract_or_test_member xtr_or_tst_member
- X#endif
- X
- X#ifdef REALLY_SHORT_SYMS /* TOPS-20 linker: first 6 chars */
- X# define process_cdir_file_hdr XXpcdfh
- X# define process_local_file_hdr XXplfh
- X# define extract_or_test_files XXxotf /* necessary? */
- X# define extract_or_test_member XXxotm /* necessary? */
- X# define check_for_newer XXcfn
- X# define overwrite_all XXoa
- X# define process_all_files XXpaf
- X# define extra_field XXef
- X# define explode_lit8 XXel8
- X# define explode_lit4 XXel4
- X# define explode_nolit8 XXnl8
- X# define explode_nolit4 XXnl4
- X# define cpdist8 XXcpdist8
- X# define inflate_codes XXic
- X# define inflate_stored XXis
- X# define inflate_fixed XXif
- X# define inflate_dynamic XXid
- X# define inflate_block XXib
- X# define maxcodemax XXmax
- X#endif
- X
- X#define ZSUFX ".zip"
- X#define CENTRAL_HDR_SIG "\113\001\002" /* the infamous "PK" signature */
- X#define LOCAL_HDR_SIG "\113\003\004" /* bytes, sans "P" (so unzip */
- X#define END_CENTRAL_SIG "\113\005\006" /* executable not mistaken for */
- X#define EXTD_LOCAL_SIG "\113\007\010" /* zipfile itself) */
- X
- X#define SKIP 0 /* choice of activities for do_string() */
- X#define DISPLAY 1
- X#define FILENAME 2
- X#define EXTRA_FIELD 3
- X
- X#define DOES_NOT_EXIST -1 /* return values for check_for_newer() */
- X#define EXISTS_AND_OLDER 0
- X#define EXISTS_AND_NEWER 1
- X
- X#define ROOT 0 /* checkdir() extract-to path: called once */
- X#define INIT 1 /* allocate buildpath: called once per member */
- X#define APPEND_DIR 2 /* append a dir comp.: many times per member */
- X#define APPEND_NAME 3 /* append actual filename: once per member */
- X#define GETPATH 4 /* retrieve the complete path and free it */
- X#define END 5 /* free root path prior to exiting program */
- X
- X/* version_made_by codes (central dir): make sure these */
- X/* are not defined on their respective systems!! */
- X#define FS_FAT_ 0 /* filesystem used by MS-DOS, OS/2, NT */
- X#define AMIGA_ 1
- X#define VMS_ 2
- X#define UNIX_ 3
- X#define VM_CMS_ 4
- X#define ATARI_ 5 /* what if it's a minix filesystem? [cjh] */
- X#define FS_HPFS_ 6 /* filesystem used by OS/2, NT */
- X#define MAC_ 7
- X#define Z_SYSTEM_ 8
- X#define CPM_ 9
- X#define TOPS20_ 10
- X#define FS_NTFS_ 11 /* filesystem used by Windows NT */
- X#define QDOS_MAYBE_ 12 /* a bit premature, but somebody once started */
- X#define ACORN_ 13 /* Archimedes Acorn RISCOS */
- X#define NUM_HOSTS 14 /* index of last system + 1 */
- X
- X#define STORED 0 /* compression methods */
- X#define SHRUNK 1
- X#define REDUCED1 2
- X#define REDUCED2 3
- X#define REDUCED3 4
- X#define REDUCED4 5
- X#define IMPLODED 6
- X#define TOKENIZED 7
- X#define DEFLATED 8
- X#define NUM_METHODS 9 /* index of last method + 1 */
- X/* don't forget to update list_files() appropriately if NUM_METHODS changes */
- X
- X#define PK_OK 0 /* no error */
- X#define PK_COOL 0 /* no error */
- X#define PK_GNARLY 0 /* no error */
- X#define PK_WARN 1 /* warning error */
- X#define PK_ERR 2 /* error in zipfile */
- X#define PK_BADERR 3 /* severe error in zipfile */
- X#define PK_MEM 4 /* insufficient memory */
- X#define PK_MEM2 5 /* insufficient memory */
- X#define PK_MEM3 6 /* insufficient memory */
- X#define PK_MEM4 7 /* insufficient memory */
- X#define PK_MEM5 8 /* insufficient memory */
- X#define PK_NOZIP 9 /* zipfile not found */
- X#define PK_PARAM 10 /* bad or illegal parameters specified */
- X#define PK_FIND 11 /* no files found */
- X#define PK_DISK 50 /* disk full */
- X#define PK_EOF 51 /* unexpected EOF */
- X
- X#define IZ_DIR 76 /* potential zipfile is a directory */
- X#define IZ_CREATED_DIR 77 /* directory created: set time and permissions */
- X#define IZ_VOL_LABEL 78 /* volume label, but can't set on hard disk */
- X
- X#define DF_MDY 0 /* date format 10/26/91 (USA only) */
- X#define DF_DMY 1 /* date format 26/10/91 (most of the world) */
- X#define DF_YMD 2 /* date format 91/10/26 (a few countries) */
- X
- X/*---------------------------------------------------------------------------
- X True sizes of the various headers, as defined by PKWARE--so it is not
- X likely that these will ever change. But if they do, make sure both these
- X defines AND the typedefs below get updated accordingly.
- X ---------------------------------------------------------------------------*/
- X#define LREC_SIZE 26 /* lengths of local file headers, central */
- X#define CREC_SIZE 42 /* directory headers, and the end-of- */
- X#define ECREC_SIZE 18 /* central-dir record, respectively */
- X
- X#define MAX_BITS 13 /* used in old unshrink() */
- X#define HSIZE (1 << MAX_BITS) /* size of global work area */
- X
- X#define LF 10 /* '\n' on ASCII machines; must be 10 due to EBCDIC */
- X#define CR 13 /* '\r' on ASCII machines; must be 13 due to EBCDIC */
- X#define CTRLZ 26 /* DOS & OS/2 EOF marker (used in file_io.c, vms.c) */
- X
- X#ifdef EBCDIC
- X# define native(c) ebcdic[(c)]
- X# define NATIVE "EBCDIC"
- X#endif
- X
- X#ifdef MPW
- X# define FFLUSH(f) PUTC('\n',f)
- X#else
- X# define FFLUSH fflush
- X#endif
- X
- X#ifdef ZMEM /* GRR: THIS IS AN EXPERIMENT... (seems to work) */
- X# undef ZMEM
- X# define memcpy(dest,src,len) bcopy(src,dest,len)
- X# define memzero bzero
- X#else
- X# define memzero(dest,len) memset(dest,0,len)
- X#endif
- X
- X#ifdef VMS
- X# define ENV_UNZIP "UNZIP_OPTS" /* name of environment variable */
- X# define ENV_ZIPINFO "ZIPINFO_OPTS"
- X#else /* !VMS */
- X# define ENV_UNZIP "UNZIP"
- X# define ENV_ZIPINFO "ZIPINFO"
- X#endif /* ?VMS */
- X#define ENV_UNZIP2 "UNZIPOPT" /* alternate name for zip compat. */
- X#define ENV_ZIPINFO2 "ZIPINFOOPT"
- X
- X#if !defined(QQ) && !defined(NOQQ)
- X# define QQ
- X#endif
- X
- X#ifdef QQ /* Newtware version: no file */
- X# define QCOND (!qflag) /* comments with -vq or -vqq */
- X#else /* Bill Davidsen version: no way to */
- X# define QCOND (which_hdr) /* kill file comments when listing */
- X#endif
- X
- X#ifdef OLD_QQ
- X# define QCOND2 (qflag < 2)
- X#else
- X# define QCOND2 (!qflag)
- X#endif
- X
- X#ifndef TRUE
- X# define TRUE 1 /* sort of obvious */
- X#endif
- X#ifndef FALSE
- X# define FALSE 0
- X#endif
- X
- X#ifndef SEEK_SET
- X# define SEEK_SET 0
- X# define SEEK_CUR 1
- X# define SEEK_END 2
- X#endif
- X
- X#if (defined(UNIX) && defined(S_IFLNK) && !defined(MTS))
- X# define SYMLINKS
- X# ifndef S_ISLNK
- X# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
- X# endif
- X#endif /* UNIX && S_IFLNK && !MTS */
- X
- X#ifndef S_ISDIR
- X# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
- X#endif
- X
- X#ifndef IS_VOLID
- X# define IS_VOLID(m) ((m) & 0x08)
- X#endif
- X
- X
- X
- X
- X
- X/**************/
- X/* Typedefs */
- X/**************/
- X
- Xtypedef char boolean;
- Xtypedef unsigned char uch; /* code assumes unsigned bytes; these type- */
- Xtypedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */
- Xtypedef unsigned long ulg; /* predefined on some systems) & match zip */
- X
- Xtypedef struct min_info {
- X long offset;
- X ulg compr_size; /* compressed size (needed if extended header) */
- X ulg crc; /* crc (needed if extended header) */
- X int hostnum;
- X unsigned file_attr; /* local flavor, as used by creat(), chmod()... */
- X unsigned encrypted : 1; /* file encrypted: decrypt before uncompressing */
- X unsigned ExtLocHdr : 1; /* use time instead of CRC for decrypt check */
- X unsigned textfile : 1; /* file is text (according to zip) */
- X unsigned textmode : 1; /* file is to be extracted as text */
- X unsigned lcflag : 1; /* convert filename to lowercase */
- X unsigned vollabel : 1; /* "file" is an MS-DOS volume (disk) label */
- X} min_info;
- X
- Xtypedef struct VMStimbuf {
- X char *revdate; /* (both correspond to Unix modtime/st_mtime) */
- X char *credate;
- X} VMStimbuf;
- X
- X/*---------------------------------------------------------------------------
- X Zipfile work area declarations.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MALLOC_WORK
- X
- X union work {
- X struct {
- X short *Prefix_of; /* (8193 * sizeof(short)) */
- X uch *Suffix_of;
- X uch *Stack;
- X } shrink; /* unshrink() */
- X uch *Slide; /* explode(), inflate(), unreduce() */
- X };
- X# define prefix_of area.shrink.Prefix_of
- X# define suffix_of area.shrink.Suffix_of
- X# define stack area.shrink.Stack
- X
- X#else /* !MALLOC_WORK */
- X
- X# ifdef NEW_UNSHRINK /* weird segmentation violations if union NODE array */
- X union work {
- X uch Stack[8192]; /* unshrink() */
- X uch Slide[WSIZE]; /* explode(), inflate(), unreduce() */
- X };
- X# define stack area.Stack
- X# else
- X union work {
- X struct {
- X short Prefix_of[HSIZE]; /* (8192 * sizeof(short)) */
- X uch Suffix_of[HSIZE];
- X uch Stack[HSIZE];
- X } shrink;
- X uch Slide[WSIZE]; /* explode(), inflate(), unreduce() */
- X };
- X# define prefix_of area.shrink.Prefix_of
- X# define suffix_of area.shrink.Suffix_of
- X# define stack area.shrink.Stack
- X# endif /* ?NEW_UNSHRINK */
- X
- X#endif /* ?MALLOC_WORK */
- X
- X#define slide area.Slide
- X
- X/*---------------------------------------------------------------------------
- X Zipfile layout declarations. If these headers ever change, make sure the
- X xxREC_SIZE defines (above) change with them!
- X ---------------------------------------------------------------------------*/
- X
- X typedef uch local_byte_hdr[ LREC_SIZE ];
- X# define L_VERSION_NEEDED_TO_EXTRACT_0 0
- X# define L_VERSION_NEEDED_TO_EXTRACT_1 1
- X# define L_GENERAL_PURPOSE_BIT_FLAG 2
- X# define L_COMPRESSION_METHOD 4
- X# define L_LAST_MOD_FILE_TIME 6
- X# define L_LAST_MOD_FILE_DATE 8
- X# define L_CRC32 10
- X# define L_COMPRESSED_SIZE 14
- X# define L_UNCOMPRESSED_SIZE 18
- X# define L_FILENAME_LENGTH 22
- X# define L_EXTRA_FIELD_LENGTH 24
- X
- X typedef uch cdir_byte_hdr[ CREC_SIZE ];
- X# define C_VERSION_MADE_BY_0 0
- X# define C_VERSION_MADE_BY_1 1
- X# define C_VERSION_NEEDED_TO_EXTRACT_0 2
- X# define C_VERSION_NEEDED_TO_EXTRACT_1 3
- X# define C_GENERAL_PURPOSE_BIT_FLAG 4
- X# define C_COMPRESSION_METHOD 6
- X# define C_LAST_MOD_FILE_TIME 8
- X# define C_LAST_MOD_FILE_DATE 10
- X# define C_CRC32 12
- X# define C_COMPRESSED_SIZE 16
- X# define C_UNCOMPRESSED_SIZE 20
- X# define C_FILENAME_LENGTH 24
- X# define C_EXTRA_FIELD_LENGTH 26
- X# define C_FILE_COMMENT_LENGTH 28
- X# define C_DISK_NUMBER_START 30
- X# define C_INTERNAL_FILE_ATTRIBUTES 32
- X# define C_EXTERNAL_FILE_ATTRIBUTES 34
- X# define C_RELATIVE_OFFSET_LOCAL_HEADER 38
- X
- X typedef uch ec_byte_rec[ ECREC_SIZE+4 ];
- X/* define SIGNATURE 0 space-holder only */
- X# define NUMBER_THIS_DISK 4
- X# define NUM_DISK_WITH_START_CENTRAL_DIR 6
- X# define NUM_ENTRIES_CENTRL_DIR_THS_DISK 8
- X# define TOTAL_ENTRIES_CENTRAL_DIR 10
- X# define SIZE_CENTRAL_DIRECTORY 12
- X# define OFFSET_START_CENTRAL_DIRECTORY 16
- X# define ZIPFILE_COMMENT_LENGTH 20
- X
- X
- X typedef struct local_file_header { /* LOCAL */
- X uch version_needed_to_extract[2];
- X ush general_purpose_bit_flag;
- X ush compression_method;
- X ush last_mod_file_time;
- X ush last_mod_file_date;
- X ulg crc32;
- X ulg csize;
- X ulg ucsize;
- X ush filename_length;
- X ush extra_field_length;
- X } local_file_hdr;
- X
- X typedef struct central_directory_file_header { /* CENTRAL */
- X uch version_made_by[2];
- X uch version_needed_to_extract[2];
- X ush general_purpose_bit_flag;
- X ush compression_method;
- X ush last_mod_file_time;
- X ush last_mod_file_date;
- X ulg crc32;
- X ulg csize;
- X ulg ucsize;
- X ush filename_length;
- X ush extra_field_length;
- X ush file_comment_length;
- X ush disk_number_start;
- X ush internal_file_attributes;
- X ulg external_file_attributes;
- X ulg relative_offset_local_header;
- X } cdir_file_hdr;
- X
- X typedef struct end_central_dir_record { /* END CENTRAL */
- X ush number_this_disk;
- X ush num_disk_with_start_central_dir;
- X ush num_entries_centrl_dir_ths_disk;
- X ush total_entries_central_dir;
- X ulg size_central_directory;
- X ulg offset_start_central_directory;
- X ush zipfile_comment_length;
- X } ecdir_rec;
- X
- X
- X
- X
- X
- X/*************************/
- X/* Function Prototypes */
- X/*************************/
- X
- X#ifndef __
- X# define __ OF
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Functions in unzip.c (main initialization/driver routines):
- X ---------------------------------------------------------------------------*/
- X
- Xint uz_opts __((int *pargc, char ***pargv));
- Xint usage __((int error));
- Xint process_zipfiles __((void));
- Xint do_seekable __((int lastchance));
- Xint uz_end_central __((void));
- Xint process_cdir_file_hdr __((void));
- Xint process_local_file_hdr __((void));
- X
- X/*---------------------------------------------------------------------------
- X Functions in zipinfo.c (zipfile-listing routines):
- X ---------------------------------------------------------------------------*/
- X
- Xint zi_opts __((int *pargc, char ***pargv));
- Xint zi_end_central __((void));
- Xint zipinfo __((void));
- X/* static int zi_long __((void)); */
- X/* static int zi_short __((void)); */
- X/* static char *zi_time __((ush *datez, ush *timez)); */
- Xulg SizeOfEAs __((void *extra_field)); /* also in os2.c? */
- Xint list_files __((void));
- X/* static int ratio __((ulg uc, ulg c)); */
- X
- X/*---------------------------------------------------------------------------
- X Functions in file_io.c:
- X ---------------------------------------------------------------------------*/
- X
- Xint open_input_file __((void));
- Xint open_outfile __((void)); /* also vms.c */
- Xunsigned readbuf __((char *buf, register unsigned len));
- Xint FillBitBuffer __((void));
- Xint readbyte __((void));
- X#ifdef FUNZIP
- X int flush __((ulg size));
- X#else
- X int flush __((uch *buf, ulg size, int unshrink));
- X#endif
- Xvoid handler __((int signal));
- Xtime_t dos_to_unix_time __((unsigned ddate, unsigned dtime));
- Xint check_for_newer __((char *filename)); /* also os2.c, vms.c */
- Xint find_ecrec __((long searchlen));
- Xint get_cdir_ent __((void));
- Xint do_string __((unsigned int len, int option));
- Xush makeword __((uch *b));
- Xulg makelong __((uch *sig));
- Xint zstrnicmp __((register char *s1, register char *s2, register int n));
- X
- X#ifdef ZMEM /* MUST be ifdef'd because of conflicts with the standard def. */
- X char *memset __((register char *, register char, register unsigned int));
- X char *memcpy __((register char *, register char *, register unsigned int));
- X#endif
- X
- X#ifdef SMALL_MEM
- X char *LoadFarString __((char Far *sz));
- X char *LoadFarStringSmall __((char Far *sz));
- X char *LoadFarStringSmall2 __((char Far *sz));
- X char Far * Far zfstrcpy __((char Far *s1, const char Far *s2));
- X#endif
- X
- X
- X/*---------------------------------------------------------------------------
- X Functions in extract.c:
- X ---------------------------------------------------------------------------*/
- X
- Xint extract_or_test_files __((void));
- X/* static int store_info __((void)); */
- X/* static int extract_or_test_member __((void)); */
- Xint memextract __((uch *, ulg, uch *, ulg));
- Xint FlushMemory __((void));
- Xint ReadMemoryByte __((ush *x));
- X
- X/*---------------------------------------------------------------------------
- X Decompression functions:
- X ---------------------------------------------------------------------------*/
- X
- Xint explode __((void)); /* explode.c */
- Xint inflate __((void)); /* inflate.c */
- Xint inflate_free __((void)); /* inflate.c */
- Xvoid unreduce __((void)); /* unreduce.c */
- X/* static void LoadFollowers __((void)); * unreduce.c */
- Xint unshrink __((void)); /* unshrink.c */
- X/* static void partial_clear __((void)); * unshrink.c */
- X
- X/*---------------------------------------------------------------------------
- X Human68K-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef __human68k__
- X void InitTwentyOne __((void));
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Macintosh-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MACOS
- X int macmkdir __((char *, short, long));
- X short macopen __((char *, short, short, long));
- X FILE *macfopen __((char *, char *, short, long));
- X short maccreat __((char *, short, long, OSType, OSType));
- X short macread __((short, char *, unsigned));
- X long macwrite __((short, char *, unsigned));
- X short macclose __((short));
- X long maclseek __((short, long, short));
- X char *macgetenv __((char *));
- X char *wfgets __((char *, int, FILE *));
- X void wfprintf __((FILE *, char *, ...));
- X void wprintf __((char *, ...));
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X MSDOS-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#if (defined(__GO32__) || (defined(MSDOS) && defined(__EMX__)))
- X unsigned _dos_getcountryinfo(void *); /* msdos.c */
- X void _dos_setftime(int, unsigned short, unsigned short); /* msdos.c */
- X void _dos_setfileattr(char *, int); /* msdos.c */
- X unsigned _dos_creat(char *, unsigned, int *); /* msdos.c */
- X void _dos_getdrive(unsigned *); /* msdos.c */
- X unsigned _dos_close(int); /* msdos.c */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X OS/2-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef OS2 /* GetFileTime conflicts with something in NT header files */
- X int GetCountryInfo __((void)); /* os2.c */
- X long GetFileTime __((char *name)); /* os2.c */
- X void SetPathInfo __((char *path, ush moddate, ush modtime, int flags));
- X int IsEA __((void *extra_field)); /* os2.c */
- X void SetEAs __((char *path, void *eablock)); /* os2.c */
- X ulg SizeOfEAs __((void *extra_field)); /* os2.c */
- X/* static int IsFileNameValid __((char *name)); os2.c */
- X/* static void map2fat __((char *pathcomp, char **pEndFAT)); os2.c */
- X/* static int SetLongNameEA __((char *name, char *longname)); os2.c */
- X/* static void InitNLS __((void)); os2.c */
- X int IsUpperNLS __((int nChr)); /* os2.c */
- X int ToLowerNLS __((int nChr)); /* os2.c */
- X void DebugMalloc __((void)); /* os2.c */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X TOPS20-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef TOPS20
- X int upper __((char *s)); /* tops20.c */
- X int enquote __((char *s)); /* tops20.c */
- X int dequote __((char *s)); /* tops20.c */
- X int fnlegal __(()); /* error if prototyped(?) */ /* tops20.c */
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X VMS-only functions:
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef VMS
- X int check_format __((void)); /* vms.c */
- X int find_vms_attrs __((void)); /* vms.c */
- X int CloseOutputFile __((void)); /* vms.c */
- X/* static uch *extract_block __((struct extra_block *, int *, uch *, int)); */
- X/* static int _flush_blocks __((int final_flag)); * vms.c */
- X/* static int _flush_records __((int final_flag)); * vms.c */
- X/* static int WriteBuffer __((unsigned char *buf, int len)); * vms.c */
- X/* static int WriteRecord __((unsigned char *rec, int len)); * vms.c */
- X/* static void message __((int string, char *status)); * vms.c */
- X void return_VMS __((int zip_error)); /* vms.c */
- X#ifdef VMSCLI
- X ulg vms_unzip_cmdline __((int *, char ***)); /* cmdline.c */
- X#endif
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Miscellaneous/shared functions:
- X ---------------------------------------------------------------------------*/
- X
- Xint match __((char *s, char *p, int ic)); /* match.c */
- Xint iswild __((char *p)); /* match.c */
- X
- Xvoid envargs __((int *, char ***, char *, char *)); /* envargs.c */
- Xvoid mksargs __((int *, char ***)); /* envargs.c */
- X
- Xint dateformat __((void));
- Xvoid version __((void)); /* local */
- Xint mapattr __((void)); /* local */
- Xint mapname __((int renamed)); /* local */
- Xint checkdir __((char *pathcomp, int flag)); /* local */
- Xchar *do_wild __((char *wildzipfn)); /* local */
- Xchar *GetLoadPath __((void)); /* local */
- X#ifndef MTS /* macro in MTS */
- X void close_outfile __((void)); /* local */
- X#endif
- X
- X
- X
- X
- X
- X/************/
- X/* Macros */
- X/************/
- X
- X#ifndef MAX
- X# define MAX(a,b) ((a) > (b) ? (a) : (b))
- X#endif
- X#ifndef MIN
- X# define MIN(a,b) ((a) < (b) ? (a) : (b))
- X#endif
- X
- X#ifdef DEBUG
- X# define Trace(x) FPRINTF x
- X#else
- X# define Trace(x)
- X#endif
- X
- X#if defined(UNIX) || defined(T20_VMS) /* generally old systems */
- X# define ToLower(x) ((char)(isupper((int)x)? tolower((int)x) : x))
- X#else
- X# define ToLower tolower /* assumed "smart"; used in match() */
- X#endif
- X
- X
- X#define LSEEK(abs_offset) {LONGINT request=(abs_offset)+extra_bytes,\
- X inbuf_offset=request%INBUFSIZ, bufstart=request-inbuf_offset;\
- X if(request<0) {FPRINTF(stderr, LoadFarStringSmall(SeekMsg), LoadFarString(ReportMsg)); return(3);}\
- X else if(bufstart!=cur_zipfile_bufstart)\
- X {cur_zipfile_bufstart=lseek(zipfd,(LONGINT)bufstart,SEEK_SET);\
- X if((incnt=read(zipfd,(char *)inbuf,INBUFSIZ))<=0) return(51);\
- X inptr=inbuf+(int)inbuf_offset; incnt-=(int)inbuf_offset;} else\
- X {incnt+=(inptr-inbuf)-(int)inbuf_offset; inptr=inbuf+(int)inbuf_offset;}}
- X
- X/*
- X * Seek to the block boundary of the block which includes abs_offset,
- X * then read block into input buffer and set pointers appropriately.
- X * If block is already in the buffer, just set the pointers. This macro
- X * is used by process_end_central_dir (unzip.c) and do_string (file_io.c).
- X * A slightly modified version is embedded within extract_or_test_files
- X * (unzip.c). ReadByte and readbuf (file_io.c) are compatible.
- X *
- X * macro LSEEK(abs_offset)
- X * ulg abs_offset;
- X * {
- X * LONGINT request = abs_offset + extra_bytes;
- X * LONGINT inbuf_offset = request % INBUFSIZ;
- X * LONGINT bufstart = request - inbuf_offset;
- X *
- X * if (request < 0) {
- X * FPRINTF(stderr, LoadFarStringSmall(SeekMsg),
- X * LoadFarString(ReportMsg));
- X * return(3); /-* 3: severe error in zipfile *-/
- X * } else if (bufstart != cur_zipfile_bufstart) {
- X * cur_zipfile_bufstart = lseek(zipfd, (LONGINT)bufstart, SEEK_SET);
- X * if ((incnt = read(zipfd,inbuf,INBUFSIZ)) <= 0)
- X * return(51); /-* 51: unexpected EOF *-/
- X * inptr = inbuf + (int)inbuf_offset;
- X * incnt -= (int)inbuf_offset;
- X * } else {
- X * incnt += (inptr-inbuf) - (int)inbuf_offset;
- X * inptr = inbuf + (int)inbuf_offset;
- X * }
- X * }
- X *
- X */
- X
- X
- X#define SKIP_(length) if(length&&((error=do_string(length,SKIP))!=0))\
- X {error_in_archive=error; if(error>1) return error;}
- X
- X/*
- X * Skip a variable-length field, and report any errors. Used in zipinfo.c
- X * and unzip.c in several functions.
- X *
- X * macro SKIP_(length)
- X * ush length;
- X * {
- X * if (length && ((error = do_string(length, SKIP)) != 0)) {
- X * error_in_archive = error; /-* might be warning *-/
- X * if (error > 1) /-* fatal *-/
- X * return (error);
- X * }
- X * }
- X *
- X */
- X
- X
- X#ifdef FUNZIP
- X# define FLUSH flush
- X# define NEXTBYTE getc(in) /* redefined in crypt.h if full version */
- X#else
- X# define FLUSH(w) if (mem_mode) outcnt=(w); else flush(slide,(ulg)w,0)
- X# define NEXTBYTE \
- X (csize-- <= 0L ? EOF : (--incnt >= 0 ? (int)(*inptr++) : readbyte()))
- X#endif
- X
- X
- X#define READBITS(nbits,zdest) {if(nbits>bits_left) {int temp; zipeof=1;\
- X while (bits_left<=8*(sizeof(bitbuf)-1) && (temp=NEXTBYTE)!=EOF) {\
- X bitbuf|=(ulg)temp<<bits_left; bits_left+=8; zipeof=0;}}\
- X zdest=(int)((ush)bitbuf&mask_bits[nbits]);bitbuf>>=nbits;bits_left-=nbits;}
- X
- X/*
- X * macro READBITS(nbits,zdest) * only used by unreduce and unshrink *
- X * {
- X * if (nbits > bits_left) { * fill bitbuf, which is 8*sizeof(ulg) bits *
- X * int temp;
- X *
- X * zipeof = 1;
- X * while (bits_left <= 8*(sizeof(bitbuf)-1) &&
- X * (temp = NEXTBYTE) != EOF) {
- X * bitbuf |= (ulg)temp << bits_left;
- X * bits_left += 8;
- X * zipeof = 0;
- X * }
- X * }
- X * zdest = (int)((ush)bitbuf & mask_bits[nbits]);
- X * bitbuf >>= nbits;
- X * bits_left -= nbits;
- X * }
- X *
- X */
- X
- X
- X/* GRR: should change name to STRLOWER and use StringLower if possible */
- X
- X/*
- X * Copy the zero-terminated string in str1 into str2, converting any
- X * uppercase letters to lowercase as we go. str2 gets zero-terminated
- X * as well, of course. str1 and str2 may be the same character array.
- X */
- X#ifdef __human68k__
- X# define TOLOWER(str1, str2) \
- X { \
- X char *p=(str1), *q=(str2); \
- X uch c; \
- X while ((c = *p++) != '\0') { \
- X if (iskanji(c)) { \
- X if (*p == '\0') \
- X break; \
- X *q++ = c; \
- X *q++ = *p++; \
- X } else \
- X *q++ = isupper(c) ? tolower(c) : c; \
- X } \
- X *q = '\0'; \
- X }
- X#else
- X# define TOLOWER(str1, str2) \
- X { \
- X char *p, *q; \
- X p = (str1) - 1; \
- X q = (str2); \
- X while (*++p) \
- X *q++ = (char)(isupper((int)(*p))? tolower((int)(*p)) : *p); \
- X *q = '\0'; \
- X }
- X#endif
- X/*
- X * NOTES: This macro makes no assumptions about the characteristics of
- X * the tolower() function or macro (beyond its existence), nor does it
- X * make assumptions about the structure of the character set (i.e., it
- X * should work on EBCDIC machines, too). The fact that either or both
- X * of isupper() and tolower() may be macros has been taken into account;
- X * watch out for "side effects" (in the C sense) when modifying this
- X * macro.
- X */
- X
- X
- X#ifndef native
- X# define native(c) (c)
- X# define A_TO_N(str1)
- X#else
- X# ifndef NATIVE
- X# define NATIVE "native chars"
- X# endif
- X# define A_TO_N(str1) {register unsigned char *p;\
- X for (p=str1; *p; p++) *p=native(*p);}
- X#endif
- X
- X/*
- X * Translate the zero-terminated string in str1 from ASCII to the native
- X * character set. The translation is performed in-place and uses the
- X * "native" macro to translate each character.
- X *
- X * macro A_TO_N( str1 )
- X * {
- X * register unsigned char *p;
- X *
- X * for (p = str1; *p; ++p)
- X * *p = native(*p);
- X * }
- X *
- X * NOTE: Using the "native" macro means that is it the only part of unzip
- X * which knows which translation table (if any) is actually in use to
- X * produce the native character set. This makes adding new character set
- X * translation tables easy, insofar as all that is needed is an appropriate
- X * "native" macro definition and the translation table itself. Currently,
- X * the only non-ASCII native character set implemented is EBCDIC, but this
- X * may not always be so.
- X */
- X
- X
- X
- X
- X
- X/*************/
- X/* Globals */
- X/*************/
- X
- X extern int zipinfo_mode;
- X extern int aflag;
- X extern int cflag;
- X extern int C_flag;
- X extern int fflag;
- X extern int hflag;
- X extern int jflag;
- X extern int lflag;
- X extern int L_flag;
- X extern int overwrite_none;
- X extern int overwrite_all;
- X extern int force_flag;
- X extern int qflag;
- X#ifdef DOS_NT_OS2
- X extern int sflag;
- X extern int volflag;
- X#endif
- X extern int tflag;
- X extern int T_flag;
- X extern int uflag;
- X extern int vflag;
- X extern int V_flag;
- X#ifdef VMS
- X extern int secinf;
- X#endif
- X extern int zflag;
- X#ifdef MACOS
- X extern int HFSFlag;
- X#endif
- X extern int filespecs;
- X extern int xfilespecs;
- X extern int process_all_files;
- X extern int create_dirs;
- X#ifndef NO_ZIPINFO
- X extern int newzip;
- X#endif
- X extern LONGINT real_ecrec_offset;
- X extern LONGINT expect_ecrec_offset;
- X extern long csize;
- X extern long ucsize;
- X extern long used_csize;
- X extern char **pfnames;
- X extern char **pxnames;
- X extern char near sig[];
- X extern char near answerbuf[];
- X extern min_info *pInfo;
- X
- X extern union work area;
- X
- X#ifdef FUNZIP
- X extern ulg near crc_32_tab[];
- X#else
- X extern ulg *crc_32_tab;
- X#endif
- X extern ulg crc32val;
- X extern ush near mask_bits[];
- X
- X extern uch *inbuf;
- X extern uch *inptr;
- X extern int incnt;
- X extern ulg bitbuf;
- X extern int bits_left;
- X extern boolean zipeof;
- X extern char *zipfn;
- X extern int zipfd;
- X extern LONGINT ziplen;
- X extern LONGINT cur_zipfile_bufstart;
- X extern LONGINT extra_bytes;
- X extern uch *extra_field;
- X extern uch *hold;
- X extern char near local_hdr_sig[];
- X extern char near central_hdr_sig[];
- X extern char near end_central_sig[];
- X extern local_file_hdr lrec;
- X extern cdir_file_hdr crec;
- X extern ecdir_rec ecrec;
- X extern struct stat statbuf;
- X
- X extern int mem_mode;
- X extern int disk_full;
- X extern int newfile;
- X#ifdef SYMLINKS
- X extern int symlnk;
- X#endif
- X#ifdef FUNZIP
- X extern FILE *in;
- X#endif
- X extern FILE *outfile;
- X extern uch *outbuf;
- X extern uch *outbuf2;
- X extern uch *outptr;
- X extern ulg outcnt;
- X#ifdef MSWIN
- X extern char *filename;
- X#else
- X extern char near filename[];
- X#endif
- X
- X#ifdef DECLARE_ERRNO
- X extern int errno;
- X#endif
- X
- X#ifdef EBCDIC
- X extern uch ebcdic[];
- X#endif
- X
- X#ifdef MACOS
- X extern short gnVRefNum;
- X extern long glDirID;
- X extern OSType gostCreator;
- X extern OSType gostType;
- X extern boolean fMacZipped;
- X extern boolean macflag;
- X extern short giCursor;
- X extern CursHandle rghCursor[];
- X#endif
- X
- X extern char Far CentSigMsg[];
- X extern char Far EndSigMsg[];
- X extern char Far SeekMsg[];
- X extern char Far ReportMsg[];
- X extern char Far FilenameNotMatched[];
- X extern char Far ExclFilenameNotMatched[];
- X
- X#endif /* !__unzip_h */
- END_OF_FILE
- if test 59872 -ne `wc -c <'unzip-5.12/unzip.h'`; then
- echo shar: \"'unzip-5.12/unzip.h'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/unzip.h'
- fi
- if test ! -d 'unzip-5.12/vms' ; then
- echo shar: Creating directory \"'unzip-5.12/vms'\"
- mkdir 'unzip-5.12/vms'
- fi
- echo shar: End of archive 1 \(of 20\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-