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

« back to all changes in this revision

Viewing changes to zipinfo.c.orig

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-06-25 15:57:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080625155703-rea6vbrcb62yry5m
Tags: 5.52-11ubuntu1
* Merge with Debian; remaining changes:
  - debian/rules: Configure with large file support.
  - unzip.c: Change banner to indicate Ubuntu modification.
  - support UTF-8 file names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  Copyright (c) 1990-2005 Info-ZIP.  All rights reserved.
3
 
 
4
 
  See the accompanying file LICENSE, version 2000-Apr-09 or later
5
 
  (the contents of which are also included in unzip.h) for terms of use.
6
 
  If, for some reason, all these files are missing, the Info-ZIP license
7
 
  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
8
 
*/
9
 
/*---------------------------------------------------------------------------
10
 
 
11
 
  zipinfo.c                                              Greg Roelofs et al.
12
 
 
13
 
  This file contains all of the ZipInfo-specific listing routines for UnZip.
14
 
 
15
 
  Contains:  zi_opts()
16
 
             zi_end_central()
17
 
             zipinfo()
18
 
             zi_long()
19
 
             zi_short()
20
 
             zi_time()
21
 
 
22
 
  ---------------------------------------------------------------------------*/
23
 
 
24
 
 
25
 
#define UNZIP_INTERNAL
26
 
#include "unzip.h"
27
 
 
28
 
 
29
 
#ifndef NO_ZIPINFO  /* strings use up too much space in small-memory systems */
30
 
 
31
 
/* Define OS-specific attributes for use on ALL platforms--the S_xxxx
32
 
 * versions of these are defined differently (or not defined) by different
33
 
 * compilers and operating systems. */
34
 
 
35
 
#define UNX_IFMT       0170000     /* Unix file type mask */
36
 
#define UNX_IFREG      0100000     /* Unix regular file */
37
 
#define UNX_IFSOCK     0140000     /* Unix socket (BSD, not SysV or Amiga) */
38
 
#define UNX_IFLNK      0120000     /* Unix symbolic link (not SysV, Amiga) */
39
 
#define UNX_IFBLK      0060000     /* Unix block special       (not Amiga) */
40
 
#define UNX_IFDIR      0040000     /* Unix directory */
41
 
#define UNX_IFCHR      0020000     /* Unix character special   (not Amiga) */
42
 
#define UNX_IFIFO      0010000     /* Unix fifo    (BCC, not MSC or Amiga) */
43
 
#define UNX_ISUID      04000       /* Unix set user id on execution */
44
 
#define UNX_ISGID      02000       /* Unix set group id on execution */
45
 
#define UNX_ISVTX      01000       /* Unix directory permissions control */
46
 
#define UNX_ENFMT      UNX_ISGID   /* Unix record locking enforcement flag */
47
 
#define UNX_IRWXU      00700       /* Unix read, write, execute: owner */
48
 
#define UNX_IRUSR      00400       /* Unix read permission: owner */
49
 
#define UNX_IWUSR      00200       /* Unix write permission: owner */
50
 
#define UNX_IXUSR      00100       /* Unix execute permission: owner */
51
 
#define UNX_IRWXG      00070       /* Unix read, write, execute: group */
52
 
#define UNX_IRGRP      00040       /* Unix read permission: group */
53
 
#define UNX_IWGRP      00020       /* Unix write permission: group */
54
 
#define UNX_IXGRP      00010       /* Unix execute permission: group */
55
 
#define UNX_IRWXO      00007       /* Unix read, write, execute: other */
56
 
#define UNX_IROTH      00004       /* Unix read permission: other */
57
 
#define UNX_IWOTH      00002       /* Unix write permission: other */
58
 
#define UNX_IXOTH      00001       /* Unix execute permission: other */
59
 
 
60
 
#define VMS_IRUSR      UNX_IRUSR   /* VMS read/owner */
61
 
#define VMS_IWUSR      UNX_IWUSR   /* VMS write/owner */
62
 
#define VMS_IXUSR      UNX_IXUSR   /* VMS execute/owner */
63
 
#define VMS_IRGRP      UNX_IRGRP   /* VMS read/group */
64
 
#define VMS_IWGRP      UNX_IWGRP   /* VMS write/group */
65
 
#define VMS_IXGRP      UNX_IXGRP   /* VMS execute/group */
66
 
#define VMS_IROTH      UNX_IROTH   /* VMS read/other */
67
 
#define VMS_IWOTH      UNX_IWOTH   /* VMS write/other */
68
 
#define VMS_IXOTH      UNX_IXOTH   /* VMS execute/other */
69
 
 
70
 
#define AMI_IFMT       06000       /* Amiga file type mask */
71
 
#define AMI_IFDIR      04000       /* Amiga directory */
72
 
#define AMI_IFREG      02000       /* Amiga regular file */
73
 
#define AMI_IHIDDEN    00200       /* to be supported in AmigaDOS 3.x */
74
 
#define AMI_ISCRIPT    00100       /* executable script (text command file) */
75
 
#define AMI_IPURE      00040       /* allow loading into resident memory */
76
 
#define AMI_IARCHIVE   00020       /* not modified since bit was last set */
77
 
#define AMI_IREAD      00010       /* can be opened for reading */
78
 
#define AMI_IWRITE     00004       /* can be opened for writing */
79
 
#define AMI_IEXECUTE   00002       /* executable image, a loadable runfile */
80
 
#define AMI_IDELETE    00001       /* can be deleted */
81
 
 
82
 
#define THS_IFMT    0xF000         /* Theos file type mask */
83
 
#define THS_IFIFO   0x1000         /* pipe */
84
 
#define THS_IFCHR   0x2000         /* char device */
85
 
#define THS_IFSOCK  0x3000         /* socket */
86
 
#define THS_IFDIR   0x4000         /* directory */
87
 
#define THS_IFLIB   0x5000         /* library */
88
 
#define THS_IFBLK   0x6000         /* block device */
89
 
#define THS_IFREG   0x8000         /* regular file */
90
 
#define THS_IFREL   0x9000         /* relative (direct) */
91
 
#define THS_IFKEY   0xA000         /* keyed */
92
 
#define THS_IFIND   0xB000         /* indexed */
93
 
#define THS_IFRND   0xC000         /* ???? */
94
 
#define THS_IFR16   0xD000         /* 16 bit real mode program */
95
 
#define THS_IFP16   0xE000         /* 16 bit protected mode prog */
96
 
#define THS_IFP32   0xF000         /* 32 bit protected mode prog */
97
 
#define THS_IMODF   0x0800         /* modified */
98
 
#define THS_INHID   0x0400         /* not hidden */
99
 
#define THS_IEUSR   0x0200         /* erase permission: owner */
100
 
#define THS_IRUSR   0x0100         /* read permission: owner */
101
 
#define THS_IWUSR   0x0080         /* write permission: owner */
102
 
#define THS_IXUSR   0x0040         /* execute permission: owner */
103
 
#define THS_IROTH   0x0004         /* read permission: other */
104
 
#define THS_IWOTH   0x0002         /* write permission: other */
105
 
#define THS_IXOTH   0x0001         /* execute permission: other */
106
 
 
107
 
#ifdef OLD_THEOS_EXTRA
108
 
#  include "theos/oldstat.h"
109
 
#endif
110
 
 
111
 
#ifndef NSK_UNSTRUCTURED
112
 
# define NSK_UNSTRUCTURED   0
113
 
#endif
114
 
#ifndef NSK_OBJECTFILECODE
115
 
# define NSK_OBJECTFILECODE 100
116
 
#endif
117
 
#ifndef NSK_EDITFILECODE
118
 
# define NSK_EDITFILECODE   101
119
 
#endif
120
 
 
121
 
#define LFLAG  3   /* short "ls -l" type listing */
122
 
 
123
 
static int   zi_long   OF((__GPRO__ ulg *pEndprev));
124
 
static int   zi_short  OF((__GPRO));
125
 
static void  zi_showMacTypeCreator
126
 
                       OF((__GPRO__ uch *ebfield));
127
 
static char *zi_time   OF((__GPRO__ ZCONST ulg *datetimez,
128
 
                           ZCONST time_t *modtimez, char *d_t_str));
129
 
 
130
 
 
131
 
/**********************************************/
132
 
/*  Strings used in zipinfo.c (ZipInfo half)  */
133
 
/**********************************************/
134
 
 
135
 
static ZCONST char nullStr[] = "";
136
 
static ZCONST char PlurSufx[] = "s";
137
 
 
138
 
static ZCONST char Far LongHeader[] = "Archive:  %s   %ld bytes   %u file%s\n";
139
 
static ZCONST char Far ShortHeader[] = "Archive:  %s   %ld   %u\n";
140
 
static ZCONST char Far EndCentDirRec[] = "\nEnd-of-central-directory record:\n";
141
 
static ZCONST char Far LineSeparators[] = "-------------------------------\n\n";
142
 
static ZCONST char Far ActOffsetCentDir[] = "\
143
 
  Actual offset of end-of-central-dir record:   %9ld (%.8lXh)\n\
144
 
  Expected offset of end-of-central-dir record: %9ld (%.8lXh)\n\
145
 
  (based on the length of the central directory and its expected offset)\n\n";
146
 
static ZCONST char Far SinglePartArchive1[] = "\
147
 
  This zipfile constitutes the sole disk of a single-part archive; its\n\
148
 
  central directory contains %u %s.  The central directory is %lu\n\
149
 
  (%.8lXh) bytes long, and its (expected) offset in bytes from the\n";
150
 
static ZCONST char Far SinglePartArchive2[] = "\
151
 
  beginning of the zipfile is %lu (%.8lXh).\n\n";
152
 
static ZCONST char Far MultiPartArchive1[] = "\
153
 
  This zipfile constitutes disk %u of a multi-part archive.  The central\n\
154
 
  directory starts on disk %u; %u of its entries %s contained within\n";
155
 
static ZCONST char Far MultiPartArchive2[] = "\
156
 
  this zipfile, out of a total of %u %s.  The entire central\n\
157
 
  directory is %lu (%.8lXh) bytes long, and its offset in bytes from\n";
158
 
static ZCONST char Far MultiPartArchive3[] = "\
159
 
  the beginning of the zipfile in which it begins is %lu (%.8lXh).\n\n";
160
 
static ZCONST char Far NoZipfileComment[] = "  There is no zipfile comment.\n";
161
 
static ZCONST char Far ZipfileCommentDesc[] =
162
 
  "  The zipfile comment is %u bytes long and contains the following text:\n\n";
163
 
static ZCONST char Far ZipfileCommBegin[] =
164
 
 "======================== zipfile comment begins ==========================\n";
165
 
static ZCONST char Far ZipfileCommEnd[] =
166
 
 "========================= zipfile comment ends ===========================\n";
167
 
static ZCONST char Far ZipfileCommTrunc2[] =
168
 
  "\n  The zipfile comment is truncated.\n";
169
 
static ZCONST char Far ZipfileCommTruncMsg[] =
170
 
  "\ncaution:  zipfile comment truncated\n";
171
 
 
172
 
static ZCONST char Far CentralDirEntry[] =
173
 
  "\nCentral directory entry #%lu:\n---------------------------\n\n";
174
 
static ZCONST char Far ZipfileStats[] =
175
 
  "%lu file%s, %lu bytes uncompressed, %lu bytes compressed:  %s%d.%d%%\n";
176
 
 
177
 
/* zi_long() strings */
178
 
static ZCONST char Far OS_FAT[] = "MS-DOS, OS/2 or NT FAT";
179
 
static ZCONST char Far OS_Amiga[] = "Amiga";
180
 
static ZCONST char Far OS_VMS[] = "VMS";
181
 
static ZCONST char Far OS_Unix[] = "Unix";
182
 
static ZCONST char Far OS_VMCMS[] = "VM/CMS";
183
 
static ZCONST char Far OS_AtariST[] = "Atari ST";
184
 
static ZCONST char Far OS_HPFS[] = "OS/2 or NT HPFS";
185
 
static ZCONST char Far OS_Macintosh[] = "Macintosh HFS";
186
 
static ZCONST char Far OS_ZSystem[] = "Z-System";
187
 
static ZCONST char Far OS_CPM[] = "CP/M";
188
 
static ZCONST char Far OS_TOPS20[] = "TOPS-20";
189
 
static ZCONST char Far OS_NTFS[] = "NTFS";
190
 
static ZCONST char Far OS_QDOS[] = "SMS/QDOS";
191
 
static ZCONST char Far OS_Acorn[] = "Acorn RISC OS";
192
 
static ZCONST char Far OS_MVS[] = "MVS";
193
 
static ZCONST char Far OS_VFAT[] = "Win32 VFAT";
194
 
static ZCONST char Far OS_AtheOS[] = "AtheOS";
195
 
static ZCONST char Far OS_BeOS[] = "BeOS";
196
 
static ZCONST char Far OS_Tandem[] = "Tandem NSK";
197
 
static ZCONST char Far OS_Theos[] = "Theos";
198
 
static ZCONST char Far OS_MacDarwin[] = "Mac OS/X (Darwin)";
199
 
#ifdef OLD_THEOS_EXTRA
200
 
  static ZCONST char Far OS_TheosOld[] = "Theos (Old)";
201
 
#endif /* OLD_THEOS_EXTRA */
202
 
 
203
 
static ZCONST char Far MthdNone[] = "none (stored)";
204
 
static ZCONST char Far MthdShrunk[] = "shrunk";
205
 
static ZCONST char Far MthdRedF1[] = "reduced (factor 1)";
206
 
static ZCONST char Far MthdRedF2[] = "reduced (factor 2)";
207
 
static ZCONST char Far MthdRedF3[] = "reduced (factor 3)";
208
 
static ZCONST char Far MthdRedF4[] = "reduced (factor 4)";
209
 
static ZCONST char Far MthdImplode[] = "imploded";
210
 
static ZCONST char Far MthdToken[] = "tokenized";
211
 
static ZCONST char Far MthdDeflate[] = "deflated";
212
 
static ZCONST char Far MthdDeflat64[] = "deflated (enhanced-64k)";
213
 
static ZCONST char Far MthdDCLImplode[] = "imploded (PK DCL)";
214
 
static ZCONST char Far MthdPKRes11[] = "unkn. #11 (PK reserved)";
215
 
static ZCONST char Far MthdBZip2[] = "bzipped";
216
 
 
217
 
static ZCONST char Far DeflNorm[] = "normal";
218
 
static ZCONST char Far DeflMax[] = "maximum";
219
 
static ZCONST char Far DeflFast[] = "fast";
220
 
static ZCONST char Far DeflSFast[] = "superfast";
221
 
 
222
 
static ZCONST char Far ExtraBytesPreceding[] =
223
 
  "  There are an extra %ld bytes preceding this file.\n\n";
224
 
 
225
 
