home *** CD-ROM | disk | FTP | other *** search
- From: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Newsgroups: comp.sources.misc
- Subject: v44i069: unzip - Info-ZIP portable UnZip, version 5.12, Part04/20
- Date: 18 Sep 1994 23:14:35 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <35j37b$qmc@sparky.sterling.com>
- X-Md4-Signature: 33ef05d4562f4c968484d7930bebbc87
-
- Submitted-by: zip-bugs@wkuvx1.wku.edu (Info-ZIP group)
- Posting-number: Volume 44, Issue 69
- Archive-name: unzip/part04
- Environment: UNIX, VMS, OS/2, MS-DOS, MACINTOSH, WIN-NT, LINUX, MINIX, COHERENT, AMIGA?, ATARI TOS, SGI, DEC, Cray, Convex, Amdahl, Sun
- Supersedes: unzip50: Volume 31, Issue 104-117
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: unzip-5.12/amiga/makefile.azt unzip-5.12/zipinfo.c
- # Wrapped by kent@sparky on Sat Sep 17 23:33:37 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 4 (of 20)."'
- if test -f 'unzip-5.12/amiga/makefile.azt' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/amiga/makefile.azt'\"
- else
- echo shar: Extracting \"'unzip-5.12/amiga/makefile.azt'\" \(2163 characters\)
- sed "s/^X//" >'unzip-5.12/amiga/makefile.azt' <<'END_OF_FILE'
- X# Makefile for UnZip 5.11+ using Manx Aztec C 5.2 10 July 1994
- X#
- X# You may need to change directory names for stat.c, filedate.c and amiga.c.
- X
- X
- XCC = cc
- XCFLAGS = -d AMIGA -ps -sabfmnpu -wcpr0u
- X# -ps means short ints, -s... is optimizations, -w... is type checking
- XLD = ln
- XLDFLAGS = +q -m
- XLDLIBS = -lc16
- X
- XOBJS = unzip.o crypt.o envargs.o explode.o unshrink.o \
- X extract.o zipinfo.o file_io.o inflate.o match.o unreduce.o \
- X amiga/amiga.o amiga/crc_68.o amiga/flate.o
- XXOBJS = unzip.xo crypt.o extract.xo file_io.o inflate.o amiga/flate.o \
- X match.o amiga/amiga.xo
- XFOBJS = funzip.o crypt.fo inflate.fo amiga/flate.fo
- X
- X
- X.c.o :
- X $(CC) -o $@ $(CFLAGS) $*.c
- X
- X.c.xo:
- X $(CC) -o $@ -d SFX $(CFLAGS) $*.c
- X
- X.c.fo:
- X $(CC) -o $@ -d FUNZIP $(CFLAGS) $*.c
- X
- XUnZip : $(OBJS)
- X $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
- X
- XUnZipSFX : $(FOBJS)
- X $(LD) $(LDFLAGS) -o $@ $(FOBJS) $(LDLIBS)
- X
- XfUnZip : $(FOBJS)
- X $(LD) $(LDFLAGS) -o $@ $(XOBJS) $(LDLIBS)
- X
- Xf : fUnZip
- X
- Xall : UnZip UnZipSFX fUnZip
- X
- Xclean :
- X delete #?.(o|xo|fo) quiet
- X
- X
- X$(OBJS) $(XOBJS) $(FOBJS) : unzip.h amiga/amiga.h amiga/z-stat.h
- X
- Xcrypt.o crypt.fo : zip.h
- X
- Xinflate.o inflate.fo : inflate.h
- X
- Xfile_io.o funzip.o : tables.h
- X
- Xcrypt.o crypt.fo unzip.o unzip.xo funzip.o file_io.o : crypt.h
- Xextract.o extract.xo inflate.o inflate.fo : crypt.h
- X
- Xunzip.o unzip.xo : version.h
- X
- Xfile_io.o : file_io.c
- X $(CC) -o file_io.o $(CFLAGS) -d ASM_CRC file_io.c
- X
- Xinflate.o : inflate.c
- X $(CC) -o inflate.o $(CFLAGS) -d ASM_INFLATECODES inflate.c
- X
- Xinflate.fo : inflate.c
- X $(CC) -o inflate.fo $(CFLAGS) -d FUNZIP -d ASM_INFLATECODES inflate.c
- X
- Xamiga/amiga.o : amiga/filedate.c amiga/stat.c amiga/amiga.c
- X $(CC) -o amiga/amiga.o -d __VERSION__=5 -d __REVISION__=2 \
- X $(CFLAGS) amiga/amiga.c
- X
- Xamiga/amiga.xo : amiga/filedate.c amiga/stat.c amiga/amiga.c
- X $(CC) -o amiga/amiga.xo -d __VERSION__=5 -d __REVISION__=2 -d SFX \
- X $(CFLAGS) amiga/amiga.c
- X
- Xamiga/crc_68.o : amiga/crc_68.a
- X as -n -o amiga/crc_68.o -eREGARGS amiga/crc_68.a
- X
- Xamiga/flate.o : amiga/flate.a
- X as -n -o amiga/flate.o amiga/flate.a
- X
- Xamiga/flate.fo : amiga/flate.a
- X as -n -o amiga/flate.fo -eCRYPT -eFUNZIP amiga/flate.a
- END_OF_FILE
- if test 2163 -ne `wc -c <'unzip-5.12/amiga/makefile.azt'`; then
- echo shar: \"'unzip-5.12/amiga/makefile.azt'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/amiga/makefile.azt'
- fi
- if test -f 'unzip-5.12/zipinfo.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'unzip-5.12/zipinfo.c'\"
- else
- echo shar: Extracting \"'unzip-5.12/zipinfo.c'\" \(64797 characters\)
- sed "s/^X//" >'unzip-5.12/zipinfo.c' <<'END_OF_FILE'
- X/*---------------------------------------------------------------------------
- X
- X zipinfo.c
- X
- X This file contains all of the zipfile-listing routines for UnZip, inclu-
- X ding the bulk of what used to be the separate program ZipInfo. All of
- X the ZipInfo routines are by Greg Roelofs; list_files is by the usual mish-
- X mash of Info-ZIP contributors (see the listing in CONTRIBS).
- X
- X Contains: zi_opts()
- X zi_end_central()
- X zipinfo()
- X zi_long()
- X zi_short()
- X zi_time()
- X list_files()
- X ratio()
- X fnprint()
- X
- X ---------------------------------------------------------------------------*/
- X
- X
- X#include "unzip.h"
- X
- Xstatic char unkn[16];
- X
- Xstatic int ratio OF((ulg uc, ulg c));
- Xstatic void fnprint OF((void));
- X
- X
- X/********************************************/
- X/* Strings used in zipinfo.c (UnZip half) */
- X/********************************************/
- X
- X/* also referenced in UpdateListBox() in updatelb.c (Windows version) */
- Xchar Far HeadersS[] = " Length Date Time Name";
- Xchar Far HeadersS1[] = " ------ ---- ---- ----";
- Xchar Far HeadersL[] = " Length Method Size Ratio Date Time CRC-32 Name";
- Xchar Far HeadersL1[] = " ------ ------ ---- ----- ---- ---- ------ ----";
- Xchar Far *Headers[][2] = { {HeadersS, HeadersS1}, {HeadersL, HeadersL1} };
- X
- Xstatic char Far CaseConversion[] = "%s (\"^\" ==> case\n%s conversion)\n";
- Xstatic char Far CompFactorStr[] = "%c%d%%";
- Xstatic char Far CompMethodUnknown[] = "Unk:%03d";
- X#ifdef MSWIN
- X static char Far LongHdrStats[] =
- X "%7lu %-7s%7lu %4s %02u-%02u-%02u %02u:%02u %08lx %c%s";
- X static char Far LongFileHeader[] =
- X "%7lu %7lu %4s %-7u";
- X static char Far ShortHdrStats[] = "%7lu %02u-%02u-%02u %02u:%02u %c%s";
- X static char Far ShortFileHeader[] = "%7lu %-7u";
- X#else /* !MSWIN */
- X static char Far LongHdrStats[] =
- X "%7lu %-7s%7lu %4s %02u-%02u-%02u %02u:%02u %08lx %c";
- X static char Far ShortHdrStats[] = "%7lu %02u-%02u-%02u %02u:%02u %c";
- X static char Far LongFileHeader[] =
- X " ------ ------ --- \
- X -------\n%7lu %7lu %4s %-7u\n";
- X static char Far ShortFileHeader[] =
- X " ------ -------\n%7lu %-7u\n";
- X#endif /* ?MSWIN */
- X
- X
- X
- X#ifndef NO_ZIPINFO /* strings use up too much space in small-memory systems */
- X
- X/* Define OS-specific attributes for use on ALL platforms--the S_xxxx
- X * versions of these are defined differently (or not defined) by different
- X * compilers and operating systems. */
- X
- X#define UNX_IFMT 0170000 /* Unix file type mask */
- X#define UNX_IFDIR 0040000 /* Unix directory */
- X#define UNX_IFREG 0100000 /* Unix regular file */
- X#define UNX_IFSOCK 0140000 /* Unix socket (BSD, not SysV or Amiga) */
- X#define UNX_IFLNK 0120000 /* Unix symbolic link (not SysV, Amiga) */
- X#define UNX_IFBLK 0060000 /* Unix block special (not Amiga) */
- X#define UNX_IFCHR 0020000 /* Unix character special (not Amiga) */
- X#define UNX_IFIFO 0010000 /* Unix fifo (BCC, not MSC or Amiga) */
- X#define UNX_ISUID 04000 /* Unix set user id on execution */
- X#define UNX_ISGID 02000 /* Unix set group id on execution */
- X#define UNX_ISVTX 01000 /* Unix directory permissions control */
- X#define UNX_ENFMT UNX_ISGID /* Unix record locking enforcement flag */
- X#define UNX_IRWXU 00700 /* Unix read, write, execute: owner */
- X#define UNX_IRUSR 00400 /* Unix read permission: owner */
- X#define UNX_IWUSR 00200 /* Unix write permission: owner */
- X#define UNX_IXUSR 00100 /* Unix execute permission: owner */
- X#define UNX_IRWXG 00070 /* Unix read, write, execute: group */
- X#define UNX_IRGRP 00040 /* Unix read permission: group */
- X#define UNX_IWGRP 00020 /* Unix write permission: group */
- X#define UNX_IXGRP 00010 /* Unix execute permission: group */
- X#define UNX_IRWXO 00007 /* Unix read, write, execute: other */
- X#define UNX_IROTH 00004 /* Unix read permission: other */
- X#define UNX_IWOTH 00002 /* Unix write permission: other */
- X#define UNX_IXOTH 00001 /* Unix execute permission: other */
- X
- X#define VMS_IRUSR UNX_IRUSR /* VMS read/owner */
- X#define VMS_IWUSR UNX_IWUSR /* VMS write/owner */
- X#define VMS_IXUSR UNX_IXUSR /* VMS execute/owner */
- X#define VMS_IRGRP UNX_IRGRP /* VMS read/group */
- X#define VMS_IWGRP UNX_IWGRP /* VMS write/group */
- X#define VMS_IXGRP UNX_IXGRP /* VMS execute/group */
- X#define VMS_IROTH UNX_IROTH /* VMS read/other */
- X#define VMS_IWOTH UNX_IWOTH /* VMS write/other */
- X#define VMS_IXOTH UNX_IXOTH /* VMS execute/other */
- X
- X#define AMI_IFMT 06000 /* Amiga file type mask */
- X#define AMI_IFDIR 04000 /* Amiga directory */
- X#define AMI_IFREG 02000 /* Amiga regular file */
- X#define AMI_IHIDDEN 00200 /* to be supported in AmigaDOS 3.x */
- X#define AMI_ISCRIPT 00100 /* executable script (text command file) */
- X#define AMI_IPURE 00040 /* allow loading into resident memory */
- X#define AMI_IARCHIVE 00020 /* not modified since bit was last set */
- X#define AMI_IREAD 00010 /* can be opened for reading */
- X#define AMI_IWRITE 00004 /* can be opened for writing */
- X#define AMI_IEXECUTE 00002 /* executable image, a loadable runfile */
- X#define AMI_IDELETE 00001 /* can be deleted */
- X
- X/* extra-field ID values: */
- X#define EF_AV 0x0007 /* PKWARE authenticity verification */
- X#define EF_OS2 0x0009 /* OS/2 extended attributes */
- X#define EF_PKVMS 0x000c /* PKWARE's VMS ID */
- X#define EF_IZVMS 0x4d49 /* Info-ZIP's VMS ID ("IM") */
- X#define EF_ASIUNIX 0x756e /* ASi/PKWARE's Unix ID ("IM") */
- X#define EF_SPARK 0x4341 /* David Pilling's Acorn/SparkFS ID ("AC") */
- X
- X#define LFLAG 3 /* short "ls -l" type listing */
- X
- Xstatic int zi_long OF((void));
- Xstatic int zi_short OF((void));
- Xstatic char *zi_time OF((ush *datez, ush *timez));
- X
- X
- X/**********************************************/
- X/* Strings used in zipinfo.c (ZipInfo half) */
- X/**********************************************/
- X
- Xstatic char Far LongHeader[] = "Archive: %s %ld bytes %d file%s\n";
- Xstatic char Far ShortHeader[] = "Archive: %s %ld %d\n";
- Xstatic char Far EndCentDirRec[] = "\nEnd-of-central-directory record:\n";
- Xstatic char Far LineSeparators[] = "-------------------------------\n\n";
- Xstatic char Far ActOffsetCentDir[] = "\
- X Actual offset of end-of-central-dir record: %9ld (%.8lXh)\n\
- X Expected offset of end-of-central-dir record: %9ld (%.8lXh)\n\
- X (based on the length of the central directory and its expected offset)\n\n";
- Xstatic char Far SinglePartArchive[] = "\
- X This zipfile constitutes the sole disk of a single-part archive; its\n\
- X central directory contains %u %s. The central directory is %lu\n\
- X (%.8lXh) bytes long, and its (expected) offset in bytes from the\n\
- X beginning of the zipfile is %lu (%.8lXh).\n\n";
- Xstatic char Far MultiPartArchive[] = "\
- X This zipfile constitutes disk %u of a multi-part archive. The central\n\
- X directory starts on disk %u; %u of its entries %s contained within\n\
- X this zipfile, out of a total of %u %s. The entire central\n\
- X directory is %lu (%.8lXh) bytes long, and its offset in bytes from\n\
- X the beginning of the zipfile in which it begins is %lu (%.8lXh).\n\n";
- Xstatic char Far NoZipfileComment[] = " There is no zipfile comment.\n";
- Xstatic char Far ZipfileCommentDesc[] =
- X " The zipfile comment is %u bytes long and contains the following text:\n\n";
- Xstatic char Far ZipfileCommBegin[] =
- X "======================== zipfile comment begins ==========================\n";
- Xstatic char Far ZipfileCommEnd[] =
- X "========================= zipfile comment ends ===========================\n";
- Xstatic char Far ZipfileCommTrunc2[] = "\n The zipfile comment is truncated.\n";
- Xstatic char Far ZipfileCommTruncMsg[] =
- X "\ncaution: zipfile comment truncated\n";
- X
- X#ifdef T20_VMS
- X static char Far CentralDirEntry[] = "\nCentral directory entry #%d:\n";
- X#else
- X static char Far CentralDirEntry[] = "%s\nCentral directory entry #%d:\n";
- X#endif
- X
- Xstatic char Far CentralDirLines[] = "---------------------------\n\n";
- Xstatic char Far ZipfileStats[] =
- X "%d file%s, %lu bytes uncompressed, %lu bytes compressed: %s%d.%d%%\n";
- X
- X/* zi_long() strings */
- Xstatic char Far OS_FAT[] = "MS-DOS, OS/2 or NT FAT";
- Xstatic char Far OS_Amiga[] = "Amiga";
- Xstatic char Far OS_VAXVMS[] = "VAX VMS";
- Xstatic char Far OS_Unix[] = "Unix";
- Xstatic char Far OS_VMCMS[] = "VM/CMS";
- Xstatic char Far OS_AtariST[] = "Atari ST";
- Xstatic char Far OS_HPFS[] = "OS/2 or NT HPFS";
- Xstatic char Far OS_Macintosh[] = "Macintosh";
- Xstatic char Far OS_ZSystem[] = "Z-System";
- Xstatic char Far OS_CPM[] = "CP/M";
- Xstatic char Far OS_TOPS20[] = "TOPS-20";
- Xstatic char Far OS_NTFS[] = "NT NTFS";
- Xstatic char Far OS_QDOS[] = "QDOS (maybe)";
- Xstatic char Far OS_Acorn[] = "Acorn RISCOS";
- X
- Xstatic char Far MthdNone[] = "none (stored)";
- Xstatic char Far MthdShrunk[] = "shrunk";
- Xstatic char Far MthdRedF1[] = "reduced (factor 1)";
- Xstatic char Far MthdRedF2[] = "reduced (factor 2)";
- Xstatic char Far MthdRedF3[] = "reduced (factor 3)";
- Xstatic char Far MthdRedF4[] = "reduced (factor 4)";
- Xstatic char Far MthdImplode[] = "imploded";
- Xstatic char Far MthdToken[] = "tokenized";
- Xstatic char Far MthdDeflate[] = "deflated";
- X
- Xstatic char Far ExtraBytesPreceding[] =
- X " There are an extra %ld bytes preceding this file.\n\n";
- X
- Xstatic char Far Unknown[] = "unknown (%d)";
- X
- Xstatic char Far HostOS[] =
- X "\n host operating system (created on): %s\n";
- Xstatic char Far EncodeSWVer[] =
- X " version of encoding software: %d.%d\n";
- Xstatic char Far MinOSCompReq[] =
- X " minimum operating system compatibility required: %s\n";
- Xstatic char Far MinSWVerReq[] =
- X " minimum software version required to extract: %d.%d\n";
- Xstatic char Far CompressMethod[] =
- X " compression method: %s\n";
- Xstatic char Far SlideWindowSizeImplode[] =
- X " size of sliding dictionary (implosion): %cK\n";
- Xstatic char Far ShannonFanoTrees[] =
- X " number of Shannon-Fano trees (implosion): %c\n";
- Xstatic char Far CompressSubtype[] =
- X " compression sub-type (deflation): %s\n";
- Xstatic char Far FileSecurity[] =
- X " file security status: %sencrypted\n";
- Xstatic char Far ExtendedLocalHdr[] =
- X " extended local header: %s\n";
- Xstatic char Far FileModDate[] =
- X " file last modified on: %s\n";
- Xstatic char Far CRC32Value[] =
- X " 32-bit CRC value (hex): %.8lx\n";
- Xstatic char Far CompressedFileSize[] =
- X " compressed size: %lu bytes\n";
- Xstatic char Far UncompressedFileSize[] =
- X " uncompressed size: %lu bytes\n";
- Xstatic char Far FilenameLength[] =
- X " length of filename: %u characters\n";
- Xstatic char Far ExtraFieldLength[] =
- X " length of extra field: %u bytes\n";
- Xstatic char Far FileCommentLength[] =
- X " length of file comment: %u characters\n";
- Xstatic char Far FileDiskNum[] =
- X " disk number on which file begins: disk %u\n";
- Xstatic char Far ApparentFileType[] =
- X " apparent file type: %s\n";
- Xstatic char Far VMSFileAttributes[] =
- X " VMS file attributes (%06o octal): %s\n";
- Xstatic char Far AmigaFileAttributes[] =
- X " Amiga file attributes (%06o octal): %s\n";
- Xstatic char Far UnixFileAttributes[] =
- X " Unix file attributes (%06o octal): %s\n";
- Xstatic char Far NonMSDOSFileAttributes[] =
- X " non-MSDOS external file attributes: %06lX hex\n";
- Xstatic char Far MSDOSFileAttributes[] =
- X " MS-DOS file attributes (%02X hex): none\n";
- Xstatic char Far MSDOSFileAttributesRO[] =
- X " MS-DOS file attributes (%02X hex): read-only\n";
- Xstatic char Far MSDOSFileAttributesAlpha[] =
- X " MS-DOS file attributes (%02X hex): %s%s%s%s%s%s\n";
- Xstatic char Far LocalHeaderOffset[] =
- X " offset of local header from start of archive: %lu (%.8lXh) bytes\n";
- Xstatic char Far ExtraFieldType[] = "\n\
- X The central-directory extra field has ID 0x%04x (%s) and has %u\n\
- X data bytes";
- Xstatic char Far OS2EAs[] = "\
- X. The local extra field has %lu bytes of OS/2 extended\n\
- X attributes (may not match OS/2 \"dir\" amount due to storage method).";
- Xstatic char Far First16[] = ". The first 16 are%s";
- Xstatic char Far ColonIndent[] = ":\n ";
- Xstatic char Far efFormat[] = " %02x";
- Xstatic char Far efAV[] = "PKWARE AV";
- Xstatic char Far efOS2[] = "OS/2";
- Xstatic char Far efPKVMS[] = "PKWARE VMS";
- Xstatic char Far efIZVMS[] = "Info-ZIP VMS";
- Xstatic char Far efASiUnix[] = "ASi Unix";
- X/* static char Far efIZUnix[] = "Info-ZIP Unix"; */
- Xstatic char Far efSpark[] = "Acorn SparkFS";
- Xstatic char Far efUnknown[] = "unknown";
- Xstatic char Far NoFileComment[] = "\n There is no file comment.\n";
- Xstatic char Far FileCommBegin[] = "\n\
- X------------------------- file comment begins ----------------------------\n";
- Xstatic char Far FileCommEnd[] = "\
- X-------------------------- file comment ends -----------------------------\n";
- Xstatic char Far JanMonth[] = "Jan";
- Xstatic char Far FebMonth[] = "Feb";
- Xstatic char Far MarMonth[] = "Mar";
- Xstatic char Far AprMonth[] = "Apr";
- Xstatic char Far MayMonth[] = "May";
- Xstatic char Far JunMonth[] = "Jun";
- Xstatic char Far JulMonth[] = "Jul";
- Xstatic char Far AugMonth[] = "Aug";
- Xstatic char Far SepMonth[] = "Sep";
- Xstatic char Far OctMonth[] = "Oct";
- Xstatic char Far NovMonth[] = "Nov";
- Xstatic char Far DecMonth[] = "Dec";
- Xstatic char Far BogusFmt[] = "%03d";
- Xstatic char Far DMYHMTime[] = "%2u-%s-%02u %02u:%02u";
- Xstatic char Far YMDHMSTime[] = "%u %s %u %02u:%02u:%02u";
- Xstatic char Far DecimalTime[] = "%02u%02u%02u.%02u%02u%02u";
- X
- X
- X
- X
- X
- X/************************/
- X/* Function zi_opts() */
- X/************************/
- X
- Xint zi_opts(pargc, pargv)
- X int *pargc;
- X char ***pargv;
- X{
- X char **argv, *s;
- X int argc, c, error=FALSE, negative=0;
- X int hflag_slmv=TRUE, hflag_2=FALSE; /* diff options => diff defaults */
- X int tflag_slm=TRUE, tflag_2v=FALSE;
- X int explicit_h=FALSE, explicit_t=FALSE;
- X
- X
- X#ifdef MACOS
- X lflag = LFLAG; /* reset default on each call */
- X#endif
- X argc = *pargc;
- X argv = *pargv;
- X
- X while (--argc > 0 && (*++argv)[0] == '-') {
- X s = argv[0] + 1;
- X while ((c = *s++) != 0) { /* "!= 0": prevent Turbo C warning */
- X switch (c) {
- X case '-':
- X ++negative;
- X break;
- X case '1': /* shortest listing: JUST filenames */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 1;
- X break;
- X case '2': /* just filenames, plus headers if specified */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 2;
- X break;
- X case 'h': /* header line */
- X if (negative)
- X hflag_2 = hflag_slmv = FALSE, negative = 0;
- X else {
- X hflag_2 = hflag_slmv = explicit_h = TRUE;
- X if (lflag == -1)
- X lflag = 0;
- X }
- X break;
- X case 'l': /* longer form of "ls -l" type listing */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 5;
- X break;
- X case 'm': /* medium form of "ls -l" type listing */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 4;
- X break;
- X case 's': /* default: shorter "ls -l" type listing */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 3;
- X break;
- X case 't': /* totals line */
- X if (negative)
- X tflag_2v = tflag_slm = FALSE, negative = 0;
- X else {
- X tflag_2v = tflag_slm = explicit_t = TRUE;
- X if (lflag == -1)
- X lflag = 0;
- X }
- X break;
- X case ('T'): /* use (sortable) decimal time format */
- X if (negative)
- X T_flag = FALSE, negative = 0;
- X else
- X T_flag = TRUE;
- X break;
- X case 'v': /* turbo-verbose listing */
- X if (negative)
- X lflag = -2, negative = 0;
- X else
- X lflag = 10;
- X break;
- X case 'z': /* print zipfile comment */
- X if (negative)
- X zflag = negative = 0;
- X else
- X zflag = 1;
- X break;
- X case 'Z': /* ZipInfo mode: ignore */
- X break;
- X default:
- X error = TRUE;
- X break;
- X }
- X }
- X }
- X if ((argc-- == 0) || error) {
- X *pargc = argc;
- X *pargv = argv;
- X return usage(error);
- X }
- X
- X /* if no listing options given (or all negated), or if only -h/-t given
- X * with individual files specified, use default listing format */
- X if ((lflag < 0) || ((argc > 0) && (lflag == 0)))
- X lflag = LFLAG;
- X
- X /* set header and totals flags to default or specified values */
- X switch (lflag) {
- X case 0: /* 0: can only occur if either -t or -h explicitly given; */
- X case 2: /* therefore set both flags equal to normally false value */
- X hflag = hflag_2;
- X tflag = tflag_2v;
- X break;
- X case 1: /* only filenames, *always* */
- X hflag = FALSE;
- X tflag = FALSE;
- X zflag = FALSE;
- X break;
- X case 3:
- X case 4:
- X case 5:
- X hflag = ((argc > 0) && !explicit_h)? FALSE : hflag_slmv;
- X tflag = ((argc > 0) && !explicit_t)? FALSE : tflag_slm;
- X break;
- X case 10:
- X hflag = hflag_slmv;
- X tflag = tflag_2v;
- X break;
- X }
- X
- X *pargc = argc;
- X *pargv = argv;
- X return 0;
- X
- X} /* end function zi_opts() */
- X
- X
- X
- X
- X
- X/*******************************/
- X/* Function zi_end_central() */
- X/*******************************/
- X
- Xint zi_end_central() /* return PK-type error code */
- X{
- X int error = PK_COOL;
- X
- X
- X/*---------------------------------------------------------------------------
- X Print out various interesting things about the zipfile.
- X ---------------------------------------------------------------------------*/
- X
- X /* header fits on one line, for anything up to 10GB and 10000 files: */
- X if (hflag)
- X PRINTF(((int)strlen(zipfn) < 39)?
- X LoadFarString(LongHeader) :
- X LoadFarString(ShortHeader), zipfn, (long)ziplen,
- X ecrec.total_entries_central_dir,
- X (ecrec.total_entries_central_dir==1)? "":"s");
- X
- X /* verbose format */
- X if (lflag > 9) {
- X PRINTF(LoadFarString(EndCentDirRec));
- X PRINTF(LoadFarString(LineSeparators));
- X
- X PRINTF(LoadFarString(ActOffsetCentDir),
- X (long)real_ecrec_offset, (long)real_ecrec_offset,
- X (long)expect_ecrec_offset, (long)expect_ecrec_offset);
- X
- X if (ecrec.number_this_disk == 0) {
- X PRINTF(LoadFarString(SinglePartArchive),
- X ecrec.total_entries_central_dir,
- X (ecrec.total_entries_central_dir == 1)? "entry" : "entries",
- X ecrec.size_central_directory, ecrec.size_central_directory,
- X ecrec.offset_start_central_directory,
- X ecrec.offset_start_central_directory);
- X } else {
- X PRINTF(LoadFarString(MultiPartArchive),
- X ecrec.number_this_disk,
- X ecrec.num_disk_with_start_central_dir,
- X ecrec.num_entries_centrl_dir_ths_disk,
- X (ecrec.num_entries_centrl_dir_ths_disk == 1)? "is" : "are",
- X ecrec.total_entries_central_dir,
- X (ecrec.total_entries_central_dir == 1) ? "entry" : "entries",
- X ecrec.size_central_directory, ecrec.size_central_directory,
- X ecrec.offset_start_central_directory,
- X ecrec.offset_start_central_directory);
- X }
- X
- X /*-----------------------------------------------------------------------
- X Get the zipfile comment, if any, and print it out. (Comment may be
- X up to 64KB long. May the fleas of a thousand camels infest the arm-
- X pits of anyone who actually takes advantage of this fact.)
- X -----------------------------------------------------------------------*/
- X
- X if (!ecrec.zipfile_comment_length)
- X PRINTF(LoadFarString(NoZipfileComment));
- X else {
- X PRINTF(LoadFarString(ZipfileCommentDesc),
- X ecrec.zipfile_comment_length );
- X PRINTF(LoadFarString(ZipfileCommBegin));
- X if (do_string(ecrec.zipfile_comment_length, DISPLAY))
- X error = PK_WARN;
- X PRINTF(LoadFarString(ZipfileCommEnd));
- X if (error)
- X PRINTF(LoadFarString(ZipfileCommTrunc2));
- X } /* endif (comment exists) */
- X
- X /* non-verbose mode: print zipfile comment only if requested */
- X } else if (zflag && ecrec.zipfile_comment_length) {
- X if (do_string(ecrec.zipfile_comment_length,DISPLAY)) {
- X FPRINTF(stderr, LoadFarString(ZipfileCommTruncMsg));
- X error = PK_WARN;
- X }
- X } /* endif (verbose) */
- X
- X return error;
- X
- X} /* end function zi_end_central() */
- X
- X
- X
- X
- X
- X/************************/
- X/* Function zipinfo() */
- X/************************/
- X
- Xint zipinfo() /* return PK-type error code */
- X{
- X int j, do_this_file=FALSE, error, error_in_archive=PK_COOL;
- X int *fn_matched=NULL, *xn_matched=NULL;
- X ush members=0;
- X ulg tot_csize=0L, tot_ucsize=0L;
- X
- X
- X/*---------------------------------------------------------------------------
- X Malloc space for check on unmatched filespecs (no big deal if one or both
- X are NULL).
- X ---------------------------------------------------------------------------*/
- X
- X if (filespecs > 0 &&
- X (fn_matched=(int *)malloc(filespecs*sizeof(int))) != NULL)
- X for (j = 0; j < filespecs; ++j)
- X fn_matched[j] = FALSE;
- X
- X if (xfilespecs > 0 &&
- X (xn_matched=(int *)malloc(xfilespecs*sizeof(int))) != NULL)
- X for (j = 0; j < xfilespecs; ++j)
- X xn_matched[j] = FALSE;
- X
- X/*---------------------------------------------------------------------------
- X Set file pointer to start of central directory, then loop through cen-
- X tral directory entries. Check that directory-entry signature bytes are
- X actually there (just a precaution), then process the entry. We know
- X the entire central directory is on this disk: we wouldn't have any of
- X this information unless the end-of-central-directory record was on this
- X disk, and we wouldn't have gotten to this routine unless this is also
- X the disk on which the central directory starts. In practice, this had
- X better be the *only* disk in the archive, but maybe someday we'll add
- X multi-disk support.
- X ---------------------------------------------------------------------------*/
- X
- X pInfo->lcflag = 0; /* used in do_string(): never TRUE in zipinfo mode */
- X pInfo->textmode = 0; /* so one can read on screen (but is it ever used?) */
- X newzip = TRUE; /* for zi_long() check of extra bytes */
- X
- X for (j = 0; j < (int)ecrec.total_entries_central_dir; ++j) {
- X if (readbuf(sig, 4) == 0)
- X return PK_EOF;
- X if (strncmp(sig, central_hdr_sig, 4)) { /* just to make sure */
- X FPRINTF(stderr, LoadFarString(CentSigMsg), j); /* sig not found */
- X return PK_BADERR;
- X }
- X if ((error = get_cdir_ent()) != PK_COOL)
- X return error; /* only PK_EOF defined */
- X
- X /* do Amigas (AMIGA_) also have volume labels? */
- X if (IS_VOLID(crec.external_file_attributes) &&
- X (pInfo->hostnum == FS_FAT_ || pInfo->hostnum == FS_HPFS_ ||
- X pInfo->hostnum == FS_NTFS_ || pInfo->hostnum == ATARI_))
- X pInfo->vollabel = TRUE;
- X else
- X pInfo->vollabel = FALSE;
- X
- X if ((error = do_string(crec.filename_length, FILENAME)) != PK_COOL) {
- X error_in_archive = error; /* might be warning */
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X
- X if (!process_all_files) { /* check if specified on command line */
- X char **pfn = pfnames-1;
- X
- X do_this_file = FALSE;
- X while (*++pfn)
- X if (match(filename, *pfn, 0)) {
- X do_this_file = TRUE;
- X if (fn_matched)
- X fn_matched[pfn-pfnames] = TRUE;
- X break; /* found match, so stop looping */
- X }
- X if (do_this_file) { /* check if this is an excluded file */
- X char **pxn = pxnames-1;
- X
- X while (*++pxn)
- X if (match(filename, *pxn, 0)) {
- X do_this_file = FALSE;
- X if (xn_matched)
- X xn_matched[pxn-pxnames] = TRUE;
- X break;
- X }
- X }
- X }
- X
- X /*-----------------------------------------------------------------------
- X If current file was specified on command line, or if no names were
- X specified, do the listing for this file. Otherwise, get rid of the
- X file comment and go back for the next file.
- X -----------------------------------------------------------------------*/
- X
- X if (process_all_files || do_this_file) {
- X
- X switch (lflag) {
- X case 1:
- X case 2:
- X fnprint();
- X SKIP_(crec.extra_field_length)
- X SKIP_(crec.file_comment_length)
- X break;
- X
- X case 3:
- X case 4:
- X case 5:
- X if ((error = zi_short()) != PK_COOL) {
- X error_in_archive = error; /* might be warning */
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X break;
- X
- X case 10:
- X#ifdef T20_VMS /* GRR: add cbreak-style "more" */
- X PRINTF(LoadFarString(CentralDirEntry), j);
- X#else
- X /* formfeed/CR for piping to "more": */
- X PRINTF(LoadFarString(CentralDirEntry), "\014", j);
- X#endif
- X PRINTF(LoadFarString(CentralDirLines));
- X
- X if ((error = zi_long()) != PK_COOL) {
- X error_in_archive = error; /* might be warning */
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X break;
- X
- X default:
- X SKIP_(crec.extra_field_length)
- X SKIP_(crec.file_comment_length)
- X break;
- X
- X } /* end switch (lflag) */
- X
- X tot_csize += crec.csize;
- X tot_ucsize += crec.ucsize;
- X if (crec.general_purpose_bit_flag & 1)
- X tot_csize -= 12; /* don't count encryption header */
- X ++members;
- X
- X } else { /* not listing */
- X SKIP_(crec.extra_field_length)
- X SKIP_(crec.file_comment_length)
- X
- X } /* end if (list member?) */
- X
- X } /* end for-loop (j: member files) */
- X
- X/*---------------------------------------------------------------------------
- X Double check that we're back at the end-of-central-directory record.
- X ---------------------------------------------------------------------------*/
- X
- X if (readbuf(sig, 4) == 0) /* disk error? */
- X return PK_EOF;
- X if (strncmp(sig, end_central_sig, 4)) { /* just to make sure again */
- X FPRINTF(stderr, LoadFarString(EndSigMsg)); /* didn't find sig */
- X error_in_archive = PK_WARN;
- X }
- X
- X/*---------------------------------------------------------------------------
- X Check that we actually found requested files; if so, print totals.
- X ---------------------------------------------------------------------------*/
- X
- X if (tflag) {
- X char *sgn = "";
- X int cfactor = ratio(tot_ucsize, tot_csize);
- X
- X if (cfactor < 0) {
- X sgn = "-";
- X cfactor = -cfactor;
- X }
- X PRINTF(LoadFarString(ZipfileStats),
- X members, (members==1)? "":"s", tot_ucsize, tot_csize, sgn, cfactor/10,
- X cfactor%10);
- X }
- X
- X/*---------------------------------------------------------------------------
- X Check for unmatched filespecs on command line and print warning if any
- X found.
- X ---------------------------------------------------------------------------*/
- X
- X if (fn_matched) {
- X for (j = 0; j < filespecs; ++j)
- X if (!fn_matched[j])
- X FPRINTF(stderr, LoadFarString(FilenameNotMatched),
- X pfnames[j]);
- X free(fn_matched);
- X }
- X if (xn_matched) {
- X for (j = 0; j < xfilespecs; ++j)
- X if (!xn_matched[j])
- X FPRINTF(stderr, LoadFarString(ExclFilenameNotMatched),
- X pxnames[j]);
- X free(xn_matched);
- X }
- X if (members == 0 && error_in_archive <= PK_WARN)
- X error_in_archive = PK_FIND;
- X
- X return error_in_archive;
- X
- X} /* end function zipinfo() */
- X
- X
- X
- X
- X
- X#define OS_unkn unkn
- X
- X/************************/
- X/* Function zi_long() */
- X/************************/
- X
- Xstatic int zi_long() /* return PK-type error code */
- X{
- X int error, error_in_archive=PK_COOL;
- X ush hostnum, hostver, extnum, extver, methnum, xattr;
- X char workspace[12], attribs[22];
- X static char meth_unkn[16];
- X static char Far *os[NUM_HOSTS+1] = {
- X OS_FAT, OS_Amiga, OS_VAXVMS, OS_Unix, OS_VMCMS, OS_AtariST, OS_HPFS,
- X OS_Macintosh, OS_ZSystem, OS_CPM, OS_TOPS20, OS_NTFS, OS_QDOS,
- X OS_Acorn, OS_unkn
- X };
- X static char Far *method[NUM_METHODS+1] = {
- X MthdNone, MthdShrunk, MthdRedF1, MthdRedF2, MthdRedF3, MthdRedF4,
- X MthdImplode, MthdToken, MthdDeflate, meth_unkn
- X };
- X static char *dtype[4] = {"normal", "maximum", "fast", "superfast"};
- X static ulg endprev;
- X
- X
- X/*---------------------------------------------------------------------------
- X Check whether there's any extra space inside the zipfile.
- X ---------------------------------------------------------------------------*/
- X
- X if (newzip) { /* reset if new zipfile; account for multi-part archives */
- X endprev = (crec.relative_offset_local_header == 4L)? 4L : 0L;
- X newzip = FALSE;
- X }
- X
- X if (crec.relative_offset_local_header != endprev)
- X PRINTF(LoadFarString(ExtraBytesPreceding),
- X (long)crec.relative_offset_local_header - (long)endprev);
- X
- X /* calculate endprev for next time around */
- X endprev = crec.relative_offset_local_header + 4L + LREC_SIZE +
- X crec.filename_length + crec.extra_field_length + crec.file_comment_length
- X + crec.csize;
- X
- X/*---------------------------------------------------------------------------
- X Print out various interesting things about the compressed file.
- X ---------------------------------------------------------------------------*/
- X
- X hostnum = MIN(crec.version_made_by[1], NUM_HOSTS);
- X hostver = crec.version_made_by[0];
- X extnum = MIN(crec.version_needed_to_extract[1], NUM_HOSTS);
- X extver = crec.version_needed_to_extract[0];
- X methnum = MIN(crec.compression_method, NUM_METHODS);
- X
- X if (hostnum == NUM_HOSTS)
- X sprintf(OS_unkn, LoadFarString(Unknown), (int)crec.version_made_by[1]);
- X if (methnum == NUM_METHODS)
- X sprintf(meth_unkn, LoadFarString(Unknown), crec.compression_method);
- X
- X PRINTF(" "); fnprint();
- X
- X PRINTF(LoadFarString(HostOS), LoadFarStringSmall(os[hostnum]));
- X PRINTF(LoadFarString(EncodeSWVer), hostver/10, hostver%10);
- X PRINTF(LoadFarString(MinOSCompReq), LoadFarStringSmall(os[extnum]));
- X PRINTF(LoadFarString(MinSWVerReq), extver/10, extver%10);
- X PRINTF(LoadFarString(CompressMethod), LoadFarStringSmall(method[methnum]));
- X if (methnum == IMPLODED) {
- X PRINTF(LoadFarString(SlideWindowSizeImplode),
- X (crec.general_purpose_bit_flag & 2)? '8' : '4');
- X PRINTF(LoadFarString(ShannonFanoTrees),
- X (crec.general_purpose_bit_flag & 4)? '3' : '2');
- X } else if (methnum == DEFLATED) {
- X ush dnum=(crec.general_purpose_bit_flag>>1) & 3;
- X PRINTF(LoadFarString(CompressSubtype), dtype[dnum]);
- X }
- X PRINTF(LoadFarString(FileSecurity),
- X (crec.general_purpose_bit_flag & 1)? "" : "not ");
- X PRINTF(LoadFarString(ExtendedLocalHdr),
- X (crec.general_purpose_bit_flag & 8)? "yes" : "no");
- X /* print upper 3 bits for amusement? */
- X PRINTF(LoadFarString(FileModDate),
- X zi_time(&crec.last_mod_file_date, &crec.last_mod_file_time));
- X PRINTF(LoadFarString(CRC32Value), crec.crc32);
- X PRINTF(LoadFarString(CompressedFileSize), crec.csize);
- X PRINTF(LoadFarString(UncompressedFileSize), crec.ucsize);
- X PRINTF(LoadFarString(FilenameLength), crec.filename_length);
- X PRINTF(LoadFarString(ExtraFieldLength), crec.extra_field_length);
- X PRINTF(LoadFarString(FileCommentLength), crec.file_comment_length);
- X PRINTF(LoadFarString(FileDiskNum), crec.disk_number_start);
- X PRINTF(LoadFarString(ApparentFileType),
- X (crec.internal_file_attributes & 1)? "text" : "binary");
- X/*
- X PRINTF(" external file attributes (hex): %.8lx\n",
- X crec.external_file_attributes);
- X */
- X xattr = (ush)((crec.external_file_attributes >> 16) & 0xFFFF);
- X if (hostnum == VMS_) {
- X char *p=attribs, *q=attribs+1;
- X int i, j, k;
- X
- X for (k = 0; k < 12; ++k)
- X workspace[k] = 0;
- X if (xattr & VMS_IRUSR)
- X workspace[0] = 'R';
- X if (xattr & VMS_IWUSR) {
- X workspace[1] = 'W';
- X workspace[3] = 'D';
- X }
- X if (xattr & VMS_IXUSR)
- X workspace[2] = 'E';
- X if (xattr & VMS_IRGRP)
- X workspace[4] = 'R';
- X if (xattr & VMS_IWGRP) {
- X workspace[5] = 'W';
- X workspace[7] = 'D';
- X }
- X if (xattr & VMS_IXGRP)
- X workspace[6] = 'E';
- X if (xattr & VMS_IROTH)
- X workspace[8] = 'R';
- X if (xattr & VMS_IWOTH) {
- X workspace[9] = 'W';
- X workspace[11] = 'D';
- X }
- X if (xattr & VMS_IXOTH)
- X workspace[10] = 'E';
- X
- X *p++ = '(';
- X for (k = j = 0; j < 3; ++j) { /* loop over groups of permissions */
- X for (i = 0; i < 4; ++i, ++k) /* loop over perms within a group */
- X if (workspace[k])
- X *p++ = workspace[k];
- X *p++ = ','; /* group separator */
- X if (j == 0)
- X while ((*p++ = *q++) != ','); /* system, owner perms are same */
- X }
- X *p-- = 0;
- X *p = ')'; /* overwrite last comma */
- X PRINTF(LoadFarString(VMSFileAttributes), xattr, attribs);
- X
- X } else if (hostnum == AMIGA_) {
- X switch (xattr & AMI_IFMT) {
- X case AMI_IFDIR: attribs[0] = 'd'; break;
- X case AMI_IFREG: attribs[0] = '-'; break;
- X default: attribs[0] = '?'; break;
- X }
- X attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
- X attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
- X attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
- X attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
- X attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
- X attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
- X attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
- X attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
- X attribs[9] = 0; /* better dlm the string */
- X PRINTF(LoadFarString(AmigaFileAttributes), xattr, attribs);
- X
- X } else if ((hostnum != FS_FAT_) && (hostnum != FS_HPFS_) &&
- X (hostnum != FS_NTFS_) && (hostnum != ATARI_) &&
- X (hostnum != ACORN_))
- X { /* assume Unix-like */
- X switch (xattr & UNX_IFMT) {
- X case UNX_IFDIR: attribs[0] = 'd'; break;
- X case UNX_IFREG: attribs[0] = '-'; break;
- X case UNX_IFLNK: attribs[0] = 'l'; break;
- X case UNX_IFBLK: attribs[0] = 'b'; break;
- X case UNX_IFCHR: attribs[0] = 'c'; break;
- X case UNX_IFIFO: attribs[0] = 'p'; break;
- X case UNX_IFSOCK: attribs[0] = 's'; break;
- X default: attribs[0] = '?'; break;
- X }
- X attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
- X attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
- X attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
- X
- X attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
- X attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
- X attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
- X
- X if (xattr & UNX_IXUSR)
- X attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
- X else
- X attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S = undefined */
- X if (xattr & UNX_IXGRP)
- X attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
- X else
- X attribs[6] = (xattr & UNX_ISGID)? 'l' : '-';
- X if (xattr & UNX_IXOTH)
- X attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x'; /* "sticky bit" */
- X else
- X attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T = undefined */
- X attribs[10] = 0;
- X
- X PRINTF(LoadFarString(UnixFileAttributes), xattr, attribs);
- X
- X } else {
- X PRINTF(LoadFarString(NonMSDOSFileAttributes),
- X crec.external_file_attributes >> 8);
- X
- X } /* endif (hostnum: external attributes format) */
- X
- X if ((xattr=(ush)(crec.external_file_attributes & 0xFF)) == 0)
- X PRINTF(LoadFarString(MSDOSFileAttributes), xattr);
- X else if (xattr == 1)
- X PRINTF(LoadFarString(MSDOSFileAttributesRO), xattr);
- X else
- X PRINTF(LoadFarString(MSDOSFileAttributesAlpha),
- X xattr, (xattr&1)?"rdo ":"", (xattr&2)?"hid ":"", (xattr&4)?"sys ":"",
- X (xattr&8)?"lab ":"", (xattr&16)?"dir ":"", (xattr&32)?"arc":"");
- X PRINTF(LoadFarString(LocalHeaderOffset),
- X crec.relative_offset_local_header, crec.relative_offset_local_header);
- X
- X/*---------------------------------------------------------------------------
- X Skip the extra field, if any, and print the file comment, if any (the
- X filename has already been printed, above). That finishes up this file
- X entry...
- X ---------------------------------------------------------------------------*/
- X
- X if (crec.extra_field_length > 0) {
- X ush ef_id, ef_datalen;
- X
- X if ((error = do_string(crec.extra_field_length, EXTRA_FIELD)) != 0) {
- X error_in_archive = error;
- X if (error > PK_WARN) /* fatal: can't continue */
- X return error;
- X }
- X if (extra_field == (uch *)NULL)
- X return PK_ERR; /* not consistent with crec length */
- X ef_id = makeword(extra_field);
- X ef_datalen = makeword(&extra_field[2]);
- X switch (ef_id) {
- X case EF_AV:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efAV), ef_datalen);
- X break;
- X case EF_OS2:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efOS2), ef_datalen);
- X/* GRR: should check that ef_datalen really 4 and not 2 before doing this: */
- X PRINTF(LoadFarString(OS2EAs), makelong(&extra_field[4]));
- X break;
- X case EF_PKVMS:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efPKVMS), ef_datalen);
- X break;
- X case EF_IZVMS:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efIZVMS), ef_datalen);
- X break;
- X case EF_ASIUNIX:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efASiUnix), ef_datalen);
- X break;
- X case EF_SPARK:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efSpark), ef_datalen);
- X break;
- X default:
- X PRINTF(LoadFarString(ExtraFieldType), ef_id,
- X LoadFarStringSmall(efUnknown), ef_datalen);
- X break;
- X }
- X if (ef_id != EF_OS2) {
- X ush i, n;
- X
- X if (ef_datalen <= 16) {
- X PRINTF(LoadFarString(ColonIndent));
- X/* GRR: should double-check that datalen <= crec.extra_field_length - 4 */
- X n = ef_datalen;
- X } else {
- X PRINTF(LoadFarString(First16),
- X LoadFarStringSmall(ColonIndent));
- X n = 16;
- X }
- X for (i = 0; i < n; ++i)
- X PRINTF(LoadFarString(efFormat), extra_field[i+4]);
- X }
- X PRINTF("\n");
- X }
- X
- X if (!crec.file_comment_length)
- X PRINTF(LoadFarString(NoFileComment));
- X else {
- X PRINTF(LoadFarString(FileCommBegin));
- X if ((error = do_string(crec.file_comment_length, DISPLAY)) != PK_COOL) {
- X error_in_archive = error; /* might be warning */
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X PRINTF(LoadFarString(FileCommEnd));
- X }
- X
- X return error_in_archive;
- X
- X} /* end function zi_long() */
- X
- X
- X
- X
- X
- X/*************************/
- X/* Function zi_short() */
- X/*************************/
- X
- Xstatic int zi_short() /* return PK-type error code */
- X{
- X int k, error, error_in_archive=PK_COOL;
- X ush methnum, hostnum, hostver, xattr;
- X char *p, workspace[12], attribs[16];
- X static char impl[5]="i#:#", defl[5]="def#";
- X static char dtype[5]="NXFS"; /* normal, maximum, fast, superfast */
- X static char *os[NUM_HOSTS+1] = {
- X "fat", "ami", "vms", "unx", "cms", "atr", "hpf", "mac", "zzz",
- X "cpm", "t20", "ntf", "qds", "aco", "???"
- X };
- X static char *method[NUM_METHODS+1] = {
- X "stor", "shrk", "re:1", "re:2", "re:3", "re:4", impl, "tokn",
- X defl, unkn
- X };
- X
- X
- X/*---------------------------------------------------------------------------
- X Print out various interesting things about the compressed file.
- X ---------------------------------------------------------------------------*/
- X
- X methnum = MIN(crec.compression_method, NUM_METHODS);
- X hostnum = MIN(crec.version_made_by[1], NUM_HOSTS);
- X hostver = crec.version_made_by[0];
- X/*
- X extnum = MIN(crec.version_needed_to_extract[1], NUM_HOSTS);
- X extver = crec.version_needed_to_extract[0];
- X */
- X
- X if (methnum == IMPLODED) {
- X impl[1] = (char) ((crec.general_purpose_bit_flag & 2)? '8' : '4');
- X impl[3] = (char) ((crec.general_purpose_bit_flag & 4)? '3' : '2');
- X } else if (methnum == DEFLATED) {
- X ush dnum=(crec.general_purpose_bit_flag>>1) & 3;
- X defl[3] = dtype[dnum];
- X } else if (methnum == NUM_METHODS) { /* unknown */
- X sprintf(unkn, "u%03d", crec.compression_method);
- X }
- X
- X for (k = 0; k < 15; ++k)
- X attribs[k] = ' ';
- X attribs[15] = 0;
- X
- X xattr = (ush)((crec.external_file_attributes >> 16) & 0xFFFF);
- X switch (hostnum) {
- X case VMS_:
- X { int i, j;
- X
- X for (k = 0; k < 12; ++k)
- X workspace[k] = 0;
- X if (xattr & VMS_IRUSR)
- X workspace[0] = 'R';
- X if (xattr & VMS_IWUSR) {
- X workspace[1] = 'W';
- X workspace[3] = 'D';
- X }
- X if (xattr & VMS_IXUSR)
- X workspace[2] = 'E';
- X if (xattr & VMS_IRGRP)
- X workspace[4] = 'R';
- X if (xattr & VMS_IWGRP) {
- X workspace[5] = 'W';
- X workspace[7] = 'D';
- X }
- X if (xattr & VMS_IXGRP)
- X workspace[6] = 'E';
- X if (xattr & VMS_IROTH)
- X workspace[8] = 'R';
- X if (xattr & VMS_IWOTH) {
- X workspace[9] = 'W';
- X workspace[11] = 'D';
- X }
- X if (xattr & VMS_IXOTH)
- X workspace[10] = 'E';
- X
- X p = attribs;
- X for (k = j = 0; j < 3; ++j) { /* groups of permissions */
- X for (i = 0; i < 4; ++i, ++k) /* perms within a group */
- X if (workspace[k])
- X *p++ = workspace[k];
- X *p++ = ','; /* group separator */
- X }
- X *--p = ' '; /* overwrite last comma */
- X if ((p - attribs) < 12)
- X sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
- X }
- X break;
- X
- X case FS_FAT_:
- X case FS_HPFS_:
- X case FS_NTFS_:
- X case ATARI_:
- X case ACORN_:
- X xattr = (ush)(crec.external_file_attributes & 0xFF);
- X sprintf(attribs, ".r.-... %d.%d", hostver/10, hostver%10);
- X attribs[2] = (xattr & 0x01)? '-' : 'w';
- X attribs[5] = (xattr & 0x02)? 'h' : '-';
- X attribs[6] = (xattr & 0x04)? 's' : '-';
- X attribs[4] = (xattr & 0x20)? 'a' : '-';
- X if (xattr & 0x10) {
- X attribs[0] = 'd';
- X attribs[3] = 'x';
- X } else
- X attribs[0] = '-';
- X if (IS_VOLID(xattr))
- X attribs[0] = 'V';
- X else if ((p = strrchr(filename, '.')) != (char *)NULL) {
- X ++p;
- X if (STRNICMP(p, "com", 3) == 0 || STRNICMP(p, "exe", 3) == 0 ||
- X STRNICMP(p, "btm", 3) == 0 || STRNICMP(p, "cmd", 3) == 0 ||
- X STRNICMP(p, "bat", 3) == 0)
- X attribs[3] = 'x';
- X }
- X break;
- X
- X case AMIGA_:
- X switch (xattr & AMI_IFMT) {
- X case AMI_IFDIR: attribs[0] = 'd'; break;
- X case AMI_IFREG: attribs[0] = '-'; break;
- X default: attribs[0] = '?'; break;
- X }
- X attribs[1] = (xattr & AMI_IHIDDEN)? 'h' : '-';
- X attribs[2] = (xattr & AMI_ISCRIPT)? 's' : '-';
- X attribs[3] = (xattr & AMI_IPURE)? 'p' : '-';
- X attribs[4] = (xattr & AMI_IARCHIVE)? 'a' : '-';
- X attribs[5] = (xattr & AMI_IREAD)? 'r' : '-';
- X attribs[6] = (xattr & AMI_IWRITE)? 'w' : '-';
- X attribs[7] = (xattr & AMI_IEXECUTE)? 'e' : '-';
- X attribs[8] = (xattr & AMI_IDELETE)? 'd' : '-';
- X sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
- X break;
- X
- X default: /* assume Unix-like */
- X switch (xattr & UNX_IFMT) {
- X case UNX_IFDIR: attribs[0] = 'd'; break;
- X case UNX_IFREG: attribs[0] = '-'; break;
- X case UNX_IFLNK: attribs[0] = 'l'; break;
- X case UNX_IFBLK: attribs[0] = 'b'; break;
- X case UNX_IFCHR: attribs[0] = 'c'; break;
- X case UNX_IFIFO: attribs[0] = 'p'; break;
- X case UNX_IFSOCK: attribs[0] = 's'; break;
- X default: attribs[0] = '?'; break;
- X }
- X attribs[1] = (xattr & UNX_IRUSR)? 'r' : '-';
- X attribs[4] = (xattr & UNX_IRGRP)? 'r' : '-';
- X attribs[7] = (xattr & UNX_IROTH)? 'r' : '-';
- X attribs[2] = (xattr & UNX_IWUSR)? 'w' : '-';
- X attribs[5] = (xattr & UNX_IWGRP)? 'w' : '-';
- X attribs[8] = (xattr & UNX_IWOTH)? 'w' : '-';
- X
- X if (xattr & UNX_IXUSR)
- X attribs[3] = (xattr & UNX_ISUID)? 's' : 'x';
- X else
- X attribs[3] = (xattr & UNX_ISUID)? 'S' : '-'; /* S==undefined */
- X if (xattr & UNX_IXGRP)
- X attribs[6] = (xattr & UNX_ISGID)? 's' : 'x'; /* == UNX_ENFMT */
- X else
- X /* attribs[6] = (xattr & UNX_ISGID)? 'l' : '-'; real 4.3BSD */
- X attribs[6] = (xattr & UNX_ISGID)? 'S' : '-'; /* SunOS 4.1.x */
- X if (xattr & UNX_IXOTH)
- X attribs[9] = (xattr & UNX_ISVTX)? 't' : 'x'; /* "sticky bit" */
- X else
- X attribs[9] = (xattr & UNX_ISVTX)? 'T' : '-'; /* T==undefined */
- X
- X sprintf(&attribs[12], "%d.%d", hostver/10, hostver%10);
- X break;
- X
- X } /* end switch (hostnum: external attributes format) */
- X
- X PRINTF("%s %s %7lu %c%c", attribs, os[hostnum], crec.ucsize,
- X (crec.general_purpose_bit_flag & 1)?
- X ((crec.internal_file_attributes & 1)? 'T' : 'B') : /* encrypted */
- X ((crec.internal_file_attributes & 1)? 't' : 'b'), /* plaintext */
- X (crec.general_purpose_bit_flag & 8)? (crec.extra_field_length? 'X' : 'l')
- X : (crec.extra_field_length? 'x' : '-'));
- X if (lflag == 4) {
- X ulg csiz = crec.csize;
- X
- X if (crec.general_purpose_bit_flag & 1)
- X csiz -= 12; /* if encrypted, don't count encryption header */
- X PRINTF("%3d%%", (ratio(crec.ucsize,csiz) + 5)/10);
- X } else if (lflag == 5)
- X PRINTF(" %7lu", crec.csize);
- X
- X PRINTF(" %s %s ", method[methnum],
- X zi_time(&crec.last_mod_file_date, &crec.last_mod_file_time));
- X fnprint();
- X
- X/*---------------------------------------------------------------------------
- X Skip the extra field and/or the file comment, if any (the filename has
- X already been printed, above). That finishes up this file entry...
- X ---------------------------------------------------------------------------*/
- X
- X SKIP_(crec.extra_field_length)
- X SKIP_(crec.file_comment_length)
- X
- X return error_in_archive;
- X
- X} /* end function zi_short() */
- X
- X
- X
- X
- X
- X/************************/
- X/* Function zi_time() */
- X/************************/
- X
- Xstatic char *zi_time(datez, timez)
- X ush *datez, *timez;
- X{
- X ush yr, mo, dy, hh, mm, ss;
- X static char d_t_str[21], bogus[4];
- X static char Far *month[13] = {
- X bogus, JanMonth, FebMonth, MarMonth, AprMonth, MayMonth, JunMonth,
- X JulMonth, AugMonth, SepMonth, OctMonth, NovMonth, DecMonth
- X };
- X
- X
- X
- X/*---------------------------------------------------------------------------
- X Convert the file-modification date and time info to a string of the form
- X "1991 Feb 23 17:15:00" or "23-Feb-91 17:15," depending on value of lflag.
- X ---------------------------------------------------------------------------*/
- X
- X yr = ((*datez >> 9) & 0x7f) + 80;
- X mo = ((*datez >> 5) & 0x0f);
- X dy = *datez & 0x1f;
- X
- X hh = (*timez >> 11) & 0x1f;
- X mm = (*timez >> 5) & 0x3f;
- X ss = (*timez & 0x1f) * 2;
- X
- X if (mo == 0 || mo > 12) {
- X sprintf(bogus, LoadFarString(BogusFmt), mo);
- X mo = 0;
- X }
- X
- X if (lflag > 9) /* verbose listing format */
- X sprintf(d_t_str, LoadFarString(YMDHMSTime), yr+1900,
- X LoadFarStringSmall(month[mo]), dy, hh, mm, ss);
- X else if (T_flag)
- X sprintf(d_t_str, LoadFarString(DecimalTime), yr%100, mo, dy, hh, mm,
- X ss);
- X else /* was: if ((lflag >= 3) && (lflag <= 5)) */
- X sprintf(d_t_str, LoadFarString(DMYHMTime), dy,
- X LoadFarStringSmall(month[mo]), yr%100, hh, mm);
- X
- X return d_t_str;
- X
- X} /* end function zi_time() */
- X
- X#endif /* !NO_ZIPINFO */
- X
- X
- X
- X
- X
- X/*************************/
- X/* Function list_files() */
- X/*************************/
- X
- Xint list_files() /* return PK-type error code */
- X{
- X char sgn, cfactorstr[10];
- X int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
- X int longhdr=(vflag>1), date_format, methnum;
- X ush j, yr, mo, dy, hh, mm, members=0;
- X ulg csiz, tot_csize=0L, tot_ucsize=0L;
- X#ifdef OS2
- X ulg ea_size, tot_easize=0L, tot_eafiles=0L;
- X#endif
- X#ifdef MSWIN
- X PSTR psLBEntry; /* list box entry */
- X#endif
- X min_info info;
- X static char defl[]="Defl:#", dtype[]="NXFS"; /* see zi_short() */
- X static char *method[NUM_METHODS+1] =
- X {"Stored", "Shrunk", "Reduce1", "Reduce2", "Reduce3", "Reduce4",
- X "Implode", "Token", defl, unkn};
- X
- X
- X
- X/*---------------------------------------------------------------------------
- X Unlike extract_or_test_files(), this routine confines itself to the cen-
- X tral directory. Thus its structure is somewhat simpler, since we can do
- X just a single loop through the entire directory, listing files as we go.
- X
- X So to start off, print the heading line and then begin main loop through
- X the central directory. The results will look vaguely like the following:
- X
- X Length Method Size Ratio Date Time CRC-32 Name ("^" ==> case
- X ------ ------ ---- ----- ---- ---- ------ ---- conversion)
- X 44004 Implode 13041 71% 11-02-89 19:34 8b4207f7 Makefile.UNIX
- X 3438 Shrunk 2209 36% 09-15-90 14:07 a2394fd8 ^dos-file.ext
- X ---------------------------------------------------------------------------*/
- X
- X pInfo = &info;
- X date_format = DATE_FORMAT;
- X
- X#ifndef MSWIN
- X if (qflag < 2)
- X if (L_flag)
- X PRINTF(LoadFarString(CaseConversion),
- X LoadFarStringSmall(Headers[longhdr][0]),
- X LoadFarStringSmall2(Headers[longhdr][1]));
- X else
- X PRINTF("%s\n%s\n", LoadFarString(Headers[longhdr][0]),
- X LoadFarStringSmall(Headers[longhdr][1]));
- X#endif /* !MSWIN */
- X
- X for (j = 0; j < ecrec.total_entries_central_dir; ++j) {
- X
- X if (readbuf(sig, 4) == 0)
- X return PK_EOF;
- X if (strncmp(sig, central_hdr_sig, 4)) { /* just to make sure */
- X FPRINTF(stderr, LoadFarString(CentSigMsg), j); /* sig not found */
- X FPRINTF(stderr, LoadFarString(ReportMsg)); /* check binary xfers */
- X return PK_BADERR;
- X }
- X /* process_cdir_file_hdr() sets pInfo->lcflag: */
- X if ((error = process_cdir_file_hdr()) != PK_COOL)
- X return error; /* only PK_EOF defined */
- X
- X /*
- X * We could DISPLAY the filename instead of storing (and possibly trun-
- X * cating, in the case of a very long name) and printing it, but that
- X * has the disadvantage of not allowing case conversion--and it's nice
- X * to be able to see in the listing precisely how you have to type each
- X * filename in order for unzip to consider it a match. Speaking of
- X * which, if member names were specified on the command line, check in
- X * with match() to see if the current file is one of them, and make a
- X * note of it if it is.
- X */
- X
- X if ((error = do_string(crec.filename_length, FILENAME)) != PK_COOL) {
- X error_in_archive = error; /* ^--(uses pInfo->lcflag) */
- X if (error > PK_WARN) /* fatal: can't continue */
- X return error;
- X }
- X if (extra_field != (uch *)NULL) {
- X free(extra_field);
- X extra_field = (uch *)NULL;
- X }
- X if ((error = do_string(crec.extra_field_length, EXTRA_FIELD)) != 0) {
- X error_in_archive = error;
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X if (!process_all_files) { /* check if specified on command line */
- X char **pfn = pfnames-1;
- X
- X do_this_file = FALSE;
- X while (*++pfn)
- X if (match(filename, *pfn, C_flag)) {
- X do_this_file = TRUE;
- X break; /* found match, so stop looping */
- X }
- X if (do_this_file) { /* check if this is an excluded file */
- X char **pxn = pxnames-1;
- X
- X while (*++pxn)
- X if (match(filename, *pxn, C_flag)) {
- X do_this_file = FALSE; /* ^-- ignore case in match */
- X break;
- X }
- X }
- X }
- X /*
- X * If current file was specified on command line, or if no names were
- X * specified, do the listing for this file. Otherwise, get rid of the
- X * file comment and go back for the next file.
- X */
- X
- X if (process_all_files || do_this_file) {
- X
- X yr = (((crec.last_mod_file_date >> 9) & 0x7f) + 80) % (unsigned)100;
- X mo = (crec.last_mod_file_date >> 5) & 0x0f;
- X dy = crec.last_mod_file_date & 0x1f;
- X
- X /* permute date so it displays according to national convention */
- X switch (date_format) {
- X case DF_YMD:
- X hh = mo; mo = yr; yr = dy; dy = hh;
- X break;
- X case DF_DMY:
- X hh = mo; mo = dy; dy = hh;
- X }
- X hh = (crec.last_mod_file_time >> 11) & 0x1f;
- X mm = (crec.last_mod_file_time >> 5) & 0x3f;
- X
- X csiz = crec.csize;
- X if (crec.general_purpose_bit_flag & 1)
- X csiz -= 12; /* if encrypted, don't count encryption header */
- X if ((cfactor = ratio(crec.ucsize, csiz)) < 0) {
- X sgn = '-';
- X cfactor = (-cfactor + 5) / 10;
- X } else {
- X sgn = ' ';
- X cfactor = (cfactor + 5) / 10;
- X }
- X sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
- X
- X methnum = MIN(crec.compression_method, NUM_METHODS);
- X if (methnum == DEFLATED)
- X defl[5] = dtype[(crec.general_purpose_bit_flag>>1) & 3];
- X else if (methnum == NUM_METHODS)
- X sprintf(unkn, LoadFarString(CompMethodUnknown),
- X crec.compression_method);
- X
- X#if 0 /* GRR/Euro: add this? */
- X#if defined(DOS_NT_OS2) || defined(UNIX)
- X for (p = filename; *p; ++p)
- X if (!isprint(*p))
- X *p = '?'; /* change non-printable chars to '?' */
- X#endif /* DOS_NT_OS2 || UNIX */
- X#endif /* 0 */
- X
- X#ifdef MSWIN
- X#ifdef NEED_EARLY_REDRAW
- X /* turn on listbox redrawing just before adding last line */
- X if (j == (ecrec.total_entries_central_dir-1))
- X (void)SendMessage(hWndList, WM_SETREDRAW, TRUE, 0L);
- X#endif /* NEED_EARLY_REDRAW */
- X psLBEntry =
- X (PSTR)LocalAlloc(LMEM_FIXED, FILNAMSIZ+LONG_FORM_FNAME_INX);
- X /* GRR: does OemToAnsi filter out escape and CR characters? */
- X OemToAnsi(filename, filename); /* translate to ANSI */
- X if (longhdr) {
- X wsprintf(psLBEntry, LoadFarString(LongHdrStats),
- X crec.ucsize, (LPSTR)method[methnum], csiz, cfactorstr,
- X mo, dy, yr, hh, mm, crec.crc32, (pInfo->lcflag?'^':' '),
- X (LPSTR)filename);
- X SendMessage(hWndList, LB_ADDSTRING, 0,
- X (LONG)(LPSTR)psLBEntry);
- X } else {
- X wsprintf(psLBEntry, LoadFarString(ShortHdrStats),
- X crec.ucsize, mo, dy, yr, hh, mm, (pInfo->lcflag?'^':' '),
- X (LPSTR)filename);
- X SendMessage(hWndList, LB_ADDSTRING, 0,
- X (LONG)(LPSTR)psLBEntry);
- X }
- X LocalFree((HANDLE)psLBEntry);
- X#else /* !MSWIN */
- X if (longhdr)
- X PRINTF(LoadFarString(LongHdrStats),
- X crec.ucsize, method[methnum], csiz, cfactorstr, mo, dy, yr,
- X hh, mm, crec.crc32, (pInfo->lcflag?'^':' '));
- X else
- X PRINTF(LoadFarString(ShortHdrStats), crec.ucsize,
- X mo, dy, yr, hh, mm, (pInfo->lcflag?'^':' '));
- X fnprint();
- X#endif /* ?MSWIN */
- X
- X error = do_string(crec.file_comment_length, QCOND? DISPLAY : SKIP);
- X if (error) {
- X error_in_archive = error; /* might be just warning */
- X if (error > PK_WARN) /* fatal */
- X return error;
- X }
- X tot_ucsize += crec.ucsize;
- X tot_csize += csiz;
- X ++members;
- X#ifdef OS2
- X if ((ea_size = SizeOfEAs(extra_field)) != 0) {
- X tot_easize += ea_size;
- X tot_eafiles++;
- X }
- X#endif
- X } else { /* not listing this file */
- X SKIP_(crec.file_comment_length)
- X }
- X } /* end for-loop (j: files in central directory) */
- X
- X/*---------------------------------------------------------------------------
- X Print footer line and totals (compressed size, uncompressed size, number
- X of members in zipfile).
- X ---------------------------------------------------------------------------*/
- X
- X if (qflag < 2) {
- X if ((cfactor = ratio(tot_ucsize, tot_csize)) < 0) {
- X sgn = '-';
- X cfactor = (-cfactor + 5) / 10;
- X } else {
- X sgn = ' ';
- X cfactor = (cfactor + 5) / 10;
- X }
- X sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
- X#ifdef MSWIN
- X /* Display just the totals since the dashed lines get displayed
- X * in UpdateListBox(). Get just enough space to display total. */
- X if (longhdr)
- X wsprintf(lpumb->szTotalsLine,LoadFarString(LongFileHeader),
- X tot_ucsize, tot_csize, cfactorstr, members);
- X else
- X wsprintf(lpumb->szTotalsLine, LoadFarString(ShortFileHeader),
- X tot_ucsize, members);
- X#else /* !MSWIN */
- X if (longhdr)
- X PRINTF(LoadFarString(LongFileHeader), tot_ucsize, tot_csize, cfactorstr, members);
- X else
- X PRINTF(LoadFarString(ShortFileHeader), tot_ucsize, members);
- X#endif /* ?MSWIN */
- X#ifdef OS2
- X if (tot_eafiles && tot_easize)
- X PRINTF("\n%ld file%s %ld bytes of EA's attached.\n", tot_eafiles,
- X tot_eafiles == 1 ? " has" : "s have a total of", tot_easize);
- X#endif
- X }
- X/*---------------------------------------------------------------------------
- X Double check that we're back at the end-of-central-directory record.
- X ---------------------------------------------------------------------------*/
- X
- X if (readbuf(sig, 4) == 0)
- X return PK_EOF;
- X if (strncmp(sig, end_central_sig, 4)) { /* just to make sure again */
- X FPRINTF(stderr, LoadFarString(EndSigMsg)); /* didn't find sig */
- X error_in_archive = PK_WARN;
- X }
- X if (members == 0 && error_in_archive <= PK_WARN)
- X error_in_archive = PK_FIND;
- X
- X return error_in_archive;
- X
- X} /* end function list_files() */
- X
- X
- X
- X
- X
- X/********************/
- X/* Function ratio() */
- X/********************/
- X
- Xstatic int ratio(uc, c)
- X ulg uc, c;
- X{
- X ulg denom;
- X
- X if (uc == 0)
- X return 0;
- X if (uc > 2000000L) { /* risk signed overflow if multiply numerator */
- X denom = uc / 1000L;
- X return ((uc >= c) ?
- X (int) ((uc-c + (denom>>1)) / denom) :
- X -((int) ((c-uc + (denom>>1)) / denom)));
- X } else { /* ^^^^^^^^ rounding */
- X denom = uc;
- X return ((uc >= c) ?
- X (int) ((1000L*(uc-c) + (denom>>1)) / denom) :
- X -((int) ((1000L*(c-uc) + (denom>>1)) / denom)));
- X } /* ^^^^^^^^ rounding */
- X}
- X
- X
- X
- X
- X
- X/************************/
- X/* Function fnprint() */
- X/************************/
- X
- Xstatic void fnprint() /* print filename (after filtering) and newline */
- X{
- X register uch *p = (uch *)filename-1;
- X register uch *q = (uch *)slide;
- X
- X#ifdef NATIVE
- X PRINTF("%s", filename); /* GRR: can ANSI be used with EBCDIC? */
- X#else /* ASCII */
- X while (*++p) {
- X if (*p < 32) { /* ASCII control character */
- X *q++ = '^';
- X *q++ = *p + 64;
- X } else
- X *q++ = *p;
- X } /* filename better not be longer than slide[] ... */
- X *q = '\0';
- X PRINTF("%s\n", slide);
- X#endif /* ?NATIVE */
- X
- X} /* end function fnprint() */
- END_OF_FILE
- if test 64797 -ne `wc -c <'unzip-5.12/zipinfo.c'`; then
- echo shar: \"'unzip-5.12/zipinfo.c'\" unpacked with wrong size!
- fi
- # end of 'unzip-5.12/zipinfo.c'
- fi
- echo shar: End of archive 4 \(of 20\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-