home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sources / misc / 3854 next >
Encoding:
Text File  |  1992-08-23  |  59.1 KB  |  1,651 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: zip-bugs@cs.ucla.edu (Info-ZIP group)
  4. Subject:  v31i104:  unzip50 - Info-ZIP portable UnZip, version 5.0, Part01/14
  5. Message-ID: <csm-v31i104=unzip50.215137@sparky.IMD.Sterling.COM>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 24bec5aef0397fc9dd575993881bf064
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. Date: Mon, 24 Aug 1992 02:51:55 GMT
  11. Approved: kent@sparky.imd.sterling.com
  12. Lines: 1637
  13.  
  14. Submitted-by: zip-bugs@cs.ucla.edu (Info-ZIP group)
  15. Posting-number: Volume 31, Issue 104
  16. Archive-name: unzip50/part01
  17. Supersedes: unzip: Volume 29, Issue 31-42
  18. Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT AMIGA?, !ATARI, symlink, SGI, DEC, Cray, Convex, Amdahl, Sun
  19.  
  20.  ______________________________________________________________________
  21.  
  22.   NOTE:  Info-ZIP's mailing addresses and ftp site will be changing
  23.   within the next month.  The current e-mail addresses should hold for
  24.   a while via mail-forwarding, but watch for the new addresses in our
  25.   next release.
  26.  ______________________________________________________________________
  27.  
  28.   UnZip 5.0 is a decompression and file unpacking utility for use with
  29.   ZIP archives (*.zip) created by Zip or PKZIP.  It is compatible with
  30.   all currently released versions of Zip and PKZIP, and, aside from
  31.   multi-disk archives, it is expected to be compatible with the soon-to-
  32.   be-released PKZIP 2.x.  Info-ZIP's companion to UnZip is called Zip
  33.   (of course); it is being posted concurrently, as are the encryption/
  34.   decryption routines for Zip and UnZip, and a Microsoft Windows add-on 
  35.   to UnZip called WizUnZip.
  36.  
  37.   This version of UnZip has been ported to a wide array of Unix and other
  38.   mainframes, minis, and micros (as listed above).  Features not found in
  39.   the PKWare version include default extraction of directory trees (with 
  40.   a switch to defeat this, rather than the other way around); VMS, Macin-
  41.   tosh and OS/2 extended file attributes; textfile conversion between MSDOS,
  42.   Unix, VMS and Macintosh; the ZipInfo zipfile information utility; and, 
  43.   of course, the ability to run under most of your favorite operating sys-
  44.   tems.  Plus it's free. :-)  New features in this version include support
  45.   for deflation (the new, higher-performance compression method introduced
  46.   in the PKZIP 1.93a); much faster decompression; relaxed copyright restric-
  47.   tions, due to rewritten code (see COPYING for details); multiple password
  48.   guessing, for encrypted zipfiles; support for options stored in an envi-
  49.   ronment variable, to change the default behavior; and a new Unix filter
  50.   version of UnZip called FUnZip.
  51.  
  52. -----
  53. #! /bin/sh
  54. # This is a shell archive.  Remove anything before this line, then feed it
  55. # into a shell via "sh file" or similar.  To overwrite existing files,
  56. # type "sh file -c".
  57. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  58. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  59. # Contents:  AMIGA ATARI MAC MSDOS MSDOS/bcc MSDOS/tcc NT OS2
  60. #   OS2/Contents VMS VMS/bilf unzip.doc unzip.h
  61. # Wrapped by kent@sparky on Sun Aug 23 21:09:31 1992
  62. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  63. echo If this archive is complete, you will see the following message:
  64. echo '          "shar: End of archive 1 (of 14)."'
  65. if test ! -d 'AMIGA' ; then
  66.     echo shar: Creating directory \"'AMIGA'\"
  67.     mkdir 'AMIGA'
  68. fi
  69. if test ! -d 'ATARI' ; then
  70.     echo shar: Creating directory \"'ATARI'\"
  71.     mkdir 'ATARI'
  72. fi
  73. if test ! -d 'MAC' ; then
  74.     echo shar: Creating directory \"'MAC'\"
  75.     mkdir 'MAC'
  76. fi
  77. if test ! -d 'MSDOS' ; then
  78.     echo shar: Creating directory \"'MSDOS'\"
  79.     mkdir 'MSDOS'
  80. fi
  81. if test ! -d 'MSDOS/bcc' ; then
  82.     echo shar: Creating directory \"'MSDOS/bcc'\"
  83.     mkdir 'MSDOS/bcc'
  84. fi
  85. if test ! -d 'MSDOS/tcc' ; then
  86.     echo shar: Creating directory \"'MSDOS/tcc'\"
  87.     mkdir 'MSDOS/tcc'
  88. fi
  89. if test ! -d 'NT' ; then
  90.     echo shar: Creating directory \"'NT'\"
  91.     mkdir 'NT'
  92. fi
  93. if test ! -d 'OS2' ; then
  94.     echo shar: Creating directory \"'OS2'\"
  95.     mkdir 'OS2'
  96. fi
  97. if test -f 'OS2/Contents' -a "${1}" != "-c" ; then 
  98.   echo shar: Will not clobber existing file \"'OS2/Contents'\"
  99. else
  100.   echo shar: Extracting \"'OS2/Contents'\" \(441 characters\)
  101.   sed "s/^X//" >'OS2/Contents' <<'END_OF_FILE'
  102. XContents of the OS2 sub-archive for UnZip 5.0 and later:
  103. X
  104. X  Contents      this file
  105. X  makefile.os2  makefile for MSC, IBM C Set/2, gcc/emx, or Watcom C/386 9.0
  106. X  os2unzip.c    OS/2 HPFS/FAT support routines
  107. X  unzip.def     OS/2 linker definition file
  108. X  zipinfo.def   OS/2 linker definition file
  109. X
  110. XThere is, as yet, no support for the Zortech or gcc2.1 (Michael Johnson port)
  111. Xcompilers, and the Borland 32-bit OS/2 compiler doesn't exist yet.
  112. END_OF_FILE
  113.   if test 441 -ne `wc -c <'OS2/Contents'`; then
  114.     echo shar: \"'OS2/Contents'\" unpacked with wrong size!
  115.   fi
  116.   # end of 'OS2/Contents'
  117. fi
  118. if test ! -d 'VMS' ; then
  119.     echo shar: Creating directory \"'VMS'\"
  120.     mkdir 'VMS'
  121. fi
  122. if test ! -d 'VMS/bilf' ; then
  123.     echo shar: Creating directory \"'VMS/bilf'\"
  124.     mkdir 'VMS/bilf'
  125. fi
  126. if test -f 'unzip.doc' -a "${1}" != "-c" ; then 
  127.   echo shar: Will not clobber existing file \"'unzip.doc'\"
  128. else
  129.   echo shar: Extracting \"'unzip.doc'\" \(9489 characters\)
  130.   sed "s/^X//" >'unzip.doc' <<'END_OF_FILE'
  131. X
  132. XUNZIP(1)                 USER COMMANDS                   UNZIP(1)
  133. X
  134. XNAME
  135. X     unzip - list/test/extract from a ZIP archive file
  136. X
  137. XSYNOPSIS
  138. X     unzip [ -cflptuvxz[ajnoqUV] ] file[.zip] [filespec ...]
  139. X
  140. XARGUMENTS
  141. X     file[.zip]  Path of the ZIP archive.  The suffix ``.zip'' is
  142. X                 applied  if  the  file specified does not exist.
  143. X                 Note that self-extracting  ZIP  files  are  sup-
  144. X                 ported;  just  specify the ``.exe'' suffix your-
  145. X                 self.
  146. X
  147. X     [filespec]  An optional list of archive members to  be  pro-
  148. X                 cessed.  Expressions may be used to match multi-
  149. X                 ple members; be sure to quote  expressions  that
  150. X                 contain  characters interpreted by the operating
  151. X                 system.  See  DESCRIPTION   (below)   for   more
  152. X                 details.
  153. X
  154. XOPTIONS
  155. X     -c  extract files to stdout/screen (``CRT'')
  156. X     -f  freshen existing files (replace if newer); create none
  157. X     -l  list archive files (short format)
  158. X     -p  extract files to pipe; no informational messages
  159. X     -t  test archive files
  160. X     -u  update existing files; create new ones if needed
  161. X     -v  list archive files (verbose format)
  162. X     -x  extract files in archive (default)
  163. X     -z  display only the archive comment
  164. X
  165. XMODIFIERS
  166. X     -a  convert to MS-DOS textfile format (CR  LF),  Mac  format
  167. X         (CR),  Unix/VMS  format  (LF),  OR from ASCII to EBCDIC,
  168. X         depending on your system (only use for TEXT files!)
  169. X     -j  junk paths (don't recreate  archive's  directory  struc-
  170. X         ture)
  171. X     -n  never overwrite existing files; don't prompt
  172. X     -o  OK to overwrite files without prompting
  173. X     -q  perform operations quietly (-qq => even quieter)
  174. X     -s  [OS/2,  MS-DOS]  allow  spaces   in   filenames   (e.g.,
  175. X         ``EA DATA. SF'')
  176. X     -U  leave filenames uppercase if created under MS-DOS,  VMS,
  177. X         etc.
  178. X     -V  retain (VMS) file version numbers
  179. X     -X  [VMS]  restore  owner/protection   info   (may   require
  180. X         privileges)
  181. X
  182. XDESCRIPTION
  183. X     UnZip will list, test, or extract from a ZIP  archive,  com-
  184. X     monly  found on MSDOS systems.  Archive member extraction is
  185. X     implied by the absence of the -c,  -p,  -t,  -l,  -v  or  -z
  186. X
  187. XInfo-ZIP          Last change: 22 Aug 92 (v5.0)                 1
  188. X
  189. XUNZIP(1)                 USER COMMANDS                   UNZIP(1)
  190. X
  191. X     options.    All  archive  members  are  processed  unless  a
  192. X     filespec is provided to specify  a  subset  of  the  archive
  193. X     members.   The  filespec  is similar to an egrep expression,
  194. X     and may contain:
  195. X
  196. X     *      matches a sequence of 0 or more characters
  197. X     ?      matches exactly 1 character
  198. X     \nnn   matches the character having octal code nnn
  199. X     [...]  matches any single character found inside the  brack-
  200. X            ets; ranges are specified by a beginning character, a
  201. X            hyphen, and an ending character.  If  an  exclamation
  202. X            point  or  a  carat  (`!'  or  `^')  follows the left
  203. X            bracket, then the range of characters matched is com-
  204. X            plemented  with  respect  to  the ASCII character set
  205. X            (that is, anything except the characters  inside  the
  206. X            brackets is considered a match).
  207. X
  208. XENVIRONMENT OPTIONS
  209. X     UnZip's default behavior may be modified via options  placed
  210. X     in  an  environment  variable.   This  can  be done with any
  211. X     option, but it is probably most useful with the -q,  -o,  or
  212. X     -n modifiers:  in order to make UnZip quieter by default, or
  213. X     to make it always overwrite or never overwrite files  as  it
  214. X     extracts them.  For example, to make UnZip act as quietly as
  215. X     possible, only reporting errors, one would use  one  of  the
  216. X     following commands:
  217. X
  218. X           setenv UNZIP -qq           Unix C shell
  219. X
  220. X           UNZIP=-qq; export UNZIP    Unix Bourne shell
  221. X
  222. X           set UNZIP=-qq              OS/2 or MS-DOS
  223. X
  224. X           define UNZIP_OPTS "-qq"    VMS (quotes for LOWERCASE)
  225. X
  226. X     Environment options are, in effect, considered  to  be  just
  227. X     like  any  other  command-line options, except that they are
  228. X     effectively the first options on the command line.  To over-
  229. X     ride  an  environment option, one may use the ``minus opera-
  230. X     tor'' to remove it.  For instance, to override  one  of  the
  231. X     quiet-flags in the example above, use the command
  232. X
  233. X           unzip --q[other options] zipfile
  234. X
  235. X     The first hyphen is the normal  switch  character,  and  the
  236. X     second  is  a  minus sign, acting on the q option.  Thus the
  237. X     effect here is to cancel a single quantum of quietness.   To
  238. X     cancel both quiet flags, two (or more) minuses may be used:
  239. X
  240. X           unzip -x--q zipfile
  241. X
  242. XInfo-ZIP          Last change: 22 Aug 92 (v5.0)                 2
  243. X
  244. XUNZIP(1)                 USER COMMANDS                   UNZIP(1)
  245. X
  246. X     or
  247. X
  248. X           unzip ---qx zipfile
  249. X
  250. X     (the two are equivalent).  This may seem awkward or  confus-
  251. X     ing,  but it is reasonably intuitive:  just ignore the first
  252. X     hyphen and go from there.  It is also  consistent  with  the
  253. X     behavior of Unix nice(1).
  254. X
  255. XEXAMPLES
  256. X     To  use  UnZip  to  extract  all  members  of  the   archive
  257. X     letters.zip, creating any directories as necessary:
  258. X
  259. X           unzip letters
  260. X
  261. X     To extract all members of letters.zip to the current  direc-
  262. X     tory:
  263. X
  264. X           unzip -j letters
  265. X
  266. X     To test letters.zip, printing only a summary  message  indi-
  267. X     cating whether the archive is OK or not:
  268. X
  269. X           unzip -tq letters
  270. X
  271. X     To extract to standard output  all  members  of  letters.zip
  272. X     whose  names  end  in ``.tex'', converting to the local end-
  273. X     of-line convention and piping the output into more(1):
  274. X
  275. X           unzip -ca letters \*.tex | more
  276. X
  277. X     (The backslash before the asterisk is only required  if  the
  278. X     shell  expands  wildcards,  as  in Unix; double quotes could
  279. X     have been used instead, as in the source example below.)  To
  280. X     extract  the  binary  file paper1.dvi to standard output and
  281. X     pipe it to a printing program:
  282. X
  283. X           unzip -p articles paper1.dvi | dvips
  284. X
  285. X     To extract all FORTRAN and C source  files--*.f,  *.c,  *.h,
  286. X     Makefile  (the  double quotes are necessary only in Unix and
  287. X     only if globbing is turned on):
  288. X
  289. X           unzip source.zip "*.[fch]" Makefile
  290. X
  291. X     To extract only newer versions of the files already  in  the
  292. X     current  directory,  without  querying (NOTE:  be careful of
  293. X     unzipping in one timezone a zipfile created in  another--ZIP
  294. X     archives  contain  no  timezone information, and a ``newer''
  295. X     file from an eastern timezone may, in fact, be older):
  296. X
  297. XInfo-ZIP          Last change: 22 Aug 92 (v5.0)                 3
  298. X
  299. XUNZIP(1)                 USER COMMANDS                   UNZIP(1)
  300. X
  301. X           unzip -fo sources
  302. X
  303. X     To extract newer  versions  of  the  files  already  in  the
  304. X     current  directory and to create any files not already there
  305. X     (same caveat as previous example):
  306. X
  307. X           unzip -uo sources
  308. X
  309. X     In the last five examples, assume that UNZIP  or  UNZIP_OPTS
  310. X     is set to -q.  To do a singly quiet listing:
  311. X
  312. X           unzip -l file
  313. X
  314. X     To do a doubly quiet listing:
  315. X
  316. X           unzip -ql file
  317. X
  318. X     To do a standard listing:
  319. X
  320. X           unzip --ql file
  321. X
  322. X     or
  323. X
  324. X           unzip -l-q file
  325. X
  326. X     or
  327. X
  328. X           unzip -l--q file
  329. X
  330. X     (extra minuses don't hurt).
  331. X
  332. XTIPS
  333. X     The current maintainer, being a lazy  sort,  finds  it  very
  334. X     useful to define an alias ``tt'' for ``unzip -tq''.  One may
  335. X     then simply type ``tt zipfile'' to test the  archive,  some-
  336. X     thing  which  one  ought  make  a habit of doing.  With luck
  337. X     UnZip will report ``No  errors  detected  in  zipfile.zip,''
  338. X     after which one may breathe a sigh of relief.
  339. X
  340. XSEE ALSO
  341. X     funzip(1),  zip(1),  zipcloak(1),  zipinfo(1),   zipnote(1),
  342. X     zipsplit(1)
  343. X
  344. XAUTHORS
  345. X     Samuel H. Smith, Carl Mascott, David P. Kirschbaum, Greg  R.
  346. X     Roelofs,  Mark  Adler,  Kai  Uwe  Rommel, Igor Mandrichenko,
  347. X     Johnny Lee, Jean-loup Gailly; Glenn  Andrews,  Joel  Aycock,
  348. X     Allan  Bjorklund,  James  Birdsall,  Wim Bonner, John Cowan,
  349. X     Frank da Cruz, Bill Davidsen, Arjan de Vet, James Dugal, Jim
  350. X     Dumser,  Mark  Edwards, David Feinleib, Mike Freeman, Hunter
  351. X     Goatley, Robert Heath, Dave  Heiland,  Larry  Jones,  Kjetil
  352. X     J(o)rgenson,  Bob Kemp, J. Kercheval, Alvin Koh, Bo Kullmar,
  353. X
  354. XInfo-ZIP          Last change: 22 Aug 92 (v5.0)                 4
  355. X
  356. XUNZIP(1)                 USER COMMANDS                   UNZIP(1)
  357. X
  358. X     Johnny Lee, Warner Losh, Fulvio Marino,  Gene  McManus,  Joe
  359. X     Meadows,  Mike  O'Carroll,  Humberto  Ortiz-Zuazaga, Piet W.
  360. X     Plomp, Antonio Querubin Jr., Steve Salisbury, Georg  Sassen,
  361. X     Jon  Saxton,  Hugh Schmidt, Martin Schulz, Charles Scripter,
  362. X     Chris Seaman, Richard Seay, Alex Sergejew,  Cliff  Stanford,
  363. X     Onno  van der Linden, Jim Van Zandt, Antoine Verheijen, Paul
  364. X     Wells.
  365. X
  366. XVERSIONS
  367. X     v1.2  15 Mar 89  Samuel H. Smith
  368. X     v2.0   9 Sep 89  Samuel H. Smith
  369. X     v2.x  fall 1989  many Usenet contributors
  370. X     v3.0   1 May 90  Info-ZIP (DPK, consolidator)
  371. X     v3.1  15 Aug 90  Info-ZIP (DPK, consolidator)
  372. X     v4.0   1 Dec 90  Info-ZIP (GRR, maintainer)
  373. X     v4.1  12 May 91  Info-ZIP
  374. X     v4.2  20 Mar 92  Info-ZIP (zip-bugs subgroup; GRR, maint.)
  375. X     v5.0  21 Aug 92  Info-ZIP (zip-bugs subgroup; GRR, maint.)
  376. X
  377. XInfo-ZIP          Last change: 22 Aug 92 (v5.0)                 5
  378. X
  379. END_OF_FILE
  380.   if test 9489 -ne `wc -c <'unzip.doc'`; then
  381.     echo shar: \"'unzip.doc'\" unpacked with wrong size!
  382.   fi
  383.   # end of 'unzip.doc'
  384. fi
  385. if test -f 'unzip.h' -a "${1}" != "-c" ; then 
  386.   echo shar: Will not clobber existing file \"'unzip.h'\"
  387. else
  388.   echo shar: Extracting \"'unzip.h'\" \(43208 characters\)
  389.   sed "s/^X//" >'unzip.h' <<'END_OF_FILE'
  390. X/*---------------------------------------------------------------------------
  391. X
  392. X  unzip.h
  393. X
  394. X  This header file is used by all of the unzip source files.  Its contents
  395. X  are divided into seven more-or-less separate sections:  predefined macros,
  396. X  OS-dependent includes, (mostly) OS-independent defines, typedefs, function 
  397. X  prototypes (or "prototypes," in the case of non-ANSI compilers), macros, 
  398. X  and global-variable declarations.
  399. X
  400. X  ---------------------------------------------------------------------------*/
  401. X
  402. X
  403. X
  404. X/*****************************************/
  405. X/*  Predefined, Machine-specific Macros  */
  406. X/*****************************************/
  407. X
  408. X#if (defined(__GO32__) && defined(unix))   /* DOS extender */
  409. X#  undef unix
  410. X#endif
  411. X
  412. X#if (defined(unix) && !defined(UNIX))
  413. X#  define UNIX
  414. X#endif /* unix && !UNIX */
  415. X
  416. X/* Much of the following is swiped from zip's tailor.h: */
  417. X
  418. X/* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
  419. X#ifdef __POWERC
  420. X#  define __TURBOC__
  421. X#  define MSDOS
  422. X#endif /* __POWERC */
  423. X#if (defined(__TURBOC__) && defined(__MSDOS__) && !defined(MSDOS))
  424. X#  define MSDOS
  425. X#endif
  426. X
  427. X/* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C,
  428. X * or Silicon Graphics, or Convex, or IBM C Set/2, or GNU gcc under emx, or
  429. X * or Watcom C, or Macintosh, or Windows NT.
  430. X */
  431. X#if (__STDC__ || defined(MSDOS) || defined(sgi) || defined(CONVEX))
  432. X#  ifndef PROTO
  433. X#    define PROTO
  434. X#  endif
  435. X#  define MODERN
  436. X#endif
  437. X#if (defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__))
  438. X#  ifndef PROTO
  439. X#    define PROTO
  440. X#  endif
  441. X#  define MODERN
  442. X#endif
  443. X#if (defined(THINK_C) || defined(MPW) || defined(WIN32))
  444. X#  ifndef PROTO
  445. X#    define PROTO
  446. X#  endif
  447. X#  define MODERN
  448. X#endif
  449. X
  450. X/* turn off prototypes if requested */
  451. X#if (defined(NOPROTO) && defined(PROTO))
  452. X#  undef PROTO
  453. X#endif
  454. X
  455. X/* used to remove arguments in function prototypes for non-ANSI C */
  456. X#ifdef PROTO
  457. X#  define OF(a) a
  458. X#else /* !PROTO */
  459. X#  define OF(a) ()
  460. X#endif /* ?PROTO */
  461. X
  462. X#if (defined(ultrix) || defined(bsd4_2) || defined(sun) || defined(pyr))
  463. X#  if (!defined(BSD) && !defined(__SYSTEM_FIVE) && !defined(SYSV))
  464. X#    define BSD
  465. X#  endif /* !BSD && !__SYSTEM_FIVE && !SYSV */
  466. X#endif /* ultrix || bsd4_2 || sun || pyr */
  467. X
  468. X#if (defined(CONVEX) || defined(CRAY) || defined(__SYSTEM_FIVE))
  469. X#  ifndef TERMIO
  470. X#    define TERMIO
  471. X#  endif /* !TERMIO */
  472. X#endif /* CONVEX || CRAY || __SYSTEM_FIVE */
  473. X
  474. X#ifdef pyr  /* Pyramid */
  475. X#  ifndef ZMEM
  476. X#    define ZMEM
  477. X#  endif /* !ZMEM */
  478. X#endif /* pyr */
  479. X
  480. X#ifdef CRAY
  481. X#  ifdef ZMEM
  482. X#    undef ZMEM
  483. X#  endif /* ZMEM */
  484. X#endif /* CRAY */
  485. X
  486. X/* the i386 test below is to catch SCO Unix (which has redefinition
  487. X * warnings if param.h is included), but it probably doesn't hurt if
  488. X * other 386 Unixes get nailed, too...except now that 386BSD and BSDI
  489. X * exist.  Sigh.  <sys/param.h> is mostly included for "BSD", I think.
  490. X * [An alternate fix for SCO Unix is below.]
  491. X */
  492. X#if (defined(MINIX) || (defined(i386) && defined(unix)))
  493. X#  define NO_PARAM_H
  494. X#endif /* MINIX || (i386 && unix) */
  495. X
  496. X
  497. X
  498. X
  499. X
  500. X/***************************/
  501. X/*  OS-Dependent Includes  */
  502. X/***************************/
  503. X
  504. X#ifndef MINIX            /* Minix needs it after all the other includes (?) */
  505. X#  include <stdio.h>
  506. X#endif
  507. X#include <ctype.h>       /* skip for VMS, to use tolower() function? */
  508. X#include <errno.h>       /* used in mapname() */
  509. X#ifndef NO_ERRNO
  510. X#  define DECLARE_ERRNO  /* everybody except MSC 6.0, SCO cc, Watcom C/386 */
  511. X#endif /* !NO_ERRNO */
  512. X#ifdef VMS
  513. X#  include <types.h>     /* (placed up here instead of in VMS section below */
  514. X#  include <stat.h>      /* because types.h is used in some other headers) */
  515. X#else /* !VMS */
  516. X#  if !defined(THINK_C) && !defined(MPW)
  517. X#    include <sys/types.h>                 /* off_t, time_t, dev_t, ... */
  518. X#    include <sys/stat.h>
  519. X#  endif /* !THINK_C && !MPW */
  520. X#endif /* ?VMS */
  521. X
  522. X#ifdef MODERN
  523. X#  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
  524. X#    include <stddef.h>
  525. X#  endif
  526. X#  if (!defined(__GNUC__) && !defined(apollo))   /* both define __STDC__ */
  527. X#    include <stdlib.h>    /* standard library prototypes, malloc(), etc. */
  528. X#  else
  529. X#    ifdef __EMX__
  530. X#      include <stdlib.h>  /* emx IS gcc but has stdlib.h */
  531. X#    endif
  532. X#  endif
  533. X#  include <string.h>      /* defines strcpy, strcmp, memcpy, etc. */
  534. X   typedef size_t extent;
  535. X   typedef void voidp;
  536. X#else /* !MODERN */
  537. X   char *malloc();
  538. X   char *strchr(), *strrchr();
  539. X   long lseek();
  540. X   typedef unsigned int extent;
  541. X#  define void int
  542. X   typedef char voidp;
  543. X#endif /* ?MODERN */
  544. X
  545. X/* this include must be down here for SysV.4, for some reason... */
  546. X#include <signal.h>      /* used in unzip.c, file_io.c */
  547. X
  548. X
  549. X
  550. X/*---------------------------------------------------------------------------
  551. X    Next, a word from our Unix (mostly) sponsors:
  552. X  ---------------------------------------------------------------------------*/
  553. X
  554. X#ifdef UNIX
  555. X#  ifdef AMIGA
  556. X#    include <libraries/dos.h>
  557. X#  else /* !AMIGA */
  558. X#    ifndef NO_PARAM_H
  559. X#if 0  /* [GRR: this is an alternate fix for SCO's redefinition bug] */
  560. X#      ifdef NGROUPS_MAX
  561. X#        undef NGROUPS_MAX     /* SCO bug:  defined again in <param.h> */
  562. X#      endif /* NGROUPS_MAX */
  563. X#endif /* 0 */
  564. X#      include <sys/param.h>   /* conflict with <sys/types.h>, some systems? */
  565. X#    endif /* !NO_PARAM_H */
  566. X#  endif /* ?AMIGA */
  567. X
  568. X#  ifndef BSIZE
  569. X#    ifdef MINIX
  570. X#      define BSIZE   1024
  571. X#    else /* !MINIX */
  572. X#      define BSIZE   DEV_BSIZE  /* assume common for all Unix systems */
  573. X#    endif /* ?MINIX */
  574. X#  endif
  575. X
  576. X#  ifndef BSD
  577. X#    if (!defined(AMIGA) && !defined(MINIX))
  578. X#      define NO_MKDIR           /* for mapname() */
  579. X#    endif /* !AMIGA && !MINIX */
  580. X#    include <time.h>
  581. X     struct tm *gmtime(), *localtime();
  582. X#  else   /* BSD */
  583. X#    include <sys/time.h>
  584. X#    include <sys/timeb.h>
  585. X#    ifdef _AIX
  586. X#      include <time.h>
  587. X#    endif
  588. X#  endif
  589. X
  590. X#else   /* !UNIX */
  591. X#  define BSIZE   512               /* disk block size */
  592. X#endif /* ?UNIX */
  593. X
  594. X#if (defined(V7) || defined(BSD))
  595. X#  define strchr    index
  596. X#  define strrchr   rindex
  597. X#endif
  598. X
  599. X/*---------------------------------------------------------------------------
  600. X    And now, our MS-DOS and OS/2 corner:
  601. X  ---------------------------------------------------------------------------*/
  602. X
  603. X#ifdef __TURBOC__
  604. X#  define DOS_OS2
  605. X#  include <sys/timeb.h>      /* for structure ftime                        */
  606. X#  ifndef __BORLANDC__        /* there appears to be a bug (?) in Borland's */
  607. X#    include <mem.h>          /*   MEM.H related to __STDC__ and far poin-  */
  608. X#  endif                      /*   ters. (dpk)  [mem.h included for memcpy] */
  609. X#  include <dos.h>            /* for REGS macro (at least for Turbo C 2.0)  */
  610. X#else                         /* NOT Turbo C (or Power C)...                */
  611. X#  ifdef MSDOS                /*   but still MS-DOS, so we'll assume it's   */
  612. X#    ifndef MSC               /*   Microsoft's compiler and fake the ID, if */
  613. X#      define MSC             /*   necessary (it is in 5.0; apparently not  */
  614. X#    endif                    /*   in 5.1 and 6.0)                          */
  615. X#    include <dos.h>          /* for _dos_setftime()                        */
  616. X#  endif
  617. X#endif
  618. X
  619. X#if (defined(__IBMC__) && defined(__OS2__))
  620. X#  define DOS_OS2
  621. X#  define S_IFMT 0xF000
  622. X#  define timezone _timezone
  623. X#endif
  624. X
  625. X#ifdef __WATCOMC__
  626. X#  define DOS_OS2
  627. X#  define __32BIT__
  628. X#  ifdef DECLARE_ERRNO
  629. X#    undef DECLARE_ERRNO
  630. X#  endif
  631. X#  undef far
  632. X#  define far
  633. X#endif
  634. X
  635. X#ifdef __EMX__
  636. X#  define DOS_OS2
  637. X#  define __32BIT__
  638. X#  define far
  639. X#endif /* __EMX__ */
  640. X
  641. X#ifdef MSC                    /* defined for all versions of MSC now         */
  642. X#  define DOS_OS2             /* Turbo C under DOS, MSC under DOS or OS/2    */
  643. X#  if (defined(_MSC_VER) && (_MSC_VER >= 600))    /* new with 5.1 or 6.0 ... */
  644. X#    undef DECLARE_ERRNO      /* errno is now a function in a dynamic link   */
  645. X#  endif                      /*   library (or something)--incompatible with */
  646. X#endif                        /*   the usual "extern int errno" declaration  */
  647. X
  648. X#ifdef DOS_OS2                /* defined for all MS-DOS and OS/2 compilers   */
  649. X#  include <io.h>             /* lseek(), open(), setftime(), dup(), creat() */
  650. X#  include <time.h>           /* localtime() */
  651. X#endif
  652. X
  653. X#ifdef OS2                    /* defined for all OS/2 compilers */
  654. X#  ifdef isupper
  655. X#    undef isupper
  656. X#  endif
  657. X#  ifdef tolower
  658. X#    undef tolower
  659. X#  endif
  660. X#  define isupper(x)   IsUpperNLS((unsigned char)(x))
  661. X#  define tolower(x)   ToLowerNLS((unsigned char)(x))
  662. X#endif
  663. X
  664. X#ifdef WIN32
  665. X#  include <io.h>             /* read(), open(), etc. */
  666. X#  include <time.h>
  667. X#  include <memory.h>
  668. X#  include <direct.h>         /* mkdir() */
  669. X#  ifdef FILE_IO_C
  670. X#    include <fcntl.h>
  671. X#    include <conio.h>
  672. X#    include <sys\types.h>
  673. X#    include <sys\utime.h>
  674. X#    include <windows.h>
  675. X#    define DOS_OS2
  676. X#    define getch() getchar()
  677. X#  endif
  678. X#endif
  679. X
  680. X/*---------------------------------------------------------------------------
  681. X    Followed by some VMS (mostly) stuff:
  682. X  ---------------------------------------------------------------------------*/
  683. X
  684. X#ifdef VMS
  685. X#  include <time.h>               /* the usual non-BSD time functions */
  686. X#  include <file.h>               /* same things as fcntl.h has */
  687. X#  include <rms.h>
  688. X#  define _MAX_PATH NAM$C_MAXRSS  /* to define FILNAMSIZ below */
  689. X#  define UNIX                    /* can share most of same code from now on */
  690. X#  define RETURN    return_VMS    /* VMS interprets return codes incorrectly */
  691. X#else /* !VMS */
  692. X#  ifndef THINK_C
  693. X#    define RETURN  return        /* only used in main() */
  694. X#  else
  695. X#    define RETURN(v) { int n;\
  696. X                        n = (v);\
  697. X                        fprintf(stderr, "\npress <return> to continue ");\
  698. X                        while (getc(stdin) != '\n');\
  699. X                        putc('\n', stderr);\
  700. X                        InitCursor();\
  701. X                        goto start;\
  702. X                      }
  703. X#  endif
  704. X#  ifdef V7
  705. X#    define O_RDONLY  0
  706. X#    define O_WRONLY  1
  707. X#    define O_RDWR    2
  708. X#  else /* !V7 */
  709. X#    ifdef MTS
  710. X#      include <sys/file.h>     /* MTS uses this instead of fcntl.h */
  711. X#      include <timeb.h>
  712. X#      include <time.h>
  713. X#    else /* !MTS */
  714. X#      ifdef COHERENT           /* Coherent 3.10/Mark Williams C */
  715. X#        include <sys/fcntl.h>
  716. X#        define SHORT_NAMES
  717. X#        define tzset  settz
  718. X#      else /* !COHERENT */
  719. X#        include <fcntl.h>      /* O_BINARY for open() w/o CR/LF translation */
  720. X#      endif /* ?COHERENT */
  721. X#    endif /* ?MTS */
  722. X#  endif /* ?V7 */
  723. X#endif /* ?VMS */
  724. X
  725. X#if (defined(MSDOS) || defined(VMS))
  726. X#  define DOS_VMS
  727. X#endif
  728. X
  729. X/*---------------------------------------------------------------------------
  730. X    And some Mac stuff for good measure:
  731. X  ---------------------------------------------------------------------------*/
  732. X
  733. X#ifdef THINK_C
  734. X#  define MACOS
  735. X#  ifndef __STDC__            /* if Think C hasn't defined __STDC__ ... */
  736. X#    define __STDC__ 1        /*   make sure it's defined: it needs it */
  737. X#  else /* __STDC__ defined */
  738. X#    if !__STDC__             /* sometimes __STDC__ is defined as 0; */
  739. X#      undef __STDC__         /*   it needs to be 1 or required header */
  740. X#      define __STDC__ 1      /*   files are not properly included. */
  741. X#    endif /* !__STDC__ */
  742. X#  endif /* ?defined(__STDC__) */
  743. X#endif /* THINK_C */
  744. X
  745. X#ifdef MPW
  746. X#  define MACOS
  747. X#  include <Errors.h>
  748. X#  include <Files.h>
  749. X#  include <Memory.h>
  750. X#  include <Quickdraw.h>
  751. X#  include <ToolUtils.h>
  752. X#  define CtoPstr c2pstr
  753. X#  define PtoCstr p2cstr
  754. X#  ifdef CR
  755. X#    undef  CR
  756. X#  endif
  757. X#endif /* MPW */
  758. X
  759. X#ifdef MACOS
  760. X#  define open(x,y) macopen(x,y, gnVRefNum, glDirID)
  761. X#  define close macclose
  762. X#  define read macread
  763. X#  define write macwrite
  764. X#  define lseek maclseek
  765. X#  define creat(x,y) maccreat(x, gnVRefNum, glDirID, gostCreator, gostType)
  766. X#  define stat(x,y) macstat(x,y,gnVRefNum, glDirID)
  767. X
  768. X#  ifndef isascii
  769. X#    define isascii(c) ((unsigned char)(c) <= 0x3F)
  770. X#  endif
  771. X
  772. X#  include "macstat.h"
  773. X
  774. Xtypedef struct _ZipExtraHdr {
  775. X    unsigned short header;    /*    2 bytes */
  776. X    unsigned short data;      /*    2 bytes */
  777. X} ZIP_EXTRA_HEADER;
  778. X
  779. Xtypedef struct _MacInfoMin {
  780. X    unsigned short header;    /*    2 bytes */
  781. X    unsigned short data;      /*    2 bytes */
  782. X    unsigned long signature;  /*    4 bytes */
  783. X    FInfo finfo;              /*   16 bytes */
  784. X    unsigned long lCrDat;     /*    4 bytes */
  785. X    unsigned long lMdDat;     /*    4 bytes */
  786. X    unsigned long flags ;     /*    4 bytes */
  787. X    unsigned long lDirID;     /*    4 bytes */
  788. X                              /*------------*/
  789. X} MACINFOMIN;                 /* = 40 bytes for size of data */
  790. X
  791. Xtypedef struct _MacInfo {
  792. X    unsigned short header;    /*    2 bytes */
  793. X    unsigned short data;      /*    2 bytes */
  794. X    unsigned long signature;  /*    4 bytes */
  795. X    FInfo finfo;              /*   16 bytes */
  796. X    unsigned long lCrDat;     /*    4 bytes */
  797. X    unsigned long lMdDat;     /*    4 bytes */
  798. X    unsigned long flags ;     /*    4 bytes */
  799. X    unsigned long lDirID;     /*    4 bytes */
  800. X    char rguchVolName[28];    /*   28 bytes */
  801. X                              /*------------*/
  802. X} MACINFO;                    /* = 68 bytes for size of data */
  803. X#endif /* MACOS */
  804. X
  805. X/*---------------------------------------------------------------------------
  806. X    And finally, some random extra stuff:
  807. X  ---------------------------------------------------------------------------*/
  808. X
  809. X#ifdef MINIX
  810. X#  include <stdio.h>
  811. X#endif
  812. X
  813. X#ifdef SHORT_NAMES         /* Mark Williams C, ...? */
  814. X#  define extract_or_test_files    xtr_or_tst_files
  815. X#  define extract_or_test_member   xtr_or_tst_member
  816. X#endif
  817. X
  818. X#ifdef MTS
  819. X#  include <unix.h>          /* Some important non-ANSI routines */
  820. X#  define mkdir(s,n) (-1)    /* No "make directory" capability */
  821. X#  define EBCDIC             /* Set EBCDIC conversion on */
  822. X#endif
  823. X
  824. X
  825. X
  826. X
  827. X
  828. X/*************/
  829. X/*  Defines  */
  830. X/*************/
  831. X
  832. X#ifndef WSIZE
  833. X#  define WSIZE 0x8000       /* window size--must be a power of two, and */
  834. X#endif /* !WSIZE */          /*  at least 32K for zip's deflate method */
  835. X
  836. X#define DIR_BLKSIZ    64     /* number of directory entries per block
  837. X                              *  (should fit in 4096 bytes, usually) */
  838. X#ifndef INBUFSIZ
  839. X#  define INBUFSIZ    2048   /* works for MS-DOS small model */
  840. X#endif /* !INBUFSIZ */
  841. X
  842. X/*
  843. X * If <limits.h> exists on most systems, should include that, since it may
  844. X * define some or all of the following:  NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
  845. X * _POSIX_PATH_MAX.
  846. X */
  847. X#ifdef DOS_OS2
  848. X#  include <limits.h>
  849. X#endif /* DOS_OS2 */
  850. X
  851. X#ifdef _MAX_PATH
  852. X#  define FILNAMSIZ       (_MAX_PATH)
  853. X#else /* !_MAX_PATH */
  854. X#  define FILNAMSIZ       1025
  855. X#endif /* ?_MAX_PATH */
  856. X
  857. X#ifndef PATH_MAX
  858. X#  ifdef MAXPATHLEN                /* defined in <sys/param.h> some systems */
  859. X#    define PATH_MAX      MAXPATHLEN
  860. X#  else
  861. X#    if FILENAME_MAX > 255         /* used like PATH_MAX on some systems */
  862. X#      define PATH_MAX    FILENAME_MAX
  863. X#    else
  864. X#      define PATH_MAX    (FILNAMSIZ - 1)
  865. X#    endif
  866. X#  endif /* ?MAXPATHLEN */
  867. X#endif /* !PATH_MAX */
  868. X
  869. X#define OUTBUFSIZ         INBUFSIZ
  870. X
  871. X#define ZSUFX             ".zip"
  872. X#define CENTRAL_HDR_SIG   "\113\001\002"   /* the infamous "PK" signature */
  873. X#define LOCAL_HDR_SIG     "\113\003\004"   /*  bytes, sans "P" (so unzip */
  874. X#define END_CENTRAL_SIG   "\113\005\006"   /*  executable not mistaken for */
  875. X#define EXTD_LOCAL_SIG    "\113\007\010"   /*  zipfile itself) */
  876. X
  877. X#define SKIP              0    /* choice of activities for do_string() */
  878. X#define DISPLAY           1
  879. X#define FILENAME          2
  880. X#define EXTRA_FIELD       3
  881. X
  882. X#define DOES_NOT_EXIST    -1   /* return values for check_for_newer() */
  883. X#define EXISTS_AND_OLDER  0
  884. X#define EXISTS_AND_NEWER  1
  885. X
  886. X#define DOS_OS2_FAT_      0    /* version_made_by codes (central dir) */
  887. X#define AMIGA_            1
  888. X#define VMS_              2    /* make sure these are not defined on */
  889. X#define UNIX_             3    /*  the respective systems!!  (like, for */
  890. X#define VM_CMS_           4    /*  instance, "VMS", or "UNIX":  CFLAGS = */
  891. X#define ATARI_            5    /*  -O -DUNIX) */
  892. X#define OS2_HPFS_         6
  893. X#define MAC_              7
  894. X#define Z_SYSTEM_         8
  895. X#define CPM_              9
  896. X/* #define TOPS20_   10?  (TOPS20_ is to be defined in PKZIP 2.0...)  */
  897. X#define NUM_HOSTS         10   /* index of last system + 1 */
  898. X
  899. X#define STORED            0    /* compression methods */
  900. X#define SHRUNK            1
  901. X#define REDUCED1          2
  902. X#define REDUCED2          3
  903. X#define REDUCED3          4
  904. X#define REDUCED4          5
  905. X#define IMPLODED          6
  906. X#define TOKENIZED         7
  907. X#define DEFLATED          8
  908. X#define NUM_METHODS       9    /* index of last method + 1 */
  909. X/* don't forget to update list_files() appropriately if NUM_METHODS changes */
  910. X
  911. X#define DF_MDY            0    /* date format 10/26/91 (USA only) */
  912. X#define DF_DMY            1    /* date format 26/10/91 (most of the world) */
  913. X#define DF_YMD            2    /* date format 91/10/26 (a few countries) */
  914. X
  915. X#define UNZIP_VERSION     20   /* compatible with PKUNZIP 2.0 */
  916. X#define VMS_VERSION       42   /* if OS-needed-to-extract is VMS:  can do */
  917. X
  918. X/*---------------------------------------------------------------------------
  919. X    True sizes of the various headers, as defined by PKWare--so it is not
  920. X    likely that these will ever change.  But if they do, make sure both these
  921. X    defines AND the typedefs below get updated accordingly.
  922. X  ---------------------------------------------------------------------------*/
  923. X#define LREC_SIZE     26    /* lengths of local file headers, central */
  924. X#define CREC_SIZE     42    /*  directory headers, and the end-of-    */
  925. X#define ECREC_SIZE    18    /*  central-dir record, respectively      */
  926. X
  927. X#define MAX_BITS      13                 /* used in unShrink() */
  928. X#define HSIZE         (1 << MAX_BITS)    /* size of global work area */
  929. X
  930. X#define LF      10    /* '\n' on ASCII machines.  Must be 10 due to EBCDIC */
  931. X#define CR      13    /* '\r' on ASCII machines.  Must be 13 due to EBCDIC */
  932. X#define CTRLZ   26    /* DOS & OS/2 EOF marker (used in file_io.c, vms.c) */
  933. X
  934. X#ifdef EBCDIC
  935. X#  define ascii_to_native(c)   ebcdic[(c)]
  936. X#  define NATIVE    "EBCDIC"
  937. X#endif
  938. X
  939. X#if MPW
  940. X#  define FFLUSH    putc('\n',stderr);
  941. X#else /* !MPW */
  942. X#  define FFLUSH    fflush(stderr);
  943. X#endif /* ?MPW */
  944. X
  945. X#ifdef VMS
  946. X#  define ENV_UNZIP     "UNZIP_OPTS"      /* name of environment variable */
  947. X#  define ENV_ZIPINFO   "ZIPINFO_OPTS"
  948. X#else /* !VMS */
  949. X#  define ENV_UNZIP     "UNZIP"
  950. X#  define ENV_ZIPINFO   "ZIPINFO"
  951. X#endif /* ?VMS */
  952. X
  953. X#ifdef CRYPT
  954. X#  define PWLEN         80
  955. X#  define DECRYPT(b)    (update_keys(t=((b)&0xff)^decrypt_byte()),t)
  956. X#endif /* CRYPT */
  957. X
  958. X#ifdef QQ  /* Newtware version */
  959. X#  define QCOND   (!quietflg)   /* for no file comments with -vq or -vqq */
  960. X#else      /* (original) Bill Davidsen version  */
  961. X#  define QCOND   (which_hdr)   /* no way to kill file comments with -v, -l */
  962. X#endif
  963. X
  964. X#ifndef TRUE
  965. X#  define TRUE      1   /* sort of obvious */
  966. X#endif
  967. X#ifndef FALSE
  968. X#  define FALSE     0
  969. X#endif
  970. X
  971. X#ifndef SEEK_SET        /* These should all be declared in stdio.h!  But   */
  972. X#  define SEEK_SET  0   /*  since they're not (in many cases), do so here. */
  973. X#  define SEEK_CUR  1
  974. X#  define SEEK_END  2
  975. X#endif
  976. X
  977. X#ifndef S_IRUSR
  978. X#  define S_IRWXU       00700       /* read, write, execute: owner */
  979. X#  define S_IRUSR       00400       /* read permission: owner */
  980. X#  define S_IWUSR       00200       /* write permission: owner */
  981. X#  define S_IXUSR       00100       /* execute permission: owner */
  982. X#  define S_IRWXG       00070       /* read, write, execute: group */
  983. X#  define S_IRGRP       00040       /* read permission: group */
  984. X#  define S_IWGRP       00020       /* write permission: group */
  985. X#  define S_IXGRP       00010       /* execute permission: group */
  986. X#  define S_IRWXO       00007       /* read, write, execute: other */
  987. X#  define S_IROTH       00004       /* read permission: other */
  988. X#  define S_IWOTH       00002       /* write permission: other */
  989. X#  define S_IXOTH       00001       /* execute permission: other */
  990. X#endif /* !S_IRUSR */
  991. X
  992. X#ifdef ZIPINFO      /* these are individually checked because SysV doesn't */
  993. X#  ifndef S_IFBLK   /*  have some of them, Microsoft C others, etc. */
  994. X#    define   S_IFBLK     0060000     /* block special */
  995. X#  endif
  996. X#  ifndef S_IFIFO  /* in Borland C, not MSC */
  997. X#    define   S_IFIFO     0010000     /* fifo */
  998. X#  endif
  999. X#  ifndef S_IFLNK  /* in BSD, not SysV */
  1000. X#    define   S_IFLNK     0120000     /* symbolic link */
  1001. X#  endif
  1002. X#  ifndef S_IFSOCK  /* in BSD, not SysV */
  1003. X#    define   S_IFSOCK    0140000     /* socket */
  1004. X#  endif
  1005. X#  ifndef S_ISUID
  1006. X#    define S_ISUID       04000       /* set user id on execution */
  1007. X#  endif
  1008. X#  ifndef S_ISGID
  1009. X#    define S_ISGID       02000       /* set group id on execution */
  1010. X#  endif
  1011. X#  ifndef S_ISVTX
  1012. X#    define S_ISVTX       01000       /* directory permissions control */
  1013. X#  endif
  1014. X#  ifndef S_ENFMT
  1015. X#    define S_ENFMT       S_ISGID     /* record locking enforcement flag */
  1016. X#  endif
  1017. X#endif /* ZIPINFO */
  1018. X
  1019. X
  1020. X
  1021. X
  1022. X
  1023. X/**************/
  1024. X/*  Typedefs  */
  1025. X/**************/
  1026. X
  1027. X#ifndef _BULL_SOURCE                /* Bull has it defined somewhere already */
  1028. X   typedef unsigned char  byte;     /* code assumes UNSIGNED bytes */
  1029. X#endif /* !_BULL_SOURCE */
  1030. X
  1031. Xtypedef char              boolean;
  1032. Xtypedef long              longint;
  1033. Xtypedef unsigned short    UWORD;
  1034. Xtypedef unsigned long     ULONG;
  1035. X
  1036. Xtypedef struct min_info {
  1037. X    unsigned unix_attr;
  1038. X    unsigned dos_attr;
  1039. X    int hostnum;
  1040. X    longint offset;
  1041. X    ULONG compr_size;        /* compressed size (needed if extended header) */
  1042. X    ULONG crc;               /* crc (needed if extended header) */
  1043. X    unsigned encrypted : 1;  /* file encrypted: decrypt before uncompressing */
  1044. X    unsigned ExtLocHdr : 1;  /* use time instead of CRC for decrypt check */
  1045. X    unsigned text : 1;       /* file is text or binary */
  1046. X    unsigned lcflag : 1;     /* convert filename to lowercase */
  1047. X} min_info;
  1048. X
  1049. Xtypedef struct VMStimbuf {
  1050. X    char *revdate;           /* (both correspond to Unix modtime/st_mtime) */
  1051. X    char *credate;
  1052. X} VMStimbuf;
  1053. X
  1054. X/*---------------------------------------------------------------------------
  1055. X    Zipfile layout declarations.  If these headers ever change, make sure the
  1056. X    xxREC_SIZE defines (above) change with them!
  1057. X  ---------------------------------------------------------------------------*/
  1058. X
  1059. X   typedef byte   local_byte_hdr[ LREC_SIZE ];
  1060. X#      define L_VERSION_NEEDED_TO_EXTRACT_0     0
  1061. X#      define L_VERSION_NEEDED_TO_EXTRACT_1     1
  1062. X#      define L_GENERAL_PURPOSE_BIT_FLAG        2
  1063. X#      define L_COMPRESSION_METHOD              4
  1064. X#      define L_LAST_MOD_FILE_TIME              6
  1065. X#      define L_LAST_MOD_FILE_DATE              8
  1066. X#      define L_CRC32                           10
  1067. X#      define L_COMPRESSED_SIZE                 14
  1068. X#      define L_UNCOMPRESSED_SIZE               18
  1069. X#      define L_FILENAME_LENGTH                 22
  1070. X#      define L_EXTRA_FIELD_LENGTH              24
  1071. X
  1072. X   typedef byte   cdir_byte_hdr[ CREC_SIZE ];
  1073. X#      define C_VERSION_MADE_BY_0               0
  1074. X#      define C_VERSION_MADE_BY_1               1
  1075. X#      define C_VERSION_NEEDED_TO_EXTRACT_0     2
  1076. X#      define C_VERSION_NEEDED_TO_EXTRACT_1     3
  1077. X#      define C_GENERAL_PURPOSE_BIT_FLAG        4
  1078. X#      define C_COMPRESSION_METHOD              6
  1079. X#      define C_LAST_MOD_FILE_TIME              8
  1080. X#      define C_LAST_MOD_FILE_DATE              10
  1081. X#      define C_CRC32                           12
  1082. X#      define C_COMPRESSED_SIZE                 16
  1083. X#      define C_UNCOMPRESSED_SIZE               20
  1084. X#      define C_FILENAME_LENGTH                 24
  1085. X#      define C_EXTRA_FIELD_LENGTH              26
  1086. X#      define C_FILE_COMMENT_LENGTH             28
  1087. X#      define C_DISK_NUMBER_START               30
  1088. X#      define C_INTERNAL_FILE_ATTRIBUTES        32
  1089. X#      define C_EXTERNAL_FILE_ATTRIBUTES        34
  1090. X#      define C_RELATIVE_OFFSET_LOCAL_HEADER    38
  1091. X
  1092. X   typedef byte   ec_byte_rec[ ECREC_SIZE+4 ];
  1093. X/*     define SIGNATURE                         0   space-holder only */
  1094. X#      define NUMBER_THIS_DISK                  4
  1095. X#      define NUM_DISK_WITH_START_CENTRAL_DIR   6
  1096. X#      define NUM_ENTRIES_CENTRL_DIR_THS_DISK   8
  1097. X#      define TOTAL_ENTRIES_CENTRAL_DIR         10
  1098. X#      define SIZE_CENTRAL_DIRECTORY            12
  1099. X#      define OFFSET_START_CENTRAL_DIRECTORY    16
  1100. X#      define ZIPFILE_COMMENT_LENGTH            20
  1101. X
  1102. X
  1103. X   typedef struct local_file_header {                 /* LOCAL */
  1104. X       byte version_needed_to_extract[2];
  1105. X       UWORD general_purpose_bit_flag;
  1106. X       UWORD compression_method;
  1107. X       UWORD last_mod_file_time;
  1108. X       UWORD last_mod_file_date;
  1109. X       ULONG crc32;
  1110. X       ULONG compressed_size;
  1111. X       ULONG uncompressed_size;
  1112. X       UWORD filename_length;
  1113. X       UWORD extra_field_length;
  1114. X   } local_file_hdr;
  1115. X
  1116. X   typedef struct central_directory_file_header {     /* CENTRAL */
  1117. X       byte version_made_by[2];
  1118. X       byte version_needed_to_extract[2];
  1119. X       UWORD general_purpose_bit_flag;
  1120. X       UWORD compression_method;
  1121. X       UWORD last_mod_file_time;
  1122. X       UWORD last_mod_file_date;
  1123. X       ULONG crc32;
  1124. X       ULONG compressed_size;
  1125. X       ULONG uncompressed_size;
  1126. X       UWORD filename_length;
  1127. X       UWORD extra_field_length;
  1128. X       UWORD file_comment_length;
  1129. X       UWORD disk_number_start;
  1130. X       UWORD internal_file_attributes;
  1131. X       ULONG external_file_attributes;
  1132. X       ULONG relative_offset_local_header;
  1133. X   } cdir_file_hdr;
  1134. X
  1135. X   typedef struct end_central_dir_record {            /* END CENTRAL */
  1136. X       UWORD number_this_disk;
  1137. X       UWORD num_disk_with_start_central_dir;
  1138. X       UWORD num_entries_centrl_dir_ths_disk;
  1139. X       UWORD total_entries_central_dir;
  1140. X       ULONG size_central_directory;
  1141. X       ULONG offset_start_central_directory;
  1142. X       UWORD zipfile_comment_length;
  1143. X   } ecdir_rec;
  1144. X
  1145. X
  1146. X
  1147. X
  1148. X
  1149. X/*************************/
  1150. X/*  Function Prototypes  */
  1151. X/*************************/
  1152. X
  1153. X#ifndef __
  1154. X#  define __   OF
  1155. X#endif
  1156. X
  1157. X/*---------------------------------------------------------------------------
  1158. X    Functions in unzip.c and/or zipinfo.c:
  1159. X  ---------------------------------------------------------------------------*/
  1160. X
  1161. Xint    usage                     __((int error));
  1162. Xint    process_zipfile           __((void));
  1163. Xint    find_end_central_dir      __((void));
  1164. Xint    process_end_central_dir   __((void));
  1165. Xint    list_files                __((void));                      /* unzip.c */
  1166. Xint    process_cdir_file_hdr     __((void));                      /* unzip.c */
  1167. Xint    process_local_file_hdr    __((void));                      /* unzip.c */
  1168. Xint    process_central_dir       __((void));
  1169. Xint    long_info                 __((void));                    /* zipinfo.c */
  1170. Xint    short_info                __((void));                    /* zipinfo.c */
  1171. Xchar   *zipinfo_time             __((UWORD *datez, UWORD *timez));
  1172. X
  1173. X/*---------------------------------------------------------------------------
  1174. X    Functions in extract.c:
  1175. X  ---------------------------------------------------------------------------*/
  1176. X
  1177. Xint    extract_or_test_files     __((void));
  1178. X/* static int   store_info               __((void)); */
  1179. X/* static int   extract_or_test_member   __((void)); */
  1180. Xint    memextract                __((byte *, ULONG, byte *, ULONG));
  1181. Xint    FlushMemory               __((void));
  1182. Xint    ReadMemoryByte            __((UWORD *x));
  1183. X
  1184. X/*---------------------------------------------------------------------------
  1185. X    Decompression functions:
  1186. X  ---------------------------------------------------------------------------*/
  1187. X
  1188. Xint    explode                   __((void));                    /* explode.c */
  1189. X
  1190. Xvoid   inflate                   __((void));                    /* inflate.c */
  1191. X
  1192. Xvoid   unReduce                  __((void));                   /* unreduce.c */
  1193. X/* static void  LoadFollowers    __((void));                    * unreduce.c */
  1194. X
  1195. Xvoid   unShrink                  __((void));                   /* unshrink.c */
  1196. X/* static void  partial_clear    __((void));                    * unshrink.c */
  1197. X
  1198. X/*---------------------------------------------------------------------------
  1199. X    Functions in file_io.c and crypt.c:
  1200. X  ---------------------------------------------------------------------------*/
  1201. X
  1202. Xint    open_input_file           __((void));                    /* file_io.c */
  1203. Xint    readbuf                   __((char *buf, register unsigned len));
  1204. Xint    create_output_file        __((void));             /* file_io.c, vms.c */
  1205. Xint    FillBitBuffer             __((void));                    /* file_io.c */
  1206. Xint    ReadByte                  __((UWORD *x));                /* file_io.c */
  1207. Xint    FlushOutput               __((void));             /* file_io.c, vms.c */
  1208. X/* static int   dos2unix         __((unsigned char *, int));     * file_io.c */
  1209. Xvoid   set_file_time_and_close   __((void));                    /* file_io.c */
  1210. Xvoid   handler                   __((int signal));              /* file_io.c */
  1211. Xint    echo                      __((int opt));                 /* file_io.c */
  1212. Xvoid   echoff                    __((int f));                   /* file_io.c */
  1213. Xvoid   echon                     __((void));                    /* file_io.c */
  1214. Xchar   *getp                     __((char *, char *, int));     /* file_io.c */
  1215. X
  1216. Xint    decrypt_byte              __((void));                      /* crypt.c */
  1217. Xvoid   update_keys               __((int));                       /* crypt.c */
  1218. Xvoid   init_keys                 __((char *));                    /* crypt.c */
  1219. X
  1220. X/*---------------------------------------------------------------------------
  1221. X    Macintosh file_io functions:
  1222. X  ---------------------------------------------------------------------------*/
  1223. X
  1224. X#ifdef MACOS
  1225. X/* static int   IsHFSDisk        __((int)); */
  1226. X   void     macfstest            __((int));
  1227. X   int      macmkdir             __((char *, short, long));
  1228. X   void     ResolveMacVol        __((short, short *, long *, StringPtr));
  1229. X   short    macopen              __((char *, short, short, long));
  1230. X   short    maccreat             __((char *, short, long, OSType, OSType));
  1231. X   short    macread              __((short, char *, unsigned));
  1232. X   short    macwrite             __((short, char *, unsigned));
  1233. X   short    macclose             __((short));
  1234. X   long     maclseek             __((short, long, short));
  1235. X#endif
  1236. X
  1237. X/*---------------------------------------------------------------------------
  1238. X    OS/2 file_io functions:
  1239. X  ---------------------------------------------------------------------------*/
  1240. X
  1241. Xvoid     ChangeNameForFAT  __((char *name));                   /* os2unzip.c */
  1242. Xint      IsFileNameValid   __((char *name));                   /* os2unzip.c */
  1243. Xint      GetCountryInfo    __((void));                         /* os2unzip.c */
  1244. Xlong     GetFileTime       __((char *name));                   /* os2unzip.c */
  1245. Xvoid     SetPathInfo __((char *path, UWORD moddate, UWORD modtime, int flags));
  1246. Xint      SetLongNameEA     __((char *name, char *longname));   /* os2unzip.c */
  1247. Xint      IsEA              __((void *extra_field));            /* os2unzip.c */
  1248. XULONG    SizeOfEAs         __((void *extra_field));            /* os2unzip.c */
  1249. Xvoid     SetEAs            __((char *path, void *eablock));    /* os2unzip.c */
  1250. Xint      IsUpperNLS        __((int nChr));                     /* os2unzip.c */
  1251. Xint      ToLowerNLS        __((int nChr));                     /* os2unzip.c */
  1252. X
  1253. X/*---------------------------------------------------------------------------
  1254. X    VMS file_io functions:
  1255. X  ---------------------------------------------------------------------------*/
  1256. X
  1257. Xint      check_format      __((void));                              /* vms.c */
  1258. Xint      find_vms_attrs    __((void));                              /* vms.c */
  1259. Xint      CloseOutputFile   __((void));                              /* vms.c */
  1260. X/* static byte *extract_block __((struct extra_block *, int *, byte *, int));*/
  1261. X/* static int  _flush_blocks  __((int final_flag));                  * vms.c */
  1262. X/* static int  _flush_records __((int final_flag));                  * vms.c */
  1263. X/* static int  WriteBuffer    __((unsigned char *buf, int len));     * vms.c */
  1264. X/* static int  WriteRecord    __((unsigned char *rec, int len));     * vms.c */
  1265. X/* static void message        __((int string, char *status));        * vms.c */
  1266. X
  1267. Xint      VMSmunch          __((char *, int, char *));          /* VMSmunch.c */
  1268. X
  1269. X/*---------------------------------------------------------------------------
  1270. X    Functions in match.c, mapname.c, misc.c, etc.:
  1271. X  ---------------------------------------------------------------------------*/
  1272. X
  1273. Xint      match             __((char *string, char *pattern));     /* match.c */
  1274. X
  1275. Xint      mapname           __((int create_dirs));               /* mapname.c */
  1276. X
  1277. Xvoid     UpdateCRC         __((register unsigned char *s, register int len));
  1278. Xint      do_string         __((unsigned int len, int option));     /* misc.c */
  1279. Xtime_t   dos_to_unix_time  __((unsigned ddate, unsigned dtime));   /* misc.c */
  1280. Xint      check_for_newer   __((char *filename));                   /* misc.c */
  1281. Xint      dateformat        __((void));                             /* misc.c */
  1282. XUWORD    makeword          __((byte *b));                          /* misc.c */
  1283. XULONG    makelong          __((byte *sig));                        /* misc.c */
  1284. Xvoid     return_VMS        __((int zip_error));                    /* misc.c */
  1285. X
  1286. Xvoid     envargs           __((int *, char ***, char *));       /* envargs.c */
  1287. X
  1288. X#ifdef AMIGA
  1289. X   int   utime             __((char *file, time_t timep[]));      /* utime.c */
  1290. X#endif /* AMIGA */
  1291. X
  1292. X#ifdef ZMEM   /* these MUST be ifdef'd because of conflicts with the std def */
  1293. X   char  *memset           __((register char *buf, register char init,
  1294. X                               register unsigned int len));        /* misc.c */
  1295. X   char  *memcpy           __((register char *dst, register char *src,
  1296. X                               register unsigned int len));        /* misc.c */
  1297. X#endif /* ZMEM */
  1298. X
  1299. X
  1300. X
  1301. X
  1302. X
  1303. X/************/
  1304. X/*  Macros  */
  1305. X/************/
  1306. X
  1307. X#ifndef MAX
  1308. X#  define MAX(a,b)   ((a) > (b) ? (a) : (b))
  1309. X#endif
  1310. X
  1311. X#ifndef MIN
  1312. X#  define MIN(a,b)   ((a) < (b) ? (a) : (b))
  1313. X#endif
  1314. X
  1315. X
  1316. X#define LSEEK(abs_offset) {longint request=(abs_offset)+extra_bytes,\
  1317. X   inbuf_offset=request%INBUFSIZ, bufstart=request-inbuf_offset;\
  1318. X   if(request<0) {fprintf(stderr, SeekMsg, ReportMsg); return(3);}\
  1319. X   else if(bufstart!=cur_zipfile_bufstart)\
  1320. X   {cur_zipfile_bufstart=lseek(zipfd,bufstart,SEEK_SET);\
  1321. X   if((incnt=read(zipfd,(char *)inbuf,INBUFSIZ))<=0) return(51);\
  1322. X   inptr=inbuf+(int)inbuf_offset; incnt-=(int)inbuf_offset;} else\
  1323. X   {incnt+=(inptr-inbuf)-(int)inbuf_offset; inptr=inbuf+(int)inbuf_offset;}}
  1324. X
  1325. X/*
  1326. X *  Seek to the block boundary of the block which includes abs_offset,
  1327. X *  then read block into input buffer and set pointers appropriately.
  1328. X *  If block is already in the buffer, just set the pointers.  This macro
  1329. X *  is used by process_end_central_dir (unzip.c) and do_string (misc.c).
  1330. X *  A slightly modified version is embedded within extract_or_test_files
  1331. X *  (unzip.c).  ReadByte and readbuf (file_io.c) are compatible.
  1332. X *
  1333. X *  macro LSEEK(abs_offset)
  1334. X *      ULONG   abs_offset;
  1335. X *  {
  1336. X *      longint   request = abs_offset + extra_bytes;
  1337. X *      longint   inbuf_offset = request % INBUFSIZ;
  1338. X *      longint   bufstart = request - inbuf_offset;
  1339. X *
  1340. X *      if (request < 0) {
  1341. X *          fprintf(stderr, SeekMsg, ReportMsg);
  1342. X *          return(3);             /-* 3:  severe error in zipfile *-/
  1343. X *      } else if (bufstart != cur_zipfile_bufstart) {
  1344. X *          cur_zipfile_bufstart = lseek(zipfd, bufstart, SEEK_SET);
  1345. X *          if ((incnt = read(zipfd,inbuf,INBUFSIZ)) <= 0)
  1346. X *              return(51);        /-* 51:  unexpected EOF *-/
  1347. X *          inptr = inbuf + (int)inbuf_offset;
  1348. X *          incnt -= (int)inbuf_offset;
  1349. X *      } else {
  1350. X *          incnt += (inptr-inbuf) - (int)inbuf_offset;
  1351. X *          inptr = inbuf + (int)inbuf_offset;
  1352. X *      }
  1353. X *  }
  1354. X *
  1355. X */
  1356. X
  1357. X
  1358. X#define SKIP_(length) if(length&&((error=do_string(length,SKIP))!=0))\
  1359. X  {error_in_archive=error; if(error>1) return error;}
  1360. X
  1361. X/*
  1362. X *  Skip a variable-length field, and report any errors.  Used in zipinfo.c
  1363. X *  and unzip.c in several functions.
  1364. X *
  1365. X *  macro SKIP_(length)
  1366. X *      UWORD   length;
  1367. X *  {
  1368. X *      if (length && ((error = do_string(length, SKIP)) != 0)) {
  1369. X *          error_in_archive = error;   /-* might be warning *-/
  1370. X *          if (error > 1)              /-* fatal *-/
  1371. X *              return (error);
  1372. X *      }
  1373. X *  }
  1374. X *
  1375. X */
  1376. X
  1377. X
  1378. X#define OUTB(intc) {*outptr++=(byte)(intc); if (++outcnt==OUTBUFSIZ)\
  1379. X  FlushOutput();}
  1380. X
  1381. X/*
  1382. X *  macro OUTB(intc)
  1383. X *  {
  1384. X *      *outptr++ = (byte)(intc);
  1385. X *      if (++outcnt == OUTBUFSIZ)
  1386. X *          FlushOutput();
  1387. X *  }
  1388. X *
  1389. X */
  1390. X
  1391. X
  1392. X#define READBIT(nbits,zdest) {if(nbits>bits_left) FillBitBuffer();\
  1393. X  zdest=(int)((UWORD)bitbuf&mask_bits[nbits]);bitbuf>>=nbits;bits_left-=nbits;}
  1394. X
  1395. X/*
  1396. X * macro READBIT(nbits,zdest)
  1397. X *  {
  1398. X *      if (nbits > bits_left)
  1399. X *          FillBitBuffer();
  1400. X *      zdest = (int)((UWORD)bitbuf & mask_bits[nbits]);
  1401. X *      bitbuf >>= nbits;
  1402. X *      bits_left -= nbits;
  1403. X *  }
  1404. X *
  1405. X */
  1406. X
  1407. X
  1408. X#define PEEKBIT(nbits) (nbits>bits_left? (FillBitBuffer(),\
  1409. X  (UWORD)bitbuf & mask_bits[nbits]) : (UWORD)bitbuf & mask_bits[nbits])
  1410. X
  1411. X
  1412. X#define NUKE_CRs(buf,len) {register int i,j; for (i=j=0; j<len;\
  1413. X  (buf)[i++]=(buf)[j++]) if ((buf)[j]=='\r') ++j; len=i;}
  1414. X
  1415. X/*
  1416. X *  Remove all the ASCII carriage returns from buffer buf (length len),
  1417. X *  shortening as necessary (note that len gets modified in the process,
  1418. X *  so it CANNOT be an expression).  This macro is intended to be used
  1419. X *  BEFORE A_TO_N(); hence the check for CR instead of '\r'.  NOTE:  The
  1420. X *  if-test gets performed one time too many, but it doesn't matter.
  1421. X *
  1422. X *  macro NUKE_CRs(buf,len)
  1423. X *  {
  1424. X *      register int   i, j;
  1425. X *
  1426. X *      for (i = j = 0;  j < len;  (buf)[i++] = (buf)[j++])
  1427. X *          if ((buf)[j] == CR)
  1428. X *              ++j;
  1429. X *      len = i;
  1430. X *  }
  1431. X *
  1432. X */
  1433. X
  1434. X
  1435. X#define TOLOWER(str1,str2) {char *ps1,*ps2; ps1=(str1)-1; ps2=(str2);\
  1436. X  while(*++ps1) *ps2++=(char)(isupper((int)(*ps1))?tolower((int)(*ps1)):*ps1);\
  1437. X  *ps2='\0';}
  1438. X
  1439. X/*
  1440. X *  Copy the zero-terminated string in str1 into str2, converting any
  1441. X *  uppercase letters to lowercase as we go.  str2 gets zero-terminated
  1442. X *  as well, of course.  str1 and str2 may be the same character array.
  1443. X *
  1444. X *  macro TOLOWER( str1, str2 )
  1445. X *  {
  1446. X *      char  *ps1, *ps2;
  1447. X *
  1448. X *      ps1 = (str1) - 1;
  1449. X *      ps2 = (str2);
  1450. X *      while (*++ps1)
  1451. X *          *ps2++ = (char)(isupper((int)(*ps1))? tolower((int)(*ps1)) : *ps1);
  1452. X *      *ps2='\0';
  1453. X *  }
  1454. X *
  1455. X *  NOTES:  This macro makes no assumptions about the characteristics of
  1456. X *    the tolower() function or macro (beyond its existence), nor does it
  1457. X *    make assumptions about the structure of the character set (i.e., it
  1458. X *    should work on EBCDIC machines, too).  The fact that either or both
  1459. X *    of isupper() and tolower() may be macros has been taken into account;
  1460. X *    watch out for "side effects" (in the C sense) when modifying this
  1461. X *    macro.
  1462. X */
  1463. X
  1464. X
  1465. X#ifndef ascii_to_native
  1466. X#  define ascii_to_native(c)   (c)
  1467. X#  define A_TO_N(str1)
  1468. X#else
  1469. X#  ifndef NATIVE
  1470. X#    define NATIVE     "native chars"
  1471. X#  endif
  1472. X#  define A_TO_N(str1) {register unsigned char *ps1;\
  1473. X     for (ps1=str1; *ps1; ps1++) *ps1=ascii_to_native(*ps1);}
  1474. X#endif
  1475. X
  1476. X/*
  1477. X *  Translate the zero-terminated string in str1 from ASCII to the native
  1478. X *  character set. The translation is performed in-place and uses the
  1479. X *  ascii_to_native macro to translate each character.
  1480. X *
  1481. X *  macro A_TO_N( str1 )
  1482. X *  {
  1483. X *      register unsigned char *ps1;
  1484. X *
  1485. X *      for (ps1 = str1;  *ps1;  ++ps1)
  1486. X *          *ps1 = ascii_to_native(*ps1);
  1487. X *  }
  1488. X *
  1489. X *  NOTE:  Using the ascii_to_native macro means that is it the only part of
  1490. X *    unzip which knows which translation table (if any) is actually in use
  1491. X *    to produce the native character set.  This makes adding new character
  1492. X *    set translation tables easy, insofar as all that is needed is an
  1493. X *    appropriate ascii_to_native macro definition and the translation
  1494. X *    table itself.  Currently, the only non-ASCII native character set
  1495. X *    implemented is EBCDIC, but this may not always be so.
  1496. X */
  1497. X
  1498. X
  1499. X
  1500. X
  1501. X
  1502. X/*************/
  1503. X/*  Globals  */
  1504. X/*************/
  1505. X
  1506. X   extern int       aflag;
  1507. X/* extern int       bflag;   reserved */
  1508. X   extern int       cflag;
  1509. X   extern int       fflag;
  1510. X   extern int       jflag;
  1511. X   extern int       overwrite_none;
  1512. X   extern int       overwrite_all;
  1513. X   extern int       force_flag;
  1514. X   extern int       quietflg;
  1515. X#ifdef DOS_OS2
  1516. X   extern int       sflag;
  1517. X#endif
  1518. X   extern int       tflag;
  1519. X   extern int       uflag;
  1520. X   extern int       V_flag;
  1521. X#ifdef VMS
  1522. X   extern int       secinf;
  1523. X#endif
  1524. X#ifdef MACOS
  1525. X   extern int       hfsflag;
  1526. X#endif
  1527. X   extern int       process_all_files;
  1528. X   extern longint   csize;
  1529. X   extern longint   ucsize;
  1530. X   extern char      *fnames[];
  1531. X   extern char      **fnv;
  1532. X   extern char      sig[];
  1533. X   extern char      answerbuf[];
  1534. X   extern min_info  *pInfo;
  1535. X   extern char      *key;
  1536. X   extern ULONG     keys[];
  1537. X
  1538. X#ifdef MACOS
  1539. X   union work {
  1540. X     struct {
  1541. X       short *Prefix_of;        /* (8193 * sizeof(short)) */
  1542. X       byte *Suffix_of;
  1543. X       byte *Stack;
  1544. X     } shrink;
  1545. X     byte *Slide;
  1546. X   };
  1547. X#else
  1548. X   union work {
  1549. X     struct {
  1550. X       short Prefix_of[HSIZE + 2];      /* (8194 * sizeof(short)) */
  1551. X       byte Suffix_of[HSIZE + 2];       /* also s-f length_nodes (smaller) */
  1552. X       byte Stack[HSIZE + 2];           /* also s-f distance_nodes (smaller) */
  1553. X     } shrink;
  1554. X     byte Slide[WSIZE];
  1555. X   };
  1556. X#endif
  1557. X   extern union work area;
  1558. X
  1559. X#  define prefix_of area.shrink.Prefix_of
  1560. X#  define suffix_of area.shrink.Suffix_of
  1561. X#  define stack area.shrink.Stack
  1562. X#  define slide area.Slide
  1563. X
  1564. X   extern ULONG     crc32val;
  1565. X   extern UWORD     mask_bits[];
  1566. X
  1567. X   extern byte      *inbuf;
  1568. X   extern byte      *inptr;
  1569. X   extern int       incnt;
  1570. X   extern ULONG     bitbuf;
  1571. X   extern int       bits_left;
  1572. X   extern boolean   zipeof;
  1573. X   extern int       zipfd;
  1574. X#ifdef MSWIN
  1575. X   extern char      *zipfn;
  1576. X#else
  1577. X   extern char      zipfn[];
  1578. X#endif
  1579. X   extern longint   extra_bytes;
  1580. X   extern longint   cur_zipfile_bufstart;
  1581. X   extern byte      *extra_field;
  1582. X   extern char      local_hdr_sig[];
  1583. X   extern char      central_hdr_sig[];
  1584. X   extern char      end_central_sig[];
  1585. X   extern local_file_hdr  lrec;
  1586. X   extern cdir_file_hdr   crec;
  1587. X   extern ecdir_rec       ecrec;
  1588. X   extern struct stat     statbuf;
  1589. X
  1590. X   extern byte      *outbuf;
  1591. X   extern byte      *outptr;
  1592. X#ifdef MSWIN
  1593. X   extern byte __far *outout;
  1594. X   extern char     *filename;
  1595. X#else
  1596. X   extern byte      *outout;
  1597. X   extern char      filename[];
  1598. X#endif
  1599. X   extern longint   outpos;
  1600. X   extern int       outcnt;
  1601. X   extern int       outfd;
  1602. X   extern int       mem_mode;
  1603. X   extern int       disk_full;
  1604. X
  1605. X   extern char      *EndSigMsg;
  1606. X   extern char      *CentSigMsg;
  1607. X   extern char      *SeekMsg;
  1608. X   extern char      *ReportMsg;
  1609. X
  1610. X#ifdef DECLARE_ERRNO
  1611. X   extern int       errno;
  1612. X#endif
  1613. X
  1614. X#ifdef EBCDIC
  1615. X   extern byte      ebcdic[];
  1616. X#endif
  1617. X
  1618. X#ifdef MACOS
  1619. X   extern short     gnVRefNum;
  1620. X   extern long      glDirID;
  1621. X   extern OSType    gostCreator;
  1622. X   extern OSType    gostType;
  1623. X   extern boolean   fMacZipped;
  1624. X   extern boolean   macflag;
  1625. X   extern short     giCursor;
  1626. X   extern CursHandle rghCursor[];
  1627. X#endif
  1628. END_OF_FILE
  1629.   if test 43208 -ne `wc -c <'unzip.h'`; then
  1630.     echo shar: \"'unzip.h'\" unpacked with wrong size!
  1631.   fi
  1632.   # end of 'unzip.h'
  1633. fi
  1634. echo shar: End of archive 1 \(of 14\).
  1635. cp /dev/null ark1isdone
  1636. MISSING=""
  1637. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1638.     if test ! -f ark${I}isdone ; then
  1639.     MISSING="${MISSING} ${I}"
  1640.     fi
  1641. done
  1642. if test "${MISSING}" = "" ; then
  1643.     echo You have unpacked all 14 archives.
  1644.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1645. else
  1646.     echo You still must unpack the following archives:
  1647.     echo "        " ${MISSING}
  1648. fi
  1649. exit 0
  1650. exit 0 # Just in case...
  1651.