static ZCONST char Far UnknownNo[] = "unknown (%d)";
226
 
 
227
 
static ZCONST char Far LocalHeaderOffset[] =
228
 
  "\n  offset of local header from start of archive:     %lu (%.8lXh) bytes\n";
229
 
static ZCONST char Far HostOS[] =
230
 
  "  file system or operating system of origin:        %s\n";
231
 
static ZCONST char Far EncodeSWVer[] =
232
 
  "  version of encoding software:                     %u.%u\n";
233
 
static ZCONST char Far MinOSCompReq[] =
234
 
  "  minimum file system compatibility required:       %s\n";
235
 
static ZCONST char Far MinSWVerReq[] =
236
 
  "  minimum software version required to extract:     %u.%u\n";
237
 
static ZCONST char Far CompressMethod[] =
238
 
  "  compression method:                               %s\n";
239
 
static ZCONST char Far SlideWindowSizeImplode[] =
240
 
  "  size of sliding dictionary (implosion):           %cK\n";
241
 
static ZCONST char Far ShannonFanoTrees[] =
242
 
  "  number of Shannon-Fano trees (implosion):         %c\n";
243
 
static ZCONST char Far CompressSubtype[] =
244
 
  "  compression sub-type (deflation):                 %s\n";
245
 
static ZCONST char Far FileSecurity[] =
246
 
  "  file security status:                             %sencrypted\n";
247
 
static ZCONST char Far ExtendedLocalHdr[] =
248
 
  "  extended local header:                            %s\n";
249
 
static ZCONST char Far FileModDate[] =
250
 
  "  file last modified on (DOS date/time):            %s\n";
251
 
#ifdef USE_EF_UT_TIME
252
 
  static ZCONST char Far UT_FileModDate[] =
253
 
    "  file last modified on (UT extra field modtime):   %s %s\n";
254
 
  static ZCONST char Far LocalTime[] = "local";
255
 
#ifndef NO_GMTIME
256
 
  static ZCONST char Far GMTime[] = "UTC";
257
 
#endif
258
 
#endif /* USE_EF_UT_TIME */
259
 
static ZCONST char Far CRC32Value[] =
260
 
  "  32-bit CRC value (hex):                           %.8lx\n";
261
 
static ZCONST char Far CompressedFileSize[] =
262
 
  "  compressed size:                                  %lu bytes\n";
263
 
static ZCONST char Far UncompressedFileSize[] =
264
 
  "  uncompressed size:                                %lu bytes\n";
265
 
static ZCONST char Far FilenameLength[] =
266
 
  "  length of filename:                               %u characters\n";
267
 
static ZCONST char Far ExtraFieldLength[] =
268
 
  "  length of extra field:                            %u bytes\n";
269
 
static ZCONST char Far FileCommentLength[] =
270
 
  "  length of file comment:                           %u characters\n";
271
 
static ZCONST char Far FileDiskNum[] =
272
 
  "  disk number on which file begins:                 disk %u\n";
273
 
static ZCONST char Far ApparentFileType[] =
274
 
  "  apparent file type:                               %s\n";
275
 
static ZCONST char Far VMSFileAttributes[] =
276
 
  "  VMS file attributes (%06o octal):               %s\n";
277
 
static ZCONST char Far AmigaFileAttributes[] =
278
 
  "  Amiga file attributes (%06o octal):             %s\n";
279
 
static ZCONST char Far UnixFileAttributes[] =
280
 
  "  Unix file attributes (%06o octal):              %s\n";
281
 
static ZCONST char Far NonMSDOSFileAttributes[] =
282
 
  "  non-MSDOS external file attributes:               %06lX hex\n";
283
 
static ZCONST char Far MSDOSFileAttributes[] =
284
 
  "  MS-DOS file attributes (%02X hex):                  none\n";
285
 
static ZCONST char Far MSDOSFileAttributesRO[] =
286
 
  "  MS-DOS file attributes (%02X hex):                  read-only\n";
287
 
static ZCONST char Far MSDOSFileAttributesAlpha[] =
288
 
  "  MS-DOS file attributes (%02X hex):                  %s%s%s%s%s%s%s%s\n";
289
 
static ZCONST char Far TheosFileAttributes[] =
290
 
  "  Theos file attributes (%04X hex):                 %s\n";
291
 
 
292
 
static ZCONST char Far TheosFTypLib[] = "Library     ";
293
 
static ZCONST char Far TheosFTypDir[] = "Directory   ";
294
 
static ZCONST char Far TheosFTypReg[] = "Sequential  ";
295
 
static ZCONST char Far TheosFTypRel[] = "Direct      ";
296
 
static ZCONST char Far TheosFTypKey[] = "Keyed       ";
297
 
static ZCONST char Far TheosFTypInd[] = "Indexed     ";
298
 
static ZCONST char Far TheosFTypR16[] = " 86 program ";
299
 
static ZCONST char Far TheosFTypP16[] = "286 program ";
300
 
static ZCONST char Far TheosFTypP32[] = "386 program ";
301
 
static ZCONST char Far TheosFTypUkn[] = "???         ";
302
 
 
303
 
static ZCONST char Far ExtraFieldTrunc[] = "\n\
304
 
  error: EF data block (type 0x%04x) size %u exceeds remaining extra field\n\
305
 
         space %u; block length has been truncated.\n";
306
 
static ZCONST char Far ExtraFields[] = "\n\
307
 
  The central-directory extra field contains:";
308
 
static ZCONST char Far ExtraFieldType[] = "\n\
309
 
  - A subfield with ID 0x%04x (%s) and %u data bytes";
310
 
static ZCONST char Far efPKSZ64[] = "PKWARE 64-bit sizes";
311
 
static ZCONST char Far efAV[] = "PKWARE AV";
312
 
static ZCONST char Far efOS2[] = "OS/2";
313
 
static ZCONST char Far efPKVMS[] = "PKWARE VMS";
314
 
static ZCONST char Far efPKWin32[] = "PKWARE Win32";
315
 
static ZCONST char Far efPKUnix[] = "PKWARE Unix";
316
 
static ZCONST char Far efIZVMS[] = "Info-ZIP VMS";
317
 
static ZCONST char Far efIZUnix[] = "old Info-ZIP Unix/OS2/NT";
318
 
static ZCONST char Far efIZUnix2[] = "Unix UID/GID";
319
 
static ZCONST char Far efTime[] = "universal time";
320
 
static ZCONST char Far efJLMac[] = "old Info-ZIP Macintosh";
321
 
static ZCONST char Far efMac3[] = "new Info-ZIP Macintosh";
322
 
static ZCONST char Far efZipIt[] = "ZipIt Macintosh";
323
 
static ZCONST char Far efSmartZip[] = "SmartZip Macintosh";
324
 
static ZCONST char Far efZipIt2[] = "ZipIt Macintosh (short)";
325
 
static ZCONST char Far efVMCMS[] = "VM/CMS";
326
 
static ZCONST char Far efMVS[] = "MVS";
327
 
static ZCONST char Far efACL[] = "OS/2 ACL";
328
 
static ZCONST char Far efNTSD[] = "Security Descriptor";
329
 
static ZCONST char Far efAtheOS[] = "AtheOS";
330
 
static ZCONST char Far efBeOS[] = "BeOS";
331
 
static ZCONST char Far efQDOS[] = "SMS/QDOS";
332
 
static ZCONST char Far efAOSVS[] = "AOS/VS";
333
 
static ZCONST char Far efSpark[] = "Acorn SparkFS";
334
 
static ZCONST char Far efMD5[] = "Fred Kantor MD5";
335
 
static ZCONST char Far efASiUnix[] = "ASi Unix";
336
 
static ZCONST char Far efTandem[] = "Tandem NSK";
337
 
static ZCONST char Far efTheos[] = "Theos";
338
 
static ZCONST char Far efUnknown[] = "unknown";
339
 
 
340
 
static ZCONST char Far OS2EAs[] = ".\n\
341
 
    The local extra field has %lu bytes of OS/2 extended attributes.\n\
