~ubuntu-branches/ubuntu/raring/unzip/raring

« back to all changes in this revision

Viewing changes to .pc/05-unzip60-alt-iconv-utf8/unzip.c

  • Committer: Package Import Robot
  • Author(s): Logan Rosen
  • Date: 2012-08-05 21:31:45 UTC
  • mfrom: (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20120805213145-yjn97p3843amjk91
Tags: 6.0-7ubuntu1
* Merge from Debian unstable. Remaining change:
  - Added patch from archlinux which adds the -O option allowing a charset
  to be specified for the proper unzipping of non-latin and non-unicode
  filenames.
* Merge adds Multi-Arch: foreign. (LP: #1010450)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 1990-2009 Info-ZIP.  All rights reserved.
 
3
 
 
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
 
8
*/
 
9
/*---------------------------------------------------------------------------
 
10
 
 
11
  unzip.c
 
12
 
 
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.
 
19
 
 
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
 
24
  distribution.
 
25
 
 
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.
 
29
 
 
30
  ---------------------------------------------------------------------------
 
31
 
 
32
  [from original zipinfo.c]
 
33
 
 
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.
 
40
 
 
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".
 
46
 
 
47
  Another dandy product from your buddies at Newtware!
 
48
 
 
49
  Author:  Greg Roelofs, newt@pobox.com, http://pobox.com/~newt/
 
50
           23 August 1990 -> April 1997
 
51
 
 
52
  ---------------------------------------------------------------------------
 
53
 
 
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
 
57
              and TOPS-20.
 
58
 
 
59
  Copyrights:  see accompanying file "LICENSE" in UnZip source distribution.
 
60
               (This software is free but NOT IN THE PUBLIC DOMAIN.)
 
61
 
 
62
  ---------------------------------------------------------------------------*/
 
63
 
 
64
 
 
65
 
 
66
#define __UNZIP_C       /* identifies this source module */
 
67
#define UNZIP_INTERNAL
 
68
#include "unzip.h"      /* includes, typedefs, macros, prototypes, etc. */
 
69
#include "crypt.h"
 
70
#include "unzvers.h"
 
71
 
 
72
#ifndef WINDLL          /* The WINDLL port uses windll/windll.c instead... */
 
73
 
 
74
/***************************/
 
75
/* Local type declarations */
 
76
/***************************/
 
77
 
 
78
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
 
79
typedef struct _sign_info
 
80
    {
 
81
        struct _sign_info *previous;
 
82
        void (*sighandler)(int);
 
83
        int sigtype;
 
84
    } savsigs_info;
 
85
#endif
 
86
 
 
87
/*******************/
 
88
/* Local Functions */
 
89
/*******************/
 
90
 
 
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)));
 
94
#endif
 
95
#ifndef SFX
 
96
static void  help_extended      OF((__GPRO));
 
97
static void  show_version_info  OF((__GPRO));
 
98
#endif
 
99
 
 
100
 
 
101
/*************/
 
102
/* Constants */
 
103
/*************/
 
104
 
 
105
#include "consts.h"  /* all constant global variables are in here */
 
106
                     /* (non-constant globals were moved to globals.c) */
 
107
 
 
108
/* constant local variables: */
 
109
 
 
110
#ifndef SFX
 
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;
 
116
#ifdef RISCOS
 
117
   static ZCONST char Far EnvUnZipExts[] = ENV_UNZIPEXTS;
 
118
#endif /* RISCOS */
 
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";
 
124
#endif /* !SFX */
 
125
 
 
126
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
 
127
  static ZCONST char Far CantSaveSigHandler[] =
 
128
    "error:  cannot save signal handler settings\n";
 
129
#endif
 
130
 
 
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";
 
138
#endif
 
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";
 
142
#endif
 
143
 
 
144
#if CRYPT
 
145
   static ZCONST char Far MustGivePasswd[] =
 
146
     "error:  must give decryption password with -P option\n";
 
147
#endif
 
148
 
 
149
#ifndef SFX
 
150
   static ZCONST char Far Zfirst[] =
 
151
   "error:  -Z must be first option for ZipInfo mode (check UNZIP variable?)\n";
 
152
#endif
 
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";
 
157
 
 
158
/* usage() strings */
 
159
#ifndef SFX
 
160
#ifdef VMS
 
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";
 
164
#else /* !VMS */
 
165
   static ZCONST char Far Example3[] = "ReadMe";
 
166
#ifdef RISCOS
 
167
   static ZCONST char Far Example2[] =
 
168
"  unzip foo -d RAM:$   => extract all files from foo into RAMDisc\n";
 
169
#else /* !RISCOS */
 
170
#if (defined(OS2) || (defined(DOS_FLX_OS2_W32) && defined(MORE)))
 
171
   static ZCONST char Far Example2[] =
 
172
     "";                /* no room:  too many local3[] items */
 
173
#else /* !OS2 */
 
174
#ifdef MACOS
 
175
   static ZCONST char Far Example2[] = ""; /* not needed */
 
176
#else /* !MACOS */
 
177
   static ZCONST char Far Example2[] = " \
 
178
 unzip -p foo | more  => send contents of foo.zip via pipe into program more\n";
 
179
#endif /* ?MACOS */
 
180
#endif /* ?OS2 */
 
181
#endif /* ?RISCOS */
 
182
#endif /* ?VMS */
 
183
 
 
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 */
 
191
 
 
192
/* local2[] and local3[]:  modifier options */
 
193
#ifdef DOS_FLX_H68_OS2_W32
 
194
#ifdef FLEXOS
 
195
   static ZCONST char Far local2[] = "";
 
196
#else
 
197
   static ZCONST char Far local2[] =
 
198
     " -$  label removables (-$$ => fixed disks)";
 
199
#endif
 
200
#ifdef OS2
 
201
#ifdef MORE
 
202
   static ZCONST char Far local3[] = "\
 
203
  -X  restore ACLs if supported              -s  spaces in filenames => '_'\n\
 
204
                                             -M  pipe through \"more\" pager\n";
 
205
#else
 
206
   static ZCONST char Far local3[] = " \
 
207
 -X  restore ACLs if supported              -s  spaces in filenames => '_'\n\n";
 
208
#endif /* ?MORE */
 
209
#else /* !OS2 */
 
210
#ifdef WIN32
 
211
#ifdef NTSD_EAS
 
212
#ifdef MORE
 
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";
 
216
#else
 
217
   static ZCONST char Far local3[] = " \
 
218
 -X  restore ACLs (-XX => use privileges)   -s  spaces in filenames => '_'\n\n";
 
219
#endif /* ?MORE */
 
220
#else /* !NTSD_EAS */
 
221
#ifdef MORE
 
222
   static ZCONST char Far local3[] = "\
 
223
  -M  pipe through \"more\" pager            \
 
224
  -s  spaces in filenames => '_'\n\n";
 
225
#else
 
226
   static ZCONST char Far local3[] = " \
 
227
                                            -s  spaces in filenames => '_'\n\n";
 
228
#endif /* ?MORE */
 
229
#endif /* ?NTSD_EAS */
 
230
#else /* !WIN32 */
 
231
#ifdef MORE
 
232
   static ZCONST char Far local3[] = "  -\
 
233
M  pipe through \"more\" pager              -s  spaces in filenames => '_'\n\n";
 
234
#else
 
235
   static ZCONST char Far local3[] = "\
 
236
                                             -s  spaces in filenames => '_'\n";
 
237
#endif
 
238
#endif /* ?WIN32 */
 
239
#endif /* ?OS2 || ?WIN32 */
 
240
#else /* !DOS_FLX_OS2_W32 */
 
241
#ifdef VMS
 
242
   static ZCONST char Far local2[] = " -X  restore owner/ACL protection info";
 
243
#ifdef MORE
 
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.)\
 
248
\n\n";
 
249
#else
 
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.)\
 
254
\n\n";
 
255
#endif
 
256
#else /* !VMS */
 
257
#ifdef ATH_BEO_UNX
 
258
   static ZCONST char Far local2[] = " -X  restore UID/GID info";
 
259
#ifdef MORE
 
260
   static ZCONST char Far local3[] = "\
 
261
  -K  keep setuid/setgid/tacky permissions   -M  pipe through \"more\" pager\n";
 
262
#else
 
263
   static ZCONST char Far local3[] = "\
 
264
  -K  keep setuid/setgid/tacky permissions\n";
 
265
#endif
 
266
#else /* !ATH_BEO_UNX */
 
267
#ifdef TANDEM
 
268
   static ZCONST char Far local2[] = "\
 
269
 -X  restore Tandem User ID                 -r  remove file extensions\n\
 
270
  -b  create 'C' (180) text files          ";
 
271
#ifdef MORE
 
272
   static ZCONST char Far local3[] = " \
 
273
                                            -M  pipe through \"more\" pager\n";
 
274
#else
 
275
   static ZCONST char Far local3[] = "\n";
 
276
#endif
 
277
#else /* !TANDEM */
 
278
#ifdef AMIGA
 
279
   static ZCONST char Far local2[] = " -N  restore comments as filenotes";
 
280
#ifdef MORE
 
281
   static ZCONST char Far local3[] = " \
 
282
                                            -M  pipe through \"more\" pager\n";
 
283
#else
 
284
   static ZCONST char Far local3[] = "\n";
 
285
#endif
 
286
#else /* !AMIGA */
 
287
#ifdef MACOS
 
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\
 
291
\n";
 
292
#else /* !MACOS */
 
293
#ifdef MORE
 
294
   static ZCONST char Far local2[] = " -M  pipe through \"more\" pager";
 
295
   static ZCONST char Far local3[] = "\n";
 
296
#else
 
297
   static ZCONST char Far local2[] = "";   /* Atari, Mac, CMS/MVS etc. */
 
298
   static ZCONST char Far local3[] = "";
 
299
#endif
 
300
#endif /* ?MACOS */
 
301
#endif /* ?AMIGA */
 
302
#endif /* ?TANDEM */
 
303
#endif /* ?ATH_BEO_UNX */
 
304
#endif /* ?VMS */
 
305
#endif /* ?DOS_FLX_OS2_W32 */
 
306
#endif /* !SFX */
 
307
 
 
308
#ifndef NO_ZIPINFO
 
309
#ifdef VMS
 
310
   static ZCONST char Far ZipInfoExample[] = "* or % (e.g., \"*font-%.zip\")";
 
311
#else
 
312
   static ZCONST char Far ZipInfoExample[] = "*, ?, [] (e.g., \"[a-j]*.zip\")";
 
313
#endif
 
314
 
 
315
static ZCONST char Far ZipInfoUsageLine1[] = "\
 
316
ZipInfo %d.%d%d%s of %s, by Greg Roelofs and the Info-ZIP group.\n\
 
317
\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";
 
323
 
 
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";
 
329
 
 
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";
 
335
#ifdef MORE
 
336
   static ZCONST char Far ZipInfoUsageLine4[] =
 
337
     "  -M  page output through built-in \"more\"\n";
 
338
#else /* !MORE */
 
339
   static ZCONST char Far ZipInfoUsageLine4[] = "";
 
340
#endif /* ?MORE */
 
341
#endif /* !NO_ZIPINFO */
 
342
 
 
343
#ifdef BETA
 
