home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume31 / unzip50 / part01 < prev    next >
Encoding:
Text File  |  1992-08-22  |  58.9 KB  |  1,646 lines

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