342
 
    (May not match OS/2 \"dir\" amount due to storage method)";
343
 
static ZCONST char Far izVMSdata[] = ".  The extra\n\
344
 
    field is %s and has %u bytes of VMS %s information%s";
345
 
static ZCONST char Far izVMSstored[] = "stored";
346
 
static ZCONST char Far izVMSrleenc[] = "run-length encoded";
347
 
static ZCONST char Far izVMSdeflat[] = "deflated";
348
 
static ZCONST char Far izVMScunknw[] = "compressed(?)";
349
 
static ZCONST char Far *izVMScomp[4] =
350
 
  {izVMSstored, izVMSrleenc, izVMSdeflat, izVMScunknw};
351
 
static ZCONST char Far ACLdata[] = ".\n\
352
 
    The local extra field has %lu bytes of access control list information";
353
 
static ZCONST char Far NTSDData[] = ".\n\
354
 
    The local extra field has %lu bytes of NT security descriptor data";
355
 
static ZCONST char Far UTdata[] = ".\n\
356
 
    The local extra field has UTC/GMT %s time%s";
357
 
static ZCONST char Far UTmodification[] = "modification";
358
 
static ZCONST char Far UTaccess[] = "access";
359
 
static ZCONST char Far UTcreation[] = "creation";
360
 
static ZCONST char Far ZipItFname[] = ".\n\
361
 
    The Mac long filename is %s";
362
 
static ZCONST char Far Mac3data[] = ".\n\
363
 
    The local extra field has %lu bytes of %scompressed Macintosh\n\
364
 
    finder attributes";
365
 
 /* MacOSdata[] is used by EF_MAC3, EF_ZIPIT, EF_ZIPIT2 and EF_JLEE e. f. */
366
 
static ZCONST char Far MacOSdata[] = ".\n\
367
 
    The associated file has type code `%c%c%c%c' and creator code `%c%c%c%c'";
368
 
static ZCONST char Far MacOSdata1[] = ".\n\
369
 
    The associated file has type code `0x%lx' and creator code `0x%lx'";
370
 
static ZCONST char Far MacOSJLEEflags[] = ".\n    File is marked as %s";
371
 
static ZCONST char Far MacOS_RF[] = "Resource-fork";
372
 
static ZCONST char Far MacOS_DF[] = "Data-fork";
373
 
static ZCONST char Far MacOSMAC3flags[] = ".\n\
374
 
    File is marked as %s, File Dates are in %d Bit";
375
 
static ZCONST char Far AtheOSdata[] = ".\n\
376
 
    The local extra field has %lu bytes of %scompressed AtheOS file attributes";
377
 
static ZCONST char Far BeOSdata[] = ".\n\
378
 
    The local extra field has %lu bytes of %scompressed BeOS file attributes";
379
 
 /* The associated file has type code `%c%c%c%c' and creator code `%c%c%c%c'" */
380
 
static ZCONST char Far QDOSdata[] = ".\n\
381
 
    The QDOS extra field subtype is `%c%c%c%c'";
382
 
static ZCONST char Far AOSVSdata[] = ".\n\
383
 
    The AOS/VS extra field revision is %d.%d";
384
 
static ZCONST char Far TandemUnstr[] = "Unstructured";
385
 
static ZCONST char Far TandemRel[]   = "Relative";
386
 
static ZCONST char Far TandemEntry[] = "Entry Sequenced";
387
 
static ZCONST char Far TandemKey[]   = "Key Sequenced";
388
 
static ZCONST char Far TandemEdit[]  = "Edit";
389
 
static ZCONST char Far TandemObj[]  = "Object";
390
 
static ZCONST char Far *TandemFileformat[6] =
391
 
  {TandemUnstr, TandemRel, TandemEntry, TandemKey, TandemEdit, TandemObj};
392
 
static ZCONST char Far Tandemdata[] = ".\n\
393
 
    The file was originally a Tandem %s file, with file code %u";
394
 
static ZCONST char Far MD5data[] = ".\n\
395
 
    The 128-bit MD5 signature is %s";
396
 
#ifdef CMS_MVS
397
 
   static ZCONST char Far VmMvsExtraField[] = ".\n\
398
 
    The stored file open mode (FLDATA TYPE) is \"%s\"";
399
 
   static ZCONST char Far VmMvsInvalid[] = "[invalid]";
400
 
#endif /* CMS_MVS */
401
 
 
402
 
static ZCONST char Far First20[] = ".  The first\n    20 are:  ";
403
 
static ZCONST char Far ColonIndent[] = ":\n   ";
404
 
static ZCONST char Far efFormat[] = " %02x";
405
 
 
406
 
static ZCONST char Far lExtraFieldType[] = "\n\
407
 
  There %s a local extra field with ID 0x%04x (%s) and\n\
408
 
  %u data bytes (%s).\n";
409
 
static ZCONST char Far efIZuid[] =
410
 
  "GMT modification/access times and Unix UID/GID";
411
 
static ZCONST char Far efIZnouid[] = "GMT modification/access times only";
412
 
 
413
 
 
414
 
static ZCONST char Far NoFileComment[] = "\n  There is no file comment.\n";
415
 
static ZCONST char Far FileCommBegin[] = "\n\
416
 
------------------------- file comment begins ----------------------------\n";
417
 
static ZCONST char Far FileCommEnd[] = "\
418
 
-------------------------- file comment ends -----------------------------\n";
419
 
 
420
 
/* zi_time() strings */
421
 
static ZCONST char Far BogusFmt[] = "%03d";
422
 
static ZCONST char Far DMYHMTime[] = "%2u-%s-%02u %02u:%02u";
423
 
static ZCONST char Far YMDHMSTime[] = "%u %s %u %02u:%02u:%02u";
424
 
static ZCONST char Far DecimalTime[] = "%04u%02u%02u.%02u%02u%02u";
425
 
#ifdef USE_EF_UT_TIME
426
 
  static ZCONST char Far YMDHMSTimeError[] = "???? ??? ?? ??:??:??";
427
 
#endif
428
 
 
429
 
 
430
 
 
431
 
 
432
 
 
433
 
#ifndef WINDLL
434
 
 
435
 
/************************/
436
 
/*  Function zi_opts()  */
437
 
/************************/
438
 
 
439
 
int zi_opts(__G__ pargc, pargv)
440
 
    int *pargc;
441
 
    char ***pargv;
442
 
    __GDEF
443
 
{
444
 
    char   **argv, *s;
445
 
    int    argc, c, error=FALSE, negative=0;
446
 
    int    hflag_slmv=TRUE, hflag_2=FALSE;  /* diff options => diff defaults */
447
 
    int    tflag_slm=TRUE, tflag_2v=FALSE;
448
 
    int    explicit_h=FALSE, explicit_t=FALSE;
449
 
 
450
 
 
451
 
#ifdef MACOS
452
 
    uO.lflag = LFLAG;         /* reset default on each call */
453
 
#endif
454
 
    G.extract_flag = FALSE;   /* zipinfo does not extract to disk */
455
 
    argc = *pargc;
456
 
    argv = *pargv;
457
 
 
458
 
    while (--argc > 0 && (*++argv)[0] == '-') {
459
 
        s = argv[0] + 1;
460
 
        while ((c = *s++) != 0) {    /* "!= 0":  prevent Turbo C warning */
461
 
            switch (c) {
462
 
                case '-':
463
 
                    ++negative;
464
 
                    break;
465
 
                case '1':      /* shortest listing:  JUST filenames */
466
 
                    if (negative)
467
 
                        uO.lflag = -2, negative = 0;
468
 
                    else
469
 
                        uO.lflag = 1;
470
 
                    break;
471
 
                case '2':      /* just filenames, plus headers if specified */
472
 
                    if (negative)
473
 
                        uO.lflag = -2, negative = 0;
474
 
                    else
475
 
                        uO.lflag = 2;
476
 
                    break;
477
 
#ifndef CMS_MVS
478
 
                case ('C'):    /* -C:  match filenames case-insensitively */
479
 
                    if (negative)
480
 
                        uO.C_flag = FALSE, negative = 0;
481
 
                    else
482
 
                        uO.C_flag = TRUE;
483
 
                    break;
484
 
#endif /* !CMS_MVS */
485
 
                case 'h':      /* header line */
486
 
                    if (negative)
487
 
                        hflag_2 = hflag_slmv = FALSE, negative = 0;
488
 
                    else {
489
 
                        hflag_2 = hflag_slmv = explicit_h = TRUE;
490
 
                        if (uO.lflag == -1)
491
 
                            uO.lflag = 0;
492
 
                    }
493
 
                    break;
494
 
                case 'l':      /* longer form of "ls -l" type listing */
495
 
                    if (negative)
496
 
                        uO.lflag = -2, negative = 0;
497
 
                    else
498
 
                        uO.lflag = 5;
499
 
                    break;
500
 
                case 'm':      /* medium form of "ls -l" type listing */
501
 
                    if (negative)
502
 
                        uO.lflag = -2, negative = 0;
503
 
                    else
504
 
                        uO.lflag = 4;
505
 
                    break;
506
 
#ifdef MORE
507
 
                case 'M':      /* send output through built-in "more" */
508
 
                    if (negative)
509
 
                        G.M_flag = FALSE, negative = 0;
510
 
                    else
511
 
                        G.M_flag = TRUE;
512
 
                    break;
513
 
#endif
514
 
                case 's':      /* default:  shorter "ls -l" type listing */
515
 
                    if (negative)
516
 
                        uO.lflag = -2, negative = 0;
517
 
                    else
518
 
                        uO.lflag = 3;
519
 
                    break;
520
 
                case 't':      /* totals line */
521
 
                    if (negative)
522
 
                        tflag_2v = tflag_slm = FALSE, negative = 0;
523
 
                    else {
524
 
                        tflag_2v = tflag_slm = explicit_t = TRUE;
525
 
                        if (uO.lflag == -1)
526
 
                            uO.lflag = 0;
527
 
                    }
528
 
                    break;
529
 
                case ('T'):    /* use (sortable) decimal time format */
530
 
                    if (negative)
531
 
                        uO.T_flag = FALSE, negative = 0;
532
 
                    else
533
 
                        uO.T_flag = TRUE;
534
 
                    break;
535
 
                case 'v':      /* turbo-verbose listing */
536
 
                    if (negative)
537
 
                        uO.lflag = -2, negative = 0;
538
 
                    else
539
 
                        uO.lflag = 10;
540
 
                    break;
541
 
#ifdef WILD_STOP_AT_DIR
542
 
                case ('W'):    /* Wildcard interpretation (stop at '/'?) */
543
 
                    if (negative)
544
 
                        uO.W_flag = FALSE, negative = 0;
545
 
                    else
546
 
                        uO.W_flag = TRUE;
547
 
                    break;
548
 
#endif /* WILD_STOP_AT_DIR */
549
 
                case 'z':      /* print zipfile comment */
550
 
                    if (negative)
551
 
                        uO.zflag = negative = 0;
552
 
                    else
553
 
                        uO.zflag = 1;
554
 
                    break;
555
 
                case 'Z':      /* ZipInfo mode:  ignore */
556
 
                    break;
557
 
                default:
558
 
                    error = TRUE;
559
 
                    break;
560
 
            }
561
 
        }
562
 
    }
563
 
    if ((argc-- == 0) || error) {
564
 
        *pargc = argc;
565
 
        *pargv = argv;
566
 
        return USAGE(error);
567
 
    }
568
 
 
569
 
#ifdef MORE
570
 
    if (G.M_flag && !isatty(1))  /* stdout redirected: "more" func useless */
571
 
        G.M_flag = 0;
572
 
#endif
573
 
 
574
 
    /* if no listing options given (or all negated), or if only -h/-t given
575
 
     * with individual files specified, use default listing format */
576
 
    if ((uO.lflag < 0) || ((argc > 0) && (uO.lflag == 0)))
577
 
        uO.lflag = LFLAG;
578
 
 
579
 
    /* set header and totals flags to default or specified values */
580
 
    switch (uO.lflag) {
581
 
        case 0:   /* 0:  can only occur if either -t or -h explicitly given; */
582
 
        case 2:   /*  therefore set both flags equal to normally false value */
583
 
            uO.hflag = hflag_2;
584
 
            uO.tflag = tflag_2v;
585
 
            break;
586
 
        case 1:   /* only filenames, *always* */
587
 
            uO.hflag = FALSE;
588
 
            uO.tflag = FALSE;
589
 
            uO.zflag = FALSE;
590
 
            break;
591
 
        case 3:
592
 
        case 4:
593
 
        case 5:
594
 
            uO.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
595
 
            uO.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
596
 
            break;
597
 
        case 10:
598
 
            uO.hflag = hflag_slmv;
599
 
            uO.tflag = tflag_2v;
600
 
            break;
601
 
    }
602
 
 
603
 
    *pargc = argc;
604
 
    *pargv = argv;
605
 
    return 0;
606
 
 
607
 
} /* end function zi_opts() */
608
 
 
609
 
#endif /* !WINDLL */
610
 
 
611
 
 
612
 
 
613
 
 
614
 
 
615
 
/*******************************/
616
 
/*  Function zi_end_central()  */
617
 
/*******************************/
618
 
 
619
 
int zi_end_central(__G)   /* return PK-type error code */
620
 
    __GDEF
621
 
{
622
 
    int  error = PK_COOL;
623
 
 
624
 
 
625
 
/*---------------------------------------------------------------------------
626
 
    Print out various interesting things about the zipfile.
627
 
  ---------------------------------------------------------------------------*/
628
 
 
629
 
    /* header fits on one line, for anything up to 10GB and 10000 files: */
630
 
    if (uO.hflag)
631
 
        Info(slide, 0, ((char *)slide, ((int)strlen(G.zipfn) < 39)?
632
 
          LoadFarString(LongHeader) : LoadFarString(ShortHeader), G.zipfn,
633
 
          (long)G.ziplen, G.ecrec.total_entries_central_dir,
634
 
          (G.ecrec.total_entries_central_dir==1)?
635
 
          nullStr : PlurSufx));
636
 
 
637
 
    /* verbose format */
638
 
    if (uO.lflag > 9) {
639
 
        Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));
640
 
        Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));
641
 
 
642
 
        Info(slide, 0, ((char *)slide, LoadFarString(ActOffsetCentDir),
643
 
          (long)G.real_ecrec_offset, (long)G.real_ecrec_offset,
644
 
          (long)G.expect_ecrec_offset, (long)G.expect_ecrec_offset));
645
 
 
646
 
        if (G.ecrec.number_this_disk == 0) {
647
 
            Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive1),
648
 
              G.ecrec.total_entries_central_dir,
649
 
              (G.ecrec.total_entries_central_dir == 1)? "entry" : "entries",
650
 
              G.ecrec.size_central_directory,
651
 
              G.ecrec.size_central_directory));
652
 
            Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive2),
653
 
              G.ecrec.offset_start_central_directory,
654
 
              G.ecrec.offset_start_central_directory));
655
 
        } else {
656
 
            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive1),
657
 
              G.ecrec.number_this_disk + 1,
658
 
              G.ecrec.num_disk_start_cdir + 1,
659
 
              G.ecrec.num_entries_centrl_dir_ths_disk,
660
 
              (G.ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are"));
661
 
            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive2),
662
 
              G.ecrec.total_entries_central_dir,
663
 
              (G.ecrec.total_entries_central_dir == 1) ? "entry" : "entries",
664
 
              G.ecrec.size_central_directory,
665
 
              G.ecrec.size_central_directory));
666
 
            Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive3),
667
 
              G.ecrec.offset_start_central_directory,
668
 
              G.ecrec.offset_start_central_directory));
669
 
        }
670
 
 
671
 
    /*-----------------------------------------------------------------------
672
 
        Get the zipfile comment, if any, and print it out.  (Comment may be
673
 
        up to 64KB long.  May the fleas of a thousand camels infest the arm-
674
 
        pits of anyone who actually takes advantage of this fact.)
675
 
      -----------------------------------------------------------------------*/
676
 
 
677
 
        if (!G.ecrec.zipfile_comment_length)
678
 
            Info(slide, 0, ((char *)slide, LoadFarString(NoZipfileComment)));
679
 
        else {
680
 
            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommentDesc),
681
 
              G.ecrec.zipfile_comment_length));
682
 
            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommBegin)));
683
 
            if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY))
684
 
                error = PK_WARN;
685
 
            Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommEnd)));
686
 
            if (error)
687
 
                Info(slide, 0, ((char *)slide,
688
 
                  LoadFarString(ZipfileCommTrunc2)));
689
 
        } /* endif (comment exists) */
690
 
 
691
 
    /* non-verbose mode:  print zipfile comment only if requested */
692
 
    } else if (uO.zflag && G.ecrec.zipfile_comment_length) {
693
 
        if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY)) {
694
 
            Info(slide, 0x401, ((char *)slide,
695
 
              LoadFarString(ZipfileCommTruncMsg)));
696
 
            error = PK_WARN;
697
 
        }
698
 
    } /* endif (verbose) */
699
 
 
700
 
    return error;
701
 
 
702
 
} /* end function zi_end_central() */
703
 
 
704
 
 
705
 
 
706
 
 
707
 
 
708
 
/************************/
709
 
/*  Function zipinfo()  */
710
 
/************************/
711
 
 
712
 
int zipinfo(__G)   /* return PK-type error code */
713
 
    __GDEF
714
 
{
715
 
    int do_this_file=FALSE, error, error_in_archive=PK_COOL;
716
 
    int *fn_matched=NULL, *xn_matched=NULL;
717
 
    ulg j, members=0L;
718
 
    ulg tot_csize=0L, tot_ucsize=0L;
719
 
    ulg endprev;   /* buffers end of previous entry for zi_long()'s check
720
 
                    *  of extra bytes */
721
 
 
722
 
 
723
 
/*---------------------------------------------------------------------------
724
 
    Malloc space for check on unmatched filespecs (no big deal if one or both
725
 
    are NULL).
726
 
  ---------------------------------------------------------------------------*/
727
 
 
728
 
    if (G.filespecs > 0  &&
729
 
        (fn_matched=(int *)malloc(G.filespecs*sizeof(int))) != NULL)
730
 
        for (j = 0;  j < G.filespecs;  ++j)
731
 
            fn_matched[j] = FALSE;
732
 
 
733
 
    if (G.xfilespecs > 0  &&
734
 
        (xn_matched=(int *)malloc(G.xfilespecs*sizeof(int))) != NULL)
735
 
        for (j = 0;  j < G.xfilespecs;  ++j)
736
 
            xn_matched[j] = FALSE;
737
 
 
738
 
/*---------------------------------------------------------------------------
739
 
    Set file pointer to start of central directory, then loop through cen-
740
 
    tral directory entries.  Check that directory-entry signature bytes are
741
 
    actually there (just a precaution), then process the entry.  We know
742
 
    the entire central directory is on this disk:  we wouldn't have any of
743
 
    this information unless the end-of-central-directory record was on this
744
 
    disk, and we wouldn't have gotten to this routine unless this is also
745
 
    the disk on which the central directory starts.  In practice, this had
746
 
    better be the *only* disk in the archive, but maybe someday we'll add
747
 
    multi-disk support.
748
 
  ---------------------------------------------------------------------------*/
749
 
 
750
 
    uO.L_flag = FALSE;      /* zipinfo mode: never convert name to lowercase */
751
 
    G.pInfo = G.info;       /* (re-)initialize, (just to make sure) */
752
 
    G.pInfo->textmode = 0;  /* so one can read on screen (is this ever used?) */
753
 
 
754
 
    /* reset endprev for new zipfile; account for multi-part archives (?) */
755
 
    endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;
756
 
 
757
 
 
758
 
    for (j = 1L;; j++) {
759
 
        if (readbuf(__G__ G.sig, 4) == 0)
760
 
            return PK_EOF;
761
 
        if (strncmp(G.sig, central_hdr_sig, 4)) {  /* is it a CentDir entry? */
762
 
            if (((unsigned)(j - 1) & (unsigned)0xFFFF) ==
763
 
                (unsigned)G.ecrec.total_entries_central_dir) {
764
 
                /* "j modulus 64k" matches the reported 16-bit-unsigned
765
 
                 * number of directory entries -> probably, the regular
766
 
                 * end of the central directory has been reached
767
 
                 */
768
 
                break;
769
 
            } else {
770
 
                Info(slide, 0x401,
771
 
                     ((char *)slide, LoadFarString(CentSigMsg), j));
772
 
                Info(slide, 0x401,
773
 
                     ((char *)slide, LoadFarString(ReportMsg)));
774
 
                return PK_BADERR;   /* sig not found */
775
 
            }
776
 
        }
777
 
        /* process_cdir_file_hdr() sets pInfo->hostnum, pInfo->lcflag, ...: */
778
 
        if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
779
 
            return error;       /* only PK_EOF defined */
780
 
 
781
 
        if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
782
 
             PK_COOL)
783
 
        {
784
 
          error_in_archive = error;   /* might be warning */
785
 
          if (error > PK_WARN)        /* fatal */
786
 
              return error;
787
 
        }
788
 
 
789
 
        if (!G.process_all_files) {   /* check if specified on command line */
790
 
            unsigned i;
791
 
 
792
 
            if (G.filespecs == 0)
793
 
                do_this_file = TRUE;
794
 
            else {  /* check if this entry matches an `include' argument */
795
 
                do_this_file = FALSE;
796
 
                for (i = 0; i < G.filespecs; i++)
797
 
                    if (match(G.filename, G.pfnames[i], uO.C_flag WISEP)) {
798
 
                        do_this_file = TRUE;
799
 
                        if (fn_matched)
800
 
                            fn_matched[i] = TRUE;
801
 
                        break;       /* found match, so stop looping */
802
 
                    }
803
 
            }