344
#  ifdef VMSCLI
 
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";
 
348
#  else
 
349
     static ZCONST char Far BetaVersion[] = "%s\
 
350
        THIS IS STILL A BETA VERSION OF UNZIP%s -- DO NOT DISTRIBUTE.\n\n";
 
351
#  endif
 
352
#endif
 
353
 
 
354
#ifdef SFX
 
355
#  ifdef VMSCLI
 
356
   /* UnzipSFXBanner[] is also used in vms/cmdline.c:  do not make it static */
 
357
     ZCONST char Far UnzipSFXBanner[] =
 
358
#  else
 
359
     static ZCONST char Far UnzipSFXBanner[] =
 
360
#  endif
 
361
     "UnZipSFX %d.%d%d%s of %s, by Info-ZIP (http://www.info-zip.org).\n";
 
362
#  ifdef SFX_EXDIR
 
363
     static ZCONST char Far UnzipSFXOpts[] =
 
364
    "Valid options are -tfupcz and -d <exdir>; modifiers are -abjnoqCL%sV%s.\n";
 
365
#  else
 
366
     static ZCONST char Far UnzipSFXOpts[] =
 
367
       "Valid options are -tfupcz; modifiers are -abjnoqCL%sV%s.\n";
 
368
#  endif
 
369
#else /* !SFX */
 
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";
 
377
#endif
 
378
   static ZCONST char Far None[] = "[none]";
 
379
#  ifdef ACORN_FTYPE_NFS
 
380
     static ZCONST char Far AcornFtypeNFS[] = "ACORN_FTYPE_NFS";
 
381
#  endif
 
382
#  ifdef ASM_CRC
 
383
     static ZCONST char Far AsmCRC[] = "ASM_CRC";
 
384
#  endif
 
385
#  ifdef ASM_INFLATECODES
 
386
     static ZCONST char Far AsmInflateCodes[] = "ASM_INFLATECODES";
 
387
#  endif
 
388
#  ifdef CHECK_VERSIONS
 
389
     static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS";
 
390
#  endif
 
391
#  ifdef COPYRIGHT_CLEAN
 
392
     static ZCONST char Far Copyright_Clean[] =
 
393
     "COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)";
 
394
#  endif
 
395
#  ifdef DEBUG
 
396
     static ZCONST char Far UDebug[] = "DEBUG";
 
397
#  endif
 
398
#  ifdef DEBUG_TIME
 
399
     static ZCONST char Far DebugTime[] = "DEBUG_TIME";
 
400
#  endif
 
401
#  ifdef DLL
 
402
     static ZCONST char Far Dll[] = "DLL";
 
403
#  endif
 
404
#  ifdef DOSWILD
 
405
     static ZCONST char Far DosWild[] = "DOSWILD";
 
406
#  endif
 
407
#  ifdef LZW_CLEAN
 
408
     static ZCONST char Far LZW_Clean[] =
 
409
     "LZW_CLEAN (PKZIP/Zip 1.x unshrinking method not supported)";
 
410
#  endif
 
411
#  ifndef MORE
 
412
     static ZCONST char Far No_More[] = "NO_MORE";
 
413
#  endif
 
414
#  ifdef NO_ZIPINFO
 
415
     static ZCONST char Far No_ZipInfo[] = "NO_ZIPINFO";
 
416
#  endif
 
417
#  ifdef NTSD_EAS
 
418
     static ZCONST char Far NTSDExtAttrib[] = "NTSD_EAS";
 
419
#  endif
 
420
#  if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
 
421
     static ZCONST char Far W32NoIZTimeFix[] = "NO_W32TIMES_IZFIX";
 
422
#  endif
 
423
#  ifdef OLD_THEOS_EXTRA
 
424
     static ZCONST char Far OldTheosExtra[] =
 
425
     "OLD_THEOS_EXTRA (handle also old Theos port extra field)";
 
426
#  endif
 
427
#  ifdef OS2_EAS
 
428
     static ZCONST char Far OS2ExtAttrib[] = "OS2_EAS";
 
429
#  endif
 
430
#  ifdef QLZIP
 
431
     static ZCONST char Far SMSExFldOnUnix[] = "QLZIP";
 
432
#  endif
 
433
#  ifdef REENTRANT
 
434
     static ZCONST char Far Reentrant[] = "REENTRANT";
 
435
#  endif
 
436
#  ifdef REGARGS
 
437
     static ZCONST char Far RegArgs[] = "REGARGS";
 
438
#  endif
 
439
#  ifdef RETURN_CODES
 
440
     static ZCONST char Far Return_Codes[] = "RETURN_CODES";
 
441
#  endif
 
442
#  ifdef SET_DIR_ATTRIB
 
443
     static ZCONST char Far SetDirAttrib[] = "SET_DIR_ATTRIB";
 
444
#  endif
 
445
#  ifdef SYMLINKS
 
446
     static ZCONST char Far SymLinkSupport[] =
 
447
     "SYMLINKS (symbolic links supported, if RTL and file system permit)";
 
448
#  endif
 
449
#  ifdef TIMESTAMP
 
450
     static ZCONST char Far TimeStamp[] = "TIMESTAMP";
 
451
#  endif
 
452
#  ifdef UNIXBACKUP
 
453
     static ZCONST char Far UnixBackup[] = "UNIXBACKUP";
 
454
#  endif
 
455
#  ifdef USE_EF_UT_TIME
 
456
     static ZCONST char Far Use_EF_UT_time[] = "USE_EF_UT_TIME";
 
457
#  endif
 
458
#  ifndef LZW_CLEAN
 
459
     static ZCONST char Far Use_Unshrink[] =
 
460
     "USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)";
 
461
#  endif
 
462
#  ifndef COPYRIGHT_CLEAN
 
463
     static ZCONST char Far Use_Smith_Code[] =
 
464
     "USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)";
 
465
#  endif
 
466
#  ifdef USE_DEFLATE64
 
467
     static ZCONST char Far Use_Deflate64[] =
 
468
     "USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)";
 
469
#  endif
 
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)";
 
476
#    else
 
477
       /* direct native UTF-8 check, only */
 
478
       static ZCONST char Far Use_Unicode[] =
 
479
       "UNICODE_SUPPORT [char coding: %s] (handle UTF-8 paths)";
 
480
#    endif
 
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 */
 
489
#  ifdef _MBCS
 
490
     static ZCONST char Far Have_MBCS_Support[] =
 
491
     "MBCS-support (multibyte character support, MB_CUR_MAX = %u)";
 
492
#  endif
 
493
#  ifdef MULT_VOLUME
 
494
     static ZCONST char Far Use_MultiVol[] =
 
495
     "MULT_VOLUME (multi-volume archives supported)";
 
496
#  endif
 
497
#  ifdef LARGE_FILE_SUPPORT
 
498
     static ZCONST char Far Use_LFS[] =
 
499
     "LARGE_FILE_SUPPORT (large files over 2 GiB supported)";
 
500
#  endif
 
501
#  ifdef ZIP64_SUPPORT
 
502
     static ZCONST char Far Use_Zip64[] =
 
503
     "ZIP64_SUPPORT (archives using Zip64 for large files supported)";
 
504
#  endif
 
505
#  if (defined(__DJGPP__) && (__DJGPP__ >= 2))
 
506
#    ifdef USE_DJGPP_ENV
 
507
       static ZCONST char Far Use_DJGPP_Env[] = "USE_DJGPP_ENV";
 
508
#    endif
 
509
#    ifdef USE_DJGPP_GLOB
 
510
       static ZCONST char Far Use_DJGPP_Glob[] = "USE_DJGPP_GLOB";
 
511
#    endif
 
512
#  endif /* __DJGPP__ && (__DJGPP__ >= 2) */
 
513
#  ifdef USE_VFAT
 
514
     static ZCONST char Far Use_VFAT_support[] = "USE_VFAT";
 
515
#  endif
 
516
#  ifdef USE_ZLIB
 
517
     static ZCONST char Far UseZlib[] =
 
518
     "USE_ZLIB (compiled with version %s; using version %s)";
 
519
#  endif
 
520
#  ifdef USE_BZIP2
 
521
     static ZCONST char Far UseBZip2[] =
 
522
     "USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version %s)";
 
523
#  endif
 
524
#  ifdef VMS_TEXT_CONV
 
525
     static ZCONST char Far VmsTextConv[] = "VMS_TEXT_CONV";
 
526
#  endif
 
527
#  ifdef VMSCLI
 
528
     static ZCONST char Far VmsCLI[] = "VMSCLI";
 
529
#  endif
 
530
#  ifdef VMSWILD
 
531
     static ZCONST char Far VmsWild[] = "VMSWILD";
 
532
#  endif
 
533
#  ifdef WILD_STOP_AT_DIR
 
534
     static ZCONST char Far WildStopAtDir[] = "WILD_STOP_AT_DIR";
 
535
#  endif
 
536
#  if CRYPT
 
537
#    ifdef PASSWD_FROM_STDIN
 
538
       static ZCONST char Far PasswdStdin[] = "PASSWD_FROM_STDIN";
 
539
#    endif
 
540
     static ZCONST char Far Decryption[] =
 
541
       "        [decryption, version %d.%d%s of %s]\n";
 
542
     static ZCONST char Far CryptDate[] = CR_VERSION_DATE;
 
543
#  endif
 
544
#  ifndef __RSXNT__
 
545
#    ifdef __EMX__
 
546
       static ZCONST char Far EnvEMX[] = "EMX";
 
547
       static ZCONST char Far EnvEMXOPT[] = "EMXOPT";
 
548
#    endif
 
549
#    if (defined(__GO32__) && (!defined(__DJGPP__) || (__DJGPP__ < 2)))
 
550
       static ZCONST char Far EnvGO32[] = "GO32";
 
551
       static ZCONST char Far EnvGO32TMP[] = "GO32TMP";
 
552
#    endif
 
553
#  endif /* !__RSXNT__ */
 
554
 
 
555
#ifdef VMS
 
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.\
 
563
\n\n";
 
564
# else
 
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.\
 
568
\n\n";
 
569
# endif /* ?COPYRIGHT_CLEAN */
 
570
#else /* !VMS */
 
571
# ifdef COPYRIGHT_CLEAN
 
572
   static ZCONST char Far UnzipUsageLine1[] = "\
 
573
UnZip %d.%d%d%s of %s, by Debian. Original by Info-ZIP.\
 
574
\n\n";
 
575
# else
 
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.\
 
579
\n\n";
 
580
# endif /* ?COPYRIGHT_CLEAN */
 
581
# define UnzipUsageLine1v       UnzipUsageLine1
 
582
#endif /* ?VMS */
 
583
 
 
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.\
 
587
\n\n";
 
588
 
 
589
#ifdef MACOS
 
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";
 
594
#else /* !MACOS */
 
595
#ifdef VM_CMS
 
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";
 
600
#else /* !VM_CMS */
 
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";
 
605
#endif /* ?VM_CMS */
 
606
#endif /* ?MACOS */
 
607
 
 
608
#ifdef NO_ZIPINFO
 
609
#  define ZIPINFO_MODE_OPTION  ""
 
610
   static ZCONST char Far ZipInfoMode[] =
 
611
     "(ZipInfo mode is disabled in this version.)";
 
612
#else
 
