2
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
4
See the accompanying file LICENSE, version 2000-Apr-09 or later
5
(the contents of which are also included in unzip.h) for terms of use.
6
If, for some reason, all these files are missing, the Info-ZIP license
7
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9
/*---------------------------------------------------------------------------
11
zipinfo.c Greg Roelofs et al.
13
This file contains all of the ZipInfo-specific listing routines for UnZip.
22
---------------------------------------------------------------------------*/
25
#define UNZIP_INTERNAL
29
#ifndef NO_ZIPINFO /* strings use up too much space in small-memory systems */
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. */
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 */
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 */
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 */
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 */
107
#ifdef OLD_THEOS_EXTRA
108
# include "theos/oldstat.h"
111
#ifndef NSK_UNSTRUCTURED
112
# define NSK_UNSTRUCTURED 0
114
#ifndef NSK_OBJECTFILECODE
115
# define NSK_OBJECTFILECODE 100
117
#ifndef NSK_EDITFILECODE
118
# define NSK_EDITFILECODE 101
121
#define LFLAG 3 /* short "ls -l" type listing */
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));
131
/**********************************************/
132
/* Strings used in zipinfo.c (ZipInfo half) */
133
/**********************************************/
135
static ZCONST char nullStr[] = "";
136
static ZCONST char PlurSufx[] = "s";
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";
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";
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 */
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";
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";
222
static ZCONST char Far ExtraBytesPreceding[] =
223
" There are an extra %ld bytes preceding this file.\n\n";
225
static ZCONST char Far UnknownNo[] = "unknown (%d)";
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";
256
static ZCONST char Far GMTime[] = "UTC";
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";
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[] = "??? ";
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";
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\
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";
397
static ZCONST char Far VmMvsExtraField[] = ".\n\
398
The stored file open mode (FLDATA TYPE) is \"%s\"";
399
static ZCONST char Far VmMvsInvalid[] = "[invalid]";
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";
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";
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";
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[] = "???? ??? ?? ??:??:??";
435
/************************/
436
/* Function zi_opts() */
437
/************************/
439
int zi_opts(__G__ pargc, pargv)
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;
452
uO.lflag = LFLAG; /* reset default on each call */
454
G.extract_flag = FALSE; /* zipinfo does not extract to disk */
458
while (--argc > 0 && (*++argv)[0] == '-') {
460
while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
465
case '1': /* shortest listing: JUST filenames */
467
uO.lflag = -2, negative = 0;
471
case '2': /* just filenames, plus headers if specified */
473
uO.lflag = -2, negative = 0;
478
case ('C'): /* -C: match filenames case-insensitively */
480
uO.C_flag = FALSE, negative = 0;
484
#endif /* !CMS_MVS */
485
case 'h': /* header line */
487
hflag_2 = hflag_slmv = FALSE, negative = 0;
489
hflag_2 = hflag_slmv = explicit_h = TRUE;
494
case 'l': /* longer form of "ls -l" type listing */
496
uO.lflag = -2, negative = 0;
500
case 'm': /* medium form of "ls -l" type listing */
502
uO.lflag = -2, negative = 0;
507
case 'M': /* send output through built-in "more" */
509
G.M_flag = FALSE, negative = 0;
514
case 's': /* default: shorter "ls -l" type listing */
516
uO.lflag = -2, negative = 0;
520
case 't': /* totals line */
522
tflag_2v = tflag_slm = FALSE, negative = 0;
524
tflag_2v = tflag_slm = explicit_t = TRUE;
529
case ('T'): /* use (sortable) decimal time format */
531
uO.T_flag = FALSE, negative = 0;
535
case 'v': /* turbo-verbose listing */
537
uO.lflag = -2, negative = 0;
541
#ifdef WILD_STOP_AT_DIR
542
case ('W'): /* Wildcard interpretation (stop at '/'?) */
544
uO.W_flag = FALSE, negative = 0;
548
#endif /* WILD_STOP_AT_DIR */
549
case 'z': /* print zipfile comment */
551
uO.zflag = negative = 0;
555
case 'Z': /* ZipInfo mode: ignore */
563
if ((argc-- == 0) || error) {
570
if (G.M_flag && !isatty(1)) /* stdout redirected: "more" func useless */
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)))
579
/* set header and totals flags to default or specified values */
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 */
586
case 1: /* only filenames, *always* */
594
uO.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
595
uO.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
598
uO.hflag = hflag_slmv;
607
} /* end function zi_opts() */
615
/*******************************/
616
/* Function zi_end_central() */
617
/*******************************/
619
int zi_end_central(__G) /* return PK-type error code */
625
/*---------------------------------------------------------------------------
626
Print out various interesting things about the zipfile.
627
---------------------------------------------------------------------------*/
629
/* header fits on one line, for anything up to 10GB and 10000 files: */
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));
639
Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));
640
Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));
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));
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));
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));
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
-----------------------------------------------------------------------*/
677
if (!G.ecrec.zipfile_comment_length)
678
Info(slide, 0, ((char *)slide, LoadFarString(NoZipfileComment)));
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))
685
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommEnd)));
687
Info(slide, 0, ((char *)slide,
688
LoadFarString(ZipfileCommTrunc2)));
689
} /* endif (comment exists) */
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)));
698
} /* endif (verbose) */
702
} /* end function zi_end_central() */
708
/************************/
709
/* Function zipinfo() */
710
/************************/
712
int zipinfo(__G) /* return PK-type error code */
715
int do_this_file=FALSE, error, error_in_archive=PK_COOL;
716
int *fn_matched=NULL, *xn_matched=NULL;
718
ulg tot_csize=0L, tot_ucsize=0L;
719
ulg endprev; /* buffers end of previous entry for zi_long()'s check
723
/*---------------------------------------------------------------------------
724
Malloc space for check on unmatched filespecs (no big deal if one or both
726
---------------------------------------------------------------------------*/
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;
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;
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
748
---------------------------------------------------------------------------*/
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?) */
754
/* reset endprev for new zipfile; account for multi-part archives (?) */
755
endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;
759
if (readbuf(__G__ G.sig, 4) == 0)
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
771
((char *)slide, LoadFarString(CentSigMsg), j));
773
((char *)slide, LoadFarString(ReportMsg)));
774
return PK_BADERR; /* sig not found */
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 */
781
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
784
error_in_archive = error; /* might be warning */
785
if (error > PK_WARN) /* fatal */
789
if (!G.process_all_files) { /* check if specified on command line */
792
if (G.filespecs == 0)
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)) {
800
fn_matched[i] = TRUE;
801
break; /* found match, so stop looping */
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 */
809
xn_matched[i] = TRUE;
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
-----------------------------------------------------------------------*/
821
if (G.process_all_files || do_this_file) {
827
SKIP_(G.crec.extra_field_length)
828
SKIP_(G.crec.file_comment_length)
834
if ((error = zi_short(__G)) != PK_COOL) {
835
error_in_archive = error; /* might be warning */
836
if (error > PK_WARN) /* fatal */
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 */
852
SKIP_(G.crec.extra_field_length)
853
SKIP_(G.crec.file_comment_length)
856
} /* end switch (lflag) */
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 */
865
if ((G.statreportcb != NULL) &&
866
(*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,
867
G.filename, (zvoid *)&G.crec.ucsize)) {
869
free((zvoid *)fn_matched);
871
free((zvoid *)xn_matched);
872
return IZ_CTRLC; /* cancel operation by user request */
875
#ifdef MACOS /* MacOS is no preemptive OS, thus call event-handling by hand */
879
} else { /* not listing this file */
880
SKIP_(G.crec.extra_field_length)
881
SKIP_(G.crec.file_comment_length)
883
} /* end if (list member?) */
885
} /* end for-loop (j: member files) */
887
/*---------------------------------------------------------------------------
888
Check that we actually found requested files; if so, print totals.
889
---------------------------------------------------------------------------*/
893
int cfactor = ratio(tot_ucsize, tot_csize);
899
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),
900
members, (members==1L)? nullStr:PlurSufx, tot_ucsize,
901
tot_csize, sgn, cfactor/10, cfactor%10));
904
/*---------------------------------------------------------------------------
905
Check for unmatched filespecs on command line and print warning if any
907
---------------------------------------------------------------------------*/
910
for (j = 0; j < G.filespecs; ++j)
912
Info(slide, 0x401, ((char *)slide,
913
LoadFarString(FilenameNotMatched), G.pfnames[j]));
914
free((zvoid *)fn_matched);
917
for (j = 0; j < G.xfilespecs; ++j)
919
Info(slide, 0x401, ((char *)slide,
920
LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));
921
free((zvoid *)xn_matched);
924
/*---------------------------------------------------------------------------
925
Double check that we're back at the end-of-central-directory record.
926
---------------------------------------------------------------------------*/
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 */
932
if (members == 0 && error_in_archive <= PK_WARN)
933
error_in_archive = PK_FIND;
936
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
938
return error_in_archive;
940
} /* end function zipinfo() */
946
/************************/
947
/* Function zi_long() */
948
/************************/
950
static int zi_long(__G__ pEndprev) /* return PK-type error code */
952
ulg *pEndprev; /* for zi_long() check of extra bytes */
954
#ifdef USE_EF_UT_TIME
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;
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,
969
static ZCONST char Far *method[NUM_METHODS] = {
970
MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
971
MthdImplode, MthdToken, MthdDeflate, MthdDeflat64, MthdDCLImplode,
972
MthdPKRes11, MthdBZip2
974
static ZCONST char Far *dtypelng[4] = {
975
DeflNorm, DeflMax, DeflFast, DeflSFast
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
---------------------------------------------------------------------------*/
985
if (G.crec.relative_offset_local_header != *pEndprev && *pEndprev > 0L) {
987
Info(slide, 0, ((char *)slide,
988
" [crec.relative_offset_local_header = %lu, endprev = %lu]\n",
989
G.crec.relative_offset_local_header, *pEndprev));
991
Info(slide, 0, ((char *)slide, LoadFarString(ExtraBytesPreceding),
992
(long)G.crec.relative_offset_local_header - (long)(*pEndprev)));
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;
1000
/*---------------------------------------------------------------------------
1001
Read the extra field, if any. It may be used to get UNIX style modtime.
1002
---------------------------------------------------------------------------*/
1004
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
1006
if (G.extra_field != NULL) {
1007
free(G.extra_field);
1008
G.extra_field = NULL;
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.
1018
/*---------------------------------------------------------------------------
1019
Print out various interesting things about the compressed file.
1020
---------------------------------------------------------------------------*/
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);
1028
(*G.message)((zvoid *)&G, (uch *)" ", 2L, 0); fnprint(__G);
1030
Info(slide, 0, ((char *)slide, LoadFarString(LocalHeaderOffset),
1031
G.crec.relative_offset_local_header,
1032
G.crec.relative_offset_local_header));
1034
if (hostnum >= NUM_HOSTS) {
1035
sprintf(unkn, LoadFarString(UnknownNo),
1036
(int)G.crec.version_made_by[1]);
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);
1045
#endif /* OLD_THEOS_EXTRA */
1047
Info(slide, 0, ((char *)slide, LoadFarString(HostOS), varmsg_str));
1048
Info(slide, 0, ((char *)slide, LoadFarString(EncodeSWVer), hostver/10,
1051
if ((extnum >= NUM_HOSTS) || (os[extnum] == NULL)) {
1052
sprintf(unkn, LoadFarString(UnknownNo),
1053
(int)G.crec.version_needed_to_extract[1]);
1056
varmsg_str = LoadFarStringSmall(os[extnum]);
1058
Info(slide, 0, ((char *)slide, LoadFarString(MinOSCompReq), varmsg_str));
1059
Info(slide, 0, ((char *)slide, LoadFarString(MinSWVerReq), extver/10,
1062
if (methnum >= NUM_METHODS) {
1063
sprintf(unkn, LoadFarString(UnknownNo), G.crec.compression_method);
1066
varmsg_str = LoadFarStringSmall(method[methnum]);
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);
1077
Info(slide, 0, ((char *)slide, LoadFarString(CompressSubtype),
1078
LoadFarStringSmall(dtypelng[dnum])));
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? */
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
1091
# define d_t_buf attribs
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 &&
1100
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
1101
G.crec.last_mod_dos_datetime, &z_utime, NULL)
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)));
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 */
1116
#endif /* USE_EF_UT_TIME */
1118
Info(slide, 0, ((char *)slide, LoadFarString(CRC32Value), G.crec.crc32));
1119
Info(slide, 0, ((char *)slide, LoadFarString(CompressedFileSize),
1121
Info(slide, 0, ((char *)slide, LoadFarString(UncompressedFileSize),
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 */
1136
printf(" external file attributes (hex): %.8lx\n",
1137
G.crec.external_file_attributes);
1139
xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
1140
if (hostnum == VMS_) {
1141
char *p=attribs, *q=attribs+1;
1144
for (k = 0; k < 12; ++k)
1146
if (xattr & VMS_IRUSR)
1148
if (xattr & VMS_IWUSR) {
1152
if (xattr & VMS_IXUSR)
1154
if (xattr & VMS_IRGRP)
1156
if (xattr & VMS_IWGRP) {
1160
if (xattr & VMS_IXGRP)
1162
if (xattr & VMS_IROTH)
1164
if (xattr & VMS_IWOTH) {
1166
workspace[11] = 'D';
1168
if (xattr & VMS_IXOTH)
1169
workspace[10] = 'E';
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 */
1175
*p++ = workspace[k];
1176
*p++ = ','; /* group separator */
1178
while ((*p++ = *q++) != ',')
1179
; /* system, owner perms are same */
1182
*p = ')'; /* overwrite last comma */
1183
Info(slide, 0, ((char *)slide, LoadFarString(VMSFileAttributes), xattr,
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;
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),
1204
} else if (hostnum == THEOS_) {
1205
ZCONST char Far *fpFtyp;
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;
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';
1229
Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
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;
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;
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';
1259
Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
1261
#endif /* OLD_THEOS_EXTRA */
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;
1278
attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
1279
attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
1280
attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
1282
attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
1283
attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
1284
attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
1286
if (xattr & UNX_IXUSR)
1287
attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
1289
attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S = undefined */
1290
if (xattr & UNX_IXGRP)
1291
attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
1293
attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
1294
if (xattr & UNX_IXOTH)
1295
attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x'; /* "sticky bit" */
1297
attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T = undefined */
1300
Info(slide, 0, ((char *)slide, LoadFarString(UnixFileAttributes), xattr,
1304
Info(slide, 0, ((char *)slide, LoadFarString(NonMSDOSFileAttributes),
1305
G.crec.external_file_attributes >> 8));
1307
} /* endif (hostnum: external attributes format) */
1309
if ((xattr=(unsigned)(G.crec.external_file_attributes & 0xFF)) == 0)
1310
Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributes),
1312
else if (xattr == 1)
1313
Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesRO),
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));
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
1330
---------------------------------------------------------------------------*/
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;
1338
if (error_in_archive > PK_WARN) /* fatal: can't continue */
1339
/* delayed "fatal error" return from extra field reading */
1341
if (G.extra_field == (uch *)NULL)
1342
return PK_ERR; /* not consistent with crec length */
1344
Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields)));
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;
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;
1360
ef_fieldname = efPKSZ64;
1363
ef_fieldname = efAV;
1366
ef_fieldname = efOS2;
1369
ef_fieldname = efACL;
1372
ef_fieldname = efNTSD;
1375
ef_fieldname = efPKVMS;
1378
ef_fieldname = efIZVMS;
1381
ef_fieldname = efPKWin32;
1384
ef_fieldname = efPKUnix;
1387
ef_fieldname = efIZUnix;
1388
if (hostnum == UNIX_ && *pEndprev > 0L)
1389
*pEndprev += 4L; /* also have UID/GID in local copy */
1392
ef_fieldname = efIZUnix2;
1394
*pEndprev += 4L; /* 4 byte UID/GID in local copy */
1397
ef_fieldname = efTime;
1400
ef_fieldname = efMac3;
1403
ef_fieldname = efJLMac;
1406
ef_fieldname = efZipIt;
1409
ef_fieldname = efZipIt2;
1412
ef_fieldname = efVMCMS;
1415
ef_fieldname = efMVS;
1418
ef_fieldname = efAtheOS;
1421
ef_fieldname = efBeOS;
1424
ef_fieldname = efQDOS;
1427
ef_fieldname = efAOSVS;
1429
case EF_SPARK: /* from RISC OS */
1430
ef_fieldname = efSpark;
1433
ef_fieldname = efMD5;
1436
ef_fieldname = efASiUnix;
1439
ef_fieldname = efTandem;
1442
ef_fieldname = efSmartZip;
1445
#ifdef OLD_THEOS_EXTRA
1448
ef_fieldname = efTheos;
1451
ef_fieldname = efUnknown;
1454
Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
1455
eb_id, LoadFarStringSmall(ef_fieldname), eb_datalen));
1457
/* additional, field-specific information: */
1461
if (eb_datalen >= EB_OS2_HLEN) {
1462
if (eb_id == EF_OS2)
1463
ef_fieldname = OS2EAs;
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 */
1472
if (eb_datalen >= EB_NTSD_C_LEN) {
1473
Info(slide, 0, ((char *)slide, LoadFarString(NTSDData),
1475
*pEndprev = 0L; /* no clue about csize of local */
1479
if (eb_datalen >= 8) {
1481
unsigned compr = makeword(ef_ptr+EB_IZVMS_FLGS)
1487
switch (makelong(ef_ptr)) {
1488
case 0x42414656: /* "VFAB" */
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" */
1504
if (eb_datalen >= 16) {
1505
/* put termitation first, for A_TO_N() */
1510
(char *)ef_ptr+EB_IZVMS_HLEN, 4);
1518
Info(slide, 0, ((char *)slide,
1519
LoadFarString(izVMSdata),
1520
LoadFarStringSmall(izVMScomp[compr]),
1521
makeword(ef_ptr+EB_IZVMS_UCSIZ), p, q));
1525
if (eb_datalen >= 1) {
1531
strcpy(types, LoadFarString(UTmodification));
1535
len = strlen(types);
1538
strcpy(types+len, LoadFarString(UTaccess));
1544
len = strlen(types);
1547
strcpy(types+len, LoadFarString(UTcreation));
1553
Info(slide, 0, ((char *)slide,
1554
LoadFarString(UTdata), types,
1555
num == 1? nullStr : PlurSufx));
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;
1564
Info(slide, 0, ((char *)slide, LoadFarString(Mac3data),
1565
eb_uc, eb_is_uc ? "un" : nullStr));
1568
*pEndprev += makelong(ef_ptr);
1570
*pEndprev = 0L; /* no clue about csize of local */
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]);
1582
if (eb_datalen >= 5 &&
1583
makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
1585
if (eb_datalen >= 12) {
1586
zi_showMacTypeCreator(__G__ &ef_ptr[4]);
1591
if (eb_datalen >= 5 &&
1592
makelong(ef_ptr) == 0x5449505A /* "ZPIT" */) {
1593
unsigned fnlen = ef_ptr[4];
1595
if ((unsigned)eb_datalen >= fnlen + (5 + 8)) {
1596
uch nullchar = ef_ptr[fnlen+5];
1598
ef_ptr[fnlen+5] = '\0'; /* terminate filename */
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]);
1608
if (eb_datalen >= 40 &&
1609
makelong(ef_ptr) == 0x45454C4A /* "JLEE" */)
1611
zi_showMacTypeCreator(__G__ &ef_ptr[4]);
1613
Info(slide, 0, ((char *)slide,
1614
LoadFarString(MacOSJLEEflags),
1615
LoadFarStringSmall(ef_ptr[31] & 1 ?
1616
MacOS_DF : MacOS_RF)));
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));
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)));
1644
#endif /* CMS_MVS */
1647
if (eb_datalen >= EB_BEOS_HLEN) {
1648
ulg eb_uc = makelong(ef_ptr);
1650
*(ef_ptr+EB_FLGS_OFFS) & EB_BE_FL_UNCMPR;
1652
if (eb_id == EF_ATHEOS)
1653
ef_fieldname = AtheOSdata;
1655
ef_fieldname = BeOSdata;
1656
Info(slide, 0, ((char *)slide,
1657
LoadFarString(ef_fieldname),
1658
eb_uc, eb_is_uc ? "un" : nullStr));
1661
*pEndprev += makelong(ef_ptr);
1663
*pEndprev = 0L; /* no clue about csize of local */
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]));
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));
1680
if (eb_datalen == 20) {
1681
unsigned type, code;
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)
1690
else if (code == NSK_OBJECTFILECODE)
1693
Info(slide, 0, ((char *)slide,
1694
LoadFarString(Tandemdata),
1695
LoadFarStringSmall(TandemFileformat[type]),
1700
if (eb_datalen >= 19) {
1704
for (i = 0; i < 16; ++i)
1705
sprintf(&md5[i<<1], "%02x", ef_ptr[15-i]);
1707
Info(slide, 0, ((char *)slide, LoadFarString(MD5data),
1710
} /* else: fall through !! */
1712
if (eb_datalen > 0) {
1715
if (eb_datalen <= 24) {
1716
Info(slide, 0, ((char *)slide,
1717
LoadFarString(ColonIndent)));
1720
Info(slide, 0, ((char *)slide,
1721
LoadFarString(First20)));
1724
for (i = 0; i < n; ++i)
1725
Info(slide, 0, ((char *)slide,
1726
LoadFarString(efFormat), ef_ptr[i]));
1730
(*G.message)((zvoid *)&G, (uch *)".", 1L, 0);
1732
ef_ptr += eb_datalen;
1733
ef_len -= eb_datalen;
1735
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
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))
1742
if (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)
1744
Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
1745
"is", EF_IZUNIX, LoadFarStringSmall(efIZUnix),
1746
(unsigned)(xattr&12), (xattr&4)? efIZuid : efIZnouid));
1748
*pEndprev += (ulg)(xattr&12);
1750
else if (hostnum == FS_FAT_ && !(xattr&4))
1751
Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
1752
"may be", EF_IZUNIX, LoadFarStringSmall(efIZUnix), 8,
1756
if (!G.crec.file_comment_length)
1757
Info(slide, 0, ((char *)slide, LoadFarString(NoFileComment)));
1759
Info(slide, 0, ((char *)slide, LoadFarString(FileCommBegin)));
1760
if ((error = do_string(__G__ G.crec.file_comment_length, DISPL_8)) !=
1763
error_in_archive = error; /* might be warning */
1764
if (error > PK_WARN) /* fatal */
1767
Info(slide, 0, ((char *)slide, LoadFarString(FileCommEnd)));
1770
return error_in_archive;
1772
} /* end function zi_long() */
1778
/*************************/
1779
/* Function zi_short() */
1780
/*************************/
1782
static int zi_short(__G) /* return PK-type error code */
1785
#ifdef USE_EF_UT_TIME
1789
int k, error, error_in_archive=PK_COOL;
1790
unsigned hostnum, hostver, methnum, xattr;
1791
char *p, workspace[12], attribs[16];
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", "???"
1800
#ifdef OLD_THEOS_EXTRA
1801
static ZCONST char Far os_TheosOld[] = "tho";
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###"
1809
/*---------------------------------------------------------------------------
1810
Print out various interesting things about the compressed file.
1811
---------------------------------------------------------------------------*/
1813
methnum = (unsigned)MIN(G.crec.compression_method, NUM_METHODS);
1814
hostnum = (unsigned)(G.pInfo->hostnum);
1815
hostver = (unsigned)(G.pInfo->hostver);
1817
extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
1818
extver = (unsigned)G.crec.version_needed_to_extract[0];
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);
1832
for (k = 0; k < 15; ++k)
1836
xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
1841
for (k = 0; k < 12; ++k)
1843
if (xattr & VMS_IRUSR)
1845
if (xattr & VMS_IWUSR) {
1849
if (xattr & VMS_IXUSR)
1851
if (xattr & VMS_IRGRP)
1853
if (xattr & VMS_IWGRP) {
1857
if (xattr & VMS_IXGRP)
1859
if (xattr & VMS_IROTH)
1861
if (xattr & VMS_IWOTH) {
1863
workspace[11] = 'D';
1865
if (xattr & VMS_IXOTH)
1866
workspace[10] = 'E';
1869
for (k = j = 0; j < 3; ++j) { /* groups of permissions */
1870
for (i = 0; i < 4; ++i, ++k) /* perms within a group */
1872
*p++ = workspace[k];
1873
*p++ = ','; /* group separator */
1875
*--p = ' '; /* overwrite last comma */
1876
if ((p - attribs) < 12)
1877
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
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;
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);
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;
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);
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;
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);
1949
} /* else: fall through! */
1950
#endif /* OLD_THEOS_EXTRA */
1958
if (hostnum != FS_FAT_ ||
1959
(unsigned)(xattr & 0700) !=
1961
((unsigned)!(G.crec.external_file_attributes & 1) << 7) |
1962
((unsigned)(G.crec.external_file_attributes & 0x10) << 2))
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' : '-';
1976
if (IS_VOLID(xattr))
1978
else if ((p = MBSRCHR(G.filename, '.')) != (char *)NULL) {
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)
1988
} /* else: fall through! */
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;
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' : '-';
2008
if (xattr & UNX_IXUSR)
2009
attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
2011
attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S==undefined */
2012
if (xattr & UNX_IXGRP)
2013
attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
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" */
2020
attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T==undefined */
2022
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
2025
} /* end switch (hostnum: external attributes format) */
2027
#ifdef OLD_THEOS_EXTRA
2028
Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
2029
LoadFarStringSmall(((hostnum == FS_VFAT_ && hostver == 20) ?
2034
Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
2035
LoadFarStringSmall(os[hostnum]),
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 */
2051
if (uO.lflag == 4) {
2052
ulg csiz = G.crec.csize;
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));
2061
/* Read the extra field, if any. The extra field info may be used
2062
* in the file modification time section, below.
2064
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
2066
if (G.extra_field != NULL) {
2067
free(G.extra_field);
2068
G.extra_field = NULL;
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.
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.
2081
# define d_t_buf attribs
2082
#ifdef USE_EF_UT_TIME
2083
z_modtim = G.extra_field &&
2087
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
2088
G.crec.last_mod_dos_datetime, &z_utime, NULL)
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" */
2094
# define z_modtim NULL
2096
Info(slide, 0, ((char *)slide, " %s %s ", methbuf,
2097
zi_time(__G__ &G.crec.last_mod_dos_datetime, z_modtim, d_t_buf)));
2100
/*---------------------------------------------------------------------------
2101
Skip the file comment, if any (the filename has already been printed,
2102
above). That finishes up this file entry...
2103
---------------------------------------------------------------------------*/
2105
SKIP_(G.crec.file_comment_length)
2107
return error_in_archive;
2109
} /* end function zi_short() */
2115
/**************************************/
2116
/* Function zi_showMacTypeCreator() */
2117
/**************************************/
2119
static void zi_showMacTypeCreator(__G__ ebfield)
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])));
2134
Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata1),
2135
(((ulg)ebfield[0]) << 24) +
2136
(((ulg)ebfield[1]) << 16) +
2137
(((ulg)ebfield[2]) << 8) +
2139
(((ulg)ebfield[4]) << 24) +
2140
(((ulg)ebfield[5]) << 16) +
2141
(((ulg)ebfield[6]) << 8) +
2142
((ulg)ebfield[7])));
2144
} /* end function zi_showMacTypeCreator() */
2150
/************************/
2151
/* Function zi_time() */
2152
/************************/
2154
static char *zi_time(__G__ datetimez, modtimez, d_t_str)
2156
ZCONST ulg *datetimez;
2157
ZCONST time_t *modtimez;
2160
unsigned yr, mo, dy, hh, mm, ss;
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"
2167
#ifdef USE_EF_UT_TIME
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
---------------------------------------------------------------------------*/
2180
#ifdef USE_EF_UT_TIME
2181
if (modtimez != NULL) {
2183
/* check for our secret message from above... */
2184
t = (d_t_str[0] == (char)1)? gmtime(modtimez) : localtime(modtimez);
2186
t = localtime(modtimez);
2188
if (uO.lflag > 9 && t == (struct tm *)NULL)
2189
/* time conversion error in verbose listing format,
2190
* return string with '?' instead of data
2192
return (strcpy(d_t_str, LoadFarString(YMDHMSTimeError)));
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);
2200
hh = (unsigned)(t->tm_hour);
2201
mm = (unsigned)(t->tm_min);
2202
ss = (unsigned)(t->tm_sec);
2204
#endif /* USE_EF_UT_TIME */
2206
yr = ((unsigned)(*datetimez >> 25) & 0x7f) + 80;
2207
mo = ((unsigned)(*datetimez >> 21) & 0x0f);
2208
dy = ((unsigned)(*datetimez >> 16) & 0x1f);
2210
hh = (((unsigned)*datetimez >> 11) & 0x1f);
2211
mm = (((unsigned)*datetimez >> 5) & 0x3f);
2212
ss = (((unsigned)*datetimez << 1) & 0x3e);
2215
if (mo == 0 || mo > 12) {
2216
sprintf(monthbuf, LoadFarString(BogusFmt), mo);
2217
monthstr = monthbuf;
2219
monthstr = LoadFarStringSmall(month[mo-1]);
2221
if (uO.lflag > 9) /* verbose listing format */
2222
sprintf(d_t_str, LoadFarString(YMDHMSTime), yr+1900, monthstr, dy, hh,
2225
sprintf(d_t_str, LoadFarString(DecimalTime), yr+1900, mo, dy, hh, mm,
2227
else /* was: if ((uO.lflag >= 3) && (uO.lflag <= 5)) */
2228
sprintf(d_t_str, LoadFarString(DMYHMTime), dy, monthstr, yr%100, hh,
2233
} /* end function zi_time() */
2235
#endif /* !NO_ZIPINFO */