804
 
            if (do_this_file) {  /* check if this is an excluded file */
805
 
                for (i = 0; i < G.xfilespecs; i++)
806
 
                    if (match(G.filename, G.pxnames[i], uO.C_flag WISEP)) {
807
 
                        do_this_file = FALSE;  /* ^-- ignore case in match */
808
 
                        if (xn_matched)
809
 
                            xn_matched[i] = TRUE;
810
 
                        break;
811
 
                    }
812
 
            }
813
 
        }
814
 
 
815
 
    /*-----------------------------------------------------------------------
816
 
        If current file was specified on command line, or if no names were
817
 
        specified, do the listing for this file.  Otherwise, get rid of the
818
 
        file comment and go back for the next file.
819
 
      -----------------------------------------------------------------------*/
820
 
 
821
 
        if (G.process_all_files || do_this_file) {
822
 
 
823
 
            switch (uO.lflag) {
824
 
                case 1:
825
 
                case 2:
826
 
                    fnprint(__G);
827
 
                    SKIP_(G.crec.extra_field_length)
828
 
                    SKIP_(G.crec.file_comment_length)
829
 
                    break;
830
 
 
831
 
                case 3:
832
 
                case 4:
833
 
                case 5:
834
 
                    if ((error = zi_short(__G)) != PK_COOL) {
835
 
                        error_in_archive = error;   /* might be warning */
836
 
                        if (error > PK_WARN)        /* fatal */
837
 
                            return error;
838
 
                    }
839
 
                    break;
840
 
 
841
 
                case 10:
842
 
                    Info(slide, 0, ((char *)slide,
843
 
                      LoadFarString(CentralDirEntry), j));
844
 
                    if ((error = zi_long(__G__ &endprev)) != PK_COOL) {
845
 
                        error_in_archive = error;   /* might be warning */
846
 
                        if (error > PK_WARN)        /* fatal */
847
 
                            return error;
848
 
                    }
849
 
                    break;
850
 
 
851
 
                default:
852
 
                    SKIP_(G.crec.extra_field_length)
853
 
                    SKIP_(G.crec.file_comment_length)
854
 
                    break;
855
 
 
856
 
            } /* end switch (lflag) */
857
 
 
858
 
            tot_csize += G.crec.csize;
859
 
            tot_ucsize += G.crec.ucsize;
860
 
            if (G.crec.general_purpose_bit_flag & 1)
861
 
                tot_csize -= 12;   /* don't count encryption header */
862
 
            ++members;
863
 
 
864
 
#ifdef DLL
865
 
            if ((G.statreportcb != NULL) &&
866
 
                (*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,
867
 
                                  G.filename, (zvoid *)&G.crec.ucsize)) {
868
 
                if (fn_matched)
869
 
                    free((zvoid *)fn_matched);
870
 
                if (xn_matched)
871
 
                    free((zvoid *)xn_matched);
872
 
                return IZ_CTRLC;        /* cancel operation by user request */
873
 
            }
874
 
#endif
875
 
#ifdef MACOS  /* MacOS is no preemptive OS, thus call event-handling by hand */
876
 
            UserStop();
877
 
#endif
878
 
 
879
 
        } else {        /* not listing this file */
880
 
            SKIP_(G.crec.extra_field_length)
881
 
            SKIP_(G.crec.file_comment_length)
882
 
 
883
 
        } /* end if (list member?) */
884
 
 
885
 
    } /* end for-loop (j: member files) */
886
 
 
887
 
/*---------------------------------------------------------------------------
888
 
    Check that we actually found requested files; if so, print totals.
889
 
  ---------------------------------------------------------------------------*/
890
 
 
891
 
    if (uO.tflag) {
892
 
        char *sgn = "";
893
 
        int cfactor = ratio(tot_ucsize, tot_csize);
894
 
 
895
 
        if (cfactor < 0) {
896
 
            sgn = "-";
897
 
            cfactor = -cfactor;
898
 
        }
899
 
        Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),
900
 
          members, (members==1L)? nullStr:PlurSufx, tot_ucsize,
901
 
          tot_csize, sgn, cfactor/10, cfactor%10));
902
 
    }
903
 
 
904
 
/*---------------------------------------------------------------------------
905
 
    Check for unmatched filespecs on command line and print warning if any
906
 
    found.
907
 
  ---------------------------------------------------------------------------*/
908
 
 
909
 
    if (fn_matched) {
910
 
        for (j = 0;  j < G.filespecs;  ++j)
911
 
            if (!fn_matched[j])
912
 
                Info(slide, 0x401, ((char *)slide,
913
 
                  LoadFarString(FilenameNotMatched), G.pfnames[j]));
914
 
        free((zvoid *)fn_matched);
915
 
    }
916
 
    if (xn_matched) {
917
 
        for (j = 0;  j < G.xfilespecs;  ++j)
918
 
            if (!xn_matched[j])
919
 
                Info(slide, 0x401, ((char *)slide,
920
 
                  LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));
921
 
        free((zvoid *)xn_matched);
922
 
    }
923
 
 
924
 
/*---------------------------------------------------------------------------
925
 
    Double check that we're back at the end-of-central-directory record.
926
 
  ---------------------------------------------------------------------------*/
927
 
 
928
 
    if (strncmp(G.sig, end_central_sig, 4)) {   /* just to make sure again */
929
 
        Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
930
 
        error_in_archive = PK_WARN;   /* didn't find sig */
931
 
    }
932
 
    if (members == 0 && error_in_archive <= PK_WARN)
933
 
        error_in_archive = PK_FIND;
934
 
 
935
 
    if (uO.lflag >= 10)
936
 
        (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
937
 
 
938
 
    return error_in_archive;
939
 
 
940
 
} /* end function zipinfo() */
941
 
 
942
 
 
943
 
 
944
 
 
945
 
 
946
 
/************************/
947
 
/*  Function zi_long()  */
948
 
/************************/
949
 
 
950
 
static int zi_long(__G__ pEndprev)   /* return PK-type error code */
951
 
    __GDEF
952
 
    ulg *pEndprev;                   /* for zi_long() check of extra bytes */
953
 
{
954
 
#ifdef USE_EF_UT_TIME
955
 
    iztimes z_utime;
956
 
#endif
957
 
    int  error, error_in_archive=PK_COOL;
958
 
    unsigned  hostnum, hostver, extnum, extver, methnum, xattr;
959
 
    char workspace[12], attribs[22];
960
 
    ZCONST char *varmsg_str;
961
 
    char unkn[16];
962
 
    static ZCONST char Far *os[NUM_HOSTS] = {
963
 
        OS_FAT, OS_Amiga, OS_VMS, OS_Unix, OS_VMCMS, OS_AtariST, OS_HPFS,
964
 
        OS_Macintosh, OS_ZSystem, OS_CPM, OS_TOPS20, OS_NTFS, OS_QDOS,
965
 
        OS_Acorn, OS_VFAT, OS_MVS, OS_BeOS, OS_Tandem, OS_Theos, OS_MacDarwin,
966
 
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
967
 
        OS_AtheOS
968
 
    };
969
 
    static ZCONST char Far *method[NUM_METHODS] = {
970
 
        MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
971
 
        MthdImplode, MthdToken, MthdDeflate, MthdDeflat64, MthdDCLImplode,
972
 
        MthdPKRes11, MthdBZip2
973
 
    };
974
 
    static ZCONST char Far *dtypelng[4] = {
975
 
        DeflNorm, DeflMax, DeflFast, DeflSFast
976
 
    };
977
 
 
978
 
 
979
 
/*---------------------------------------------------------------------------
980
 
    Check whether there's any extra space inside the zipfile.  If *pEndprev is
981
 
    zero, it's probably a signal that OS/2 extra fields are involved (with
982
 
    unknown compressed size).  We won't worry about prepended junk here...
983
 
  ---------------------------------------------------------------------------*/
984
 
 
985
 
    if (G.crec.relative_offset_local_header != *pEndprev && *pEndprev > 0L) {
986
 
        /*  GRR DEBUG
987
 
        Info(slide, 0, ((char *)slide,
988
 
          "  [crec.relative_offset_local_header = %lu, endprev = %lu]\n",
989
 
          G.crec.relative_offset_local_header, *pEndprev));
990
 
         */
991
 
        Info(slide, 0, ((char *)slide, LoadFarString(ExtraBytesPreceding),
992
 
          (long)G.crec.relative_offset_local_header - (long)(*pEndprev)));
993
 
    }
994
 
 
995
 
    /* calculate endprev for next time around (problem:  extra fields may
996
 
     * differ in length between local and central-directory records) */
997
 
    *pEndprev = G.crec.relative_offset_local_header + (4L + LREC_SIZE) +
998
 
      G.crec.filename_length + G.crec.extra_field_length + G.crec.csize;
999
 
 
1000
 
/*---------------------------------------------------------------------------
1001
 
    Read the extra field, if any. It may be used to get UNIX style modtime.
1002
 
  ---------------------------------------------------------------------------*/
1003
 
 
1004
 
    if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
1005
 
    {
1006
 
        if (G.extra_field != NULL) {
1007
 
            free(G.extra_field);
1008
 
            G.extra_field = NULL;
1009
 
        }
1010
 
        error_in_archive = error;
1011
 
        /* The premature return in case of a "fatal" error (PK_EOF) is
1012
 
         * delayed until we analyze the extra field contents.
1013
 
         * This allows us to display all the other info that has been
1014
 
         * successfully read in.
1015
 
         */
1016
 
    }
1017
 
 
1018
 
/*---------------------------------------------------------------------------
1019
 
    Print out various interesting things about the compressed file.
1020
 
  ---------------------------------------------------------------------------*/
1021
 
 
1022
 
    hostnum = (unsigned)(G.pInfo->hostnum);
1023
 
    hostver = (unsigned)(G.pInfo->hostver);
1024
 
    extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
1025
 
    extver = (unsigned)G.crec.version_needed_to_extract[0];
1026
 
    methnum = (unsigned)MIN(G.crec.compression_method, NUM_METHODS);
1027
 
 
1028
 
    (*G.message)((zvoid *)&G, (uch *)"  ", 2L, 0);  fnprint(__G);
1029
 
 
1030
 
    Info(slide, 0, ((char *)slide, LoadFarString(LocalHeaderOffset),
1031
 
      G.crec.relative_offset_local_header,
1032
 
      G.crec.relative_offset_local_header));
1033
 
 
1034
 
    if (hostnum >= NUM_HOSTS) {
1035
 
        sprintf(unkn, LoadFarString(UnknownNo),
1036
 
                (int)G.crec.version_made_by[1]);
1037
 
        varmsg_str = unkn;
1038
 
    } else {
1039
 
        varmsg_str = LoadFarStringSmall(os[hostnum]);
1040
 
#ifdef OLD_THEOS_EXTRA
1041
 
        if (hostnum == FS_VFAT_ && hostver == 20) {
1042
 
            /* entry made by old non-official THEOS port zip archive */
1043
 
            varmsg_str = LoadFarStringSmall(OS_TheosOld);
1044
 
        }
1045
 
#endif /* OLD_THEOS_EXTRA */
1046
 
    }
1047
 
    Info(slide, 0, ((char *)slide, LoadFarString(HostOS), varmsg_str));
1048
 
    Info(slide, 0, ((char *)slide, LoadFarString(EncodeSWVer), hostver/10,
1049
 
      hostver%10));
1050
 
 
1051
 
    if ((extnum >= NUM_HOSTS) || (os[extnum] == NULL)) {
1052
 
        sprintf(unkn, LoadFarString(UnknownNo),
1053
 
                (int)G.crec.version_needed_to_extract[1]);
1054
 
        varmsg_str = unkn;
1055
 
    } else {
1056
 
        varmsg_str = LoadFarStringSmall(os[extnum]);
1057
 
    }
1058
 
    Info(slide, 0, ((char *)slide, LoadFarString(MinOSCompReq), varmsg_str));
1059
 
    Info(slide, 0, ((char *)slide, LoadFarString(MinSWVerReq), extver/10,
1060
 
      extver%10));
1061
 
 
1062
 
    if (methnum >= NUM_METHODS) {
1063
 
        sprintf(unkn, LoadFarString(UnknownNo), G.crec.compression_method);
1064
 
        varmsg_str = unkn;
1065
 
    } else {
1066
 
        varmsg_str = LoadFarStringSmall(method[methnum]);
1067
 
    }
1068
 
    Info(slide, 0, ((char *)slide, LoadFarString(CompressMethod), varmsg_str));
1069
 
    if (methnum == IMPLODED) {
1070
 
        Info(slide, 0, ((char *)slide, LoadFarString(SlideWindowSizeImplode),
1071
 
          (G.crec.general_purpose_bit_flag & 2)? '8' : '4'));
1072
 
        Info(slide, 0, ((char *)slide, LoadFarString(ShannonFanoTrees),
1073
 
          (G.crec.general_purpose_bit_flag & 4)? '3' : '2'));
1074
 
    } else if (methnum == DEFLATED || methnum == ENHDEFLATED) {
1075
 
        ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
1076
 
 
1077
 
        Info(slide, 0, ((char *)slide, LoadFarString(CompressSubtype),
1078
 
          LoadFarStringSmall(dtypelng[dnum])));
1079
 
    }
1080
 
 
1081
 
    Info(slide, 0, ((char *)slide, LoadFarString(FileSecurity),
1082
 
      (G.crec.general_purpose_bit_flag & 1) ? nullStr : "not "));
1083
 
    Info(slide, 0, ((char *)slide, LoadFarString(ExtendedLocalHdr),
1084
 
      (G.crec.general_purpose_bit_flag & 8) ? "yes" : "no"));
1085
 
    /* print upper 3 bits for amusement? */
1086
 
 
1087
 
    /* For printing of date & time, a "char d_t_buf[21]" is required.
1088
 
     * To save stack space, we reuse the "char attribs[22]" buffer which
1089
 
     * is not used yet.
1090
 
     */
1091
 
#   define d_t_buf attribs
1092
 
 
1093
 
    zi_time(__G__ &G.crec.last_mod_dos_datetime, NULL, d_t_buf);
1094
 
    Info(slide, 0, ((char *)slide, LoadFarString(FileModDate), d_t_buf));
1095
 
#ifdef USE_EF_UT_TIME
1096
 
    if (G.extra_field &&
1097
 
#ifdef IZ_CHECK_TZ
1098
 
        G.tz_is_valid &&
1099
 
#endif
1100
 
        (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
1101
 
                          G.crec.last_mod_dos_datetime, &z_utime, NULL)
1102
 
         & EB_UT_FL_MTIME))