613
#  define ZIPINFO_MODE_OPTION  "[-Z] "
 
614
   static ZCONST char Far ZipInfoMode[] =
 
615
     "-Z => ZipInfo mode (\"unzip -Z\" for usage).";
 
616
#endif /* ?NO_ZIPINFO */
 
617
 
 
618
#ifdef VMS
 
619
   static ZCONST char Far VMSusageLine2b[] = "\
 
620
=> define foreign command symbol in LOGIN.COM:  $ unzip :== $dev:[dir]unzip.exe\
 
621
\n";
 
622
#endif
 
623
 
 
624
#ifdef MACOS
 
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";
 
630
#else /* !MACOS */
 
631
#ifdef VM_CMS
 
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";
 
638
#else /* !VM_CMS */
 
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";
 
645
#endif /* ?VM_CMS */
 
646
#endif /* ?MACOS */
 
647
 
 
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]
 
652
 *
 
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]
 
655
 */
 
656
#if (defined(UNICODE_SUPPORT) && !defined(WIN32))
 
657
#ifdef VMS
 
658
static ZCONST char Far UnzipUsageLine4[] = "\
 
659
modifiers:\n\
 
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";
 
667
#else /* !VMS */
 
668
static ZCONST char Far UnzipUsageLine4[] = "\
 
669
modifiers:\n\
 
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";
 
676
#endif /* ?VMS */
 
677
#else /* !UNICODE_SUPPORT */
 
678
#ifdef VMS
 
679
static ZCONST char Far UnzipUsageLine4[] = "\
 
680
modifiers:\n\
 
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";
 
687
#else /* !VMS */
 
688
static ZCONST char Far UnzipUsageLine4[] = "\
 
689
modifiers:\n\
 
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";
 
695
#endif /* ?VMS */
 
696
#endif /* ?UNICODE_SUPPORT */
 
697
 
 
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\
 
701
%s\
 
702
  unzip -fo foo %-6s => quietly replace existing %s if archive file newer\n";
 
703
#endif /* ?SFX */
 
704
 
 
705
 
 
706
 
 
707
 
 
708
 
 
709
/*****************************/
 
710
/*  main() / UzpMain() stub  */
 
711
/*****************************/
 
712
 
 
713
int MAIN(argc, argv)   /* return PK-type error code (except under VMS) */
 
714
    int argc;
 
715
    char *argv[];
 
716
{
 
717
    int r;
 
718
 
 
719
    CONSTRUCTGLOBALS();
 
720
    r = unzip(__G__ argc, argv);
 
721
    DESTROYGLOBALS();
 
722
    RETURN(r);
 
723
}
 
724
 
 
725
 
 
726
 
 
727
 
 
728
/*******************************/
 
729
/*  Primary UnZip entry point  */
 
730
/*******************************/
 
731
 
 
732
int unzip(__G__ argc, argv)
 
733
    __GDEF
 
734
    int argc;
 
735
    char *argv[];
 
736
{
 
737
#ifndef NO_ZIPINFO
 
738
    char *p;
 
739
#endif
 
740
#if (defined(DOS_FLX_H68_NLM_OS2_W32) || !defined(SFX))
 
741
    int i;
 
742
#endif
 
743
    int retcode, error=FALSE;
 
744
#ifndef NO_EXCEPT_SIGNALS
 
745
#ifdef REENTRANT
 
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
 
751
#else
 
752
#   define SET_SIGHANDLER(sigtype, newsighandler) \
 
753
      signal((sigtype), (newsighandler))
 
754
#endif
 
755
#endif /* NO_EXCEPT_SIGNALS */
 
756
 
 
757
    /* initialize international char support to the current environment */
 
758
    SETLOCALE(LC_CTYPE, "");
 
759
 
 
760
#ifdef UNICODE_SUPPORT
 
761
    /* see if can use UTF-8 Unicode locale */
 
762
# ifdef UTF8_MAYBE_NATIVE
 
763
    {
 
764
        char *codeset;
 
765
#  if !(defined(NO_NL_LANGINFO) || defined(NO_LANGINFO_H))
 
766
        /* get the codeset (character set encoding) currently used */
 
767
#       include <langinfo.h>
 
768
 
 
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;
 
777
        }
 
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;
 
783
        } else {
 
784
            /* Current codeset is not UTF-8 or cannot be determined. */
 
785
            G.native_is_utf8 = FALSE;
 
786
        }
 
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.
 
791
         */
 
792
    }
 
793
# endif /* UTF8_MAYBE_NATIVE */
 
794
 
 
795
    /* initialize Unicode */
 
796
    G.unicode_escape_all = 0;
 
797
    G.unicode_mismatch = 0;
 
798
 
 
799
    G.unipath_version = 0;
 
800
    G.unipath_checksum = 0;
 
801
    G.unipath_filename = NULL;
 
802
#endif /* UNICODE_SUPPORT */
 
803
 
 
804
 
 
805
#if (defined(__IBMC__) && defined(__DEBUG_ALLOC__))
 
806
    extern void DebugMalloc(void);
 
807
 
 
808
    atexit(DebugMalloc);
 
809
#endif
 
810
 
 
811
#ifdef MALLOC_WORK
 
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.)
 
820
     */
 
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);
 
832
#endif
 
833
 
 
834
/*---------------------------------------------------------------------------
 
835
    Set signal handler for restoring echo, warn of zipfile corruption, etc.
 
836
  ---------------------------------------------------------------------------*/
 
837
#ifndef NO_EXCEPT_SIGNALS
 
838
#ifdef SIGINT
 
839
    SET_SIGHANDLER(SIGINT, handler);
 
840
#endif
 
841
#ifdef SIGTERM                 /* some systems really have no SIGTERM */
 
842
    SET_SIGHANDLER(SIGTERM, handler);
 
843
#endif
 
844
#if defined(SIGABRT) && !(defined(AMIGA) && defined(__SASC))
 
845
    SET_SIGHANDLER(SIGABRT, handler);
 
846
#endif
 
847
#ifdef SIGBREAK
 
848
    SET_SIGHANDLER(SIGBREAK, handler);
 
849
#endif
 
850
#ifdef SIGBUS
 
851
    SET_SIGHANDLER(SIGBUS, handler);
 
852
#endif
 
853
#ifdef SIGILL
 
854
    SET_SIGHANDLER(SIGILL, handler);
 
855
#endif
 
856
#ifdef SIGSEGV
 
857
    SET_SIGHANDLER(SIGSEGV, handler);
 
858
#endif
 
859
#endif /* NO_EXCEPT_SIGNALS */
 
860
 
 
861
#if (defined(WIN32) && defined(__RSXNT__))
 
862
    for (i = 0 ; i < argc; i++) {
 
863
        _ISO_INTERN(argv[i]);
 
864
    }
 
865
#endif
 
866
 
 
867
/*---------------------------------------------------------------------------
 
868
    Macintosh initialization code.
 
869
  ---------------------------------------------------------------------------*/
 
870
 
 
871
#ifdef MACOS
 
872
    {
 
873
        int a;
 
874
 
 
875
        for (a = 0;  a < 4;  ++a)
 
876
            G.rghCursor[a] = GetCursor(a+128);
 
877
        G.giCursor = 0;
 
878
    }
 
879
#endif
 
880
 
 
881
/*---------------------------------------------------------------------------
 
882
    NetWare initialization code.
 
883
  ---------------------------------------------------------------------------*/
 
884
 
 
885
#ifdef NLM
 
886
    InitUnZipConsole();
 
887
#endif
 
888
 
 
889
/*---------------------------------------------------------------------------
 
890
    Acorn RISC OS initialization code.
 
891
  ---------------------------------------------------------------------------*/
 
892
 
 
893
#ifdef RISCOS
 
894
    set_prefix();
 
895
#endif
 
896
 
 
897
/*---------------------------------------------------------------------------
 
898
    Theos initialization code.
 
899
  ---------------------------------------------------------------------------*/
 
900
 
 
901
#ifdef THEOS
 
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.
 
905
     */
 
906
    if (! _setargv(&argc, &argv)) {
 
907
        Info(slide, 0x401, ((char *)slide, "cannot process argv\n"));
 
908
        retcode = PK_MEM;
 
909
        goto cleanup_and_exit;
 
910
    }
 
911
#endif
 
912
 
 
913
/*---------------------------------------------------------------------------
 
914
    Sanity checks.  Commentary by Otis B. Driftwood and Fiorello:
 
915
 
 
916
    D:  It's all right.  That's in every contract.  That's what they
 
917
        call a sanity clause.
 
918
 
 
919
    F:  Ha-ha-ha-ha-ha.  You can't fool me.  There ain't no Sanity
 
920
        Claus.
 
921
  ---------------------------------------------------------------------------*/
 
922
 
 
923
#ifdef DEBUG
 
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"));
 
928
        retcode = PK_BADERR;
 
929
        goto cleanup_and_exit;
 
930
    }
 
931
    /* test if we can show 64-bit values */
 
932
    {
 
933
        zoff_t z = ~(zoff_t)0;  /* z should be all 1s now */
 
934
        char *sz;
 
935
 
 
936
        sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
 
937
        if ((sz[0] != 'F') || (strlen(sz) != 16))
 
938
        {
 
939
            z = 0;
 
940
        }
 
941
 
 
942
        /* shift z so only MSB is set */
 
943
        z <<= 63;
 
944
        sz = FmZofft(z, FZOFFT_HEX_DOT_WID, "X");
 
945
        if ((sz[0] != '8') || (strlen(sz) != 16))
 
946
        {
 
947
            Info(slide, 0x401, ((char *)slide,
 
948
              "Can't show 64-bit values correctly\n"));
 
949
            retcode = PK_BADERR;
 
950
            goto cleanup_and_exit;
 
951
        }
 
952
    }
 
953
# endif /* LARGE_FILE_SUPPORT */
 
954
 
 
955
    /* 2004-11-30 SMS.
 
956
       Test the NEXTBYTE macro for proper operation.
 
957
    */
 
958
    {
 
959
        int test_char;
 
960
        static uch test_buf[2] = { 'a', 'b' };
 
961
 
 
962
        G.inptr = test_buf;
 
963
        G.incnt = 1;
 
964
 
 
965
        test_char = NEXTBYTE;           /* Should get 'a'. */
 
966
        if (test_char == 'a')
 
967
        {
 
968
            test_char = NEXTBYTE;       /* Should get EOF, not 'b'. */
 
969
        }
 
970
        if (test_char != EOF)
 
971
        {
 
972
            Info(slide, 0x401, ((char *)slide,
 
973
 "NEXTBYTE macro failed.  Try compiling with ALT_NEXTBYTE defined?"));
 
974
 
 
975
            retcode = PK_BADERR;
 
976
            goto cleanup_and_exit;
 
977
        }
 
978
    }
 
979
#endif /* DEBUG */
 
980
 
 
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
  ---------------------------------------------------------------------------*/
 
986
 
 
987
#ifdef SFX
 
988
    G.argv0 = argv[0];
 
989
#if (defined(OS2) || defined(WIN32))
 
990
    G.zipfn = GetLoadPath(__G);/* non-MSC NT puts path into G.filename[] */
 
991
#else
 
992
    G.zipfn = G.argv0;
 
993
#endif
 
