home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip540.zip / unzip.c < prev    next >
C/C++ Source or Header  |  1998-11-21  |  60KB  |  1,730 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   unzip.c
  4.  
  5.   UnZip - a zipfile extraction utility.  See below for make instructions, or
  6.   read the comments in Makefile and the various Contents files for more de-
  7.   tailed explanations.  To report a bug, send a *complete* description to
  8.   Zip-Bugs@lists.wku.edu; include machine type, operating system and ver-
  9.   sion, compiler and version, and reasonably detailed error messages or prob-
  10.   lem report.  To join Info-ZIP, see the instructions in README.
  11.  
  12.   UnZip 5.x is a greatly expanded and partially rewritten successor to 4.x,
  13.   which in turn was almost a complete rewrite of version 3.x.  For a detailed
  14.   revision history, see UnzpHist.zip at quest.jpl.nasa.gov.  For a list of
  15.   the many (near infinite) contributors, see "CONTRIBS" in the UnZip source
  16.   distribution.
  17.  
  18.   ---------------------------------------------------------------------------
  19.  
  20.   [from original zipinfo.c]
  21.  
  22.   This program reads great gobs of totally nifty information, including the
  23.   central directory stuff, from ZIP archives ("zipfiles" for short).  It
  24.   started as just a testbed for fooling with zipfiles, but at this point it
  25.   is actually a useful utility.  It also became the basis for the rewrite of
  26.   UnZip (3.16 -> 4.0), using the central directory for processing rather than
  27.   the individual (local) file headers.
  28.  
  29.   As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
  30.   If the executable is named "unzip" (or "unzip.exe", depending), it behaves
  31.   like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
  32.   ZipInfo.  The ZipInfo behavior may also be triggered by use of unzip's -Z
  33.   option; for example, "unzip -Z [zipinfo_options] archive.zip".
  34.  
  35.   Another dandy product from your buddies at Newtware!
  36.  
  37.   Author:  Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
  38.            23 August 1990 -> April 1997
  39.  
  40.   ---------------------------------------------------------------------------
  41.  
  42.   Version:  unzip5??.{tar.Z | tar.gz | zip} for Unix, VMS, OS/2, MS-DOS, Amiga,
  43.               Atari, Windows 3.x/95/NT/CE, Macintosh, Human68K, Acorn RISC OS,
  44.               BeOS, SMS/QDOS, VM/CMS, MVS, AOS/VS and TOPS-20.  Decryption
  45.               requires sources in zcrypt28.zip.  See the accompanying "WHERE"
  46.               file in the main source distribution for ftp, uucp, BBS and mail-
  47.               server sites, or see http://www.cdrom.com/pub/infozip/UnZip.html .
  48.  
  49.   Copyrights:  see accompanying file "COPYING" in UnZip source distribution.
  50.                (This software is free but NOT IN THE PUBLIC DOMAIN.  There
  51.                are some restrictions on commercial use.)
  52.  
  53.   ---------------------------------------------------------------------------*/
  54.  
  55.  
  56.  
  57. #define UNZIP_C
  58. #define UNZIP_INTERNAL
  59. #include "unzip.h"        /* includes, typedefs, macros, prototypes, etc. */
  60. #include "crypt.h"
  61. #include "version.h"
  62.  
  63. #ifndef WINDLL            /* The WINDLL port uses windll/windll.c instead... */
  64.  
  65. /*******************/
  66. /* Local Functions */
  67. /*******************/
  68.  
  69. #ifndef SFX
  70. static void  show_version_info  OF((__GPRO));
  71. #endif
  72.  
  73.  
  74. /*************/
  75. /* Constants */
  76. /*************/
  77.  
  78. #include "consts.h"  /* all constant global variables are in here */
  79.                      /* (non-constant globals were moved to globals.c) */
  80.  
  81. /* constant local variables: */
  82.  
  83. #ifndef SFX
  84.    static ZCONST char Far EnvUnZip[] = ENV_UNZIP;
  85.    static ZCONST char Far EnvUnZip2[] = ENV_UNZIP2;
  86.    static ZCONST char Far EnvZipInfo[] = ENV_ZIPINFO;
  87.    static ZCONST char Far EnvZipInfo2[] = ENV_ZIPINFO2;
  88. #ifdef RISCOS
  89.    static ZCONST char Far EnvUnZipExts[] = ENV_UNZIPEXTS;
  90. #endif /* RISCOS */
  91. #endif
  92.  
  93. #if (!defined(SFX) || defined(SFX_EXDIR))
  94.    static ZCONST char Far NotExtracting[] =
  95.      "caution:  not extracting; -d ignored\n";
  96.    static ZCONST char Far MustGiveExdir[] =
  97.      "error:  must specify directory to which to extract with -d option\n";
  98.    static ZCONST char Far OnlyOneExdir[] =
  99.      "error:  -d option used more than once (only one exdir allowed)\n";
  100. #endif
  101.  
  102. #if CRYPT
  103.    static ZCONST char Far MustGivePasswd[] =
  104.      "error:  must give decryption password with -P option\n";
  105. #endif
  106.  
  107. #ifndef SFX
  108.    static ZCONST char Far Zfirst[] =
  109.    "error:  -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
  110. #endif
  111. static ZCONST char Far InvalidOptionsMsg[] = "error:\
  112.   -fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
  113. static ZCONST char Far IgnoreOOptionMsg[] =
  114.   "caution:  both -n and -o specified; ignoring -o\n";
  115.  
  116. /* usage() strings */
  117. #ifndef SFX
  118. #ifdef VMS
  119.    static ZCONST char Far Example3[] = "vms.c";
  120.    static ZCONST char Far Example2[] = "  unzip\
  121.  \"-V\" foo \"Bar\" => must quote uppercase options and filenames in VMS\n";
  122. #else /* !VMS */
  123.    static ZCONST char Far Example3[] = "ReadMe";
  124. #ifdef RISCOS
  125.    static ZCONST char Far Example2[] =
  126. "  unzip foo -d RAM:$   => extract all files from foo into RAMDisc\n";
  127. #else /* !RISCOS */
  128. #if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
  129.    static ZCONST char Far Example2[] =
  130.      "";                /* no room:  too many local3[] items */
  131. #else /* !OS2 */
  132. #ifdef MACOS
  133.    static ZCONST char Far Example2[] = ""; /* not needed */
  134. #else /* !MACOS */
  135.    static ZCONST char Far Example2[] = " \
  136.  unzip -p foo | more  => send contents of foo.zip via pipe into program more\n";
  137. #endif /* ?MACOS */
  138. #endif /* ?OS2 */
  139. #endif /* ?RISCOS */
  140. #endif /* ?VMS */
  141.  
  142. /* local1[]:  command options */
  143. #if (defined(DLL) && defined(API_DOC))
  144.    static ZCONST char Far local1[] =
  145.      "  -A  print extended help for API functions";
  146. #else /* !(DLL && API_DOC) */
  147.    static ZCONST char Far local1[] = "";
  148. #endif /* ?(DLL && API_DOC) */
  149.  
  150. /* local2[] and local3[]:  modifier options */
  151. #ifdef DOS_FLX_OS2_W32
  152. #ifdef FLEXOS
  153.    static ZCONST char Far local2[] = "";
  154. #else
  155.    static ZCONST char Far local2[] =
  156.      " -$  label removables (-$$ => fixed disks)";
  157. #endif
  158. #ifdef OS2
  159. #ifdef MORE
  160.    static ZCONST char Far local3[] = "\
  161.   -X  restore ACLs if supported              -s  spaces in filenames => '_'\n\
  162.                                              -M  pipe through \"more\" pager\n";
  163. #else
  164.    static ZCONST char Far local3[] = " \
  165.  -X  restore ACLs if supported              -s  spaces in filenames => '_'\n\n";
  166. #endif /* ?MORE */
  167. #else /* !OS2 */
  168. #ifdef WIN32
  169. #ifdef MORE
  170.    static ZCONST char Far local3[] = "\
  171.   -X  restore ACLs (-XX => use privileges)   -s  spaces in filenames => '_'\n\
  172.                                              -M  pipe through \"more\" pager\n";
  173. #else
  174.    static ZCONST char Far local3[] = " \
  175.  -X  restore ACLs (-XX => use privileges)   -s  spaces in filenames => '_'\n\n";
  176. #endif /* ?MORE */
  177. #else /* !WIN32 */
  178. #ifdef MORE
  179.    static ZCONST char Far local3[] = "  -\
  180. M  pipe through \"more\" pager              -s  spaces in filenames => '_'\n\n";
  181. #else
  182.    static ZCONST char Far local3[] = "\
  183.                                              -s  spaces in filenames => '_'\n";
  184. #endif
  185. #endif /* ?WIN32 */
  186. #endif /* ?OS2 || ?WIN32 */
  187. #else /* !DOS_FLX_OS2_W32 */
  188. #ifdef VMS
  189.    static ZCONST char Far local2[] = "\"-X\" restore owner/protection info";
  190. #ifdef MORE
  191.    static ZCONST char Far local3[] = "  \
  192.                                           \"-M\" pipe through \"more\" pager\n";
  193. #else
  194.    static ZCONST char Far local3[] = "\n";
  195. #endif
  196. #else /* !VMS */
  197. #if (defined(__BEOS__) || defined(TANDEM) || defined(UNIX))
  198.    static ZCONST char Far local2[] = " -X  restore UID/GID info";
  199. #ifdef MORE
  200.    static ZCONST char Far local3[] = "\
  201.                                              -M  pipe through \"more\" pager\n";
  202. #else
  203.    static ZCONST char Far local3[] = "\n";
  204. #endif
  205. #else /* !(__BEOS__ || TANDEM || UNIX) */
  206. #ifdef AMIGA
  207.    static ZCONST char Far local2[] = " -N  restore comments as filenotes";
  208. #ifdef MORE
  209.    static ZCONST char Far local3[] = "\
  210.                                              -M  pipe through \"more\" pager\n";
  211. #else
  212.    static ZCONST char Far local3[] = "\n";
  213. #endif
  214. #else /* !AMIGA */
  215. #ifdef MACOS
  216.    static ZCONST char Far local2[] = " -E  show Mac info during extraction";
  217.    static ZCONST char Far local3[] = " \
  218.  -i  ignore filenames in mac extra info     -J  junk (ignore) Mac extra info\n\n";
  219. #else /* !MACOS */
  220. #ifdef MORE
  221.    static ZCONST char Far local2[] = " -M  pipe through \"more\" pager";
  222.    static ZCONST char Far local3[] = "\n";
  223. #else
  224.    static ZCONST char Far local2[] = "";   /* Atari, Mac, CMS/MVS etc. */
  225.    static ZCONST char Far local3[] = "";
  226. #endif
  227. #endif /* ?MACOS */
  228. #endif /* ?AMIGA */
  229. #endif /* ?(__BEOS__ || TANDEM || UNIX) */
  230. #endif /* ?VMS */
  231. #endif /* ?DOS_FLX_OS2_W32 */
  232. #endif /* !SFX */
  233.  
  234. #ifndef NO_ZIPINFO
  235. #ifdef VMS
  236.    static ZCONST char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
  237. #else
  238.    static ZCONST char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
  239. #endif
  240.  
  241. static ZCONST char Far ZipInfoUsageLine1[] = "\
  242. ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
  243. \n\
  244. List name, date/time, attribute, size, compression method, etc., about files\n\
  245. in list (excluding those in xlist) contained in the specified .zip archive(s).\
  246. \n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
  247.    usage:  zipinfo [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n\
  248.       or:  unzip %s-Z%s [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n";
  249.  
  250. static ZCONST char Far ZipInfoUsageLine2[] = "\nmain\
  251.  listing-format options:             -s  short Unix \"ls -l\" format (def.)\n\
  252.   -1  filenames ONLY, one per line       -m  medium Unix \"ls -l\" format\n\
  253.   -2  just filenames but allow -h/-t/-z  -l  long Unix \"ls -l\" format\n\
  254.                                          -v  verbose, multi-page format\n";
  255.  
  256. static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
  257.   -h  print header line       -t  print totals for listed files or for all\n\
  258.   -z  print zipfile comment  %c-T%c print file times in sortable decimal format\
  259. \n %c-C%c be case-insensitive   %s\
  260.   -x  exclude filenames that follow from listing\n";
  261. #ifdef MORE
  262. #ifdef VMS
  263.    static ZCONST char Far ZipInfoUsageLine4[] =
  264.      " \"-M\" page output through built-in \"more\"\n";
  265. #else
  266.    static ZCONST char Far ZipInfoUsageLine4[] =
  267.      "  -M  page output through built-in \"more\"\n";
  268. #endif
  269. #else /* !MORE */
  270.    static ZCONST char Far ZipInfoUsageLine4[] = "";
  271. #endif /* ?MORE */
  272. #endif /* !NO_ZIPINFO */
  273.  
  274. #ifdef BETA
  275. #  ifdef VMSCLI
  276.    /* BetaVersion[] is also used in vms/cmdline.c:  do not make it static */
  277.      ZCONST char Far BetaVersion[] = "%s\
  278.         THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
  279. #  else
  280.      static ZCONST char Far BetaVersion[] = "%s\
  281.         THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
  282. #  endif
  283. #endif
  284.  
  285. #ifdef SFX
  286. #  ifdef VMSCLI
  287.    /* UnzipSFXBanner[] is also used in vms/cmdline.c:  do not make it static */
  288.      ZCONST char Far UnzipSFXBanner[] =
  289. #  else
  290.      static ZCONST char Far UnzipSFXBanner[] =
  291. #  endif
  292.      "UnZipSFX %d.%d%d%s of %s, by Info-ZIP (Zip-Bugs@lists.wku.edu).\n";
  293. #  ifdef SFX_EXDIR
  294.      static ZCONST char Far UnzipSFXOpts[] =
  295.     "Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
  296. #  else
  297.      static ZCONST char Far UnzipSFXOpts[] =
  298.        "Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
  299. #  endif
  300. #else /* !SFX */
  301.    static ZCONST char Far CompileOptions[] =
  302.      "UnZip special compilation options:\n";
  303.    static ZCONST char Far CompileOptFormat[] = "\t%s\n";
  304.    static ZCONST char Far EnvOptions[] =
  305.      "\nUnZip and ZipInfo environment options:\n";
  306.    static ZCONST char Far EnvOptFormat[] = "%16s:  %s\n";
  307.    static ZCONST char Far None[] = "[none]";
  308. #  ifdef ACORN_FTYPE_NFS
  309.      static ZCONST char Far AcornFtypeNFS[] = "ACORN_FTYPE_NFS";
  310. #  endif
  311. #  ifdef ASM_CRC
  312.      static ZCONST char Far AsmCRC[] = "ASM_CRC";
  313. #  endif
  314. #  ifdef ASM_INFLATECODES
  315.      static ZCONST char Far AsmInflateCodes[] = "ASM_INFLATECODES";
  316. #  endif
  317. #  ifdef CHECK_VERSIONS
  318.      static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS";
  319. #  endif
  320. #  ifdef COPYRIGHT_CLEAN
  321.      static ZCONST char Far Copyright_Clean[] =
  322.      "COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
  323. #  endif
  324. #  ifdef DEBUG
  325.      static ZCONST char Far UDebug[] = "DEBUG";
  326. #  endif
  327. #  ifdef DEBUG_TIME
  328.      static ZCONST char Far DebugTime[] = "DEBUG_TIME";
  329. #  endif
  330. #  ifdef DLL
  331.      static ZCONST char Far Dll[] = "DLL";
  332. #  endif
  333. #  ifdef DOSWILD
  334.      static ZCONST char Far DosWild[] = "DOSWILD";
  335. #  endif
  336. #  ifdef LZW_CLEAN
  337.      static ZCONST char Far LZW_Clean[] =
  338.      "LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
  339. #  endif
  340. #  ifndef MORE
  341.      static ZCONST char Far No_More[] = "NO_MORE";
  342. #  endif
  343. #  ifdef NO_ZIPINFO
  344.      static ZCONST char Far No_ZipInfo[] = "NO_ZIPINFO";
  345. #  endif
  346. #  ifdef NTSD_EAS
  347.      static ZCONST char Far NTSDExtAttrib[] = "NTSD_EAS";
  348. #  endif
  349. #  ifdef OS2_EAS
  350.      static ZCONST char Far OS2ExtAttrib[] = "OS2_EAS";
  351. #  endif
  352. #  ifdef QLZIP
  353.      static ZCONST char Far SMSExFldOnUnix[] = "QLZIP";
  354. #  endif
  355. #  ifdef REENTRANT
  356.      static ZCONST char Far Reentrant[] = "REENTRANT";
  357. #  endif
  358. #  ifdef REGARGS
  359.      static ZCONST char Far RegArgs[] = "REGARGS";
  360. #  endif
  361. #  ifdef RETURN_CODES
  362.      static ZCONST char Far Return_Codes[] = "RETURN_CODES";
  363. #  endif
  364. #  ifdef SET_DIR_ATTRIB
  365.      static ZCONST char Far SetDirAttrib[] = "SET_DIR_ATTRIB";
  366. #  endif
  367. #  ifdef TIMESTAMP
  368.      static ZCONST char Far TimeStamp[] = "TIMESTAMP";
  369. #  endif
  370. #  ifdef UNIXBACKUP
  371.      static ZCONST char Far UnixBackup[] = "UNIXBACKUP";
  372. #  endif
  373. #  ifdef USE_EF_UT_TIME
  374.      static ZCONST char Far Use_EF_UT_time[] = "USE_EF_UT_TIME";
  375. #  endif
  376. #  ifndef LZW_CLEAN
  377.      static ZCONST char Far Use_Unshrink[] =
  378.      "USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
  379. #  endif
  380. #  ifndef COPYRIGHT_CLEAN
  381.      static ZCONST char Far Use_Smith_Code[] =
  382.      "USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
  383. #  endif
  384. #  ifdef USE_VFAT
  385.      static ZCONST char Far Use_VFAT_support[] = "USE_VFAT";
  386. #  endif
  387. #  ifdef USE_ZLIB
  388.      static ZCONST char Far UseZlib[] =
  389.      "USE_ZLIB (compiled with version %s; using version %s)";
  390. #  endif
  391. #  ifdef VMS_TEXT_CONV
  392.      static ZCONST char Far VmsTextConv[] = "VMS_TEXT_CONV";
  393. #  endif
  394. #  ifdef VMSCLI
  395.      static ZCONST char Far VmsCLI[] = "VMSCLI";
  396. #  endif
  397. #  ifdef VMSWILD
  398.      static ZCONST char Far VmsWild[] = "VMSWILD";
  399. #  endif
  400. #  if CRYPT
  401. #    ifdef PASSWD_FROM_STDIN
  402.        static ZCONST char Far PasswdStdin[] = "PASSWD_FROM_STDIN";
  403. #    endif
  404.      static ZCONST char Far Decryption[] =
  405.        "\t[decryption, version %d.%d%s of %s]\n";
  406.      static ZCONST char Far CryptDate[] = CR_VERSION_DATE;
  407. #  endif
  408. #  ifndef __RSXNT__
  409. #    ifdef __EMX__
  410.        static ZCONST char Far EnvEMX[] = "EMX";
  411.        static ZCONST char Far EnvEMXOPT[] = "EMXOPT";
  412. #    endif
  413. #    if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
  414.        static ZCONST char Far EnvGO32[] = "GO32";
  415.        static ZCONST char Far EnvGO32TMP[] = "GO32TMP";
  416. #    endif
  417. #  endif /* !__RSXNT__ */
  418.  
  419. #ifdef VMS
  420. /* UnzipUsageLine1[] is also used in vms/cmdline.c:  do not make it static */
  421.    ZCONST char Far UnzipUsageLine1[] = "\
  422. UnZip %d.%d%d%s of %s, by Info-ZIP.  For more details see: unzip -v.\n\n";
  423. #ifdef COPYRIGHT_CLEAN
  424.    static ZCONST char Far UnzipUsageLine1v[] = "\
  425. UnZip %d.%d%d%s of %s, by Info-ZIP.  Maintained by C. Spieler.  Send\n\
  426. bug reports to the authors at Zip-Bugs@lists.wku.edu; see README for details.\
  427. \n\n";
  428. #else
  429.    static ZCONST char Far UnzipUsageLine1v[] = "\
  430. UnZip %d.%d%d%s of %s, by Info-ZIP.  UnReduce (c) 1989 by S. H. Smith.\n\
  431. Send bug reports to authors at Zip-Bugs@lists.wku.edu; see README for details.\
  432. \n\n";
  433. #endif /* ?COPYRIGHT_CLEAN */
  434. #else /* !VMS */
  435. #ifdef COPYRIGHT_CLEAN
  436.    static ZCONST char Far UnzipUsageLine1[] = "\
  437. UnZip %d.%d%d%s of %s, by Info-ZIP.  Maintained by C. Spieler.  Send\n\
  438. bug reports to the authors at Zip-Bugs@lists.wku.edu; see README for details.\
  439. \n\n";
  440. #else
  441.    static ZCONST char Far UnzipUsageLine1[] = "\
  442. UnZip %d.%d%d%s of %s, by Info-ZIP.  UnReduce (c) 1989 by S. H. Smith.\n\
  443. Send bug reports to authors at Zip-Bugs@lists.wku.edu; see README for details.\
  444. \n\n";
  445. #endif /* ?COPYRIGHT_CLEAN */
  446. #define UnzipUsageLine1v        UnzipUsageLine1
  447. #endif /* ?VMS */
  448.  
  449. static ZCONST char Far UnzipUsageLine2v[] = "\
  450. Latest sources and executables are at ftp://ftp.cdrom.com/pub/infozip/ , as of\
  451. \nabove date; see http://www.cdrom.com/pub/infozip/UnZip.html for other sites.\
  452. \n\n";
  453.  
  454. #ifdef MACOS
  455. static ZCONST char Far UnzipUsageLine2[] = "\
  456. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-d exdir]\n \
  457.  Default action is to extract files in list, to exdir;\n\
  458.   file[.zip] may be a wildcard.  %s\n";
  459. #else /* !MACOS */
  460. #ifdef VM_CMS
  461. static ZCONST char Far UnzipUsageLine2[] = "\
  462. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d fm]\n \
  463.  Default action is to extract files in list, except those in xlist, to disk fm;\n\
  464.   file[.zip] may be a wildcard.  %s\n";
  465. #else /* !VM_CMS */
  466. static ZCONST char Far UnzipUsageLine2[] = "\
  467. Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
  468.  Default action is to extract files in list, except those in xlist, to exdir;\n\
  469.   file[.zip] may be a wildcard.  %s\n";
  470. #endif /* ?VM_CMS */
  471. #endif /* ?MACOS */
  472.  
  473. #ifdef NO_ZIPINFO
  474. #  define ZIPINFO_MODE_OPTION  ""
  475.    static ZCONST char Far ZipInfoMode[] =
  476.      "(ZipInfo mode is disabled in this version.)";
  477. #else
  478. #  define ZIPINFO_MODE_OPTION  "[-Z] "
  479. #  ifdef VMS
  480.      static ZCONST char Far ZipInfoMode[] =
  481.        "\"-Z\" => ZipInfo mode (`unzip \"-Z\"' for usage).";
  482. #  else
  483.      static ZCONST char Far ZipInfoMode[] =
  484.        "-Z => ZipInfo mode (\"unzip -Z\" for usage).";
  485. #  endif
  486. #endif /* ?NO_ZIPINFO */
  487.  
  488. #ifdef VMS
  489.    static ZCONST char Far VMSusageLine2b[] = "\
  490. => define foreign command symbol in LOGIN.COM:  $ unzip :== $dev:[dir]unzip.exe\
  491. \n";
  492. #endif
  493.  
  494. #ifdef MACOS
  495. static ZCONST char Far UnzipUsageLine3[] = "\n\
  496.   -d  extract files into exdir               -l  list files (short format)\n\
  497.   -f  freshen existing files, create none    -t  test compressed archive data\n\
  498.   -u  update files, create if necessary      -z  display archive comment\n\
  499. %s\n";
  500. #else /* !MACOS */
  501. #ifdef VM_CMS
  502. static ZCONST char Far UnzipUsageLine3[] = "\n\
  503.   -p  extract files to pipe, no messages     -l  list files (short format)\n\
  504.   -f  freshen existing files, create none    -t  test compressed archive data\n\
  505.   -u  update files, create if necessary      -z  display archive comment\n\
  506.   -x  exclude files that follow (in xlist)   -d  extract files onto disk fm\n\
  507. %s\n";
  508. #else /* !VM_CMS */
  509. static ZCONST char Far UnzipUsageLine3[] = "\n\
  510.   -p  extract files to pipe, no messages     -l  list files (short format)\n\
  511.   -f  freshen existing files, create none    -t  test compressed archive data\n\
  512.   -u  update files, create if necessary      -z  display archive comment\n\
  513.   -x  exclude files that follow (in xlist)   -d  extract files into exdir\n\
  514. %s\n";
  515. #endif /* ?VM_CMS */
  516. #endif /* ?MACOS */
  517.  
  518. static ZCONST char Far UnzipUsageLine4[] = "\
  519. modifiers:                                   -q  quiet mode (-qq => quieter)\n\
  520.   -n  never overwrite existing files         -a  auto-convert any text files\n\
  521.   -o  overwrite files WITHOUT prompting      -aa treat ALL files as text\n \
  522.  -j  junk paths (do not make directories)   -v  be verbose/print version info\n\
  523.  %c-C%c match filenames case-insensitively    %c-L%c make (some) names \
  524. lowercase\n %-42s %c-V%c retain VMS version numbers\n%s";
  525.  
  526. static ZCONST char Far UnzipUsageLine5[] = "\
  527. Examples (see unzip.doc for more info):\n\
  528.   unzip data1 -x joe   => extract all files except joe from zipfile data1.zip\n\
  529. %s\
  530.   unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
  531. #endif /* ?SFX */
  532.  
  533.  
  534.  
  535.  
  536.  
  537. /*****************************/
  538. /*  main() / UzpMain() stub  */
  539. /*****************************/
  540.  
  541. int MAIN(argc, argv)   /* return PK-type error code (except under VMS) */
  542.     int argc;
  543.     char *argv[];
  544. {
  545.     int r;
  546.  
  547.     CONSTRUCTGLOBALS();
  548.     r = unzip(__G__ argc, argv);
  549.     DESTROYGLOBALS()
  550.     RETURN(r);
  551. }
  552.  
  553.  
  554.  
  555.  
  556. /*******************************/
  557. /*  Primary UnZip entry point  */
  558. /*******************************/
  559.  
  560. int unzip(__G__ argc, argv)
  561.     __GDEF
  562.     int argc;
  563.     char *argv[];
  564. {
  565. #ifndef NO_ZIPINFO
  566.     char *p;
  567. #endif
  568. #ifdef DOS_FLX_H68_OS2_W32
  569.     int i;
  570. #endif
  571.     int retcode, error=FALSE;
  572.  
  573. #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
  574.     extern void DebugMalloc(void);
  575.  
  576.     atexit(DebugMalloc);
  577. #endif
  578.  
  579. #ifdef MALLOC_WORK
  580.     G.area.Slide =(uch *)calloc(8193, sizeof(shrint)+sizeof(uch)+sizeof(uch));
  581.     G.area.shrink.Parent = (shrint *)G.area.Slide;
  582.     G.area.shrink.value = G.area.Slide + (sizeof(shrint)*(HSIZE+1));
  583.     G.area.shrink.Stack = G.area.Slide +
  584.                            (sizeof(shrint) + sizeof(uch))*(HSIZE+1);
  585. #endif
  586.  
  587. /*---------------------------------------------------------------------------
  588.     Macintosh initialization code.
  589.   ---------------------------------------------------------------------------*/
  590.  
  591. #ifdef MACOS
  592.     {
  593.         int a;
  594.  
  595.         for (a = 0;  a < 4;  ++a)
  596.             G.rghCursor[a] = GetCursor(a+128);
  597.         G.giCursor = 0;
  598.     }
  599. #endif
  600.  
  601. /*---------------------------------------------------------------------------
  602.     Human68K initialization code.
  603.   ---------------------------------------------------------------------------*/
  604.  
  605. #ifdef __human68k__
  606.     InitTwentyOne();
  607. #endif
  608.  
  609. /*---------------------------------------------------------------------------
  610.     Acorn RISC OS initialization code.
  611.   ---------------------------------------------------------------------------*/
  612.  
  613. #ifdef RISCOS
  614.     set_prefix();
  615. #endif
  616.  
  617. /*---------------------------------------------------------------------------
  618.     Set signal handler for restoring echo, warn of zipfile corruption, etc.
  619.   ---------------------------------------------------------------------------*/
  620.  
  621. #ifdef SIGINT
  622.     signal(SIGINT, handler);
  623. #endif
  624. #ifdef SIGTERM                 /* some systems really have no SIGTERM */
  625.     signal(SIGTERM, handler);
  626. #endif
  627. #ifdef SIGBUS
  628.     signal(SIGBUS, handler);
  629. #endif
  630. #ifdef SIGSEGV
  631.     signal(SIGSEGV, handler);
  632. #endif
  633.  
  634. #if (defined(WIN32) && defined(__RSXNT__))
  635.     for (i = 0 ; i < argc; i++) {
  636.        _ISO_INTERN(argv[i]);
  637.     }
  638. #endif
  639.  
  640. /*---------------------------------------------------------------------------
  641.     First figure out if we're running in UnZip mode or ZipInfo mode, and put
  642.     the appropriate environment-variable options into the queue.  Then rip
  643.     through any command-line options lurking about...
  644.   ---------------------------------------------------------------------------*/
  645.  
  646. #ifdef SFX
  647.     G.argv0 = argv[0];
  648. #if (defined(OS2) || defined(WIN32))
  649.     G.zipfn = GetLoadPath(__G);/* non-MSC NT puts path into G.filename[] */
  650. #else
  651.     G.zipfn = G.argv0;
  652. #endif
  653.  
  654. #ifdef VMSCLI
  655.     {
  656.         ulg status = vms_unzip_cmdline(&argc, &argv);
  657.         if (!(status & 1))
  658.             return status;
  659.     }
  660. #endif /* VMSCLI */
  661.  
  662.     uO.zipinfo_mode = FALSE;
  663.     error = uz_opts(__G__ &argc, &argv);   /* UnZipSFX call only */
  664.  
  665. #else /* !SFX */
  666.  
  667. #ifdef RISCOS
  668.     /* get the extensions to swap from environment */
  669.     getRISCOSexts(ENV_UNZIPEXTS);
  670. #endif
  671.  
  672. #ifdef MSDOS
  673.     /* extract MKS extended argument list from environment (before envargs!) */
  674.     mksargs(&argc, &argv);
  675. #endif
  676.  
  677. #ifdef VMSCLI
  678.     {
  679.         ulg status = vms_unzip_cmdline(&argc, &argv);
  680.         if (!(status & 1))
  681.             return status;
  682.     }
  683. #endif /* VMSCLI */
  684.  
  685.     G.noargs = (argc == 1);   /* no options, no zipfile, no anything */
  686.  
  687. #ifndef NO_ZIPINFO
  688.     for (p = argv[0] + strlen(argv[0]); p >= argv[0]; --p) {
  689.         if (*p == DIR_END
  690. #ifdef DIR_END2
  691.             || *p == DIR_END2
  692. #endif
  693.            )
  694.             break;
  695.     }
  696.     ++p;
  697.  
  698.     if (STRNICMP(p, LoadFarStringSmall(Zipnfo), 7) == 0 ||
  699.         STRNICMP(p, "ii", 2) == 0 ||
  700.         (argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
  701.     {
  702.         uO.zipinfo_mode = TRUE;
  703.         envargs(__G__ &argc, &argv, LoadFarStringSmall(EnvZipInfo),
  704.           LoadFarStringSmall2(EnvZipInfo2));
  705.         error = zi_opts(__G__ &argc, &argv);
  706.     } else
  707. #endif /* NO_ZIPINFO */
  708.     {
  709.         uO.zipinfo_mode = FALSE;
  710.         envargs(__G__ &argc, &argv, LoadFarStringSmall(EnvUnZip),
  711.           LoadFarStringSmall2(EnvUnZip2));
  712.         error = uz_opts(__G__ &argc, &argv);
  713.     }
  714.  
  715. #endif /* ?SFX */
  716.  
  717.     if ((argc < 0) || error)
  718.         return error;
  719.  
  720. /*---------------------------------------------------------------------------
  721.     Now get the zipfile name from the command line and then process any re-
  722.     maining options and file specifications.
  723.   ---------------------------------------------------------------------------*/
  724.  
  725. #ifdef DOS_FLX_H68_OS2_W32
  726.     /* convert MSDOS-style directory separators to Unix-style ones for
  727.      * user's convenience (include zipfile name itself)
  728.      */
  729. #ifdef SFX
  730.     for (G.pfnames = argv, i = argc;  i > 0;  --i) {
  731. #else
  732.     /* argc does not include the zipfile specification */
  733.     for (G.pfnames = argv, i = argc+1;  i > 0;  --i) {
  734. #endif
  735.         char *q;
  736.  
  737.         for (q = *G.pfnames;  *q;  ++q)
  738.             if (*q == '\\')
  739.                 *q = '/';
  740.         ++G.pfnames;
  741.     }
  742. #endif /* DOS_FLX_H68_OS2_W32 */
  743.  
  744. #ifndef SFX
  745.     G.wildzipfn = *argv++;
  746. #endif
  747.  
  748. #if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
  749.  
  750.     G.filespecs = argc;
  751.     G.xfilespecs = 0;
  752.  
  753.     if (argc > 0) {
  754.         char **pp = argv-1;
  755.  
  756.         G.pfnames = argv;
  757.         while (*++pp)
  758.             if (strcmp(*pp, "-x") == 0) {
  759.                 if (pp > argv) {
  760.                     *pp = 0;              /* terminate G.pfnames */
  761.                     G.filespecs = pp - G.pfnames;
  762.                 } else {
  763.                     G.pfnames = (char **)fnames;  /* defaults */
  764.                     G.filespecs = 0;
  765.                 }
  766.                 G.pxnames = pp + 1;      /* excluded-names ptr: _after_ -x */
  767.                 G.xfilespecs = argc - G.filespecs - 1;
  768.                 break;                    /* skip rest of args */
  769.             }
  770.         G.process_all_files = FALSE;
  771.     } else
  772.         G.process_all_files = TRUE;      /* for speed */
  773.  
  774. #else /* !SFX || SFX_EXDIR */             /* check for -x or -d */
  775.  
  776.     G.filespecs = argc;
  777.     G.xfilespecs = 0;
  778.  
  779.     if (argc > 0) {
  780.         int in_files=FALSE, in_xfiles=FALSE;
  781.         char **pp = argv-1;
  782.  
  783.         G.process_all_files = FALSE;
  784.         G.pfnames = argv;
  785.         while (*++pp) {
  786.             Trace((stderr, "pp - argv = %d\n", pp-argv));
  787. #ifdef CMS_MVS
  788.             if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) {
  789. #else
  790.             if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) {
  791. #endif
  792.                 int firstarg = (pp == argv);
  793.  
  794.                 uO.exdir = (*pp) + 2;
  795.                 if (in_files) {      /* ... zipfile ... -d exdir ... */
  796.                     *pp = (char *)NULL;         /* terminate G.pfnames */
  797.                     G.filespecs = pp - G.pfnames;
  798.                     in_files = FALSE;
  799.                 } else if (in_xfiles) {
  800.                     *pp = (char *)NULL;         /* terminate G.pxnames */
  801.                     G.xfilespecs = pp - G.pxnames;
  802.                     /* "... -x xlist -d exdir":  nothing left */
  803.                 }
  804.                 /* first check for "-dexdir", then for "-d exdir" */
  805.                 if (*uO.exdir == '\0') {
  806.                     if (*++pp)
  807.                         uO.exdir = *pp;
  808.                     else {
  809.                         Info(slide, 0x401, ((char *)slide,
  810.                           LoadFarString(MustGiveExdir)));
  811.                         return(PK_PARAM);  /* don't extract here by accident */
  812.                     }
  813.                 }
  814.                 if (firstarg) { /* ... zipfile -d exdir ... */
  815.                     if (pp[1]) {
  816.                         G.pfnames = pp + 1;  /* argv+2 */
  817.                         G.filespecs = argc - (G.pfnames-argv);  /* for now... */
  818.                     } else {
  819.                         G.process_all_files = TRUE;
  820.                         G.pfnames = (char **)fnames;  /* GRR: necessary? */
  821.                         G.filespecs = 0;     /* GRR: necessary? */
  822.                         break;
  823.                     }
  824.                 }
  825.             } else if (!in_xfiles) {
  826.                 if (strcmp(*pp, "-x") == 0) {
  827.                     in_xfiles = TRUE;
  828.                     if (pp == G.pfnames) {
  829.                         G.pfnames = (char **)fnames;  /* defaults */
  830.                         G.filespecs = 0;
  831.                     } else if (in_files) {
  832.                         *pp = 0;                   /* terminate G.pfnames */
  833.                         G.filespecs = pp - G.pfnames;  /* adjust count */
  834.                         in_files = FALSE;
  835.                     }
  836.                     G.pxnames = pp + 1; /* excluded-names ptr starts after -x */
  837.                     G.xfilespecs = argc - (G.pxnames-argv);  /* anything left */
  838.                 } else
  839.                     in_files = TRUE;
  840.             }
  841.         }
  842.     } else
  843.         G.process_all_files = TRUE;      /* for speed */
  844.  
  845.     if (uO.exdir != (char *)NULL && !G.extract_flag)    /* -d ignored */
  846.         Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting)));
  847. #endif /* ?(SFX && !SFX_EXDIR) */
  848.  
  849. /*---------------------------------------------------------------------------
  850.     Okey dokey, we have everything we need to get started.  Let's roll.
  851.   ---------------------------------------------------------------------------*/
  852.  
  853.     retcode = process_zipfiles(__G);
  854.     return(retcode);
  855.  
  856. } /* end main()/unzip() */
  857.  
  858.  
  859.  
  860.  
  861.  
  862. /**********************/
  863. /* Function uz_opts() */
  864. /**********************/
  865.  
  866. int uz_opts(__G__ pargc, pargv)
  867.     __GDEF
  868.     int *pargc;
  869.     char ***pargv;
  870. {
  871.     char **argv, *s;
  872.     int argc, c, error=FALSE, negative=0;
  873.  
  874.  
  875.     argc = *pargc;
  876.     argv = *pargv;
  877.  
  878.     while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
  879.         s = *argv + 1;
  880.         while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
  881. #ifdef CMS_MVS
  882.             switch (tolower(c))
  883. #else
  884.             switch (c)
  885. #endif
  886.             {
  887.                 case ('-'):
  888.                     ++negative;
  889.                     break;
  890.                 case ('a'):
  891.                     if (negative) {
  892.                         uO.aflag = MAX(uO.aflag-negative,0);
  893.                         negative = 0;
  894.                     } else
  895.                         ++uO.aflag;
  896.                     break;
  897. #if (defined(DLL) && defined(API_DOC))
  898.                 case ('A'):    /* extended help for API */
  899.                     APIhelp(__G__ argc, argv);
  900.                     *pargc = -1;  /* signal to exit successfully */
  901.                     return 0;
  902. #endif
  903.                 case ('b'):
  904.                     if (negative) {
  905. #ifdef VMS
  906.                         uO.bflag = MAX(uO.bflag-negative,0);
  907. #endif
  908.                         negative = 0;   /* do nothing:  "-b" is default */
  909.                     } else {
  910. #ifdef VMS
  911.                         if (uO.aflag == 0)
  912.                            ++uO.bflag;
  913. #endif
  914.                         uO.aflag = 0;
  915.                     }
  916.                     break;
  917. #ifdef UNIXBACKUP
  918.                 case ('B'): /* -B: back up existing files */
  919.                     if (negative)
  920.                         uO.B_flag = FALSE, negative = 0;
  921.                     else
  922.                         uO.B_flag = TRUE;
  923.                     break;
  924. #endif
  925.                 case ('c'):
  926.                     if (negative) {
  927.                         uO.cflag = FALSE, negative = 0;
  928. #ifdef NATIVE
  929.                         uO.aflag = 0;
  930. #endif
  931.                     } else {
  932.                         uO.cflag = TRUE;
  933. #ifdef NATIVE
  934.                         uO.aflag = 2;   /* so you can read it on the screen */
  935. #endif
  936. #ifdef DLL
  937.                         if (G.redirect_text)
  938.                             G.redirect_data = 2;
  939. #endif
  940.                     }
  941.                     break;
  942. #ifndef CMS_MVS
  943.                 case ('C'):    /* -C:  match filenames case-insensitively */
  944.                     if (negative)
  945.                         uO.C_flag = FALSE, negative = 0;
  946.                     else
  947.                         uO.C_flag = TRUE;
  948.                     break;
  949. #endif /* !CMS_MVS */
  950. #if (!defined(SFX) || defined(SFX_EXDIR))
  951.                 case ('d'):
  952.                     if (negative) {   /* negative not allowed with -d exdir */
  953.                         Info(slide, 0x401, ((char *)slide,
  954.                           LoadFarString(MustGiveExdir)));
  955.                         return(PK_PARAM);  /* don't extract here by accident */
  956.                     }
  957.                     if (uO.exdir != (char *)NULL) {
  958.                         Info(slide, 0x401, ((char *)slide,
  959.                           LoadFarString(OnlyOneExdir)));
  960.                         return(PK_PARAM);    /* GRR:  stupid restriction? */
  961.                     } else {
  962.                         /* first check for "-dexdir", then for "-d exdir" */
  963.                         uO.exdir = s;
  964.                         if (*uO.exdir == '\0') {
  965.                             if (argc > 1) {
  966.                                 --argc;
  967.                                 uO.exdir = *++argv;
  968.                                 if (*uO.exdir == '-') {
  969.                                     Info(slide, 0x401, ((char *)slide,
  970.                                       LoadFarString(MustGiveExdir)));
  971.                                     return(PK_PARAM);
  972.                                 }
  973.                                 /* else uO.exdir points at extraction dir */
  974.                             } else {
  975.                                 Info(slide, 0x401, ((char *)slide,
  976.                                   LoadFarString(MustGiveExdir)));
  977.                                 return(PK_PARAM);
  978.                             }
  979.                         }
  980.                         /* uO.exdir now points at extraction dir (-dexdir or
  981.                          *  -d exdir); point s at end of exdir to avoid mis-
  982.                          *  interpretation of exdir characters as more options
  983.                          */
  984.                         if (*s != 0)
  985.                             while (*++s != 0)
  986.                                 ;
  987.                     }
  988.                     break;
  989. #endif /* !SFX || SFX_EXDIR */
  990.                 case ('e'):    /* just ignore -e, -x options (extract) */
  991.                     break;
  992. #ifdef MACOS
  993.                 case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
  994.                     if( negative ) {
  995.                         uO.E_flag = FALSE, negative = 0;
  996.                     } else {
  997.                         uO.E_flag = TRUE;
  998.                     }
  999.                     break;
  1000. #endif /* MACOS */
  1001.                 case ('f'):    /* "freshen" (extract only newer files) */
  1002.                     if (negative)
  1003.                         uO.fflag = uO.uflag = FALSE, negative = 0;
  1004.                     else
  1005.                         uO.fflag = uO.uflag = TRUE;
  1006.                     break;
  1007. #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
  1008.                 case ('F'):    /* Acorn filetype & NFS extension handling */
  1009.                     if (negative)
  1010.                         uO.acorn_nfs_ext = FALSE, negative = 0;
  1011.                     else
  1012.                         uO.acorn_nfs_ext = TRUE;
  1013.                     break;
  1014. #endif /* RISCOS || ACORN_FTYPE_NFS */
  1015.                 case ('h'):    /* just print help message and quit */
  1016.                     *pargc = -1;
  1017.                     return USAGE(PK_OK);
  1018. #ifdef MACOS
  1019.                 case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
  1020.                     if( negative ) {
  1021.                         uO.i_flag = FALSE, negative = 0;
  1022.                     } else {
  1023.                         uO.i_flag = TRUE;
  1024.                     }
  1025.                     break;
  1026. #endif  /* MACOS */
  1027.                 case ('j'):    /* junk pathnames/directory structure */
  1028.                     if (negative)
  1029.                         uO.jflag = FALSE, negative = 0;
  1030.                     else
  1031.                         uO.jflag = TRUE;
  1032.                     break;
  1033. #if (defined(__BEOS__) || defined(MACOS))
  1034.                 case ('J'):    /* Junk BeOS or MacOS file attributes */
  1035.                     if( negative ) {
  1036.                         uO.J_flag = FALSE, negative = 0;
  1037.                     } else {
  1038.                         uO.J_flag = TRUE;
  1039.                     }
  1040.                     break;
  1041. #endif /* __BEOS__ || MACOS */
  1042. #ifndef SFX
  1043.                 case ('l'):
  1044.                     if (negative) {
  1045.                         uO.vflag = MAX(uO.vflag-negative,0);
  1046.                         negative = 0;
  1047.                     } else
  1048.                         ++uO.vflag;
  1049.                     break;
  1050. #endif /* !SFX */
  1051. #ifndef CMS_MVS
  1052.                 case ('L'):    /* convert (some) filenames to lowercase */
  1053.                     if (negative)
  1054.                         uO.L_flag = FALSE, negative = 0;
  1055.                     else
  1056.                         uO.L_flag = TRUE;
  1057.                     break;
  1058. #endif /* !CMS_MVS */
  1059. #ifdef MORE
  1060. #ifdef CMS_MVS
  1061.                 case ('m'):
  1062. #endif
  1063.                 case ('M'):    /* send all screen output through "more" fn. */
  1064. /* GRR:  eventually check for numerical argument => height */
  1065.                     if (negative)
  1066.                         G.M_flag = FALSE, negative = 0;
  1067.                     else
  1068.                         G.M_flag = TRUE;
  1069.                     break;
  1070. #endif /* MORE */
  1071.                 case ('n'):    /* don't overwrite any files */
  1072.                     if (negative)
  1073.                         uO.overwrite_none = FALSE, negative = 0;
  1074.                     else
  1075.                         uO.overwrite_none = TRUE;
  1076.                     break;
  1077. #ifdef AMIGA
  1078.                 case ('N'):    /* restore comments as filenotes */
  1079.                     if (negative)
  1080.                         uO.N_flag = FALSE, negative = 0;
  1081.                     else
  1082.                         uO.N_flag = TRUE;
  1083.                     break;
  1084. #endif /* AMIGA */
  1085.                 case ('o'):    /* OK to overwrite files without prompting */
  1086.                     if (negative) {
  1087.                         uO.overwrite_all = MAX(uO.overwrite_all-negative,0);
  1088.                         negative = 0;
  1089.                     } else
  1090.                         ++uO.overwrite_all;
  1091.                     break;
  1092.                 case ('p'):    /* pipes:  extract to stdout, no messages */
  1093.                     if (negative) {
  1094.                         uO.cflag = FALSE;
  1095.                         uO.qflag = MAX(uO.qflag-999,0);
  1096.                         negative = 0;
  1097.                     } else {
  1098.                         uO.cflag = TRUE;
  1099.                         uO.qflag += 999;
  1100.                     }
  1101.                     break;
  1102. #if CRYPT
  1103.                 /* GRR:  yes, this is highly insecure, but dozens of people
  1104.                  * have pestered us for this, so here we go... */
  1105.                 case ('P'):
  1106.                     if (negative) {   /* negative not allowed with -P passwd */
  1107.                         Info(slide, 0x401, ((char *)slide,
  1108.                           LoadFarString(MustGivePasswd)));
  1109.                         return(PK_PARAM);  /* don't extract here by accident */
  1110.                     }
  1111.                     if (uO.pwdarg != (char *)NULL) {
  1112. /*
  1113.                         GRR:  eventually support multiple passwords?
  1114.                         Info(slide, 0x401, ((char *)slide,
  1115.                           LoadFarString(OnlyOnePasswd)));
  1116.                         return(PK_PARAM);
  1117.  */
  1118.                     } else {
  1119.                         /* first check for "-Ppasswd", then for "-P passwd" */
  1120.                         uO.pwdarg = s;
  1121.                         if (*uO.pwdarg == '\0') {
  1122.                             if (argc > 1) {
  1123.                                 --argc;
  1124.                                 uO.pwdarg = *++argv;
  1125.                                 if (*uO.pwdarg == '-') {
  1126.                                     Info(slide, 0x401, ((char *)slide,
  1127.                                       LoadFarString(MustGivePasswd)));
  1128.                                     return(PK_PARAM);
  1129.                                 }
  1130.                                 /* else pwdarg points at decryption password */
  1131.                             } else {
  1132.                                 Info(slide, 0x401, ((char *)slide,
  1133.                                   LoadFarString(MustGivePasswd)));
  1134.                                 return(PK_PARAM);
  1135.                             }
  1136.                         }
  1137.                         /* pwdarg now points at decryption password (-Ppasswd or
  1138.                          *  -P passwd); point s at end of passwd to avoid mis-
  1139.                          *  interpretation of passwd characters as more options
  1140.                          */
  1141.                         if (*s != 0)
  1142.                             while (*++s != 0)
  1143.                                 ;
  1144.                     }
  1145.                     break;
  1146. #endif /* CRYPT */
  1147.                 case ('q'):    /* quiet:  fewer comments/messages */
  1148.                     if (negative) {
  1149.                         uO.qflag = MAX(uO.qflag-negative,0);
  1150.                         negative = 0;
  1151.                     } else
  1152.                         ++uO.qflag;
  1153.                     break;
  1154. #ifdef QDOS
  1155.                 case ('Q'):   /* QDOS flags */
  1156.                     qlflag ^= strtol(s, &s, 10);
  1157.                     break;    /* we XOR this as we can config qlflags */
  1158. #endif
  1159. #ifdef DOS_FLX_OS2_W32
  1160.                 case ('s'):    /* spaces in filenames:  allow by default */
  1161.                     if (negative)
  1162.                         uO.sflag = FALSE, negative = 0;
  1163.                     else
  1164.                         uO.sflag = TRUE;
  1165.                     break;
  1166. #endif /* DOS_FLX_OS2_W32 */
  1167.                 case ('t'):
  1168.                     if (negative)
  1169.                         uO.tflag = FALSE, negative = 0;
  1170.                     else
  1171.                         uO.tflag = TRUE;
  1172.                     break;
  1173. #ifdef TIMESTAMP
  1174.                 case ('T'):
  1175.                     if (negative)
  1176.                         uO.T_flag = FALSE, negative = 0;
  1177.                     else
  1178.                         uO.T_flag = TRUE;
  1179.                     break;
  1180. #endif
  1181.                 case ('u'):    /* update (extract only new and newer files) */
  1182.                     if (negative)
  1183.                         uO.uflag = FALSE, negative = 0;
  1184.                     else
  1185.                         uO.uflag = TRUE;
  1186.                     break;
  1187. #ifndef CMS_MVS
  1188.                 case ('U'):    /* obsolete; to be removed in version 6.0 */
  1189.                     if (negative)
  1190.                         uO.L_flag = TRUE, negative = 0;
  1191.                     else
  1192.                         uO.L_flag = FALSE;
  1193.                     break;
  1194. #endif /* !CMS_MVS */
  1195. #ifndef SFX
  1196.                 case ('v'):    /* verbose */
  1197.                     if (negative) {
  1198.                         uO.vflag = MAX(uO.vflag-negative,0);
  1199.                         negative = 0;
  1200.                     } else if (uO.vflag)
  1201.                         ++uO.vflag;
  1202.                     else
  1203.                         uO.vflag = 2;
  1204.                     break;
  1205. #endif /* !SFX */
  1206. #ifndef CMS_MVS
  1207.                 case ('V'):    /* Version (retain VMS/DEC-20 file versions) */
  1208.                     if (negative)
  1209.                         uO.V_flag = FALSE, negative = 0;
  1210.                     else
  1211.                         uO.V_flag = TRUE;
  1212.                     break;
  1213. #endif /* !CMS_MVS */
  1214.                 case ('x'):    /* extract:  default */
  1215. #ifdef SFX
  1216.                     /* when 'x' is the only option in this argument, and the
  1217.                      * next arg is not an option, assume this initiates an
  1218.                      * exclusion list (-x xlist):  terminate option-scanning
  1219.                      * and leave uz_opts with argv still pointing to "-x";
  1220.                      * the xlist is processed later
  1221.                      */
  1222.                     if (s - argv[0] == 2 && *s == '\0' &&
  1223.                         argc > 1 && argv[1][0] != '-') {
  1224.                         /* break out of nested loops without "++argv;--argc" */
  1225.                         goto opts_done;
  1226.                     }
  1227. #endif /* SFX */
  1228.                     break;
  1229. #if (defined(RESTORE_UIDGID) || defined(OS2_W32))
  1230.                 case ('X'):   /* restore owner/protection info (need privs?) */
  1231.                     if (negative) {
  1232.                         uO.X_flag = MAX(uO.X_flag-negative,0);
  1233.                         negative = 0;
  1234.                     } else
  1235.                         ++uO.X_flag;
  1236.                     break;
  1237. #endif /* RESTORE_UIDGID || OS2_W32 */
  1238.                 case ('z'):    /* display only the archive comment */
  1239.                     if (negative) {
  1240.                         uO.zflag = MAX(uO.zflag-negative,0);
  1241.                         negative = 0;
  1242.                     } else
  1243.                         ++uO.zflag;
  1244.                     break;
  1245. #ifndef SFX
  1246.                 case ('Z'):    /* should have been first option (ZipInfo) */
  1247.                     Info(slide, 0x401, ((char *)slide, LoadFarString(Zfirst)));
  1248.                     error = TRUE;
  1249.                     break;
  1250. #endif /* !SFX */
  1251. #ifdef DOS_OS2_W32
  1252.                 case ('$'):
  1253.                     if (negative) {
  1254.                         uO.volflag = MAX(uO.volflag-negative,0);
  1255.                         negative = 0;
  1256.                     } else
  1257.                         ++uO.volflag;
  1258.                     break;
  1259. #endif /* DOS_OS2_W32 */
  1260.                 default:
  1261.                     error = TRUE;
  1262.                     break;
  1263.  
  1264.             } /* end switch */
  1265.         } /* end while (not end of argument string) */
  1266.     } /* end while (not done with switches) */
  1267.  
  1268. /*---------------------------------------------------------------------------
  1269.     Check for nonsensical combinations of options.
  1270.   ---------------------------------------------------------------------------*/
  1271.  
  1272. #ifdef SFX
  1273. opts_done:  /* yes, very ugly...but only used by UnZipSFX with -x xlist */
  1274. #endif
  1275.  
  1276.     if ((uO.cflag && uO.tflag) || (uO.cflag && uO.uflag) ||
  1277.         (uO.tflag && uO.uflag) || (uO.fflag && uO.overwrite_none))
  1278.     {
  1279.         Info(slide, 0x401, ((char *)slide, LoadFarString(InvalidOptionsMsg)));
  1280.         error = TRUE;
  1281.     }
  1282.     if (uO.aflag > 2)
  1283.         uO.aflag = 2;
  1284. #ifdef VMS
  1285.     if (uO.bflag > 2)
  1286.         uO.bflag = 2;
  1287. #endif
  1288.     if (uO.overwrite_all && uO.overwrite_none) {
  1289.         Info(slide, 0x401, ((char *)slide, LoadFarString(IgnoreOOptionMsg)));
  1290.         uO.overwrite_all = FALSE;
  1291.     }
  1292. #ifdef MORE
  1293.     if (G.M_flag && !isatty(1))  /* stdout redirected: "more" func. useless */
  1294.         G.M_flag = 0;
  1295. #endif
  1296.  
  1297. #ifdef SFX
  1298.     if (error)
  1299. #else
  1300.     if ((argc-- == 0) || error)
  1301. #endif
  1302.     {
  1303.         *pargc = argc;
  1304.         *pargv = argv;
  1305. #ifndef SFX
  1306.         if (uO.vflag >= 2 && argc == -1) {              /* "unzip -v" */
  1307.             show_version_info(__G);
  1308.             return PK_OK;
  1309.         }
  1310.         if (!G.noargs && !error)
  1311.             error = PK_PARAM;   /* had options (not -h or -v) but no zipfile */
  1312. #endif /* !SFX */
  1313.         return USAGE(error);
  1314.     }
  1315.  
  1316. #ifdef SFX
  1317.     /* print our banner unless we're being fairly quiet */
  1318.     if (uO.qflag < 2)
  1319.         Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
  1320.           UZ_MAJORVER, UZ_MINORVER, PATCHLEVEL, BETALEVEL,
  1321.           LoadFarStringSmall(VersionDate)));
  1322. #ifdef BETA
  1323.     /* always print the beta warning:  no unauthorized distribution!! */
  1324.     Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
  1325.       "SFX"));
  1326. #endif
  1327. #endif /* SFX */
  1328.  
  1329.     if (uO.cflag || uO.tflag || uO.vflag || uO.zflag
  1330. #ifdef TIMESTAMP
  1331.                                                      || uO.T_flag
  1332. #endif
  1333.                                                                  )
  1334.         G.extract_flag = FALSE;
  1335.     else
  1336.         G.extract_flag = TRUE;
  1337.  
  1338.     *pargc = argc;
  1339.     *pargv = argv;
  1340.     return PK_OK;
  1341.  
  1342. } /* end function uz_opts() */
  1343.  
  1344.  
  1345.  
  1346.  
  1347. /********************/
  1348. /* Function usage() */
  1349. /********************/
  1350.  
  1351. #ifdef SFX
  1352. #  ifdef VMS
  1353. #    define LOCAL "X.  Quote uppercase options"
  1354. #  endif
  1355. #  ifdef UNIX
  1356. #    define LOCAL "X"
  1357. #  endif
  1358. #  ifdef DOS_OS2_W32
  1359. #    define LOCAL "s$"
  1360. #  endif
  1361. #  ifdef FLEXOS
  1362. #    define LOCAL "s"
  1363. #  endif
  1364. #  ifdef AMIGA
  1365. #    define LOCAL "N"
  1366. #  endif
  1367.    /* Default for all other systems: */
  1368. #  ifndef LOCAL
  1369. #    define LOCAL ""
  1370. #  endif
  1371.  
  1372. #  ifdef MORE
  1373. #    define SFXOPT1 "M"
  1374. #  else
  1375. #    define SFXOPT1 ""
  1376. #  endif
  1377.  
  1378. int usage(__G__ error)   /* return PK-type error code */
  1379.     __GDEF
  1380.     int error;
  1381. {
  1382.     Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
  1383.       UZ_MAJORVER, UZ_MINORVER, PATCHLEVEL, BETALEVEL,
  1384.       LoadFarStringSmall(VersionDate)));
  1385.     Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXOpts),
  1386.       SFXOPT1, LOCAL));
  1387. #ifdef BETA
  1388.     Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
  1389.       "SFX"));
  1390. #endif
  1391.  
  1392.     if (error)
  1393.         return PK_PARAM;
  1394.     else
  1395.         return PK_COOL;     /* just wanted usage screen: no error */
  1396.  
  1397. } /* end function usage() */
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403. #else /* !SFX */
  1404. #  ifdef VMS
  1405. #    define QUOT '\"'
  1406. #    define QUOTS "\""
  1407. #  else
  1408. #    define QUOT ' '
  1409. #    define QUOTS ""
  1410. #  endif
  1411.  
  1412. int usage(__G__ error)   /* return PK-type error code */
  1413.     __GDEF
  1414.     int error;
  1415. {
  1416.     int flag = (error? 1 : 0);
  1417.  
  1418.  
  1419. /*---------------------------------------------------------------------------
  1420.     Print either ZipInfo usage or UnZip usage, depending on incantation.
  1421.     (Strings must be no longer than 512 bytes for Turbo C, apparently.)
  1422.   ---------------------------------------------------------------------------*/
  1423.  
  1424.     if (uO.zipinfo_mode) {
  1425.  
  1426. #ifndef NO_ZIPINFO
  1427.  
  1428.         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine1),
  1429.           ZI_MAJORVER, ZI_MINORVER, PATCHLEVEL, BETALEVEL,
  1430.           LoadFarStringSmall(VersionDate),
  1431.           LoadFarStringSmall2(ZipInfoExample), QUOTS,QUOTS));
  1432.         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine2)));
  1433.         Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
  1434.           QUOT,QUOT, QUOT,QUOT, LoadFarStringSmall(ZipInfoUsageLine4)));
  1435. #ifdef VMS
  1436.         Info(slide, flag, ((char *)slide, "\nRemember that non-lowercase\
  1437.  filespecs must be quoted in VMS (e.g., \"Makefile\").\n"));
  1438. #endif
  1439.  
  1440. #endif /* !NO_ZIPINFO */
  1441.  
  1442.     } else {   /* UnZip mode */
  1443.  
  1444.         Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine1),
  1445.           UZ_MAJORVER, UZ_MINORVER, PATCHLEVEL, BETALEVEL,
  1446.           LoadFarStringSmall(VersionDate)));
  1447. #ifdef BETA
  1448.         Info(slide, flag, ((char *)slide, LoadFarString(BetaVersion), "", ""));
  1449. #endif
  1450.  
  1451.         Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine2),
  1452.           ZIPINFO_MODE_OPTION, LoadFarStringSmall(ZipInfoMode)));
  1453. #ifdef VMS
  1454.         if (!error)  /* maybe no command-line tail found; show extra help */
  1455.             Info(slide, flag, ((char *)slide, LoadFarString(VMSusageLine2b)));
  1456. #endif
  1457.  
  1458.         Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine3),
  1459.           LoadFarStringSmall(local1)));
  1460.  
  1461.         Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine4),
  1462.           QUOT,QUOT, QUOT,QUOT, LoadFarStringSmall(local2), QUOT,QUOT,
  1463.           LoadFarStringSmall2(local3)));
  1464.  
  1465.         /* This is extra work for SMALL_MEM, but it will work since
  1466.          * LoadFarStringSmall2 uses the same buffer.  Remember, this
  1467.          * is a hack. */
  1468.         Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine5),
  1469.           LoadFarStringSmall(Example2), LoadFarStringSmall2(Example3),
  1470.           LoadFarStringSmall2(Example3)));
  1471.  
  1472.     } /* end if (uO.zipinfo_mode) */
  1473.  
  1474.     if (error)
  1475.         return PK_PARAM;
  1476.     else
  1477.         return PK_COOL;     /* just wanted usage screen: no error */
  1478.  
  1479. } /* end function usage() */
  1480.  
  1481. #endif /* ?SFX */
  1482.  
  1483.  
  1484.  
  1485.  
  1486. #ifndef SFX
  1487.  
  1488. /********************************/
  1489. /* Function show_version_info() */
  1490. /********************************/
  1491.  
  1492. static void show_version_info(__G)
  1493.     __GDEF
  1494. {
  1495.     if (uO.qflag > 3)                           /* "unzip -vqqqq" */
  1496.         Info(slide, 0, ((char *)slide, "%d\n",
  1497.           (UZ_MAJORVER*100 + UZ_MINORVER*10 + PATCHLEVEL)));
  1498.     else {
  1499.         char *envptr, *getenv();
  1500.         int numopts = 0;
  1501.  
  1502.         Info(slide, 0, ((char *)slide, LoadFarString(UnzipUsageLine1v),
  1503.           UZ_MAJORVER, UZ_MINORVER, PATCHLEVEL, BETALEVEL,
  1504.           LoadFarStringSmall(VersionDate)));
  1505.         Info(slide, 0, ((char *)slide,
  1506.           LoadFarString(UnzipUsageLine2v)));
  1507.         version(__G);
  1508.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptions)));
  1509. #ifdef ACORN_FTYPE_NFS
  1510.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1511.           LoadFarStringSmall(AcornFtypeNFS)));
  1512.         ++numopts;
  1513. #endif
  1514. #ifdef ASM_CRC
  1515.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1516.           LoadFarStringSmall(AsmCRC)));
  1517.         ++numopts;
  1518. #endif
  1519. #ifdef ASM_INFLATECODES
  1520.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1521.           LoadFarStringSmall(AsmInflateCodes)));
  1522.         ++numopts;
  1523. #endif
  1524. #ifdef CHECK_VERSIONS
  1525.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1526.           LoadFarStringSmall(Check_Versions)));
  1527.         ++numopts;
  1528. #endif
  1529. #ifdef COPYRIGHT_CLEAN
  1530.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1531.           LoadFarStringSmall(Copyright_Clean)));
  1532.         ++numopts;
  1533. #endif
  1534. #ifdef DEBUG
  1535.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1536.           LoadFarStringSmall(UDebug)));
  1537.         ++numopts;
  1538. #endif
  1539. #ifdef DEBUG_TIME
  1540.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1541.           LoadFarStringSmall(DebugTime)));
  1542.         ++numopts;
  1543. #endif
  1544. #ifdef DLL
  1545.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1546.           LoadFarStringSmall(Dll)));
  1547.         ++numopts;
  1548. #endif
  1549. #ifdef DOSWILD
  1550.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1551.           LoadFarStringSmall(DosWild)));
  1552.         ++numopts;
  1553. #endif
  1554. #ifdef LZW_CLEAN
  1555.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1556.           LoadFarStringSmall(LZW_Clean)));
  1557.         ++numopts;
  1558. #endif
  1559. #ifndef MORE
  1560.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1561.           LoadFarStringSmall(No_More)));
  1562.         ++numopts;
  1563. #endif
  1564. #ifdef NO_ZIPINFO
  1565.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1566.           LoadFarStringSmall(No_ZipInfo)));
  1567.         ++numopts;
  1568. #endif
  1569. #ifdef NTSD_EAS
  1570.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1571.           LoadFarStringSmall(NTSDExtAttrib)));
  1572.         ++numopts;
  1573. #endif
  1574. #ifdef OS2_EAS
  1575.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1576.           LoadFarStringSmall(OS2ExtAttrib)));
  1577.         ++numopts;
  1578. #endif
  1579. #ifdef QLZIP
  1580.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1581.           LoadFarStringSmall(SMSExFldOnUnix)));
  1582.         ++numopts;
  1583. #endif
  1584. #ifdef REENTRANT
  1585.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1586.           LoadFarStringSmall(Reentrant)));
  1587.         ++numopts;
  1588. #endif
  1589. #ifdef REGARGS
  1590.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1591.           LoadFarStringSmall(RegArgs)));
  1592.         ++numopts;
  1593. #endif
  1594. #ifdef RETURN_CODES
  1595.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1596.           LoadFarStringSmall(Return_Codes)));
  1597.         ++numopts;
  1598. #endif
  1599. #ifdef SET_DIR_ATTRIB
  1600.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1601.           LoadFarStringSmall(SetDirAttrib)));
  1602.         ++numopts;
  1603. #endif
  1604. #ifdef TIMESTAMP
  1605.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1606.           LoadFarStringSmall(TimeStamp)));
  1607.         ++numopts;
  1608. #endif
  1609. #ifdef UNIXBACKUP
  1610.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1611.           LoadFarStringSmall(UnixBackup)));
  1612.         ++numopts;
  1613. #endif
  1614. #ifdef USE_EF_UT_TIME
  1615.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1616.           LoadFarStringSmall(Use_EF_UT_time)));
  1617.         ++numopts;
  1618. #endif
  1619. #ifndef COPYRIGHT_CLEAN
  1620.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1621.           LoadFarStringSmall(Use_Smith_Code)));
  1622.         ++numopts;
  1623. #endif
  1624. #ifndef LZW_CLEAN
  1625.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1626.           LoadFarStringSmall(Use_Unshrink)));
  1627.         ++numopts;
  1628. #endif
  1629. #ifdef USE_VFAT
  1630.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1631.           LoadFarStringSmall(Use_VFAT_support)));
  1632.         ++numopts;
  1633. #endif
  1634. #ifdef USE_ZLIB
  1635.         sprintf((char *)(slide+256), LoadFarStringSmall(UseZlib),
  1636.           ZLIB_VERSION, zlib_version);
  1637.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1638.           (char *)(slide+256)));
  1639.         ++numopts;
  1640. #endif
  1641. #ifdef VMS_TEXT_CONV
  1642.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1643.           LoadFarStringSmall(VmsTextConv)));
  1644.         ++numopts;
  1645. #endif
  1646. #ifdef VMSCLI
  1647.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1648.           LoadFarStringSmall(VmsCLI)));
  1649.         ++numopts;
  1650. #endif
  1651. #ifdef VMSWILD
  1652.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1653.           LoadFarStringSmall(VmsWild)));
  1654.         ++numopts;
  1655. #endif
  1656. #if CRYPT
  1657. # ifdef PASSWD_FROM_STDIN
  1658.         Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
  1659.           LoadFarStringSmall(PasswdStdin)));
  1660. # endif
  1661.         Info(slide, 0, ((char *)slide, LoadFarString(Decryption),
  1662.           CR_MAJORVER, CR_MINORVER, CR_BETA_VER,
  1663.           LoadFarStringSmall(CryptDate)));
  1664.         ++numopts;
  1665. #endif /* CRYPT */
  1666.         if (numopts == 0)
  1667.             Info(slide, 0, ((char *)slide,
  1668.               LoadFarString(CompileOptFormat),
  1669.               LoadFarStringSmall(None)));
  1670.  
  1671.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptions)));
  1672.         envptr = getenv(LoadFarStringSmall(EnvUnZip));
  1673.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1674.           LoadFarStringSmall(EnvUnZip),
  1675.           (envptr == (char *)NULL || *envptr == 0)?
  1676.           LoadFarStringSmall2(None) : envptr));
  1677.         envptr = getenv(LoadFarStringSmall(EnvUnZip2));
  1678.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1679.           LoadFarStringSmall(EnvUnZip2),
  1680.           (envptr == (char *)NULL || *envptr == 0)?
  1681.           LoadFarStringSmall2(None) : envptr));
  1682.         envptr = getenv(LoadFarStringSmall(EnvZipInfo));
  1683.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1684.           LoadFarStringSmall(EnvZipInfo),
  1685.           (envptr == (char *)NULL || *envptr == 0)?
  1686.           LoadFarStringSmall2(None) : envptr));
  1687.         envptr = getenv(LoadFarStringSmall(EnvZipInfo2));
  1688.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1689.           LoadFarStringSmall(EnvZipInfo2),
  1690.           (envptr == (char *)NULL || *envptr == 0)?
  1691.           LoadFarStringSmall2(None) : envptr));
  1692. #ifndef __RSXNT__
  1693. #ifdef __EMX__
  1694.         envptr = getenv(LoadFarStringSmall(EnvEMX));
  1695.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1696.           LoadFarStringSmall(EnvEMX),
  1697.           (envptr == (char *)NULL || *envptr == 0)?
  1698.           LoadFarStringSmall2(None) : envptr));
  1699.         envptr = getenv(LoadFarStringSmall(EnvEMXOPT));
  1700.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1701.           LoadFarStringSmall(EnvEMXOPT),
  1702.           (envptr == (char *)NULL || *envptr == 0)?
  1703.           LoadFarStringSmall2(None) : envptr));
  1704. #endif /* __EMX__ */
  1705. #if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
  1706.         envptr = getenv(LoadFarStringSmall(EnvGO32));
  1707.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1708.           LoadFarStringSmall(EnvGO32),
  1709.           (envptr == (char *)NULL || *envptr == 0)?
  1710.           LoadFarStringSmall2(None) : envptr));
  1711.         envptr = getenv(LoadFarStringSmall(EnvGO32TMP));
  1712.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1713.           LoadFarStringSmall(EnvGO32TMP),
  1714.           (envptr == (char *)NULL || *envptr == 0)?
  1715.           LoadFarStringSmall2(None) : envptr));
  1716. #endif /* __GO32__ && !(__DJGPP__ >= 2) */
  1717. #endif /* !__RSXNT__ */
  1718. #ifdef RISCOS
  1719.         envptr = getenv(LoadFarStringSmall(EnvUnZipExts));
  1720.         Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
  1721.           LoadFarStringSmall(EnvUnZipExts),
  1722.           (envptr == (char *)NULL || *envptr == 0)?
  1723.           LoadFarStringSmall2(None) : envptr));
  1724. #endif /* RISCOS */
  1725.     }
  1726. } /* end function show_version() */
  1727.  
  1728. #endif /* !SFX */
  1729. #endif /* !WINDLL */
  1730.