home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume44
/
unzip
/
part11
< prev
next >
Wrap
Internet Message Format
|
1994-09-19
|
72KB
From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
Newsgroups: comp.sources.misc
Subject: v44i076: unzip - Info-ZIP portable UnZip, version 5.12, Part11/20
Date: 18 Sep 1994 23:15:55 -0500
Organization: Sterling Software
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-ID: <35j39r$qp4@sparky.sterling.com>
X-Md4-Signature: 4920733f0064af3e6e74920667821d9b
Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
Posting-number: Volume 44, Issue 76
Archive-name: unzip/part11
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/atari/README unzip-5.12/mac/mac.c
# unzip-5.12/unzip.doc
# Wrapped by kent@sparky on Sat Sep 17 23:33:42 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 11 (of 20)."'
if test -f 'unzip-5.12/atari/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unzip-5.12/atari/README'\"
else
echo shar: Extracting \"'unzip-5.12/atari/README'\" \(2181 characters\)
sed "s/^X//" >'unzip-5.12/atari/README' <<'END_OF_FILE'
XHere it is... the UnZip 5.1 port for the Atari ST/TT/Falcon!
X
XThis took me longer than I expected thanks to a difference between the
XMiNT library and most UNIX libraries... symlinks are 0x16000
Xinstead of 0xa000... I'm told this isn't even defined in POSIX, so I
Xcan't really complain. At least we've got a filesystem that can use
Xsymlinks!
X
XThis port requires GNU C and allows you to build an unzip/zipinfo/funzip
Xthat supports long filenames (on appropriate filesystems, thanks to the
XMiNT library), as well as symlinks. It also does "proper" (ie, DOS-style)
Xtranslation of text-file end-of-line characters. The programs also build
Xas shared-text binaries, so you can start unzipping several files at once
Xin the background and only a small part of unzip will be duplicated in
Xmemory.
X
XI build unzip with the MiNT library, GNU C 2.5.8 (2.5.7 and lower have a
Xrather sever problem in the optimiser that affects 68000 code only; it
Xadds 68020-only instructions to the 68000 code). Oh, and I tested it
Xextensively under MiNT's minix filesystem as well as the bogus DOS
Xfilesystem that "normal" Atari partitions have.
X
XThe Makefile won't need any editing if you want to built unzip et al. on
Xa minix filesystem; if you want to install it on a DOS filesystem, use
X"cp" instead of "ln" for zipinfo. [Or, to save disk space, make a script/
Xcommand-file which invokes "unzip -Z ...". --CN] This is such a good
Xidea that I'm annoyed that Greg thought of it and I didn't... ;-) If
Xyou're using a shell worth your while, you can alias zipinfo to
X'unzip -Z' and then forget all about this paragraph.
X
XIf you want to compile this using Turbo C (aka Pure C in North America)
Xyou're on your own... That's ok, I'll make a nice binary version of
Xunzip available as soon as the official 5.1 version is released (give or
Xtake a few days).
X
XEnjoy! Cave Newt should be given kudos for keeping this monster easy to
Xport... ;-) [Hah! But thanks anyway. :-) --CN]
X
XPLEASE email me to tell me if you've uploaded the source or binary
Xversions of Unzip 5.x to any BBS systems or commercial online systems so
Xwe can update the Where file!
X
X-Chris-
Xcherborth@semprini.waterloo-rdp.on.ca
END_OF_FILE
if test 2181 -ne `wc -c <'unzip-5.12/atari/README'`; then
echo shar: \"'unzip-5.12/atari/README'\" unpacked with wrong size!
fi
# end of 'unzip-5.12/atari/README'
fi
if test -f 'unzip-5.12/mac/mac.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unzip-5.12/mac/mac.c'\"
else
echo shar: Extracting \"'unzip-5.12/mac/mac.c'\" \(31814 characters\)
sed "s/^X//" >'unzip-5.12/mac/mac.c' <<'END_OF_FILE'
X/*---------------------------------------------------------------------------
X
X mac.c
X
X Macintosh-specific routines for use with Info-ZIP's UnZip 5.1 and later.
X
X This source file incorporates the contents of what was formerly macfile.c,
X which supported commands (such as mkdir()) not available directly on the
X Mac, and which also determined whether HFS (Hierarchical File System) or
X MFS (Macintosh File System) was in use.
X
X Contains: do_wild()
X mapattr()
X mapname()
X checkdir()
X close_outfile()
X version()
X IsHFSDisk()
X MacFSTest()
X macmkdir()
X ResolveMacVol()
X macopen()
X macfopen()
X maccreat()
X macread()
X macwrite()
X macclose()
X maclseek()
X
X ---------------------------------------------------------------------------*/
X
X
X
X#include "unzip.h"
X
X#ifdef MACOS
X#ifndef FSFCBLen
X# define FSFCBLen (*(short *)0x3F6)
X#endif
X
X#define read_only file_attr /* for readability only */
X
Xstatic short wAppVRefNum;
Xstatic long lAppDirID;
Xint HFSFlag; /* set if disk has hierarchical file system */
X
Xstatic int created_dir; /* used in mapname(), checkdir() */
Xstatic int renamed_fullpath; /* ditto */
X
X#define MKDIR(path) macmkdir(path, gnVRefNum, glDirID)
X
X
X
X
X
X/**********************/
X/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
X/**********************/
X
Xchar *do_wild(wildspec)
X char *wildspec; /* only used first time on a given dir */
X{
X static DIR *dir = NULL;
X static char *dirname, *wildname, matchname[FILNAMSIZ];
X static int firstcall=TRUE, have_dirname, dirnamelen;
X struct direct *file;
X
X
X /* Even when we're just returning wildspec, we *always* do so in
X * matchname[]--calling routine is allowed to append four characters
X * to the returned string, and wildspec may be a pointer to argv[].
X */
X if (firstcall) { /* first call: must initialize everything */
X firstcall = FALSE;
X
X /* break the wildspec into a directory part and a wildcard filename */
X if ((wildname = strrchr(wildspec, ':')) == NULL) {
X dirname = ":";
X dirnamelen = 1;
X have_dirname = FALSE;
X wildname = wildspec;
X } else {
X ++wildname; /* point at character after ':' */
X dirnamelen = wildname - wildspec;
X if ((dirname = (char *)malloc(dirnamelen+1)) == NULL) {
X fprintf(stderr, "warning: can't allocate wildcard buffers\n");
X strcpy(matchname, wildspec);
X return matchname; /* but maybe filespec was not a wildcard */
X }
X strncpy(dirname, wildspec, dirnamelen);
X dirname[dirnamelen] = '\0';
X have_dirname = TRUE;
X }
X
X if ((dir = opendir(dirname)) != NULL) {
X while ((file = readdir(dir)) != NULL) {
X if (match(file->d_name, wildname, 0)) { /* 0 == case sens. */
X if (have_dirname) {
X strcpy(matchname, dirname);
X strcpy(matchname+dirnamelen, file->d_name);
X } else
X strcpy(matchname, file->d_name);
X return matchname;
X }
X }
X /* if we get to here directory is exhausted, so close it */
X closedir(dir);
X dir = NULL;
X }
X
X /* return the raw wildspec in case that works (e.g., directory not
X * searchable, but filespec was not wild and file is readable) */
X strcpy(matchname, wildspec);
X return matchname;
X }
X
X /* last time through, might have failed opendir but returned raw wildspec */
X if (dir == NULL) {
X firstcall = TRUE; /* nothing left to try--reset for new wildspec */
X if (have_dirname)
X free(dirname);
X return (char *)NULL;
X }
X
X#ifndef THINK_C /* Think C only matches one at most (for now) */
X /* If we've gotten this far, we've read and matched at least one entry
X * successfully (in a previous call), so dirname has been copied into
X * matchname already.
X */
X while ((file = readdir(dir)) != NULL)
X if (match(file->d_name, wildname, 0)) { /* 0 == don't ignore case */
X if (have_dirname) {
X /* strcpy(matchname, dirname); */
X strcpy(matchname+dirnamelen, file->d_name);
X } else
X strcpy(matchname, file->d_name);
X return matchname;
X }
X#endif
X
X closedir(dir); /* have read at least one dir entry; nothing left */
X dir = NULL;
X firstcall = TRUE; /* reset for new wildspec */
X if (have_dirname)
X free(dirname);
X return (char *)NULL;
X
X} /* end function do_wild() */
X
X
X
X
X
X/**********************/
X/* Function mapattr() */
X/**********************/
X
Xint mapattr()
X{
X /* only care about read-only bit, so just look at MS-DOS side of attrs */
X pInfo->read_only = (unsigned)(crec.external_file_attributes & 1);
X return 0;
X
X} /* end function mapattr() */
X
X
X
X
X
X/************************/
X/* Function mapname() */
X/************************/
X
Xint mapname(renamed) /* return 0 if no error, 1 if caution (filename trunc), */
X int renamed; /* 2 if warning (skip file because dir doesn't exist), */
X{ /* 3 if error (skip file), 10 if no memory (skip file) */
X char pathcomp[FILNAMSIZ]; /* path-component buffer */
X char *pp, *cp=NULL; /* character pointers */
X char *lastsemi = NULL; /* pointer to last semi-colon in pathcomp */
X int quote = FALSE; /* flags */
X int error = 0;
X register unsigned workch; /* hold the character being tested */
X
X
X/*---------------------------------------------------------------------------
X Initialize various pointers and counters and stuff.
X ---------------------------------------------------------------------------*/
X
X /* can create path as long as not just freshening, or if user told us */
X create_dirs = (!fflag || renamed);
X
X created_dir = FALSE; /* not yet */
X
X /* user gave full pathname: don't prepend rootpath */
X renamed_fullpath = (renamed && (*filename == '/'));
X
X if (checkdir((char *)NULL, INIT) == 10)
X return 10; /* initialize path buffer, unless no memory */
X
X pp = pathcomp; /* point to translation buffer */
X if (!(renamed_fullpath || jflag))
X *pp++ = ':';
X *pp = '\0';
X
X if (jflag) /* junking directories */
X cp = (char *)strrchr(filename, '/');
X if (cp == NULL) /* no '/' or not junking dirs */
X cp = filename; /* point to internal zipfile-member pathname */
X else
X ++cp; /* point to start of last component of path */
X
X/*---------------------------------------------------------------------------
X Begin main loop through characters in filename.
X ---------------------------------------------------------------------------*/
X
X while ((workch = (uch)*cp++) != 0) {
X
X if (quote) { /* if character quoted, */
X *pp++ = (char)workch; /* include it literally */
X quote = FALSE;
X } else
X switch (workch) {
X case '/': /* can assume -j flag not given */
X *pp = '\0';
X if ((error = checkdir(pathcomp, APPEND_DIR)) > 1)
X return error;
X pp = pathcomp; /* reset conversion buffer for next piece */
X lastsemi = NULL; /* leave directory semi-colons alone */
X break;
X
X case ';': /* VMS version (or DEC-20 attrib?) */
X lastsemi = pp; /* keep for now; remove VMS ";##" */
X *pp++ = (char)workch; /* later, if requested */
X break;
X
X case '\026': /* control-V quote for special chars */
X quote = TRUE; /* set flag for next character */
X break;
X
X default:
X /* allow European characters in filenames: */
X if (isprint(workch) || (128 <= workch && workch <= 254))
X *pp++ = (char)workch;
X } /* end switch */
X
X } /* end while loop */
X
X *pp = '\0'; /* done with pathcomp: terminate it */
X
X /* if not saving them, remove with VMS version numbers (appended ";###") */
X if (!V_flag && lastsemi) {
X pp = lastsemi + 1;
X while (isdigit((uch)(*pp)))
X ++pp;
X if (*pp == '\0') /* only digits between ';' and end: nuke */
X *lastsemi = '\0';
X }
X
X/*---------------------------------------------------------------------------
X Report if directory was created (and no file to create: filename ended
X in '/'), check name to be sure it exists, and combine path and name be-
X fore exiting.
X ---------------------------------------------------------------------------*/
X
X if (filename[strlen(filename) - 1] == '/') {
X checkdir(filename, GETPATH);
X if (created_dir && QCOND2) {
X fprintf(stdout, " creating: %s\n", filename);
X return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
X }
X return 2; /* dir existed already; don't look for data to extract */
X }
X
X if (*pathcomp == '\0') {
X fprintf(stderr, "mapname: conversion of %s failed\n", filename);
X return 3;
X }
X
X checkdir(pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
X checkdir(filename, GETPATH);
X
X return error;
X
X} /* end function mapname() */
X
X
X
X
X
X/***********************/
X/* Function checkdir() */
X/***********************/
X
Xint checkdir(pathcomp, flag)
X char *pathcomp;
X int flag;
X/*
X * returns: 1 - (on APPEND_NAME) truncated filename
X * 2 - path doesn't exist, not allowed to create
X * 3 - path doesn't exist, tried to create and failed; or
X * path exists and is not a directory, but is supposed to be
X * 4 - path is too long
X * 10 - can't allocate memory for filename buffers
X */
X{
X static int rootlen = 0; /* length of rootpath */
X static char *rootpath; /* user's "extract-to" directory */
X static char *buildpath; /* full path (so far) to extracted file */
X static char *end; /* pointer to end of buildpath ('\0') */
X
X# define FN_MASK 7
X# define FUNCTION (flag & FN_MASK)
X
X
X
X/*---------------------------------------------------------------------------
X APPEND_DIR: append the path component to the path being built and check
X for its existence. If doesn't exist and we are creating directories, do
X so for this one; else signal success or error as appropriate.
X ---------------------------------------------------------------------------*/
X
X if (FUNCTION == APPEND_DIR) {
X int too_long = FALSE;
X#ifdef SHORT_NAMES
X char *old_end = end;
X#endif
X
X Trace((stderr, "appending dir segment [%s]\n", pathcomp));
X while ((*end = *pathcomp++) != '\0')
X ++end;
X#ifdef SHORT_NAMES /* path components restricted to 14 chars, typically */
X if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
X *(end = old_end + FILENAME_MAX) = '\0';
X#endif
X
X /* GRR: could do better check, see if overrunning buffer as we go:
X * check end-buildpath after each append, set warning variable if
X * within 20 of FILNAMSIZ; then if var set, do careful check when
X * appending. Clear variable when begin new path. */
X
X if ((end-buildpath) > FILNAMSIZ-3) /* need ':', one-char name, '\0' */
X too_long = TRUE; /* check if extracting directory? */
X if (stat(buildpath, &statbuf)) { /* path doesn't exist */
X if (!create_dirs) { /* told not to create (freshening) */
X free(buildpath);
X return 2; /* path doesn't exist: nothing to do */
X }
X if (too_long) {
X fprintf(stderr, "checkdir error: path too long: %s\n",
X buildpath);
X fflush(stderr);
X free(buildpath);
X return 4; /* no room for filenames: fatal */
X }
X if (MKDIR(buildpath) == -1) { /* create the directory */
X fprintf(stderr, "checkdir error: can't create %s\n\
X unable to process %s.\n", buildpath, filename);
X fflush(stderr);
X free(buildpath);
X return 3; /* path didn't exist, tried to create, failed */
X }
X created_dir = TRUE;
X } else if (!S_ISDIR(statbuf.st_mode)) {
X fprintf(stderr, "checkdir error: %s exists but is not directory\n\
X unable to process %s.\n", buildpath, filename);
X fflush(stderr);
X free(buildpath);
X return 3; /* path existed but wasn't dir */
X }
X if (too_long) {
X fprintf(stderr, "checkdir error: path too long: %s\n", buildpath);
X fflush(stderr);
X free(buildpath);
X return 4; /* no room for filenames: fatal */
X }
X *end++ = ':';
X *end = '\0';
X Trace((stderr, "buildpath now = [%s]\n", buildpath));
X return 0;
X
X } /* end if (FUNCTION == APPEND_DIR) */
X
X/*---------------------------------------------------------------------------
X GETPATH: copy full path to the string pointed at by pathcomp, and free
X buildpath.
X ---------------------------------------------------------------------------*/
X
X if (FUNCTION == GETPATH) {
X strcpy(pathcomp, buildpath);
X Trace((stderr, "getting and freeing path [%s]\n", pathcomp));
X free(buildpath);
X buildpath = end = NULL;
X return 0;
X }
X
X/*---------------------------------------------------------------------------
X APPEND_NAME: assume the path component is the filename; append it and
X return without checking for existence.
X ---------------------------------------------------------------------------*/
X
X if (FUNCTION == APPEND_NAME) {
X#ifdef SHORT_NAMES
X char *old_end = end;
X#endif
X
X Trace((stderr, "appending filename [%s]\n", pathcomp));
X while ((*end = *pathcomp++) != '\0') {
X ++end;
X#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */
X if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
X *(end = old_end + FILENAME_MAX) = '\0';
X#endif
X if ((end-buildpath) >= FILNAMSIZ) {
X *--end = '\0';
X fprintf(stderr, "checkdir warning: path too long; truncating\n\
Xcheckdir warning: path too long; truncating\n\
X %s\n -> %s\n", filename, buildpath);
X fflush(stderr);
X return 1; /* filename truncated */
X }
X }
X Trace((stderr, "buildpath now = [%s]\n", buildpath));
X return 0; /* could check for existence here, prompt for new name... */
X }
X
X/*---------------------------------------------------------------------------
X INIT: allocate and initialize buffer space for the file currently being
X extracted. If file was renamed with an absolute path, don't prepend the
X extract-to path.
X ---------------------------------------------------------------------------*/
X
X if (FUNCTION == INIT) {
X Trace((stderr, "initializing buildpath to "));
X if ((buildpath = (char *)malloc(strlen(filename)+rootlen+2)) == NULL)
X return 10;
X if ((rootlen > 0) && !renamed_fullpath) {
X strcpy(buildpath, rootpath);
X end = buildpath + rootlen;
X } else {
X *buildpath = '\0';
X end = buildpath;
X }
X Trace((stderr, "[%s]\n", buildpath));
X return 0;
X }
X
X/*---------------------------------------------------------------------------
X ROOT: if appropriate, store the path in rootpath and create it if neces-
X sary; else assume it's a zipfile member and return. This path segment
X gets used in extracting all members from every zipfile specified on the
X command line.
X ---------------------------------------------------------------------------*/
X
X#if (!defined(SFX) || defined(SFX_EXDIR))
X if (FUNCTION == ROOT) {
X Trace((stderr, "initializing root path to [%s]\n", pathcomp));
X if (pathcomp == NULL) {
X rootlen = 0;
X return 0;
X }
X if ((rootlen = strlen(pathcomp)) > 0) {
X int had_trailing_pathsep=FALSE;
X
X if (pathcomp[rootlen-1] == ':') {
X pathcomp[--rootlen] = '\0';
X had_trailing_pathsep = TRUE;
X }
X if (rootlen > 0 && (stat(pathcomp, &statbuf) ||
X !S_ISDIR(statbuf.st_mode))) /* path does not exist */
X {
X if (!create_dirs /* || iswild(pathcomp) */
X#ifdef OLD_EXDIR
X || !had_trailing_pathsep
X#endif
X ) {
X rootlen = 0;
X return 2; /* treat as stored file */
X }
X /* create the directory (could add loop here to scan pathcomp
X * and create more than one level, but why really necessary?) */
X if (MKDIR(pathcomp) == -1) {
X fprintf(stderr,
X "checkdir: can't create extraction directory: %s\n",
X pathcomp);
X fflush(stderr);
X rootlen = 0; /* path didn't exist, tried to create, and */
X return 3; /* failed: file exists, or 2+ levels required */
X }
X }
X if ((rootpath = (char *)malloc(rootlen+2)) == NULL) {
X rootlen = 0;
X return 10;
X }
X strcpy(rootpath, pathcomp);
X rootpath[rootlen++] = ':';
X rootpath[rootlen] = '\0';
X }
X Trace((stderr, "rootpath now = [%s]\n", rootpath));
X return 0;
X }
X#endif /* !SFX || SFX_EXDIR */
X
X/*---------------------------------------------------------------------------
X END: free rootpath, immediately prior to program exit.
X ---------------------------------------------------------------------------*/
X
X if (FUNCTION == END) {
X Trace((stderr, "freeing rootpath\n"));
X if (rootlen > 0)
X free(rootpath);
X return 0;
X }
X
X return 99; /* should never reach */
X
X} /* end function checkdir() */
X
X
X
X
X
X/****************************/
X/* Function close_outfile() */
X/****************************/
X
Xvoid close_outfile()
X{
X long m_time;
X DateTimeRec dtr;
X ParamBlockRec pbr;
X HParamBlockRec hpbr;
X OSErr err;
X
X
X if (fileno(outfile) == 1) /* don't attempt to close or set time on stdout */
X return;
X
X fclose(outfile);
X
X /*
X * Macintosh bases all file modification times on the number of seconds
X * elapsed since Jan 1, 1904, 00:00:00. Therefore, to maintain
X * compatibility with MS-DOS archives, which date from Jan 1, 1980,
X * with NO relation to GMT, the following conversions must be made:
X * the Year (yr) must be incremented by 1980;
X * and converted to seconds using the Mac routine Date2Secs(),
X * almost similar in complexity to the Unix version :-)
X * J. Lee
X */
X
X dtr.year = (((lrec.last_mod_file_date >> 9) & 0x7f) + 1980);
X dtr.month = ((lrec.last_mod_file_date >> 5) & 0x0f);
X dtr.day = (lrec.last_mod_file_date & 0x1f);
X
X dtr.hour = ((lrec.last_mod_file_time >> 11) & 0x1f);
X dtr.minute = ((lrec.last_mod_file_time >> 5) & 0x3f);
X dtr.second = ((lrec.last_mod_file_time & 0x1f) * 2);
X
X Date2Secs(&dtr, (unsigned long *)&m_time);
X c2pstr(filename);
X if (HFSFlag) {
X hpbr.fileParam.ioNamePtr = (StringPtr)filename;
X hpbr.fileParam.ioVRefNum = gnVRefNum;
X hpbr.fileParam.ioDirID = glDirID;
X hpbr.fileParam.ioFDirIndex = 0;
X err = PBHGetFInfo(&hpbr, 0L);
X hpbr.fileParam.ioFlMdDat = m_time;
X if ( !fMacZipped )
X hpbr.fileParam.ioFlCrDat = m_time;
X hpbr.fileParam.ioDirID = glDirID;
X if (err == noErr)
X err = PBHSetFInfo(&hpbr, 0L);
X if (err != noErr)
X printf("error: can't set the time for %s\n", filename);
X } else {
X pbr.fileParam.ioNamePtr = (StringPtr)filename;
X pbr.fileParam.ioVRefNum = pbr.fileParam.ioFVersNum =
X pbr.fileParam.ioFDirIndex = 0;
X err = PBGetFInfo(&pbr, 0L);
X pbr.fileParam.ioFlMdDat = pbr.fileParam.ioFlCrDat = m_time;
X if (err == noErr)
X err = PBSetFInfo(&pbr, 0L);
X if (err != noErr)
X printf("error: can't set the time for %s\n", filename);
X }
X
X /* set read-only perms if needed */
X if ((err == noErr) && pInfo->read_only) {
X if (HFSFlag) {
X hpbr.fileParam.ioNamePtr = (StringPtr)filename;
X hpbr.fileParam.ioVRefNum = gnVRefNum;
X hpbr.fileParam.ioDirID = glDirID;
X err = PBHSetFLock(&hpbr, 0);
X } else
X err = SetFLock((ConstStr255Param)filename, 0);
X }
X p2cstr(filename);
X
X} /* end function close_outfile() */
X
X
X
X
X
X#ifndef SFX
X
X/************************/
X/* Function version() */
X/************************/
X
Xvoid version()
X{
X extern char Far CompiledWith[];
X#if 0
X char buf[40];
X#endif
X
X printf(LoadFarString(CompiledWith),
X
X#ifdef __GNUC__
X "gcc ", __VERSION__,
X#else
X# if 0
X "cc ", (sprintf(buf, " version %d", _RELEASE), buf),
X# else
X# ifdef THINK_C
X "Think C", "",
X# else
X# ifdef MPW
X "MPW C", "",
X# else
X "unknown compiler", "",
X# endif
X# endif
X# endif
X#endif
X
X "MacOS",
X
X#if defined(foobar) || defined(FOOBAR)
X " (Foo BAR)", /* hardware or OS version */
X#else
X "",
X#endif /* Foo BAR */
X
X#ifdef __DATE__
X " on ", __DATE__
X#else
X "", ""
X#endif
X );
X
X} /* end function version() */
X
X#endif /* !SFX */
X
X
X
X
X
X/************************/
X/* Function IsHFSDisk() */
X/************************/
X
Xstatic int IsHFSDisk(short wRefNum)
X{
X /* get info about the specified volume */
X if (HFSFlag == true) {
X HParamBlockRec hpbr;
X Str255 temp;
X short wErr;
X
X hpbr.volumeParam.ioCompletion = 0;
X hpbr.volumeParam.ioNamePtr = temp;
X hpbr.volumeParam.ioVRefNum = wRefNum;
X hpbr.volumeParam.ioVolIndex = 0;
X wErr = PBHGetVInfo(&hpbr, 0);
X
X if (wErr == noErr && hpbr.volumeParam.ioVFSID == 0
X && hpbr.volumeParam.ioVSigWord == 0x4244) {
X return true;
X }
X }
X
X return false;
X} /* IsHFSDisk */
X
X
X
X
X
X/************************/
X/* Function MacFSTest() */
X/************************/
X
Xvoid MacFSTest(int vRefNum)
X{
X Str255 st;
X
X /* is this machine running HFS file system? */
X if (FSFCBLen <= 0) {
X HFSFlag = false;
X }
X else
X {
X HFSFlag = true;
X }
X
X /* get the file's volume reference number and directory ID */
X if (HFSFlag == true) {
X WDPBRec wdpb;
X OSErr err = noErr;
X
X if (vRefNum != 0) {
X wdpb.ioCompletion = false;
X wdpb.ioNamePtr = st;
X wdpb.ioWDIndex = 0;
X wdpb.ioVRefNum = vRefNum;
X err = PBHGetVol(&wdpb, false);
X
X if (err == noErr) {
X wAppVRefNum = wdpb.ioWDVRefNum;
X lAppDirID = wdpb.ioWDDirID;
X }
X }
X
X /* is the disk we're using formatted for HFS? */
X HFSFlag = IsHFSDisk(wAppVRefNum);
X }
X
X return;
X} /* mactest */
X
X
X
X
X
X/***********************/
X/* Function macmkdir() */
X/***********************/
X
Xint macmkdir(char *path, short nVRefNum, long lDirID)
X{
X OSErr err = -1;
X
X if (path != 0 && strlen(path)<256 && HFSFlag == true) {
X HParamBlockRec hpbr;
X Str255 st;
X
X c2pstr(path);
X if ((nVRefNum == 0) && (lDirID == 0))
X {
X hpbr.fileParam.ioNamePtr = st;
X hpbr.fileParam.ioCompletion = NULL;
X err = PBHGetVol((WDPBPtr)&hpbr, false);
X nVRefNum = hpbr.wdParam.ioWDVRefNum;
X lDirID = hpbr.wdParam.ioWDDirID;
X }
X else
X {
X err = noErr;
X }
X if (err == noErr) {
X hpbr.fileParam.ioCompletion = NULL;
X hpbr.fileParam.ioVRefNum = nVRefNum;
X hpbr.fileParam.ioDirID = lDirID;
X hpbr.fileParam.ioNamePtr = (StringPtr)path;
X err = PBDirCreate(&hpbr, false);
X }
X p2cstr(path);
X }
X
X return (int)err;
X} /* macmkdir */
X
X
X
X
X
X/****************************/
X/* Function ResolveMacVol() */
X/****************************/
X
Xvoid ResolveMacVol(short nVRefNum, short *pnVRefNum, long *plDirID, StringPtr pst)
X{
X if (HFSFlag)
X {
X WDPBRec wdpbr;
X Str255 st;
X OSErr err;
X
X wdpbr.ioCompletion = (ProcPtr)NULL;
X wdpbr.ioNamePtr = st;
X wdpbr.ioVRefNum = nVRefNum;
X wdpbr.ioWDIndex = 0;
X wdpbr.ioWDProcID = 0;
X wdpbr.ioWDVRefNum = 0;
X err = PBGetWDInfo( &wdpbr, false );
X if ( err == noErr )
X {
X if (pnVRefNum)
X *pnVRefNum = wdpbr.ioWDVRefNum;
X if (plDirID)
X *plDirID = wdpbr.ioWDDirID;
X if (pst)
X BlockMove( st, pst, st[0]+1 );
X }
X }
X else
X {
X if (pnVRefNum)
X *pnVRefNum = nVRefNum;
X if (plDirID)
X *plDirID = 0;
X if (pst)
X *pst = 0;
X }
X}
X
X
X
X
X
X/**********************/
X/* Function macopen() */
X/**********************/
X
Xshort macopen(char *sz, short nFlags, short nVRefNum, long lDirID)
X{
X OSErr err;
X Str255 st;
X char chPerms = (!nFlags) ? fsRdPerm : fsRdWrPerm;
X short nFRefNum;
X
X c2pstr( sz );
X BlockMove( sz, st, sz[0]+1 );
X p2cstr( sz );
X if (HFSFlag)
X {
X if (nFlags > 1)
X err = HOpenRF( nVRefNum, lDirID, st, chPerms, &nFRefNum);
X else
X err = HOpen( nVRefNum, lDirID, st, chPerms, &nFRefNum);
X }
X else
X {
X /*
X * Have to use PBxxx style calls since the high level
X * versions don't support specifying permissions
X */
X ParamBlockRec pbr;
X
X pbr.ioParam.ioNamePtr = st;
X pbr.ioParam.ioVRefNum = gnVRefNum;
X pbr.ioParam.ioVersNum = 0;
X pbr.ioParam.ioPermssn = chPerms;
X pbr.ioParam.ioMisc = 0;
X if (nFlags >1)
X err = PBOpenRF( &pbr, false );
X else
X err = PBOpen( &pbr, false );
X nFRefNum = pbr.ioParam.ioRefNum;
X }
X if ( err || (nFRefNum == 1) )
X return -1;
X else {
X if ( nFlags )
X SetEOF( nFRefNum, 0 );
X return nFRefNum;
X }
X}
X
X
X
X
X
X/***********************/
X/* Function macfopen() */
X/***********************/
X
XFILE *macfopen(char *filename, char *mode, short nVRefNum, long lDirID)
X {
X short outfd, fDataFork=TRUE;
X MACINFO mi;
X OSErr err;
X
X fMacZipped = FALSE;
X c2pstr(filename);
X if (extra_field &&
X (lrec.extra_field_length > sizeof(MACINFOMIN)) &&
X (lrec.extra_field_length <= sizeof(MACINFO))) {
X BlockMove(extra_field, &mi, lrec.extra_field_length);
X if ((makeword((uch *)&mi.header) == 1992) &&
X (makeword((uch *)&mi.data) ==
X lrec.extra_field_length-sizeof(ZIP_EXTRA_HEADER)) &&
X (mi.signature == 'JLEE')) {
X gostCreator = mi.finfo.fdCreator;
X gostType = mi.finfo.fdType;
X fDataFork = (mi.flags & 1) ? TRUE : FALSE;
X fMacZipped = true;
X /* If it was Zipped w/Mac version, the filename has either */
X /* a 'd' or 'r' appended. Remove the d/r when unzipping */
X filename[0]-=1;
X }
X }
X if (!fMacZipped) {
X if (!aflag)
X gostType = gostCreator = '\?\?\?\?';
X else {
X gostCreator = CREATOR;
X gostType = 'TEXT';
X }
X }
X p2cstr(filename);
X
X if ((outfd = creat(filename, 0)) != -1) {
X if (fMacZipped) {
X c2pstr(filename);
X if (HFSFlag) {
X HParamBlockRec hpbr;
X
X hpbr.fileParam.ioNamePtr = (StringPtr)filename;
X hpbr.fileParam.ioVRefNum = gnVRefNum;
X hpbr.fileParam.ioDirID = glDirID;
X hpbr.fileParam.ioFlFndrInfo = mi.finfo;
X hpbr.fileParam.ioFlCrDat = mi.lCrDat;
X hpbr.fileParam.ioFlMdDat = mi.lMdDat;
X err = PBHSetFInfo(&hpbr, 0);
X } else {
X err = SetFInfo((StringPtr)filename , 0, &mi.finfo);
X }
X p2cstr(filename);
X }
X outfd = open(filename, (fDataFork) ? 1 : 2);
X }
X
X if (outfd == -1)
X return NULL;
X else
X return (FILE *)outfd;
X }
X
X
X
X
X
X/***********************/
X/* Function maccreat() */
X/***********************/
X
Xshort maccreat(char *sz, short nVRefNum, long lDirID, OSType ostCreator, OSType ostType)
X{
X OSErr err;
X Str255 st;
X FInfo fi;
X
X c2pstr( sz );
X BlockMove( sz, st, sz[0]+1 );
X p2cstr( sz );
X if (HFSFlag)
X {
X err = HGetFInfo( nVRefNum, lDirID, st, &fi );
X if (err == fnfErr)
X err = HCreate( nVRefNum, lDirID, st, ostCreator, ostType );
X else if (err == noErr)
X {
X fi.fdCreator = ostCreator;
X fi.fdType = ostType;
X err = HSetFInfo( nVRefNum, lDirID, st, &fi );
X }
X }
X else
X {
X err = GetFInfo( st, nVRefNum, &fi );
X if (err == fnfErr)
X err = Create( st, nVRefNum, ostCreator, ostType );
X else if (err == noErr)
X {
X fi.fdCreator = ostCreator;
X fi.fdType = ostType;
X err = SetFInfo( st, nVRefNum, &fi );
X }
X }
X if (err == noErr)
X return noErr;
X else
X return -1;
X}
X
X
X
X
X
X/**********************/
X/* Function macread() */
X/**********************/
X
Xshort macread(short nFRefNum, char *pb, unsigned cb)
X{
X long lcb = cb;
X
X (void)FSRead( nFRefNum, &lcb, pb );
X
X return (short)lcb;
X}
X
X
X
X
X
X/***********************/
X/* Function macwrite() */
X/***********************/
X
Xlong macwrite(short nFRefNum, char *pb, unsigned cb)
X{
X long lcb = cb;
X
X#ifdef THINK_C
X if ( (nFRefNum == 1) )
X screenDump( pb, lcb );
X else
X#endif
X (void)FSWrite( nFRefNum, &lcb, pb );
X
X return (long)lcb;
X}
X
X
X
X
X
X/***********************/
X/* Function macclose() */
X/***********************/
X
Xshort macclose(short nFRefNum)
X{
X return FSClose( nFRefNum );
X}
X
X
X
X
X
X/***********************/
X/* Function maclseek() */
X/***********************/
X
Xlong maclseek(short nFRefNum, long lib, short nMode)
X{
X ParamBlockRec pbr;
X
X if (nMode == SEEK_SET)
X nMode = fsFromStart;
X else if (nMode == SEEK_CUR)
X nMode = fsFromMark;
X else if (nMode == SEEK_END)
X nMode = fsFromLEOF;
X pbr.ioParam.ioRefNum = nFRefNum;
X pbr.ioParam.ioPosMode = nMode;
X pbr.ioParam.ioPosOffset = lib;
X (void)PBSetFPos(&pbr, 0);
X return pbr.ioParam.ioPosOffset;
X}
X
X#endif /* MACOS */
END_OF_FILE
if test 31814 -ne `wc -c <'unzip-5.12/mac/mac.c'`; then
echo shar: \"'unzip-5.12/mac/mac.c'\" unpacked with wrong size!
fi
# end of 'unzip-5.12/mac/mac.c'
fi
if test -f 'unzip-5.12/unzip.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unzip-5.12/unzip.doc'\"
else
echo shar: Extracting \"'unzip-5.12/unzip.doc'\" \(33336 characters\)
sed "s/^X//" >'unzip-5.12/unzip.doc' <<'END_OF_FILE'
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
XNAME
X unzip - list, test and extract compressed files in a ZIP
X archive
X
XSYNOPSIS
X unzip [-Z] [-cflptuvz[abjnoqsCLV$]] file[.zip] [file(s) ...]
X [-x xfile(s) ...] [-d exdir]
X
XDESCRIPTION
X unzip will list, test, or extract files from a ZIP archive,
X commonly found on MS-DOS systems. The default behavior
X (with no options) is to extract into the current directory
X (and subdirectories below it) all files from the specified
X ZIP archive. A companion program, zip(1L), creates ZIP
X archives; both programs are compatible with archives created
X by PKWARE's PKZIP and PKUNZIP for MS-DOS, but in many cases
X the program options or default behaviors differ.
X
XARGUMENTS
X file[.zip]
X Path of the ZIP archive(s). If the file specification
X is a wildcard, each matching file is processed in an
X order determined by the operating system (or file sys-
X tem). Only the filename can be a wildcard; the path
X itself cannot. Wildcard expressions are similar to
X Unix egrep(1) (regular) expressions and may contain:
X
X * matches a sequence of 0 or more characters
X
X ? matches exactly 1 character
X
X [...]
X matches any single character found inside the
X brackets; ranges are specified by a beginning
X character, a hyphen, and an ending character. If
X an exclamation point or a caret (`!' or `^') fol-
X lows the left bracket, then the range of charac-
X ters within the brackets is complemented (that is,
X anything except the characters inside the brackets
X is considered a match).
X
X (Be sure to quote any character which might otherwise
X be interpreted or modified by the operating system,
X particularly under Unix and VMS.) If no matches are
X found, the specification is assumed to be a literal
X filename; and if that also fails, the suffix .zip is
X appended. Note that self-extracting ZIP files are sup-
X ported, as with any other ZIP archive; just specify the
X .exe suffix (if any) explicitly.
X
X [file(s)]
X An optional list of archive members to be processed,
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 1
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X separated by spaces. (VMS versions compiled with
X VMSCLI defined must delimit files with commas instead.
X See -v in OPTIONS below.) Regular expressions (wild-
X cards) may be used to match multiple members; see
X above. Again, be sure to quote expressions that would
X otherwise be expanded or modified by the operating sys-
X tem.
X
X [-x xfile(s)]
X An optional list of archive members to be excluded from
X processing. Since wildcard characters match directory
X separators (`/'), this option may be used to exclude
X any files which are in subdirectories. For example,
X ``unzip foo *.[ch] -x */*'' would extract all C source
X files in the main directory, but none in any subdirec-
X tories. Without the -x option, all C source files in
X all directories within the zipfile would be extracted.
X
X [-d exdir]
X An optional directory to which to extract files. By
X default, all files and subdirectories are recreated in
X the current directory; the -d option allows extraction
X in an arbitrary directory (always assuming one has per-
X mission to write to the directory). This option need
X not appear at the end of the command line; it is also
X accepted immediately after the zipfile specification,
X or between the file(s) and the -x option. The option
X and directory may be concatenated without any white
X space between them, but note that this may cause normal
X shell behavior to be suppressed. In particular,
X ``-d ~'' (tilde) is expanded by Unix C shells into the
X name of the user's home directory, but ``-d~'' is
X treated as a literal subdirectory ``~'' of the current
X directory.
X
XOPTIONS
X Note that, in order to support obsolescent hardware, unzip's
X usage screen is limited to 22 or 23 lines and should there-
X fore be considered a reminder of the basic unzip syntax
X rather than an exhaustive list of all possible flags.
X
X -Z zipinfo(1L) mode. If the first option on the command
X line is -Z, the remaining options are taken to be
X zipinfo(1L) options. See the appropriate manual page
X for a description of these options.
X
X -c extract files to stdout/screen (``CRT''). This option
X is similar to the -p option except that the name of
X each file is printed as it is extracted, the -a option
X is allowed, and ASCII-EBCDIC conversion is automati-
X cally performed if appropriate. This option is not
X listed in the unzip usage screen.
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 2
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X -f freshen existing files, i.e., extract only those files
X which already exist on disk and which are newer than
X the disk copies. By default unzip queries before
X overwriting, but the -o option may be used to suppress
X the queries. Note that under many operating systems,
X the TZ (timezone) environment variable must be set
X correctly in order for -f and -u to work properly
X (under Unix the variable is usually set automatically).
X The reasons for this are somewhat subtle but have to do
X with the differences between DOS-format file times
X (always local time) and Unix-format times (always in
X GMT) and the necessity to compare the two. A typical
X TZ value is ``PST8PDT'' (US Pacific time with automatic
X adjustment for Daylight Savings Time or ``summer
X time'').
X
X -l list archive files (short format). The names,
X uncompressed file sizes and modification dates and
X times of the specified files are printed, along with
X totals for all files specified. In addition, the zip-
X file comment and individual file comments (if any) are
X displayed. If a file was archived from a single-case
X file system (for example, the old MS-DOS FAT file sys-
X tem) and the -L option was given, the filename is con-
X verted to lowercase and is prefixed with a caret (^).
X
X -p extract files to pipe (stdout). Nothing but the file
X data is sent to stdout, and the files are always
X extracted in binary format, just as they are stored (no
X conversions).
X
X -t test archive files. This option extracts each speci-
X fied file in memory and compares the CRC (cyclic redun-
X dancy check, an enhanced checksum) of the expanded file
X with the original file's stored CRC value.
X
X -u update existing files and create new ones if needed.
X This option performs the same function as the -f
X option, extracting (with query) files which are newer
X than those with the same name on disk, and in addition
X it extracts those files which do not already exist on
X disk. See -f above for information on setting the
X timezone properly.
X
X -v be verbose or print diagnostic version info. This
X option has evolved and now behaves as both an option
X and a modifier. As an option it has two purposes:
X when a zipfile is specified with no other options, -v
X lists archive files verbosely, adding to the -l info
X the compression method, compressed size, compression
X ratio and 32-bit CRC. When no zipfile is specified
X (that is, the complete command is simply ``unzip -v''),
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 3
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X a diagnostic screen is printed. In addition to the
X normal header with release date and version, unzip
X lists the home Info-ZIP ftp site and where to find a
X list of other ftp and non-ftp sites; the target operat-
X ing system for which it was compiled, as well as (pos-
X sibly) the hardware on which it was compiled, the com-
X piler and version used, and the compilation date; any
X special compilation options which might affect the
X program's operation (see also DECRYPTION below); and
X any options stored in environment variables which might
X do the same (see ENVIRONMENT OPTIONS below). As a
X modifier it works in conjunction with other options
X (e.g., -t) to produce more verbose or debugging output;
X this is not yet fully implemented but will be in future
X releases.
X
X -z display only the archive comment.
X
XMODIFIERS
X -a convert text files. Ordinarily all files are extracted
X exactly as they are stored (as ``binary'' files). The
X -a option causes files identified by zip as text files
X (those with the `t' label in zipinfo listings, rather
X than `b') to be automatically extracted as such, con-
X verting line endings, end-of-file characters and the
X character set itself as necessary. (For example, Unix
X files use line feeds (LFs) for end-of-line (EOL) and
X have no end-of-file (EOF) marker; Macintoshes use car-
X riage returns (CRs) for EOLs; and most PC operating
X systems use CR+LF for EOLs and control-Z for EOF. In
X addition, IBM mainframes and the Michigan Terminal Sys-
X tem use EBCDIC rather than the more common ASCII char-
X acter set, and NT supports Unicode.) Note that zip's
X identification of text files is by no means perfect;
X some ``text'' files may actually be binary and vice
X versa. unzip therefore prints ``[text]'' or
X ``[binary]'' as a visual check for each file it
X extracts when using the -a option. The -aa option
X forces all files to be extracted as text, regardless of
X the supposed file type.
X
X -b treat all files as binary (no text conversions). This
X is a shortcut for ---a.
X
X -C match filenames case-insensitively. unzip's philosophy
X is ``you get what you ask for'' (this is also responsi-
X ble for the -L/-U change; see the relevant options
X below). Because some filesystems are fully case-
X sensitive (notably those under the Unix operating sys-
X tem) and because both ZIP archives and unzip itself are
X portable across platforms, unzip's default behavior is
X to match both wildcard and literal filenames case-
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 4
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X sensitively. That is, specifying ``makefile'' on the
X command line will only match ``makefile'' in the
X archive, not ``Makefile'' or ``MAKEFILE'' (and simi-
X larly for wildcard specifications). Since this does
X not correspond to the behavior of many other
X operating/file systems (for example, OS/2 HPFS which
X preserves mixed case but is not sensitive to it), the
X -C option may be used to force all filename matches to
X be case-insensitive. In the example above, all three
X files would then match ``makefile'' (or ``make*'', or
X similar). The -C option affects files in both the nor-
X mal file list and the excluded-file list (xlist).
X
X -j junk paths. The archive's directory structure is not
X recreated; all files are deposited in the extraction
X directory (by default, the current one).
X
X -L convert to lowercase any filename originating on an
X uppercase-only operating system or filesystem. (This
X was unzip's default behavior in releases prior to 5.11;
X the new default behavior is identical to the old
X behavior with the -U option, which is now obsolete and
X will be removed in a future release.) Depending on the
X archiver, files archived under single-case filesystems
X (VMS, old MS-DOS FAT, etc.) may be stored as all-
X uppercase names; this can be ugly or inconvenient when
X extracting to a case-preserving filesystem such as OS/2
X HPFS or a case-sensitive one such as under Unix. By
X default unzip lists and extracts such filenames exactly
X as they're stored (excepting truncation, conversion of
X unsupported characters, etc.); this option causes the
X names of all files from certain systems to be converted
X to lowercase.
X
X -n never overwrite existing files. If a file already
X exists, skip the extraction of that file without
X prompting. By default unzip queries before extracting
X any file which already exists; the user may choose to
X overwrite only the current file, overwrite all files,
X skip extraction of the current file, skip extraction of
X all existing files, or rename the current file.
X
X -o overwrite existing files without prompting. This is a
X dangerous option, so use it with care. (It is often
X used with -f, however.)
X
X -q perform operations quietly (-qq = even quieter). Ordi-
X narily unzip prints the names of the files it's
X extracting or testing, the extraction methods, any file
X or zipfile comments which may be stored in the archive,
X and possibly a summary when finished with each archive.
X The -q[q] options suppress the printing of some or all
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 5
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X of these messages.
X
X -s [OS/2, NT, MS-DOS] convert spaces in filenames to
X underscores. Since all PC operating systems allow
X spaces in filenames, unzip by default extracts
X filenames with spaces intact (e.g., ``EA DATA. SF'').
X This can be awkward, however, since MS-DOS in particu-
X lar does not gracefully support spaces in filenames.
X Conversion of spaces to underscores can eliminate the
X awkwardness in some cases.
X
X -U (obsolete; to be removed in a future release) leave
X filenames uppercase if created under MS-DOS, VMS, etc.
X See -L above.
X
X -V retain (VMS) file version numbers. VMS files can be
X stored with a version number, in the format
X file.ext;##. By default the ``;##'' version numbers
X are stripped, but this option allows them to be
X retained. (On filesystems which limit filenames to
X particularly short lengths, the version numbers may be
X truncated or stripped regardless of this option.)
X
X -X [VMS] restore owner/protection info (may require system
X privileges). Ordinary file attributes are always
X restored, but this option allows UICs to be restored as
X well. [The next version of unzip will support Unix
X UID/GID info as well, and possibly NT permissions.]
X
X -$ [MS-DOS, OS/2, NT, Amiga] restore the volume label if
X the extraction medium is removable (e.g., a diskette).
X Doubling the option (-$$) allows fixed media (hard
X disks) to be labelled as well. By default, volume
X labels are ignored.
X
XENVIRONMENT OPTIONS
X unzip's default behavior may be modified via options placed
X in an environment variable. This can be done with any
X option, but it is probably most useful with the -a, -L, -C,
X -q, -o, or -n modifiers: make unzip auto-convert text files
X by default, make it convert filenames from uppercase systems
X to lowercase, make it match names case-insensitively, make
X it quieter, or make it always overwrite or never overwrite
X files as it extracts them. For example, to make unzip act
X as quietly as possible, only reporting errors, one would use
X one of the following commands:
X
X UNZIP=-qq; export UNZIP Unix Bourne shell
X setenv UNZIP -qq Unix C shell
X set UNZIP=-qq OS/2 or MS-DOS
X define UNZIP_OPTS "-qq" VMS (quotes for lowercase)
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 6
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X Environment options are, in effect, considered to be just
X like any other command-line options, except that they are
X effectively the first options on the command line. To over-
X ride an environment option, one may use the ``minus opera-
X tor'' to remove it. For instance, to override one of the
X quiet-flags in the example above, use the command
X
X unzip --q[other options] zipfile
X
X The first hyphen is the normal switch character, and the
X second is a minus sign, acting on the q option. Thus the
X effect here is to cancel one quantum of quietness. To can-
X cel both quiet flags, two (or more) minuses may be used:
X
X unzip -t--q zipfile
X unzip ---qt zipfile
X
X (the two are equivalent). This may seem awkward or confus-
X ing, but it is reasonably intuitive: just ignore the first
X hyphen and go from there. It is also consistent with the
X behavior of Unix nice(1).
X
X As suggested by the examples above, the default variable
X names are UNZIP_OPTS for VMS (where the symbol used to
X install unzip as a foreign command would otherwise be con-
X fused with the environment variable), and UNZIP for all
X other operating systems. For compatibility with zip(1L),
X UNZIPOPT is also accepted (don't ask). If both UNZIP and
X UNZIPOPT are defined, however, UNZIP takes precedence.
X unzip's diagnostic option (-v with no zipfile name) can be
X used to check the values of all four possible unzip and
X zipinfo environment variables.
X
X The timezone variable (TZ) should be set according to the
X local timezone in order for the -f and -u to operate
X correctly. See the description of -f above for details.
X This variable may also be necessary in order for timestamps
X on extracted files to be set correctly.
X
XDECRYPTION
X Encrypted archives are fully supported by Info-ZIP software,
X but due to United States export restrictions, the encryption
X and decryption sources are not packaged with the regular
X unzip and zip distributions. Since the crypt sources were
X written by Europeans, however, they are freely available at
X sites throughout the world; see the file ``Where'' in any
X Info-ZIP source or binary distribution for locations both
X inside and outside the US.
X
X Because of the separate distribution, not all compiled ver-
X sions of unzip support decryption. To check a version for
X crypt support, either attempt to test or extract an
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 7
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X encrypted archive, or else check unzip's diagnostic screen
X (see the -v option above) for ``[decryption]'' as one of the
X special compilation options.
X
X There are no runtime options for decryption; if a zipfile
X member is encrypted, unzip will prompt for the password
X without echoing what is typed. unzip continues to use the
X same password as long as it appears to be valid; it does
X this by testing a 12-byte header. The correct password will
X always check out against the header, but there is a 1-in-256
X chance that an incorrect password will as well. (This is a
X security feature of the PKWARE zipfile format; it helps
X prevent brute-force attacks which might otherwise gain a
X large speed advantage by testing only the header.) In the
X case that an incorrect password is given but it passes the
X header test anyway, either an incorrect CRC will be gen-
X erated for the extracted data or else unzip will fail during
X the extraction because the ``decrypted'' bytes do not con-
X stitute a valid compressed data stream.
X
X If the first password fails the header check on some file,
X unzip will prompt for another password, and so on until all
X files are extracted. If a password is not known, entering a
X null password (that is, just a carriage return) is taken as
X a signal to skip all further prompting. Only unencrypted
X files in the archive(s) will thereafter be extracted.
X (Actually that's not quite true; older versions of zip(1L)
X and zipcloak(1L) allowed null passwords, so unzip checks
X each encrypted file to see if the null password works. This
X may result in ``false positives'' and extraction errors, as
X noted above.)
X
X Note that there is presently no way to avoid interactive
X decryption. This is another security feature: plaintext
X passwords given on the command line or stored in files con-
X stitute a risk because they may be seen by others. Future
X releases may (under protest, with great disapproval) support
X such shenanigans.
X
XEXAMPLES
X To use unzip to extract all members of the archive
X letters.zip into the current directory and subdirectories
X below it, creating any subdirectories as necessary:
X
X unzip letters
X
X To extract all members of letters.zip into the current
X directory only:
X
X unzip -j letters
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 8
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X To test letters.zip, printing only a summary message indi-
X cating whether the archive is OK or not:
X
X unzip -tq letters
X
X To test all zipfiles in the current directory, printing only
X the summaries:
X
X unzip -tq \*.zip
X
X (The backslash before the asterisk is only required if the
X shell expands wildcards, as in Unix; double quotes could
X have been used instead, as in the source examples
X below.) To extract to standard output all members of
X letters.zip whose names end in .tex, auto-converting to the
X local end-of-line convention and piping the output into
X more(1):
X
X unzip -ca letters \*.tex | more
X
X To extract the binary file paper1.dvi to standard output and
X pipe it to a printing program:
X
X unzip -p articles paper1.dvi | dvips
X
X To extract all FORTRAN and C source files--*.f, *.c, *.h,
X and Makefile--into the /tmp directory:
X
X unzip source.zip "*.[fch]" Makefile -d /tmp
X
X (the double quotes are necessary only in Unix and only if
X globbing is turned on). To extract all FORTRAN and C source
X files, regardless of case (e.g., both *.c and *.C, and any
X makefile, Makefile, MAKEFILE or similar):
X
X unzip -C source.zip "*.[fch]" makefile -d /tmp
X
X To extract any such files but convert any uppercase MS-DOS
X or VMS names to lowercase and convert the line-endings of
X all of the files to the local standard (without respect to
X any files which might be marked ``binary''):
X
X unzip -aaCL source.zip "*.[fch]" makefile -d /tmp
X
X To extract only newer versions of the files already in the
X current directory, without querying (NOTE: be careful of
X unzipping in one timezone a zipfile created in another--ZIP
X archives to date contain no timezone information, and a
X ``newer'' file from an eastern timezone may, in fact, be
X older):
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 9
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X unzip -fo sources
X
X To extract newer versions of the files already in the
X current directory and to create any files not already there
X (same caveat as previous example):
X
X unzip -uo sources
X
X To display a diagnostic screen showing which unzip and
X zipinfo options are stored in environment variables, whether
X decryption support was compiled in, the compiler with which
X unzip was compiled, etc.:
X
X unzip -v
X
X In the last five examples, assume that UNZIP or UNZIP_OPTS
X is set to -q. To do a singly quiet listing:
X
X unzip -l file.zip
X
X To do a doubly quiet listing:
X
X unzip -ql file.zip
X
X (Note that the ``.zip'' is generally not necessary.) To do
X a standard listing:
X
X unzip --ql file.zip
X or
X unzip -l-q file.zip
X or
X unzip -l--q file.zip (extra minuses don't hurt)
X
XTIPS
X The current maintainer, being a lazy sort, finds it very
X useful to define a pair of aliases: tt for ``unzip -tq''
X and ii for ``unzip -Z'' (or ``zipinfo''). One may then sim-
X ply type ``tt zipfile'' to test an archive, something which
X is worth making a habit of doing. With luck unzip will
X report ``No errors detected in zipfile.zip,'' after which
X one may breathe a sigh of relief.
X
X The maintainer also finds it useful to set the UNZIP
X environment variable to ``-aL'' and is tempted to add ``-C''
X as well. His ZIPINFO variable is set to ``-z''.
X
XDIAGNOSTICS
X The exit status (or error level) approximates the exit codes
X defined by PKWARE and takes on the following values, except
X under VMS:
X
X 0 normal; no errors or warnings detected.
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 10
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X 1 one or more warning errors were encountered, but
X processing completed successfully anyway. This
X includes zipfiles where one or more files was
X skipped due to unsupported compression method or
X encryption with an unknown password.
X
X 2 a generic error in the zipfile format was
X detected. Processing may have completed success-
X fully anyway; some broken zipfiles created by
X other archivers have simple work-arounds.
X
X 3 a severe error in the zipfile format was detected.
X Processing probably failed immediately.
X
X 4-8 unzip was unable to allocate memory for one or
X more buffers.
X
X 9 the specified zipfiles were not found.
X
X 10 invalid options were specified on the command
X line.
X
X 11 no matching files were found.
X
X 50 the disk is (or was) full during extraction.
X
X 51 the end of the ZIP archive was encountered prema-
X turely.
X
X VMS interprets standard Unix (or PC) return values as other,
X scarier-looking things, so by default unzip always returns 0
X (which reportedly gets converted into a VMS status of 1--
X i.e., success). There are two compilation options available
X to modify or expand upon this behavior: defining
X RETURN_CODES results in a human-readable explanation of what
X the real error status was (but still with a faked ``suc-
X cess'' exit value), while defining RETURN_SEVERITY causes
X unzip to exit with a ``real'' VMS status. The latter
X behavior will become the default in future versions unless
X it is found to conflict with officially defined VMS codes.
X The current mapping is as follows: 1 (success) for normal
X exit, 0x7fff0001 for warning errors, and (0x7fff000? +
X 16*normal_unzip_exit_status) for all other errors, where the
X `?' is 2 (error) for unzip values 2 and 9-11, and 4 (fatal
X error) for the remaining ones (3-8, 50, 51). Check the
X ``unzip -v'' output to see whether RETURN_SEVERITY was
X defined at compilation time.
X
XBUGS
X When attempting to extract a corrupted archive, unzip may go
X into an infinite loop and, if not stopped quickly enough,
X fill all available disk space. Compiling with CHECK_EOF
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 11
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X should fix this problem for all zipfiles, but the option was
X introduced too late in the testing process to be made the
X default behavior. Future versions will be robust enough to
X fail gracefully on damaged archives. Check the ``unzip -v''
X output to see whether CHECK_EOF was defined during compila-
X tion.
X
X [MS-DOS] When extracting or testing files from an archive on
X a defective floppy diskette, if the ``Fail'' option is
X chosen from DOS's ``Abort, Retry, Fail?'' message, unzip may
X hang the system, requiring a reboot. Instead, press
X control-C (or control-Break) to terminate unzip.
X
X Under DEC Ultrix, unzip will sometimes fail on long zipfiles
X (bad CRC, not always reproducible). This is apparently due
X either to a hardware bug (cache memory) or an operating sys-
X tem bug (improper handling of page faults?).
X
X Dates and times of stored directories are not restored.
X
X [OS/2] Extended attributes for existing directories are
X never updated. This is a limitation of the operating sys-
X tem; unzip has no way to determine whether the stored attri-
X butes are newer or older than the existing ones.
X
X [VMS] When extracting to another directory, only the [.foo]
X syntax is accepted for the -d option; the simple Unix foo
X syntax is silently ignored (as is the less common VMS
X foo.dir syntax).
X
X [VMS] When the file being extracted already exists, unzip's
X query only allows skipping, overwriting or renaming; there
X should additionally be a choice for creating a new version
X of the file. In fact, the ``overwrite'' choice does create
X a new version; the old version is not overwritten or
X deleted.
X
XSEE ALSO
X funzip(1L), zip(1L), zipcloak(1L), zipgrep(1L), zipinfo(1L),
X zipnote(1L), zipsplit(1L)
X
XAUTHORS
X The primary Info-ZIP authors (current zip-bugs workgroup)
X are: Jean-loup Gailly (Zip); Greg R. Roelofs (UnZip); Mark
X Adler (decompression, fUnZip); Kai Uwe Rommel (OS/2); Igor
X Mandrichenko and Hunter Goatley (VMS); John Bush and Paul
X Kienitz (Amiga); Antoine Verheijen (Macintosh); Chris Her-
X borth (Atari); Henry Gessau (NT); Karl Davis, Sergio Monesi
X and Evan Shattock (Acorn Archimedes); and Robert Heath (Win-
X dows). The author of the original unzip code upon which
X Info-ZIP's is based was Samuel H. Smith; Carl Mascott did
X the first Unix port; and David P. Kirschbaum organized and
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 12
X
XUNZIP(1L) MISC. REFERENCE MANUAL PAGES UNZIP(1L)
X
X led Info-ZIP in its early days. The full list of contribu-
X tors to UnZip has grown quite large; please refer to the
X CONTRIBS file in the UnZip source distribution for a rela-
X tively complete version.
X
XVERSIONS
X v1.2 15 Mar 89 Samuel H. Smith
X v2.0 9 Sep 89 Samuel H. Smith
X v2.x fall 1989 many Usenet contributors
X v3.0 1 May 90 Info-ZIP (DPK, consolidator)
X v3.1 15 Aug 90 Info-ZIP (DPK, consolidator)
X v4.0 1 Dec 90 Info-ZIP (GRR, maintainer)
X v4.1 12 May 91 Info-ZIP
X v4.2 20 Mar 92 Info-ZIP (zip-bugs subgroup, GRR)
X v5.0 21 Aug 92 Info-ZIP (zip-bugs subgroup, GRR)
X v5.01 15 Jan 93 Info-ZIP (zip-bugs subgroup, GRR)
X v5.1 7 Feb 94 Info-ZIP (zip-bugs subgroup, GRR)
X v5.11 2 Aug 94 Info-ZIP (zip-bugs subgroup, GRR)
X v5.12 28 Aug 94 Info-ZIP (zip-bugs subgroup, GRR)
X
XInfo-ZIP Last change: 28 Aug 94 (v5.12) 13
X
END_OF_FILE
if test 33336 -ne `wc -c <'unzip-5.12/unzip.doc'`; then
echo shar: \"'unzip-5.12/unzip.doc'\" unpacked with wrong size!
fi
# end of 'unzip-5.12/unzip.doc'
fi
echo shar: End of archive 11 \(of 20\).
cp /dev/null ark11isdone
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...