994
 
 
995
#ifdef VMSCLI
 
996
    {
 
997
        ulg status = vms_unzip_cmdline(&argc, &argv);
 
998
        if (!(status & 1)) {
 
999
            retcode = (int)status;
 
1000
            goto cleanup_and_exit;
 
1001
        }
 
1002
    }
 
1003
#endif /* VMSCLI */
 
1004
 
 
1005
    uO.zipinfo_mode = FALSE;
 
1006
    error = uz_opts(__G__ &argc, &argv);   /* UnZipSFX call only */
 
1007
 
 
1008
#else /* !SFX */
 
1009
 
 
1010
#ifdef RISCOS
 
1011
    /* get the extensions to swap from environment */
 
1012
    getRISCOSexts(ENV_UNZIPEXTS);
 
1013
#endif
 
1014
 
 
1015
#ifdef MSDOS
 
1016
    /* extract MKS extended argument list from environment (before envargs!) */
 
1017
    mksargs(&argc, &argv);
 
1018
#endif
 
1019
 
 
1020
#ifdef VMSCLI
 
1021
    {
 
1022
        ulg status = vms_unzip_cmdline(&argc, &argv);
 
1023
        if (!(status & 1)) {
 
1024
            retcode = (int)status;
 
1025
            goto cleanup_and_exit;
 
1026
        }
 
1027
    }
 
1028
#endif /* VMSCLI */
 
1029
 
 
1030
    G.noargs = (argc == 1);   /* no options, no zipfile, no anything */
 
1031
 
 
1032
#ifndef NO_ZIPINFO
 
1033
    for (p = argv[0] + strlen(argv[0]); p >= argv[0]; --p) {
 
1034
        if (*p == DIR_END
 
1035
#ifdef DIR_END2
 
1036
            || *p == DIR_END2
 
1037
#endif
 
1038
           )
 
1039
            break;
 
1040
    }
 
1041
    ++p;
 
1042
 
 
1043
#ifdef THEOS
 
1044
    if (strncmp(p, "ZIPINFO.",8) == 0 || strstr(p, ".ZIPINFO:") != NULL ||
 
1045
        strncmp(p, "II.",3) == 0 || strstr(p, ".II:") != NULL ||
 
1046
#else
 
1047
    if (STRNICMP(p, LoadFarStringSmall(Zipnfo), 7) == 0 ||
 
1048
        STRNICMP(p, "ii", 2) == 0 ||
 
1049
#endif
 
1050
        (argc > 1 && strncmp(argv[1], "-Z", 2) == 0))
 
1051
    {
 
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));
 
1057
#endif
 
1058
    } else
 
1059
#endif /* !NO_ZIPINFO */
 
1060
    {
 
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));
 
1066
#endif
 
1067
    }
 
1068
 
 
1069
    if (!error) {
 
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).
 
1076
         */
 
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));
 
1081
               retcode = PK_PARAM;
 
1082
               goto cleanup_and_exit;
 
1083
           }
 
1084
        }
 
1085
#ifndef NO_ZIPINFO
 
1086
        if (uO.zipinfo_mode)
 
1087
            error = zi_opts(__G__ &argc, &argv);
 
1088
        else
 
1089
#endif /* !NO_ZIPINFO */
 
1090
            error = uz_opts(__G__ &argc, &argv);
 
1091
    }
 
1092
 
 
1093
#endif /* ?SFX */
 
1094
 
 
1095
    if ((argc < 0) || error) {
 
1096
        retcode = error;
 
1097
        goto cleanup_and_exit;
 
1098
    }
 
1099
 
 
1100
/*---------------------------------------------------------------------------
 
1101
    Now get the zipfile name from the command line and then process any re-
 
1102
    maining options and file specifications.
 
1103
  ---------------------------------------------------------------------------*/
 
1104
 
 
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)
 
1108
     */
 
1109
#ifdef SFX
 
1110
    for (G.pfnames = argv, i = argc;  i > 0;  --i) {
 
1111
#else
 
1112
    /* argc does not include the zipfile specification */
 
1113
    for (G.pfnames = argv, i = argc+1;  i > 0;  --i) {
 
1114
#endif
 
1115
#ifdef __human68k__
 
1116
        extern char *_toslash(char *);
 
1117
        _toslash(*G.pfnames);
 
1118
#else /* !__human68k__ */
 
1119
        char *q = *G.pfnames;
 
1120
 
 
1121
        while (*q != '\0') {
 
1122
            if (*q == '\\')
 
1123
                *q = '/';
 
1124
            INCSTR(q);
 
1125
        }
 
1126
#endif /* ?__human68k__ */
 
1127
        ++G.pfnames;
 
1128
    }
 
1129
#endif /* DOS_FLX_H68_NLM_OS2_W32 */
 
1130
 
 
1131
#ifndef SFX
 
1132
    G.wildzipfn = *argv++;
 
1133
#endif
 
1134
 
 
1135
#if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */
 
1136
 
 
1137
    G.filespecs = argc;
 
1138
    G.xfilespecs = 0;
 
1139
 
 
1140
    if (argc > 0) {
 
1141
        char **pp = argv-1;
 
1142
 
 
1143
        G.pfnames = argv;
 
1144
        while (*++pp)
 
1145
            if (strcmp(*pp, "-x") == 0) {
 
1146
                if (pp > argv) {
 
1147
                    *pp = 0;              /* terminate G.pfnames */
 
1148
                    G.filespecs = pp - G.pfnames;
 
1149
                } else {
 
1150
                    G.pfnames = (char **)fnames;  /* defaults */
 
1151
                    G.filespecs = 0;
 
1152
                }
 
1153
                G.pxnames = pp + 1;      /* excluded-names ptr: _after_ -x */
 
1154
                G.xfilespecs = argc - G.filespecs - 1;
 
1155
                break;                    /* skip rest of args */
 
1156
            }
 
1157
        G.process_all_files = FALSE;
 
1158
    } else
 
1159
        G.process_all_files = TRUE;      /* for speed */
 
1160
 
 
1161
#else /* !SFX || SFX_EXDIR */             /* check for -x or -d */
 
1162
 
 
1163
    G.filespecs = argc;
 
1164
    G.xfilespecs = 0;
 
1165
 
 
1166
    if (argc > 0) {
 
1167
        int in_files=FALSE, in_xfiles=FALSE;
 
1168
        char **pp = argv-1;
 
1169
 
 
1170
        G.process_all_files = FALSE;
 
1171
        G.pfnames = argv;
 
1172
        while (*++pp) {
 
1173
            Trace((stderr, "pp - argv = %d\n", pp-argv));
 
1174
#ifdef CMS_MVS
 
1175
            if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) {
 
1176
#else
 
1177
            if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) {
 
1178
#endif
 
1179
                int firstarg = (pp == argv);
 
1180
 
 
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;
 
1185
                    in_files = FALSE;
 
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 */
 
1190
                }
 
1191
                /* first check for "-dexdir", then for "-d exdir" */
 
1192
                if (*uO.exdir == '\0') {
 
1193
                    if (*++pp)
 
1194
                        uO.exdir = *pp;
 
1195
                    else {
 
1196
                        Info(slide, 0x401, ((char *)slide,
 
1197
                          LoadFarString(MustGiveExdir)));
 
1198
                        /* don't extract here by accident */
 
1199
                        retcode = PK_PARAM;
 
1200
                        goto cleanup_and_exit;
 
1201
                    }
 
1202
                }
 
1203
                if (firstarg) { /* ... zipfile -d exdir ... */
 
1204
                    if (pp[1]) {
 
1205
                        G.pfnames = pp + 1;  /* argv+2 */
 
1206
                        G.filespecs = argc - (G.pfnames-argv);  /* for now... */
 
1207
                    } else {
 
1208
                        G.process_all_files = TRUE;
 
1209
                        G.pfnames = (char **)fnames;  /* GRR: necessary? */
 
1210
                        G.filespecs = 0;     /* GRR: necessary? */
 
1211
                        break;
 
1212
                    }
 
1213
                }
 
1214
            } else if (!in_xfiles) {
 
1215
                if (strcmp(*pp, "-x") == 0) {
 
1216
                    in_xfiles = TRUE;
 
1217
                    if (pp == G.pfnames) {
 
1218
                        G.pfnames = (char **)fnames;  /* defaults */
 
1219
                        G.filespecs = 0;
 
1220
                    } else if (in_files) {
 
1221
                        *pp = 0;                   /* terminate G.pfnames */
 
1222
                        G.filespecs = pp - G.pfnames;  /* adjust count */
 
1223
                        in_files = FALSE;
 
1224
                    }
 
1225
                    G.pxnames = pp + 1; /* excluded-names ptr starts after -x */
 
1226
                    G.xfilespecs = argc - (G.pxnames-argv);  /* anything left */
 
1227
                } else
 
1228
                    in_files = TRUE;
 
1229
            }
 
1230
        }
 
1231
    } else
 
1232
        G.process_all_files = TRUE;      /* for speed */
 
1233
 
 
1234
    if (uO.exdir != (char *)NULL && !G.extract_flag)    /* -d ignored */
 
1235
        Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting)));
 
1236
#endif /* ?(SFX && !SFX_EXDIR) */
 
1237
 
 
1238
#ifdef UNICODE_SUPPORT
 
1239
    /* set Unicode-escape-all if option -U used */
 
1240
    if (uO.U_flag == 1)
 
1241
# ifdef UNICODE_WCHAR
 
1242
        G.unicode_escape_all = TRUE;
 
1243
# else
 
1244
        Info(slide, 0x401, ((char *)slide, LoadFarString(UTF8EscapeUnSupp)));
 
1245
# endif
 
1246
#endif
 
1247
 
 
1248
 
 
1249
/*---------------------------------------------------------------------------
 
1250
    Okey dokey, we have everything we need to get started.  Let's roll.
 
1251
  ---------------------------------------------------------------------------*/
 
1252
 
 
1253
    retcode = process_zipfiles(__G);
 
1254
 
 
1255
cleanup_and_exit:
 
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;
 
1260
 
 
1261
        signal(thissigsav->sigtype, thissigsav->sighandler);
 
1262
        oldsighandlers = thissigsav->previous;
 
1263
        free(thissigsav);
 
1264
    }
 
1265
#endif
 
1266
#if (defined(MALLOC_WORK) && !defined(REENTRANT))
 
1267
    if (G.area.Slide != (uch *)NULL) {
 
1268
        free(G.area.Slide);
 
1269
        G.area.Slide = (uch *)NULL;
 
1270
    }
 
1271
#endif
 
1272
#if (defined(MSDOS) && !defined(SFX) && !defined(WINDLL))
 
1273
    if (retcode != PK_OK)
 
1274
        check_for_windows("UnZip");
 
1275
#endif
 
1276
    return(retcode);
 
1277
 
 
1278
} /* end main()/unzip() */
 
1279
 
 
1280
 
 
1281
 
 
1282
 
 
1283
 
 
1284
#if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS))
 
1285
/*******************************/
 
1286
/* Function setsignalhandler() */
 
1287
/*******************************/
 
1288
 
 
1289
static int setsignalhandler(__G__ p_savedhandler_chain, signal_type,
 
1290
                            newhandler)
 
1291
    __GDEF
 
1292
    savsigs_info **p_savedhandler_chain;
 