1103
 
    {
1104
 
        TIMET_TO_NATIVE(z_utime.mtime)   /* NOP unless MSC 7.0 or Macintosh */
1105
 
        d_t_buf[0] = (char)0;               /* signal "show local time" */
1106
 
        zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
1107
 
        Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
1108
 
          d_t_buf, LoadFarStringSmall(LocalTime)));
1109
 
#ifndef NO_GMTIME
1110
 
        d_t_buf[0] = (char)1;           /* signal "show UTC (GMT) time" */
1111
 
        zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
1112
 
        Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
1113
 
          d_t_buf, LoadFarStringSmall(GMTime)));
1114
 
#endif /* !NO_GMTIME */
1115
 
    }
1116
 
#endif /* USE_EF_UT_TIME */
1117
 
 
1118
 
    Info(slide, 0, ((char *)slide, LoadFarString(CRC32Value), G.crec.crc32));
1119
 
    Info(slide, 0, ((char *)slide, LoadFarString(CompressedFileSize),
1120
 
      G.crec.csize));
1121
 
    Info(slide, 0, ((char *)slide, LoadFarString(UncompressedFileSize),
1122
 
      G.crec.ucsize));
1123
 
    Info(slide, 0, ((char *)slide, LoadFarString(FilenameLength),
1124
 
      G.crec.filename_length));
1125
 
    Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldLength),
1126
 
      G.crec.extra_field_length));
1127
 
    Info(slide, 0, ((char *)slide, LoadFarString(FileCommentLength),
1128
 
      G.crec.file_comment_length));
1129
 
    Info(slide, 0, ((char *)slide, LoadFarString(FileDiskNum),
1130
 
      G.crec.disk_number_start + 1));
1131
 
    Info(slide, 0, ((char *)slide, LoadFarString(ApparentFileType),
1132
 
      (G.crec.internal_file_attributes & 1)? "text"
1133
 
         : (G.crec.internal_file_attributes & 2)? "ebcdic"
1134
 
              : "binary"));             /* changed to accept EBCDIC */
1135
 
#ifdef ATARI
1136
 
    printf("  external file attributes (hex):                   %.8lx\n",
1137
 
      G.crec.external_file_attributes);
1138
 
#endif
1139
 
    xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
1140
 
    if (hostnum == VMS_) {
1141
 
        char   *p=attribs, *q=attribs+1;
1142
 
        int    i, j, k;
1143
 
 
1144
 
        for (k = 0;  k < 12;  ++k)
1145
 
            workspace[k] = 0;
1146
 
        if (xattr & VMS_IRUSR)
1147
 
            workspace[0] = 'R';
1148
 
        if (xattr & VMS_IWUSR) {
1149
 
            workspace[1] = 'W';
1150
 
            workspace[3] = 'D';
1151
 
        }
1152
 
        if (xattr & VMS_IXUSR)
1153
 
            workspace[2] = 'E';
1154
 
        if (xattr & VMS_IRGRP)
1155
 
            workspace[4] = 'R';
1156
 
        if (xattr & VMS_IWGRP) {
1157
 
            workspace[5] = 'W';
1158
 
            workspace[7] = 'D';
1159
 
        }
1160
 
        if (xattr & VMS_IXGRP)
1161
 
            workspace[6] = 'E';
1162
 
        if (xattr & VMS_IROTH)
1163
 
            workspace[8] = 'R';
1164
 
        if (xattr & VMS_IWOTH) {
1165
 
            workspace[9] = 'W';
1166
 
            workspace[11] = 'D';
1167
 
        }
1168
 
        if (xattr & VMS_IXOTH)
1169
 
            workspace[10] = 'E';
1170
 
 
1171
 
        *p++ = '(';
1172
 
        for (k = j = 0;  j < 3;  ++j) {    /* loop over groups of permissions */
1173
 
            for (i = 0;  i < 4;  ++i, ++k)  /* loop over perms within a group */
1174
 
                if (workspace[k])
1175
 
                    *p++ = workspace[k];
1176
 
            *p++ = ',';                       /* group separator */
1177
 
            if (j == 0)
1178
 
                while ((*p++ = *q++) != ',')
1179
 
                    ;                         /* system, owner perms are same */
1180
 
        }
1181
 
        *p-- = '\0';
1182
 
        *p = ')';   /* overwrite last comma */
1183
 
        Info(slide, 0, ((char *)slide, LoadFarString(VMSFileAttributes), xattr,
1184
 
          attribs));
1185
 
 
1186
 
    } else if (hostnum == AMIGA_) {
1187
 
        switch (xattr & AMI_IFMT) {
1188
 
            case AMI_IFDIR:  attribs[0] = 'd';  break;
1189
 
            case AMI_IFREG:  attribs[0] = '-';  break;
1190
 
            default:         attribs[0] = '?';  break;
1191
 
        }
1192
 
        attribs[1] = (xattr & AMI_IHIDDEN)?   'h' : '-';
1193
 
        attribs[2] = (xattr & AMI_ISCRIPT)?   's' : '-';
1194
 
        attribs[3] = (xattr & AMI_IPURE)?     'p' : '-';
1195
 
        attribs[4] = (xattr & AMI_IARCHIVE)?  'a' : '-';
1196
 
        attribs[5] = (xattr & AMI_IREAD)?     'r' : '-';
1197
 
        attribs[6] = (xattr & AMI_IWRITE)?    'w' : '-';
1198
 
        attribs[7] = (xattr & AMI_IEXECUTE)?  'e' : '-';
1199
 
        attribs[8] = (xattr & AMI_IDELETE)?   'd' : '-';
1200
 
        attribs[9] = 0;   /* better dlm the string */
1201
 
        Info(slide, 0, ((char *)slide, LoadFarString(AmigaFileAttributes),
1202
 
          xattr, attribs));
1203
 
 
1204
 
    } else if (hostnum == THEOS_) {
1205
 
        ZCONST char Far *fpFtyp;
1206
 
 
1207
 
        switch (xattr & THS_IFMT) {
1208
 
            case THS_IFLIB:  fpFtyp = TheosFTypLib;  break;
1209
 
            case THS_IFDIR:  fpFtyp = TheosFTypDir;  break;
1210
 
            case THS_IFREG:  fpFtyp = TheosFTypReg;  break;
1211
 
            case THS_IFREL:  fpFtyp = TheosFTypRel;  break;
1212
 
            case THS_IFKEY:  fpFtyp = TheosFTypKey;  break;
1213
 
            case THS_IFIND:  fpFtyp = TheosFTypInd;  break;
1214
 
            case THS_IFR16:  fpFtyp = TheosFTypR16;  break;
1215
 
            case THS_IFP16:  fpFtyp = TheosFTypP16;  break;
1216
 
            case THS_IFP32:  fpFtyp = TheosFTypP32;  break;
1217
 
            default:         fpFtyp = TheosFTypUkn;  break;
1218
 
        }
1219
 
        strcpy(attribs, LoadFarStringSmall(fpFtyp));
1220
 
        attribs[12] = (xattr & THS_INHID) ? '.' : 'H';
1221
 
        attribs[13] = (xattr & THS_IMODF) ? '.' : 'M';
1222
 
        attribs[14] = (xattr & THS_IWOTH) ? '.' : 'W';
1223
 
        attribs[15] = (xattr & THS_IROTH) ? '.' : 'R';
1224
 
        attribs[16] = (xattr & THS_IEUSR) ? '.' : 'E';
1225
 
        attribs[17] = (xattr & THS_IXUSR) ? '.' : 'X';
1226
 
        attribs[18] = (xattr & THS_IWUSR) ? '.' : 'W';
1227
 
        attribs[19] = (xattr & THS_IRUSR) ? '.' : 'R';
1228
 
        attribs[20] = 0;
1229
 
        Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
1230
 
          xattr, attribs));
1231
 
 
1232
 
#ifdef OLD_THEOS_EXTRA
1233
 
    } else if (hostnum == FS_VFAT_ && hostver == 20) {
1234
 
        /* process old non-official THEOS port zip archive */
1235
 
        ZCONST char Far *fpFtyp;
1236
 
 
1237
 
        switch (xattr & _THS_IFMT) {
1238
 
            case _THS_IFLIB:  fpFtyp = TheosFTypLib;  break;
1239
 
            case _THS_IFDIR:  fpFtyp = TheosFTypDir;  break;
1240
 
            case _THS_IFREG:  fpFtyp = TheosFTypReg;  break;
1241
 
            case _THS_IODRC:  fpFtyp = TheosFTypRel;  break;
1242
 
            case _THS_IOKEY:  fpFtyp = TheosFTypKey;  break;
1243
 
            case _THS_IOIND:  fpFtyp = TheosFTypInd;  break;
1244
 
            case _THS_IOPRG:  fpFtyp = TheosFTypR16;  break;
1245
 
            case _THS_IO286:  fpFtyp = TheosFTypP16;  break;
1246
 
            case _THS_IO386:  fpFtyp = TheosFTypP32;  break;
1247
 
            default:         fpFtyp = TheosFTypUkn;  break;
1248
 
        }
1249
 
        strcpy(attribs, LoadFarStringSmall(fpFtyp));
1250
 
        attribs[12] = (xattr & _THS_HIDDN) ? 'H' : '.';
1251
 
        attribs[13] = (xattr & _THS_IXOTH) ? '.' : 'X';
1252
 
        attribs[14] = (xattr & _THS_IWOTH) ? '.' : 'W';
1253
 
        attribs[15] = (xattr & _THS_IROTH) ? '.' : 'R';
1254
 
        attribs[16] = (xattr & _THS_IEUSR) ? '.' : 'E';
1255
 
        attribs[17] = (xattr & _THS_IXUSR) ? '.' : 'X';
1256
 
        attribs[18] = (xattr & _THS_IWUSR) ? '.' : 'W';
1257
 
        attribs[19] = (xattr & _THS_IRUSR) ? '.' : 'R';
1258
 
        attribs[20] = 0;
1259
 
        Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
1260
 
          xattr, attribs));
1261
 
#endif /* OLD_THEOS_EXTRA */
1262
 
 
1263
 
    } else if ((hostnum != FS_FAT_) && (hostnum != FS_HPFS_) &&
1264
 
               (hostnum != FS_NTFS_) && (hostnum != FS_VFAT_) &&
1265
 
               (hostnum != ACORN_) &&
1266
 
               (hostnum != VM_CMS_) && (hostnum != MVS_))
1267
 
    {                                 /* assume Unix-like */
1268
 
        switch ((unsigned)(xattr & UNX_IFMT)) {
1269
 
            case (unsigned)UNX_IFDIR:   attribs[0] = 'd';  break;
1270
 
            case (unsigned)UNX_IFREG:   attribs[0] = '-';  break;
1271
 
            case (unsigned)UNX_IFLNK:   attribs[0] = 'l';  break;
1272
 
            case (unsigned)UNX_IFBLK:   attribs[0] = 'b';  break;
1273
 
            case (unsigned)UNX_IFCHR:   attribs[0] = 'c';  break;
1274
 
            case (unsigned)UNX_IFIFO:   attribs[0] = 'p';  break;
1275
 
            case (unsigned)UNX_IFSOCK:  attribs[0] = 's';  break;
1276
 
            default:          attribs[0] = '?';  break;
1277
 
        }
1278
 
        attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
1279
 
        attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
1280
 
        attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
1281
 
 
1282
 
        attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
1283
 
        attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
1284
 
        attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
1285
 
 
1286
 
        if (xattr & UNX_IXUSR)
1287
 
            attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
1288
 
        else
1289
 
            attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';   /* S = undefined */
1290
 
        if (xattr & UNX_IXGRP)
1291
 
            attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';   /* == UNX_ENFMT */
1292
 
        else
1293
 
            attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
1294
 
        if (xattr & UNX_IXOTH)
1295
 
            attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';   /* "sticky bit" */
1296
 
        else
1297
 
            attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';   /* T = undefined */
1298
 
        attribs[10] = 0;
1299
 
 
1300
 
        Info(slide, 0, ((char *)slide, LoadFarString(UnixFileAttributes), xattr,
1301
 
          attribs));
1302
 
 
1303
 
    } else {
1304
 
        Info(slide, 0, ((char *)slide, LoadFarString(NonMSDOSFileAttributes),
1305
 
            G.crec.external_file_attributes >> 8));
1306
 
 
1307
 
    } /* endif (hostnum: external attributes format) */
1308
 
 
1309
 
    if ((xattr=(unsigned)(G.crec.external_file_attributes & 0xFF)) == 0)
1310
 
        Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributes),
1311
 
          xattr));
1312
 
    else if (xattr == 1)
1313
 
        Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesRO),
1314
 
          xattr));
1315
 
    else
1316
 
        Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesAlpha),
1317
 
          xattr, (xattr&1)? "rdo " : nullStr,
1318
 
          (xattr&2)? "hid " : nullStr,
1319
 
          (xattr&4)? "sys " : nullStr,
1320
 
          (xattr&8)? "lab " : nullStr,
1321
 
          (xattr&16)? "dir " : nullStr,
1322
 
          (xattr&32)? "arc " : nullStr,
1323
 
          (xattr&64)? "lnk " : nullStr,
1324
 
          (xattr&128)? "exe" : nullStr));
1325
 
 
1326
 
/*---------------------------------------------------------------------------
1327
 
    Analyze the extra field, if any, and print the file comment, if any (the
1328
 
    filename has already been printed, above).  That finishes up this file
1329
 
    entry...
1330
 
  ---------------------------------------------------------------------------*/
1331
 
 
1332
 
    if (G.crec.extra_field_length > 0) {
1333
 
        uch *ef_ptr = G.extra_field;
1334
 
        ush ef_len = G.crec.extra_field_length;
1335
 
        ush eb_id, eb_datalen;
1336
 
        ZCONST char Far *ef_fieldname;
1337
 
 
1338
 
        if (error_in_archive > PK_WARN)   /* fatal:  can't continue */
1339
 
            /* delayed "fatal error" return from extra field reading */
1340
 
            return error;
1341
 
        if (G.extra_field == (uch *)NULL)
1342
 
            return PK_ERR;   /* not consistent with crec length */
1343
 
 
1344
 
        Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields)));
