home *** CD-ROM | disk | FTP | other *** search
- From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Newsgroups: comp.sources.misc
- Subject: v44i067: unzip - Info-ZIP portable UnZip, version 5.12, Part02/20
- Date: 18 Sep 1994 23:14:15 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <35j36n$ql8@sparky.sterling.com>
- X-Md4-Signature: 47ae4012b7e9e158096699c48e706456
-
- Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Posting-number: Volume 44, Issue 67
- Archive-name: unzip/part02
- 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
-
- #! /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/nt/Contents unzip-5.12/unzip.c
- # Wrapped by kent@sparky on Sat Sep 17 23:33:36 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 2 (of 20)."'
- if test -f 'unzip-5.12/nt/Contents' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/nt/Contents'\"
- else
- echo shar: Extracting \"'unzip-5.12/nt/Contents'\" \(202 characters\)
- sed "s/^X//" >'unzip-5.12/nt/Contents' <<'END_OF_FILE'
- XContents of the "nt" sub-archive for UnZip 5.1 and later:
- X
- X Contents this file
- X Makefile makefile for UnZip and MS NT SDK or VC++, or DEC C/C++
- X nt.c NT-specific support routines
- X
- END_OF_FILE
- if test 202 -ne `wc -c <'unzip-5.12/nt/Contents'`; then
- echo shar: \"'unzip-5.12/nt/Contents'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/nt/Contents'
- fi
- if test -f 'unzip-5.12/unzip.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/unzip.c'\"
- else
- echo shar: Extracting \"'unzip-5.12/unzip.c'\" \(66790 characters\)
- sed "s/^X//" >'unzip-5.12/unzip.c' <<'END_OF_FILE'
- X/*---------------------------------------------------------------------------
- X
- X unzip.c
- X
- X UnZip - a zipfile extraction utility. See below for make instructions, or
- X read the comments in Makefile and the various Contents files for more de-
- X tailed explanations. To report a bug, send a *complete* description to
- X zip-bugs@wkuvx1.wku.edu; include machine type, operating system and ver-
- X sion, compiler and version, and reasonably detailed error messages or prob-
- X lem report. To join Info-ZIP, see the instructions in README.
- X
- X UnZip 5.x is a greatly expanded and partially rewritten successor to 4.x,
- X which in turn was almost a complete rewrite of version 3.x. For a detailed
- X revision history, see UnzpHist.zip at quest.jpl.nasa.gov. For a list of
- X the many (near infinite) contributors, see "CONTRIBS" in the UnZip source
- X distribution.
- X
- X ---------------------------------------------------------------------------
- X
- X [from original zipinfo.c]
- X
- X This program reads great gobs of totally nifty information, including the
- X central directory stuff, from ZIP archives ("zipfiles" for short). It
- X started as just a testbed for fooling with zipfiles, but at this point it
- X is actually a useful utility. It also became the basis for the rewrite of
- X UnZip (3.16 -> 4.0), using the central directory for processing rather than
- X the individual (local) file headers.
- X
- X As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
- X If the executable is named "unzip" (or "unzip.exe", depending), it behaves
- X like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
- X ZipInfo. The ZipInfo behavior may also be triggered by use of unzip's -Z
- X option; for example, "unzip -Z [zipinfo_options] archive.zip".
- X
- X Another dandy product from your buddies at Newtware!
- X
- X Author: Greg Roelofs, newt@uchicago.edu, 23 August 1990 -> ... 1994
- X
- X ---------------------------------------------------------------------------
- X
- X Version: unzip512.{tar.Z | zip | zoo} for Unix, VMS, OS/2, MS-DOS, Windows,
- X Windows NT, Macintosh, Amiga, Atari, Human68K and TOPS-20. De-
- X cryption requires sources in zcrypt23.zip, and Windows (not NT)
- X support requires sources in wunz20sr.zip (not up to date). See
- X accompanying file "Where" in the main source distribution for
- X ftp, uucp and mail-server sites.
- X
- X Copyrights: see accompanying file "COPYING" in UnZip source distribution.
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X
- X#include "unzip.h" /* includes, typedefs, macros, prototypes, etc. */
- X#include "crypt.h"
- X#include "version.h"
- X#ifdef MSWIN
- X# include "wizunzip.h"
- X#endif
- X
- X
- X
- X/**********************/
- X/* Global Variables */
- X/**********************/
- X
- Xint zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */
- X
- Xint aflag=0; /* -a: do ASCII-EBCDIC and/or end-of-line translation */
- Xint cflag=0; /* -c: output to stdout */
- Xint C_flag=0; /* -C: match filenames case-insensitively */
- Xint dflag=0; /* -d: all args are files/dirs to be extracted */
- Xint fflag=0; /* -f: "freshen" (extract only newer files) */
- Xint hflag=0; /* -h: header line (zipinfo) */
- Xint jflag=0; /* -j: junk pathnames (unzip) */
- Xint lflag=(-1); /* -12slmv: listing format (zipinfo) */
- Xint L_flag=0; /* -L: convert filenames from some OSes to lowercase */
- Xint overwrite_none=0; /* -n: never overwrite files (no prompting) */
- Xint overwrite_all=0; /* -o: OK to overwrite files without prompting */
- Xint force_flag=0; /* (shares -o for now): force to override errors, etc. */
- Xint qflag=0; /* -q: produce a lot less output */
- X#ifdef DOS_NT_OS2
- X int sflag=0; /* -s: convert filename spaces (blanks) to underscores */
- X int volflag=0; /* -$: extract volume labels */
- X#endif
- Xint tflag=0; /* -t: test (unzip) or totals line (zipinfo) */
- Xint T_flag=0; /* -T: decimal time format (zipinfo) */
- Xint uflag=0; /* -u: "update" (extract only newer & brand-new files) */
- Xint vflag=0; /* -v: (verbosely) list directory */
- Xint V_flag=0; /* -V: don't strip VMS version numbers */
- X#ifdef VMS
- X int secinf=0; /* -X: keep owner/protection */
- X#endif
- Xint zflag=0; /* -z: display the zipfile comment (only, for unzip) */
- X
- Xint filespecs; /* number of real file specifications to be matched */
- Xint xfilespecs; /* number of excluded filespecs to be matched */
- Xint process_all_files = 0;
- Xint create_dirs; /* used by main(), mapname(), checkdir() */
- Xint extract_flag;
- X
- X#if (defined(CRYPT) || !defined(NO_ZIPINFO))
- X int newzip; /* used in extract.c, crypt.c, zipinfo.c */
- X#endif
- X
- XLONGINT real_ecrec_offset, expect_ecrec_offset;
- X
- Xlong csize; /* used by list_files(), ReadByte(): must be signed */
- Xlong ucsize; /* used by list_files(), unReduce(), explode() */
- Xlong used_csize; /* used by extract_or_test_member(), explode() */
- X
- Xstatic char *fnames[2] = {"*", NULL}; /* default filenames vector */
- Xchar **pfnames = fnames, **pxnames = &fnames[1];
- Xchar near sig[5];
- Xchar near answerbuf[10];
- X
- Xmin_info info[DIR_BLKSIZ], *pInfo=info;
- X
- X/*---------------------------------------------------------------------------
- X unreduce/unshrink/explode/inflate working storage and globals:
- X ---------------------------------------------------------------------------*/
- X
- Xunion work area; /* see unzip.h for the definition of work */
- Xulg crc32val;
- X
- Xush near mask_bits[] = {
- X 0x0000,
- X 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- X 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
- X};
- X
- X/*---------------------------------------------------------------------------
- X Input file variables:
- X ---------------------------------------------------------------------------*/
- X
- Xuch *inbuf, *inptr; /* input buffer (any size is OK) and pointer */
- Xint incnt;
- X
- Xulg bitbuf;
- Xint bits_left;
- Xboolean zipeof;
- X
- X#ifdef SFX
- X char *argv0; /* used for NT and EXE_EXTENSION */
- X#else
- X char *wildzipfn;
- X#endif
- Xchar *zipfn; /* GRR: MSWIN: must nuke any malloc'd zipfn... */
- X
- Xint zipfd; /* zipfile file handle */
- XLONGINT ziplen;
- X
- Xuch *hold;
- Xchar near local_hdr_sig[5]; /* initialize signatures at runtime so unzip */
- Xchar near central_hdr_sig[5]; /* executable won't look like a zipfile */
- Xchar near end_central_sig[5];
- X/* char extd_local_sig[5]; NOT USED YET */
- X
- Xcdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */
- Xlocal_file_hdr lrec; /* used in unzip.c, extract.c */
- Xecdir_rec ecrec; /* used in unzip.c, extract.c */
- Xstruct stat statbuf; /* used by main, mapname, check_for_newer */
- X
- XLONGINT cur_zipfile_bufstart; /* extract_or_test_files, readbuf, ReadByte */
- XLONGINT extra_bytes = 0; /* used in unzip.c, misc.c */
- X
- Xuch *extra_field = (uch *)NULL; /* used by VMS, Mac and OS/2 versions */
- X
- X#ifdef MACOS
- X short gnVRefNum;
- X long glDirID;
- X OSType gostCreator;
- X OSType gostType;
- X boolean fMacZipped;
- X boolean macflag;
- X CursHandle rghCursor[4]; /* status cursors */
- X short giCursor = 0;
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Output stream variables:
- X ---------------------------------------------------------------------------*/
- X
- Xint mem_mode = 0;
- Xint disk_full;
- X#ifdef SYMLINKS
- X int symlnk;
- X#endif
- XFILE *outfile;
- Xuch *outbuf;
- Xuch *outptr;
- Xulg outcnt; /* number of chars stored in outbuf */
- X#ifdef SMALL_MEM
- X uch *outbuf2; /* initialized in main() (never changes) */
- X#else
- X uch *outbuf2 = (uch *)NULL; /* malloc'd ONLY if unshrink and -a */
- X#endif
- X#ifdef MSWIN
- X char *filename;
- X#else
- X char near filename[FILNAMSIZ]; /* also used by NT for temporary SFX path */
- X#endif
- X
- X
- X
- X
- X
- X/********************/
- X/* Global strings */
- X/********************/
- X
- Xchar Far UnzipVersion[] = UZ_VERSION; /* now defined in version.h */
- X#ifndef NO_ZIPINFO
- X char Far ZipinfoVersion[] = ZI_VERSION;
- X#endif
- X
- Xchar Far EndSigMsg[] = "\nnote:\
- X didn't find end-of-central-dir signature at end of central dir.\n";
- Xchar Far CentSigMsg[] =
- X "error: expected central file header signature not found (file #%u).\n";
- Xchar Far SeekMsg[] =
- X "error [%s]: attempt to seek before beginning of zipfile\n%s";
- Xchar Far FilenameNotMatched[] = "caution: filename not matched: %s\n";
- Xchar Far ExclFilenameNotMatched[] =
- X "caution: excluded filename not matched: %s\n";
- X
- X#ifndef SFX
- X char Far CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
- X#endif
- X
- X#ifdef VMS
- X char Far ReportMsg[] = "\
- X (please check that you have transferred or created the zipfile in the\n\
- X appropriate BINARY mode--this includes ftp, Kermit, AND unzip'd zipfiles)\n";
- X#else
- X char Far ReportMsg[] = "\
- X (please check that you have transferred or created the zipfile in the\n\
- X appropriate BINARY mode and that you have compiled unzip properly)\n";
- X#endif
- X
- X/*******************/
- X/* Local strings */
- X/*******************/
- X
- X#ifndef SFX
- X static char Far EnvUnZip[] = ENV_UNZIP;
- X static char Far EnvUnZip2[] = ENV_UNZIP2;
- X static char Far EnvZipInfo[] = ENV_ZIPINFO;
- X static char Far EnvZipInfo2[] = ENV_ZIPINFO2;
- X#endif
- X
- X#if (!defined(SFX) || defined(SFX_EXDIR))
- X static char Far NotExtracting[] = "caution: not extracting; -d ignored\n";
- X static char Far MustGiveExdir[] =
- X "error: must specify directory to which to extract with -d option\n";
- X#endif
- X
- Xstatic char Far CentDirTooLong[] =
- X "error [%s]: reported length of central directory is\n\
- X %d bytes too long (Atari STZip zipfile? J.H.Holm ZIPSPLIT 1.1\n\
- X zipfile?). Compensating...\n";
- Xstatic char Far InvalidOptionsMsg[] = "error:\
- X -fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
- Xstatic char Far IgnoreOOptionMsg[] =
- X "caution: both -n and -o specified; ignoring -o\n";
- Xstatic char Far CantAllocateBuffers[] =
- X "error: can't allocate unzip buffers\n";
- X
- X/* usage() strings */
- X#ifndef VMSCLI
- X#ifndef SFX
- X#ifdef VMS
- X static char Far Example2[] = "vms.c";
- X static char Far Example1[] =
- X"unzip \"-V\" foo \"Bar\" => must quote uppercase options and filenames in VMS";
- X#else
- X static char Far Example2[] = "ReadMe";
- X static char Far Example1[] =
- X"unzip -p foo | more => send contents of foo.zip via pipe into program more";
- X#endif /* ?VMS */
- X
- X#ifdef DOS_NT_OS2
- X static char Far loc_str[] = " -$ label removables (-$$ => fixed disks)";
- X static char Far loc2str[] = "\
- X -s spaces in filenames => '_'\n";
- X#else /* !DOS_NT_OS2 */
- X#ifdef VMS
- X static char Far loc_str[] = "\"-X\" restore owner/protection info";
- X static char Far loc2str[] = "\n";
- X#else
- X static char Far loc_str[] = ""; /* Unix, Amiga, Mac, etc. */
- X /* char Far loc_str[] = " -X restore UID/GID info"; Unix version, in 5.2 */
- X static char Far loc2str[] = "";
- X#endif /* ?VMS */
- X#endif /* ?DOS_NT_OS2 */
- X#endif /* !SFX */
- X
- X#ifndef NO_ZIPINFO
- X#ifdef VMSWILD
- X static char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
- X#else
- X static char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
- X#endif
- Xstatic char Far ZipInfoUsageLine1[] = "\
- XZipInfo %s, by Newtware and the fine folks at Info-ZIP.\n\
- X\n\
- XList name, date/time, attribute, size, compression method, etc., about files\n\
- Xin list (excluding those in xlist) contained in the specified .zip archive(s).\
- X\n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
- X usage: zipinfo [-12smlvhtTz] file[.zip] [list...] [-x xlist...]\n\
- X or: unzip %s-Z%s [-12smlvhtTz] file[.zip] [list...] [-x xlist...]\n";
- X
- Xstatic char Far ZipInfoUsageLine2[] = "\nmain\
- X listing-format options: -s short Unix \"ls -l\" format (def.)\n\
- X -1 filenames ONLY, one per line -m medium Unix \"ls -l\" format\n\
- X -2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
- X -v verbose, multi-page format\n";
- X
- Xstatic char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
- X -h print header line -t print totals for listed files or for all\n\
- X -z print zipfile comment %c-T%c print file times in sortable decimal format\
- X\n -x exclude filenames that follow from listing\n";
- X/*" -p disable automatic \"more\" function (for pipes) [not implemented]\n";*/
- X#endif /* !NO_ZIPINFO */
- X#endif /* !VMSCLI */
- X
- X#ifdef BETA
- X static char Far BetaVersion[] = "%s\
- X THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
- X#endif
- X
- X#ifdef SFX
- X# if (defined(SFX_EXDIR) && !defined(VMS))
- X static char Far UnzipSFXUsage[] = "\
- XUnZipSFX %s, by Info-ZIP (zip-bugs@wkuvx1.wku.edu).\n\
- XValid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCLV%s.\n";
- X# else
- X static char Far UnzipSFXUsage[] = "\
- XUnZipSFX %s, by Info-ZIP (zip-bugs@wkuvx1.wku.edu).\n\
- XValid options are -tfupcz; modifiers are -abjnoqCLV%s.\n";
- X# endif
- X static char Far CantFindMyself[] =
- X "unzipsfx: can't find myself! [%s]\n";
- X#else /* !SFX */
- X static char Far CompileOptions[] = "UnZip special compilation options:\n";
- X static char Far CompileOptFormat[] = "\t%s\n";
- X static char Far EnvOptions[] = "\nUnZip and ZipInfo environment options:\n";
- X static char Far EnvOptFormat[] = "%16s: %s\n";
- X static char Far None[] = "[none]";
- X# ifdef NO_ZIPINFO
- X static char Far No_ZipInfo[] = "NO_ZIPINFO";
- X# endif
- X# ifdef CHECK_EOF
- X static char Far Check_EOF[] = "CHECK_EOF";
- X# endif
- X# ifdef DOSWILD
- X static char Far DosWild[] = "DOSWILD";
- X# endif
- X# ifdef VMSWILD
- X static char Far VmsWild[] = "VMSWILD";
- X# endif
- X# ifdef VMSCLI
- X static char Far VmsCLI[] = "VMSCLI";
- X# endif
- X# ifdef ASM_INFLATECODES
- X static char Far AsmInflateCodes[] = "ASM_INFLATECODES";
- X# endif
- X# ifdef ASM_CRC
- X static char Far AsmCRC[] = "ASM_CRC";
- X# endif
- X# ifdef REGARGS
- X static char Far RegArgs[] = "REGARGS";
- X# endif
- X# ifdef OLD_EXDIR
- X static char Far Old_Exdir[] = "OLD_EXDIR";
- X# endif
- X# ifdef CHECK_VERSIONS
- X static char Far Check_Versions[] = "CHECK_VERSIONS";
- X# endif
- X# ifdef RETURN_CODES
- X static char Far Return_Codes[] = "RETURN_CODES";
- X# endif
- X# ifdef RETURN_SEVERITY
- X static char Far Return_Severity[] = "RETURN_SEVERITY";
- X# endif
- X# ifdef DEBUG
- X static char Far Debug[] = "DEBUG";
- X# endif
- X# ifdef DEBUG_TIME
- X static char Far DebugTime[] = "DEBUG_TIME";
- X# endif
- X# ifdef CRYPT
- X static char Far Decryption[] = "[decryption]";
- X# endif
- X# ifdef __EMX__
- X static char Far EnvEMX[] = "EMX";
- X static char Far EnvEMXOPT[] = "EMXOPT";
- X# endif
- X# ifdef __GO32__
- X static char Far EnvGO32[] = "GO32";
- X static char Far EnvGO32TMP[] = "GO32TMP";
- X# endif
- X
- X/* UnzipUsageLine1[] is also used in vms/cmdline.c: do not make it static */
- Xchar Far UnzipUsageLine1[] = "\
- XUnZip %s, by Info-ZIP. Portions (c) 1989 by S. H. Smith.\n\
- XSend bug reports to authors at zip-bugs@wkuvx1.wku.edu; see README for details.\
- X\n\n";
- Xstatic char Far UnzipUsageLine2a[] = "\
- XLatest sources and executables are always in ftp.uu.net:/pub/archiving/zip, at\
- X\nleast as of date of this release; see \"Where\" for other ftp and non-ftp \
- Xsites.\n\n";
- X
- X#ifndef VMSCLI
- Xstatic char Far UnzipUsageLine2[] = "\
- XUsage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
- X Default action is to extract files in list, except those in xlist, to exdir;\n\
- X file[.zip] may be a wildcard. %s\n\n";
- X
- X#ifdef NO_ZIPINFO
- X# define ZIPINFO_MODE_OPTION ""
- X static char Far ZipinfoMode[] =
- X "(ZipInfo mode is disabled in this version.)";
- X#else
- X# define ZIPINFO_MODE_OPTION "[-Z] "
- X# ifdef VMS
- X static char Far ZipinfoMode[] =
- X "\"-Z\" => ZipInfo mode (`unzip \"-Z\"' for usage).";
- X# else
- X static char Far ZipinfoMode[] =
- X "-Z => ZipInfo mode (\"unzip -Z\" for usage).";
- X# endif
- X#endif /* ?NO_ZIPINFO */
- X
- Xstatic char Far UnzipUsageLine3[] = "\
- X -p extract files to pipe, no messages -l list files (short format)\n\
- X -f freshen existing files, create none -t test compressed archive data\n\
- X -u update files, create if necessary -z display archive comment\n\
- X -x exclude files which follow (in xlist) -d extract files into exdir\n\n";
- X
- Xstatic char Far UnzipUsageLine4[] = "\
- Xmodifiers: -q quiet mode (-qq => quieter)\n\
- X -n never overwrite existing files -a auto-convert any text files\n\
- X -o overwrite files WITHOUT prompting -aa treat ALL files as text\n \
- X -j junk paths (don't make directories) -v be verbose/print version info\n\
- X %c-C%c match filenames case-insensitively %c-L%c make (some) names \
- Xlowercase\n %-42s %c-V%c retain VMS version numbers\n%s";
- X
- Xstatic char Far UnzipUsageLine5[] = "\
- XExamples (see unzip.doc for more info):\n\
- X unzip data1 -x joe => extract all files except joe from zipfile data1.zip\n\
- X %s\n\
- X unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
- X#endif /* !VMSCLI */
- X
- X/* process_zipfiles() strings */
- X static char Far FilesProcessOK[] = "%d archive%s successfully processed.\n";
- X static char Far ArchiveWarning[] =
- X "%d archive%s had warnings but no fatal errors.\n";
- X static char Far ArchiveFatalError[] = "%d archive%s had fatal errors.\n";
- X static char Far FileHadNoZipfileDir[] =
- X "%d file%s had no zipfile directory.\n";
- X static char Far ZipfileWasDir[] = "1 \"zipfile\" was a directory.\n";
- X static char Far ManyZipfilesWereDir[] =
- X "%d \"zipfiles\" were directories.\n";
- X static char Far NoZipfileFound[] = "No zipfiles found.\n";
- X#endif /* ?SFX */
- X
- X/* do_seekable() strings */
- X#ifndef SFX
- X#ifdef UNIX
- X static char Far CantFindZipfileDirMsg[] =
- X "%s: can't find zipfile directory in one of %s or\n\
- X %s%s.zip, and can't find %s, period.\n";
- X static char Far CantFindEitherZipfile[] =
- X "%s: can't find %s, %s.zip or %s, so there.\n";
- X#else /* !UNIX */
- X static char Far CantFindZipfileDirMsg[] =
- X "%s: can't find zipfile directory in %s,\n\
- X %sand can't find %s, period.\n";
- X static char Far CantFindEitherZipfile[] =
- X "%s: can't find either %s or %s, so there.\n";
- X#endif /* ?UNIX */
- X static char Far MaybeExe[] =
- X "note: %s may be a plain executable, not an archive\n";
- X static char Far CentDirNotInZipMsg[] = "\n\
- X Zipfile is part of a multi-disk archive, and this is not the disk on\n\
- X which the central zipfile directory begins.\n";
- X#ifdef NO_MULTIPART
- X static char Far NoMultiDiskArcSupport[] =
- X "\nerror [%s]: zipfile is part of multi-disk archive\n\
- X (sorry, not yet supported).\n";
- X static char Far MaybePakBug[] = "warning [%s]:\
- X zipfile claims to be 2nd disk of a 2-part archive;\n\
- X attempting to process anyway. If no further errors occur, this archive\n\
- X was probably created by PAK v2.51 or earlier. This bug was reported to\n\
- X NoGate in March 1991 and was supposed to have been fixed by mid-1991; as\n\
- X of mid-1992 it still hadn't been. (If further errors do occur, archive\n\
- X was probably created by PKZIP 2.04c or later; UnZip does not yet support\n\
- X multi-part archives.)\n";
- X#else
- X static char Far MaybePakBug[] = "warning [%s]:\
- X zipfile claims to be last disk of a multi-part archive;\n\
- X attempting to process anyway, assuming all parts have been concatenated\n\
- X together in order. Expect \"errors\" and warnings...true multi-part support\
- X\n doesn't exist yet (coming soon).\n";
- X#endif
- X static char Far ExtraBytesAtStart[] =
- X "warning [%s]: extra %ld bytes at beginning or within zipfile\n\
- X (attempting to process anyway)\n";
- X#endif /* !SFX */
- X
- Xstatic char Far MissingBytes[] =
- X "error [%s]: missing %ld bytes in zipfile\n\
- X (attempting to process anyway)\n";
- Xstatic char Far NullCentDirOffset[] =
- X "error [%s]: NULL central directory offset\n\
- X (attempting to process anyway)\n";
- Xstatic char Far ZipfileEmpty[] = "warning [%s]: zipfile is empty\n";
- Xstatic char Far CentDirStartNotFound[] =
- X "error [%s]: start of central directory not found;\n\
- X zipfile corrupt.\n%s";
- Xstatic char Far ZipfileCommTrunc1[] = "\ncaution: zipfile comment truncated\n";
- X
- X
- X
- X
- X
- X#ifdef MSWIN
- X# include "winsetup.c" /* duplicates some code in main() */
- X#else /* !MSWIN */
- X
- X
- X
- X/******************/
- X/* Main program */
- X/******************/
- X
- Xint MAIN(argc, argv) /* return PK-type error code (except under VMS) */
- X int argc;
- X char *argv[];
- X{
- X#ifndef NO_ZIPINFO
- X char *p;
- X#endif
- X int error=FALSE;
- X#if defined(__IBMC__) && defined(__DEBUG_ALLOC__)
- X extern void DebugMalloc(void);
- X
- X
- X atexit(DebugMalloc);
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Macintosh initialization code.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MACOS
- X int a;
- X
- X for (a = 0; a < 4; ++a)
- X rghCursor[a] = GetCursor(a+128);
- X giCursor = 0;
- X
- X aflag=cflag=dflag=fflag=L_flag=jflag=qflag=tflag=uflag=vflag=zflag = 0;
- X local_hdr_sig[1] = central_hdr_sig[1] = end_central_sig[1] = '\0';
- X/* extd_local_sig[1] = '\0'; */
- X error = FALSE;
- X
- X overwrite_none = overwrite_all = force_flag = 0;
- X#endif /* MACOS */
- X
- X#ifdef MALLOC_WORK
- X area.Slide = (uch *)calloc(8193, sizeof(short)+sizeof(char)+sizeof(char));
- X area.shrink.Prefix_of = (short *)area.Slide;
- X area.shrink.Suffix_of = area.Slide + (sizeof(short)*(HSIZE+1));
- X area.shrink.Stack = area.Slide + (sizeof(short) + sizeof(char))*(HSIZE+1);
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Human68K initialization code.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef __human68k__
- X InitTwentyOne();
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X Set signal handler for restoring echo, warn of zipfile corruption, etc.
- X ---------------------------------------------------------------------------*/
- X
- X signal(SIGINT, handler);
- X#ifdef SIGTERM /* some systems really have no SIGTERM */
- X signal(SIGTERM, handler);
- X#endif
- X#ifdef SIGBUS
- X signal(SIGBUS, handler);
- X#endif
- X#ifdef SIGSEGV
- X signal(SIGSEGV, handler);
- X#endif
- X
- X/*---------------------------------------------------------------------------
- X First figure out if we're running in UnZip mode or ZipInfo mode, and put
- X the appropriate environment-variable options into the queue. Then rip
- X through any command-line options lurking about...
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef SFX
- X argv0 = argv[0];
- X#if defined(OS2) || defined(NT)
- X zipfn = GetLoadPath(); /* non-MSC NT puts path into filename[] */
- X#else
- X zipfn = argv0;
- X#endif
- X zipinfo_mode = FALSE;
- X if ((error = uz_opts(&argc, &argv)) != 0)
- X RETURN(error);
- X
- X#else /* !SFX */
- X
- X#ifdef MSDOS
- X /* extract MKS extended argument list from environment (before envargs!) */
- X mksargs(&argc, &argv);
- X#endif
- X
- X#ifdef VMSCLI
- X {
- X ulg status = vms_unzip_cmdline(&argc, &argv);
- X if (!(status & 1))
- X return status;
- X }
- X#endif /* VMSCLI */
- X
- X#ifndef NO_ZIPINFO
- X if ((p = strrchr(argv[0], DIR_END)) == (char *)NULL)
- X p = argv[0];
- X else
- X ++p;
- X
- X if (STRNICMP(p, "zipinfo", 7) == 0 || STRNICMP(p, "ii", 2) == 0 ||
- X (argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
- X {
- X zipinfo_mode = TRUE;
- X envargs(&argc, &argv, LoadFarStringSmall(EnvZipInfo),
- X LoadFarStringSmall2(EnvZipInfo2));
- X error = zi_opts(&argc, &argv);
- X } else
- X#endif /* NO_ZIPINFO */
- X {
- X zipinfo_mode = FALSE;
- X envargs(&argc, &argv, LoadFarStringSmall(EnvUnZip),
- X LoadFarStringSmall2(EnvUnZip2));
- X error = uz_opts(&argc, &argv);
- X }
- X if ((argc < 0) || error)
- X RETURN(error);
- X
- X#endif /* ?SFX */
- X
- X/*---------------------------------------------------------------------------
- X Now get the zipfile name from the command line and then process any re-
- X maining options and file specifications.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef DOS_NT_OS2
- X /* convert MSDOS-style directory separators to Unix-style ones for
- X * user's convenience (include zipfile name itself)
- X */
- X pfnames = argv;
- X while (*pfnames != NULL) {
- X char *q;
- X
- X for (q = *pfnames; *q; ++q)
- X if (*q == '\\')
- X *q = '/';
- X ++pfnames;
- X }
- X#endif /* DOS_NT_OS2 */
- X
- X#ifndef SFX
- X wildzipfn = *argv++;
- X#endif
- X
- X#if (defined(OLD_EXDIR) || (defined(SFX) && !defined(SFX_EXDIR)))
- X
- X#ifndef SFX
- X if (argc > 0) {
- X /* -d: "name/" immediately after zipfile name is a stored directory to
- X * be extracted--do NOT treat as directory to which to extract files
- X */
- X if (extract_flag && !dflag) {
- X create_dirs = !fflag;
- X if ((error = checkdir(*argv, ROOT)) > 2) /* mem, or file in way */
- X RETURN(error);
- X else if (!error) { /* it IS extract-to dir, so adjust pointers */
- X ++argv;
- X --argc;
- X }
- X }
- X }
- X#endif /* !SFX */
- X
- X filespecs = argc;
- X xfilespecs = 0;
- X
- X if (argc > 0) {
- X char **pp = argv-1;
- X
- X pfnames = argv;
- X while (*++pp)
- X if (strcmp(*pp, "-x") == 0) {
- X if (pp > argv) {
- X *pp = 0; /* terminate pfnames */
- X filespecs = pp - pfnames;
- X } else {
- X pfnames = fnames; /* defaults */
- X filespecs = 0;
- X }
- X pxnames = pp + 1; /* excluded-names ptr starts after -x */
- X xfilespecs = argc - filespecs - 1;
- X break; /* skip rest of args */
- X }
- X process_all_files = FALSE;
- X } else
- X process_all_files = TRUE; /* for speed */
- X
- X#else /* !(OLD_EXDIR || (SFX && !SFX_EXDIR)) */
- X
- X filespecs = argc;
- X xfilespecs = 0;
- X
- X if (argc > 0) {
- X int in_files=FALSE, in_xfiles=FALSE;
- X char **pp = argv-1;
- X
- X process_all_files = FALSE;
- X pfnames = argv;
- X while (*++pp) {
- X Trace((stderr, "pp - argv = %d\n", pp-argv));
- X if (!dflag && strncmp(*pp, "-d", 2) == 0) {
- X char *q = *pp;
- X int firstarg = (pp == argv);
- X
- X dflag = TRUE;
- X if (in_files) { /* ... zipfile ... -d exdir ... */
- X *pp = 0; /* terminate pfnames */
- X filespecs = pp - pfnames;
- X in_files = FALSE;
- X } else if (in_xfiles) {
- X *pp = 0; /* terminate pxnames */
- X xfilespecs = pp - pxnames;
- X /* "... -x xlist -d exdir": nothing left */
- X }
- X /* first check for "-dpath", then for "-d path" */
- X if (q[2])
- X q += 2;
- X else if (*++pp)
- X q = *pp;
- X else {
- X FPRINTF(stderr, LoadFarString(MustGiveExdir));
- X RETURN(PK_PARAM); /* don't extract here by accident */
- X }
- X if (extract_flag) {
- X create_dirs = !fflag;
- X if ((error = checkdir(q, ROOT)) > 2)
- X RETURN(error); /* out of memory, or file in way */
- X } else
- X FPRINTF(stderr, LoadFarString(NotExtracting));
- X if (firstarg) /* ... zipfile -d exdir ... */
- X if (pp[1]) {
- X pfnames = pp + 1; /* argv+2 */
- X filespecs = argc - (pfnames-argv); /* for now... */
- X } else {
- X process_all_files = TRUE;
- X pfnames = fnames; /* GRR: necessary? */
- X filespecs = 0; /* GRR: necessary? */
- X break;
- X }
- X } else if (!in_xfiles) {
- X if (strcmp(*pp, "-x") == 0) {
- X in_xfiles = TRUE;
- X if (pp == argv || (pp == argv+2 && dflag)) {
- X pfnames = fnames; /* defaults */
- X filespecs = 0;
- X } else if (in_files) {
- X *pp = 0; /* terminate pfnames */
- X filespecs = pp - pfnames; /* adjust count */
- X in_files = FALSE;
- X }
- X pxnames = pp + 1; /* excluded-names ptr starts after -x */
- X xfilespecs = argc - (pxnames-argv); /* anything left... */
- X } else
- X in_files = TRUE;
- X }
- X }
- X } else
- X process_all_files = TRUE; /* for speed */
- X
- X#endif /* ?(OLD_EXDIR || (SFX && !SFX_EXDIR)) */
- X
- X/*---------------------------------------------------------------------------
- X Okey dokey, we have everything we need to get started. Let's roll.
- X ---------------------------------------------------------------------------*/
- X
- X inbuf = (uch *)malloc(INBUFSIZ + 4); /* 4 extra for hold[] (below) */
- X outbuf = (uch *)malloc(OUTBUFSIZ + 1); /* 1 extra for string termin. */
- X
- X if ((inbuf == (uch *)NULL) || (outbuf == (uch *)NULL)) {
- X FPRINTF(stderr, LoadFarString(CantAllocateBuffers));
- X RETURN(PK_MEM);
- X }
- X hold = inbuf + INBUFSIZ; /* to check for boundary-spanning signatures */
- X#ifdef SMALL_MEM
- X outbuf2 = outbuf+RAWBUFSIZ; /* never changes */
- X#endif
- X
- X RETURN(process_zipfiles()); /* keep passing errors back... */
- X
- X} /* end main() */
- X
- X
- X
- X
- X
- X/**********************/
- X/* Function uz_opts() */
- X/**********************/
- X
- Xint uz_opts(pargc, pargv)
- X int *pargc;
- X char ***pargv;
- X{
- X char **argv, *s;
- X int argc, c, error=FALSE, negative=0;
- X
- X
- X argc = *pargc;
- X argv = *pargv;
- X
- X while (--argc > 0 && (*++argv)[0] == '-') {
- X s = argv[0] + 1;
- X while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
- X switch (c) {
- X case ('-'):
- X ++negative;
- X break;
- X case ('a'):
- X if (negative) {
- X aflag = MAX(aflag-negative,0);
- X negative = 0;
- X } else
- X ++aflag;
- X break;
- X case ('b'):
- X if (negative)
- X negative = 0; /* do nothing: "-b" is default */
- X else
- X aflag = 0;
- X break;
- X case ('c'):
- X if (negative) {
- X cflag = FALSE, negative = 0;
- X#ifdef NATIVE
- X aflag = 0;
- X#endif
- X } else {
- X cflag = TRUE;
- X#ifdef NATIVE
- X aflag = 2; /* so you can read it on the screen */
- X#endif
- X }
- X break;
- X case ('C'): /* -C: match filenames case-insensitively */
- X if (negative)
- X C_flag = FALSE, negative = 0;
- X else
- X C_flag = TRUE;
- X break;
- X case ('d'): /* arg after zipfn is stored dir, not extract-to */
- X#ifdef OLD_EXDIR
- X if (negative)
- X dflag = FALSE, negative = 0;
- X else
- X dflag = TRUE;
- X#endif
- X break;
- X case ('e'): /* just ignore -e, -x options (extract) */
- X break;
- X case ('f'): /* "freshen" (extract only newer files) */
- X if (negative)
- X fflag = uflag = FALSE, negative = 0;
- X else
- X fflag = uflag = TRUE;
- X break;
- X case ('j'): /* junk pathnames/directory structure */
- X if (negative)
- X jflag = FALSE, negative = 0;
- X else
- X jflag = TRUE;
- X break;
- X#ifndef SFX
- X case ('l'):
- X if (negative) {
- X vflag = MAX(vflag-negative,0);
- X negative = 0;
- X } else
- X ++vflag;
- X break;
- X#endif /* !SFX */
- X case ('L'): /* convert (some) filenames to lowercase */
- X if (negative)
- X L_flag = FALSE, negative = 0;
- X else
- X L_flag = TRUE;
- X break;
- X case ('n'): /* don't overwrite any files */
- X if (negative)
- X overwrite_none = FALSE, negative = 0;
- X else
- X overwrite_none = TRUE;
- X break;
- X case ('o'): /* OK to overwrite files without prompting */
- X if (negative) {
- X overwrite_all = MAX(overwrite_all-negative,0);
- X force_flag = MAX(force_flag-negative,0);
- X negative = 0;
- X } else {
- X ++overwrite_all;
- X ++force_flag; /* (share -o for now) force to cont. */
- X }
- X break;
- X case ('p'): /* pipes: extract to stdout, no messages */
- X if (negative) {
- X cflag = FALSE;
- X qflag = MAX(qflag-999,0);
- X negative = 0;
- X } else {
- X cflag = TRUE;
- X qflag += 999;
- X }
- X break;
- X case ('q'): /* quiet: fewer comments/messages */
- X if (negative) {
- X qflag = MAX(qflag-negative,0);
- X negative = 0;
- X } else
- X ++qflag;
- X break;
- X#ifdef DOS_NT_OS2
- X case ('s'): /* spaces in filenames: allow by default */
- X if (negative)
- X sflag = FALSE, negative = 0;
- X else
- X sflag = TRUE;
- X break;
- X#endif
- X case ('t'):
- X if (negative)
- X tflag = FALSE, negative = 0;
- X else
- X tflag = TRUE;
- X break;
- X case ('u'): /* update (extract only new and newer files) */
- X if (negative)
- X uflag = FALSE, negative = 0;
- X else
- X uflag = TRUE;
- X break;
- X case ('U'): /* obsolete; to be removed in future release */
- X if (negative)
- X L_flag = TRUE, negative = 0;
- X else
- X L_flag = FALSE;
- X break;
- X#ifndef SFX
- X case ('v'): /* verbose */
- X if (negative) {
- X vflag = MAX(vflag-negative,0);
- X negative = 0;
- X } else if (vflag)
- X ++vflag;
- X else
- X vflag = 2;
- X break;
- X#endif /* !SFX */
- X case ('V'): /* Version (retain VMS/DEC-20 file versions) */
- X if (negative)
- X V_flag = FALSE, negative = 0;
- X else
- X V_flag = TRUE;
- X break;
- X case ('x'): /* extract: default */
- X break;
- X#ifdef VMS
- X case ('X'): /* restore owner/protection info (need privs?) */
- X if (negative)
- X secinf = FALSE, negative = 0;
- X else
- X secinf = TRUE;
- X break;
- X#endif /* VMS */
- X case ('z'): /* display only the archive comment */
- X if (negative) {
- X zflag -= negative;
- X negative = 0;
- X } else
- X ++zflag;
- X break;
- X#ifdef DOS_NT_OS2
- X case ('$'):
- X if (negative) {
- X volflag = MAX(volflag-negative,0);
- X negative = 0;
- X } else
- X ++volflag;
- X break;
- X#endif /* DOS_NT_OS2 */
- X default:
- X error = TRUE;
- X break;
- X
- X } /* end switch */
- X } /* end while (not end of argument string) */
- X } /* end while (not done with switches) */
- X
- X/*---------------------------------------------------------------------------
- X Check for nonsensical combinations of options.
- X ---------------------------------------------------------------------------*/
- X
- X if ((cflag && tflag) || (cflag && uflag) || (tflag && uflag) ||
- X (fflag && overwrite_none)) {
- X FPRINTF(stderr, LoadFarString(InvalidOptionsMsg));
- X error = TRUE;
- X }
- X if (aflag > 2)
- X aflag = 2;
- X if (overwrite_all && overwrite_none) {
- X FPRINTF(stderr, LoadFarString(IgnoreOOptionMsg));
- X overwrite_all = FALSE;
- X }
- X
- X#ifdef SFX
- X if (error)
- X#else
- X if ((argc-- == 0) || error)
- X#endif
- X {
- X *pargc = argc;
- X *pargv = argv;
- X#ifndef SFX
- X if (vflag >= 2 && argc == -1) {
- X if (qflag > 3)
- X PRINTF("%d\n", (UZ_MAJORVER*100 + UZ_MINORVER*10 + PATCHLEVEL));
- X else {
- X char *envptr, *getenv();
- X int numopts = 0;
- X
- X PRINTF(LoadFarString(UnzipUsageLine1),
- X LoadFarStringSmall(UnzipVersion));
- X PRINTF(LoadFarString(UnzipUsageLine2a));
- X version();
- X PRINTF(LoadFarString(CompileOptions));
- X#ifdef NO_ZIPINFO
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(No_ZipInfo));
- X ++numopts;
- X#endif
- X#ifdef CHECK_EOF
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Check_EOF));
- X ++numopts;
- X#endif
- X#ifdef DOSWILD
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(DosWild));
- X ++numopts;
- X#endif
- X#ifdef VMSWILD
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(VmsWild));
- X ++numopts;
- X#endif
- X#ifdef VMSCLI
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(VmsCLI));
- X ++numopts;
- X#endif
- X#ifdef ASM_INFLATECODES
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(AsmInflateCodes));
- X ++numopts;
- X#endif
- X#ifdef ASM_CRC
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(AsmCRC));
- X ++numopts;
- X#endif
- X#ifdef REGARGS
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(RegArgs));
- X ++numopts;
- X#endif
- X#ifdef OLD_EXDIR
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Old_Exdir));
- X ++numopts;
- X#endif
- X#ifdef CHECK_VERSIONS
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Check_Versions));
- X ++numopts;
- X#endif
- X#ifdef RETURN_CODES
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Return_Codes));
- X ++numopts;
- X#endif
- X#ifdef RETURN_SEVERITY
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Return_Severity));
- X ++numopts;
- X#endif
- X#ifdef DEBUG
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Debug));
- X ++numopts;
- X#endif
- X#ifdef DEBUG_TIME
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(DebugTime));
- X ++numopts;
- X#endif
- X#ifdef CRYPT
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(Decryption));
- X ++numopts;
- X#endif
- X if (numopts == 0)
- X PRINTF(LoadFarString(CompileOptFormat),
- X LoadFarStringSmall(None));
- X
- X PRINTF(LoadFarString(EnvOptions));
- X envptr = getenv(LoadFarStringSmall(EnvUnZip));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvUnZip),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X envptr = getenv(LoadFarStringSmall(EnvUnZip2));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvUnZip2),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X envptr = getenv(LoadFarStringSmall(EnvZipInfo));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvZipInfo),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X envptr = getenv(LoadFarStringSmall(EnvZipInfo2));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvZipInfo2),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X#ifdef __EMX__
- X envptr = getenv(LoadFarStringSmall(EnvEMX));
- X PRINTF(LoadFarString(EnvOptFormat), LoadFarStringSmall(EnvEMX),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X envptr = getenv(LoadFarStringSmall(EnvEMXOPT));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvEMXOPT),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X#endif /* __EMX__ */
- X#ifdef __GO32__
- X envptr = getenv(LoadFarStringSmall(EnvGO32));
- X PRINTF(LoadFarString(EnvOptFormat), LoadFarStringSmall(EnvGO32),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X envptr = getenv(LoadFarStringSmall(EnvGO32TMP));
- X PRINTF(LoadFarString(EnvOptFormat),
- X LoadFarStringSmall(EnvGO32TMP),
- X (envptr == (char *)NULL || *envptr == 0)?
- X LoadFarStringSmall2(None) : envptr);
- X#endif /* __GO32__ */
- X }
- X return 0;
- X } else
- X#endif /* !SFX */
- X return usage(error);
- X }
- X
- X if (cflag || tflag || vflag)
- X extract_flag = FALSE;
- X else
- X extract_flag = TRUE;
- X
- X *pargc = argc;
- X *pargv = argv;
- X return 0;
- X
- X} /* end function uz_opts() */
- X
- X
- X
- X
- X
- X/********************/
- X/* Function usage() */
- X/********************/
- X
- X#ifdef SFX
- X# ifdef VMS
- X# define LOCAL "X. Quote uppercase options"
- X# else
- X# ifdef DOS_NT_OS2
- X# define LOCAL "s$"
- X# else
- X# ifdef AMIGA
- X# define LOCAL "$"
- X# else
- X# define LOCAL ""
- X# endif
- X# endif /* ?DOS_NT_OS2 */
- X# endif /* ?VMS */
- X
- Xint usage(error) /* return PK-type error code */
- X int error;
- X{
- X FILE *usagefp;
- X
- X if (error)
- X usagefp = (FILE *)stderr;
- X else
- X usagefp = (FILE *)stdout;
- X
- X FPRINTF(usagefp, LoadFarString(UnzipSFXUsage),
- X LoadFarStringSmall(UnzipVersion), LOCAL);
- X#ifdef BETA
- X FPRINTF(usagefp, LoadFarString(BetaVersion), "\n", "SFX");
- X#endif
- X
- X if (error)
- X return PK_PARAM;
- X else
- X return PK_COOL; /* just wanted usage screen: no error */
- X
- X} /* end function usage() */
- X
- X
- X
- X
- X
- X#else /* !SFX */
- X#ifndef VMSCLI
- X
- Xint usage(error) /* return PK-type error code */
- X int error;
- X{
- X#ifdef VMS
- X# define QUOT '\"'
- X# define QUOTS "\""
- X#else
- X# define QUOT ' '
- X# define QUOTS ""
- X#endif
- X
- X FILE *usagefp;
- X
- X
- X/*---------------------------------------------------------------------------
- X If user requested usage, send it to stdout; else send to stderr.
- X ---------------------------------------------------------------------------*/
- X
- X if (error)
- X usagefp = (FILE *)stderr;
- X else
- X usagefp = (FILE *)stdout;
- X
- X/*---------------------------------------------------------------------------
- X Print either ZipInfo usage or UnZip usage, depending on incantation.
- X (Strings must be no longer than 512 bytes for Turbo C, apparently.)
- X ---------------------------------------------------------------------------*/
- X
- X if (zipinfo_mode) {
- X
- X#ifndef NO_ZIPINFO
- X
- X FPRINTF(usagefp, LoadFarString(ZipInfoUsageLine1),
- X LoadFarStringSmall(ZipinfoVersion),
- X LoadFarStringSmall2(ZipInfoExample), QUOTS,QUOTS);
- X FPRINTF(usagefp, LoadFarString(ZipInfoUsageLine2));
- X FPRINTF(usagefp, LoadFarString(ZipInfoUsageLine3), QUOT,QUOT);
- X#ifdef VMS
- X FPRINTF(usagefp, "\nRemember that non-lowercase filespecs must be\
- X quoted in VMS (e.g., \"Makefile\").\n");
- X#endif
- X
- X#endif /* !NO_ZIPINFO */
- X
- X } else { /* UnZip mode */
- X
- X FPRINTF(usagefp, LoadFarString(UnzipUsageLine1),
- X LoadFarStringSmall(UnzipVersion));
- X#ifdef BETA
- X FPRINTF(usagefp, LoadFarString(BetaVersion), "", "");
- X#endif
- X FPRINTF(usagefp, LoadFarString(UnzipUsageLine2), ZIPINFO_MODE_OPTION,
- X LoadFarStringSmall(ZipinfoMode));
- X
- X FPRINTF(usagefp, LoadFarString(UnzipUsageLine3));
- X
- X FPRINTF(usagefp, LoadFarString(UnzipUsageLine4), QUOT,QUOT, QUOT,QUOT,
- X LoadFarStringSmall(loc_str), QUOT,QUOT,
- X LoadFarStringSmall2(loc2str));
- X
- X /* This is extra work for SMALL_MEM, but it will work since
- X * LoadFarStringSmall2 uses the same buffer. Remember, this
- X * is a hack. */
- X FPRINTF(usagefp, LoadFarString(UnzipUsageLine5),
- X LoadFarStringSmall(Example1),
- X LoadFarStringSmall2(Example2),
- X LoadFarStringSmall2(Example2));
- X
- X }
- X
- X if (error)
- X return PK_PARAM;
- X else
- X return PK_COOL; /* just wanted usage screen: no error */
- X
- X} /* end function usage() */
- X
- X#endif /* !VMSCLI */
- X#endif /* ?SFX */
- X#endif /* ?MSWIN */
- X
- X
- X
- X
- X/*******************************/
- X/* Function process_zipfiles() */
- X/*******************************/
- X
- Xint process_zipfiles() /* return PK-type error code */
- X{
- X#ifndef SFX
- X char *lastzipfn = (char *)NULL;
- X int NumWinFiles, NumLoseFiles, NumWarnFiles;
- X int NumMissDirs, NumMissFiles;
- X#endif
- X int error=0, error_in_archive=0;
- X
- X
- X/*---------------------------------------------------------------------------
- X Start by constructing the various PK signature strings.
- X ---------------------------------------------------------------------------*/
- X
- X local_hdr_sig[0] /* = extd_local_sig[0] */ = '\120'; /* ASCII 'P', */
- X central_hdr_sig[0] = end_central_sig[0] = '\120'; /* not EBCDIC */
- X
- X strcpy(local_hdr_sig+1, LOCAL_HDR_SIG);
- X strcpy(central_hdr_sig+1, CENTRAL_HDR_SIG);
- X strcpy(end_central_sig+1, END_CENTRAL_SIG);
- X/* strcpy(extd_local_sig+1, EXTD_LOCAL_SIG); still to be used in multi? */
- X
- X/*---------------------------------------------------------------------------
- X Match (possible) wildcard zipfile specification with existing files and
- X attempt to process each. If no hits, try again after appending ".zip"
- X suffix. If still no luck, give up.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef SFX
- X if ((error = do_seekable(0)) == PK_NOZIP) {
- X#ifdef EXE_EXTENSION
- X int len=strlen(argv0);
- X
- X /* append .exe if appropriate; also .sfx? */
- X if ((zipfn = (char *)malloc(len+5)) != (char *)NULL) {
- X strcpy(zipfn, argv0);
- X strcpy(zipfn+len, EXE_EXTENSION);
- X error = do_seekable(0);
- X free(zipfn);
- X zipfn = argv0; /* for "can't find myself" message only */
- X }
- X#endif /* EXE_EXTENSION */
- X#ifdef NT
- X zipfn = argv0; /* for "can't find myself" message only */
- X#endif
- X }
- X if (error) {
- X if (error == IZ_DIR)
- X error_in_archive = PK_NOZIP;
- X else
- X error_in_archive = error;
- X if (error == PK_NOZIP)
- X FPRINTF(stderr, LoadFarString(CantFindMyself), zipfn);
- X }
- X
- X#else /* !SFX */
- X NumWinFiles = NumLoseFiles = NumWarnFiles = 0;
- X NumMissDirs = NumMissFiles = 0;
- X
- X while ((zipfn = do_wild(wildzipfn)) != (char *)NULL) {
- X Trace((stderr, "do_wild( %s ) returns %s\n", wildzipfn, zipfn));
- X
- X lastzipfn = zipfn;
- X
- X /* print a blank line between the output of different zipfiles */
- X if (!qflag && error != PK_NOZIP && error != IZ_DIR &&
- X (NumWinFiles+NumLoseFiles+NumWarnFiles+NumMissFiles) > 0)
- X PRINTF("\n");
- X FFLUSH(stdout);
- X
- X if ((error = do_seekable(0)) == PK_WARN)
- X ++NumWarnFiles;
- X else if (error == IZ_DIR)
- X ++NumMissDirs;
- X else if (error == PK_NOZIP)
- X ++NumMissFiles;
- X else if (error)
- X ++NumLoseFiles;
- X else
- X ++NumWinFiles;
- X
- X if (error != IZ_DIR && error > error_in_archive)
- X error_in_archive = error;
- X Trace((stderr, "do_seekable(0) returns %d\n", error));
- X
- X } /* end while-loop (wildcard zipfiles) */
- X
- X if ((NumWinFiles + NumWarnFiles + NumLoseFiles) == 0 &&
- X (NumMissDirs + NumMissFiles) == 1 && lastzipfn != (char *)NULL)
- X {
- X char *p = lastzipfn + strlen(lastzipfn);
- X
- X NumMissDirs = NumMissFiles = 0;
- X if (error_in_archive == PK_NOZIP)
- X error_in_archive = PK_COOL;
- X zipfn = lastzipfn;
- X strcpy(p, ".zip");
- X
- X#ifdef UNIX
- X if ((error = do_seekable(0)) == PK_NOZIP || error == IZ_DIR) {
- X if (error == IZ_DIR)
- X ++NumMissDirs;
- X strcpy(p, ".ZIP");
- X error = do_seekable(1);
- X }
- X#else
- X error = do_seekable(1);
- X#endif
- X if (error == PK_WARN)
- X ++NumWarnFiles;
- X else if (error == IZ_DIR)
- X ++NumMissDirs;
- X else if (error == PK_NOZIP)
- X /* if increment again => bug: "1 file had no zipfile directory." */
- X /* ++NumMissFiles */ ;
- X else if (error)
- X ++NumLoseFiles;
- X else
- X ++NumWinFiles;
- X
- X if (error > error_in_archive)
- X error_in_archive = error;
- X Trace((stderr, "do_seekable(1) returns %d\n", error));
- X }
- X#endif /* ?SFX */
- X
- X FFLUSH(stdout);
- X FFLUSH(stderr);
- X
- X/*---------------------------------------------------------------------------
- X Print summary of all zipfiles, assuming zipfile spec was a wildcard (no
- X need for a summary if just one zipfile).
- X ---------------------------------------------------------------------------*/
- X
- X#ifndef SFX
- X if (iswild(wildzipfn)) {
- X if (NumMissFiles + NumLoseFiles + NumWarnFiles > 0 || NumWinFiles != 1)
- X FPRINTF(stderr, "\n");
- X if ((NumWinFiles > 1) || (NumWinFiles == 1 &&
- X NumMissDirs + NumMissFiles + NumLoseFiles + NumWarnFiles > 0))
- X FPRINTF(stderr, LoadFarString(FilesProcessOK),
- X NumWinFiles, (NumWinFiles == 1)? " was" : "s were");
- X if (NumWarnFiles > 0)
- X FPRINTF(stderr, LoadFarString(ArchiveWarning),
- X NumWarnFiles, (NumWarnFiles == 1)? "" : "s");
- X if (NumLoseFiles > 0)
- X FPRINTF(stderr, LoadFarString(ArchiveFatalError),
- X NumLoseFiles, (NumLoseFiles == 1)? "" : "s");
- X if (NumMissFiles > 0)
- X FPRINTF(stderr, LoadFarString(FileHadNoZipfileDir),
- X NumMissFiles, (NumMissFiles == 1)? "" : "s");
- X if (NumMissDirs == 1)
- X FPRINTF(stderr, LoadFarString(ZipfileWasDir));
- X else if (NumMissDirs > 0)
- X FPRINTF(stderr, LoadFarString(ManyZipfilesWereDir), NumMissDirs);
- X if (NumWinFiles + NumLoseFiles + NumWarnFiles == 0)
- X FPRINTF(stderr, LoadFarString(NoZipfileFound));
- X }
- X#endif /* !SFX */
- X
- X /* free allocated memory */
- X inflate_free();
- X checkdir((char *)NULL, END);
- X#ifndef SMALL_MEM
- X if (outbuf2)
- X free(outbuf2); /* malloc'd ONLY if unshrink and -a */
- X#endif
- X free(outbuf);
- X free(inbuf);
- X
- X return error_in_archive;
- X
- X} /* end function process_zipfiles() */
- X
- X
- X
- X
- X
- X/**************************/
- X/* Function do_seekable() */
- X/**************************/
- X
- Xint do_seekable(lastchance) /* return PK-type error code */
- X int lastchance;
- X{
- X#ifndef SFX
- X static int no_ecrec = FALSE;
- X int maybe_exe=FALSE;
- X#endif
- X int error=0, error_in_archive;
- X
- X
- X/*---------------------------------------------------------------------------
- X Open the zipfile for reading in BINARY mode to prevent CR/LF translation,
- X which would corrupt the bit streams.
- X ---------------------------------------------------------------------------*/
- X
- X if (SSTAT(zipfn, &statbuf) || (error = S_ISDIR(statbuf.st_mode)) != 0) {
- X#ifndef SFX
- X if (lastchance)
- X if (no_ecrec)
- X FPRINTF(stderr, LoadFarString(CantFindZipfileDirMsg),
- X zipinfo_mode? "zipinfo" : "unzip",
- X wildzipfn, zipinfo_mode? " " : "",
- X#ifdef UNIX
- X wildzipfn,
- X#endif
- X zipfn);
- X else
- X FPRINTF(stderr,
- X LoadFarString(CantFindEitherZipfile),
- X zipinfo_mode? "zipinfo" : "unzip", wildzipfn,
- X#ifdef UNIX
- X wildzipfn,
- X#endif
- X zipfn);
- X#endif /* !SFX */
- X return error? IZ_DIR : PK_NOZIP;
- X }
- X ziplen = statbuf.st_size;
- X
- X#ifndef SFX
- X#if defined(UNIX) || defined(DOS_NT_OS2)
- X if (statbuf.st_mode & S_IEXEC) /* no extension on Unix exec's: might */
- X maybe_exe = TRUE; /* find unzip, not unzip.zip; etc. */
- X#endif
- X#endif /* !SFX */
- X
- X#ifdef VMS
- X if (check_format()) /* check for variable-length format */
- X return PK_ERR;
- X#endif
- X
- X if (open_input_file()) /* this should never happen, given */
- X return PK_NOZIP; /* the stat() test above, but... */
- X
- X/*---------------------------------------------------------------------------
- X Find and process the end-of-central-directory header. UnZip need only
- X check last 65557 bytes of zipfile: comment may be up to 65535, end-of-
- X central-directory record is 18 bytes, and signature itself is 4 bytes;
- X add some to allow for appended garbage. Since ZipInfo is often used as
- X a debugging tool, search the whole zipfile if zipinfo_mode is true.
- X ---------------------------------------------------------------------------*/
- X
- X cur_zipfile_bufstart = 0;
- X inptr = inbuf;
- X
- X if (!qflag && !zipinfo_mode)
- X PRINTF("Archive: %s\n", zipfn);
- X
- X if ((
- X#ifndef NO_ZIPINFO
- X zipinfo_mode &&
- X ((error_in_archive = find_ecrec(ziplen)) != 0 ||
- X (error_in_archive = zi_end_central()) > PK_WARN))
- X || (!zipinfo_mode &&
- X#endif
- X ((error_in_archive = find_ecrec(MIN(ziplen,66000L))) != 0 ||
- X (error_in_archive = uz_end_central()) > PK_WARN)))
- X {
- X close(zipfd);
- X#ifdef SFX
- X ++lastchance; /* avoid picky compiler warnings */
- X return error_in_archive;
- X#else
- X if (maybe_exe)
- X FPRINTF(stderr, LoadFarString(MaybeExe), zipfn);
- X if (lastchance)
- X return error_in_archive;
- X else {
- X no_ecrec = TRUE; /* assume we found wrong file: e.g., */
- X return PK_NOZIP; /* unzip instead of unzip.zip */
- X }
- X#endif /* ?SFX */
- X }
- X
- X if ((zflag > 0) && !zipinfo_mode) { /* in unzip, zflag = comment ONLY */
- X close(zipfd);
- X return error_in_archive;
- X }
- X
- X/*---------------------------------------------------------------------------
- X Test the end-of-central-directory info for incompatibilities (multi-disk
- X archives) or inconsistencies (missing or extra bytes in zipfile).
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef NO_MULTIPART
- X error = !zipinfo_mode && (ecrec.number_this_disk == 1) &&
- X (ecrec.num_disk_with_start_central_dir == 1);
- X#else
- X error = !zipinfo_mode && (ecrec.number_this_disk != 0);
- X#endif
- X
- X#ifndef SFX
- X if (zipinfo_mode &&
- X ecrec.number_this_disk != ecrec.num_disk_with_start_central_dir)
- X {
- X FPRINTF(stderr, LoadFarString(CentDirNotInZipMsg));
- X error_in_archive = PK_FIND;
- X#ifdef NO_MULTIPART /* concatenation of multiple parts works in some cases */
- X } else if (!zipinfo_mode && !error && ecrec.number_this_disk != 0) {
- X FPRINTF(stderr, LoadFarString(NoMultiDiskArcSupport), zipfn);
- X error_in_archive = PK_FIND;
- X#endif
- X } else { /* this is a (relatively) normal zipfile: process normally */
- X if (error) {
- X FPRINTF(stderr, LoadFarString(MaybePakBug), zipfn);
- X error_in_archive = PK_WARN;
- X }
- X#endif
- X if ((extra_bytes = real_ecrec_offset-expect_ecrec_offset) < (LONGINT)0)
- X {
- X FPRINTF(stderr, LoadFarString(MissingBytes), zipfn,
- X (long)(-extra_bytes));
- X error_in_archive = PK_ERR;
- X } else if (extra_bytes > 0) {
- X if ((ecrec.offset_start_central_directory == 0) &&
- X (ecrec.size_central_directory != 0)) /* zip 1.5 -go bug */
- X {
- X FPRINTF(stderr, LoadFarString(NullCentDirOffset), zipfn);
- X ecrec.offset_start_central_directory = extra_bytes;
- X extra_bytes = 0;
- X error_in_archive = PK_ERR;
- X }
- X#ifndef SFX
- X else {
- X FPRINTF(stderr, LoadFarString(ExtraBytesAtStart), zipfn,
- X (long)extra_bytes);
- X error_in_archive = PK_WARN;
- X }
- X#endif
- X }
- X
- X /*-----------------------------------------------------------------------
- X Check for empty zipfile and exit now if so.
- X -----------------------------------------------------------------------*/
- X
- X if (expect_ecrec_offset == 0L && ecrec.size_central_directory == 0) {
- X if (zipinfo_mode)
- X PRINTF("%sEmpty zipfile.\n", lflag>9 ? "\n " : "");
- X else
- X FPRINTF(stderr, LoadFarString(ZipfileEmpty), zipfn);
- X close(zipfd);
- X return (error_in_archive > PK_WARN)? error_in_archive : PK_WARN;
- X }
- X
- X /*-----------------------------------------------------------------------
- X Compensate for missing or extra bytes, and seek to where the start
- X of central directory should be. If header not found, uncompensate
- X and try again (necessary for at least some Atari archives created
- X with STZip, as well as archives created by J.H. Holm's ZIPSPLIT 1.1).
- X -----------------------------------------------------------------------*/
- X
- X LSEEK( ecrec.offset_start_central_directory )
- X#ifdef OLD_SEEK_TEST
- X if (readbuf(sig, 4) == 0) {
- X close(zipfd);
- X return PK_ERR; /* file may be locked, or possibly disk error(?) */
- X }
- X if (strncmp(sig, central_hdr_sig, 4))
- X#else
- X if ((readbuf(sig, 4) == 0) || strncmp(sig, central_hdr_sig, 4))
- X#endif
- X {
- X long tmp = extra_bytes;
- X
- X extra_bytes = 0;
- X LSEEK( ecrec.offset_start_central_directory )
- X if ((readbuf(sig, 4) == 0) || strncmp(sig, central_hdr_sig, 4)) {
- X FPRINTF(stderr, LoadFarString(CentDirStartNotFound), zipfn,
- X LoadFarStringSmall(ReportMsg));
- X close(zipfd);
- X return PK_BADERR;
- X }
- X FPRINTF(stderr, LoadFarString(CentDirTooLong), zipfn, -tmp);
- X error_in_archive = PK_ERR;
- X }
- X
- X /*-----------------------------------------------------------------------
- X Seek to the start of the central directory one last time, since we
- X have just read the first entry's signature bytes; then list, extract
- X or test member files as instructed, and close the zipfile.
- X -----------------------------------------------------------------------*/
- X
- X Trace((stderr, "about to extract/list files (error = %d)\n",
- X error_in_archive));
- X
- X LSEEK( ecrec.offset_start_central_directory )
- X
- X#ifndef NO_ZIPINFO
- X if (zipinfo_mode) {
- X error = zipinfo(); /* ZIPINFO 'EM */
- X if (lflag > 9)
- X PRINTF("\n");
- X } else
- X#endif
- X#ifndef SFX
- X if (vflag && !tflag && !cflag)
- X error = list_files(); /* LIST 'EM */
- X else
- X#endif
- X error = extract_or_test_files(); /* EXTRACT OR TEST 'EM */
- X
- X Trace((stderr, "done with extract/list files (error = %d)\n", error));
- X
- X if (error > error_in_archive) /* don't overwrite stronger error */
- X error_in_archive = error; /* with (for example) a warning */
- X#ifndef SFX
- X }
- X#endif
- X
- X close(zipfd);
- X return error_in_archive;
- X
- X} /* end function do_seekable() */
- X
- X
- X
- X
- X
- X/*****************************/
- X/* Function uz_end_central() */
- X/*****************************/
- X
- Xint uz_end_central() /* return PK-type error code */
- X{
- X int error = PK_COOL;
- X
- X
- X/*---------------------------------------------------------------------------
- X Get the zipfile comment (up to 64KB long), if any, and print it out.
- X Then position the file pointer to the beginning of the central directory
- X and fill buffer.
- X ---------------------------------------------------------------------------*/
- X
- X#ifdef MSWIN
- X cchComment = ecrec.zipfile_comment_length; /* save for comment button */
- X if (ecrec.zipfile_comment_length && (zflag > 0))
- X#else
- X if (ecrec.zipfile_comment_length && (zflag > 0 || (zflag == 0 && !qflag)))
- X#endif
- X {
- X#if 0
- X#ifndef MSWIN
- X if (zflag == 0) (add "&& single_zipfile" perhaps; unnecessary with
- X PRINTF("[%s] comment:\n", zipfn); multiple zipfiles: "Archive:...")
- X#endif /* !MSWIN */
- X#endif /* 0 */
- X if (do_string(ecrec.zipfile_comment_length,DISPLAY)) {
- X FPRINTF(stderr, LoadFarString(ZipfileCommTrunc1));
- X error = PK_WARN;
- X }
- X }
- X return error;
- X
- X} /* end function uz_end_central() */
- X
- X
- X
- X
- X
- X/************************************/
- X/* Function process_cdir_file_hdr() */
- X/************************************/
- X
- Xint process_cdir_file_hdr() /* return PK-type error code */
- X{
- X int error;
- X
- X
- X/*---------------------------------------------------------------------------
- X Get central directory info, save host and method numbers, and set flag
- X for lowercase conversion of filename, depending on the OS from which the
- X file is coming.
- X ---------------------------------------------------------------------------*/
- X
- X if ((error = get_cdir_ent()) != 0)
- X return error;
- X
- X pInfo->hostnum = MIN(crec.version_made_by[1], NUM_HOSTS);
- X/* extnum = MIN(crec.version_needed_to_extract[1], NUM_HOSTS); */
- X
- X pInfo->lcflag = 0;
- X if (L_flag) /* user specified case-conversion */
- X switch (pInfo->hostnum) {
- X case FS_FAT_: /* PKZIP and zip -k store in uppercase */
- X case ATARI_: /* MS-DOS filesystem */
- X case CPM_: /* like MS-DOS, right? */
- X case VM_CMS_: /* all caps? */
- X case TOPS20_:
- X case VMS_: /* our Zip uses lowercase, but ASi's doesn't */
- X /* case Z_SYSTEM_: ? */
- X /* case QDOS_: ? */
- X pInfo->lcflag = 1; /* convert filename to lowercase */
- X break;
- X
- X default: /* AMIGA_, FS_HPFS_, FS_NTFS_, MAC_, UNIX_, */
- X break; /* (Z_SYSTEM_): no conversion */
- X }
- X
- X /* do Amigas (AMIGA_) also have volume labels? */
- X if (IS_VOLID(crec.external_file_attributes) &&
- X (pInfo->hostnum == FS_FAT_ || pInfo->hostnum == FS_HPFS_ ||
- X pInfo->hostnum == FS_NTFS_ || pInfo->hostnum == ATARI_))
- X {
- X pInfo->vollabel = TRUE;
- X pInfo->lcflag = 0; /* preserve case of volume labels */
- X } else
- X pInfo->vollabel = FALSE;
- X
- X return PK_COOL;
- X
- X} /* end function process_cdir_file_hdr() */
- X
- X
- X
- X
- X
- X/*************************************/
- X/* Function process_local_file_hdr() */
- X/*************************************/
- X
- Xint process_local_file_hdr() /* return PK-type error code */
- X{
- X local_byte_hdr byterec;
- X
- X
- X/*---------------------------------------------------------------------------
- X Read the next local file header and do any necessary machine-type con-
- X versions (byte ordering, structure padding compensation--do so by copy-
- X ing the data from the array into which it was read (byterec) to the
- X usable struct (lrec)).
- X ---------------------------------------------------------------------------*/
- X
- X if (readbuf((char *)byterec, LREC_SIZE) == 0)
- X return PK_EOF;
- X
- X lrec.version_needed_to_extract[0] = byterec[L_VERSION_NEEDED_TO_EXTRACT_0];
- X lrec.version_needed_to_extract[1] = byterec[L_VERSION_NEEDED_TO_EXTRACT_1];
- X
- X lrec.general_purpose_bit_flag = makeword(&byterec[L_GENERAL_PURPOSE_BIT_FLAG]);
- X lrec.compression_method = makeword(&byterec[L_COMPRESSION_METHOD]);
- X lrec.last_mod_file_time = makeword(&byterec[L_LAST_MOD_FILE_TIME]);
- X lrec.last_mod_file_date = makeword(&byterec[L_LAST_MOD_FILE_DATE]);
- X lrec.crc32 = makelong(&byterec[L_CRC32]);
- X lrec.csize = makelong(&byterec[L_COMPRESSED_SIZE]);
- X lrec.ucsize = makelong(&byterec[L_UNCOMPRESSED_SIZE]);
- X lrec.filename_length = makeword(&byterec[L_FILENAME_LENGTH]);
- X lrec.extra_field_length = makeword(&byterec[L_EXTRA_FIELD_LENGTH]);
- X
- X csize = (long) lrec.csize;
- X ucsize = (long) lrec.ucsize;
- X
- X if ((lrec.general_purpose_bit_flag & 8) != 0) {
- X /* can't trust local header, use central directory: */
- X lrec.crc32 = pInfo->crc;
- X csize = (long)(lrec.csize = pInfo->compr_size);
- X }
- X
- X return PK_COOL;
- X
- X} /* end function process_local_file_hdr() */
- END_OF_FILE
- if test 66790 -ne `wc -c <'unzip-5.12/unzip.c'`; then
- echo shar: \"'unzip-5.12/unzip.c'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/unzip.c'
- fi
- echo shar: End of archive 2 \(of 20\).
- cp /dev/null ark2isdone
- 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...
-