1293
    int signal_type;
 
1294
    void (*newhandler)(int);
 
1295
{
 
1296
    savsigs_info *savsig;
 
1297
 
 
1298
    savsig = malloc(sizeof(savsigs_info));
 
1299
    if (savsig == NULL) {
 
1300
        /* error message and break */
 
1301
        Info(slide, 0x401, ((char *)slide, LoadFarString(CantSaveSigHandler)));
 
1302
        return PK_MEM;
 
1303
    }
 
1304
    savsig->sigtype = signal_type;
 
1305
    savsig->sighandler = signal(SIGINT, newhandler);
 
1306
    if (savsig->sighandler == SIG_ERR) {
 
1307
        free(savsig);
 
1308
    } else {
 
1309
        savsig->previous = *p_savedhandler_chain;
 
1310
        *p_savedhandler_chain = savsig;
 
1311
    }
 
1312
    return PK_OK;
 
1313
 
 
1314
} /* end function setsignalhandler() */
 
1315
 
 
1316
#endif /* REENTRANT && !NO_EXCEPT_SIGNALS */
 
1317
 
 
1318
 
 
1319
 
 
1320
 
 
1321
 
 
1322
/**********************/
 
1323
/* Function uz_opts() */
 
1324
/**********************/
 
1325
 
 
1326
int uz_opts(__G__ pargc, pargv)
 
1327
    __GDEF
 
1328
    int *pargc;
 
1329
    char ***pargv;
 
1330
{
 
1331
    char **argv, *s;
 
1332
    int argc, c, error=FALSE, negative=0, showhelp=0;
 
1333
 
 
1334
 
 
1335
    argc = *pargc;
 
1336
    argv = *pargv;
 
1337
 
 
1338
    while (++argv, (--argc > 0 && *argv != NULL && **argv == '-')) {
 
1339
        s = *argv + 1;
 
1340
        while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
 
1341
#ifdef CMS_MVS
 
1342
            switch (tolower(c))
 
1343
#else
 
1344
            switch (c)
 
1345
#endif
 
1346
            {
 
1347
                case ('-'):
 
1348
                    ++negative;
 
1349
                    break;
 
1350
#ifdef RISCOS
 
1351
                case ('/'):
 
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 */
 
1356
                    }
 
1357
                    exts2swap = s; /* override Unzip$Exts */
 
1358
                    s += strlen(s);
 
1359
                    break;
 
1360
#endif
 
1361
                case ('a'):
 
1362
                    if (negative) {
 
1363
                        uO.aflag = MAX(uO.aflag-negative,0);
 
1364
                        negative = 0;
 
1365
                    } else
 
1366
                        ++uO.aflag;
 
1367
                    break;
 
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 */
 
1372
                    return 0;
 
1373
#endif
 
1374
                case ('b'):
 
1375
                    if (negative) {
 
1376
#if (defined(TANDEM) || defined(VMS))
 
1377
                        uO.bflag = MAX(uO.bflag-negative,0);
 
1378
#endif
 
1379
                        negative = 0;   /* do nothing:  "-b" is default */
 
1380
                    } else {
 
1381
#ifdef VMS
 
1382
                        if (uO.aflag == 0)
 
1383
                           ++uO.bflag;
 
1384
#endif
 
1385
#ifdef TANDEM
 
1386
                        ++uO.bflag;
 
1387
#endif
 
1388
                        uO.aflag = 0;
 
1389
                    }
 
1390
                    break;
 
1391
#ifdef UNIXBACKUP
 
1392
                case ('B'): /* -B: back up existing files */
 
1393
                    if (negative)
 
1394
                        uO.B_flag = FALSE, negative = 0;
 
1395
                    else
 
1396
                        uO.B_flag = TRUE;
 
1397
                    break;
 
1398
#endif
 
1399
                case ('c'):
 
1400
                    if (negative) {
 
1401
                        uO.cflag = FALSE, negative = 0;
 
1402
#ifdef NATIVE
 
1403
                        uO.aflag = 0;
 
1404
#endif
 
1405
                    } else {
 
1406
                        uO.cflag = TRUE;
 
1407
#ifdef NATIVE
 
1408
                        uO.aflag = 2;   /* so you can read it on the screen */
 
1409
#endif
 
1410
#ifdef DLL
 
1411
                        if (G.redirect_text)
 
1412
                            G.redirect_data = 2;
 
1413
#endif
 
1414
                    }
 
1415
                    break;
 
1416
#ifndef CMS_MVS
 
1417
                case ('C'):    /* -C:  match filenames case-insensitively */
 
1418
                    if (negative)
 
1419
                        uO.C_flag = FALSE, negative = 0;
 
1420
                    else
 
1421
                        uO.C_flag = TRUE;
 
1422
                    break;
 
1423
#endif /* !CMS_MVS */
 
1424
#if (!defined(SFX) || defined(SFX_EXDIR))
 
1425
                case ('d'):
 
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 */
 
1430
                    }
 
1431
                    if (uO.exdir != (char *)NULL) {
 
1432
                        Info(slide, 0x401, ((char *)slide,
 
1433
                          LoadFarString(OnlyOneExdir)));
 
1434
                        return(PK_PARAM);    /* GRR:  stupid restriction? */
 
1435
                    } else {
 
1436
                        /* first check for "-dexdir", then for "-d exdir" */
 
1437
                        uO.exdir = s;
 
1438
                        if (*uO.exdir == '\0') {
 
1439
                            if (argc > 1) {
 
1440
                                --argc;
 
1441
                                uO.exdir = *++argv;
 
1442
                                if (*uO.exdir == '-') {
 
1443
                                    Info(slide, 0x401, ((char *)slide,
 
1444
                                      LoadFarString(MustGiveExdir)));
 
1445
                                    return(PK_PARAM);
 
1446
                                }
 
1447
                                /* else uO.exdir points at extraction dir */
 
1448
                            } else {
 
1449
                                Info(slide, 0x401, ((char *)slide,
 
1450
                                  LoadFarString(MustGiveExdir)));
 
1451
                                return(PK_PARAM);
 
1452
                            }
 
1453
                        }
 
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
 
1457
                         */
 
1458
                        if (*s != 0)
 
1459
                            while (*++s != 0)
 
1460
                                ;
 
1461
                    }
 
1462
                    break;
 
1463
#endif /* !SFX || SFX_EXDIR */
 
1464
#if (!defined(NO_TIMESTAMPS))
 
1465
                case ('D'):    /* -D: Skip restoring dir (or any) timestamp. */
 
1466
                    if (negative) {
 
1467
                        uO.D_flag = MAX(uO.D_flag-negative,0);
 
1468
                        negative = 0;
 
1469
                    } else
 
1470
                        uO.D_flag++;
 
1471
                    break;
 
1472
#endif /* (!NO_TIMESTAMPS) */
 
1473
                case ('e'):    /* just ignore -e, -x options (extract) */
 
1474
                    break;
 
1475
#ifdef MACOS
 
1476
                case ('E'): /* -E [MacOS] display Mac e.f. when restoring */
 
1477
                    if( negative ) {
 
1478
                        uO.E_flag = FALSE, negative = 0;
 
1479
                    } else {
 
1480
                        uO.E_flag = TRUE;
 
1481
                    }
 
1482
                    break;
 
1483
#endif /* MACOS */
 
1484
                case ('f'):    /* "freshen" (extract only newer files) */
 
1485
                    if (negative)
 
1486
                        uO.fflag = uO.uflag = FALSE, negative = 0;
 
1487
                    else
 
1488
                        uO.fflag = uO.uflag = TRUE;
 
1489
                    break;
 
1490
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
 
1491
                case ('F'):    /* Acorn filetype & NFS extension handling */
 
1492
                    if (negative)
 
1493
                        uO.acorn_nfs_ext = FALSE, negative = 0;
 
1494
                    else
 
1495
                        uO.acorn_nfs_ext = TRUE;
 
1496
                    break;
 
1497
#endif /* RISCOS || ACORN_FTYPE_NFS */
 
1498
                case ('h'):    /* just print help message and quit */
 
1499
                    if (showhelp == 0) {
 
1500
#ifndef SFX
 
1501
                        if (*s == 'h')
 
1502
                            showhelp = 2;
 
1503
                        else
 
1504
#endif /* !SFX */
 
1505
                        {
 
1506
                            showhelp = 1;
 
1507
                        }
 
1508
                    }
 
1509
                    break;
 
1510
#ifdef MACOS
 
1511
                case ('i'): /* -i [MacOS] ignore filenames stored in Mac ef */
 
1512
                    if( negative ) {
 
1513
                        uO.i_flag = FALSE, negative = 0;
 
1514
                    } else {
 
1515
                        uO.i_flag = TRUE;
 
1516
                    }
 
1517
                    break;
 
1518
#endif  /* MACOS */
 
1519
                case ('j'):    /* junk pathnames/directory structure */
 
1520
                    if (negative)
 
1521
                        uO.jflag = FALSE, negative = 0;
 
1522
                    else
 
1523
                        uO.jflag = TRUE;
 
1524
                    break;
 
1525
#if (defined(ATH_BEO) || defined(MACOS))
 
1526
                case ('J'):    /* Junk AtheOS, BeOS or MacOS file attributes */
 
1527
                    if( negative ) {
 
1528
                        uO.J_flag = FALSE, negative = 0;
 
1529
                    } else {
 
1530
                        uO.J_flag = TRUE;
 
1531
                    }
 
1532
                    break;
 
1533
#endif /* ATH_BEO || MACOS */
 
1534
#ifdef ATH_BEO_UNX
 
1535
                case ('K'):
 
1536
                    if (negative) {
 
1537
                        uO.K_flag = FALSE, negative = 0;
 
1538
                    } else {
 
1539
                        uO.K_flag = TRUE;
 
1540
                    }
 
1541
                    break;
 
1542
#endif /* ATH_BEO_UNX */
 
1543
#ifndef SFX
 
1544
                case ('l'):
 
1545
                    if (negative) {
 
1546
                        uO.vflag = MAX(uO.vflag-negative,0);
 
1547
                        negative = 0;
 
1548
                    } else
 
1549
                        ++uO.vflag;
 
1550
                    break;
 
1551
#endif /* !SFX */
 
1552
#ifndef CMS_MVS
 
1553
                case ('L'):    /* convert (some) filenames to lowercase */
 
1554
                    if (negative) {
 
1555
                        uO.L_flag = MAX(uO.L_flag-negative,0);
 
1556
                        negative = 0;
 
1557
                    } else
 
1558
                        ++uO.L_flag;
 
1559
                    break;
 
1560
#endif /* !CMS_MVS */
 
1561
#ifdef MORE
 
1562
#ifdef CMS_MVS
 
1563
                case ('m'):
 
1564
#endif
 
1565
                case ('M'):    /* send all screen output through "more" fn. */
 
1566
/* GRR:  eventually check for numerical argument => height */
 
1567
                    if (negative)
 
1568
                        G.M_flag = FALSE, negative = 0;
 
1569
                    else
 
1570
                        G.M_flag = TRUE;
 
1571
                    break;
 
1572
#endif /* MORE */
 
1573
                case ('n'):    /* don't overwrite any files */
 
1574
                    if (negative)
 
1575
                        uO.overwrite_none = FALSE, negative = 0;
 
1576
                    else
 
1577
                        uO.overwrite_none = TRUE;
 
1578
                    break;
 
1579
#ifdef AMIGA
 
1580
                case ('N'):    /* restore comments as filenotes */
 
1581
                    if (negative)
 
1582
                        uO.N_flag = FALSE, negative = 0;
 
1583
                    else
 
1584
                        uO.N_flag = TRUE;
 
1585
                    break;
 
1586
#endif /* AMIGA */
 
1587
                case ('o'):    /* OK to overwrite files without prompting */
 
1588
                    if (negative) {
 
1589
                        uO.overwrite_all = MAX(uO.overwrite_all-negative,0);
 
1590
                        negative = 0;
 
1591
                    } else
 
1592
                        ++uO.overwrite_all;
 
1593
                    break;
 
1594
                case ('p'):    /* pipes:  extract to stdout, no messages */
 
1595
                    if (negative) {
 
1596
                        uO.cflag = FALSE;
 
1597
                        uO.qflag = MAX(uO.qflag-999,0);
 
1598
                        negative = 0;
 
1599
                    } else {
 
1600
                        uO.cflag = TRUE;
 
1601
                        uO.qflag += 999;
 
1602
                    }
 
1603
                    break;
 
1604
#if CRYPT
 
1605
                /* GRR:  yes, this is highly insecure, but dozens of people
 
1606
                 * have pestered us for this, so here we go... */
 
1607
                case ('P'):
 
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 */
 
1612
                    }
 