1345
 
 
1346
 
        while (ef_len >= EB_HEADSIZE) {
1347
 
            eb_id = makeword(&ef_ptr[EB_ID]);
1348
 
            eb_datalen = makeword(&ef_ptr[EB_LEN]);
1349
 
            ef_ptr += EB_HEADSIZE;
1350
 
            ef_len -= EB_HEADSIZE;
1351
 
 
1352
 
            if (eb_datalen > (ush)ef_len) {
1353
 
                Info(slide, 0x421, ((char *)slide,
1354
 
                  LoadFarString(ExtraFieldTrunc), eb_id, eb_datalen, ef_len));
1355
 
                eb_datalen = ef_len;
1356
 
            }
1357
 
 
1358
 
            switch (eb_id) {
1359
 
                case EF_PKSZ64:
1360
 
                    ef_fieldname = efPKSZ64;
1361
 
                    break;
1362
 
                case EF_AV:
1363
 
                    ef_fieldname = efAV;
1364
 
                    break;
1365
 
                case EF_OS2:
1366
 
                    ef_fieldname = efOS2;
1367
 
                    break;
1368
 
                case EF_ACL:
1369
 
                    ef_fieldname = efACL;
1370
 
                    break;
1371
 
                case EF_NTSD:
1372
 
                    ef_fieldname = efNTSD;
1373
 
                    break;
1374
 
                case EF_PKVMS:
1375
 
                    ef_fieldname = efPKVMS;
1376
 
                    break;
1377
 
                case EF_IZVMS:
1378
 
                    ef_fieldname = efIZVMS;
1379
 
                    break;
1380
 
                case EF_PKW32:
1381
 
                    ef_fieldname = efPKWin32;
1382
 
                    break;
1383
 
                case EF_PKUNIX:
1384
 
                    ef_fieldname = efPKUnix;
1385
 
                    break;
1386
 
                case EF_IZUNIX:
1387
 
                    ef_fieldname = efIZUnix;
1388
 
                    if (hostnum == UNIX_ && *pEndprev > 0L)
1389
 
                        *pEndprev += 4L;  /* also have UID/GID in local copy */
1390
 
                    break;
1391
 
                case EF_IZUNIX2:
1392
 
                    ef_fieldname = efIZUnix2;
1393
 
                    if (*pEndprev > 0L)
1394
 
                        *pEndprev += 4L;  /* 4 byte UID/GID in local copy */
1395
 
                    break;
1396
 
                case EF_TIME:
1397
 
                    ef_fieldname = efTime;
1398
 
                    break;
1399
 
                case EF_MAC3:
1400
 
                    ef_fieldname = efMac3;
1401
 
                    break;
1402
 
                case EF_JLMAC:
1403
 
                    ef_fieldname = efJLMac;
1404
 
                    break;
1405
 
                case EF_ZIPIT:
1406
 
                    ef_fieldname = efZipIt;
1407
 
                    break;
1408
 
                case EF_ZIPIT2:
1409
 
                    ef_fieldname = efZipIt2;
1410
 
                    break;
1411
 
                case EF_VMCMS:
1412
 
                    ef_fieldname = efVMCMS;
1413
 
                    break;
1414
 
                case EF_MVS:
1415
 
                    ef_fieldname = efMVS;
1416
 
                    break;
1417
 
                case EF_ATHEOS:
1418
 
                    ef_fieldname = efAtheOS;
1419
 
                    break;
1420
 
                case EF_BEOS:
1421
 
                    ef_fieldname = efBeOS;
1422
 
                    break;
1423
 
                case EF_QDOS:
1424
 
                    ef_fieldname = efQDOS;
1425
 
                    break;
1426
 
                case EF_AOSVS:
1427
 
                    ef_fieldname = efAOSVS;
1428
 
                    break;
1429
 
                case EF_SPARK:   /* from RISC OS */
1430
 
                    ef_fieldname = efSpark;
1431
 
                    break;
1432
 
                case EF_MD5:
1433
 
                    ef_fieldname = efMD5;
1434
 
                    break;
1435
 
                case EF_ASIUNIX:
1436
 
                    ef_fieldname = efASiUnix;
1437
 
                    break;
1438
 
                case EF_TANDEM:
1439
 
                    ef_fieldname = efTandem;
1440
 
                    break;
1441
 
                case EF_SMARTZIP:
1442
 
                    ef_fieldname = efSmartZip;
1443
 
                    break;
1444
 
                case EF_THEOS:
1445
 
#ifdef OLD_THEOS_EXTRA
1446
 
                case EF_THEOSO:
1447
 
#endif
1448
 
                    ef_fieldname = efTheos;
1449
 
                    break;
1450
 
                default:
1451
 
                    ef_fieldname = efUnknown;
1452
 
                    break;
1453
 
            }
1454
 
            Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
1455
 
                 eb_id, LoadFarStringSmall(ef_fieldname), eb_datalen));
1456
 
 
1457
 
            /* additional, field-specific information: */
1458
 
            switch (eb_id) {
1459
 
                case EF_OS2:
1460
 
                case EF_ACL:
1461
 
                    if (eb_datalen >= EB_OS2_HLEN) {
1462
 
                        if (eb_id == EF_OS2)
1463
 
                            ef_fieldname = OS2EAs;
1464
 
                        else
1465
 
                            ef_fieldname = ACLdata;
1466
 
                        Info(slide, 0, ((char *)slide,
1467
 
                          LoadFarString(ef_fieldname), makelong(ef_ptr)));
1468
 
                        *pEndprev = 0L;   /* no clue about csize of local */
1469
 
                    }
1470
 
                    break;
1471
 
                case EF_NTSD:
1472
 
                    if (eb_datalen >= EB_NTSD_C_LEN) {
1473
 
                        Info(slide, 0, ((char *)slide, LoadFarString(NTSDData),
1474
 
                          makelong(ef_ptr)));
1475
 
                        *pEndprev = 0L;   /* no clue about csize of local */
1476
 
                    }
1477
 
                    break;
1478
 
                case EF_IZVMS:
1479
 
                    if (eb_datalen >= 8) {
1480
 
                        char *p, q[8];
1481
 
                        unsigned compr = makeword(ef_ptr+EB_IZVMS_FLGS)
1482
 
                                        & EB_IZVMS_BCMASK;
1483
 
 
1484
 
                        *q = '\0';
1485
 
                        if (compr > 3)
1486
 
                            compr = 3;
1487
 
                        switch (makelong(ef_ptr)) {
1488
 
                            case 0x42414656: /* "VFAB" */
1489
 
                                p = "FAB"; break;
1490
 
                            case 0x4C4C4156: /* "VALL" */
1491
 
                                p = "XABALL"; break;
1492
 
                            case 0x43484656: /* "VFHC" */
1493
 
                                p = "XABFHC"; break;
1494
 
                            case 0x54414456: /* "VDAT" */
1495
 
                                p = "XABDAT"; break;
1496
 
                            case 0x54445256: /* "VRDT" */
1497
 
                                p = "XABRDT"; break;
1498
 
                            case 0x4F525056: /* "VPRO" */
1499
 
                                p = "XABPRO"; break;
1500
 
                            case 0x59454B56: /* "VKEY" */
1501
 
                                p = "XABKEY"; break;
1502
 
                            case 0x56534D56: /* "VMSV" */
1503
 
                                p = "version";
1504
 
                                if (eb_datalen >= 16) {
1505
 
                                    /* put termitation first, for A_TO_N() */
1506
 
                                    q[7] = '\0';
1507
 
                                    q[0] = ' ';
1508
 
                                    q[1] = '(';
1509
 
                                    strncpy(q+2,
1510
 
                                            (char *)ef_ptr+EB_IZVMS_HLEN, 4);
1511
 
                                    A_TO_N(q+2);
1512
 
                                    q[6] = ')';
1513
 
                                }
1514
 
                                break;
1515
 
                            default:
1516
 
                                p = "unknown";
1517
 
                        }
1518
 
                        Info(slide, 0, ((char *)slide,
1519
 
                          LoadFarString(izVMSdata),
1520
 
                          LoadFarStringSmall(izVMScomp[compr]),
1521
 
                          makeword(ef_ptr+EB_IZVMS_UCSIZ), p, q));
1522
 
                    }
1523
 
                    break;
1524
 
                case EF_TIME:
1525
 
                    if (eb_datalen >= 1) {
1526
 
                        char types[80];
1527
 
                        int num = 0, len;
1528
 
 
1529
 
                        *types = '\0';
1530
 
                        if (*ef_ptr & 1) {
1531
 
                            strcpy(types, LoadFarString(UTmodification));
1532
 
                            ++num;
1533
 
                        }
1534
 
                        if (*ef_ptr & 2) {
1535
 
                            len = strlen(types);
1536
 
                            if (num)
1537
 
                                types[len++] = '/';
1538
 
                            strcpy(types+len, LoadFarString(UTaccess));
1539
 
                            ++num;
1540
 
                            if (*pEndprev > 0L)
1541
 
                                *pEndprev += 4L;
1542
 
                        }
1543
 
                        if (*ef_ptr & 4) {
1544
 
                            len = strlen(types);
1545
 
                            if (num)
1546
 
                                types[len++] = '/';
1547
 
                            strcpy(types+len, LoadFarString(UTcreation));
1548
 
                            ++num;
1549
 
                            if (*pEndprev > 0L)
1550
 
                                *pEndprev += 4L;
1551
 
                        }
1552
 
                        if (num > 0)
1553
 
                            Info(slide, 0, ((char *)slide,
1554
 
                              LoadFarString(UTdata), types,
1555
 
                              num == 1? nullStr : PlurSufx));
1556
 
                    }
1557
 
                    break;
1558
 
                case EF_MAC3:
1559
 
                    if (eb_datalen >= EB_MAC3_HLEN) {
1560
 
                        ulg eb_uc = makelong(ef_ptr);
1561
 
                        unsigned mac3_flgs = makeword(ef_ptr+EB_FLGS_OFFS);
1562
 
                        unsigned eb_is_uc = mac3_flgs & EB_M3_FL_UNCMPR;
1563
 
 
1564
 
                        Info(slide, 0, ((char *)slide, LoadFarString(Mac3data),
1565
 
                          eb_uc, eb_is_uc ? "un" : nullStr));
1566
 
                        if (eb_is_uc) {
1567
 
                            if (*pEndprev > 0L)
1568
 
                                *pEndprev += makelong(ef_ptr);
1569
 
                        } else {
1570
 
                            *pEndprev = 0L; /* no clue about csize of local */
1571
 
                        }
1572
 
 
1573
 
                        Info(slide, 0, ((char *)slide,
1574
 
                          LoadFarString(MacOSMAC3flags),
1575
 
                          LoadFarStringSmall(mac3_flgs & EB_M3_FL_DATFRK ?
1576
 
                                             MacOS_DF : MacOS_RF),
1577
 
                          (mac3_flgs & EB_M3_FL_TIME64 ? 64 : 32)));
1578
 
                        zi_showMacTypeCreator(__G__ &ef_ptr[6]);
1579
 
                    }
1580
 
                    break;
1581
 
                case EF_ZIPIT2:
1582
 
                    if (eb_datalen >= 5 &&
1583
 
                        makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
1584
 
 
1585
 
                        if (eb_datalen >= 12) {
1586
 
                            zi_showMacTypeCreator(__G__ &ef_ptr[4]);
1587
 
                        }
1588
 
                    }
1589
 
                    break;
1590
 
                case EF_ZIPIT:
1591
 
                    if (eb_datalen >= 5 &&
1592
 
                        makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
1593
 
                        unsigned fnlen = ef_ptr[4];
1594
 
 
1595
 
                        if ((unsigned)eb_datalen >= fnlen + (5 + 8)) {
1596
 
                            uch nullchar = ef_ptr[fnlen+5];
1597
 
 
1598
 
                            ef_ptr[fnlen+5] = '\0'; /* terminate filename */
1599
 
                            A_TO_N(ef_ptr+5);
1600
 
                            Info(slide, 0, ((char *)slide,
1601
 
                              LoadFarString(ZipItFname), (char *)ef_ptr+5));
1602
 
                            ef_ptr[fnlen+5] = nullchar;
1603
 
                            zi_showMacTypeCreator(__G__ &ef_ptr[fnlen+5]);
1604
 
                        }
1605
 
                    }
1606
 
                    break;
1607
 
                case EF_JLMAC:
1608
 
                    if (eb_datalen >= 40 &&
1609
 
                        makelong(ef_ptr) == 0x45454C4A /* "JLEE" */)
1610
 
                    {
1611
 
                        zi_showMacTypeCreator(__G__ &ef_ptr[4]);
1612
 
 
1613
 
                        Info(slide, 0, ((char *)slide,
1614
 
                          LoadFarString(MacOSJLEEflags),
1615
 
                          LoadFarStringSmall(ef_ptr[31] & 1 ?
1616
 
                                             MacOS_DF : MacOS_RF)));
1617
 
                    }
1618
 
                    break;
1619
 
                case EF_SMARTZIP:
1620
 
                    if ((eb_datalen == EB_SMARTZIP_HLEN) &&
1621
 
                        makelong(ef_ptr) == 0x70695A64 /* "dZip" */) {
1622
 
                        char filenameBuf[32];
1623
 
                        zi_showMacTypeCreator(__G__ &ef_ptr[4]);
1624
 
                        memcpy(filenameBuf, &ef_ptr[33], 31);
1625
 
                        filenameBuf[ef_ptr[32]] = '\0';
1626
 
                        A_TO_N(filenameBuf);
1627
 
                        Info(slide, 0, ((char *)slide,
1628
 
                             LoadFarString(ZipItFname), filenameBuf));
1629
 
                    }
1630
 
                    break;
1631
 
#ifdef CMS_MVS
1632
 
                case EF_VMCMS:
1633
 
                case EF_MVS:
1634
 
                    {
1635
 
                        char type[100];
1636
 
 
1637
 
                        Info(slide, 0, ((char *)slide,
1638
 
                             LoadFarString(VmMvsExtraField),
1639
 
                             (getVMMVSexfield(type, ef_ptr-EB_HEADSIZE,
1640
 
                             (unsigned)eb_datalen) > 0)?
1641
 
                             type : LoadFarStringSmall(VmMvsInvalid)));
1642
 
                    }
1643
 
                    break;
1644
 
#endif /* CMS_MVS */
1645
 
                case EF_ATHEOS:
1646
 
                case EF_BEOS:
1647
 
                    if (eb_datalen >= EB_BEOS_HLEN) {
1648
 
                        ulg eb_uc = makelong(ef_ptr);
1649
 
                        unsigned eb_is_uc =
1650
 
                          *(ef_ptr+EB_FLGS_OFFS) & EB_BE_FL_UNCMPR;
1651
 
 
1652
 
                        if (eb_id == EF_ATHEOS)
1653
 
                            ef_fieldname = AtheOSdata;
1654
 
                        else
1655
 
                            ef_fieldname = BeOSdata;
1656
 
                        Info(slide, 0, ((char *)slide,
1657
 
                          LoadFarString(ef_fieldname),
1658
 
                          eb_uc, eb_is_uc ? "un" : nullStr));
1659
 
                        if (eb_is_uc) {
1660
 
                            if (*pEndprev > 0L)
1661
 
                                *pEndprev += makelong(ef_ptr);
1662
 
                        } else {
1663
 
                            *pEndprev = 0L; /* no clue about csize of local */
1664
 
                        }
1665
 
                    }
1666
 
                    break;
1667
 
                case EF_QDOS:
1668
 
                    if (eb_datalen >= 4) {
1669
 
                        Info(slide, 0, ((char *)slide, LoadFarString(QDOSdata),
1670
 
                          ef_ptr[0], ef_ptr[1], ef_ptr[2], ef_ptr[3]));
1671
 
                    }
1672
 
                    break;
1673
 
                case EF_AOSVS:
1674
 
                    if (eb_datalen >= 5) {
1675
 
                        Info(slide, 0, ((char *)slide, LoadFarString(AOSVSdata),
1676
 
                          ((int)(uch)ef_ptr[4])/10, ((int)(uch)ef_ptr[4])%10));
1677
 
                    }
1678
 
                    break;
1679
 
                case EF_TANDEM:
1680
 
                    if (eb_datalen == 20) {
1681
 
                        unsigned type, code;
1682
 
 
1683
 
                        type = (ef_ptr[18] & 0x60) >> 5;
1684
 
                        code = makeword(ef_ptr);
1685
 
                        /* Arrg..., Tandem e.f. uses BigEndian byte-order */
1686
 
                        code = ((code << 8) & 0xff00) | ((code >> 8) & 0x00ff);
1687
 
                        if (type == NSK_UNSTRUCTURED) {
1688
 
                            if (code == NSK_EDITFILECODE)
1689
 
                                type = 4;
1690
 
                            else if (code == NSK_OBJECTFILECODE)
1691
 
                                type = 5;
1692
 
                        }
1693
 
                        Info(slide, 0, ((char *)slide,
1694
 
                          LoadFarString(Tandemdata),
1695
 
                          LoadFarStringSmall(TandemFileformat[type]),
1696
 
                          code));
1697
 
                    }
1698
 
                    break;
1699
 
                case EF_MD5:
1700
 
                    if (eb_datalen >= 19) {
1701
 
                        char md5[33];
1702
 
                        int i;
1703
 
 
1704
 
                        for (i = 0;  i < 16;  ++i)
1705
 
                            sprintf(&md5[i<<1], "%02x", ef_ptr[15-i]);
1706
 
                        md5[32] = '\0';
1707
 
                        Info(slide, 0, ((char *)slide, LoadFarString(MD5data),
1708
 
                          md5));
1709
 
                        break;
1710
 
                    }   /* else: fall through !! */
1711
 
                default:
1712
 
                    if (eb_datalen > 0) {
1713
 
                        ush i, n;
1714
 
 
1715
 
                        if (eb_datalen <= 24) {
1716
 
                            Info(slide, 0, ((char *)slide,
1717
 
                                 LoadFarString(ColonIndent)));
1718
 
                            n = eb_datalen;
1719
 
                        } else {
1720
 
                            Info(slide, 0, ((char *)slide,
1721
 
                                 LoadFarString(First20)));
1722
 
                            n = 20;
1723
 
                        }
1724
 
                        for (i = 0;  i < n;  ++i)
1725
 
                            Info(slide, 0, ((char *)slide,
1726
 
                                 LoadFarString(efFormat), ef_ptr[i]));
1727
 
                    }
1728
 
                    break;
1729
 
            }
