home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / unzip / part12 < 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: v44i077:  unzip - Info-ZIP portable UnZip, version 5.12, Part12/20
  4. Date: 18 Sep 1994 23:16:01 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <35j3a1$qpg@sparky.sterling.com>
  9. X-Md4-Signature: 84e6e974cc4c02fa0169d55b28be519c
  10.  
  11. Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
  12. Posting-number: Volume 44, Issue 77
  13. Archive-name: unzip/part12
  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/atari.c unzip-5.12/match.c
  22. #   unzip-5.12/unix/unzip.1
  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 12 (of 20)."'
  27. if test -f 'unzip-5.12/atari/atari.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'unzip-5.12/atari/atari.c'\"
  29. else
  30.   echo shar: Extracting \"'unzip-5.12/atari/atari.c'\" \(26647 characters\)
  31.   sed "s/^X//" >'unzip-5.12/atari/atari.c' <<'END_OF_FILE'
  32. X/*---------------------------------------------------------------------------
  33. X
  34. X  atari.c
  35. X
  36. X  Atari-specific routines for use with Info-ZIP's UnZip 5.1 and later.
  37. X
  38. X  Contains:  readdir()
  39. X             do_wild()           <-- generic enough to put in file_io.c?
  40. X             mapattr()
  41. X             mapname()
  42. X             checkdir()
  43. X             mkdir()
  44. X             close_outfile()
  45. X             version()
  46. X
  47. X  Due to the amazing MiNT library being very, very close to BSD unix's
  48. X  library, I'm using the unix.c as a base for this.  Note:  If you're not
  49. X  going to compile this with the MiNT libraries (for GNU C, Turbo C, Pure C,
  50. X  Lattice C, or Heat & Serve C), you're going to be in for some nasty work.
  51. X  Most of the modifications in this file were made by Chris Herborth
  52. X  (cherborth@semprini.waterloo-rdp.on.ca) and /should/ be marked with [cjh].
  53. X
  54. X  ---------------------------------------------------------------------------*/
  55. X
  56. X
  57. X#include "unzip.h"
  58. X#include <dirent.h>            /* MiNTlibs has dirent [cjh] */
  59. X
  60. Xstatic int created_dir;        /* used in mapname(), checkdir() */
  61. Xstatic int renamed_fullpath;   /* ditto */
  62. X
  63. X/**********************/
  64. X/* Function do_wild() */   /* for porting:  dir separator; match(ignore_case) */
  65. X/**********************/
  66. X
  67. Xchar *do_wild(wildspec)
  68. X    char *wildspec;         /* only used first time on a given dir */
  69. X{
  70. X    static DIR *dir = NULL;
  71. X    static char *dirname, *wildname, matchname[FILNAMSIZ];
  72. X    static int firstcall=TRUE, have_dirname, dirnamelen;
  73. X    struct dirent *file;
  74. X
  75. X
  76. X    /* Even when we're just returning wildspec, we *always* do so in
  77. X     * matchname[]--calling routine is allowed to append four characters
  78. X     * to the returned string, and wildspec may be a pointer to argv[].
  79. X     */
  80. X    if (firstcall) {        /* first call:  must initialize everything */
  81. X        firstcall = FALSE;
  82. X
  83. X        /* break the wildspec into a directory part and a wildcard filename */
  84. X        if ((wildname = strrchr(wildspec, '/')) == NULL) {
  85. X            dirname = ".";
  86. X            dirnamelen = 1;
  87. X            have_dirname = FALSE;
  88. X            wildname = wildspec;
  89. X        } else {
  90. X            ++wildname;     /* point at character after '/' */
  91. X            dirnamelen = wildname - wildspec;
  92. X            if ((dirname = (char *)malloc(dirnamelen+1)) == NULL) {
  93. X                fprintf(stderr, "warning:  can't allocate wildcard buffers\n");
  94. X                strcpy(matchname, wildspec);
  95. X                return matchname;   /* but maybe filespec was not a wildcard */
  96. X            }
  97. X            strncpy(dirname, wildspec, dirnamelen);
  98. X            dirname[dirnamelen] = '\0';   /* terminate for strcpy below */
  99. X            have_dirname = TRUE;
  100. X        }
  101. X
  102. X        if ((dir = opendir(dirname)) != NULL) {
  103. X            while ((file = readdir(dir)) != NULL) {
  104. X                if (file->d_name[0] == '.' && wildname[0] != '.')
  105. X                    continue;  /* Unix:  '*' and '?' do not match leading dot */
  106. X                    /* Need something here for TOS filesystem? [cjh] */
  107. X                if (match(file->d_name, wildname, 0)) {  /* 0 == case sens. */
  108. X                    if (have_dirname) {
  109. X                        strcpy(matchname, dirname);
  110. X                        strcpy(matchname+dirnamelen, file->d_name);
  111. X                    } else
  112. X                        strcpy(matchname, file->d_name);
  113. X                    return matchname;
  114. X                }
  115. X            }
  116. X            /* if we get to here directory is exhausted, so close it */
  117. X            closedir(dir);
  118. X            dir = NULL;
  119. X        }
  120. X
  121. X        /* return the raw wildspec in case that works (e.g., directory not
  122. X         * searchable, but filespec was not wild and file is readable) */
  123. X        strcpy(matchname, wildspec);
  124. X        return matchname;
  125. X    }
  126. X
  127. X    /* last time through, might have failed opendir but returned raw wildspec */
  128. X    if (dir == NULL) {
  129. X        firstcall = TRUE;  /* nothing left to try--reset for new wildspec */
  130. X        if (have_dirname)
  131. X            free(dirname);
  132. X        return (char *)NULL;
  133. X    }
  134. X
  135. X    /* If we've gotten this far, we've read and matched at least one entry
  136. X     * successfully (in a previous call), so dirname has been copied into
  137. X     * matchname already.
  138. X     */
  139. X    while ((file = readdir(dir)) != NULL)
  140. X        /* May need special TOS handling here. [cjh] */
  141. X        if (match(file->d_name, wildname, 0)) {   /* 0 == don't ignore case */
  142. X            if (have_dirname) {
  143. X                /* strcpy(matchname, dirname); */
  144. X                strcpy(matchname+dirnamelen, file->d_name);
  145. X            } else
  146. X                strcpy(matchname, file->d_name);
  147. X            return matchname;
  148. X        }
  149. X
  150. X    closedir(dir);     /* have read at least one dir entry; nothing left */
  151. X    dir = NULL;
  152. X    firstcall = TRUE;  /* reset for new wildspec */
  153. X    if (have_dirname)
  154. X        free(dirname);
  155. X    return (char *)NULL;
  156. X
  157. X} /* end function do_wild() */
  158. X
  159. X
  160. X
  161. X
  162. X
  163. X/**********************/
  164. X/* Function mapattr() */
  165. X/**********************/
  166. X
  167. Xint mapattr()
  168. X{
  169. X    ulg tmp = crec.external_file_attributes;
  170. X
  171. X    switch (pInfo->hostnum) {
  172. X        case UNIX_:
  173. X            /* minix filesystem under MiNT on Atari [cjh] */
  174. X        case VMS_:
  175. X            pInfo->file_attr = (unsigned)(tmp >> 16);
  176. X            return 0;
  177. X        case AMIGA_:
  178. X            tmp = (unsigned)(tmp>>17 & 7);   /* Amiga RWE bits */
  179. X            pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
  180. X            break;
  181. X        /* all remaining cases:  expand MSDOS read-only bit into write perms */
  182. X        case FS_FAT_:
  183. X        case FS_HPFS_:
  184. X        case FS_NTFS_:
  185. X        case MAC_:
  186. X        case ATARI_:             /* (used to set = 0666) */
  187. X            /* TOS filesystem [cjh] */
  188. X        case TOPS20_:
  189. X        default:
  190. X            tmp = !(tmp & 1) << 1;   /* read-only bit --> write perms bits */
  191. X            pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
  192. X            break;
  193. X    } /* end switch (host-OS-created-by) */
  194. X
  195. X    /* for originating systems with no concept of "group," "other," "system": */
  196. X    umask( (int)(tmp=umask(0)) );    /* apply mask to expanded r/w(/x) perms */
  197. X    pInfo->file_attr &= ~tmp;
  198. X
  199. X    return 0;
  200. X
  201. X} /* end function mapattr() */
  202. X
  203. X
  204. X
  205. X
  206. X
  207. X/************************/
  208. X/*  Function mapname()  */
  209. X/************************/
  210. X
  211. Xint mapname(renamed)  /* return 0 if no error, 1 if caution (filename trunc), */
  212. X    int renamed;      /* 2 if warning (skip file because dir doesn't exist), */
  213. X{                     /* 3 if error (skip file), 10 if no memory (skip file) */
  214. X    char pathcomp[FILNAMSIZ];   /* path-component buffer */
  215. X    char *pp, *cp=NULL;         /* character pointers */
  216. X    char *lastsemi = NULL;      /* pointer to last semi-colon in pathcomp */
  217. X    int quote = FALSE;          /* flags */
  218. X    int error = 0;
  219. X    register unsigned workch;   /* hold the character being tested */
  220. X
  221. X
  222. X/*---------------------------------------------------------------------------
  223. X    Initialize various pointers and counters and stuff.
  224. X  ---------------------------------------------------------------------------*/
  225. X
  226. X    if (pInfo->vollabel)
  227. X        return IZ_VOL_LABEL;    /* can't set disk volume labels in Unix */
  228. X
  229. X    /* can create path as long as not just freshening, or if user told us */
  230. X    create_dirs = (!fflag || renamed);
  231. X
  232. X    created_dir = FALSE;        /* not yet */
  233. X
  234. X    /* user gave full pathname:  don't prepend rootpath */
  235. X    renamed_fullpath = (renamed && (*filename == '/'));
  236. X
  237. X    if (checkdir((char *)NULL, INIT) == 10)
  238. X        return 10;              /* initialize path buffer, unless no memory */
  239. X
  240. X    *pathcomp = '\0';           /* initialize translation buffer */
  241. X    pp = pathcomp;              /* point to translation buffer */
  242. X    if (jflag)                  /* junking directories */
  243. X        cp = (char *)strrchr(filename, '/');
  244. X    if (cp == NULL)             /* no '/' or not junking dirs */
  245. X        cp = filename;          /* point to internal zipfile-member pathname */
  246. X    else
  247. X        ++cp;                   /* point to start of last component of path */
  248. X
  249. X/*---------------------------------------------------------------------------
  250. X    Begin main loop through characters in filename.
  251. X  ---------------------------------------------------------------------------*/
  252. X
  253. X    while ((workch = (uch)*cp++) != 0) {
  254. X
  255. X        if (quote) {                 /* if character quoted, */
  256. X            *pp++ = (char)workch;    /*  include it literally */
  257. X            quote = FALSE;
  258. X        } else
  259. X            switch (workch) {
  260. X            case '/':             /* can assume -j flag not given */
  261. X                *pp = '\0';
  262. X                if ((error = checkdir(pathcomp, APPEND_DIR)) > 1)
  263. X                    return error;
  264. X                pp = pathcomp;    /* reset conversion buffer for next piece */
  265. X                lastsemi = NULL;  /* leave directory semi-colons alone */
  266. X                break;
  267. X
  268. X            case ';':             /* VMS version (or DEC-20 attrib?) */
  269. X                lastsemi = pp;         /* keep for now; remove VMS ";##" */
  270. X                *pp++ = (char)workch;  /*  later, if requested */
  271. X                break;
  272. X
  273. X            case '\026':          /* control-V quote for special chars */
  274. X                quote = TRUE;     /* set flag for next character */
  275. X                break;
  276. X
  277. X#ifdef MTS
  278. X            case ' ':             /* change spaces to underscore under */
  279. X                *pp++ = '_';      /*  MTS; leave as spaces under Unix */
  280. X                break;
  281. X#endif
  282. X
  283. X            default:
  284. X                /* allow European characters in filenames: */
  285. X                if (isprint(workch) || (128 <= workch && workch <= 254))
  286. X                    *pp++ = (char)workch;
  287. X            } /* end switch */
  288. X
  289. X    } /* end while loop */
  290. X
  291. X    *pp = '\0';                   /* done with pathcomp:  terminate it */
  292. X
  293. X    /* if not saving them, remove VMS version numbers (appended ";###") */
  294. X    if (!V_flag && lastsemi) {
  295. X        pp = lastsemi + 1;
  296. X        while (isdigit((uch)(*pp)))
  297. X            ++pp;
  298. X        if (*pp == '\0')          /* only digits between ';' and end:  nuke */
  299. X            *lastsemi = '\0';
  300. X    }
  301. X
  302. X/*---------------------------------------------------------------------------
  303. X    Report if directory was created (and no file to create:  filename ended
  304. X    in '/'), check name to be sure it exists, and combine path and name be-
  305. X    fore exiting.
  306. X  ---------------------------------------------------------------------------*/
  307. X
  308. X    if (filename[strlen(filename) - 1] == '/') {
  309. X        checkdir(filename, GETPATH);
  310. X        if (created_dir && QCOND2) {
  311. X            fprintf(stdout, "   creating: %s\n", filename);
  312. X            return IZ_CREATED_DIR;   /* set dir time (note trailing '/') */
  313. X        }
  314. X        return 2;   /* dir existed already; don't look for data to extract */
  315. X    }
  316. X
  317. X    if (*pathcomp == '\0') {
  318. X        fprintf(stderr, "mapname:  conversion of %s failed\n", filename);
  319. X        return 3;
  320. X    }
  321. X
  322. X    checkdir(pathcomp, APPEND_NAME);   /* returns 1 if truncated:  care? */
  323. X    checkdir(filename, GETPATH);
  324. X
  325. X    return error;
  326. X
  327. X} /* end function mapname() */
  328. X
  329. X
  330. X
  331. X
  332. X#if 0  /*========== NOTES ==========*/
  333. X
  334. X  extract-to dir:      a:path/
  335. X  buildpath:           path1/path2/ ...   (NULL-terminated)
  336. X  pathcomp:                filename 
  337. X
  338. X  mapname():
  339. X    loop over chars in zipfile member name
  340. X      checkdir(path component, COMPONENT | CREATEDIR) --> map as required?
  341. X        (d:/tmp/unzip/)                    (disk:[tmp.unzip.)
  342. X        (d:/tmp/unzip/jj/)                 (disk:[tmp.unzip.jj.)
  343. X        (d:/tmp/unzip/jj/temp/)            (disk:[tmp.unzip.jj.temp.)
  344. X    finally add filename itself and check for existence? (could use with rename)
  345. X        (d:/tmp/unzip/jj/temp/msg.outdir)  (disk:[tmp.unzip.jj.temp]msg.outdir)
  346. X    checkdir(name, COPYFREE)     -->  copy path to name and free space
  347. X
  348. X#endif /* 0 */
  349. X
  350. X
  351. X
  352. X
  353. X/***********************/
  354. X/* Function checkdir() */
  355. X/***********************/
  356. X
  357. Xint checkdir(pathcomp, flag)
  358. X    char *pathcomp;
  359. X    int flag;
  360. X/*
  361. X * returns:  1 - (on APPEND_NAME) truncated filename
  362. X *           2 - path doesn't exist, not allowed to create
  363. X *           3 - path doesn't exist, tried to create and failed; or
  364. X *               path exists and is not a directory, but is supposed to be
  365. X *           4 - path is too long
  366. X *          10 - can't allocate memory for filename buffers
  367. X */
  368. X{
  369. X    static int rootlen = 0;   /* length of rootpath */
  370. X    static char *rootpath;    /* user's "extract-to" directory */
  371. X    static char *buildpath;   /* full path (so far) to extracted file */
  372. X    static char *end;         /* pointer to end of buildpath ('\0') */
  373. X
  374. X#   define FN_MASK   7
  375. X#   define FUNCTION  (flag & FN_MASK)
  376. X
  377. X
  378. X
  379. X/*---------------------------------------------------------------------------
  380. X    APPEND_DIR:  append the path component to the path being built and check
  381. X    for its existence.  If doesn't exist and we are creating directories, do
  382. X    so for this one; else signal success or error as appropriate.
  383. X  ---------------------------------------------------------------------------*/
  384. X
  385. X    if (FUNCTION == APPEND_DIR) {
  386. X        int too_long = FALSE;
  387. X/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
  388. X#ifdef SHORT_NAMES
  389. X        char *old_end = end;
  390. X#endif
  391. X
  392. X        Trace((stderr, "appending dir segment [%s]\n", pathcomp));
  393. X        while ((*end = *pathcomp++) != '\0')
  394. X            ++end;
  395. X/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
  396. X#ifdef SHORT_NAMES   /* path components restricted to 14 chars, typically */
  397. X        if ((end-old_end) > FILENAME_MAX)  /* GRR:  proper constant? */
  398. X            *(end = old_end + FILENAME_MAX) = '\0';
  399. X#endif
  400. X
  401. X        /* GRR:  could do better check, see if overrunning buffer as we go:
  402. X         * check end-buildpath after each append, set warning variable if
  403. X         * within 20 of FILNAMSIZ; then if var set, do careful check when
  404. X         * appending.  Clear variable when begin new path. */
  405. X
  406. X        if ((end-buildpath) > FILNAMSIZ-3)  /* need '/', one-char name, '\0' */
  407. X            too_long = TRUE;                /* check if extracting directory? */
  408. X        if (stat(buildpath, &statbuf)) {    /* path doesn't exist */
  409. X            if (!create_dirs) {   /* told not to create (freshening) */
  410. X                free(buildpath);
  411. X                return 2;         /* path doesn't exist:  nothing to do */
  412. X            }
  413. X            if (too_long) {
  414. X                fprintf(stderr, "checkdir error:  path too long: %s\n",
  415. X                  buildpath);
  416. X                fflush(stderr);
  417. X                free(buildpath);
  418. X                return 4;         /* no room for filenames:  fatal */
  419. X            }
  420. X            if (mkdir(buildpath, 0777) == -1) {   /* create the directory */
  421. X                fprintf(stderr, "checkdir error:  can't create %s\n\
  422. X                 unable to process %s.\n", buildpath, filename);
  423. X                fflush(stderr);
  424. X                free(buildpath);
  425. X                return 3;      /* path didn't exist, tried to create, failed */
  426. X            }
  427. X            created_dir = TRUE;
  428. X        } else if (!S_ISDIR(statbuf.st_mode)) {
  429. X            fprintf(stderr, "checkdir error:  %s exists but is not directory\n\
  430. X                 unable to process %s.\n", buildpath, filename);
  431. X            fflush(stderr);
  432. X            free(buildpath);
  433. X            return 3;          /* path existed but wasn't dir */
  434. X        }
  435. X        if (too_long) {
  436. X            fprintf(stderr, "checkdir error:  path too long: %s\n", buildpath);
  437. X            fflush(stderr);
  438. X            free(buildpath);
  439. X            return 4;         /* no room for filenames:  fatal */
  440. X        }
  441. X        *end++ = '/';
  442. X        *end = '\0';
  443. X        Trace((stderr, "buildpath now = [%s]\n", buildpath));
  444. X        return 0;
  445. X
  446. X    } /* end if (FUNCTION == APPEND_DIR) */
  447. X
  448. X/*---------------------------------------------------------------------------
  449. X    GETPATH:  copy full path to the string pointed at by pathcomp, and free
  450. X    buildpath.
  451. X  ---------------------------------------------------------------------------*/
  452. X
  453. X    if (FUNCTION == GETPATH) {
  454. X        strcpy(pathcomp, buildpath);
  455. X        Trace((stderr, "getting and freeing path [%s]\n", pathcomp));
  456. X        free(buildpath);
  457. X        buildpath = end = NULL;
  458. X        return 0;
  459. X    }
  460. X
  461. X/*---------------------------------------------------------------------------
  462. X    APPEND_NAME:  assume the path component is the filename; append it and
  463. X    return without checking for existence.
  464. X  ---------------------------------------------------------------------------*/
  465. X
  466. X    if (FUNCTION == APPEND_NAME) {
  467. X/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
  468. X#ifdef SHORT_NAMES
  469. X        char *old_end = end;
  470. X#endif
  471. X
  472. X        Trace((stderr, "appending filename [%s]\n", pathcomp));
  473. X        while ((*end = *pathcomp++) != '\0') {
  474. X            ++end;
  475. X/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
  476. X#ifdef SHORT_NAMES  /* truncate name at 14 characters, typically */
  477. X            if ((end-old_end) > FILENAME_MAX)      /* GRR:  proper constant? */
  478. X                *(end = old_end + FILENAME_MAX) = '\0';
  479. X#endif
  480. X            if ((end-buildpath) >= FILNAMSIZ) {
  481. X                *--end = '\0';
  482. X                fprintf(stderr, "checkdir warning:  path too long; truncating\n\
  483. Xcheckdir warning:  path too long; truncating\n\
  484. X                   %s\n                -> %s\n", filename, buildpath);
  485. X                fflush(stderr);
  486. X                return 1;   /* filename truncated */
  487. X            }
  488. X        }
  489. X        Trace((stderr, "buildpath now = [%s]\n", buildpath));
  490. X        return 0;  /* could check for existence here, prompt for new name... */
  491. X    }
  492. X
  493. X/*---------------------------------------------------------------------------
  494. X    INIT:  allocate and initialize buffer space for the file currently being
  495. X    extracted.  If file was renamed with an absolute path, don't prepend the
  496. X    extract-to path.
  497. X  ---------------------------------------------------------------------------*/
  498. X
  499. X/* GRR:  for VMS and TOPS-20, add up to 13 to strlen */
  500. X
  501. X    if (FUNCTION == INIT) {
  502. X        Trace((stderr, "initializing buildpath to "));
  503. X        if ((buildpath = (char *)malloc(strlen(filename)+rootlen+1)) == NULL)
  504. X            return 10;
  505. X        if ((rootlen > 0) && !renamed_fullpath) {
  506. X            strcpy(buildpath, rootpath);
  507. X            end = buildpath + rootlen;
  508. X        } else {
  509. X            *buildpath = '\0';
  510. X            end = buildpath;
  511. X        }
  512. X        Trace((stderr, "[%s]\n", buildpath));
  513. X        return 0;
  514. X    }
  515. X
  516. X/*---------------------------------------------------------------------------
  517. X    ROOT:  if appropriate, store the path in rootpath and create it if neces-
  518. X    sary; else assume it's a zipfile member and return.  This path segment
  519. X    gets used in extracting all members from every zipfile specified on the
  520. X    command line.
  521. X  ---------------------------------------------------------------------------*/
  522. X
  523. X#if (!defined(SFX) || defined(SFX_EXDIR))
  524. X    if (FUNCTION == ROOT) {
  525. X        Trace((stderr, "initializing root path to [%s]\n", pathcomp));
  526. X        if (pathcomp == NULL) {
  527. X            rootlen = 0;
  528. X            return 0;
  529. X        }
  530. X        if ((rootlen = strlen(pathcomp)) > 0) {
  531. X            int had_trailing_pathsep=FALSE;
  532. X
  533. X            if (pathcomp[rootlen-1] == '/') {
  534. X                pathcomp[--rootlen] = '\0';
  535. X                had_trailing_pathsep = TRUE;
  536. X            }
  537. X            if (rootlen > 0 && (stat(pathcomp, &statbuf) ||
  538. X                !S_ISDIR(statbuf.st_mode)))          /* path does not exist */
  539. X            {
  540. X                if (!create_dirs                     /* || iswild(pathcomp) */
  541. X#ifdef OLD_EXDIR
  542. X                                 || !had_trailing_pathsep
  543. X#endif
  544. X                                                         ) {
  545. X                    rootlen = 0;
  546. X                    return 2;   /* skip (or treat as stored file) */
  547. X                }
  548. X                /* create the directory (could add loop here to scan pathcomp
  549. X                 * and create more than one level, but why really necessary?) */
  550. X                if (mkdir(pathcomp, 0777) == -1) {
  551. X                    fprintf(stderr,
  552. X                      "checkdir:  can't create extraction directory: %s\n",
  553. X                      pathcomp);
  554. X                    fflush(stderr);
  555. X                    rootlen = 0;   /* path didn't exist, tried to create, and */
  556. X                    return 3;  /* failed:  file exists, or 2+ levels required */
  557. X                }
  558. X            }
  559. X            if ((rootpath = (char *)malloc(rootlen+2)) == NULL) {
  560. X                rootlen = 0;
  561. X                return 10;
  562. X            }
  563. X            strcpy(rootpath, pathcomp);
  564. X            rootpath[rootlen++] = '/';
  565. X            rootpath[rootlen] = '\0';
  566. X        }
  567. X        Trace((stderr, "rootpath now = [%s]\n", rootpath));
  568. X        return 0;
  569. X    }
  570. X#endif /* !SFX || SFX_EXDIR */
  571. X
  572. X/*---------------------------------------------------------------------------
  573. X    END:  free rootpath, immediately prior to program exit.
  574. X  ---------------------------------------------------------------------------*/
  575. X
  576. X    if (FUNCTION == END) {
  577. X        Trace((stderr, "freeing rootpath\n"));
  578. X        if (rootlen > 0)
  579. X            free(rootpath);
  580. X        return 0;
  581. X    }
  582. X
  583. X    return 99;  /* should never reach */
  584. X
  585. X} /* end function checkdir() */
  586. X
  587. X
  588. X
  589. X
  590. X/****************************/
  591. X/* Function close_outfile() */
  592. X/****************************/
  593. X
  594. Xvoid close_outfile()
  595. X{
  596. X    static short yday[]={0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  597. X    long m_time;
  598. X    int yr, mo, dy, hh, mm, ss, leap, days;
  599. X    struct utimbuf tp;
  600. X#   define YRBASE  1970
  601. X    extern long timezone;  /* seems ok for Atari if undefine __STRICT_ANSI__ */
  602. X                           /* [cjh] */
  603. X
  604. X/*---------------------------------------------------------------------------
  605. X    If symbolic links are supported, allocate a storage area, put the uncom-
  606. X    pressed "data" in it, and create the link.  Since we know it's a symbolic
  607. X    link to start with, we shouldn't have to worry about overflowing unsigned
  608. X    ints with unsigned longs.
  609. X  ---------------------------------------------------------------------------*/
  610. X
  611. X    /* symlinks allowed on minix filesystems [cjh]
  612. X     * Hopefully this will work properly... We won't bother to try if
  613. X     * MiNT isn't present; the symlink should fail if we're on a TOS
  614. X     * filesystem.
  615. X     * BUG: should we copy the original file to the "symlink" if the
  616. X     *      link fails?
  617. X     */
  618. X    if (symlnk) {
  619. X        unsigned ucsize = (unsigned)lrec.ucsize;
  620. X        char *linktarget = (char *)malloc((unsigned)lrec.ucsize+1);
  621. X
  622. X        fclose(outfile);                    /* close "data" file... */
  623. X        outfile = fopen(filename, FOPR);    /* ...and reopen for reading */
  624. X        if (!linktarget || (fread(linktarget, 1, ucsize, outfile) != ucsize)) {
  625. X            fprintf(stderr, "\nwarning:  symbolic link (%s) failed\n",
  626. X              filename);
  627. X            if (linktarget)
  628. X                free(linktarget);
  629. X            fclose(outfile);
  630. X            return;
  631. X        }
  632. X        fclose(outfile);                    /* close "data" file for good... */
  633. X        unlink(filename);                   /* ...and delete it */
  634. X        linktarget[ucsize] = '\0';
  635. X        fprintf(stdout, "-> %s ", linktarget);
  636. X        if (symlink(linktarget, filename))  /* create the real link */
  637. X            perror("symlink error");
  638. X        free(linktarget);
  639. X        return;                             /* can't set time on symlinks */
  640. X    }
  641. X
  642. X    fclose(outfile);
  643. X
  644. X/*---------------------------------------------------------------------------
  645. X    Change the file permissions from default ones to those stored in the
  646. X    zipfile.
  647. X  ---------------------------------------------------------------------------*/
  648. X
  649. X#ifndef NO_CHMOD
  650. X    if (chmod(filename, 0xffff & pInfo->file_attr))
  651. X            perror("chmod (file attributes) error");
  652. X#endif
  653. X
  654. X/*---------------------------------------------------------------------------
  655. X    Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
  656. X    time:  adjust base year from 1980 to 1970, do usual conversions from
  657. X    yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
  658. X    light savings time differences.
  659. X  ---------------------------------------------------------------------------*/
  660. X
  661. X    yr = ((lrec.last_mod_file_date >> 9) & 0x7f) + (1980 - YRBASE);
  662. X    mo = ((lrec.last_mod_file_date >> 5) & 0x0f) - 1;
  663. X    dy = (lrec.last_mod_file_date & 0x1f) - 1;
  664. X    hh = (lrec.last_mod_file_time >> 11) & 0x1f;
  665. X    mm = (lrec.last_mod_file_time >> 5) & 0x3f;
  666. X    ss = (lrec.last_mod_file_time & 0x1f) * 2;
  667. X
  668. X    /* leap = # of leap yrs from YRBASE up to but not including current year */
  669. X    leap = ((yr + YRBASE - 1) / 4);   /* leap year base factor */
  670. X
  671. X    /* how many days from YRBASE to this year? (& add expired days this year) */
  672. X    days = (yr * 365) + (leap - 492) + yday[mo];
  673. X
  674. X    /* if year is a leap year and month is after February, add another day */
  675. X    if ((mo > 1) && ((yr+YRBASE)%4 == 0) && ((yr+YRBASE) != 2100))
  676. X        ++days;   /* OK through 2199 */
  677. X
  678. X    /* convert date & time to seconds relative to 00:00:00, 01/01/YRBASE */
  679. X    m_time = ((days + dy) * 86400) + (hh * 3600) + (mm * 60) + ss;
  680. X
  681. X    /* adjust for local timezone */
  682. X    /* This seems ok, if you undefine __STRICT_ANSI__; use tzset(). [cjh] */
  683. X    tzset();              /* get `timezone' */
  684. X    m_time += timezone;   /* seconds WEST of GMT:  add */
  685. X
  686. X    /* adjust for daylight savings time (or local equivalent) */
  687. X    if (localtime(&m_time)->tm_isdst)
  688. X        m_time -= 60L * 60L;   /* adjust for daylight savings time */
  689. X
  690. X    /* set the file's access and modification times */
  691. X    tp.actime = tp.modtime = m_time;
  692. X    if (utime(filename, &tp))
  693. X        fprintf(stderr, "warning:  can't set the time for %s\n", filename);
  694. X
  695. X} /* end function close_outfile() */
  696. X
  697. X
  698. X
  699. X
  700. X#ifndef SFX
  701. X
  702. X/************************/
  703. X/*  Function version()  */
  704. X/************************/
  705. X
  706. Xvoid version()
  707. X{
  708. X    extern char Far  CompiledWith[];
  709. X#ifdef __TURBOC__
  710. X    char buf[40];
  711. X#endif
  712. X
  713. X    printf(LoadFarString(CompiledWith),
  714. X
  715. X#ifdef __GNUC__
  716. X      "gcc ", __VERSION__,
  717. X#else
  718. X#  if 0
  719. X      "cc ", (sprintf(buf, " version %d", _RELEASE), buf),
  720. X#  else
  721. X#  ifdef __TURBOC__
  722. X      "Turbo C", (sprintf(buf, " (0x%04x = %d)", __TURBOC__, __TURBOC__), buf),
  723. X#  else
  724. X      "unknown compiler", "",
  725. X#  endif
  726. X#  endif
  727. X#endif
  728. X
  729. X#ifdef __MINT__
  730. X      "Atari TOS/MiNT",
  731. X#else
  732. X      "Atari TOS",
  733. X#endif
  734. X
  735. X#if defined(atarist) || defined(ATARIST)
  736. X      " (Atari ST/TT/Falcon030)",
  737. X#else
  738. X      "",
  739. X#endif
  740. X
  741. X#ifdef __DATE__
  742. X      " on ", __DATE__
  743. X#else
  744. X      "", ""
  745. X#endif
  746. X      );
  747. X
  748. X} /* end function version() */
  749. X
  750. X#endif /* !SFX */
  751. END_OF_FILE
  752.   if test 26647 -ne `wc -c <'unzip-5.12/atari/atari.c'`; then
  753.     echo shar: \"'unzip-5.12/atari/atari.c'\" unpacked with wrong size!
  754.   fi
  755.   # end of 'unzip-5.12/atari/atari.c'
  756. fi
  757. if test -f 'unzip-5.12/match.c' -a "${1}" != "-c" ; then 
  758.   echo shar: Will not clobber existing file \"'unzip-5.12/match.c'\"
  759. else
  760.   echo shar: Extracting \"'unzip-5.12/match.c'\" \(10263 characters\)
  761.   sed "s/^X//" >'unzip-5.12/match.c' <<'END_OF_FILE'
  762. X/*---------------------------------------------------------------------------
  763. X
  764. X  match.c
  765. X
  766. X  The match() routine recursively compares a string to a "pattern" (regular
  767. X  expression), returning TRUE if a match is found or FALSE if not.  This
  768. X  version is specifically for use with unzip.c:  as did the previous match()
  769. X  routines from SEA and J. Kercheval, it leaves the case (upper, lower, or
  770. X  mixed) of the string alone, but converts any uppercase characters in the
  771. X  pattern to lowercase if indicated by the global var pInfo->lcflag (which
  772. X  is to say, string is assumed to have been converted to lowercase already,
  773. X  if such was necessary).
  774. X
  775. X  GRR:  reversed order of text, pattern in matche() (now same as match());
  776. X        added ignore_case/ic flags, Case() macro.
  777. X
  778. X  PaulK:  replaced matche() with recmatch() from Zip, modified to have an
  779. X          ignore_case argument; replaced test frame with simpler one.
  780. X
  781. X  ---------------------------------------------------------------------------
  782. X
  783. X  Copyright on recmatch() from Zip's util.c (although recmatch() was almost
  784. X  certainly written by Mark Adler...ask me how I can tell :-) ):
  785. X
  786. X     Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  787. X     Kai Uwe Rommel and Igor Mandrichenko.
  788. X
  789. X     Permission is granted to any individual or institution to use, copy,
  790. X     or redistribute this software so long as all of the original files are
  791. X     included unmodified, that it is not sold for profit, and that this copy-
  792. X     right notice is retained.
  793. X
  794. X  ---------------------------------------------------------------------------
  795. X
  796. X  Match the pattern (wildcard) against the string (fixed):
  797. X
  798. X     match(string, pattern, ignore_case);
  799. X
  800. X  returns TRUE if string matches pattern, FALSE otherwise.  In the pattern:
  801. X
  802. X     `*' matches any sequence of characters (zero or more)
  803. X     `?' matches any single character
  804. X     [SET] matches any character in the specified set,
  805. X     [!SET] or [^SET] matches any character not in the specified set.
  806. X
  807. X  A set is composed of characters or ranges; a range looks like ``character
  808. X  hyphen character'' (as in 0-9 or A-Z).  [0-9a-zA-Z_] is the minimal set of
  809. X  characters allowed in the [..] pattern construct.  Other characters are
  810. X  allowed (i.e., 8-bit characters) if your system will support them.
  811. X
  812. X  To suppress the special syntactic significance of any of ``[]*?!^-\'', in-
  813. X  side or outside a [..] construct and match the character exactly, precede
  814. X  it with a ``\'' (backslash).
  815. X
  816. X  Note that "*.*" and "*." are treated specially under MS-DOS if DOSWILD is
  817. X  defined.  See the DOSWILD section below for an explanation.  Note also
  818. X  that with VMSWILD defined, '%' is used instead of '?', and sets (ranges)
  819. X  are delimited by () instead of [].
  820. X
  821. X  ---------------------------------------------------------------------------*/
  822. X
  823. X
  824. X
  825. X/* define ToLower() in here (for Unix, define ToLower to be macro (using
  826. X * isupper()); otherwise just use tolower() */
  827. X#include "unzip.h"
  828. X
  829. X#if 0  /* this is not useful until it matches Amiga names insensitively */
  830. X#ifdef AMIGA        /* some other platforms might also want to use this */
  831. X#  define ANSI_CHARSET       /* MOVE INTO UNZIP.H EVENTUALLY */
  832. X#endif
  833. X#endif /* 0 */
  834. X  
  835. X#ifdef ANSI_CHARSET
  836. X#  ifdef ToLower
  837. X#    undef ToLower
  838. X#  endif
  839. X   /* uppercase letters are values 41 thru 5A, C0 thru D6, and D8 thru DE */
  840. X#  define IsUpper(c) (c>=0xC0 ? c<=0xDE && c!=0xD7 : c>=0x41 && c<=0x5A)
  841. X#  define ToLower(c) (IsUpper((uch) c) ? (unsigned) c | 0x20 : (unsigned) c)
  842. X#endif
  843. X#define Case(x)  (ic? ToLower(x) : (x))
  844. X
  845. X#ifdef VMSWILD
  846. X#  define WILDCHAR   '%'
  847. X#  define BEG_RANGE  '('
  848. X#  define END_RANGE  ')'
  849. X#else
  850. X#  define WILDCHAR   '?'
  851. X#  define BEG_RANGE  '['
  852. X#  define END_RANGE  ']'
  853. X#endif
  854. X
  855. X#if 0                /* GRR:  add this to unzip.h someday... */
  856. X#if !(defined(MSDOS) && defined(DOSWILD))
  857. X#define match(s,p,ic)   (recmatch((uch *)p,(uch *)s,ic) == 1)
  858. Xint recmatch OF((uch *pattern, uch *string, int ignore_case));
  859. X#endif
  860. X#endif /* 0 */
  861. Xstatic int recmatch OF((uch *pattern, uch *string, int ignore_case));
  862. X
  863. X
  864. X
  865. X/* match() is a shell to recmatch() to return only Boolean values. */
  866. X
  867. Xint match(string, pattern, ignore_case)
  868. X    char *string, *pattern;
  869. X    int ignore_case;
  870. X{
  871. X#if (defined(MSDOS) && defined(DOSWILD))
  872. X    char *dospattern;
  873. X    int j = strlen(pattern);
  874. X
  875. X/*---------------------------------------------------------------------------
  876. X    Optional MS-DOS preprocessing section:  compare last three chars of the
  877. X    wildcard to "*.*" and translate to "*" if found; else compare the last
  878. X    two characters to "*." and, if found, scan the non-wild string for dots.
  879. X    If in the latter case a dot is found, return failure; else translate the
  880. X    "*." to "*".  In either case, continue with the normal (Unix-like) match
  881. X    procedure after translation.  (If not enough memory, default to normal
  882. X    match.)  This causes "a*.*" and "a*." to behave as MS-DOS users expect.
  883. X  ---------------------------------------------------------------------------*/
  884. X
  885. X    if ((dospattern = (char *)malloc(j+1)) != NULL) {
  886. X        strcpy(dospattern, pattern);
  887. X        if (!strcmp(dospattern+j-3, "*.*")) {
  888. X            dospattern[j-2] = '\0';                    /* nuke the ".*" */
  889. X        } else if (!strcmp(dospattern+j-2, "*.")) {
  890. X            char *p = strchr(string, '.');
  891. X
  892. X            if (p) {   /* found a dot:  match fails */
  893. X                free(dospattern);
  894. X                return 0;
  895. X            }
  896. X            dospattern[j-1] = '\0';                    /* nuke the end "." */
  897. X        }
  898. X        j = recmatch((uch *)dospattern, (uch *)string, ignore_case);
  899. X        free(dospattern);
  900. X        return j == 1;
  901. X    } else
  902. X#endif /* MSDOS && DOSWILD */
  903. X    return recmatch((uch *)pattern, (uch *)string, ignore_case) == 1;
  904. X}
  905. X
  906. X
  907. X
  908. Xstatic int recmatch(p, s, ic)
  909. X    uch *p;               /* sh pattern to match */
  910. X    uch *s;               /* string to which to match it */
  911. X    int ic;               /* true for case insensitivity */
  912. X/* Recursively compare the sh pattern p with the string s and return 1 if
  913. X * they match, and 0 or 2 if they don't or if there is a syntax error in the
  914. X * pattern.  This routine recurses on itself no more deeply than the number
  915. X * of characters in the pattern. */
  916. X{
  917. X    unsigned int c;       /* pattern char or start of range in [-] loop */ 
  918. X
  919. X    /* Get first character, the pattern for new recmatch calls follows */
  920. X    c = *p++;
  921. X
  922. X    /* If that was the end of the pattern, match if string empty too */
  923. X    if (c == 0)
  924. X        return *s == 0;
  925. X
  926. X    /* '?' (or '%') matches any character (but not an empty string) */
  927. X    if (c == WILDCHAR)
  928. X        return *s ? recmatch(p, s + 1, ic) : 0;
  929. X
  930. X    /* '*' matches any number of characters, including zero */
  931. X#ifdef AMIGA
  932. X    if (c == '#' && *p == '?')     /* "#?" is Amiga-ese for "*" */
  933. X        c = '*', p++;
  934. X#endif /* AMIGA */
  935. X    if (c == '*') {
  936. X        if (*p == 0)
  937. X            return 1;
  938. X        for (; *s; s++)
  939. X            if ((c = recmatch(p, s, ic)) != 0)
  940. X                return (int)c;
  941. X        return 2;       /* 2 means give up--match will return false */
  942. X    }
  943. X
  944. X    /* Parse and process the list of characters and ranges in brackets */
  945. X    if (c == BEG_RANGE) {
  946. X        int e;          /* flag true if next char to be taken literally */
  947. X        uch *q;         /* pointer to end of [-] group */
  948. X        int r;          /* flag true to match anything but the range */
  949. X
  950. X        if (*s == 0)                           /* need a character to match */
  951. X            return 0;
  952. X        p += (r = (*p == '!' || *p == '^'));   /* see if reverse */
  953. X        for (q = p, e = 0; *q; q++)            /* find closing bracket */
  954. X            if (e)
  955. X                e = 0;
  956. X            else
  957. X                if (*q == '\\')      /* GRR:  change to ^ for MS-DOS, OS/2? */
  958. X                    e = 1;
  959. X                else if (*q == END_RANGE)
  960. X                    break;
  961. X        if (*q != END_RANGE)         /* nothing matches if bad syntax */
  962. X            return 0;
  963. X        for (c = 0, e = *p == '-'; p < q; p++) {  /* go through the list */
  964. X            if (e == 0 && *p == '\\')             /* set escape flag if \ */
  965. X                e = 1;
  966. X            else if (e == 0 && *p == '-')         /* set start of range if - */
  967. X                c = *(p-1);
  968. X            else {
  969. X                unsigned int cc = Case(*s);
  970. X
  971. X                if (*(p+1) != '-')
  972. X                    for (c = c ? c : *p; c <= *p; c++)  /* compare range */
  973. X                        if ((unsigned)Case(c) == cc)  /* typecast for MSC bug */
  974. X                            return r ? 0 : recmatch(q + 1, s + 1, ic);
  975. X                c = e = 0;   /* clear range, escape flags */
  976. X            }
  977. X        }
  978. X        return r ? recmatch(q + 1, s + 1, ic) : 0;  /* bracket match failed */
  979. X    }
  980. X
  981. X    /* if escape ('\'), just compare next character */
  982. X    if (c == '\\' && (c = *p++) == 0)     /* if \ at end, then syntax error */
  983. X        return 0;
  984. X
  985. X    /* just a character--compare it */
  986. X    return Case((uch)c) == Case(*s) ? recmatch(p, ++s, ic) : 0;
  987. X
  988. X} /* end function recmatch() */
  989. X
  990. X
  991. X
  992. X
  993. X
  994. Xint iswild(p)        /* originally only used for stat()-bug workaround in */
  995. X    char *p;         /*  VAX C, Turbo/Borland C, Watcom C, Atari MiNT libs; */
  996. X{                    /*  now used in process_zipfiles() as well */
  997. X    for (; *p; ++p)
  998. X        if (*p == '\\' && *(p+1))
  999. X            ++p;
  1000. X#ifdef VMS
  1001. X        else if (*p == '%' || *p == '*')
  1002. X#else /* !VMS */
  1003. X#ifdef AMIGA
  1004. X        else if (*p == '?' || *p == '*' || (*p=='#' && p[1]=='?') || *p == '[')
  1005. X#else /* !AMIGA */
  1006. X        else if (*p == '?' || *p == '*' || *p == '[')
  1007. X#endif /* ?AMIGA */
  1008. X#endif /* ?VMS */
  1009. X            return TRUE;
  1010. X
  1011. X    return FALSE;
  1012. X
  1013. X} /* end function iswild() */
  1014. X
  1015. X
  1016. X
  1017. X
  1018. X
  1019. X#ifdef TEST_MATCH
  1020. X
  1021. X#define put(s) {fputs(s,stdout); fflush(stdout);}
  1022. X
  1023. Xvoid main()
  1024. X{
  1025. X    char pat[256], str[256];
  1026. X
  1027. X    for (;;) {
  1028. X        put("Pattern (return to exit): ");
  1029. X        gets(pat);
  1030. X        if (!pat[0])
  1031. X            break;
  1032. X        for (;;) {
  1033. X            put("String (return for new pattern): ");
  1034. X            gets(str);
  1035. X            if (!str[0])
  1036. X                break;
  1037. X            printf("Case sensitive: %s  insensitive: %s\n",
  1038. X              match(str, pat, 0) ? "YES" : "NO",
  1039. X              match(str, pat, 1) ? "YES" : "NO");
  1040. X        }
  1041. X    }
  1042. X    exit(0);
  1043. X}
  1044. X
  1045. X#endif /* TEST_MATCH */
  1046. END_OF_FILE
  1047.   if test 10263 -ne `wc -c <'unzip-5.12/match.c'`; then
  1048.     echo shar: \"'unzip-5.12/match.c'\" unpacked with wrong size!
  1049.   fi
  1050.   # end of 'unzip-5.12/match.c'
  1051. fi
  1052. if test -f 'unzip-5.12/unix/unzip.1' -a "${1}" != "-c" ; then 
  1053.   echo shar: Will not clobber existing file \"'unzip-5.12/unix/unzip.1'\"
  1054. else
  1055.   echo shar: Extracting \"'unzip-5.12/unix/unzip.1'\" \(30113 characters\)
  1056.   sed "s/^X//" >'unzip-5.12/unix/unzip.1' <<'END_OF_FILE'
  1057. X.\" Info-ZIP grants permission to any individual or institution to use, copy,
  1058. X.\" or redistribute this software, so long as:  (1) all of the original files
  1059. X.\" are included; (2) it is not sold for profit; and (3) this notice is re-
  1060. X.\" tained.
  1061. X.\"
  1062. X.\" unzip.1 by Greg Roelofs, Fulvio Marino, Jim van Zandt and others.
  1063. X.\"
  1064. X.\" =========================================================================
  1065. X.\" define .Y macro (for user-command examples; normal Courier font):
  1066. X.de Y
  1067. X.ft CW
  1068. X.in +4n
  1069. X.nf
  1070. X\&\\$1
  1071. X.ft
  1072. X.in
  1073. X.fi
  1074. X..
  1075. X.\" =========================================================================
  1076. X.TH UNZIP 1L "28 Aug 94 (v5.12)"
  1077. X.SH NAME
  1078. Xunzip \- list, test and extract compressed files in a ZIP archive
  1079. X.PD
  1080. X.\" =========================================================================
  1081. X.SH SYNOPSIS
  1082. X\fBunzip\fP [\fB\-Z\fP] [\fB\-cflptuvz\fP[\fBabjnoqsCLV$\fP]]
  1083. X\fIfile\fP[\fI.zip\fP] [\fIfile(s)\fP\ .\|.\|.]
  1084. X[\fB\-x\fP\ \fIxfile(s)\fP\ .\|.\|.] [\fB\-d\fP\ \fIexdir\fP]
  1085. X.PD
  1086. X.\" =========================================================================
  1087. X.SH DESCRIPTION
  1088. X\fIunzip\fP will list, test, or extract files from a ZIP archive, commonly
  1089. Xfound on MS-DOS systems.  The default behavior (with no options) is to extract
  1090. Xinto the current directory (and subdirectories below it) all files from the 
  1091. Xspecified ZIP archive.  A companion program, \fIzip\fP(1L), creates ZIP 
  1092. Xarchives; both programs are compatible with archives created by PKWARE's 
  1093. X\fIPKZIP\fP and \fIPKUNZIP\fP for MS-DOS, but in many cases the program 
  1094. Xoptions or default behaviors differ.
  1095. X.PD
  1096. X.\" =========================================================================
  1097. X.SH ARGUMENTS
  1098. X.TP
  1099. X.IR file [ .zip ]
  1100. XPath of the ZIP archive(s).  If the file specification is a wildcard,
  1101. Xeach matching file is processed in an order determined by the operating
  1102. Xsystem (or file system).  Only the filename can be a wildcard; the path
  1103. Xitself cannot.  Wildcard expressions are similar to Unix \fIegrep\fP(1)
  1104. X(regular) expressions and may contain:
  1105. X.RS
  1106. X.IP *
  1107. Xmatches a sequence of 0 or more characters
  1108. X.IP ?
  1109. Xmatches exactly 1 character
  1110. X.IP [.\|.\|.]
  1111. Xmatches any single character found inside the brackets; ranges are specified
  1112. Xby a beginning character, a hyphen, and an ending character.  If an exclamation
  1113. Xpoint or a caret (`!' or `^') follows the left bracket, then the range of 
  1114. Xcharacters within the brackets is complemented (that is, anything \fIexcept\fP
  1115. Xthe characters inside the brackets is considered a match).
  1116. X.RE
  1117. X.IP
  1118. X(Be sure to quote any character which might otherwise be interpreted or
  1119. Xmodified by the operating system, particularly under Unix and VMS.)  If no
  1120. Xmatches are found, the specification is assumed to be a literal filename; 
  1121. Xand if that also fails, the suffix \fC.zip\fP is appended.  Note that 
  1122. Xself-extracting ZIP files are supported, as with any other ZIP archive;
  1123. Xjust specify the \fC.exe\fP suffix (if any) explicitly.
  1124. X.IP [\fIfile(s)\fP]
  1125. XAn optional list of archive members to be processed, separated by spaces.
  1126. X(VMS versions compiled with VMSCLI defined must delimit files with commas
  1127. Xinstead.  See \fB\-v\fP in \fBOPTIONS\fP below.)
  1128. XRegular expressions (wildcards) may be used to match multiple members; see
  1129. Xabove.  Again, be sure to quote expressions that would otherwise be expanded
  1130. Xor modified by the operating system.
  1131. X.IP [\fB\-x\fP\ \fIxfile(s)\fP]
  1132. XAn optional list of archive members to be excluded from processing.
  1133. XSince wildcard characters match directory separators (`/'), this option
  1134. Xmay be used to exclude any files which are in subdirectories.  For
  1135. Xexample, ``\fCunzip foo *.[ch] -x */*\fR'' would extract all C source files
  1136. Xin the main directory, but none in any subdirectories.  Without the \fB\-x\fP
  1137. Xoption, all C source files in all directories within the zipfile would be
  1138. Xextracted.
  1139. X.IP [\fB\-d\fP\ \fIexdir\fP]
  1140. XAn optional directory to which to extract files.  By default, all files
  1141. Xand subdirectories are recreated in the current directory; the \fB\-d\fP
  1142. Xoption allows extraction in an arbitrary directory (always assuming one
  1143. Xhas permission to write to the directory).  This option need not appear
  1144. Xat the end of the command line; it is also accepted immediately after the
  1145. Xzipfile specification, or between the \fIfile(s)\fP and the \fB\-x\fP
  1146. Xoption.  The option and directory may
  1147. Xbe concatenated without any white space between them, but note that this
  1148. Xmay cause normal shell behavior to be suppressed.  In particular,
  1149. X``\fC\-d\ ~\fR'' (tilde) is expanded by Unix C shells into the name 
  1150. Xof the user's home directory, but ``\fC\-d~\fR'' is treated as a
  1151. Xliteral subdirectory ``\fB~\fP'' of the current directory.
  1152. X.\" =========================================================================
  1153. X.SH OPTIONS
  1154. XNote that, in order to support obsolescent hardware, \fIunzip\fP's usage
  1155. Xscreen is limited to 22 or 23 lines and should therefore be considered a
  1156. Xreminder of the basic \fIunzip\fP syntax rather than an exhaustive list
  1157. Xof all possible flags.
  1158. X.TP
  1159. X.B \-Z
  1160. X\fIzipinfo\fP(1L) mode.  If the first option on the command line is \fB\-Z\fP,
  1161. Xthe remaining options are taken to be \fIzipinfo\fP(1L) options.  See the
  1162. Xappropriate manual page for a description of these options.
  1163. X.TP
  1164. X.B \-c
  1165. Xextract files to stdout/screen (``CRT'').  This option is similar to the
  1166. X\fB\-p\fP option except that the name of each file is printed as it is
  1167. Xextracted, the \fB\-a\fP option is allowed, and ASCII-EBCDIC conversion
  1168. Xis automatically performed if appropriate.  This option is not listed in
  1169. Xthe \fIunzip\fP usage screen.
  1170. X.TP
  1171. X.B \-f
  1172. Xfreshen existing files, i.e., extract only those files which
  1173. Xalready exist on disk and which are newer than the disk copies.  By
  1174. Xdefault \fIunzip\fP queries before overwriting, but the \fB\-o\fP option
  1175. Xmay be used to suppress the queries.  Note that under many operating systems,
  1176. Xthe TZ (timezone) environment variable must be set correctly in order for 
  1177. X\fB\-f\fP and \fB\-u\fP to work properly (under Unix the variable is usually
  1178. Xset automatically).  The reasons for this are somewhat subtle but 
  1179. Xhave to do with the differences between DOS-format file times (always local 
  1180. Xtime) and Unix-format times (always in GMT) and the necessity to compare the
  1181. Xtwo.  A typical TZ value is ``PST8PDT'' (US Pacific time with automatic
  1182. Xadjustment for Daylight Savings Time or ``summer time'').
  1183. X.TP
  1184. X.B \-l
  1185. Xlist archive files (short format).  The names, uncompressed file sizes and
  1186. Xmodification dates and times of the specified files are printed, along
  1187. Xwith totals for all files specified.  In addition, the zipfile comment and 
  1188. Xindividual file comments (if any) are displayed.  If a file was archived 
  1189. Xfrom a single-case file system (for example, the old MS-DOS FAT file system) 
  1190. Xand the \fB\-L\fP option was given, the filename is converted to lowercase 
  1191. Xand is prefixed with a caret (^).
  1192. X.TP
  1193. X.B \-p
  1194. Xextract files to pipe (stdout).  Nothing but the file data is sent to
  1195. Xstdout, and the files are always extracted in binary format, just as they
  1196. Xare stored (no conversions).
  1197. X.TP
  1198. X.B \-t
  1199. Xtest archive files.  This option extracts each specified file in memory
  1200. Xand compares the CRC (cyclic redundancy check, an enhanced checksum) of 
  1201. Xthe expanded file with the original file's stored CRC value.
  1202. X.TP
  1203. X.B \-u
  1204. Xupdate existing files and create new ones if needed.  This option performs
  1205. Xthe same function as the \fB\-f\fP option, extracting (with query) files
  1206. Xwhich are newer than those with the same name on disk, and in addition it
  1207. Xextracts those files which do not already exist on disk.  See \fB\-f\fP 
  1208. Xabove for information on setting the timezone properly.
  1209. X.TP
  1210. X.B \-v
  1211. Xbe verbose or print diagnostic version info.  This option has evolved and
  1212. Xnow behaves as both an option and a modifier.  As an option it has two
  1213. Xpurposes:  when a zipfile is specified with no other options, \fB\-v\fP
  1214. Xlists archive files verbosely, adding to the \fB\-l\fP info the compression 
  1215. Xmethod, compressed size, compression ratio and 32-bit CRC.  When no zipfile
  1216. Xis specified (that is, the complete command is simply ``\fCunzip -v\fR''), a
  1217. Xdiagnostic screen is printed.  In addition to the normal header with release
  1218. Xdate and version, \fIunzip\fP lists the home Info-ZIP ftp site and where to 
  1219. Xfind a list of other ftp and non-ftp sites; the target operating system for 
  1220. Xwhich it was compiled, as well as (possibly) the hardware on which it was 
  1221. Xcompiled, the compiler and version used, and the compilation date; any special 
  1222. Xcompilation options which might affect the program's operation (see also
  1223. X\fBDECRYPTION\fP below); and any options stored in environment variables 
  1224. Xwhich might do the same (see \fBENVIRONMENT OPTIONS\fP below).  As a
  1225. Xmodifier it works in conjunction with other options (e.g., \fB\-t\fP) to
  1226. Xproduce more verbose or debugging output; this is not yet fully implemented
  1227. Xbut will be in future releases.
  1228. X.TP
  1229. X.B \-z
  1230. Xdisplay only the archive comment.
  1231. X.PD
  1232. X.\" =========================================================================
  1233. X.SH MODIFIERS
  1234. X.TP
  1235. X.B \-a
  1236. Xconvert text files.  Ordinarily all files are extracted exactly as they
  1237. Xare stored (as ``binary'' files).  The \fB\-a\fP option causes files identified
  1238. Xby \fIzip\fP as text files (those with the `t' label in \fIzipinfo\fP
  1239. Xlistings, rather than `b') to be automatically extracted as such, converting
  1240. Xline endings, end-of-file characters and the character set itself as necessary.
  1241. X(For example, Unix files use line feeds (LFs) for end-of-line (EOL) and
  1242. Xhave no end-of-file (EOF) marker; Macintoshes use carriage returns (CRs)
  1243. Xfor EOLs; and most PC operating systems use CR+LF for EOLs and control-Z for 
  1244. XEOF.  In addition, IBM mainframes and the Michigan Terminal System use EBCDIC
  1245. Xrather than the more common ASCII character set, and NT supports Unicode.)
  1246. XNote that \fIzip\fP's identification of text files is by no means perfect; some
  1247. X``text'' files may actually be binary and vice versa.  \fIunzip\fP therefore
  1248. Xprints ``\fC[text]\fR'' or ``\fC[binary]\fR'' as a visual check for each file 
  1249. Xit extracts when using the \fB\-a\fP option.  The \fB\-aa\fP option forces 
  1250. Xall files to be extracted as text, regardless of the supposed file type.
  1251. X.TP
  1252. X.B \-b
  1253. Xtreat all files as binary (no text conversions).  This is a shortcut for
  1254. X\fB\-\-\-a\fP.
  1255. X.TP
  1256. X.B \-C
  1257. Xmatch filenames case-insensitively.  \fIunzip\fP's philosophy is ``you get
  1258. Xwhat you ask for'' (this is also responsible for the \fB\-L\fP/\fB\-U\fP 
  1259. Xchange; see the relevant options below).  Because some filesystems are fully
  1260. Xcase-sensitive (notably those under the Unix operating system) and because
  1261. Xboth ZIP archives and \fIunzip\fP itself are portable across platforms,
  1262. X\fIunzip\fP's default behavior is to match both wildcard and literal filenames
  1263. Xcase-sensitively.  That is, specifying ``\fCmakefile\fR'' on the command line
  1264. Xwill \fIonly\fP match ``makefile'' in the archive, not ``Makefile'' or
  1265. X``MAKEFILE'' (and similarly for wildcard specifications).  Since this does
  1266. Xnot correspond to the behavior of many other operating/file systems (for 
  1267. Xexample, OS/2 HPFS which preserves mixed case but is not sensitive to it),
  1268. Xthe \fB\-C\fP option may be used to force all filename matches to be 
  1269. Xcase-insensitive.  In the example above, all three files would then match 
  1270. X``\fCmakefile\fR'' (or ``\fCmake*\fR'', or similar).  The \fB\-C\fP option
  1271. Xaffects files in both the normal file list and the excluded-file list (xlist).
  1272. X.TP
  1273. X.B \-j
  1274. Xjunk paths.  The archive's directory structure is not recreated; all files
  1275. Xare deposited in the extraction directory (by default, the current one).
  1276. X.TP
  1277. X.B \-L
  1278. Xconvert to lowercase any filename originating on an uppercase-only operating 
  1279. Xsystem or filesystem.  (This was \fIunzip\fP's default behavior in releases 
  1280. Xprior to 5.11; the new default behavior is identical to the old behavior with 
  1281. Xthe \fB\-U\fP option, which is now obsolete and will be removed in a future 
  1282. Xrelease.)  Depending on the archiver, files archived under single-case 
  1283. Xfilesystems (VMS, old MS-DOS FAT, etc.) may be stored as all-uppercase names; 
  1284. Xthis can be ugly or inconvenient when extracting to a case-preserving 
  1285. Xfilesystem such as OS/2 HPFS or a case-sensitive one such as under
  1286. XUnix.  By default \fIunzip\fP lists and extracts such filenames exactly as 
  1287. Xthey're stored (excepting truncation, conversion of unsupported characters, 
  1288. Xetc.); this option causes the names of all files from certain systems to be 
  1289. Xconverted to lowercase.
  1290. X.TP
  1291. X.B \-n
  1292. Xnever overwrite existing files.  If a file already exists, skip the extraction
  1293. Xof that file without prompting.  By default \fIunzip\fP queries before
  1294. Xextracting any file which already exists; the user may choose to overwrite
  1295. Xonly the current file, overwrite all files, skip extraction of the current
  1296. Xfile, skip extraction of all existing files, or rename the current file.
  1297. X.TP
  1298. X.B \-o
  1299. Xoverwrite existing files without prompting.  This is a dangerous option, so
  1300. Xuse it with care.  (It is often used with \fB\-f\fP, however.)
  1301. X.TP
  1302. X.B \-q
  1303. Xperform operations quietly (\fB\-qq\fP = even quieter).  Ordinarily \fIunzip\fP
  1304. Xprints the names of the files it's extracting or testing, the extraction
  1305. Xmethods, any file or zipfile comments which may be stored in the archive,
  1306. Xand possibly a summary when finished with each archive.  The \fB\-q\fP[\fBq\fP]
  1307. Xoptions suppress the printing of some or all of these messages.
  1308. X.TP
  1309. X.B \-s
  1310. X[OS/2, NT, MS-DOS] convert spaces in filenames to underscores.  Since all PC
  1311. Xoperating systems allow spaces in filenames, \fIunzip\fP by default extracts 
  1312. Xfilenames with spaces intact (e.g., ``\fCEA\ DATA.\ SF\fR'').  This can be
  1313. Xawkward, however, since MS-DOS in particular does not gracefully support 
  1314. Xspaces in filenames.  Conversion of spaces to underscores can eliminate the 
  1315. Xawkwardness in some cases.
  1316. X.TP
  1317. X.B \-U
  1318. X(obsolete; to be removed in a future release) leave filenames uppercase if 
  1319. Xcreated under MS-DOS, VMS, etc.  See \fB\-L\fP above.
  1320. X.TP
  1321. X.B \-V
  1322. Xretain (VMS) file version numbers.  VMS files can be stored with a version
  1323. Xnumber, in the format \fCfile.ext;##\fP.  By default the ``\fC;##\fR'' version 
  1324. Xnumbers are stripped, but this option allows them to be retained.  (On 
  1325. Xfilesystems which limit filenames to particularly short lengths, the version 
  1326. Xnumbers may be truncated or stripped regardless of this option.)
  1327. X.TP
  1328. X.B \-X
  1329. X[VMS] restore owner/protection info (may require system privileges).  Ordinary
  1330. Xfile attributes are always restored, but this option allows UICs to be restored
  1331. Xas well.  [The next version of \fIunzip\fP will support Unix UID/GID info as 
  1332. Xwell, and possibly NT permissions.]
  1333. X.TP
  1334. X.B \-$
  1335. X[MS-DOS, OS/2, NT, Amiga] restore the volume label if the extraction medium is
  1336. Xremovable (e.g., a diskette).  Doubling the option (\fB\-$$\fP) allows fixed
  1337. Xmedia (hard disks) to be labelled as well.  By default, volume labels are
  1338. Xignored.
  1339. X.PD
  1340. X.\" =========================================================================
  1341. X.SH ENVIRONMENT OPTIONS
  1342. X\fIunzip\fP's default behavior may be modified via options placed in
  1343. Xan environment variable.  This can be done with any option, but it
  1344. Xis probably most useful with the \fB\-a\fP, \fB\-L\fP, \fB\-C\fP, \fB\-q\fP, 
  1345. X\fB\-o\fP, or \fB\-n\fP modifiers:  make \fIunzip\fP auto-convert text 
  1346. Xfiles by default, make it convert filenames from uppercase systems to 
  1347. Xlowercase, make it match names case-insensitively, make it quieter,
  1348. Xor make it always overwrite or never overwrite files as it extracts
  1349. Xthem.  For example, to make \fIunzip\fP act as quietly as possible, only
  1350. Xreporting errors, one would use one of the following commands:
  1351. X.LP
  1352. X.DT
  1353. X.ft CW
  1354. X.in +4n
  1355. X.ta \w'UNZIP=\-qq; export UNZIP'u+4n
  1356. X.in
  1357. X.ft
  1358. X.PD 0
  1359. X.Y "UNZIP=\-qq; export UNZIP\t\fRUnix Bourne shell"
  1360. X.Y "setenv UNZIP \-qq\t\fRUnix C shell"
  1361. X.Y "set UNZIP=\-qq\t\fROS/2 or MS-DOS"
  1362. X.Y "define UNZIP_OPTS ""\-qq""\t\fRVMS (quotes for \fIlowercase\fP)"
  1363. X.PD
  1364. X.LP
  1365. XEnvironment options are, in effect, considered to be just like any other
  1366. Xcommand-line options, except that they are effectively the first options
  1367. Xon the command line.  To override an environment option, one may use the
  1368. X``minus operator'' to remove it.  For instance, to override one of the 
  1369. Xquiet-flags in the example above, use the command
  1370. X.LP
  1371. X.Y "unzip \-\-q[\fIother options\fC] zipfile"
  1372. X.LP
  1373. XThe first hyphen is the normal
  1374. Xswitch character, and the second is a minus sign, acting on the q option.
  1375. XThus the effect here is to cancel one quantum of quietness.  To cancel
  1376. Xboth quiet flags, two (or more) minuses may be used:
  1377. X.LP
  1378. X.PD 0
  1379. X.Y "unzip \-t\-\-q zipfile"
  1380. X.Y "unzip \-\-\-qt zipfile"
  1381. X.PD
  1382. X.LP
  1383. X(the two are equivalent).  This may seem awkward
  1384. Xor confusing, but it is reasonably intuitive:  just ignore the first
  1385. Xhyphen and go from there.  It is also consistent with the behavior of
  1386. XUnix \fInice\fP(1).
  1387. X.LP
  1388. XAs suggested by the examples above, the default variable names are UNZIP_OPTS 
  1389. Xfor VMS (where the symbol used to install \fIunzip\fP as a foreign command
  1390. Xwould otherwise be confused with the environment variable), and UNZIP
  1391. Xfor all other operating systems.  For compatibility with \fIzip\fP(1L),
  1392. XUNZIPOPT is also accepted (don't ask).  If both UNZIP and UNZIPOPT
  1393. Xare defined, however, UNZIP takes precedence.  \fIunzip\fP's diagnostic
  1394. Xoption (\fB\-v\fP with no zipfile name) can be used to check the values
  1395. Xof all four possible \fIunzip\fP and \fIzipinfo\fP environment variables.
  1396. X.LP
  1397. XThe timezone variable (TZ) should be set according to the local timezone
  1398. Xin order for the \fB\-f\fP and \fB\-u\fP to operate correctly.  See the
  1399. Xdescription of \fB\-f\fP above for details.  This variable may also be
  1400. Xnecessary in order for timestamps on extracted files to be set correctly.
  1401. X.PD
  1402. X.\" =========================================================================
  1403. X.SH DECRYPTION
  1404. XEncrypted archives are fully supported by Info-ZIP software, but due to
  1405. XUnited States export restrictions, the encryption and decryption sources
  1406. Xare not packaged with the regular \fIunzip\fP and \fIzip\fP distributions.
  1407. XSince the crypt sources were written by Europeans, however, they are 
  1408. Xfreely available at sites throughout the world; see the file ``Where'' in 
  1409. Xany Info-ZIP source or binary distribution for locations both inside and
  1410. Xoutside the US.
  1411. X.LP
  1412. XBecause of the separate distribution, not all compiled versions of \fIunzip\fP
  1413. Xsupport decryption.  To check a version for crypt support, either attempt to
  1414. Xtest or extract an encrypted archive, or else check \fIunzip\fP's diagnostic
  1415. Xscreen (see the \fB\-v\fP option above) for ``\fC[decryption]\fR'' as one of
  1416. Xthe special compilation options.
  1417. X.LP
  1418. XThere are no runtime options for decryption; if a zipfile member is encrypted,
  1419. X\fIunzip\fP will prompt for the password without echoing what is typed.
  1420. X\fIunzip\fP continues to use the same password as long as it appears to be
  1421. Xvalid; it does this by testing a 12-byte header.  The correct password will
  1422. Xalways check out against the header, but there is a 1-in-256 chance that an
  1423. Xincorrect password will as well.  (This is a security feature of the PKWARE
  1424. Xzipfile format; it helps prevent brute-force attacks which might otherwise
  1425. Xgain a large speed advantage by testing only the header.)  In the case that
  1426. Xan incorrect password is 
  1427. Xgiven but it passes the header test anyway, either an incorrect CRC will be 
  1428. Xgenerated for the extracted data or else \fIunzip\fP will fail during the 
  1429. Xextraction because the ``decrypted'' bytes do not constitute a valid 
  1430. Xcompressed data stream.
  1431. X.LP
  1432. XIf the first password fails the header check on some file, \fIunzip\fP will
  1433. Xprompt for another password, and so on until all files are extracted.  If
  1434. Xa password is not known, entering a null password (that is, just a carriage
  1435. Xreturn) is taken as a signal to skip all further prompting.  Only unencrypted
  1436. Xfiles in the archive(s) will thereafter be extracted.  (Actually that's not
  1437. Xquite true; older versions of \fIzip\fP(1L) and \fIzipcloak\fP(1L) allowed
  1438. Xnull passwords, so \fIunzip\fP checks each encrypted file to see if the null
  1439. Xpassword works.  This may result in ``false positives'' and extraction
  1440. Xerrors, as noted above.)
  1441. X.LP
  1442. XNote that there is presently no way to avoid interactive decryption.  This
  1443. Xis another security feature:  plaintext passwords given on the command line 
  1444. Xor stored in files constitute a risk because they may be seen by others.
  1445. XFuture releases may (under protest, with great disapproval) support such 
  1446. Xshenanigans.
  1447. X.PD
  1448. X.\" =========================================================================
  1449. X.SH EXAMPLES
  1450. XTo use \fIunzip\fP to extract all members of the archive \fIletters.zip\fP
  1451. Xinto the current directory and subdirectories below it, creating any
  1452. Xsubdirectories as necessary:
  1453. X.LP
  1454. X.Y "unzip letters"
  1455. X.LP
  1456. XTo extract all members of \fIletters.zip\fP into the current directory only:
  1457. X.LP
  1458. X.Y "unzip -j letters"
  1459. X.LP
  1460. XTo test \fIletters.zip\fP, printing only a summary message indicating
  1461. Xwhether the archive is OK or not:
  1462. X.LP
  1463. X.Y "unzip -tq letters"
  1464. X.LP
  1465. XTo test \fIall\fP zipfiles in the current directory, printing only the
  1466. Xsummaries:
  1467. X.LP
  1468. X.Y "unzip -tq \e*.zip"
  1469. X.LP
  1470. X(The backslash before the asterisk is only required if the shell expands
  1471. Xwildcards, as in Unix; double quotes could have been used instead, as in
  1472. Xthe source examples below.)\ \ To extract to standard output all members of 
  1473. X\fIletters.zip\fP whose names end in \fI.tex\fP, auto-converting to the 
  1474. Xlocal end-of-line convention and piping the output into \fImore\fP(1):
  1475. X.LP
  1476. X.Y "unzip \-ca letters \e*.tex | more"
  1477. X.LP
  1478. XTo extract the binary file \fIpaper1.dvi\fP to standard output and pipe it 
  1479. Xto a printing program:
  1480. X.LP
  1481. X.Y "unzip \-p articles paper1.dvi | dvips"
  1482. X.LP
  1483. XTo extract all FORTRAN and C source files--*.f, *.c, *.h, and Makefile--into
  1484. Xthe /tmp directory:
  1485. X.LP
  1486. X.Y "unzip source.zip ""*.[fch]"" Makefile -d /tmp"
  1487. X.LP
  1488. X(the double quotes are necessary only in Unix and only if globbing is turned
  1489. Xon).  To extract all FORTRAN and C source files, regardless of case (e.g.,
  1490. Xboth *.c and *.C, and any makefile, Makefile, MAKEFILE or similar):
  1491. X.LP
  1492. X.Y "unzip \-C source.zip ""*.[fch]"" makefile -d /tmp"
  1493. X.LP
  1494. XTo extract any such files but convert any uppercase MS-DOS or VMS names to
  1495. Xlowercase and convert the line-endings of all of the files to the local
  1496. Xstandard (without respect to any files which might be marked ``binary''):
  1497. X.LP
  1498. X.Y "unzip \-aaCL source.zip ""*.[fch]"" makefile -d /tmp"
  1499. X.LP
  1500. XTo extract only newer versions of the files already in the current 
  1501. Xdirectory, without querying (NOTE:  be careful of unzipping in one timezone a 
  1502. Xzipfile created in another--ZIP archives to date contain no timezone 
  1503. Xinformation, and a ``newer'' file from an eastern timezone may, in fact, be
  1504. Xolder):
  1505. X.LP
  1506. X.Y "unzip \-fo sources"
  1507. X.LP
  1508. XTo extract newer versions of the files already in the current directory and
  1509. Xto create any files not already there (same caveat as previous example):
  1510. X.LP
  1511. X.Y "unzip \-uo sources"
  1512. X.LP
  1513. XTo display a diagnostic screen showing which \fIunzip\fP and \fIzipinfo\fP
  1514. Xoptions are stored in environment variables, whether decryption support was 
  1515. Xcompiled in, the compiler with which \fIunzip\fP was compiled, etc.:
  1516. X.LP
  1517. X.Y "unzip \-v"
  1518. X.LP
  1519. XIn the last five examples, assume that UNZIP or UNZIP_OPTS is set to -q.
  1520. XTo do a singly quiet listing:
  1521. X.LP
  1522. X.Y "unzip \-l file.zip"
  1523. X.LP
  1524. XTo do a doubly quiet listing:
  1525. X.LP
  1526. X.Y "unzip \-ql file.zip"
  1527. X.LP
  1528. X(Note that the ``\fC.zip\fR'' is generally not necessary.)  To do a standard
  1529. Xlisting:
  1530. X.LP
  1531. X.PD 0
  1532. X.Y "unzip \-\-ql file.zip"
  1533. X.LP
  1534. Xor
  1535. X.Y "unzip \-l\-q file.zip"
  1536. X.LP
  1537. Xor
  1538. X.Y "unzip \-l\-\-q file.zip\t\fR(extra minuses don't hurt)"
  1539. X.PD
  1540. X.\" =========================================================================
  1541. X.SH TIPS
  1542. XThe current maintainer, being a lazy sort, finds it very useful to define
  1543. Xa pair of aliases:  \fCtt\fP for ``\fCunzip \-tq\fR'' and \fCii\fP for 
  1544. X``\fCunzip \-Z\fR'' (or ``\fCzipinfo\fR'').  One may then simply type 
  1545. X``\fCtt zipfile\fR'' to test an archive, something which is worth making a 
  1546. Xhabit of doing.  With luck \fIunzip\fP will report ``\fCNo errors detected 
  1547. Xin zipfile.zip\fP,'' after which one may breathe a sigh of relief.
  1548. X.LP
  1549. XThe maintainer also finds it useful to set the UNZIP environment variable
  1550. Xto ``\fC\-aL\fR'' and is tempted to add ``\fC\-C\fR'' as well.  His ZIPINFO 
  1551. Xvariable is set to ``\fC\-z\fR''.
  1552. X.PD
  1553. X.\" =========================================================================
  1554. X.SH DIAGNOSTICS
  1555. XThe exit status (or error level) approximates the exit codes defined by PKWARE 
  1556. Xand takes on the following values, except under VMS:
  1557. X.RS
  1558. X.IP 0
  1559. Xnormal; no errors or warnings detected.
  1560. X.IP 1
  1561. Xone or more warning errors were encountered, but processing completed
  1562. Xsuccessfully anyway.  This includes zipfiles where one or more files
  1563. Xwas skipped due to unsupported compression method or encryption with an
  1564. Xunknown password.
  1565. X.IP 2
  1566. Xa generic error in the zipfile format was detected.  Processing may have
  1567. Xcompleted successfully anyway; some broken zipfiles created by other
  1568. Xarchivers have simple work-arounds.
  1569. X.IP 3
  1570. Xa severe error in the zipfile format was detected.  Processing probably
  1571. Xfailed immediately.
  1572. X.IP 4-8
  1573. X\fIunzip\fP was unable to allocate memory for one or more buffers.
  1574. X.IP 9
  1575. Xthe specified zipfiles were not found.
  1576. X.IP 10
  1577. Xinvalid options were specified on the command line.
  1578. X.IP 11
  1579. Xno matching files were found.
  1580. X.IP 50
  1581. Xthe disk is (or was) full during extraction.
  1582. X.IP 51
  1583. Xthe end of the ZIP archive was encountered prematurely.
  1584. X.RE
  1585. X.LP
  1586. XVMS interprets standard Unix (or PC) return values as other, scarier-looking
  1587. Xthings, so by default \fIunzip\fP always returns 0 (which reportedly gets
  1588. Xconverted into a VMS status of 1--i.e., success).  There are two compilation
  1589. Xoptions available to modify or expand upon this behavior:  defining
  1590. XRETURN_CODES results in a human-readable explanation of what the real
  1591. Xerror status was (but still with a faked ``success'' exit value), while
  1592. Xdefining RETURN_SEVERITY causes \fIunzip\fP to exit with a ``real'' VMS
  1593. Xstatus.  The latter behavior will become the default in future
  1594. Xversions unless it is found to conflict with officially defined VMS codes.
  1595. XThe current mapping is as follows:   1 (success) for normal exit, 0x7fff0001
  1596. Xfor warning errors, and (0x7fff000? + 16*normal_unzip_exit_status) for all
  1597. Xother errors, where the `?' is 2 (error) for \fIunzip\fP values 2 and 9-11,
  1598. Xand 4 (fatal error) for the remaining ones (3-8, 50, 51).  Check the 
  1599. X``\fCunzip \-v\fR'' output to see whether RETURN_SEVERITY was defined at 
  1600. Xcompilation time.
  1601. X.PD
  1602. X.\" =========================================================================
  1603. X.SH BUGS
  1604. XWhen attempting to extract a corrupted archive, \fIunzip\fP may go into
  1605. Xan infinite loop and, if not stopped quickly enough, fill all available disk
  1606. Xspace.  Compiling with CHECK_EOF should fix this problem for all zipfiles,
  1607. Xbut the option was introduced too late in the testing process to be made
  1608. Xthe default behavior.  Future versions will be robust enough to fail
  1609. Xgracefully on damaged archives.  Check the ``\fCunzip \-v\fR'' output to
  1610. Xsee whether CHECK_EOF was defined during compilation.
  1611. X.LP
  1612. X[MS-DOS] When extracting or testing files from an archive on a defective
  1613. Xfloppy diskette, if the ``Fail'' option is chosen from DOS's ``Abort, Retry,
  1614. XFail?'' message, \fIunzip\fP may hang the system, requiring a reboot.  Instead,
  1615. Xpress control-C (or control-Break) to terminate \fIunzip\fP.
  1616. X.LP
  1617. XUnder DEC Ultrix, \fIunzip\fP will sometimes fail on long zipfiles (bad CRC,
  1618. Xnot always reproducible).  This is apparently due either to a hardware bug
  1619. X(cache memory) or an operating system bug (improper handling of page faults?).
  1620. X.LP
  1621. XDates and times of stored directories are not restored.
  1622. X.LP
  1623. X[OS/2] Extended attributes for existing directories are never updated.  This
  1624. Xis a limitation of the operating system; \fIunzip\fP has no way to determine
  1625. Xwhether the stored attributes are newer or older than the existing ones.
  1626. X.LP
  1627. X[VMS] When extracting to another directory, only the \fI[.foo]\fP syntax is
  1628. Xaccepted for the \fB\-d\fP option; the simple Unix \fIfoo\fP syntax is
  1629. Xsilently ignored (as is the less common VMS \fIfoo.dir\fP syntax).
  1630. X.LP
  1631. X[VMS] When the file being extracted already exists, \fIunzip\fP's query only
  1632. Xallows skipping, overwriting or renaming; there should additionally be a 
  1633. Xchoice for creating a new version of the file.  In fact, the ``overwrite''
  1634. Xchoice does create a new version; the old version is not overwritten or
  1635. Xdeleted.
  1636. X.PD
  1637. X.\" =========================================================================
  1638. X.SH SEE ALSO
  1639. X\fIfunzip\fP(1L), \fIzip\fP(1L), \fIzipcloak\fP(1L), \fIzipgrep\fP(1L),
  1640. X\fIzipinfo\fP(1L), \fIzipnote\fP(1L), \fIzipsplit\fP(1L)
  1641. X.PD
  1642. X.\" =========================================================================
  1643. X.SH AUTHORS
  1644. XThe primary Info-ZIP authors (current zip-bugs workgroup) are:  Jean-loup
  1645. XGailly (Zip); Greg R. Roelofs (UnZip); Mark Adler (decompression, fUnZip); 
  1646. XKai Uwe Rommel (OS/2); Igor Mandrichenko and Hunter Goatley (VMS); John Bush
  1647. Xand Paul Kienitz (Amiga); Antoine Verheijen (Macintosh); Chris Herborth 
  1648. X(Atari); Henry Gessau (NT); Karl Davis, Sergio Monesi and Evan Shattock 
  1649. X(Acorn Archimedes); and Robert Heath (Windows).  The author of the original 
  1650. Xunzip code upon which Info-ZIP's is based was Samuel H. Smith; Carl Mascott 
  1651. Xdid the first Unix port; and David P. Kirschbaum organized and led Info-ZIP
  1652. Xin its early days.  The full list of contributors to UnZip has grown quite
  1653. Xlarge; please refer to the CONTRIBS file in the UnZip source distribution
  1654. Xfor a relatively complete version.
  1655. X.PD
  1656. X.\" =========================================================================
  1657. X.SH VERSIONS
  1658. X.ta \w'vx.xxnn'u +\w'fall 1989'u+3n
  1659. X.PD 0
  1660. X.IP "v1.2\t15 Mar 89" \w'\t\t'u
  1661. XSamuel H. Smith
  1662. X.IP "v2.0\t\ 9 Sep 89"
  1663. XSamuel H. Smith
  1664. X.IP "v2.x\tfall 1989"
  1665. Xmany Usenet contributors
  1666. X.IP "v3.0\t\ 1 May 90"
  1667. XInfo-ZIP (DPK, consolidator)
  1668. X.IP "v3.1\t15 Aug 90"
  1669. XInfo-ZIP (DPK, consolidator)
  1670. X.IP "v4.0\t\ 1 Dec 90"
  1671. XInfo-ZIP (GRR, maintainer)
  1672. X.IP "v4.1\t12 May 91"
  1673. XInfo-ZIP
  1674. X.IP "v4.2\t20 Mar 92"
  1675. XInfo-ZIP (zip-bugs subgroup, GRR)
  1676. X.IP "v5.0\t21 Aug 92"
  1677. XInfo-ZIP (zip-bugs subgroup, GRR)
  1678. X.IP "v5.01\t15 Jan 93"
  1679. XInfo-ZIP (zip-bugs subgroup, GRR)
  1680. X.IP "v5.1\t\ 7 Feb 94"
  1681. XInfo-ZIP (zip-bugs subgroup, GRR)
  1682. X.IP "v5.11\t\ 2 Aug 94"
  1683. XInfo-ZIP (zip-bugs subgroup, GRR)
  1684. X.IP "v5.12\t28 Aug 94"
  1685. XInfo-ZIP (zip-bugs subgroup, GRR)
  1686. X.PD
  1687. END_OF_FILE
  1688.   if test 30113 -ne `wc -c <'unzip-5.12/unix/unzip.1'`; then
  1689.     echo shar: \"'unzip-5.12/unix/unzip.1'\" unpacked with wrong size!
  1690.   fi
  1691.   # end of 'unzip-5.12/unix/unzip.1'
  1692. fi
  1693. echo shar: End of archive 12 \(of 20\).
  1694. cp /dev/null ark12isdone
  1695. MISSING=""
  1696. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  1697.     if test ! -f ark${I}isdone ; then
  1698.     MISSING="${MISSING} ${I}"
  1699.     fi
  1700. done
  1701. if test "${MISSING}" = "" ; then
  1702.     echo You have unpacked all 20 archives.
  1703.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1704. else
  1705.     echo You still must unpack the following archives:
  1706.     echo "        " ${MISSING}
  1707. fi
  1708. exit 0
  1709. exit 0 # Just in case...
  1710.