1613
                    if (uO.pwdarg != (char *)NULL) {
 
1614
/*
 
1615
                        GRR:  eventually support multiple passwords?
 
1616
                        Info(slide, 0x401, ((char *)slide,
 
1617
                          LoadFarString(OnlyOnePasswd)));
 
1618
                        return(PK_PARAM);
 
1619
 */
 
1620
                    } else {
 
1621
                        /* first check for "-Ppasswd", then for "-P passwd" */
 
1622
                        uO.pwdarg = s;
 
1623
                        if (*uO.pwdarg == '\0') {
 
1624
                            if (argc > 1) {
 
1625
                                --argc;
 
1626
                                uO.pwdarg = *++argv;
 
1627
                                if (*uO.pwdarg == '-') {
 
1628
                                    Info(slide, 0x401, ((char *)slide,
 
1629
                                      LoadFarString(MustGivePasswd)));
 
1630
                                    return(PK_PARAM);
 
1631
                                }
 
1632
                                /* else pwdarg points at decryption password */
 
1633
                            } else {
 
1634
                                Info(slide, 0x401, ((char *)slide,
 
1635
                                  LoadFarString(MustGivePasswd)));
 
1636
                                return(PK_PARAM);
 
1637
                            }
 
1638
                        }
 
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
 
1642
                         */
 
1643
                        if (*s != 0)
 
1644
                            while (*++s != 0)
 
1645
                                ;
 
1646
                    }
 
1647
                    break;
 
1648
#endif /* CRYPT */
 
1649
                case ('q'):    /* quiet:  fewer comments/messages */
 
1650
                    if (negative) {
 
1651
                        uO.qflag = MAX(uO.qflag-negative,0);
 
1652
                        negative = 0;
 
1653
                    } else
 
1654
                        ++uO.qflag;
 
1655
                    break;
 
1656
#ifdef QDOS
 
1657
                case ('Q'):   /* QDOS flags */
 
1658
                    qlflag ^= strtol(s, &s, 10);
 
1659
                    break;    /* we XOR this as we can config qlflags */
 
1660
#endif
 
1661
#ifdef TANDEM
 
1662
                case ('r'):    /* remove file extensions */
 
1663
                    if (negative)
 
1664
                        uO.rflag = FALSE, negative = 0;
 
1665
                    else
 
1666
                        uO.rflag = TRUE;
 
1667
                    break;
 
1668
#endif /* TANDEM */
 
1669
#ifdef DOS_FLX_NLM_OS2_W32
 
1670
                case ('s'):    /* spaces in filenames:  allow by default */
 
1671
                    if (negative)
 
1672
                        uO.sflag = FALSE, negative = 0;
 
1673
                    else
 
1674
                        uO.sflag = TRUE;
 
1675
                    break;
 
1676
#endif /* DOS_FLX_NLM_OS2_W32 */
 
1677
#ifdef VMS
 
1678
                /* VMS:  extract "text" files in Stream_LF format (-a[a]) */
 
1679
                case ('S'):
 
1680
                    if (negative)
 
1681
                        uO.S_flag = FALSE, negative = 0;
 
1682
                    else
 
1683
                        uO.S_flag = TRUE;
 
1684
                    break;
 
1685
#endif /* VMS */
 
1686
                case ('t'):
 
1687
                    if (negative)
 
1688
                        uO.tflag = FALSE, negative = 0;
 
1689
                    else
 
1690
                        uO.tflag = TRUE;
 
1691
                    break;
 
1692
#ifdef TIMESTAMP
 
1693
                case ('T'):
 
1694
                    if (negative)
 
1695
                        uO.T_flag = FALSE, negative = 0;
 
1696
                    else
 
1697
                        uO.T_flag = TRUE;
 
1698
                    break;
 
1699
#endif
 
1700
                case ('u'):    /* update (extract only new and newer files) */
 
1701
                    if (negative)
 
1702
                        uO.uflag = FALSE, negative = 0;
 
1703
                    else
 
1704
                        uO.uflag = TRUE;
 
1705
                    break;
 
1706
#ifdef UNICODE_SUPPORT
 
1707
                case ('U'):    /* escape UTF-8, or disable UTF-8 support */
 
1708
                    if (negative) {
 
1709
                        uO.U_flag = MAX(uO.U_flag-negative,0);
 
1710
                        negative = 0;
 
1711
                    } else
 
1712
                        uO.U_flag++;
 
1713
                    break;
 
1714
#else /* !UNICODE_SUPPORT */
 
1715
#ifndef CMS_MVS
 
1716
                case ('U'):    /* obsolete; to be removed in version 6.0 */
 
1717
                    if (negative)
 
1718
                        uO.L_flag = TRUE, negative = 0;
 
1719
                    else
 
1720
                        uO.L_flag = FALSE;
 
1721
                    break;
 
1722
#endif /* !CMS_MVS */
 
1723
#endif /* ?UNICODE_SUPPORT */
 
1724
#ifndef SFX
 
1725
                case ('v'):    /* verbose */
 
1726
                    if (negative) {
 
1727
                        uO.vflag = MAX(uO.vflag-negative,0);
 
1728
                        negative = 0;
 
1729
                    } else if (uO.vflag)
 
1730
                        ++uO.vflag;
 
1731
                    else
 
1732
                        uO.vflag = 2;
 
1733
                    break;
 
1734
#endif /* !SFX */
 
1735
#ifndef CMS_MVS
 
1736
                case ('V'):    /* Version (retain VMS/DEC-20 file versions) */
 
1737
                    if (negative)
 
1738
                        uO.V_flag = FALSE, negative = 0;
 
1739
                    else
 
1740
                        uO.V_flag = TRUE;
 
1741
                    break;
 
1742
#endif /* !CMS_MVS */
 
1743
#ifdef WILD_STOP_AT_DIR
 
1744
                case ('W'):    /* Wildcard interpretation (stop at '/'?) */
 
1745
                    if (negative)
 
1746
                        uO.W_flag = FALSE, negative = 0;
 
1747
                    else
 
1748
                        uO.W_flag = TRUE;
 
1749
                    break;
 
1750
#endif /* WILD_STOP_AT_DIR */
 
1751
                case ('x'):    /* extract:  default */
 
1752
#ifdef SFX
 
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
 
1758
                     */
 
1759
                    if (s - argv[0] == 2 && *s == '\0' &&
 
1760
                        argc > 1 && argv[1][0] != '-') {
 
1761
                        /* break out of nested loops without "++argv;--argc" */
 
1762
                        goto opts_done;
 
1763
                    }
 
1764
#endif /* SFX */
 
1765
                    break;
 
1766
#if (defined(RESTORE_UIDGID) || defined(RESTORE_ACL))
 
1767
                case ('X'):   /* restore owner/protection info (need privs?) */
 
1768
                    if (negative) {
 
1769
                        uO.X_flag = MAX(uO.X_flag-negative,0);
 
1770
                        negative = 0;
 
1771
                    } else
 
1772
                        ++uO.X_flag;
 
1773
                    break;
 
1774
#endif /* RESTORE_UIDGID || RESTORE_ACL */
 
1775
#ifdef VMS
 
1776
                case ('Y'):    /* Treat ".nnn" as ";nnn" version. */
 
1777
                    if (negative)
 
1778
                        uO.Y_flag = FALSE, negative = 0;
 
1779
                    else
 
1780
                        uO.Y_flag = TRUE;
 
1781
                    break;
 
1782
#endif /* VMS */
 
1783
                case ('z'):    /* display only the archive comment */
 
1784
                    if (negative) {
 
1785
                        uO.zflag = MAX(uO.zflag-negative,0);
 
1786
                        negative = 0;
 
1787
                    } else
 
1788
                        ++uO.zflag;
 
1789
                    break;
 
1790
#ifndef SFX
 
1791
                case ('Z'):    /* should have been first option (ZipInfo) */
 
1792
                    Info(slide, 0x401, ((char *)slide, LoadFarString(Zfirst)));
 
1793
                    error = TRUE;
 
1794
                    break;
 
1795
#endif /* !SFX */
 
1796
#ifdef VMS
 
1797
                case ('2'):    /* Force ODS2-compliant names. */
 
1798
                    if (negative)
 
1799
                        uO.ods2_flag = FALSE, negative = 0;
 
1800
                    else
 
1801
                        uO.ods2_flag = TRUE;
 
1802
                    break;
 
1803
#endif /* VMS */
 
1804
#ifdef DOS_H68_OS2_W32
 
1805
                case ('$'):
 
1806
                    if (negative) {
 
1807
                        uO.volflag = MAX(uO.volflag-negative,0);
 
1808
                        negative = 0;
 
1809
                    } else
 
1810
                        ++uO.volflag;
 
1811
                    break;
 
1812
#endif /* DOS_H68_OS2_W32 */
 
1813
#if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM))
 
1814
                case (':'):    /* allow "parent dir" path components */
 
1815
                    if (negative) {
 
1816
                        uO.ddotflag = MAX(uO.ddotflag-negative,0);
 
1817
                        negative = 0;
 
1818
                    } else
 
1819
                        ++uO.ddotflag;
 
1820
                    break;
 
1821
#endif /* !RISCOS && !CMS_MVS && !TANDEM */
 
1822
#ifdef UNIX
 
1823
                case ('^'):    /* allow control chars in filenames */
 
1824
                    if (negative) {
 
1825
                        uO.cflxflag = MAX(uO.cflxflag-negative,0);
 
1826
                        negative = 0;
 
1827
                    } else
 
1828
                        ++uO.cflxflag;
 
1829
                    break;
 
1830
#endif /* UNIX */
 
1831
                default:
 
1832
                    error = TRUE;
 
1833
                    break;
 
1834
 
 
1835
            } /* end switch */
 
1836
        } /* end while (not end of argument string) */
 
