home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / unzip / part11 < prev    next >
Internet Message Format  |  1994-09-19  |  72KB

  1. From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
  2. Newsgroups: comp.sources.misc
  3. Subject: v44i076:  unzip - Info-ZIP portable UnZip, version 5.12, Part11/20
  4. Date: 18 Sep 1994 23:15:55 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <35j39r$qp4@sparky.sterling.com>
  9. X-Md4-Signature: 4920733f0064af3e6e74920667821d9b
  10.  
  11. Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
  12. Posting-number: Volume 44, Issue 76
  13. Archive-name: unzip/part11
  14. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT, AMIGA?, ATARI TOS, SGI, DEC, Cray, Convex, Amdahl, Sun
  15. Supersedes: unzip50: Volume 31, Issue 104-117
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  unzip-5.12/atari/README unzip-5.12/mac/mac.c
  22. #   unzip-5.12/unzip.doc
  23. # Wrapped by kent@sparky on Sat Sep 17 23:33:42 1994
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 11 (of 20)."'
  27. if test -f 'unzip-5.12/atari/README' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'unzip-5.12/atari/README'\"
  29. else
  30.   echo shar: Extracting \"'unzip-5.12/atari/README'\" \(2181 characters\)
  31.   sed "s/^X//" >'unzip-5.12/atari/README' <<'END_OF_FILE'
  32. XHere it is...  the UnZip 5.1 port for the Atari ST/TT/Falcon!
  33. X
  34. XThis took me longer than I expected thanks to a difference between the
  35. XMiNT library and most UNIX libraries...  symlinks are 0x16000
  36. Xinstead of 0xa000...  I'm told this isn't even defined in POSIX, so I
  37. Xcan't really complain.  At least we've got a filesystem that can use
  38. Xsymlinks!
  39. X
  40. XThis port requires GNU C and allows you to build an unzip/zipinfo/funzip
  41. Xthat supports long filenames (on appropriate filesystems, thanks to the 
  42. XMiNT library), as well as symlinks.  It also does "proper" (ie, DOS-style)
  43. Xtranslation of text-file end-of-line characters.  The programs also build 
  44. Xas shared-text binaries, so you can start unzipping several files at once 
  45. Xin the background and only a small part of unzip will be duplicated in 
  46. Xmemory.
  47. X
  48. XI build unzip with the MiNT library, GNU C 2.5.8 (2.5.7 and lower have a
  49. Xrather sever problem in the optimiser that affects 68000 code only; it
  50. Xadds 68020-only instructions to the 68000 code).  Oh, and I tested it
  51. Xextensively under MiNT's minix filesystem as well as the bogus DOS
  52. Xfilesystem that "normal" Atari partitions have.
  53. X
  54. XThe Makefile won't need any editing if you want to built unzip et al. on
  55. Xa minix filesystem; if you want to install it on a DOS filesystem, use
  56. X"cp" instead of "ln" for zipinfo.  [Or, to save disk space, make a script/
  57. Xcommand-file which invokes "unzip -Z ...". --CN]  This is such a good
  58. Xidea that I'm annoyed that Greg thought of it and I didn't...  ;-)  If
  59. Xyou're using a shell worth your while, you can alias zipinfo to 
  60. X'unzip -Z' and then forget all about this paragraph.
  61. X
  62. XIf you want to compile this using Turbo C (aka Pure C in North America)
  63. Xyou're on your own...  That's ok, I'll make a nice binary version of
  64. Xunzip available as soon as the official 5.1 version is released (give or
  65. Xtake a few days).
  66. X
  67. XEnjoy!  Cave Newt should be given kudos for keeping this monster easy to
  68. Xport...  ;-)  [Hah!  But thanks anyway. :-) --CN]
  69. X
  70. XPLEASE email me to tell me if you've uploaded the source or binary
  71. Xversions of Unzip 5.x to any BBS systems or commercial online systems so
  72. Xwe can update the Where file!
  73. X
  74. X-Chris-
  75. Xcherborth@semprini.waterloo-rdp.on.ca
  76. END_OF_FILE
  77.   if test 2181 -ne `wc -c <'unzip-5.12/atari/README'`; then
  78.     echo shar: \"'unzip-5.12/atari/README'\" unpacked with wrong size!
  79.   fi
  80.   # end of 'unzip-5.12/atari/README'
  81. fi
  82. if test -f 'unzip-5.12/mac/mac.c' -a "${1}" != "-c" ; then 
  83.   echo shar: Will not clobber existing file \"'unzip-5.12/mac/mac.c'\"
  84. else
  85.   echo shar: Extracting \"'unzip-5.12/mac/mac.c'\" \(31814 characters\)
  86.   sed "s/^X//" >'unzip-5.12/mac/mac.c' <<'END_OF_FILE'
  87. X/*---------------------------------------------------------------------------
  88. X
  89. X  mac.c
  90. X
  91. X  Macintosh-specific routines for use with Info-ZIP's UnZip 5.1 and later.
  92. X
  93. X  This source file incorporates the contents of what was formerly macfile.c,
  94. X  which supported commands (such as mkdir()) not available directly on the
  95. X  Mac, and which also determined whether HFS (Hierarchical File System) or
  96. X  MFS (Macintosh File System) was in use.
  97. X
  98. X  Contains:  do_wild()
  99. X             mapattr()
  100. X             mapname()
  101. X             checkdir()
  102. X             close_outfile()
  103. X             version()
  104. X             IsHFSDisk()
  105. X             MacFSTest()
  106. X             macmkdir()
  107. X             ResolveMacVol()
  108. X             macopen()
  109. X             macfopen()
  110. X             maccreat()
  111. X             macread()
  112. X             macwrite()
  113. X             macclose()
  114. X             maclseek()
  115. X
  116. X  ---------------------------------------------------------------------------*/
  117. X
  118. X
  119. X
  120. X#include "unzip.h"
  121. X
  122. X#ifdef MACOS
  123. X#ifndef FSFCBLen
  124. X#  define FSFCBLen  (*(short *)0x3F6)
  125. X#endif
  126. X
  127. X#define read_only   file_attr   /* for readability only */
  128. X
  129. Xstatic short wAppVRefNum;
  130. Xstatic long lAppDirID;
  131. Xint HFSFlag;            /* set if disk has hierarchical file system */
  132. X
  133. Xstatic int created_dir;        /* used in mapname(), checkdir() */
  134. Xstatic int renamed_fullpath;   /* ditto */
  135. X
  136. X#define MKDIR(path)     macmkdir(path, gnVRefNum, glDirID)
  137. X
  138. X
  139. X
  140. X
  141. X
  142. X/**********************/
  143. X/* Function do_wild() */   /* for porting:  dir separator; match(ignore_case) */
  144. X/**********************/
  145. X
  146. Xchar *do_wild(wildspec)
  147. X    char *wildspec;         /* only used first time on a given dir */
  148. X{
  149. X    static DIR *dir = NULL;
  150. X    static char *dirname, *wildname, matchname[FILNAMSIZ];
  151. X    static int firstcall=TRUE, have_dirname, dirnamelen;
  152. X    struct direct *file;
  153. X
  154. X
  155. X    /* Even when we're just returning wildspec, we *always* do so in
  156. X     * matchname[]--calling routine is allowed to append four characters
  157. X     * to the returned string, and wildspec may be a pointer to argv[].
  158. X     */
  159. X    if (firstcall) {        /* first call:  must initialize everything */
  160. X        firstcall = FALSE;
  161. X
  162. X        /* break the wildspec into a directory part and a wildcard filename */
  163. X        if ((wildname = strrchr(wildspec, ':')) == NULL) {
  164. X            dirname = ":";
  165. X            dirnamelen = 1;
  166. X            have_dirname = FALSE;
  167. X            wildname = wildspec;
  168. X        } else {
  169. X            ++wildname;     /* point at character after ':' */
  170. X            dirnamelen = wildname - wildspec;
  171. X            if ((dirname = (char *)malloc(dirnamelen+1)) == NULL) {
  172. X                fprintf(stderr, "warning:  can't allocate wildcard buffers\n");
  173. X                strcpy(matchname, wildspec);
  174. X                return matchname;   /* but maybe filespec was not a wildcard */
  175. X            }
  176. X            strncpy(dirname, wildspec, dirnamelen);
  177. X            dirname[dirnamelen] = '\0';
  178. X            have_dirname = TRUE;
  179. X        }
  180. X
  181. X        if ((dir = opendir(dirname)) != NULL) {
  182. X            while ((file = readdir(dir)) != NULL) {
  183. X                if (match(file->d_name, wildname, 0)) {  /* 0 == case sens. */
  184. X                    if (have_dirname) {
  185. X                        strcpy(matchname, dirname);
  186. X                        strcpy(matchname+dirnamelen, file->d_name);
  187. X                    } else
  188. X                        strcpy(matchname, file->d_name);
  189. X                    return matchname;
  190. X                }
  191. X            }
  192. X            /* if we get to here directory is exhausted, so close it */
  193. X            closedir(dir);
  194. X            dir = NULL;
  195. X        }
  196. X
  197. X        /* return the raw wildspec in case that works (e.g., directory not
  198. X         * searchable, but filespec was not wild and file is readable) */
  199. X        strcpy(matchname, wildspec);
  200. X        return matchname;
  201. X    }
  202. X
  203. X    /* last time through, might have failed opendir but returned raw wildspec */
  204. X    if (dir == NULL) {
  205. X        firstcall = TRUE;  /* nothing left to try--reset for new wildspec */
  206. X        if (have_dirname)
  207. X            free(dirname);
  208. X        return (char *)NULL;
  209. X    }
  210. X
  211. X#ifndef THINK_C            /* Think C only matches one at most (for now) */
  212. X    /* If we've gotten this far, we've read and matched at least one entry
  213. X     * successfully (in a previous call), so dirname has been copied into
  214. X     * matchname already.
  215. X     */
  216. X    while ((file = readdir(dir)) != NULL)
  217. X        if (match(file->d_name, wildname, 0)) {   /* 0 == don't ignore case */
  218. X            if (have_dirname) {
  219. X                /* strcpy(matchname, dirname); */
  220. X                strcpy(matchname+dirnamelen, file->d_name);
  221. X            } else
  222. X                strcpy(matchname, file->d_name);
  223. X            return matchname;
  224. X        }
  225. X#endif
  226. X
  227. X    closedir(dir);     /* have read at least one dir entry; nothing left */
  228. X    dir = NULL;
  229. X    firstcall = TRUE;  /* reset for new wildspec */
  230. X    if (have_dirname)
  231. X        free(dirname);
  232. X    return (char *)NULL;
  233. X
  234. X} /* end function do_wild() */
  235. X
  236. X
  237. X
  238. X
  239. X
  240. X/**********************/
  241. X/* Function mapattr() */
  242. X/**********************/
  243. X
  244. Xint mapattr()
  245. X{
  246. X    /* only care about read-only bit, so just look at MS-DOS side of attrs */
  247. X    pInfo->read_only = (unsigned)(crec.external_file_attributes & 1);
  248. X    return 0;
  249. X
  250. X} /* end function mapattr() */
  251. X
  252. X
  253. X
  254. X
  255. X
  256. X/************************/
  257. X/*  Function mapname()  */
  258. X/************************/
  259. X
  260. Xint mapname(renamed)  /* return 0 if no error, 1 if caution (filename trunc), */
  261. X    int renamed;      /* 2 if warning (skip file because dir doesn't exist), */
  262. X{                     /* 3 if error (skip file), 10 if no memory (skip file) */
  263. X    char pathcomp[FILNAMSIZ];   /* path-component buffer */
  264. X    char *pp, *cp=NULL;         /* character pointers */
  265. X    char *lastsemi = NULL;      /* pointer to last semi-colon in pathcomp */
  266. X    int quote = FALSE;          /* flags */
  267. X    int error = 0;
  268. X    register unsigned workch;   /* hold the character being tested */
  269. X
  270. X
  271. X/*---------------------------------------------------------------------------
  272. X    Initialize various pointers and counters and stuff.
  273. X  ---------------------------------------------------------------------------*/
  274. X
  275. X    /* can create path as long as not just freshening, or if user told us */
  276. X    create_dirs = (!fflag || renamed);
  277. X
  278. X    created_dir = FALSE;        /* not yet */
  279. X
  280. X    /* user gave full pathname:  don't prepend rootpath */
  281. X    renamed_fullpath = (renamed && (*filename == '/'));
  282. X
  283. X    if (checkdir((char *)NULL, INIT) == 10)
  284. X        return 10;              /* initialize path buffer, unless no memory */
  285. X
  286. X    pp = pathcomp;              /* point to translation buffer */
  287. X    if (!(renamed_fullpath || jflag))
  288. X        *pp++ = ':';
  289. X    *pp = '\0';
  290. X
  291. X    if (jflag)                  /* junking directories */
  292. X        cp = (char *)strrchr(filename, '/');
  293. X    if (cp == NULL)             /* no '/' or not junking dirs */
  294. X        cp = filename;          /* point to internal zipfile-member pathname */
  295. X    else
  296. X        ++cp;                   /* point to start of last component of path */
  297. X
  298. X/*---------------------------------------------------------------------------
  299. X    Begin main loop through characters in filename.
  300. X  ---------------------------------------------------------------------------*/
  301. X
  302. X    while ((workch = (uch)*cp++) != 0) {
  303. X
  304. X        if (quote) {                 /* if character quoted, */
  305. X            *pp++ = (char)workch;    /*  include it literally */
  306. X            quote = FALSE;
  307. X        } else
  308. X            switch (workch) {
  309. X            case '/':             /* can assume -j flag not given */
  310. X                *pp = '\0';
  311. X                if ((error = checkdir(pathcomp, APPEND_DIR)) > 1)
  312. X                    return error;
  313. X                pp = pathcomp;    /* reset conversion buffer for next piece */
  314. X                lastsemi = NULL;  /* leave directory semi-colons alone */
  315. X                break;
  316. X
  317. X            case ';':             /* VMS version (or DEC-20 attrib?) */
  318. X                lastsemi = pp;         /* keep for now; remove VMS ";##" */
  319. X                *pp++ = (char)workch;  /*  later, if requested */
  320. X                break;
  321. X
  322. X            case '\026':          /* control-V quote for special chars */
  323. X                quote = TRUE;     /* set flag for next character */
  324. X                break;
  325. X
  326. X            default:
  327. X                /* allow European characters in filenames: */
  328. X                if (isprint(workch) || (128 <= workch && workch <= 254))
  329. X                    *pp++ = (char)workch;
  330. X            } /* end switch */
  331. X
  332. X    } /* end while loop */
  333. X
  334. X    *pp = '\0';                   /* done with pathcomp:  terminate it */
  335. X
  336. X    /* if not saving them, remove with VMS version numbers (appended ";###") */
  337. X    if (!V_flag && lastsemi) {
  338. X        pp = lastsemi + 1;
  339. X        while (isdigit((uch)(*pp)))
  340. X            ++pp;
  341. X        if (*pp == '\0')          /* only digits between ';' and end:  nuke */
  342. X            *lastsemi = '\0';
  343. X    }
  344. X
  345. X/*---------------------------------------------------------------------------
  346. X    Report if directory was created (and no file to create:  filename ended
  347. X    in '/'), check name to be sure it exists, and combine path and name be-
  348. X    fore exiting.
  349. X  ---------------------------------------------------------------------------*/
  350. X
  351. X    if (filename[strlen(filename) - 1] == '/') {
  352. X        checkdir(filename, GETPATH);
  353. X        if (created_dir && QCOND2) {
  354. X            fprintf(stdout, "   creating: %s\n", filename);
  355. X            return IZ_CREATED_DIR;   /* set dir time (note trailing '/') */
  356. X        }
  357. X        return 2;   /* dir existed already; don't look for data to extract */
  358. X    }
  359. X
  360. X    if (*pathcomp == '\0') {
  361. X        fprintf(stderr, "mapname:  conversion of %s failed\n", filename);
  362. X        return 3;
  363. X    }
  364. X
  365. X    checkdir(pathcomp, APPEND_NAME);   /* returns 1 if truncated:  care? */
  366. X    checkdir(filename, GETPATH);
  367. X
  368. X    return error;
  369. X
  370. X} /* end function mapname() */
  371. X
  372. X
  373. X
  374. X
  375. X
  376. X/***********************/
  377. X/* Function checkdir() */
  378. X/***********************/
  379. X
  380. Xint checkdir(pathcomp, flag)
  381. X    char *pathcomp;
  382. X    int flag;
  383. X/*
  384. X * returns:  1 - (on APPEND_NAME) truncated filename
  385. X *           2 - path doesn't exist, not allowed to create
  386. X *           3 - path doesn't exist, tried to create and failed; or
  387. X *               path exists and is not a directory, but is supposed to be
  388. X *           4 - path is too long
  389. X *          10 - can't allocate memory for filename buffers
  390. X */
  391. X{
  392. X    static int rootlen = 0;   /* length of rootpath */
  393. X    static char *rootpath;    /* user's "extract-to" directory */
  394. X    static char *buildpath;   /* full path (so far) to extracted file */
  395. X    static char *end;         /* pointer to end of buildpath ('\0') */
  396. X
  397. X#   define FN_MASK   7
  398. X#   define FUNCTION  (flag & FN_MASK)
  399. X
  400. X
  401. X
  402. X/*---------------------------------------------------------------------------
  403. X    APPEND_DIR:  append the path component to the path being built and check
  404. X    for its existence.  If doesn't exist and we are creating directories, do
  405. X    so for this one; else signal success or error as appropriate.
  406. X  ---------------------------------------------------------------------------*/
  407. X
  408. X    if (FUNCTION == APPEND_DIR) {
  409. X        int too_long = FALSE;
  410. X#ifdef SHORT_NAMES
  411. X        char *old_end = end;
  412. X#endif
  413. X
  414. X        Trace((stderr, "appending dir segment [%s]\n", pathcomp));
  415. X        while ((*end = *pathcomp++) != '\0')
  416. X            ++end;
  417. X#ifdef SHORT_NAMES   /* path components restricted to 14 chars, typically */
  418. X        if ((end-old_end) > FILENAME_MAX)  /* GRR:  proper constant? */
  419. X            *(end = old_end + FILENAME_MAX) = '\0';
  420. X#endif
  421. X
  422. X        /* GRR:  could do better check, see if overrunning buffer as we go:
  423. X         * check end-buildpath after each append, set warning variable if
  424. X         * within 20 of FILNAMSIZ; then if var set, do careful check when
  425. X         * appending.  Clear variable when begin new path. */
  426. X
  427. X        if ((end-buildpath) > FILNAMSIZ-3)  /* need ':', one-char name, '\0' */
  428. X            too_long = TRUE;                /* check if extracting directory? */
  429. X        if (stat(buildpath, &statbuf)) {    /* path doesn't exist */
  430. X            if (!create_dirs) {   /* told not to create (freshening) */
  431. X                free(buildpath);
  432. X                return 2;         /* path doesn't exist:  nothing to do */
  433. X            }
  434. X            if (too_long) {
  435. X                fprintf(stderr, "checkdir error:  path too long: %s\n",
  436. X                  buildpath);
  437. X                fflush(stderr);
  438. X                free(buildpath);
  439. X                return 4;         /* no room for filenames:  fatal */
  440. X            }
  441. X            if (MKDIR(buildpath) == -1) {   /* create the directory */
  442. X                fprintf(stderr, "checkdir error:  can't create %s\n\
  443. X                 unable to process %s.\n", buildpath, filename);
  444. X                fflush(stderr);
  445. X                free(buildpath);
  446. X                return 3;      /* path didn't exist, tried to create, failed */
  447. X            }
  448. X            created_dir = TRUE;
  449. X        } else if (!S_ISDIR(statbuf.st_mode)) {
  450. X            fprintf(stderr, "checkdir error:  %s exists but is not directory\n\
  451. X                 unable to process %s.\n", buildpath, filename);
  452. X            fflush(stderr);
  453. X            free(buildpath);
  454. X            return 3;          /* path existed but wasn't dir */
  455. X        }
  456. X        if (too_long) {
  457. X            fprintf(stderr, "checkdir error:  path too long: %s\n", buildpath);
  458. X            fflush(stderr);
  459. X            free(buildpath);
  460. X            return 4;         /* no room for filenames:  fatal */
  461. X        }
  462. X        *end++ = ':';
  463. X        *end = '\0';
  464. X        Trace((stderr, "buildpath now = [%s]\n", buildpath));
  465. X        return 0;
  466. X
  467. X    } /* end if (FUNCTION == APPEND_DIR) */
  468. X
  469. X/*---------------------------------------------------------------------------
  470. X    GETPATH:  copy full path to the string pointed at by pathcomp, and free
  471. X    buildpath.
  472. X  ---------------------------------------------------------------------------*/
  473. X
  474. X    if (FUNCTION == GETPATH) {
  475. X        strcpy(pathcomp, buildpath);
  476. X        Trace((stderr, "getting and freeing path [%s]\n", pathcomp));
  477. X        free(buildpath);
  478. X        buildpath = end = NULL;
  479. X        return 0;
  480. X    }
  481. X
  482. X/*---------------------------------------------------------------------------
  483. X    APPEND_NAME:  assume the path component is the filename; append it and
  484. X    return without checking for existence.
  485. X  ---------------------------------------------------------------------------*/
  486. X
  487. X    if (FUNCTION == APPEND_NAME) {
  488. X#ifdef SHORT_NAMES
  489. X        char *old_end = end;
  490. X#endif
  491. X
  492. X        Trace((stderr, "appending filename [%s]\n", pathcomp));
  493. X        while ((*end = *pathcomp++) != '\0') {
  494. X            ++end;
  495. X#ifdef SHORT_NAMES  /* truncate name at 14 characters, typically */
  496. X            if ((end-old_end) > FILENAME_MAX)      /* GRR:  proper constant? */
  497. X                *(end = old_end + FILENAME_MAX) = '\0';
  498. X#endif
  499. X            if ((end-buildpath) >= FILNAMSIZ) {
  500. X                *--end = '\0';
  501. X                fprintf(stderr, "checkdir warning:  path too long; truncating\n\
  502. Xcheckdir warning:  path too long; truncating\n\
  503. X                   %s\n                -> %s\n", filename, buildpath);
  504. X                fflush(stderr);
  505. X                return 1;   /* filename truncated */
  506. X            }
  507. X        }
  508. X        Trace((stderr, "buildpath now = [%s]\n", buildpath));
  509. X        return 0;  /* could check for existence here, prompt for new name... */
  510. X    }
  511. X
  512. X/*---------------------------------------------------------------------------
  513. X    INIT:  allocate and initialize buffer space for the file currently being
  514. X    extracted.  If file was renamed with an absolute path, don't prepend the
  515. X    extract-to path.
  516. X  ---------------------------------------------------------------------------*/
  517. X
  518. X    if (FUNCTION == INIT) {
  519. X        Trace((stderr, "initializing buildpath to "));
  520. X        if ((buildpath = (char *)malloc(strlen(filename)+rootlen+2)) == NULL)
  521. X            return 10;
  522. X        if ((rootlen > 0) && !renamed_fullpath) {
  523. X            strcpy(buildpath, rootpath);
  524. X            end = buildpath + rootlen;
  525. X        } else {
  526. X            *buildpath = '\0';
  527. X            end = buildpath;
  528. X        }
  529. X        Trace((stderr, "[%s]\n", buildpath));
  530. X        return 0;
  531. X    }
  532. X
  533. X/*---------------------------------------------------------------------------
  534. X    ROOT:  if appropriate, store the path in rootpath and create it if neces-
  535. X    sary; else assume it's a zipfile member and return.  This path segment
  536. X    gets used in extracting all members from every zipfile specified on the
  537. X    command line.
  538. X  ---------------------------------------------------------------------------*/
  539. X
  540. X#if (!defined(SFX) || defined(SFX_EXDIR))
  541. X    if (FUNCTION == ROOT) {
  542. X        Trace((stderr, "initializing root path to [%s]\n", pathcomp));
  543. X        if (pathcomp == NULL) {
  544. X            rootlen = 0;
  545. X            return 0;
  546. X        }
  547. X        if ((rootlen = strlen(pathcomp)) > 0) {
  548. X            int had_trailing_pathsep=FALSE;
  549. X
  550. X            if (pathcomp[rootlen-1] == ':') {
  551. X                pathcomp[--rootlen] = '\0';
  552. X                had_trailing_pathsep = TRUE;
  553. X            }
  554. X            if (rootlen > 0 && (stat(pathcomp, &statbuf) ||
  555. X                !S_ISDIR(statbuf.st_mode)))          /* path does not exist */
  556. X            {
  557. X                if (!create_dirs                     /* || iswild(pathcomp) */
  558. X#ifdef OLD_EXDIR
  559. X                                 || !had_trailing_pathsep
  560. X#endif
  561. X                                                         ) {
  562. X                    rootlen = 0;
  563. X                    return 2;   /* treat as stored file */
  564. X                }
  565. X                /* create the directory (could add loop here to scan pathcomp
  566. X                 * and create more than one level, but why really necessary?) */
  567. X                if (MKDIR(pathcomp) == -1) {
  568. X                    fprintf(stderr,
  569. X                      "checkdir:  can't create extraction directory: %s\n",
  570. X                      pathcomp);
  571. X                    fflush(stderr);
  572. X                    rootlen = 0;   /* path didn't exist, tried to create, and */
  573. X                    return 3;  /* failed:  file exists, or 2+ levels required */
  574. X                }
  575. X            }
  576. X            if ((rootpath = (char *)malloc(rootlen+2)) == NULL) {
  577. X                rootlen = 0;
  578. X                return 10;
  579. X            }
  580. X            strcpy(rootpath, pathcomp);
  581. X            rootpath[rootlen++] = ':';
  582. X            rootpath[rootlen] = '\0';
  583. X        }
  584. X        Trace((stderr, "rootpath now = [%s]\n", rootpath));
  585. X        return 0;
  586. X    }
  587. X#endif /* !SFX || SFX_EXDIR */
  588. X
  589. X/*---------------------------------------------------------------------------
  590. X    END:  free rootpath, immediately prior to program exit.
  591. X  ---------------------------------------------------------------------------*/
  592. X
  593. X    if (FUNCTION == END) {
  594. X        Trace((stderr, "freeing rootpath\n"));
  595. X        if (rootlen > 0)
  596. X            free(rootpath);
  597. X        return 0;
  598. X    }
  599. X
  600. X    return 99;  /* should never reach */
  601. X
  602. X} /* end function checkdir() */
  603. X
  604. X
  605. X
  606. X
  607. X
  608. X/****************************/
  609. X/* Function close_outfile() */
  610. X/****************************/
  611. X
  612. Xvoid close_outfile()
  613. X{
  614. X    long m_time;
  615. X    DateTimeRec dtr;
  616. X    ParamBlockRec pbr;
  617. X    HParamBlockRec hpbr;
  618. X    OSErr err;
  619. X
  620. X
  621. X    if (fileno(outfile) == 1)   /* don't attempt to close or set time on stdout */
  622. X        return;
  623. X
  624. X    fclose(outfile);
  625. X
  626. X    /*
  627. X     * Macintosh bases all file modification times on the number of seconds
  628. X     * elapsed since Jan 1, 1904, 00:00:00.  Therefore, to maintain
  629. X     * compatibility with MS-DOS archives, which date from Jan 1, 1980,
  630. X     * with NO relation to GMT, the following conversions must be made:
  631. X     *      the Year (yr) must be incremented by 1980;
  632. X     *      and converted to seconds using the Mac routine Date2Secs(),
  633. X     *      almost similar in complexity to the Unix version :-)
  634. X     *                                     J. Lee
  635. X     */
  636. X
  637. X    dtr.year = (((lrec.last_mod_file_date >> 9) & 0x7f) + 1980);
  638. X    dtr.month = ((lrec.last_mod_file_date >> 5) & 0x0f);
  639. X    dtr.day = (lrec.last_mod_file_date & 0x1f);
  640. X
  641. X    dtr.hour = ((lrec.last_mod_file_time >> 11) & 0x1f);
  642. X    dtr.minute = ((lrec.last_mod_file_time >> 5) & 0x3f);
  643. X    dtr.second = ((lrec.last_mod_file_time & 0x1f) * 2);
  644. X
  645. X    Date2Secs(&dtr, (unsigned long *)&m_time);
  646. X    c2pstr(filename);
  647. X    if (HFSFlag) {
  648. X        hpbr.fileParam.ioNamePtr = (StringPtr)filename;
  649. X        hpbr.fileParam.ioVRefNum = gnVRefNum;
  650. X        hpbr.fileParam.ioDirID = glDirID;
  651. X        hpbr.fileParam.ioFDirIndex = 0;
  652. X        err = PBHGetFInfo(&hpbr, 0L);
  653. X        hpbr.fileParam.ioFlMdDat = m_time;
  654. X        if ( !fMacZipped )
  655. X            hpbr.fileParam.ioFlCrDat = m_time;
  656. X        hpbr.fileParam.ioDirID = glDirID;
  657. X        if (err == noErr)
  658. X            err = PBHSetFInfo(&hpbr, 0L);
  659. X        if (err != noErr)
  660. X            printf("error:  can't set the time for %s\n", filename);
  661. X    } else {
  662. X        pbr.fileParam.ioNamePtr = (StringPtr)filename;
  663. X        pbr.fileParam.ioVRefNum = pbr.fileParam.ioFVersNum =
  664. X          pbr.fileParam.ioFDirIndex = 0;
  665. X        err = PBGetFInfo(&pbr, 0L);
  666. X        pbr.fileParam.ioFlMdDat = pbr.fileParam.ioFlCrDat = m_time;
  667. X        if (err == noErr)
  668. X            err = PBSetFInfo(&pbr, 0L);
  669. X        if (err != noErr)
  670. X            printf("error:  can't set the time for %s\n", filename);
  671. X    }
  672. X
  673. X    /* set read-only perms if needed */
  674. X    if ((err == noErr) && pInfo->read_only) {
  675. X        if (HFSFlag) {
  676. X            hpbr.fileParam.ioNamePtr = (StringPtr)filename;
  677. X            hpbr.fileParam.ioVRefNum = gnVRefNum;
  678. X            hpbr.fileParam.ioDirID = glDirID;
  679. X            err = PBHSetFLock(&hpbr, 0);
  680. X        } else
  681. X            err = SetFLock((ConstStr255Param)filename, 0);
  682. X    }
  683. X    p2cstr(filename);
  684. X
  685. X} /* end function close_outfile() */
  686. X
  687. X
  688. X
  689. X
  690. X
  691. X#ifndef SFX
  692. X
  693. X/************************/
  694. X/*  Function version()  */
  695. X/************************/
  696. X
  697. Xvoid version()
  698. X{
  699. X    extern char Far  CompiledWith[];
  700. X#if 0
  701. X    char buf[40];
  702. X#endif
  703. X
  704. X    printf(LoadFarString(CompiledWith),
  705. X
  706. X#ifdef __GNUC__
  707. X      "gcc ", __VERSION__,
  708. X#else
  709. X#  if 0
  710. X      "cc ", (sprintf(buf, " version %d", _RELEASE), buf),
  711. X#  else
  712. X#  ifdef THINK_C
  713. X      "Think C", "",
  714. X#  else
  715. X#  ifdef MPW
  716. X      "MPW C", "",
  717. X#  else
  718. X      "unknown compiler", "",
  719. X#  endif
  720. X#  endif
  721. X#  endif
  722. X#endif
  723. X
  724. X      "MacOS",
  725. X
  726. X#if defined(foobar) || defined(FOOBAR)
  727. X      " (Foo BAR)",    /* hardware or OS version */
  728. X#else
  729. X      "",
  730. X#endif /* Foo BAR */
  731. X
  732. X#ifdef __DATE__
  733. X      " on ", __DATE__
  734. X#else
  735. X      "", ""
  736. X#endif
  737. X      );
  738. X
  739. X} /* end function version() */
  740. X
  741. X#endif /* !SFX */
  742. X
  743. X
  744. X
  745. X
  746. X
  747. X/************************/
  748. X/* Function IsHFSDisk() */
  749. X/************************/
  750. X
  751. Xstatic int IsHFSDisk(short wRefNum)
  752. X{
  753. X    /* get info about the specified volume */
  754. X    if (HFSFlag == true) {
  755. X        HParamBlockRec    hpbr;
  756. X        Str255 temp;
  757. X        short wErr;
  758. X
  759. X        hpbr.volumeParam.ioCompletion = 0;
  760. X        hpbr.volumeParam.ioNamePtr = temp;
  761. X        hpbr.volumeParam.ioVRefNum = wRefNum;
  762. X        hpbr.volumeParam.ioVolIndex = 0;
  763. X        wErr = PBHGetVInfo(&hpbr, 0);
  764. X
  765. X        if (wErr == noErr && hpbr.volumeParam.ioVFSID == 0
  766. X            && hpbr.volumeParam.ioVSigWord == 0x4244) {
  767. X                return true;
  768. X        }
  769. X    }
  770. X
  771. X    return false;
  772. X} /* IsHFSDisk */
  773. X
  774. X
  775. X
  776. X
  777. X
  778. X/************************/
  779. X/* Function MacFSTest() */
  780. X/************************/
  781. X
  782. Xvoid MacFSTest(int vRefNum)
  783. X{
  784. X    Str255 st;
  785. X
  786. X    /* is this machine running HFS file system? */
  787. X    if (FSFCBLen <= 0) {
  788. X        HFSFlag = false;
  789. X    }
  790. X    else
  791. X    {
  792. X        HFSFlag = true;
  793. X    }
  794. X
  795. X    /* get the file's volume reference number and directory ID */
  796. X    if (HFSFlag == true) {
  797. X        WDPBRec    wdpb;
  798. X        OSErr err = noErr;
  799. X
  800. X        if (vRefNum != 0) {
  801. X            wdpb.ioCompletion = false;
  802. X            wdpb.ioNamePtr = st;
  803. X            wdpb.ioWDIndex = 0;
  804. X            wdpb.ioVRefNum = vRefNum;
  805. X            err = PBHGetVol(&wdpb, false);
  806. X
  807. X            if (err == noErr) {
  808. X                wAppVRefNum = wdpb.ioWDVRefNum;
  809. X                lAppDirID = wdpb.ioWDDirID;
  810. X            }
  811. X        }
  812. X
  813. X        /* is the disk we're using formatted for HFS? */
  814. X        HFSFlag = IsHFSDisk(wAppVRefNum);
  815. X    }
  816. X
  817. X    return;
  818. X} /* mactest */
  819. X
  820. X
  821. X
  822. X
  823. X
  824. X/***********************/
  825. X/* Function macmkdir() */
  826. X/***********************/
  827. X
  828. Xint macmkdir(char *path, short nVRefNum, long lDirID)
  829. X{
  830. X    OSErr    err = -1;
  831. X
  832. X    if (path != 0 && strlen(path)<256 && HFSFlag == true) {
  833. X        HParamBlockRec    hpbr;
  834. X        Str255    st;
  835. X
  836. X        c2pstr(path);
  837. X        if ((nVRefNum == 0) && (lDirID == 0))
  838. X        {
  839. X            hpbr.fileParam.ioNamePtr = st;
  840. X            hpbr.fileParam.ioCompletion = NULL;
  841. X            err = PBHGetVol((WDPBPtr)&hpbr, false);
  842. X            nVRefNum = hpbr.wdParam.ioWDVRefNum;
  843. X            lDirID = hpbr.wdParam.ioWDDirID;
  844. X        }
  845. X        else
  846. X        {
  847. X            err = noErr;
  848. X        }
  849. X        if (err == noErr) {
  850. X            hpbr.fileParam.ioCompletion = NULL;
  851. X            hpbr.fileParam.ioVRefNum = nVRefNum;
  852. X            hpbr.fileParam.ioDirID = lDirID;
  853. X            hpbr.fileParam.ioNamePtr = (StringPtr)path;
  854. X            err = PBDirCreate(&hpbr, false);
  855. X        }
  856. X        p2cstr(path);
  857. X    }
  858. X
  859. X    return (int)err;
  860. X} /* macmkdir */
  861. X
  862. X
  863. X
  864. X
  865. X
  866. X/****************************/
  867. X/* Function ResolveMacVol() */
  868. X/****************************/
  869. X
  870. Xvoid ResolveMacVol(short nVRefNum, short *pnVRefNum, long *plDirID, StringPtr pst)
  871. X{
  872. X    if (HFSFlag)
  873. X    {
  874. X        WDPBRec  wdpbr;
  875. X        Str255   st;
  876. X        OSErr    err;
  877. X
  878. X        wdpbr.ioCompletion = (ProcPtr)NULL;
  879. X        wdpbr.ioNamePtr = st;
  880. X        wdpbr.ioVRefNum = nVRefNum;
  881. X        wdpbr.ioWDIndex = 0;
  882. X        wdpbr.ioWDProcID = 0;
  883. X        wdpbr.ioWDVRefNum = 0;
  884. X        err = PBGetWDInfo( &wdpbr, false );
  885. X        if ( err == noErr )
  886. X        {
  887. X            if (pnVRefNum)
  888. X                *pnVRefNum = wdpbr.ioWDVRefNum;
  889. X            if (plDirID)
  890. X                *plDirID = wdpbr.ioWDDirID;
  891. X            if (pst)
  892. X                BlockMove( st, pst, st[0]+1 );
  893. X        }
  894. X    }
  895. X    else
  896. X    {
  897. X        if (pnVRefNum)
  898. X            *pnVRefNum = nVRefNum;
  899. X        if (plDirID)
  900. X            *plDirID = 0;
  901. X        if (pst)
  902. X            *pst = 0;
  903. X    }
  904. X}
  905. X
  906. X
  907. X
  908. X
  909. X
  910. X/**********************/
  911. X/* Function macopen() */
  912. X/**********************/
  913. X
  914. Xshort macopen(char *sz, short nFlags, short nVRefNum, long lDirID)
  915. X{
  916. X    OSErr   err;
  917. X    Str255  st;
  918. X    char    chPerms = (!nFlags) ? fsRdPerm : fsRdWrPerm;
  919. X    short   nFRefNum;
  920. X
  921. X    c2pstr( sz );
  922. X    BlockMove( sz, st, sz[0]+1 );
  923. X    p2cstr( sz );
  924. X    if (HFSFlag)
  925. X    {
  926. X        if (nFlags > 1)
  927. X            err = HOpenRF( nVRefNum, lDirID, st, chPerms, &nFRefNum);
  928. X        else
  929. X            err = HOpen( nVRefNum, lDirID, st, chPerms, &nFRefNum);
  930. X    }
  931. X    else
  932. X    {
  933. X        /*
  934. X         * Have to use PBxxx style calls since the high level
  935. X         * versions don't support specifying permissions
  936. X         */
  937. X        ParamBlockRec    pbr;
  938. X
  939. X        pbr.ioParam.ioNamePtr = st;
  940. X        pbr.ioParam.ioVRefNum = gnVRefNum;
  941. X        pbr.ioParam.ioVersNum = 0;
  942. X        pbr.ioParam.ioPermssn = chPerms;
  943. X        pbr.ioParam.ioMisc = 0;
  944. X        if (nFlags >1)
  945. X            err = PBOpenRF( &pbr, false );
  946. X        else
  947. X            err = PBOpen( &pbr, false );
  948. X        nFRefNum = pbr.ioParam.ioRefNum;
  949. X    }
  950. X    if ( err || (nFRefNum == 1) )
  951. X        return -1;
  952. X    else {
  953. X        if ( nFlags )
  954. X            SetEOF( nFRefNum, 0 );
  955. X        return nFRefNum;
  956. X    }
  957. X}
  958. X
  959. X
  960. X
  961. X
  962. X
  963. X/***********************/
  964. X/* Function macfopen() */
  965. X/***********************/
  966. X
  967. XFILE *macfopen(char *filename, char *mode, short nVRefNum, long lDirID)
  968. X    {
  969. X        short outfd, fDataFork=TRUE;
  970. X        MACINFO mi;
  971. X        OSErr err;
  972. X
  973. X        fMacZipped = FALSE;
  974. X        c2pstr(filename);
  975. X        if (extra_field &&
  976. X            (lrec.extra_field_length > sizeof(MACINFOMIN)) &&
  977. X            (lrec.extra_field_length <= sizeof(MACINFO))) {
  978. X            BlockMove(extra_field, &mi, lrec.extra_field_length);
  979. X            if ((makeword((uch *)&mi.header) == 1992) &&
  980. X                (makeword((uch *)&mi.data) ==
  981. X                    lrec.extra_field_length-sizeof(ZIP_EXTRA_HEADER)) &&
  982. X                (mi.signature == 'JLEE')) {
  983. X                gostCreator = mi.finfo.fdCreator;
  984. X                gostType = mi.finfo.fdType;
  985. X                fDataFork = (mi.flags & 1) ? TRUE : FALSE;
  986. X                fMacZipped = true;
  987. X                /* If it was Zipped w/Mac version, the filename has either */
  988. X                /* a 'd' or 'r' appended.  Remove the d/r when unzipping */
  989. X                filename[0]-=1;
  990. X            }
  991. X        }
  992. X        if (!fMacZipped) {
  993. X            if (!aflag)
  994. X                gostType = gostCreator = '\?\?\?\?';
  995. X            else {
  996. X                gostCreator = CREATOR;
  997. X                gostType = 'TEXT';
  998. X            }
  999. X        }
  1000. X        p2cstr(filename);
  1001. X
  1002. X        if ((outfd = creat(filename, 0)) != -1) {
  1003. X            if (fMacZipped) {
  1004. X                c2pstr(filename);
  1005. X                if (HFSFlag) {
  1006. X                    HParamBlockRec   hpbr;
  1007. X
  1008. X                    hpbr.fileParam.ioNamePtr = (StringPtr)filename;
  1009. X                    hpbr.fileParam.ioVRefNum = gnVRefNum;
  1010. X                    hpbr.fileParam.ioDirID = glDirID;
  1011. X                    hpbr.fileParam.ioFlFndrInfo = mi.finfo;
  1012. X                    hpbr.fileParam.ioFlCrDat = mi.lCrDat;
  1013. X                    hpbr.fileParam.ioFlMdDat = mi.lMdDat;
  1014. X                    err = PBHSetFInfo(&hpbr, 0);
  1015. X                } else {
  1016. X                    err = SetFInfo((StringPtr)filename , 0, &mi.finfo);
  1017. X                }
  1018. X                p2cstr(filename);
  1019. X            }
  1020. X            outfd = open(filename, (fDataFork) ? 1 : 2);
  1021. X        }
  1022. X
  1023. X        if (outfd == -1)
  1024. X            return NULL;
  1025. X        else
  1026. X            return (FILE *)outfd;
  1027. X    }
  1028. X
  1029. X
  1030. X
  1031. X
  1032. X
  1033. X/***********************/
  1034. X/* Function maccreat() */
  1035. X/***********************/
  1036. X
  1037. Xshort maccreat(char *sz, short nVRefNum, long lDirID, OSType ostCreator, OSType ostType)
  1038. X{
  1039. X    OSErr   err;
  1040. X    Str255  st;
  1041. X    FInfo   fi;
  1042. X
  1043. X    c2pstr( sz );
  1044. X    BlockMove( sz, st, sz[0]+1 );
  1045. X    p2cstr( sz );
  1046. X    if (HFSFlag)
  1047. X    {
  1048. X        err = HGetFInfo( nVRefNum, lDirID, st, &fi );
  1049. X        if (err == fnfErr)
  1050. X            err = HCreate( nVRefNum, lDirID, st, ostCreator, ostType );
  1051. X        else if (err == noErr)
  1052. X        {
  1053. X            fi.fdCreator = ostCreator;
  1054. X            fi.fdType = ostType;
  1055. X            err = HSetFInfo( nVRefNum, lDirID, st, &fi );
  1056. X        }
  1057. X    }
  1058. X    else
  1059. X    {
  1060. X        err = GetFInfo( st, nVRefNum, &fi );
  1061. X        if (err == fnfErr)
  1062. X            err = Create( st, nVRefNum, ostCreator, ostType );
  1063. X        else if (err == noErr)
  1064. X        {
  1065. X            fi.fdCreator = ostCreator;
  1066. X            fi.fdType = ostType;
  1067. X            err = SetFInfo( st, nVRefNum, &fi );
  1068. X        }
  1069. X    }
  1070. X    if (err == noErr)
  1071. X        return noErr;
  1072. X    else
  1073. X        return -1;
  1074. X}
  1075. X
  1076. X
  1077. X
  1078. X
  1079. X
  1080. X/**********************/
  1081. X/* Function macread() */
  1082. X/**********************/
  1083. X
  1084. Xshort macread(short nFRefNum, char *pb, unsigned cb)
  1085. X{
  1086. X    long    lcb = cb;
  1087. X
  1088. X    (void)FSRead( nFRefNum, &lcb, pb );
  1089. X
  1090. X    return (short)lcb;
  1091. X}
  1092. X
  1093. X
  1094. X
  1095. X
  1096. X
  1097. X/***********************/
  1098. X/* Function macwrite() */
  1099. X/***********************/
  1100. X
  1101. Xlong macwrite(short nFRefNum, char *pb, unsigned cb)
  1102. X{
  1103. X    long    lcb = cb;
  1104. X
  1105. X#ifdef THINK_C
  1106. X    if ( (nFRefNum == 1) )
  1107. X        screenDump( pb, lcb );
  1108. X    else
  1109. X#endif
  1110. X        (void)FSWrite( nFRefNum, &lcb, pb );
  1111. X
  1112. X    return (long)lcb;
  1113. X}
  1114. X
  1115. X
  1116. X
  1117. X
  1118. X
  1119. X/***********************/
  1120. X/* Function macclose() */
  1121. X/***********************/
  1122. X
  1123. Xshort macclose(short nFRefNum)
  1124. X{
  1125. X    return FSClose( nFRefNum );
  1126. X}
  1127. X
  1128. X
  1129. X
  1130. X
  1131. X
  1132. X/***********************/
  1133. X/* Function maclseek() */
  1134. X/***********************/
  1135. X
  1136. Xlong maclseek(short nFRefNum, long lib, short nMode)
  1137. X{
  1138. X    ParamBlockRec   pbr;
  1139. X
  1140. X    if (nMode == SEEK_SET)
  1141. X        nMode = fsFromStart;
  1142. X    else if (nMode == SEEK_CUR)
  1143. X        nMode = fsFromMark;
  1144. X    else if (nMode == SEEK_END)
  1145. X        nMode = fsFromLEOF;
  1146. X    pbr.ioParam.ioRefNum = nFRefNum;
  1147. X    pbr.ioParam.ioPosMode = nMode;
  1148. X    pbr.ioParam.ioPosOffset = lib;
  1149. X    (void)PBSetFPos(&pbr, 0);
  1150. X    return pbr.ioParam.ioPosOffset;
  1151. X}
  1152. X
  1153. X#endif /* MACOS */
  1154. END_OF_FILE
  1155.   if test 31814 -ne `wc -c <'unzip-5.12/mac/mac.c'`; then
  1156.     echo shar: \"'unzip-5.12/mac/mac.c'\" unpacked with wrong size!
  1157.   fi
  1158.   # end of 'unzip-5.12/mac/mac.c'
  1159. fi
  1160. if test -f 'unzip-5.12/unzip.doc' -a "${1}" != "-c" ; then 
  1161.   echo shar: Will not clobber existing file \"'unzip-5.12/unzip.doc'\"
  1162. else
  1163.   echo shar: Extracting \"'unzip-5.12/unzip.doc'\" \(33336 characters\)
  1164.   sed "s/^X//" >'unzip-5.12/unzip.doc' <<'END_OF_FILE'
  1165. X
  1166. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1167. X
  1168. XNAME
  1169. X     unzip - list, test and extract compressed  files  in  a  ZIP
  1170. X     archive
  1171. X
  1172. XSYNOPSIS
  1173. X     unzip [-Z] [-cflptuvz[abjnoqsCLV$]] file[.zip] [file(s) ...]
  1174. X     [-x xfile(s) ...] [-d exdir]
  1175. X
  1176. XDESCRIPTION
  1177. X     unzip will list, test, or extract files from a ZIP  archive,
  1178. X     commonly  found  on  MS-DOS  systems.   The default behavior
  1179. X     (with no options) is to extract into the  current  directory
  1180. X     (and  subdirectories  below it) all files from the specified
  1181. X     ZIP archive.  A  companion  program,  zip(1L),  creates  ZIP
  1182. X     archives; both programs are compatible with archives created
  1183. X     by PKWARE's PKZIP and PKUNZIP for MS-DOS, but in many  cases
  1184. X     the program options or default behaviors differ.
  1185. X
  1186. XARGUMENTS
  1187. X     file[.zip]
  1188. X          Path of the ZIP archive(s).  If the file  specification
  1189. X          is  a  wildcard,  each matching file is processed in an
  1190. X          order determined by the operating system (or file  sys-
  1191. X          tem).   Only  the  filename can be a wildcard; the path
  1192. X          itself cannot.  Wildcard  expressions  are  similar  to
  1193. X          Unix egrep(1) (regular) expressions and may contain:
  1194. X
  1195. X          *    matches a sequence of 0 or more characters
  1196. X
  1197. X          ?    matches exactly 1 character
  1198. X
  1199. X          [...]
  1200. X               matches any  single  character  found  inside  the
  1201. X               brackets;  ranges  are  specified  by  a beginning
  1202. X               character, a hyphen, and an ending character.   If
  1203. X               an  exclamation point or a caret (`!' or `^') fol-
  1204. X               lows the left bracket, then the range  of  charac-
  1205. X               ters within the brackets is complemented (that is,
  1206. X               anything except the characters inside the brackets
  1207. X               is considered a match).
  1208. X
  1209. X          (Be sure to quote any character which  might  otherwise
  1210. X          be  interpreted  or  modified  by the operating system,
  1211. X          particularly under Unix and VMS.)  If  no  matches  are
  1212. X          found,  the  specification  is  assumed to be a literal
  1213. X          filename; and if that also fails, the  suffix  .zip  is
  1214. X          appended.  Note that self-extracting ZIP files are sup-
  1215. X          ported, as with any other ZIP archive; just specify the
  1216. X          .exe suffix (if any) explicitly.
  1217. X
  1218. X     [file(s)]
  1219. X          An optional list of archive members  to  be  processed,
  1220. X
  1221. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 1
  1222. X
  1223. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1224. X
  1225. X          separated  by  spaces.   (VMS  versions  compiled  with
  1226. X          VMSCLI defined must delimit files with commas  instead.
  1227. X          See  -v  in  OPTIONS below.) Regular expressions (wild-
  1228. X          cards) may be  used  to  match  multiple  members;  see
  1229. X          above.   Again, be sure to quote expressions that would
  1230. X          otherwise be expanded or modified by the operating sys-
  1231. X          tem.
  1232. X
  1233. X     [-x xfile(s)]
  1234. X          An optional list of archive members to be excluded from
  1235. X          processing.   Since wildcard characters match directory
  1236. X          separators (`/'), this option may be  used  to  exclude
  1237. X          any  files  which  are in subdirectories.  For example,
  1238. X          ``unzip foo *.[ch] -x */*'' would extract all C  source
  1239. X          files  in the main directory, but none in any subdirec-
  1240. X          tories.  Without the -x option, all C source  files  in
  1241. X          all directories within the zipfile would be extracted.
  1242. X
  1243. X     [-d exdir]
  1244. X          An optional directory to which to  extract  files.   By
  1245. X          default,  all files and subdirectories are recreated in
  1246. X          the current directory; the -d option allows  extraction
  1247. X          in an arbitrary directory (always assuming one has per-
  1248. X          mission to write to the directory).  This  option  need
  1249. X          not  appear  at the end of the command line; it is also
  1250. X          accepted immediately after the  zipfile  specification,
  1251. X          or  between  the file(s) and the -x option.  The option
  1252. X          and directory may be  concatenated  without  any  white
  1253. X          space between them, but note that this may cause normal
  1254. X          shell  behavior  to  be  suppressed.   In   particular,
  1255. X          ``-d ~''  (tilde) is expanded by Unix C shells into the
  1256. X          name of the  user's  home  directory,  but  ``-d~''  is
  1257. X          treated  as a literal subdirectory ``~'' of the current
  1258. X          directory.
  1259. X
  1260. XOPTIONS
  1261. X     Note that, in order to support obsolescent hardware, unzip's
  1262. X     usage  screen is limited to 22 or 23 lines and should there-
  1263. X     fore be considered a reminder  of  the  basic  unzip  syntax
  1264. X     rather than an exhaustive list of all possible flags.
  1265. X
  1266. X     -Z   zipinfo(1L) mode.  If the first option on  the  command
  1267. X          line  is  -Z,  the  remaining  options  are taken to be
  1268. X          zipinfo(1L) options.  See the appropriate  manual  page
  1269. X          for a description of these options.
  1270. X
  1271. X     -c   extract files to stdout/screen (``CRT'').  This  option
  1272. X          is  similar  to  the  -p option except that the name of
  1273. X          each file is printed as it is extracted, the -a  option
  1274. X          is  allowed,  and  ASCII-EBCDIC conversion is automati-
  1275. X          cally performed if appropriate.   This  option  is  not
  1276. X          listed in the unzip usage screen.
  1277. X
  1278. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 2
  1279. X
  1280. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1281. X
  1282. X     -f   freshen existing files, i.e., extract only those  files
  1283. X          which  already  exist  on disk and which are newer than
  1284. X          the disk  copies.   By  default  unzip  queries  before
  1285. X          overwriting,  but the -o option may be used to suppress
  1286. X          the queries.  Note that under many  operating  systems,
  1287. X          the  TZ  (timezone)  environment  variable  must be set
  1288. X          correctly in order for  -f  and  -u  to  work  properly
  1289. X          (under Unix the variable is usually set automatically).
  1290. X          The reasons for this are somewhat subtle but have to do
  1291. X          with  the  differences  between  DOS-format  file times
  1292. X          (always local time) and Unix-format  times  (always  in
  1293. X          GMT)  and  the necessity to compare the two.  A typical
  1294. X          TZ value is ``PST8PDT'' (US Pacific time with automatic
  1295. X          adjustment   for  Daylight  Savings  Time  or  ``summer
  1296. X          time'').
  1297. X
  1298. X     -l   list  archive  files  (short   format).    The   names,
  1299. X          uncompressed  file  sizes  and  modification  dates and
  1300. X          times of the specified files are  printed,  along  with
  1301. X          totals  for all files specified.  In addition, the zip-
  1302. X          file comment and individual file comments (if any)  are
  1303. X          displayed.   If  a file was archived from a single-case
  1304. X          file system (for example, the old MS-DOS FAT file  sys-
  1305. X          tem)  and the -L option was given, the filename is con-
  1306. X          verted to lowercase and is prefixed with a caret (^).
  1307. X
  1308. X     -p   extract files to pipe (stdout).  Nothing but  the  file
  1309. X          data  is  sent  to  stdout,  and  the  files are always
  1310. X          extracted in binary format, just as they are stored (no
  1311. X          conversions).
  1312. X
  1313. X     -t   test archive files.  This option extracts  each  speci-
  1314. X          fied file in memory and compares the CRC (cyclic redun-
  1315. X          dancy check, an enhanced checksum) of the expanded file
  1316. X          with the original file's stored CRC value.
  1317. X
  1318. X     -u   update existing files and create new  ones  if  needed.
  1319. X          This  option  performs  the  same  function  as  the -f
  1320. X          option, extracting (with query) files which  are  newer
  1321. X          than  those with the same name on disk, and in addition
  1322. X          it extracts those files which do not already  exist  on
  1323. X          disk.   See  -f  above  for  information on setting the
  1324. X          timezone properly.
  1325. X
  1326. X     -v   be verbose or  print  diagnostic  version  info.   This
  1327. X          option  has  evolved  and now behaves as both an option
  1328. X          and a modifier.  As an  option  it  has  two  purposes:
  1329. X          when  a  zipfile is specified with no other options, -v
  1330. X          lists archive files verbosely, adding to  the  -l  info
  1331. X          the  compression  method,  compressed size, compression
  1332. X          ratio and 32-bit CRC.  When  no  zipfile  is  specified
  1333. X          (that is, the complete command is simply ``unzip -v''),
  1334. X
  1335. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 3
  1336. X
  1337. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1338. X
  1339. X          a diagnostic screen is printed.   In  addition  to  the
  1340. X          normal  header  with  release  date  and version, unzip
  1341. X          lists the home Info-ZIP ftp site and where  to  find  a
  1342. X          list of other ftp and non-ftp sites; the target operat-
  1343. X          ing system for which it was compiled, as well as  (pos-
  1344. X          sibly)  the hardware on which it was compiled, the com-
  1345. X          piler and version used, and the compilation  date;  any
  1346. X          special  compilation  options  which  might  affect the
  1347. X          program's operation (see also  DECRYPTION  below);  and
  1348. X          any options stored in environment variables which might
  1349. X          do the same (see  ENVIRONMENT  OPTIONS  below).   As  a
  1350. X          modifier  it  works  in  conjunction with other options
  1351. X          (e.g., -t) to produce more verbose or debugging output;
  1352. X          this is not yet fully implemented but will be in future
  1353. X          releases.
  1354. X
  1355. X     -z   display only the archive comment.
  1356. X
  1357. XMODIFIERS
  1358. X     -a   convert text files.  Ordinarily all files are extracted
  1359. X          exactly  as they are stored (as ``binary'' files).  The
  1360. X          -a option causes files identified by zip as text  files
  1361. X          (those  with  the `t' label in zipinfo listings, rather
  1362. X          than `b') to be automatically extracted as  such,  con-
  1363. X          verting  line  endings,  end-of-file characters and the
  1364. X          character set itself as necessary.  (For example,  Unix
  1365. X          files  use  line  feeds (LFs) for end-of-line (EOL) and
  1366. X          have no end-of-file (EOF) marker; Macintoshes use  car-
  1367. X          riage  returns  (CRs)  for  EOLs; and most PC operating
  1368. X          systems use CR+LF for EOLs and control-Z for  EOF.   In
  1369. X          addition, IBM mainframes and the Michigan Terminal Sys-
  1370. X          tem use EBCDIC rather than the more common ASCII  char-
  1371. X          acter  set,  and  NT supports Unicode.) Note that zip's
  1372. X          identification of text files is by  no  means  perfect;
  1373. X          some  ``text''  files  may  actually be binary and vice
  1374. X          versa.    unzip   therefore   prints   ``[text]''    or
  1375. X          ``[binary]''  as  a  visual  check  for  each  file  it
  1376. X          extracts when using the  -a  option.   The  -aa  option
  1377. X          forces all files to be extracted as text, regardless of
  1378. X          the supposed file type.
  1379. X
  1380. X     -b   treat all files as binary (no text conversions).   This
  1381. X          is a shortcut for ---a.
  1382. X
  1383. X     -C   match filenames case-insensitively.  unzip's philosophy
  1384. X          is ``you get what you ask for'' (this is also responsi-
  1385. X          ble for the -L/-U  change;  see  the  relevant  options
  1386. X          below).   Because  some  filesystems  are  fully  case-
  1387. X          sensitive (notably those under the Unix operating  sys-
  1388. X          tem) and because both ZIP archives and unzip itself are
  1389. X          portable across platforms, unzip's default behavior  is
  1390. X          to  match  both  wildcard  and  literal filenames case-
  1391. X
  1392. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 4
  1393. X
  1394. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1395. X
  1396. X          sensitively.  That is, specifying ``makefile''  on  the
  1397. X          command  line  will  only  match  ``makefile''  in  the
  1398. X          archive, not ``Makefile'' or  ``MAKEFILE''  (and  simi-
  1399. X          larly  for  wildcard  specifications).  Since this does
  1400. X          not  correspond  to  the   behavior   of   many   other
  1401. X          operating/file  systems  (for  example, OS/2 HPFS which
  1402. X          preserves mixed case but is not sensitive to  it),  the
  1403. X          -C  option may be used to force all filename matches to
  1404. X          be case-insensitive.  In the example above,  all  three
  1405. X          files  would  then match ``makefile'' (or ``make*'', or
  1406. X          similar).  The -C option affects files in both the nor-
  1407. X          mal file list and the excluded-file list (xlist).
  1408. X
  1409. X     -j   junk paths.  The archive's directory structure  is  not
  1410. X          recreated;  all  files  are deposited in the extraction
  1411. X          directory (by default, the current one).
  1412. X
  1413. X     -L   convert to lowercase any  filename  originating  on  an
  1414. X          uppercase-only  operating  system or filesystem.  (This
  1415. X          was unzip's default behavior in releases prior to 5.11;
  1416. X          the  new  default  behavior  is  identical  to  the old
  1417. X          behavior with the -U option, which is now obsolete  and
  1418. X          will be removed in a future release.)  Depending on the
  1419. X          archiver, files archived under single-case  filesystems
  1420. X          (VMS,  old  MS-DOS  FAT,  etc.)  may  be stored as all-
  1421. X          uppercase names; this can be ugly or inconvenient  when
  1422. X          extracting to a case-preserving filesystem such as OS/2
  1423. X          HPFS or a case-sensitive one such as  under  Unix.   By
  1424. X          default unzip lists and extracts such filenames exactly
  1425. X          as they're stored (excepting truncation, conversion  of
  1426. X          unsupported  characters,  etc.); this option causes the
  1427. X          names of all files from certain systems to be converted
  1428. X          to lowercase.
  1429. X
  1430. X     -n   never overwrite existing  files.   If  a  file  already
  1431. X          exists,  skip  the  extraction  of  that  file  without
  1432. X          prompting.  By default unzip queries before  extracting
  1433. X          any  file  which already exists; the user may choose to
  1434. X          overwrite only the current file, overwrite  all  files,
  1435. X          skip extraction of the current file, skip extraction of
  1436. X          all existing files, or rename the current file.
  1437. X
  1438. X     -o   overwrite existing files without prompting.  This is  a
  1439. X          dangerous  option,  so  use it with care.  (It is often
  1440. X          used with -f, however.)
  1441. X
  1442. X     -q   perform operations quietly (-qq = even quieter).  Ordi-
  1443. X          narily  unzip  prints  the  names  of  the  files  it's
  1444. X          extracting or testing, the extraction methods, any file
  1445. X          or zipfile comments which may be stored in the archive,
  1446. X          and possibly a summary when finished with each archive.
  1447. X          The  -q[q] options suppress the printing of some or all
  1448. X
  1449. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 5
  1450. X
  1451. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1452. X
  1453. X          of these messages.
  1454. X
  1455. X     -s   [OS/2, NT,  MS-DOS]  convert  spaces  in  filenames  to
  1456. X          underscores.   Since  all  PC  operating  systems allow
  1457. X          spaces  in  filenames,  unzip   by   default   extracts
  1458. X          filenames  with  spaces intact (e.g., ``EA DATA. SF'').
  1459. X          This can be awkward, however, since MS-DOS in  particu-
  1460. X          lar  does  not  gracefully support spaces in filenames.
  1461. X          Conversion of spaces to underscores can  eliminate  the
  1462. X          awkwardness in some cases.
  1463. X
  1464. X     -U   (obsolete; to be removed in  a  future  release)  leave
  1465. X          filenames  uppercase if created under MS-DOS, VMS, etc.
  1466. X          See -L above.
  1467. X
  1468. X     -V   retain (VMS) file version numbers.  VMS  files  can  be
  1469. X          stored   with   a   version   number,   in  the  format
  1470. X          file.ext;##.  By default the  ``;##''  version  numbers
  1471. X          are  stripped,  but  this  option  allows  them  to  be
  1472. X          retained.  (On filesystems  which  limit  filenames  to
  1473. X          particularly  short lengths, the version numbers may be
  1474. X          truncated or stripped regardless of this option.)
  1475. X
  1476. X     -X   [VMS] restore owner/protection info (may require system
  1477. X          privileges).    Ordinary  file  attributes  are  always
  1478. X          restored, but this option allows UICs to be restored as
  1479. X          well.   [The  next  version  of unzip will support Unix
  1480. X          UID/GID info as well, and possibly NT permissions.]
  1481. X
  1482. X     -$   [MS-DOS, OS/2, NT, Amiga] restore the volume  label  if
  1483. X          the  extraction medium is removable (e.g., a diskette).
  1484. X          Doubling the option  (-$$)  allows  fixed  media  (hard
  1485. X          disks)  to  be  labelled  as  well.  By default, volume
  1486. X          labels are ignored.
  1487. X
  1488. XENVIRONMENT OPTIONS
  1489. X     unzip's default behavior may be modified via options  placed
  1490. X     in  an  environment  variable.   This  can  be done with any
  1491. X     option, but it is probably most useful with the -a, -L,  -C,
  1492. X     -q, -o, or -n modifiers:  make unzip auto-convert text files
  1493. X     by default, make it convert filenames from uppercase systems
  1494. X     to  lowercase,  make it match names case-insensitively, make
  1495. X     it quieter, or make it always overwrite or  never  overwrite
  1496. X     files  as  it extracts them.  For example, to make unzip act
  1497. X     as quietly as possible, only reporting errors, one would use
  1498. X     one of the following commands:
  1499. X
  1500. X         UNZIP=-qq; export UNZIP    Unix Bourne shell
  1501. X         setenv UNZIP -qq           Unix C shell
  1502. X         set UNZIP=-qq              OS/2 or MS-DOS
  1503. X         define UNZIP_OPTS "-qq"    VMS (quotes for lowercase)
  1504. X
  1505. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 6
  1506. X
  1507. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1508. X
  1509. X     Environment options are, in effect, considered  to  be  just
  1510. X     like  any  other  command-line options, except that they are
  1511. X     effectively the first options on the command line.  To over-
  1512. X     ride  an  environment option, one may use the ``minus opera-
  1513. X     tor'' to remove it.  For instance, to override  one  of  the
  1514. X     quiet-flags in the example above, use the command
  1515. X
  1516. X         unzip --q[other options] zipfile
  1517. X
  1518. X     The first hyphen is the normal  switch  character,  and  the
  1519. X     second  is  a  minus sign, acting on the q option.  Thus the
  1520. X     effect here is to cancel one quantum of quietness.  To  can-
  1521. X     cel both quiet flags, two (or more) minuses may be used:
  1522. X
  1523. X         unzip -t--q zipfile
  1524. X         unzip ---qt zipfile
  1525. X
  1526. X     (the two are equivalent).  This may seem awkward or  confus-
  1527. X     ing,  but it is reasonably intuitive:  just ignore the first
  1528. X     hyphen and go from there.  It is also  consistent  with  the
  1529. X     behavior of Unix nice(1).
  1530. X
  1531. X     As suggested by the examples  above,  the  default  variable
  1532. X     names  are  UNZIP_OPTS  for  VMS  (where  the symbol used to
  1533. X     install unzip as a foreign command would otherwise  be  con-
  1534. X     fused  with  the  environment  variable),  and UNZIP for all
  1535. X     other operating systems.  For  compatibility  with  zip(1L),
  1536. X     UNZIPOPT  is  also  accepted (don't ask).  If both UNZIP and
  1537. X     UNZIPOPT  are  defined,  however,  UNZIP  takes  precedence.
  1538. X     unzip's  diagnostic  option (-v with no zipfile name) can be
  1539. X     used to check the values of  all  four  possible  unzip  and
  1540. X     zipinfo environment variables.
  1541. X
  1542. X     The timezone variable (TZ) should be set  according  to  the
  1543. X     local  timezone  in  order  for  the  -f  and  -u to operate
  1544. X     correctly.  See the description of  -f  above  for  details.
  1545. X     This  variable may also be necessary in order for timestamps
  1546. X     on extracted files to be set correctly.
  1547. X
  1548. XDECRYPTION
  1549. X     Encrypted archives are fully supported by Info-ZIP software,
  1550. X     but due to United States export restrictions, the encryption
  1551. X     and decryption sources are not  packaged  with  the  regular
  1552. X     unzip  and  zip distributions.  Since the crypt sources were
  1553. X     written by Europeans, however, they are freely available  at
  1554. X     sites  throughout  the  world; see the file ``Where'' in any
  1555. X     Info-ZIP source or binary distribution  for  locations  both
  1556. X     inside and outside the US.
  1557. X
  1558. X     Because of the separate distribution, not all compiled  ver-
  1559. X     sions  of  unzip support decryption.  To check a version for
  1560. X     crypt  support,  either  attempt  to  test  or  extract   an
  1561. X
  1562. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 7
  1563. X
  1564. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1565. X
  1566. X     encrypted  archive,  or else check unzip's diagnostic screen
  1567. X     (see the -v option above) for ``[decryption]'' as one of the
  1568. X     special compilation options.
  1569. X
  1570. X     There are no runtime options for decryption;  if  a  zipfile
  1571. X     member  is  encrypted,  unzip  will  prompt for the password
  1572. X     without echoing what is typed.  unzip continues to  use  the
  1573. X     same  password  as  long  as it appears to be valid; it does
  1574. X     this by testing a 12-byte header.  The correct password will
  1575. X     always check out against the header, but there is a 1-in-256
  1576. X     chance that an incorrect password will as well.  (This is  a
  1577. X     security  feature  of  the  PKWARE  zipfile format; it helps
  1578. X     prevent brute-force attacks which  might  otherwise  gain  a
  1579. X     large  speed  advantage by testing only the header.)  In the
  1580. X     case that an incorrect password is given but it  passes  the
  1581. X     header  test  anyway,  either  an incorrect CRC will be gen-
  1582. X     erated for the extracted data or else unzip will fail during
  1583. X     the  extraction  because the ``decrypted'' bytes do not con-
  1584. X     stitute a valid compressed data stream.
  1585. X
  1586. X     If the first password fails the header check on  some  file,
  1587. X     unzip  will prompt for another password, and so on until all
  1588. X     files are extracted.  If a password is not known, entering a
  1589. X     null  password (that is, just a carriage return) is taken as
  1590. X     a signal to skip all further  prompting.   Only  unencrypted
  1591. X     files  in  the  archive(s)  will  thereafter  be  extracted.
  1592. X     (Actually that's not quite true; older versions  of  zip(1L)
  1593. X     and  zipcloak(1L)  allowed  null  passwords, so unzip checks
  1594. X     each encrypted file to see if the null password works.  This
  1595. X     may  result in ``false positives'' and extraction errors, as
  1596. X     noted above.)
  1597. X
  1598. X     Note that there is presently no  way  to  avoid  interactive
  1599. X     decryption.   This  is  another security feature:  plaintext
  1600. X     passwords given on the command line or stored in files  con-
  1601. X     stitute  a  risk because they may be seen by others.  Future
  1602. X     releases may (under protest, with great disapproval) support
  1603. X     such shenanigans.
  1604. X
  1605. XEXAMPLES
  1606. X     To  use  unzip  to  extract  all  members  of  the   archive
  1607. X     letters.zip  into  the  current directory and subdirectories
  1608. X     below it, creating any subdirectories as necessary:
  1609. X
  1610. X         unzip letters
  1611. X
  1612. X     To extract all  members  of  letters.zip  into  the  current
  1613. X     directory only:
  1614. X
  1615. X         unzip -j letters
  1616. X
  1617. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 8
  1618. X
  1619. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1620. X
  1621. X     To test letters.zip, printing only a summary  message  indi-
  1622. X     cating whether the archive is OK or not:
  1623. X
  1624. X         unzip -tq letters
  1625. X
  1626. X     To test all zipfiles in the current directory, printing only
  1627. X     the summaries:
  1628. X
  1629. X         unzip -tq \*.zip
  1630. X
  1631. X     (The backslash before the asterisk is only required  if  the
  1632. X     shell  expands  wildcards,  as  in Unix; double quotes could
  1633. X     have  been  used  instead,  as  in   the   source   examples
  1634. X     below.)  To  extract  to  standard  output  all  members  of
  1635. X     letters.zip whose names end in .tex, auto-converting to  the
  1636. X     local  end-of-line  convention  and  piping  the output into
  1637. X     more(1):
  1638. X
  1639. X         unzip -ca letters \*.tex | more
  1640. X
  1641. X     To extract the binary file paper1.dvi to standard output and
  1642. X     pipe it to a printing program:
  1643. X
  1644. X         unzip -p articles paper1.dvi | dvips
  1645. X
  1646. X     To extract all FORTRAN and C source  files--*.f,  *.c,  *.h,
  1647. X     and Makefile--into the /tmp directory:
  1648. X
  1649. X         unzip source.zip "*.[fch]" Makefile -d /tmp
  1650. X
  1651. X     (the double quotes are necessary only in Unix  and  only  if
  1652. X     globbing is turned on).  To extract all FORTRAN and C source
  1653. X     files, regardless of case (e.g., both *.c and *.C,  and  any
  1654. X     makefile, Makefile, MAKEFILE or similar):
  1655. X
  1656. X         unzip -C source.zip "*.[fch]" makefile -d /tmp
  1657. X
  1658. X     To extract any such files but convert any  uppercase  MS-DOS
  1659. X     or  VMS  names  to lowercase and convert the line-endings of
  1660. X     all of the files to the local standard (without  respect  to
  1661. X     any files which might be marked ``binary''):
  1662. X
  1663. X         unzip -aaCL source.zip "*.[fch]" makefile -d /tmp
  1664. X
  1665. X     To extract only newer versions of the files already  in  the
  1666. X     current  directory,  without  querying (NOTE:  be careful of
  1667. X     unzipping in one timezone a zipfile created in  another--ZIP
  1668. X     archives  to  date  contain  no  timezone information, and a
  1669. X     ``newer'' file from an eastern timezone  may,  in  fact,  be
  1670. X     older):
  1671. X
  1672. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                 9
  1673. X
  1674. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1675. X
  1676. X         unzip -fo sources
  1677. X
  1678. X     To extract newer  versions  of  the  files  already  in  the
  1679. X     current  directory and to create any files not already there
  1680. X     (same caveat as previous example):
  1681. X
  1682. X         unzip -uo sources
  1683. X
  1684. X     To display a  diagnostic  screen  showing  which  unzip  and
  1685. X     zipinfo options are stored in environment variables, whether
  1686. X     decryption support was compiled in, the compiler with  which
  1687. X     unzip was compiled, etc.:
  1688. X
  1689. X         unzip -v
  1690. X
  1691. X     In the last five examples, assume that UNZIP  or  UNZIP_OPTS
  1692. X     is set to -q.  To do a singly quiet listing:
  1693. X
  1694. X         unzip -l file.zip
  1695. X
  1696. X     To do a doubly quiet listing:
  1697. X
  1698. X         unzip -ql file.zip
  1699. X
  1700. X     (Note that the ``.zip'' is generally not necessary.)  To  do
  1701. X     a standard listing:
  1702. X
  1703. X         unzip --ql file.zip
  1704. X     or
  1705. X         unzip -l-q file.zip
  1706. X     or
  1707. X         unzip -l--q file.zip       (extra minuses don't hurt)
  1708. X
  1709. XTIPS
  1710. X     The current maintainer, being a lazy  sort,  finds  it  very
  1711. X     useful  to  define  a pair of aliases:  tt for ``unzip -tq''
  1712. X     and ii for ``unzip -Z'' (or ``zipinfo'').  One may then sim-
  1713. X     ply  type ``tt zipfile'' to test an archive, something which
  1714. X     is worth making a habit of  doing.   With  luck  unzip  will
  1715. X     report  ``No  errors  detected in zipfile.zip,'' after which
  1716. X     one may breathe a sigh of relief.
  1717. X
  1718. X     The maintainer  also  finds  it  useful  to  set  the  UNZIP
  1719. X     environment variable to ``-aL'' and is tempted to add ``-C''
  1720. X     as well.  His ZIPINFO variable is set to ``-z''.
  1721. X
  1722. XDIAGNOSTICS
  1723. X     The exit status (or error level) approximates the exit codes
  1724. X     defined  by PKWARE and takes on the following values, except
  1725. X     under VMS:
  1726. X
  1727. X          0    normal; no errors or warnings detected.
  1728. X
  1729. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                10
  1730. X
  1731. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1732. X
  1733. X          1    one or more warning errors were  encountered,  but
  1734. X               processing  completed  successfully  anyway.  This
  1735. X               includes zipfiles where  one  or  more  files  was
  1736. X               skipped  due  to unsupported compression method or
  1737. X               encryption with an unknown password.
  1738. X
  1739. X          2    a  generic  error  in  the  zipfile   format   was
  1740. X               detected.   Processing may have completed success-
  1741. X               fully anyway;  some  broken  zipfiles  created  by
  1742. X               other archivers have simple work-arounds.
  1743. X
  1744. X          3    a severe error in the zipfile format was detected.
  1745. X               Processing probably failed immediately.
  1746. X
  1747. X          4-8  unzip was unable to allocate  memory  for  one  or
  1748. X               more buffers.
  1749. X
  1750. X          9    the specified zipfiles were not found.
  1751. X
  1752. X          10   invalid options  were  specified  on  the  command
  1753. X               line.
  1754. X
  1755. X          11   no matching files were found.
  1756. X
  1757. X          50   the disk is (or was) full during extraction.
  1758. X
  1759. X          51   the end of the ZIP archive was encountered  prema-
  1760. X               turely.
  1761. X
  1762. X     VMS interprets standard Unix (or PC) return values as other,
  1763. X     scarier-looking things, so by default unzip always returns 0
  1764. X     (which reportedly gets converted into a VMS  status  of  1--
  1765. X     i.e., success).  There are two compilation options available
  1766. X     to  modify  or  expand   upon   this   behavior:    defining
  1767. X     RETURN_CODES results in a human-readable explanation of what
  1768. X     the real error status was (but still  with  a  faked  ``suc-
  1769. X     cess''  exit  value),  while defining RETURN_SEVERITY causes
  1770. X     unzip to exit  with  a  ``real''  VMS  status.   The  latter
  1771. X     behavior  will  become the default in future versions unless
  1772. X     it is found to conflict with officially defined  VMS  codes.
  1773. X     The  current mapping is as follows:   1 (success) for normal
  1774. X     exit, 0x7fff0001  for  warning  errors,  and  (0x7fff000?  +
  1775. X     16*normal_unzip_exit_status) for all other errors, where the
  1776. X     `?' is 2 (error) for unzip values 2 and 9-11, and  4  (fatal
  1777. X     error)  for  the  remaining  ones  (3-8, 50, 51).  Check the
  1778. X     ``unzip -v''  output  to  see  whether  RETURN_SEVERITY  was
  1779. X     defined at compilation time.
  1780. X
  1781. XBUGS
  1782. X     When attempting to extract a corrupted archive, unzip may go
  1783. X     into  an  infinite  loop and, if not stopped quickly enough,
  1784. X     fill all available disk  space.   Compiling  with  CHECK_EOF
  1785. X
  1786. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                11
  1787. X
  1788. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1789. X
  1790. X     should fix this problem for all zipfiles, but the option was
  1791. X     introduced too late in the testing process to  be  made  the
  1792. X     default  behavior.  Future versions will be robust enough to
  1793. X     fail gracefully on damaged archives.  Check the ``unzip -v''
  1794. X     output  to see whether CHECK_EOF was defined during compila-
  1795. X     tion.
  1796. X
  1797. X     [MS-DOS] When extracting or testing files from an archive on
  1798. X     a  defective  floppy  diskette,  if  the  ``Fail'' option is
  1799. X     chosen from DOS's ``Abort, Retry, Fail?'' message, unzip may
  1800. X     hang   the  system,  requiring  a  reboot.   Instead,  press
  1801. X     control-C (or control-Break) to terminate unzip.
  1802. X
  1803. X     Under DEC Ultrix, unzip will sometimes fail on long zipfiles
  1804. X     (bad  CRC, not always reproducible).  This is apparently due
  1805. X     either to a hardware bug (cache memory) or an operating sys-
  1806. X     tem bug (improper handling of page faults?).
  1807. X
  1808. X     Dates and times of stored directories are not restored.
  1809. X
  1810. X     [OS/2] Extended  attributes  for  existing  directories  are
  1811. X     never  updated.   This is a limitation of the operating sys-
  1812. X     tem; unzip has no way to determine whether the stored attri-
  1813. X     butes are newer or older than the existing ones.
  1814. X
  1815. X     [VMS] When extracting to another directory, only the  [.foo]
  1816. X     syntax  is  accepted  for the -d option; the simple Unix foo
  1817. X     syntax is silently  ignored  (as  is  the  less  common  VMS
  1818. X     foo.dir syntax).
  1819. X
  1820. X     [VMS] When the file being extracted already exists,  unzip's
  1821. X     query  only  allows skipping, overwriting or renaming; there
  1822. X     should additionally be a choice for creating a  new  version
  1823. X     of  the file.  In fact, the ``overwrite'' choice does create
  1824. X     a new  version;  the  old  version  is  not  overwritten  or
  1825. X     deleted.
  1826. X
  1827. XSEE ALSO
  1828. X     funzip(1L), zip(1L), zipcloak(1L), zipgrep(1L), zipinfo(1L),
  1829. X     zipnote(1L), zipsplit(1L)
  1830. X
  1831. XAUTHORS
  1832. X     The primary Info-ZIP authors  (current  zip-bugs  workgroup)
  1833. X     are:   Jean-loup Gailly (Zip); Greg R. Roelofs (UnZip); Mark
  1834. X     Adler (decompression, fUnZip); Kai Uwe Rommel  (OS/2);  Igor
  1835. X     Mandrichenko  and  Hunter  Goatley (VMS); John Bush and Paul
  1836. X     Kienitz (Amiga); Antoine Verheijen (Macintosh);  Chris  Her-
  1837. X     borth  (Atari); Henry Gessau (NT); Karl Davis, Sergio Monesi
  1838. X     and Evan Shattock (Acorn Archimedes); and Robert Heath (Win-
  1839. X     dows).   The  author  of  the original unzip code upon which
  1840. X     Info-ZIP's is based was Samuel H. Smith;  Carl  Mascott  did
  1841. X     the  first  Unix port; and David P. Kirschbaum organized and
  1842. X
  1843. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                12
  1844. X
  1845. XUNZIP(1L)         MISC. REFERENCE MANUAL PAGES          UNZIP(1L)
  1846. X
  1847. X     led Info-ZIP in its early days.  The full list of  contribu-
  1848. X     tors  to  UnZip  has  grown quite large; please refer to the
  1849. X     CONTRIBS file in the UnZip source distribution for  a  rela-
  1850. X     tively complete version.
  1851. X
  1852. XVERSIONS
  1853. X     v1.2   15 Mar 89   Samuel H. Smith
  1854. X     v2.0    9 Sep 89   Samuel H. Smith
  1855. X     v2.x   fall 1989   many Usenet contributors
  1856. X     v3.0    1 May 90   Info-ZIP (DPK, consolidator)
  1857. X     v3.1   15 Aug 90   Info-ZIP (DPK, consolidator)
  1858. X     v4.0    1 Dec 90   Info-ZIP (GRR, maintainer)
  1859. X     v4.1   12 May 91   Info-ZIP
  1860. X     v4.2   20 Mar 92   Info-ZIP (zip-bugs subgroup, GRR)
  1861. X     v5.0   21 Aug 92   Info-ZIP (zip-bugs subgroup, GRR)
  1862. X     v5.01  15 Jan 93   Info-ZIP (zip-bugs subgroup, GRR)
  1863. X     v5.1    7 Feb 94   Info-ZIP (zip-bugs subgroup, GRR)
  1864. X     v5.11   2 Aug 94   Info-ZIP (zip-bugs subgroup, GRR)
  1865. X     v5.12  28 Aug 94   Info-ZIP (zip-bugs subgroup, GRR)
  1866. X
  1867. XInfo-ZIP         Last change: 28 Aug 94 (v5.12)                13
  1868. X
  1869. END_OF_FILE
  1870.   if test 33336 -ne `wc -c <'unzip-5.12/unzip.doc'`; then
  1871.     echo shar: \"'unzip-5.12/unzip.doc'\" unpacked with wrong size!
  1872.   fi
  1873.   # end of 'unzip-5.12/unzip.doc'
  1874. fi
  1875. echo shar: End of archive 11 \(of 20\).
  1876. cp /dev/null ark11isdone
  1877. MISSING=""
  1878. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  1879.     if test ! -f ark${I}isdone ; then
  1880.     MISSING="${MISSING} ${I}"
  1881.     fi
  1882. done
  1883. if test "${MISSING}" = "" ; then
  1884.     echo You have unpacked all 20 archives.
  1885.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1886. else
  1887.     echo You still must unpack the following archives:
  1888.     echo "        " ${MISSING}
  1889. fi
  1890. exit 0
  1891. exit 0 # Just in case...
  1892.