2
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
4
See the accompanying file LICENSE, version 2009-Jan-02 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, submit a *complete* description via
16
//www.info-zip.org/zip-bug.html; include machine type, operating system and
17
version, compiler and version, and reasonably detailed error messages or
18
problem 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
UnZip 6.0 adds support for archives larger than 4 GiB using the Zip64
27
extensions as well as support for Unicode information embedded per the
28
latest zip standard additions.
30
---------------------------------------------------------------------------
32
[from original zipinfo.c]
34
This program reads great gobs of totally nifty information, including the
35
central directory stuff, from ZIP archives ("zipfiles" for short). It
36
started as just a testbed for fooling with zipfiles, but at this point it
37
is actually a useful utility. It also became the basis for the rewrite of
38
UnZip (3.16 -> 4.0), using the central directory for processing rather than
39
the individual (local) file headers.
41
As of ZipInfo v2.0 and UnZip v5.1, the two programs are combined into one.
42
If the executable is named "unzip" (or "unzip.exe", depending), it behaves
43
like UnZip by default; if it is named "zipinfo" or "ii", it behaves like
44
ZipInfo. The ZipInfo behavior may also be triggered by use of unzip's -Z
45
option; for example, "unzip -Z [zipinfo_options] archive.zip".
47
Another dandy product from your buddies at Newtware!
49
Author: Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
50
23 August 1990 -> April 1997
52
---------------------------------------------------------------------------
54
Version: unzip5??.{tar.Z | tar.gz | zip} for Unix, VMS, OS/2, MS-DOS, Amiga,
55
Atari, Windows 3.x/95/NT/CE, Macintosh, Human68K, Acorn RISC OS,
56
AtheOS, BeOS, SMS/QDOS, VM/CMS, MVS, AOS/VS, Tandem NSK, Theos
59
Copyrights: see accompanying file "LICENSE" in UnZip source distribution.
60
(This software is free but NOT IN THE PUBLIC DOMAIN.)
62
---------------------------------------------------------------------------*/
66
#define __UNZIP_C /* identifies this source module */
67
#define UNZIP_INTERNAL
68
#include "unzip.h" /* includes, typedefs, macros, prototypes, etc. */
72
#ifndef WINDLL /* The WINDLL port uses windll/windll.c instead... */
74
/***************************/
75
/* Local type declarations */
76
/***************************/
78
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
79
typedef struct _sign_info
81
struct _sign_info *previous;
82
void (*sighandler)(int);
91
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
92
static int setsignalhandler OF((__GPRO__ savsigs_info **p_savedhandler_chain,
93
int signal_type, void (*newhandler)(int)));
96
static void help_extended OF((__GPRO));
97
static void show_version_info OF((__GPRO));
105
#include "consts.h" /* all constant global variables are in here */
106
/* (non-constant globals were moved to globals.c) */
108
/* constant local variables: */
111
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
112
static ZCONST char Far EnvUnZip[] = ENV_UNZIP;
113
static ZCONST char Far EnvUnZip2[] = ENV_UNZIP2;
114
static ZCONST char Far EnvZipInfo[] = ENV_ZIPINFO;
115
static ZCONST char Far EnvZipInfo2[] = ENV_ZIPINFO2;
117
static ZCONST char Far EnvUnZipExts[] = ENV_UNZIPEXTS;
119
static ZCONST char Far NoMemEnvArguments[] =
120
"envargs: cannot get memory for arguments";
121
#endif /* !_WIN32_WCE */
122
static ZCONST char Far CmdLineParamTooLong[] =
123
"error: command line parameter #%d exceeds internal size limit\n";
126
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
127
static ZCONST char Far CantSaveSigHandler[] =
128
"error: cannot save signal handler settings\n";
131
#if (!defined(SFX) || defined(SFX_EXDIR))
132
static ZCONST char Far NotExtracting[] =
133
"caution: not extracting; -d ignored\n";
134
static ZCONST char Far MustGiveExdir[] =
135
"error: must specify directory to which to extract with -d option\n";
136
static ZCONST char Far OnlyOneExdir[] =
137
"error: -d option used more than once (only one exdir allowed)\n";
139
#if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR))
140
static ZCONST char Far UTF8EscapeUnSupp[] =
141
"warning: -U \"escape all non-ASCII UTF-8 chars\" is not supported\n";
145
static ZCONST char Far MustGivePasswd[] =
146
"error: must give decryption password with -P option\n";
150
static ZCONST char Far Zfirst[] =
151
"error: -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
153
static ZCONST char Far InvalidOptionsMsg[] = "error:\
154
-fn or any combination of -c, -l, -p, -t, -u and -v options invalid\n";
155
static ZCONST char Far IgnoreOOptionMsg[] =
156
"caution: both -n and -o specified; ignoring -o\n";
158
/* usage() strings */
161
static ZCONST char Far Example3[] = "vms.c";
162
static ZCONST char Far Example2[] = " unzip \"-V\" foo \"Bar\"\
163
(Quote names to preserve case, unless SET PROC/PARS=EXT)\n";
165
static ZCONST char Far Example3[] = "ReadMe";
167
static ZCONST char Far Example2[] =
168
" unzip foo -d RAM:$ => extract all files from foo into RAMDisc\n";
170
#if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
171
static ZCONST char Far Example2[] =
172
""; /* no room: too many local3[] items */
175
static ZCONST char Far Example2[] = ""; /* not needed */
177
static ZCONST char Far Example2[] = " \
178
unzip -p foo | more => send contents of foo.zip via pipe into program more\n";
184
/* local1[]: command options */
185
#if defined(TIMESTAMP)
186
static ZCONST char Far local1[] =
187
" -T timestamp archive to latest";
188
#else /* !TIMESTAMP */
189
static ZCONST char Far local1[] = "";
190
#endif /* ?TIMESTAMP */
192
/* local2[] and local3[]: modifier options */
193
#ifdef DOS_FLX_H68_OS2_W32
195
static ZCONST char Far local2[] = "";
197
static ZCONST char Far local2[] =
198
" -$ label removables (-$$ => fixed disks)";
202
static ZCONST char Far local3[] = "\
203
-X restore ACLs if supported -s spaces in filenames => '_'\n\
204
-M pipe through \"more\" pager\n";
206
static ZCONST char Far local3[] = " \
207
-X restore ACLs if supported -s spaces in filenames => '_'\n\n";
213
static ZCONST char Far local3[] = "\
214
-X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\
215
-M pipe through \"more\" pager\n";
217
static ZCONST char Far local3[] = " \
218
-X restore ACLs (-XX => use privileges) -s spaces in filenames => '_'\n\n";
220
#else /* !NTSD_EAS */
222
static ZCONST char Far local3[] = "\
223
-M pipe through \"more\" pager \
224
-s spaces in filenames => '_'\n\n";
226
static ZCONST char Far local3[] = " \
227
-s spaces in filenames => '_'\n\n";
229
#endif /* ?NTSD_EAS */
232
static ZCONST char Far local3[] = " -\
233
M pipe through \"more\" pager -s spaces in filenames => '_'\n\n";
235
static ZCONST char Far local3[] = "\
236
-s spaces in filenames => '_'\n";
239
#endif /* ?OS2 || ?WIN32 */
240
#else /* !DOS_FLX_OS2_W32 */
242
static ZCONST char Far local2[] = " -X restore owner/ACL protection info";
244
static ZCONST char Far local3[] = "\
245
-Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
246
--D restore dir (-D: no) timestamps -M pipe through \"more\" pager\n\
247
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
250
static ZCONST char Far local3[] = "\n\
251
-Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
252
--D restore dir (-D: no) timestamps\n\
253
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
258
static ZCONST char Far local2[] = " -X restore UID/GID info";
260
static ZCONST char Far local3[] = "\
261
-K keep setuid/setgid/tacky permissions -M pipe through \"more\" pager\n";
263
static ZCONST char Far local3[] = "\
264
-K keep setuid/setgid/tacky permissions\n";
266
#else /* !ATH_BEO_UNX */
268
static ZCONST char Far local2[] = "\
269
-X restore Tandem User ID -r remove file extensions\n\
270
-b create 'C' (180) text files ";
272
static ZCONST char Far local3[] = " \
273
-M pipe through \"more\" pager\n";
275
static ZCONST char Far local3[] = "\n";
279
static ZCONST char Far local2[] = " -N restore comments as filenotes";
281
static ZCONST char Far local3[] = " \
282
-M pipe through \"more\" pager\n";
284
static ZCONST char Far local3[] = "\n";
288
static ZCONST char Far local2[] = " -E show Mac info during extraction";
289
static ZCONST char Far local3[] = " \
290
-i ignore filenames in mac extra info -J junk (ignore) Mac extra info\n\
294
static ZCONST char Far local2[] = " -M pipe through \"more\" pager";
295
static ZCONST char Far local3[] = "\n";
297
static ZCONST char Far local2[] = ""; /* Atari, Mac, CMS/MVS etc. */
298
static ZCONST char Far local3[] = "";
303
#endif /* ?ATH_BEO_UNX */
305
#endif /* ?DOS_FLX_OS2_W32 */
310
static ZCONST char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
312
static ZCONST char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
315
static ZCONST char Far ZipInfoUsageLine1[] = "\
316
ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
318
List name, date/time, attribute, size, compression method, etc., about files\n\
319
in list (excluding those in xlist) contained in the specified .zip archive(s).\
320
\n\"file[.zip]\" may be a wildcard name containing %s.\n\n\
321
usage: zipinfo [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n\
322
or: unzip %s-Z%s [-12smlvChMtTz] file[.zip] [list...] [-x xlist...]\n";
324
static ZCONST char Far ZipInfoUsageLine2[] = "\nmain\
325
listing-format options: -s short Unix \"ls -l\" format (def.)\n\
326
-1 filenames ONLY, one per line -m medium Unix \"ls -l\" format\n\
327
-2 just filenames but allow -h/-t/-z -l long Unix \"ls -l\" format\n\
328
-v verbose, multi-page format\n";
330
static ZCONST char Far ZipInfoUsageLine3[] = "miscellaneous options:\n\
331
-h print header line -t print totals for listed files or for all\n\
332
-z print zipfile comment -T print file times in sortable decimal format\
333
\n -C be case-insensitive %s\
334
-x exclude filenames that follow from listing\n";
336
static ZCONST char Far ZipInfoUsageLine4[] =
337
" -M page output through built-in \"more\"\n";
339
static ZCONST char Far ZipInfoUsageLine4[] = "";
341
#endif /* !NO_ZIPINFO */
345
/* BetaVersion[] is also used in vms/cmdline.c: do not make it static */
346
ZCONST char Far BetaVersion[] = "%s\
347
THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
349
static ZCONST char Far BetaVersion[] = "%s\
350
THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
356
/* UnzipSFXBanner[] is also used in vms/cmdline.c: do not make it static */
357
ZCONST char Far UnzipSFXBanner[] =
359
static ZCONST char Far UnzipSFXBanner[] =
361
"UnZipSFX %d.%d%d%s of %s, by Info-ZIP (http://www.info-zip.org).\n";
363
static ZCONST char Far UnzipSFXOpts[] =
364
"Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
366
static ZCONST char Far UnzipSFXOpts[] =
367
"Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
370
static ZCONST char Far CompileOptions[] =
371
"UnZip special compilation options:\n";
372
static ZCONST char Far CompileOptFormat[] = " %s\n";
373
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
374
static ZCONST char Far EnvOptions[] =
375
"\nUnZip and ZipInfo environment options:\n";
376
static ZCONST char Far EnvOptFormat[] = "%16s: %.1024s\n";
378
static ZCONST char Far None[] = "[none]";
379
# ifdef ACORN_FTYPE_NFS
380
static ZCONST char Far AcornFtypeNFS[] = "ACORN_FTYPE_NFS";
383
static ZCONST char Far AsmCRC[] = "ASM_CRC";
385
# ifdef ASM_INFLATECODES
386
static ZCONST char Far AsmInflateCodes[] = "ASM_INFLATECODES";
388
# ifdef CHECK_VERSIONS
389
static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS";
391
# ifdef COPYRIGHT_CLEAN
392
static ZCONST char Far Copyright_Clean[] =
393
"COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
396
static ZCONST char Far UDebug[] = "DEBUG";
399
static ZCONST char Far DebugTime[] = "DEBUG_TIME";
402
static ZCONST char Far Dll[] = "DLL";
405
static ZCONST char Far DosWild[] = "DOSWILD";
408
static ZCONST char Far LZW_Clean[] =
409
"LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
412
static ZCONST char Far No_More[] = "NO_MORE";
415
static ZCONST char Far No_ZipInfo[] = "NO_ZIPINFO";
418
static ZCONST char Far NTSDExtAttrib[] = "NTSD_EAS";
420
# if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
421
static ZCONST char Far W32NoIZTimeFix[] = "NO_W32TIMES_IZFIX";
423
# ifdef OLD_THEOS_EXTRA
424
static ZCONST char Far OldTheosExtra[] =
425
"OLD_THEOS_EXTRA (handle also old Theos port extra field)";
428
static ZCONST char Far OS2ExtAttrib[] = "OS2_EAS";
431
static ZCONST char Far SMSExFldOnUnix[] = "QLZIP";
434
static ZCONST char Far Reentrant[] = "REENTRANT";
437
static ZCONST char Far RegArgs[] = "REGARGS";
440
static ZCONST char Far Return_Codes[] = "RETURN_CODES";
442
# ifdef SET_DIR_ATTRIB
443
static ZCONST char Far SetDirAttrib[] = "SET_DIR_ATTRIB";
446
static ZCONST char Far SymLinkSupport[] =
447
"SYMLINKS (symbolic links supported, if RTL and file system permit)";
450
static ZCONST char Far TimeStamp[] = "TIMESTAMP";
453
static ZCONST char Far UnixBackup[] = "UNIXBACKUP";
455
# ifdef USE_EF_UT_TIME
456
static ZCONST char Far Use_EF_UT_time[] = "USE_EF_UT_TIME";
459
static ZCONST char Far Use_Unshrink[] =
460
"USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
462
# ifndef COPYRIGHT_CLEAN
463
static ZCONST char Far Use_Smith_Code[] =
464
"USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
466
# ifdef USE_DEFLATE64
467
static ZCONST char Far Use_Deflate64[] =
468
"USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)";
470
# ifdef UNICODE_SUPPORT
471
# ifdef UTF8_MAYBE_NATIVE
472
# ifdef UNICODE_WCHAR
473
/* direct native UTF-8 check AND charset transform via wchar_t */
474
static ZCONST char Far Use_Unicode[] =
475
"UNICODE_SUPPORT [wide-chars, char coding: %s] (handle UTF-8 paths)";
477
/* direct native UTF-8 check, only */
478
static ZCONST char Far Use_Unicode[] =
479
"UNICODE_SUPPORT [char coding: %s] (handle UTF-8 paths)";
481
static ZCONST char Far SysChUTF8[] = "UTF-8";
482
static ZCONST char Far SysChOther[] = "other";
483
# else /* !UTF8_MAYBE_NATIVE */
484
/* charset transform via wchar_t, no native UTF-8 support */
485
static ZCONST char Far Use_Unicode[] =
486
"UNICODE_SUPPORT [wide-chars] (handle UTF-8 paths)";
487
# endif /* ?UTF8_MAYBE_NATIVE */
488
# endif /* UNICODE_SUPPORT */
490
static ZCONST char Far Have_MBCS_Support[] =
491
"MBCS-support (multibyte character support, MB_CUR_MAX = %u)";
494
static ZCONST char Far Use_MultiVol[] =
495
"MULT_VOLUME (multi-volume archives supported)";
497
# ifdef LARGE_FILE_SUPPORT
498
static ZCONST char Far Use_LFS[] =
499
"LARGE_FILE_SUPPORT (large files over 2 GiB supported)";
501
# ifdef ZIP64_SUPPORT
502
static ZCONST char Far Use_Zip64[] =
503
"ZIP64_SUPPORT (archives using Zip64 for large files supported)";
505
# if (defined(__DJGPP__) && (__DJGPP__ >= 2))
506
# ifdef USE_DJGPP_ENV
507
static ZCONST char Far Use_DJGPP_Env[] = "USE_DJGPP_ENV";
509
# ifdef USE_DJGPP_GLOB
510
static ZCONST char Far Use_DJGPP_Glob[] = "USE_DJGPP_GLOB";
512
# endif /* __DJGPP__ && (__DJGPP__ >= 2) */
514
static ZCONST char Far Use_VFAT_support[] = "USE_VFAT";
517
static ZCONST char Far UseZlib[] =
518
"USE_ZLIB (compiled with version %s; using version %s)";
521
static ZCONST char Far UseBZip2[] =
522
"USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version %s)";
524
# ifdef VMS_TEXT_CONV
525
static ZCONST char Far VmsTextConv[] = "VMS_TEXT_CONV";
528
static ZCONST char Far VmsCLI[] = "VMSCLI";
531
static ZCONST char Far VmsWild[] = "VMSWILD";
533
# ifdef WILD_STOP_AT_DIR
534
static ZCONST char Far WildStopAtDir[] = "WILD_STOP_AT_DIR";
537
# ifdef PASSWD_FROM_STDIN
538
static ZCONST char Far PasswdStdin[] = "PASSWD_FROM_STDIN";
540
static ZCONST char Far Decryption[] =
541
" [decryption, version %d.%d%s of %s]\n";
542
static ZCONST char Far CryptDate[] = CR_VERSION_DATE;
546
static ZCONST char Far EnvEMX[] = "EMX";
547
static ZCONST char Far EnvEMXOPT[] = "EMXOPT";
549
# if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
550
static ZCONST char Far EnvGO32[] = "GO32";
551
static ZCONST char Far EnvGO32TMP[] = "GO32TMP";
553
# endif /* !__RSXNT__ */
556
/* UnzipUsageLine1[] is also used in vms/cmdline.c: do not make it static */
557
ZCONST char Far UnzipUsageLine1[] = "\
558
UnZip %d.%d%d%s of %s, by Info-ZIP. For more details see: unzip -v.\n\n";
559
# ifdef COPYRIGHT_CLEAN
560
static ZCONST char Far UnzipUsageLine1v[] = "\
561
UnZip %d.%d%d%s of %s, by Info-ZIP. Maintained by C. Spieler. Send\n\
562
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.\
565
static ZCONST char Far UnzipUsageLine1v[] = "\
566
UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
567
Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
569
# endif /* ?COPYRIGHT_CLEAN */
571
# ifdef COPYRIGHT_CLEAN
572
static ZCONST char Far UnzipUsageLine1[] = "\
573
UnZip %d.%d%d%s of %s, by Debian. Original by Info-ZIP.\
576
static ZCONST char Far UnzipUsageLine1[] = "\
577
UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\
578
Send bug reports using //www.info-zip.org/zip-bug.html; see README for details.\
580
# endif /* ?COPYRIGHT_CLEAN */
581
# define UnzipUsageLine1v UnzipUsageLine1
584
static ZCONST char Far UnzipUsageLine2v[] = "\
585
Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;\
586
\nsee ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.\
590
static ZCONST char Far UnzipUsageLine2[] = "\
591
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-d exdir]\n \
592
Default action is to extract files in list, to exdir;\n\
593
file[.zip] may be a wildcard. %s\n";
596
static ZCONST char Far UnzipUsageLine2[] = "\
597
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d fm]\n \
598
Default action is to extract files in list, except those in xlist, to disk fm;\
599
\n file[.zip] may be a wildcard. %s\n";
601
static ZCONST char Far UnzipUsageLine2[] = "\
602
Usage: unzip %s[-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]\n \
603
Default action is to extract files in list, except those in xlist, to exdir;\n\
604
file[.zip] may be a wildcard. %s\n";
609
# define ZIPINFO_MODE_OPTION ""
610
static ZCONST char Far ZipInfoMode[] =
611
"(ZipInfo mode is disabled in this version.)";
613
# define ZIPINFO_MODE_OPTION "[-Z] "
614
static ZCONST char Far ZipInfoMode[] =
615
"-Z => ZipInfo mode (\"unzip -Z\" for usage).";
616
#endif /* ?NO_ZIPINFO */
619
static ZCONST char Far VMSusageLine2b[] = "\
620
=> define foreign command symbol in LOGIN.COM: $ unzip :== $dev:[dir]unzip.exe\
625
static ZCONST char Far UnzipUsageLine3[] = "\n\
626
-d extract files into exdir -l list files (short format)\n\
627
-f freshen existing files, create none -t test compressed archive data\n\
628
-u update files, create if necessary -z display archive comment only\n\
629
-v list verbosely/show version info %s\n";
632
static ZCONST char Far UnzipUsageLine3[] = "\n\
633
-p extract files to pipe, no messages -l list files (short format)\n\
634
-f freshen existing files, create none -t test compressed archive data\n\
635
-u update files, create if necessary -z display archive comment only\n\
636
-v list verbosely/show version info %s\n\
637
-x exclude files that follow (in xlist) -d extract files onto disk fm\n";
639
static ZCONST char Far UnzipUsageLine3[] = "\n\
640
-p extract files to pipe, no messages -l list files (short format)\n\
641
-f freshen existing files, create none -t test compressed archive data\n\
642
-u update files, create if necessary -z display archive comment only\n\
643
-v list verbosely/show version info %s\n\
644
-x exclude files that follow (in xlist) -d extract files into exdir\n";
648
/* There is not enough space on a standard 80x25 Windows console screen for
649
* the additional line advertising the UTF-8 debugging options. This may
650
* eventually also be the case for other ports. Probably, the -U option need
651
* not be shown on the introductory screen at all. [Chr. Spieler, 2008-02-09]
653
* Likely, other advanced options should be moved to an extended help page and
654
* the option to list that page put here. [E. Gordon, 2008-3-16]
656
#if (defined(UNICODE_SUPPORT) && !defined(WIN32))
658
static ZCONST char Far UnzipUsageLine4[] = "\
660
-n never overwrite or make a new version of an existing file\n\
661
-o always make a new version (-oo: overwrite original) of an existing file\n\
662
-q quiet mode (-qq => quieter) -a auto-convert any text files\n\
663
-j junk paths (do not make directories) -aa treat ALL files as text\n\
664
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
665
-C match filenames case-insensitively -L make (some) names \
666
lowercase\n %-42s -V retain VMS version numbers\n%s";
668
static ZCONST char Far UnzipUsageLine4[] = "\
670
-n never overwrite existing files -q quiet mode (-qq => quieter)\n\
671
-o overwrite files WITHOUT prompting -a auto-convert any text files\n\
672
-j junk paths (do not make directories) -aa treat ALL files as text\n\
673
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields\n\
674
-C match filenames case-insensitively -L make (some) names \
675
lowercase\n %-42s -V retain VMS version numbers\n%s";
677
#else /* !UNICODE_SUPPORT */
679
static ZCONST char Far UnzipUsageLine4[] = "\
681
-n never overwrite or make a new version of an existing file\n\
682
-o always make a new version (-oo: overwrite original) of an existing file\n\
683
-q quiet mode (-qq => quieter) -a auto-convert any text files\n\
684
-j junk paths (do not make directories) -aa treat ALL files as text\n\
685
-C match filenames case-insensitively -L make (some) names \
686
lowercase\n %-42s -V retain VMS version numbers\n%s";
688
static ZCONST char Far UnzipUsageLine4[] = "\
690
-n never overwrite existing files -q quiet mode (-qq => quieter)\n\
691
-o overwrite files WITHOUT prompting -a auto-convert any text files\n\
692
-j junk paths (do not make directories) -aa treat ALL files as text\n\
693
-C match filenames case-insensitively -L make (some) names \
694
lowercase\n %-42s -V retain VMS version numbers\n%s";
696
#endif /* ?UNICODE_SUPPORT */
698
static ZCONST char Far UnzipUsageLine5[] = "\
699
See \"unzip -hh\" or unzip.txt for more help. Examples:\n\
700
unzip data1 -x joe => extract all files except joe from zipfile data1.zip\n\
702
unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
709
/*****************************/
710
/* main() / UzpMain() stub */
711
/*****************************/
713
int MAIN(argc, argv) /* return PK-type error code (except under VMS) */
720
r = unzip(__G__ argc, argv);
728
/*******************************/
729
/* Primary UnZip entry point */
730
/*******************************/
732
int unzip(__G__ argc, argv)
740
#if (defined(DOS_FLX_H68_NLM_OS2_W32) || !defined(SFX))
743
int retcode, error=FALSE;
744
#ifndef NO_EXCEPT_SIGNALS
746
savsigs_info *oldsighandlers = NULL;
747
# define SET_SIGHANDLER(sigtype, newsighandler) \
748
if ((retcode = setsignalhandler(__G__ &oldsighandlers, (sigtype), \
749
(newsighandler))) > PK_WARN) \
750
goto cleanup_and_exit
752
# define SET_SIGHANDLER(sigtype, newsighandler) \
753
signal((sigtype), (newsighandler))
755
#endif /* NO_EXCEPT_SIGNALS */
757
/* initialize international char support to the current environment */
758
SETLOCALE(LC_CTYPE, "");
760
#ifdef UNICODE_SUPPORT
761
/* see if can use UTF-8 Unicode locale */
762
# ifdef UTF8_MAYBE_NATIVE
765
# if !(defined(NO_NL_LANGINFO) || defined(NO_LANGINFO_H))
766
/* get the codeset (character set encoding) currently used */
767
# include <langinfo.h>
769
codeset = nl_langinfo(CODESET);
770
# else /* NO_NL_LANGINFO || NO_LANGINFO_H */
771
/* query the current locale setting for character classification */
772
codeset = setlocale(LC_CTYPE, NULL);
773
if (codeset != NULL) {
774
/* extract the codeset portion of the locale name */
775
codeset = strchr(codeset, '.');
776
if (codeset != NULL) ++codeset;
778
# endif /* ?(NO_NL_LANGINFO || NO_LANGINFO_H) */
779
/* is the current codeset UTF-8 ? */
780
if ((codeset != NULL) && (strcmp(codeset, "UTF-8") == 0)) {
781
/* successfully found UTF-8 char coding */
782
G.native_is_utf8 = TRUE;
784
/* Current codeset is not UTF-8 or cannot be determined. */
785
G.native_is_utf8 = FALSE;
787
/* Note: At least for UnZip, trying to change the process codeset to
788
* UTF-8 does not work. For the example Linux setup of the
789
* UnZip maintainer, a successful switch to "en-US.UTF-8"
790
* resulted in garbage display of all non-basic ASCII characters.
793
# endif /* UTF8_MAYBE_NATIVE */
795
/* initialize Unicode */
796
G.unicode_escape_all = 0;
797
G.unicode_mismatch = 0;
799
G.unipath_version = 0;
800
G.unipath_checksum = 0;
801
G.unipath_filename = NULL;
802
#endif /* UNICODE_SUPPORT */
805
#if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
806
extern void DebugMalloc(void);
812
/* The following (rather complex) expression determines the allocation
813
size of the decompression work area. It simulates what the
814
combined "union" and "struct" declaration of the "static" work
815
area reservation achieves automatically at compile time.
816
Any decent compiler should evaluate this expression completely at
817
compile time and provide constants to the zcalloc() call.
818
(For better readability, some subexpressions are encapsulated
819
in temporarly defined macros.)
821
# define UZ_SLIDE_CHUNK (sizeof(shrint)+sizeof(uch)+sizeof(uch))
822
# define UZ_NUMOF_CHUNKS \
823
(unsigned)(((WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK > HSIZE) ? \
824
(WSIZE+UZ_SLIDE_CHUNK-1)/UZ_SLIDE_CHUNK : HSIZE)
825
G.area.Slide = (uch *)zcalloc(UZ_NUMOF_CHUNKS, UZ_SLIDE_CHUNK);
826
# undef UZ_SLIDE_CHUNK
827
# undef UZ_NUMOF_CHUNKS
828
G.area.shrink.Parent = (shrint *)G.area.Slide;
829
G.area.shrink.value = G.area.Slide + (sizeof(shrint)*(HSIZE));
830
G.area.shrink.Stack = G.area.Slide +
831
(sizeof(shrint) + sizeof(uch))*(HSIZE);
834
/*---------------------------------------------------------------------------
835
Set signal handler for restoring echo, warn of zipfile corruption, etc.
836
---------------------------------------------------------------------------*/
837
#ifndef NO_EXCEPT_SIGNALS
839
SET_SIGHANDLER(SIGINT, handler);
841
#ifdef SIGTERM /* some systems really have no SIGTERM */
842
SET_SIGHANDLER(SIGTERM, handler);
844
#if defined(SIGABRT) && !(defined(AMIGA) && defined(__SASC))
845
SET_SIGHANDLER(SIGABRT, handler);
848
SET_SIGHANDLER(SIGBREAK, handler);
851
SET_SIGHANDLER(SIGBUS, handler);
854
SET_SIGHANDLER(SIGILL, handler);
857
SET_SIGHANDLER(SIGSEGV, handler);
859
#endif /* NO_EXCEPT_SIGNALS */
861
#if (defined(WIN32) && defined(__RSXNT__))
862
for (i = 0 ; i < argc; i++) {
863
_ISO_INTERN(argv[i]);
867
/*---------------------------------------------------------------------------
868
Macintosh initialization code.
869
---------------------------------------------------------------------------*/
875
for (a = 0; a < 4; ++a)
876
G.rghCursor[a] = GetCursor(a+128);
881
/*---------------------------------------------------------------------------
882
NetWare initialization code.
883
---------------------------------------------------------------------------*/
889
/*---------------------------------------------------------------------------
890
Acorn RISC OS initialization code.
891
---------------------------------------------------------------------------*/
897
/*---------------------------------------------------------------------------
898
Theos initialization code.
899
---------------------------------------------------------------------------*/
902
/* The easiest way found to force creation of libraries when selected
903
* members are to be unzipped. Explicitly add libraries names to the
904
* arguments list before the first member of the library.
906
if (! _setargv(&argc, &argv)) {
907
Info(slide, 0x401, ((char *)slide, "cannot process argv\n"));
909
goto cleanup_and_exit;
913
/*---------------------------------------------------------------------------
914
Sanity checks. Commentary by Otis B. Driftwood and Fiorello:
916
D: It's all right. That's in every contract. That's what they
917
call a sanity clause.
919
F: Ha-ha-ha-ha-ha. You can't fool me. There ain't no Sanity
921
---------------------------------------------------------------------------*/
924
# ifdef LARGE_FILE_SUPPORT
925
/* test if we can support large files - 10/6/04 EG */
926
if (sizeof(zoff_t) < 8) {
927
Info(slide, 0x401, ((char *)slide, "LARGE_FILE_SUPPORT set but not supported\n"));
929
goto cleanup_and_exit;
931
/* test if we can show 64-bit values */
933
zoff_t z = ~(zoff_t)0; /* z should be all 1s now */
936
sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
937
if ((sz[0] != 'F') || (strlen(sz) != 16))
942
/* shift z so only MSB is set */
944
sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
945
if ((sz[0] != '8') || (strlen(sz) != 16))
947
Info(slide, 0x401, ((char *)slide,
948
"Can't show 64-bit values correctly\n"));
950
goto cleanup_and_exit;
953
# endif /* LARGE_FILE_SUPPORT */
956
Test the NEXTBYTE macro for proper operation.
960
static uch test_buf[2] = { 'a', 'b' };
965
test_char = NEXTBYTE; /* Should get 'a'. */
966
if (test_char == 'a')
968
test_char = NEXTBYTE; /* Should get EOF, not 'b'. */
970
if (test_char != EOF)
972
Info(slide, 0x401, ((char *)slide,
973
"NEXTBYTE macro failed. Try compiling with ALT_NEXTBYTE defined?"));
976
goto cleanup_and_exit;
981
/*---------------------------------------------------------------------------
982
First figure out if we're running in UnZip mode or ZipInfo mode, and put
983
the appropriate environment-variable options into the queue. Then rip
984
through any command-line options lurking about...
985
---------------------------------------------------------------------------*/
989
#if (defined(OS2) || defined(WIN32))
990
G.zipfn = GetLoadPath(__G);/* non-MSC NT puts path into G.filename[] */
997
ulg status = vms_unzip_cmdline(&argc, &argv);
999
retcode = (int)status;
1000
goto cleanup_and_exit;
1005
uO.zipinfo_mode = FALSE;
1006
error = uz_opts(__G__ &argc, &argv); /* UnZipSFX call only */
1011
/* get the extensions to swap from environment */
1012
getRISCOSexts(ENV_UNZIPEXTS);
1016
/* extract MKS extended argument list from environment (before envargs!) */
1017
mksargs(&argc, &argv);
1022
ulg status = vms_unzip_cmdline(&argc, &argv);
1023
if (!(status & 1)) {
1024
retcode = (int)status;
1025
goto cleanup_and_exit;
1030
G.noargs = (argc == 1); /* no options, no zipfile, no anything */
1033
for (p = argv[0] + strlen(argv[0]); p >= argv[0]; --p) {
1044
if (strncmp(p, "ZIPINFO.",8) == 0 || strstr(p, ".ZIPINFO:") != NULL ||
1045
strncmp(p, "II.",3) == 0 || strstr(p, ".II:") != NULL ||
1047
if (STRNICMP(p, LoadFarStringSmall(Zipnfo), 7) == 0 ||
1048
STRNICMP(p, "ii", 2) == 0 ||
1050
(argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
1052
uO.zipinfo_mode = TRUE;
1053
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
1054
if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvZipInfo),
1055
LoadFarStringSmall2(EnvZipInfo2))) != PK_OK)
1056
perror(LoadFarString(NoMemEnvArguments));
1059
#endif /* !NO_ZIPINFO */
1061
uO.zipinfo_mode = FALSE;
1062
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
1063
if ((error = envargs(&argc, &argv, LoadFarStringSmall(EnvUnZip),
1064
LoadFarStringSmall2(EnvUnZip2))) != PK_OK)
1065
perror(LoadFarString(NoMemEnvArguments));
1070
/* Check the length of all passed command line parameters.
1071
* Command arguments might get sent through the Info() message
1072
* system, which uses the sliding window area as string buffer.
1073
* As arguments may additionally get fed through one of the FnFilter
1074
* macros, we require all command line arguments to be shorter than
1075
* WSIZE/4 (and ca. 2 standard line widths for fixed message text).
1077
for (i = 1 ; i < argc; i++) {
1078
if (strlen(argv[i]) > ((WSIZE>>2) - 160)) {
1079
Info(slide, 0x401, ((char *)slide,
1080
LoadFarString(CmdLineParamTooLong), i));
1082
goto cleanup_and_exit;
1086
if (uO.zipinfo_mode)
1087
error = zi_opts(__G__ &argc, &argv);
1089
#endif /* !NO_ZIPINFO */
1090
error = uz_opts(__G__ &argc, &argv);
1095
if ((argc < 0) || error) {
1097
goto cleanup_and_exit;
1100
/*---------------------------------------------------------------------------
1101
Now get the zipfile name from the command line and then process any re-
1102
maining options and file specifications.
1103
---------------------------------------------------------------------------*/
1105
#ifdef DOS_FLX_H68_NLM_OS2_W32
1106
/* convert MSDOS-style 'backward slash' directory separators to Unix-style
1107
* 'forward slashes' for user's convenience (include zipfile name itself)
1110
for (G.pfnames = argv, i = argc; i > 0; --i) {
1112
/* argc does not include the zipfile specification */
1113
for (G.pfnames = argv, i = argc+1; i > 0; --i) {
1116
extern char *_toslash(char *);
1117
_toslash(*G.pfnames);
1118
#else /* !__human68k__ */
1119
char *q = *G.pfnames;
1121
while (*q != '\0') {
1126
#endif /* ?__human68k__ */
1129
#endif /* DOS_FLX_H68_NLM_OS2_W32 */
1132
G.wildzipfn = *argv++;
1135
#if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
1145
if (strcmp(*pp, "-x") == 0) {
1147
*pp = 0; /* terminate G.pfnames */
1148
G.filespecs = pp - G.pfnames;
1150
G.pfnames = (char **)fnames; /* defaults */
1153
G.pxnames = pp + 1; /* excluded-names ptr: _after_ -x */
1154
G.xfilespecs = argc - G.filespecs - 1;
1155
break; /* skip rest of args */
1157
G.process_all_files = FALSE;
1159
G.process_all_files = TRUE; /* for speed */
1161
#else /* !SFX || SFX_EXDIR */ /* check for -x or -d */
1167
int in_files=FALSE, in_xfiles=FALSE;
1170
G.process_all_files = FALSE;
1173
Trace((stderr, "pp - argv = %d\n", pp-argv));
1175
if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) {
1177
if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) {
1179
int firstarg = (pp == argv);
1181
uO.exdir = (*pp) + 2;
1182
if (in_files) { /* ... zipfile ... -d exdir ... */
1183
*pp = (char *)NULL; /* terminate G.pfnames */
1184
G.filespecs = pp - G.pfnames;
1186
} else if (in_xfiles) {
1187
*pp = (char *)NULL; /* terminate G.pxnames */
1188
G.xfilespecs = pp - G.pxnames;
1189
/* "... -x xlist -d exdir": nothing left */
1191
/* first check for "-dexdir", then for "-d exdir" */
1192
if (*uO.exdir == '\0') {
1196
Info(slide, 0x401, ((char *)slide,
1197
LoadFarString(MustGiveExdir)));
1198
/* don't extract here by accident */
1200
goto cleanup_and_exit;
1203
if (firstarg) { /* ... zipfile -d exdir ... */
1205
G.pfnames = pp + 1; /* argv+2 */
1206
G.filespecs = argc - (G.pfnames-argv); /* for now... */
1208
G.process_all_files = TRUE;
1209
G.pfnames = (char **)fnames; /* GRR: necessary? */
1210
G.filespecs = 0; /* GRR: necessary? */
1214
} else if (!in_xfiles) {
1215
if (strcmp(*pp, "-x") == 0) {
1217
if (pp == G.pfnames) {
1218
G.pfnames = (char **)fnames; /* defaults */
1220
} else if (in_files) {
1221
*pp = 0; /* terminate G.pfnames */
1222
G.filespecs = pp - G.pfnames; /* adjust count */
1225
G.pxnames = pp + 1; /* excluded-names ptr starts after -x */
1226
G.xfilespecs = argc - (G.pxnames-argv); /* anything left */
1232
G.process_all_files = TRUE; /* for speed */
1234
if (uO.exdir != (char *)NULL && !G.extract_flag) /* -d ignored */
1235
Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting)));
1236
#endif /* ?(SFX && !SFX_EXDIR) */
1238
#ifdef UNICODE_SUPPORT
1239
/* set Unicode-escape-all if option -U used */
1241
# ifdef UNICODE_WCHAR
1242
G.unicode_escape_all = TRUE;
1244
Info(slide, 0x401, ((char *)slide, LoadFarString(UTF8EscapeUnSupp)));
1249
/*---------------------------------------------------------------------------
1250
Okey dokey, we have everything we need to get started. Let's roll.
1251
---------------------------------------------------------------------------*/
1253
retcode = process_zipfiles(__G);
1256
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
1257
/* restore all signal handlers back to their state at function entry */
1258
while (oldsighandlers != NULL) {
1259
savsigs_info *thissigsav = oldsighandlers;
1261
signal(thissigsav->sigtype, thissigsav->sighandler);
1262
oldsighandlers = thissigsav->previous;
1266
#if (defined(MALLOC_WORK) && !defined(REENTRANT))
1267
if (G.area.Slide != (uch *)NULL) {
1269
G.area.Slide = (uch *)NULL;
1272
#if (defined(MSDOS) && !defined(SFX) && !defined(WINDLL))
1273
if (retcode != PK_OK)
1274
check_for_windows("UnZip");
1278
} /* end main()/unzip() */
1284
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
1285
/*******************************/
1286
/* Function setsignalhandler() */
1287
/*******************************/
1289
static int setsignalhandler(__G__ p_savedhandler_chain, signal_type,
1292
savsigs_info **p_savedhandler_chain;
1294
void (*newhandler)(int);
1296
savsigs_info *savsig;
1298
savsig = malloc(sizeof(savsigs_info));
1299
if (savsig == NULL) {
1300
/* error message and break */
1301
Info(slide, 0x401, ((char *)slide, LoadFarString(CantSaveSigHandler)));
1304
savsig->sigtype = signal_type;
1305
savsig->sighandler = signal(SIGINT, newhandler);
1306
if (savsig->sighandler == SIG_ERR) {
1309
savsig->previous = *p_savedhandler_chain;
1310
*p_savedhandler_chain = savsig;
1314
} /* end function setsignalhandler() */
1316
#endif /* REENTRANT && !NO_EXCEPT_SIGNALS */
1322
/**********************/
1323
/* Function uz_opts() */
1324
/**********************/
1326
int uz_opts(__G__ pargc, pargv)
1332
int argc, c, error=FALSE, negative=0, showhelp=0;
1338
while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
1340
while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
1352
if (negative) { /* negative not allowed with -/ swap */
1353
Info(slide, 0x401, ((char *)slide,
1354
"error: must give extensions list"));
1355
return(PK_PARAM); /* don't extract here by accident */
1357
exts2swap = s; /* override Unzip$Exts */
1363
uO.aflag = MAX(uO.aflag-negative,0);
1368
#if (defined(DLL) && defined(API_DOC))
1369
case ('A'): /* extended help for API */
1370
APIhelp(__G__ argc, argv);
1371
*pargc = -1; /* signal to exit successfully */
1376
#if (defined(TANDEM) || defined(VMS))
1377
uO.bflag = MAX(uO.bflag-negative,0);
1379
negative = 0; /* do nothing: "-b" is default */
1392
case ('B'): /* -B: back up existing files */
1394
uO.B_flag = FALSE, negative = 0;
1401
uO.cflag = FALSE, negative = 0;
1408
uO.aflag = 2; /* so you can read it on the screen */
1411
if (G.redirect_text)
1412
G.redirect_data = 2;
1417
case ('C'): /* -C: match filenames case-insensitively */
1419
uO.C_flag = FALSE, negative = 0;
1423
#endif /* !CMS_MVS */
1424
#if (!defined(SFX) || defined(SFX_EXDIR))
1426
if (negative) { /* negative not allowed with -d exdir */
1427
Info(slide, 0x401, ((char *)slide,
1428
LoadFarString(MustGiveExdir)));
1429
return(PK_PARAM); /* don't extract here by accident */
1431
if (uO.exdir != (char *)NULL) {
1432
Info(slide, 0x401, ((char *)slide,
1433
LoadFarString(OnlyOneExdir)));
1434
return(PK_PARAM); /* GRR: stupid restriction? */
1436
/* first check for "-dexdir", then for "-d exdir" */
1438
if (*uO.exdir == '\0') {
1442
if (*uO.exdir == '-') {
1443
Info(slide, 0x401, ((char *)slide,
1444
LoadFarString(MustGiveExdir)));
1447
/* else uO.exdir points at extraction dir */
1449
Info(slide, 0x401, ((char *)slide,
1450
LoadFarString(MustGiveExdir)));
1454
/* uO.exdir now points at extraction dir (-dexdir or
1455
* -d exdir); point s at end of exdir to avoid mis-
1456
* interpretation of exdir characters as more options
1463
#endif /* !SFX || SFX_EXDIR */
1464
#if (!defined(NO_TIMESTAMPS))
1465
case ('D'): /* -D: Skip restoring dir (or any) timestamp. */
1467
uO.D_flag = MAX(uO.D_flag-negative,0);
1472
#endif /* (!NO_TIMESTAMPS) */
1473
case ('e'): /* just ignore -e, -x options (extract) */
1476
case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
1478
uO.E_flag = FALSE, negative = 0;
1484
case ('f'): /* "freshen" (extract only newer files) */
1486
uO.fflag = uO.uflag = FALSE, negative = 0;
1488
uO.fflag = uO.uflag = TRUE;
1490
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
1491
case ('F'): /* Acorn filetype & NFS extension handling */
1493
uO.acorn_nfs_ext = FALSE, negative = 0;
1495
uO.acorn_nfs_ext = TRUE;
1497
#endif /* RISCOS || ACORN_FTYPE_NFS */
1498
case ('h'): /* just print help message and quit */
1499
if (showhelp == 0) {
1511
case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
1513
uO.i_flag = FALSE, negative = 0;
1519
case ('j'): /* junk pathnames/directory structure */
1521
uO.jflag = FALSE, negative = 0;
1525
#if (defined(ATH_BEO) || defined(MACOS))
1526
case ('J'): /* Junk AtheOS, BeOS or MacOS file attributes */
1528
uO.J_flag = FALSE, negative = 0;
1533
#endif /* ATH_BEO || MACOS */
1537
uO.K_flag = FALSE, negative = 0;
1542
#endif /* ATH_BEO_UNX */
1546
uO.vflag = MAX(uO.vflag-negative,0);
1553
case ('L'): /* convert (some) filenames to lowercase */
1555
uO.L_flag = MAX(uO.L_flag-negative,0);
1560
#endif /* !CMS_MVS */
1565
case ('M'): /* send all screen output through "more" fn. */
1566
/* GRR: eventually check for numerical argument => height */
1568
G.M_flag = FALSE, negative = 0;
1573
case ('n'): /* don't overwrite any files */
1575
uO.overwrite_none = FALSE, negative = 0;
1577
uO.overwrite_none = TRUE;
1580
case ('N'): /* restore comments as filenotes */
1582
uO.N_flag = FALSE, negative = 0;
1587
case ('o'): /* OK to overwrite files without prompting */
1589
uO.overwrite_all = MAX(uO.overwrite_all-negative,0);
1594
case ('p'): /* pipes: extract to stdout, no messages */
1597
uO.qflag = MAX(uO.qflag-999,0);
1605
/* GRR: yes, this is highly insecure, but dozens of people
1606
* have pestered us for this, so here we go... */
1608
if (negative) { /* negative not allowed with -P passwd */
1609
Info(slide, 0x401, ((char *)slide,
1610
LoadFarString(MustGivePasswd)));
1611
return(PK_PARAM); /* don't extract here by accident */
1613
if (uO.pwdarg != (char *)NULL) {
1615
GRR: eventually support multiple passwords?
1616
Info(slide, 0x401, ((char *)slide,
1617
LoadFarString(OnlyOnePasswd)));
1621
/* first check for "-Ppasswd", then for "-P passwd" */
1623
if (*uO.pwdarg == '\0') {
1626
uO.pwdarg = *++argv;
1627
if (*uO.pwdarg == '-') {
1628
Info(slide, 0x401, ((char *)slide,
1629
LoadFarString(MustGivePasswd)));
1632
/* else pwdarg points at decryption password */
1634
Info(slide, 0x401, ((char *)slide,
1635
LoadFarString(MustGivePasswd)));
1639
/* pwdarg now points at decryption password (-Ppasswd or
1640
* -P passwd); point s at end of passwd to avoid mis-
1641
* interpretation of passwd characters as more options
1649
case ('q'): /* quiet: fewer comments/messages */
1651
uO.qflag = MAX(uO.qflag-negative,0);
1657
case ('Q'): /* QDOS flags */
1658
qlflag ^= strtol(s, &s, 10);
1659
break; /* we XOR this as we can config qlflags */
1662
case ('r'): /* remove file extensions */
1664
uO.rflag = FALSE, negative = 0;
1669
#ifdef DOS_FLX_NLM_OS2_W32
1670
case ('s'): /* spaces in filenames: allow by default */
1672
uO.sflag = FALSE, negative = 0;
1676
#endif /* DOS_FLX_NLM_OS2_W32 */
1678
/* VMS: extract "text" files in Stream_LF format (-a[a]) */
1681
uO.S_flag = FALSE, negative = 0;
1688
uO.tflag = FALSE, negative = 0;
1695
uO.T_flag = FALSE, negative = 0;
1700
case ('u'): /* update (extract only new and newer files) */
1702
uO.uflag = FALSE, negative = 0;
1706
#ifdef UNICODE_SUPPORT
1707
case ('U'): /* escape UTF-8, or disable UTF-8 support */
1709
uO.U_flag = MAX(uO.U_flag-negative,0);
1714
#else /* !UNICODE_SUPPORT */
1716
case ('U'): /* obsolete; to be removed in version 6.0 */
1718
uO.L_flag = TRUE, negative = 0;
1722
#endif /* !CMS_MVS */
1723
#endif /* ?UNICODE_SUPPORT */
1725
case ('v'): /* verbose */
1727
uO.vflag = MAX(uO.vflag-negative,0);
1729
} else if (uO.vflag)
1736
case ('V'): /* Version (retain VMS/DEC-20 file versions) */
1738
uO.V_flag = FALSE, negative = 0;
1742
#endif /* !CMS_MVS */
1743
#ifdef WILD_STOP_AT_DIR
1744
case ('W'): /* Wildcard interpretation (stop at '/'?) */
1746
uO.W_flag = FALSE, negative = 0;
1750
#endif /* WILD_STOP_AT_DIR */
1751
case ('x'): /* extract: default */
1753
/* when 'x' is the only option in this argument, and the
1754
* next arg is not an option, assume this initiates an
1755
* exclusion list (-x xlist): terminate option-scanning
1756
* and leave uz_opts with argv still pointing to "-x";
1757
* the xlist is processed later
1759
if (s - argv[0] == 2 && *s == '\0' &&
1760
argc > 1 && argv[1][0] != '-') {
1761
/* break out of nested loops without "++argv;--argc" */
1766
#if (defined(RESTORE_UIDGID) || defined(RESTORE_ACL))
1767
case ('X'): /* restore owner/protection info (need privs?) */
1769
uO.X_flag = MAX(uO.X_flag-negative,0);
1774
#endif /* RESTORE_UIDGID || RESTORE_ACL */
1776
case ('Y'): /* Treat ".nnn" as ";nnn" version. */
1778
uO.Y_flag = FALSE, negative = 0;
1783
case ('z'): /* display only the archive comment */
1785
uO.zflag = MAX(uO.zflag-negative,0);
1791
case ('Z'): /* should have been first option (ZipInfo) */
1792
Info(slide, 0x401, ((char *)slide, LoadFarString(Zfirst)));
1797
case ('2'): /* Force ODS2-compliant names. */
1799
uO.ods2_flag = FALSE, negative = 0;
1801
uO.ods2_flag = TRUE;
1804
#ifdef DOS_H68_OS2_W32
1807
uO.volflag = MAX(uO.volflag-negative,0);
1812
#endif /* DOS_H68_OS2_W32 */
1813
#if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
1814
case (':'): /* allow "parent dir" path components */
1816
uO.ddotflag = MAX(uO.ddotflag-negative,0);
1821
#endif /* !RISCOS && !CMS_MVS && !TANDEM */
1823
case ('^'): /* allow control chars in filenames */
1825
uO.cflxflag = MAX(uO.cflxflag-negative,0);
1836
} /* end while (not end of argument string) */
1837
} /* end while (not done with switches) */
1839
/*---------------------------------------------------------------------------
1840
Check for nonsensical combinations of options.
1841
---------------------------------------------------------------------------*/
1844
opts_done: /* yes, very ugly...but only used by UnZipSFX with -x xlist */
1847
if (showhelp > 0) { /* just print help message and quit */
1850
if (showhelp == 2) {
1856
return USAGE(PK_OK);
1860
if ((uO.cflag && (uO.tflag || uO.uflag)) ||
1861
(uO.tflag && uO.uflag) || (uO.fflag && uO.overwrite_none))
1863
Info(slide, 0x401, ((char *)slide, LoadFarString(InvalidOptionsMsg)));
1871
/* Clear -s flag when converting text files. */
1875
if (uO.overwrite_all && uO.overwrite_none) {
1876
Info(slide, 0x401, ((char *)slide, LoadFarString(IgnoreOOptionMsg)));
1877
uO.overwrite_all = FALSE;
1880
if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func. useless */
1887
if ((argc-- == 0) || error)
1893
if (uO.vflag >= 2 && argc == -1) { /* "unzip -v" */
1894
show_version_info(__G);
1897
if (!G.noargs && !error)
1898
error = TRUE; /* had options (not -h or -v) but no zipfile */
1900
return USAGE(error);
1904
/* print our banner unless we're being fairly quiet */
1906
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
1907
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
1908
LoadFarStringSmall(VersionDate)));
1910
/* always print the beta warning: no unauthorized distribution!! */
1911
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
1916
if (uO.cflag || uO.tflag || uO.vflag || uO.zflag
1921
G.extract_flag = FALSE;
1923
G.extract_flag = TRUE;
1929
} /* end function uz_opts() */
1934
/********************/
1935
/* Function usage() */
1936
/********************/
1940
# define LOCAL "X.\n\
1941
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)"
1949
# if (defined(FLEXOS) || defined(NLM))
1955
/* Default for all other systems: */
1960
# ifndef NO_TIMESTAMP
1962
# define SFXOPT1 "DM"
1964
# define SFXOPT1 "D"
1968
# define SFXOPT1 "M"
1974
int usage(__G__ error) /* return PK-type error code */
1978
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
1979
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
1980
LoadFarStringSmall(VersionDate)));
1981
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXOpts),
1984
Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
1991
return PK_COOL; /* just wanted usage screen: no error */
1993
} /* end function usage() */
2008
int usage(__G__ error) /* return PK-type error code */
2012
int flag = (error? 1 : 0);
2015
/*---------------------------------------------------------------------------
2016
Print either ZipInfo usage or UnZip usage, depending on incantation.
2017
(Strings must be no longer than 512 bytes for Turbo C, apparently.)
2018
---------------------------------------------------------------------------*/
2020
if (uO.zipinfo_mode) {
2024
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine1),
2025
ZI_MAJORVER, ZI_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
2026
LoadFarStringSmall(VersionDate),
2027
LoadFarStringSmall2(ZipInfoExample), QUOTS,QUOTS));
2028
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine2)));
2029
Info(slide, flag, ((char *)slide, LoadFarString(ZipInfoUsageLine3),
2030
LoadFarStringSmall(ZipInfoUsageLine4)));
2032
Info(slide, flag, ((char *)slide, "\n\
2033
You must quote non-lowercase options and filespecs, unless SET PROC/PARSE=EXT.\
2037
#endif /* !NO_ZIPINFO */
2039
} else { /* UnZip mode */
2041
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine1),
2042
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
2043
LoadFarStringSmall(VersionDate)));
2045
Info(slide, flag, ((char *)slide, LoadFarString(BetaVersion), "", ""));
2048
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine2),
2049
ZIPINFO_MODE_OPTION, LoadFarStringSmall(ZipInfoMode)));
2051
if (!error) /* maybe no command-line tail found; show extra help */
2052
Info(slide, flag, ((char *)slide, LoadFarString(VMSusageLine2b)));
2055
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine3),
2056
LoadFarStringSmall(local1)));
2058
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine4),
2059
LoadFarStringSmall(local2), LoadFarStringSmall2(local3)));
2061
/* This is extra work for SMALL_MEM, but it will work since
2062
* LoadFarStringSmall2 uses the same buffer. Remember, this
2064
Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine5),
2065
LoadFarStringSmall(Example2), LoadFarStringSmall2(Example3),
2066
LoadFarStringSmall2(Example3)));
2068
} /* end if (uO.zipinfo_mode) */
2073
return PK_COOL; /* just wanted usage screen: no error */
2075
} /* end function usage() */
2084
/* Print extended help to stdout. */
2085
static void help_extended(__G)
2088
extent i; /* counter for help array */
2091
static ZCONST char *text[] = {
2093
"Extended Help for UnZip",
2095
"See the UnZip Manual for more detailed help",
2098
"UnZip lists and extracts files in zip archives. The default action is to",
2099
"extract zipfile entries to the current directory, creating directories as",
2100
"needed. With appropriate options, UnZip lists the contents of archives",
2103
"Basic unzip command line:",
2104
" unzip [-Z] options archive[.zip] [file ...] [-x xfile ...] [-d exdir]",
2107
" unzip -l foo.zip - list files in short format in archive foo.zip",
2109
" unzip -t foo - test the files in archive foo",
2111
" unzip -Z foo - list files using more detailed zipinfo format",
2113
" unzip foo - unzip the contents of foo in current dir",
2115
" unzip -a foo - unzip foo and convert text files to local OS",
2117
"If unzip is run in zipinfo mode, a more detailed list of archive contents",
2118
"is provided. The -Z option sets zipinfo mode and changes the available",
2121
"Basic zipinfo command line:",
2122
" zipinfo options archive[.zip] [file ...] [-x xfile ...]",
2123
" unzip -Z options archive[.zip] [file ...] [-x xfile ...]",
2125
"Below, Mac OS refers to Mac OS before Mac OS X. Mac OS X is a Unix based",
2126
"port and is referred to as Unix Apple.",
2130
" -Z Switch to zipinfo mode. Must be first option.",
2131
" -hh Display extended help.",
2132
" -A [OS/2, Unix DLL] Print extended help for DLL.",
2133
" -c Extract files to stdout/screen. As -p but include names. Also,",
2134
" -a allowed and EBCDIC conversions done if needed.",
2135
" -f Freshen by extracting only if older file on disk.",
2136
" -l List files using short form.",
2137
" -p Extract files to pipe (stdout). Only file data is output and all",
2138
" files extracted in binary mode (as stored).",
2139
" -t Test archive files.",
2140
" -T Set timestamp on archive(s) to that of newest file. Similar to",
2141
" zip -o but faster.",
2142
" -u Update existing older files on disk as -f and extract new files.",
2143
" -v Use verbose list format. If given alone as unzip -v show version",
2144
" information. Also can be added to other list commands for more",
2146
" -z Display only archive comment.",
2149
" -a Convert text files to local OS format. Convert line ends, EOF",
2150
" marker, and from or to EBCDIC character set as needed.",
2151
" -b Treat all files as binary. [Tandem] Force filecode 180 ('C').",
2152
" [VMS] Autoconvert binary files. -bb forces convert of all files.",
2153
" -B [UNIXBACKUP compile option enabled] Save a backup copy of each",
2154
" overwritten file in foo~ or foo~99999 format.",
2155
" -C Use case-insensitive matching.",
2156
" -D Skip restoration of timestamps for extracted directories. On VMS this",
2157
" is on by default and -D essentially becames -DD.",
2158
" -DD Skip restoration of timestamps for all entries.",
2159
" -E [MacOS (not Unix Apple)] Display contents of MacOS extra field during",
2161
" -F [Acorn] Suppress removal of NFS filetype extension. [Non-Acorn if",
2162
" ACORN_FTYPE_NFS] Translate filetype and append to name.",
2163
" -i [MacOS] Ignore filenames in MacOS extra field. Instead, use name in",
2164
" standard header.",
2165
" -j Junk paths and deposit all files in extraction directory.",
2166
" -J [BeOS] Junk file attributes. [MacOS] Ignore MacOS specific info.",
2167
" -K [AtheOS, BeOS, Unix] Restore SUID/SGID/Tacky file attributes.",
2168
" -L Convert to lowercase any names from uppercase only file system.",
2169
" -LL Convert all files to lowercase.",
2170
" -M Pipe all output through internal pager similar to Unix more(1).",
2171
" -n Never overwrite existing files. Skip extracting that file, no prompt.",
2172
" -N [Amiga] Extract file comments as Amiga filenotes.",
2173
" -o Overwrite existing files without prompting. Useful with -f. Use with",
2175
" -P p Use password p to decrypt files. THIS IS INSECURE! Some OS show",
2176
" command line to other users.",
2177
" -q Perform operations quietly. The more q (as in -qq) the quieter.",
2178
" -s [OS/2, NT, MS-DOS] Convert spaces in filenames to underscores.",
2179
" -S [VMS] Convert text files (-a, -aa) into Stream_LF format.",
2180
" -U [UNICODE enabled] Show non-local characters as #Uxxxx or #Lxxxxxx ASCII",
2181
" text escapes where x is hex digit. [Old] -U used to leave names",
2182
" uppercase if created on MS-DOS, VMS, etc. See -L.",
2183
" -UU [UNICODE enabled] Disable use of stored UTF-8 paths. Note that UTF-8",
2184
" paths stored as native local paths are still processed as Unicode.",
2185
" -V Retain VMS file version numbers.",
2186
" -W [Only if WILD_STOP_AT_DIR] Modify pattern matching so ? and * do not",
2187
" match directory separator /, but ** does. Allows matching at specific",
2188
" directory levels.",
2189
" -X [VMS, Unix, OS/2, NT, Tandem] Restore UICs and ACL entries under VMS,",
2190
" or UIDs/GIDs under Unix, or ACLs under certain network-enabled",
2191
" versions of OS/2, or security ACLs under Windows NT. Can require",
2192
" user privileges.",
2193
" -XX [NT] Extract NT security ACLs after trying to enable additional",
2194
" system privileges.",
2195
" -Y [VMS] Treat archived name endings of .nnn as VMS version numbers.",
2196
" -$ [MS-DOS, OS/2, NT] Restore volume label if extraction medium is",
2197
" removable. -$$ allows fixed media (hard drives) to be labeled.",
2198
" -/ e [Acorn] Use e as extension list.",
2199
" -: [All but Acorn, VM/CMS, MVS, Tandem] Allow extract archive members into",
2200
" locations outside of current extraction root folder. This allows",
2201
" paths such as ../foo to be extracted above the current extraction",
2202
" directory, which can be a security problem.",
2203
" -^ [Unix] Allow control characters in names of extracted entries. Usually",
2204
" this is not a good thing and should be avoided.",
2205
" -2 [VMS] Force unconditional conversion of names to ODS-compatible names.",
2206
" Default is to exploit destination file system, preserving cases and",
2207
" extended name characters on ODS5 and applying ODS2 filtering on ODS2.",
2211
" Internally unzip supports the following wildcards:",
2212
" ? (or %% or #, depending on OS) matches any single character",
2213
" * matches any number of characters, including zero",
2214
" [list] matches char in list (regex), can do range [ac-f], all but [!bf]",
2215
" If port supports [], must escape [ as [[]",
2216
" For shells that expand wildcards, escape (\\* or \"*\") so unzip can recurse.",
2218
"Include and Exclude:",
2219
" -i pattern pattern ... include files that match a pattern",
2220
" -x pattern pattern ... exclude files that match a pattern",
2221
" Patterns are paths with optional wildcards and match paths as stored in",
2222
" archive. Exclude and include lists end at next option or end of line.",
2223
" unzip archive -x pattern pattern ...",
2225
"Multi-part (split) archives (archives created as a set of split files):",
2226
" Currently split archives are not readable by unzip. A workaround is",
2227
" to use zip to convert the split archive to a single-file archive and",
2228
" use unzip on that. See the manual page for Zip 3.0 or later.",
2230
"Streaming (piping into unzip):",
2231
" Currently unzip does not support streaming. The funzip utility can be",
2232
" used to process the first entry in a stream.",
2233
" cat archive | funzip",
2235
"Testing archives:",
2236
" -t test contents of archive",
2237
" This can be modified using -q for quieter operation, and -qq for even",
2238
" quieter operation.",
2241
" If compiled with Unicode support, unzip automatically handles archives",
2242
" with Unicode entries. Currently Unicode on Win32 systems is limited.",
2243
" Characters not in the current character set are shown as ASCII escapes",
2244
" in the form #Uxxxx where the Unicode character number fits in 16 bits,",
2245
" or #Lxxxxxx where it doesn't, where x is the ASCII character for a hex",
2249
"zipinfo options (these are used in zipinfo mode (unzip -Z ...)):",
2250
" -1 List names only, one per line. No headers/trailers. Good for scripts.",
2251
" -2 List names only as -1, but include headers, trailers, and comments.",
2252
" -s List archive entries in short Unix ls -l format. Default list format.",
2253
" -m List in long Unix ls -l format. As -s, but includes compression %.",
2254
" -l List in long Unix ls -l format. As -m, but compression in bytes.",
2255
" -v List zipfile information in verbose, multi-page format.",
2256
" -h List header line. Includes archive name, actual size, total files.",
2257
" -M Pipe all output through internal pager similar to Unix more(1) command.",
2258
" -t List totals for files listed or for all files. Includes uncompressed",
2259
" and compressed sizes, and compression factors.",
2260
" -T Print file dates and times in a sortable decimal format (yymmdd.hhmmss)",
2261
" Default date and time format is a more human-readable version.",
2262
" -U [UNICODE] If entry has a UTF-8 Unicode path, display any characters",
2263
" not in current character set as text #Uxxxx and #Lxxxxxx escapes",
2264
" representing the Unicode character number of the character in hex.",
2265
" -UU [UNICODE] Disable use of any UTF-8 path information.",
2266
" -z Include archive comment if any in listing.",
2269
"funzip stream extractor:",
2270
" funzip extracts the first member in an archive to stdout. Typically",
2271
" used to unzip the first member of a stream or pipe. If a file argument",
2272
" is given, read from that file instead of stdin.",
2274
"funzip command line:",
2275
" funzip [-password] [input[.zip|.gz]]",
2278
"unzipsfx self extractor:",
2279
" Self-extracting archives made with unzipsfx are no more (or less)",
2280
" portable across different operating systems than unzip executables.",
2281
" In general, a self-extracting archive made on a particular Unix system,",
2282
" for example, will only self-extract under the same flavor of Unix.",
2283
" Regular unzip may still be used to extract embedded archive however.",
2285
"unzipsfx command line:",
2286
" <unzipsfx+archive_filename> [-options] [file(s) ... [-x xfile(s) ...]]",
2288
"unzipsfx options:",
2289
" -c, -p - Output to pipe. (See above for unzip.)",
2290
" -f, -u - Freshen and Update, as for unzip.",
2291
" -t - Test embedded archive. (Can be used to list contents.)",
2292
" -z - Print archive comment. (See unzip above.)",
2294
"unzipsfx modifiers:",
2295
" Most unzip modifiers are supported. These include",
2296
" -a - Convert text files.",
2297
" -n - Never overwrite.",
2298
" -o - Overwrite without prompting.",
2299
" -q - Quiet operation.",
2300
" -C - Match names case-insensitively.",
2301
" -j - Junk paths.",
2302
" -V - Keep version numbers.",
2303
" -s - Convert spaces to underscores.",
2304
" -$ - Restore volume label.",
2306
"If unzipsfx compiled with SFX_EXDIR defined, -d option also available:",
2307
" -d exd - Extract to directory exd.",
2308
"By default, all files extracted to current directory. This option",
2309
"forces extraction to specified directory.",
2311
"See unzipsfx manual page for more information.",
2315
for (i = 0; i < sizeof(text)/sizeof(char *); i++)
2317
Info(slide, 0, ((char *)slide, "%s\n", text[i]));
2319
} /* end function help_extended() */
2324
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
2325
#if (!defined(MODERN) || defined(NO_STDLIB_H))
2326
/* Declare getenv() to be sure (might be missing in some environments) */
2327
extern char *getenv();
2331
/********************************/
2332
/* Function show_version_info() */
2333
/********************************/
2335
static void show_version_info(__G)
2338
if (uO.qflag > 3) /* "unzip -vqqqq" */
2339
Info(slide, 0, ((char *)slide, "%d\n",
2340
(UZ_MAJORVER*100 + UZ_MINORVER*10 + UZ_PATCHLEVEL)));
2342
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
2347
Info(slide, 0, ((char *)slide, LoadFarString(UnzipUsageLine1v),
2348
UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
2349
LoadFarStringSmall(VersionDate)));
2350
Info(slide, 0, ((char *)slide,
2351
LoadFarString(UnzipUsageLine2v)));
2353
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptions)));
2354
#ifdef ACORN_FTYPE_NFS
2355
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2356
LoadFarStringSmall(AcornFtypeNFS)));
2360
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2361
LoadFarStringSmall(AsmCRC)));
2364
#ifdef ASM_INFLATECODES
2365
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2366
LoadFarStringSmall(AsmInflateCodes)));
2369
#ifdef CHECK_VERSIONS
2370
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2371
LoadFarStringSmall(Check_Versions)));
2374
#ifdef COPYRIGHT_CLEAN
2375
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2376
LoadFarStringSmall(Copyright_Clean)));
2380
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2381
LoadFarStringSmall(UDebug)));
2385
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2386
LoadFarStringSmall(DebugTime)));
2390
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2391
LoadFarStringSmall(Dll)));
2395
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2396
LoadFarStringSmall(DosWild)));
2400
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2401
LoadFarStringSmall(LZW_Clean)));
2405
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2406
LoadFarStringSmall(No_More)));
2410
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2411
LoadFarStringSmall(No_ZipInfo)));
2415
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2416
LoadFarStringSmall(NTSDExtAttrib)));
2419
#if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
2420
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2421
LoadFarStringSmall(W32NoIZTimeFix)));
2424
#ifdef OLD_THEOS_EXTRA
2425
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2426
LoadFarStringSmall(OldTheosExtra)));
2430
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2431
LoadFarStringSmall(OS2ExtAttrib)));
2435
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2436
LoadFarStringSmall(SMSExFldOnUnix)));
2440
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2441
LoadFarStringSmall(Reentrant)));
2445
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2446
LoadFarStringSmall(RegArgs)));
2450
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2451
LoadFarStringSmall(Return_Codes)));
2454
#ifdef SET_DIR_ATTRIB
2455
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2456
LoadFarStringSmall(SetDirAttrib)));
2460
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2461
LoadFarStringSmall(SymLinkSupport)));
2465
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2466
LoadFarStringSmall(TimeStamp)));
2470
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2471
LoadFarStringSmall(UnixBackup)));
2474
#ifdef USE_EF_UT_TIME
2475
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2476
LoadFarStringSmall(Use_EF_UT_time)));
2479
#ifndef COPYRIGHT_CLEAN
2480
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2481
LoadFarStringSmall(Use_Smith_Code)));
2485
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2486
LoadFarStringSmall(Use_Unshrink)));
2489
#ifdef USE_DEFLATE64
2490
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2491
LoadFarStringSmall(Use_Deflate64)));
2494
#ifdef UNICODE_SUPPORT
2495
# ifdef UTF8_MAYBE_NATIVE
2496
sprintf((char *)(slide+256), LoadFarStringSmall(Use_Unicode),
2497
LoadFarStringSmall2(G.native_is_utf8 ? SysChUTF8 : SysChOther));
2498
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2499
(char *)(slide+256)));
2501
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2502
LoadFarStringSmall(Use_Unicode)));
2507
sprintf((char *)(slide+256), LoadFarStringSmall(Have_MBCS_Support),
2508
(unsigned int)MB_CUR_MAX);
2509
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2510
(char *)(slide+256)));
2514
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2515
LoadFarStringSmall(Use_MultiVol)));
2518
#ifdef LARGE_FILE_SUPPORT
2519
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2520
LoadFarStringSmall(Use_LFS)));
2523
#ifdef ZIP64_SUPPORT
2524
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2525
LoadFarStringSmall(Use_Zip64)));
2528
#if (defined(__DJGPP__) && (__DJGPP__ >= 2))
2529
# ifdef USE_DJGPP_ENV
2530
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2531
LoadFarStringSmall(Use_DJGPP_Env)));
2534
# ifdef USE_DJGPP_GLOB
2535
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2536
LoadFarStringSmall(Use_DJGPP_Glob)));
2539
#endif /* __DJGPP__ && (__DJGPP__ >= 2) */
2541
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2542
LoadFarStringSmall(Use_VFAT_support)));
2546
sprintf((char *)(slide+256), LoadFarStringSmall(UseZlib),
2547
ZLIB_VERSION, zlibVersion());
2548
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2549
(char *)(slide+256)));
2553
sprintf((char *)(slide+256), LoadFarStringSmall(UseBZip2),
2554
BZ2_bzlibVersion());
2555
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2556
(char *)(slide+256)));
2559
#ifdef VMS_TEXT_CONV
2560
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2561
LoadFarStringSmall(VmsTextConv)));
2565
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2566
LoadFarStringSmall(VmsCLI)));
2570
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2571
LoadFarStringSmall(VmsWild)));
2574
#ifdef WILD_STOP_AT_DIR
2575
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2576
LoadFarStringSmall(WildStopAtDir)));
2580
# ifdef PASSWD_FROM_STDIN
2581
Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
2582
LoadFarStringSmall(PasswdStdin)));
2584
Info(slide, 0, ((char *)slide, LoadFarString(Decryption),
2585
CR_MAJORVER, CR_MINORVER, CR_BETA_VER,
2586
LoadFarStringSmall(CryptDate)));
2590
Info(slide, 0, ((char *)slide,
2591
LoadFarString(CompileOptFormat),
2592
LoadFarStringSmall(None)));
2594
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
2595
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptions)));
2596
envptr = getenv(LoadFarStringSmall(EnvUnZip));
2597
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2598
LoadFarStringSmall(EnvUnZip),
2599
(envptr == (char *)NULL || *envptr == 0)?
2600
LoadFarStringSmall2(None) : envptr));
2601
envptr = getenv(LoadFarStringSmall(EnvUnZip2));
2602
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2603
LoadFarStringSmall(EnvUnZip2),
2604
(envptr == (char *)NULL || *envptr == 0)?
2605
LoadFarStringSmall2(None) : envptr));
2606
envptr = getenv(LoadFarStringSmall(EnvZipInfo));
2607
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2608
LoadFarStringSmall(EnvZipInfo),
2609
(envptr == (char *)NULL || *envptr == 0)?
2610
LoadFarStringSmall2(None) : envptr));
2611
envptr = getenv(LoadFarStringSmall(EnvZipInfo2));
2612
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2613
LoadFarStringSmall(EnvZipInfo2),
2614
(envptr == (char *)NULL || *envptr == 0)?
2615
LoadFarStringSmall2(None) : envptr));
2618
envptr = getenv(LoadFarStringSmall(EnvEMX));
2619
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2620
LoadFarStringSmall(EnvEMX),
2621
(envptr == (char *)NULL || *envptr == 0)?
2622
LoadFarStringSmall2(None) : envptr));
2623
envptr = getenv(LoadFarStringSmall(EnvEMXOPT));
2624
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2625
LoadFarStringSmall(EnvEMXOPT),
2626
(envptr == (char *)NULL || *envptr == 0)?
2627
LoadFarStringSmall2(None) : envptr));
2628
#endif /* __EMX__ */
2629
#if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
2630
envptr = getenv(LoadFarStringSmall(EnvGO32));
2631
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2632
LoadFarStringSmall(EnvGO32),
2633
(envptr == (char *)NULL || *envptr == 0)?
2634
LoadFarStringSmall2(None) : envptr));
2635
envptr = getenv(LoadFarStringSmall(EnvGO32TMP));
2636
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2637
LoadFarStringSmall(EnvGO32TMP),
2638
(envptr == (char *)NULL || *envptr == 0)?
2639
LoadFarStringSmall2(None) : envptr));
2640
#endif /* __GO32__ && !(__DJGPP__ >= 2) */
2641
#endif /* !__RSXNT__ */
2643
envptr = getenv(LoadFarStringSmall(EnvUnZipExts));
2644
Info(slide, 0, ((char *)slide, LoadFarString(EnvOptFormat),
2645
LoadFarStringSmall(EnvUnZipExts),
2646
(envptr == (char *)NULL || *envptr == 0)?
2647
LoadFarStringSmall2(None) : envptr));
2649
#endif /* !_WIN32_WCE */
2651
} /* end function show_version() */
2654
#endif /* !WINDLL */