1837
    } /* end while (not done with switches) */
 
1838
 
 
1839
/*---------------------------------------------------------------------------
 
1840
    Check for nonsensical combinations of options.
 
1841
  ---------------------------------------------------------------------------*/
 
1842
 
 
1843
#ifdef SFX
 
1844
opts_done:  /* yes, very ugly...but only used by UnZipSFX with -x xlist */
 
1845
#endif
 
1846
 
 
1847
    if (showhelp > 0) {         /* just print help message and quit */
 
1848
        *pargc = -1;
 
1849
#ifndef SFX
 
1850
        if (showhelp == 2) {
 
1851
            help_extended(__G);
 
1852
            return PK_OK;
 
1853
        } else
 
1854
#endif /* !SFX */
 
1855
        {
 
1856
            return USAGE(PK_OK);
 
1857
        }
 
1858
    }
 
1859
 
 
1860
    if ((uO.cflag && (uO.tflag || uO.uflag)) ||
 
1861
        (uO.tflag && uO.uflag) || (uO.fflag && uO.overwrite_none))
 
1862
    {
 
1863
        Info(slide, 0x401, ((char *)slide, LoadFarString(InvalidOptionsMsg)));
 
1864
        error = TRUE;
 
1865
    }
 
1866
    if (uO.aflag > 2)
 
1867
        uO.aflag = 2;
 
1868
#ifdef VMS
 
1869
    if (uO.bflag > 2)
 
1870
        uO.bflag = 2;
 
1871
    /* Clear -s flag when converting text files. */
 
1872
    if (uO.aflag <= 0)
 
1873
        uO.S_flag = 0;
 
1874
#endif /* VMS */
 
1875
    if (uO.overwrite_all && uO.overwrite_none) {
 
1876
        Info(slide, 0x401, ((char *)slide, LoadFarString(IgnoreOOptionMsg)));
 
1877
        uO.overwrite_all = FALSE;
 
1878
    }
 
1879
#ifdef MORE
 
1880
    if (G.M_flag && !isatty(1))  /* stdout redirected: "more" func. useless */
 
1881
        G.M_flag = 0;
 
1882
#endif
 
1883
 
 
1884
#ifdef SFX
 
1885
    if (error)
 
1886
#else
 
1887
    if ((argc-- == 0) || error)
 
1888
#endif
 
1889
    {
 
1890
        *pargc = argc;
 
1891
        *pargv = argv;
 
1892
#ifndef SFX
 
1893
        if (uO.vflag >= 2 && argc == -1) {              /* "unzip -v" */
 
1894
            show_version_info(__G);
 
1895
            return PK_OK;
 
1896
        }
 
1897
        if (!G.noargs && !error)
 
1898
            error = TRUE;       /* had options (not -h or -v) but no zipfile */
 
1899
#endif /* !SFX */
 
1900
        return USAGE(error);
 
1901
    }
 
1902
 
 
1903
#ifdef SFX
 
1904
    /* print our banner unless we're being fairly quiet */
 
1905
    if (uO.qflag < 2)
 
1906
        Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(UnzipSFXBanner),
 
1907
          UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
 
1908
          LoadFarStringSmall(VersionDate)));
 
1909
#ifdef BETA
 
1910
    /* always print the beta warning:  no unauthorized distribution!! */
 
1911
    Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
 
1912
      "SFX"));
 
1913
#endif
 
1914
#endif /* SFX */
 
1915
 
 
1916
    if (uO.cflag || uO.tflag || uO.vflag || uO.zflag
 
1917
#ifdef TIMESTAMP
 
1918
                                                     || uO.T_flag
 
1919
#endif
 
1920
                                                                 )
 
1921
        G.extract_flag = FALSE;
 
1922
    else
 
1923
        G.extract_flag = TRUE;
 
1924
 
 
1925
    *pargc = argc;
 
1926
    *pargv = argv;
 
1927
    return PK_OK;
 
1928
 
 
1929
} /* end function uz_opts() */
 
1930
 
 
1931
 
 
1932
 
 
1933
 
 
1934
/********************/
 
1935
/* Function usage() */
 
1936
/********************/
 
1937
 
 
1938
#ifdef SFX
 
1939
#  ifdef VMS
 
1940
#    define LOCAL "X.\n\
 
1941
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)"
 
1942
#  endif
 
1943
#  ifdef UNIX
 
1944
#    define LOCAL "X"
 
1945
#  endif
 
1946
#  ifdef DOS_OS2_W32
 
1947
#    define LOCAL "s$"
 
1948
#  endif
 
1949
#  if (defined(FLEXOS) || defined(NLM))
 
1950
#    define LOCAL "s"
 
1951
#  endif
 
1952
#  ifdef AMIGA
 
1953
#    define LOCAL "N"
 
1954
#  endif
 
1955
   /* Default for all other systems: */
 
1956
#  ifndef LOCAL
 
1957
#    define LOCAL ""
 
1958
#  endif
 
1959
 
 
1960
#  ifndef NO_TIMESTAMP
 
1961
#    ifdef MORE
 
1962
#      define SFXOPT1 "DM"
 
1963
#    else
 
1964
#      define SFXOPT1 "D"
 
1965
#    endif
 
1966
#  else
 
1967
#    ifdef MORE
 
1968
#      define SFXOPT1 "M"
 
1969
#    else
 
1970
#      define SFXOPT1 ""
 
1971
#    endif
 
1972
#  endif
 
1973
 
 
1974
int usage(__G__ error)   /* return PK-type error code */
 
1975
    __GDEF
 
1976
    int error;
 
1977
{
 
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),
 
1982
      SFXOPT1, LOCAL));
 
1983
#ifdef BETA
 
1984
    Info(slide, error? 1 : 0, ((char *)slide, LoadFarString(BetaVersion), "\n",
 
1985
      "SFX"));
 
1986
#endif
 
1987
 
 
1988
    if (error)
 
1989
        return PK_PARAM;
 
1990
    else
 
1991
        return PK_COOL;     /* just wanted usage screen: no error */
 
1992
 
 
1993
} /* end function usage() */
 
1994
 
 
1995
 
 
1996
 
 
1997
 
 
1998
 
 
1999
#else /* !SFX */
 
2000
#  ifdef VMS
 
2001
#    define QUOT '\"'
 
2002
#    define QUOTS "\""
 
2003
#  else
 
2004
#    define QUOT ' '
 
2005
#    define QUOTS ""
 
2006
#  endif
 
2007
 
 
2008
int usage(__G__ error)   /* return PK-type error code */
 
2009
    __GDEF
 
2010
    int error;
 
2011
{
 
2012
    int flag = (error? 1 : 0);
 
2013
 
 
2014
 
 
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
  ---------------------------------------------------------------------------*/
 
2019
 
 
2020
    if (uO.zipinfo_mode) {
 
2021
 
 
2022
#ifndef NO_ZIPINFO
 
2023
 
 
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)));
 
2031
#ifdef VMS
 
2032
        Info(slide, flag, ((char *)slide, "\n\
 
2033
You must quote non-lowercase options and filespecs, unless SET PROC/PARSE=EXT.\
 
2034
\n"));
 
2035
#endif
 
2036
 
 
2037
#endif /* !NO_ZIPINFO */
 
2038
 
 
2039
    } else {   /* UnZip mode */
 
2040
 
 
2041
        Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine1),
 
2042
          UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL,
 
2043
          LoadFarStringSmall(VersionDate)));
 
2044
#ifdef BETA
 
2045
        Info(slide, flag, ((char *)slide, LoadFarString(BetaVersion), "", ""));
 
2046
#endif
 
2047
 
 
2048
        Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine2),
 
2049
          ZIPINFO_MODE_OPTION, LoadFarStringSmall(ZipInfoMode)));
 
2050
#ifdef VMS
 
2051
        if (!error)  /* maybe no command-line tail found; show extra help */
 
2052
            Info(slide, flag, ((char *)slide, LoadFarString(VMSusageLine2b)));
 
2053
#endif
 
2054
 
 
2055
        Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine3),
 
2056
          LoadFarStringSmall(local1)));
 
2057
 
 
2058
        Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine4),
 
2059
          LoadFarStringSmall(local2), LoadFarStringSmall2(local3)));
 
2060
 
 
2061
        /* This is extra work for SMALL_MEM, but it will work since
 
2062
         * LoadFarStringSmall2 uses the same buffer.  Remember, this
 
2063
         * is a hack. */
 
2064
        Info(slide, flag, ((char *)slide, LoadFarString(UnzipUsageLine5),
 
2065
          LoadFarStringSmall(Example2), LoadFarStringSmall2(Example3),
 
2066
          LoadFarStringSmall2(Example3)));
 
2067
 
 
2068
    } /* end if (uO.zipinfo_mode) */
 
2069
 
 
2070
    if (error)
 
2071
        return PK_PARAM;
 
2072
    else
 
2073
        return PK_COOL;     /* just wanted usage screen: no error */
 
2074
 
 
2075
} /* end function usage() */
 
2076
 
 
2077
#endif /* ?SFX */
 
2078
 
 
2079
 
 
2080
 
 
2081
 
 
2082
#ifndef SFX
 
2083
 
 
2084
/* Print extended help to stdout. */
 
2085
static void help_extended(__G)
 
2086
    __GDEF
 
2087
{
 
2088
    extent i;             /* counter for help array */
 
2089
 
 
2090
    /* help array */
 
2091
    static ZCONST char *text[] = {
 
2092
  "",
 
2093
  "Extended Help for UnZip",
 
2094
  "",
 
2095
  "See the UnZip Manual for more detailed help",
 
2096
  "",
 
2097
  "",
 
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",
 
2101
  "instead.",
 
2102
  "",
 
2103
  "Basic unzip command line:",
 
2104
  "  unzip [-Z] options archive[.zip] [file ...] [-x xfile ...] [-d exdir]",
 
2105
  "",
 
2106
  "Some examples:",
 
2107
  "  unzip -l foo.zip        - list files in short format in archive foo.zip",
 
2108
  "",
 
2109
  "  unzip -t foo            - test the files in archive foo",
 
2110
  "",
 
2111
  "  unzip -Z foo            - list files using more detailed zipinfo format",
 
2112
  "",
 
2113
  "  unzip foo               - unzip the contents of foo in current dir",
 
2114
  "",
 
2115
  "  unzip -a foo            - unzip foo and convert text files to local OS",
 
2116
  "",
 
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",
 
2119
  "options.",
 
2120
  "",
 
2121
  "Basic zipinfo command line:",
 
2122
  "  zipinfo options archive[.zip] [file ...] [-x xfile ...]",
 
2123
  "  unzip -Z options archive[.zip] [file ...] [-x xfile ...]",
 
2124
  "",
 
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.",
 
2127
  "",
 
2128
  "",
 
2129
  "unzip options:",
 
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",
 
2145
  "         verbose output.",
 
2146
  "  -z   Display only archive comment.",
 
2147
  "",
 
2148
  "unzip modifiers:",
 
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",
 
2160
  "         restore.",
 
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",
 
2174
  "         care.",
 
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.",
 
2208
  "",
 
2209
  "",
 
2210
  "Wildcards:",
 
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.",
 
2217
  "",
 
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 ...",
 
2224
  "",
 
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.",
 
2229
  "",
 
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",
 
2234
  "",
 
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.",
 
2239
  "",
 
2240
  "Unicode:",
 
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",
 
2246
  "  digit.",
 
2247
  "",
 
2248
  "",
 
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.",
 
2267
  "",
 
2268
  "",
 
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.",
 
2273
  "",
 
2274
  "funzip command line:",
 
2275
  "  funzip [-password] [input[.zip|.gz]]",
 
2276
  "",
 
2277
  "",
 
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.",
 
2284
  "",
 
2285
  "unzipsfx command line:",
 
2286
  "  <unzipsfx+archive_filename>  [-options] [file(s) ... [-x xfile(s) ...]]",
 
2287
  "",
 
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.)",
 
2293
  "",
 
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.",
 
2305
  "",
 
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.",
 
2310
  "",
 
2311
  "See unzipsfx manual page for more information.",
 
2312
  ""
 
2313
    };
 
