#define UNZIP_INTERNAL
#include "unzip.h"
#ifndef NO_ZIPINFO
#define UNX_IFMT 0170000
#define UNX_IFREG 0100000
#define UNX_IFSOCK 0140000
#define UNX_IFLNK 0120000
#define UNX_IFBLK 0060000
#define UNX_IFDIR 0040000
#define UNX_IFCHR 0020000
#define UNX_IFIFO 0010000
#define UNX_ISUID 04000
#define UNX_ISGID 02000
#define UNX_ISVTX 01000
#define UNX_ENFMT UNX_ISGID
#define UNX_IRWXU 00700
#define UNX_IRUSR 00400
#define UNX_IWUSR 00200
#define UNX_IXUSR 00100
#define UNX_IRWXG 00070
#define UNX_IRGRP 00040
#define UNX_IWGRP 00020
#define UNX_IXGRP 00010
#define UNX_IRWXO 00007
#define UNX_IROTH 00004
#define UNX_IWOTH 00002
#define UNX_IXOTH 00001
#define VMS_IRUSR UNX_IRUSR
#define VMS_IWUSR UNX_IWUSR
#define VMS_IXUSR UNX_IXUSR
#define VMS_IRGRP UNX_IRGRP
#define VMS_IWGRP UNX_IWGRP
#define VMS_IXGRP UNX_IXGRP
#define VMS_IROTH UNX_IROTH
#define VMS_IWOTH UNX_IWOTH
#define VMS_IXOTH UNX_IXOTH
#define AMI_IFMT 06000
#define AMI_IFDIR 04000
#define AMI_IFREG 02000
#define AMI_IHIDDEN 00200
#define AMI_ISCRIPT 00100
#define AMI_IPURE 00040
#define AMI_IARCHIVE 00020
#define AMI_IREAD 00010
#define AMI_IWRITE 00004
#define AMI_IEXECUTE 00002
#define AMI_IDELETE 00001
#define THS_IFMT 0xF000
#define THS_IFIFO 0x1000
#define THS_IFCHR 0x2000
#define THS_IFSOCK 0x3000
#define THS_IFDIR 0x4000
#define THS_IFLIB 0x5000
#define THS_IFBLK 0x6000
#define THS_IFREG 0x8000
#define THS_IFREL 0x9000
#define THS_IFKEY 0xA000
#define THS_IFIND 0xB000
#define THS_IFRND 0xC000
#define THS_IFR16 0xD000
#define THS_IFP16 0xE000
#define THS_IFP32 0xF000
#define THS_IMODF 0x0800
#define THS_INHID 0x0400
#define THS_IEUSR 0x0200
#define THS_IRUSR 0x0100
#define THS_IWUSR 0x0080
#define THS_IXUSR 0x0040
#define THS_IROTH 0x0004
#define THS_IWOTH 0x0002
#define THS_IXOTH 0x0001
#ifdef OLD_THEOS_EXTRA
# include "theos/oldstat.h"
#endif
#ifndef NSK_UNSTRUCTURED
# define NSK_UNSTRUCTURED 0
#endif
#ifndef NSK_OBJECTFILECODE
# define NSK_OBJECTFILECODE 100
#endif
#ifndef NSK_EDITFILECODE
# define NSK_EDITFILECODE 101
#endif
#define LFLAG 3
static int zi_long OF((__GPRO__ ulg *pEndprev));
static int zi_short OF((__GPRO));
static void zi_showMacTypeCreator
OF((__GPRO__ uch *ebfield));
static char *zi_time OF((__GPRO__ ZCONST ulg *datetimez,
ZCONST time_t *modtimez, char *d_t_str));
static ZCONST char nullStr[] = "";
static ZCONST char PlurSufx[] = "s";
static ZCONST char Far LongHeader[] = "Archive: %s %ld bytes %u file%s\n";
static ZCONST char Far ShortHeader[] = "Archive: %s %ld %u\n";
static ZCONST char Far EndCentDirRec[] = "\nEnd-of-central-directory record:\n";
static ZCONST char Far LineSeparators[] = "-------------------------------\n\n";
static ZCONST char Far ActOffsetCentDir[] = "\
Actual offset of end-of-central-dir record: %9ld (%.8lXh)\n\
Expected offset of end-of-central-dir record: %9ld (%.8lXh)\n\
(based on the length of the central directory and its expected offset)\n\n";
static ZCONST char Far SinglePartArchive1[] = "\
This zipfile constitutes the sole disk of a single-part archive; its\n\
central directory contains %u %s. The central directory is %lu\n\
(%.8lXh) bytes long, and its (expected) offset in bytes from the\n";
static ZCONST char Far SinglePartArchive2[] = "\
beginning of the zipfile is %lu (%.8lXh).\n\n";
static ZCONST char Far MultiPartArchive1[] = "\
This zipfile constitutes disk %u of a multi-part archive. The central\n\
directory starts on disk %u; %u of its entries %s contained within\n";
static ZCONST char Far MultiPartArchive2[] = "\
this zipfile, out of a total of %u %s. The entire central\n\
directory is %lu (%.8lXh) bytes long, and its offset in bytes from\n";
static ZCONST char Far MultiPartArchive3[] = "\
the beginning of the zipfile in which it begins is %lu (%.8lXh).\n\n";
static ZCONST char Far NoZipfileComment[] = " There is no zipfile comment.\n";
static ZCONST char Far ZipfileCommentDesc[] =
" The zipfile comment is %u bytes long and contains the following text:\n\n";
static ZCONST char Far ZipfileCommBegin[] =
"======================== zipfile comment begins ==========================\n";
static ZCONST char Far ZipfileCommEnd[] =
"========================= zipfile comment ends ===========================\n";
static ZCONST char Far ZipfileCommTrunc2[] =
"\n The zipfile comment is truncated.\n";
static ZCONST char Far ZipfileCommTruncMsg[] =
"\ncaution: zipfile comment truncated\n";
static ZCONST char Far CentralDirEntry[] =
"\nCentral directory entry #%lu:\n---------------------------\n\n";
static ZCONST char Far ZipfileStats[] =
"%lu file%s, %lu bytes uncompressed, %lu bytes compressed: %s%d.%d%%\n";
static ZCONST char Far OS_FAT[] = "MS-DOS, OS/2 or NT FAT";
static ZCONST char Far OS_Amiga[] = "Amiga";
static ZCONST char Far OS_VMS[] = "VMS";
static ZCONST char Far OS_Unix[] = "Unix";
static ZCONST char Far OS_VMCMS[] = "VM/CMS";
static ZCONST char Far OS_AtariST[] = "Atari ST";
static ZCONST char Far OS_HPFS[] = "OS/2 or NT HPFS";
static ZCONST char Far OS_Macintosh[] = "Macintosh HFS";
static ZCONST char Far OS_ZSystem[] = "Z-System";
static ZCONST char Far OS_CPM[] = "CP/M";
static ZCONST char Far OS_TOPS20[] = "TOPS-20";
static ZCONST char Far OS_NTFS[] = "NTFS";
static ZCONST char Far OS_QDOS[] = "SMS/QDOS";
static ZCONST char Far OS_Acorn[] = "Acorn RISC OS";
static ZCONST char Far OS_MVS[] = "MVS";
static ZCONST char Far OS_VFAT[] = "Win32 VFAT";
static ZCONST char Far OS_BeOS[] = "BeOS";
static ZCONST char Far OS_Tandem[] = "Tandem NSK";
static ZCONST char Far OS_Theos[] = "Theos";
#ifdef OLD_THEOS_EXTRA
static ZCONST char Far OS_TheosOld[] = "Theos (Old)";
#endif
static ZCONST char Far MthdNone[] = "none (stored)";
static ZCONST char Far MthdShrunk[] = "shrunk";
static ZCONST char Far MthdRedF1[] = "reduced (factor 1)";
static ZCONST char Far MthdRedF2[] = "reduced (factor 2)";
static ZCONST char Far MthdRedF3[] = "reduced (factor 3)";
static ZCONST char Far MthdRedF4[] = "reduced (factor 4)";
static ZCONST char Far MthdImplode[] = "imploded";
static ZCONST char Far MthdToken[] = "tokenized";
static ZCONST char Far MthdDeflate[] = "deflated";
static ZCONST char Far MthdDeflat64[] = "deflated (enhanced-64k)";
static ZCONST char Far MthdDCLImplode[] = "imploded (PK DCL)";
static ZCONST char Far DeflNorm[] = "normal";
static ZCONST char Far DeflMax[] = "maximum";
static ZCONST char Far DeflFast[] = "fast";
static ZCONST char Far DeflSFast[] = "superfast";
static ZCONST char Far ExtraBytesPreceding[] =
" There are an extra %ld bytes preceding this file.\n\n";
static ZCONST char Far UnknownNo[] = "unknown (%d)";
static ZCONST char Far LocalHeaderOffset[] =
"\n offset of local header from start of archive: %lu (%.8lXh) bytes\n";
static ZCONST char Far HostOS[] =
" file system or operating system of origin: %s\n";
static ZCONST char Far EncodeSWVer[] =
" version of encoding software: %u.%u\n";
static ZCONST char Far MinOSCompReq[] =
" minimum file system compatibility required: %s\n";
static ZCONST char Far MinSWVerReq[] =
" minimum software version required to extract: %u.%u\n";
static ZCONST char Far CompressMethod[] =
" compression method: %s\n";
static ZCONST char Far SlideWindowSizeImplode[] =
" size of sliding dictionary (implosion): %cK\n";
static ZCONST char Far ShannonFanoTrees[] =
" number of Shannon-Fano trees (implosion): %c\n";
static ZCONST char Far CompressSubtype[] =
" compression sub-type (deflation): %s\n";
static ZCONST char Far FileSecurity[] =
" file security status: %sencrypted\n";
static ZCONST char Far ExtendedLocalHdr[] =
" extended local header: %s\n";
static ZCONST char Far FileModDate[] =
" file last modified on (DOS date/time): %s\n";
#ifdef USE_EF_UT_TIME
static ZCONST char Far UT_FileModDate[] =
" file last modified on (UT extra field modtime): %s %s\n";
static ZCONST char Far LocalTime[] = "local";
#ifndef NO_GMTIME
static ZCONST char Far GMTime[] = "UTC";
#endif
#endif
static ZCONST char Far CRC32Value[] =
" 32-bit CRC value (hex): %.8lx\n";
static ZCONST char Far CompressedFileSize[] =
" compressed size: %lu bytes\n";
static ZCONST char Far UncompressedFileSize[] =
" uncompressed size: %lu bytes\n";
static ZCONST char Far FilenameLength[] =
" length of filename: %u characters\n";
static ZCONST char Far ExtraFieldLength[] =
" length of extra field: %u bytes\n";
static ZCONST char Far FileCommentLength[] =
" length of file comment: %u characters\n";
static ZCONST char Far FileDiskNum[] =
" disk number on which file begins: disk %u\n";
static ZCONST char Far ApparentFileType[] =
" apparent file type: %s\n";
static ZCONST char Far VMSFileAttributes[] =
" VMS file attributes (%06o octal): %s\n";
static ZCONST char Far AmigaFileAttributes[] =
" Amiga file attributes (%06o octal): %s\n";
static ZCONST char Far UnixFileAttributes[] =
" Unix file attributes (%06o octal): %s\n";
static ZCONST char Far NonMSDOSFileAttributes[] =
" non-MSDOS external file attributes: %06lX hex\n";
static ZCONST char Far MSDOSFileAttributes[] =
" MS-DOS file attributes (%02X hex): none\n";
static ZCONST char Far MSDOSFileAttributesRO[] =
" MS-DOS file attributes (%02X hex): read-only\n";
static ZCONST char Far MSDOSFileAttributesAlpha[] =
" MS-DOS file attributes (%02X hex): %s%s%s%s%s%s%s%s\n";
static ZCONST char Far TheosFileAttributes[] =
" Theos file attributes (%04X hex): %s\n";
static ZCONST char Far TheosFTypLib[] = "Library ";
static ZCONST char Far TheosFTypDir[] = "Directory ";
static ZCONST char Far TheosFTypReg[] = "Sequential ";
static ZCONST char Far TheosFTypRel[] = "Direct ";
static ZCONST char Far TheosFTypKey[] = "Keyed ";
static ZCONST char Far TheosFTypInd[] = "Indexed ";
static ZCONST char Far TheosFTypR16[] = " 86 program ";
static ZCONST char Far TheosFTypP16[] = "286 program ";
static ZCONST char Far TheosFTypP32[] = "386 program ";
static ZCONST char Far TheosFTypUkn[] = "??? ";
static ZCONST char Far ExtraFieldTrunc[] = "\n\
error: EF data block (type 0x%04x) size %u exceeds remaining extra field\n\
space %u; block length has been truncated.\n";
static ZCONST char Far ExtraFields[] = "\n\
The central-directory extra field contains:";
static ZCONST char Far ExtraFieldType[] = "\n\
- A subfield with ID 0x%04x (%s) and %u data bytes";
static ZCONST char Far efPKSZ64[] = "PKWARE 64-bit sizes";
static ZCONST char Far efAV[] = "PKWARE AV";
static ZCONST char Far efOS2[] = "OS/2";
static ZCONST char Far efPKVMS[] = "PKWARE VMS";
static ZCONST char Far efPKWin32[] = "PKWARE Win32";
static ZCONST char Far efPKUnix[] = "PKWARE Unix";
static ZCONST char Far efIZVMS[] = "Info-ZIP VMS";
static ZCONST char Far efIZUnix[] = "old Info-ZIP Unix/OS2/NT";
static ZCONST char Far efIZUnix2[] = "Unix UID/GID";
static ZCONST char Far efTime[] = "universal time";
static ZCONST char Far efJLMac[] = "old Info-ZIP Macintosh";
static ZCONST char Far efMac3[] = "new Info-ZIP Macintosh";
static ZCONST char Far efZipIt[] = "ZipIt Macintosh";
static ZCONST char Far efSmartZip[] = "SmartZip Macintosh";
static ZCONST char Far efZipIt2[] = "ZipIt Macintosh (short)";
static ZCONST char Far efVMCMS[] = "VM/CMS";
static ZCONST char Far efMVS[] = "MVS";
static ZCONST char Far efACL[] = "OS/2 ACL";
static ZCONST char Far efNTSD[] = "Security Descriptor";
static ZCONST char Far efBeOS[] = "BeOS";
static ZCONST char Far efQDOS[] = "SMS/QDOS";
static ZCONST char Far efAOSVS[] = "AOS/VS";
static ZCONST char Far efSpark[] = "Acorn SparkFS";
static ZCONST char Far efMD5[] = "Fred Kantor MD5";
static ZCONST char Far efASiUnix[] = "ASi Unix";
static ZCONST char Far efTandem[] = "Tandem NSK";
static ZCONST char Far efTheos[] = "Theos";
static ZCONST char Far efUnknown[] = "unknown";
static ZCONST char Far OS2EAs[] = ".\n\
The local extra field has %lu bytes of OS/2 extended attributes.\n\
(May not match OS/2 \"dir\" amount due to storage method)";
static ZCONST char Far izVMSdata[] = ". The extra\n\
field is %s and has %u bytes of VMS %s information%s";
static ZCONST char Far izVMSstored[] = "stored";
static ZCONST char Far izVMSrleenc[] = "run-length encoded";
static ZCONST char Far izVMSdeflat[] = "deflated";
static ZCONST char Far izVMScunknw[] = "compressed(?)";
static ZCONST char Far *izVMScomp[4] =
{izVMSstored, izVMSrleenc, izVMSdeflat, izVMScunknw};
static ZCONST char Far ACLdata[] = ".\n\
The local extra field has %lu bytes of access control list information";
static ZCONST char Far NTSDData[] = ".\n\
The local extra field has %lu bytes of NT security descriptor data";
static ZCONST char Far UTdata[] = ".\n\
The local extra field has UTC/GMT %s time%s";
static ZCONST char Far UTmodification[] = "modification";
static ZCONST char Far UTaccess[] = "access";
static ZCONST char Far UTcreation[] = "creation";
static ZCONST char Far ZipItFname[] = ".\n\
The Mac long filename is %s";
static ZCONST char Far Mac3data[] = ".\n\
The local extra field has %lu bytes of %scompressed Macintosh\n\
finder attributes";
static ZCONST char Far MacOSdata[] = ".\n\
The associated file has type code `%c%c%c%c' and creator code `%c%c%c%c'";
static ZCONST char Far MacOSdata1[] = ".\n\
The associated file has type code `0x%lx' and creator code `0x%lx'";
static ZCONST char Far MacOSJLEEflags[] = ".\n File is marked as %s";
static ZCONST char Far MacOS_RF[] = "Resource-fork";
static ZCONST char Far MacOS_DF[] = "Data-fork";
static ZCONST char Far MacOSMAC3flags[] = ".\n\
File is marked as %s, File Dates are in %d Bit";
static ZCONST char Far BeOSdata[] = ".\n\
The local extra field has %lu bytes of %scompressed BeOS file attributes";
static ZCONST char Far QDOSdata[] = ".\n\
The QDOS extra field subtype is `%c%c%c%c'";
static ZCONST char Far AOSVSdata[] = ".\n\
The AOS/VS extra field revision is %d.%d";
static ZCONST char Far TandemUnstr[] = "Unstructured";
static ZCONST char Far TandemRel[] = "Relative";
static ZCONST char Far TandemEntry[] = "Entry Sequenced";
static ZCONST char Far TandemKey[] = "Key Sequenced";
static ZCONST char Far TandemEdit[] = "Edit";
static ZCONST char Far TandemObj[] = "Object";
static ZCONST char Far *TandemFileformat[6] =
{TandemUnstr, TandemRel, TandemEntry, TandemKey, TandemEdit, TandemObj};
static ZCONST char Far Tandemdata[] = ".\n\
The file was originally a Tandem %s file, with file code %u";
static ZCONST char Far MD5data[] = ".\n\
The 128-bit MD5 signature is %s";
#ifdef CMS_MVS
static ZCONST char Far VmMvsExtraField[] = ".\n\
The stored file open mode (FLDATA TYPE) is \"%s\"";
static ZCONST char Far VmMvsInvalid[] = "[invalid]";
#endif
static ZCONST char Far First20[] = ". The first\n 20 are: ";
static ZCONST char Far ColonIndent[] = ":\n ";
static ZCONST char Far efFormat[] = " %02x";
static ZCONST char Far lExtraFieldType[] = "\n\
There %s a local extra field with ID 0x%04x (%s) and\n\
%u data bytes (%s).\n";
static ZCONST char Far efIZuid[] =
"GMT modification/access times and Unix UID/GID";
static ZCONST char Far efIZnouid[] = "GMT modification/access times only";
static ZCONST char Far NoFileComment[] = "\n There is no file comment.\n";
static ZCONST char Far FileCommBegin[] = "\n\
------------------------- file comment begins ----------------------------\n";
static ZCONST char Far FileCommEnd[] = "\
-------------------------- file comment ends -----------------------------\n";
static ZCONST char Far BogusFmt[] = "%03d";
static ZCONST char Far DMYHMTime[] = "%2u-%s-%02u %02u:%02u";
static ZCONST char Far YMDHMSTime[] = "%u %s %u %02u:%02u:%02u";
static ZCONST char Far DecimalTime[] = "%04u%02u%02u.%02u%02u%02u";
#ifdef USE_EF_UT_TIME
static ZCONST char Far YMDHMSTimeError[] = "???? ??? ?? ??:??:??";
#endif
#ifndef WINDLL
int zi_opts(__G__ pargc, pargv)
int *pargc;
char ***pargv;
__GDEF
{
char **argv, *s;
int argc, c, error=FALSE, negative=0;
int hflag_slmv=TRUE, hflag_2=FALSE;
int tflag_slm=TRUE, tflag_2v=FALSE;
int explicit_h=FALSE, explicit_t=FALSE;
#ifdef MACOS
uO.lflag = LFLAG;
#endif
G.extract_flag = FALSE;
argc = *pargc;
argv = *pargv;
while (--argc > 0 && (*++argv)[0] == '-') {
s = argv[0] + 1;
while ((c = *s++) != 0) {
switch (c) {
case '-':
++negative;
break;
case '1':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 1;
break;
case '2':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 2;
break;
#ifndef CMS_MVS
case ('C'):
if (negative)
uO.C_flag = FALSE, negative = 0;
else
uO.C_flag = TRUE;
break;
#endif
case 'h':
if (negative)
hflag_2 = hflag_slmv = FALSE, negative = 0;
else {
hflag_2 = hflag_slmv = explicit_h = TRUE;
if (uO.lflag == -1)
uO.lflag = 0;
}
break;
case 'l':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 5;
break;
case 'm':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 4;
break;
#ifdef MORE
case 'M':
if (negative)
G.M_flag = FALSE, negative = 0;
else
G.M_flag = TRUE;
break;
#endif
case 's':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 3;
break;
case 't':
if (negative)
tflag_2v = tflag_slm = FALSE, negative = 0;
else {
tflag_2v = tflag_slm = explicit_t = TRUE;
if (uO.lflag == -1)
uO.lflag = 0;
}
break;
case ('T'):
if (negative)
uO.T_flag = FALSE, negative = 0;
else
uO.T_flag = TRUE;
break;
case 'v':
if (negative)
uO.lflag = -2, negative = 0;
else
uO.lflag = 10;
break;
case 'z':
if (negative)
uO.zflag = negative = 0;
else
uO.zflag = 1;
break;
case 'Z':
break;
default:
error = TRUE;
break;
}
}
}
if ((argc-- == 0) || error) {
*pargc = argc;
*pargv = argv;
return USAGE(error);
}
#ifdef MORE
if (G.M_flag && !isatty(1))
G.M_flag = 0;
#endif
if ((uO.lflag < 0) || ((argc > 0) && (uO.lflag == 0)))
uO.lflag = LFLAG;
switch (uO.lflag) {
case 0:
case 2:
uO.hflag = hflag_2;
uO.tflag = tflag_2v;
break;
case 1:
uO.hflag = FALSE;
uO.tflag = FALSE;
uO.zflag = FALSE;
break;
case 3:
case 4:
case 5:
uO.hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
uO.tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
break;
case 10:
uO.hflag = hflag_slmv;
uO.tflag = tflag_2v;
break;
}
*pargc = argc;
*pargv = argv;
return 0;
}
#endif
int zi_end_central(__G)
__GDEF
{
int error = PK_COOL;
if (uO.hflag)
Info(slide, 0, ((char *)slide, ((int)strlen(G.zipfn) < 39)?
LoadFarString(LongHeader) : LoadFarString(ShortHeader), G.zipfn,
(long)G.ziplen, G.ecrec.total_entries_central_dir,
(G.ecrec.total_entries_central_dir==1)?
nullStr : PlurSufx));
if (uO.lflag > 9) {
Info(slide, 0, ((char *)slide, LoadFarString(EndCentDirRec)));
Info(slide, 0, ((char *)slide, LoadFarString(LineSeparators)));
Info(slide, 0, ((char *)slide, LoadFarString(ActOffsetCentDir),
(long)G.real_ecrec_offset, (long)G.real_ecrec_offset,
(long)G.expect_ecrec_offset, (long)G.expect_ecrec_offset));
if (G.ecrec.number_this_disk == 0) {
Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive1),
G.ecrec.total_entries_central_dir,
(G.ecrec.total_entries_central_dir == 1)? "entry" : "entries",
G.ecrec.size_central_directory,
G.ecrec.size_central_directory));
Info(slide, 0, ((char *)slide, LoadFarString(SinglePartArchive2),
G.ecrec.offset_start_central_directory,
G.ecrec.offset_start_central_directory));
} else {
Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive1),
G.ecrec.number_this_disk + 1,
G.ecrec.num_disk_start_cdir + 1,
G.ecrec.num_entries_centrl_dir_ths_disk,
(G.ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are"));
Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive2),
G.ecrec.total_entries_central_dir,
(G.ecrec.total_entries_central_dir == 1) ? "entry" : "entries",
G.ecrec.size_central_directory,
G.ecrec.size_central_directory));
Info(slide, 0, ((char *)slide, LoadFarString(MultiPartArchive3),
G.ecrec.offset_start_central_directory,
G.ecrec.offset_start_central_directory));
}
if (!G.ecrec.zipfile_comment_length)
Info(slide, 0, ((char *)slide, LoadFarString(NoZipfileComment)));
else {
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommentDesc),
G.ecrec.zipfile_comment_length));
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommBegin)));
if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY))
error = PK_WARN;
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileCommEnd)));
if (error)
Info(slide, 0, ((char *)slide,
LoadFarString(ZipfileCommTrunc2)));
}
} else if (uO.zflag && G.ecrec.zipfile_comment_length) {
if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY)) {
Info(slide, 0x401, ((char *)slide,
LoadFarString(ZipfileCommTruncMsg)));
error = PK_WARN;
}
}
return error;
}
int zipinfo(__G)
__GDEF
{
int do_this_file=FALSE, error, error_in_archive=PK_COOL;
int *fn_matched=NULL, *xn_matched=NULL;
ulg j, members=0L;
ulg tot_csize=0L, tot_ucsize=0L;
ulg endprev;
if (G.filespecs > 0 &&
(fn_matched=(int *)malloc(G.filespecs*sizeof(int))) != NULL)
for (j = 0; j < G.filespecs; ++j)
fn_matched[j] = FALSE;
if (G.xfilespecs > 0 &&
(xn_matched=(int *)malloc(G.xfilespecs*sizeof(int))) != NULL)
for (j = 0; j < G.xfilespecs; ++j)
xn_matched[j] = FALSE;
uO.L_flag = FALSE;
G.pInfo = G.info;
G.pInfo->textmode = 0;
endprev = (G.crec.relative_offset_local_header == 4L)? 4L : 0L;
for (j = 1L;; j++) {
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, central_hdr_sig, 4)) {
if (((unsigned)(j - 1) & (unsigned)0xFFFF) ==
(unsigned)G.ecrec.total_entries_central_dir) {
break;
} else {
Info(slide, 0x401,
((char *)slide, LoadFarString(CentSigMsg), j));
Info(slide, 0x401,
((char *)slide, LoadFarString(ReportMsg)));
return PK_BADERR;
}
}
if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
return error;
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
PK_COOL)
{
error_in_archive = error;
if (error > PK_WARN)
return error;
}
if (!G.process_all_files) {
unsigned i;
do_this_file = FALSE;
for (i = 0; i < G.filespecs; i++)
if (match(G.filename, G.pfnames[i], uO.C_flag)) {
do_this_file = TRUE;
if (fn_matched)
fn_matched[i] = TRUE;
break;
}
if (do_this_file) {
for (i = 0; i < G.xfilespecs; i++)
if (match(G.filename, G.pxnames[i], uO.C_flag)) {
do_this_file = FALSE;
if (xn_matched)
xn_matched[i] = TRUE;
break;
}
}
}
if (G.process_all_files || do_this_file) {
switch (uO.lflag) {
case 1:
case 2:
fnprint(__G);
SKIP_(G.crec.extra_field_length)
SKIP_(G.crec.file_comment_length)
break;
case 3:
case 4:
case 5:
if ((error = zi_short(__G)) != PK_COOL) {
error_in_archive = error;
if (error > PK_WARN)
return error;
}
break;
case 10:
Info(slide, 0, ((char *)slide,
LoadFarString(CentralDirEntry), j));
if ((error = zi_long(__G__ &endprev)) != PK_COOL) {
error_in_archive = error;
if (error > PK_WARN)
return error;
}
break;
default:
SKIP_(G.crec.extra_field_length)
SKIP_(G.crec.file_comment_length)
break;
}
tot_csize += G.crec.csize;
tot_ucsize += G.crec.ucsize;
if (G.crec.general_purpose_bit_flag & 1)
tot_csize -= 12;
++members;
#ifdef DLL
if ((G.statreportcb != NULL) &&
(*G.statreportcb)(__G__ UZ_ST_FINISH_MEMBER, G.zipfn,
G.filename, (zvoid *)&G.crec.ucsize)) {
if (fn_matched)
free((zvoid *)fn_matched);
if (xn_matched)
free((zvoid *)xn_matched);
return IZ_CTRLC;
}
#endif
#ifdef MACOS
UserStop();
#endif
} else {
SKIP_(G.crec.extra_field_length)
SKIP_(G.crec.file_comment_length)
}
}
if (uO.tflag) {
char *sgn = "";
int cfactor = ratio(tot_ucsize, tot_csize);
if (cfactor < 0) {
sgn = "-";
cfactor = -cfactor;
}
Info(slide, 0, ((char *)slide, LoadFarString(ZipfileStats),
members, (members==1L)? nullStr:PlurSufx, tot_ucsize,
tot_csize, sgn, cfactor/10, cfactor%10));
}
if (fn_matched) {
for (j = 0; j < G.filespecs; ++j)
if (!fn_matched[j])
Info(slide, 0x401, ((char *)slide,
LoadFarString(FilenameNotMatched), G.pfnames[j]));
free((zvoid *)fn_matched);
}
if (xn_matched) {
for (j = 0; j < G.xfilespecs; ++j)
if (!xn_matched[j])
Info(slide, 0x401, ((char *)slide,
LoadFarString(ExclFilenameNotMatched), G.pxnames[j]));
free((zvoid *)xn_matched);
}
if (strncmp(G.sig, end_central_sig, 4)) {
Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
error_in_archive = PK_WARN;
}
if (members == 0 && error_in_archive <= PK_WARN)
error_in_archive = PK_FIND;
if (uO.lflag >= 10)
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
return error_in_archive;
}
static int zi_long(__G__ pEndprev)
__GDEF
ulg *pEndprev;
{
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
int error, error_in_archive=PK_COOL;
unsigned hostnum, hostver, extnum, extver, methnum, xattr;
char workspace[12], attribs[22];
ZCONST char *varmsg_str;
char unkn[16];
static ZCONST char Far *os[NUM_HOSTS] = {
OS_FAT, OS_Amiga, OS_VMS, OS_Unix, OS_VMCMS, OS_AtariST, OS_HPFS,
OS_Macintosh, OS_ZSystem, OS_CPM, OS_TOPS20, OS_NTFS, OS_QDOS,
OS_Acorn, OS_VFAT, OS_MVS, OS_BeOS, OS_Tandem, OS_Theos
};
static ZCONST char Far *method[NUM_METHODS] = {
MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
MthdImplode, MthdToken, MthdDeflate, MthdDeflat64, MthdDCLImplode
};
static ZCONST char Far *dtypelng[4] = {
DeflNorm, DeflMax, DeflFast, DeflSFast
};
if (G.crec.relative_offset_local_header != *pEndprev && *pEndprev > 0L) {
Info(slide, 0, ((char *)slide, LoadFarString(ExtraBytesPreceding),
(long)G.crec.relative_offset_local_header - (long)(*pEndprev)));
}
*pEndprev = G.crec.relative_offset_local_header + (4L + LREC_SIZE) +
G.crec.filename_length + G.crec.extra_field_length + G.crec.csize;
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
{
if (G.extra_field != NULL) {
free(G.extra_field);
G.extra_field = NULL;
}
error_in_archive = error;
}
hostnum = (unsigned)(G.pInfo->hostnum);
hostver = (unsigned)(G.pInfo->hostver);
extnum = (unsigned)MIN(G.crec.version_needed_to_extract[1], NUM_HOSTS);
extver = (unsigned)G.crec.version_needed_to_extract[0];
methnum = (unsigned)MIN(G.crec.compression_method, NUM_METHODS);
(*G.message)((zvoid *)&G, (uch *)" ", 2L, 0); fnprint(__G);
Info(slide, 0, ((char *)slide, LoadFarString(LocalHeaderOffset),
G.crec.relative_offset_local_header,
G.crec.relative_offset_local_header));
if (hostnum >= NUM_HOSTS) {
sprintf(unkn, LoadFarString(UnknownNo),
(int)G.crec.version_made_by[1]);
varmsg_str = unkn;
} else {
varmsg_str = LoadFarStringSmall(os[hostnum]);
#ifdef OLD_THEOS_EXTRA
if (hostnum == FS_VFAT_ && hostver == 20) {
varmsg_str = LoadFarStringSmall(OS_TheosOld);
}
#endif
}
Info(slide, 0, ((char *)slide, LoadFarString(HostOS), varmsg_str));
Info(slide, 0, ((char *)slide, LoadFarString(EncodeSWVer), hostver/10,
hostver%10));
if (extnum >= NUM_HOSTS) {
sprintf(unkn, LoadFarString(UnknownNo),
(int)G.crec.version_needed_to_extract[1]);
varmsg_str = unkn;
} else {
varmsg_str = LoadFarStringSmall(os[extnum]);
}
Info(slide, 0, ((char *)slide, LoadFarString(MinOSCompReq), varmsg_str));
Info(slide, 0, ((char *)slide, LoadFarString(MinSWVerReq), extver/10,
extver%10));
if (methnum >= NUM_METHODS) {
sprintf(unkn, LoadFarString(UnknownNo), G.crec.compression_method);
varmsg_str = unkn;
} else {
varmsg_str = LoadFarStringSmall(method[methnum]);
}
Info(slide, 0, ((char *)slide, LoadFarString(CompressMethod), varmsg_str));
if (methnum == IMPLODED) {
Info(slide, 0, ((char *)slide, LoadFarString(SlideWindowSizeImplode),
(G.crec.general_purpose_bit_flag & 2)? '8' : '4'));
Info(slide, 0, ((char *)slide, LoadFarString(ShannonFanoTrees),
(G.crec.general_purpose_bit_flag & 4)? '3' : '2'));
} else if (methnum == DEFLATED || methnum == ENHDEFLATED) {
ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
Info(slide, 0, ((char *)slide, LoadFarString(CompressSubtype),
LoadFarStringSmall(dtypelng[dnum])));
}
Info(slide, 0, ((char *)slide, LoadFarString(FileSecurity),
(G.crec.general_purpose_bit_flag & 1) ? nullStr : "not "));
Info(slide, 0, ((char *)slide, LoadFarString(ExtendedLocalHdr),
(G.crec.general_purpose_bit_flag & 8) ? "yes" : "no"));
# define d_t_buf attribs
zi_time(__G__ &G.crec.last_mod_dos_datetime, NULL, d_t_buf);
Info(slide, 0, ((char *)slide, LoadFarString(FileModDate), d_t_buf));
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
#ifdef IZ_CHECK_TZ
G.tz_is_valid &&
#endif
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
G.crec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME))
{
TIMET_TO_NATIVE(z_utime.mtime)
d_t_buf[0] = (char)0;
zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
d_t_buf, LoadFarStringSmall(LocalTime)));
#ifndef NO_GMTIME
d_t_buf[0] = (char)1;
zi_time(__G__ &G.crec.last_mod_dos_datetime, &(z_utime.mtime), d_t_buf);
Info(slide, 0, ((char *)slide, LoadFarString(UT_FileModDate),
d_t_buf, LoadFarStringSmall(GMTime)));
#endif
}
#endif
Info(slide, 0, ((char *)slide, LoadFarString(CRC32Value), G.crec.crc32));
Info(slide, 0, ((char *)slide, LoadFarString(CompressedFileSize),
G.crec.csize));
Info(slide, 0, ((char *)slide, LoadFarString(UncompressedFileSize),
G.crec.ucsize));
Info(slide, 0, ((char *)slide, LoadFarString(FilenameLength),
G.crec.filename_length));
Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldLength),
G.crec.extra_field_length));
Info(slide, 0, ((char *)slide, LoadFarString(FileCommentLength),
G.crec.file_comment_length));
Info(slide, 0, ((char *)slide, LoadFarString(FileDiskNum),
G.crec.disk_number_start + 1));
Info(slide, 0, ((char *)slide, LoadFarString(ApparentFileType),
(G.crec.internal_file_attributes & 1)? "text"
: (G.crec.internal_file_attributes & 2)? "ebcdic"
: "binary"));
#ifdef ATARI
printf(" external file attributes (hex): %.8lx\n",
G.crec.external_file_attributes);
#endif
xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
if (hostnum == VMS_) {
char *p=attribs, *q=attribs+1;
int i, j, k;
for (k = 0; k < 12; ++k)
workspace[k] = 0;
if (xattr & VMS_IRUSR)
workspace[0] = 'R';
if (xattr & VMS_IWUSR) {
workspace[1] = 'W';
workspace[3] = 'D';
}
if (xattr & VMS_IXUSR)
workspace[2] = 'E';
if (xattr & VMS_IRGRP)
workspace[4] = 'R';
if (xattr & VMS_IWGRP) {
workspace[5] = 'W';
workspace[7] = 'D';
}
if (xattr & VMS_IXGRP)
workspace[6] = 'E';
if (xattr & VMS_IROTH)
workspace[8] = 'R';
if (xattr & VMS_IWOTH) {
workspace[9] = 'W';
workspace[11] = 'D';
}
if (xattr & VMS_IXOTH)
workspace[10] = 'E';
*p++ = '(';
for (k = j = 0; j < 3; ++j) {
for (i = 0; i < 4; ++i, ++k)
if (workspace[k])
*p++ = workspace[k];
*p++ = ',';
if (j == 0)
while ((*p++ = *q++) != ',')
;
}
*p-- = '\0';
*p = ')';
Info(slide, 0, ((char *)slide, LoadFarString(VMSFileAttributes), xattr,
attribs));
} else if (hostnum == AMIGA_) {
switch (xattr & AMI_IFMT) {
case AMI_IFDIR: attribs[0] = 'd'; break;
case AMI_IFREG: attribs[0] = '-'; break;
default: attribs[0] = '?'; break;
}
attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
attribs[9] = 0;
Info(slide, 0, ((char *)slide, LoadFarString(AmigaFileAttributes),
xattr, attribs));
} else if (hostnum == THEOS_) {
ZCONST char Far *fpFtyp;
switch (xattr & THS_IFMT) {
case THS_IFLIB: fpFtyp = TheosFTypLib; break;
case THS_IFDIR: fpFtyp = TheosFTypDir; break;
case THS_IFREG: fpFtyp = TheosFTypReg; break;
case THS_IFREL: fpFtyp = TheosFTypRel; break;
case THS_IFKEY: fpFtyp = TheosFTypKey; break;
case THS_IFIND: fpFtyp = TheosFTypInd; break;
case THS_IFR16: fpFtyp = TheosFTypR16; break;
case THS_IFP16: fpFtyp = TheosFTypP16; break;
case THS_IFP32: fpFtyp = TheosFTypP32; break;
default: fpFtyp = TheosFTypUkn; break;
}
strcpy(attribs, LoadFarStringSmall(fpFtyp));
attribs[12] = (xattr & THS_INHID) ? '.' : 'H';
attribs[13] = (xattr & THS_IMODF) ? '.' : 'M';
attribs[14] = (xattr & THS_IWOTH) ? '.' : 'W';
attribs[15] = (xattr & THS_IROTH) ? '.' : 'R';
attribs[16] = (xattr & THS_IEUSR) ? '.' : 'E';
attribs[17] = (xattr & THS_IXUSR) ? '.' : 'X';
attribs[18] = (xattr & THS_IWUSR) ? '.' : 'W';
attribs[19] = (xattr & THS_IRUSR) ? '.' : 'R';
attribs[20] = 0;
Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
xattr, attribs));
#ifdef OLD_THEOS_EXTRA
} else if (hostnum == FS_VFAT_ && hostver == 20) {
ZCONST char Far *fpFtyp;
switch (xattr & _THS_IFMT) {
case _THS_IFLIB: fpFtyp = TheosFTypLib; break;
case _THS_IFDIR: fpFtyp = TheosFTypDir; break;
case _THS_IFREG: fpFtyp = TheosFTypReg; break;
case _THS_IODRC: fpFtyp = TheosFTypRel; break;
case _THS_IOKEY: fpFtyp = TheosFTypKey; break;
case _THS_IOIND: fpFtyp = TheosFTypInd; break;
case _THS_IOPRG: fpFtyp = TheosFTypR16; break;
case _THS_IO286: fpFtyp = TheosFTypP16; break;
case _THS_IO386: fpFtyp = TheosFTypP32; break;
default: fpFtyp = TheosFTypUkn; break;
}
strcpy(attribs, LoadFarStringSmall(fpFtyp));
attribs[12] = (xattr & _THS_HIDDN) ? 'H' : '.';
attribs[13] = (xattr & _THS_IXOTH) ? '.' : 'X';
attribs[14] = (xattr & _THS_IWOTH) ? '.' : 'W';
attribs[15] = (xattr & _THS_IROTH) ? '.' : 'R';
attribs[16] = (xattr & _THS_IEUSR) ? '.' : 'E';
attribs[17] = (xattr & _THS_IXUSR) ? '.' : 'X';
attribs[18] = (xattr & _THS_IWUSR) ? '.' : 'W';
attribs[19] = (xattr & _THS_IRUSR) ? '.' : 'R';
attribs[20] = 0;
Info(slide, 0, ((char *)slide, LoadFarString(TheosFileAttributes),
xattr, attribs));
#endif
} else if ((hostnum != FS_FAT_) && (hostnum != FS_HPFS_) &&
(hostnum != FS_NTFS_) && (hostnum != FS_VFAT_) &&
(hostnum != ACORN_) &&
(hostnum != VM_CMS_) && (hostnum != MVS_))
{
switch ((unsigned)(xattr & UNX_IFMT)) {
case (unsigned)UNX_IFDIR: attribs[0] = 'd'; break;
case (unsigned)UNX_IFREG: attribs[0] = '-'; break;
case (unsigned)UNX_IFLNK: attribs[0] = 'l'; break;
case (unsigned)UNX_IFBLK: attribs[0] = 'b'; break;
case (unsigned)UNX_IFCHR: attribs[0] = 'c'; break;
case (unsigned)UNX_IFIFO: attribs[0] = 'p'; break;
case (unsigned)UNX_IFSOCK: attribs[0] = 's'; break;
default: attribs[0] = '?'; break;
}
attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
if (xattr & UNX_IXUSR)
attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
else
attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';
if (xattr & UNX_IXGRP)
attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';
else
attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
if (xattr & UNX_IXOTH)
attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';
else
attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';
attribs[10] = 0;
Info(slide, 0, ((char *)slide, LoadFarString(UnixFileAttributes), xattr,
attribs));
} else {
Info(slide, 0, ((char *)slide, LoadFarString(NonMSDOSFileAttributes),
G.crec.external_file_attributes >> 8));
}
if ((xattr=(unsigned)(G.crec.external_file_attributes & 0xFF)) == 0)
Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributes),
xattr));
else if (xattr == 1)
Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesRO),
xattr));
else
Info(slide, 0, ((char *)slide, LoadFarString(MSDOSFileAttributesAlpha),
xattr, (xattr&1)? "rdo " : nullStr,
(xattr&2)? "hid " : nullStr,
(xattr&4)? "sys " : nullStr,
(xattr&8)? "lab " : nullStr,
(xattr&16)? "dir " : nullStr,
(xattr&32)? "arc " : nullStr,
(xattr&64)? "lnk " : nullStr,
(xattr&128)? "exe" : nullStr));
if (G.crec.extra_field_length > 0) {
uch *ef_ptr = G.extra_field;
ush ef_len = G.crec.extra_field_length;
ush eb_id, eb_datalen;
ZCONST char Far *ef_fieldname;
if (error_in_archive > PK_WARN)
return error;
if (G.extra_field == (uch *)NULL)
return PK_ERR;
Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields)));
while (ef_len >= EB_HEADSIZE) {
eb_id = makeword(&ef_ptr[EB_ID]);
eb_datalen = makeword(&ef_ptr[EB_LEN]);
ef_ptr += EB_HEADSIZE;
ef_len -= EB_HEADSIZE;
if (eb_datalen > (ush)ef_len) {
Info(slide, 0x421, ((char *)slide,
LoadFarString(ExtraFieldTrunc), eb_id, eb_datalen, ef_len));
eb_datalen = ef_len;
}
switch (eb_id) {
case EF_PKSZ64:
ef_fieldname = efPKSZ64;
break;
case EF_AV:
ef_fieldname = efAV;
break;
case EF_OS2:
ef_fieldname = efOS2;
break;
case EF_ACL:
ef_fieldname = efACL;
break;
case EF_NTSD:
ef_fieldname = efNTSD;
break;
case EF_PKVMS:
ef_fieldname = efPKVMS;
break;
case EF_IZVMS:
ef_fieldname = efIZVMS;
break;
case EF_PKW32:
ef_fieldname = efPKWin32;
break;
case EF_PKUNIX:
ef_fieldname = efPKUnix;
break;
case EF_IZUNIX:
ef_fieldname = efIZUnix;
if (hostnum == UNIX_ && *pEndprev > 0L)
*pEndprev += 4L;
break;
case EF_IZUNIX2:
ef_fieldname = efIZUnix2;
if (*pEndprev > 0L)
*pEndprev += 4L;
break;
case EF_TIME:
ef_fieldname = efTime;
break;
case EF_MAC3:
ef_fieldname = efMac3;
break;
case EF_JLMAC:
ef_fieldname = efJLMac;
break;
case EF_ZIPIT:
ef_fieldname = efZipIt;
break;
case EF_ZIPIT2:
ef_fieldname = efZipIt2;
break;
case EF_VMCMS:
ef_fieldname = efVMCMS;
break;
case EF_MVS:
ef_fieldname = efMVS;
break;
case EF_BEOS:
ef_fieldname = efBeOS;
break;
case EF_QDOS:
ef_fieldname = efQDOS;
break;
case EF_AOSVS:
ef_fieldname = efAOSVS;
break;
case EF_SPARK:
ef_fieldname = efSpark;
break;
case EF_MD5:
ef_fieldname = efMD5;
break;
case EF_ASIUNIX:
ef_fieldname = efASiUnix;
break;
case EF_TANDEM:
ef_fieldname = efTandem;
break;
case EF_SMARTZIP:
ef_fieldname = efSmartZip;
break;
case EF_THEOS:
#ifdef OLD_THEOS_EXTRA
case EF_THEOSO:
#endif
ef_fieldname = efTheos;
break;
default:
ef_fieldname = efUnknown;
break;
}
Info(slide, 0, ((char *)slide, LoadFarString(ExtraFieldType),
eb_id, LoadFarStringSmall(ef_fieldname), eb_datalen));
switch (eb_id) {
case EF_OS2:
case EF_ACL:
if (eb_datalen >= EB_OS2_HLEN) {
if (eb_id == EF_OS2)
ef_fieldname = OS2EAs;
else
ef_fieldname = ACLdata;
Info(slide, 0, ((char *)slide,
LoadFarString(ef_fieldname), makelong(ef_ptr)));
*pEndprev = 0L;
}
break;
case EF_NTSD:
if (eb_datalen >= EB_NTSD_C_LEN) {
Info(slide, 0, ((char *)slide, LoadFarString(NTSDData),
makelong(ef_ptr)));
*pEndprev = 0L;
}
break;
case EF_IZVMS:
if (eb_datalen >= 8) {
char *p, q[8];
unsigned compr = makeword(ef_ptr+EB_IZVMS_FLGS)
& EB_IZVMS_BCMASK;
*q = '\0';
if (compr > 3)
compr = 3;
if (strncmp((char *)ef_ptr, "VFAB", 4) == 0)
p = "FAB";
else if (strncmp((char *)ef_ptr, "VALL", 4) == 0)
p = "XABALL";
else if (strncmp((char *)ef_ptr, "VFHC", 4) == 0)
p = "XABFHC";
else if (strncmp((char *)ef_ptr, "VDAT", 4) == 0)
p = "XABDAT";
else if (strncmp((char *)ef_ptr, "VRDT", 4) == 0)
p = "XABRDT";
else if (strncmp((char *)ef_ptr, "VPRO", 4) == 0)
p = "XABPRO";
else if (strncmp((char *)ef_ptr, "VKEY", 4) == 0)
p = "XABKEY";
else if (strncmp((char *)ef_ptr, "VMSV", 4) == 0) {
p = "version";
if (eb_datalen >= 16) {
q[0] = ' ';
q[1] = '(';
strncpy(q+2, (char *)ef_ptr+EB_IZVMS_HLEN, 4);
q[6] = ')';
q[7] = '\0';
}
} else
p = "unknown";
Info(slide, 0, ((char *)slide,
LoadFarString(izVMSdata),
LoadFarStringSmall(izVMScomp[compr]),
makeword(ef_ptr+EB_IZVMS_UCSIZ), p, q));
}
break;
case EF_TIME:
if (eb_datalen >= 1) {
char types[80];
int num = 0, len;
*types = '\0';
if (*ef_ptr & 1) {
strcpy(types, LoadFarString(UTmodification));
++num;
}
if (*ef_ptr & 2) {
len = strlen(types);
if (num)
types[len++] = '/';
strcpy(types+len, LoadFarString(UTaccess));
++num;
if (*pEndprev > 0L)
*pEndprev += 4L;
}
if (*ef_ptr & 4) {
len = strlen(types);
if (num)
types[len++] = '/';
strcpy(types+len, LoadFarString(UTcreation));
++num;
if (*pEndprev > 0L)
*pEndprev += 4L;
}
if (num > 0)
Info(slide, 0, ((char *)slide,
LoadFarString(UTdata), types,
num == 1? nullStr : PlurSufx));
}
break;
case EF_MAC3:
if (eb_datalen >= EB_MAC3_HLEN) {
ulg eb_uc = makelong(ef_ptr);
unsigned mac3_flgs = makeword(ef_ptr+EB_FLGS_OFFS);
unsigned eb_is_uc = mac3_flgs & EB_M3_FL_UNCMPR;
Info(slide, 0, ((char *)slide, LoadFarString(Mac3data),
eb_uc, eb_is_uc ? "un" : nullStr));
if (eb_is_uc) {
if (*pEndprev > 0L)
*pEndprev += makelong(ef_ptr);
} else {
*pEndprev = 0L;
}
Info(slide, 0, ((char *)slide,
LoadFarString(MacOSMAC3flags),
LoadFarStringSmall(mac3_flgs & EB_M3_FL_DATFRK ?
MacOS_DF : MacOS_RF),
(mac3_flgs & EB_M3_FL_TIME64 ? 64 : 32)));
zi_showMacTypeCreator(__G__ &ef_ptr[6]);
}
break;
case EF_ZIPIT2:
if (eb_datalen >= 5 &&
strncmp((char *)ef_ptr, "ZPIT", 4) == 0) {
if (eb_datalen >= 12) {
zi_showMacTypeCreator(__G__ &ef_ptr[4]);
}
}
break;
case EF_ZIPIT:
if (eb_datalen >= 5 &&
strncmp((char *)ef_ptr, "ZPIT", 4) == 0) {
unsigned fnlen = ef_ptr[4];
if ((unsigned)eb_datalen >= fnlen + (5 + 8)) {
uch nullchar = ef_ptr[fnlen+5];
ef_ptr[fnlen+5] = '\0';
Info(slide, 0, ((char *)slide,
LoadFarString(ZipItFname), (char *)ef_ptr+5));
ef_ptr[fnlen+5] = nullchar;
zi_showMacTypeCreator(__G__ &ef_ptr[fnlen+5]);
}
}
break;
case EF_JLMAC:
if (eb_datalen >= 40 &&
strncmp((char *)ef_ptr, "JLEE", 4) == 0)
{
zi_showMacTypeCreator(__G__ &ef_ptr[4]);
Info(slide, 0, ((char *)slide,
LoadFarString(MacOSJLEEflags),
LoadFarStringSmall(ef_ptr[31] & 1 ?
MacOS_DF : MacOS_RF)));
}
break;
case EF_SMARTZIP:
if ((eb_datalen == EB_SMARTZIP_HLEN) &&
strncmp((char *)ef_ptr, "dZip", 4) == 0) {
char filenameBuf[32];
zi_showMacTypeCreator(__G__ &ef_ptr[4]);
memcpy(filenameBuf, &ef_ptr[33], 31);
filenameBuf[ef_ptr[32]] = '\0';
Info(slide, 0, ((char *)slide,
LoadFarString(ZipItFname), filenameBuf));
}
break;
#ifdef CMS_MVS
case EF_VMCMS:
case EF_MVS:
{
char type[100];
Info(slide, 0, ((char *)slide,
LoadFarString(VmMvsExtraField),
(getVMMVSexfield(type, ef_ptr-EB_HEADSIZE,
(unsigned)eb_datalen) > 0)?
type : LoadFarStringSmall(VmMvsInvalid)));
}
break;
#endif
case EF_BEOS:
if (eb_datalen >= EB_BEOS_HLEN) {
ulg eb_uc = makelong(ef_ptr);
unsigned eb_is_uc =
*(ef_ptr+EB_FLGS_OFFS) & EB_BE_FL_UNCMPR;
Info(slide, 0, ((char *)slide, LoadFarString(BeOSdata),
eb_uc, eb_is_uc ? "un" : nullStr));
if (eb_is_uc) {
if (*pEndprev > 0L)
*pEndprev += makelong(ef_ptr);
} else {
*pEndprev = 0L;
}
}
break;
case EF_QDOS:
if (eb_datalen >= 4) {
Info(slide, 0, ((char *)slide, LoadFarString(QDOSdata),
ef_ptr[0], ef_ptr[1], ef_ptr[2], ef_ptr[3]));
}
break;
case EF_AOSVS:
if (eb_datalen >= 5) {
Info(slide, 0, ((char *)slide, LoadFarString(AOSVSdata),
((int)(uch)ef_ptr[4])/10, ((int)(uch)ef_ptr[4])%10));
}
break;
case EF_TANDEM:
if (eb_datalen == 20) {
unsigned type, code;
type = (ef_ptr[18] & 0x60) >> 5;
code = makeword(ef_ptr);
code = ((code << 8) & 0xff00) | ((code >> 8) & 0x00ff);
if (type == NSK_UNSTRUCTURED) {
if (code == NSK_EDITFILECODE)
type = 4;
else if (code == NSK_OBJECTFILECODE)
type = 5;
}
Info(slide, 0, ((char *)slide,
LoadFarString(Tandemdata),
LoadFarStringSmall(TandemFileformat[type]),
code));
}
break;
case EF_MD5:
if (eb_datalen >= 19) {
char md5[33];
int i;
for (i = 0; i < 16; ++i)
sprintf(&md5[i<<1], "%02x", ef_ptr[15-i]);
md5[32] = '\0';
Info(slide, 0, ((char *)slide, LoadFarString(MD5data),
md5));
break;
}
default:
if (eb_datalen > 0) {
ush i, n;
if (eb_datalen <= 24) {
Info(slide, 0, ((char *)slide,
LoadFarString(ColonIndent)));
n = eb_datalen;
} else {
Info(slide, 0, ((char *)slide,
LoadFarString(First20)));
n = 20;
}
for (i = 0; i < n; ++i)
Info(slide, 0, ((char *)slide,
LoadFarString(efFormat), ef_ptr[i]));
}
break;
}
(*G.message)((zvoid *)&G, (uch *)".", 1L, 0);
ef_ptr += eb_datalen;
ef_len -= eb_datalen;
}
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
}
if ((xattr = (unsigned)((G.crec.external_file_attributes & 0xC000) >> 12))
& 8)
{
if (hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)
{
Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
"is", EF_IZUNIX, LoadFarStringSmall(efIZUnix),
(unsigned)(xattr&12), (xattr&4)? efIZuid : efIZnouid));
if (*pEndprev > 0L)
*pEndprev += (ulg)(xattr&12);
}
else if (hostnum == FS_FAT_ && !(xattr&4))
Info(slide, 0, ((char *)slide, LoadFarString(lExtraFieldType),
"may be", EF_IZUNIX, LoadFarStringSmall(efIZUnix), 8,
efIZnouid));
}
if (!G.crec.file_comment_length)
Info(slide, 0, ((char *)slide, LoadFarString(NoFileComment)));
else {
Info(slide, 0, ((char *)slide, LoadFarString(FileCommBegin)));
if ((error = do_string(__G__ G.crec.file_comment_length, DISPL_8)) !=
PK_COOL)
{
error_in_archive = error;
if (error > PK_WARN)
return error;
}
Info(slide, 0, ((char *)slide, LoadFarString(FileCommEnd)));
}
return error_in_archive;
}
static int zi_short(__G)
__GDEF
{
#ifdef USE_EF_UT_TIME
iztimes z_utime;
time_t *z_modtim;
#endif
int k, error, error_in_archive=PK_COOL;
unsigned hostnum, hostver, methnum, xattr;
char *p, workspace[12], attribs[16];
char methbuf[5];
static ZCONST char dtype[5]="NXFS";
static ZCONST char Far os[NUM_HOSTS+1][4] = {
"fat", "ami", "vms", "unx", "cms", "atr", "hpf", "mac", "zzz",
"cpm", "t20", "ntf", "qds", "aco", "vft", "mvs", "be ", "nsk",
"ths", "???"
};
#ifdef OLD_THEOS_EXTRA
static ZCONST char Far os_TheosOld[] = "tho";
#endif
static ZCONST char Far method[NUM_METHODS+1][5] = {
"stor", "shrk", "re:1", "re:2", "re:3", "re:4", "i#:#", "tokn",
"def#", "d64#", "dcli", "u###"
};
methnum = (unsigned)MIN(G.crec.compression_method, NUM_METHODS);
hostnum = (unsigned)(G.pInfo->hostnum);
hostver = (unsigned)(G.pInfo->hostver);
zfstrcpy(methbuf, method[methnum]);
if (methnum == IMPLODED) {
methbuf[1] = (char)((G.crec.general_purpose_bit_flag & 2)? '8' : '4');
methbuf[3] = (char)((G.crec.general_purpose_bit_flag & 4)? '3' : '2');
} else if (methnum == DEFLATED || methnum == ENHDEFLATED) {
ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
methbuf[3] = dtype[dnum];
} else if (methnum >= NUM_METHODS) {
sprintf(&methbuf[1], "%03u", G.crec.compression_method);
}
for (k = 0; k < 15; ++k)
attribs[k] = ' ';
attribs[15] = 0;
xattr = (unsigned)((G.crec.external_file_attributes >> 16) & 0xFFFF);
switch (hostnum) {
case VMS_:
{ int i, j;
for (k = 0; k < 12; ++k)
workspace[k] = 0;
if (xattr & VMS_IRUSR)
workspace[0] = 'R';
if (xattr & VMS_IWUSR) {
workspace[1] = 'W';
workspace[3] = 'D';
}
if (xattr & VMS_IXUSR)
workspace[2] = 'E';
if (xattr & VMS_IRGRP)
workspace[4] = 'R';
if (xattr & VMS_IWGRP) {
workspace[5] = 'W';
workspace[7] = 'D';
}
if (xattr & VMS_IXGRP)
workspace[6] = 'E';
if (xattr & VMS_IROTH)
workspace[8] = 'R';
if (xattr & VMS_IWOTH) {
workspace[9] = 'W';
workspace[11] = 'D';
}
if (xattr & VMS_IXOTH)
workspace[10] = 'E';
p = attribs;
for (k = j = 0; j < 3; ++j) {
for (i = 0; i < 4; ++i, ++k)
if (workspace[k])
*p++ = workspace[k];
*p++ = ',';
}
*--p = ' ';
if ((p - attribs) < 12)
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
}
break;
case AMIGA_:
switch (xattr & AMI_IFMT) {
case AMI_IFDIR: attribs[0] = 'd'; break;
case AMI_IFREG: attribs[0] = '-'; break;
default: attribs[0] = '?'; break;
}
attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
break;
case THEOS_:
switch (xattr & THS_IFMT) {
case THS_IFLIB: *attribs = 'L'; break;
case THS_IFDIR: *attribs = 'D'; break;
case THS_IFCHR: *attribs = 'C'; break;
case THS_IFREG: *attribs = 'S'; break;
case THS_IFREL: *attribs = 'R'; break;
case THS_IFKEY: *attribs = 'K'; break;
case THS_IFIND: *attribs = 'I'; break;
case THS_IFR16: *attribs = 'P'; break;
case THS_IFP16: *attribs = '2'; break;
case THS_IFP32: *attribs = '3'; break;
default: *attribs = '?'; break;
}
attribs[1] = (xattr & THS_INHID) ? '.' : 'H';
attribs[2] = (xattr & THS_IMODF) ? '.' : 'M';
attribs[3] = (xattr & THS_IWOTH) ? '.' : 'W';
attribs[4] = (xattr & THS_IROTH) ? '.' : 'R';
attribs[5] = (xattr & THS_IEUSR) ? '.' : 'E';
attribs[6] = (xattr & THS_IXUSR) ? '.' : 'X';
attribs[7] = (xattr & THS_IWUSR) ? '.' : 'W';
attribs[8] = (xattr & THS_IRUSR) ? '.' : 'R';
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
break;
case FS_VFAT_:
#ifdef OLD_THEOS_EXTRA
if (hostver == 20) {
switch (xattr & _THS_IFMT) {
case _THS_IFLIB: *attribs = 'L'; break;
case _THS_IFDIR: *attribs = 'd'; break;
case _THS_IFCHR: *attribs = 'c'; break;
case _THS_IFREG: *attribs = 'S'; break;
case _THS_IODRC: *attribs = 'D'; break;
case _THS_IOKEY: *attribs = 'K'; break;
case _THS_IOIND: *attribs = 'I'; break;
case _THS_IOPRG: *attribs = 'P'; break;
case _THS_IO286: *attribs = '2'; break;
case _THS_IO386: *attribs = '3'; break;
default: *attribs = '?'; break;
}
attribs[1] = (xattr & _THS_HIDDN) ? 'H' : '.';
attribs[2] = (xattr & _THS_IXOTH) ? '.' : 'X';
attribs[3] = (xattr & _THS_IWOTH) ? '.' : 'W';
attribs[4] = (xattr & _THS_IROTH) ? '.' : 'R';
attribs[5] = (xattr & _THS_IEUSR) ? '.' : 'E';
attribs[6] = (xattr & _THS_IXUSR) ? '.' : 'X';
attribs[7] = (xattr & _THS_IWUSR) ? '.' : 'W';
attribs[8] = (xattr & _THS_IRUSR) ? '.' : 'R';
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
break;
}
#endif
case FS_FAT_:
case FS_HPFS_:
case FS_NTFS_:
case VM_CMS_:
case MVS_:
case ACORN_:
if (hostnum != FS_FAT_ ||
(unsigned)(xattr & 0700) !=
((unsigned)0400 |
((unsigned)!(G.crec.external_file_attributes & 1) << 7) |
((unsigned)(G.crec.external_file_attributes & 0x10) << 2))
)
{
xattr = (unsigned)(G.crec.external_file_attributes & 0xFF);
sprintf(attribs, ".r.-... %u.%u", hostver/10, hostver%10);
attribs[2] = (xattr & 0x01)? '-' : 'w';
attribs[5] = (xattr & 0x02)? 'h' : '-';
attribs[6] = (xattr & 0x04)? 's' : '-';
attribs[4] = (xattr & 0x20)? 'a' : '-';
if (xattr & 0x10) {
attribs[0] = 'd';
attribs[3] = 'x';
} else
attribs[0] = '-';
if (IS_VOLID(xattr))
attribs[0] = 'V';
else if ((p = MBSRCHR(G.filename, '.')) != (char *)NULL) {
++p;
if (STRNICMP(p, "com", 3) == 0 ||
STRNICMP(p, "exe", 3) == 0 ||
STRNICMP(p, "btm", 3) == 0 ||
STRNICMP(p, "cmd", 3) == 0 ||
STRNICMP(p, "bat", 3) == 0)
attribs[3] = 'x';
}
break;
}
default:
switch ((unsigned)(xattr & UNX_IFMT)) {
case (unsigned)UNX_IFDIR: attribs[0] = 'd'; break;
case (unsigned)UNX_IFREG: attribs[0] = '-'; break;
case (unsigned)UNX_IFLNK: attribs[0] = 'l'; break;
case (unsigned)UNX_IFBLK: attribs[0] = 'b'; break;
case (unsigned)UNX_IFCHR: attribs[0] = 'c'; break;
case (unsigned)UNX_IFIFO: attribs[0] = 'p'; break;
case (unsigned)UNX_IFSOCK: attribs[0] = 's'; break;
default: attribs[0] = '?'; break;
}
attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
if (xattr & UNX_IXUSR)
attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
else
attribs[3] = (xattr & UNX_ISUID)? 'S' : '-';
if (xattr & UNX_IXGRP)
attribs[6] = (xattr & UNX_ISGID)? 's' : 'x';
else
attribs[6] = (xattr & UNX_ISGID)? 'S' : '-';
if (xattr & UNX_IXOTH)
attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x';
else
attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-';
sprintf(&attribs[12], "%u.%u", hostver/10, hostver%10);
break;
}
#ifdef OLD_THEOS_EXTRA
Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
LoadFarStringSmall(((hostnum == FS_VFAT_ && hostver == 20) ?
os_TheosOld :
os[hostnum])),
G.crec.ucsize));
#else
Info(slide, 0, ((char *)slide, "%s %s %8lu ", attribs,
LoadFarStringSmall(os[hostnum]),
G.crec.ucsize));
#endif
Info(slide, 0, ((char *)slide, "%c",
(G.crec.general_purpose_bit_flag & 1)?
((G.crec.internal_file_attributes & 1)? 'T' : 'B') :
((G.crec.internal_file_attributes & 1)? 't' : 'b')));
k = (G.crec.extra_field_length ||
((G.crec.external_file_attributes & 0x8000) &&
(hostnum == UNIX_ || hostnum == FS_HPFS_ || hostnum == FS_NTFS_)));
Info(slide, 0, ((char *)slide, "%c", k?
((G.crec.general_purpose_bit_flag & 8)? 'X' : 'x') :
((G.crec.general_purpose_bit_flag & 8)? 'l' : '-')));
if (uO.lflag == 4) {
ulg csiz = G.crec.csize;
if (G.crec.general_purpose_bit_flag & 1)
csiz -= 12;
Info(slide, 0, ((char *)slide, "%3d%%",
(ratio(G.crec.ucsize,csiz)+5)/10));
} else if (uO.lflag == 5)
Info(slide, 0, ((char *)slide, " %8lu", G.crec.csize));
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD)) != 0)
{
if (G.extra_field != NULL) {
free(G.extra_field);
G.extra_field = NULL;
}
error_in_archive = error;
}
# define d_t_buf attribs
#ifdef USE_EF_UT_TIME
z_modtim = G.extra_field &&
#ifdef IZ_CHECK_TZ
G.tz_is_valid &&
#endif
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
G.crec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME)
? &z_utime.mtime : NULL;
TIMET_TO_NATIVE(z_utime.mtime)
d_t_buf[0] = (char)0;
#else
# define z_modtim NULL
#endif
Info(slide, 0, ((char *)slide, " %s %s ", methbuf,
zi_time(__G__ &G.crec.last_mod_dos_datetime, z_modtim, d_t_buf)));
fnprint(__G);
SKIP_(G.crec.file_comment_length)
return error_in_archive;
}
static void zi_showMacTypeCreator(__G__ ebfield)
__GDEF
uch *ebfield;
{
if (isprint(ebfield[0]) && isprint(ebfield[1]) &&
isprint(ebfield[2]) && isprint(ebfield[3]) &&
isprint(ebfield[4]) && isprint(ebfield[5]) &&
isprint(ebfield[6]) && isprint(ebfield[7])) {
Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata),
ebfield[0], ebfield[1], ebfield[2], ebfield[3],
ebfield[4], ebfield[5], ebfield[6], ebfield[7]));
} else {
Info(slide, 0, ((char *)slide, LoadFarString(MacOSdata1),
(((ulg)ebfield[0]) << 24) +
(((ulg)ebfield[1]) << 16) +
(((ulg)ebfield[2]) << 8) +
((ulg)ebfield[3]),
(((ulg)ebfield[4]) << 24) +
(((ulg)ebfield[5]) << 16) +
(((ulg)ebfield[6]) << 8) +
((ulg)ebfield[7])));
}
}
static char *zi_time(__G__ datetimez, modtimez, d_t_str)
__GDEF
ZCONST ulg *datetimez;
ZCONST time_t *modtimez;
char *d_t_str;
{
unsigned yr, mo, dy, hh, mm, ss;
char monthbuf[4];
ZCONST char *monthstr;
static ZCONST char Far month[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
#ifdef USE_EF_UT_TIME
struct tm *t;
#endif
#ifdef USE_EF_UT_TIME
if (modtimez != NULL) {
#ifndef NO_GMTIME
t = (d_t_str[0] == (char)1)? gmtime(modtimez) : localtime(modtimez);
#else
t = localtime(modtimez);
#endif
if (uO.lflag > 9 && t == (struct tm *)NULL)
return (strcpy(d_t_str, LoadFarString(YMDHMSTimeError)));
} else
t = (struct tm *)NULL;
if (t != (struct tm *)NULL) {
mo = (unsigned)(t->tm_mon + 1);
dy = (unsigned)(t->tm_mday);
yr = (unsigned)(t->tm_year);
hh = (unsigned)(t->tm_hour);
mm = (unsigned)(t->tm_min);
ss = (unsigned)(t->tm_sec);
} else
#endif
{
yr = ((unsigned)(*datetimez >> 25) & 0x7f) + 80;
mo = ((unsigned)(*datetimez >> 21) & 0x0f);
dy = ((unsigned)(*datetimez >> 16) & 0x1f);
hh = (((unsigned)*datetimez >> 11) & 0x1f);
mm = (((unsigned)*datetimez >> 5) & 0x3f);
ss = (((unsigned)*datetimez << 1) & 0x3e);
}
if (mo == 0 || mo > 12) {
sprintf(monthbuf, LoadFarString(BogusFmt), mo);
monthstr = monthbuf;
} else
monthstr = LoadFarStringSmall(month[mo-1]);
if (uO.lflag > 9)
sprintf(d_t_str, LoadFarString(YMDHMSTime), yr+1900, monthstr, dy, hh,
mm, ss);
else if (uO.T_flag)
sprintf(d_t_str, LoadFarString(DecimalTime), yr+1900, mo, dy, hh, mm,
ss);
else
sprintf(d_t_str, LoadFarString(DMYHMTime), dy, monthstr, yr%100, hh,
mm);
return d_t_str;
}
#endif