1730
 
            (*G.message)((zvoid *)&G, (uch *)".", 1L, 0);
1731
 
 
1732
 
            ef_ptr += eb_datalen;
1733
 
            ef_len -= eb_datalen;
1734
 
        }
1735
 
        (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
1736
 
    }
1737
 
 
1738
 
    /* high bit == Unix/OS2/NT GMT times (mtime, atime); next bit == UID/GID */
1739
 
    if ((xattr = (unsigned)((G.crec.external_file_attributes & 0xC000) >> 12))
1740
 
        & 8)
1741
 
    {
1742
 
        if (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)
1743
 
        {
1744
 
            Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
1745
 
              "is", EF_IZUNIX, LoadFarStringSmall(efIZUnix),
1746
 
              (unsigned)(xattr&12), (xattr&4)? efIZuid : efIZnouid));
1747
 
            if (*pEndprev > 0L)
1748
 
                *pEndprev += (ulg)(xattr&12);
1749
 
        }
1750
 
        else if (hostnum == FS_FAT_ && !(xattr&4))
1751
 
            Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
1752
 
              "may be", EF_IZUNIX, LoadFarStringSmall(efIZUnix), 8,
1753
 
              efIZnouid));
1754
 
    }
1755
 
 
1756
 
    if (!G.crec.file_comment_length)
1757
 
        Info(slide, 0, ((char *)slide, LoadFarString(NoFileComment)));
1758
 
    else {
1759
 
        Info(slide, 0, ((char *)slide, LoadFarString(FileCommBegin)));
1760
 
        if ((error = do_string(__G__ G.crec.file_comment_length, DISPL_8)) !=
1761
 
            PK_COOL)
1762
 
        {
1763
 
            error_in_archive = error;   /* might be warning */
1764
 
            if (error > PK_WARN)   /* fatal */
1765
 
                return error;
1766
 
        }
1767
 
        Info(slide, 0, ((char *)slide, LoadFarString(FileCommEnd)));
1768
 
    }
1769
 
 
1770
 
    return error_in_archive;
1771
 
 
1772
 
} /* end function zi_long() */
1773
 
 
1774
 
 
1775
 
 
1776
 
 
1777
 
 
1778
 
/*************************/
1779
 
/*  Function zi_short()  */
1780
 
/*************************/
1781
 
 
1782
 
static int zi_short(__G)   /* return PK-type error code */
1783
 
    __GDEF
1784
 
{
1785
 
#ifdef USE_EF_UT_TIME
1786
 
    iztimes     z_utime;
1787
 
    time_t      *z_modtim;
1788
 
#endif
1789
 
    int         k, error, error_in_archive=PK_COOL;
1790
 
    unsigned    hostnum, hostver, methnum, xattr;
1791
 
    char        *p, workspace[12], attribs[16];
1792
 
    char        methbuf[5];
1793
 
    static ZCONST char dtype[5]="NXFS"; /* normal, maximum, fast, superfast */
1794
 
    static ZCONST char Far os[NUM_HOSTS+1][4] = {
1795
 
        "fat", "ami", "vms", "unx", "cms", "atr", "hpf", "mac", "zzz",
1796
 
        "cpm", "t20", "ntf", "qds", "aco", "vft", "mvs", "be ", "nsk",
1797
 
        "ths", "osx", "???", "???", "???", "???", "???", "???", "???",
1798
 
        "???", "???", "???", "ath", "???"
1799
 
    };
1800
 
#ifdef OLD_THEOS_EXTRA
1801
 
    static ZCONST char Far os_TheosOld[] = "tho";
1802
 
#endif
1803
 
    static ZCONST char Far method[NUM_METHODS+1][5] = {
1804
 
        "stor", "shrk", "re:1", "re:2", "re:3", "re:4", "i#:#", "tokn",
1805
 
        "def#", "d64#", "dcli", "u011", "bzp2", "u###"
1806
 
    };
1807
 
 
1808
 
 
1809
 
/*---------------------------------------------------------------------------
1810
 
    Print out various interesting things about the compressed file.
1811
 
  ---------------------------------------------------------------------------*/
1812
 
 
1813
 
    methnum = (unsigned)MIN(G.crec.compression_method, NUM_METHODS);
1814
 
    hostnum = (unsigned)(G.pInfo->hostnum);
1815
 
    hostver = (unsigned)(G.pInfo->hostver);
1816
 
/*
1817
 
    extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
1818
 
    extver = (unsigned)G.crec.version_needed_to_extract[0];
1819
 
 */
1820
 
 
1821
 
    zfstrcpy(methbuf, method[methnum]);
1822
 
    if (methnum == IMPLODED) {
1823
 
        methbuf[1] = (char)((G.crec.general_purpose_bit_flag & 2)? '8' : '4');
1824
 
        methbuf[3] = (char)((G.crec.general_purpose_bit_flag & 4)? '3' : '2');
1825
 
    } else if (methnum == DEFLATED || methnum == ENHDEFLATED) {
1826
 
        ush  dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
1827
 
        methbuf[3] = dtype[dnum];
1828
 
    } else if (methnum >= NUM_METHODS) {   /* unknown */
1829
 
        sprintf(&methbuf[1], "%03u", G.crec.compression_method);
1830
 
    }
1831
 
 
1832
 
    for (k = 0;  k < 15;  ++k)
1833
 
        attribs[k] = ' ';
1834
 
    attribs[15] = 0;
1835
 
 
1836
 
    xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
1837
 
    switch (hostnum) {
1838
 
        case VMS_:
1839
 
            {   int    i, j;
1840
 
 
1841
 
                for (k = 0;  k < 12;  ++k)
1842
 
                    workspace[k] = 0;
1843
 
                if (xattr & VMS_IRUSR)
1844
 
                    workspace[0] = 'R';
1845
 
                if (xattr & VMS_IWUSR) {
1846
 
                    workspace[1] = 'W';
1847
 
                    workspace[3] = 'D';
1848
 
                }
1849
 
                if (xattr & VMS_IXUSR)
1850
 
                    workspace[2] = 'E';
1851
 
                if (xattr & VMS_IRGRP)
1852
 
                    workspace[4] = 'R';
1853
 
                if (xattr & VMS_IWGRP) {
1854
 
                    workspace[5] = 'W';
1855
 
                    workspace[7] = 'D';
1856
 
                }
1857
 
                if (xattr & VMS_IXGRP)
1858
 
                  workspace[6] = 'E';
1859
 
                if (xattr & VMS_IROTH)
1860
 
                    workspace[8] = 'R';
1861
 
                if (xattr & VMS_IWOTH) {
1862
 
                    workspace[9] = 'W';
1863
 
                    workspace[11] = 'D';
1864
 
                }
1865
 
                if (xattr & VMS_IXOTH)
1866
 
                    workspace[10] = 'E';
1867
 
 
1868
 
                p = attribs;
1869
 
                for (k = j = 0;  j < 3;  ++j) {     /* groups of permissions */
1870
 
                    for (i = 0;  i < 4;  ++i, ++k)  /* perms within a group */
1871
 
                        if (workspace[k])
1872
 
                            *p++ = workspace[k];
1873
 
                    *p++ = ',';                     /* group separator */
1874
 
                }
1875
 
                *--p = ' ';   /* overwrite last comma */
1876
 
                if ((p - attribs) < 12)
1877
 
                    sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
1878
 
            }
1879
 
            break;
1880
 
 
1881
 
        case AMIGA_:
1882
 
            switch (xattr & AMI_IFMT) {
1883
 
                case AMI_IFDIR:  attribs[0] = 'd';  break;
1884
 
                case AMI_IFREG:  attribs[0] = '-';  break;
1885
 
                default:         attribs[0] = '?';  break;
1886
 
            }
1887
 
            attribs[1] = (xattr & AMI_IHIDDEN)?   'h' : '-';
1888
 
            attribs[2] = (xattr & AMI_ISCRIPT)?   's' : '-';
1889
 
            attribs[3] = (xattr & AMI_IPURE)?     'p' : '-';
1890
 
            attribs[4] = (xattr & AMI_IARCHIVE)?  'a' : '-';
1891
 
            attribs[5] = (xattr & AMI_IREAD)?     'r' : '-';
1892
 
            attribs[6] = (xattr & AMI_IWRITE)?    'w' : '-';
1893
 
            attribs[7] = (xattr & AMI_IEXECUTE)?  'e' : '-';
1894
 
            attribs[8] = (xattr & AMI_IDELETE)?   'd' : '-';
1895
 
            sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
1896
 
            break;
1897
 
 
1898
 
        case THEOS_:
1899
 
            switch (xattr & THS_IFMT) {
1900
 
                case THS_IFLIB: *attribs = 'L'; break;
1901
 
                case THS_IFDIR: *attribs = 'D'; break;
1902
 
                case THS_IFCHR: *attribs = 'C'; break;
1903
 
                case THS_IFREG: *attribs = 'S'; break;
1904
 
                case THS_IFREL: *attribs = 'R'; break;
1905
 
                case THS_IFKEY: *attribs = 'K'; break;
1906
 
                case THS_IFIND: *attribs = 'I'; break;
1907
 
                case THS_IFR16: *attribs = 'P'; break;
1908
 
                case THS_IFP16: *attribs = '2'; break;
1909
 
                case THS_IFP32: *attribs = '3'; break;
1910
 
                default:        *attribs = '?'; break;
1911
 
            }
1912
 
            attribs[1] = (xattr & THS_INHID) ? '.' : 'H';
1913
 
            attribs[2] = (xattr & THS_IMODF) ? '.' : 'M';
1914
 
            attribs[3] = (xattr & THS_IWOTH) ? '.' : 'W';
1915
 
            attribs[4] = (xattr & THS_IROTH) ? '.' : 'R';
1916
 
            attribs[5] = (xattr & THS_IEUSR) ? '.' : 'E';
1917
 
            attribs[6] = (xattr & THS_IXUSR) ? '.' : 'X';
1918
 
            attribs[7] = (xattr & THS_IWUSR) ? '.' : 'W';
1919
 
            attribs[8] = (xattr & THS_IRUSR) ? '.' : 'R';
1920
 
            sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
1921
 
            break;
1922
 
 
1923
 
        case FS_VFAT_:
1924
 
#ifdef OLD_THEOS_EXTRA
1925
 
            if (hostver == 20) {
1926
 
                switch (xattr & _THS_IFMT) {
1927
 
                    case _THS_IFLIB: *attribs = 'L'; break;
1928
 
                    case _THS_IFDIR: *attribs = 'd'; break;
1929
 
                    case _THS_IFCHR: *attribs = 'c'; break;
1930
 
                    case _THS_IFREG: *attribs = 'S'; break;
1931
 
                    case _THS_IODRC: *attribs = 'D'; break;
1932
 
                    case _THS_IOKEY: *attribs = 'K'; break;
1933
 
                    case _THS_IOIND: *attribs = 'I'; break;
1934
 
                    case _THS_IOPRG: *attribs = 'P'; break;
1935
 
                    case _THS_IO286: *attribs = '2'; break;
1936
 
                    case _THS_IO386: *attribs = '3'; break;
1937
 
                    default:         *attribs = '?'; break;
1938
 
                }
1939
 
                attribs[1] = (xattr & _THS_HIDDN) ? 'H' : '.';
1940
 
                attribs[2] = (xattr & _THS_IXOTH) ? '.' : 'X';
1941
 
                attribs[3] = (xattr & _THS_IWOTH) ? '.' : 'W';
1942
 
                attribs[4] = (xattr & _THS_IROTH) ? '.' : 'R';
1943
 
                attribs[5] = (xattr & _THS_IEUSR) ? '.' : 'E';
1944
 
                attribs[6] = (xattr & _THS_IXUSR) ? '.' : 'X';
1945
 
                attribs[7] = (xattr & _THS_IWUSR) ? '.' : 'W';
1946
 
                attribs[8] = (xattr & _THS_IRUSR) ? '.' : 'R';
1947
 
                sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
1948
 
                break;
1949
 
            } /* else: fall through! */
1950
 
#endif /* OLD_THEOS_EXTRA */
1951
 
 
1952
 
        case FS_FAT_:
1953
 
        case FS_HPFS_:
1954
 
        case FS_NTFS_:
1955
 
        case VM_CMS_:
1956
 
        case MVS_:
1957
 
        case ACORN_:
1958
 
            if (hostnum != FS_FAT_ ||
1959
 
                (unsigned)(xattr & 0700) !=
1960
 
                 ((unsigned)0400 |
1961
 
                  ((unsigned)!(G.crec.external_file_attributes & 1) << 7) |
1962
 
                  ((unsigned)(G.crec.external_file_attributes & 0x10) << 2))
1963
 
               )
1964
 
            {
1965
 
                xattr = (unsigned)(G.crec.external_file_attributes & 0xFF);
1966
 
                sprintf(attribs, ".r.-...     %u.%u", hostver/10, hostver%10);
1967
 
                attribs[2] = (xattr & 0x01)? '-' : 'w';
1968
 
                attribs[5] = (xattr & 0x02)? 'h' : '-';
1969
 
                attribs[6] = (xattr & 0x04)? 's' : '-';
1970
 
                attribs[4] = (xattr & 0x20)? 'a' : '-';
1971
 
                if (xattr & 0x10) {
1972
 
                    attribs[0] = 'd';
1973
 
                    attribs[3] = 'x';
1974
 
                } else
1975
 
                    attribs[0] = '-';
1976
 
                if (IS_VOLID(xattr))
1977
 
                    attribs[0] = 'V';
1978
 
                else if ((p = MBSRCHR(G.filename, '.')) != (char *)NULL) {
1979
 
                    ++p;
1980
 
                    if (STRNICMP(p, "com", 3) == 0 ||
1981
 
                        STRNICMP(p, "exe", 3) == 0 ||
1982
 
                        STRNICMP(p, "btm", 3) == 0 ||
1983
 
                        STRNICMP(p, "cmd", 3) == 0 ||
1984
 
                        STRNICMP(p, "bat", 3) == 0)
1985
 
                        attribs[3] = 'x';
1986
 
                }
1987
 
                break;
1988
 
            } /* else: fall through! */
1989
 
 
1990
 
        default:   /* assume Unix-like */
1991
 
            switch ((unsigned)(xattr & UNX_IFMT)) {
1992
 
                case (unsigned)UNX_IFDIR:   attribs[0] = 'd';  break;
1993
 
                case (unsigned)UNX_IFREG:   attribs[0] = '-';  break;
1994
 
                case (unsigned)UNX_IFLNK:   attribs[0] = 'l';  break;
1995
 
                case (unsigned)UNX_IFBLK:   attribs[0] = 'b';  break;
1996
 
                case (unsigned)UNX_IFCHR:   attribs[0] = 'c';  break;
1997
 
                case (unsigned)UNX_IFIFO:   attribs[0] = 'p';  break;
1998
 
                case (unsigned)UNX_IFSOCK:  attribs[0] = 's';  break;
1999
 
                default:          attribs[0] = '?';  break;
2000
 
            }
2001
 
            attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
2002
 
            attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
2003
 
            attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
2004
 
            attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
2005
 
            attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
2006
 
            attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
2007
 
 
2008
 
            if (xattr & UNX_IXUSR)
2009
 
                attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
2010
 
            else
2011
 
                attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';  /* S==undefined */
2012
 
            if (xattr & UNX_IXGRP)
2013
 
                attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';  /* == UNX_ENFMT */
2014
 
            else
2015
 
                /* attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';  real 4.3BSD */
2016
 
                attribs[6] = (xattr & UNX_ISGID)? 'S' : '-';  /* SunOS 4.1.x */
2017
 
            if (xattr & UNX_IXOTH)
2018
 
                attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';  /* "sticky bit" */
2019
 
            else
2020
 
                attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';  /* T==undefined */
2021
 
 
2022
 
            sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
2023
 
            break;
2024
 
 
2025
 
    } /* end switch (hostnum: external attributes format) */
2026
 
 
2027
 
#ifdef OLD_THEOS_EXTRA
2028
 
    Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
2029
 
      LoadFarStringSmall(((hostnum == FS_VFAT_ && hostver == 20) ?
2030
 
                          os_TheosOld :
2031
 
                          os[hostnum])),
2032
 
      G.crec.ucsize));