2314
 
 
2315
    for (i = 0; i < sizeof(text)/sizeof(char *); i++)
 
2316
    {
 
2317
        Info(slide, 0, ((char *)slide, "%s\n", text[i]));
 
2318
    }
 
2319
} /* end function help_extended() */
 
2320
 
 
2321
 
 
2322
 
 
2323
 
 
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();
 
2328
#endif
 
2329
#endif
 
2330
 
 
2331
/********************************/
 
2332
/* Function show_version_info() */
 
2333
/********************************/
 
2334
 
 
2335
static void show_version_info(__G)
 
2336
    __GDEF
 
2337
{
 
2338
    if (uO.qflag > 3)                           /* "unzip -vqqqq" */
 
2339
        Info(slide, 0, ((char *)slide, "%d\n",
 
2340
          (UZ_MAJORVER*100 + UZ_MINORVER*10 + UZ_PATCHLEVEL)));
 
2341
    else {
 
2342
#ifndef _WIN32_WCE /* Win CE does not support environment variables */
 
2343
        char *envptr;
 
2344
#endif
 
2345
        int numopts = 0;
 
2346
 
 
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)));
 
2352
        version(__G);
 
2353
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptions)));
 
2354
#ifdef ACORN_FTYPE_NFS
 
2355
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2356
          LoadFarStringSmall(AcornFtypeNFS)));
 
2357
        ++numopts;
 
2358
#endif
 
2359
#ifdef ASM_CRC
 
2360
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2361
          LoadFarStringSmall(AsmCRC)));
 
2362
        ++numopts;
 
2363
#endif
 
2364
#ifdef ASM_INFLATECODES
 
2365
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2366
          LoadFarStringSmall(AsmInflateCodes)));
 
2367
        ++numopts;
 
2368
#endif
 
2369
#ifdef CHECK_VERSIONS
 
2370
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2371
          LoadFarStringSmall(Check_Versions)));
 
2372
        ++numopts;
 
2373
#endif
 
2374
#ifdef COPYRIGHT_CLEAN
 
2375
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2376
          LoadFarStringSmall(Copyright_Clean)));
 
2377
        ++numopts;
 
2378
#endif
 
2379
#ifdef DEBUG
 
2380
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2381
          LoadFarStringSmall(UDebug)));
 
2382
        ++numopts;
 
2383
#endif
 
2384
#ifdef DEBUG_TIME
 
2385
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2386
          LoadFarStringSmall(DebugTime)));
 
2387
        ++numopts;
 
2388
#endif
 
2389
#ifdef DLL
 
2390
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2391
          LoadFarStringSmall(Dll)));
 
2392
        ++numopts;
 
2393
#endif
 
2394
#ifdef DOSWILD
 
2395
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2396
          LoadFarStringSmall(DosWild)));
 
2397
        ++numopts;
 
2398
#endif
 
2399
#ifdef LZW_CLEAN
 
2400
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2401
          LoadFarStringSmall(LZW_Clean)));
 
2402
        ++numopts;
 
2403
#endif
 
2404
#ifndef MORE
 
2405
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2406
          LoadFarStringSmall(No_More)));
 
2407
        ++numopts;
 
2408
#endif
 
2409
#ifdef NO_ZIPINFO
 
2410
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2411
          LoadFarStringSmall(No_ZipInfo)));
 
2412
        ++numopts;
 
2413
#endif
 
2414
#ifdef NTSD_EAS
 
2415
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2416
          LoadFarStringSmall(NTSDExtAttrib)));
 
2417
        ++numopts;
 
2418
#endif
 
2419
#if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
 
2420
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2421
          LoadFarStringSmall(W32NoIZTimeFix)));
 
2422
        ++numopts;
 
2423
#endif
 
2424
#ifdef OLD_THEOS_EXTRA
 
2425
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2426
          LoadFarStringSmall(OldTheosExtra)));
 
2427
        ++numopts;
 
2428
#endif
 
2429
#ifdef OS2_EAS
 
2430
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2431
          LoadFarStringSmall(OS2ExtAttrib)));
 
2432
        ++numopts;
 
2433
#endif
 
2434
#ifdef QLZIP
 
2435
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2436
          LoadFarStringSmall(SMSExFldOnUnix)));
 
2437
        ++numopts;
 
2438
#endif
 
2439
#ifdef REENTRANT
 
2440
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2441
          LoadFarStringSmall(Reentrant)));
 
2442
        ++numopts;
 
2443
#endif
 
2444
#ifdef REGARGS
 
2445
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2446
          LoadFarStringSmall(RegArgs)));
 
2447
        ++numopts;
 
2448
#endif
 
2449
#ifdef RETURN_CODES
 
2450
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2451
          LoadFarStringSmall(Return_Codes)));
 
2452
        ++numopts;
 
2453
#endif
 
2454
#ifdef SET_DIR_ATTRIB
 
2455
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2456
          LoadFarStringSmall(SetDirAttrib)));
 
2457
        ++numopts;
 
2458
#endif
 
2459
#ifdef SYMLINKS
 
2460
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2461
          LoadFarStringSmall(SymLinkSupport)));
 
2462
        ++numopts;
 
2463
#endif
 
2464
#ifdef TIMESTAMP
 
2465
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2466
          LoadFarStringSmall(TimeStamp)));
 
2467
        ++numopts;
 
2468
#endif
 
2469
#ifdef UNIXBACKUP
 
2470
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2471
          LoadFarStringSmall(UnixBackup)));
 
2472
        ++numopts;
 
2473
#endif
 
2474
#ifdef USE_EF_UT_TIME
 
2475
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2476
          LoadFarStringSmall(Use_EF_UT_time)));
 
2477
        ++numopts;
 
2478
#endif
 
2479
#ifndef COPYRIGHT_CLEAN
 
2480
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2481
          LoadFarStringSmall(Use_Smith_Code)));
 
2482
        ++numopts;
 
2483
#endif
 
2484
#ifndef LZW_CLEAN
 
2485
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2486
          LoadFarStringSmall(Use_Unshrink)));
 
2487
        ++numopts;
 
2488
#endif
 
2489
#ifdef USE_DEFLATE64
 
2490
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2491
          LoadFarStringSmall(Use_Deflate64)));
 
2492
        ++numopts;
 
2493
#endif
 
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)));
 
2500
# else
 
2501
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2502
          LoadFarStringSmall(Use_Unicode)));
 
2503
# endif
 
2504
        ++numopts;
 
2505
#endif
 
2506
#ifdef _MBCS
 
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)));
 
2511
        ++numopts;
 
2512
#endif
 
2513
#ifdef MULT_VOLUME
 
2514
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2515
          LoadFarStringSmall(Use_MultiVol)));
 
2516
        ++numopts;
 
2517
#endif
 
2518
#ifdef LARGE_FILE_SUPPORT
 
2519
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2520
          LoadFarStringSmall(Use_LFS)));
 
2521
        ++numopts;
 
2522
#endif
 
2523
#ifdef ZIP64_SUPPORT
 
2524
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2525
          LoadFarStringSmall(Use_Zip64)));
 
2526
        ++numopts;
 
2527
#endif
 
2528
#if (defined(__DJGPP__) && (__DJGPP__ >= 2))
 
2529
#  ifdef USE_DJGPP_ENV
 
2530
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2531
          LoadFarStringSmall(Use_DJGPP_Env)));
 
2532
        ++numopts;
 
2533
#  endif
 
2534
#  ifdef USE_DJGPP_GLOB
 
2535
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2536
          LoadFarStringSmall(Use_DJGPP_Glob)));
 
2537
        ++numopts;
 
2538
#  endif
 
2539
#endif /* __DJGPP__ && (__DJGPP__ >= 2) */
 
2540
#ifdef USE_VFAT
 
2541
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2542
          LoadFarStringSmall(Use_VFAT_support)));
 
2543
        ++numopts;
 
2544
#endif
 
2545
#ifdef USE_ZLIB
 
2546
        sprintf((char *)(slide+256), LoadFarStringSmall(UseZlib),
 
2547
          ZLIB_VERSION, zlibVersion());
 
2548
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2549
          (char *)(slide+256)));
 
2550
        ++numopts;
 
2551
#endif
 
2552
#ifdef USE_BZIP2
 
2553
        sprintf((char *)(slide+256), LoadFarStringSmall(UseBZip2),
 
2554
          BZ2_bzlibVersion());
 
2555
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2556
          (char *)(slide+256)));
 
2557
        ++numopts;
 
2558
#endif
 
2559
#ifdef VMS_TEXT_CONV
 
2560
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2561
          LoadFarStringSmall(VmsTextConv)));
 
2562
        ++numopts;
 
2563
#endif
 
2564
#ifdef VMSCLI
 
2565
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2566
          LoadFarStringSmall(VmsCLI)));
 
2567
        ++numopts;
 
2568
#endif
 
2569
#ifdef VMSWILD
 
2570
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2571
          LoadFarStringSmall(VmsWild)));
 
2572
        ++numopts;
 
2573
#endif
 
2574
#ifdef WILD_STOP_AT_DIR
 
2575
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2576
          LoadFarStringSmall(WildStopAtDir)));
 
2577
        ++numopts;
 
2578
#endif
 
2579
#if CRYPT
 
2580
# ifdef PASSWD_FROM_STDIN
 
2581
        Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat),
 
2582
          LoadFarStringSmall(PasswdStdin)));
 
2583
# endif
 
2584
        Info(slide, 0, ((char *)slide, LoadFarString(Decryption),
 
2585
          CR_MAJORVER, CR_MINORVER, CR_BETA_VER,
 
2586
          LoadFarStringSmall(CryptDate)));
 
2587
        ++numopts;
 
2588
#endif /* CRYPT */
 
2589
        if (numopts == 0)
 
2590
            Info(slide, 0, ((char *)slide,
 
2591
              LoadFarString(CompileOptFormat),
 
2592
              LoadFarStringSmall(None)));
 
2593
 
 
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));
 
2616
#ifndef __RSXNT__
 
2617
#ifdef __EMX__
 
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__ */
 
2642
#ifdef RISCOS
 
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));
 
2648
#endif /* RISCOS */
 
2649
#endif /* !_WIN32_WCE */
 
2650
    }
 
2651
} /* end function show_version() */
 
2652
 
 
2653
#endif /* !SFX */
 
2654
#endif /* !WINDLL */