2 Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
4 See the accompanying file LICENSE, version 2000-Apr-09 or later
5 (the contents of which are also included in unzip.h) for terms of use.
6 If, for some reason, all these files are missing, the Info-ZIP license
7 also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9 /*---------------------------------------------------------------------------
13 UnZip - a zipfile extraction utility. See below for make instructions, or
14 read the comments in Makefile and the various Contents files for more de-
15 tailed explanations. To report a bug, send a *complete* description to
16 Zip-Bugs@lists.wku.edu; include machine type, operating system and ver-
17 sion, compiler and version, and reasonably detailed error messages or prob-
18 lem report. To join Info-ZIP, see the instructions in README.
20 UnZip 5.x is a greatly expanded and partially rewritten successor to 4.x,
21 which in turn was almost a complete rewrite of version 3.x. For a detailed
22 revision history, see UnzpHist.zip at quest.jpl.nasa.gov. For a list of
23 the many (near infinite) contributors, see "CONTRIBS" in the UnZip source
26 ---------------------------------------------------------------------------
28 [from original zipinfo.c]
30 This program reads great gobs of totally nifty information, including the
31 central directory stuff, from ZIP archives ("zipfiles" for short). It
32 started as just a testbed for fooling with zipfiles, but at this point it
33 is actually a useful utility. It also became the basis for the rewrite of
34 UnZip (3.16 -> 4.0), using the central directory for processing rather than
35 the individual (local) file headers.
37 As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
38 If the executable is named "unzip" (or "unzip.exe", depending), it behaves
39 like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
40 ZipInfo. The ZipInfo behavior may also be triggered by use of unzip's -Z
41 option; for example, "unzip -Z [zipinfo_options] archive.zip".
43 Another dandy product from your buddies at Newtware!
45 Author: Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
46 23 August 1990 -> April 1997
48 ---------------------------------------------------------------------------
50 Version: unzip5??.{tar.Z | tar.gz | zip} for Unix, VMS, OS/2, MS-DOS, Amiga,
51 Atari, Windows 3.x/95/NT/CE, Macintosh, Human68K, Acorn RISC OS,
52 BeOS, SMS/QDOS, VM/CMS, MVS, AOS/VS, Tandem NSK, Theos and
55 Copyrights: see accompanying file "LICENSE" in UnZip source distribution.
56 (This software is free but NOT IN THE PUBLIC DOMAIN.)
58 ---------------------------------------------------------------------------*/
62 #define __UNZIP_C /* identifies this source module */
63 #define UNZIP_INTERNAL
64 #include "unzip.h" /* includes, typedefs, macros, prototypes, etc. */
68 #ifndef WINDLL /* The WINDLL port uses windll/windll.c instead... */
70 /***************************/
71 /* Local type declarations */
72 /***************************/
75 typedef struct _sign_info
77 struct _sign_info
*previous
;
78 void (*sighandler
)(int);
88 static int setsignalhandler
OF((__GPRO__ savsigs_info
**p_savedhandler_chain
,
89 int signal_type
, void (*newhandler
)(int)));
92 static void show_version_info
OF((__GPRO
));
100 #include "consts.h" /* all constant global variables are in here */
101 /* (non-constant globals were moved to globals.c) */
103 /* constant local variables: */
106 static ZCONST
char Far EnvUnZip
[] = ENV_UNZIP
;
107 static ZCONST
char Far EnvUnZip2
[] = ENV_UNZIP2
;
108 static ZCONST
char Far EnvZipInfo
[] = ENV_ZIPINFO
;
109 static ZCONST
char Far EnvZipInfo2
[] = ENV_ZIPINFO2
;
111 static ZCONST
char Far EnvUnZipExts
[] = ENV_UNZIPEXTS
;
113 static ZCONST
char Far NoMemArguments
[] =
114 "envargs: cannot get memory for arguments";
118 static ZCONST
char Far CantSaveSigHandler
[] =
119 "error: cannot save signal handler settings\n";
122 #if (!defined(SFX) || defined(SFX_EXDIR))
123 static ZCONST
char Far NotExtracting
[] =
124 "caution: not extracting; -d ignored\n";
125 static ZCONST
char Far MustGiveExdir
[] =
126 "error: must specify directory to which to extract with -d option\n";
127 static ZCONST
char Far OnlyOneExdir
[] =
128 "error: -d option used more than once (only one exdir allowed)\n";
132 static ZCONST
char Far MustGivePasswd
[] =
133 "error: must give decryption password with -P option\n";
137 static ZCONST
char Far Zfirst
[] =
138 "error: -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
140 static ZCONST
char Far InvalidOptionsMsg
[] = "error:\
141 -fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
142 static ZCONST
char Far IgnoreOOptionMsg
[] =
143 "caution: both -n and -o specified; ignoring -o\n";
145 /* usage() strings */
148 static ZCONST
char Far Example3
[] = "vms.c";
149 static ZCONST
char Far Example2
[] = " unzip\
150 \"-V\" foo \"Bar\" => must quote uppercase options and filenames in VMS\n";
152 static ZCONST
char Far Example3
[] = "ReadMe";
154 static ZCONST
char Far Example2
[] =
155 " unzip foo -d RAM:$ => extract all files from foo into RAMDisc\n";
157 #if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
158 static ZCONST
char Far Example2
[] =
159 ""; /* no room: too many local3[] items */
162 static ZCONST
char Far Example2
[] = ""; /* not needed */
164 static ZCONST
char Far Example2
[] = " \
165 unzip -p foo | more => send contents of foo.zip via pipe into program more\n";
171 /* local1[]: command options */
172 #if (defined(DLL) && defined(API_DOC))
173 static ZCONST
char Far local1
[] =
174 " -A print extended help for API functions";
175 #else /* !(DLL && API_DOC) */
176 static ZCONST
char Far local1
[] = "";
177 #endif /* ?(DLL && API_DOC) */
179 /* local2[] and local3[]: modifier options */
180 #ifdef DOS_FLX_H68_OS2_W32
182 static ZCONST
char Far local2
[] = "";
184 static ZCONST
char Far local2
[] =
185 " -$ label removables (-$$ => fixed disks)";
189 static ZCONST
char Far local3
[] = "\
190 -X restore ACLs if supported -s spaces in filenames => '_'\n\
191 -M pipe through \"more\" pager\n";
193 static ZCONST
char Far local3
[] = " \
194 -X restore ACLs if supported -s spaces in filenames => '_'\n\n";
200 static ZCONST
char Far local3
[] = "\
201 -X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\
202 -M pipe through \"more\" pager\n";
204 static ZCONST
char Far local3
[] = " \
205 -X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\n";
207 #else /* !NTSD_EAS */
209 static ZCONST
char Far local3
[] = "\
210 -M pipe through \"more\" pager \
211 -s spaces in filenames => '_'\n\n";
213 static ZCONST
char Far local3
[] = " \
214 -s spaces in filenames => '_'\n\n";
216 #endif /* ?NTSD_EAS */
219 static ZCONST
char Far local3
[] = " -\
220 M pipe through \"more\" pager -s spaces in filenames => '_'\n\n";
222 static ZCONST
char Far local3
[] = "\
223 -s spaces in filenames => '_'\n";
226 #endif /* ?OS2 || ?WIN32 */
227 #else /* !DOS_FLX_OS2_W32 */
229 static ZCONST
char Far local2
[] = "\"-X\" restore owner/protection info";
231 static ZCONST
char Far local3
[] = " \
232 \"-M\" pipe through \"more\" pager\n";
234 static ZCONST
char Far local3
[] = "\n";
238 static ZCONST
char Far local2
[] = " -X restore UID/GID info";
240 static ZCONST
char Far local3
[] = "\
241 -M pipe through \"more\" pager\n";
243 static ZCONST
char Far local3
[] = "\n";
247 static ZCONST
char Far local2
[] = " -X restore Tandem User ID";
249 static ZCONST
char Far local3
[] = "\
250 -b create 'C' (180) text files -M pipe through \"more\" pager\n";
252 static ZCONST
char Far local3
[] = " -b create 'C' (180) text files\n";
256 static ZCONST
char Far local2
[] = " -N restore comments as filenotes";
258 static ZCONST
char Far local3
[] = " \
259 -M pipe through \"more\" pager\n";
261 static ZCONST
char Far local3
[] = "\n";
265 static ZCONST
char Far local2
[] = " -E show Mac info during extraction";
266 static ZCONST
char Far local3
[] = " \
267 -i ignore filenames in mac extra info -J junk (ignore) Mac extra info\n\
271 static ZCONST
char Far local2
[] = " -M pipe through \"more\" pager";
272 static ZCONST
char Far local3
[] = "\n";
274 static ZCONST
char Far local2
[] = ""; /* Atari, Mac, CMS/MVS etc. */
275 static ZCONST
char Far local3
[] = "";
280 #endif /* ?BEO_UNX */
282 #endif /* ?DOS_FLX_OS2_W32 */
287 static ZCONST
char Far ZipInfoExample
[] = "* or % (e.g., \"*font-%.zip\")";
289 static ZCONST
char Far ZipInfoExample
[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
292 static ZCONST
char Far ZipInfoUsageLine1
[] = "\
293 ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
295 List name, date/time, attribute, size, compression method, etc., about files\n\
296 in list (excluding those in xlist) contained in the specified .zip archive(s).\
297 \n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
298 usage: zipinfo [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n\
299 or: unzip %s-Z%s [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n";
301 static ZCONST
char Far ZipInfoUsageLine2
[] = "\nmain\
302 listing-format options: -s short Unix \"ls -l\" format (def.)\n\
303 -1 filenames ONLY, one per line -m medium Unix \"ls -l\" format\n\
304 -2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
305 -v verbose, multi-page format\n";
307 static ZCONST
char Far ZipInfoUsageLine3
[] = "miscellaneous options:\n\
308 -h print header line -t print totals for listed files or for all\n\
309 -z print zipfile comment %c-T%c print file times in sortable decimal format\
310 \n %c-C%c be case-insensitive %s\
311 -x exclude filenames that follow from listing\n";
314 static ZCONST
char Far ZipInfoUsageLine4
[] =
315 " \"-M\" page output through built-in \"more\"\n";
317 static ZCONST
char Far ZipInfoUsageLine4
[] =
318 " -M page output through built-in \"more\"\n";
321 static ZCONST
char Far ZipInfoUsageLine4
[] = "";
323 #endif /* !NO_ZIPINFO */
327 /* BetaVersion[] is also used in vms/cmdline.c: do not make it static */
328 ZCONST
char Far BetaVersion
[] = "%s\
329 THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
331 static ZCONST
char Far BetaVersion
[] = "%s\
332 THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
338 /* UnzipSFXBanner[] is also used in vms/cmdline.c: do not make it static */
339 ZCONST
char Far UnzipSFXBanner
[] =
341 static ZCONST
char Far UnzipSFXBanner
[] =
343 "UnZipSFX %d.%d%d%s of %s, by Info-ZIP (Zip-Bugs@lists.wku.edu).\n";
345 static ZCONST
char Far UnzipSFXOpts
[] =
346 "Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
348 static ZCONST
char Far UnzipSFXOpts
[] =
349 "Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
352 static ZCONST
char Far CompileOptions
[] =
353 "UnZip special compilation options:\n";
354 static ZCONST
char Far CompileOptFormat
[] = "\t%s\n";
355 static ZCONST
char Far EnvOptions
[] =
356 "\nUnZip and ZipInfo environment options:\n";
357 static ZCONST
char Far EnvOptFormat
[] = "%16s: %s\n";
358 static ZCONST
char Far None
[] = "[none]";
359 # ifdef ACORN_FTYPE_NFS
360 static ZCONST
char Far AcornFtypeNFS
[] = "ACORN_FTYPE_NFS";
363 static ZCONST
char Far AsmCRC
[] = "ASM_CRC";
365 # ifdef ASM_INFLATECODES
366 static ZCONST
char Far AsmInflateCodes
[] = "ASM_INFLATECODES";
368 # ifdef CHECK_VERSIONS
369 static ZCONST
char Far Check_Versions
[] = "CHECK_VERSIONS";
371 # ifdef COPYRIGHT_CLEAN
372 static ZCONST
char Far Copyright_Clean
[] =
373 "COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
376 static ZCONST
char Far UDebug
[] = "DEBUG";
379 static ZCONST
char Far DebugTime
[] = "DEBUG_TIME";
382 static ZCONST
char Far Dll
[] = "DLL";
385 static ZCONST
char Far DosWild
[] = "DOSWILD";
388 static ZCONST
char Far LZW_Clean
[] =
389 "LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
392 static ZCONST
char Far No_More
[] = "NO_MORE";
395 static ZCONST
char Far No_ZipInfo
[] = "NO_ZIPINFO";
398 static ZCONST
char Far NTSDExtAttrib
[] = "NTSD_EAS";
400 # ifdef OLD_THEOS_EXTRA
401 static ZCONST
char Far OldTheosExtra
[] =
402 "OLD_THEOS_EXTRA (handle also old Theos port extra field)";
405 static ZCONST
char Far OS2ExtAttrib
[] = "OS2_EAS";
408 static ZCONST
char Far SMSExFldOnUnix
[] = "QLZIP";
411 static ZCONST
char Far Reentrant
[] = "REENTRANT";
414 static ZCONST
char Far RegArgs
[] = "REGARGS";
417 static ZCONST
char Far Return_Codes
[] = "RETURN_CODES";
419 # ifdef SET_DIR_ATTRIB
420 static ZCONST
char Far SetDirAttrib
[] = "SET_DIR_ATTRIB";
423 static ZCONST
char Far TimeStamp
[] = "TIMESTAMP";
426 static ZCONST
char Far UnixBackup
[] = "UNIXBACKUP";
428 # ifdef USE_EF_UT_TIME
429 static ZCONST
char Far Use_EF_UT_time
[] = "USE_EF_UT_TIME";
432 static ZCONST
char Far Use_Unshrink
[] =
433 "USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
435 # ifndef COPYRIGHT_CLEAN
436 static ZCONST
char Far Use_Smith_Code
[] =
437 "USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
439 # ifdef USE_DEFLATE64
440 static ZCONST
char Far Use_Deflate64
[] =
441 "USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)";
444 static ZCONST
char Far Use_MultiVol
[] =
445 "MULT_VOLUME (multi-volume archives supported)";
447 # if (defined(__DJGPP__) && (__DJGPP__ >= 2))
448 # ifdef USE_DJGPP_ENV
449 static ZCONST
char Far Use_DJGPP_Env
[] = "USE_DJGPP_ENV";
451 # ifdef USE_DJGPP_GLOB
452 static ZCONST
char Far Use_DJGPP_Glob
[] = "USE_DJGPP_GLOB";
454 # endif /* __DJGPP__ && (__DJGPP__ >= 2) */
456 static ZCONST
char Far Use_VFAT_support
[] = "USE_VFAT";
459 static ZCONST
char Far UseZlib
[] =
460 "USE_ZLIB (compiled with version %s; using version %s)";
462 # ifdef VMS_TEXT_CONV
463 static ZCONST
char Far VmsTextConv
[] = "VMS_TEXT_CONV";
466 static ZCONST
char Far VmsCLI
[] = "VMSCLI";
469 static ZCONST
char Far VmsWild
[] = "VMSWILD";
471 # ifdef WILD_STOP_AT_DIR
472 static ZCONST
char Far WildStopAtDir
[] = "WILD_STOP_AT_DIR";
475 # ifdef PASSWD_FROM_STDIN
476 static ZCONST
char Far PasswdStdin
[] = "PASSWD_FROM_STDIN";
478 static ZCONST
char Far Decryption
[] =
479 "\t[decryption, version %d.%d%s of %s]\n";
480 static ZCONST
char Far CryptDate
[] = CR_VERSION_DATE
;
484 static ZCONST
char Far EnvEMX
[] = "EMX";
485 static ZCONST
char Far EnvEMXOPT
[] = "EMXOPT";
487 # if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
488 static ZCONST
char Far EnvGO32
[] = "GO32";
489 static ZCONST
char Far EnvGO32TMP
[] = "GO32TMP";
491 # endif /* !__RSXNT__ */
494 /* UnzipUsageLine1[] is also used in vms/cmdline.c: do not make it static */
495 ZCONST
char Far UnzipUsageLine1
[] = "\
496 UnZip %d.%d%d%s of %s, by Info-ZIP. For more details see: unzip -v.\n\n";
497 #ifdef COPYRIGHT_CLEAN
498 static ZCONST
char Far UnzipUsageLine1v
[] = "\
499 UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
500 bug reports to the authors at Zip-Bugs@lists.wku.edu; see README for details.\
503 static ZCONST
char Far UnzipUsageLine1v
[] = "\
504 UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
505 Send bug reports to authors at Zip-Bugs@lists.wku.edu; see README for details.\
507 #endif /* ?COPYRIGHT_CLEAN */
509 #ifdef COPYRIGHT_CLEAN
510 static ZCONST
char Far UnzipUsageLine1
[] = "\
511 UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
512 bug reports to the authors at Zip-Bugs@lists.wku.edu; see README for details.\
515 static ZCONST
char Far UnzipUsageLine1
[] = "\
516 UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
517 Send bug reports to authors at Zip-Bugs@lists.wku.edu; see README for details.\
519 #endif /* ?COPYRIGHT_CLEAN */
520 #define UnzipUsageLine1v UnzipUsageLine1
523 static ZCONST
char Far UnzipUsageLine2v
[] = "\
524 Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;\
525 \nsee ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.\
529 static ZCONST
char Far UnzipUsageLine2
[] = "\
530 Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-d exdir]\n \
531 Default action is to extract files in list, to exdir;\n\
532 file[.zip] may be a wildcard. %s\n";
535 static ZCONST
char Far UnzipUsageLine2
[] = "\
536 Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d fm]\n \
537 Default action is to extract files in list, except those in xlist, to disk fm;\
538 \n file[.zip] may be a wildcard. %s\n";
540 static ZCONST
char Far UnzipUsageLine2
[] = "\
541 Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
542 Default action is to extract files in list, except those in xlist, to exdir;\n\
543 file[.zip] may be a wildcard. %s\n";
548 # define ZIPINFO_MODE_OPTION ""
549 static ZCONST
char Far ZipInfoMode
[] =
550 "(ZipInfo mode is disabled in this version.)";
552 # define ZIPINFO_MODE_OPTION "[-Z] "
554 static ZCONST
char Far ZipInfoMode
[] =
555 "\"-Z\" => ZipInfo mode (`unzip \"-Z\"' for usage).";
557 static ZCONST
char Far ZipInfoMode
[] =
558 "-Z => ZipInfo mode (\"unzip -Z\" for usage).";
560 #endif /* ?NO_ZIPINFO */
563 static ZCONST
char Far VMSusageLine2b
[] = "\
564 => define foreign command symbol in LOGIN.COM: $ unzip :== $dev:[dir]unzip.exe\
569 static ZCONST
char Far UnzipUsageLine3
[] = "\n\
570 -d extract files into exdir -l list files (short format)\n\
571 -f freshen existing files, create none -t test compressed archive data\n\
572 -u update files, create if necessary -z display archive comment\n\
576 static ZCONST
char Far UnzipUsageLine3
[] = "\n\
577 -p extract files to pipe, no messages -l list files (short format)\n\
578 -f freshen existing files, create none -t test compressed archive data\n\
579 -u update files, create if necessary -z display archive comment\n\
580 -x exclude files that follow (in xlist) -d extract files onto disk fm\n\
583 static ZCONST
char Far UnzipUsageLine3
[] = "\n\
584 -p extract files to pipe, no messages -l list files (short format)\n\
585 -f freshen existing files, create none -t test compressed archive data\n\
586 -u update files, create if necessary -z display archive comment\n\
587 -x exclude files that follow (in xlist) -d extract files into exdir\n\
592 static ZCONST
char Far UnzipUsageLine4
[] = "\
593 modifiers: -q quiet mode (-qq => quieter)\n\
594 -n never overwrite existing files -a auto-convert any text files\n\
595 -o overwrite files WITHOUT prompting -aa treat ALL files as text\n \
596 -j junk paths (do not make directories) -v be verbose/print version info\n\
597 %c-C%c match filenames case-insensitively %c-L%c make (some) names \
598 lowercase\n %-42s %c-V%c retain VMS version numbers\n%s";
600 static ZCONST
char Far UnzipUsageLine5
[] = "\
601 Examples (see unzip.txt for more info):\n\
602 unzip data1 -x joe => extract all files except joe from zipfile data1.zip\n\
604 unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
611 /*****************************/
612 /* main() / UzpMain() stub */
613 /*****************************/
615 int MAIN(argc
, argv
) /* return PK-type error code (except under VMS) */
622 r
= unzip(__G__ argc
, argv
);
630 /*******************************/
631 /* Primary UnZip entry point */
632 /*******************************/
634 int unzip(__G__ argc
, argv
)
642 #ifdef DOS_FLX_H68_NLM_OS2_W32
645 int retcode
, error
=FALSE
;
647 savsigs_info
*oldsighandlers
= NULL
;
648 # define SET_SIGHANDLER(sigtype, newsighandler) \
649 if ((retcode = setsignalhandler(__G__ &oldsighandlers, (sigtype), \
650 (newsighandler))) > PK_WARN) \
651 goto cleanup_and_exit
653 # define SET_SIGHANDLER(sigtype, newsighandler) \
654 signal((sigtype), (newsighandler))
657 SETLOCALE(LC_CTYPE
,"");
659 #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
660 extern void DebugMalloc(void);
666 /* The following (rather complex) expression determines the allocation
667 size of the decompression work area. It simulates what the
668 combined "union" and "struct" declaration of the "static" work
669 area reservation achieves automatically at compile time.
670 Any decent compiler should evaluate this expression completely at
671 compile time and provide constants to the zcalloc() call.
672 (For better readability, some subexpressions are encapsulated
673 in temporarly defined macros.)
675 # define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
676 # define UZ_NUMOF_CHUNKS \
677 (unsigned)(((WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK > HSIZE) ? \
678 (WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK : HSIZE)
679 G
.area
.Slide
= (uch
*)zcalloc(UZ_NUMOF_CHUNKS
, UZ_SLIDE_CHUNK
);
680 # undef UZ_SLIDE_CHUNK
681 # undef UZ_NUMOF_CHUNKS
682 G
.area
.shrink
.Parent
= (shrint
*)G
.area
.Slide
;
683 G
.area
.shrink
.value
= G
.area
.Slide
+ (sizeof(shrint
)*(HSIZE
));
684 G
.area
.shrink
.Stack
= G
.area
.Slide
+
685 (sizeof(shrint
) + sizeof(uch
))*(HSIZE
);
688 /*---------------------------------------------------------------------------
689 Set signal handler for restoring echo, warn of zipfile corruption, etc.
690 ---------------------------------------------------------------------------*/
693 SET_SIGHANDLER(SIGINT
, handler
);
695 #ifdef SIGTERM /* some systems really have no SIGTERM */
696 SET_SIGHANDLER(SIGTERM
, handler
);
699 SET_SIGHANDLER(SIGBUS
, handler
);
702 SET_SIGHANDLER(SIGSEGV
, handler
);
705 #if (defined(WIN32) && defined(__RSXNT__))
706 for (i
= 0 ; i
< argc
; i
++) {
707 _ISO_INTERN(argv
[i
]);
711 /*---------------------------------------------------------------------------
712 Macintosh initialization code.
713 ---------------------------------------------------------------------------*/
719 for (a
= 0; a
< 4; ++a
)
720 G
.rghCursor
[a
] = GetCursor(a
+128);
725 /*---------------------------------------------------------------------------
726 NetWare initialization code.
727 ---------------------------------------------------------------------------*/
733 /*---------------------------------------------------------------------------
734 Acorn RISC OS initialization code.
735 ---------------------------------------------------------------------------*/
741 /*---------------------------------------------------------------------------
742 Theos initialization code.
743 ---------------------------------------------------------------------------*/
746 /* The easiest way found to force creation of libraries when selected
747 * members are to be unzipped. Explicitely add libraries names to the
748 * arguments list before the first member of the library.
750 if (! _setargv(&argc
, &argv
)) {
751 Info(slide
, 0x401, ((char *)slide
, "cannot process argv\n"));
753 goto cleanup_and_exit
;
757 /*---------------------------------------------------------------------------
758 First figure out if we're running in UnZip mode or ZipInfo mode, and put
759 the appropriate environment-variable options into the queue. Then rip
760 through any command-line options lurking about...
761 ---------------------------------------------------------------------------*/
765 #if (defined(OS2) || defined(WIN32))
766 G
.zipfn
= GetLoadPath(__G
);/* non-MSC NT puts path into G.filename[] */
773 ulg status
= vms_unzip_cmdline(&argc
, &argv
);
775 retcode
= (int)status
;
776 goto cleanup_and_exit
;
781 uO
.zipinfo_mode
= FALSE
;
782 error
= uz_opts(__G__
&argc
, &argv
); /* UnZipSFX call only */
787 /* get the extensions to swap from environment */
788 getRISCOSexts(ENV_UNZIPEXTS
);
792 /* extract MKS extended argument list from environment (before envargs!) */
793 mksargs(&argc
, &argv
);
798 ulg status
= vms_unzip_cmdline(&argc
, &argv
);
800 retcode
= (int)status
;
801 goto cleanup_and_exit
;
806 G
.noargs
= (argc
== 1); /* no options, no zipfile, no anything */
809 for (p
= argv
[0] + strlen(argv
[0]); p
>= argv
[0]; --p
) {
820 if (strncmp(p
, "ZIPINFO.",8) == 0 || strstr(p
, ".ZIPINFO:") != NULL
||
821 strncmp(p
, "II.",3) == 0 || strstr(p
, ".II:") != NULL
||
823 if (STRNICMP(p
, LoadFarStringSmall(Zipnfo
), 7) == 0 ||
824 STRNICMP(p
, "ii", 2) == 0 ||
826 (argc
> 1 && strncmp(argv
[1], "-Z", 2) == 0))
828 uO
.zipinfo_mode
= TRUE
;
829 if ((error
= envargs(&argc
, &argv
, LoadFarStringSmall(EnvZipInfo
),
830 LoadFarStringSmall2(EnvZipInfo2
))) != PK_OK
)
831 perror(LoadFarString(NoMemArguments
));
833 error
= zi_opts(__G__
&argc
, &argv
);
835 #endif /* NO_ZIPINFO */
837 uO
.zipinfo_mode
= FALSE
;
838 if ((error
= envargs(&argc
, &argv
, LoadFarStringSmall(EnvUnZip
),
839 LoadFarStringSmall2(EnvUnZip2
))) != PK_OK
)
840 perror(LoadFarString(NoMemArguments
));
842 error
= uz_opts(__G__
&argc
, &argv
);
847 if ((argc
< 0) || error
) {
849 goto cleanup_and_exit
;
852 /*---------------------------------------------------------------------------
853 Now get the zipfile name from the command line and then process any re-
854 maining options and file specifications.
855 ---------------------------------------------------------------------------*/
857 #ifdef DOS_FLX_H68_NLM_OS2_W32
858 /* convert MSDOS-style 'backward slash' directory separators to Unix-style
859 * 'forward slashes' for user's convenience (include zipfile name itself)
862 for (G
.pfnames
= argv
, i
= argc
; i
> 0; --i
) {
864 /* argc does not include the zipfile specification */
865 for (G
.pfnames
= argv
, i
= argc
+1; i
> 0; --i
) {
868 extern char *_toslash(char *);
869 _toslash(*G
.pfnames
);
870 #else /* !__human68k__ */
873 for (q
= *G
.pfnames
; *q
; ++q
)
877 #endif /* ?__human68k__ */
879 #endif /* DOS_FLX_H68_NLM_OS2_W32 */
882 G
.wildzipfn
= *argv
++;
885 #if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
895 if (strcmp(*pp
, "-x") == 0) {
897 *pp
= 0; /* terminate G.pfnames */
898 G
.filespecs
= pp
- G
.pfnames
;
900 G
.pfnames
= (char **)fnames
; /* defaults */
903 G
.pxnames
= pp
+ 1; /* excluded-names ptr: _after_ -x */
904 G
.xfilespecs
= argc
- G
.filespecs
- 1;
905 break; /* skip rest of args */
907 G
.process_all_files
= FALSE
;
909 G
.process_all_files
= TRUE
; /* for speed */
911 #else /* !SFX || SFX_EXDIR */ /* check for -x or -d */
917 int in_files
=FALSE
, in_xfiles
=FALSE
;
920 G
.process_all_files
= FALSE
;
923 Trace((stderr
, "pp - argv = %d\n", pp
-argv
));
925 if (!uO
.exdir
&& STRNICMP(*pp
, "-d", 2) == 0) {
927 if (!uO
.exdir
&& strncmp(*pp
, "-d", 2) == 0) {
929 int firstarg
= (pp
== argv
);
931 uO
.exdir
= (*pp
) + 2;
932 if (in_files
) { /* ... zipfile ... -d exdir ... */
933 *pp
= (char *)NULL
; /* terminate G.pfnames */
934 G
.filespecs
= pp
- G
.pfnames
;
936 } else if (in_xfiles
) {
937 *pp
= (char *)NULL
; /* terminate G.pxnames */
938 G
.xfilespecs
= pp
- G
.pxnames
;
939 /* "... -x xlist -d exdir": nothing left */
941 /* first check for "-dexdir", then for "-d exdir" */
942 if (*uO
.exdir
== '\0') {
946 Info(slide
, 0x401, ((char *)slide
,
947 LoadFarString(MustGiveExdir
)));
948 /* don't extract here by accident */
950 goto cleanup_and_exit
;
953 if (firstarg
) { /* ... zipfile -d exdir ... */
955 G
.pfnames
= pp
+ 1; /* argv+2 */
956 G
.filespecs
= argc
- (G
.pfnames
-argv
); /* for now... */
958 G
.process_all_files
= TRUE
;
959 G
.pfnames
= (char **)fnames
; /* GRR: necessary? */
960 G
.filespecs
= 0; /* GRR: necessary? */
964 } else if (!in_xfiles
) {
965 if (strcmp(*pp
, "-x") == 0) {
967 if (pp
== G
.pfnames
) {
968 G
.pfnames
= (char **)fnames
; /* defaults */
970 } else if (in_files
) {
971 *pp
= 0; /* terminate G.pfnames */
972 G
.filespecs
= pp
- G
.pfnames
; /* adjust count */
975 G
.pxnames
= pp
+ 1; /* excluded-names ptr starts after -x */
976 G
.xfilespecs
= argc
- (G
.pxnames
-argv
); /* anything left */
982 G
.process_all_files
= TRUE
; /* for speed */
984 if (uO
.exdir
!= (char *)NULL
&& !G
.extract_flag
) /* -d ignored */
985 Info(slide
, 0x401, ((char *)slide
, LoadFarString(NotExtracting
)));
986 #endif /* ?(SFX && !SFX_EXDIR) */
988 /*---------------------------------------------------------------------------
989 Okey dokey, we have everything we need to get started. Let's roll.
990 ---------------------------------------------------------------------------*/
992 retcode
= process_zipfiles(__G
);
996 /* restore all signal handlers back to their state at function entry */
997 while (oldsighandlers
!= NULL
) {
998 savsigs_info
*thissigsav
= oldsighandlers
;
1000 signal(thissigsav
->sigtype
, thissigsav
->sighandler
);
1001 oldsighandlers
= thissigsav
->previous
;
1005 #if (defined(MALLOC_WORK) && !defined(REENTRANT))
1006 if (G
.area
.Slide
!= (uch
*)NULL
) {
1008 G
.area
.Slide
= (uch
*)NULL
;
1013 } /* end main()/unzip() */
1020 /*******************************/
1021 /* Function setsignalhandler() */
1022 /*******************************/
1024 static int setsignalhandler(__G__ p_savedhandler_chain
, signal_type
,
1027 savsigs_info
**p_savedhandler_chain
;
1029 void (*newhandler
)(int);
1031 savsigs_info
*savsig
;
1033 savsig
= malloc(sizeof(savsigs_info
));
1034 if (savsig
== NULL
) {
1035 /* error message and break */
1036 Info(slide
, 0x401, ((char *)slide
, LoadFarString(CantSaveSigHandler
)));
1039 savsig
->sigtype
= signal_type
;
1040 savsig
->sighandler
= signal(SIGINT
, newhandler
);
1041 if (savsig
->sighandler
== SIG_ERR
) {
1044 savsig
->previous
= *p_savedhandler_chain
;
1045 *p_savedhandler_chain
= savsig
;
1049 } /* end function setsignalhandler() */
1051 #endif /* REENTRANT */
1057 /**********************/
1058 /* Function uz_opts() */
1059 /**********************/
1061 int uz_opts(__G__ pargc
, pargv
)
1067 int argc
, c
, error
=FALSE
, negative
=0;
1073 while (++argv
, (--argc
> 0 && *argv
!= NULL
&& **argv
== '-')) {
1075 while ((c
= *s
++) != 0) { /* "!= 0": prevent Turbo C warning */
1087 if (negative
) { /* negative not allowed with -/ swap */
1088 Info(slide
, 0x401, ((char *)slide
,
1089 "error: must give extensions list"));
1090 return(PK_PARAM
); /* don't extract here by accident */
1092 exts2swap
= s
; /* override Unzip$Exts */
1098 uO
.aflag
= MAX(uO
.aflag
-negative
,0);
1103 #if (defined(DLL) && defined(API_DOC))
1104 case ('A'): /* extended help for API */
1105 APIhelp(__G__ argc
, argv
);
1106 *pargc
= -1; /* signal to exit successfully */
1111 #if (defined(TANDEM) || defined(VMS))
1112 uO
.bflag
= MAX(uO
.bflag
-negative
,0);
1114 negative
= 0; /* do nothing: "-b" is default */
1127 case ('B'): /* -B: back up existing files */
1129 uO
.B_flag
= FALSE
, negative
= 0;
1136 uO
.cflag
= FALSE
, negative
= 0;
1143 uO
.aflag
= 2; /* so you can read it on the screen */
1146 if (G
.redirect_text
)
1147 G
.redirect_data
= 2;
1152 case ('C'): /* -C: match filenames case-insensitively */
1154 uO
.C_flag
= FALSE
, negative
= 0;
1158 #endif /* !CMS_MVS */
1159 #if (!defined(SFX) || defined(SFX_EXDIR))
1161 if (negative
) { /* negative not allowed with -d exdir */
1162 Info(slide
, 0x401, ((char *)slide
,
1163 LoadFarString(MustGiveExdir
)));
1164 return(PK_PARAM
); /* don't extract here by accident */
1166 if (uO
.exdir
!= (char *)NULL
) {
1167 Info(slide
, 0x401, ((char *)slide
,
1168 LoadFarString(OnlyOneExdir
)));
1169 return(PK_PARAM
); /* GRR: stupid restriction? */
1171 /* first check for "-dexdir", then for "-d exdir" */
1173 if (*uO
.exdir
== '\0') {
1177 if (*uO
.exdir
== '-') {
1178 Info(slide
, 0x401, ((char *)slide
,
1179 LoadFarString(MustGiveExdir
)));
1182 /* else uO.exdir points at extraction dir */
1184 Info(slide
, 0x401, ((char *)slide
,
1185 LoadFarString(MustGiveExdir
)));
1189 /* uO.exdir now points at extraction dir (-dexdir or
1190 * -d exdir); point s at end of exdir to avoid mis-
1191 * interpretation of exdir characters as more options
1198 #endif /* !SFX || SFX_EXDIR */
1199 case ('e'): /* just ignore -e, -x options (extract) */
1202 case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
1204 uO
.E_flag
= FALSE
, negative
= 0;
1210 case ('f'): /* "freshen" (extract only newer files) */
1212 uO
.fflag
= uO
.uflag
= FALSE
, negative
= 0;
1214 uO
.fflag
= uO
.uflag
= TRUE
;
1216 #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
1217 case ('F'): /* Acorn filetype & NFS extension handling */
1219 uO
.acorn_nfs_ext
= FALSE
, negative
= 0;
1221 uO
.acorn_nfs_ext
= TRUE
;
1223 #endif /* RISCOS || ACORN_FTYPE_NFS */
1224 case ('h'): /* just print help message and quit */
1226 return USAGE(PK_OK
);
1228 case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
1230 uO
.i_flag
= FALSE
, negative
= 0;
1236 case ('j'): /* junk pathnames/directory structure */
1238 uO
.jflag
= FALSE
, negative
= 0;
1242 #if ((defined(__BEOS__) || defined(__HAIKU__)) || defined(MACOS) || defined(HAS_JUNK_EXTRA_FIELD_OPTION))
1243 case ('J'): /* Junk BeOS or MacOS file attributes */
1245 uO
.J_flag
= FALSE
, negative
= 0;
1250 #endif /* __BEOS__ || MACOS */
1254 uO
.vflag
= MAX(uO
.vflag
-negative
,0);
1261 case ('L'): /* convert (some) filenames to lowercase */
1263 uO
.L_flag
= MAX(uO
.L_flag
-negative
,0);
1268 #endif /* !CMS_MVS */
1273 case ('M'): /* send all screen output through "more" fn. */
1274 /* GRR: eventually check for numerical argument => height */
1276 G
.M_flag
= FALSE
, negative
= 0;
1281 case ('n'): /* don't overwrite any files */
1283 uO
.overwrite_none
= FALSE
, negative
= 0;
1285 uO
.overwrite_none
= TRUE
;
1288 case ('N'): /* restore comments as filenotes */
1290 uO
.N_flag
= FALSE
, negative
= 0;
1295 case ('o'): /* OK to overwrite files without prompting */
1297 uO
.overwrite_all
= MAX(uO
.overwrite_all
-negative
,0);
1302 case ('p'): /* pipes: extract to stdout, no messages */
1305 uO
.qflag
= MAX(uO
.qflag
-999,0);
1313 /* GRR: yes, this is highly insecure, but dozens of people
1314 * have pestered us for this, so here we go... */
1316 if (negative
) { /* negative not allowed with -P passwd */
1317 Info(slide
, 0x401, ((char *)slide
,
1318 LoadFarString(MustGivePasswd
)));
1319 return(PK_PARAM
); /* don't extract here by accident */
1321 if (uO
.pwdarg
!= (char *)NULL
) {
1323 GRR: eventually support multiple passwords?
1324 Info(slide, 0x401, ((char *)slide,
1325 LoadFarString(OnlyOnePasswd)));
1329 /* first check for "-Ppasswd", then for "-P passwd" */
1331 if (*uO
.pwdarg
== '\0') {
1334 uO
.pwdarg
= *++argv
;
1335 if (*uO
.pwdarg
== '-') {
1336 Info(slide
, 0x401, ((char *)slide
,
1337 LoadFarString(MustGivePasswd
)));
1340 /* else pwdarg points at decryption password */
1342 Info(slide
, 0x401, ((char *)slide
,
1343 LoadFarString(MustGivePasswd
)));
1347 /* pwdarg now points at decryption password (-Ppasswd or
1348 * -P passwd); point s at end of passwd to avoid mis-
1349 * interpretation of passwd characters as more options
1357 case ('q'): /* quiet: fewer comments/messages */
1359 uO
.qflag
= MAX(uO
.qflag
-negative
,0);
1365 case ('Q'): /* QDOS flags */
1366 qlflag
^= strtol(s
, &s
, 10);
1367 break; /* we XOR this as we can config qlflags */
1369 #ifdef DOS_FLX_NLM_OS2_W32
1370 case ('s'): /* spaces in filenames: allow by default */
1372 uO
.sflag
= FALSE
, negative
= 0;
1376 #endif /* DOS_FLX_NLM_OS2_W32 */
1379 uO
.tflag
= FALSE
, negative
= 0;
1386 uO
.T_flag
= FALSE
, negative
= 0;
1391 case ('u'): /* update (extract only new and newer files) */
1393 uO
.uflag
= FALSE
, negative
= 0;
1398 case ('U'): /* obsolete; to be removed in version 6.0 */
1400 uO
.L_flag
= TRUE
, negative
= 0;
1404 #endif /* !CMS_MVS */
1406 case ('v'): /* verbose */
1408 uO
.vflag
= MAX(uO
.vflag
-negative
,0);
1410 } else if (uO
.vflag
)
1417 case ('V'): /* Version (retain VMS/DEC-20 file versions) */
1419 uO
.V_flag
= FALSE
, negative
= 0;
1423 #endif /* !CMS_MVS */
1424 case ('x'): /* extract: default */
1426 /* when 'x' is the only option in this argument, and the
1427 * next arg is not an option, assume this initiates an
1428 * exclusion list (-x xlist): terminate option-scanning
1429 * and leave uz_opts with argv still pointing to "-x";
1430 * the xlist is processed later
1432 if (s
- argv
[0] == 2 && *s
== '\0' &&
1433 argc
> 1 && argv
[1][0] != '-') {
1434 /* break out of nested loops without "++argv;--argc" */
1439 #if (defined(RESTORE_UIDGID) || defined(RESTORE_ACL))
1440 case ('X'): /* restore owner/protection info (need privs?) */
1442 uO
.X_flag
= MAX(uO
.X_flag
-negative
,0);
1447 #endif /* RESTORE_UIDGID || RESTORE_ACL */
1448 case ('z'): /* display only the archive comment */
1450 uO
.zflag
= MAX(uO
.zflag
-negative
,0);
1456 case ('Z'): /* should have been first option (ZipInfo) */
1457 Info(slide
, 0x401, ((char *)slide
, LoadFarString(Zfirst
)));
1461 #ifdef DOS_H68_OS2_W32
1464 uO
.volflag
= MAX(uO
.volflag
-negative
,0);
1469 #endif /* DOS_H68_OS2_W32 */
1470 #if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
1473 uO
.ddotflag
= MAX(uO
.ddotflag
-negative
,0);
1478 #endif /* !RISCOS && !CMS_MVS && !TANDEM */
1484 } /* end while (not end of argument string) */
1485 } /* end while (not done with switches) */
1487 /*---------------------------------------------------------------------------
1488 Check for nonsensical combinations of options.
1489 ---------------------------------------------------------------------------*/
1492 opts_done
: /* yes, very ugly...but only used by UnZipSFX with -x xlist */
1495 if ((uO
.cflag
&& uO
.tflag
) || (uO
.cflag
&& uO
.uflag
) ||
1496 (uO
.tflag
&& uO
.uflag
) || (uO
.fflag
&& uO
.overwrite_none
))
1498 Info(slide
, 0x401, ((char *)slide
, LoadFarString(InvalidOptionsMsg
)));
1507 if (uO
.overwrite_all
&& uO
.overwrite_none
) {
1508 Info(slide
, 0x401, ((char *)slide
, LoadFarString(IgnoreOOptionMsg
)));
1509 uO
.overwrite_all
= FALSE
;
1512 if (G
.M_flag
&& !isatty(1)) /* stdout redirected: "more" func. useless */
1519 if ((argc
-- == 0) || error
)
1525 if (uO
.vflag
>= 2 && argc
== -1) { /* "unzip -v" */
1526 show_version_info(__G
);
1529 if (!G
.noargs
&& !error
)
1530 error
= PK_PARAM
; /* had options (not -h or -v) but no zipfile */
1532 return USAGE(error
);
1536 /* print our banner unless we're being fairly quiet */
1538 Info(slide
, error
? 1 : 0, ((char *)slide
, LoadFarString(UnzipSFXBanner
),
1539 UZ_MAJORVER
, UZ_MINORVER
, UZ_PATCHLEVEL
, UZ_BETALEVEL
,
1540 LoadFarStringSmall(VersionDate
)));
1542 /* always print the beta warning: no unauthorized distribution!! */
1543 Info(slide
, error
? 1 : 0, ((char *)slide
, LoadFarString(BetaVersion
), "\n",
1548 if (uO
.cflag
|| uO
.tflag
|| uO
.vflag
|| uO
.zflag
1553 G
.extract_flag
= FALSE
;
1555 G
.extract_flag
= TRUE
;
1561 } /* end function uz_opts() */
1566 /********************/
1567 /* Function usage() */
1568 /********************/
1572 # define LOCAL "X. Quote uppercase options"
1580 # if (defined(FLEXOS) || defined(NLM))
1586 /* Default for all other systems: */
1592 # define SFXOPT1 "M"
1597 int usage(__G__ error
) /* return PK-type error code */
1601 Info(slide
, error
? 1 : 0, ((char *)slide
, LoadFarString(UnzipSFXBanner
),
1602 UZ_MAJORVER
, UZ_MINORVER
, UZ_PATCHLEVEL
, UZ_BETALEVEL
,
1603 LoadFarStringSmall(VersionDate
)));
1604 Info(slide
, error
? 1 : 0, ((char *)slide
, LoadFarString(UnzipSFXOpts
),
1607 Info(slide
, error
? 1 : 0, ((char *)slide
, LoadFarString(BetaVersion
), "\n",
1614 return PK_COOL
; /* just wanted usage screen: no error */
1616 } /* end function usage() */
1631 int usage(__G__ error
) /* return PK-type error code */
1635 int flag
= (error
? 1 : 0);
1638 /*---------------------------------------------------------------------------
1639 Print either ZipInfo usage or UnZip usage, depending on incantation.
1640 (Strings must be no longer than 512 bytes for Turbo C, apparently.)
1641 ---------------------------------------------------------------------------*/
1643 if (uO
.zipinfo_mode
) {
1647 Info(slide
, flag
, ((char *)slide
, LoadFarString(ZipInfoUsageLine1
),
1648 ZI_MAJORVER
, ZI_MINORVER
, UZ_PATCHLEVEL
, UZ_BETALEVEL
,
1649 LoadFarStringSmall(VersionDate
),
1650 LoadFarStringSmall2(ZipInfoExample
), QUOTS
,QUOTS
));
1651 Info(slide
, flag
, ((char *)slide
, LoadFarString(ZipInfoUsageLine2
)));
1652 Info(slide
, flag
, ((char *)slide
, LoadFarString(ZipInfoUsageLine3
),
1653 QUOT
,QUOT
, QUOT
,QUOT
, LoadFarStringSmall(ZipInfoUsageLine4
)));
1655 Info(slide
, flag
, ((char *)slide
, "\nRemember that non-lowercase\
1656 filespecs must be quoted in VMS (e.g., \"Makefile\").\n"));
1659 #endif /* !NO_ZIPINFO */
1661 } else { /* UnZip mode */
1663 Info(slide
, flag
, ((char *)slide
, LoadFarString(UnzipUsageLine1
),
1664 UZ_MAJORVER
, UZ_MINORVER
, UZ_PATCHLEVEL
, UZ_BETALEVEL
,
1665 LoadFarStringSmall(VersionDate
)));
1667 Info(slide
, flag
, ((char *)slide
, LoadFarString(BetaVersion
), "", ""));
1670 Info(slide
, flag
, ((char *)slide
, LoadFarString(UnzipUsageLine2
),
1671 ZIPINFO_MODE_OPTION
, LoadFarStringSmall(ZipInfoMode
)));
1673 if (!error
) /* maybe no command-line tail found; show extra help */
1674 Info(slide
, flag
, ((char *)slide
, LoadFarString(VMSusageLine2b
)));
1677 Info(slide
, flag
, ((char *)slide
, LoadFarString(UnzipUsageLine3
),
1678 LoadFarStringSmall(local1
)));
1680 Info(slide
, flag
, ((char *)slide
, LoadFarString(UnzipUsageLine4
),
1681 QUOT
,QUOT
, QUOT
,QUOT
, LoadFarStringSmall(local2
), QUOT
,QUOT
,
1682 LoadFarStringSmall2(local3
)));
1684 /* This is extra work for SMALL_MEM, but it will work since
1685 * LoadFarStringSmall2 uses the same buffer. Remember, this
1687 Info(slide
, flag
, ((char *)slide
, LoadFarString(UnzipUsageLine5
),
1688 LoadFarStringSmall(Example2
), LoadFarStringSmall2(Example3
),
1689 LoadFarStringSmall2(Example3
)));
1691 } /* end if (uO.zipinfo_mode) */
1696 return PK_COOL
; /* just wanted usage screen: no error */
1698 } /* end function usage() */
1707 /********************************/
1708 /* Function show_version_info() */
1709 /********************************/
1711 static void show_version_info(__G
)
1714 if (uO
.qflag
> 3) /* "unzip -vqqqq" */
1715 Info(slide
, 0, ((char *)slide
, "%d\n",
1716 (UZ_MAJORVER
*100 + UZ_MINORVER
*10 + UZ_PATCHLEVEL
)));
1718 char *envptr
, *getenv();
1721 Info(slide
, 0, ((char *)slide
, LoadFarString(UnzipUsageLine1v
),
1722 UZ_MAJORVER
, UZ_MINORVER
, UZ_PATCHLEVEL
, UZ_BETALEVEL
,
1723 LoadFarStringSmall(VersionDate
)));
1724 Info(slide
, 0, ((char *)slide
,
1725 LoadFarString(UnzipUsageLine2v
)));
1727 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptions
)));
1728 #ifdef ACORN_FTYPE_NFS
1729 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1730 LoadFarStringSmall(AcornFtypeNFS
)));
1734 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1735 LoadFarStringSmall(AsmCRC
)));
1738 #ifdef ASM_INFLATECODES
1739 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1740 LoadFarStringSmall(AsmInflateCodes
)));
1743 #ifdef CHECK_VERSIONS
1744 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1745 LoadFarStringSmall(Check_Versions
)));
1748 #ifdef COPYRIGHT_CLEAN
1749 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1750 LoadFarStringSmall(Copyright_Clean
)));
1754 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1755 LoadFarStringSmall(UDebug
)));
1759 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1760 LoadFarStringSmall(DebugTime
)));
1764 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1765 LoadFarStringSmall(Dll
)));
1769 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1770 LoadFarStringSmall(DosWild
)));
1774 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1775 LoadFarStringSmall(LZW_Clean
)));
1779 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1780 LoadFarStringSmall(No_More
)));
1784 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1785 LoadFarStringSmall(No_ZipInfo
)));
1789 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1790 LoadFarStringSmall(NTSDExtAttrib
)));
1793 #ifdef OLD_THEOS_EXTRA
1794 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1795 LoadFarStringSmall(OldTheosExtra
)));
1799 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1800 LoadFarStringSmall(OS2ExtAttrib
)));
1804 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1805 LoadFarStringSmall(SMSExFldOnUnix
)));
1809 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1810 LoadFarStringSmall(Reentrant
)));
1814 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1815 LoadFarStringSmall(RegArgs
)));
1819 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1820 LoadFarStringSmall(Return_Codes
)));
1823 #ifdef SET_DIR_ATTRIB
1824 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1825 LoadFarStringSmall(SetDirAttrib
)));
1829 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1830 LoadFarStringSmall(TimeStamp
)));
1834 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1835 LoadFarStringSmall(UnixBackup
)));
1838 #ifdef USE_EF_UT_TIME
1839 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1840 LoadFarStringSmall(Use_EF_UT_time
)));
1843 #ifndef COPYRIGHT_CLEAN
1844 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1845 LoadFarStringSmall(Use_Smith_Code
)));
1849 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1850 LoadFarStringSmall(Use_Unshrink
)));
1853 #ifdef USE_DEFLATE64
1854 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1855 LoadFarStringSmall(Use_Deflate64
)));
1859 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1860 LoadFarStringSmall(Use_MultiVol
)));
1863 # if (defined(__DJGPP__) && (__DJGPP__ >= 2))
1864 # ifdef USE_DJGPP_ENV
1865 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1866 LoadFarStringSmall(Use_DJGPP_Env
)));
1869 # ifdef USE_DJGPP_GLOB
1870 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1871 LoadFarStringSmall(Use_DJGPP_Glob
)));
1874 # endif /* __DJGPP__ && (__DJGPP__ >= 2) */
1876 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1877 LoadFarStringSmall(Use_VFAT_support
)));
1881 sprintf((char *)(slide
+256), LoadFarStringSmall(UseZlib
),
1882 ZLIB_VERSION
, zlib_version
);
1883 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1884 (char *)(slide
+256)));
1887 #ifdef VMS_TEXT_CONV
1888 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1889 LoadFarStringSmall(VmsTextConv
)));
1893 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1894 LoadFarStringSmall(VmsCLI
)));
1898 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1899 LoadFarStringSmall(VmsWild
)));
1902 #ifdef WILD_STOP_AT_DIR
1903 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1904 LoadFarStringSmall(WildStopAtDir
)));
1908 # ifdef PASSWD_FROM_STDIN
1909 Info(slide
, 0, ((char *)slide
, LoadFarString(CompileOptFormat
),
1910 LoadFarStringSmall(PasswdStdin
)));
1912 Info(slide
, 0, ((char *)slide
, LoadFarString(Decryption
),
1913 CR_MAJORVER
, CR_MINORVER
, CR_BETA_VER
,
1914 LoadFarStringSmall(CryptDate
)));
1918 Info(slide
, 0, ((char *)slide
,
1919 LoadFarString(CompileOptFormat
),
1920 LoadFarStringSmall(None
)));
1922 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptions
)));
1923 envptr
= getenv(LoadFarStringSmall(EnvUnZip
));
1924 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1925 LoadFarStringSmall(EnvUnZip
),
1926 (envptr
== (char *)NULL
|| *envptr
== 0)?
1927 LoadFarStringSmall2(None
) : envptr
));
1928 envptr
= getenv(LoadFarStringSmall(EnvUnZip2
));
1929 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1930 LoadFarStringSmall(EnvUnZip2
),
1931 (envptr
== (char *)NULL
|| *envptr
== 0)?
1932 LoadFarStringSmall2(None
) : envptr
));
1933 envptr
= getenv(LoadFarStringSmall(EnvZipInfo
));
1934 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1935 LoadFarStringSmall(EnvZipInfo
),
1936 (envptr
== (char *)NULL
|| *envptr
== 0)?
1937 LoadFarStringSmall2(None
) : envptr
));
1938 envptr
= getenv(LoadFarStringSmall(EnvZipInfo2
));
1939 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1940 LoadFarStringSmall(EnvZipInfo2
),
1941 (envptr
== (char *)NULL
|| *envptr
== 0)?
1942 LoadFarStringSmall2(None
) : envptr
));
1945 envptr
= getenv(LoadFarStringSmall(EnvEMX
));
1946 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1947 LoadFarStringSmall(EnvEMX
),
1948 (envptr
== (char *)NULL
|| *envptr
== 0)?
1949 LoadFarStringSmall2(None
) : envptr
));
1950 envptr
= getenv(LoadFarStringSmall(EnvEMXOPT
));
1951 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1952 LoadFarStringSmall(EnvEMXOPT
),
1953 (envptr
== (char *)NULL
|| *envptr
== 0)?
1954 LoadFarStringSmall2(None
) : envptr
));
1955 #endif /* __EMX__ */
1956 #if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
1957 envptr
= getenv(LoadFarStringSmall(EnvGO32
));
1958 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1959 LoadFarStringSmall(EnvGO32
),
1960 (envptr
== (char *)NULL
|| *envptr
== 0)?
1961 LoadFarStringSmall2(None
) : envptr
));
1962 envptr
= getenv(LoadFarStringSmall(EnvGO32TMP
));
1963 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1964 LoadFarStringSmall(EnvGO32TMP
),
1965 (envptr
== (char *)NULL
|| *envptr
== 0)?
1966 LoadFarStringSmall2(None
) : envptr
));
1967 #endif /* __GO32__ && !(__DJGPP__ >= 2) */
1968 #endif /* !__RSXNT__ */
1970 envptr
= getenv(LoadFarStringSmall(EnvUnZipExts
));
1971 Info(slide
, 0, ((char *)slide
, LoadFarString(EnvOptFormat
),
1972 LoadFarStringSmall(EnvUnZipExts
),
1973 (envptr
== (char *)NULL
|| *envptr
== 0)?
1974 LoadFarStringSmall2(None
) : envptr
));
1977 } /* end function show_version() */
1980 #endif /* !WINDLL */