2033
 
#else
2034
 
    Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
2035
 
      LoadFarStringSmall(os[hostnum]),
2036
 
      G.crec.ucsize));
2037
 
#endif
2038
 
    Info(slide, 0, ((char *)slide, "%c",
2039
 
      (G.crec.general_purpose_bit_flag & 1)?
2040
 
      ((G.crec.internal_file_attributes & 1)? 'T' : 'B') :  /* encrypted */
2041
 
      ((G.crec.internal_file_attributes & 1)? 't' : 'b'))); /* plaintext */
2042
 
    k = (G.crec.extra_field_length ||
2043
 
         /* a local-only "UX" (old Unix/OS2/NT GMT times "IZUNIX") e.f.? */
2044
 
         ((G.crec.external_file_attributes & 0x8000) &&
2045
 
          (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)));
2046
 
    Info(slide, 0, ((char *)slide, "%c", k?
2047
 
      ((G.crec.general_purpose_bit_flag & 8)? 'X' : 'x') :  /* extra field */
2048
 
      ((G.crec.general_purpose_bit_flag & 8)? 'l' : '-'))); /* no extra field */
2049
 
      /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extended local header or not */
2050
 
 
2051
 
    if (uO.lflag == 4) {
2052
 
        ulg csiz = G.crec.csize;
2053
 
 
2054
 
        if (G.crec.general_purpose_bit_flag & 1)
2055
 
            csiz -= 12;    /* if encrypted, don't count encryption header */
2056
 
        Info(slide, 0, ((char *)slide, "%3d%%",
2057
 
          (ratio(G.crec.ucsize,csiz)+5)/10));
2058
 
    } else if (uO.lflag == 5)
2059
 
        Info(slide, 0, ((char *)slide, " %8lu", G.crec.csize));
2060
 
 
2061
 
    /* Read the extra field, if any.  The extra field info may be used
2062
 
     * in the file modification time section, below.
2063
 
     */
2064
 
    if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
2065
 
    {
2066
 
        if (G.extra_field != NULL) {
2067
 
            free(G.extra_field);
2068
 
            G.extra_field = NULL;
2069
 
        }
2070
 
        error_in_archive = error;
2071
 
        /* We do not return prematurely in case of a "fatal" error (PK_EOF).
2072
 
         * This does not hurt here, because we do not need to read from the
2073
 
         * zipfile again before the end of this function.
2074
 
         */
2075
 
    }
2076
 
 
2077
 
    /* For printing of date & time, a "char d_t_buf[16]" is required.
2078
 
     * To save stack space, we reuse the "char attribs[16]" buffer whose
2079
 
     * content is no longer needed.
2080
 
     */
2081
 
#   define d_t_buf attribs
2082
 
#ifdef USE_EF_UT_TIME
2083
 
    z_modtim = G.extra_field &&
2084
 
#ifdef IZ_CHECK_TZ
2085
 
               G.tz_is_valid &&
2086
 
#endif
2087
 
               (ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
2088
 
                                 G.crec.last_mod_dos_datetime, &z_utime, NULL)
2089
 
                & EB_UT_FL_MTIME)
2090
 
              ? &z_utime.mtime : NULL;
2091
 
    TIMET_TO_NATIVE(z_utime.mtime)     /* NOP unless MSC 7.0 or Macintosh */
2092
 
    d_t_buf[0] = (char)0;              /* signal "show local time" */
2093
 
#else
2094
 
#   define z_modtim NULL
2095
 
#endif
2096
 
    Info(slide, 0, ((char *)slide, " %s %s ", methbuf,
2097
 
      zi_time(__G__ &G.crec.last_mod_dos_datetime, z_modtim, d_t_buf)));
2098
 
    fnprint(__G);
2099
 
 
2100
 
/*---------------------------------------------------------------------------
2101
 
    Skip the file comment, if any (the filename has already been printed,
2102
 
    above).  That finishes up this file entry...
2103
 
  ---------------------------------------------------------------------------*/
2104
 
 
2105
 
    SKIP_(G.crec.file_comment_length)
2106
 
 
2107
 
    return error_in_archive;
2108
 
 
2109
 
} /* end function zi_short() */
2110
 
 
2111
 
 
2112
 
 
2113
 
 
2114
 
 
2115
 
/**************************************/
2116
 
/*  Function zi_showMacTypeCreator()  */
2117
 
/**************************************/
2118
 
 
2119
 
static void zi_showMacTypeCreator(__G__ ebfield)
2120
 
    __GDEF
2121
 
    uch *ebfield;
2122
 
{
2123
 
    /* not every Type / Creator character is printable */
2124
 
    if (isprint(native(ebfield[0])) && isprint(native(ebfield[1])) &&
2125
 
        isprint(native(ebfield[2])) && isprint(native(ebfield[3])) &&
2126
 
        isprint(native(ebfield[4])) && isprint(native(ebfield[5])) &&
2127
 
        isprint(native(ebfield[6])) && isprint(native(ebfield[7]))) {
2128
 
       Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata),
2129
 
            native(ebfield[0]), native(ebfield[1]),
2130
 
            native(ebfield[2]), native(ebfield[3]),
2131
 
            native(ebfield[4]), native(ebfield[5]),
2132
 
            native(ebfield[6]), native(ebfield[7])));
2133
 
    } else {
2134
 
       Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata1),
2135
 
            (((ulg)ebfield[0]) << 24) +
2136
 
            (((ulg)ebfield[1]) << 16) +
2137
 
            (((ulg)ebfield[2]) << 8)  +
2138
 
            ((ulg)ebfield[3]),
2139
 
            (((ulg)ebfield[4]) << 24) +
2140
 
            (((ulg)ebfield[5]) << 16) +
2141
 
            (((ulg)ebfield[6]) << 8)  +
2142
 
            ((ulg)ebfield[7])));
2143
 
    }
2144
 
} /* end function zi_showMacTypeCreator() */
2145
 
 
2146
 
 
2147
 
 
2148
 
 
2149
 
 
2150
 
/************************/
2151
 
/*  Function zi_time()  */
2152
 
/************************/
2153
 
 
2154
 
static char *zi_time(__G__ datetimez, modtimez, d_t_str)
2155
 
    __GDEF
2156
 
    ZCONST ulg *datetimez;
2157
 
    ZCONST time_t *modtimez;
2158
 
    char *d_t_str;
2159
 
{
2160
 
    unsigned yr, mo, dy, hh, mm, ss;
2161
 
    char monthbuf[4];
2162
 
    ZCONST char *monthstr;
2163
 
    static ZCONST char Far month[12][4] = {
2164
 
        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
2165
 
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
2166
 
    };
2167
 
#ifdef USE_EF_UT_TIME
2168
 
    struct tm *t;
2169
 
#endif
2170
 
 
2171
 
 
2172
 
 
2173
 
/*---------------------------------------------------------------------------
2174
 
    Convert the file-modification date and time info to a string of the form
2175
 
    "1991 Feb 23 17:15:00", "23-Feb-91 17:15" or "19910223.171500", depending
2176
 
    on values of lflag and T_flag.  If using Unix-time extra fields, convert
2177
 
    to local time or not, depending on value of first character in d_t_str[].
2178
 
  ---------------------------------------------------------------------------*/
2179
 
 
2180
 
#ifdef USE_EF_UT_TIME
2181
 
    if (modtimez != NULL) {
2182
 
#ifndef NO_GMTIME
2183
 
        /* check for our secret message from above... */
2184
 
        t = (d_t_str[0] == (char)1)? gmtime(modtimez) : localtime(modtimez);
2185
 
#else
2186
 
        t = localtime(modtimez);
2187
 
#endif
2188
 
        if (uO.lflag > 9 && t == (struct tm *)NULL)
2189
 
            /* time conversion error in verbose listing format,
2190
 
             * return string with '?' instead of data
2191
 
             */
2192
 
            return (strcpy(d_t_str, LoadFarString(YMDHMSTimeError)));
2193
 
    } else
2194
 
        t = (struct tm *)NULL;
2195
 
    if (t != (struct tm *)NULL) {
2196
 
        mo = (unsigned)(t->tm_mon + 1);
2197
 
        dy = (unsigned)(t->tm_mday);
2198
 
        yr = (unsigned)(t->tm_year);
2199
 
 
2200
 
        hh = (unsigned)(t->tm_hour);
2201
 
        mm = (unsigned)(t->tm_min);
2202
 
        ss = (unsigned)(t->tm_sec);
2203
 
    } else
2204
 
#endif /* USE_EF_UT_TIME */
2205
 
    {
2206
 
        yr = ((unsigned)(*datetimez >> 25) & 0x7f) + 80;
2207
 
        mo = ((unsigned)(*datetimez >> 21) & 0x0f);
2208
 
        dy = ((unsigned)(*datetimez >> 16) & 0x1f);
2209
 
 
2210
 
        hh = (((unsigned)*datetimez >> 11) & 0x1f);
2211
 
        mm = (((unsigned)*datetimez >> 5) & 0x3f);
2212
 
        ss = (((unsigned)*datetimez << 1) & 0x3e);
2213
 
    }
2214
 
 
2215
 
    if (mo == 0 || mo > 12) {
2216
 
        sprintf(monthbuf, LoadFarString(BogusFmt), mo);
2217
 
        monthstr = monthbuf;
2218
 
    } else
2219
 
        monthstr = LoadFarStringSmall(month[mo-1]);
2220
 
 
2221
 
    if (uO.lflag > 9)   /* verbose listing format */
2222
 
        sprintf(d_t_str, LoadFarString(YMDHMSTime), yr+1900, monthstr, dy, hh,
2223
 
          mm, ss);
2224
 
    else if (uO.T_flag)
2225
 
        sprintf(d_t_str, LoadFarString(DecimalTime), yr+1900, mo, dy, hh, mm,
2226
 
          ss);
2227
 
    else   /* was:  if ((uO.lflag >= 3) && (uO.lflag <= 5)) */
2228
 
        sprintf(d_t_str, LoadFarString(DMYHMTime), dy, monthstr, yr%100, hh,
2229
 
          mm);
2230
 
 
2231
 
    return d_t_str;
2232
 
 
2233
 
} /* end function zi_time() */
2234
 
 
2235
 
#endif /* !NO_ZIPINFO */