This commit is contained in:
Apple 2016-02-18 23:23:08 +01:00 committed by Lubos Dolezel
commit 1e61b20f59
742 changed files with 254823 additions and 0 deletions

50
Makefile Normal file
View File

@ -0,0 +1,50 @@
##
# Top-level wrapper Makefile for zip and unzip tools
##
PROJECT=zip
COMPONENTS=zip unzip
SRCROOT=$(shell pwd)
OBJROOT?=/tmp/$(PROJECT).obj
SYMROOT?=/tmp/$(PROJECT).sym
DSTROOT?=/tmp/$(PROJECT).dst
OSVERSIONS = /usr/local/OpenSourceVersions
.PHONY: installsrc install clean installhdrs builddirs
ifndef CoreOSMakefiles
CoreOSMakefiles = $(MAKEFILEPATH)/CoreOS
endif
include $(CoreOSMakefiles)/Standard/Standard.make
all: install
installsrc:
$(MKDIR) $(SRCROOT)
$(PAX) -rw . $(SRCROOT)
install installhdrs:: $(OBJROOT) $(SYMROOT) $(DSTROOT)
install:: builddirs ossinfo
install clean installhdrs::
for proj in $(COMPONENTS) ; do \
( cd $${proj} && $(MAKE) $@ $(MAKEFLAGS) SRCROOT=$(SRCROOT)/$${proj} \
OBJROOT=$(OBJROOT)/$${proj} SYMROOT=$(SYMROOT)/$${proj} \
DSTROOT=$(DSTROOT) ) || exit 1; \
done
$(OBJROOT) $(SYMROOT) $(DSTROOT):
$(_v) $(MKDIR) $@
builddirs: $(OBJROOT) $(SYMROOT)
for proj in $(COMPONENTS) ; do \
$(MKDIR) $(OBJROOT)/$${proj}; \
$(MKDIR) $(SYMROOT)/$${proj}; \
done
ossinfo: builddirs
$(MKDIR) $(DSTROOT)/$(OSVERSIONS)
$(INSTALL_FILE) $(SRCROOT)/$(PROJECT).plist $(DSTROOT)/$(OSVERSIONS)/$(PROJECT).plist

19
README Normal file
View File

@ -0,0 +1,19 @@
This is the "zip" project, which comprises both zip(1) and unzip(1),
and associated tools. The canonical home page for these tools are:
Zip: <http://www.info-zip.org/Zip.html>
UnZip: <http://www.info-zip.org/UnZip.html>
Currently, this project tracks:
Zip 2.32 (released 20 June 2005)
UnZip 5.52 (released 27 February 2005)
Imports should commit the new tarball, and change the makefiles
as appropriate.
Local modifications should be implemented as patches applied during build.
Shantonu Sen
ssen@apple.com
October 5, 2006

55
unzip/Makefile Normal file
View File

@ -0,0 +1,55 @@
PROJECT = unzip
VERSION = 5.52
DISTFILE = $(PROJECT)$(shell echo $(VERSION) | tr -d '.').tar.gz
OSLICENSES = /usr/local/OpenSourceLicenses
PATCHFILES = patch-unix_unix.c patch-quarantine patch-CVE-2008-0888 \
unzip-6.0_overflow2.diff patch-list.c
SRCROOT ?= $(shell pwd)
OBJROOT ?= $(SRCROOT)/obj
SYMROOT ?= $(SRCROOT)/sym
DSTROOT ?= $(SRCROOT)/dst
ifndef CoreOSMakefiles
CoreOSMakefiles = $(MAKEFILEPATH)/CoreOS
endif
include $(MAKEFILEPATH)/CoreOS/Standard/Standard.make
all: install
installhdrs:
clean:
rm -rf $(SYMROOT) $(OBJROOT)
install: destroot symbols ossinfo
installsrc:
pax -rw . $(SRCROOT)
destroot: patchsrc unpacksrc
$(MAKE) -C $(OBJROOT)/$(PROJECT)-$(VERSION) \
-f unix/Makefile macosx install \
prefix=$(DSTROOT)/usr \
MANDIR=$(DSTROOT)/usr/share/man/'man$$(manext)' \
LOC="$(CFLAGS) $(RC_CFLAGS)" LD="$(CC) $(RC_CFLAGS)" \
CC="$(CC)" INSTALL="$(INSTALL)" DESTDIR=$(DSTROOT) STRIP="echo"
symbols:
$(CP) $(OBJROOT)/$(PROJECT)-$(VERSION)/unzip $(SYMROOT)
$(DSYMUTIL) $(SYMROOT)/unzip
ossinfo: unpacksrc
$(MKDIR) $(DSTROOT)/$(OSLICENSES)
$(INSTALL_FILE) $(OBJROOT)/$(PROJECT)-$(VERSION)/LICENSE $(DSTROOT)/$(OSLICENSES)/$(PROJECT).txt
unpacksrc:
mkdir -p $(OBJROOT)
tar zxvf $(SRCROOT)/$(DISTFILE) -C $(OBJROOT)
patchsrc: unpacksrc
for p in $(PATCHFILES); do \
patch -d $(OBJROOT)/$(PROJECT)-$(VERSION) -f -p0 --posix < $(SRCROOT)/$${p} || exit 1; \
done

42
unzip/patch-CVE-2008-0888 Normal file
View File

@ -0,0 +1,42 @@
diff -up inflate.c.pom inflate.c
--- inflate.c.pom 2005-02-27 07:08:46.000000000 +0100
+++ inflate.c 2008-03-19 14:47:58.000000000 +0100
@@ -983,6 +983,7 @@ static int inflate_dynamic(__G)
unsigned l; /* last length */
unsigned m; /* mask for bit lengths table */
unsigned n; /* number of lengths to get */
+ struct huft *tlp;
struct huft *tl; /* literal/length code table */
struct huft *td; /* distance code table */
unsigned bl; /* lookup bits for tl */
@@ -995,6 +996,7 @@ static int inflate_dynamic(__G)
register unsigned k; /* number of bits in bit buffer */
int retval = 0; /* error code returned: initialized to "no error" */
+ td = tlp = tl = (struct huft *)NULL;
/* make local bit buffer */
Trace((stderr, "\ndynamic block"));
@@ -1047,9 +1049,9 @@ static int inflate_dynamic(__G)
while (i < n)
{
NEEDBITS(bl)
- j = (td = tl + ((unsigned)b & m))->b;
+ j = (tlp = tl + ((unsigned)b & m))->b;
DUMPBITS(j)
- j = td->v.n;
+ j = tlp->v.n;
if (j < 16) /* length of code in bits (0..15) */
ll[i++] = l = j; /* save last length in l */
else if (j == 16) /* repeat last length 3 to 6 times */
@@ -1149,8 +1151,8 @@ static int inflate_dynamic(__G)
cleanup_and_exit:
/* free the decoding tables, return */
- huft_free(tl);
- huft_free(td);
+ if (tl) huft_free(tl);
+ if (td) huft_free(td);
return retval;
}

11
unzip/patch-list.c Normal file
View File

@ -0,0 +1,11 @@
--- list.c 2014-11-17 19:09:21.000000000 -0800
+++ list.c 2014-11-17 19:08:51.000000000 -0800
@@ -327,7 +327,7 @@ int list_files(__G) /* return PK-type
if (methnum == DEFLATED || methnum == ENHDEFLATED) {
methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
} else if (methnum >= NUM_METHODS) {
- sprintf(&methbuf[4], "%03u", G.crec.compression_method);
+ snprintf(&methbuf[4], sizeof(methbuf)-4, "%03u", G.crec.compression_method);
}
#if 0 /* GRR/Euro: add this? */

70
unzip/patch-quarantine Normal file
View File

@ -0,0 +1,70 @@
diff -ru unzip-5.52/unix/unix.c unzip-5.52.new/unix/unix.c
--- unix/unix.c.orig 2005-02-26 11:43:42.000000000 -0800
+++ unix/unix.c 2012-06-30 00:09:07.000000000 -0700
@@ -71,6 +71,8 @@
# endif
#endif /* ?DIRENT */
+#include <quarantine.h>
+
#ifdef SET_DIR_ATTRIB
typedef struct uxdirattr { /* struct for holding unix style directory */
struct uxdirattr *next; /* info until can be sorted and set at end */
@@ -685,6 +687,23 @@
/* Function checkdir() */
/***********************/
+static int
+mkdir_qtn(int zipfd, const char *path, int mode)
+{
+ int r = mkdir(path, mode);
+
+ if (r != 0 && errno != EEXIST)
+ return r;
+
+ qtn_file_t qf = qtn_file_alloc();
+ if (qf != NULL) {
+ if (qtn_file_init_with_fd(qf, zipfd) == 0) {
+ (void)qtn_file_apply_to_path(qf, path);
+ }
+ qtn_file_free(qf);
+ }
+}
+
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
@@ -751,7 +770,7 @@
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
- if (mkdir(G.buildpath, 0777) == -1) { /* create the directory */
+ if (mkdir_qtn(G.zipfd, G.buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: cannot create %s\n\
unable to process %s.\n",
@@ -897,7 +916,7 @@
}
/* create the directory (could add loop here scanning tmproot
* to create more than one level, but why really necessary?) */
- if (mkdir(tmproot, 0777) == -1) {
+ if (mkdir_qtn(G.zipfd, tmproot, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: cannot create extraction directory: %s\n",
FnFilter1(tmproot)));
@@ -1042,6 +1061,14 @@
ush z_uidgid[2];
int have_uidgid_flg;
+ qtn_file_t qf = qtn_file_alloc();
+ if (qf != NULL) {
+ if (qtn_file_init_with_fd(qf, G.zipfd) == 0) {
+ (void)qtn_file_apply_to_fd(qf, fileno(G.outfile));
+ }
+ qtn_file_free(qf);
+ }
+
fclose(G.outfile);
/*---------------------------------------------------------------------------
Only in unzip-5.52.new/unix: unix.c.orig

36
unzip/patch-unix_unix.c Normal file
View File

@ -0,0 +1,36 @@
--- unix/unix.c.orig Sat Feb 26 16:43:42 2005
+++ unix/unix.c Fri Sep 9 14:36:35 2005
@@ -1042,6 +1042,16 @@
ush z_uidgid[2];
int have_uidgid_flg;
+/*---------------------------------------------------------------------------
+ Change the file permissions from default ones to those stored in the
+ zipfile.
+ ---------------------------------------------------------------------------*/
+
+#ifndef NO_CHMOD
+ if (fchmod(fileno(G.outfile), 0xffff & G.pInfo->file_attr))
+ perror("chmod (file attributes) error");
+#endif
+
fclose(G.outfile);
/*---------------------------------------------------------------------------
@@ -1150,16 +1160,6 @@
" (warning) cannot set times"));
#endif /* ?AOS_VS */
}
-
-/*---------------------------------------------------------------------------
- Change the file permissions from default ones to those stored in the
- zipfile.
- ---------------------------------------------------------------------------*/
-
-#ifndef NO_CHMOD
- if (chmod(G.filename, filtattr(__G__ G.pInfo->file_attr)))
- perror("chmod (file attributes) error");
-#endif
} /* end function close_outfile() */

80
unzip/unzip-5.52/BUGS Normal file
View File

@ -0,0 +1,80 @@
Bogus bugs (not our fault!):
---------------------------
By far THE BIGGEST source of bug reports to Info-ZIP/zip-bugs is the
incorrect transfer of zipfiles (or of the UnZip executable itself).
ALWAYS TRANSFER IN BINARY MODE! This includes ftp transfers and *both*
ends of a Kermit connection ("set file type binary"). If your copy
isn't exactly the same size as the original, you made a mistake.
Another common source of errors such as "compression method 8 not sup-
ported" is the existence of an old version of UnZip somewhere in your
path. Make sure you're using the version you think you're using; give
the full path explicitly if necessary. Executing "unzip" without any
options will print a help screen, at the top of which is the UnZip
version number and release date; and executing "unzip -v" without any
zipfile or other options will give information about what compiler was
used, the target operating system, any special UnZip options, and the
date of compilation--only for version 5.11 and later, though! (Also,
under Unix C shell and some Bourne shells, "which unzip" will print
the path of the unzip you're actually using. Under OS/2 and MS-DOS,
whch21gr.zip [on Simtel mirror sites] will do the same thing; in addi-
tion, "which -a unzip" will show *all* copies of "unzip" in your path.)
Bugs (real and/or imagined):
---------------------------
- [OS/2 DLL] when trying to use the REXX function UzUnZipToStem to extract a
file with `&' in its name, the DLL crashes (but UzUnZipToVar still works)
[Daniel H, 961215]
- UnZip has problems with archives bigger than 2GB; it may print "note: didn't
find end-of-central-dir signature at end of central dir" (harmless) or
may not be able to seek to member files [James Lemley 970107, Iris Spaniol
970206, ...]
- fix overwrite behavior: hidden/system problems?; etc.
- 32-bit DOS UnZip still unable to set volume labels?
- 32-bit DOS UnZip under OS/2 doesn't extract all wildcard zipfiles?
[DOS box: unzip386 (ver 5.12) x:\32bit\unix\emx09a\*.zip, Hobbes 3/95]
- 32-bit DOS UnZip under OS/2 doesn't set timestamp when overwriting files
on HPFS partition? (go32 and pmode/w both; emx/rsx OK) [Eberhard Mattes
950726]
- USE_FWRITE still causes occasional CRC errors when extracting on Pyramid?
[Kevin Fritz 931102]
- still NT/W95 bug with "unzip -v d:*.zip" not matching properly? [Steve S
940527]
980427: bug no longer exists, Opendir() must have been corrected by someone
- when ^Z received in no-echo mode, echo is not restored (works OK if
resume, however)
- signal() handler disabled after first use with one of BSD/SysV?
- MKS Korn shell: unzip assumes the MKS-style command-line environment
options are relevant to it, but this is not the case if unzip was called
by another program (e.g., from a .BAT file). A fix for this exists for
Borland compilers but not for MSC, Watcom, djgpp, etc.
- OS/2: for paths with one long component, the .LONGNAME EA may be saved for
all components (waste of disk space): how to check??
- VMS: for extracting to other directories, only the VMS-style "-d [.foo]"
format is accepted; "-d foo" should also be allowed. Long filenames are
not automatically truncated to 39.39.
- Novell Netware: Netware drives may clear the archive bit on extracted
files under OS/2 and/or MS-DOS. UnZip always *tries* to set the archive
bit, however. [pynq@uchicago, 940527]
- DEC Ultrix: on long zipfiles, unzip will sometimes fail (bad CRC, not always
reproducible); this is apparently due either to a hardware bug (cache mem)
or OS bug (page faults?) [Igor, Jean-loup, bottom of BUGS.long]
- funzip/more/decryption/no-echo bug: race condition(?) causes terminal to
be "reset" to no-echo state
- Macintosh (100200), Atari (020000) external file attributes not interpreted
correctly (both unzip and zipinfo)
- pkbug error: zipfile with incorrect csize and/or ucsize--check for end of
compressed (csize) data in uncompression routines:
unreduce.c: while (((outpos + outcnt) < ucsize) && (!zipeof)) {
[James Birdsall, Mark, bottom of BUGS.long]
- OS/2: directory EAs not restored if directory exists [Kai Uwe, KG27515@uark]
(subsequent note: no way to determine which EAs are newer ==> cannot
restore without user input)
(update: as of UnZip 5.30, option -o forces restoring of directory EAs)
- MS-DOS: Borland executables don't allow other than 80-column, 25/43/50-line
screen modes (Borland bug) [Michael Stillwell]

View File

@ -0,0 +1,212 @@
__________________________________________________________________________
This is the Info-ZIP file COPYING (for UnZip), last updated 17 Jul 2000.
__________________________________________________________________________
FIRST NOTE:
This file contains some details about the copyright history of
contributions to the UnZip project.
Additionally, it summarises some exceptions to the general BSD-like
copyright found in LICENSE that covers our generic code and most of
the system specific ports.
Please read LICENSE first to find out what is allowed to do with
Info-ZIP's UnZip code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are currently two explicit copyrights on portions of UnZip
code (at least, of which Info-ZIP is aware):
Jim Luther's Mac OS File Manager interface code; and Christopher Evans'
MacBinaryIII coding code (for the MacOS port).. These copyrights
are discussed in more detail below.
All remaining code is now (starting with UnZip version 5.41) covered
by the new Info-ZIP license. For details, please read the acompaning
file LICENSE. The terms and conditions in this license supersede the
copyright conditions of the contributions by Igor Mandrichenko
(vms/vms.c), Greg Roelofs (zipinfo.c, new version of unshrink.c),
Mike White (Windows DLL code in "windll/*"), Steve P. Miller (Pocket
UnZip GUI "wince/*"), and Mark Adler (inflate/explode decompresseion
core routines, previously put into the public domain). All these
Info-ZIP contributors (or "primary" authors) have permitted us to
replace their copyright notes by the Info-ZIP License.
Frequently Asked Questions regarding (re)distribution of Zip and UnZip
are near the end of this file.
There are no known patents on any of the code in UnZip. Unisys
claims a patent on LZW encoding and on LZW decoding _in an apparatus
that performs LZW encoding_, but the patent appears to exempt a stand-
alone decoder (as in UnZip's unshrink.c). Unisys has publicly claimed
otherwise, but the issue has never been tested in court. Since this
point is unclear, unshrinking is not enabled by default. It is the
responsibility of the user to make his or her peace with Unisys and
its licensing requirements. (unshrink.c may be removed from future
releases altogether.)
__________________________________________________________________________
The original unzip source code has been extensively modified and
almost entirely rewritten (changes include random zipfile access
rather than sequential; replacement of unimplode() with explode();
replacement of old unshrink() with new (unrelated) unshrink(); re-
placement of output routines; addition of inflate(), wildcards,
filename-mapping, text translation, ...; etc.). As far as we can
tell, only the core code of the unreduce method remained substantially
similar to Mr. Smith's original source. As of UnZip 5.42, the complete
core code is now covered by the Info-ZIP Licence. Therefore, support
for the reduce method has been removed.
The drop of the reduce method should only affect some test archives,
reducing was never used in any publically distributed Zip program.
For pathologic cases where support for reduced archive entries is
needed, the unreduce code copyrighted by Samuel H. Smith is available
as a separate distribution (the restricted copyright of this code is
cited below in the "historical" section).
The following copyright applies to the Mac OS File Manager interface code
(macos/source/macstuff.[ch]), distributed with UnZip 5.4 and later:
* MoreFiles
*
* A collection of File Manager and related routines
*
* by Jim Luther (Apple Macintosh Developer Technical Support Emeritus)
* with significant code contributions by Nitin Ganatra
* (Apple Macintosh Developer Technical Support Emeritus)
* Copyright 1992-1998 Apple Computer, Inc.
* Portions copyright 1995 Jim Luther
* All rights reserved.
* The Package "More Files" is distributed under the following
* license terms:
*
* "You may incorporate this sample code into your
* applications without restriction, though the
* sample code has been provided "AS IS" and the
* responsibility for its operation is 100% yours.
* However, what you are not permitted to do is to
* redistribute the source as "DSC Sample Code" after
* having made changes. If you're going to
* redistribute the source, we require that you make
* it clear in the source that the code was descended
* from Apple Sample Code, but that you've made
* changes."
The usage terms of this copyright note are compatible with the
Info-ZIP license, they do not add further restrictions.
The following copyright applies to the Mac OS "macbin3" decoding code
(extra field compatibility with ZipIt):
* MacBinaryIII.h
*
* Copyright 1997 Christopher Evans (cevans@poppybank.com)
*
* Basic encoding and decoding of Macintosh files to the
* MacBinary III spec.
* ----------------------------------------------------------------------
* This source is copyrighted by Christopher Evans (cevans@poppybank.com)
* (available at ftp://ftp.lazerware.com/MacBinaryIII_src_C.sit
* homepage of Leonard Rosenthol leonardr@netcom.com)
This copyright note does not contain any usage terms. So, we assume
that this code is freely reusable until we are proved wrong...
--------------------------------------------------------------------------
The remaining copyright notes have been superseeded by the new
Info-ZIP license, with explicit permission from the respective
original authors. They are cited here for historical reasons,
only:
The following copyright applies to the full-featured unreduce.c
(now distributed separately):
* Copyright 1989 Samuel H. Smith; All rights reserved
*
* Do not distribute modified versions without my permission.
* Do not remove or alter this notice or any other copyright notice.
* If you use this in your own program you must distribute source code.
* Do not use any of this in a commercial product.
Regarding the first stipulation, Mr. Smith was tracked down in southern
California some years back [Samuel H. Smith, The Tool Shop; as of mid-
May 1994, (213) 851-9969 (voice), (213) 887-2127(?) (subscription BBS),
71150.2731@compuserve.com]:
"He says that he thought that whoever contacted him understood that
he has no objection to the Info-ZIP group's inclusion of his code.
His primary concern is that it remain freely distributable, he said."
Despite the fact that our "normal" code has been entirely rewritten
and by default no longer contains any of Mr. Smith's code, Info-ZIP
remains indebted and grateful to him. We hope he finds our contribu-
tions as useful as we have his.
Note that the third and fourth stipulations still apply to any com-
pany that wishes to incorporate the unreduce code into its products;
if you wish to do so, you must contact Mr. Smith directly regarding
licensing.
-----
The following copyright applied to most of the VMS code in vms.c,
distributed with UnZip version 4.2 and later:
* Copyright (c) 1992-93 Igor Mandrichenko.
* Permission is granted to any individual or institution to use, copy,
* or redistribute this software so long as all of the original files
* are included unmodified and that this copyright notice is retained.
-----
The following copyright applied to the new version of unshrink.c,
distributed with UnZip version 5.2 and later:
* Copyright (c) 1994 Greg Roelofs.
* Permission is granted to any individual/institution/corporate
* entity to use, copy, redistribute or modify this software for
* any purpose whatsoever, subject to the conditions noted in the
* Frequently Asked Questions section below, plus one additional
* condition: namely, that my name not be removed from the source
* code. (Other names may, of course, be added as modifications
* are made.) Corporate legal staff (like at IBM :-) ) who have
* problems understanding this can contact me through Zip-Bugs...
-----
The following copyright applied to the Windows DLL code (windll/*),
distributed with UnZip version 5.2 and later:
* Copyright (c) 1996 Mike White.
* Permission is granted to any individual or institution to use,
* copy, or redistribute this software so long as all of the original
* files are included, that it is not sold for profit, and that this
* copyright notice is retained.
-----
The following copyright applied to the Windows CE GUI port, ``Pocket
UnZip,'' distributed with UnZip version 5.3 and later:
* All the source files for Pocket UnZip, except for components
* written by the Info-ZIP group, are copyrighted 1997 by Steve P.
* Miller. The product "Pocket UnZip" itself is property of the
* author and cannot be altered in any way without written consent
* from Steve P. Miller.
-----
The remaining code was written by many people associated with the
Info-ZIP group, with large contributions from (but not limited to):
Greg Roelofs (overall program logic, ZipInfo, unshrink, filename
mapping/portability, etc.), Mark Adler (inflate, explode, funzip),
Kai Uwe Rommel (OS/2), John Bush and Paul Kienitz (Amiga), Antoine
Verheijen (Macintosh), Hunter Goatley (more VMS), Mike White (Windows
DLLs), Christian Spieler (overall logic, optimization, VMS, etc.) and
others. See the file CONTRIBS in the source distribution for a much
more complete list of contributors.
The decompression core code for the deflate method (inflate.[ch],
explode.c) was originally written by Mark Adler who submitted it
as public domain code.
--------------------------------------------------------------------------

84
unzip/unzip-5.52/Contents Normal file
View File

@ -0,0 +1,84 @@
Contents of the UnZip 5.52 source archive. The OS-specific subdirectories
at the end contain their own Contents listings:
Contents this file
README what UnZip is; general information
LICENSE Info-ZIP license; terms for using and distributing UnZip
COPYING.OLD historic copyrights and distribution policy (obsolete)
INSTALL how to compile and install UnZip and related utilities
WHERE where Zip/UnZip and encryption/decryption support can be found
History.550 new features and fixes of the last major release
History.551 new features and fixes in this maintenance release
ToDo rough priority list of new features to be added in next release
BUGS known bugs, problems, and (possible) other features to be added
unzip.txt UnZip manual page, human-readable format
unzipsfx.txt UnZipSFX manual page, human-readable format
zipinfo.txt ZipInfo manual page, human-readable format
zipgrep.txt ZipGrep manual page, human-readable format
funzip.txt fUnZip manual page, human-readable format
file_id.diz BBS-oriented file describing this archive
testmake.zip test archive for checking whether newly compiled UnZip works
api.c generic DLL entry points, support functions (required for DLLs)
apihelp.c API help text for DLL versions (currently OS/2 only)
consts.h global, initialized variables that never change (required)
crc32.c code for calculation 32bit CRC of a string buffer (required*)
crc_i386.S fast assembler replacement for crc32.c (Intel 386 and newer)
crctab.c supplies polynomial table for CRC calculation
crypt.c de-/encryption routines (required*)
crypt.h de-/encryption header file (required*)
ebcdic.h static lookup table for ASCII <-> EBCDIC translation (required)
envargs.c code to read options from environment variables (required)
explode.c code for exploding (required)
extract.c high-level extraction and decryption code (required)
fileio.c file manipulation and password code (required)
funzip.c filter unzip: extracts in a pipe from stdin to stdout
gbloffs.c helper program to retrieve offsets of globals struct members
globals.c code to support global variables with reentrancy (required)
globals.h definition of global structure G (required)
inflate.c code for inflating (required*)
inflate.h header file for inflating (required*)
list.c UnZip listing routines, non-ZipInfo mode (required)
match.c pattern-matching code for filename wildcards (required)
process.c zipfile headers code (required)
tables.h static lookup tables used in fileio.c and funzip.c (required*)
timezone.c timezone and timestamp functions (required)
timezone.h header file for interface to "internal" tz functions (required)
ttyio.c code for handling nonecho tty input: password, pager (required)
ttyio.h header file for nonecho tty input: password, pager (required)
unreduce.c code for unreducing (required)
unshrink.c code for unshrinking (required)
unzip.c UnZip main(), usage and options code (required)
unzip.h public half of main UnZip header file (required*)
unzipstb.c minimal UnZip "stub" file demonstrating use of DLL versions
unzpriv.h private (internal) half of main UnZip header file (required*)
unzvers.h header with UnZip/UnZipSFX and ZipInfo version info (required)
zip.h dummy header for use with crypt.c (required*)
zipinfo.c UnZip listing routines, ZipInfo mode (required)
acorn/ support files for compiling under Acorn RISC OS
amiga/ support files for compiling under AmigaDOS
aosvs/ support files for compiling under Data General AOS/VS
atari/ support files for compiling under Atari TOS
atheos/ support files for compiling under AtheOS/Syllable
beos/ support files for compiling under BeOS
cmsmvs/ support files for compiling under VM/CMS and MVS
flexos/ support files for compiling under FlexOS
human68k/ support files for compiling under X68000/Human68K
macos/ support files for compiling under Macintosh OS
msdos/ support files for compiling under MS-DOS
novell/ support files for compiling for Novell Netware NLM
os2/ support files for compiling under OS/2 (includes DLL stuff)
qdos/ support files for compiling under SMS/QDOS
tandem/ support files for compiling under Tandem NSK
theos/ support files for compiling under Theos
tops20/ support files for compiling under TOPS-20
unix/ support files for compiling under Unix
vms/ support files for compiling under VMS
win32/ support files for compiling under Windows 9x and Windows NT
wince/ support files for compiling under Windows CE (GUI version)
windll/ support files for compiling Windows 3.x/9x/NT DLLs
man/ nroff man-page sources for the main user documentation
proginfo/ programming docs, additional technical info, contributor list
Files marked "required*" are also needed to compile fUnZip. The normal
UnZip makefile targets now make both UnZipSFX and fUnZip, except in a few
cases; ZipInfo is now incorporated into UnZip (see zipinfo.txt for usage).

View File

@ -0,0 +1,273 @@
UnZip, version 5.5, 17 February 2002
Features added (or removed):
5.5a (04 Feb 01):
- unzip.1: added documentation for the new Acorn NFS filetype features [SPC]
- generic (inflate.c, globals.h, fileio.c, unzpriv.h): integrated support of
Deflate64 for all ports with exception of MSDOS and OS/2 16-bit [SPC]
5.5b (11 Feb 01):
- added Deflate64 support to fUnZip [SPC]
- added Deflate64 support for 16-bit environments [SPC]
5.5c (18 Apr 01):
- SFX: made SFX_EXDIR default, added NO_SFXEXDIR option to allow switching
off the "-d exdir" support [SPC]
- OS2, WIN32: added presetting of file size for extracted files, to reduce
file fragmentation [Pavel Lastovicka, Kai Uwe Rommel, SPC]
- VMS, new functionality of -b option: when extracting to standard output
(-c or -p), -b switches to "binary piping mode" by disabling text data
conversion [SPC]
5.5d (28 Apr 01):
- SFX: added simple "execute command after extraction" feature that uses a
command specification supplied with the Zip archive comment, controlled
by the CHEAP_SFX_AUTORUN compile time option [Paul Kienitz]
- SFX: slightly refined the CHEAP_SFX_AUTORUN code, switched off SFX_EXDIR
when CHEAP_SFX_AUTORUN is enabled, documented the new autorun feature [SPC]
- VMS: extended new "binary piping" functionality of -b switch to extraction
of archive entries with VMS attributes saved [SPC]
5.5f (30 Sep 01):
- extract.c, TestExtraField(): added crc32 check for PKVMS e.f. type [SPC]
- added real VMS-e.f. analysis for fool-proof detection of VMS "variable
length record" text files, enabled VMS_TEXT_CONV as default (but not for
SFX stub) [SPC]
- added support for optional ACORN_FTYPE_NFS feature to more OS that allow
long filenames and commas within filenames (BeOS, Novell, OS/2, Theos,
Win32) [SPC]
5.5g (05 Nov 01):
- extract.c, extract_or_test_entrylist(): added code for "stripping off
absolute path spec" when extracting [SPC]
5.5h (12 Jan 02):
- unzip.h, unzip.c; mapname() in all ports except CMS/MVS, Tandem, TOPS20:
added code to strip "../" path components from extracted names and new
option "-:" to allow deactivating this security feature; changed mapname()
calling interface to allow reporting warning error levels to caller [SPC]
- man/unzip.1: documented the new "-:" option [SPC]
- vms/cmdline.c etc.: added support for "-:" option to VMS DCL interface;
updated VMS help files with description of "-:" option [SPC]
- windll/windll.{c|txt}: modified handling of DCL struct's "ndflag" member
to allow setting the "-:" option through the windll interface [SPC]
- unzpriv.h, zipinfo.c: rudimentary support for recognizing PKWARE's new
"64-bit size specs" extra field [SPC]
5.5 (17 Feb 02):
- unix/Makefile: added separate makefile symbol INSTALL_PROGRAM for command
to install "binary" (compiled and linked) program files [Santiago Vila]
Bugs fixed:
5.5a (04 Feb 01):
- all OS with Unix-compatible file attributes (Acorn, AosVS, BeOS, QDOS, Unix,
and others), mapattr(): corrected wrong masking expression in check for
missing directory attribute; added this check for ports where it was
still missing [Eric Siegerman, SPC]
- inflate.c: reorganized inner loop function for slight performance gain [SPC]
- explode.c: reorganized code (2 instead of 4 inner-loop function versions),
fixed memory leaks when get_tree() fails (added huft_free() calls) [SPC]
5.5b (11 Feb 01):
- inflate.c: some more optimizations (also resulting in easier readable code)
[SPC]
- unzip.c: revised work area size calculation in the WORK_MALLOC case, when
the decompression buffer is malloc'ed separately; removed suspicious
"one unit excess" allocation (8193 instead of 8192, not clear why this
was introduced in ancient times) [SPC]
- VMS - cvthelp.tpu, unzip_cli.help: reformatted CLI help file to show negated
form of negatable options on a separate line in the header of qualifier
descriptions [Hunter Goatley]
- generic: renamed version.h into unzvers.h (for better distinction from zip
sources) and updated all makefiles [SPC]
- windll: changed windll.rc to get version info directly from unzvers.h and
killed windll/unzver.h [SPC]
- api.c, global.h, extract.c, explode.c, inflate.c, unshrink.c: corrected
declarations of variables and function parameters holding redirected buffer
size (unsigned vs. ulg issues), added/modified appropiate type casts [SPC]
5.5c (18 Apr 01):
- most make procedures: unzipsfx compilation requires completely separate
object files (exception: crc32), because global structure is now different
from unzip setup (sfx: no Deflate64!) [Thom Schmidt, SPC]
- inflate.c: moved macro definitions for invalid huft code marker out of
"no ZLIB only" code part; it is used in huft_build() [Thomas Klausner]
- AMIGA, HUMAN68K: replaced specific mkGoff.c helper program sources by a more
generic gbloffs.c source (located in the top level directory); adapted
makefiles to this change [SPC]
- win32/win32: modified version() to recognize Borland C++ 5.5.1 [SPC]
- AMIGA: adapted assembler core routine flate.a to Deflate64 and the 64k
extraction buffer; adapted inflate setup to allow for 16bit ints in
an otherwise 32-bit environment [Paul Kienitz]
- human68k/flate.s: incorporated Paul's updates of amiga/flate.a in the
HUMAN68K source variant [SPC]
- MacOS: updates from MacZip release 1.07b [Dirk Haase]
- unzpriv.h: updated exceptions of "made by FAT -> filename charset is OEM"
rule to now include the PKZIP 4.0 case [SPC]
- unzpriv.h, extract.c zipinfo.c: in preparation to multivolume support,
struct min_info has been extended to hold the entry's disk volume number
(to conserve space, hostnum & hostver members are shortened to uch) [SPC]
- extract.c, extract_or_test_files() function: isolated code of "second loop"
in a separate function, in preparation for multivolume support [SPC]
- os2/os2.c: use posix-style mkdir definition whenever __GNUC__ is defined,
for better compatibility with non-EMX gcc ports [Pavel Lastovicka, SPC]
- windll/windll.c: added missing SETLOCALE() initialization to Wiz_Init()
[Kevin Cheng]
- WINDLL port: in windll.c, changed FreeDllMem() scope into static; tried
to clarify in windll.txt that Wiz_SetOpts() and Wiz_Unzip() must be
used as a pair of functions [SPC]
- VMS: removed unused and undocumented /TYPE switch from CLI interface [SPC]
5.5d (28 Apr 01):
- unix/Makefile: correction for LynxOS target [Mark Clayton]
- extract.c: synchronized extract_or_test_entrylist() prototype declaration
for the SET_DIR_ATTRIB case with actually used function interface [SPC]
- vms/descrip.mms: corrected typo in match_$O rule [Michael Lemke]
- vms/vms.c: limit buffer size for single block output to less than 64k
(RMS limit on VAX); corrected record overflow checks to use the right
RMS limit of (32k-1) [Mike Freeman, SPC]
- unzver.h: renamed COMPANY_NAME symbol to IZ_COMPANY_NAME, check for
symbol being already defined; restrict definition of OS/2-DLL specific
version symbols to OS/2 port [Mike White, SPC]
- windll/uzexampl.c: corrected inclusion path of unzver.h [Mike White]
- acorn/GMakefile: need NO_STRNICMP, fixed missing renaming of version.h
into unzvers.h [Andy Wingate]
- vms/vms.c: fixed long standing bug BUFS512 expression - clipping to a
multiple of 512 is achieved by ANDing with ~511 instead of ~512 [SPC]
5.5e (29 Apr 01):
- vms/vms.c: added missing -c handling in WriteBuffer() to make the "-b"
binary piping mode functional [SPC]
5.5f (30 Sep 01):
- OS2, WIN32: reenable -X "restore ACLs" option (has been broken since
version 5.42 due to incomplete change by SPC [Michael Ringe, SPC]
- moved IZVMS specific e.f. decompression from vms/vms.c into extract.c, this
functionality is now needed for generic VMS_TEXT_CONV feature [SPC]
- zipinfo.c: fixed 16-bit specific bug in verbose IZVMS e.f. report [SPC]
- unix/unxcfg.h: fixed setup for GNU/Hurd [Marcus Brinkmann]
- tandem/tandem.c: fixed copy&paste typo in stat() [<YuZH@spdb.com.cn>]
- vms/cmdline.c: verbatim '%' signs in format specification strings are
"escaped" by doubling them, to prevent compiler warnings for newest
DEC (COMPAQ) C versions [Dirk Munk, SPC]
- tandem/tanunz.c, tandem/tandem.[ch], fileio.c: created Tandem-specific
version of open_outfile(), moved UNZIP part of zipopen() code into this
function [SPC]
- generic: added ZCONST attributes to several function string pointer
parameters when the function does not modify the string contents [SPC]
- Contents, README, INSTALL, ToDo, WHERE: documentation updates [SPC]
5.5g (05 Nov 01):
- win32/Makefile.bc: completed support for guisfx stub and static lib [SPC]
- vms/vms.c: in find_vms_attrs(), fixed IZVMS ef-block parser which has been
broken by changes for 5.5f beta [SPC]
- acorn/acorn.c: fixed missing semicolon in setRISCOSexfield() prototype
declaration [Andy Wingate]
- win32/Makefile.bc: removed -q flag for compatibility with older versions
of Borland C++ Builder [E-Yen Tan]
5.5h (12 Jan 02):
- man/*.1: modified manpages to be more "friendly" to automatic conversion
tools into the OpenSource "DocBook" format [Eric S. Raymond];
tested new manpages and corrected some formatting quirks [SPC]
- extract.c: corrected size mismatches between format specifiers and actual
numeric arguments [SPC]
- msdos/msdos.c: cleanup of token concatenation preprocessor warnings emitted
by GCC 3.02 [SPC]
- process.c: moved definition of symbol SPARKID_2 from acorn/riscos.h into
this file (symbol used by getRISCOSexfield()) [Santiago Vila, SPC]
- unzip.c, unzip() main function, REENTRANT code: fixed signal handler "leak"
by saving previous state of all allocated signal handlers and restoring
them at function exit [Jim Mathies, SPC]
- unzip.h, unzpriv.h: moved "internal" function return codes (IZ_DIR etc.)
into the private main header unzpriv.h [SPC]
- extract.c, fileio.c: extended UNIXBACKUP optional functionality to create
"numbered" backup filenames, fixed behaviour when backup file already
exists (-o option switches off numbered backup files and overwrites the
first backup file when neccessary) [Mauricio Ponzo, SPC]
- unzpriv.h, fileio.c, process.c: changed ZLSEEK macro into a real function
seek_zipf() (located in fileio.c); added check of return code to its
calls; fixed filehandle leak in do_seekable() that occured in case of
ZLSEEK errors [Miki Shapiro, SPC]
- wince/intrface.cpp: added SetFileSize() function to preallocate extraction
file space, as implemented in the win32 port (dummy function for WinCE
native compiles because availability of system service is unknown) [SPC]
- funzip.c: changed skope of err() helper function to "static" [Mark Adler]
5.5i (01 Feb 02):
- acorn/acorn.c: correct dir traversal security fix (Acorn uses '^'as parent
folder reference); update and enhance the special character translations;
static printRISCOSexfield() functions must only be declared when its
definition is active [Darren Salt]
- unzip.h, unzip.c, man/unzip.1: disabled -: option for Acorn [SPC]
- amiga/flate.a, amiga/makefile.azt: modified the way of including gbloffs'
output in the assembler inflate code [Paul Kienitz]
- gbloffs.c: corrected USE_DEFLATE64 symbol name, added missing type cast to
CRYPT symbol handling [Paul Kienitz]
- unix/Makefile: corrected and renamed target(s) for MacOS X [Mark Adler, SPC]
- acorn/makefile: make does not like recursive macro definitions [Darren Salt]
- unreduce.c: indented the #error message directive to hide it from pure
traditional K&R C style preprocessors [Peter Jones, SPC]
- amiga/filedate.c: exclude time handling code from Zip utility compiles
(a Zip change) [Paul Kienitz]
- acorn/GMakeFile: updated machine-specific options, used standard "gcc" as
command driver for linking [Andy Wingate]
- unix/unix.c, mapname(): removed extranous opening parentesis from optional
ACORN_FTYPE_NFS only code [Santiago Vila, SPC]
- acorn/acorn.c: corrected location of the MimeMap module [Darren Salt]
- acorn/riscos.c: fixed problem with readdir() sometimes not detecting end-
of-dir on "RISCOS V4 long directory format" FSs [Darren Salt]
- msdos/makefile.wat, os2/makefile.os2, win32/Makefile.wat: updated the
Watcom C support, checked MSDOS builds, added win32 DLL target [SPC]
5.5j (11 Feb 02):
- acorn/GMakefile, acorn/Contents: made clean target working as expected,
updated and moved version info of gcc used (Andy Wingate)
- tandem/make: added support for switching on/off of CRYPT option [Dave Smith]
- tandem/HISTORY: updated "version of current binaries" info [Dave Smith]
- tandem/tanunz.c, open_outfile(): removed unneeded fopen redefines [SPC]
- tandem/tanunz.c, checkdir(): fixed missing closing ')' of FnFilter2 macro
calls [Dave Smith]
- LICENSE: clarification that unmodified UnZipSFX stub binaries can be
distributed as part of SFX Zip archives without any further documentation
requirements [Christian Spieler, Ian E. Gorman, Greg Roelofs]
5.5 (17 Feb 02):
- inflate.c, explode.c, globals.h, unzpriv.h: changed type of "extra bits"
arrays used to build the decoding huffman trees from "ush" into "uch" for
optimization and adapted corresponding variable types [SPC]
- tandem/tandem.c: small cosmetic changes to catch up with Zip mods [SPC]
- unzpriv.h, tandem/tandem.h: removed Zip-specific settings, implemented the
USE_EF_UT_TIME default setting for both Zip and UnZip in tandem.h, removed
corresponding entry from unzpriv.h [SPC]
- LICENSE: refinement of the SFX stub related insertion [Greg Roelofs]
- windll/windll.rc: updated copyright year [SPC]
- msdos/makefile.dj1, msdos/makefile.dj2: added missing header dependencies,
corrected wrong object list for unzipsfx target (only .dj1) [SPC]
- tandem/tanunz.c, open_outfile(): repaired wrong variable names, added
"upshifting" of filename before executing system calls [Dave Smith]
- unzpriv.h, TANDEM setup: define INT_16BIT symbol when compiling in NON WIDE
mode to get DEFLATE64 option to work [Dave Smith]
- win32/Makefile.wat: finished "$(OBJS)" -> "$(OBJU) conversion [Paul Kienitz]
- win32/w32cfg.h: Watcom C requires IZTZ_DEFINESTDGLOBALS setting when using
the timehandling replacement code from timezone.c [Paul Kienitz]
- README, unzvers.h: removed BETA notes for public release [SPC]
- os2/os2.c, SetFileSize(): 16-bit OS/2 needs fake code here [Kai-Uwe Rommel]
- unzpriv.h: added ZCONST to varmessage() buf arg [Kai-Uwe Rommel, SPC]
- os2/os2.c: added #ifndef FUNZIP sections to allow inclusion of this module
in the object modules list for 16-bit fUnZip targets [SPC]
- os2/makefile.os2: fixed 16-bit targets to include os2f.obj resp. msdosf.obj
in the fUnZip object modules list [SPC]
- fileio.c, do_string(): added typecasts in CHEAP_SFX_AUTORUN option code to
remove signed/unsigned mismatch warnings [Hunter Goatley]
==================
These changes occurred in beta versions 5.5a to 5.5. This list may have
left out some bugfixes and even some features...void where prohibited, your
mileage may vary, etc., etc.
Christian Spieler

View File

@ -0,0 +1,189 @@
UnZip, version 5.51, 22 May 2004
Features added (or removed):
5.51a (09 Mar 02):
- no new features
5.51b (11 Jan 03):
- TANDEM: new -r option to suppress extension merging [Dave Smith]
- WinCE, new port in addition to pUnZip (GUI): command line tool usable for
"batch" processes (not quite finished, needs "makefile" cleanup, tests,
and refinements) [Simon Roberts, SPC]
- SET_DIR_ATTRIB feature code revised and reorganized to allow seamless
adaption to different OS environments; added support for restoring
directory timestamps to the WIN32 port [Kai-Uwe-Rommel, SPC]
5.51c (13 May 03):
- WinCE command line tool integration is (almost) finished: project file is
cleaned up and works with VC-embedded 3.0; port needs testing... [SPC]
5.51d (27 Feb 04):
- Cygwin is recognized as a target in the Unix port
[Charles Wilson, Cosmin Truta, SPC]
- remove support for quoting characters from all ports; this feature was a
security hole [SPC]
5.51e (01 Mar 04):
- Win32 port (list.c, unzpriv.h, win32.c, w32cfg.h): the date in (non-ZipInfo)
listings is displayed using the separator given by the system's locale,
when available [Cosmin Truta]
5.51f (16 Apr 04):
- no new features
5.51 final (22 May 04):
- no new features
Bugs fixed:
5.51a (09 Mar 02):
- process.c: corrected process_zipfiles() message and return code when a
wildcard archive spec matches exactly one "non-ziparchive" file [SPC]
- fileio.c: fixed partflush() "-a" textmode output for 16-bit ports
(was a new bug, introduced in 5.50) [SPC]
- inflate.c: modified CHECK_EOF code to allow "virtual" reading beyond EOF in
NEEDBITS() macro to fix an old but rarely triggered extraction bug [SPC]
- amiga/flate.a, human68k/flate.s: attempted to synchronize with changed
C version [SPC]
- explode.c, inflate.c, globals.h, unzpriv.h: cleaned up some "signed vs.
unsigned" inconsistencies [SPC]
- inflate.c: provided workaround for CHECK_EOF problem when using zlib (send
a fake input byte when seeing error because of "premature" EOF) [SPC]
- unzpriv.h: disabled DEFLATE64 when compiling/linking against zlib [SPC]
- windll/windll_lc.def: added missing file to distribution archive [SPC]
- windll/vb/vbunzip.bas: corrected UZDLLServ callback function - the second
function parameter is the size of the archive entry, not the length of
the message string [SPC]
5.51b (11 Jan 03):
- consts.h, funzip.c, inflate.c, unzpriv.h: changed type of mask_bits[] array
into "unsigned" for better core-loop performance [SPC]
- amiga/flate.a, human68k/flate.s: small correction (optimization) to changes
in 5.51a, removed debugging stuff [Paul Kienitz]
- fileio.c: added display of system error string to error message shown when
open_input_file() fails at the [f]open() function [SPC]
- process.c: slightly generalize summary message when no Zip archive could be
found or opened (file may be present but unaccessible due to locking or
insufficient permission) [Santiago Vila, SPC]
- globals.h: undefine zlib_version macro when compiling against zlib to work
around a naming conflict [SPC]
- unzpriv.h: do not define WILD_STAT_BUG for Borland C on WIN32 [SPC]
- unzip.h, unzpriv.h: added precautions for some WIN32 compiler environments
which also try to appear as UNIX compatible [SPC]
- tandem/tanunz.c bugfix: set file code of generic (non-Tandem) non-text files
to 0 (unstructured) instead of 100 (object file) [Dave Smith]
- win32/win32.c: added recognition for Borland C++ Builder 6.0 to version()
[Brad Clarke]
- tandem/tanunz.c bugfix: set file code of Enscribe files containing text data
to 101 (Edit) [Dave Smith]
- api.c writeToMemory(), fileio.c flush(): Added check for buffer overflow
when extracting to memory and output buffer is different from decompression
work area [Samuel R. Blackburn, SPC]
- tandem configuration bugfix: Deflate64 was incompatible with non-WIDE memory
models; fixed OUTBUFSIZ logic and "unsigned" vs. "size_t" incompatibility
issues [Dave Smith, SPC]
5.51c (13 May 03):
- OS2, WIN32, WinCE: '\\' chars are not allowed in file names, map them to '_'
to prevent misinterpreting them as directory separators [David F, SPC]
- windll, VB example: updated integration of "Open file" common dialog and
added special Readme text to document installation and maintenance issues
of the VB example code [ED, SPC]
- unzpriv.h: enclosed shift op expressions in definitions of MPN_xxx macro
constant with parentheses (for safety) [Cosmin Truta]
- win32/win32.c: fixed bugs in set_direc_attribs(), do not try to set dirtimes
on Win9x systems [Cosmin Truta]
- SET_DIR_ATTRIBS option: changed defer_dir_attribs() function interface to
allow non-error return without deferred direntry data [SPC]
- BeOS, Theos: updated SET_DIR_ATTRIBS code to work with the revised generic
code [SPC]
- WinCE port: revitalized WinCE port code, updated VC project files, added
"VC embedded Tools 3.0" project file [SPC]
- unzip.h: added rule to define UNIX flag for NetBSD [Ray Phillips]
- unix/Makefile: added "-DUNIX" to default CF settings, to get rid of misc
problems concerning auto-detection of a "Unix" environment [SPC]
- LICENSE: include SFXWiz in the exeption clause concerning distribution
of self-extracting archives [Greg Roelofs]
- Amiga, AosVS, Atari, BeOS, FlexOS, Human68K, MacOS, MSDOS, Novell, OS/2,
Unix, Win32, (Theos, WinCE - only code sync, no bug to fix):
fixed hole in directory traversal security code which did not recognize
"../" when path component contained some control character which was
silently skipped ["jelmer", SPC]
5.51d (27 Feb 04):
- unix/unix.c: added recognition for Cygwin, i586 and i686 to version()
[Cosmin Truta]
- unzip.h, unzpriv.h, unix/unzcfg.h: allowed Cygwin to compile as a Unix port
[Charles Wilson, Cosmin Truta, SPC]
- unix/unxcfg.h: added inclusion of <utime.h> for DG/UX to fix setting
of file time-stamps [Dave Lovelace]
- macos/source/macstat.c: corrected size in zeroing instruction of stat buffer
[Yamaga Tomonori]
- extract.c: fixed memory leak in SET_DIR_ATTRIB code in case of premature
exit (disk full or user break), execute deferred tasks for processed
entries in this case [SPC]
- unix/zipgrep: allow grep of filenames with embedded spaces [Greg Roelofs]
- win32: update support for newer Cygwin releases [Cosmin Truta]
- use central directory's entry names for extraction/testing, emit warning for
local/central entry name difference (bug report by Jan Echternach) [SPC]
- all SYMLINKS-capable ports (AOS/VS, Atari, BeOS, Unix): defer creation of
symlinks until all extractions for current archive are finished, to close
a security hole (bug report by Jan Echternach)
(Changed: globals.h, unzpriv.h, extract.c, [system]/[system].c) [SPC]
- crypt.h: changed default setting for Zip to enable crypt support [SPC]
- partial documentation updates, as suggested by Greg [SPC]
5.51e (01 Mar 04):
- unzpriv.h: guarded some definitions of USE_EF_UT_TIME [Cosmin Truta]
- Cygwin: putenv() must not be called in iz_w32_prepareTZenv() [Cosmin Truta]
- unix/unxcfg.h: include <unistd.h> for Cygwin [Cosmin Truta]
- unix/unix.c: enable old code that sets DIRENT symbol for _POSIX_VERSION
environments [Cosmin Truta]
- win32/Makefile.bc: updated the "clean" target [Cosmin Truta]
- win32/Makefile.gcc: updated CC_CPU_OPT to "-mcpu=pentiumpro";
fixed the "clean" target [Cosmin Truta]
- man/unzip.1: added note about the use of the "-:" option [Lon Hohberger]
- merged in usable changes (see above) from Cosmin's bogus 5.51d beta archive
variant [SPC]
- win32: guarded "NTSD integration code" (not working, under construction)
with preprocessor symbol NTSD_DEV to allow intermediate compilation and
testing of the current state [SPC]
5.51f (16 Apr 04):
- Acorn: updated/fixed Makefile [Darren Salt]
- win32/Makefile: revised (experimental) USE_ZLIB support to work with the
current ZLIB release 1.2.1; [Cosmin Truta, Christian Spieler]
- win32/Makefile: "clean" target simplified for Win9x support [Cosmin Truta]
- INSTALL: describe DATE_SEPCHAR option [Cosmin Truta]
- unzip.c: make command-arg "\\"-to-"/" conversion MBCS-safe [SPC]
- BeOS, QDOS, Tandem, Theos, Unix - close_outfile(): to make compilers happy,
use union for matching "struct utimbuf" with "iztimes" [Jan Echternach]
- all SYMLINKS-capable ports (AOS/VS, Atari, BeOS, Unix): check for allocation
size overflow of "deferring symlink" structure (reported by Jan Echternach)
(Changed: [system]/[system].c) [SPC]
- api.c - redirect_outfile(): check for allocation overflow in textmode when
lenEOL != 1; check against integer overflow for 16-bit ports [SPC]
- fileio.c - open_outfile(): use G.lrec.ucsize throughoutly instead of
G.pInfo.uncompr_size [SPC]
- extract.c - extract_or_test_entrylist(): check for ucsize vs. csize mismatch
in STORED entries; synchronize and emit warning message [SPC]
5.51f2 (16 Apr 04):
- extract.c: fixed compilation error (misplaced ')') [Cosmin Truta]
- win32/Makefile: added missing rule to build unzsfx32.lib [Cosmin Truta]
- INSTALL, History.551: fixed some minor typos in docs [Cosmin Truta]
5.51 final (22 May 04):
- no code changes
- updated WHERE file, History.551 file, and various copyright and release
dates where necessary [GRR]
- removed "beta" status from unzver.h [GRR]
==================
These changes occurred in beta versions 5.51a to 5.51. This list may have
left out some bugfixes and even some features...void where prohibited, your
mileage may vary, etc., etc.
Christian Spieler

View File

@ -0,0 +1,215 @@
UnZip, version 5.52, 28 February 2005
Features added (or removed):
5.52a (10 Dec 04):
- no new features
5.52b (30 Dec 04):
- no new features
5.52c (8 Jan 05):
- no new features
5.52d (17 Jan 05):
- VMS: Faster I/O, both reading the archive and creating extracted data
files. Disk paralysis during file allocation, when highwater marking
is enabled on the destination device, is gone. [Steven Schweda (SMS)]
- VMS: Where the C RTL permits, with SET PROCESS /PARSE = EXTENDED,
command-line case is preserved, obviating quotation of upper- or
mixed-case options and parameters. [SMS]
5.52e (23 Jan 05):
- i386 ASM_CRC code crc_i386.S, win32/crc_i386.asm, win32/crc_i386.c:
enabled optimization for i686 by default, as pre-686 CPUs are no longer
widely used nowadays. (win32/crc_lcc.asm was already i686-optimized)
[Cosmin Truta (CT)]
- INSTALL, unzpriv.h: unshrinking is now enabled by default [CT]
- AtheOS/BeOS/Unix: do not restore SUID/SGID/Tacky bits per default; added
new security override option "-K" for backward compatibility, updated
unzip.1 man page [Johnny Lee, EG]
5.52f (27 Jan 05):
- unzpriv.h, list.c, zipinfo.c: added recognition of additional hosts and
compression methods according to latest PKWARE appnote specs [SPC]
- AtheOS/Syllable: new port, kindly contributed by Nikolaev Ruslan [SPC]
5.52g (06 Feb 05):
- no new features
5.52h (20 Feb 05):
- no new features
5.52i (24 Feb 05):
- no new features
5.52j (27 Feb 05):
- no new features
5.52 (28 Feb 05):
- no new features
Bugs fixed:
5.52a (10 Dec 04):
- Debian patch 001 - change __GNU__ to __GLIBC__ in unix/unxcfg.h. This is
required to build under glibc-based systems not being Linux-based (like
the Debian GNU/kFreeBSD port, which is in preparation). In fact,
everywhere the macro __GNU__ is used, __GLIBC__ should be used instead.
It could be made even shorter since defined(linux) || defined(__GLIBC__)
should be the same as simply defined(__GLIBC__).
- fileio.c - open_input_file(): added trailing newline to error message
[Debian patch 002, Santiago Vila]
5.52b (30 Dec 04):
- README: added short note about purpose of release 5.52 [Ed Gordon]
- format fixes [Ed Gordon]
5.52c (8 Jan 05):
- minor fixes [Ed Gordon]
5.52d (17 Jan 05):
- On VMS, when an odd output byte count is incremented to the next
larger even value, the extra byte written is now always zero,
reducing random differences between original and extracted files. [SMS]
- On VMS, "cannot find either fred;1 or fred;1.zip." messages have been
changed to show only non-fictional file names. [SMS]
5.52e (23 Jan 05):
- win32/vc6/unzip.dsw (new): replaced win32/VC6.dsp with a complete
Visual C++ 6.0 project to build unzip, funzip and unzipsfx, with both
ASM and non-ASM settings [CT]
- win32: MSC project files now preserve Win32 CRLF line ends [CT]
- win32/crc_i386.c: compile only if ASM_CRC is defined [CT]
- changed strcasecmp to strncasecmp in vms/vmszip.c [SMS]
5.52f (27 Jan 05):
- win32: for UnZip 5.5x, our tradition "distribute all text files with LF line
endings" remains in effect, MSC project files are plain text and get
distributed in UNIX LF-only format [SPC]
- windll/windll.rc: updated copyright year [SPC]
- proginfo/extra.fld: synchronized with current appnote.iz (and PKWARE's
appnote.txt v6.2 as of 2004-04-26) [SPC]
- win32/makefile.lcc: adapted to current lcc-win32 release [SPC]
- windll/uzexampl.c: fixed some function definition mismatches (previously
there were different but compatible param types used) [SPC]
- extract.c: fixed ucsize/csize mismatch test introduced in UnZip 5.51 and
corrected a follow-up extraction size bug (12 excess bytes written) for
encrypted stored entries [SPC]
- MacOS, OS2 - fixed security holes: formatted output (?printf) should not
use unchecked strings as format specifiers [Ulf Harnhammar]
- man/unzip.1, man/zipinfo.1: added explicit note on how to supply a
left bracket in a filename argument; clarified the scope of the -C option;
documented the different compressed size calculation modes for encrypted
entries in UnZip's and ZipInfo's listing output [Greg Roelofs, SPC]
- list.c, zipinfo.c: fixed ancient bug: when specifying only an exclude list,
all not-excluded zip archive entries should be listed [SPC]
- extract.c, unzpriv.h, w32.cfg, wce.cfg: added Cdecl modifier to the qsort
comparison function (allows use of stdcall mode in SFXWiz project) [SPC]
- extract.c, unzpriv.h: use LONGINT consistently for >>all<< zipfile offset
variables and adapt some type casts (allow handling of 4G archives on
systems that support 64bit file offsets) [Paul Slootman]
- renamed LONGINT into Z_OFF_T for better "in-code-documentation" [SPC]
- unzpriv.h, NEXTBYTE macro modified to allow compatibility with unsigned
bufsize counter incnt [Steven M. Schweda]
- unix/unxcfg.h: corrected Debian patch #1 by re-adding __GNU__ conditionals
where they appeared before [SPC]
- unzip.h, win32/decs.h, win32/struct.h: encapsulated declarations as
extern "C" for C++ compilation mode [SPC]
- Win32 port: integrated deferred NTSD handling for directories in the
generic dir attributes setting functionality [SPC]
- Win32: synchronized new MSVC6 project files with master Makefile (removed
unused modules and link libs, SFX opt for size, enable DBCS) [SPC]
- BeOS: synchronized code with Unix port to support reentrancy [SPC]
- All but TOPS20, VMS, WinCE: added length check to externally
supplied argument in do_wild() [SPC]
5.52g (06 Feb 05):
- VMS (fileio.c - open_infile()): corrected VMS specific open-args, patch
was accidentally left out in 5.52f [SMS, SPC]
- win32/w32cfg.h: define Cdecl as empty macro for Watcom C [P. Kienitz, SPC]
- win32/win32.c: updated OS-system message in version() [SPC]
- extract.c: corrected integer size mismatch in deferred dirs code [SPC]
- VMS: support "-T" option as /TIMESTAMP in CLI command interface [SMC]
- VMS: updated help files for UNIX and DCL interface with missing descriptions
of recently added options and new hint notes [SMC, SPC]
- win32/win32.c - set_direc_attribs(): work-around for "cannot set timestamp
of read-only dirs" bug [Cosmin Truta]
- win32/win32.c - NTQueryVolInfo(): fixed typecast warning [Cosmin Truta]
- unzpriv.h, unix/Makefile, win32/Makefile.gcc: changed build policy for
POSIX-emulating gcc distributions on Win32 (e.g. CygWin) to default to
creating POSIX-mode binaries; win32/Makefile.gcc may be used to build
win32-aware binaries (added -DFORCE_WIN32_OVER_UNIX to default compilation
options) [Cosmin Truta, SPC]
- INSTALL, History.552: stylistic text corrections [Cosmin Truta]
- win32/win32.c: complete revision of timestamp handling code; added prepro-
cessor flag NO_W32TIMES_IZFIX to allow optional compile with time handling
exactly like the (faulty) standard of other Windows programs [SPC]
- unzip.c, INSTALL: announce and document new NO_W32TIMES_IZFIX compilation
option [SPC]
- WHERE: updated to new version numbers for Zip and UnZip [SPC]
- README: summary of main changes for 5.52 added [SPC]
5.52h (20 Feb 05):
- License: updated list of core authors [Cosmin Truta, Christian Spieler]
- WHERE: further corrections [Cosmin Truta]
- windll/windll.c - Wiz_SetOpts(): corrected mapping of PromptToOverwrite and
noflag to UnZip's internal options structure, finally fixing the windll
extract mode interface (previous change from 5.40 -> 5.41 fixed some
issues but created new bugs) [SPC]
- windll/windll.txt: documented the exact meaning of the windll struct DCL
flags nfflag, ExtractOnlyNewer, noflag, PromptToOverwrite and their
interactions [SPC]
- win32: set ASM_CRC as default for MSC, GCC, LCC, EMX/RSX (vanilla BCC does
not support inline asm) [SPC]
5.52i (24 Feb 05):
- proginfo/ziplimit.txt: corrected enhanced limits of the Zip64 extensions,
updated status info on Info-ZIP's support of Zip64 archives [SPC]
- windll: renamed MS Visual C++ (5&6) project files into unique names, added
master workspace file for building all windll projects in one process [SPC]
- windll: extended MS Visual C++ project files to support both ASM_CRC and
NOASM builds; changed unzip dll projects to link against the multithreading
MS C runtime dll [SPC]
- wince/intrface.cpp - utimeToFileTime(): revised code for more efficiency,
added support for NO_W32TIMES_IZFIX [SPC]
- documentation and changelog fixes [SPC]
5.52j (27 Feb 05):
- AtheOS: some documentation updates (2004-Sep-06) [SPC]
- tandem/tanunz.c: fix typo in do_wild() [SPC]
- unix/Makefile: added -DUNIX to some special targets, to be sure [SPC]
- vms/cmdline.c: corrected declaration of external string constants [SPC]
- vms/vms.h: removed obsolete definitions [SPC]
- vms/vms.c: stream-lined code formatting [SPC]
- WinCE: added workspace file for VCEmbedded 3.0 environment [SPC]
- windll/: windll.{c|txt}, uzexampl.{c|h}: misc formatting cleanups [SPC]
- extract.c, fileio.c: cosmetic updates [SPC]
- inflate.c: fixed undefined global vars error in DEBUG message of the
USE_ZLIB interface code [Johnny Lee]
- gbloffs.c: made assembler symbols output safe against multiple defines
(from UnZip 6.0 beta) [Paul Kienitz, SPC]
- Theos: updated theos/Contents, theos/makefile to include Theos-specific
translation table header file charconv.h [SPC]
- VMS (unzip.c): updated some help messages from UnZip 6.0 beta sources
[Steven M. Schweda, SPC]
- INSTALL: updated description of VMS_TEXT_CONV option [SPC]
- LICENSE, unzip.h: added Steven M. Schweda to Info-ZIP group [SPC]
- man/unzip.1: updated Authors list [SPC]
- README, unzvers.h: switched to "Release" mode (removed BETA note) [SPC]
5.52 (28 Feb 05):
- win32/win32.c - defer_dir_attribs(): fixed critical "mem-access to nirwana"
bug when processing directory entries without any local extra field;
added some explaining comments [Kai Uwe Rommel, Johnny Lee, SPC]
- wince/punzip.rcv: derive VERSION_PATCH from UZ_PATCHLEVEL [SPC]
- Updated release dates (History.552, README, unzvers.h, all man pages) [SPC]
==================
These changes occurred in beta versions 5.52a to 5.52. This list may have
left out some bugfixes and even some features...void where prohibited, your
mileage may vary, etc., etc.
Christian Spieler

641
unzip/unzip-5.52/INSTALL Normal file
View File

@ -0,0 +1,641 @@
__________________________________________________________________________
This is the Info-ZIP file INSTALL (for UnZip), last updated 27 Feb 2005.
__________________________________________________________________________
Yes, this is a rather long file, but don't be intimidated: much of its
length is due to coverage of multiple operating systems and of optional
customization features, large portions of which may be skipped.
__________________________________________________________________________
To compile UnZip, UnZipSFX and/or fUnZip (quick-start instructions):
========================================
(1) Unpack everything into a work directory somewhere, and make sure you're
in the main UnZip directory (the one with this file in it).
* (See note below concerning line termination format used in the source
distribution)
(2) Copy the appropriate makefile into the current directory, except under
OS/2.
(3) Run your "make" utility on the makefile (e.g., "nmake -f makefile.msc").
(4) Try out your new UnZip the way you would any new utility: read the
docs first.
Ah ha ha ha!! Oh, that kills me. But seriously...for VMS, UnZip must
be installed as a "foreign symbol"; see the Install section below or
[.vms]readme.vms for details. (It basically involves adding a line
sort of like this to login.com: $ unzip == "$disk:[dir]unzip.exe")
For DOS and other OSes without explicit timezone support (i.e., everybody
but Unix, Windows 95 and NT), make sure the "TZ" environment variable is
set to a valid and reasonable value; see your compiler docs for details.
(*) The unzip sources as well as other Info-ZIP source archives are packaged
in Unix format. All text files use single LF (Ascii 0x0a) characters as
line terminators. On systems that use different conventions for plain text
files (e.g.:DOS,Win9x,WinNT,OS/2 -> combined CR+LF; MacOS -> single CR),
some utilities (editors, compilers, etc.) may not accept source files
with LF line terminators.
For these systems, we recommend to use Info-ZIP's UnZip utility for
extraction of our distribution archives, applying the command option
"-a" (= translate text files to native format) in the extraction command.
In case this procedure is not applicable, an appropiate third-party
conversion utility may be used to achieve the desired line termination
style (examples: "flip", available for Unix, DOS, OS/2; or "tr" on Unix).
To compile UnZip, UnZipSFX and/or fUnZip (detailed instructions):
========================================
(1) Unpack *.c and *.h (the actual source files), preserving the directory
structure (e.g., ./unix/unix.c). The sole exception is TOPS-20, where
tops20/* should be unpacked into the current directory, but TOPS-20
is no longer fully supported anyway.
As of UnZip 5.41, full decryption support has been integrated in the
UnZip source distribution. If you wish to compile binaries without
decryption support, you must define the preprocessor flag NO_CRYPT.
For many environments, you may add this flag to the custom compilation
flags supplied by the environment variable LOCAL_UNZIP. For more
details, see the make procedures and accompanied documentation for your
particular target OS.
(2) Choose the appropriate makefile based on the description in the Con-
tents file for your OS (that is, there's only one for Unix or OS/2, but
MS-DOS and several other OSes have several, depending on the compiler).
Copy it into the current directory and rename if necessary or desired.
(Some makefiles can be invoked in place; see (5) below.)
Don't be afraid to read the makefile! Many options will be explained only
in the comments contained therein. The defaults may not quite suit your
system. When making changes, remember that some "make" utilities expect
tabs as part of the makefile syntax. Failure with cryptic error messages
will result if your editor quietly replaces those tabs with spaces.
Special point of confusion: some non-MSDOS makefiles contain MS-DOS
targets (useful for cross-compilations). An example is the OS/2 makefile
os2/makefile.os2 that contains the gccdos target for DOS emx+gcc and
some more DOS related targets for Watcom C and MSC. But since version 5.3,
the msdos subdirectory contains makefiles for all supported DOS compilers.
[The old djgpp, djgpp1 and gcc_dos targets in unix/Makefile have been
removed in 5.3; use msdos/makefile.dj* instead.]
Extra-special point of confusion: makefile.os2 expects to remain in
the os2 subdirectory. Invoke it via "nmake -f os2/makefile.os2 gcc",
for example.
(3) If you want a non-standard version of UnZip, define one or more of the
following optional macros, either by adding them to the LOCAL_UNZIP
environment variable or by editing your makefile as appropriate. The
syntax differs from compiler to compiler, but macros are often defined
via "-DMACRO_NAME" or similar (for one called MACRO_NAME). Note that
some of these may not be fully supported in future releases (or even
in the current release). Note also that very short command lines in
MS-DOS (128 characters) may place severe limits on how many of these
can be used; if need be, the definitions can be placed at the top of
unzip.h instead (it is included in all source files)--for example,
"#define MACRO_NAME", one macro per line.
DOSWILD (MS-DOS only)
Treat trailing "*.*" like Unix "*" (i.e., matches anything); treat
trailing "*." as match for files without a dot (i.e., matches any-
thing, as long as no dots in name). Special treatment only occurs
if patterns are at end of arguments; i.e., "a*.*" matches all files
starting with "a", but "*.*c" matches all files ending in "c" *only*
if they have a dot somewhere before the "c". [The default method of
specifying files without a dot would be "* -x *.*", making use of
UnZip's exclude-files option.] The matching is actually the same as
Unix, if you assume that undotted filenames really have an invisible
dot at the end, which is how DOS and related systems treat filenames
in general. All other regular expressions (including "?" and
"[range_of_chars]") retain their Unix-like behavior.
WILD_STOP_AT_DIR (incompatible with WINDLL!)
Enables an additional option "-W". When this qualifier is specified,
the pattern matching routine is modified so that both '?' (single-char
wildcard) and '*' (multi-char wildcard) do not match the directory
separator character '/'. Examples:
"*.c" matches "foo.c" but not "mydir/foo.c"
"*/*.c" matches "bar/foo.c" but not "baz/bar/foo.c"
"??*/*" matches "ab/foo" and "abc/foo" but not "a/foo" or "a/b/foo"
To enable matching across directory separator chars, two consecutive
multi-char wildcards "**" should be specified.
This modified behaviour is equivalent to the pattern matching style
used by the shells of some of UnZip's supported target OSs (one
example is Acorn RISC OS).
VMSWILD (VMS only)
Use parentheses rather than brackets to delimit sets (ranges), and
use '%' instead of '?' as the single-character wildcard for internal
filename matching. (External matching of zipfile names always uses
the standard VMS wildcard facilities; character sets are disallowed.)
VMSCLI (VMS only)
Use VMS-style "slash options" (/FOOBAR) instead of the default Unix-
style hyphenated options (-f). This capability does not affect options
stored in environment variables (UNZIP_OPTS or ZIPINFO_OPTS); those use
the Unix style regardless. Beginning with UnZip 5.32, the supplied
VMS build methods generate both VMS-style and default "UNIX-style"
executables; you should NOT add VMSCLI to the custom options.
CHECK_VERSIONS (VMS only)
UnZip "extra fields" are used to store VMS (RMS) filesystem info,
and the format of this information may differ in various versions
of VMS. Defining this option will enable UnZip warnings when the
stored extra-field VMS version(s) do(es) not match the version of
VMS currently being used. This is a common occurrence in zipfiles
received from other sites, but since the format of the filesystem
does not seem to have changed in years (including on Alpha and
IA64 systems), the warnings are not enabled by default.
RETURN_CODES (VMS only)
VMS interprets return codes according to a rigid set of guidelines,
which means it misinterprets normal UnZip return codes as all sorts
of really nasty errors. Therefore VMS UnZip returns an alternate set
of return codes; since these may be difficult to interpret, define
RETURN_CODES for human-readable explanations.
VMS_TEXT_CONV (everybody except VMS)
VMS Stream_LF-format text files archived with the "-V" option
(/VMS) should be readable when extracted on other systems.
They may
get some junk appended, depending on Zip version and precise options
used for archiving them, but appart from that problem they should
be fine. Text files with other formats (like the default VFC, with
its embedded byte counts) may be only semi-readable at best when
extracted on other systems. Defining this option enables UnZip's
-aa option to detect and convert VMS VFC-record text files into
native text format. Non-VMS UnZips now use a rudimentary VMS extra
field analyser to relyably determine such text files. (Earlier
versions of UnZip applied some heuristics instead.)
Therefore this option is now enabled by default for the main program
(but not the SFX stub), because it can be extremely useful on those
rare occasions when a VMS text file must be extracted as normal text.
USE_DJGPP_ENV (MS-DOS DJGPP 2.0x only)
Regular DJGPP v2.0x compiled programs which use ENVIRONMENT are
able to read from the file "djgpp.env" as well as those set in the
environment. This adds about 1KB to the size of the executable.
This option is disabled by default in Info-ZIP source. If you are
able to use "djgpp.env" and don't like to clutter the environment
with many special purpose variables, you may want to compile with
this option set.
USE_DJGPP_GLOB (MS-DOS DJGPP 2.0x only)
If you like to get UnZip binaries that handle command line arguments
similar to Unix tools which are run in an Unix shell, you might want
to set this compilation option. This option enables the support for
globbing command line arguments containing wild card that is built
into the DJGPP startup code. When using a binary compiled with this
option, you may have to enclose wildcard arguments in double quotes
to get them passed to the program unmodified. Enabling this option
is not recommended, because it results in Info-Zip binaries that do
not behave as expected for MS-DOS programs.
USE_VFAT (MS-DOS only, for using same executable under DOS and Win95/NT)
djgpp 2.x and emx/gcc+RSX 5.1 can detect when they are running under a
Win32 DOS box and will accordingly enable long-filename support. For
now only djgpp 2.x and emx/gcc with RSX 5.1 or later have this feature
(and it is defined by default in msdos/makefile.dj2 and makefile.emx),
but if/when other compilers build in similar support, define this
macro to enable its use. See also msdos/doscfg.h. [Note that djgpp
2.0's LFN support is flaky; users should upgrade to 2.01 or later.]
NO_W32TIMES_IZFIX (Win32 including WinDLL, and WinCE)
By specifying this option, you can disable Info-ZIP's special timestamp
adjustment to get stable time stamps on NTFS disks that do not change
depending on the current time being normal vs. daylight saving time.
When this option is set, UnZip behaves exactly like other programs;
file timestamps on NTFS partitions are created so that their >current<
local time representation displayed by directory listings (cmd.exe "dir"
command or Windows Explorer listings) is the same as shown by UnZip's
listing. But the actual UTC timestamp values stored in the NTFS
file attributes vary depending on whether extraction is done at
summer or winter time.
This option is not recommended because it sacrifies the timestamp
comparison checks when extracting or modifying archives in "update
only newer" mode.
However, for environments where consistency of >displayed< dates
of files extracted to NTFS vs. FAT disks is considered more important
than correctly working update/freshen tasks of Zip&UnZip, this
option may be used.
>> DO NOT DISTRIBUTE OR PUBLISH executables that were compiled with
this option! <<
NOTIMESTAMP
This option disables the -T option, which basically does exactly what
Zip's -go options do (i.e., set the timestamp of the zipfile to that of
the newest file in the archive without rewriting the archive). Unlike
Zip, however, UnZip supports wildcard specifications for the archive
name; for example, "unzip -T *.zip" will set the dates of all zipfiles
in the current directory. (UnZip's option is also much faster.)
DATE_FORMAT=DF_DMY or DF_MDY or DF_YMD
This option controls the order in which date components are printed
in listings: day-month-year or month-day-year or year-month-day.
For DOS, FlexOS, OS2, Theos and Win32, the format is automatically
obtained from the operating system; most others default to DF_MDY.
DATE_SEPCHAR='-' or '.' or '/' etc.
This option controls the character that separates the date components
shown in (non-ZipInfo-mode) listings. The Win32 port obtains the
separator automatically from the operating system's locale settings;
all others default to '-'.
ACORN_FTYPE_NFS (needs support for long filenames with embedded commas)
This option enables a -F option that instructs UnZip to interpret the
filetype information extracted from Acorn RiscOS extra field blocks.
The filetype IDs are translated into "NFS filetype extensions" and
appended to the names of the extracted files. This feature facilitates
maintenance of Unix-based NFS volumes that are exported to Acorn RiscOS
systems.
QLZIP (Unix only)
Add some support for QDOS extra fields. This option enables Unix
UnZip to append "datalen info" to QDOS exec type files in the same
format as used by QDOS cross-compilers on Unix or the qltools v2.2(+).
UNIXBACKUP (Unix only)
This option enables a -B option that instructs UnZip to rename files
that would normally be overwritten. The renamed files are given a
tilde suffix (`~'). Note that previously renamed files may be over-
written without notice, even if the -n option is given.
OS2_EAS
List the sizes of OS/2 EAs and ACLs for each file as two extra columns
in "unzip -l" output. This is primarily useful for OS/2 systems, but
because zipfiles are portable, OS2_EAS can be defined for any system.
(May be extended someday to show sizes of Mac resource forks, RISCOS
and VMS file info, etc.)
DELETE_IF_FULL (anybody with unlink() function)
If a write error is encountered (most likely due to a full disk),
enabling this option will cause the incomplete file to be deleted
instead of closed normally. This is particularly useful for the
Windows CE port, which must generally contend with extremely limited
resources.
ASM_CRC (Amiga/Aztec C; many x86 systems: DOS, OS/2, Win32, Unix)
Use an assembler routine to calculate the CRC for each file (speed).
ASM_INFLATECODES (Amiga/Aztec C only, for now)
Use an assembler version of inflate_codes() for speed.
OLD_EXDIR
No longer supported.
SFX_EXDIR
Enable the "-d <extract_dir>" option for UnZipSFX. This is now
enabled by default (since UnZip 5.5) to facilitate use with
automated installation scripts and the like. For disabling
this feature, see the NO_SFX_EXDIR option.
NO_SFX_EXDIR
Disables the "-d <extract_dir>" option for UnZipSFX to generate the
smallest possible executable stub. (Prior to the UnZip 5.5 release,
this was the default.)
CHEAP_SFX_AUTORUN
Enable a simple "run command after extraction" feature for
the (command line) UnZipSFX stub. This feature is currently
incompatible with the "-d <extract_dir>" command line option,
therefore CHEAP_SFX_AUTORUN implicitely sets the NO_SFX_EXDIR
option.
NO_ZIPINFO
Compile without ZipInfo mode (-Z) enabled; makes a smaller executable
because many text strings are left out. Automatically enabled for
some small-model compiles under MS-DOS and OS/2, so ordinarily there
is no need to specify this explicitly. (Note that even with this
defined, the resulting executable may still be too big to extract
some zipfiles correctly, if compiled with the small memory model.)
USE_DEFLATE64 (default for UnZip and fUnZip)
NO_DEFLATE64 (default for UnZipSFX stub)
The "deflate64" algorithm from PKZIP 4.0 (or newer) is an enhanced
variant of the deflate algorithm that achieves slightly better
compression ratios on highly redundant data. Normally, UnZip should
be compiled with support for this compression algorithm enabled.
However, this results in significantly larger memory requirements
to run the program. For 16-bit executables (DOS and OS/2), the
special memory management to support the 64k history buffer results
in a slight performance (= speed) penalty. And for the SFX stub,
"deflate64" support might be unnessessary as long as the Info-ZIP
Zip utility does not support it (quite likely, this will never
get implemented). So, the NO_DEFLATE64 option is provided to allow
exclusion of the deflate64 support.
MULT_VOLUME (experimental for 5.5x, do NOT use in production versions!)
NO_MULT_VOLUME (default)
The symbol MULT_VOLUME is used to flag code portions needed for
support of multi-volume archives. For now, this flag MUST NOT be
used to compile a production versions of UnZip. This flag has been
introduced to allow integration of experimental code for multi-volume
support in the master source tree. This feature will become a default
option in the future 6.0 release of UnZip.
LZW_CLEAN
USE_UNSHRINK (now default, as of January 2005)
The "shrinking" algorithm from PKZIP 1.0 is an LZW variant. Unisys
patented the Lempel-Ziv-Welch algorithm in 1985 and has publicly
claimed that decompression is covered by it. (IBM also patented the
same thing in a filing 3 weeks prior to Unisys's.) In 2004, the
Unisys and IBM patents expired worldwide, so unshrinking is now
enabled again by default. If you do not wish to include the LZW
method, you may still disable it by defining LZW_CLEAN.
(Unshrinking was used by PKZIP 1.0 and 1.1, and Zip 1.0 and 1.1.
All newer archives use only the deflation method.)
COPYRIGHT_CLEAN (now default)
USE_SMITH_CODE
The last chunk of code in UnZip that was blatantly derived from Sam
Smith's unzip 2.0 (as in, "substantially similar") is in unreduce.c.
Since reducing was only used by very early PKZIP beta versions (0.9x),
support for it is now omitted by default (COPYRIGHT_CLEAN). To in-
clude unreducing capability, define USE_SMITH_CODE and replace the
stub unreduce.c source file by the separatly distributed full source
code module. Note that this subjects UnZip to any and all restrictions
in Smith's copyright; see the UnZip COPYING.OLD file for details.
USE_CRYPT
Enable decryption support for all binaries. The default setting
is to disable decryption support for the SFX stub to keep its size
as small as possible. For other binaries of the UnZip distribution,
decryption support is enabled by default.
NO_CRYPT
Disable decryption support for all binaries.
PASSWD_FROM_STDIN (with full crypt sources only; Unix, VMS only)
Used to allow the password on encrypted files to be read from stdin
rather than the default stderr. This was useful for those who wished
to automate the testing or decoding of encrypted archives (say, in a
shell script via ``echo "password" | unzip -tq archive''), but as of
version 5.3, UnZip has a -P option for passing a password directly to
the program. PASSWD_FROM_STDIN will therefore probably be phased out
in future versions. Note that the same security warnings given in the
description of the -P option apply here as well.
DEBUG
Used for debugging purposes; enables Trace() statements. Generally
it's best to compile only one or two modules this way.
DEBUG_TIME
Used for debugging the timezone code in fileio.c; enables TTrace()
statements. This code is only used for the freshen/update options
(-f and -u), and non-Unix compilers often get it wrong.
(4) If you regularly compile new versions of UnZip and always want the same
non-standard option(s), you may wish to add it (them) to the LOCAL_UNZIP
environment variable (assuming it's supported in your makefile). Under
MS-DOS, for example, add this to AUTOEXEC.BAT:
set LOCAL_UNZIP=-DDOSWILD -DDATE_FORMAT=DF_DMY
You can also use the variable to hold special compiler options (e.g.,
-FPi87 for Microsoft C, if the x87 libraries are the only ones on your
disk and they follow Microsoft's default naming conventions; MSC also
supports the CL environment variable, however).
(5) Run the make utility on your chosen makefile:
Unix
For most systems it's possible to invoke the makefile in place, at
the possible cost of an ignorable warning; do "make -f unix/Makefile
list" to get a list of possible system targets, and then "make -f
unix/Makefile target" for your chosen target. The "generic" target
works for most systems, but if it fails with a message about ftime()
unresolved or timezone redefined, do "make clean", "make help", and
then either "make generic2" or "make generic3" as instructed. If all
else fails, read the makefile itself; it contains numerous comments.
(One of these days we'll make a configure script that automates this
procedure better.)
VMS (OpenVMS):
For a one-time build of the default UnZip, simply run the supplied
command file MAKE_UNZ.COM. To use either DEC C on an Alpha or the
default compiler (DEC C if available, else VAX C) on a VAX, type
"@make_unz" (after copying make_unz.com into the current directory;
otherwise do "@[.vms]make_unz" to invoke it in place).
If you want to force the use of VAX C when both VAX C and DEC C are
available, do "@make_unz vaxc" (or "@[.vms]make_unz vaxc").
To use GNU C (gcc) on either platform, do "@make_unz gnuc".
(NOTE: Currently, gcc for VMS(AXP) is not yet available!)
The command procedure MAKE_UNZ.COM now recognizes custom feature
options supplied in the logical name LOCAL_UNZIP; details are
explained in the comments at the top of MAKE_UNZ.COM.
For repeated makes or other hacker-like tinkering with the sources,
or to create a custom version of UnZip, you may use the included "MMS"
makefile, DESCRIP.MMS. Copy it into the current directory, read the
comments at the top of it and run MadGoat's free MMS clone "MMK" on it.
Newer versions of DEC's MMS should work, too, but older ones apparently
choke on some MMK-specific extensions in DESCRIP.MMS. (If somebody
has an "older" version that works, let us know and we'll remove this
caveat.)
MS-DOS
See the msdos\Contents file for notes regarding which makefile(s) to
use with which compiler. In summary: pick one of msdos\makefile.*
as appropriate, or (as noted above) use the OS/2 gccdos target for
emx+gcc. There is also an mscdos cross-compilation target in
os2\makefile.os2 and a sco_dos cross-compilation target in the Unix
makefile. For Watcom 16-bit or 32-bit versions, see the comments in
the OS/2 section below.
After choosing the appropriate makefile and editing as necessary or
desired, invoke the corresponding make utility. Microsoft's NMAKE
and the free dmake and GNU make utilities are generally the most
versatile. The makefiles in the msdos directory can be invoked in
place ("nmake -f msdos\makefile.msc", for example).
OS/2
Either GNU make, nmake or dmake may be used with the OS/2 makefile;
all are freely available on the net. Do "nmake -f os2\makefile.os2",
for example, to get a list of supported targets. More generally,
read the comments at the top of the makefile for an explanation of
the differences between some of the same-compiler targets.
Win32 (WinNT or Win95)
You will need Microsoft Visual C++ 2.x for Win95 or NT (Intel, MIPS,
Alpha, PowerPC?), or Watcom C++ for Win95 or NT (Intel only). As an
alternative for Intel platforms, GNU C (the emx/rsxnt port) is now
supported as well. DEC C/C++ for NT/Alpha may or may not still work.
For the Watcom compiler, use WMAKE and win32\makefile.wat; for the
others, use NMAKE and win32\Makefile. With emx+gcc, a good choice is
GNUMake 3.75 from the djgpp V2.01 distribution.
WinCE (WinCE or WinNT)
Only Microsoft Visual C++ 5.0 or later is supported. Use the included
project file and check wince\README for details.
AmigaDOS
SAS/Lattice C and Manx Aztec C are supported. For SAS C 6.x do "smake
-f amiga/smakefile all"; for Aztec C do "make -f amiga/makefile.azt
all". The Aztec C version supports assembly-language versions of two
routines; these are enabled by default.
Atari TOS
Turbo C is no longer supported; use gcc and the MiNT libraries, and
do "make". Note that all versions of gcc prior to 2.5.8 have a bug
affecting 68000-based machines (optimizer adds 68020 instructions).
See atari\README for comments on using other compilers.
Macintosh
Metrowerks CodeWarrior Pro 4 with Universal Interfaces 3.1 is the only
currently supported compiler, although the Mac Programmer's Workbench
(MPW) and Think C were supported at one time and still have some hooks.
Other Compilers may work too, no compiler specific instructions
(pragma, header, macros, ...) were used in the code.
For CodeWarrior Pro 4, un-BinHex the CodeWarrior project file and
UnZip resource file (using Stuffit Expander or BinHex 4.0 or later),
then open the project and click on the compile button.
See ":macos:Contents" for the possible project targets.
Link order of the standard libraries is very important: Link all
sources first and all standard libraries last.
Acorn (RISC OS)
Extract the files from the archive and place in standard 'Acorn' C
form (i.e., *.c, *.h and *.s become c.*, h.* and s.*, respectively),
either using the UNZIP$EXTS environment variable and a pre-built UnZip
binary, or using Spark[FS] and doing it manually. Then copy the
Acorn.Makefile to the main UnZip directory and either type 'amu' or
use the desktop make utility.
VM/CMS
Unpack all the files and transfer them with ASCII -> EBCDIC conver-
sion to an appropriate directory/minidisk/whatever, then execute
UNZVMC to compile and link all the sources. This may require C/370
version 2.1 or later and certain `nucleus extensions,' although
UnZip 5.3 has been reported to compile fine with the `ADCYCLE C/370
v1.2 compiler.' Note that it will abend without access to the C/370
runtime library. See the README.CMS file for more details.
MVS
Unpack all the files and transfer them to an appropriate PDS with
ASCII -> EBCDIC conversion enabled, then edit UNZMVSC.JOB as required,
and execute it to compile and link all the sources. C/370 2.1 or
later is required. See README.MVS for further details. [This is a
new port and may need a little more work even to compile.]
Human68K
[This is a Japanese machine and OS.] It appears that GNU make and
gcc are required; presumably just do "gmake -f human68k/Makefile.gcc"
to build everything. This port has not been tested since the 5.12
release.
TOPS-20
[No longer fully supported due to new, unported features, although
patches are always accepted.] Unpack all files into the current
directory only (including those in the zipfile's tops20 directory),
then use make.mic and "do make".
BeOS
You can run the BeOS makefile in place by typing "make -f
beos/Makefile". In fact, this is how the author tests it.
Running the appropriate make utility should produce three executables on
most systems, one for UnZip/ZipInfo, one for UnZipSFX, and one for fUnZip.
(VMS is one prominent exception: fUnZip makes no sense on it. The Amiga
produces a fourth executable called MakeSFX, which is necessary because
Amiga self-extracting archives cannot be created by simple concatenation.
If necessary the source amiga/makesfx.c can be compiled on other systems.)
Read any OS-specific README files for notes on setting things up for
normal use (especially for VMS) and for warnings about known quirks and
bugs in various compilers (especially for MS-DOS).
Also note that many OSes require a timezone variable to be set correctly
(often "TZ"); Unix and VMS generally do so by default, Win95/NT do if set
up properly, but other OSes generally do not. See the discussion of the
-f and -u options in the UnZip man page (or unzip.txt). BeOS doesn't
currently support timezone information at all, but this will probably be
added soon.
Then test your new UnZip on a few archives and let us know if there are
problems (but *please* first make certain that the archives aren't actu-
ally corrupted and that you didn't make one of the silly mistakes dis-
cussed in the documentation). If possible, double-check any problems
with PKUNZIP or with a previous version of UnZip prior to reporting a
"bug." The zipfile itself may be damaged.
To install:
===========
Unix
The default prefix for the installation location is /usr/local (things
go into the bin and man/man1 subdirectories beneath the prefix), and
the default man-page extension is "1" (corresponding to man/man1, above).
To install as per the defaults, do "make install"; otherwise do "make
prefix=/your/path manext=your_extension install". (For Intel Unix flavors
where the assembler CRC routines were used [ASM_CRC], use the install_asm
target instead of the regular install target.) For example, to install
in your home directory with "l" as the man-page extension (for "local"),
do "make prefix=$HOME manext=l install". Permissions will be 755 for the
executables and 644 for the man pages. In general root must perform in-
stallation into a public directory. Do "rehash" if your shell requires
it in order to find the new executables.
VMS
Install UnZip as foreign symbol by adding this to login.com:
$ unzip == "$disk:[dir]unzip.exe"
$ zipinfo == "$disk:[dir]unzip.exe ""-Z"""
where "disk" and "dir" are the location of the UnZip executable; the "$"
before the disk name is important, as are the double-double-quotes around
the -Z. Some people, including the author, prefer a short alias such as
"ii" instead of "zipinfo"; edit to taste. Optionally also install unzipsfx
for use with the MAKESFX.COM command file. See vms/README (or [.VMS]README.)
for details on this and for notes/warnings about zipfiles and UnZip under
VMS.
OS/2, MS-DOS, NT, Atari, Amiga
Move or copy unzip.exe (or unzip.ttp, or UnZip, or whatever) to a direc-
tory in your path; also possibly copy the UnZip executable to zipinfo.exe
(or ii.exe), or else create an alias or a batch/command file for ZipInfo
("@unzip -Z %1 %2 %3 %4 %5 %6 %7 %8 %9" under MS-DOS). The latter is only
relevant if NO_ZIPINFO was *not* defined, obviously... Under djgpp 2.x,
zipinfo.exe is a 2K stub symbolically linked to unzip.exe.
Acorn RISC OS
Copy the executables unzip, funzip and zipinfo to somewhere in your
Run$Path. See your Welcome manual if you don't know about Run$Path.
BeOS
The default prefix for the installation location is /boot/usr/local
(things go into the bin and man/man1 subdirectories beneath the prefix),
and the default man-page extension is "1" (corresponding to the man/man1,
above). Of course, these Unix man-pages aren't useful until someone ports
something that can format them... plain text versions are also installed
with an extension of ".txt". To install, do a "make install", or to
change the prefix, do "make prefix=/your/path install". For example, to
install in /boot/bin, do "make prefix=/boot/bin install".
Macintosh
MacZip requires at least System 7 and a Macintosh with a minimum of a
Motorola 68020 or PowerPC 601 processor. Other configurations may work
but it is not tested at all.
The application (MacZip) is distributed as a combination of zip and unzip
in one program. The offical release is a fat binary with both regular 68K
and native PowerPC versions included.
Move the executable(s) somewhere--for example, drag it (or them) to your
Applications folder. For easy access, make an alias in the Launcher Control
Panel or directly on your desktop.
This port supports also Apple-event.So you can install it in your
WWW-Browser as a helper-app.
Look into "macos/README.TXT" (or ":macos:README.TXT" on Mac) for further
info.
Human68K, TOPS-20, AOS/VS, MVS, VM/CMS, etc.
Dunno, sorry...

55
unzip/unzip-5.52/LICENSE Normal file
View File

@ -0,0 +1,55 @@
This is version 2005-Feb-10 of the Info-ZIP copyright and license.
The definitive version of this document should be available at
ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
For the purposes of this copyright and license, "Info-ZIP" is defined as
the following set of individuals:
Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
Rich Wales, Mike White
This software is provided "as is," without warranty of any kind, express
or implied. In no event shall Info-ZIP or its contributors be held liable
for any direct, indirect, incidental, special or consequential damages
arising out of the use of or inability to use this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. Redistributions of source code must retain the above copyright notice,
definition, disclaimer, and this list of conditions.
2. Redistributions in binary form (compiled executables) must reproduce
the above copyright notice, definition, disclaimer, and this list of
conditions in documentation and/or other materials provided with the
distribution. The sole exception to this condition is redistribution
of a standard UnZipSFX binary (including SFXWiz) as part of a
self-extracting archive; that is permitted without inclusion of this
license, as long as the normal SFX banner has not been removed from
the binary or disabled.
3. Altered versions--including, but not limited to, ports to new operating
systems, existing ports with new graphical interfaces, and dynamic,
shared, or static library versions--must be plainly marked as such
and must not be misrepresented as being the original source. Such
altered versions also must not be misrepresented as being Info-ZIP
releases--including, but not limited to, labeling of the altered
versions with the names "Info-ZIP" (or any variation thereof, including,
but not limited to, different capitalizations), "Pocket UnZip," "WiZ"
or "MacZip" without the explicit permission of Info-ZIP. Such altered
versions are further prohibited from misrepresentative use of the
Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
"UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
own source and binary releases.

288
unzip/unzip-5.52/README Normal file
View File

@ -0,0 +1,288 @@
This is the README file for the 28 February 2005 public release of the
Info-ZIP group's portable UnZip zipfile-extraction program (and related
utilities).
unzip552.zip portable UnZip, version 5.52, source code distribution
unzip552.tar.Z same as above, but compress'd tar format
unzip552.tar.gz same as above, but gzip'd tar format
__________________________________________________________________________
BEFORE YOU ASK: UnZip, its companion utility Zip, and related utilities
and support files can be found in many places; read the file "WHERE" for
further details. To contact the authors with suggestions, bug reports,
or fixes, continue reading this file (README) and, if this is part of a
source distribution, the file "ZipPorts" in the proginfo directory. Also
in source distributions: read "BUGS" for a list of known bugs, non-bugs
and possible future bugs; INSTALL for instructions on how to build UnZip;
and "Contents" for a commented listing of all the distributed files.
__________________________________________________________________________
GENERAL INFO
------------
UnZip is an extraction utility for archives compressed in .zip format (also
called "zipfiles"). Although highly compatible both with PKWARE's PKZIP
and PKUNZIP utilities for MS-DOS and with Info-ZIP's own Zip program, our
primary objectives have been portability and non-MSDOS functionality.
This version of UnZip has been ported to a stupendous array of hardware--
from micros to supercomputers--and operating systems: Unix (many flavors),
VMS, OS/2 (including DLL version), Windows NT and Windows 95 (including DLL
version), Windows CE (GUI version), Windows 3.x (including DLL version),
MS-DOS, AmigaDOS, Atari TOS, Acorn RISC OS, BeOS, Macintosh (GUI version),
SMS/QDOS, MVS, VM/CMS, FlexOS, Tandem NSK, Human68k (mostly), AOS/VS (partly)
and TOPS-20 (partly). UnZip features not found in PKUNZIP include source
code; default extraction of directory trees (with a switch to defeat this,
rather than the reverse); system-specific extended file attributes; and, of
course, the ability to run under most of your favorite operating systems.
Plus, it's free. :-)
For source distributions, see the main Contents file for a list of what's
included, and read INSTALL for instructions on compiling (including OS-
specific comments). The individual operating systems' Contents files (for
example, vms/Contents) may list important compilation info in addition to
explaining what files are what, so be sure to read them. Some of the ports
have their own, special README files, so be sure to look for those, too.
See unzip.1 or unzip.txt for usage (or the corresponding UnZipSFX, ZipInfo,
fUnZip and ZipGrep docs). For VMS, unzip_def.rnh or unzip_cli.help may be
compiled into unzip.hlp and installed as a normal VMS help entry; see
vms/descrip.mms.
CHANGES AND NEW FEATURES
------------------------
The 5.52 maintenance release fixes a few minor problems found in the 5.51
release, closes some more security holes, adds a new AtheOS port, and
contains a Win32 extra-field code cleanup that was not finished earlier.
The most important changes are:
- (re)enabled unshrinking support by default, the LZW patents have expired
- fixed an extraction size bug for encrypted stored entries (12 excess bytes
were written with 5.51)
- fixed false "uncompressed size mismatch" messages when extracting
encrypted archive entries
- do not restore SUID/SGID/Tacky attribute bits on Unix (BeOS, AtheOS)
unless explicitely requested by new "-K" command line qualifier
- optional support for "-W" qualifier to modify the pattern matching syntax
(with -W: "*" stops at directory delimiter, "**" matches unlimited)
- prevent buffer overflow caused by bogus extra-long Zipfile specification
- performance enhancements for VMS port
- fixed windll interface handling of its extraction mode qualifiers
nfflag, ExtractOnlyNewer, noflag, PromptToOverwrite; added detailed
explanation of their meanings and interactions to the windll documentation
The 5.51 maintenance release adds a command-line CE port, intended for
batch processing. With the integration of this port, the pUnZip port
has been revised and "revitalized".
The most important changes for the general public are a number of
bug fixes, mostly related to security issues:
- repair a serious bug in the textmode output conversion code for the 16-bit
ports (16-bit MSDOS, OS/2 1.x, some variants of AMIGA, possibly others)
which was introduced by the Deflate64 support of release 5.5
- fix a long standing bug in the the inflate decompression method that
prevented correct extraction in some rare cases
- fixed holes in parent dir traversal security code (e.g.: ".^C." slipped
through the previous version of the check code)
- fixed security hole: check naming consistency in local and central header
- fixed security hole: prevent extracted symlinks from redirecting file
extraction paths
The main addition in the 5.5 release is support for PKWARE's new Deflate64(tm)
algorithm, which appeared first in PKZIP 4.0 (published November 2000).
As usual, some other bugfixes and clean-ups have been integrated:
- support for Deflate64 (Zip compression method #9)
- support for extracting VMS variable length record text files on
any system
- optional "cheap autorun" feature for the SFX stub
- security fixes:
* strip leading slash from stored pathspecs,
* remove "../" parent dir path components from extracted file names
- new option "-:" to allow verbatim extraction of file names containing
"../" parent dir path specs
- fixed file handle leak for the DLL code
- repaired OS2 & WinNT ACL extraction which was broken in 5.42
The 5.42 maintenance release fixes more bugs and cleans up the redistribution
conditions:
- removal of unreduce.c and amiga/timelib.c code to get rid of the last
distribution restrictions beyond the BSD-like Info-ZIP LICENSE
- new generic timelib replacement (currently used by AMIGA port)
- more reasonable mapping rules of UNIX "leading-dot" filenames to the
DOS 8.3 name convention
- repaired screensize detection in MORE paging code
(was broken for DOS/OS2/WIN32 in 5.41)
The 5.41 maintenance release adds another new port and fixes some bugs.
- new BSD-like LICENSE
- new Novell Netware NLM port
- supports extraction of archives with more than 64k entries
- attribute handling of VMS port was broken in UnZip 5.4
- decryption support integrated in the main source distribution
The 5.4 release adds new ports, again. Other important items are changes
to the listing format, new supplemental features and several bug fixes
(especially concerning time-stamp handling...):
- new IBM OS/390 port, a UNIX derivate (POSIX with EBCDIC charset)
- complete revision of the MacOS port
- changed listing formats to enlarge the file size fields for more digits
- added capability to restore directory attributes on MSDOS, OS/2, WIN32
- enabled support of symbolic links on BeOS
- Unix: optional Acorn filetype support, useful for volumes exported via NFS
- several changes/additions to the DLL API
- GUI SFX stub for Win16 (Windows 3.1) and Win32 (Windows 9x, Windows NT)
- new free GCC compiler environments supported on WIN32
- many time-zone handling bug fixes for WIN32, AMIGA, ...
The 5.32 release adds two new ports and a fix for at least one relatively
serious bug:
- new FlexOS port
- new Tandem NSK port
- new Visual BASIC support (compatibility with the Windows DLLs)
- new -T option (set zipfile timestamp) for virtually all ports
- fix for timestamps beyond 2038 (e.g., 2097; crashed under DOS/Win95/NT)
- fix for undetected "dangling" symbolic links (i.e., no pointee)
- fix for VMS indexed-file extraction problem (stored with Zip 2.0 or 2.1)
- further performance optimizations
The 5.31 release included nothing but small bug-fixes and typo corrections,
with the exception of some minor performance tweaks.
The 5.3 release added still more ports and more cross-platform portability
features:
- new BeOS port
- new SMS/QDOS port
- new Windows CE graphical port
- VM/CMS port fully updated and tested
- MVS port fully updated and tested
- updated Windows DLL port, with WiZ GUI spun off to a separate package
- full Universal Time (UTC or GMT) support for trans-timezone consistency
- cross-platform support for 8-bit characters (ISO Latin-1, OEM code pages)
- support for NT security descriptors (ACLs)
- support for overwriting OS/2 directory EAs if -o option given
- updated Solaris/SVR4 package facility
What is (still!) not added is multi-part archive support (a.k.a. "diskette
spanning") and a unified and more powerful DLL interface. These are the
two highest priorities for the 6.x releases. Work on the former is almost
certain to have commenced by the time you read this. This time we mean it!
You betcha. :-)
Although the DLLs are still basically a mess, the Windows DLLs (16- and 32-
bit) now have some documentation and a small example application. Note that
they should now be compatible with C/C++, Visual BASIC and Delphi. Weirder
languages (FoxBase, etc.) are probably Right Out.
Finally, note that support for unshrinking has now been turned OFF by default,
although the source code is still available (as with unreducing). This was
done for legal reasons, not technical ones, and no, we're not any happier
about it than you are. :-( See the COPYING file for details.
INTERNET RESOURCES
------------------
Info-ZIP's web site is at http://www.info-zip.org/pub/infozip/
and contains the most up-to-date information about coming releases,
links to binaries, and common problems.
(See http://www.info-zip.org/pub/infozip/FAQ.html for the latter.)
Files may also be retrieved via ftp://ftp.info-zip.org/pub/infozip/ .
Thanks to LEO (Munich, Germany) for hosting our primary site.
DISTRIBUTION
------------
If you have a question regarding redistribution of Info-ZIP software, either
as is, as packaging for a commercial product, or as an integral part of a
commercial product, please read the Frequently Asked Questions (FAQ) section
of the included COPYING file.
Insofar as C compilers are rare on some platforms and the authors only have
direct access to a subset of the supported systems, others may wish to pro-
vide ready-to-run executables for new systems. In general there is no prob-
lem with this; we require only that such distributions include this README
file, the WHERE file, the COPYING file (contains copyright/redistribution
information), and the appropriate documentation files (unzip.txt and/or
unzip.1 for UnZip, etc.). If the local system provides a way to make self-
extracting archives in which both the executables and text files can be
stored together, that's best (in particular, use UnZipSFX if at all possible,
even if it's a few kilobytes bigger than the alternatives); otherwise we
suggest a bare UnZip executable and a separate zipfile containing the re-
maining text and binary files. If another archiving method is in common
use on the target system (for example, Zoo or LHa), that may also be used.
BUGS AND NEW PORTS: CONTACTING INFO-ZIP
----------------------------------------
All bug reports and patches (context diffs only, please!) should go to
Zip-Bugs@lists.wku.edu, which is the e-mail address for the Info-ZIP
authors. (Note that a few rare systems require the Zip-Bugs part to be
capitalized as shown; most systems work OK with lowercase "zip-bugs,"
however.) DO NOT MAIL US LARGE BINARIES--EVER. If you need to send us
a problem archive that happens to be large (> 20K), contact us first for
instructions.
"Dumb questions" that aren't adequately answered in the documentation
should also be directed to Zip-Bugs rather than to a global forum such
as Usenet. (Kindly make certain that your question *isn't* answered by
the documentation, however--a great deal of effort has gone into making
it clear and complete.)
Suggestions for new features can be discussed on Info-ZIP@lists.wku.edu,
a mailing list for Info-ZIP beta testers and interested parties; you need
to subscribe first, however (see below). We make no promises to act on all
suggestions or even all patches, but if it is something that is manifestly
useful, sending the required patches to Zip-Bugs directly (as per the
instructions in the ZipPorts file) is likely to produce a quicker response
than asking us to do it--the authors are always ridiculously short on time.
(Please do NOT send patches or encoded zipfiles to the Info-ZIP list.
Please DO read the ZipPorts file before sending any large patch. It would
be difficult to over-emphasize this point...)
If you are considering a port, not only should you read the ZipPorts file,
but also please check in with Zip-Bugs BEFORE getting started, since the
code is constantly being updated behind the scenes. (For example, VxWorks,
VMOS and Netware ports were once claimed to be under construction, although
we have yet to see any up-to-date patches.) We will arrange to send you the
latest sources. The alternative is the possibility that your hard work will
be tucked away in a subdirectory and mostly ignored, or completely ignored
if someone else has already done the port (and you'd be surprised how often
this has happened).
BETA TESTING: JOINING INFO-ZIP
-------------------------------
If you'd like to keep up to date with our UnZip (and companion Zip utility)
development, join the ranks of beta testers, add your own thoughts and
contributions, or simply lurk, you may join one of our mailing lists.
There is an announcements-only list (Info-ZIP-announce) and a general
discussion/testing list (Info-ZIP). You must be a subscriber to post, and
you can subscribe via the links on our Frequently Asked Questions page:
http://www.info-zip.org/pub/infozip/FAQ.html#lists
(Please note that as of late May 2004, the lists are unavailable pending
a move to a new site; we hope to have them restored shortly. In the
interim ...) Feel free to use our bug-reporting web page for bug reports
and to ask questions not answered on the FAQ page above:
http://www.info-zip.org/zip-bug.html
There is also a closed mailing list for internal discussions of our core
development team. This list is now kept secret to prevent us from being
flooded with spam messages.
-- Greg Roelofs (sometimes known as Cave Newt), principal UnZip developer
guy, with inspiration from David Kirschbaum, was Author of this text.
-- Christian Spieler (shorthand: SPC), current UnZip maintenance coordinator,
applied the most recent changes.

179
unzip/unzip-5.52/ToDo Normal file
View File

@ -0,0 +1,179 @@
================================
For UnZip 6.0/6.1/who knows:
================================
o implement handling of file sizes beyond the 32-bit limit of
2GByte (resp. 4GByte), using the new 64-bit extra field extensions
as defined by PKWARE (this will not get implemented for the present
16-bit ports - plain DOS and OS/2 1.x)
top of the list for 6.0!
UnZip 6.0 is now under development, first betas for Win32 and Unix
are available
o add multi-part zipfile handling
major feature for 6.0!
could happen for 6.0 - 10/8/2004 EG
o better support for multilingual uses and different codepages;
support unicode (UTF-8 coded) filenames and comment texts
a requested feature getting more and more important,
maybe in 6.1
o add new low-level, binary API; rewrite "normal" (command-line) UnZip
to use it
maybe soon (maybe 6.1)
o use (simple!) configure script in combination with Unix Makefile
very soon (6.0 or 6.1)
may be needed in 6.0 to autodetect large file support - 10/8/2004 EG
o add precautions against extracting files outside the tree below
the current directory resp. the specified extraction folder.
(automatically remove absolute path specs from zip entries; emit
warnings when traversing outside the extraction tree...)
done as of version 5.51
o MSDOS/WIN32/others: detection of "reserved" names (= names of character
devices, or system extensions that look like a characters device driver)
at runtime; with the goal of emitting "meaningful" error messages and/or
rename queries.
(Currently, these reserved names are catched as "non-deletable files".
On MSDOS and WIN32, when the RTL stat() function allows to identify
character devices, the "reserved" names are automatically prefixed with
an underscore.)
o redesign "file exists -- is newer/older -- overwrite/skip/rename"
logic in extract.c and the corresponding system specific mapname()
services; to prevent superfluous decryption key prompts for entry
that will be skipped, later.
o rewrite to use fread/fseek/etc. [eventually: test
write(bytes) vs. fwrite(words), especially on Crays/Alphas]
soon (probably in conjunction with multi-part handling)
o incorporate new backfill version of inflate()
wait for zlib version
o check NEXTBYTE for EOF in crypt.c, funzip.c and explode.c, too
whenever
o add option to force completely non-interactive operation (no queries
for overwrite/rename, password, etc.); also allow some sort of non-
interactive password provision? (file? command-line? env. variable?)
someday?
o add testing of extra fields (if have CRC)
later
o rewrite to allow use as a filter
way, way later...
o add Unix hard-link support?
way, way later...
o add ".ini" file support as a (more elaborate) alternative to the presently
supported preconfiguring abilities via special environment variables
(UNZIP on many systems...)?
way, way later (if ever)...
o add option to search zipfile contents for a string and print the
results? ("zipgrep" option--e.g., unzip -g or unzip -S) (easy for
fixed strings, hard for wildcards/true regex's)
way, way later, if at all...probably use libregex
o add -y "display symlinks" option to zipinfo? various sorting options?
(-St date/time, -Sn name)?
who knows
o add "in-depth" option to zipinfo? (check local headers against
central, etc.)--make it a better debugging tool (or just create
zipfix)
who knows (zip -F, -FF already exist)
Some maintenance or OS specific topics for 6.0 release:
* add "unix-style-path -> partitioned-dataset filename" conversion
to MVS port
* should we add support for (null) entry names (empty entry name field), to
conform to the PKWARE specification?
=======================================
Requested features:
- extract or exclude on basis of UID [Armin Bub, Armin.Bub@bk.bosch.de, 970904]
=======================================
o miscellaneous little stuff: whenever
--------------------------
- add support for setting directory time stamps to win32 port. This requires
a solution similar to the UNIX SET_DIR_ATTRIB optional code; maybe, it could
be combined with the delayed restoring of directory ACLs. Unfortunately,
the simple version used in the OS/2 case (setting dir time stamp just after
creating the directory) does not work, because WinNT updates directory
change times whenever the directory content gets modified (addition,
deletion, rename, file change), at least for NTFS file systems.
(SPC, 2000-11-16)
- change DOS -f/-u stuff to use DOS API for getting filetimes, not stat()
- add (-N?) option to lose all user input and/or switch to "(*input)()"
function, replaceable by UzpAltMain() param
- add -@ option to read from stdin (zip) or from file (PKZIP)? (go32 built-in)
- add -oo option to overwrite OS/2 and DOS system and hidden files, too
- add option to compute MD5 checksum on files and/or on entire zipfile?
- decide whether to use WinGUI "skipping" diagnostics in extract.c
- combine "y/n/A/N" query/response stuff into unified section with query
function(s) (InputFn?)
- disable ^V code in remaining mapname() routines
- change filename-matching logic so case-insensitive if case-sensitive fails?
- allow multiple dir creation with -d option? [Bob Maynard]
- use gcc -pg, gprof to do profiling on unzip
- Doug Patriarche (doug.patriarche.bvdhp01@nt.com) Northern Telecom Canada Ltd.
"I need to do a port of zip/unzip for Wind River Systems' VxWorks OS"
[GRR: 15 March 95 -> "early June"]
Features from old BUGS file (mostly duplicates of other entries above):
- ignore case for internal filename match on non-Unix systems, unless file-
specs enclosed in single quotes
- modify to decompress input stream if part of a pipe, but continue using
central directory if not (BIG job!)--extended local header capability
- add zipinfo option(s) to sort alphabetically, by date/time, in reverse, etc.
- when listing filenames, use '?' for non-printables? [Thomas Wolff, 92.6.1]
- add zipinfo "in-depth" option? (check local vs. central filenames, etc.)
- create zipcat program to concatenate zipfiles
- add -oo option (overwrite and override)? no user queries (if bad password,
skip file; if disk full, take default action; if VMS special on non-VMS,
unpack anyway; etc.)
- add -Q[Q[Q]] option (quiet mode on comments, cautions, warnings and errors)?
forget -oo, or make synonym? Default level -Q?

258
unzip/unzip-5.52/WHERE Normal file
View File

@ -0,0 +1,258 @@
__________________________________________________________________________
This is the Info-ZIP file ``WHERE,'' last updated on 17 February 2005.
__________________________________________________________________________
The latest version of this file can be found online at:
ftp://ftp.info-zip.org/pub/infozip/doc/WHERE
Note that some ftp sites may not yet have the latest versions of Zip
and UnZip when you read this. The latest versions always appear in
ftp://ftp.info-zip.org/pub/infozip/ (and subdirectories thereof) first,
except for encryption binaries, which always appear in
ftp://ftp.icce.rug.nl/infozip/ (and subdirectories) first.
IF YOU FIND AN ERROR: please let us know! We don't have time to
check each and every site personally (or even collectively), so any
number of the sites listed below may have moved or disappeared en-
tirely. E-mail to Zip-Bugs@lists.wku.edu and we'll update this file.
__________________________________________________________________________
Info-ZIP's home WWW site is listed on Yahoo and is at:
ftp://ftp.info-zip.org/pub/infozip/Info-ZIP.html (master version)
http://ftp.info-zip.org/pub/infozip/ (master version)
http://www.info-zip.org/
Note that the old sites at http://www.cdrom.com/pub/infozip/ and
http://www.freesoftware.com/pub/infozip are PERMANENTLY BROKEN. They
cannot be updated or removed, apparently.
The Zip and UnZip pages have links to most known mirror sites carrying our
source and/or binary distributions, and they generally are more up-to-date
and have better information than what you are reading:
ftp://ftp.info-zip.org/pub/infozip/Zip.html
ftp://ftp.info-zip.org/pub/infozip/UnZip.html
The related zlib package by Info-ZIP's Jean-loup Gailly and Mark Adler is at:
http://www.zlib.org/
Source-code archives for Info-ZIP's portable Zip, UnZip, and related
utilities:
zip231.zip Zip 2.31 (deflation; includes zipnote/zipsplit/zipcloak)
zip231.tar.Z ditto, compress'd tar format
zip11.zip Zip 1.1 (shrinking, implosion; compatible w. PKUNZIP 1.1)
zip11.tar.Z ditto, compress'd tar format
unzip552.zip UnZip 5.52 (all methods[*]; unzip/funzip/unzipsfx/zipgrep)
unzip552.tar.gz ditto, gzip'd tar format
unzip552.tar.Z ditto, compress'd tar format
unred552.zip UnZip 5.52 add-on, contains copyrighted unreduce support
zcrypt29.zip encryption support for Zip 2.3[**]
zcrypt10.zip encryption support for Zip 1.1
MacZip106src.zip contains all the GUI stuff and the project files to build
the MacZip main-app. To build MacZip successfully, both
the Zip 2.31 and UnZip 5.52 sources are required, too.
wiz502.zip WiZ 5.02, Windows 9x/NT GUI front-end for Info-ZIP DLLs
wiz502+dlls.zip WiZ 5.02, Windows 9x/NT GUI front-end plus DLL sources
[*] Unreducing is disabled by default, but is available as add-on.
As of July 2004, Unisys's LZW patent was expired worldwide, and
unshrinking is turned on by default since the release of UnZip 5.52.
See UnZip's INSTALL file for details.
[**] As of January 2000, US export regulations were amended to allow export
of free encryption source code from the US. As of June 2002, these
regulations were further relaxed to allow export of encryption binaries
associated with free encryption source code. The Zip 2.31, UnZip 5.52
and Wiz 5.02 archives now include full crypto source code. As of the
Zip 2.31 release, all official binaries include encryption support; the
former "zcr" archives ceased to exist.
(Note that restrictions may still exist in other countries, of course.)
Executables archives (and related files) for Info-ZIP's software; not all
of these will be immediately available due to lack of access to appropriate
systems on the part of Info-ZIP members.
zip231x.zip MSDOS executables and docs
zip231x1.zip OS/2 1.x (16-bit) executables and docs
zip231x2.zip OS/2 2/3/4.x (32-bit) executables and docs
zip231xA.zip Amiga executables and docs
zip231xB.zip BeOS executables and docs
zip231xC.zip VM/CMS executable and docs
zip231xK.zip Tandem NSK executables and docs
zip231xM.xmit MVS classic executable
zip231xM-docs.zip MVS classic port, docs only
zip231dN.zip WinNT/Win9x (Intel) DLL, header files, docs
zip231xN.zip WinNT/Win9x (Intel) executables and docs
zip231xN-axp.zip WinNT (Alpha AXP) executables and docs
zip231xN-mip.zip WinNT (MIPS R4000) executables and docs
zip231xN-ppc.zip WinNT (PowerPC) executables and docs
zip231xO.zip IBM OS/390 Open Edition binaries and docs
zip231xQ.zip SMS/QDOS executables and docs
zip231xR.zip Acorn RISC OS executables and docs
zip231xT.zip Atari TOS executables and docs
zip231-vms-axp-obj.zip
VMS (Alpha AXP) object libs, link procedure and docs
zip231-vms-axp-exe.zip
VMS (Alpha AXP) executables for VMS 6.1 or later and docs
zip231-vms-vax-decc-obj.zip
VMS (VAX) object libs (new DEC C), link procedure and docs
zip231-vms-vax-decc-exe.zip
VMS (VAX) executables (DEC C) for VMS 6.1 or later; docs
zip231-vms-vax-vaxc-obj.zip
VMS (VAX) object libs (old VAX C), link procedure and docs
zip231x.hqx Macintosh BinHex'd executables and docs
unz552x.exe MSDOS self-extracting executable (16-bit unzip, ..., docs)
unz552x3.exe MSDOS self-extracting executable (16-, 32-bit unzip, docs)
unz552x1.exe OS/2 1.x (16-bit) self-extracting executables and docs
unz552x2.exe OS/2 2/3/4.x (32-bit) self-extracting executables and docs
unz552d2.zip OS/2 2/3/4.x (32-bit) DLL, header file, demo exe and docs
unz552xA.ami Amiga self-extracting executables and docs
unz552xA.lha Amiga executables and docs, LHa archive
unz552xB.sfx BeOS self-extracting executables and docs
unz552xB.tar.gz BeOS executables and docs, gzip'd tar archive
unz552xC.mod VM/CMS executable module in "packed" format
unz552xC-docs.zip VM/CMS docs, only
unz552xF.zip FlexOS executable and docs
unz552xK.zip Tandem NSK executable and docs
unz552xM.xmit MVS classic executable
unz552xM-docs.zip MVS classic port, docs only
unz552dN.zip NT4/W2K/XP/2K3/W9x (32-bit Intel) DLL, header files, docs
unz552xN.exe NT/2K/XP/2K3/W9x self-extracting i386 executables and docs
unz552xN-axp.exe WinNT (Alpha AXP) self-extracting executables and docs
unz552xN-mip.exe WinNT (MIPS R4000) self-extracting executables and docs
unz552xN-ppc.exe WinNT (PowerPC) self-extracting executables and docs
unz552xQ.sfx SMS/QDOS self-extracting executables and docs
unz552xO.tar.Z IBM OS/390 Open edition (Unix-like), exes and docs
unz552xR.exe Acorn RISC OS self-extracting executables and docs
unz552xR.spk Acorn RISC OS Spark'd executables and docs
unz552xT.tos Atari TOS self-extracting executables and docs
unz552x-vms-axp-obj.bck VMS backup saveset,
contains UnZip (Alpha) obj libs, link procedure, docs
unz552x-vms-axp-obj.exe VMS (Alpha AXP) SFX archive (statically linked),
contains UnZip (Alpha) obj libs, link procedure, docs
unz552x-vms-axp-exe.exe VMS (Alpha AXP) SFX archive (dynamically linked),
contains UnZip (Alpha AXP, DEC C) executables and docs,
smaller than object archive, but requires VMS 6.1
unz552x-vms-vax-decc-obj.bck VMS backup saveset,
contains UnZip (new DEC C) obj libs, link procedure, docs
unz552x-vms-vax-decc-obj.exe VMS (VAX) SFX archive (statically linked),
contains UnZip (new DEC C) obj libs, link procedure, docs
unz552x-vms-vax-decc-exe.exe VMS (VAX) SFX archive (dynamically linked),
contains UnZip (new DEC C) executables and docs,
smaller than object archive, but requires VMS 6.1
unz552x-vms-vax-vaxc-obj.bck VMS backup saveset,
contains UnZip (old VAX C) obj libs, link procedure, docs
unz552x-vms-vax-vaxc-obj.exe VMS (VAX) SFX archive (statically linked),
contains UnZip (old VAX C) obj libs, link procedure, docs
unz552x.hqx Macintosh BinHex'd executables and docs for unzip
(unz552x.tar.{Z,gz} Unix exes/docs for Solaris 2.x, SCO Unix, Linux, etc.,
depending on directory/location; generally only provided
in cases where the OS does *not* ship with a bundled C
compiler)
MacZip106nc.hqx Macintosh combined Zip&UnZip application with GUI,
executables and docs (no encryption)
MacZip106c.hqx Macintosh combined Zip&UnZip application with GUI,
executables and docs (with encryption)
wiz502xN.exe WiZ 5.02 32-bit (Win9x/NT/2K/XP/2K3) app+docs (self-extr.)
UnzpHist.zip complete changes-history of UnZip and its precursors
ZipHist.zip complete changes-history of Zip
ftp/web sites for the US-exportable sources and executables:
NOTE: Look for the Info-ZIP file names given above (not PKWARE or third-
party stuff) in the following locations. Some sites like to use slightly
different names, such as zip-2.31.tar.gz instead of zip231.tar.Z.
ftp://ftp.info-zip.org/pub/infozip/ [THE INFO-ZIP HOME SITE]
ftp://sunsite.doc.ic.ac.uk/packages/zip/ [MIRRORS THE INFO-ZIP HOME SITE]
ftp://unix.hensa.ac.uk/mirrors/uunet/pub/archiving/zip/
ftp://ftp.cmdl.noaa.gov/aerosol/doc/archiver/{all,dos,os2,mac,vax_alpha}/
ftp://garbo.uwasa.fi/pc/arcers/ [AND OTHER GARBO MIRRORS]
ftp://garbo.uwasa.fi/unix/arcers/ [AND OTHER GARBO MIRRORS]
ftp://ftp.elf.stuba.sk/pub/pc/pack/ [AND OTHER STUBA MIRRORS]
ftp://ftp-os2.cdrom.com/pub/os2/archiver/
ftp://ftp-os2.nmsu.edu/os2/archiver/
ftp://ftp.informatik.tu-muenchen.de/pub/comp/os/os2/archiver/
ftp://sumex-aim.stanford.edu/info-mac/cmp/
ftp://ftp.wustl.edu/pub/aminet/util/arc/ [AND OTHER AMINET MIRRORS]
ftp://atari.archive.umich.edu/pub/Archivers/ [AND OTHER UMICH MIRRORS]
http://www.umich.edu/~archive/atari/Archivers/
ftp://jake.educom.com.au/pub/infozip/acorn/ [Acorn RISC OS]
http://www.sitec.net/maczip/ [MacZip port]
ftp/web sites for the encryption and decryption sources and/or executables:
Outside the US:
ftp://ftp.info-zip.org/pub/infozip/ [THE INFO-ZIP HOME SITE]
ftp://ftp.icce.rug.nl/infozip/ [THE INFO-ZIP ENCRYPTION HOME SITE]
ftp://ftp.elf.stuba.sk/pub/pc/pack/
ftp://garbo.uwasa.fi/pc/arcers/
ftp://ftp.inria.fr/system/arch-compr/
ftp://ftp.leo.org/pub/comp/os/os2/leo/archiver/
(mail server at ftp-mailer@ftp.leo.org)
ftp://ftp.win.tue.nl/pub/compression/zip/
ftp://ftp.uni-erlangen.de/pub/pc/msdos/arc-utils/zip/
The primary distribution site for the MacZip port can be found at:
http://www.sitec.net/maczip/
ftp sites for VMS-format Zip and UnZip packages (sources, object files and
executables, no encryption/decryption--see also "Mail servers" section below):
ftp.spc.edu [192.107.46.27] and ftp.wku.edu:
[.MACRO32]AAAREADME.TXT
[.MACRO32.SAVESETS]UNZIP.BCK or UNZIP.ZIP (if already have older version)
[.MACRO32.SAVESETS]ZIP.ZIP
To find other ftp/web sites:
The "archie" ftp database utility can be used to find an ftp site near
you (although the command-line versions always seem to find old ver-
sions...the `FTPsearch' server at http://ftpsearch.ntnu.no/ftpsearch
--formerly `Archie 95'--is quite up-to-date, however). Or check a stan-
dard WWW search engine like AltaVista (http://www.altavista.digital.com/)
or Yahoo (http://www.yahoo.com/). If you don't know how to use these,
DON'T ASK US--read the web sites' help pages or check the Usenet groups
news.announce.newusers or news.answers or some such, or ask your system
administrator.
Mail servers:
To get the encryption sources by e-mail, send the following commands
to ftp-mailer@informatik.tu-muenchen.de:
get /pub/comp/os/os2/archiver/zcrypt29.zip
quit
To get the VMS Zip/UnZip package by e-mail, send the following
commands in the body of a mail message to fileserv@wku.edu (the
"HELP" command is also accepted):
SEND FILESERV_TOOLS
SEND UNZIP
SEND ZIP
To get Atari executables by e-mail, send a message to
atari@atari.archive.umich.edu for information about the mail server.
__________________________________________________________________________

View File

@ -0,0 +1,26 @@
Contents of the "acorn" subdirectory for UnZip 5.4 and later:
acorn.c.acorn Acorn-specific resources
acorn.c.riscos mainly file-handling routines for FileCore-based filesystems
acorn.Contents this file
acorn.GMakeFile Makefile for gcc
acorn.h.riscos
acorn.h.swiven
acorn.makefile Makefile script for default Acorn C compiler
acorn.README notes about Acorn-specific features
acorn.RunMe1st Obey file to move files into suitable place for compilation
on RISC OS machines
acorn.s.swiven SWI veneers
acorn.srcrename small executable that converts files from Unix style to
RISC OS style, used by RunMe1st
Notes:
Use the "RunMe1st" file (it is an Obey file) to convert all the files from
"filename/[chs]" to "[chs].filename" (so that UnZip could be easily compiled
under RISC OS). It will also set the correct makefile.
To compile just set the CSD to the main UnZip directory and run 'amu'.
Currently only the Acorn C V5 compiler has been tested but probably also
Acorn C V4 and the Acorn Assembler V2 will be able to compile UnZip.

View File

@ -0,0 +1,142 @@
# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.2 or later)
# using gcc 2.95.4 (or later).
# You may look at <URL:http://hard-mofo.dsvr.net/gcc/> for an up-to-date
# gcc port.
CC = gcc -mlibscl
BIND = $(CC)
AS = $(CC) -c
ASM = as
SQUEEZE = squeeze -v
E =
# flags
# CFLAGS flags for C compile
# LFLAGS1 flags after output file spec, before obj file list
# LFLAGS2 flags after obj file list (libraries, etc)
#
LIB =
CFLAGS = -O2 -mthrowback -DNO_STRNICMP
ASMFLAGS = -throwback -objasm -upper
LFLAGS1 =
LFLAGS2 = $(LIB)
# object file lists
OBJS1 = o.unzip o.crc32 o.crctab o.crypt o.envargs o.explode
OBJS2 = o.extract o.fileio o.globals o.inflate o.list o.match
OBJS3 = o.process o.ttyio o.unreduce o.unshrink o.zipinfo
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) o.riscos o.swiven o.acorn
OBJF = o.funzip o.crc32 o.cryptf o.globalsf o.inflatef o.ttyiof \
o.riscos o.swiven
OBJX = o.unzipsfx o.crc32 o.crctab_ o.crypt_ o.extract_ o.fileio_ o.globals_ \
o.inflate_ o.match_ o.process_ o.ttyio_ o.acorn_ o.swiven o.riscos_
UNZIP_H = h.unzip h.unzpriv h.globals acorn.h.riscos acorn.h.swiven
all: unzip funzip unzipsfx
install: unzip funzip unzipsfx
$(SQUEEZE) unzip %.unzip
$(SQUEEZE) funzip %.funzip
$(SQUEEZE) unzipsfx unzipsfx
copy %.unzip %.zipinfo ~CVF
# rules for unzip and funzip
o.crc32: c.crc32 $(UNZIP_H) h.zip
$(CC) $(CFLAGS) -c c.crc32 -o o.crc32
o.crctab: c.crctab $(UNZIP_H) h.zip
$(CC) $(CFLAGS) -c c.crctab -o o.crctab
o.crypt: c.crypt $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -c c.crypt -o o.crypt
o.envargs: c.envargs $(UNZIP_H)
$(CC) $(CFLAGS) -c c.envargs -o o.envargs
o.explode: c.explode $(UNZIP_H)
$(CC) $(CFLAGS) -c c.explode -o o.explode
o.extract: c.extract $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -c c.extract -o o.extract
o.fileio: c.fileio $(UNZIP_H) h.crypt h.ttyio h.ebcdic
$(CC) $(CFLAGS) -c c.fileio -o o.fileio
o.funzip: c.funzip $(UNZIP_H) h.crypt h.ttyio h.tables
$(CC) $(CFLAGS) -c c.funzip -o o.funzip
o.globals: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -c c.globals -o o.globals
o.inflate: c.inflate h.inflate $(UNZIP_H)
$(CC) $(CFLAGS) -c c.inflate -o o.inflate
o.list: c.list $(UNZIP_H)
$(CC) $(CFLAGS) -c c.list -o o.list
o.match: c.match $(UNZIP_H)
$(CC) $(CFLAGS) -c c.match -o o.match
o.process: c.process $(UNZIP_H)
$(CC) $(CFLAGS) -c c.process -o o.process
o.ttyio: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -c c.ttyio -o o.ttyio
o.unreduce: c.unreduce $(UNZIP_H)
$(CC) $(CFLAGS) -c c.unreduce -o o.unreduce
o.unshrink: c.unshrink $(UNZIP_H)
$(CC) $(CFLAGS) -c c.unshrink -o o.unshrink
o.unzip: c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
$(CC) $(CFLAGS) -c c.unzip -o o.unzip
o.zipinfo: c.zipinfo $(UNZIP_H)
$(CC) $(CFLAGS) -c c.zipinfo -o o.zipinfo
o.crctab_: c.crctab $(UNZIP_H) h.zip
$(CC) $(CFLAGS) -DSFX -c c.crctab -o o.crctab_
o.crypt_: c.crypt $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DSFX -c c.crypt -o o.crypt_
o.extract_: c.extract $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
o.fileio_: c.fileio $(UNZIP_H) h.crypt h.ttyio h.ebcdic
$(CC) $(CFLAGS) -DSFX -c c.fileio -o o.fileio_
o.globals_: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.globals -o o.globals_
o.inflate_: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DSFX -c c.inflate -o o.inflate_
o.match_: c.match $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.match -o o.match_
o.process_: c.process $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.process -o o.process_
o.ttyio_: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DSFX -c c.ttyio -o o.ttyio_
o.unzipsfx: c.unzip $(UNZIP_H) h.crypt h.unzvers h.consts
$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx
o.cryptf: c.crypt $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.cryptf
o.globalsf: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globalsf
o.inflatef: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflatef
o.ttyiof: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyiof
o.acorn: acorn.c.acorn $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c acorn.c.acorn
o.acorn_: acorn.c.acorn $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.acorn_ acorn.c.acorn
o.riscos: acorn.c.riscos $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c acorn.c.riscos
o.riscos_: acorn.c.riscos $(UNZIP_H)
$(CC) $(CFLAGS) -I@ -c -DSFX -DSFX_EXDIR -o o.riscos_ acorn.c.riscos
o.swiven: acorn.s.swiven
$(ASM) $(ASMFLAGS) acorn.s.swiven -o o.swiven
unzip: $(OBJS)
$(BIND) -o unzip$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
funzip: $(OBJF)
$(BIND) -o funzip$(E) $(LFLAGS1) $(OBJF) $(LFLAGS2)
unzipsfx: $(OBJX)
$(BIND) -o unzipsfx$(E) $(LFLAGS1) $(OBJX) $(LFLAGS2)
clean:
remove unzip
remove funzip
remove zipinfo
remove unzipsfx
create o.!fake! 0
wipe o.* ~cf
# end of Makefile

View File

@ -0,0 +1,69 @@
Acorn-specific usage instructions
---------------------------------
As zipfiles can come from a variety of sources apart from Acorn machines,
consideration had to be given to the handling of dot-extensions, e.g.
"DOSFILE.TXT", "unix-filename.tar.gz". These are extracted as "DOSFILE/TXT"
and "unix-filename/tar/gz"; their names may or may not be truncated,
depending on where the files are being created: what filing system and, for
Filecore-based filing systems such as ADFS or an IDEFS or SCSIFS, which
disk/partition format (names will not be truncated if you're using E+ or F+).
Where truncation occurs, you must be REALLY careful about extracting files
from archives. The files
dummy_source.c and dummy_source.h
will both be extracted as
dummy_sour
UnZip will prompt you for confirmation of the over-writing of these files,
but you must be really careful unless you wish to lose files! Also, because
UnZip is a unix-ported program, the filenames are CASE SENSITIVE.
*unzip new/zip newfile
will extract 'newfile', but not 'NewFile', 'NEWFILE' or any other
combinations. However, you can use the -C option to force operations to
disregard the case of filenames.
The Acorn UnZip port has an additional feature to cope with the extraction of
files containing 'c' code. As you may be aware, Acorn Desktop C requires all
files called "foo.c" to be renamed to "c.foo", ie "foo" in a directory called
"c".
There are two ways of using this feature.
- The old way: use a colon-separated environment variable named "Unzip$Exts".
Any extensions found in this variable will be extracted to directories
named after the extension, with the extension stripped. For example:
*Set Unzip$Exts "c:h:o:s"
*unzip foo/zip
- The new way: use the -/ option. For example:
Any extensions found in the parameter for this option will be extracted to
directories named after the extension, with the extension stripped. For
example:
*unzip -/c:h:o:s foo/zip
If foo/zip contains a file named "foo.c", this file will be written as "foo"
in directory "c". This can be used to include "c:h:o:s:txt" to pull all the
text files out to a separate directory.
UnZip fully supports SparkFS Extra Field. This means that zipfiles created
with SparkFS or Zip (on RISC OS) will be correctly unzipped, including
filetypes.
UnZipSFX can be used to create self-extracting archives. To use it, just
create a common zipfile using Zip (or SparkFS), then load the UnZipSFX
executable into an editor (eg. Edit, Zap), go with the caret the end of the
file (using CTRL-CursorDown) and drag the zipfile to the editor window (in
other words, append the zipfile to the UnZipSFX executable). Now, saving the
resulting file (with filetype Absolute (&FF8)), you have a self-extracting
archive (ie. double-clicking on it will unzip the contents of the original
zipfile to the currently selected directory).

View File

@ -0,0 +1,17 @@
| This Obey file prepares the UnZip port for a Desktop C re-compile.
| Run it and it will copy all the needed files into the correct
| place.
| Set the correct type of 'srcrename' so that the only requirement
| for the user is to set 'RunMe1st' to Obey
SetType <Obey$Dir>.srcrename FF8
| Run 'srcrename' on the main UnZip directory with recursion enabled
/<Obey$Dir>.srcrename -r -e c:h:s:o <Obey$Dir>.^
| Create the 'o' directory
CDir <Obey$Dir>.^.o
| Put the Makefile in its correct place and set the correct filetype
SetType <Obey$Dir>.makefile FE1
Copy <Obey$Dir>.makefile <Obey$Dir>.^.makefile ~C ~V F

View File

@ -0,0 +1,989 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
acorn.c
RISCOS-specific routines for use with Info-ZIP's UnZip 5.2 and later.
Contains: do_wild() <-- generic enough to put in fileio.c?
mapattr()
mapname()
checkdir()
mkdir()
setRISCOSexfield()
printRISCOSexfield()
close_outfile()
stamp_file()
version()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "^.unzip.h"
#include "riscos.h"
#define FTYPE_FFF (1<<17) /* set filetype to &FFF when extracting */
#ifdef WILD_STOP_AT_DIR
# define WESEP , (oU.W_flag ? '.' : '\0')
#else
# define WESEP
#endif
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
static int has_mimemap = -1; /* used in mimemap() */
extern int mkdir(const char *path, int mode);
static int has_NFS_ext(const char *name);
static void setRISCOSexfield(ZCONST char *path, ZCONST void *ef_spark);
#ifdef DEBUG
static void printRISCOSexfield(int isdir, ZCONST void *extra_field);
#endif
static int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut);
static int mimemap(const char *name);
#ifndef SFX
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
/**********************/
char *do_wild(__G__ wildspec)
__GDEF
ZCONST char *wildspec; /* only used first time on a given dir */
{
static DIR *wild_dir = (DIR *)NULL;
static ZCONST char *wildname;
static char *dirname, matchname[FILNAMSIZ];
static int notfirstcall=FALSE, have_dirname, dirnamelen;
struct dirent *file;
/* Even when we're just returning wildspec, we *always* do so in
* matchname[]--calling routine is allowed to append four characters
* to the returned string, and wildspec may be a pointer to argv[].
*/
if (!notfirstcall) { /* first call: must initialize everything */
notfirstcall = TRUE;
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = (ZCONST char *)strrchr(wildspec, '.')) ==
(ZCONST char *)NULL)
{
dirname = ".";
dirnamelen = 1;
have_dirname = FALSE;
wildname = wildspec;
} else {
++wildname; /* point at character after '/' */
dirnamelen = wildname - wildspec;
if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
Info(slide, 0x201, ((char *)slide,
"warning: cannot allocate wildcard buffers\n"));
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((wild_dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
if (file->d_name[0] == '/' && wildname[0] != '/')
continue; /* Unix: '*' and '?' do not match leading dot */
if (match(file->d_name, wildname, 0 WESEP)) { /* 0=case sens.*/
if (have_dirname) {
strcpy(matchname, dirname);
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
}
/* if we get to here directory is exhausted, so close it */
closedir(wild_dir);
wild_dir = (DIR *)NULL;
}
/* return the raw wildspec in case that works (e.g., directory not
* searchable, but filespec was not wild and file is readable) */
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (wild_dir == (DIR *)NULL) {
notfirstcall = FALSE; /* nothing left to try--reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
}
/* If we've gotten this far, we've read and matched at least one entry
* successfully (in a previous call), so dirname has been copied into
* matchname already.
*/
while ((file = readdir(wild_dir)) != (struct dirent *)NULL)
if (match(file->d_name, wildname, 0 WESEP)) { /* 0 == case sens. */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
closedir(wild_dir); /* have read at least one dir entry; nothing left */
wild_dir = (DIR *)NULL;
notfirstcall = FALSE; /* reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
} /* end function do_wild() */
#endif /* !SFX */
/**************************/
/* Function has_NFS_ext() */
/**************************/
static int has_NFS_ext(const char* name)
{
int i = strlen(name) - 4;
return (i >= 0 && name[i] == ',' && (i > 0 || name[i-1]=='/') &&
isxdigit(name[i+1]) && isxdigit(name[i+2]) && isxdigit(name[i+3]));
} /* end function has_NFS_ext() */
/**********************/
/* Function mapattr() */
/**********************/
int mapattr(__G)
__GDEF
{
ulg tmp = G.crec.external_file_attributes;
switch (G.pInfo->hostnum) {
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
case THEOS_:
tmp &= 0xF1FFFFFFL;
if ((tmp & 0xF0000000L) != 0x40000000L)
tmp &= 0x01FFFFFFL; /* not a dir, mask all ftype bits */
else
tmp &= 0x41FFFFFFL; /* leave directory bit as set */
/* fall through! */
case ACORN_:
case UNIX_:
case VMS_:
case ATARI_:
case ATHEOS_:
case BEOS_:
case QDOS_:
case TANDEM_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
if (G.pInfo->file_attr != 0 || !G.extra_field) {
break;
} else {
/* Some (non-Info-ZIP) implementations of Zip for Unix and
VMS (and probably others ??) leave 0 in the upper 16-bit
part of the external_file_attributes field. Instead, they
store file permission attributes in some extra field.
As a work-around, we search for the presence of one of
these extra fields and fall back to the MSDOS compatible
part of external_file_attributes if one of the known
e.f. types has been detected.
Later, we might implement extraction of the permission
bits from the VMS extra field. But for now, the work-around
should be sufficient to provide "readable" extracted files.
(For ASI Unix e.f., an experimental remap of the e.f.
mode value IS already provided!)
*/
ush ebID;
unsigned ebLen;
uch *ef = G.extra_field;
unsigned ef_len = G.crec.extra_field_length;
int r = FALSE;
while (!r && ef_len >= EB_HEADSIZE) {
ebID = makeword(ef);
ebLen = (unsigned)makeword(ef+EB_LEN);
if (ebLen > (ef_len - EB_HEADSIZE))
/* discoverd some e.f. inconsistency! */
break;
switch (ebID) {
case EF_ASIUNIX:
if (ebLen >= (EB_ASI_MODE+2)) {
G.pInfo->file_attr =
(unsigned)makeword(ef+(EB_HEADSIZE+EB_ASI_MODE));
/* force stop of loop: */
ef_len = (ebLen + EB_HEADSIZE);
break;
}
/* else: fall through! */
case EF_PKVMS:
/* "found nondecypherable e.f. with perm. attr" */
r = TRUE;
default:
break;
}
ef_len -= (ebLen + EB_HEADSIZE);
ef += (ebLen + EB_HEADSIZE);
}
if (!r)
break;
}
/* fall through! */
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
/* PKWARE's PKZip for Unix marks entries as FS_FAT_, but stores the
* Unix attributes in the upper 16 bits of the external attributes
* field, just like Info-ZIP's Zip for Unix. We try to use that
* value, after a check for consistency with the MSDOS attribute
* bits (see below).
*/
G.pInfo->file_attr = (unsigned)(tmp >> 16);
/* fall through! */
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case TOPS20_:
default:
/* Ensure that DOS subdir bit is set when the entry's name ends
* in a '/'. Some third-party Zip programs fail to set the subdir
* bit for directory entries.
*/
if ((tmp & 0x10) == 0) {
extent fnlen = strlen(G.filename);
if (fnlen > 0 && G.filename[fnlen-1] == '/')
tmp |= 0x10;
}
/* read-only bit --> write perms; subdir bit --> dir exec bit */
tmp = !(tmp & 1) << 1 | (tmp & 0x10) >> 4;
if ((G.pInfo->file_attr & 0700) == (unsigned)(0400 | tmp<<6))
/* keep previous G.pInfo->file_attr setting, when its "owner"
* part appears to be consistent with DOS attribute flags!
*/
break;
G.pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
break;
} /* end switch (host-OS-created-by) */
G.pInfo->file_attr&=0xFFFF;
G.pInfo->file_attr|=(0xFFDu<<20);
if (has_NFS_ext(G.filename)) {
int ftype=strtol(G.filename+strlen(G.filename)-3,NULL,16)&0xFFF;
G.pInfo->file_attr = (G.pInfo->file_attr & 0x000FFFFF) | (ftype<<20);
} else {
int type = mimemap(G.filename);
if (type == -1)
type = (G.crec.internal_file_attributes & 1) ? 0xFFF : 0xFFD;
G.pInfo->file_attr = (G.pInfo->file_attr & 0x000FFFFF) | (type<<20);
}
return 0;
} /* end function mapattr() */
/************************/
/* Function mimemap() */
/************************/
static int mimemap(const char *name)
{
const char *ext = name;
int type;
if (has_mimemap < 0)
has_mimemap =
!(SWI_OS_CLI("%RMEnsure MimeMap 0.05 RMLoad System:Modules.Network.MimeMap")
|| SWI_OS_CLI("%RMEnsure MimeMap 0.05"));
if (!has_mimemap)
return -1; /* no MimeMap module; fall back on text flag test */
do {
while (*ext && *ext!='.')
ext++;
if (!*ext)
return -1; /* no suitable extension; fallback */
type = SWI_MimeMap_Translate(ext++);
} while (type == -1);
return type;
}
/************************/
/* Function mapname() */
/************************/
int mapname(__G__ renamed)
__GDEF
int renamed;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - caution (truncated filename)
* MPN_INF_SKIP - info "skip entry" (dir doesn't exist)
* MPN_ERR_SKIP - error -> skip entry
* MPN_ERR_TOOLONG - error -> path is too long
* MPN_NOMEM - error (memory allocation failed) -> skip entry
* [also MPN_VOL_LABEL, MPN_CREATED_DIR]
*/
{
char pathcomp[FILNAMSIZ]; /* path-component buffer */
char *pp, *cp=(char *)NULL; /* character pointers */
char *lastsemi=(char *)NULL; /* pointer to last semi-colon in pathcomp */
int error = MPN_OK;
register unsigned workch; /* hold the character being tested */
char *checkswap=NULL; /* pointer the the extension to check */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return MPN_VOL_LABEL; /* can't set disk volume labels in RISCOS */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!uO.fflag || renamed);
created_dir = FALSE; /* not yet */
/* user gave full pathname: don't prepend rootpath */
renamed_fullpath = (renamed && (*G.filename == '/'));
if (checkdir(__G__ (char *)NULL, INIT) == MPN_NOMEM)
return MPN_NOMEM; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (uO.jflag) /* junking directories */
cp = (char *)strrchr(G.filename, '/');
if (cp == (char *)NULL) /* no '/' or not junking dirs */
cp = G.filename; /* point to internal zipfile-member pathname */
else
++cp; /* point to start of last component of path */
/*---------------------------------------------------------------------------
Begin main loop through characters in filename.
---------------------------------------------------------------------------*/
while ((workch = (uch)*cp++) != 0) {
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if (((error = checkdir(__G__ pathcomp, APPEND_DIR))
& MPN_MASK) > MPN_INF_TRUNC)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave direct. semi-colons alone */
checkswap=NULL; /* reset checking at start of new leafname */
break;
case '.':
*pp++ = '/';
checkswap=pp;
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
case ' ': /* change spaces to hard-spaces */
*pp++ = 160; /* (ISO 8859-1 Latin-1 codepage) */
break;
/* The following substitutions, unless stated otherwise, follow
* those for DOSFS. They translate special symbols into other
* characters which have no special meaning to RISC OS. */
case '#': *pp++ = '?'; break; /* single-char wildcard */
case '&': *pp++ = '+'; break;
case '@': *pp++ = '='; break;
case '%': *pp++ = ';'; break;
case '$': *pp++ = '<'; break;
case '^': *pp++ = '>'; break; /* parent-dir reference */
/* The following substitutions deal with the remaining special
* symbols. ('.' is handled above.) */
case '*': *pp++ = 0xD7; break; /* Latin-1 'multiply' */
case '"': *pp++ = '~'; break;
case ':': *pp++ = ';'; break;
case '\\': *pp++ = '/'; break;
case '|': *pp++ = 0xA6; break; /* Latin-1 'broken bar' */
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
/*---------------------------------------------------------------------------
Report if directory was created (and no file to create: filename ended
in '/'), check name to be sure it exists, and combine path and name be-
fore exiting.
---------------------------------------------------------------------------*/
if (G.filename[strlen(G.filename) - 1] == '/') {
checkdir(__G__ G.filename, GETPATH);
if (created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, " creating: %s\n",
FnFilter1(G.filename)));
}
/* set dir time (note trailing '/') */
return (error & ~MPN_MASK) | MPN_CREATED_DIR;
}
/* dir existed already; don't look for data to extract */
return (error & ~MPN_MASK) | MPN_INF_SKIP;
}
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!uO.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
FnFilter1(G.filename)));
return (error & ~MPN_MASK) | MPN_ERR_SKIP;
}
if (checkswap!=NULL) {
if (checkext(checkswap)) {
if ((error = checkdir(__G__ checkswap, APPEND_DIR)) > 1)
return error;
*(checkswap-1)=0; /* remove extension from pathcomp */
}
}
if (!uO.acorn_nfs_ext && has_NFS_ext(pathcomp)) {
/* remove the filetype extension unless requested otherwise */
/* the filetype should be already set by mapattr() */
pathcomp[strlen(pathcomp)-4]=0;
}
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH);
return error;
} /* end function mapname() */
/***********************/
/* Function checkdir() */
/***********************/
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - (on APPEND_NAME) truncated filename
* MPN_INF_SKIP - path doesn't exist, not allowed to create
* MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path
* exists and is not a directory, but is supposed to be
* MPN_ERR_TOOLONG - path is too long
* MPN_NOMEM - can't allocate memory for filename buffers
*/
{
static int rootlen = 0; /* length of rootpath */
static char *rootpath; /* user's "extract-to" directory */
static char *buildpath; /* full path (so far) to extracted file */
static char *end; /* pointer to end of buildpath ('\0') */
# define FN_MASK 7
# define FUNCTION (flag & FN_MASK)
/*---------------------------------------------------------------------------
APPEND_DIR: append the path component to the path being built and check
for its existence. If doesn't exist and we are creating directories, do
so for this one; else signal success or error as appropriate.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_DIR) {
int too_long = FALSE;
#ifdef SHORT_NAMES
char *old_end = end;
#endif
Trace((stderr, "appending dir segment [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0')
++end;
#ifdef SHORT_NAMES /* path components restricted to 14 chars, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(end = old_end + FILENAME_MAX) = '\0';
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath after each append, set warning variable if
* within 20 of FILNAMSIZ; then if var set, do careful check when
* appending. Clear variable when begin new path. */
/* next check: need to append '/', at least one-char name, '\0' */
if ((end-buildpath) > FILNAMSIZ-3)
too_long = TRUE; /* check if extracting dir? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
FnFilter1(buildpath)));
fflush(stderr);
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: cannot create %s\n\
unable to process %s.\n",
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path didn't exist, tried to create, failed */
return MPN_ERR_SKIP;
}
created_dir = TRUE;
} else if (!S_ISDIR(G.statbuf.st_mode)) {
Info(slide, 1, ((char *)slide,
"checkdir error: %s exists but is not directory\n\
unable to process %s.\n",
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path existed but wasn't dir */
return MPN_ERR_SKIP;
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
*end++ = '.'; /************* was '/' *************/
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
return MPN_OK;
} /* end if (FUNCTION == APPEND_DIR) */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
strcpy(pathcomp, buildpath);
Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp)));
free(buildpath);
buildpath = end = (char *)NULL;
return MPN_OK;
}
/*---------------------------------------------------------------------------
APPEND_NAME: assume the path component is the filename; append it and
return without checking for existence.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_NAME) {
#ifdef SHORT_NAMES
char *old_end = end;
#endif
Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0') {
++end;
#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(end = old_end + FILENAME_MAX) = '\0';
#endif
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 0x201, ((char *)slide,
"checkdir warning: path too long; truncating\n\
%s\n -> %s\n",
FnFilter1(G.filename), FnFilter2(buildpath)));
return MPN_INF_TRUNC; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
/* could check for existence here, prompt for new name... */
return MPN_OK;
}
/*---------------------------------------------------------------------------
INIT: allocate and initialize buffer space for the file currently being
extracted. If file was renamed with an absolute path, don't prepend the
extract-to path.
---------------------------------------------------------------------------*/
/* GRR: for VMS and TOPS-20, add up to 13 to strlen */
if (FUNCTION == INIT) {
Trace((stderr, "initializing buildpath to "));
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))
== (char *)NULL)
return MPN_NOMEM;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", FnFilter1(buildpath)));
return MPN_OK;
}
/*---------------------------------------------------------------------------
ROOT: if appropriate, store the path in rootpath and create it if
necessary; else assume it's a zipfile member and return. This path
segment gets used in extracting all members from every zipfile specified
on the command line.
---------------------------------------------------------------------------*/
#if (!defined(SFX) || defined(SFX_EXDIR))
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n",
FnFilter1(pathcomp)));
if (pathcomp == (char *)NULL) {
rootlen = 0;
return MPN_OK;
}
if (rootlen > 0) /* rootpath was already set, nothing to do */
return MPN_OK;
if ((rootlen = strlen(pathcomp)) > 0) {
char *tmproot;
if ((tmproot = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return MPN_NOMEM;
}
strcpy(tmproot, pathcomp);
if (tmproot[rootlen-1] == '.') { /****** was '/' ********/
tmproot[--rootlen] = '\0';
}
if (rootlen > 0 && (SSTAT(tmproot, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode)))
{ /* path does not exist */
if (!G.create_dirs /* || isshexp(tmproot) */ ) {
free(tmproot);
rootlen = 0;
/* skip (or treat as stored file) */
return MPN_INF_SKIP;
}
/* create the directory (could add loop here scanning tmproot
* to create more than one level, but why really necessary?) */
if (mkdir(tmproot, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: cannot create extraction directory: %s\n",
FnFilter1(tmproot)));
free(tmproot);
rootlen = 0;
/* path didn't exist, tried to create, and failed: */
/* file exists, or 2+ subdir levels required */
return MPN_ERR_SKIP;
}
}
tmproot[rootlen++] = '.'; /*********** was '/' *************/
tmproot[rootlen] = '\0';
if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {
free(tmproot);
rootlen = 0;
return MPN_NOMEM;
}
Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath)));
}
return MPN_OK;
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
/********************/
/* Function mkdir() */
/********************/
int mkdir(path, mode)
const char *path;
int mode; /* ignored */
/*
* returns: 0 - successful
* -1 - failed (errno not set, however)
*/
{
return (SWI_OS_File_8((char *)path) == NULL)? 0 : -1;
}
/*********************************/
/* extra_field-related functions */
/*********************************/
static void setRISCOSexfield(ZCONST char *path, ZCONST void *ef_spark)
{
if (ef_spark!=NULL) {
extra_block *block=(extra_block *)ef_spark;
SWI_OS_File_1((char *)path,block->loadaddr,block->execaddr,block->attr);
}
}
#ifdef DEBUG
static void printRISCOSexfield(int isdir, ZCONST void *extra_field)
{
extra_block *block=(extra_block *)extra_field;
printf("\n This file has RISC OS file informations in the local extra field.\n");
if (isdir) {
/* I prefer not to print this string... should change later... */
/* printf(" The file is a directory.\n");*/
} else if ((block->loadaddr & 0xFFF00000) != 0xFFF00000) {
printf(" Load address: %.8X\n",block->loadaddr);
printf(" Exec address: %.8X\n",block->execaddr);
} else {
/************* should change this to use OS_FSControl 18 to get filetype string ************/
char tmpstr[16];
char ftypestr[32];
int flen;
sprintf(tmpstr,"File$Type_%03x",(block->loadaddr & 0x000FFF00) >> 8);
if (SWI_OS_ReadVarVal(tmpstr,ftypestr,32,&flen)==NULL) {
ftypestr[flen]=0;
printf(" Filetype: %s (&%.3X)\n",ftypestr,(block->loadaddr & 0x000FFF00) >> 8);
} else {
printf(" Filetype: &%.3X\n",(block->loadaddr & 0x000FFF00) >> 8);
}
}
printf(" Access: ");
if (block->attr & (1<<3))
printf("L");
if (block->attr & (1<<0))
printf("W");
if (block->attr & (1<<1))
printf("R");
printf("/");
if (block->attr & (1<<4))
printf("w");
if (block->attr & (1<<5))
printf("r");
printf("\n\n");
}
#endif /* DEBUG */
/**********************************************/
/* internal help function for time conversion */
/**********************************************/
static int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut)
{
unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */
unsigned timhi; /* 2 high bytes of acorn file-time */
timlo = ((unsigned)ut & 0x00ffffffU) * 100 + 0x00996a00U;
timhi = ((unsigned)ut >> 24);
timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
if (timhi & 0xffff0000U)
return 1; /* calculation overflow, do not change time */
/* insert the five time bytes into loadaddr and execaddr variables */
*pexadr = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
*pldadr = (*pldadr & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU);
return 0; /* subject to future extension to signal overflow */
}
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
{
zvoid *spark_ef;
fclose(G.outfile);
if ((spark_ef = getRISCOSexfield(G.extra_field, G.lrec.extra_field_length))
!= NULL) {
setRISCOSexfield(G.filename, spark_ef);
} else {
unsigned int loadaddr, execaddr;
int attr;
int mode=G.pInfo->file_attr&0xffff; /* chmod equivalent mode */
time_t m_time;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
#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.lrec.extra_field_length, 0,
G.lrec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME))
{
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
z_utime.mtime));
m_time = z_utime.mtime;
} else
#endif /* USE_EF_UT_TIME */
m_time = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
/* set the file's modification time */
SWI_OS_File_5(G.filename, NULL, &loadaddr, NULL, NULL, &attr);
uxtime2acornftime(&execaddr, &loadaddr, m_time);
loadaddr = (loadaddr & 0xfff000ffU) |
((G.pInfo->file_attr&0xfff00000) >> 12);
attr=(attr&0xffffff00) | ((mode&0400) >> 8) | ((mode&0200) >> 6) |
((mode&0004) << 2) | ((mode&0002) << 4);
SWI_OS_File_1(G.filename, loadaddr, execaddr, attr);
}
} /* end function close_outfile() */
#ifdef TIMESTAMP
/***************************/
/* Function stamp_file() */
/***************************/
int stamp_file(fname, modtime)
ZCONST char *fname;
time_t modtime;
{
unsigned int loadaddr, execaddr;
int attr;
/* set the file's modification time */
if (SWI_OS_File_5((char *)fname, NULL, &loadaddr, NULL, NULL, &attr)
!= NULL)
return -1;
if (uxtime2acornftime(&execaddr, &loadaddr, modtime) != 0)
return -1;
return (SWI_OS_File_1((char *)fname, loadaddr, execaddr, attr) == NULL) ?
0 : -1;
} /* end function stamp_file() */
#endif /* TIMESTAMP */
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
sprintf((char *)slide, LoadFarString(CompiledWith),
#ifdef __GNUC__
"gcc ", __VERSION__,
#else
# ifdef __CC_NORCROFT
"Norcroft ", "cc",
# else
"cc", "",
# endif
#endif
"RISC OS",
" (Acorn Computers Ltd)",
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);
} /* end function version() */
#endif /* !SFX */

View File

@ -0,0 +1,125 @@
# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.5 or later)
# last modified: 01 Mar 2004
# add -g to CC to debug
# add -d to BIND to debug
CC = cc
BIND = link
AS = $(CC) -c
ASM = objasm
SQUEEZE = squeeze -v
E =
# flags
# CFLAGS flags for C compile
# LFLAGS1 flags after output file spec, before obj file list
# LFLAGS2 flags after obj file list (libraries, etc)
#
LIB =
CBASE = -throwback -wn -DNO_STRNICMP
CFLAGS = $(CBASE) -IC:,@.
ASMFLAGS = -Throwback -Stamp -NoCache -CloseExec -quit
LFLAGS1 =
LFLAGS2 = $(LIB) C:o.Stubs
# object file lists
OBJS1 = unzip.o crc32.o crctab.o crypt.o envargs.o explode.o
OBJS2 = extract.o fileio.o globals.o inflate.o list.o match.o
OBJS3 = process.o ttyio.o unreduce.o unshrink.o zipinfo.o
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) riscos.o swiven.o acorn.o
OBJF = funzip.o crc32.o cryptf.o globalsf.o inflatef.o ttyiof.o \
riscos.o swiven.o
OBJX = unzipsfx.o crc32.o crctab.o crypt_.o extract_.o fileio_.o globals.o \
inflate.o match.o process_.o ttyio.o acorn_.o swiven.o riscos_.o
UNZIP_H = unzip.h unzpriv.h globals.h acorn/riscos.h acorn/swiven.h
all: unzip funzip unzipsfx
install: unzip funzip unzipsfx
$(SQUEEZE) unzip %.unzip
$(SQUEEZE) funzip %.funzip
$(SQUEEZE) unzipsfx unzipsfx
copy %.unzip %.zipinfo ~CVF
# suffix rules
.SUFFIXES: .o .c
.c.o:
$(CC) $(CFLAGS) -c $<
.s.o:
$(ASM) $(ASMFLAGS) -from @*.s -to @*.o
# rules for unzip and funzip
crc32.o: crc32.c $(UNZIP_H) zip.h
crctab.o: crctab.c $(UNZIP_H) zip.h
crypt.o: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs.o: envargs.c $(UNZIP_H)
explode.o: explode.c $(UNZIP_H)
extract.o: extract.c $(UNZIP_H) crypt.h
fileio.o: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip.o: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
globals.o: globals.c $(UNZIP_H)
inflate.o: inflate.c inflate.h $(UNZIP_H)
list.o: list.c $(UNZIP_H)
match.o: match.c $(UNZIP_H)
process.o: process.c $(UNZIP_H)
ttyio.o: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce.o: unreduce.c $(UNZIP_H)
unshrink.o: unshrink.c $(UNZIP_H)
unzip.o: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo.o: zipinfo.c $(UNZIP_H)
crypt_.o: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) $(CFLAGS) -DSFX -c c.crypt -o o.crypt_
extract_.o: extract.c $(UNZIP_H) crypt.h
$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
fileio_.o: fileio.c $(UNZIP_H) crypt.h
$(CC) $(CFLAGS) -DSFX -c c.fileio -o o.fileio_
globals_.o: globals.c $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globals_
inflate_.o: inflate.c inflate.h $(UNZIP_H) crypt.h
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflate_
process_.o: process.c $(UNZIP_H)
$(CC) $(CFLAGS) -DSFX -c c.process -o o.process_
ttyio_.o: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyio_
unzipsfx.o: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx
o.cryptf: c.crypt $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.cryptf
o.globalsf: c.globals $(UNZIP_H)
$(CC) $(CFLAGS) -DFUNZIP -c c.globals -o o.globalsf
o.inflatef: c.inflate h.inflate $(UNZIP_H) h.crypt
$(CC) $(CFLAGS) -DFUNZIP -c c.inflate -o o.inflatef
o.ttyiof: c.ttyio $(UNZIP_H) h.zip h.crypt h.ttyio
$(CC) $(CFLAGS) -DFUNZIP -c c.ttyio -o o.ttyiof
acorn.o: acorn/acorn.c $(UNZIP_H)
$(CC) $(CFLAGS) -c acorn/acorn.c
acorn_.o: acorn/acorn.c $(UNZIP_H)
$(CC) $(CFLAGS) -c -DSFX -DSFX_EXDIR -o acorn_.o acorn/acorn.c
riscos.o: acorn/riscos.c $(UNZIP_H)
$(CC) $(CFLAGS) -c acorn/riscos.c
riscos_.o: acorn/riscos.c $(UNZIP_H)
$(CC) $(CFLAGS) -c -DSFX -DSFX_EXDIR -o riscos_.o acorn/riscos.c
swiven.o: acorn/swiven.s
$(ASM) $(ASMFLAGS) -from acorn.s.swiven -to o.swiven
unzip: $(OBJS)
$(BIND) -o unzip$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
funzip: $(OBJF)
$(BIND) -o funzip$(E) $(LFLAGS1) $(OBJF) $(LFLAGS2)
unzipsfx: $(OBJX)
$(BIND) -o unzipsfx$(E) $(LFLAGS1) $(OBJX) $(LFLAGS2)
clean: ;remove unzip; remove funzip;
remove zipinfo; remove unzipsfx;
create o.!fake! 0
wipe o.* ~cf
# end of Makefile

View File

@ -0,0 +1,364 @@
/*
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* riscos.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* #define NO_UNZIPH_STUFF */
#define UNZIP_INTERNAL
#include "unzip.h"
#include "riscos.h"
#define MAXEXT 16
char *exts2swap = NULL; /* Extensions to swap (actually, directory names) */
int stat(char *filename,struct stat *res)
{
int attr; /* object attributes */
unsigned int load; /* load address */
unsigned int exec; /* exec address */
int type; /* type: 0 not found, 1 file, 2 dir, 3 image */
if (!res)
return -1;
if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
return -1;
if (type==0)
return -1;
res->st_dev=0;
res->st_ino=0;
res->st_nlink=0;
res->st_uid=1;
res->st_gid=1;
res->st_rdev=0;
res->st_blksize=1024;
res->st_mode = ((attr & 0001) << 8) | ((attr & 0002) << 6) |
((attr & 0020) >> 2) | ((attr & 0040) >> 4);
switch (type) {
case 1: /* File */
res->st_mode |= S_IFREG;
break;
case 2: /* Directory */
res->st_mode |= S_IFDIR | 0700;
break;
case 3: /* Image file */
if (uO.scanimage)
res->st_mode |= S_IFDIR | 0700;
else
res->st_mode |= S_IFREG;
break;
}
if ((((unsigned int) load) >> 20) == 0xfff) { /* date stamped file */
register unsigned int t1, t2, tc;
t1 = (unsigned int) (exec);
t2 = (unsigned int) (load & 0xff);
tc = 0x6e996a00U;
if (t1 < tc)
t2--;
t1 -= tc;
t2 -= 0x33; /* 00:00:00 Jan. 1 1970 = 0x336e996a00 */
t1 = (t1 / 100) + (t2 * 42949673U); /* 0x100000000 / 100 = 42949672.96 */
t1 -= (t2 / 25); /* compensate for .04 error */
res->st_atime = res->st_mtime = res->st_ctime = t1;
}
else
res->st_atime = res->st_mtime = res->st_ctime = 0;
return 0;
}
#ifndef SFX
DIR *opendir(char *dirname)
{
DIR *thisdir;
int type;
int attr;
os_error *er;
thisdir=(DIR *)malloc(sizeof(DIR));
if (thisdir==NULL)
return NULL;
thisdir->dirname=(char *)malloc(strlen(dirname)+1);
if (thisdir->dirname==NULL) {
free(thisdir);
return NULL;
}
strcpy(thisdir->dirname,dirname);
if (thisdir->dirname[strlen(thisdir->dirname)-1]=='.')
thisdir->dirname[strlen(thisdir->dirname)-1]=0;
if (er=SWI_OS_File_5(thisdir->dirname,&type,NULL,NULL,NULL,&attr),er!=NULL ||
type<=1 || (type==3 && !uO.scanimage))
{
free(thisdir->dirname);
free(thisdir);
return NULL;
}
thisdir->buf=malloc(DIR_BUFSIZE);
if (thisdir->buf==NULL) {
free(thisdir->dirname);
free(thisdir);
return NULL;
}
thisdir->size=DIR_BUFSIZE;
thisdir->offset=0;
thisdir->read=0;
return thisdir;
}
struct dirent *readdir(DIR *d)
{
static struct dirent dent;
if (d->read==0) { /* no more objects read in the buffer */
if (d->offset==-1) { /* no more objects to read */
return NULL;
}
d->read=255;
if (SWI_OS_GBPB_9(d->dirname,d->buf,&d->read,&d->offset,DIR_BUFSIZE,NULL)!=NULL)
return NULL;
if (d->read==0) {
d->offset=-1;
return NULL;
}
d->read--;
d->act=(char *)d->buf;
}
else { /* some object is ready in buffer */
d->read--;
d->act=(char *)(d->act+strlen(d->act)+1);
}
strcpy(dent.d_name,d->act);
dent.d_namlen=strlen(dent.d_name);
/* If we're returning the last item, check if there are any more.
* If there are, nothing will happen; if not, then d->offset = -1 */
if (!d->read)
SWI_OS_GBPB_9(d->dirname,d->buf,&d->read,&d->offset,0,NULL);
return &dent;
}
void closedir(DIR *d)
{
if (d->buf!=NULL)
free(d->buf);
if (d->dirname!=NULL)
free(d->dirname);
free(d);
}
int unlink(f)
char *f; /* file to delete */
/* Delete the file *f, returning non-zero on failure. */
{
os_error *er;
char canon[256];
int size=255;
er=SWI_OS_FSControl_37(f,canon,&size);
if (er==NULL) {
er=SWI_OS_FSControl_27(canon,0x100);
}
else {
er=SWI_OS_FSControl_27(f,0x100);
}
return (int)er;
}
int rmdir(char *d)
{
int objtype;
char *s;
int len;
len = strlen(d);
if ((s = malloc(len + 1)) == NULL)
return -1;
strcpy(s,d);
if (s[len-1]=='.')
s[len-1]=0;
if (SWI_OS_File_5(s,&objtype,NULL,NULL,NULL,NULL)!=NULL) {
free(s);
return -1;
}
if (objtype<2 || (!uO.scanimage && objtype==3)) {
/* this is a file or it doesn't exist */
free(s);
return -1;
}
if (SWI_OS_File_6(s)!=NULL) {
free(s);
return -1;
}
free(s);
return 0;
}
#endif /* !SFX */
int chmod(char *file, int mode)
{
/*************** NOT YET IMPLEMENTED!!!!!! ******************/
/* I don't know if this will be needed or not... */
file=file;
mode=mode;
return 0;
}
void setfiletype(char *fname,int ftype)
{
char str[256];
sprintf(str,"SetType %s &%3.3X",fname,ftype);
SWI_OS_CLI(str);
}
void getRISCOSexts(char *envstr)
{
char *envptr; /* value returned by getenv */
envptr = getenv(envstr);
if (envptr == NULL || *envptr == 0) return;
exts2swap=malloc(1+strlen(envptr));
if (exts2swap == NULL)
return;
strcpy(exts2swap, envptr);
}
int checkext(char *suff)
{
register char *extptr = exts2swap ? exts2swap : "";
register char *suffptr;
register int e,s;
while(*extptr) {
suffptr=suff;
e=*extptr; s=*suffptr;
while (e && e!=':' && s && s!='.' && s!='/' && e==s) {
e=*++extptr; s=*++suffptr;
}
if (e==':') e=0;
if (s=='.' || s=='/') s=0;
if (!e && !s) {
return 1;
}
while(*extptr!=':' && *extptr!='\0') /* skip to next extension */
extptr++;
if (*extptr!='\0')
extptr++;
}
return 0;
}
void swapext(char *name, char *exptr)
{
char ext[MAXEXT];
register char *p1=exptr+1;
register char *p2=ext;
int extchar=*exptr;
while(*p1 && *p1!='.' && *p1!='/')
*p2++=*p1++;
*p2=0;
p2=exptr-1;
p1--;
while(p2 >= name)
*p1--=*p2--;
p1=name;
p2=ext;
while(*p2)
*p1++=*p2++;
*p1=(extchar=='/'?'.':'/');
}
void remove_prefix(void)
{
SWI_DDEUtils_Prefix(NULL);
}
void set_prefix(void)
{
char *pref;
int size=0;
if (SWI_OS_FSControl_37("@",pref,&size)!=NULL)
return;
size=1-size;
if (pref=malloc(size),pref!=NULL) {
if (SWI_OS_FSControl_37("@",pref,&size)!=NULL) {
free(pref);
return;
}
if (SWI_DDEUtils_Prefix(pref)==NULL) {
atexit(remove_prefix);
}
free(pref);
}
}
#ifdef localtime
# undef localtime
#endif
#ifdef gmtime
# undef gmtime
#endif
/* Acorn's implementation of localtime() and gmtime()
* doesn't consider the timezone offset, so we have to
* add it before calling the library functions
*/
struct tm *riscos_localtime(const time_t *timer)
{
time_t localt=*timer;
localt+=SWI_Read_Timezone()/100;
return localtime(&localt);
}
struct tm *riscos_gmtime(const time_t *timer)
{
time_t localt=*timer;
localt+=SWI_Read_Timezone()/100;
return gmtime(&localt);
}

View File

@ -0,0 +1,136 @@
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* riscos.h */
#ifndef __riscos_h
#define __riscos_h
#include <time.h>
typedef struct {
int errnum;
char errmess[252];
} os_error;
#ifndef __swiven_h
# include "swiven.h"
#endif
#define MAXPATHLEN 256
#define MAXFILENAMELEN 64 /* should be 11 for ADFS, 13 for DOS, 64 seems a sensible value... */
#define DIR_BUFSIZE 1024 /* this should be enough to read a whole E-Format directory */
struct stat {
unsigned int st_dev;
int st_ino;
unsigned int st_mode;
int st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned int st_rdev;
unsigned int st_size;
unsigned int st_blksize;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
typedef struct {
char *dirname;
void *buf;
int size;
char *act;
int offset;
int read;
} DIR;
struct dirent {
unsigned int d_off; /* offset of next disk directory entry */
int d_fileno; /* file number of entry */
size_t d_reclen; /* length of this record */
size_t d_namlen; /* length of d_name */
char d_name[MAXFILENAMELEN]; /* name */
};
typedef struct {
unsigned int load_addr;
unsigned int exec_addr;
int lenght;
int attrib;
int objtype;
char name[13];
} riscos_direntry;
typedef struct {
short ID;
short size;
int ID_2;
unsigned int loadaddr;
unsigned int execaddr;
int attr;
int zero;
} extra_block;
#define S_IFMT 0770000
#define S_IFDIR 0040000
#define S_IFREG 0100000 /* 0200000 in UnixLib !?!?!?!? */
#ifndef S_IEXEC
# define S_IEXEC 0000100
# define S_IWRITE 0000200
# define S_IREAD 0000400
#endif
#ifndef NO_UNZIPH_STUFF
# include <time.h>
# if (!defined(HAVE_STRNICMP) & !defined(NO_STRNICMP))
# define NO_STRNICMP
# endif
# ifndef DATE_FORMAT
# define DATE_FORMAT DF_DMY
# endif
# define lenEOL 1
# define PutNativeEOL *q++ = native(LF);
# define USE_STRM_INPUT
# define USE_FWRITE
# define PIPE_ERROR (errno == 9999) /* always false */
# define isatty(x) (TRUE) /* used in funzip.c to find if stdin redirected:
should find a better way, now just work as if stdin never redirected */
# define USE_EF_UT_TIME
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
# endif
# define localtime riscos_localtime
# define gmtime riscos_gmtime
#endif /* !NO_UNZIPH_STUFF */
#define _raw_getc() SWI_OS_ReadC()
extern char *exts2swap; /* Extensions to swap */
int stat(char *filename,struct stat *res);
DIR *opendir(char *dirname);
struct dirent *readdir(DIR *d);
void closedir(DIR *d);
int unlink(char *f);
int rmdir(char *d);
int chmod(char *file, int mode);
void setfiletype(char *fname,int ftype);
void getRISCOSexts(char *envstr);
int checkext(char *suff);
void swapext(char *name, char *exptr);
void remove_prefix(void);
void set_prefix(void);
struct tm *riscos_localtime(const time_t *timer);
struct tm *riscos_gmtime(const time_t *timer);
#endif /* !__riscos_h */

Binary file not shown.

View File

@ -0,0 +1,69 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* swiven.h */
#ifndef __swiven_h
#define __swiven_h
os_error *SWI_OS_FSControl_26(char *source, char *dest, int actionmask);
/* copy */
os_error *SWI_OS_FSControl_27(char *filename, int actionmask);
/* wipe */
os_error *SWI_OS_GBPB_9(char *dirname, void *buf, int *number,
int *offset, int size, char *match);
/* read dir */
os_error *SWI_OS_File_1(char *filename, unsigned int loadaddr,
unsigned int execaddr, int attrib);
/* write file attributes */
os_error *SWI_OS_File_5(char *filename, int *objtype, unsigned int *loadaddr,
unsigned int *execaddr, int *length, int *attrib);
/* read file info */
os_error *SWI_OS_File_6(char *filename);
/* delete */
os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size);
/* create an empty file */
os_error *SWI_OS_File_8(char *dirname);
/* create a directory */
os_error *SWI_OS_File_18(char *filename, int filetype);
/* set a file's type */
os_error *SWI_OS_CLI(char *cmd);
/* execute a command */
int SWI_OS_ReadC(void);
/* get a key from the keyboard buffer */
os_error *SWI_OS_ReadVarVal(char *var, char *buf, int len, int *bytesused);
/* reads an OS varibale */
os_error *SWI_OS_FSControl_54(char *buffer, int dir, char *fsname, int *size);
/* reads the path of a specified directory */
os_error *SWI_OS_FSControl_37(char *pathname, char *buffer, int *size);
/* canonicalise path */
os_error *SWI_DDEUtils_Prefix(char *dir);
/* sets the 'prefix' directory */
int SWI_Read_Timezone(void);
/* returns the timezone offset (centiseconds) */
int SWI_MimeMap_Translate(const char *ext);
/* given a filename extn, returns the filetype (or -1 if no match).
* Uses the MimeMap module */
#endif /* !__swiven_h */

View File

@ -0,0 +1,316 @@
;===========================================================================
; Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
;
; See the accompanying file LICENSE, version 2000-Apr-09 or later
; (the contents of which are also included in unzip.h) for terms of use.
; If, for some reason, all these files are missing, the Info-ZIP license
; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
;===========================================================================
; SWI veneers used by Zip/Unzip
;
r0 RN 0
r1 RN 1
r2 RN 2
r3 RN 3
r4 RN 4
r5 RN 5
r6 RN 6
r7 RN 7
r8 RN 8
r9 RN 9
r10 RN 10
r11 RN 11
r12 RN 12
sp RN 13
lr RN 14
pc RN 15
sl RN 10
fp RN 11
ip RN 12
XOS_Bit EQU &020000
OS_GBPB EQU &00000C
OS_File EQU &000008
OS_FSControl EQU &000029
OS_CLI EQU &000005
OS_ReadC EQU &000004
OS_ReadVarVal EQU &000023
DDEUtils_Prefix EQU &042580
Territory_ReadCurrentTimeZone EQU &043048
MimeMap_Translate EQU &050B00
MACRO
STARTCODE $name
EXPORT $name
$name
MEND
AREA |C$$code|, CODE, READONLY
; os_error *SWI_OS_FSControl_26(char *source, char *dest, int actionmask);
STARTCODE SWI_OS_FSControl_26
MOV ip, lr
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #26
SWI OS_FSControl + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
; os_error *SWI_OS_FSControl_27(char *filename, int actionmask);
STARTCODE SWI_OS_FSControl_27
MOV ip, lr
MOV r3, r1
MOV r1, r0
MOV r0, #27
SWI OS_FSControl + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
; os_error *SWI_OS_GBPB_9(char *dirname, void *buf, int *number,
; int *offset, int size, char *match);
STARTCODE SWI_OS_GBPB_9
MOV ip, sp
STMFD sp!, {r2-r6,lr}
LDMIA ip, {r5,r6}
LDR r4, [r3]
LDR r3, [r2]
MOV r2, r1
MOV r1, r0
MOV r0, #9
SWI OS_GBPB + XOS_Bit
LDMVSFD sp!, {r2-r6,pc}^
MOV r0, #0
LDMFD sp, {r5,r6}
STR r3, [r5]
STR r4, [r6]
LDMFD sp!, {r2-r6,pc}^
; os_error *SWI_OS_File_1(char *filename, int loadaddr, int execaddr, int attrib);
STARTCODE SWI_OS_File_1
STMFD sp!, {r5,lr}
MOV r5, r3
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #1
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r5,pc}^
; os_error *SWI_OS_File_5(char *filename, int *objtype, int *loadaddr,
; int *execaddr, int *length, int *attrib);
STARTCODE SWI_OS_File_5
STMFD sp!, {r1-r5,lr}
MOV r1, r0
MOV r0, #5
SWI OS_File + XOS_Bit
LDMVSFD sp!, {r1-r5,pc}^
LDR lr, [sp]
TEQ lr, #0
STRNE r0, [lr]
LDR lr, [sp, #4]
TEQ lr ,#0
STRNE r2, [lr]
LDR lr, [sp, #8]
TEQ lr, #0
STRNE r3, [lr]
LDR lr, [sp ,#24]
TEQ lr, #0
STRNE r4, [lr]
LDR lr, [sp ,#28]
TEQ lr, #0
STRNE r5, [lr]
MOV r0, #0
LDMFD sp!, {r1-r5,pc}^
; os_error *SWI_OS_File_6(char *filename);
STARTCODE SWI_OS_File_6
STMFD sp!, {r4-r5,lr}
MOV r1, r0
MOV r0, #6
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
; os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size);
STARTCODE SWI_OS_File_7
STMFD sp!, {r4-r5,lr}
MOV r5, r3
MOV r4, #0
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #7
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
; os_error *SWI_OS_File_8(char *dirname);
STARTCODE SWI_OS_File_8
STMFD sp!, {r4,lr}
MOV r1, r0
MOV r4, #0
MOV r0, #8
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4,pc}^
; os_error *SWI_OS_File_18(char *filename, int filetype);
STARTCODE SWI_OS_File_18
STMFD sp!, {r4-r5,lr}
MOV r2, r1
MOV r1, r0
MOV r0, #18
SWI OS_File + XOS_Bit
MOVVC r0, #0
LDMFD sp!, {r4-r5,pc}^
; os_error *SWI_OS_CLI(char *cmd);
STARTCODE SWI_OS_CLI
MOV ip, lr
SWI OS_CLI + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
; int SWI_OS_ReadC(void);
STARTCODE SWI_OS_ReadC
MOV ip, lr
SWI OS_ReadC + XOS_Bit
MOVS pc, ip
; os_error *SWI_OS_ReadVarVal(char *var, char *buf, int len, int *bytesused);
STARTCODE SWI_OS_ReadVarVal
STMFD sp!, {r4,lr}
MOV ip, r3
MOV r3, #0
MOV r4, #0
SWI OS_ReadVarVal + XOS_Bit
LDMVSFD sp!, {r4,pc}^
TEQ ip, #0
STRNE r2, [ip]
MOV r0, #0
LDMFD sp!, {r4,pc}^
; os_error *SWI_OS_FSControl_54(char *buffer, int dir, char *fsname, int *size);
STARTCODE SWI_OS_FSControl_54
STMFD sp!, {r3-r6,lr}
LDR r5, [r3]
MOV r3, r2
MOV r2, r1
MOV r1, r0
MOV r0, #54
SWI OS_FSControl + XOS_Bit
LDMVSFD sp!, {r3-r6,pc}^
MOV r0, #0
LDMFD sp!, {r3}
STR r5, [r3]
LDMFD sp!, {r4-r6,pc}^
; os_error *SWI_OS_FSControl_37(char *pathname, char *buffer, int *size);
STARTCODE SWI_OS_FSControl_37
STMFD sp!, {r2,r3-r5,lr}
LDR r5, [r2]
MOV r3, #0
MOV r4, #0
MOV r2, r1
MOV r1, r0
MOV r0, #37
SWI OS_FSControl + XOS_Bit
LDMVSFD sp!, {r2,r3-r5,pc}^
MOV r0, #0
LDMFD sp!, {r2}
STR r5, [r2]
LDMFD sp!, {r3-r5,pc}^
; os_error *SWI_DDEUtils_Prefix(char *dir);
STARTCODE SWI_DDEUtils_Prefix
MOV ip, lr
SWI DDEUtils_Prefix + XOS_Bit
MOVVC r0, #0
MOVS pc, ip
; int SWI_Read_Timezone(void);
STARTCODE SWI_Read_Timezone
MOV ip, lr
SWI Territory_ReadCurrentTimeZone + XOS_Bit
MOVVC r0, r1
MOVVS r0, #0
MOVS pc, ip
; int SWI_MimeMap_Translate(char *ext);
STARTCODE SWI_MimeMap_Translate
MOV ip,lr
MOV r1, r0
MOV r0, #3
MOV r2, #0
SWI MimeMap_Translate + XOS_Bit
MOVVC r0, r3
MVNVS r0, #0 ; return -1 on error
MOVS pc, ip
END

View File

@ -0,0 +1,32 @@
Contents of the "amiga" directory for UnZip 5.5 and later:
Contents this file
amiga.c Amiga-specific file I/O routines
amiga.h Amiga-specific header file
filedate.c SetFileDate clone for OS 1.3, and other low-level resources
smakefile SAS/C makefile for UnZip, fUnZip, and UnZipSFX
makefile.azt Aztec C makefile for UnZip, fUnZip, and UnZipSFX
stat.c stat() emulation for Aztec, along with opendir()/readdir()/etc
z-stat.h replacement stat.h header file for use with stat.c
crc_68.a assembler version of crc32.c
flate.a assembler version of inflate_codes() (define ASM_INFLATECODES)
makesfx.c source for MakeSFX, without which UnZipSFX is not usable
Notes:
The crc_68.a source file is not currently used by the SAS/C makefile,
nor is flate.a; as of UnZip 5.2 neither of these wants args in
registers.
The DICE makefile has been removed since no one is supporting that
compiler anymore.
As of UnZip 5.2, if you have AmigaDOS 2.1 or newer and have set your
timezone in the Locale preferences editor, this will be an adequate
substitute for setting TZ. If you do not set TZ to your current timezone,
files will be restored with times corrsponding to "EST5EDT", U.S. Eastern
time. See ../proginfo/timezone.txt for directions on how to set the
TZ variable.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,177 @@
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* amiga.h
*
* Globular definitions that affect all of AmigaDom.
*
* Originally included in unzip.h, extracted for simplicity and eeze of
* maintenance by John Bush.
*
* THIS FILE IS #INCLUDE'd by unzpriv.h
*
*/
#ifndef __amiga_amiga_h
#define __amiga_amiga_h
#include "amiga/z-stat.h" /* substitute for <stat.h> and <direct.h> */
#include <limits.h>
#ifndef NO_FCNTL_H
# include <fcntl.h>
#else
int mkdir(const char *_name);
#endif
#ifdef AZTEC_C /* Manx Aztec C, 5.0 or newer only */
# include <clib/dos_protos.h>
# include <pragmas/dos_lib.h> /* do inline dos.library calls */
# define O_BINARY 0
# define direct dirent
# ifndef IZTZ_DEFINESTDGLOBALS
# define IZTZ_DEFINESTDGLOBALS
# endif
# define DECLARE_TIMEZONE
# define ASM_INFLATECODES
# define ASM_CRC
/* This compiler environment supplies a flat 32-bit address space */
/* where C rtl functions are capable of handling large (32-bit-wide) */
/* allocations and I/O. But, for speed on old 68000 CPUs, standard */
/* ints are 16-bits wide per default. ("size_t" is defined as */
/* "unsigned long" in this case.) The Deflate64 support requires */
/* the variables for handling the decompression buffer to hold */
/* 32-bit wide integers. The INT_16BIT symbol defined below forces */
/* the declarations of these variables to use "unsigned long" type. */
# ifndef _INT32
# define INT_16BIT /* or deflate64 stuff will fail */
# endif
/* Note that defining REENTRANT will not eliminate all global/static */
/* variables. The functions we use from c.lib, including stdio, are */
/* not reentrant. Neither are the stuff in amiga/stat.c or the time */
/* functions in amiga/filedate.c, because they just augment c.lib. */
/* If you want a fully reentrant and reexecutable "pure" UnZip with */
/* Aztec C, assemble and link in the startup module purify.a by Paul */
/* Kienitz. REENTRANT should be used just to reduce memory waste. */
#endif /* AZTEC_C */
#ifdef __SASC
/* includes */
# include <sys/types.h>
# include <sys/dir.h>
# include <dos.h>
# include <exec/memory.h>
# include <exec/execbase.h>
# if (defined(_M68020) && (!defined(__USE_SYSBASE)))
/* on 68020 or higher processors it is faster */
# define __USE_SYSBASE /* to use the pragma libcall instead of syscall */
# endif /* to access functions of the exec.library */
# include <proto/exec.h> /* see SAS/C manual:part 2,chapter 2,pages 6-7 */
# include <proto/dos.h>
# include <proto/locale.h>
# ifdef DEBUG
# include <sprof.h> /* profiler header file */
# endif
# if ( (!defined(O_BINARY)) && defined(O_RAW))
# define O_BINARY O_RAW
# endif
# if (defined(_SHORTINT) && !defined(USE_FWRITE))
# define USE_FWRITE /* define if write() returns 16-bit int */
# endif
# if (!defined(REENTRANT) && !defined(FUNZIP))
# define REENTRANT /* define if unzip is going to be pure */
# endif
# if defined(REENTRANT) && defined(DYNALLOC_CRCTAB)
# undef DYNALLOC_CRCTAB
# endif
# ifdef MWDEBUG
# include <stdio.h> /* both stdio.h and stdlib.h must be included */
# include <stdlib.h> /* before memwatch.h */
# include "memwatch.h"
# undef getenv
# endif /* MWDEBUG */
# ifndef IZTZ_SETLOCALTZINFO
/* XXX !! We have really got to find a way to operate without these. */
# define IZTZ_SETLOCALTZINFO
# endif
#endif /* SASC */
#define MALLOC_WORK
#define USE_EF_UT_TIME
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
#ifndef IZTZ_GETLOCALETZINFO
# define IZTZ_GETLOCALETZINFO GetPlatformLocalTimezone
#endif
/* the amiga port uses Info-ZIP's own timezone library, which includes
* a "working" mktime() implementation
*/
#ifndef HAVE_MKTIME
# define HAVE_MKTIME
#endif
/* check that TZ environment variable is defined before using UTC times */
#if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ))
# define IZ_CHECK_TZ
#endif
#define AMIGA_FILENOTELEN 80
#ifndef DATE_FORMAT
# define DATE_FORMAT DF_MDY
#endif
#define lenEOL 1
#define PutNativeEOL *q++ = native(LF);
#define PIPE_ERROR 0
#ifdef GLOBAL /* crypt.c usage conflicts with AmigaDOS headers */
# undef GLOBAL
#endif
/* Funkshine Prough Toe Taipes */
extern int real_timezone_is_set;
void tzset(void);
#define VALID_TIMEZONE(tempvar) (tzset(), real_timezone_is_set)
int Agetch(void); /* getch() like function, in amiga/filedate.c */
LONG FileDate(char *, time_t[]);
int screensize(int *ttrows, int *ttcols);
void _abort(void); /* ctrl-C trap */
#define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
#define SCREENWIDTH 80
#define SCREENLWRAP 1
#define TABSIZE 8
/* Static variables that we have to add to Uz_Globs: */
#define SYSTEM_SPECIFIC_GLOBALS \
int filenote_slot;\
char *(filenotes[DIR_BLKSIZ]);\
int created_dir, renamed_fullpath, rootlen;\
char *rootpath, *buildpath, *build_end;\
DIR *wild_dir;\
ZCONST char *wildname;\
char *dirname, matchname[FILNAMSIZ];\
int dirnamelen, notfirstcall;
/* filenotes[] and filenote_slot are for the -N option that restores */
/* comments of Zip archive entries as AmigaDOS filenotes. The others */
/* are used by functions in amiga/amiga.c only. */
/* created_dir and renamed_fullpath are used by mapname() and checkdir(). */
/* rootlen, rootpath, buildpath, and build_end are used by checkdir(). */
/* wild_dir, dirname, wildname, matchname[], dirnamelen and notfirstcall */
/* are used by do_wild(). */
#endif /* __amiga_amiga_h */

View File

@ -0,0 +1,144 @@
;===========================================================================
; Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
;
; See the accompanying file LICENSE, version 2000-Apr-09 or later
; (the contents of which are also included in zip.h) for terms of use.
; If, for some reason, all these files are missing, the Info-ZIP license
; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
;===========================================================================
; crc_68 created by Paul Kienitz, last modified 04 Jan 96.
;
; Return an updated 32 bit CRC value, given the old value and a block of data.
; The CRC table used to compute the value is gotten by calling get_crc_table().
; This replaces the older updcrc() function used in Zip and fUnZip. The
; prototype of the function is:
;
; ulg crc32(ulg crcval, uch *text, extent textlen);
;
; On the Amiga, type extent is always unsigned long, not unsigned int, because
; int can be short or long at whim, but size_t is long.
;
; If using this source on a non-Amiga 680x0 system, note that we treat
; a0/a1/d0/d1 as scratch registers not preserved across function calls.
; We do not bother to support registerized arguments for crc32() -- the
; textlen parm is usually large enough so that savings outside the loop
; are pointless.
;
; Define NO_UNROLLED_LOOPS to use a simple short loop which might be more
; efficient on certain machines with dinky instruction caches ('020?), or for
; processing short strings. If loops are unrolled, the textlen parm must be
; less than 512K; if not unrolled, it must be less than 64K.
xdef _crc32 ; (ulg val, uch *buf, extent bufsize)
DO_CRC0 MACRO
moveq #0,ltemp
move.b (textbuf)+,ltemp
eor.b crcval,ltemp
lsl.w #2,ltemp
move.l (crc_table,ltemp.w),ltemp
lsr.l #8,crcval
eor.l ltemp,crcval
ENDM
machine mc68020
DO_CRC2 MACRO
move.b (textbuf)+,btemp
eor.b crcval,btemp
lsr.l #8,crcval
move.l (crc_table,btemp.w*4),ltemp
eor.l ltemp,crcval
ENDM
crc_table equr a0 array of unsigned long
crcval equr d0 unsigned long initial value
textbuf equr a1 array of unsigned char
textbufsize equr d1 unsigned long (count of bytes in textbuf)
btemp equr d2
ltemp equr d3
xref _get_crc_table ; ulg *get_crc_table(void)
NOLIST
INCLUDE 'exec/execbase.i'
LIST
xref _SysBase ; struct ExecBase *
_crc32:
move.l 8(sp),d0
bne.s valid
moveq #0,d0
rts
valid: movem.l btemp/ltemp,-(sp)
jsr _get_crc_table
move.l d0,ltemp
move.l 12(sp),crcval
move.l 16(sp),textbuf
move.l 20(sp),textbufsize
not.l crcval
move.l _SysBase,crc_table
move.w AttnFlags(crc_table),btemp
move.l ltemp,crc_table
btst #AFB_68020,btemp
bne twenty
IFD NO_UNROLLED_LOOPS
bra.s decr
loop: DO_CRC0
decr: dbra textbufsize,loop
bra.s done
twenty: moveq #0,btemp
bra.s decr2
loop2: DO_CRC2
decr2: dbra textbufsize,loop2
ELSE ; !NO_UNROLLED_LOOPS
move.l textbufsize,btemp
lsr.l #3,textbufsize
bra decr8
loop8: DO_CRC0
DO_CRC0
DO_CRC0
DO_CRC0
DO_CRC0
DO_CRC0
DO_CRC0
DO_CRC0
decr8: dbra textbufsize,loop8
and.w #7,btemp
bra.s decr1
loop1: DO_CRC0
decr1: dbra btemp,loop1
bra done
twenty: moveq #0,btemp
move.l textbufsize,-(sp)
lsr.l #3,textbufsize
bra decr82
loop82: DO_CRC2
DO_CRC2
DO_CRC2
DO_CRC2
DO_CRC2
DO_CRC2
DO_CRC2
DO_CRC2
decr82: dbra textbufsize,loop82
move.l (sp)+,textbufsize
and.w #7,textbufsize
bra.s decr12
loop12: DO_CRC2
decr12: dbra textbufsize,loop12
ENDC ; ?NO_UNROLLED_LOOPS
done: movem.l (sp)+,btemp/ltemp
not.l crcval
;;;;; move.l crcval,d0 ; crcval already is d0
rts

View File

@ -0,0 +1,599 @@
/*
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Low-level Amiga routines shared between Zip and UnZip.
*
* Contains: FileDate()
* getenv() [replaces inadequate standard library version]
* setenv() [SAS/C only, replaces standard library version]
* set_TZ() [SAS/C only]
* GetPlatformLocalTimezone() [callback from timezone.c tzset()]
* time()
* sendpkt()
* Agetch()
*
* The first five are used by most Info-ZIP programs except fUnZip.
* The last two are used by all except the non-CRYPT version of fUnZip.
* Probably some of the stuff in here is unused by ZipNote and ZipSplit too...
* sendpkt() is used by Agetch() and FileDate(), and by screensize() in
* amiga/amiga.c (UnZip); time() is used only by Zip.
*/
/* HISTORY/CHANGES
* 2 Sep 92, Greg Roelofs, Original coding.
* 6 Sep 92, John Bush, Incorporated into UnZip 5.1
* 6 Sep 92, John Bush, Interlude "FileDate()" defined, which calls or
* redefines SetFileDate() depending upon AMIGADOS2 definition.
* 11 Oct 92, John Bush, Eliminated AMIGADOS2 switch by determining
* revision via OpenLibrary() call. Now only one version of
* the program runs on both platforms (1.3.x vs. 2.x)
* 11 Oct 92, John Bush, Merged with Zip version and changed arg passing
* to take time_t input instead of struct DateStamp.
* Arg passing made to conform with utime().
* 22 Nov 92, Paul Kienitz, fixed includes for Aztec and cleaned up some
* lint-ish errors; simplified test for AmigaDOS version.
* 11 Nov 95, Paul Kienitz, added Agetch() for crypt password input and
* UnZip's "More" prompt -- simplifies crypt.h and avoids
* use of library code redundant with sendpkt(). Made it
* available to fUnZip, which does not use FileDate().
* 22 Nov 95, Paul Kienitz, created a new tzset() that gets the current
* timezone from the Locale preferences. These exist only under
* AmigaDOS 2.1 and up, but it is probably correctly set on more
* Amigas than the TZ environment variable is. We check that
* only if TZ is not validly set. We do not parse daylight
* savings syntax except to check for presence vs. absence of a
* DST part; United States rules are assumed. This is better
* than the tzset()s in the Amiga compilers' libraries do.
* 15 Jan 96, Chr. Spieler, corrected the logic when to select low level
* sendpkt() (when FileDate(), Agetch() or windowheight() is used),
* and AMIGA's Agetch() (CRYPT, and UnZip(SFX)'s UzpMorePause()).
* 10 Feb 96, Paul Kienitz, re-fiddled that selection logic again, moved
* stuff around for clarity.
* 16 Mar 96, Paul Kienitz, created a replacement localtime() to go with the
* new tzset(), because Aztec's is hopelessly broken. Also
* gmtime(), which localtime() calls.
* 12 Apr 96, Paul Kienitz, daylight savings was being handled incorrectly.
* 21 Apr 96, Paul Kienitz, had to replace time() as well, Aztec's returns
* local time instead of GMT. That's why their localtime() was bad,
* because it assumed time_t was already local, and gmtime() was
* the one that checked TZ.
* 23 Apr 96, Chr. Spieler, deactivated time() replacement for UnZip stuff.
* Currently, the UnZip sources do not make use of time() (and do
* not supply the working mktime() replacement, either!).
* 29 Apr 96, Paul Kienitz, created a replacement getenv() out of code that
* was previously embedded in tzset(), for reliable global test
* of whether TZ is set or not.
* 19 Jun 96, Haidinger Walter, re-adapted for current SAS/C compiler.
* 7 Jul 96, Paul Kienitz, smoothed together compiler-related changes.
* 4 Feb 97, Haidinger Walter, added set_TZ() for SAS/C.
* 23 Apr 97, Paul Kienitz, corrected Unix->Amiga DST error by adding
* mkgmtime() so localtime() could be used.
* 28 Apr 97, Christian Spieler, deactivated mkgmtime() definition for ZIP;
* the Zip sources supply this function as part of util.c.
* 24 May 97, Haidinger Walter, added time_lib support for SAS/C and moved
* set_TZ() to time_lib.c.
* 12 Jul 97, Paul Kienitz, adapted time_lib stuff for Aztec.
* 26 Jul 97, Chr. Spieler, old mkgmtime() fixed (ydays[] def, sign vs unsign).
* 30 Dec 97, Haidinger Walter, adaptation for SAS/C using z-stat.h functions.
* 19 Feb 98, Haidinger Walter, removed alloc_remember, more SAS.C fixes.
* 23 Apr 98, Chr. Spieler, removed mkgmtime(), changed FileDate to convert to
* Amiga file-time directly.
* 24 Apr 98, Paul Kienitz, clip Unix dates earlier than 1978 in FileDate().
* 02 Sep 98, Paul Kienitz, C. Spieler, always include zip.h to get a defined
* header inclusion sequence that resolves all header dependencies.
* 06 Jun 00, Paul Kienitz, removed time_lib.c due to its incompatible license,
* moved set_TZ() back here, replaced minimal tzset() and localtime()
* with new versions derived from GNU glibc source. Gave locale_TZ()
* reasonable European defaults for daylight savings.
* 17 Jun 00, Paul Kienitz, threw out GNU code because of objections to the GPL
* virus, replaced with similar functions based on the public domain
* timezone code at ftp://elsie.nci.nih.gov/pub. As with the GNU
* stuff, support for timezone files and leap seconds was removed.
* 23 Aug 00, Paul Kienitz, moved timezone code out from here into separate
* platform-independent module 'timezone.c'.
* 31 Dec 00, Christian Spieler, moved system-specific timezone help funcions
* back in here, from 'timezone.c'.
* 07 Jan 01, Paul Kienitz, Chr. Spieler, added missing #include "timezone.h"
* and "symbolic" preprocessor constants for time calculations.
* 15 Jan 02, Paul Kienitz, excluded all time handling code from compilation
* for Zip utilities (when "defined(UTIL)")
*/
#ifndef __amiga_filedate_c
#define __amiga_filedate_c
#include "zip.h"
#include <ctype.h>
#include <errno.h>
#include <exec/types.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <dos/dosextens.h>
#ifdef AZTEC_C
# include <libraries/dos.h>
# include <libraries/dosextens.h>
# include <clib/exec_protos.h>
# include <clib/dos_protos.h>
# include <clib/locale_protos.h>
# include <pragmas/exec_lib.h>
# include <pragmas/dos_lib.h>
# include <pragmas/locale_lib.h>
# define ESRCH ENOENT
# define EOSERR EIO
#endif
#ifdef __SASC
# include <stdlib.h>
# if (defined(_M68020) && (!defined(__USE_SYSBASE)))
/* on 68020 or higher processors it is faster */
# define __USE_SYSBASE /* to use the pragma libcall instead of syscall */
# endif /* to access functions of the exec.library */
# include <proto/exec.h> /* see SAS/C manual:part 2,chapter 2,pages 6-7 */
# include <proto/dos.h>
# include <proto/locale.h>
# ifdef DEBUG
# include <sprof.h>
# endif
# ifdef MWDEBUG
# include <stdio.h> /* include both before memwatch.h again just */
# include <stdlib.h> /* to be safe */
# include "memwatch.h"
# endif /* MWDEBUG */
#endif /* __SASC */
#include "crypt.h" /* just so we can tell if CRYPT is supported */
#if (!defined(FUNZIP) && !defined(UTIL))
#include "timezone.h" /* for AMIGA-specific timezone callbacks */
#ifndef SUCCESS
# define SUCCESS (-1L)
# define FAILURE 0L
#endif
#define ReqVers 36L /* required library version for SetFileDate() */
#define ENVSIZE 100 /* max space allowed for an environment var */
extern struct ExecBase *SysBase;
#ifndef min
# define min(a, b) ((a) < (b) ? (a) : (b))
# define max(a, b) ((a) < (b) ? (b) : (a))
#endif
#if defined(ZIP) || defined(HAVE_MKTIME)
static const unsigned short ydays[] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
#else
extern const unsigned short ydays[]; /* in unzip's fileio.c */
#endif
#define LEAP(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
#define YDAYS(m, y) (ydays[m] + (m > 1 && LEAP(y)))
/* Number of leap years from 1978 to `y' (not including `y' itself). */
#define ANLEAP(y) (((y) - 1977) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)
#define SECSPERMIN 60
#define MINSPERHOUR 60
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY 86400L
/* prototypes */
char *getenv(const char *var);
#ifdef __SASC
/* XXX !! We have really got to find a way to operate without these. */
int setenv(const char *var, const char *value, int overwrite);
void set_TZ(long time_zone, int day_light);
#endif
LONG FileDate(char *filename, time_t u[]);
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
int Agetch(void);
/* =============================================================== */
/***********************/
/* Function filedate() */
/***********************/
/* FileDate() (originally utime.c), by Paul Wells. Modified by John Bush
* and others (see also sendpkt() comments, below); NewtWare SetFileDate()
* clone cheaply ripped off from utime().
*/
/* DESCRIPTION
* This routine chooses between 2 methods to set the file date on AMIGA.
* Since AmigaDOS 2.x came out, SetFileDate() was available in ROM (v.36
* and higher). Under AmigaDOS 1.3.x (less than v.36 ROM), SetFileDate()
* must be accomplished by constructing a message packet and sending it
* to the file system handler of the file to be stamped.
*
* The system's ROM version is extracted from the external system Library
* base.
*
* NOTE: although argument passing conforms with utime(), note the
* following differences:
* - Return value is boolean success/failure.
* - If a structure or array is passed, only the first value
* is used, which *may* correspond to date accessed and not
* date modified.
*/
LONG FileDate(filename, u)
char *filename;
time_t u[];
{
LONG SetFileDate(UBYTE *filename, struct DateStamp *pDate);
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
struct MsgPort *taskport;
BPTR dirlock, lock;
struct FileInfoBlock *fib;
LONG pktargs[4];
UBYTE *ptr;
long ret;
struct DateStamp pDate;
struct tm *ltm;
int years;
tzset();
/* Amiga file date is based on 01-Jan-1978 00:00:00 (local time):
* 8 years and 2 leapdays difference from Unix time.
*/
ltm = localtime(&u[0]);
years = ltm->tm_year + 1900;
if (years < 1978)
pDate.ds_Days = pDate.ds_Minute = pDate.ds_Tick = 0;
else {
pDate.ds_Days = (years - 1978) * 365L + (ANLEAP(years)) +
YDAYS(ltm->tm_mon, years) + (ltm->tm_mday - 1);
pDate.ds_Minute = ltm->tm_hour * 60 + ltm->tm_min;
pDate.ds_Tick = ltm->tm_sec * TICKS_PER_SECOND;
}
if (SysBase->LibNode.lib_Version >= ReqVers)
{
return (SetFileDate(filename,&pDate)); /* native routine at 2.0+ */
}
else /* !(SysBase->lib_Version >=ReqVers) */
{
if( !(taskport = (struct MsgPort *)DeviceProc(filename)) )
{
errno = ESRCH; /* no such process */
return FAILURE;
}
if( !(lock = Lock(filename,SHARED_LOCK)) )
{
errno = ENOENT; /* no such file */
return FAILURE;
}
if( !(fib = (struct FileInfoBlock *)AllocMem(
(long)sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR)) )
{
errno = ENOMEM; /* insufficient memory */
UnLock(lock);
return FAILURE;
}
if( Examine(lock,fib)==FAILURE )
{
errno = EOSERR; /* operating system error */
UnLock(lock);
FreeMem(fib,(long)sizeof(*fib));
return FAILURE;
}
dirlock = ParentDir(lock);
ptr = (UBYTE *)AllocMem(64L,MEMF_PUBLIC);
strcpy((ptr+1),fib->fib_FileName);
*ptr = strlen(fib->fib_FileName);
FreeMem(fib,(long)sizeof(*fib));
UnLock(lock);
/* now fill in argument array */
pktargs[0] = 0;
pktargs[1] = (LONG)dirlock;
pktargs[2] = (LONG)&ptr[0] >> 2;
pktargs[3] = (LONG)&pDate;
errno = ret = sendpkt(taskport,ACTION_SET_DATE,pktargs,4L);
FreeMem(ptr,64L);
UnLock(dirlock);
return SUCCESS;
} /* ?(SysBase->lib_Version >= ReqVers) */
} /* FileDate() */
char *getenv(const char *var) /* not reentrant! */
{
static char space[ENVSIZE];
struct Process *me = (void *) FindTask(NULL);
void *old_window = me->pr_WindowPtr;
char *ret = NULL;
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
if (SysBase->LibNode.lib_Version >= ReqVers) {
if (GetVar((char *) var, space, ENVSIZE - 1, /*GVF_GLOBAL_ONLY*/ 0) > 0)
ret = space;
} else { /* early AmigaDOS, get env var the crude way */
BPTR hand, foot, spine;
int z = 0;
if (foot = Lock("ENV:", ACCESS_READ)) {
spine = CurrentDir(foot);
if (hand = Open((char *) var, MODE_OLDFILE)) {
z = Read(hand, space, ENVSIZE - 1);
Close(hand);
}
UnLock(CurrentDir(spine));
}
if (z > 0) {
space[z] = '\0';
ret = space;
}
}
me->pr_WindowPtr = old_window;
return ret;
}
#ifdef __SASC
int setenv(const char *var, const char *value, int overwrite)
{
struct Process *me = (void *) FindTask(NULL);
void *old_window = me->pr_WindowPtr;
int ret = -1;
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
if (SysBase->LibNode.lib_Version >= ReqVers)
ret = !SetVar((char *)var, (char *)value, -1, GVF_GLOBAL_ONLY | LV_VAR);
else {
BPTR hand, foot, spine;
long len = value ? strlen(value) : 0;
if (foot = Lock("ENV:", ACCESS_READ)) {
spine = CurrentDir(foot);
if (len) {
if (hand = Open((char *) var, MODE_NEWFILE)) {
ret = Write(hand, (char *) value, len + 1) >= len;
Close(hand);
}
} else
ret = DeleteFile((char *) var);
UnLock(CurrentDir(spine));
}
}
me->pr_WindowPtr = old_window;
return ret;
}
/* Stores data from timezone and daylight to ENV:TZ. */
/* ENV:TZ is required to exist by some other SAS/C library functions, */
/* like stat() or fstat(). */
void set_TZ(long time_zone, int day_light)
{
char put_tz[MAXTIMEZONELEN]; /* string for putenv: "TZ=aaabbb:bb:bbccc" */
int offset;
void *exists; /* dummy ptr to see if global envvar TZ already exists */
exists = (void *)getenv(TZ_ENVVAR);
/* see if there is already an envvar TZ_ENVVAR. If not, create it */
if (exists == NULL) {
/* create TZ string by pieces: */
sprintf(put_tz, "GMT%+ld", time_zone / 3600L);
if (time_zone % 3600L) {
offset = (int) labs(time_zone % 3600L);
sprintf(put_tz + strlen(put_tz), ":%02d", offset / 60);
if (offset % 60)
sprintf(put_tz + strlen(put_tz), ":%02d", offset % 60);
}
if (day_light)
strcat(put_tz,"DST");
setenv(TZ_ENVVAR, put_tz, 1);
}
}
#endif /* __SASC */
/* set state as well as possible from settings found in locale.library */
int GetPlatformLocalTimezone(sp, fill_tzstate_from_rules)
register struct state * ZCONST sp;
void (*fill_tzstate_from_rules)(struct state * ZCONST sp_res,
ZCONST struct rule * ZCONST start,
ZCONST struct rule * ZCONST end);
{
struct Library *LocaleBase;
struct Locale *ll;
struct Process *me = (void *) FindTask(NULL);
void *old_window = me->pr_WindowPtr;
BPTR eh;
int z, valid = FALSE;
/* read timezone from locale.library if TZ envvar missing */
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
if (LocaleBase = OpenLibrary("locale.library", 0)) {
if (ll = OpenLocale(NULL)) {
z = ll->loc_GMTOffset; /* in minutes */
if (z == -300) {
if (eh = Lock("ENV:sys/locale.prefs", ACCESS_READ)) {
UnLock(eh);
valid = TRUE;
} else
z = 300; /* bug: locale not initialized, default bogus! */
} else
valid = TRUE;
if (valid) {
struct rule startrule, stoprule;
sp->timecnt = 0;
sp->typecnt = 1;
sp->charcnt = 2;
sp->chars[0] = sp->chars[1] = '\0';
sp->ttis[0].tt_abbrind = 0;
sp->ttis[1].tt_abbrind = 1;
sp->ttis[0].tt_gmtoff = -z * MINSPERHOUR;
sp->ttis[1].tt_gmtoff = -z * MINSPERHOUR + SECSPERHOUR;
sp->ttis[0].tt_isdst = 0;
sp->ttis[1].tt_isdst = 1;
stoprule.r_type = MONTH_NTH_DAY_OF_WEEK;
stoprule.r_day = 0;
stoprule.r_week = 5;
stoprule.r_mon = 10;
stoprule.r_time = 2 * SECSPERHOUR;
startrule = stoprule;
startrule.r_mon = 4;
startrule.r_week = 1;
if (z >= -180 && z < 150) {
/* At this point we make a really gratuitous assumption: */
/* if the time zone could be Europe, we use the European */
/* Union rules without checking what country we're in. */
/* The AmigaDOS locale country codes do not, at least in */
/* 2.x versions of the OS, recognize very many countries */
/* outside of Europe and North America. */
sp->typecnt = 2;
startrule.r_mon = 3; /* one week earlier than US DST */
startrule.r_week = 5;
} else if (z >= 150 && z <= 480 &&
/* no DST in alaska, hawaii */
(ll->loc_CountryCode == 0x55534100 /*"USA"*/ ||
ll->loc_CountryCode == 0x43414E00 /*"CAN"*/))
sp->typecnt = 2;
/* We check the country code for U.S. or Canada because */
/* most of Latin America has no DST. Even in these two */
/* countries there are some exceptions... */
/* else if... Feel free to add more cases here! */
if (sp->typecnt > 1)
(*fill_tzstate_from_rules)(sp, &startrule, &stoprule);
}
CloseLocale(ll);
}
CloseLibrary(LocaleBase);
}
me->pr_WindowPtr = old_window;
return valid;
}
#ifdef ZIP
time_t time(time_t *tp)
{
time_t t;
struct DateStamp ds;
DateStamp(&ds);
t = ds.ds_Tick / TICKS_PER_SECOND + ds.ds_Minute * 60
+ (ds.ds_Days + 2922) * SECSPERDAY;
t = mktime(gmtime(&t));
/* gmtime leaves ds in the local timezone, mktime converts it to GMT */
if (tp) *tp = t;
return t;
}
#endif /* ZIP */
#endif /* !FUNZIP && !UTIL */
#if CRYPT || !defined(FUNZIP)
/* sendpkt.c
* by A. Finkel, P. Lindsay, C. Sheppner
* returns Res1 of the reply packet
*/
/*
#include <exec/types.h>
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <proto/exec.h>
#include <proto/dos.h>
*/
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
LONG sendpkt(pid,action,args,nargs)
struct MsgPort *pid; /* process identifier (handler message port) */
LONG action, /* packet type (desired action) */
*args, /* a pointer to argument list */
nargs; /* number of arguments in list */
{
struct MsgPort *replyport, *CreatePort(UBYTE *, long);
void DeletePort(struct MsgPort *);
struct StandardPacket *packet;
LONG count, *pargs, res1;
replyport = CreatePort(NULL,0L);
if( !replyport ) return(0);
packet = (struct StandardPacket *)AllocMem(
(long)sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR);
if( !packet )
{
DeletePort(replyport);
return(0);
}
packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt);
packet->sp_Pkt.dp_Link = &(packet->sp_Msg);
packet->sp_Pkt.dp_Port = replyport;
packet->sp_Pkt.dp_Type = action;
/* copy the args into the packet */
pargs = &(packet->sp_Pkt.dp_Arg1); /* address of 1st argument */
for( count=0; count<nargs; count++ )
pargs[count] = args[count];
PutMsg(pid,(struct Message *)packet); /* send packet */
WaitPort(replyport);
GetMsg(replyport);
res1 = packet->sp_Pkt.dp_Res1;
FreeMem((char *)packet,(long)sizeof(*packet));
DeletePort(replyport);
return(res1);
} /* sendpkt() */
#endif /* CRYPT || !FUNZIP */
#if CRYPT || (defined(UNZIP) && !defined(FUNZIP))
/* Agetch() reads one raw keystroke -- uses sendpkt() */
int Agetch(void)
{
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
struct Task *me = FindTask(NULL);
struct CommandLineInterface *cli = BADDR(((struct Process *) me)->pr_CLI);
BPTR fh = cli->cli_StandardInput; /* this is immune to < redirection */
void *conp = ((struct FileHandle *) BADDR(fh))->fh_Type;
char longspace[8];
long *flag = (long *) ((ULONG) &longspace[4] & ~3); /* LONGWORD ALIGNED! */
UBYTE c;
*flag = 1;
sendpkt(conp, ACTION_SCREEN_MODE, flag, 1); /* assume success */
Read(fh, &c, 1);
*flag = 0;
sendpkt(conp, ACTION_SCREEN_MODE, flag, 1);
if (c == 3) /* ^C in input */
Signal(me, SIGBREAKF_CTRL_C);
return c;
}
#endif /* CRYPT || (UNZIP && !FUNZIP) */
#endif /* __amiga_filedate_c*/

View File

@ -0,0 +1,502 @@
;===========================================================================
; Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
;
; See the accompanying file LICENSE, version 2000-Apr-09 or later
; (the contents of which are also included in unzip.h) for terms of use.
; If, for some reason, all these files are missing, the Info-ZIP license
; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
;===========================================================================
; flate.a created by Paul Kienitz, 20 June 94. Last modified 23 Mar 2002.
;
; 68000 assembly language version of inflate_codes(), for Amiga. Prototype:
;
; int inflate_codes(__GPRO__ struct huft *tl, struct huft *td,
; unsigned bl, unsigned bd);
;
; Where __GPRO__ expands to "Uz_Globs *G," if REENTRANT is defined,
; otherwise to nothing. In the latter case G is a global variable.
;
; Define the symbol FUNZIP if this is for fUnZip. It overrides REENTRANT.
;
; Define AZTEC to use the Aztec C macro version of getc() instead of the
; library getc() with FUNZIP. AZTEC is ignored if FUNZIP is not defined.
;
; Define NO_CHECK_EOF to not use the fancy paranoid version of NEEDBITS --
; this is equivalent to removing the #define CHECK_EOF from inflate.c.
;
; Define INT16 if ints are short, otherwise it assumes ints are long.
;
; Define USE_DEFLATE64 if we're supporting Deflate64 decompression.
;
; Do NOT define WSIZE; it is always 32K or 64K depending on USE_DEFLATE64.
;
; ------
;
; The following include file is generated from globals.h, and gives us equates
; that give the offsets in Uz_Globs of the fields we use, which are:
; ulg bb
; unsigned int bk, wp
; (either array of unsigned char, or pointer to unsigned char) redirslide
; For fUnZip:
; FILE *in
; For regular UnZip but not fUnZip:
; int incnt, mem_mode
; long csize
; uch *inptr
; It also defines a value SIZEOF_slide, which tells us whether the appropriate
; slide field in G (either area.Slide or redirect_pointer) is a pointer or an
; array instance. It is 4 in the former case and a large value in the latter.
; Lastly, this include will define CRYPT as 1 if appropriate and supply flag
; definitions for major compile options that may affect the layout of the
; globals structure and the functionality of the core decompression routines
; (currently FUNZIP, SFX, REENTRANT, DLL, NO_SLIDE_REDIR, USE_DEFLATE64).
INCLUDE "amiga/G_offs.a"
; struct huft is defined as follows:
;
; struct huft {
; uch e; /* number of extra bits or operation */
; uch b; /* number of bits in this code or subcode */
; union {
; ush n; /* literal, length base, or distance base */
; struct huft *t; /* pointer to next level of table */
; } v;
; }; /* sizeof(struct huft) == 6 */
;
; The G_offs include defines offsets h_e, h_b, h_v_n, and h_v_t in this
; struct, plus SIZEOF_huft.
IFD REENTRANT
IFND FUNZIP
REENT_G equ 1
ENDC
ENDC
; These macros allow us to deal uniformly with short or long ints:
IFD INT16
MOVINT MACRO
move.w \1,\2
ENDM
INTSIZE equ 2
ELSE ; !INT16
MOVINT MACRO
move.l \1,\2
ENDM
INTSIZE equ 4
ENDC
; G.bb is the global buffer that holds bits from the huffman code stream, which
; we cache in the register variable b. G.bk is the number of valid bits in it,
; which we cache in k. The macros NEEDBITS(n) and DUMPBITS(n) have side effects
; on b and k.
IFD REENT_G
G_SIZE equ 4
G_PUSH MACRO ; this macro passes "__G__" to functions
move.l G,-(sp)
ENDM
ELSE
xref _G ; Uz_Globs
G_SIZE equ 0
G_PUSH MACRO
ds.b 0 ; does nothing; the assembler dislikes MACRO ENDM
ENDM
ENDC ; REENT_G
;; xref _mask_bits ; const unsigned mask_bits[17];
IFD FUNZIP
IF CRYPT
xref _encrypted ; int -- boolean flag
xref _update_keys ; int update_keys(__GPRO__ int)
xref _decrypt_byte ; int decrypt_byte(__GPRO)
ENDC ; CRYPT
ELSE ; !FUNZIP
xref _memflush ; int memflush(__GPRO__ uch *, ulg)
xref _readbyte ; int readbyte(__GPRO)
ENDC ; FUNZIP
xref _flush ; if FUNZIP: int flush(__GPRO__ ulg)
; else: int flush(__GPRO__ uch *, ulg, int)
; Here are our register variables.
b equr d2 ; unsigned long
k equr d3 ; unsigned short <= 32
e equr d4 ; unsigned int, mostly used as unsigned char
w equr d5 ; unsigned long (was short before deflate64)
n equr d6 ; unsigned long (was short before deflate64)
d equr d7 ; unsigned int, used as unsigned short
t equr a2 ; struct huft *
lmask equr a3 ; ulg *
G equr a6 ; Uz_Globs *
; Couple other items we need:
savregs reg d2-d7/a2/a3/a6
IFD USE_DEFLATE64
WSIZE equ $10000 ; 64K... be careful not to treat as short!
ELSE
WSIZE equ $08000 ; 32K... be careful not to treat as negative!
ENDC
EOF equ -1
INVALID equ 99
; inflate_codes() returns one of the following status codes:
; 0 OK
; 1 internal inflate error or EOF on input stream
; the following return codes are passed through from FLUSH() errors
; 50 (PK_DISK) "overflow of output space"
; 80 (IZ_CTRLC) "canceled by user's request"
RET_OK equ 0
RET_ERR equ 1
IFD FUNZIP
; This does getc(in). Aztec version is based on #define getc(fp) in stdio.h
IFD AZTEC
xref __filbuf
GETC MACRO
move.l in(G),a0
move.l (a0),a1 ; in->_bp
cmp.l 4(a0),a1 ; in->_bend
blo.s gci\@
move.l a0,-(sp)
jsr __filbuf
addq #4,sp
bra.s gce\@
gci\@: moveq #0,d0 ; must be valid as longword
move.b (a1)+,d0
move.l a1,(a0)
gce\@:
ENDM
ELSE ; !AZTEC
GETC MACRO
xref _getc
move.l in(G),-(sp)
jsr _getc
addq #4,sp
ENDM
ENDC ; AZTEC
ENDC ; FUNZIP
; Input depends on the NEXTBYTE macro. This exists in three different forms.
; The first two are for fUnZip, with and without decryption. The last is for
; regular UnZip with or without decryption. The resulting byte is returned
; in d0 as a longword, and d1, a0, and a1 are clobbered.
; FLUSH also has different forms for UnZip and fUnZip. Arg must be a longword.
; The same scratch registers are trashed.
IFD FUNZIP
NEXTBYTE MACRO
GETC
IF CRYPT
tst.w _encrypted+INTSIZE-2 ; test low word if long
beq.s nbe\@
MOVINT d0,-(sp) ; save thru next call
G_PUSH
jsr _decrypt_byte
eor.w d0,G_SIZE+INTSIZE-2(sp) ; becomes arg to update_keys
jsr _update_keys
addq #INTSIZE+G_SIZE,sp
nbe\@:
ENDC ; !CRYPT
IFGT 4-INTSIZE
ext.l d0 ; assert -1 <= d0 <= 255
ENDC
ENDM
FLUSH MACRO
move.l \1,-(sp)
G_PUSH
jsr _flush
addq #4+G_SIZE,sp
ENDM
ELSE ; !FUNZIP
NEXTBYTE MACRO
subq.w #1,incnt+INTSIZE-2(G) ; treat as short
bge.s nbs\@
G_PUSH
jsr _readbyte
IFNE G_SIZE
addq #G_SIZE,sp
ENDC
IFGT 4-INTSIZE
ext.l d0 ; assert -1 <= d0 <= 255
ENDC
bra.s nbe\@
nbs\@: moveq #0,d0
move.l inptr(G),a0 ; alt vers: move.b inptr(G),d0
move.b (a0)+,d0 ; addq #1,inptr(G)
move.l a0,inptr(G)
nbe\@:
ENDM
FLUSH MACRO
MOVINT #0,-(sp) ; unshrink flag: always false
move.l \1,-(sp) ; length
IFGT SIZEOF_slide-4
pea redirslide(G) ; buffer to flush
ELSE
move.l redirslide(G),-(sp)
ENDC
G_PUSH
tst.w mem_mode+INTSIZE-2(G) ; test lower word if long
beq.s fm\@
jsr _memflush ; ignores the unshrink flag
bra.s fe\@
fm\@: jsr _flush
fe\@: lea 8+INTSIZE+G_SIZE(sp),sp
ENDM
ENDC ; ?FUNZIP
; Here are the two bit-grabbing macros, defined in their NO_CHECK_EOF form:
;
; #define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE)<<k;k+=8;}}
; #define DUMPBITS(n) {b>>=(n);k-=(n);}
;
; Without NO_CHECK_EOF, NEEDBITS reads like this:
;
; {while((int)k<(int)(n)){int c=NEXTBYTE;
; if(c==EOF){if((int)k>=0)break;return 1};
; b|=((ulg)c)<<k;k+=8;}}
;
; NEEDBITS clobbers d0, d1, a0, and a1, none of which can be used as the arg to
; the macro specifying the number of bits. The arg can be a shortword memory
; address, or d2-d7. The result is copied into d1 as a word ready for masking.
; DUMPBITS has no side effects; the arg must be a d-register (or immediate in
; the range 1-8?) and only the lower byte is significant.
NEEDBITS MACRO ; arg is short
nb\@: cmp.w \1,k ; assert 0 < k <= 32 ... arg may be 0
bge.s ne\@ ; signed compare!
NEXTBYTE ; returns in d0.l
IFND NO_CHECK_EOF
cmp.w #EOF,d0
bne.s nok\@
tst.w k
bge.s ne\@
moveq #RET_ERR,d0
bra return
ENDC ; !NO_CHECK_EOF
nok\@: lsl.l k,d0
or.l d0,b
addq.w #8,k
bra.s nb\@
ne\@: move.l b,d1 ; return a copy of b in d1
ENDM
DUMPBITS MACRO ; arg is byte, not short!
lsr.l \1,b ; upper bits of \1 are ignored, right?
sub.b \1,k
ENDM
; This is a longword version of the mask_bits constant array:
longmasks: dc.l $00000000,$00000001,$00000003,$00000007,$0000000F
dc.l $0000001F,$0000003F,$0000007F,$000000FF,$000001FF
dc.l $000003FF,$000007FF,$00000FFF,$00001FFF,$00003FFF
dc.l $00007FFF,$0000FFFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; ******************************************************************************
; Here we go, finally:
xdef _inflate_codes
_inflate_codes:
link a5,#-8
movem.l savregs,-(sp)
; 8(a5) = tl, 12(a5) = td, 16(a5) = bl, 18|20(a5) = bd... add 4 for REENT_G
; -4(a5) = ml, -8(a5) = md, both unsigned long.
; Here we cache some globals and args:
IFD REENT_G
move.l 8(a5),G
ELSE
lea _G,G ; G is now a global instance
ENDC
lea longmasks,lmask
move.l bb(G),b
MOVINT bk(G),k
IFD INT16
moveq #0,w ; keep this usable as longword
ENDC
MOVINT wp(G),w
moveq #0,e ; keep this usable as longword too
MOVINT 16+G_SIZE(a5),d0
asl.w #2,d0
move.l (lmask,d0.w),-4(a5) ; ml = mask_bits[bl]
MOVINT 16+INTSIZE+G_SIZE(a5),d0
asl.w #2,d0
move.l (lmask,d0.w),-8(a5) ; md = mask_bits[bd]
xdef newtop
xdef nonlit
xdef distop
xdef docopy
xdef nonleng
xdef tailgo
xdef finish
xdef disbrk
main_loop:
NEEDBITS 14+INTSIZE+G_SIZE(a5) ; (unsigned) bl
and.l -4(a5),d1 ; ml
IFNE SIZEOF_huft-8
mulu #SIZEOF_huft,d1
ELSE
asl.l #3,d1
ENDC
move.l 8+G_SIZE(a5),t ; tl
add.l d1,t
newtop: move.b h_b(t),d0
DUMPBITS d0
move.b h_e(t),e
cmp.b #32,e ; is it a literal?
bne nonlit ; no
move.w h_v_n(t),d0 ; yes
IFGT SIZEOF_slide-4
lea redirslide(G),a0
ELSE
move.l redirslide(G),a0
ENDC
move.b d0,(a0,w.l) ; stick in the decoded byte
addq.l #1,w
cmp.l #WSIZE,w
blo main_loop
FLUSH w
ext.l d0 ; does a test as it casts long
bne return
moveq #0,w
bra main_loop ; break (newtop loop)
nonlit: cmp.b #31,e ; is it a length?
beq finish ; no, it's the end marker
bhi nonleng ; no, it's something else
NEEDBITS e ; yes: a duplicate string
move.w e,d0
asl.w #2,d0
and.l (lmask,d0.w),d1
moveq #0,n ; cast h_v_n(t) to long
move.w h_v_n(t),n
add.l d1,n ; length of block to copy
DUMPBITS e
NEEDBITS 14+(2*INTSIZE)+G_SIZE(a5) ; bd, lower word if long
and.l -8(a5),d1 ; md
IFNE SIZEOF_huft-8
mulu #SIZEOF_huft,d1
ELSE
asl.l #3,d1
ENDC
move.l 12+G_SIZE(a5),t ; td
add.l d1,t
distop: move.b h_b(t),d0
DUMPBITS d0
move.b h_e(t),e
cmp.b #32,e ; is it a literal?
blo.s disbrk ; then stop doing this
cmp.b #INVALID,e ; is it bogus?
bne.s disgo
moveq #RET_ERR,d0 ; then fail
bra return
disgo: and.w #$001F,e
NEEDBITS e
move.w e,d0
asl.w #2,d0
and.l (lmask,d0.w),d1
IFNE SIZEOF_huft-8
mulu #SIZEOF_huft,d1
ELSE
asl.l #3,d1
ENDC
move.l h_v_t(t),t
add.l d1,t
bra distop
disbrk: NEEDBITS e
move.l e,d0
asl.w #2,d0
and.l (lmask,d0.w),d1
move.l w,d
move.w h_v_n(t),d0 ; assert top word of d0 is zero
sub.l d0,d
sub.l d1,d ; distance back to copy the block
DUMPBITS e
docopy: move.l #WSIZE,e ; copy the duplicated string
and.l #WSIZE-1,d ; ...but first check if the length
cmp.l d,w ; will overflow the window...
blo.s ddgw
sub.l w,e
bra.s dadw
ddgw: sub.l d,e
dadw: cmp.l #$08000,e ; also, only copy <= 32K, so we can
bls.s dnox ; use a dbra loop to do it
move.l #$08000,e
dnox: cmp.l n,e
bls.s delen
move.l n,e
delen: sub.l e,n ; size of sub-block to copy in this pass
IFGT SIZEOF_slide-4
lea redirslide(G),a0
ELSE
move.l redirslide(G),a0
ENDC
move.l a0,a1
add.l w,a0
add.l d,a1
; Now at this point we could do tests to see if we should use an optimized
; large block copying method such as movem's, but since (a) such methods require
; the source and destination to be compatibly aligned -- and odd bytes at each
; end have to be handled separately, (b) it's only worth checking for if the
; block is pretty large, and (c) most strings are only a few bytes long, we're
; just not going to bother. Therefore we check above to make sure we move at
; most 32K in one sub-block, so a dbra loop can handle it.
dshort: move.l e,d0
subq #1,d0 ; assert >= 0
dspin: move.b (a1)+,(a0)+
dbra d0,dspin
add.l e,w
add.l e,d
cmp.l #WSIZE,w
blo.s dnfl
FLUSH w
ext.l d0 ; does a test as it casts to long
bne return
moveq #0,w
dnfl: tst.l n ; need to do more sub-blocks?
bne docopy ; yes
moveq #0,e ; restore zeroness in upper bytes of e
bra main_loop ; break (newtop loop)
nonleng: cmp.w #INVALID,e ; bottom of newtop loop -- misc. code
bne.s tailgo ; invalid code?
moveq #RET_ERR,d0 ; then fail
bra return
tailgo: and.w #$001F,e
NEEDBITS e
move.w e,d0
asl.w #2,d0
and.l (lmask,d0.w),d1
IFNE SIZEOF_huft-8
mulu #SIZEOF_huft,d1
ELSE
asl.l #3,d1
ENDC
move.l h_v_t(t),t
add.l d1,t
bra newtop
finish: MOVINT w,wp(G) ; done: restore cached globals
MOVINT k,bk(G)
move.l b,bb(G)
moveq #RET_OK,d0 ; return "no error"
return: movem.l (sp)+,savregs
unlk a5
rts

View File

@ -0,0 +1,136 @@
# Makefile for UnZip 5.5 using Manx Aztec C 5.2, last revised 13 Jan 02.
# Define EXTRA=xxx on the Make command line for e.g. -dUSE_UNSHRINK.
EXTRA =
CC = cc
VERNUMS = -d __VERSION__=5 -d __REVISION__=2
CFLAGS = -ps -sabfmnpu -wcpr0u -d AMIGA $(EXTRA)
# -ps means short ints, -sabfmnpu is optimizations, -wcpr0u is type checking
# option flags MORE and ASM_* are now set in the Aztec section of amiga/amiga.h;
# it's cleaner, and that way any changes forces a recompile.
LD = ln
LDFLAGS = +q -m
LDLIBS = -lc16
# linker arg -m suppresses warnings about overriding c.lib functions
OBJS = unzip.o envargs.o process.o extract.o \
explode.o unshrink.o unreduce.o inflate.o match.o zipinfo.o \
list.o globals.o crypt.o ttyio.o fileio.o crctab.o timezone.o \
amiga/amiga.o amiga/crc_68.o amiga/flate.o
XOBJS = unzip.xo process.xo extract.xo inflate.xo match.xo \
globals.xo crypt.xo ttyio.xo fileio.xo crctab.xo timezone.xo \
amiga/amiga.xo amiga/crc_68.o amiga/flate.xo
FOBJS = funzip.o inflate.fo crypt.fo ttyio.fo globals.fo \
amiga/filedate.fo amiga/crc_68.o amiga/flate.fo
.c.o :
$(CC) -o $@ $(CFLAGS) $*.c
.c.xo:
$(CC) -o $@ -d SFX $(CFLAGS) $*.c
.c.fo:
$(CC) -o $@ -d FUNZIP $(CFLAGS) $*.c
all : UnZip UnZipSFX fUnZip MakeSFX
u : UnZip
f : fUnZip
x : UnZipSFX
m : MakeSFX
UnZip : $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
UnZipSFX : $(XOBJS) MakeSFX
$(LD) $(LDFLAGS) -o $@ $(XOBJS) $(LDLIBS)
fUnZip : $(FOBJS)
$(LD) $(LDFLAGS) -o $@ $(FOBJS) $(LDLIBS)
MakeSFX : amiga/makesfx.c
$(CC) $(CFLAGS) -o t:makesfx.o amiga/makesfx.c
$(LD) $(LDFLAGS) -o MakeSFX t:makesfx.o $(LDLIBS)
-@delete t:makesfx.o
clean :
-delete $(OBJS)
-delete $(XOBJS)
-delete $(FOBJS)
-delete amiga/G_offs.a amiga/G_offs.fa amiga/gbloffs amiga/Fgbloffs
cleaner : clean
-delete UnZip fUnZip UnZipSFX MakeSFX
$(OBJS) $(XOBJS) $(FOBJS) : unzip.h unzpriv.h globals.h \
amiga/amiga.h amiga/z-stat.h
crypt.o crypt.fo timezone.o ttyio.o ttyio.fo : zip.h
inflate.o inflate.fo : inflate.h
fileio.o : ebcdic.h
funzip.o : tables.h
crypt.o crypt.fo crypt.xo ttyio.o ttyio.fo ttyio.xo : crypt.h
unzip.o unzip.xo funzip.o : crypt.h
fileio.o fileio.xo extract.o extract.xo : crypt.h
inflate.o inflate.fo inflate.xo amiga/filedate.fo : crypt.h
amiga/gbloffs amiga/Fgbloffs amiga/Xgbloffs : crypt.h
crypt.o crypt.fo crypt.xo ttyio.o ttyio.fo ttyio.xo : ttyio.h
funzip.o fileio.o fileio.xo : ttyio.h
timezone.o timezone.xo amiga/amiga.o amiga/amiga.xo : timezone.h
unzip.o unzip.xo : unzvers.h consts.h
# Special case object files:
amiga/amiga.o : amiga/filedate.c amiga/stat.c amiga/amiga.c unzvers.h
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
$(CC) -o amiga/amiga.o $(CFLAGS) $(VERNUMS) amiga/amiga.c
amiga/amiga.xo : amiga/filedate.c amiga/stat.c amiga/amiga.c unzvers.h
$(CC) -o amiga/amiga.xo $(CFLAGS) $(VERNUMS) -d SFX amiga/amiga.c
amiga/crc_68.o : amiga/crc_68.a
as -n -o amiga/crc_68.o amiga/crc_68.a
amiga/flate.o : amiga/flate.a amiga/gbloffs
amiga/gbloffs > amiga/G_offs.a
as -n -o amiga/flate.o -eINT16 amiga/flate.a
amiga/flate.fo : amiga/flate.a amiga/Fgbloffs
amiga/Fgbloffs > amiga/G_offs.a
as -n -o amiga/flate.fo -eINT16 -eAZTEC amiga/flate.a
amiga/flate.xo : amiga/flate.a amiga/Xgbloffs
amiga/Xgbloffs > amiga/G_offs.a
as -n -o amiga/flate.xo -eINT16 amiga/flate.a
amiga/gbloffs : gbloffs.c unzip.h unzpriv.h globals.h amiga/amiga.h crypt.h
$(CC) -o t:gbloffs.o $(CFLAGS) gbloffs.c
$(LD) $(LDFLAGS) -o amiga/gbloffs t:gbloffs.o $(LDLIBS)
-@delete t:gbloffs.o
amiga/Fgbloffs : gbloffs.c unzip.h unzpriv.h globals.h amiga/amiga.h crypt.h
$(CC) -o t:gbloffs.o $(CFLAGS) -d FUNZIP gbloffs.c
$(LD) $(LDFLAGS) -o amiga/Fgbloffs t:gbloffs.o $(LDLIBS)
-@delete t:gbloffs.o
amiga/Xgbloffs : gbloffs.c unzip.h unzpriv.h globals.h amiga/amiga.h crypt.h
$(CC) -o t:gbloffs.o $(CFLAGS) -d SFX gbloffs.c
$(LD) $(LDFLAGS) -o amiga/Xgbloffs t:gbloffs.o $(LDLIBS)
-@delete t:gbloffs.o

View File

@ -0,0 +1,184 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* MakeSFX: join UnZipSFX and a .zip archive into a single self-extracting */
/* Amiga program. On most systems simple concatenation does the job but for */
/* the Amiga a special tool is needed. By Paul Kienitz, no rights reserved. */
/* This program is written portably, so if anyone really wants to they can */
/* produce Amiga self-extracting programs on a non-Amiga. We are careful */
/* not to mix Motorola-format longwords read from files with native long */
/* integers. Not necessarily limited to use with only the Zip format -- */
/* just combine any archive with any self-extractor program that is capable */
/* of reading a HUNK_DEBUG section at the end as an archive. */
#include <stat.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef __SASC
# include <proto/dos.h>
# ifdef DEBUG
# include <sprof.h>
# endif
#endif /* __SASC */
#ifdef AZTEC_C
# include <dos/dos.h>
# include <clib/dos_protos.h>
#endif /* AZTEC_C */
typedef unsigned long ulg;
typedef unsigned char uch;
typedef unsigned short bool;
#define false 0
#define true 1
/* the following are extracted from Commodore include file dos/doshunks.h: */
#define HUNK_NAME 1000L
#define HUNK_CODE 1001L
#define HUNK_DATA 1002L
#define HUNK_BSS 1003L
#define HUNK_RELOC32 1004L
#define HUNK_SYMBOL 1008L
#define HUNK_DEBUG 1009L
#define HUNK_END 1010L
#define HUNK_HEADER 1011L
#define HUNK_OVERLAY 1013L
#define HUNK_BREAK 1014L
/* Convert a big-endian (Motorola) sequence of four bytes to a longword: */
#define CHARS2LONG(b) (((ulg)(b)[0] << 24) | ((ulg)(b)[1] << 16) | \
((ulg)(b)[2] << 8) | ((ulg)(b)[3]))
/* b must be (uch *) in each of these. Now the reverse: */
#define LONG2CHARS(b,l) ((b)[0] = (uch)((l) >> 24), (b)[1] = (uch)((l) >> 16),\
(b)[2] = (uch)((l) >> 8), (b)[3] = (uch)(l))
#define COPYBUFFER 16384
ulg totalwritten = 0;
bool CopyData(FILE *out, FILE *inn, ulg archivesize,
char *outname, char *inname)
{
static uch buf[COPYBUFFER];
ulg written;
size_t chunk;
if (archivesize) {
LONG2CHARS(buf, HUNK_DEBUG);
written = (archivesize + 3) / 4;
LONG2CHARS(buf + 4, written);
if (fwrite(buf, 1, 8, out) < 8) {
printf("Error writing in-between data to %s\n", outname);
return false;
}
totalwritten += 8;
}
written = 0;
do {
chunk = fread(buf, 1, COPYBUFFER, inn);
if (ferror(inn)) {
printf("Error reading data from %s\n", inname);
return false;
}
if (!archivesize && !written) { /* true only for first block read */
if (CHARS2LONG(buf) != HUNK_HEADER) {
printf("%s is not an Amiga executable.\n", inname);
return false;
}
}
if (fwrite(buf, 1, chunk, out) < chunk) {
printf("Error writing %s to %s\n", archivesize ? "archive data" :
"self-extractor code", outname);
return false;
}
written += chunk;
totalwritten += chunk;
} while (!feof(inn));
if (archivesize) {
if (written != archivesize) {
printf("Wrong number of bytes copied from archive %s\n", outname);
return false;
}
LONG2CHARS(buf, 0);
chunk = 3 - (written + 3) % 4;
LONG2CHARS(buf + chunk, HUNK_END);
chunk += 4;
if (fwrite(buf, 1, chunk, out) < chunk) {
printf("Error writing end-marker data to %s\n", outname);
return false;
}
totalwritten += chunk;
}
return true;
}
void main(int argc, char **argv)
{
FILE *out, *arch, *tool;
char *toolname = argv[3];
struct stat ss;
int ret;
ulg archivesize;
if (argc < 3 || argc > 4) {
printf("Usage: %s <result-file> <zip-archive> [<self-extractor-"
"program>]\nThe third arg defaults to \"UnZipSFX\" in the"
" current dir or C:.\n", argv[0]);
exit(20);
}
if (!(arch = fopen(argv[2], "rb"))) {
printf("Could not find archive file %s\n", argv[2]);
exit(10);
}
if (stat(argv[2], &ss) || !(archivesize = ss.st_size)) {
fclose(arch);
printf("Could not check size of archive %s, or file is empty.\n",
argv[2]);
exit(10);
}
if (argc < 4)
toolname = "UnZipSFX";
if (!(tool = fopen(toolname, "rb"))) {
BPTR lk = Lock("C:", ACCESS_READ);
BPTR ocd = lk ? CurrentDir(lk) : 0;
if (!(tool = fopen(toolname, "rb"))) {
fclose(arch);
printf("Could not find self-extractor program %s\n", toolname);
if (lk)
UnLock(CurrentDir(ocd));
exit(10);
}
if (lk)
UnLock(CurrentDir(ocd));
}
if (!(out = fopen(argv[1], "wb"))) {
fclose(arch);
fclose(tool);
printf("Could not create output file %s\n", argv[1]);
exit(10);
}
ret = CopyData(out, tool, 0, argv[1], toolname)
&& CopyData(out, arch, archivesize, argv[1], argv[2]) ? 0 : 10;
fclose(out);
fclose(arch);
fclose(tool);
if (ret) {
printf("Deleting %s\n", argv[1]);
remove(argv[1]);
} else
printf("%s successfully written, size %lu bytes.\n",
argv[1], totalwritten);
exit(ret);
}
#if (defined(AZTEC_C) && defined(MCH_AMIGA))
void _wb_parse(void) { } /* avoid unneeded infrastructure */
#endif

View File

@ -0,0 +1,628 @@
#===========================================================================
# Makefile for UnZip, ZipInfo, fUnZip, MakeSFX AMIGA SAS/C Version 6.58
# Version: 5.5 last revised: 13 Feb 01
#===========================================================================
# from John Bush <john.bush@east.sun.com>
# or: <JBush@bix.com>
# updated for SAS/C Version 6.56+ and AmigaDOS 3.1 (V40)
# by Haidinger Walter <walthaid@unix.ict.tuwien.ac.at>
# additional supplements and maintenance by Paul Kienitz
# This makefile should work with at least AmigaDOS 2.04 (V37) (not tested)
# and will probably not work with AmigaDOS 1.3 (V34)
# If you have any improvements, critics or else please feel free to mail.
# Any response is appreciated. Haidinger Walter <walthaid@unix.ict.tuwien.ac.at>
# Available targets:
# all builds all executables below
# unzip builds unzip executable
# unzipsfx builds unzipsfx executable
# funzip builds funzip executable
# makesfx builds makesfx executable
# clean remove all files created by the compilation
# spotless like clean target but removes binaries too
##########################
# USER MACRO DEFINITIONS #
##########################
# Set the processor to generate code for UnZip and fUnZip. Specify one of:
# ANY 68000 68010 68020 68030 68040 68060 (Default: ANY or 68000)
# Use of the assembly versions is not supported yet since some of the asm
# source file do not assemble with 68000 instructions.
# Any help is appreciated of course.
CUSECPU = ANY
# Uncomment both CUTIL and LUTIL to make use of utility.library of OS 2.04+
# The utility.library is *not* used for UnZipSFX to ensure maximum portability
# between the different Amiga systems (minimal config: 68000 and OS 1.2).
# You can change this by adding the $(LUTIL) macro in the UnZipSFX linking
# rules (See below: Final output targets, UnZipSFX:).
# WARNINGS when using the utility library:
# 1. All Executables will *only* work with AmigaDOS 2.04 (v37) or higher.
# 2. You *need not* compile/link with short-integers using the
# utility.library. It will crash your machine. See Libraries below.
#
# Default: commented (not used)
#
#CUTIL = UTILLIB DEFINE=_UTILLIB
#LUTIL = WITH SC:LIB/utillib.with # include necessary linker defines
# Choose one stack-handling method (default=faster)
# StackExtend: Dynamic runtime stack extension. You won't notice stack overflows.
# StackCheck: On a stack overflow a requester appears which allows you to exit.
# Note that either stack watching will slow down your executable because of the
# extra code run on each function entry. On the other hand, you won't crash
# anymore due to stack overflows. However, you should not have *any* stack
# problems with info-zip if you raise your stack to 20000 (which I'd
# recommend as a minimum default stack for all applications) or more using the
# shell stack command. Type 'Stack 20000' or add it to your S:Shell-Startup.
# BTW: Typing 'Stack' prints your current stack size.
#
CSTACK = NOSTACKCHECK STACKEXTEND # slow, but always works
#CSTACK = STACKCHECK NOSTACKEXTEND # slow, requester & graceful exit
#CSTACK = NOSTACKCHECK NOSTACKEXTEND # faster but relies on larger stack (>=10K)
#
# LIBRARIES
# ---------
# Choose one DATAOPTS , SASLIB and LSTARTUP
# Always comment/uncomment all macros of a set.
# Library to use with near data and 2-byte integers
# Notes: o slower than 4-byte integers with 68000 cpu
# o *not* recommended due to poor overall performance
# o see comment in amiga/osdep.h
#DATAOPTS = DATA=NEAR SHORTINTEGERS DEF=_NEAR_DATA
#SASLIB = scs
#LSTARTUP = cres.o
# Library to use with near data and 4-byte integers (DEFAULT)
# *** use this with the utility.library ***
DATAOPTS = DATA=NEAR DEF=_NEAR_DATA
SASLIB = sc
LSTARTUP = cres.o
# Library to use with far data and 2-byte integers
# use if DYN_ALLOC is not defined
# old default - far data always works but is slower
#DATAOPTS = DATA=FAR SHORTINTEGERS DEF=_FAR_DATA
#SASLIB = scsnb
#LSTARTUP = c.o
# Library to use with far data and 4-byte integers
# if everything else fails: try this
#DATAOPTS = DATA=FAR DEF=_FAR_DATA
#SASLIB = scnb
#LSTARTUP = c.o
#
# DEBUGGING
# ---------
# Default: No debugging information added.
# The two macros below will be overwritten if you choose to add
# debug info, therefore need to comment.
CDBG = NODEBUG NOPROFILE NOCOVERAGE # default: no debug info
LDBG = STRIPDEBUG # default: no debug info
# Compiler and loader debug flags. Uncomment as needed. Recomment when done.
# Optimization disabled for faster compilation (by using NOOPT)
#CDBG1 = DEF=DEBUG DEF=DEBUG_TIME # enables Info-ZIP's debug output
# Enable profiling and coverage when desired. Option COVERAGE commented
# seperately because running coverage may corrupt your drive in case of a
# system crash since a file 'cover.dat' is created in your working directory.
# Note that the use of COVERAGE forces the use of the c.o startup module.
#CDBG2 = PROFILE
#CDBG3 = COVERAGE # must use c.o startup code:
#LSTARTUP = c.o # Uncomment *only* when you use COVERAGE
# *Uncomment* _HERE_ macros CDBG and LDBG to include debugging information
#CDBG = $(CDBG1) $(CDBG2) $(CDBG3) ADDSYM DEBUG=FULLFLUSH STACKCHECK NOOPT
#LDBG = ADDSYM
# Optional use of memwatch.library which can be found in your
# sc:extras/memlib directory. Please read the short docs (memlib.doc).
# Note that memlib has a small bug: MWTerm() displays always the first entry.
# Get the latest version from aminet (dev/debug/memlib.lha) or
# contact me to get the patch. Uncomment all macros to use.
#CMEMLIB = DEFINE=MWDEBUG=1 # define to enable library
#LMEMLIB = SC:LIB/memwatch.lib # path to library
#LSTARTUP = c.o # must use c.o with memlib!
#
# MAPPING
# -------
# Map filenames used when mapping (no need to comment)
#
MAPFS = unzip.map # UnZip map filename
MAPFX = unzipsfx.map # UnZipSFX map filename
MAPFF = funzip.map # fUnZip map filename
MAPFM = makesfx.map # MakeSFX map filename
# Map file output: Uncomment to highlight and bold headings.
#
#MAPFSTYLE = FANCY
# Map flags for each EXECUTABLE. Uncomment to enable mapping.
# For map options please refer to:
# SAS/C v6 manual, volume 1: user's guide, chapter 8, page 136: map
# Default: all options enabled: f,h,l,o,s,x
# |-> options start here
#LMAPS = $(MAPFSTYLE) MAP $(MAPFS) f,h,l,o,s,x # UnZip maps
#LMAPX = $(MAPFSTYLE) MAP $(MAPFX) f,h,l,o,s,x # UnZipSFX maps
#LMAPF = $(MAPFSTYLE) MAP $(MAPFF) f,h,l,o,s,x # fUnZip maps
#LMAPM = $(MAPFSTYLE) MAP $(MAPFM) f,h,l,o,s,x # MakeSFX maps
#
# LISTINGS
# --------
# Listfile-extensions for each executable (enter *with* dot)
#
LISTEXTS = .lst # extension for UnZip and MakeSFX listfiles
LISTEXTX = .xlst # extension for UnZipSFX listfiles
LISTEXTF = .flst # extension for fUnZip listfiles
# List files and cross references for each OBJECT.
# Add/remove flags as needed. All listed by default.
# Use LISTINCLUDES only to determine the dependencies for smake
#
CLISTOPT = LISTHEADERS LISTMACROS # LISTSYSTEM LISTINCLUDES
CXREFOPT = XHEAD XSYS
#
# Uncomment to enable listing (default: commented)
# *** WARNING: List files require *lots* of disk space!
#
#CLIST = LIST $(CLISTOPT)
#CXREF = XREF $(CXREFOPT)
#
# SUPPRESSED COMPILER WARNINGS
# ----------------------------
# Compiler warnings to ignore
#
# Warning 105 : module does not define any externally-known symbols
# Warning 304 : Dead assignment eliminated...
# Note 306 : ...function inlined...
# Warning 317 : possibly uninitialized variable...
# Comment to enable.
#
CIGNORE = IGNORE=105,304,306,317
#
# OBJECT EXTENSIONS
#
# Extensions used for objects of each executeable.
# Transformation rules require unique extensions.
# Enter *with* dot.
#
O = .o # general extension for objects
OX = .xo # extension for special UnZipSFX objects
OF = .fo # extension for special fUnZip objects
# Filename used to store converted options from environment variable
# LOCAL_UNZIP. Default: scoptions_local_unzip
#
CWITHOPT = scoptions_local_unzip
# Filenames to store compiler options to prevent command line overflow
#
# Options file for UnZip and fUnZip
CFILEC = scoptions-unzip
# Options file for UnZipSFX
CFILEX = scoptions-unzipsfx
# Special options for MakeSFX
CFILEM = scoptions-makesfx
# Temp filenames for object lists to load using linker "WITH" command.
#
OBJLISTS = unzip_objlist.with # UnZip object list
OBJLISTX = unzipsfx_objlist.with # UnZipSFX object list
OBJLISTF = funzip_objlist.with # fUnZip object list
OBJLISTM = makesfx_objlist.with # MakeSFX object list
# Filenames to store linker options
#
LWITHS = unzip.lnk # UnZip linker options
LWITHX = unzipsfx.lnk # UnZipSFX linker options
LWITHF = funzip.lnk # fUnZip linker options
LWITHM = makesfx.lnk # MakeSFX linker options
######################################
# NOTHING TO CHANGE BEYOND HERE ... #
######################################
# Compiler definitions
#
CC = sc
#
# Optimizer flags
#
OPTPASSES = 6 # set number of global optimizer passes
#
OPT1 = OPT OPTINL OPTINLOCAL OPTTIME OPTLOOP OPTSCHED
OPT2 = OPTCOMP=$(OPTPASSES) OPTDEP=$(OPTPASSES) OPTRDEP=$(OPTPASSES)
OPT = $(OPT1) $(OPT2)
# Compiler flags
#
# cpu flags for UnZip and fUnZip
CCPUOPTSF = CPU=$(CUSECPU) $(CUTIL)
# cpu flags for UnzipSFX and MakeSFX (ensures portability to all Amigas)
CCPUOPTXM = CPU=ANY
CDEFINES = $(CMEMLIB) $(CDEFINES) DEF=AMIGA DEF=PROTO
COPTIONS = CODE=NEAR NMINC VERBOSE STRINGMERGE PARAMETERS=BOTH
COPTIONS = $(COPTIONS) ERRORREXX NOERRORCONSOLE MEMSIZE=HUGE $(CLIST) $(CXREF)
COPTIONS = $(COPTIONS) $(CSTACK) STRICT UNSCHAR NOICONS
COPTIONS = $(COPTIONS) $(CIGNORE) $(OPT) $(CDBG)
# common compiler flags
CFLAGSC = $(CDEFINES) $(DATAOPTS) $(COPTIONS)
# special compiler flags with $(DATAOPTS) excluded
CFLAGSS = $(CDEFINES) $(COPTIONS)
# Linker definitions
# See SASLIB definition above
#
LD = slink
# special linker flags for UnZip to create pure (i.e. resident) binary.
LDFLAGSS = FROM SC:LIB/$(LSTARTUP)
# common linker flags for all other executeables
LDFLAGSC = FROM SC:LIB/c.o
LDFLAGS2 = NOICONS $(LDBG)
# special linker flags to select library set above
LIBFLAGSS = LIB $(LMEMLIB) SC:LIB/$(SASLIB).lib SC:LIB/amiga.lib
# common linker flags
LIBFLAGSC = LIB $(LMEMLIB) SC:LIB/sc.lib SC:LIB/amiga.lib
##################
# TARGET OBJECTS #
##################
# UnZip Objects
OBJS1 = unzip$(O) crc32$(O) crctab$(O) crypt$(O) envargs$(O) explode$(O)
OBJS2 = extract$(O) fileio$(O) globals$(O) list$(O) inflate$(O) match$(O)
OBJS3 = process$(O) ttyio$(O) unreduce$(O) unshrink$(O) zipinfo$(O)
OBJSA = amiga$(O) timezone$(O)
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJSA)
# UnZipSFX Objects
OBJX1 = unzip$(OX) extract$(OX) inflate$(OX) match$(OX) process$(OX)
OBJXI = crypt$(OX) crc32$(O) crctab$(OX) fileio$(OX) globals$(OX) ttyio$(OX)
OBJXA = amiga$(OX) timezone$(OX)
OBJX = $(OBJX1) $(OBJXI) $(OBJXA)
# fUnZip Objects
OBJF1 = funzip$(O)
OBJF2 = crc32$(OF) crypt$(OF) globals$(OF) inflate$(OF) ttyio$(OF)
OBJFA = filedate$(OF) stat$(O)
OBJF = $(OBJF1) $(OBJF2) $(OBJFA)
# MakeSFX Objects
OBJM = makesfx$(O)
# Common header files
UNZIP_H1 = unzip.h unzpriv.h globals.h
UNZIP_HA = amiga/amiga.h amiga/z-stat.h
UNZIP_H = $(UNZIP_H1) $(UNZIP_HA)
# Output targets
UNZIPS = UnZip UnZipSFX fUnZip MakeSFX
#######################################
# DEFAULT TARGET AND PROCESSING RULES #
#######################################
all: request flush $(UNZIPS)
# UnZip transformation rules
#
.c$(O) :
$(CC) WITH=$(CFILEC) LISTFILE=$>$(LISTEXTS) OBJNAME=$@ $*.c
# UnZipSFX transformation rules
#
.c$(OX):
$(CC) DEF=SFX WITH=$(CFILEC) LISTFILE=$>$(LISTEXTX) OBJNAME=$@ $*.c
# fUnZip transformation rules
#
.c$(OF):
$(CC) DEF=FUNZIP WITH=$(CFILEC) LISTFILE=$>$(LISTEXTF) OBJNAME=$@ $*.c
#########################
# Final output targets. #
#########################
unzip: local_unzip CommonFlags $(OBJS)
@Echo "$(OBJS)" >$(OBJLISTS)
Type $(OBJLISTS)
# -----
# Note: Change $(LDFLAGSS) to $(LDFLAGSC) if DYN_ALLOC is *not* defined.
# -----
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTS) $(LIBFLAGSS) " \
"$(LDFLAGS2) $(LMAPS)" >$(LWITHS)
Type $(LWITHS)
$(LD) TO UnZip WITH $(LWITHS)
funzip: local_unzip CommonFlags $(OBJF)
@Echo "$(OBJF)" >$(OBJLISTF)
Type $(OBJLISTF)
@Echo "$(LDFLAGSC) $(LUTIL) WITH $(OBJLISTF) $(LIBFLAGSS) " \
"$(LDFLAGS2) $(LMAPF)" >$(LWITHF)
Type $(LWITHF)
$(LD) TO fUnZip WITH $(LWITHF)
unzipsfx: local_unzip SFXFlags $(OBJX)
@Echo "$(OBJX)" >$(OBJLISTX)
Type $(OBJLISTX)
# ----
# Note: Insert $(LUTIL) here, to use utility library with UnZipSFX.
# ----- vvvvvvv
@Echo "$(LDFLAGSC) WITH $(OBJLISTX) $(LIBFLAGSS) " \
"$(LDFLAGS2) $(LMAPX)" >$(LWITHX)
Type $(LWITHX)
$(LD) TO UnZipSFX WITH $(LWITHX)
makesfx: MakeSFXFlags $(OBJM)
@Echo "$(OBJM)" >$(OBJLISTM)
Type $(OBJLISTM)
@Echo "$(LDFLAGSC) $(LUTIL) WITH $(OBJLISTM) $(LIBFLAGSC) " \
"$(LDFLAGS2) $(LMAPM)" >$(LWITHM)
Type $(LWITHM)
# never use short-integers with MakeSFX !
$(LD) TO MakeSFX WITH $(LWITHM)
clean:
-Delete >nil: $(OBJS) quiet
-Delete >nil: $(OBJX) quiet
-Delete >nil: $(OBJF) quiet
-Delete >nil: $(OBJM) quiet
-Delete >nil: $(OBJLISTS) $(OBJLISTX) $(OBJLISTF) $(OBJLISTM) quiet
-Delete >nil: $(MAPFS) $(MAPFX) $(MAPFF) $(MAPFM) quiet
-Delete >nil: \#?$(LISTEXTS) \#?$(LISTEXTX) \#?$(LISTEXTF) quiet
-Delete >nil: $(CWITHOPT) $(CFILEC) $(CFILEX) $(CFILEM) quiet
-Delete >nil: SCOPTIONS SASCOPTS quiet
-Delete >nil: $(LWITHS) $(LWITHX) $(LWITHF) $(LWITHM) quiet
-Delete >nil: \#?.q.?? \#?.tmp \#?.cov quiet
spotless: clean
-Delete >nil: $(UNZIPS) quiet
# UnZip dependencies:
# (objects not needed by Amiga port are commented)
# special rule for adding Amiga internal version number to UnZip
amiga$(O): amiga/amiga.c amiga/filedate.c amiga/stat.c $(UNZIP_H) crypt.h timezone.h env:Workbench
stat$(O): amiga/stat.c amiga/z-stat.h
filedate$(O): amiga/filedate.c crypt.h timezone.h
api$(O): api.c $(UNZIP_H) unzvers.h #zlib.h
apihelp$(O): apihelp.c $(UNZIP_H) unzvers.h
crc32$(O): crc32.c $(UNZIP_H) zip.h
crctab$(O): crctab.c $(UNZIP_H) zip.h
crypt$(O): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs$(O): envargs.c $(UNZIP_H)
explode$(O): explode.c $(UNZIP_H)
extract$(O): extract.c $(UNZIP_H) crypt.h
fileio$(O): fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
globals$(O): globals.c $(UNZIP_H)
inflate$(O): inflate.c $(UNZIP_H) inflate.h #zlib.h
list$(O): list.c $(UNZIP_H)
match$(O): match.c $(UNZIP_H)
process$(O): process.c $(UNZIP_H)
timezone$(O): timezone.c $(UNZIP_H) zip.h timezone.h
ttyio$(O): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$(O): unreduce.c $(UNZIP_H)
unshrink$(O): unshrink.c $(UNZIP_H)
unzip$(O): unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h #zlib.h
#unzipstb$(O): unzipstb.c $(UNZIP_H) unzvers.h
zipinfo$(O): zipinfo.c $(UNZIP_H)
# UnZipSFX dependencies:
#
# special rule for adding Amiga internal version number to UnZipSFX
amiga$(OX): amiga/amiga.c amiga/filedate.c amiga/stat.c $(UNZIP_H) crypt.h timezone.h
unzip$(OX): unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
crctab$(OX): crctab.c $(UNZIP_H) zip.h
crypt$(OX): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
extract$(OX): extract.c $(UNZIP_H) crypt.h
fileio$(OX): fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
globals$(OX): globals.c $(UNZIP_H)
inflate$(OX): inflate.c $(UNZIP_H) inflate.h #zlib.h
match$(OX): match.c $(UNZIP_H)
process$(OX): process.c $(UNZIP_H)
timezone$(OX): timezone.c $(UNZIP_H) zip.h timezone.h
ttyio$(OX): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
# fUnZip dependencies:
#
funzip$(O): funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
crc32$(OF): crc32.c $(UNZIP_H) zip.h
crypt$(OF): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
globals$(OF): globals.c $(UNZIP_H)
inflate$(OF): inflate.c $(UNZIP_H) inflate.h crypt.h #zlib.h
ttyio$(OF): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
filedate$(OF): amiga/filedate.c crypt.h
# MakeSFX dependencies
#
# special transformation rules to never use shortintegers:
makesfx$(O): amiga/makesfx.c
$(CC) WITH=$(CFILEM) LISTFILE=$>$(LISTEXTS) OBJNAME=$@ $*.c
########################
# DEPENDECIES END HERE #
########################
# flush all libraries to provide more mem for compilation
flush:
@Avail flush >nil:
# write common compiler flags to file and echo to user
CommonFlags:
@Echo "$(CFLAGSC)" "$(CCPUOPTSF)" >$(CFILEC)
@Type "$(CWITHOPT)" >>$(CFILEC)
-Type $(CFILEC)
SFXFlags:
@Echo "$(CFLAGSC)" "$(CCPUOPTXM)" >$(CFILEX)
@Type "$(CWITHOPT)" >>$(CFILEX)
-Type $(CFILEX)
# write special MakeSFX flags
MakeSFXFlags:
@Echo "$(CFLAGSS) $(CCPUOPTXM) DATA=NEAR NOSHORTINTEGERS" >$(CFILEM)
# not really needed but if someday used:
@Type "$(CWITHOPT)" >>$(CFILEM)
-Type $(CFILEM)
# special rule for adding Amiga internal version number to amiga.c
amiga$(O):
rx > env:VersionDate "say '""'translate(date('E'),'.','/')'""'"
$(CC) WITH=$(CFILEC) LISTFILE=$>$(LISTEXTS) OBJNAME=$@ $*.c
-Delete env:VersionDate
# needed in amiga/amiga.c
# should be set in startup-sequence, but just in case:
# (only works with OS 2.04 and above)
env\:WorkBench:
@Execute < < (Workbench_smk.tmp)
FailAt 21
If not exists ENV:Workbench
Version >nil:
SetEnv Workbench $$Workbench
Endif
<
# #################
# ### LOCAL_UNZIP ###
# #################
#
# Read environment variable LOCAL_UNZIP and convert options from old Lattice
# v5 to new SAS/C v6 format. You may also use the new DEFINE= syntax but
# be sure not to mix v5 and v6 options, otherwise lctosc will be confused.
#
# e.g.: to define FOO_ONE and FOO_TWO enter:
#
# SetEnv LOCAL_UNZIP "-DFOO_ONE -DFOO_TWO"
#
# To make this permanent, i.e. survive an reboot, put the statement into
# your startup-sequence or (for AmigaDOS 2.0 or higher only) make sure
# LOCAL_UNZIP is stored in the ENVARC: directory too. To do this, simply
# copy the file from ENV: to ENVARC:
# Copy ENV:LOCAL_UNZIP ENVARC:
#
# For a list of all valid non-standard compilation options see the INSTALL
# file in the root zip tree. Please read the notes there before using the
# non-standard options.
#
# e.g.: To use the non-standard timezone environment variable "INFOZIP_TZ"
# (or another arbitary name) instead of "TZ", type in your shell:
#
# Setenv LOCAL_UNZIP "-DTZ_ENVVAR=*"INFOZIP_TZ*""
#
# Note that you need to escape the quotes of INFOZIP_TZ with leading stars.
# To verify that LOCAL_UNZIP has been saved correctly, use the Getenv command:
#
# Getenv LOCAL_UNZIP
#
# ...should display:
#
# -DTZ_ENVVAR="INFOZIP_TZ"
#
local_unzip:
@Execute < < (Local_UnZip_smk.tmp)
Failat 21
Echo ""
If exists ENV:LOCAL_UNZIP
Echo "Using environment variable LOCAL_UNZIP !"
Echo "LOCAL_UNZIP: " NOLINE
GetEnv LOCAL_UNZIP
Copy >NIL: ENV:LOCAL_UNZIP SASCOPTS
Else
Echo "You could use envvar LOCAL_UNZIP to set your special compilation options."
Echo "See the makefile for more information (LOCAL_UNZIP section)."
Delete >nil: SASCOPTS quiet
Endif
Echo ""
; Do not remove the lctosc command! If LOCAL_UNZIP is unset, an
; empty file is created which needed by CommonFlags !
; Moreover, lctosc also accepts new v6 options, i.e. only changes
; known v5 options. Try `lctosc -Dfoo' and `lctosc DEFINE=foo'.
; However, you *must not* mix v5 and v6 options!
lctosc > $(CWITHOPT)
; Now make sure that env:sc/scoptions are NOT used
; we just create an empty file. The options are stored elsewhere.
Echo > SCOPTIONS "" NOLINE
<
# Echo request to the user
#
request:
@Echo ""
@Echo " This makefile is for use with SAS/C version 6.58."
@Echo " If you still have an older version, please upgrade!"
@Echo " Patches are available on the Aminet under biz/patch/sc\#?."
@Echo ""
@Echo " Just a simple request..."
@Echo " Please give me a mail that you compiled whether you encounter any errors"
@Echo " or not. I'd just like to know how many Amiga users actually make use of"
@Echo " this makefile."
@Echo " If you mail me, I'll put you on my mailing-list and notify you whenever"
@Echo " new versions of Info-Zip are released."
@Echo " Have a look at the makefile for changes like CPU type, UtilLib, Stack, etc."
@Echo " Feel free to mail comments, suggestions, critics..."
@Echo " Enjoy Info-Zip !"
@Echo " Haidinger Walter, <walthaid@unix.ict.tuwien.ac.at>"
@Echo ""
# Echo help in case of an error
#
.ONERROR:
@Echo ""
@Echo "[sigh] An error running this makefile was detected."
@Echo "This message may also appear if you interrupted smake by pressing CTRL-C."
@Echo "Contact Info-ZIP authors at Zip-Bugs@lists.wku.edu or me for help."
@Echo "Haidinger Walter, <walthaid@unix.ict.tuwien.ac.at>"

View File

@ -0,0 +1,293 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Here we have a handmade stat() function because Aztec's c.lib stat() */
/* does not support an st_mode field, which we need... also a chmod(). */
/* This stat() is by Paul Wells, modified by Paul Kienitz. */
/* Originally for use with Aztec C >= 5.0 and Lattice C <= 4.01 */
/* Adapted for SAS/C 6.5x by Haidinger Walter */
/* POLICY DECISION: We will not attempt to remove global variables from */
/* this source file for Aztec C. These routines are essentially just */
/* augmentations of Aztec's c.lib, which is itself not reentrant. If */
/* we want to produce a fully reentrant UnZip, we will have to use a */
/* suitable startup module, such as purify.a for Aztec by Paul Kienitz. */
#ifndef __amiga_stat_c
#define __amiga_stat_c
#include <exec/types.h>
#include <exec/memory.h>
#include "amiga/z-stat.h" /* fake version of stat.h */
#include <string.h>
#ifdef AZTEC_C
# include <libraries/dos.h>
# include <libraries/dosextens.h>
# include <clib/exec_protos.h>
# include <clib/dos_protos.h>
# include <pragmas/exec_lib.h>
# include <pragmas/dos_lib.h>
#endif
#ifdef __SASC
# include <sys/dir.h> /* SAS/C dir function prototypes */
# include <sys/types.h>
# include <proto/exec.h>
# include <proto/dos.h>
#endif
#ifndef SUCCESS
# define SUCCESS (-1)
# define FAILURE (0)
#endif
void close_leftover_open_dirs(void); /* prototype */
static DIR *dir_cleanup_list = NULL; /* for resource tracking */
/* CALL THIS WHEN HANDLING CTRL-C OR OTHER UNEXPECTED EXIT! */
void close_leftover_open_dirs(void)
{
while (dir_cleanup_list)
closedir(dir_cleanup_list);
}
unsigned short disk_not_mounted;
extern int stat(const char *file, struct stat *buf);
stat(file,buf)
const char *file;
struct stat *buf;
{
struct FileInfoBlock *inf;
BPTR lock;
time_t ftime;
struct tm local_tm;
if( (lock = Lock((char *)file,SHARED_LOCK))==0 )
/* file not found */
return(-1);
if( !(inf = (struct FileInfoBlock *)AllocMem(
(long)sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR)) )
{
UnLock(lock);
return(-1);
}
if( Examine(lock,inf)==FAILURE )
{
FreeMem((char *)inf,(long)sizeof(*inf));
UnLock(lock);
return(-1);
}
/* fill in buf */
buf->st_dev =
buf->st_nlink =
buf->st_uid =
buf->st_gid =
buf->st_rdev = 0;
buf->st_ino = inf->fib_DiskKey;
buf->st_blocks = inf->fib_NumBlocks;
buf->st_size = inf->fib_Size;
/* now the date. AmigaDOS has weird datestamps---
* ds_Days is the number of days since 1-1-1978;
* however, as Unix wants date since 1-1-1970...
*/
ftime =
(inf->fib_Date.ds_Days * 86400 ) +
(inf->fib_Date.ds_Minute * 60 ) +
(inf->fib_Date.ds_Tick / TICKS_PER_SECOND ) +
(86400 * 8 * 365 ) +
(86400 * 2 ); /* two leap years */
/* tzset(); */ /* this should be handled by mktime(), instead */
/* ftime += timezone; */
local_tm = *gmtime(&ftime);
local_tm.tm_isdst = -1;
ftime = mktime(&local_tm);
buf->st_ctime =
buf->st_atime =
buf->st_mtime = ftime;
buf->st_mode = (inf->fib_DirEntryType < 0 ? S_IFREG : S_IFDIR);
/* lastly, throw in the protection bits */
buf->st_mode |= ((inf->fib_Protection ^ 0xF) & 0xFF);
FreeMem((char *)inf, (long)sizeof(*inf));
UnLock((BPTR)lock);
return(0);
}
int fstat(int handle, struct stat *buf)
{
/* fake some reasonable values for stdin */
buf->st_mode = (S_IREAD|S_IWRITE|S_IFREG);
buf->st_size = -1;
buf->st_mtime = time(&buf->st_mtime);
return 0;
}
/* opendir(), readdir(), closedir(), rmdir(), and chmod() by Paul Kienitz. */
DIR *opendir(const char *path)
{
DIR *dd = AllocMem(sizeof(DIR), MEMF_PUBLIC);
if (!dd) return NULL;
if (!(dd->d_parentlock = Lock((char *)path, MODE_OLDFILE))) {
disk_not_mounted = IoErr() == ERROR_DEVICE_NOT_MOUNTED;
FreeMem(dd, sizeof(DIR));
return NULL;
} else
disk_not_mounted = 0;
if (!Examine(dd->d_parentlock, &dd->d_fib) || dd->d_fib.fib_EntryType < 0) {
UnLock(dd->d_parentlock);
FreeMem(dd, sizeof(DIR));
return NULL;
}
dd->d_cleanuplink = dir_cleanup_list; /* track them resources */
if (dir_cleanup_list)
dir_cleanup_list->d_cleanupparent = &dd->d_cleanuplink;
dd->d_cleanupparent = &dir_cleanup_list;
dir_cleanup_list = dd;
return dd;
}
void closedir(DIR *dd)
{
if (dd) {
if (dd->d_cleanuplink)
dd->d_cleanuplink->d_cleanupparent = dd->d_cleanupparent;
*(dd->d_cleanupparent) = dd->d_cleanuplink;
if (dd->d_parentlock)
UnLock(dd->d_parentlock);
FreeMem(dd, sizeof(DIR));
}
}
struct dirent *readdir(DIR *dd)
{
return (ExNext(dd->d_parentlock, &dd->d_fib) ? (struct dirent *)dd : NULL);
}
#ifdef AZTEC_C
int rmdir(const char *path)
{
return (DeleteFile((char *)path) ? 0 : IoErr());
}
int chmod(const char *filename, int bits) /* bits are as for st_mode */
{
long protmask = (bits & 0xFF) ^ 0xF;
return !SetProtection((char *)filename, protmask);
}
/* This here removes unnecessary bulk from the executable with Aztec: */
void _wb_parse(void) { }
/* fake a unix function that does not apply to amigados: */
int umask(void) { return 0; }
# include <signal.h>
/* C library signal() messes up debugging yet adds no actual usefulness */
typedef void (*__signal_return_type)(int);
__signal_return_type signal() { return SIG_ERR; }
/* The following replaces Aztec's argv-parsing function for compatibility with
Unix-like syntax used on other platforms. It also fixes the problem the
standard _cli_parse() has of accepting only lower-ascii characters. */
int _argc, _arg_len;
char **_argv, *_arg_lin;
void _cli_parse(struct Process *pp, long alen, register UBYTE *aptr)
{
register UBYTE *cp;
register struct CommandLineInterface *cli;
register short c;
register short starred = 0;
# ifdef PRESTART_HOOK
void Prestart_Hook(void);
# endif
cli = (struct CommandLineInterface *) (pp->pr_CLI << 2);
cp = (UBYTE *) (cli->cli_CommandName << 2);
_arg_len = cp[0] + alen + 2;
if (!(_arg_lin = AllocMem((long) _arg_len, 0L)))
return;
c = cp[0];
strncpy(_arg_lin, cp + 1, c);
_arg_lin[c] = 0;
for (cp = _arg_lin + c + 1; alen && (*aptr < '\n' || *aptr > '\r'); alen--)
*cp++ = *aptr++;
*cp = 0;
aptr = cp = _arg_lin + c + 1;
for (_argc = 1; ; _argc++) {
while (*cp == ' ' || *cp == '\t')
cp++;
if (!*cp)
break;
if (*cp == '"') {
cp++;
while (c = *cp++) {
if (c == '"' && !starred) {
*aptr++ = 0;
starred = 0;
break;
} else if (c == '\\' && !starred)
starred = 1;
else {
*aptr++ = c;
starred = 0;
}
}
} else {
while ((c = *cp++) && c != ' ' && c != '\t')
*aptr++ = c;
*aptr++ = 0;
}
if (c == 0)
--cp;
}
*aptr = 0;
if (!(_argv = AllocMem((_argc + 1) * sizeof(*_argv), 0L))) {
_argc = 0;
return;
}
for (c = 0, cp = _arg_lin; c < _argc; c++) {
_argv[c] = cp;
cp += strlen(cp) + 1;
}
_argv[c] = NULL;
# ifdef PRESTART_HOOK
Prestart_Hook();
# endif
}
#endif /* AZTEC_C */
#endif /* __amiga_stat_c */

View File

@ -0,0 +1,95 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#ifndef __amiga_z_stat_h
#define __amiga_z_stat_h
/* Since older versions of the Lattice C compiler for Amiga, and all current */
/* versions of the Manx Aztec C compiler for Amiga, either provide no stat() */
/* function or provide one inadequate for unzip (Aztec's has no st_mode */
/* field), we provide our own stat() function in stat.c by Paul Wells, and */
/* this fake stat.h file by Paul Kienitz. Paul Wells originally used the */
/* Lattice stat.h but that does not work for Aztec and is not distributable */
/* with this package, so I made a separate one. This has to be pulled into */
/* unzip.h when compiling an Amiga version, as "amiga/z-stat.h". */
/* We also provide here a "struct dirent" for use with opendir() & readdir() */
/* functions included in amiga/stat.c. If you use amiga/stat.c, this must */
/* be included wherever you use either readdir() or stat(). */
#ifdef AZTEC_C
# define __STAT_H
#else /* __SASC */
/* do not include the following header, replacement definitions are here */
# define _STAT_H /* do not include SAS/C <stat.h> */
# define _DIRENT_H /* do not include SAS/C <dirent.h> */
# define _SYS_DIR_H /* do not include SAS/C <sys/dir.h> */
# define _COMMIFMT_H /* do not include SAS/C <sys/commifmt.h> */
# include <dos.h>
#endif
#include <libraries/dos.h>
#include <time.h>
struct stat {
unsigned short st_mode;
time_t st_ctime, st_atime, st_mtime;
long st_size;
long st_ino;
long st_blocks;
short st_attr, st_dev, st_nlink, st_uid, st_gid, st_rdev;
};
#define S_IFDIR (1<<11)
#define S_IFREG (1<<10)
#if 0
/* these values here are totally random: */
# define S_IFLNK (1<<14)
# define S_IFSOCK (1<<13)
# define S_IFCHR (1<<8)
# define S_IFIFO (1<<7)
# define S_IFMT (S_IFDIR|S_IFREG|S_IFCHR|S_IFLNK)
#else
# define S_IFMT (S_IFDIR|S_IFREG)
#endif
#define S_IHIDDEN (1<<7)
#define S_ISCRIPT (1<<6)
#define S_IPURE (1<<5)
#define S_IARCHIVE (1<<4)
#define S_IREAD (1<<3)
#define S_IWRITE (1<<2)
#define S_IEXECUTE (1<<1)
#define S_IDELETE (1<<0)
int stat(const char *name, struct stat *buf);
int fstat(int handle, struct stat *buf); /* returns dummy values */
typedef struct dirent {
struct dirent *d_cleanuplink,
**d_cleanupparent;
BPTR d_parentlock;
struct FileInfoBlock d_fib;
} DIR;
#define d_name d_fib.fib_FileName
extern unsigned short disk_not_mounted; /* flag set by opendir() */
DIR *opendir(const char *);
void closedir(DIR *);
void close_leftover_open_dirs(void); /* call this if aborted in mid-run */
struct dirent *readdir(DIR *);
int umask(void);
#ifdef AZTEC_C
int rmdir(const char *);
int chmod(const char *filename, int bits);
#endif
#endif /* __amiga_z_stat_h */

View File

@ -0,0 +1,7 @@
Contents of the "aosvs" subdirectory for UnZip 5.3 and later:
Contents this file
README compilation notes, history, etc.
make_unz.cli command script to make UnZip only (not UnZipSFX or fUnZip)
aosvs.c AOS/VS-specific support routines
aosvs.h AOS/VS-specific typedefs and header stuff

View File

@ -0,0 +1,145 @@
[e-mail excerpt from Dave Lovelace explaining AOS/VS port, compiler, etc.]
> From: Dave Lovelace <davel@cyberspace.org>
> Subject: Re: zip on Data General AOS/VS
> Date: Wed, 17 May 1995 11:02:03 -0400 (EDT)
>
> The diffs for zip & unzip are both in the same file. I've also included the
> extra source files which I wrote, the CLI macros which I used to compile
> & link the things, & my own history of what I did. Note that some of the
> changes I made reversed earlier changes, & this was written for my own
> use (or for others here if I leave or die or something). I hope it will help.
>
> This was compiled using DG's C compiler for AOS/VS, rev 4.10. It has been
> compiled only on an MV-5500 running AOS/VS rev 7.70, but the resulting
> programs have been distributed & run on several different MVs running various
> versions of AOS/VS, so it should be fairly independent of at least minor rev
> variations. To the best of my knowledge it has *not* been tested under
> AOS/VS II, & I really don't know anything about that environment; possibly
> the special AOS/VS file info I'm storing in the extra field will have some
> different format there.
[README/history info from Dave Lovelace]
In modifying this for use on AOS/VS, I found only a few changes
were needed for DG C 4.10:
2. There was a bug in the inflate() code, because memset()
was being called with a non-char pointer. Pretty obviously
the other systems where this was used do not have char pointers
different from other pointers. IT IS QUITE POSSIBLE THAT OTHER
BUGS OF THIS SORT EXIST. Testing did not uncover any.
3. In fileio.c, it appears that utime() is being called correctly,
but it does not set the file's time and always returns failure.
Since the AOS/VS tar and cpio programs provided by DG also suffer
from the fault of not setting file times, I must conclude that
this is by design. At any rate, I modified the code (with
compilation conditional on a macro AOS_VS) to not say "error"
when this occurs.
One change which I think would be desirable: if the filename isn't
already a relative or absolute pathname (specifying a unique location),
the program follows the searchlist under AOS/VS. It will unexpectedly
replace files anywhere in your searchlist. (If you don't use the
-o option, it will ask you first, but not tell you where the file
to be replaced resides.) I suspect this could be handled by prepending
./ to any filenames which don't already begin with /. (I haven't
checked how this would work inside the program. Possibly this
could be done in every case - I don't think PKZIP ever stores an
absolute pathname.)
To see the compile options I used, look at the file MAKE.AOS_VS.CLI
You may of course need to change the searchlist to use that macro.
------------------------------------------------------------------
15-dec-93
I fixed some of the above things, introducing new problems. It now
won't follow the searchlist - but the logic prevents it from creating
directories (if they aren't explicitly in the ZIP, anyway). But
UNZIP now sets the creation time to the time stored in the ZIP, and
ZIP now stores that instead of the TLM. I had to introduce an
extra module, with some code of my own and some other public domain
code, to accomplish this.
------------------------------------------------------------------
1-jun-94
I found an additional bug: the header was causing void to be #define'd
as int, and prototypes weren't being used. I changed UNZIP.H and
added a define of PROTO to the MAKE.AOS_VS.CLI and REMAKE.CLI macros.
I found and fixed the bug that prevented the (creation) times from
being set on files with explicit paths. (The Unix-style paths didn't
work as inputs to the AOS/VS ?CREATE system call.)
Additional known bugs:
1. I have not yet located the source of the bug that prevents the
date/time from being set (also ACLs etc.) when an existing file
is overwritten. For some reason the call to delete & recreate
the file is not being reached.
2. We need to do something in ZIP to store (as comments?) the file's
type and ACL, and then here in UNZIP extract these and apply
them. This is not going to be trivial to make foolproof, but
it's badly needed.
------------------------------------------------------------------
2-jun-94
I fixed #1 above. The compiler was checking whether UNIX was defined,
and it wasn't. It appears that *some* of the places UNIX is used are
things we can't get along with, so I changed the code to check for
AOS_VS as well. It seems to work just fine.
I also introduced a function zvs_credir() to create a directory
(as opposed to a CPD, though it can create CPDs to with the proper
file-type parameter). Directories in a path which are being created
will now be directories instead of CPDs.
The big change that's needed now is to have ZIP store (somehow)
the file's ACL and file type, and then to have UNZIP use this
information to recreate the file as it was before ZIPping. Ideally,
ZIP should also store links and CPD max-block info as well. Planned
strategy: either in the name field but after the name, or in a comment,
store the packet returned by ?FSTAT (using sys_fstat()), and then
use this packet for the ?CREATE call in zvs_create().
------------------------------------------------------------------
22-Jul-94
The changes to use the extra-field field for AOS/VS file info are in
place. In general, if a ZIPfile was created with the current rev of
ZIP.PR, the files should be restored with file type, ACL, etc. OK.
I didn't test to make sure element size & max index levels come
through OK, but I think they should.
Unix symbolic links are now UNZIPped OK, but ZIP.PR isn't yet able
to ZIP links. When it is, UNZIP should be ready.
In general UNZIP now ignores the searchlist fairly well, but not
perfectly. If the directory of a file you're UNZIPping can be
referenced elsewhere in the searchlist, UNZIP will find the file
there. (For example, if the file UDD/BBASIC/ZZPGSUBSET.SR is in
the ZIPfile, and : is in your searchlist, then UDD and UDD:BBASIC
will be created under your current directory, but UNZIP will still
find :UDD:BBASIC:ZZPGSUBSET.SR instead of =UDD:BBASIC:ZZPGSUBSET.SR.
Filenames (which are now stored in uppercase by ZIP.PR) must be
matched exactly if specified. This applies to Unix path structure
as well as case.
------------------------------------------------------------------
4-Aug-94
I fixed a bug which caused (for links only) the Unix pathname to
be put through ux_to_vs_name twice. The result was that a path
such as dir1/dir2/fname went first to :dir1:dir2:fname and
then to dir1?dir2?fname.
I also added the /NOSEA switch to the cc/link lines in the macros
MAKE.AOS_VS.CLI and REMAKE.CLI. This should prevent any confusion
over whether a file exists somewhere other than relative to the current
dir. This would disable calls to system() from using the searchlist,
but in this program I think they're all useless & hopefully inactive
anyway.
------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
aosvs.h
AOS/VS-specific header file for use with Info-ZIP's UnZip 5.2 and later.
---------------------------------------------------------------------------*/
/* stuff to set up for system calls (?FSTAT & ?SACL) and the extra field */
#include <paru.h> /* parameter definitions */
#include <packets/filestatus.h> /* AOS/VS ?FSTAT packet defs */
#include <packets/create.h> /* AOS/VS ?CREATE packet defs */
#include <sys_calls.h> /* AOS/VS system call interface */
#define ZEXTRA_HEADID "VS"
#define ZEXTRA_SENTINEL "FCI"
#define ZEXTRA_REV ((uch)10) /* change/use this in later revs */
/* functions defined in zvs_create.c */
extern int zvs_create(ZCONST char *fname, long cretim, long modtim,
long acctim, char *pacl, int ftyp, int eltsize,
int maxindlev);
extern int zvs_credir(ZCONST char *dname, long cretim, long modtim,
long acctim, char *pacl, int ftyp, long maxblocks,
int hashfsize, int maxindlev);
extern long dgdate(short mm, short dd, short yy);
extern char *ux_to_vs_name(char *outname, ZCONST char *inname);
/* could probably avoid the unions - all elements in each one are the same
* size, and we're going to assume this */
typedef union zvsfstat_stru {
P_FSTAT norm_fstat_packet; /* normal fstat packet */
P_FSTAT_DIR dir_fstat_packet; /* DIR/CPD fstat packet */
P_FSTAT_UNIT unit_fstat_packet; /* unit (device) fstat packet */
P_FSTAT_IPC ipc_fstat_packet; /* IPC file fstat packet */
} ZVSFSTAT_STRU;
typedef union zvscreate_stru {
P_CREATE norm_create_packet; /* normal create packet */
P_CREATE_DIR dir_create_packet; /* DIR/CPD create packet */
P_CREATE_IPC ipc_create_packet; /* IPC file create packet */
} ZVSCREATE_STRU;
typedef struct zextrafld {
char extra_header_id[2]; /* set to VS - in theory, an int */
char extra_data_size[2]; /* size of rest (little-endian) */
char extra_sentinel[4]; /* set to FCI w/ trailing null */
uch extra_rev; /* set to 10 for rev 1.0 */
ZVSFSTAT_STRU fstat_packet; /* the fstat packet */
char aclbuf[$MXACL]; /* the raw ACL */
} ZEXTRAFLD;

View File

@ -0,0 +1,5 @@
push
prompt pop
searchlist :c_4.10 :c_4.10:lang_rt [!searchlist]
cc/link/NOUNX/NOSEA SYSV/DEFINE TERMIO/DEFINE AOS_VS/DEFINE=1 PROTO/DEFINE S_IFLNK/DEFINE=0120000 TIME.H/INCLUDE <unzip crc32 crctab crypt envargs explode extract fileio globals inflate list match process ttyio unreduce unshrink zipinfo aosvs>.c
pop

648
unzip/unzip-5.52/api.c Normal file
View File

@ -0,0 +1,648 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
api.c
This module supplies an UnZip engine for use directly from C/C++
programs. The functions are:
UzpVer *UzpVersion(void);
void UzpVersion2(UzpVer2 *version)
int UzpMain(int argc, char *argv[]);
int UzpAltMain(int argc, char *argv[], UzpInit *init);
int UzpValidate(char *archive, int AllCodes);
void UzpFreeMemBuffer(UzpBuffer *retstr);
int UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,
UzpCB *UsrFuncts, UzpBuffer *retstr);
non-WINDLL only (a special WINDLL variant is defined in windll/windll.c):
int UzpGrep(char *archive, char *file, char *pattern, int cmd, int SkipBin,
UzpCB *UsrFuncts);
OS/2 only (for now):
int UzpFileTree(char *name, cbList(callBack), char *cpInclude[],
char *cpExclude[]);
You must define `DLL' in order to include the API extensions.
---------------------------------------------------------------------------*/
#ifdef OS2
# define INCL_DOSMEMMGR
# include <os2.h>
#endif
#include <setjmp.h>
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef WINDLL
# ifdef POCKET_UNZIP
# include "wince/intrface.h"
# else
# include "windll/windll.h"
# endif
#endif
#include "unzvers.h"
#ifdef DLL /* This source file supplies DLL-only interface code. */
#ifndef POCKET_UNZIP /* WinCE pUnZip defines this elsewhere. */
jmp_buf dll_error_return;
#endif
/*---------------------------------------------------------------------------
Documented API entry points
---------------------------------------------------------------------------*/
UzpVer * UZ_EXP UzpVersion() /* should be pointer to const struct */
{
static UzpVer version; /* doesn't change between calls */
version.structlen = UZPVER_LEN;
#ifdef BETA
version.flag = 1;
#else
version.flag = 0;
#endif
version.betalevel = UZ_BETALEVEL;
version.date = UZ_VERSION_DATE;
#ifdef ZLIB_VERSION
version.zlib_version = ZLIB_VERSION;
version.flag |= 2;
#else
version.zlib_version = NULL;
#endif
/* someday each of these may have a separate patchlevel: */
version.unzip.major = UZ_MAJORVER;
version.unzip.minor = UZ_MINORVER;
version.unzip.patchlevel = UZ_PATCHLEVEL;
version.zipinfo.major = ZI_MAJORVER;
version.zipinfo.minor = ZI_MINORVER;
version.zipinfo.patchlevel = UZ_PATCHLEVEL;
/* these are retained for backward compatibility only: */
version.os2dll.major = UZ_MAJORVER;
version.os2dll.minor = UZ_MINORVER;
version.os2dll.patchlevel = UZ_PATCHLEVEL;
version.windll.major = UZ_MAJORVER;
version.windll.minor = UZ_MINORVER;
version.windll.patchlevel = UZ_PATCHLEVEL;
return &version;
}
void UZ_EXP UzpVersion2(UzpVer2 *version)
{
version->structlen = UZPVER_LEN;
#ifdef BETA
version->flag = 1;
#else
version->flag = 0;
#endif
strcpy(version->betalevel, UZ_BETALEVEL);
strcpy(version->date, UZ_VERSION_DATE);
#ifdef ZLIB_VERSION
/* Although ZLIB_VERSION is a compile-time constant, we implement an
"overrun-safe" copy because its actual value is not under our control.
*/
strncpy(version->zlib_version, ZLIB_VERSION,
sizeof(version->zlib_version) - 1);
version->zlib_version[sizeof(version->zlib_version) - 1] = '\0';
version->flag |= 2;
#else
version->zlib_version[0] = '\0';
#endif
/* someday each of these may have a separate patchlevel: */
version->unzip.major = UZ_MAJORVER;
version->unzip.minor = UZ_MINORVER;
version->unzip.patchlevel = UZ_PATCHLEVEL;
version->zipinfo.major = ZI_MAJORVER;
version->zipinfo.minor = ZI_MINORVER;
version->zipinfo.patchlevel = UZ_PATCHLEVEL;
/* these are retained for backward compatibility only: */
version->os2dll.major = UZ_MAJORVER;
version->os2dll.minor = UZ_MINORVER;
version->os2dll.patchlevel = UZ_PATCHLEVEL;
version->windll.major = UZ_MAJORVER;
version->windll.minor = UZ_MINORVER;
version->windll.patchlevel = UZ_PATCHLEVEL;
}
#ifndef SFX
#ifndef WINDLL
int UZ_EXP UzpAltMain(int argc, char *argv[], UzpInit *init)
{
int r, (*dummyfn)();
CONSTRUCTGLOBALS();
if (init->structlen >= (sizeof(ulg) + sizeof(dummyfn)) && init->msgfn)
G.message = init->msgfn;
if (init->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) && init->inputfn)
G.input = init->inputfn;
if (init->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) && init->pausefn)
G.mpause = init->pausefn;
if (init->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) && init->userfn)
(*init->userfn)(); /* allow void* arg? */
r = unzip(__G__ argc, argv);
DESTROYGLOBALS();
RETURN(r);
}
#endif /* !WINDLL */
#ifndef __16BIT__
void UZ_EXP UzpFreeMemBuffer(UzpBuffer *retstr)
{
if (retstr != NULL && retstr->strptr != NULL) {
free(retstr->strptr);
retstr->strptr = NULL;
retstr->strlength = 0;
}
}
#ifndef WINDLL
static int UzpDLL_Init OF((zvoid *pG, UzpCB *UsrFuncts));
static int UzpDLL_Init(pG, UsrFuncts)
zvoid *pG;
UzpCB *UsrFuncts;
{
int (*dummyfn)();
if (UsrFuncts->structlen >= (sizeof(ulg) + sizeof(dummyfn)) &&
UsrFuncts->msgfn)
((Uz_Globs *)pG)->message = UsrFuncts->msgfn;
else
return FALSE;
if (UsrFuncts->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) &&
UsrFuncts->inputfn)
((Uz_Globs *)pG)->input = UsrFuncts->inputfn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) &&
UsrFuncts->pausefn)
((Uz_Globs *)pG)->mpause = UsrFuncts->pausefn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) &&
UsrFuncts->passwdfn)
((Uz_Globs *)pG)->decr_passwd = UsrFuncts->passwdfn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 5*sizeof(dummyfn)) &&
UsrFuncts->statrepfn)
((Uz_Globs *)pG)->statreportcb = UsrFuncts->statrepfn;
return TRUE;
}
int UZ_EXP UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,
UzpCB *UsrFuncts, UzpBuffer *retstr)
{
int r;
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
char *intern_zip, *intern_file;
#endif
CONSTRUCTGLOBALS();
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
intern_zip = (char *)malloc(strlen(zip)+1);
if (intern_zip == NULL) {
DESTROYGLOBALS();
return PK_MEM;
}
intern_file = (char *)malloc(strlen(file)+1);
if (intern_file == NULL) {
DESTROYGLOBALS();
free(intern_zip);
return PK_MEM;
}
ISO_TO_INTERN(zip, intern_zip);
ISO_TO_INTERN(file, intern_file);
# define zip intern_zip
# define file intern_file
#endif
/* Copy those options that are meaningful for UzpUnzipToMemory, instead of
* a simple "memcpy(G.UzO, optflgs, sizeof(UzpOpts));"
*/
uO.pwdarg = optflgs->pwdarg;
uO.aflag = optflgs->aflag;
uO.C_flag = optflgs->C_flag;
uO.qflag = optflgs->qflag; /* currently, overridden in unzipToMemory */
if (!UzpDLL_Init((zvoid *)&G, UsrFuncts)) {
DESTROYGLOBALS();
return PK_BADERR;
}
G.redirect_data = 1;
r = (unzipToMemory(__G__ zip, file, retstr) <= PK_WARN);
DESTROYGLOBALS();
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
# undef file
# undef zip
free(intern_file);
free(intern_zip);
#endif
if (!r && retstr->strlength) {
free(retstr->strptr);
retstr->strptr = NULL;
}
return r;
}
#endif /* !WINDLL */
#endif /* !__16BIT__ */
#ifdef OS2DLL
int UZ_EXP UzpFileTree(char *name, cbList(callBack), char *cpInclude[],
char *cpExclude[])
{
int r;
CONSTRUCTGLOBALS();
uO.qflag = 2;
uO.vflag = 1;
uO.C_flag = 1;
G.wildzipfn = name;
G.process_all_files = TRUE;
if (cpInclude) {
char **ptr = cpInclude;
while (*ptr != NULL) ptr++;
G.filespecs = ptr - cpInclude;
G.pfnames = cpInclude, G.process_all_files = FALSE;
}
if (cpExclude) {
char **ptr = cpExclude;
while (*ptr != NULL) ptr++;
G.xfilespecs = ptr - cpExclude;
G.pxnames = cpExclude, G.process_all_files = FALSE;
}
G.processExternally = callBack;
r = process_zipfiles(__G)==0;
DESTROYGLOBALS();
return r;
}
#endif /* OS2DLL */
#endif /* !SFX */
/*---------------------------------------------------------------------------
Helper functions
---------------------------------------------------------------------------*/
void setFileNotFound(__G)
__GDEF
{
G.filenotfound++;
}
#ifndef SFX
int unzipToMemory(__GPRO__ char *zip, char *file, UzpBuffer *retstr)
{
int r;
char *incname[2];
G.process_all_files = FALSE;
G.extract_flag = TRUE;
uO.qflag = 2;
G.wildzipfn = zip;
G.pfnames = incname;
incname[0] = file;
incname[1] = NULL;
G.filespecs = 1;
r = process_zipfiles(__G);
if (retstr) {
retstr->strptr = (char *)G.redirect_buffer;
retstr->strlength = G.redirect_size;
}
return r; /* returns `PK_???' error values */
}
#endif /* !SFX */
int redirect_outfile(__G)
__GDEF
{
if (G.redirect_size != 0 || G.redirect_buffer != NULL)
return FALSE;
#ifndef NO_SLIDE_REDIR
G.redirect_slide = !G.pInfo->textmode;
#endif
#if (lenEOL != 1)
if (G.pInfo->textmode) {
G.redirect_size = G.lrec.ucsize * lenEOL;
if (G.redirect_size < G.lrec.ucsize)
G.redirect_size = ((G.lrec.ucsize > (ulg)-2L) ?
G.lrec.ucsize : (ulg)-2L);
} else
#endif
{
G.redirect_size = G.lrec.ucsize;
}
#ifdef __16BIT__
if ((ulg)((extent)G.redirect_size) != G.redirect_size)
return FALSE;
#endif
#ifdef OS2
DosAllocMem((void **)&G.redirect_buffer, G.redirect_size+1,
PAG_READ|PAG_WRITE|PAG_COMMIT);
G.redirect_pointer = G.redirect_buffer;
#else
G.redirect_pointer =
G.redirect_buffer = malloc((extent)(G.redirect_size+1));
#endif
if (!G.redirect_buffer)
return FALSE;
G.redirect_pointer[G.redirect_size] = '\0';
return TRUE;
}
int writeToMemory(__GPRO__ ZCONST uch *rawbuf, extent size)
{
int errflg = FALSE;
if ((uch *)rawbuf != G.redirect_pointer) {
extent redir_avail = (G.redirect_buffer + G.redirect_size) -
G.redirect_pointer;
/* Check for output buffer overflow */
if (size > redir_avail) {
/* limit transfer data to available space, set error return flag */
size = redir_avail;
errflg = TRUE;
}
memcpy(G.redirect_pointer, rawbuf, size);
}
G.redirect_pointer += size;
return errflg;
}
int close_redirect(__G)
__GDEF
{
if (G.pInfo->textmode) {
*G.redirect_pointer = '\0';
G.redirect_size = (ulg)(G.redirect_pointer - G.redirect_buffer);
if ((G.redirect_buffer =
realloc(G.redirect_buffer, G.redirect_size + 1)) == NULL) {
G.redirect_size = 0;
return EOF;
}
}
return 0;
}
#ifndef SFX
#ifndef __16BIT__
#ifndef WINDLL
/* Purpose: Determine if file in archive contains the string szSearch
Parameters: archive = archive name
file = file contained in the archive. This cannot be
a wild card to be meaningful
pattern = string to search for
cmd = 0 - case-insensitive search
1 - case-sensitve search
2 - case-insensitive, whole words only
3 - case-sensitive, whole words only
SkipBin = if true, skip any files that have control
characters other than CR, LF, or tab in the first
100 characters.
Returns: TRUE if a match is found
FALSE if no match is found
-1 on error
Comments: This does not pretend to be as useful as the standard
Unix grep, which returns the strings associated with a
particular pattern, nor does it search past the first
matching occurrence of the pattern.
*/
int UZ_EXP UzpGrep(char *archive, char *file, char *pattern, int cmd,
int SkipBin, UzpCB *UsrFuncts)
{
int retcode = FALSE, compare;
ulg i, j, patternLen, buflen;
char * sz, *p;
UzpOpts flgopts;
UzpBuffer retstr;
memzero(&flgopts, sizeof(UzpOpts)); /* no special options */
if (!UzpUnzipToMemory(archive, file, &flgopts, UsrFuncts, &retstr)) {
return -1; /* not enough memory, file not found, or other error */
}
if (SkipBin) {
if (retstr.strlength < 100)
buflen = retstr.strlength;
else
buflen = 100;
for (i = 0; i < buflen; i++) {
if (iscntrl(retstr.strptr[i])) {
if ((retstr.strptr[i] != 0x0A) &&
(retstr.strptr[i] != 0x0D) &&
(retstr.strptr[i] != 0x09))
{
/* OK, we now think we have a binary file of some sort */
free(retstr.strptr);
return FALSE;
}
}
}
}
patternLen = strlen(pattern);
if (retstr.strlength < patternLen) {
free(retstr.strptr);
return FALSE;
}
sz = malloc(patternLen + 3); /* add two in case doing whole words only */
if (cmd > 1) {
strcpy(sz, " ");
strcat(sz, pattern);
strcat(sz, " ");
} else
strcpy(sz, pattern);
if ((cmd == 0) || (cmd == 2)) {
for (i = 0; i < strlen(sz); i++)
sz[i] = toupper(sz[i]);
for (i = 0; i < retstr.strlength; i++)
retstr.strptr[i] = toupper(retstr.strptr[i]);
}
for (i = 0; i < (retstr.strlength - patternLen); i++) {
p = &retstr.strptr[i];
compare = TRUE;
for (j = 0; j < patternLen; j++) {
/* We cannot do strncmp here, as we may be dealing with a
* "binary" file, such as a word processing file, or perhaps
* even a true executable of some sort. */
if (p[j] != sz[j]) {
compare = FALSE;
break;
}
}
if (compare == TRUE) {
retcode = TRUE;
break;
}
}
free(sz);
free(retstr.strptr);
return retcode;
}
#endif /* !WINDLL */
#endif /* !__16BIT__ */
int UZ_EXP UzpValidate(char *archive, int AllCodes)
{
int retcode;
CONSTRUCTGLOBALS();
uO.jflag = 1;
uO.tflag = 1;
uO.overwrite_none = 0;
G.extract_flag = (!uO.zipinfo_mode &&
!uO.cflag && !uO.tflag && !uO.vflag && !uO.zflag
#ifdef TIMESTAMP
&& !uO.T_flag
#endif
);
uO.qflag = 2; /* turn off all messages */
G.fValidate = TRUE;
G.pfnames = (char **)&fnames[0]; /* assign default filename vector */
#ifdef WINDLL
Wiz_NoPrinting(TRUE);
#endif
if (archive == NULL) { /* something is screwed up: no filename */
DESTROYGLOBALS();
return PK_NOZIP;
}
G.wildzipfn = (char *)malloc(FILNAMSIZ + 1);
strcpy(G.wildzipfn, archive);
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
_ISO_INTERN(G.wildzipfn);
#endif
G.process_all_files = TRUE; /* for speed */
retcode = setjmp(dll_error_return);
if (retcode) {
#ifdef WINDLL
Wiz_NoPrinting(FALSE);
#endif
free(G.wildzipfn);
DESTROYGLOBALS();
return PK_BADERR;
}
retcode = process_zipfiles(__G);
free(G.wildzipfn);
#ifdef WINDLL
Wiz_NoPrinting(FALSE);
#endif
DESTROYGLOBALS();
/* PK_WARN == 1 and PK_FIND == 11. When we are just looking at an
archive, we should still be able to see the files inside it,
even if we can't decode them for some reason.
We also still want to be able to get at files even if there is
something odd about the zip archive, hence allow PK_WARN,
PK_FIND, IZ_UNSUP as well as PK_ERR
*/
if (AllCodes)
return retcode;
if ((retcode == PK_OK) || (retcode == PK_WARN) || (retcode == PK_ERR) ||
(retcode == IZ_UNSUP) || (retcode == PK_FIND))
return TRUE;
else
return FALSE;
}
#endif /* !SFX */
#endif /* DLL */

155
unzip/unzip-5.52/apihelp.c Normal file
View File

@ -0,0 +1,155 @@
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* apihelp.c */
#ifdef API_DOC
#define UNZIP_INTERNAL
#include "unzip.h"
#include "unzvers.h"
APIDocStruct APIDoc[] = {
{
"UZPVERSION" , "UzpVersion" ,
"UzpVer *UzpVersion(void);",
"Get version numbers of the API and the underlying UnZip code.\n\n"
"\t\tThis is used for comparing the version numbers of the run-time\n"
"\t\tDLL code with those expected from the unzip.h at compile time.\n"
"\t\tIf the version numbers do not match, there may be compatibility\n"
"\t\tproblems with further use of the DLL.\n\n"
" Example:\t/* Check the major version number of the DLL code. */\n"
"\t\tUzpVer *pVersion;\n"
"\t\tpVersion = UzpVersion();\n"
"\t\tif (pVersion->unzip.major != UZ_MAJORVER)\n"
"\t\t fprintf(stderr, \"error: using wrong version of DLL\\n\");\n\n"
"\t\tSee unzip.h for details and unzipstb.c for an example.\n"
},
{
"UZPMAIN" , "UzpMain" ,
"int UzpMain(int argc, char *argv[]);",
"Provide a direct entry point to the command line interface.\n\n"
"\t\tThis is used by the UnZip stub but you can use it in your\n"
"\t\town program as well. Output is sent to stdout.\n"
"\t\t0 on return indicates success.\n\n"
" Example:\t/* Extract 'test.zip' silently, junking paths. */\n"
"\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
"\t\tint argc = 3;\n"
"\t\tif (UzpMain(argc,argv))\n"
"\t\t printf(\"error: unzip failed\\n\");\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPALTMAIN" , "UzpAltMain" ,
"int UzpAltMain(int argc, char *argv[], UzpInit *init);",
"Provide a direct entry point to the command line interface,\n"
"optionally installing replacement I/O handler functions.\n\n"
"\t\tAs with UzpMain(), output is sent to stdout by default.\n"
"\t\t`InputFn *inputfn' is not yet implemented. 0 on return\n"
"\t\tindicates success.\n\n"
" Example:\t/* Replace normal output and `more' functions. */\n"
"\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
"\t\tint argc = 3;\n"
"\t\tUzpInit init = { 16, MyMessageFn, NULL, MyPauseFn };\n"
"\t\tif (UzpAltMain(argc,argv,&init))\n"
"\t\t printf(\"error: unzip failed\\n\");\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPUNZIPTOMEMORY", "UzpUnzipToMemory",
"int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);",
"Pass the name of the zip file and the name of the file\n"
"\t\tyou wish to extract. UzpUnzipToMemory will create a\n"
"\t\tbuffer and return it in *retstr; 0 on return indicates\n"
"\t\tfailure.\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPFILETREE", "UzpFileTree",
"int UzpFileTree(char *name, cbList(callBack),\n"
"\t\t\tchar *cpInclude[], char *cpExclude[]);",
"Pass the name of the zip file, a callback function, an\n"
"\t\tinclude and exclude file list. UzpFileTree calls the\n"
"\t\tcallback for each valid file found in the zip file.\n"
"\t\t0 on return indicates failure.\n\n"
"\t\tSee unzip.h for details.\n"
},
{ 0 }
};
static int function_help OF((__GPRO__ APIDocStruct *doc, char *fname));
static int function_help(__G__ doc, fname)
__GDEF
APIDocStruct *doc;
char *fname;
{
strcpy(slide, fname);
/* strupr(slide); non-standard */
while (doc->compare && STRNICMP(doc->compare,slide,strlen(fname)))
doc++;
if (!doc->compare)
return 0;
else
Info(slide, 0, ((char *)slide,
" Function:\t%s\n\n Syntax:\t%s\n\n Purpose:\t%s",
doc->function, doc->syntax, doc->purpose));
return 1;
}
void APIhelp(__G__ argc, argv)
__GDEF
int argc;
char **argv;
{
if (argc > 1) {
struct APIDocStruct *doc;
if (function_help(__G__ APIDoc, argv[1]))
return;
#ifdef SYSTEM_API_DETAILS
if (function_help(__G__ SYSTEM_API_DETAILS, argv[1]))
return;
#endif
Info(slide, 0, ((char *)slide,
"%s is not a documented command.\n\n", argv[1]));
}
Info(slide, 0, ((char *)slide, "\
This API provides a number of external C and REXX functions for handling\n\
zipfiles in OS/2. Programmers are encouraged to expand this API.\n\
\n\
C functions: -- See unzip.h for details\n\
UzpVer *UzpVersion(void);\n\
int UzpMain(int argc, char *argv[]);\n\
int UzpAltMain(int argc, char *argv[], UzpInit *init);\n\
int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);\n\
int UzpFileTree(char *name, cbList(callBack),\n\
char *cpInclude[], char *cpExclude[]);\n\n"));
#ifdef SYSTEM_API_BRIEF
Info(slide, 0, ((char *)slide, SYSTEM_API_BRIEF));
#endif
Info(slide, 0, ((char *)slide,
"\nFor more information, type 'unzip -A <function-name>'\n"));
}
#endif /* API_DOC */

View File

@ -0,0 +1,12 @@
Contents of the "atari" sub-archive for UnZip 5.3 and later:
Contents this file
README.old old notes on compiling UnZip, from author of Atari port
Makefile.old makefile for GNU C compiler and MiNT libraries
Makefile newer, Unix-based makefile (lots of unnecessary baggage :-( )
make_unz.mup script file for invoking makefile(s)?
atari.c Atari-specific routines
The maintainers of the Atari port have fallen behind in their duties; the
code *probably* compiles, but it has not been tested recently. Feel free
to send zip-bugs e-mail about this sorry state of affairs.

View File

@ -0,0 +1,300 @@
#==============================================================================
# Makefile for UnZip, UnZipSFX and fUnZip: Atari ("real" makes only)
# Version: 5.5 13 February 2001
#==============================================================================
# INSTRUCTIONS (such as they are):
#
# "make" -- makes UnZip on a generic Atari
#
# CF are flags for the C compiler. LF are flags for the loader. LF2 are more
# flags for the loader, if they need to be at the end of the line instead of at
# the beginning (for example, some libraries). FL and FL2 are the corre-
# sponding flags for fUnZip. LOCAL_UNZIP is an environment variable that can
# be used to add default C flags to your compile without editing the Makefile
# (e.g., -DDEBUG_STRUC, or -FPi87 on PCs using Microsoft C).
#
# Be sure to test your new UnZip (and UnZipSFX and fUnZip); successful compila-
# tion does not always imply a working program.
#####################
# MACRO DEFINITIONS #
#####################
# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
# such as -DDOSWILD).
# UnZip flags
CC = gcc# try using "gcc" target rather than changing this (if you do,
LD = $(CC)# you MUST change LD, too--else "unresolved symbol: ___main")
LOC = $(LOCAL_UNZIP)
CF = $(CFLAGS) $(LOC)
LF = -o unzip$E
LF2 = -s
# UnZipSFX flags
SL = -o unzipsfx$E
SL2 = $(LF2)
# fUnZip flags
FL = -o funzip$E
FL2 = $(LF2)
# general-purpose stuff
CP = ln -s
LN = ln
RM = rm -f
CHMOD = chmod
STRIP = strip
E = .ttp
O = .o
M = atari
SHELL = /bin/sh
# object files
OBJS1 = unzip$O crc32$O crctab$O crypt$O envargs$O explode$O
OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O
LOBJS = $(OBJS)
OBJSDLL = $(OBJS) api$O
OBJX = unzipsfx$O crc32$O crctab_$O crypt_$O extract_$O fileio_$O \
globals_$O inflate_$O match_$O process_$O ttyio_$O $M_$O
LOBJX = $(OBJX)
OBJF = funzip$O crc32$O cryptf$O globalsf$O inflatef$O ttyiof$O
#OBJS_OS2 = $(OBJS1:.o=.obj) $(OBJS2:.o=.obj) os2.obj
#OBJF_OS2 = $(OBJF:.o=.obj)
UNZIP_H = unzip.h unzpriv.h globals.h
# installation
INSTALL = cp# probably can change this to 'install' if you have it
# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
manext = 1
prefix = /usr/local
BINDIR = $(prefix)/bin# where to install executables
MANDIR = $(prefix)/man/man$(manext)# where to install man pages
INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E \
$(BINDIR)/unzip$E
INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
$(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
#
UNZIPS = unzip$E funzip$E unzipsfx$E
# this is a little ugly...well, no, it's a lot ugly:
MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1
DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt
###############################################
# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
###############################################
# this is for GNU make; comment out and notify zip-bugs if it causes errors
.SUFFIXES: .c .o .obj
# yes, we should be able to use the $O macro to combine these two, but it
# fails on some brain-damaged makes (e.g., AIX's)...no big deal
.c.o:
$(CC) -c $(CF) $*.c
.c.obj:
$(CC) -c $(CF) $*.c
####################
# DEFAULT HANDLING #
####################
all: unzips
unzips: $(UNZIPS)
docs: $(DOCS)
unzipsman: unzips docs
unzipsdocs: unzips docs
unzip$E: $(OBJS)
$(LD) $(LF) $(LOBJS) $(LF2)
unzipsfx$E: $(OBJX)
$(LD) $(SL) $(LOBJX) $(SL2)
funzip$E: $(OBJF)
$(LD) $(FL) $(OBJF) $(FL2)
crc32$O: crc32.c $(UNZIP_H) zip.h
crctab$O: crctab.c $(UNZIP_H) zip.h
crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs$O: envargs.c $(UNZIP_H)
explode$O: explode.c $(UNZIP_H)
extract$O: extract.c $(UNZIP_H) crypt.h
fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
globals$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$O: unreduce.c $(UNZIP_H)
unshrink$O: unshrink.c $(UNZIP_H)
unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
crctab_$O: crctab.c $(UNZIP_H) zip.h # unzipsfx only
$(CP) crctab.c crctab_.c
$(CC) -c $(CF) -DSFX crctab_.c
$(RM) crctab_.c
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) -DSFX crypt_.c
$(RM) crypt_.c
extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only
$(CP) extract.c extract_.c
$(CC) -c $(CF) -DSFX extract_.c
$(RM) extract_.c
fileio_$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h # unzipsfx only
$(CP) fileio.c fileio_.c
$(CC) -c $(CF) -DSFX fileio_.c
$(RM) fileio_.c
globals_$O: globals.c $(UNZIP_H) # unzipsfx only
$(CP) globals.c globals_.c
$(CC) -c $(CF) -DSFX globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) -DSFX inflate_.c
$(RM) inflate_.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) -DSFX process_.c
$(RM) process_.c
match_$O: match.c $(UNZIP_H) # unzipsfx only
$(CP) match.c match_.c
$(CC) -c $(CF) -DSFX match_.c
$(RM) match_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) -DSFX ttyio_.c
$(RM) ttyio_.c
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h # unzipsfx only
$(CP) unzip.c unzipsfx.c
$(CC) -c $(CF) -DSFX unzipsfx.c
$(RM) unzipsfx.c
cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c cryptf.c
$(CC) -c $(CF) -DFUNZIP cryptf.c
$(RM) cryptf.c
globalsf$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globalsf.c
$(CC) -c $(CF) -DFUNZIP globalsf.c
$(RM) globalsf.c
inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflatef.c
$(CC) -c $(CF) -DFUNZIP inflatef.c
$(RM) inflatef.c
ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyiof.c
$(CC) -c $(CF) -DFUNZIP ttyiof.c
$(RM) ttyiof.c
atari$O: atari/atari.c $(UNZIP_H)
$(CC) -c $(CF) -DSFX atari/atari.c
atari_$O: atari/atari.c $(UNZIP_H)
$(CP) atari/atari.c atari_.c
$(CC) -c $(CF) -DSFX atari_.c
$(RM) atari_.c
# this really only works for Unix targets, unless specify E and O on cmd line
clean:
@echo ""
@echo ' This is a Unix-specific target. (Just so you know.)'
@echo ""
rm -f $(OBJS) api$O apihelp$O unzipstb$O $(OBJF) $(OBJX) $(UNZIPS)
install: $(UNZIPS) $(MANS)
$(INSTALL) $(UNZIPS) $(BINDIR)
$(RM) $(BINDIR)/zipinfo$E
$(LN) $(BINDIR)/unzip$E $(BINDIR)/zipinfo$E
$(INSTALL) man/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) man/funzip.1 $(MANDIR)/funzip.$(manext)
$(CHMOD) 755 $(INSTALLEDBIN)
$(CHMOD) 644 $(INSTALLEDMAN)
# alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.]
uninstall:
rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
TESTZIP = testmake.zip # the test zipfile
# test some basic features of the build
test: check
check: unzips
@echo ' This is a Unix-specific target. (Just so you know.)'
if test ! -f $(TESTZIP); then \
echo " error: can't find test file $(TESTZIP)"; exit 1; fi
#
echo " testing extraction"
./unzip -b $(TESTZIP) testmake.zipinfo
if test $? ; then \
echo " error: file extraction from $(TESTZIP) failed"; exit 1; fi
#
echo ' testing zipinfo (unzip -Z)'
./unzip -Z $(TESTZIP) > testmake.unzip-Z
if diff testmake.unzip-Z testmake.zipinfo; then ;; else \
echo ' error: zipinfo output doesn't match stored version'; fi
$(RM) testmake.unzip-Z testmake.zipinfo
#
echo ' testing unzip -d exdir option'
./unzip -b $(TESTZIP) -d testun
cat testun/notes
#
echo ' testing unzip -o and funzip (ignore funzip warning)'
./unzip -boq $(TESTZIP) notes -d testun
./funzip < $(TESTZIP) > testun/notes2
if diff testun/notes testun/notes2; then ;; else \
echo 'error: funzip output disagrees with unzip'; fi
#
echo ' testing unzipsfx (self-extractor)'
cat unzipsfx $(TESTZIP) > testsfx
$(CHMOD) 0700 testsfx
./testsfx -b notes
if diff notes testun/notes; then ;; else \
echo ' error: unzipsfx file disagrees with unzip'; fi
$(RM) testsfx notes testun/notes testun/notes2
rmdir testun
#
echo ' testing complete.'
################################
# INDIVIDUAL MACHINE MAKERULES #
################################
# these are left over for backward compatibility/convenience
generic: unzips
atari: unzips

View File

@ -0,0 +1,227 @@
#==============================================================================
# Makefile for UnZip, UnZipSFX & fUnZip: Atari ST Chris Herborth
# Version: UnZip 5.20+, MiNT, GNU C 13 February 2001
#==============================================================================
# Based on the original unix Makefile and modified by Chris Herborth
# (cherborth@semprini.waterloo-rdp.on.ca), Nov.13/93.
# Be sure to test your new UnZip (and UnZipSFX and fUnZip); successful com-
# pilation does not always imply a working program.
#####################
# MACRO DEFINITIONS #
#####################
# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
# such as -DDOSWILD).
# UnZip flags
# NOTE: 'cgcc' is my cross-compiler; you'll probably use 'gcc' instead.
CC = cgcc
LD = cgcc
LOC = $(LOCAL_UNZIP) -ansi -D__MINT__ -U__STRICT_ANSI__
CF = -mbaserel -mpcrel -O2 -fomit-frame-pointer -I. $(LOC)
# CF = -O -I. $(LOC)
# CF = -mbaserel -O -I. $(LOC)
LF = -mbaserel -mpcrel -o unzip.ttp
LF2 = -s -lbiio
# UnZipSFX flags
XC = -DSFX
XL = -mbaserel -mpcrel -o unzipsfx.ttp
XL2 = $(LF2)
# fUnZip flags
FC = -DFUNZIP
FL = -mbaserel -mpcrel -o funzip.ttp
FL2 = $(LF2)
# general-purpose stuff
CP = cp
LN = ln -s
RM = rm -f
E = .ttp
O = .o
M = atari
SHELL = /bin/sh
# object files
OBJS1 = unzip$O crc32$O crctab$O crypt$O envargs$O explode$O
OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O
LOBJS = $(OBJS)
OBJX = unzipsfx$O crc32$O crctab_$O crypt_$O extract_$O fileio_$O \
globals_$O inflate_$O match_$O process_$O ttyio_$O $M_$O
OBJF = funzip$O crc32$O cryptf$O globalsf$O inflatef$O ttyiof$O
UNZIP_H = unzip.h unzpriv.h globals.h
# installation
INSTALL = cp# probably can change this to 'install' if you have it
# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
manext = 1
MANDIR = /usr/local/man/man$(manext)# where to install man pages
BINDIR = /usr/local/bin# where to install executables
#
UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
MANS = unzip.$(manext) unzipsfx.$(manext) zipinfo.$(manext) funzip.$(manext)
DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt
# this is a little ugly...
INSTALLED = $(BINDIR)/unzip$E $(BINDIR)/zipinfo$E $(BINDIR)/funzip$E \
$(BINDIR)/unzipsfx$E $(MANDIR)/unzipsfx.$(manext) \
$(MANDIR)/unzip.$(manext) $(MANDIR)/zipinfo.$(manext) \
$(MANDIR)/funzip.$(manext)
###############################################
# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
###############################################
.c$O:
$(CC) -c $(CF) $*.c
all: unzips
unzips: $(UNZIPS)
docs: $(DOCS)
unzipsman: unzips docs
unzipsdocs: unzips docs
clean:
rm -f $(OBJS) $(OBJF) $(OBJX) $(UNZIPS)
install: $(UNZIPS) $(MANS)
$(INSTALL) $(UNZIPS) $(BINDIR)
$(LN) $(BINDIR)/unzip$E $(BINDIR)/zipinfo$E
$(INSTALL) man/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) man/funzip.1 $(MANDIR)/funzip.$(manext)
# alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.]
uninstall:
rm -f $(INSTALLED)
unzip$E: $(OBJS) # add `&' if parallel makes supported
$(LD) $(LF) $(LOBJS) $(LF2)
unzipsfx$E: $(OBJX) # add `&' if parallel makes supported
$(LD) $(XL) $(OBJX) $(XL2)
funzip$E: $(OBJF) # add `&' if parallel makes supported
$(LD) $(FL) $(OBJF) $(FL2)
zipinfo$E: unzip$E
@echo\
' This is a Unix-inspired target. If your filesystem does not support'
@echo\
' symbolic links, copy unzip.ttp to zipinfo.ttp rather than linking it,'
@echo\
' or else invoke as "unzip -Z".'
$(LN) unzip$E zipinfo$E
crc32$O: crc32.c $(UNZIP_H) zip.h
crctab$O: crctab.c $(UNZIP_H) zip.h
crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs$O: envargs.c $(UNZIP_H)
explode$O: explode.c $(UNZIP_H)
extract$O: extract.c $(UNZIP_H) crypt.h
fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
globals$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$O: unreduce.c $(UNZIP_H)
unshrink$O: unshrink.c $(UNZIP_H)
unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
crctab_$O: crctab.c $(UNZIP_H) zip.h
$(CP) crctab.c crctab_.c
$(CC) -c $(CF) $(XC) crctab_.c
$(RM) crctab_.c
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) $(XC) crypt_.c
$(RM) crypt_.c
extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only
$(CP) extract.c extract_.c
$(CC) -c $(CF) $(XC) extract_.c
$(RM) extract_.c
fileio_$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
$(CP) fileio.c fileio_.c
$(CC) -c $(CF) $(XC) fileio_.c
$(RM) fileio_.c
globals_$O: globals.c $(UNZIP_H)
$(CP) globals.c globals_.c
$(CC) -c $(CF) $(XC) globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) $(XC) inflate_.c
$(RM) inflate_.c
match_$O: match.c $(UNZIP_H)
$(CP) match.c match_.c
$(CC) -c $(CF) $(XC) match_.c
$(RM) match_.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) $(XC) process_.c
$(RM) process_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) $(XC) ttyio_.c
$(RM) ttyio_.c
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h # unzipsfx only
$(CP) unzip.c unzip_.c
$(CC) -c $(CF) $(XC) unzip_.c
$(RM) unzip_.c
cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c cryptf.c
$(CC) -c $(CF) $(FC) cryptf.c
$(RM) cryptf.c
globalsf$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globalsf.c
$(CC) -c $(CF) $(FC) globalsf.c
$(RM) globalsf.c
inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflatef.c
$(CC) -c $(CF) $(FC) inflatef.c
$(RM) inflatef.c
ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyiof.c
$(CC) -c $(CF) $(FC) ttyiof.c
$(RM) ttyiof.c
# atari$O: atari/atari.c $(UNZIP_H) # Atari only
# $(CC) -c $(CF) atari/atari.c
atari$O: atari.c $(UNZIP_H)
atari_$O: atari.c $(UNZIP_H) # unzipsfx only
$(CP) atari.c atari_.c
$(CC) -c $(CF) $(XC) atari_.c
$(RM) atari_.c

View File

@ -0,0 +1,43 @@
Here it is... the UnZip 5.1 port for the Atari ST/TT/Falcon!
This took me longer than I expected thanks to a difference between the
MiNT library and most UNIX libraries... symlinks are 0x16000
instead of 0xa000... I'm told this isn't even defined in POSIX, so I
can't really complain. At least we've got a filesystem that can use
symlinks!
This port requires GNU C and allows you to build an unzip/zipinfo/funzip
that supports long filenames (on appropriate filesystems, thanks to the
MiNT library), as well as symlinks. It also does "proper" (ie, DOS-style)
translation of text-file end-of-line characters. The programs also build
as shared-text binaries, so you can start unzipping several files at once
in the background and only a small part of unzip will be duplicated in
memory.
I build unzip with the MiNT library, GNU C 2.5.8 (2.5.7 and lower have a
rather sever problem in the optimiser that affects 68000 code only; it
adds 68020-only instructions to the 68000 code). Oh, and I tested it
extensively under MiNT's minix filesystem as well as the bogus DOS
filesystem that "normal" Atari partitions have.
The Makefile won't need any editing if you want to built unzip et al. on
a minix filesystem; if you want to install it on a DOS filesystem, use
"cp" instead of "ln" for zipinfo. [Or, to save disk space, make a script/
command-file which invokes "unzip -Z ...". --CN] This is such a good
idea that I'm annoyed that Greg thought of it and I didn't... ;-) If
you're using a shell worth your while, you can alias zipinfo to
'unzip -Z' and then forget all about this paragraph.
If you want to compile this using Turbo C (aka Pure C in North America)
you're on your own... That's ok, I'll make a nice binary version of
unzip available as soon as the official 5.1 version is released (give or
take a few days).
Enjoy! Cave Newt should be given kudos for keeping this monster easy to
port... ;-) [Hah! But thanks anyway. :-) --CN]
PLEASE email me to tell me if you've uploaded the source or binary
versions of Unzip 5.x to any BBS systems or commercial online systems so
we can update the WHERE file!
-Chris Herborth-

View File

@ -0,0 +1,976 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
atari.c
Atari-specific routines for use with Info-ZIP's UnZip 5.1 and later.
Contains: readdir()
do_wild() <-- generic enough to put in fileio.c?
mapattr()
mapname()
checkdir()
mkdir()
close_outfile()
stamp_file() [optional feature]
version()
Due to the amazing MiNT library being very, very close to BSD unix's
library, I'm using the unix.c as a base for this. Note: If you're not
going to compile this with the MiNT libraries (for GNU C, Turbo C, Pure C,
Lattice C, or Heat & Serve C), you're going to be in for some nasty work.
Most of the modifications in this file were made by Chris Herborth
(cherborth@semprini.waterloo-rdp.on.ca) and /should/ be marked with [cjh].
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#include <dirent.h> /* MiNTlibs has dirent [cjh] */
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
#ifndef SFX
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
/**********************/
char *do_wild(__G__ wildspec)
__GDEF
ZCONST char *wildspec; /* only used first time on a given dir */
{
static DIR *wild_dir = (DIR *)NULL;
static ZCONST char *wildname;
static char *dirname, matchname[FILNAMSIZ];
static int notfirstcall=FALSE, have_dirname, dirnamelen;
struct dirent *file;
/* Even when we're just returning wildspec, we *always* do so in
* matchname[]--calling routine is allowed to append four characters
* to the returned string, and wildspec may be a pointer to argv[].
*/
if (!notfirstcall) { /* first call: must initialize everything */
notfirstcall = TRUE;
if (!iswild(wildspec)) {
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
have_dirname = FALSE;
dir = NULL;
return matchname;
}
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '/')) == (ZCONST char *)NULL) {
dirname = ".";
dirnamelen = 1;
have_dirname = FALSE;
wildname = wildspec;
} else {
++wildname; /* point at character after '/' */
dirnamelen = wildname - wildspec;
if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
Info(slide, 0x201, ((char *)slide,
"warning: cannot allocate wildcard buffers\n"));
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((wild_dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
Trace((stderr, "do_wild: readdir returns %s\n", file->d_name));
if (file->d_name[0] == '.' && wildname[0] != '.')
continue; /* Unix: '*' and '?' do not match leading dot */
/* Need something here for TOS filesystem? [cjh] */
if (match(file->d_name, wildname, 0 WISEP) && /* 0=case sens.*/
/* skip "." and ".." directory entries */
strcmp(file->d_name, ".") && strcmp(file->d_name, "..")) {
Trace((stderr, "do_wild: match() succeeds\n"));
if (have_dirname) {
strcpy(matchname, dirname);
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
}
/* if we get to here directory is exhausted, so close it */
closedir(wild_dir);
wild_dir = (DIR *)NULL;
}
/* return the raw wildspec in case that works (e.g., directory not
* searchable, but filespec was not wild and file is readable) */
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (wild_dir == (DIR *)NULL) {
notfirstcall = FALSE; /* nothing left to try--reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
}
/* If we've gotten this far, we've read and matched at least one entry
* successfully (in a previous call), so dirname has been copied into
* matchname already.
*/
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
/* May need special TOS handling here. [cjh] */
Trace((stderr, "do_wild: readdir returns %s\n", file->d_name));
if (file->d_name[0] == '.' && wildname[0] != '.')
continue; /* Unix: '*' and '?' do not match leading dot */
if (match(file->d_name, wildname, 0 WISEP)) { /* 0 = case sens. */
Trace((stderr, "do_wild: match() succeeds\n"));
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
}
closedir(wild_dir); /* have read at least one entry; nothing left */
wild_dir = (DIR *)NULL;
notfirstcall = FALSE; /* reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
} /* end function do_wild() */
#endif /* !SFX */
/**********************/
/* Function mapattr() */
/**********************/
int mapattr(__G)
__GDEF
{
ulg tmp = G.crec.external_file_attributes;
switch (G.pInfo->hostnum) {
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
case THEOS_:
tmp &= 0xF1FFFFFFL;
if ((tmp & 0xF0000000L) != 0x40000000L)
tmp &= 0x01FFFFFFL; /* not a dir, mask all ftype bits */
else
tmp &= 0x41FFFFFFL; /* leave directory bit as set */
/* fall through! */
case UNIX_:
case VMS_:
case ACORN_:
case ATARI_:
case ATHEOS_:
case BEOS_:
case QDOS_:
case TANDEM_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
if (G.pInfo->file_attr != 0 || !G.extra_field) {
return 0;
} else {
/* Some (non-Info-ZIP) implementations of Zip for Unix and
VMS (and probably others ??) leave 0 in the upper 16-bit
part of the external_file_attributes field. Instead, they
store file permission attributes in some extra field.
As a work-around, we search for the presence of one of
these extra fields and fall back to the MSDOS compatible
part of external_file_attributes if one of the known
e.f. types has been detected.
Later, we might implement extraction of the permission
bits from the VMS extra field. But for now, the work-around
should be sufficient to provide "readable" extracted files.
(For ASI Unix e.f., an experimental remap of the e.f.
mode value IS already provided!)
*/
ush ebID;
unsigned ebLen;
uch *ef = G.extra_field;
unsigned ef_len = G.crec.extra_field_length;
int r = FALSE;
while (!r && ef_len >= EB_HEADSIZE) {
ebID = makeword(ef);
ebLen = (unsigned)makeword(ef+EB_LEN);
if (ebLen > (ef_len - EB_HEADSIZE))
/* discoverd some e.f. inconsistency! */
break;
switch (ebID) {
case EF_ASIUNIX:
if (ebLen >= (EB_ASI_MODE+2)) {
G.pInfo->file_attr =
(unsigned)makeword(ef+(EB_HEADSIZE+EB_ASI_MODE));
/* force stop of loop: */
ef_len = (ebLen + EB_HEADSIZE);
break;
}
/* else: fall through! */
case EF_PKVMS:
/* "found nondecypherable e.f. with perm. attr" */
r = TRUE;
default:
break;
}
ef_len -= (ebLen + EB_HEADSIZE);
ef += (ebLen + EB_HEADSIZE);
}
if (!r)
return 0;
}
/* fall through! */
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
/* PKWARE's PKZip for Unix marks entries as FS_FAT_, but stores the
* Unix attributes in the upper 16 bits of the external attributes
* field, just like Info-ZIP's Zip for Unix. We try to use that
* value, after a check for consistency with the MSDOS attribute
* bits (see below).
*/
G.pInfo->file_attr = (unsigned)(tmp >> 16);
/* fall through! */
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case TOPS20_:
default:
/* Ensure that DOS subdir bit is set when the entry's name ends
* in a '/'. Some third-party Zip programs fail to set the subdir
* bit for directory entries.
*/
if ((tmp & 0x10) == 0) {
extent fnlen = strlen(G.filename);
if (fnlen > 0 && G.filename[fnlen-1] == '/')
tmp |= 0x10;
}
/* read-only bit --> write perms; subdir bit --> dir exec bit */
tmp = !(tmp & 1) << 1 | (tmp & 0x10) >> 4;
if ((G.pInfo->file_attr & 0700) == (unsigned)(0400 | tmp<<6))
/* keep previous G.pInfo->file_attr setting, when its "owner"
* part appears to be consistent with DOS attribute flags!
*/
return 0;
G.pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
break;
} /* end switch (host-OS-created-by) */
/* for originating systems with no concept of "group," "other," "system": */
umask( (int)(tmp=umask(0)) ); /* apply mask to expanded r/w(/x) perms */
G.pInfo->file_attr &= ~tmp;
return 0;
} /* end function mapattr() */
/************************/
/* Function mapname() */
/************************/
int mapname(__G__ renamed)
__GDEF
int renamed;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - caution (truncated filename)
* MPN_INF_SKIP - info "skip entry" (dir doesn't exist)
* MPN_ERR_SKIP - error -> skip entry
* MPN_ERR_TOOLONG - error -> path is too long
* MPN_NOMEM - error (memory allocation failed) -> skip entry
* [also MPN_VOL_LABEL, MPN_CREATED_DIR]
*/
{
char pathcomp[FILNAMSIZ]; /* path-component buffer */
char *pp, *cp=(char *)NULL; /* character pointers */
char *lastsemi=(char *)NULL; /* pointer to last semi-colon in pathcomp */
#ifdef ACORN_FTYPE_NFS
char *lastcomma=(char *)NULL; /* pointer to last comma in pathcomp */
RO_extra_block *ef_spark; /* pointer Acorn FTYPE ef block */
#endif
int killed_ddot = FALSE; /* is set when skipping "../" pathcomp */
int error = MPN_OK;
register unsigned workch; /* hold the character being tested */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return MPN_VOL_LABEL; /* can't set disk volume labels on Atari */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!uO.fflag || renamed);
created_dir = FALSE; /* not yet */
/* user gave full pathname: don't prepend rootpath */
renamed_fullpath = (renamed && (*G.filename == '/'));
if (checkdir(__G__ (char *)NULL, INIT) == MPN_NOMEM)
return MPN_NOMEM; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (uO.jflag) /* junking directories */
cp = (char *)strrchr(G.filename, '/');
if (cp == (char *)NULL) /* no '/' or not junking dirs */
cp = G.filename; /* point to internal zipfile-member pathname */
else
++cp; /* point to start of last component of path */
/*---------------------------------------------------------------------------
Begin main loop through characters in filename.
---------------------------------------------------------------------------*/
while ((workch = (uch)*cp++) != 0) {
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if (strcmp(pathcomp, ".") == 0) {
/* don't bother appending "./" to the path */
*pathcomp = '\0';
} else if (!uO.ddotflag && strcmp(pathcomp, "..") == 0) {
/* "../" dir traversal detected, skip over it */
*pathcomp = '\0';
killed_ddot = TRUE; /* set "show message" flag */
}
/* when path component is not empty, append it now */
if (*pathcomp != '\0' &&
((error = checkdir(__G__ pathcomp, APPEND_DIR))
& MPN_MASK) > MPN_INF_TRUNC)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave direct. semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
#ifdef ACORN_FTYPE_NFS
case ',': /* NFS filetype extension */
lastcomma = pp;
*pp++ = ','; /* keep for now; may need to remove */
break; /* later, if requested */
#endif
#ifdef MTS
case ' ': /* change spaces to underscore under */
*pp++ = '_'; /* MTS; leave as spaces under Unix */
break;
#endif
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
/* Show warning when stripping insecure "parent dir" path components */
if (killed_ddot && QCOND2) {
Info(slide, 0, ((char *)slide,
"warning: skipped \"../\" path component(s) in %s\n",
FnFilter1(G.filename)));
if (!(error & ~MPN_MASK))
error = (error & MPN_MASK) | PK_WARN;
}
/*---------------------------------------------------------------------------
Report if directory was created (and no file to create: filename ended
in '/'), check name to be sure it exists, and combine path and name be-
fore exiting.
---------------------------------------------------------------------------*/
if (G.filename[strlen(G.filename) - 1] == '/') {
checkdir(__G__ G.filename, GETPATH);
if (created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, " creating: %s\n",
FnFilter1(G.filename)));
}
/* set dir time (note trailing '/') */
return (error & ~MPN_MASK) | MPN_CREATED_DIR;
}
/* dir existed already; don't look for data to extract */
return (error & ~MPN_MASK) | MPN_INF_SKIP;
}
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!uO.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
#ifdef ACORN_FTYPE_NFS
/* translate Acorn filetype information if asked to do so */
if (uO.acorn_nfs_ext &&
(ef_spark = (RO_extra_block *)
getRISCOSexfield(G.extra_field, G.lrec.extra_field_length))
!= (RO_extra_block *)NULL)
{
/* file *must* have a RISC OS extra field */
long ft = (long)makelong(ef_spark->loadaddr);
/*32-bit*/
if (lastcomma) {
pp = lastcomma + 1;
while (isxdigit((uch)(*pp))) ++pp;
if (pp == lastcomma+4 && *pp == '\0') *lastcomma='\0'; /* nuke */
}
if ((ft & 1<<31)==0) ft=0x000FFD00;
sprintf(pathcomp+strlen(pathcomp), ",%03x", (int)(ft>>8) & 0xFFF);
}
#endif /* ACORN_FTYPE_NFS */
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
FnFilter1(G.filename)));
return (error & ~MPN_MASK) | MPN_ERR_SKIP;
}
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH);
return error;
} /* end function mapname() */
#if 0 /*========== NOTES ==========*/
extract-to dir: a:path/
buildpath: path1/path2/ ... (NULL-terminated)
pathcomp: filename
mapname():
loop over chars in zipfile member name
checkdir(path component, COMPONENT | CREATEDIR) --> map as required?
(d:/tmp/unzip/) (disk:[tmp.unzip.)
(d:/tmp/unzip/jj/) (disk:[tmp.unzip.jj.)
(d:/tmp/unzip/jj/temp/) (disk:[tmp.unzip.jj.temp.)
finally add filename itself and check for existence? (could use with rename)
(d:/tmp/unzip/jj/temp/msg.outdir) (disk:[tmp.unzip.jj.temp]msg.outdir)
checkdir(name, GETPATH) --> copy path to name and free space
#endif /* 0 */
/***********************/
/* Function checkdir() */
/***********************/
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - (on APPEND_NAME) truncated filename
* MPN_INF_SKIP - path doesn't exist, not allowed to create
* MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path
* exists and is not a directory, but is supposed to be
* MPN_ERR_TOOLONG - path is too long
* MPN_NOMEM - can't allocate memory for filename buffers
*/
{
static int rootlen = 0; /* length of rootpath */
static char *rootpath; /* user's "extract-to" directory */
static char *buildpath; /* full path (so far) to extracted file */
static char *end; /* pointer to end of buildpath ('\0') */
# define FN_MASK 7
# define FUNCTION (flag & FN_MASK)
/*---------------------------------------------------------------------------
APPEND_DIR: append the path component to the path being built and check
for its existence. If doesn't exist and we are creating directories, do
so for this one; else signal success or error as appropriate.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_DIR) {
int too_long = FALSE;
/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
#ifdef SHORT_NAMES
char *old_end = end;
#endif
Trace((stderr, "appending dir segment [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0')
++end;
/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
#ifdef SHORT_NAMES /* path components restricted to 14 chars, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(end = old_end + FILENAME_MAX) = '\0';
#endif
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath after each append, set warning variable if
* within 20 of FILNAMSIZ; then if var set, do careful check when
* appending. Clear variable when begin new path. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: cannot create %s\n\
unable to process %s.\n",
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path didn't exist, tried to create, failed */
return MPN_ERR_SKIP;
}
created_dir = TRUE;
} else if (!S_ISDIR(G.statbuf.st_mode)) {
Info(slide, 1, ((char *)slide,
"checkdir error: %s exists but is not directory\n\
unable to process %s.\n",
FnFilter2(buildpath), FnFilter(G.filename)));
free(buildpath);
/* path existed but wasn't dir */
return MPN_ERR_SKIP;
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
return MPN_OK;
} /* end if (FUNCTION == APPEND_DIR) */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
strcpy(pathcomp, buildpath);
Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp)));
free(buildpath);
buildpath = end = (char *)NULL;
return MPN_OK;
}
/*---------------------------------------------------------------------------
APPEND_NAME: assume the path component is the filename; append it and
return without checking for existence.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_NAME) {
/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
#ifdef SHORT_NAMES
char *old_end = end;
#endif
Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0') {
++end;
/* SHORT_NAMES required for TOS, but it has to co-exist for minix fs... [cjh] */
#ifdef SHORT_NAMES /* truncate name at 14 characters, typically */
if ((end-old_end) > FILENAME_MAX) /* GRR: proper constant? */
*(end = old_end + FILENAME_MAX) = '\0';
#endif
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 0x201, ((char *)slide,
"checkdir warning: path too long; truncating\n\
%s\n -> %s\n",
FnFilter1(G.filename), FnFilter2(buildpath)));
return MPN_INF_TRUNC; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
/* could check for existence here, prompt for new name... */
return MPN_OK;
}
/*---------------------------------------------------------------------------
INIT: allocate and initialize buffer space for the file currently being
extracted. If file was renamed with an absolute path, don't prepend the
extract-to path.
---------------------------------------------------------------------------*/
/* GRR: for VMS and TOPS-20, add up to 13 to strlen */
if (FUNCTION == INIT) {
Trace((stderr, "initializing buildpath to "));
#ifdef ACORN_FTYPE_NFS
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+
(uO.acorn_nfs_ext ? 5 : 1)))
#else
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+1))
#endif
== (char *)NULL)
return MPN_NOMEM;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", FnFilter1(buildpath)));
return MPN_OK;
}
/*---------------------------------------------------------------------------
ROOT: if appropriate, store the path in rootpath and create it if
necessary; else assume it's a zipfile member and return. This path
segment gets used in extracting all members from every zipfile specified
on the command line.
---------------------------------------------------------------------------*/
#if (!defined(SFX) || defined(SFX_EXDIR))
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n", pathcomp));
if (pathcomp == (char *)NULL) {
rootlen = 0;
return MPN_OK;
}
if (rootlen > 0) /* rootpath was already set, nothing to do */
return MPN_OK;
if ((rootlen = strlen(pathcomp)) > 0) {
char *tmproot;
if ((tmproot = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return MPN_NOMEM;
}
strcpy(tmproot, pathcomp);
if (tmproot[rootlen-1] == '/') {
tmproot[--rootlen] = '\0';
}
if (rootlen > 0 && (stat(tmproot, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode)))
{ /* path does not exist */
if (!G.create_dirs /* || iswild(tmproot) */ ) {
free(tmproot);
rootlen = 0;
/* skip (or treat as stored file) */
return MPN_INF_SKIP;
}
/* create the directory (could add loop here scanning tmproot
* to create more than one level, but why really necessary?) */
if (mkdir(tmproot, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: cannot create extraction directory: %s\n",
FnFilter1(tmproot)));
free(tmproot);
rootlen = 0;
/* path didn't exist, tried to create, and failed: */
/* file exists, or 2+ subdir levels required */
return MPN_ERR_SKIP;
}
}
tmproot[rootlen++] = '/';
tmproot[rootlen] = '\0';
if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {
free(tmproot);
rootlen = 0;
return MPN_NOMEM;
}
Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath)));
}
return MPN_OK;
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
#ifdef USE_EF_UT_TIME
unsigned eb_izux_flg;
iztimes zt;
#endif
ztimbuf tp;
fclose(G.outfile);
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate storage for a symlink control
structure, put the uncompressed "data" and other required info in it, and
add the structure to the "deferred symlinks" chain. Since we know it's a
symbolic link to start with, we shouldn't have to worry about overflowing
unsigned ints with unsigned longs.
---------------------------------------------------------------------------*/
/* symlinks allowed on minix filesystems [cjh]
* Hopefully this will work properly... We won't bother to try if
* MiNT isn't present; the symlink should fail if we're on a TOS
* filesystem.
* BUG: should we copy the original file to the "symlink" if the
* link fails?
*/
if (G.symlnk) {
unsigned ucsize = (unsigned)G.lrec.ucsize;
extent slnk_entrysize = sizeof(slinkentry) + ucsize +
strlen(G.filename);
slinkentry *slnk_entry;
if ((unsigned)slnk_entrysize < ucsize) {
Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed: mem alloc overflow\n",
FnFilter1(G.filename)));
return;
}
if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) {
Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed: no mem\n",
FnFilter1(G.filename)));
return;
}
slnk_entry->next = NULL;
slnk_entry->targetlen = ucsize;
slnk_entry->attriblen = 0; /* don't set attributes for symlinks */
slnk_entry->target = slnk_entry->buf;
slnk_entry->fname = slnk_entry->target + ucsize + 1;
strcpy(slnk_entry->fname, G.filename);
/* reopen the "link data" file for reading */
G.outfile = fopen(G.filename, FOPR);
if (!G.outfile ||
fread(slnk_entry->target, 1, ucsize, G.outfile) != (int)ucsize)
{
Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed\n",
FnFilter1(G.filename)));
free(slnk_entry);
fclose(G.outfile);
return;
}
fclose(G.outfile); /* close "link" file for good... */
slnk_entry->target[ucsize] = '\0';
if (QCOND2)
Info(slide, 0, ((char *)slide, "-> %s ",
FnFilter1(slnk_entry->target)));
/* add this symlink record to the list of deferred symlinks */
if (G.slink_last != NULL)
G.slink_last->next = slnk_entry;
else
G.slink_head = slnk_entry;
G.slink_last = slnk_entry;
return;
}
/*---------------------------------------------------------------------------
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
time: adjust base year from 1980 to 1970, do usual conversions from
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
light savings time differences.
---------------------------------------------------------------------------*/
#ifdef USE_EF_UT_TIME
eb_izux_flg = (G.extra_field
#ifdef IZ_CHECK_TZ
&& G.tz_is_valid
#endif
? ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length,
0, G.lrec.last_mod_dos_datetime, &zt, NULL)
: 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
tp.modtime = zt.mtime;
TTrace((stderr, "\nclose_outfile: Unix e.f. modif. time = %ld\n",
tp.modtime));
} else {
tp.modtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
tp.actime = zt.atime;
TTrace((stderr, "close_outfile: Unix e.f. access time = %ld\n",
tp.actime));
} else {
tp.actime = tp.modtime;
TTrace((stderr, "\nclose_outfile: modification/access times = %ld\n",
tp.modtime));
}
#else /* !USE_EF_UT_TIME */
tp.actime = tp.modtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
TTrace((stderr, "\nclose_outfile: modification/access times = %ld\n",
tp.modtime));
#endif /* ?USE_EF_UT_TIME */
/* set the file's access and modification times */
if (utime(G.filename, &tp))
Info(slide, 0x201, ((char *)slide,
"warning: cannot set the time for %s\n", FnFilter1(G.filename)));
/*---------------------------------------------------------------------------
Change the file permissions from default ones to those stored in the
zipfile.
---------------------------------------------------------------------------*/
#ifndef NO_CHMOD
if (chmod(G.filename, 0xffff & G.pInfo->file_attr))
perror("chmod (file attributes) error");
#endif
} /* end function close_outfile() */
#ifdef TIMESTAMP
/***************************/
/* Function stamp_file() */
/***************************/
int stamp_file(fname, modtime)
ZCONST char *fname;
time_t modtime;
{
ztimbuf tp;
tp.modtime = tp.actime = modtime;
return (utime(fname, &tp));
} /* end function stamp_file() */
#endif /* TIMESTAMP */
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
#ifdef __TURBOC__
char buf[40];
#endif
sprintf((char *)slide, LoadFarString(CompiledWith),
#ifdef __GNUC__
"gcc ", __VERSION__,
#else
# if 0
"cc ", (sprintf(buf, " version %d", _RELEASE), buf),
# else
# ifdef __TURBOC__
"Turbo C", (sprintf(buf, " (0x%04x = %d)", __TURBOC__, __TURBOC__), buf),
# else
"unknown compiler", "",
# endif
# endif
#endif
#ifdef __MINT__
"Atari TOS/MiNT",
#else
"Atari TOS",
#endif
" (Atari ST/TT/Falcon030)",
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);
} /* end function version() */
#endif /* !SFX */

View File

@ -0,0 +1,8 @@
#rm -f *.o *.ttp *.sym
#make370 SHELL=/bin/mupfel.ttp CFLAGS=" -O -DATARI" unzips
make370 SHELL=/bin/mupfel.ttp CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.ttp unzip.ttp LF2=
make370 SHELL=/bin/mupfel.ttp CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.sym unzip.sym LF2="-B/bin/sym-"
#make370 SHELL=/bin/mupfel.ttp CFLAGS="-O -DATARI" -n unzips > make_all.mup
#fixstk 32K pgp.ttp
prgflags 017 007 *.ttp

View File

@ -0,0 +1,10 @@
Contents of the "atheos" sub-directory for UnZip 5.52 and later:
Contents this file
README notes from the author of the AtheOS port
Makefile makefile for building UnZip
athcfg.h AtheOS-specific configuration settings
atheos.c AtheOS-specific routines (similar to the BeOS/Unix ones)
atheos.h structures for the AtheOS extra field
- Ruslan Nickolaev (nruslan@hotbox.ru)

View File

@ -0,0 +1,308 @@
######################################################################
#
# Makefile for Info-ZIP's unzip, unzipsfx, and funzip on AtheOS
# Version 5.52
#
# Copyright (C) 1998-2001 Info-ZIP
# Chris Herborth (chrish@qnx.com)
# Copyright (C) 2004 Nikolaev Ruslan (nruslan@hotbox.ru)
#
# To automatically install the fresh new unzip, use the "install" target:
# make -f atheos/Makefile install
######################################################################
SHELL = /bin/bash
# Punish those of you not running on SMP hardware...
MAKE = make -j 4 -f atheos/Makefile
# UnZipSFX flags
SL = -o unzipsfx
SL2 = $(LF2)
# fUnZip flags
FL = -o funzip
FL2 = $(LF2)
# general-purpose stuff
CP = cp
AS = as
RM = rm -f
LN = ln -sf
CHMOD = chmod
E =
O = .o
M = atheos
OSDEP_H = atheos/athcfg.h
# define
# object files
OBJS1 = unzip$O crc_i386$O crctab$O crypt$O envargs$O explode$O
OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O
LOBJS = $(OBJS)
OBJSDLL = $(OBJS) api$O
OBJX = unzipsfx$O crc_i386$O crctab_$O crypt_$O extract_$O fileio_$O globals_$O inflate_$O match_$O process_$O ttyio_$O $M_$O
LOBJX = $(OBJX)
OBJF = funzip$O crc_i386$O cryptf$O globalsf$O inflatef$O ttyiof$O
UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
# installation
INSTALL = install
manext = 1
prefix = /usr
BINDIR = $(prefix)/bin
MANDIR = $(prefix)/man/man$(manext)
INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E $(BINDIR)/unzip$E
INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
#
UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
# this is a little ugly...well, no, it's a lot ugly:
MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1 man/zipgrep.1
######################################################################
CC=gcc
LD=gcc
CF=-O3 -march=i586 -Wall -I. -DPASSWD_FROM_STDIN -DASM_CRC -DUSE_UNSHRINK $(LOCAL_UNZIP)
LF=-o unzip
LF2=
TARGET=$(UNZIPS)
######################################################################
# Helpful targets
all:
@echo 'TARGET = $(TARGET)'
@echo 'CC = $(CC)'
if [ -n "$(TARGET)" ] ; then \
$(MAKE) CC=$(CC) CF="$(CF)" LD="$(LD)" \
LF="$(LF)" LF2="$(LF2)" CCPP="$(CC)" CPPF="$(CF)" \
OBJS="$(OBJS)" LOBJS="$(LOBJS)" OBJX="$(OBJX)" \
LOBJX="$(LOBJX)" $(TARGET) ; \
else \
$(MAKE) help ; \
fi
help:
@echo ''
@echo "This Makefile lets you build Info-ZIP's zip."
@echo ''
@echo 'To build zip for this computer using the default compiler, just do:'
@echo ''
@echo ' make -f atheos/Makefile'
@echo ''
######################################################################
# Basic compile instructions and dependencies
# this is for GNU make; comment out and notify zip-bugs if it causes errors
.SUFFIXES: .c .o
# default for compiling C files
.c.o:
$(CC) -c $(CF) $*.c
unzips: $(UNZIPS)
objs: $(OBJS)
objsdll: $(OBJSDLL)
unzipsman: unzips
unzip$E: $(OBJS)
$(LD) $(LF) $(LOBJS) $(LF2)
$(CHMOD) +x unzip$E
unzipsfx$E: $(OBJX)
$(LD) $(SL) $(LOBJX) $(SL2)
$(CHMOD) +x unzipsfx$E
funzip$E: $(OBJF)
$(LD) $(FL) $(OBJF) $(FL2)
$(CHMOD) +x funzip$E
zipinfo$E: unzip$E
$(LN) unzip$E zipinfo$E
crctab$O: crctab.c $(UNZIP_H) zip.h
crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs$O: envargs.c $(UNZIP_H)
explode$O: explode.c $(UNZIP_H)
extract$O: extract.c $(UNZIP_H) crypt.h
fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
globals$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$O: unreduce.c $(UNZIP_H)
unshrink$O: unshrink.c $(UNZIP_H)
unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
crc_i386$O: crc_i386.S
$(CC) -E crc_i386.S > crc_i386s.s
$(AS) -o $@ crc_i386s.s
$(RM) crc_i386s.s
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h # unzipsfx only
$(CP) unzip.c unzipsfx.c
$(CC) -c $(CF) -DSFX unzipsfx.c
$(RM) unzipsfx.c
match_$O: match.c # unzipsfx only
$(CP) match.c match_.c
$(CC) -c $(CF) -DSFX match_.c
$(RM) match_.c
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) -DSFX crypt_.c
$(RM) crypt_.c
crctab_$O: crctab.c $(UNZIP_H) zip.h # unzipsfx only
$(CP) crctab.c crctab_.c
$(CC) -c $(CF) -DSFX crctab_.c
$(RM) crctab_.c
fileio_$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h # unzipsfx only
$(CP) fileio.c fileio_.c
$(CC) -c $(CF) -DSFX fileio_.c
$(RM) fileio_.c
extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only
$(CP) extract.c extract_.c
$(CC) -c $(CF) -DSFX extract_.c
$(RM) extract_.c
globals_$O: globals.c $(UNZIP_H) # unzipsfx only
$(CP) globals.c globals_.c
$(CC) -c $(CF) -DSFX globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) -DSFX inflate_.c
$(RM) inflate_.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) -DSFX process_.c
$(RM) process_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) -DSFX ttyio_.c
$(RM) ttyio_.c
cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c cryptf.c
$(CC) -c $(CF) -DFUNZIP cryptf.c
$(RM) cryptf.c
globalsf$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globalsf.c
$(CC) -c $(CF) -DFUNZIP globalsf.c
$(RM) globalsf.c
inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflatef.c
$(CC) -c $(CF) -DFUNZIP inflatef.c
$(RM) inflatef.c
ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyiof.c
$(CC) -c $(CF) -DFUNZIP ttyiof.c
$(RM) ttyiof.c
atheos$O: atheos/atheos.c $(UNZIP_H) unzvers.h atheos/atheos.h # AtheOS only
$(CC) -c $(CF) atheos/atheos.c
# version() not used by unzipsfx, so no unzvers.h dependency
atheos_$O: atheos/atheos.c $(UNZIP_H) atheos/atheos.h # unzipsfx only
$(CP) atheos/atheos.c atheos_.c
$(CC) -c $(CF) -Iatheos -DSFX atheos_.c
$(RM) atheos_.c
# this really only works for Unix targets, unless E and O specified on cmd line
clean:
$(RM) $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O unzipstb$O
install: all
$(INSTALL) -m 755 $(UNZIPS) $(BINDIR)
$(RM) $(BINDIR)/zipinfo$E
$(LN) unzip$E $(BINDIR)/zipinfo$E
$(RM) $(BINDIR)/zipgrep$E
$(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
$(INSTALL) -m 644 man/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) -m 644 man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) -m 644 man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) -m 644 man/funzip.1 $(MANDIR)/funzip.$(manext)
$(INSTALL) -m 644 man/zipgrep.1 $(MANDIR)/zipgrep.$(manext)
# alternatively, could use zip method: -cd $(BINDIR); $(RM) $(UNZIPS) [etc.]
uninstall:
$(RM) $(INSTALLEDBIN) $(INSTALLEDMAN)
TESTZIP = testmake.zip # the test zipfile
# test some basic features of the build
test: check
check:
@echo '##### This is a Unix-specific target. (Just so you know.)'
@echo '##### Make sure unzip, funzip and unzipsfx are compiled and'
@echo '##### in this directory.'
@if test ! -f ./unzip; then \
echo "##### ERROR: can't find ./unzip"; exit 1; fi
@if test ! -f ./funzip; then \
echo "##### ERROR: can't find ./funzip"; exit 1; fi
@if test ! -f ./unzipsfx; then \
echo "##### ERROR: can't find ./unzipsfx"; exit 1; fi
#
@if test ! -f $(TESTZIP); then \
echo "##### ERROR: can't find test file $(TESTZIP)"; exit 1; fi
#
@echo "##### testing extraction"
@./unzip -bo $(TESTZIP) testmake.zipinfo
@if test ! -f testmake.zipinfo ; then \
echo "##### ERROR: file extraction from $(TESTZIP) failed"; \
exit 1; fi
#
@echo '##### testing zipinfo (unzip -Z)'
@./unzip -Z $(TESTZIP) > testmake.unzip-Z
@if diff testmake.unzip-Z testmake.zipinfo; then echo "OK."; else \
echo "##### WARNING: zipinfo output doesn't match stored version"; \
echo '##### (If the only difference is the file times, compare your'; \
echo '##### timezone with the Central European timezone, which is one'; \
echo '##### hour east of Greenwich but effectively 2 hours east'; \
echo '##### during summer Daylight Savings Time. The upper two'; \
echo '##### lines should correspond to your local time when the'; \
echo '##### files were created, on 19 November 1998 at 10:46pm CET.'; \
echo '##### If the times are consistent, please ignore this warning.)'; \
fi
@$(RM) testmake.unzip-Z testmake.zipinfo
#
@echo '##### testing unzip -d exdir option'
@./unzip -bo $(TESTZIP) -d testun notes
@cat testun/notes
#
@echo '##### testing unzip -o and funzip (ignore funzip warning)'
@./unzip -boq $(TESTZIP) notes -d testun
@./funzip < $(TESTZIP) > testun/notes2
@if diff testun/notes testun/notes2; then true; else \
echo '##### ERROR: funzip output disagrees with unzip'; fi
#
@echo '##### testing unzipsfx (self-extractor)'
@cat unzipsfx $(TESTZIP) > testsfx
@$(CHMOD) 0700 testsfx
@./testsfx -bo notes
@if diff notes testun/notes; then true; else \
echo '##### ERROR: unzipsfx file disagrees with unzip'; fi
@$(RM) testsfx notes testun/notes testun/notes2
@rmdir testun
#
@echo '##### testing complete.'

View File

@ -0,0 +1,16 @@
UnZip 5.51 for AtheOS/Syllable
This port is based on both BeOS and UNIX versions.
As BeOS version it can extract specific file attributes.
TODO
----
There is only one thing to be fixed:
write_attr() should return count of bytes written. However that's a bug
related with AFS only.
Please report any bugs to Zip-Bugs@lists.wku.edu.
If this bug related with AtheOS/Syllable only, you can mail me directly:
nruslan@hotbox.ru.
- Ruslan Nickolaev (nruslan@hotbox.ru)
Sep 06/2004

View File

@ -0,0 +1,70 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
AtheOS/Syllable specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __athcfg_h
#define __athcfg_h
/* ensure that Unix-specific code portions are excluded */
#ifdef UNIX
# undef UNIX
#endif
#include <sys/types.h> /* off_t, time_t, dev_t, ... */
#include <sys/stat.h>
#include <sys/param.h>
#include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
#include <limits.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#define GOT_UTIMBUF
#define DIRENT
#if (!defined(HAVE_STRNICMP) & !defined(NO_STRNICMP))
# define NO_STRNICMP
#endif
#define INT_SPRINTF
#define SYMLINKS
#ifndef DATE_FORMAT
# define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */
#endif
#define lenEOL 1
#define PutNativeEOL *q++ = native(LF);
#define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
#define SCREENWIDTH 80
#define SCREENLWRAP 1
#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
# define USE_EF_UT_TIME
#endif
#define SET_SYMLINK_ATTRIBS
#define SET_DIR_ATTRIB
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
#define RESTORE_UIDGID
/* Static variables that we have to add to Uz_Globs: */
#define SYSTEM_SPECIFIC_GLOBALS \
int created_dir, renamed_fullpath;\
char *rootpath, *buildpath, *end;\
ZCONST char *wildname;\
char *dirname, matchname[FILNAMSIZ];\
int rootlen, have_dirname, dirnamelen, notfirstcall;\
zvoid *wild_dir;
/* created_dir, and renamed_fullpath are used by both mapname() and */
/* checkdir(). */
/* rootlen, rootpath, buildpath and end are used by checkdir(). */
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
/* and notfirstcall are used by do_wild(). */
#endif /* !__athcfg_h */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* atheos.h -- A few handy things for the AtheOS port
*
* (c) 1997 Chris Herborth (chrish@qnx.com) - BeOS port
* (c) 2004 Ruslan Nickolaev (nruslan@hotbox.ru) - AtheOS port
*
* This is covered under the usual Info-ZIP copyright
*/
#ifndef _ATHEOS_H_
#define _ATHEOS_H_
#define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */
/*
AtheOS 'At' extra-field layout:
(same structure as the BeOS 'Be' e.f. layout, only signature and internal
conventions of the file attribute data are different...)
'At' - signature
ef_size - size of data in this EF (little-endian unsigned short)
full_size - uncompressed data size (little-endian unsigned long)
flag - flags (byte)
flags & EB_BE_FL_UNCMPR = the data is not compressed
flags & EB_BE_FL_BADBITS = the data is corrupted or we
can't handle it properly
data - compressed or uncompressed file attribute data
If flag & EB_BE_FL_UNCMPR, the data is not compressed; this optimisation is
necessary to prevent wasted space for files with small attributes. In this
case, there should be (ef_size - EB_BEOS_HLEN) bytes of data, and full_size
should equal (ef_size - EB_BEOS_HLEN).
If the data is compressed, there will be (ef_size - EB_BEOS_HLEN) bytes of
compressed data, and full_size bytes of uncompressed data.
If a file has absolutely no attributes, there will not be a 'At' extra field.
The uncompressed data is arranged like this:
attr_name\0 - C string
struct attr_info (fields in little-endian format)
attr_data (length in attr_info.ai_size)
*/
#endif /* _ATHEOS_H_ */

View File

@ -0,0 +1,15 @@
Contents of the "beos" sub-directory for UnZip 5.52 and later:
Contents this file
README notes from the author of the BeOS port
Makefile makefile for building UnZip (sorry, no project files)
beocfg.h BeOS-specific configuration settings
beos.c BeOS-specific routines (similar to the Unix ones)
beos.h structures for the BeOS extra field
beosmain.cpp BeOS-specific C++ routines
unzip.rsc BeOS resources for UnZip
unzipsfx.rsc BeOS resources for UnZipSFX
This port supports both Metrowerks CodeWarrior (PowerPC and x86) and GNU C.
- Chris Herborth (chrish@qnx.com)

View File

@ -0,0 +1,414 @@
######################################################################
#
# Makefile for Info-ZIP's unzip, unzipsfx, and funzip on BeOS
#
# Copyright (c) 1998-2004 Info-ZIP
# Chris Herborth (chrish@qnx.com)
#
# This is the new New and Improved Makefile for BeOS; it will:
#
# 1) automatically detect your platform (PowerPC or x86) if none is
# specified; the default compiler is CodeWarrior for PowerPC, or
# gcc for x86
#
# 2) let you cross-compile for the other platform (PowerPC or x86), in
# theory
#
# 3) let you use Metrowerks CodeWarrior (default) or GNU C to build with
# for either platfor, in theory
#
# To choose a specific architecture, define the ARCH environment
# variable on the make command-line:
#
# ARCH=what make -f beos/Makefile
#
# where "what" can be "powerpc" or "x86".
#
# To choose a specific compiler, define the CC environment variable on
# the make command-line:
#
# CC=compiler make -f beos/Makefile
#
# where "compiler" can be "mwcc" or "x86".
#
# Of course, you can combine these two:
#
# ARCH=powerpc CC=mwcc make -f beos/Makefile
#
# or:
#
# CC=gcc ARCH=x86 make -f beos/Makefile
#
# To automatically install the fresh new unzip, use the "install" target:
#
# make -f beos/Makefile install
######################################################################
# Things that don't change:
SHELL = /bin/sh
# Punish those of you not running on SMP hardware...
MAKE = make -j 4 -f beos/Makefile
LOC=$(LOCAL_UNZIP) -DPASSWD_FROM_STDIN
AF=$(LOC)
# UnZipSfx flags
SL = -o unzipsfx
SL2 = $(LF2)
# fUnZip flags
FL = -o funzip
FL2 = $(LF2)
# general-purpose stuff
CP = cp
RM = rm -f
LN = ln -sf
E =
O = .o
M = beos
# defaults for crc32 stuff and system-dependent headers
CRC32 = crc32
OSDEP_H = beos/beocfg.h
# object files
OBJS1 = unzip$O $(CRC32)$O crctab$O crypt$O envargs$O explode$O
OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O $(BEOS_MAIN)
LOBJS = $(OBJS)
OBJSDLL = $(OBJS) api$O
OBJX = unzipsfx$O $(CRC32)$O crctab_$O crypt_$O extract_$O fileio_$O \
globals_$O inflate_$O match_$O process_$O ttyio_$O $M_$O $(BEOS_MAIN)
LOBJX = $(OBJX)
OBJF = funzip$O $(CRC32)$O cryptf$O globalsf$O inflatef$O ttyiof$O
UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
# installation
INSTALL = install
# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
manext = 1
prefix = /boot/home/config
BINDIR = $(prefix)/bin# where to install executables
MANDIR = $(prefix)/man/man$(manext)# where to install man pages
INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E \
$(BINDIR)/unzip$E
INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
$(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
#
UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
# this is a little ugly...well, no, it's a lot ugly:
MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1 man/zipgrep.1
DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt zipgrep.txt
######################################################################
# Things that change:
# Select an architecture:
ifndef ARCH
MACHINE=$(shell uname -m)
ifeq "$(MACHINE)" "BePC"
ARCH=x86
CC=gcc
else
ARCH=powerpc
CC=mwcc
endif
endif
# Now select compiler flags and whatnot based on the ARCH and CC:
WHAT=$(ARCH)-$(CC)
ifeq "$(WHAT)" "powerpc-mwcc"
CC=mwccppc
LD=mwccppc
CF=-w9 -O7 -opt schedule604 -rostr -I. $(LOC)
LF=-o unzip
LF2=-warn -L/boot/develop/lib/ppc -lbe -lroot
BEOS_MAIN=beosmain$O
TARGET=$(UNZIPS)
endif
ifeq "$(WHAT)" "powerpc-gcc"
CC=gcc
LD=gcc
CF=-O3 -mcpu=604 -Wall -ansi -I. -I/boot/develop/headers/be/support \
-I/boot/develop/headers/be/storage $(LOC)
LF=-o unzip
LF2=-L/boot/develop/lib/ppc -lbe -lroot
BEOS_MAIN=beosmain$O
TARGET=$(UNZIPS)
endif
# This isn't likely to happen for R4 or later...
ifeq "$(WHAT)" "x86-mwcc"
CC=mwccx86
LD=mwccx86
CF=-O2 -w9 -I. $(LOC)
LF=-o unzip
LF2=-warn -L/boot/develop/lib/x86 -lbe -lroot
BEOS_MAIN=beosmain$O
TARGET=$(UNZIPS)
endif
ifeq "$(WHAT)" "x86-gcc"
CC=gcc
LD=gcc
CF=-O3 -mpentiumpro \
-Wall -Wno-multichar -Wno-trigraphs \
-ansi -I. -I/boot/develop/headers/be/support \
-I/boot/develop/headers/be/storage $(LOC)
LF=-o unzip
LF2=-L/boot/develop/lib/x86 -lbe -lroot
BEOS_MAIN=beosmain$O
TARGET=$(UNZIPS)
endif
ifndef TARGET
TARGET=help
endif
######################################################################
# Helpful targets
all:
@echo 'TARGET = $(TARGET)'
@echo 'ARCH = $(ARCH)'
@echo 'CC = $(CC)'
if [ -n "$(TARGET)" ] ; then \
$(MAKE) CC=$(CC) CF="$(CF)" LD="$(LD)" \
LF="$(LF)" LF2="$(LF2)" CCPP="$(CC)" CPPF="$(CF)" \
OBJS="$(OBJS)" LOBJS="$(LOBJS)" OBJX="$(OBJX)" \
LOBJX="$(LOBJX)" $(TARGET) ; \
else \
$(MAKE) help ; \
fi
help:
@echo ''
@echo "This Makefile lets you build Info-ZIP's zip."
@echo ''
@echo 'To build zip for this computer using the default compiler, just do:'
@echo ''
@echo ' make -f beos/Makefile'
@echo ''
@echo 'To build zip for a specific architecture using a specific'
@echo 'compiler, do:'
@echo ''
@echo ' ARCH=cpu CC=compiler make -f beos/Makefile'
@echo ''
@echo 'Where:'
@echo ' cpu is either "powerpc" or "x86"'
@echo ' compiler is either "mwcc" or "gcc"'
@echo ''
######################################################################
# Basic compile instructions and dependencies
# this is for GNU make; comment out and notify zip-bugs if it causes errors
.SUFFIXES: .c .o
# default for compiling C files
.c.o:
$(CC) -c $(CF) $*.c
unzips: $(UNZIPS)
objs: $(OBJS)
objsdll: $(OBJSDLL)
docs: $(DOCS)
unzipsman: unzips docs
unzipsdocs: unzips docs
unzip$E: $(OBJS) beos/unzip.rsc
$(LD) $(LF) $(LOBJS) $(LF2)
chmod +x unzip$E
xres -o unzip$E beos/unzip.rsc
mimeset -f -all unzip$E
unzipsfx$E: $(OBJX) beos/unzipsfx.rsc
$(LD) $(SL) $(LOBJX) $(SL2)
chmod +x unzipsfx$E
xres -o unzipsfx$E beos/unzipsfx.rsc
mimeset -f -all unzipsfx
funzip$E: $(OBJF)
$(LD) $(FL) $(OBJF) $(FL2)
chmod +x funzip$E
zipinfo$E: unzip$E
$(LN) unzip$E zipinfo$E
crc32$O: crc32.c $(UNZIP_H) zip.h
crctab$O: crctab.c $(UNZIP_H) zip.h
crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs$O: envargs.c $(UNZIP_H)
explode$O: explode.c $(UNZIP_H)
extract$O: extract.c $(UNZIP_H) crypt.h
fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
globals$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$O: unreduce.c $(UNZIP_H)
unshrink$O: unshrink.c $(UNZIP_H)
unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h # unzipsfx only
$(CP) unzip.c unzipsfx.c
$(CC) -c $(CF) -DSFX unzipsfx.c
$(RM) unzipsfx.c
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) -DSFX crypt_.c
$(RM) crypt_.c
crctab_$O: crctab.c $(UNZIP_H) zip.h # unzipsfx only
$(CP) crctab.c crctab_.c
$(CC) -c $(CF) -DSFX crctab_.c
$(RM) crctab_.c
fileio_$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h # unzipsfx only
$(CP) fileio.c fileio_.c
$(CC) -c $(CF) -DSFX fileio_.c
$(RM) fileio_.c
extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only
$(CP) extract.c extract_.c
$(CC) -c $(CF) -DSFX extract_.c
$(RM) extract_.c
globals_$O: globals.c $(UNZIP_H) # unzipsfx only
$(CP) globals.c globals_.c
$(CC) -c $(CF) -DSFX globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) -DSFX inflate_.c
$(RM) inflate_.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) -DSFX process_.c
$(RM) process_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) -DSFX ttyio_.c
$(RM) ttyio_.c
cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c cryptf.c
$(CC) -c $(CF) -DFUNZIP cryptf.c
$(RM) cryptf.c
globalsf$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globalsf.c
$(CC) -c $(CF) -DFUNZIP globalsf.c
$(RM) globalsf.c
inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflatef.c
$(CC) -c $(CF) -DFUNZIP inflatef.c
$(RM) inflatef.c
ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyiof.c
$(CC) -c $(CF) -DFUNZIP ttyiof.c
$(RM) ttyiof.c
beos$O: beos/beos.c $(UNZIP_H) unzvers.h beos/beos.h # BeOS only
$(CC) -c $(CF) beos/beos.c
beosmain$O: beos/beosmain.cpp $(UNZIP_H) unzvers.h # BeOS only
$(CCPP) -c $(CPPF) beos/beosmain.cpp
# version() not used by unzipsfx, so no unzvers.h dependency
beos_$O: beos/beos.c $(UNZIP_H) beos/beos.h # unzipsfx only
$(CP) beos/beos.c beos_.c
$(CC) -c $(CF) -Ibeos -DSFX beos_.c
$(RM) beos_.c
beosmain_$O: beos/beosmain.cpp $(UNZIP_H)
$(CP) beos/beosmain.cpp beosmain_.cpp
$(CCPP) -c $(CPPF) -Ibeos -DSFX beosmain_.cpp
$(RM) beosmain_.cpp
# this really only works for Unix targets, unless E and O specified on cmd line
clean:
-rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O \
unzipstb$O beosmain.o beosmain_.o
install: all
$(INSTALL) -m 755 $(UNZIPS) $(BINDIR)
mimeset -f -all $(BINDIR)/unzip
mimeset -f -all $(BINDIR)/unzipsfx
$(RM) $(BINDIR)/zipinfo$E
$(LN) unzip$E $(BINDIR)/zipinfo$E
$(RM) $(BINDIR)/zipgrep$E
$(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
$(INSTALL) -m 644 man/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) -m 644 man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) -m 644 man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) -m 644 man/funzip.1 $(MANDIR)/funzip.$(manext)
$(INSTALL) -m 644 man/zipgrep.1 $(MANDIR)/zipgrep.$(manext)
$(INSTALL) -m 644 $(DOCS) $(MANDIR)
# alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.]
uninstall:
rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
TESTZIP = testmake.zip # the test zipfile
# test some basic features of the build
test: check
check: unzips
@echo ' This is a Unix-specific target. (Just so you know.)'
@echo ' (Should work ok on BeOS... [cjh])'
if test ! -f $(TESTZIP); then \
echo " error: can't find test file $(TESTZIP)"; exit 1; fi
#
echo " testing extraction"
./unzip -b $(TESTZIP) testmake.zipinfo
if test $? ; then \
echo " error: file extraction from $(TESTZIP) failed"; exit 1; fi
#
echo ' testing zipinfo (unzip -Z)'
./unzip -Z $(TESTZIP) > testmake.unzip-Z
if diff testmake.unzip-Z testmake.zipinfo; then ;; else \
echo ' error: zipinfo output doesn't match stored version'; fi
$(RM) testmake.unzip-Z testmake.zipinfo
#
echo ' testing unzip -d exdir option'
./unzip -b $(TESTZIP) -d testun
cat testun/notes
#
echo ' testing unzip -o and funzip (ignore funzip warning)'
./unzip -boq $(TESTZIP) notes -d testun
./funzip < $(TESTZIP) > testun/notes2
if diff testun/notes testun/notes2; then ;; else \
echo 'error: funzip output disagrees with unzip'; fi
#
echo ' testing unzipsfx (self-extractor)'
cat unzipsfx $(TESTZIP) > testsfx
$(CHMOD) 0700 testsfx
./testsfx -b notes
if diff notes testun/notes; then ;; else \
echo ' error: unzipsfx file disagrees with unzip'; fi
$(RM) testsfx notes testun/notes testun/notes2
rmdir testun
#
echo ' testing complete.'

View File

@ -0,0 +1,77 @@
UnZip 5.4 for BeOS
NOTE:
If you want to build UnZip 5.4 or later from the source, you'll need to
have the "xres" tool installed (unless you remove the "xres" lines in the
beos/Makefile). This will cease to be a problem when BeOS R4 ships this
fall. Until then, you can get xres from
ftp://ftp.be.com/pub/experimental/tools/xres-102.zip.
HISTORY
UnZip 5.30 was the first official release of Info-ZIP's UnZip to support
the filesystem in BeOS.
UnZip 5.31 added support for the new filesystem that appeared in the
Advanced Access Preview (aka DR9) Release of BeOS.
UnZip 5.32 added several important bug fixes.
UnZip 5.4:
- supports BeOS on x86 hardware (and cross-compiling, if a compiler is
present)
- ask the Registrar to assign a file type to files that don't have one
- adds a new -J option on BeOS; this lets you extract the data for a file
without restoring its file attributes (handy if you stumble on really
old BeOS ZIP archives... from before BeOS Preview Release)
- will restore attributes properly on symbolic links (you'll need
zip 2.21 or later to create ZIP files that store attributes for
symbolic links)
*** WARNING ***
You may find some extremely old BeOS zip archives that store their
file attributes differently; these will be from DR8 and earlier (when
BeOS copied the MacOS type/creator fields instead of using the current
extremely flexible scheme).
You can still unpack the _data_ in older zip files, but you won't be
able to recover the file attributes in those archives. Use the -J option
with these files or you'll get "compressed EA data missing" and "zipfile
probably corrupt" errors, even though the data is intact!
The new scheme makes handling BeOS file attributes much more robust, and
allows for possible future expansion without another round of
incompatibilities.
That's life on the edge!
*** WARNING ***
The new filesystem allows for huge files (up to several terabytes!) with
huge amounts of meta-data (up to several terabytes!). The existing ZIP
format was designed when this much data on a personal computer was
science fiction; as a result, it's quite possible that large amounts of file
attributes (more than maybe 100+K bytes) could be truncated. Zip and UnZip
try to deal with this in a fairly sensible way, working on the assumption
that the data in the file is more important than the data in the file
attributes.
One way to run into this problem is to mount an HFS volume and zip
some Mac files that have large resources attached to them. This
happens more often than you'd expect; I've seen several 0-byte files that
had over four megabytes of resources. Even more stupid, these resources
were _data_ (sound for a game), and could have been easily stored as
data...
KNOWN BUGS
None! Yahoo!
Please report any bugs to Zip-Bugs@lists.wku.edu.
- Chris Herborth (chrish@qnx.com)
November 2/1998

View File

@ -0,0 +1,60 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
BeOS specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __beocfg_h
#define __beocfg_h
#include <sys/types.h> /* [cjh]: This is pretty much a generic */
#include <sys/stat.h> /* POSIX 1003.1 system; see beos/ for */
#include <fcntl.h> /* extra code to deal with our extra file */
#include <sys/param.h> /* attributes. */
#include <unistd.h>
#include <utime.h>
#define DIRENT
#include <time.h>
#ifndef DATE_FORMAT
# define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */
#endif
#define lenEOL 1
#define PutNativeEOL *q++ = native(LF);
#define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
#define SCREENWIDTH 80
#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
# define USE_EF_UT_TIME
#endif
#define SET_SYMLINK_ATTRIBS
#define SET_DIR_ATTRIB
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
#define RESTORE_UIDGID
#define NO_STRNICMP /* not in the x86 headers at least */
#define INT_SPRINTF
#define SYMLINKS
#define MAIN main_stub /* now that we're using a wrapper... */
/* Static variables that we have to add to Uz_Globs: */
#define SYSTEM_SPECIFIC_GLOBALS \
int created_dir, renamed_fullpath;\
char *rootpath, *buildpath, *end;\
ZCONST char *wildname;\
char *dirname, matchname[FILNAMSIZ];\
int rootlen, have_dirname, dirnamelen, notfirstcall;\
zvoid *wild_dir;
/* created_dir, and renamed_fullpath are used by both mapname() and */
/* checkdir(). */
/* rootlen, rootpath, buildpath and end are used by checkdir(). */
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
/* and notfirstcall are used by do_wild(). */
#endif /* !__beocfg_h */

1485
unzip/unzip-5.52/beos/beos.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* beos.h -- A few handy things for the BeOS port. */
/* (c) 1997 Chris Herborth (chrish@qnx.com) */
/* This is covered under the usual Info-ZIP copyright. */
/* "#define EF_BE_FL_UNCMPR 0x01" has been moved into unzpriv.h */
#define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */
#define BEOS_ASSIGN_FILETYPE 1 /* call update_mime_info() */
/*
DR9 'Be' extra-field layout:
'Be' - signature
ef_size - size of data in this EF (little-endian unsigned short)
full_size - uncompressed data size (little-endian unsigned long)
flag - flags (byte)
flags & EB_BE_FL_UNCMPR = the data is not compressed
flags & EB_BE_FL_BADBITS = the data is corrupted or we
can't handle it properly
data - compressed or uncompressed file attribute data
If flag & EB_BE_FL_UNCMPR, the data is not compressed; this optimisation is
necessary to prevent wasted space for files with small attributes (which
appears to be quite common on the Advanced Access DR9 release). In this
case, there should be ( ef_size - EB_BEOS_HLEN ) bytes of data, and full_size
should equal ( ef_size - EB_BEOS_HLEN ).
If the data is compressed, there will be ( ef_size - EB_BEOS_HLEN ) bytes of
compressed data, and full_size bytes of uncompressed data.
If a file has absolutely no attributes, there will not be a 'Be' extra field.
The uncompressed data is arranged like this:
attr_name\0 - C string
struct attr_info (fields in big-endian format)
attr_data (length in attr_info.size)
*/

View File

@ -0,0 +1,44 @@
// -*- C++ -*-
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
//
// WARNING: This is C++, not C! GNU C is not supported here!
//
// beos_init.cpp
//
// BeOS-specific C++ routines for use with Info-ZIP's UnZip 5.30 or later.
//
// This is necessary because we need to have an app_server connection to be
// able to ask the system to assign a MIME type to an un-typed file. Strange
// but true (the update_mime_info() call needs to send/receive messages).
//
// If you're writing your own Zip application, you probably DO NOT want to
// include this file!
#include <app/Application.h>
#ifdef SFX
const static char *unzip_signature = "application/x-vnd.Info-ZIP.UnZipSFX";
#else
const static char *unzip_signature = "application/x-vnd.Info-ZIP.UnZip";
#endif
extern "C" int main_stub( int argc, char *argv[] );
int main( int argc, char **argv )
{
BApplication app( unzip_signature );
int retval = main_stub( argc, argv );
app.PostMessage( B_QUIT_REQUESTED );
app.Run();
return retval;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,159 @@
-----------------------------------------------------------------------
[Installation notes for VM/CMS port of UNZIP 5.32 and ZIP 2.2]
Additional notes from Ian E. Gorman (4/98):
I have not fully tested ZIP and UNZIP in VM (for example, I have not
tried all the options), so ZIP 2.2 for VM and UNZIP 5.32 for VM
should be regarded as beta versions. Try them out before you decide
that you can depend on them.
Most of the work for the VM port has been done by others, but I have
made some changes and compiled on a more recent version of VM/CMS. It
is possible that I have introduced new problems or undone some of the
solutions found by previous authors.
Installation
============
The executables are stored in CMS "PACK" format instead of being
stored in ZIP archives. This format takes a little longer to
download, but installation is slightly simpler.
Installing UNZIP
----------------
The UNZIP executable is supplied as the binary file UNZIP.MOD, in the
CMS "PACK" format.
You must get the UNZIP.MOD file on to your system as a binary file in
fixed recording mode, block size 1024.
If you are using FTP in CMS, you can get the file in the correct
format with the LOCSITE and BINARY commands. Assuming that the UNZIP
executable is stored on the remote site as unz532vm.mod, you could
issue the following commands
FTP where.ever.com
<enter user id and password and other stuff>
BINARY
LOCSITE FIX 1024
GET unz532vm.mod
QUIT
If you are using a 3270 terminal session to upload from a PC, you can
upload the file in the correct format with the SEND command:
SEND unz532vm.mod A: unz532vm mod a1 (RECFM F LRECL 1024
If your 3270 emulator does not have the SEND command, but is a GUI
application, it may allow you to upload from the menu bar. If so,
set your options to binary, VM/CMS, fixed record length, and a length
of 1024 before you upload.
When you get the PACKed file on your CMS minidisk, you convert it to
an executable module by using the COPY command with the UNPACK option:
COPY unz532vm mod a unzip module a1 (UNPACK OLDDATE REPLACE
You can omit the OLDDATE and REPLACE options if you want to.
Installing ZIP
--------------
The ZIP executable is supplied as the binary file ZIP.MOD, in the CMS
"PACK" format.
You must get the ZIP.MOD file on to your system as a binary file in
fixed recording mode, block size 1024. Assuming that the file is
stored as zip22vm.mod, you can get the file the same way you got the
UNZIP.MOD file:
Using FTP:
FTP where.ever.com
<enter user id and password and other stuff>
BINARY
LOCSITE FIX 1024
GET zip22vm.mod
QUIT
Using 3270 file transfer:
SEND unz532vm.mod A: unz532vm mod a1 (RECFM F LRECL 1024
When you get the PACKed file on your CMS minidisk, you convert it to
an executable module by using the COPY command with the UNPACK option:
COPY zip22vm mod a zip module a1 (UNPACK OLDDATE REPLACE
Installing Documentation
------------------------
Once you have UNZIP running, you can use it to extract documentation
from ZIP archives.
You can transfer the ZIP archives to VMV/CMS as a binary file with any
record length. A record length of 1 will work fine:
via FTP:
FTP where.ever.com
<enter user id and password and other stuff>
BINARY
LOCSITE FIX 1
GET zip22vm.zip zipdoc.zip
GET unz532vm.zip unzipdoc.zip
QUIT
via 3270 session:
SEND zip22vm.zip A: unzipdoc zip a1 (RECFM F LRECL 1
SEND unz532vm.zip A: zipdoc zip a1 (RECFM F LRECL 1
Once you have the ZIP archives, extract the documentation to the minidisk of
your choice by using the -d option:
unzip -a -d A2 unzipdoc.zip
unzip -a -d A2 zipdoc.zip
The "-a" option is required because the documents are archived as
ASCII text files, but they must be converted to EBCDIC to read them
in VM/CMS.
Notes
=====
Different EBCDIC Character Sets
-------------------------------
The documentation may look strange on your system, because UNZIP
translates from ASCII to "Open Systems" EBCDIC (IBM-1047). Unless
you are a software developer, you are probably using a different
kind of EBCDIC (like US EBCDIC, IBM-037). This causes some character
codes to display as different characters. For example, the character
codes that display as square brackets in IBM-1047 will display as
e-acute and a-grave in IBM-037.
You can use the IBM ICONV utility to translate documents from one
character set to another:
ICONV old doc a new doc a1 (FROMCODE IBM-1047 TOCODE IBM-037
IND$FILE protocol
-----------------
This is the method by which files are transferred via 3270 sessions
between PC and mainframe.
If you know how to transfer files via 3270 session between PC and
mainframe, you know as much as you need to know about IND$FILE.
If your mainframe has IND$FILE, and your 3270 emulator does file
transfers, you can use your emulator to transfer files between PC
and mainframe.

View File

@ -0,0 +1,434 @@
Using ZIP and UNZIP on VM/CMS
=============================
Installing executables
----------------------
The following CMS MODULEs are available:
ZIP
ZIPNOTE
ZIPCLOAK
ZIPSPLIT
UNZIP
In addition to these, each MODULE file also has an EXEC with the same
name. These EXECs are front-ends to the MODULES that will attempt to
set up the required runtime libraries before running the MODULE.
All the EXECs are identical. Only their names are different.
They are stored as plain text files.
The CMS MODULE files have been packed using the COPYFILE command to
allow their file format to be properly restored, since variable length
binary files will not currently unzip properly (see below for details).
The MODULEs are shipped with a filetype or extension of CMO (for CMS
MODULE). Their names may vary on the distribution disk to indicate
their level, etc.
To restore them to executable MODULEs on CMS, do the following:
1. Upload them to CMS with a Fixed record length with LRECL 1024.
Example, from a DOS or OS/2 window, type this:
SEND unzip.cmo A:unzip module a (RECFM F LRECL 1024
Example, using FTP from CMS, type this:
BINARY FIXED 1024
GET unzip.cmo unzip.module.a
Note: Replace "unzip.cmo" with the actual name.
2. Use COPYFILE to unpack the file.
Example, in CMS type this:
COPYFILE UNZIP MODULE A (UNPACK REPLACE OLDDATE
3. Repeat steps 1-2 for each of the programs.
4. Build the ZIPINFO module by typing this:
COPYFILE UNZIP MODULE A ZIPINFO MODULE A (OLDDATE
5. Upload the EXECs to CMS as text files (with ASCII-to-EBCDIC
translation).
Example, from a DOS or OS/2 window, type this:
SEND unzip.exc A:unzip exec a (CRLF
Example, using FTP from CMS, type this:
GET unzip.exc unzip.exec.a
6. Repeat steps 4 for each of the EXECs.
Preparing the environment
-------------------------
The executables provided were compiled with IBM C 3.1.0 and
require the the Language Environment (LE) runtime libraries.
To provide access to the runtime libraries:
1. Link to the disk containing the Language Environment files,
if necessary.
2. Use the command "GLOBAL LOADLIB SCEERUN"
These commands can be placed in your PROFILE EXEC.
Note: EXECs have been provided called ZIP, UNZIP, etc. that
issue the GLOBAL LOADLIB statement. This was done to alleviate
frustration of users that don't have the GLOBAL LOADLIB statement
in their PROFILE EXEC. These EXECs may require changing for
your system.
Unfortunately, there is no way, using IBM C, to produce a MODULE
that doesn't require a runtime library.
Testing
-------
To test the MODULEs, just type ZIP or UNZIP. They should
show help information on using the commands.
If you see something like this:
DMSLIO201W The following names are undefined:
CEEEV003
DMSABE155T User abend 4093 called from 00DCD298 reason code 000003EB
Then you don't have access to the proper runtime libraries, as
described above.
Here is additional information on the ZIP and UNZIP programs that
may assist support personnel:
- Compiled with IBM C V3R1M0 on VM/ESA 2.2.0 with
CMS level 13 Service Level 702.
- Require the SCEERUN LOADLIB runtime library. This is
part of the Language Environment (LE).
- Linked with options RMODE ANY AMODE ANY RLDSAVE.
If you continue to have trouble, report the problem to Zip-Bugs
(see the bottom of this document).
Compiling the source on VM/CMS
------------------------------
The source has been successfully compiled previously using
C/370 2.1 and 2.2. The source has been recently compiled using
IBM C 3.1.0 on VM/ESA 2.2.0 with CMS level 13. I don't have
access to an MVS system so the code hasn't been tested there
in a while.
1. Unzip the source files required for CMS. The root-level files
inside the ZIP file and the files in the CMSMVS subdirectory are
needed. Example (use both commands):
unzip -aj zip23.zip -x */* -dc
unzip -aj zip23.zip cmsmvs/* -dc
This example unzips the files to the C-disk, while translating
character data and ignoring paths.
If you don't already have a working UNZIP MODULE on CMS you will
have to unzip the files on another system and transport them
to CMS. All the required files are plain text so they can
be transferred with ASCII-to-EBCDIC translations.
2. Repeat step 1 with the zip file containing the UNZIP code.
Unzip the files to a different disk than the disk used for the ZIP
code.
3. To compile the ZIP code, run the supplied CCZIP EXEC.
To compile the UNZIP code, run the supplied CCUNZIP EXEC.
NOTE:
Some of the ZIP and UNZIP source files have the same name. It is
recommended that you keep the source from each on separate disks and
move the disk you are building from ahead of the other in the search
order.
For example, you may have a 192 disk with the ZIP source code and
a 193 disk with the UNZIP source code. To compile ZIP, access
the 192 disk as B, then run CCZIP. This will create the following
modules: ZIP, ZIPNOTE, ZIPSPLIT, ZIPCLOAK.
To compile UNZIP, access 193 as B, then run CCUNZIP. This will create
the following modules: UNZIP, ZIPINFO (a copy of UNZIP).
=========================================================================
Using ZIP/UNZIP
---------------
Documentation for the commands is in MANUAL NONAME (for ZIP) and in
UNZIP DOC UNZIP. INFOZIP DOC describes the use of the -Z option of
UNZIP.
The rest of this section explains special notes concerning the VM/CMS
version of ZIP and UNZIP.
Filenames and directories
-------------------------
1. Specifying filenames
a. When specifying CMS files, use filename.filetype.filemode format
(separate the three parts of the name with a period and use no
spaces). Example: profile.exec.a
Unfortunately, this prevents you from using ZIP from
FILELIST. To unzip a zip file, however, you can type something
like this next to it in FILELIST:
unzip /n -d c
This will unzip the contents of the current file to a C-disk.
b. It is possible to use DD names with ZIP and UNZIP on CMS, though
it can be cumbersome. Example:
filedef out disk myzip zip a
zip dd:out file1.txt file2.txt
While you can also use a DD name for the input files, ZIP
currently does not correctly resolve the filename and will
store something like "dd:in" inside the ZIP file. A file stored
in this manor cannot easily be unzipped, as "dd:in" is an invalid
filename.
c. In places where a directory name would be used on a PC, such as
for the ZIP -b (work path) option or the UNZIP -d (destination
path) options, use a filemode letter for CMS. For example,
to unzip files onto a C-disk, you might type something like this:
unzip myzip.zip -d c
Currently, ZIP uses the A-disk for work files. When zipping
large files, you may want to specify a larger disk for work files.
This example will use a C-disk for work files.
zip -b C myzip.zip.c test.dat.a
2. Filename conversions
a. Filemode letters are never stored into the zip file or take from
a zip file. Only the filename and filetype are used.
ZIP removes the filemode when storing the filename into the
zip file. UNZIP assumes "A" for the filemode unless the -d
option is used.
b. When unzipping, any path names are removed from the fileid
and the last two period-separated words are used as the
filename and filetype. These are truncated to a maximum of
eight characters, if necessary. If the filetype (extension)
is missing, then UNZIP uses "NONAME" for the filetype.
Any '(' or ')' characters are removed from the fileid.
c. All files are created in upper-case. Files in mixed-case
cannot currently be stored into a ZIP file.
d. Shared File System (SFS) directories are not supported.
Files are always accessed by fn.ft.fm. To use an SFS disk,
Assign it a filemode, then it can be used.
3. Wildcards in file names
a. Wildcards are not supported in the zip filename. The full
filename of the zip file must be given (but the .zip is not
necessary). So, you can't do this:
unzip -t *.zip
b. Wildcards CAN be used with UNZIP to select (or exclude) files
inside a zip file. Examples:
unzip myzip *.c - Unzip all .c files.
unzip myzip *.c -x z*.c - Unzip all .c files but those
starting with Z.
c. Wildcards cannot currently be used to select files with ZIP.
So, you can't do this:
zip -a myzip *.exec
I expect to fix this for CMS in the future.
4. File timestamps
a. The dates and times of files being zipped or unzipped are not
currently read or set. When a file is zipped, the timestamp
inside the zip file will always be the current system date and
time. Likewise, when unzipping, the date and time of files
being unzipped will always be the current system date/time.
b. Existing files are assumed to be newer than files inside a zip
file when using the -f freshen option of UNZIP. This will prevent
overwriting files that may be newer than the files inside the
zip file, but also effectively prevents the -f option from working.
5. ASCII, EBCDIC, and binary data
Background
----------
Most systems create data files as just a stream of bytes. Record
breaks happen when certain characters (new line and/or carriage
return characters) are encountered in the data. How to interpret
the data in a file is up to the user. The system must be told
to either notice new line characters in the data or to assume
that the data in the file is binary data and should be read or
written as-is.
CMS and MVS are record-based systems. All files are composed
of data records. These can be stored in fixed-length files or
in variable length files. With fixed-length files, each record
is the same length. The record breaks are implied by the
LRECL (logical record length) attribute associated with the file.
With variable-length files, each record contains the length of
that record. The separation of records are not part of the
data, but part of the file structure.
This means you can store any type of data in either type of file
structure without having to worry about the data being interpreted
as a record break. Fixed-length files may have padding at the
end of the file to make up a full record. Variable-length files
have no padding, but require extra record length data be stored
with the file data.
Storing fixed-length files into a zip file is simple, because all
the data can just be dumped into the zip file and the record
format (RECFM) and logical record length (LRECL) can be stored
in the extra data area of the zip file so they can be restored
when UNZIP is used.
Storing variable-length data is harder. There is no place to put
the record length data needed for each record of the file. This
data could be written to the zip file as the first two bytes of
each record and interpreted that way by UNZIP. That would make
the data unusable on systems other than CMS and MVS, though.
Currently, there isn't a solution to this problem. Each record is
written to the zip file and the record length information is
discarded. Binary data stored in variable-length files can't be put
into a zip file then later unzipped back into the proper records.
This is fine for binary data that will be read as a stream of bytes
but not OK where the records matter, such as with CMS MODULEs.
If the data is text (character data), there is a solution.
This data can be converted into ASCII when it's stored into
a zip file. The end of each record is now marked in the file
by new line characters. Another advantage of this method is
that the data is now accessible to non-EBCDIC systems. When
the data is unzipped on CMS or MVS, it is converted back into
EBCDIC and the records are recreated into a variable-length file.
So, here's what we have...
a. To store readable text data into a zip file that can be used
on other platforms, use the -a option with ZIP to convert the
data to ASCII. These files will unzip into variable-length
files on CMS and should not contain binary data or corruption
may occur.
b. Files that were zipped on an ASCII-based system will be
automatically translated to EBCDIC when unzipped. To prevent
this (to unzip binary data on CMS that was sent from an
ASCII-based system), use the -B option with UNZIP to force Binary
mode. To zip binary files on CMS, use the -B option with ZIP to
force Binary mode. This will prevent any data conversions from
taking place.
c. When using the ZIP program without specifying the "-a" or "-B"
option, ZIP defaults to "native" (EBCDIC) mode and tries to
preserve the file information (RECFM, LRECL, and BLKSIZE). So
when you unzip a file zipped with ZIP under CMS or MVS, UNZIP
restores the file info. The output will be fixed-length if the
original was fixed and variable-length if the original was
variable.
If UNZIP gives a "write error (disk full?)" message, you may be
trying to unzip a binary file that was zipped as a text file
(without using the -B option)
Summary
-------
Here's how to ZIP the different types of files.
RECFM F text
Use the -a option with ZIP to convert to ASCII for use with other
platforms or no options for use on EBCDIC systems only.
RECFM V text
Use the -a option with ZIP to convert to ASCII for use with other
platforms or no options for use on EBCDIC systems only.
RECFM F binary
Use the -B option with ZIP (upper-case "B").
RECFM V binary
Use the -B option with ZIP. Can be zipped OK but the record
structure is destroyed when unzipped. This is OK for data files
read as binary streams but not OK for files such as CMS MODULEs.
6. Character Sets
If you are used to running UNZIP on systems like UNIX, DOS, OS/2 or
Windows, you will may have some problems with differences in the
character set.
There are a number of different EBCDIC code pages, like there are a
number of different ASCII code pages. For example, there is a US
EBCDIC, a German EBCDIC, and a Swedish EBCDIC. As long as you are
working with other people who use the same EBCDIC code page, you
will have no trouble. If you work with people who use ASCII, or who
use a different EBCDIC code page, you may need to do some
translation.
UNZIP translates ASCII text files to and from Open Systems EBCDIC
(IBM-1047), which may not be the EBCDIC that you are using. For
example, US EBCDIC (IBM-037) uses different character codes for
square brackets. In such cases, you can use the ICONV utility
(supplied with IBM C) to translate between your EBCDIC character set
and IBM-1047.
If your installation does not use IBM-1047 EBCDIC, messages from
UNZIP may look a little odd. For example, in a US EBCDIC
installation, an opening square bracket will become an i-acute and a
closing square bracket will become a u-grave.
The supplied ZIP and UNZIP EXECs attempt to correct this by setting
CMS INPUT and OUTPUT translations to adjust the display of left and
right brackets. You may need to change this if brackets don't
display correctly on your system.
7. You can unzip using VM/CMS PIPELINES so unzip can be used as
a pipeline filter. Example:
'PIPE COMMAND UNZIP -p test.zip george.test | Count Lines | Cons'
Please report all bugs and problems to:
Zip-Bugs@lists.wku.edu
-----------------------------------------------------------------------
Original CMS/MVS port by George Petrov.
e-mail: c888090@nlevdpsb.snads.philips.nl
tel: +31-40-781155
Philips C&P
Eindhoven
The Netherlands
-----------------------------------------------------------------------
Additional fixes and README re-write (4/98) by Greg Hartwig.
e-mail: ghartwig@ix.netcom.com
ghartwig@vnet.ibm.com
-----------------------------------------------------------------------
Additional notes from Ian E. Gorman.
e-mail: ian@iosphere.net

View File

@ -0,0 +1,169 @@
Thank you for trying this port of UNZIP for VM/CMS and MVS!
Using under MVS:
-------------------------
1. To use the Info-ZIP's UNZIP under MVS you need:
- C/370 ver 2.1 compiler or another compatible compiler supporting
long names for function/variable names.
2. To compile the program under MVS do :
- unzip all the files from unz54vm.zip file. They are stored as
ASCII format so you have to unzip them first on PC or other
system that already have UNZIP, and then upload them to the
mainframe with ASCII to EBCDIC conversion.
- Copy all the .C files in the PDS called USERID.UNZIP.C
- Copy all the .H files in the PDS called USERID.UNZIP.H
- adjust the job UNZMVSC.JOB to work on your site. Change USERID
to your userid. You might need to change the CEE dataset names
to match your OS/390 system.
- Preallocate PDS datasets named: USERID.UNZIP.OBJ and
USERID.UNZIP.LOAD
- execute the job UNZMVSC to compile and link all the sources.
- if everything is ok you will get an UNZIP MODULE
3. Using UNZIP
- Just read the UNZIP.TXT
- A few exceptions concerning MVS
3.0. There are different ways to invoke UNZIP.
- allocating UNZIP.LOAD dataset to your ISPLLIB if you
want to invoke UNZIP under ISPF.
Then just type UNZIP ...parms... to get it work
- You can also call it directly with :
TSO CALL 'userid.UNZIP.LOAD(UNZIP)' '...parms...'
(notice to quotes!)
- You can even call it from a batch job like:
//MYZIP JOB (account)
//STEP1 EXEC PGM=UNZIP,PARM='-l mytestz.zip *.c'
//STEPLIB DD DSN=userid.UNZIP.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
This will list all the .c files from the zip file mytestz.zip
3.1. If the ZIP file has been zipped on an ASCII based system
it will be automatically translated to EBCDIC
( I hope I got all those translation tables OK :-).
You can force ASCII to EBCDIC conversion with the -a flag.
3.2. The date/time of the output files is set to the
current system date/time - not according the date/time in
the zip file.
3.3. You can even unzip using TSO/E PIPELINES
so unzip can be used as pipeline filter:
'pipe cms unzip -p test.zip george.test | count lines | cons'
( we do also a lot of pipethinking here ;-)
3.4. If you got also the ZIP program (see ZIP21VM.ZIP) you can
do zipping and unzipping without translating to ASCII
the ZIP also preserves the file informations (LRECL,BLKSIZE..)
So when you UNZIP a file zipped with ZIP under MVS it
restores the file info.
There currently some problems with file with RECFM=V*
I don't save the length of each record yet :-)
3.5. No wildcards are supported in the input zip name you have
to give the real name (.zip is not necessary)
So you CAN'T use things like: unzip -t *.zip
3.6. But you CAN use wildcards as filename selection like:
unzip -t myzip *.c - OK or even
unzip -t myzip *.c -x z*.c - to exclude all files matching
z*.c
3.7. You can unzip to a PDS using the -d parameter,
for example:
unzip -dmyzip myzip *.c
This will unzip all .c files that are in the zip file in a
PDS directory called MYZIP.C
BE AWARE that the extension of every files is being placed as
last identifier on the PDS name, so if you have a file in the
zipfile called 'testp.doc' and you use '-d mypds' the PDS
name will become 'mypds.doc(testp)'
Depending on which options IBM chose for C this week, unzip
may or may not prefix output files with your userid and/or
TSO prefix. To prevent this, quote the filename to -d, for
example
//UNZIP EXEC PGM=UNZIP,
// PARM='/-a -o ''userid.zip'' -d ''hlq.test'' *'
//STEPLIB DD DSN=USERID.UNZIP.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
The above JCL converts from ASCII to EBCDIC (-a), always
overwrites existing members (-o), extracts from 'userid.zip',
writes to files starting with 'hlq.test', all members (*).
Note the double quotes because PARM= requires single quotes.
3.8. The rules for output DCBs are a little messy. If the output
file already exists (remember the -d option) then unzip uses
the existing DCB and space values.
If the output file does not exist and the input zip came from
MVS then unzip makes its best attempt at preserving the
original DCB. However there is not enough information stored
in the zip file to do this correctly for all file types, some
file types may be corrupted.
If the output file does not exist and the input zip does not
contain MVS DCB information then unzip uses RECFM=U,
LRECL=32760 for binary data, RECFM=V, LRECL=133 for text.
Text includes ASCII to EBCDIC conversion. As soon as the
output file is created, unzip uses the same output DCB for
all following members, even if the input is a mixture of text
and binary.
In all cases, unzip has no built in parameters for space.
For a preallocated file this is not a problem. If unzip
creates an output file you get a default space allocation
which is site dependent.
It is far better to preallocate the output files with the
correct space and DCB values then use the -d option to point
to those files.
3.9. All '+','_' or '-' signs are skipped from the filenames
Please repport all bugs and problems to :
Zip-Bugs@lists.wku.edu
That's all for now.
Have fun!
George Petrov
e-mail: c888090@nlevdpsb.snads.philips.nl
tel: +31-40-781155
Philips C&P
Eindhoven
The Netherlands
Updated by:
Keith Owens <kaos@ocs.com.au>

View File

@ -0,0 +1,27 @@
Important Changes made for ZIP 2.3b and UNZIP 5.33c executables:
1. WARNING: These executables have been compiled for the
Language Environment (LE). You must now have access to the file
SCEERUN LOADLIB in order to run ZIP and UNZIP on CMS. You no longer
need access to EDCLINK LOADLIB. The provided ZIP and UNZIP EXECs
have been changed to issue a new GLOBAL LOADLIB command. You may
need to modify these EXECs for your installation. You may want to
change any GLOBAL LOADLIB command you may have in your PROFILE EXEC.
Versions could be made available for the older EDCLINK LOADLIB
runtimes upon request.
2. ZIP files will now be variable length files rather than fixed
length files.
3. Help information for ZIP and UNZIP has been changed to show
"fm" rather than "path" on CMS with certain options.
4. README CMS has been entirely rewritten. It now contains all
information for ZIP and UNZIP.
-----------------------------------------------------------------------
Greg Hartwig, April 1998.
e-mail: ghartwig@ix.netcom.com
ghartwig@vnet.ibm.com

View File

@ -0,0 +1,78 @@
/* CCUNZIP EXEC Compile unzip 5.4 for VM/CMS */
/* Author: George Petrov, 11 Apr 1995 (VMCOMPIL EXEC) */
/* Modified for IBM C V3R1 by Ian E. Gorman, 2 Nov 1998
Facilities for compiling and testing were provided by
OmniMark Technologies Corporation, Ottawa, Canada
*/
Address Command
Signal On Error
/* Allow longnames, compile re-entrant code.
global.c and vmmvs.c require EXTENDED features */
CCopts = 'LONGNAME RENT LANGLVL(EXTENDED) NOEXECOPS'
/* UNZIP options -- VM_CMS, REENTRANT */
CCopts = CCopts 'DEFINE(VM_CMS,REENTRANT)'
/* Link the load module to run in more or less than 16MB memory */
LINKopts = 'AMODE ANY RMODE ANY RLDSAVE'
'GLOBAL TXTLIB SCEELKED CMSLIB'
'GLOBAL LOADLIB SCEERUN'
/* produce the TEXT (object) files */
linklist=''
modname='UNZIP'
Say 'Building' modname 'MODULE...'
Call Compile 'UNZIP'
Call Compile 'CRC32'
Call Compile 'CRCTAB'
Call Compile 'CRYPT'
Call Compile 'ENVARGS'
Call Compile 'EXPLODE'
Call Compile 'EXTRACT'
Call Compile 'FILEIO'
Call Compile 'GLOBALS'
Call Compile 'INFLATE'
Call Compile 'PROCESS'
Call Compile 'LIST'
Call Compile 'MATCH'
Call Compile 'TTYIO'
Call Compile 'UNREDUCE'
Call Compile 'UNSHRINK'
Call Compile 'ZIPINFO'
Call Compile 'VMMVS'
Say 'Linking...'
'EXEC CMOD' linklist '(MODNAME' modname LINKopts
Say modname 'built successfully.'
/* Make ZIPINFO from UNZIP */
modname = 'ZIPINFO'
'COPYFILE UNZIP MODULE A ZIPINFO MODULE A (OLDDATE REPLACE'
Say modname 'built successfully.'
Say 'Done.'
Exit rc
error:
Say 'Error' rc 'during compilation!'
Say 'Error in line' sigl':'
Say ' 'Sourceline(sigl)
Exit rc
Compile: Procedure Expose CCopts LINKopts linklist
Parse arg filename filetype filemode .
If filetype='' Then filetype='C'
linklist = linklist filename
Say 'Compiling' filename filetype filemode '...'
'EXEC CC' filename filetype filemode '('CCopts
Return rc

View File

@ -0,0 +1,85 @@
/* MAKECPIP EXEC Make program to build a C/370 module */
/* Author: George Petrov, 29 Sep 1994 */
arg fn . '(' cparms /* Filter name */
'pipe (end ?) < 'fn' makefile', /* get all source files from */
'| frlab GLOBALS:'||,
'| drop',
'| strip',
'| var globals'
cparms = cparms globals
say ''
say 'Compile options : 'cparms
say ''
if pos('REB',cparms) > 0 then do
parse var cparms cp1 'REB' . ' ' cp2 /* REBuild options specified ? */
cparms = cp1||cp2
pipe1=,
'pipe (end ?) < 'fn' makefile', /* get all source files from */
'| nfind *'||, /* the makefile and compile */
'| frlab TEXT:'||, /* only the those who are */
'| r: tolab MODULE:'||, /* changed or never compiled */
'| drop',
'| o: fanout',
'| chop before str /(/',
'| statew',
'| c: fanout', /* compiled */
'| specs /Compiling / 1 w1-3 n / .../ n',
'| cons'
end
else do
pipe1=,
'pipe (end ?) < 'fn' makefile', /* get all source files from */
'| nfind *'||, /* the makefile and compile */
'| frlab TEXT:'||, /* only the those who are */
'| r: tolab MODULE:'||, /* changed or never compiled */
'| drop',
'| o: fanout',
'| specs w1 1 /C/ nw w3 nw write w1 1 /TEXT A/ nw',
'| chop before str /(/',
'| statew',
'| change (57 66) / /0/',
'| sort 1.8 d', /* sort the date and time */
'| uniq 1-17 singles', /* if the first is a source */
'| sort 1.8 d 64.2 d 57.2 d 60.2 d 66.8 d', /* sort the date */
'| uniq 1-8 first', /* if the first is a source */
'| locate 9.8 /C /', /* program then it has to be */
'| c: fanout', /* compiled */
'| specs /Compiling / 1 w1-3 n / .../ n',
'| cons'
end
pipe2= '?',
'r:',
'| drop',
'| specs w1 1', /* save the module name in var */
'| var module',
'?',
'o:',
'| specs w1 1',
'| join * / /',
'| var texts', /* save all the text file names */
'?', /* for later include */
'c:',
'| specs /CC / 1 w1-3 n /(NOTERM 'cparms'/ nw', /* compile! */
'| err: cms | cons',
'?',
'err:',
'| nfind 0'||,
'| var err',
'| specs /----> Errors found! RC=/ 1 1-* n',
'| cons'
/* '| g: gate'*/
pipe1 pipe2
say ''
if symbol('err') = 'VAR' & err ^= 0 then do
say 'Errors found in source files - link aborted! RC = 'err
exit err
end
say 'Generating module 'module
'pipe cms cmod' fn texts' | > 'fn' LINK A'
exit rc
error:
say 'Error in REXX detected!'
Say 'Syntax error on line' Sigl':' Sourceline(Sigl)
Say 'Error was:' Errortext(RC)
return rc

View File

@ -0,0 +1,154 @@
# Makefile for the MVS (OS/390 Base) version of UNZIP 5.4
# Produced for C/C++ V3R2 in OS/390 1.2.0 by Ian E. Gorman, 2 Nov 1998
# Facilities for compiling and testing were made available by
# OmniMark Technologies Corporation, Ottawa, Canada
# NOTES
#
# The only tabs in this file are in the first character of each recipe
# line, where they are required by make.
#
# Run this makefile in OpenMVS (OS/390 POSIX) using source files in the
# HFS file system. You can write the load module to either HFS file
# system or to a PDS in the native MVS file system. The PDS must have
# sufficient free space to hold the load module.
#
# To compile to a member of a PDS:
# make
# or
# make unzip.mvs
#
# To compile a test version into the HFS file system:
# make hfs
# UNZIP options -- MVS, REENTRANT
ZIPOPTS=-DMVS
# directories
# generic source code
SRC=..
SRC_P=$(SRC)/
# source code for MVS
CMSMVS=../cmsmvs
CMSMVS_P=$(CMSMVS)/
# include files
INCLS=-I$(SRC) -I$(CMSMVS)
# object files and load modules
BLD_P=../mvs/
# Other options
# Suffixes (E and O must be different)
E=
O=.o
# Need EXTENDED features for global.c and vmvms.c, so not using c89
CC=cc
CFLAGS=-D_OPEN_SYS $(ZIPOPTS) $(INCLS)
LD=cc
LDFLAGS=
# Files
# object (TEXT) files
OBJECTS= $(BLD_P)unzip$(O) $(BLD_P)crc32$(O) $(BLD_P)crctab$(O) \
$(BLD_P)crypt$(O) $(BLD_P)envargs$(O) $(BLD_P)explode$(O) \
$(BLD_P)extract$(O) $(BLD_P)fileio$(O) $(BLD_P)globals$(O) \
$(BLD_P)inflate$(O) $(BLD_P)process$(O) $(BLD_P)list$(O) \
$(BLD_P)match$(O) $(BLD_P)ttyio$(O) $(BLD_P)unreduce$(O) \
$(BLD_P)unshrink$(O) $(BLD_P)zipinfo$(O) $(BLD_P)vmmvs$(O)
# Header files
HFILES= $(SRC_P)consts.h $(SRC_P)crypt.h $(SRC_P)ebcdic.h \
$(SRC_P)globals.h $(SRC_P)inflate.h $(SRC_P)tables.h \
$(SRC_P)ttyio.h $(SRC_P)unzip.h $(SRC_P)unzpriv.h \
$(SRC_P)unzvers.h $(SRC_P)zip.h $(CMSMVS_P)vmmvs.h \
$(CMSMVS_P)vmstat.h
# Rules
all: $(BLD_P)unzip.mvs$(E)
hfs: $(BLD_P)unzip$(E)
# link
$(BLD_P)unzip.mvs$(E): $(OBJECTS)
$(LD) -o "//INFOZIP.LOAD(UNZIP)" $(LDFLAGS) $^
echo "tso call \"infozip(unzip)\" \"'\"\"""$$""@""\"\"'\"" > $%
chmod a+x $%
$(BLD_P)unzip$(E): $(OBJECTS)
$(LD) -o $% $(LDFLAGS) $^
# compile
$(BLD_P)api$(O): $(SRC_P)api.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)api.c
$(BLD_P)apihelp$(O): $(SRC_P)apihelp.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)apihelp.c
$(BLD_P)crc32$(O): $(SRC_P)crc32.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)crc32.c
$(BLD_P)crctab$(O): $(SRC_P)crctab.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)crctab.c
$(BLD_P)crypt$(O): $(SRC_P)crypt.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)crypt.c
$(BLD_P)envargs$(O): $(SRC_P)envargs.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)envargs.c
$(BLD_P)explode$(O): $(SRC_P)explode.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)explode.c
$(BLD_P)extract$(O): $(SRC_P)extract.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)extract.c
$(BLD_P)fileio$(O): $(SRC_P)fileio.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)fileio.c
$(BLD_P)funzip$(O): $(SRC_P)funzip.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)funzip.c
$(BLD_P)globals$(O): $(SRC_P)globals.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)globals.c
$(BLD_P)inflate$(O): $(SRC_P)inflate.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)inflate.c
$(BLD_P)list$(O): $(SRC_P)list.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)list.c
$(BLD_P)match$(O): $(SRC_P)match.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)match.c
$(BLD_P)process$(O): $(SRC_P)process.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)process.c
$(BLD_P)ttyio$(O): $(SRC_P)ttyio.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)ttyio.c
$(BLD_P)unreduce$(O): $(SRC_P)unreduce.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)unreduce.c
$(BLD_P)unshrink$(O): $(SRC_P)unshrink.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)unshrink.c
$(BLD_P)unzip$(O): $(SRC_P)unzip.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)unzip.c
$(BLD_P)unzipstb$(O): $(SRC_P)unzipstb.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)unzipstb.c
$(BLD_P)zipinfo$(O): $(SRC_P)zipinfo.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(SRC_P)zipinfo.c
$(BLD_P)vmmvs$(O): $(CMSMVS_P)vmmvs.c $(HFILES)
$(CC) -c -o $% $(CFLAGS) $(CMSMVS_P)vmmvs.c

View File

@ -0,0 +1,66 @@
/***********************************************************************/
/* */
/* Front-end EXEC to set up linkage to the C runtime libraries */
/* before executing a MODULE generated from C code. */
/* */
/* Copy this file as an EXEC with a filename matching the C MODULE. */
/* */
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
/* */
/***********************************************************************/
Address Command
Parse Arg argstring
Parse Source . . myname .
/* Set output and input character translation so brackets show up */
'SET OUTPUT AD' 'BA'x
'SET OUTPUT BD' 'BB'x
'SET INPUT BA AD'
'SET INPUT BB BD'
Call CLIB
If rc<>0 Then Do
Say 'The required C runtime libraries don''t appear to be available.'
Say myname 'can not run.'
Exit 12
End
/* Run the command */
myname argstring
Exit rc
/* Contents of the CLIB EXEC, modified for RC checking. */
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
CLIB:
/***************************************************/
/* SET UP LIBRARIES FOR LE for MVS & VM */
/***************************************************/
Address COMMAND
loadlib ='EDCLINK' /* C/370 runtime */
loadlib ='SCEERUN' /* LE runtime */
theirs=queued() /* old stack contentsM068*/
'QUERY LOADLIB ( LIFO' /* old setting M068*/
LoadlibList='' /* init list M068*/
rc=0
Do while queued()^=theirs /* all lines from cmdM068*/
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
End /*M068*/
If loadlibList='NONE' ,
Then Do
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
End
Else Do
Do xx=1 to Words(loadlib)
If Find(loadliblist,word(loadlib,xx)) = 0 ,
then loadliblist = loadliblist word(loadlib,xx)
End
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
End
Return

View File

@ -0,0 +1,26 @@
* This is a comment
* this makefile compiles filter UNZIP
GLOBALS:
long def(VM_CMS)
TEXT:
unzip c
crc32 c
crctab c
crypt c
envargs c
explode c
extract c
fileio c
globals c
inflate c
list c
match c
process c
ttyio c
unreduce c
unshrink c
zipinfo c
vmmvs c
MODULE:
unzip module

View File

@ -0,0 +1,137 @@
//*
//* LE COMPILE FOR UNZIP541.
//* ALL STEPS SHOULD GET COND CODE 0 EXCEPT FOR PLINK.PLKED WHICH GETS 4.
//*
//CBC JCLLIB ORDER=CBC.SCBCPRC
//UNZIP EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(UNZIP)',
// OUTFILE='USERID.UNZIP.OBJ(UNZIP),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//CRC32 EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(CRC32)',
// OUTFILE='USERID.UNZIP.OBJ(CRC32),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//CRCTAB EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(CRCTAB)',
// OUTFILE='USERID.UNZIP.OBJ(CRCTAB),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//CRYPT EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(CRYPT)',
// OUTFILE='USERID.UNZIP.OBJ(CRYPT),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//ENVARGS EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(ENVARGS)',
// OUTFILE='USERID.UNZIP.OBJ(ENVARGS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//EXPLODE EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(EXPLODE)',
// OUTFILE='USERID.UNZIP.OBJ(EXPLODE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//EXTRACT EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(EXTRACT)',
// OUTFILE='USERID.UNZIP.OBJ(EXTRACT),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//FILEIO EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(FILEIO)',
// OUTFILE='USERID.UNZIP.OBJ(FILEIO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//GLOBALS EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(GLOBALS)',
// OUTFILE='USERID.UNZIP.OBJ(GLOBALS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//INFLATE EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(INFLATE)',
// OUTFILE='USERID.UNZIP.OBJ(INFLATE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//LIST EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(LIST)',
// OUTFILE='USERID.UNZIP.OBJ(LIST),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//MATCH EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(MATCH)',
// OUTFILE='USERID.UNZIP.OBJ(MATCH),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//PROCESS EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(PROCESS)',
// OUTFILE='USERID.UNZIP.OBJ(PROCESS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//TTYIO EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(TTYIO)',
// OUTFILE='USERID.UNZIP.OBJ(TTYIO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//UNREDUCE EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(UNREDUCE)',
// OUTFILE='USERID.UNZIP.OBJ(UNREDUCE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//UNSHRINK EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(UNSHRINK)',
// OUTFILE='USERID.UNZIP.OBJ(UNSHRINK),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//ZIPINFO EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(ZIPINFO)',
// OUTFILE='USERID.UNZIP.OBJ(ZIPINFO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//VMMVS EXEC EDCC,COND=(0,NE),CREGSIZ='0M',
// INFILE='USERID.UNZIP.C(VMMVS)',
// OUTFILE='USERID.UNZIP.OBJ(VMMVS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
//COMPILE.USERLIB DD DSN=USERID.UNZIP.H,DISP=SHR
//PLINK EXEC PROC=EDCPL,COND=(4,LT),
// OUTFILE='USERID.UNZIP.LOAD(UNZIP),DISP=SHR',
// PPARM='NONCAL,MAP,MEMORY',
// LPARM='LIST,MAP,XREF'
//SYSPRINT DD SYSOUT=*
//PLKED.SYSIN DD DSN=USERID.UNZIP.OBJ(UNZIP),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(CRC32),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(CRCTAB),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(CRYPT),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(ENVARGS),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(EXPLODE),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(EXTRACT),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(FILEIO),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(GLOBALS),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(INFLATE),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(LIST),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(MATCH),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(PROCESS),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(TTYIO),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(UNREDUCE),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(UNSHRINK),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(ZIPINFO),DISP=SHR
// DD DSN=USERID.UNZIP.OBJ(VMMVS),DISP=SHR
//LKED.SYSLIB DD DISP=SHR,DSN=CEE.SCEELKED

View File

@ -0,0 +1,58 @@
/* VMCOMPIL EXEC Unzip compile for VM/CMS */
/* Author : George Petrov, 11 Apr 1995 */
signal on error
parms = '(long def(VM_CMS)'
/* Add local options */
/* "TARGET(COMPAT)" is required for V2.2 compiler */
parms = parms 'TARGET(COMPAT) SOURCE'
say 'Compiling UNZIP C...'
'cc unzip c 'parms
say 'Compiling CRC32 C...'
'cc crc32 c 'parms
say 'Compiling CRCTAB C...'
'cc crctab c 'parms
say 'Compiling CRYPT C...'
'cc crypt c 'parms
say 'Compiling ENVARGS C...'
'cc envargs c 'parms
say 'Compiling EXPLODE C...'
'cc explode c 'parms
say 'Compiling EXTRACT C...'
'cc extract c 'parms
say 'Compiling FILEIO C...'
'cc fileio c 'parms
say 'Compiling GLOBALS C...'
'cc globals c 'parms
say 'Compiling INFLATE C...'
'cc inflate c 'parms
say 'Compiling PROCESS C...'
'cc process c 'parms
say 'Compiling LIST C...'
'cc list c 'parms
say 'Compiling MATCH C...'
'cc match c 'parms
say 'Compiling TTYIO C...'
'cc ttyio c 'parms
say 'Compiling UNREDUCE C...'
'cc unreduce c 'parms
say 'Compiling UNSHRINK C...'
'cc unshrink c 'parms
say 'Compiling ZIPINFO C...'
'cc zipinfo c 'parms
say 'Compiling VMMVS C...'
'cc vmmvs c 'parms
say 'Linking all files...'
'cmod unzip unzip crc32 crctab crypt envargs explode extract fileio globals',
'inflate list match process ttyio unreduce unshrink zipinfo vmmvs'
say 'All Done!'
say "To run enter : UNZIP parms"
exit rc
error:
say 'Error during compilation!'
exit rc

View File

@ -0,0 +1,683 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
vmmvs.c (for both VM/CMS and MVS)
Contains: vmmvs_open_infile()
open_outfile()
close_outfile()
close_infile()
getVMMVSexfield()
do_wild()
mapattr()
mapname()
checkdir()
check_for_newer()
stat()
version()
---------------------------------------------------------------------------*/
#define __VMMVS_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h"
/********************************/
/* Function vmmvs_open_infile() */
/********************************/
FILE *vmmvs_open_infile(__G)
__GDEF
{
FILE *fzip;
G.tempfn = NULL;
fzip = fopen(G.zipfn, FOPR);
#if 0
/* Let's try it without the convert for a while -- RG Hartwig */
if ((fzip = fopen(G.zipfn,"rb,recfm=fb")) == NULL) {
size_t cnt;
char *buf;
FILE *in, *out;
if ((buf = (char *)malloc(32768)) == NULL) return NULL;
if ((G.tempfn = tmpnam(NULL)) == NULL) return NULL;
if ((in = fopen(G.zipfn,"rb")) != NULL &&
(out = fopen(G.tempfn,"wb,recfm=fb,lrecl=1")) != NULL) {
Trace((stdout,"Converting ZIP file to fixed record format...\n"));
while (!feof(in)) {
cnt = fread(buf,1,32768,in);
if (cnt) fwrite(buf,1,cnt,out);
}
}
else {
free(buf);
fclose(out);
fclose(in);
return NULL;
}
free(buf);
fclose(out);
fclose(in);
fzip = fopen(G.tempfn,"rb,recfm=fb");
if (fzip == NULL) return NULL;
/* Update the G.ziplen value since it might have changed after
the reformatting copy. */
fseek(fzip,0L,SEEK_SET);
fseek(fzip,0L,SEEK_END);
G.ziplen = ftell(fzip);
}
#endif
return fzip;
}
/***************************/
/* Function open_outfile() */
/***************************/
int open_outfile(__G) /* return 1 if fail */
__GDEF
{
char type[100];
char *mode = NULL;
#ifdef MVS
/* Check if the output file already exists and do not overwrite its DCB */
char basefilename[PATH_MAX], *p;
FILE *exists;
/* Get the base file name, without any member name */
strcpy(basefilename, G.filename);
if ((p = strchr(basefilename, '(')) != NULL) {
if (basefilename[0] == '\'')
*p++ = '\'';
*p = '\0';
}
exists = fopen(basefilename, FOPR);
if (exists) {
if (G.pInfo->textmode)
mode = FOPWTE; /* Text file, existing */
else
mode = FOPWE; /* Binary file, existing */
fclose(exists);
}
else /* continued on next line */
#endif /* MVS */
if (G.pInfo->textmode) {
if (mode == NULL)
mode = FOPWT;
} else if (G.lrec.extra_field_length > 0 && G.extra_field != NULL) {
unsigned lef_len = (unsigned)(G.lrec.extra_field_length);
uch *lef_buf = G.extra_field;
while (lef_len > EB_HEADSIZE) {
unsigned eb_id = makeword(&lef_buf[EB_ID]);
unsigned eb_dlen = makeword(&lef_buf[EB_LEN]);
if (eb_dlen > (lef_len - EB_HEADSIZE)) {
/* Discovered some extra field inconsistency! */
TTrace((stderr,
"open_outfile: block length %u > rest lef_size %u\n",
eb_dlen, lef_len - EB_HEADSIZE));
break;
}
if ((eb_id == EF_VMCMS || eb_id == EF_MVS) &&
(getVMMVSexfield(type, lef_buf, eb_dlen) > 0)) {
mode = type;
break;
}
/* Skip this extra field block */
lef_buf += (eb_dlen + EB_HEADSIZE);
lef_len -= (eb_dlen + EB_HEADSIZE);
}
}
if (mode == NULL) mode = FOPW;
Trace((stderr, "Output file='%s' opening with '%s'\n", G.filename, mode));
if ((G.outfile = fopen(G.filename, mode)) == NULL) {
Info(slide, 0x401, ((char *)slide, "\nerror: cannot create %s\n",
FnFilter1(G.filename)));
Trace((stderr, "error %d: '%s'\n", errno, strerror(errno)));
return 1;
}
return 0;
} /* end function open_outfile() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
{
fclose(G.outfile);
} /* end function close_outfile() */
/***************************/
/* Function close_infile() */
/***************************/
void close_infile(__G)
__GDEF
{
fclose(G.zipfd);
/* If we're working from a temp file, erase it now */
if (G.tempfn)
remove(G.tempfn);
} /* end function close_infile() */
/******************************/
/* Function getVMMVSexfield() */
/******************************/
extent getVMMVSexfield(type, ef_block, datalen)
char *type;
uch *ef_block;
unsigned datalen;
{
fldata_t *fdata = (fldata_t *) &ef_block[4];
if (datalen < sizeof(fldata_t))
return 0;
strcpy(type, "w");
strcat(type, fdata->__openmode == __TEXT ? ""
:fdata->__openmode == __BINARY ? "b"
:fdata->__openmode == __RECORD ? "b,type=record"
: "");
strcat(type, ",recfm=");
strcat(type, fdata->__recfmF? "F"
:fdata->__recfmV? "V"
:fdata->__recfmU? "U"
: "?");
if (fdata->__recfmBlk) strcat(type, "B");
if (fdata->__recfmS) strcat(type, "S");
if (fdata->__recfmASA) strcat(type, "A");
if (fdata->__recfmM) strcat(type, "M");
sprintf(type+strlen(type), ",lrecl=%ld", fdata->__recfmV
? fdata->__maxreclen+4
: fdata->__maxreclen);
#ifdef VM_CMS
/* For CMS, use blocksize for FB files only */
if (fdata->__recfmBlk)
sprintf(type+strlen(type), ",blksize=%ld", fdata->__blksize);
#else
/* For MVS, always use blocksize */
sprintf(type+strlen(type), ",blksize=%ld", fdata->__blksize);
#endif
return strlen(type);
} /* end function getVMMVSexfield() */
#ifndef SFX
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
/**********************/
char *do_wild(__G__ wld)
__GDEF
ZCONST char *wld; /* only used first time on a given dir */
{
static int First = 0;
static char filename[256];
if (First == 0) {
First = 1;
strncpy(filename, wld, sizeof(filename));
filename[sizeof(filename)-1] = '\0';
return filename;
}
else
return (char *)NULL;
} /* end function do_wild() */
#endif /* !SFX */
/************************/
/* Function mapattr() */
/************************/
int mapattr(__G)
__GDEF
{
return 0;
}
/************************/
/* Function mapname() */
/************************/
int mapname(__G__ renamed)
__GDEF
int renamed;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - caution (truncated filename)
* MPN_INF_SKIP - info "skip entry" (dir doesn't exist)
* MPN_ERR_SKIP - error -> skip entry
* MPN_ERR_TOOLONG - error -> path is too long
* MPN_NOMEM - error (memory allocation failed) -> skip entry
* [also MPN_VOL_LABEL, MPN_CREATED_DIR]
*/
{
char newname[FILNAMSIZ], *lbar;
#ifdef MVS
char *pmember;
#endif
int name_changed = MPN_OK;
if (G.pInfo->vollabel)
return MPN_VOL_LABEL; /* can't set disk volume labels in CMS_MVS */
#ifdef MVS
/* Remove bad characters for MVS from the filename */
while ((lbar = strpbrk(G.filename, "_+-")) != NULL) {
/* Must use memmove() here because data overlaps. */
/* strcpy() gives undefined behavior in this case. */
memmove(lbar, lbar+1, strlen(lbar));
name_changed = MPN_INF_TRUNC;
}
#endif
/* Remove bad characters for MVS/CMS from the filename */
while ((lbar = strpbrk(G.filename, "()")) != NULL) {
memmove(lbar, lbar+1, strlen(lbar));
name_changed = MPN_INF_TRUNC;
}
#ifdef VM_CMS
if ((lbar = strrchr(G.filename, '/')) != NULL) {
strcpy(newname, lbar+1);
Trace((stderr, "File '%s' renamed to '%s'\n", G.filename, newname));
strcpy(G.filename, newname);
name_changed = MPN_INF_TRUNC;
}
#else /* MVS */
if ((pmember = strrchr(G.filename, '/')) == NULL)
pmember = G.filename;
else
pmember++;
/* search for extension in file name */
if ((lbar = strrchr(pmember, '.')) != NULL) {
*lbar++ = '\0';
strcpy(newname, pmember);
strcpy(pmember, lbar);
strcat(pmember, "(");
strcat(pmember, newname);
strcat(pmember, ")");
}
/* Remove all 'internal' dots '.', to prevent false consideration as
* MVS path delimiters! */
while ((lbar = strrchr(G.filename, '.')) != NULL) {
memmove(lbar, lbar+1, strlen(lbar));
name_changed = MPN_INF_TRUNC;
}
/* Finally, convert path delimiters from internal '/' to external '.' */
while ((lbar = strchr(G.filename, '/')) != NULL)
*lbar = '.';
#endif /* ?VM_CMS */
#ifndef MVS
if ((lbar = strchr(G.filename, '.')) == NULL) {
printf("WARNING: file '%s' has no extension - renamed to '%s.NONAME'\n"\
,G.filename, G.filename);
strcat(G.filename, ".NONAME");
name_changed = MPN_INF_TRUNC;
}
#endif
checkdir(__G__ G.filename, GETPATH);
return name_changed;
} /* end function mapname() */
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - (on APPEND_NAME) truncated filename
* MPN_INF_SKIP - path doesn't exist, not allowed to create
* MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path
* exists and is not a directory, but is supposed to be
* MPN_ERR_TOOLONG - path is too long
* MPN_NOMEM - can't allocate memory for filename buffers
*/
{
static int rootlen = 0; /* length of rootpath */
static char *rootpath; /* user's "extract-to" directory */
# define FN_MASK 7
# define FUNCTION (flag & FN_MASK)
/*---------------------------------------------------------------------------
ROOT: if appropriate, store the path in rootpath and create it if neces-
sary; else assume it's a zipfile member and return. This path segment
gets used in extracting all members from every zipfile specified on the
command line. Note that under OS/2 and MS-DOS, if a candidate extract-to
directory specification includes a drive letter (leading "x:"), it is
treated just as if it had a trailing '/'--that is, one directory level
will be created if the path doesn't exist, unless this is otherwise pro-
hibited (e.g., freshening).
---------------------------------------------------------------------------*/
#if (!defined(SFX) || defined(SFX_EXDIR))
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n",
FnFilter1(pathcomp)));
if (pathcomp == (char *)NULL) {
rootlen = 0;
}
else if ((rootlen = strlen(pathcomp)) > 0) {
if ((rootpath = (char *)malloc(rootlen+1)) == NULL) {
rootlen = 0;
return MPN_NOMEM;
}
strcpy(rootpath, pathcomp);
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return MPN_OK;
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
if (rootlen > 0) {
#ifdef VM_CMS /* put the exdir after the filename */
strcat(pathcomp, "."); /* used as minidisk to be save on */
strcat(pathcomp, rootpath);
#else /* MVS */
char newfilename[PATH_MAX];
char *start_fname;
int quoted = 0;
strcpy(newfilename, rootpath);
if (newfilename[0] == '\'') {
quoted = strlen(newfilename) - 1;
if (newfilename[quoted] == '\'')
newfilename[quoted] = '\0';
else
quoted = 0;
}
if (strchr(pathcomp, '(') == NULL) {
if ((start_fname = strrchr(pathcomp, '.')) == NULL) {
start_fname = pathcomp;
}
else {
*start_fname++ = '\0';
strcat(newfilename, ".");
strcat(newfilename, pathcomp);
}
strcat(newfilename, "(");
strcat(newfilename, start_fname);
strcat(newfilename, ")");
}
else {
strcat(newfilename, ".");
strcat(newfilename, pathcomp);
}
if (quoted)
strcat(newfilename, "'");
Trace((stdout, "new dataset : %s\n", newfilename));
strcpy(pathcomp, newfilename);
#endif /* ?VM_CMS */
}
return MPN_OK;
}
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
/******************************/
/* Function check_for_newer() */ /* used for overwriting/freshening/updating */
/******************************/
int check_for_newer(__G__ filename) /* return 1 if existing file is newer */
__GDEF /* or equal; 0 if older; -1 if doesn't */
char *filename; /* exist yet */
{
FILE *stream;
if ((stream = fopen(filename, FOPR)) != NULL) {
fclose(stream);
/* File exists, assume it is "newer" than archive entry. */
return EXISTS_AND_NEWER;
}
/* File does not exist. */
return DOES_NOT_EXIST;
} /* end function check_for_newer() */
/*********************/
/* Function stat() */
/*********************/
int stat(const char *path, struct stat *buf)
{
FILE *fp;
char fname[PATH_MAX];
time_t ltime;
if ((fp = fopen(path, FOPR)) != NULL) {
fldata_t fdata;
if (fldata( fp, fname, &fdata ) == 0) {
buf->st_dev = fdata.__device;
buf->st_mode = *(short *)(&fdata);
}
/* Determine file size by seeking to EOF */
fseek(fp,0L,SEEK_END);
buf->st_size = ftell(fp);
fclose(fp);
/* set time fields in stat buf to current time. */
time(&ltime);
buf->st_atime =
buf->st_mtime =
buf->st_ctime = ltime;
/* File exists, return success */
return 0;
}
return 1;
}
#ifdef STAND_ALONE
/***************************/
/* Function main_vmmvs() */
/***************************/
/* This function is called as main() to parse arguments */
/* into argc and argv. This is required for stand-alone */
/* execution. This calls the "real" main() when done. */
int MAIN_VMMVS(void)
{
int argc=0;
char *argv[50];
int iArgLen;
char argstr[256];
char **pEPLIST, *pCmdStart, *pArgStart, *pArgEnd;
/* Get address of extended parameter list from S/370 Register 0 */
pEPLIST = (char **)__xregs(0);
/* Null-terminate the argument string */
pCmdStart = *(pEPLIST+0);
pArgStart = *(pEPLIST+1);
pArgEnd = *(pEPLIST+2);
iArgLen = pArgEnd - pCmdStart + 1;
/* Make a copy of the command string */
memcpy(argstr, pCmdStart, iArgLen);
argstr[iArgLen] = '\0'; /* Null-terminate */
/* Store first token (cmd) */
argv[argc++] = strtok(argstr, " ");
/* Store the rest (args) */
while (argv[argc-1])
argv[argc++] = strtok(NULL, " ");
argc--; /* Back off last NULL entry */
/* Call "real" main() function */
return MAIN(argc, argv);
}
#endif /* STAND_ALONE */
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
int len;
char liblvlmsg [50+1];
char *compiler = "?";
char *platform = "?";
char complevel[64];
/* Map the runtime library level information */
union {
unsigned int iVRM;
struct {
unsigned int pd:4; /* Product designation */
unsigned int vv:4; /* Version */
unsigned int rr:8; /* Release */
unsigned int mm:16; /* Modification level */
} xVRM;
} VRM;
/* Break down the runtime library level */
VRM.iVRM = __librel();
sprintf(liblvlmsg, "Using runtime library level %s V%dR%dM%d",
(VRM.xVRM.pd==1 ? "LE" : "CE"),
VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm);
/* Note: LE = Language Environment, CE = Common Env. (C/370). */
/* This refers ONLY to the current runtimes, not the compiler. */
#ifdef VM_CMS
platform = "VM/CMS";
#ifdef __IBMC__
compiler = "IBM C";
#else
compiler = "C/370";
#endif
#endif
#ifdef MVS
platform = "MVS";
#ifdef __IBMC__
compiler = "IBM C/C++";
#else
compiler = "C/370";
#endif
#endif
#ifdef __COMPILER_VER__
VRM.iVRM = __COMPILER_VER__;
sprintf(complevel," V%dR%dM%d",
VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm);
#else
#ifdef __IBMC__
sprintf(complevel," V%dR%d", __IBMC__ / 100, (__IBMC__ % 100)/10);
#else
complevel[0] = '\0';
#endif
#endif
/* Output is in the form "Compiled with %s%s for %s%s%s%s." */
len = sprintf((char *)slide, LoadFarString(CompiledWith),
/* Add compiler name and level */
compiler, complevel,
/* Add compile environment */
platform,
/* Add timestamp */
#ifdef __DATE__
" on " __DATE__
#ifdef __TIME__
" at " __TIME__
#endif
#endif
".\n", "",
liblvlmsg
);
(*G.message)((zvoid *)&G, slide, (ulg)len, 0);
} /* end function version() */
#endif /* !SFX */

View File

@ -0,0 +1,97 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* vmmvs.h: include file for both VM/CMS and MVS ports of UnZip */
#ifndef __vmmvs_h /* prevent multiple inclusions */
#define __vmmvs_h
#ifndef NULL
# define NULL (zvoid *)0
#endif
#ifdef MVS
# define _POSIX_SOURCE /* tell MVS we want full definitions */
# define NO_STRNICMP /* MVS has no strnicmp() */
# include <features.h>
/* MVS complains if a function has the same name as a csect. */
# if defined(__UNZIP_C)
# pragma csect(STATIC,"unzip_s")
# elif defined(__CRC32_C)
# pragma csect(STATIC,"crc32_s")
# elif defined(__ENVARGS_C)
# pragma csect(STATIC,"envarg_s")
# elif defined(__EXPLODE_C)
# pragma csect(STATIC,"explod_s")
# elif defined(__INFLATE_C)
# pragma csect(STATIC,"inflat_s")
# elif defined(__MATCH_C)
# pragma csect(STATIC,"match_s")
# elif defined(__UNREDUCE_C)
# pragma csect(STATIC,"unredu_s")
# elif defined(__UNSHRINK_C)
# pragma csect(STATIC,"unshri_s")
# elif defined(__ZIPINFO_C)
# pragma csect(STATIC,"zipinf_s")
# endif
#endif /* MVS */
#include <time.h> /* the usual non-BSD time functions */
#ifdef VM_CMS
# include "vmstat.h"
#endif
#ifdef MVS
# include <sys/stat.h>
#endif
#define PASSWD_FROM_STDIN
/* Kludge until we know how to open a non-echo tty channel */
#define EBCDIC
#define __EBCDIC 2 /* treat EBCDIC as binary! */
/* In the context of Info-ZIP, a portable "text" mode file implies the use of
an ASCII-compatible (ISO 8859-1, or other extended ASCII) code page. */
#ifdef MORE
# undef MORE
#endif
/* Workarounds for missing RTL functionality */
#define isatty(t) 1
#ifdef UNZIP /* definitions for UNZIP */
#define INBUFSIZ 8192
#define USE_STRM_INPUT
#define USE_FWRITE
#define PATH_MAX 128
#ifndef QUERY_TRNEWLN
# define QUERY_TRNEWLN /* terminate interaction queries with '\n' */
#endif
#ifndef DATE_FORMAT
# define DATE_FORMAT DF_MDY
#endif
#define lenEOL 1
/* The use of "ebcdic[LF]" is not reliable; VM/CMS C/370 uses the
* EBCDIC specific "NL" ('NewLine') control character (and not the EBCDIC
* equivalent of the ASCII "LF" ('LineFeed')) as line terminator!
* To work around this problem, we explicitely emit the C compiler's native
* '\n' line terminator.
*/
#if 0
#define PutNativeEOL *q++ = native(LF);
#else
#define PutNativeEOL *q++ = '\n';
#endif
#endif /* UNZIP */
#endif /* !__vmmvs_h */

View File

@ -0,0 +1,57 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#ifndef __vmstat_h
#define __vmstat_h
/* stat.h definitions */
#ifndef _INO_T_DEFINED
typedef unsigned short ino_t; /* i-node number (not used on DOS) */
#define _INO_T_DEFINED
#endif
#ifndef _DEV_T_DEFINED
typedef short dev_t; /* device code */
#define _DEV_T_DEFINED
#endif
#ifndef _OFF_T_DEFINED
typedef long off_t; /* file offset value */
#define _OFF_T_DEFINED
#endif
#ifndef _STAT_DEFINED
struct stat {
dev_t st_dev;
ino_t st_ino;
short st_mode;
short st_nlink;
int st_uid;
int st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define _STAT_DEFINED
#endif
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
#define S_IFMT 0xFFFF
#define _FLDATA(m) (*(fldata_t *) &m)
#define S_ISDIR(m) (_FLDATA(m).__dsorgPDSdir)
#define S_ISREG(m) (_FLDATA(m).__dsorgPO | \
_FLDATA(m).__dsorgPDSmem | \
_FLDATA(m).__dsorgPS)
#define S_ISBLK(m) (_FLDATA(m).__recfmBlk)
#define S_ISMEM(m) (_FLDATA(m).__dsorgMem)
#endif /* __vmstat_h */

View File

@ -0,0 +1,66 @@
/***********************************************************************/
/* */
/* Front-end EXEC to set up linkage to the C runtime libraries */
/* before executing a MODULE generated from C code. */
/* */
/* Copy this file as an EXEC with a filename matching the C MODULE. */
/* */
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
/* */
/***********************************************************************/
Address Command
Parse Arg argstring
Parse Source . . myname .
/* Set output and input character translation so brackets show up */
'SET OUTPUT AD' 'BA'x
'SET OUTPUT BD' 'BB'x
'SET INPUT BA AD'
'SET INPUT BB BD'
Call CLIB
If rc<>0 Then Do
Say 'The required C runtime libraries don''t appear to be available.'
Say myname 'can not run.'
Exit 12
End
/* Run the command */
myname argstring
Exit rc
/* Contents of the CLIB EXEC, modified for RC checking. */
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
CLIB:
/***************************************************/
/* SET UP LIBRARIES FOR LE for MVS & VM */
/***************************************************/
Address COMMAND
loadlib ='EDCLINK' /* C/370 runtime */
loadlib ='SCEERUN' /* LE runtime */
theirs=queued() /* old stack contentsM068*/
'QUERY LOADLIB ( LIFO' /* old setting M068*/
LoadlibList='' /* init list M068*/
rc=0
Do while queued()^=theirs /* all lines from cmdM068*/
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
End /*M068*/
If loadlibList='NONE' ,
Then Do
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
End
Else Do
Do xx=1 to Words(loadlib)
If Find(loadliblist,word(loadlib,xx)) = 0 ,
then loadliblist = loadliblist word(loadlib,xx)
End
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
End
Return

54
unzip/unzip-5.52/consts.h Normal file
View File

@ -0,0 +1,54 @@
/*
Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
consts.h
This file contains global, initialized variables that never change. It is
included by unzip.c and windll/windll.c.
---------------------------------------------------------------------------*/
/* And'ing with mask_bits[n] masks the lower n bits */
ZCONST unsigned near mask_bits[17] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
ZCONST char Far VersionDate[] = UZ_VERSION_DATE; /* now defined in unzvers.h */
#ifndef SFX
ZCONST char Far EndSigMsg[] =
"\nnote: didn't find end-of-central-dir signature at end of central dir.\n";
#endif
ZCONST char Far CentSigMsg[] =
"error: expected central file header signature not found (file #%lu).\n";
ZCONST char Far SeekMsg[] =
"error [%s]: attempt to seek before beginning of zipfile\n%s";
ZCONST char Far FilenameNotMatched[] = "caution: filename not matched: %s\n";
ZCONST char Far ExclFilenameNotMatched[] =
"caution: excluded filename not matched: %s\n";
#ifdef VMS
ZCONST char Far ReportMsg[] = "\
(please check that you have transferred or created the zipfile in the\n\
appropriate BINARY mode--this includes ftp, Kermit, AND unzip'd zipfiles)\n";
#else
ZCONST char Far ReportMsg[] = "\
(please check that you have transferred or created the zipfile in the\n\
appropriate BINARY mode and that you have compiled UnZip properly)\n";
#endif
#ifndef SFX
ZCONST char Far Zipnfo[] = "zipinfo";
ZCONST char Far CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
#endif

64
unzip/unzip-5.52/crc32.c Normal file
View File

@ -0,0 +1,64 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: crc32.c,v 1.5 1996/01/13 14:55:12 spc Exp $ */
#define __CRC32_C /* identifies this source module */
#include "zip.h"
#ifndef USE_ZLIB
#ifndef ASM_CRC
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef CRC32
# undef CRC32
#endif
#define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
#define DO1(buf) crc = CRC32(crc, *buf++)
#define DO2(buf) DO1(buf); DO1(buf)
#define DO4(buf) DO2(buf); DO2(buf)
#define DO8(buf) DO4(buf); DO4(buf)
/* ========================================================================= */
ulg crc32(crc, buf, len)
register ulg crc; /* crc shift register */
register ZCONST uch *buf; /* pointer to bytes to pump through */
extent len; /* number of bytes in buf[] */
/* Run a set of bytes through the crc shift register. If buf is a NULL
pointer, then initialize the crc shift register contents instead.
Return the current crc in either case. */
{
register ZCONST ulg near *crc_table;
if (buf == NULL) return 0L;
crc_table = get_crc_table();
crc = crc ^ 0xffffffffL;
#ifndef NO_UNROLLED_LOOPS
while (len >= 8) {
DO8(buf);
len -= 8;
}
#endif
if (len) do {
DO1(buf);
} while (--len);
return crc ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
}
#endif /* !ASM_CRC */
#endif /* !USE_ZLIB */

240
unzip/unzip-5.52/crc_i386.S Normal file
View File

@ -0,0 +1,240 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
* crc_i386.S, optimized CRC calculation function for Zip and UnZip,
* created by Paul Kienitz and Christian Spieler. Last revised 16 Jan 2005.
*
* GRR 961110: incorporated Scott Field optimizations from win32/crc_i386.asm
* => overall 6% speedup in "unzip -tq" on 9MB zipfile (486-66)
*
* SPC 970402: revised for Rodney Brown's optimizations (32-bit-wide
* aligned reads for most of the data from buffer), can be
* disabled by defining the macro NO_32_BIT_LOADS
*
* SPC 971012: added Rodney Brown's additional tweaks for 32-bit-optimized
* CPUs (like the Pentium Pro, Pentium II, and probably some
* Pentium clones). This optimization is controlled by the
* preprocessor switch "__686" and is disabled by default.
* (This default is based on the assumption that most users
* do not yet work on a Pentium Pro or Pentium II machine ...)
*
* COS 050116: Enabled the 686 build by default, because there are hardly any
* pre-686 CPUs in serious use nowadays. (See SPC 970402 above.)
*
* FLAT memory model assumed. Calling interface:
* - args are pushed onto the stack from right to left,
* - return value is given in the EAX register,
* - all other registers (with exception of EFLAGS) are preserved. (With
* GNU C 2.7.x, %edx and %ecx are `scratch' registers, but preserving
* them nevertheless adds only 4 single byte instructions.)
*
* This source generates the function
* ulg crc32(ulg crc, ZCONST uch *buf, extent len).
*
* Loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS.
* This results in shorter code at the expense of reduced performance.
*/
/* This file is NOT used in conjunction with zlib. */
#ifndef USE_ZLIB
/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix
* external symbols with an underline character '_'.
*/
#if defined(NO_UNDERLINE) || defined(__ELF__)
# define _crc32 crc32
# define _get_crc_table get_crc_table
#endif
/* Use 16-byte alignment if your assembler supports it. Warning: gas
* uses a log(x) parameter (.align 4 means 16-byte alignment). On SVR4
* the parameter is a number of bytes.
*/
#ifndef ALIGNMENT
# define ALIGNMENT .align 4,0x90
#endif
#if defined(i386) || defined(_i386) || defined(_I386) || defined(__i386)
/* This version is for 386 Unix, OS/2, MSDOS in 32 bit mode (gcc & gas).
* Warning: it uses the AT&T syntax: mov source,dest
* This file is only optional. If you want to use the C version,
* remove -DASM_CRC from CFLAGS in Makefile and set OBJA to an empty string.
*/
.file "crc_i386.S"
#if !defined(PRE_686) && !defined(__686)
/* Optimize for Pentium Pro and compatible CPUs by default. */
# define __686
#endif
#if defined(NO_STD_STACKFRAME) && defined(USE_STD_STACKFRAME)
# undef USE_STACKFRAME
#else
/* The default is to use standard stack frame entry, because it
* results in smaller code!
*/
# ifndef USE_STD_STACKFRAME
# define USE_STD_STACKFRAME
# endif
#endif
#ifdef USE_STD_STACKFRAME
# define _STD_ENTRY pushl %ebp ; movl %esp,%ebp
# define arg1 8(%ebp)
# define arg2 12(%ebp)
# define arg3 16(%ebp)
# define _STD_LEAVE popl %ebp
#else /* !USE_STD_STACKFRAME */
# define _STD_ENTRY
# define arg1 24(%esp)
# define arg2 28(%esp)
# define arg3 32(%esp)
# define _STD_LEAVE
#endif /* ?USE_STD_STACKFRAME */
/*
* These two (three) macros make up the loop body of the CRC32 cruncher.
* registers modified:
* eax : crc value "c"
* esi : pointer to next data byte (or lword) "buf++"
* registers read:
* edi : pointer to base of crc_table array
* scratch registers:
* ebx : index into crc_table array
* (requires upper three bytes = 0 when __686 is undefined)
*/
#ifndef __686 /* optimize for 386, 486, Pentium */
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
movb %al, %bl ;/* tmp = c & 0xFF */\
shrl $8, %eax ;/* c = (c >> 8) */\
xorl (%edi, %ebx, 4), %eax ;/* c ^= table[tmp] */
#else /* __686 : optimize for Pentium Pro and compatible CPUs */
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
movzbl %al, %ebx ;/* tmp = c & 0xFF */\
shrl $8, %eax ;/* c = (c >> 8) */\
xorl (%edi, %ebx, 4), %eax ;/* c ^=table[tmp] */
#endif /* ?__686 */
#define Do_CRC_byte /* c = (c >> 8) ^ table[(c^*buf++)&0xFF] */\
xorb (%esi), %al ;/* c ^= *buf */\
incl %esi ;/* buf++ */\
Do_CRC
#ifndef NO_32_BIT_LOADS
#define Do_CRC_lword \
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */\
addl $4, %esi ;/* ((ulg *)buf)++ */\
Do_CRC \
Do_CRC \
Do_CRC \
Do_CRC
#endif /* !NO_32_BIT_LOADS */
.text
.globl _crc32
_crc32: /* ulg crc32(ulg crc, uch *buf, extent len) */
_STD_ENTRY
pushl %edi
pushl %esi
pushl %ebx
pushl %edx
pushl %ecx
movl arg2, %esi /* 2nd arg: uch *buf */
subl %eax, %eax /* > if (!buf) */
testl %esi, %esi /* > return 0; */
jz .L_fine /* > else { */
call _get_crc_table
movl %eax, %edi
movl arg1, %eax /* 1st arg: ulg crc */
#ifndef __686
subl %ebx, %ebx /* ebx=0; bl usable as dword */
#endif
movl arg3, %ecx /* 3rd arg: extent len */
notl %eax /* > c = ~crc; */
testl %ecx, %ecx
#ifndef NO_UNROLLED_LOOPS
jz .L_bail
# ifndef NO_32_BIT_LOADS
/* Assert now have positive length */
.L_align_loop:
testl $3, %esi /* Align buf on lword boundary */
jz .L_aligned_now
Do_CRC_byte
decl %ecx
jnz .L_align_loop
.L_aligned_now:
# endif /* !NO_32_BIT_LOADS */
movl %ecx, %edx /* save len in edx */
shrl $3, %ecx /* ecx = len / 8 */
jz .L_No_Eights
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
.L_Next_Eight:
# ifndef NO_32_BIT_LOADS
/* Do_CRC_lword */
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */
addl $4, %esi ;/* ((ulg *)buf)++ */
Do_CRC
Do_CRC
Do_CRC
Do_CRC
/* Do_CRC_lword */
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */
addl $4, %esi ;/* ((ulg *)buf)++ */
Do_CRC
Do_CRC
Do_CRC
Do_CRC
# else /* NO_32_BIT_LOADS */
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
# endif /* ?NO_32_BIT_LOADS */
decl %ecx
jnz .L_Next_Eight
.L_No_Eights:
movl %edx, %ecx
andl $7, %ecx /* ecx = len % 8 */
#endif /* !NO_UNROLLED_LOOPS */
jz .L_bail /* > if (len) */
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
.L_loupe: /* > do { */
Do_CRC_byte /* c = CRC32(c, *buf++); */
decl %ecx /* > } while (--len); */
jnz .L_loupe
.L_bail: /* > } */
notl %eax /* > return ~c; */
.L_fine:
popl %ecx
popl %edx
popl %ebx
popl %esi
popl %edi
_STD_LEAVE
ret
#else
error: this asm version is for 386 only
#endif /* i386 || _i386 || _I386 || __i386 */
#endif /* !USE_ZLIB */

227
unzip/unzip-5.52/crctab.c Normal file
View File

@ -0,0 +1,227 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* crctab.c -- supply the CRC table needed for CRC-32 calculations.
* Copyright (C) 1995 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: crctab.c,v 1.4 1996/01/08 14:55:12 jloup Exp $ */
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The table is simply the CRC of all possible eight bit values. This is all
the information needed to generate CRC's on data a byte at a time for all
combinations of CRC register values and incoming bytes.
*/
#define __CRCTAB_C /* identifies this source module */
#include "zip.h"
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef DYNAMIC_CRC_TABLE
/* =========================================================================
* Make the crc table. This function is needed only if you want to compute
* the table dynamically.
*/
local void make_crc_table OF((void));
#if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT))
error: Dynamic allocation of CRC table not safe with reentrant code.
#endif /* DYNALLOC_CRCTAB && REENTRANT */
#ifdef DYNALLOC_CRCTAB
local ulg near *crc_table = NULL;
# if 0 /* not used, since sizeof("near *") <= sizeof(int) */
/* Use this section when access to a "local int" is faster than access to
a "local pointer" (e.g.: i86 16bit code with far pointers). */
local int crc_table_empty = 1;
# define CRC_TABLE_IS_EMPTY (crc_table_empty != 0)
# define MARK_CRCTAB_FILLED crc_table_empty = 0
# define MARK_CRCTAB_EMPTY crc_table_empty = 1
# else
/* Use this section on systems where the size of pointers and ints is
equal (e.g.: all 32bit systems). */
# define CRC_TABLE_IS_EMPTY (crc_table == NULL)
# define MARK_CRCTAB_FILLED crc_table = crctab_p
# define MARK_CRCTAB_EMPTY crc_table = NULL
# endif
#else /* !DYNALLOC_CRCTAB */
local ulg near crc_table[256];
local int crc_table_empty = 1;
# define CRC_TABLE_IS_EMPTY (crc_table_empty != 0)
# define MARK_CRCTAB_FILLED crc_table_empty = 0
#endif /* ?DYNALLOC_CRCTAB */
local void make_crc_table()
{
ulg c; /* crc shift register */
int n; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
#ifdef DYNALLOC_CRCTAB
ulg near *crctab_p; /* temporary pointer to allocated crc_table area */
#else /* !DYNALLOC_CRCTAB */
# define crctab_p crc_table
#endif /* DYNALLOC_CRCTAB */
#ifdef COMPUTE_XOR_PATTERN
/* This piece of code has been left here to explain how the XOR pattern
* used in the creation of the crc_table values can be recomputed.
* For production versions of this function, it is more efficient to
* supply the resultant pattern at compile time.
*/
ulg xor; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static uch p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320L) */
xor = 0L;
for (i = 0; i < sizeof(p)/sizeof(uch); i++)
xor |= 1L << (31 - p[i]);
#else
# define xor 0xedb88320L
#endif
#ifdef DYNALLOC_CRCTAB
crctab_p = (ulg near *) nearmalloc (256*sizeof(ulg));
if (crctab_p == NULL) {
ziperr(ZE_MEM, "crc_table allocation");
}
#endif /* DYNALLOC_CRCTAB */
for (n = 0; n < 256; n++) {
c = (ulg)n;
for (k = 8; k; k--)
c = c & 1 ? xor ^ (c >> 1) : c >> 1;
crctab_p[n] = c;
}
MARK_CRCTAB_FILLED;
}
#else /* !DYNAMIC_CRC_TABLE */
#ifdef DYNALLOC_CRCTAB
error: Inconsistent flags, DYNALLOC_CRCTAB without DYNAMIC_CRC_TABLE.
#endif
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
local ZCONST ulg near crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
#endif /* ?DYNAMIC_CRC_TABLE */
/* use "OF((void))" here to work around a Borland TC++ 1.0 problem */
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table OF((void))
#else
ZCONST ulg near *get_crc_table OF((void))
#endif
{
#ifdef DYNAMIC_CRC_TABLE
if (CRC_TABLE_IS_EMPTY)
make_crc_table();
#endif
#ifdef USE_ZLIB
return (ZCONST uLongf *)crc_table;
#else
return (ZCONST ulg near *)crc_table;
#endif
}
#ifdef DYNALLOC_CRCTAB
void free_crc_table()
{
if (!CRC_TABLE_IS_EMPTY)
{
nearfree((ulg near *)crc_table);
MARK_CRCTAB_EMPTY;
}
}
#endif
#endif /* !USE_ZLIB || USE_OWN_CRCTAB */

583
unzip/unzip-5.52/crypt.c Normal file
View File

@ -0,0 +1,583 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
This encryption/decryption source code for Info-Zip software was
originally written in Europe. The whole source package can be
freely distributed, including from the USA. (Prior to January 2000,
re-export from the US was a violation of US law.)
NOTE on copyright history:
Previous versions of this source package (up to version 2.8) were
not copyrighted and put in the public domain. If you cannot comply
with the Info-Zip LICENSE, you may want to look for one of those
public domain versions.
*/
/*
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
*/
#define ZCRYPT_INTERNAL
#include "zip.h"
#include "crypt.h"
#include "ttyio.h"
#if CRYPT
#ifndef FALSE
# define FALSE 0
#endif
#ifdef ZIP
/* For the encoding task used in Zip (and ZipCloak), we want to initialize
the crypt algorithm with some reasonably unpredictable bytes, see
the crypthead() function. The standard rand() library function is
used to supply these `random' bytes, which in turn is initialized by
a srand() call. The srand() function takes an "unsigned" (at least 16bit)
seed value as argument to determine the starting point of the rand()
pseudo-random number generator.
This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with
Seed1 supplied by the current time (= "(unsigned)time()") and Seed2
as some (hopefully) nondeterministic bitmask. On many (most) systems,
we use some "process specific" number, as the PID or something similar,
but when nothing unpredictable is available, a fixed number may be
sufficient.
NOTE:
1.) This implementation requires the availability of the following
standard UNIX C runtime library functions: time(), rand(), srand().
On systems where some of them are missing, the environment that
incorporates the crypt routines must supply suitable replacement
functions.
2.) It is a very bad idea to use a second call to time() to set the
"Seed2" number! In this case, both "Seed1" and "Seed2" would be
(almost) identical, resulting in a (mostly) "zero" constant seed
number passed to srand().
The implementation environment defined in the "zip.h" header should
supply a reasonable definition for ZCR_SEED2 (an unsigned number; for
most implementations of rand() and srand(), only the lower 16 bits are
significant!). An example that works on many systems would be
"#define ZCR_SEED2 (unsigned)getpid()".
The default definition for ZCR_SEED2 supplied below should be regarded
as a fallback to allow successful compilation in "beta state"
environments.
*/
# include <time.h> /* time() function supplies first part of crypt seed */
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */
# endif
# ifdef GLOBAL /* used in Amiga system headers, maybe others too */
# undef GLOBAL
# endif
# define GLOBAL(g) g
#else /* !ZIP */
# define GLOBAL(g) G.g
#endif /* ?ZIP */
#ifdef UNZIP
/* char *key = (char *)NULL; moved to globals.h */
# ifndef FUNZIP
local int testp OF((__GPRO__ ZCONST uch *h));
local int testkey OF((__GPRO__ ZCONST uch *h, ZCONST char *key));
# endif
#endif /* UNZIP */
#ifndef UNZIP /* moved to globals.h for UnZip */
local ulg keys[3]; /* keys defining the pseudo-random sequence */
#endif /* !UNZIP */
#ifndef Trace
# ifdef CRYPT_DEBUG
# define Trace(x) fprintf x
# else
# define Trace(x)
# endif
#endif
#ifndef CRC_32_TAB
# define CRC_32_TAB crc_32_tab
#endif
#define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
int decrypt_byte(__G)
__GDEF
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
int update_keys(__G__ c)
__GDEF
int c; /* byte of plain text */
{
GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c);
GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff;
GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1;
{
register int keyshift = (int)(GLOBAL(keys[1]) >> 24);
GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift);
}
return c;
}
/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
void init_keys(__G__ passwd)
__GDEF
ZCONST char *passwd; /* password string with which to modify keys */
{
GLOBAL(keys[0]) = 305419896L;
GLOBAL(keys[1]) = 591751049L;
GLOBAL(keys[2]) = 878082192L;
while (*passwd != '\0') {
update_keys(__G__ (int)*passwd);
passwd++;
}
}
#ifdef ZIP
/***********************************************************************
* Write encryption header to file zfile using the password passwd
* and the cyclic redundancy check crc.
*/
void crypthead(passwd, crc, zfile)
ZCONST char *passwd; /* password string */
ulg crc; /* crc of file being encrypted */
FILE *zfile; /* where to write header */
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
int ztemp; /* temporary for zencoded value */
uch header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1) {
srand((unsigned)time(NULL) ^ ZCR_SEED2);
}
init_keys(passwd);
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
c = (rand() >> 7) & 0xff;
header[n] = (uch)zencode(c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd);
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
ztemp = zencode(header[n], t);
putc(ztemp, zfile);
}
ztemp = zencode((int)(crc >> 16) & 0xff, t);
putc(ztemp, zfile);
ztemp = zencode((int)(crc >> 24) & 0xff, t);
putc(ztemp, zfile);
}
#ifdef UTIL
/***********************************************************************
* Encrypt the zip entry described by z from file source to file dest
* using the password passwd. Return an error code in the ZE_ class.
*/
int zipcloak(z, source, dest, passwd)
struct zlist far *z; /* zip entry to encrypt */
FILE *source, *dest; /* source and destination files */
ZCONST char *passwd; /* password string */
{
int c; /* input byte */
int res; /* result code */
ulg n; /* holds offset and counts size */
ush flag; /* previous flags */
int t; /* temporary */
int ztemp; /* temporary storage for zencode value */
/* Set encrypted bit, clear extended local header bit and write local
header to output file */
if ((n = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP;
z->off = n;
flag = z->flg;
z->flg |= 1, z->flg &= ~8;
z->lflg |= 1, z->lflg &= ~8;
z->siz += RAND_HEAD_LEN;
if ((res = putlocal(z, dest)) != ZE_OK) return res;
/* Initialize keys with password and write random header */
crypthead(passwd, z->crc, dest);
/* Skip local header in input file */
if (fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
SEEK_CUR)) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
/* Encrypt data */
for (n = z->siz - RAND_HEAD_LEN; n; n--) {
if ((c = getc(source)) == EOF) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
ztemp = zencode(c, t);
putc(ztemp, dest);
}
/* Skip extended local header in input file if there is one */
if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
if (fflush(dest) == EOF) return ZE_TEMP;
return ZE_OK;
}
/***********************************************************************
* Decrypt the zip entry described by z from file source to file dest
* using the password passwd. Return an error code in the ZE_ class.
*/
int zipbare(z, source, dest, passwd)
struct zlist far *z; /* zip entry to encrypt */
FILE *source, *dest; /* source and destination files */
ZCONST char *passwd; /* password string */
{
int c0, c1; /* last two input bytes */
ulg offset; /* used for file offsets */
ulg size; /* size of input data */
int r; /* size of encryption header */
int res; /* return code */
ush flag; /* previous flags */
/* Save position and skip local header in input file */
if ((offset = (ulg)ftell(source)) == (ulg)-1L ||
fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
SEEK_CUR)) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
/* Initialize keys with password */
init_keys(passwd);
/* Decrypt encryption header, save last two bytes */
c1 = 0;
for (r = RAND_HEAD_LEN; r; r--) {
c0 = c1;
if ((c1 = getc(source)) == EOF) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
Trace((stdout, " (%02x)", c1));
zdecode(c1);
Trace((stdout, " %02x", c1));
}
Trace((stdout, "\n"));
/* If last two bytes of header don't match crc (or file time in the
* case of an extended local header), back up and just copy. For
* pkzip 2.0, the check has been reduced to one byte only.
*/
#ifdef ZIP10
if ((ush)(c0 | (c1<<8)) !=
(z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) {
#else
c0++; /* avoid warning on unused variable */
if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) {
#endif
if (fseek(source, offset, SEEK_SET)) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
if ((res = zipcopy(z, source, dest)) != ZE_OK) return res;
return ZE_MISS;
}
/* Clear encrypted bit and local header bit, and write local header to
output file */
if ((offset = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP;
z->off = offset;
flag = z->flg;
z->flg &= ~9;
z->lflg &= ~9;
z->siz -= RAND_HEAD_LEN;
if ((res = putlocal(z, dest)) != ZE_OK) return res;
/* Decrypt data */
for (size = z->siz; size; size--) {
if ((c1 = getc(source)) == EOF) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
zdecode(c1);
putc(c1, dest);
}
/* Skip extended local header in input file if there is one */
if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
return ferror(source) ? ZE_READ : ZE_EOF;
}
if (fflush(dest) == EOF) return ZE_TEMP;
return ZE_OK;
}
#else /* !UTIL */
/***********************************************************************
* If requested, encrypt the data in buf, and in any case call fwrite()
* with the arguments to zfwrite(). Return what fwrite() returns.
*/
unsigned zfwrite(buf, item_size, nb, f)
zvoid *buf; /* data buffer */
extent item_size; /* size of each item in bytes */
extent nb; /* number of items */
FILE *f; /* file to write to */
{
int t; /* temporary */
if (key != (char *)NULL) { /* key is the global password pointer */
ulg size; /* buffer size */
char *p = (char*)buf; /* steps through buffer */
/* Encrypt data in buffer */
for (size = item_size*(ulg)nb; size != 0; p++, size--) {
*p = (char)zencode(*p, t);
}
}
/* Write the buffer out */
return fwrite(buf, item_size, nb, f);
}
#endif /* ?UTIL */
#endif /* ZIP */
#if (defined(UNZIP) && !defined(FUNZIP))
/***********************************************************************
* Get the password and set up keys for current zipfile member.
* Return PK_ class error.
*/
int decrypt(__G__ passwrd)
__GDEF
ZCONST char *passwrd;
{
ush b;
int n, r;
uch h[RAND_HEAD_LEN];
Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt)));
/* get header once (turn off "encrypted" flag temporarily so we don't
* try to decrypt the same data twice) */
GLOBAL(pInfo->encrypted) = FALSE;
defer_leftover_input(__G);
for (n = 0; n < RAND_HEAD_LEN; n++) {
b = NEXTBYTE;
h[n] = (uch)b;
Trace((stdout, " (%02x)", h[n]));
}
undefer_input(__G);
GLOBAL(pInfo->encrypted) = TRUE;
if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */
GLOBAL(newzip) = FALSE;
if (passwrd != (char *)NULL) { /* user gave password on command line */
if (!GLOBAL(key)) {
if ((GLOBAL(key) = (char *)malloc(strlen(passwrd)+1)) ==
(char *)NULL)
return PK_MEM2;
strcpy(GLOBAL(key), passwrd);
GLOBAL(nopwd) = TRUE; /* inhibit password prompting! */
}
} else if (GLOBAL(key)) { /* get rid of previous zipfile's key */
free(GLOBAL(key));
GLOBAL(key) = (char *)NULL;
}
}
/* if have key already, test it; else allocate memory for it */
if (GLOBAL(key)) {
if (!testp(__G__ h))
return PK_COOL; /* existing password OK (else prompt for new) */
else if (GLOBAL(nopwd))
return PK_WARN; /* user indicated no more prompting */
} else if ((GLOBAL(key) = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL)
return PK_MEM2;
/* try a few keys */
n = 0;
do {
r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), IZ_PWLEN+1,
GLOBAL(zipfn), GLOBAL(filename));
if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */
free (GLOBAL(key));
GLOBAL(key) = NULL;
return PK_MEM2;
}
if (r != IZ_PW_ENTERED) { /* user replied "skip" or "skip all" */
*GLOBAL(key) = '\0'; /* We try the NIL password, ... */
n = 0; /* and cancel fetch for this item. */
}
if (!testp(__G__ h))
return PK_COOL;
if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */
GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */
} while (n > 0);
return PK_WARN;
} /* end function decrypt() */
/***********************************************************************
* Test the password. Return -1 if bad, 0 if OK.
*/
local int testp(__G__ h)
__GDEF
ZCONST uch *h;
{
int r;
char *key_translated;
/* On systems with "obscure" native character coding (e.g., EBCDIC),
* the first test translates the password to the "main standard"
* character coding. */
#ifdef STR_TO_CP1
/* allocate buffer for translated password */
if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
return -1;
/* first try, test password translated "standard" charset */
r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key)));
#else /* !STR_TO_CP1 */
/* first try, test password as supplied on the extractor's host */
r = testkey(__G__ h, GLOBAL(key));
#endif /* ?STR_TO_CP1 */
#ifdef STR_TO_CP2
if (r != 0) {
#ifndef STR_TO_CP1
/* now prepare for second (and maybe third) test with translated pwd */
if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
return -1;
#endif
/* second try, password translated to alternate ("standard") charset */
r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key)));
#ifdef STR_TO_CP3
if (r != 0)
/* third try, password translated to another "standard" charset */
r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key)));
#endif
#ifndef STR_TO_CP1
free(key_translated);
#endif
}
#endif /* STR_TO_CP2 */
#ifdef STR_TO_CP1
free(key_translated);
if (r != 0) {
/* last resort, test password as supplied on the extractor's host */
r = testkey(__G__ h, GLOBAL(key));
}
#endif /* STR_TO_CP1 */
return r;
} /* end function testp() */
local int testkey(__G__ h, key)
__GDEF
ZCONST uch *h; /* decrypted header */
ZCONST char *key; /* decryption password to test */
{
ush b;
#ifdef ZIP10
ush c;
#endif
int n;
uch *p;
uch hh[RAND_HEAD_LEN]; /* decrypted header */
/* set keys and save the encrypted header */
init_keys(__G__ key);
memcpy(hh, h, RAND_HEAD_LEN);
/* check password */
for (n = 0; n < RAND_HEAD_LEN; n++) {
zdecode(hh[n]);
Trace((stdout, " %02x", hh[n]));
}
Trace((stdout,
"\n lrec.crc= %08lx crec.crc= %08lx pInfo->ExtLocHdr= %s\n",
GLOBAL(lrec.crc32), GLOBAL(pInfo->crc),
GLOBAL(pInfo->ExtLocHdr) ? "true":"false"));
Trace((stdout, " incnt = %d unzip offset into zipfile = %ld\n",
GLOBAL(incnt),
GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf))));
/* same test as in zipbare(): */
#ifdef ZIP10 /* check two bytes */
c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1];
Trace((stdout,
" (c | (b<<8)) = %04x (crc >> 16) = %04x lrec.time = %04x\n",
(ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16),
((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff))));
if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ?
((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff) :
(ush)(GLOBAL(lrec.crc32) >> 16)))
return -1; /* bad */
#else
b = hh[RAND_HEAD_LEN-1];
Trace((stdout, " b = %02x (crc >> 24) = %02x (lrec.time >> 8) = %02x\n",
b, (ush)(GLOBAL(lrec.crc32) >> 24),
((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff));
if (b != (GLOBAL(pInfo->ExtLocHdr) ?
((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff :
(ush)(GLOBAL(lrec.crc32) >> 24)))
return -1; /* bad */
#endif
/* password OK: decrypt current buffer contents before leaving */
for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ?
(int)GLOBAL(csize) : GLOBAL(incnt),
p = GLOBAL(inptr); n--; p++)
zdecode(*p);
return 0; /* OK */
} /* end function testkey() */
#endif /* UNZIP && !FUNZIP */
#else /* !CRYPT */
/* something "externally visible" to shut up compiler/linker warnings */
int zcr_dummy;
#endif /* ?CRYPT */

175
unzip/unzip-5.52/crypt.h Normal file
View File

@ -0,0 +1,175 @@
/*
Copyright (c) 1990-2004 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE]
This encryption/decryption source code for Info-Zip software was
originally written in Europe. The whole source package can be
freely distributed, including from the USA. (Prior to January 2000,
re-export from the US was a violation of US law.)
NOTE on copyright history:
Previous versions of this source package (up to version 2.8) were
not copyrighted and put in the public domain. If you cannot comply
with the Info-Zip LICENSE, you may want to look for one of those
public domain versions.
*/
#ifndef __crypt_h /* don't include more than once */
#define __crypt_h
#ifdef CRYPT
# undef CRYPT
#endif
/*
Logic of selecting "full crypt" code:
a) default behaviour:
- dummy crypt code when compiling UnZipSFX stub, to minimize size
- full crypt code when used to compile Zip, UnZip and fUnZip
b) USE_CRYPT defined:
- always full crypt code
c) NO_CRYPT defined:
- never full crypt code
NO_CRYPT takes precedence over USE_CRYPT
*/
#if defined(NO_CRYPT)
# define CRYPT 0 /* dummy version */
#else
#if defined(USE_CRYPT)
# define CRYPT 1 /* full version */
#else
#if !defined(SFX)
# define CRYPT 1 /* full version for zip and main unzip*/
#else
# define CRYPT 0 /* dummy version for unzip sfx */
#endif
#endif /* ?USE_CRYPT */
#endif /* ?NO_CRYPT */
#if CRYPT
/* full version */
#ifdef CR_BETA
# undef CR_BETA /* this is not a beta release */
#endif
#define CR_MAJORVER 2
#define CR_MINORVER 9
#ifdef CR_BETA
# define CR_BETA_VER "a BETA"
# define CR_VERSION_DATE "05 May 2000" /* last real code change */
#else
# define CR_BETA_VER ""
# define CR_VERSION_DATE "05 May 2000" /* last public release date */
# define CR_RELEASE
#endif
#ifndef __G /* UnZip only, for now (DLL stuff) */
# define __G
# define __G__
# define __GDEF
# define __GPRO void
# define __GPRO__
#endif
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
# ifndef DOS_OS2_W32
# define DOS_OS2_W32
# endif
#endif
#if defined(DOS_OS2_W32) || defined(__human68k__)
# ifndef DOS_H68_OS2_W32
# define DOS_H68_OS2_W32
# endif
#endif
#if defined(VM_CMS) || defined(MVS)
# ifndef CMS_MVS
# define CMS_MVS
# endif
#endif
/* To allow combining of Zip and UnZip static libraries in a single binary,
* the Zip and UnZip versions of the crypt core functions have to be named
* differently.
*/
#ifdef ZIP
# ifdef REALLY_SHORT_SYMS
# define decrypt_byte zdcrby
# else
# define decrypt_byte zp_decrypt_byte
# endif
# define update_keys zp_update_keys
# define init_keys zp_init_keys
#else /* !ZIP */
# ifdef REALLY_SHORT_SYMS
# define decrypt_byte dcrbyt
# endif
#endif /* ?ZIP */
#define IZ_PWLEN 80 /* input buffer size for reading encryption key */
#ifndef PWLEN /* for compatibility with previous zcrypt release... */
# define PWLEN IZ_PWLEN
#endif
#define RAND_HEAD_LEN 12 /* length of encryption random header */
/* the crc_32_tab array has to be provided externally for the crypt calculus */
#ifndef CRC_32_TAB /* UnZip provides this in globals.h */
# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
extern ZCONST ulg near *crc_32_tab;
# else
extern ZCONST ulg Far *crc_32_tab;
# endif
#endif /* !CRC_32_TAB */
/* encode byte c, using temp t. Warning: c must not have side effects. */
#define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c))
/* decode byte c in place */
#define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G))
int decrypt_byte OF((__GPRO));
int update_keys OF((__GPRO__ int c));
void init_keys OF((__GPRO__ ZCONST char *passwd));
#ifdef ZIP
void crypthead OF((ZCONST char *, ulg, FILE *));
# ifdef UTIL
int zipcloak OF((struct zlist far *, FILE *, FILE *, ZCONST char *));
int zipbare OF((struct zlist far *, FILE *, FILE *, ZCONST char *));
# else
unsigned zfwrite OF((zvoid *, extent, extent, FILE *));
extern char *key;
# endif
#endif /* ZIP */
#if (defined(UNZIP) && !defined(FUNZIP))
int decrypt OF((__GPRO__ ZCONST char *passwrd));
#endif
#ifdef FUNZIP
extern int encrypted;
# ifdef NEXTBYTE
# undef NEXTBYTE
# endif
# define NEXTBYTE \
(encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
#endif /* FUNZIP */
#else /* !CRYPT */
/* dummy version */
#define zencode
#define zdecode
#define zfwrite fwrite
#endif /* ?CRYPT */
#endif /* !__crypt_h */

284
unzip/unzip-5.52/ebcdic.h Normal file
View File

@ -0,0 +1,284 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
ebcdic.h
The CECP 1047 (Extended de-facto EBCDIC) <-> ISO 8859-1 conversion tables,
from ftp://aix1.segi.ulg.ac.be/pub/docs/iso8859/iso8859.networking
NOTES:
<Paul_von_Behren@stortek.com> (OS/390 port 12/97)
These table no longer represent the standard mappings (for example in the
OS/390 iconv utility). In order to follow current standards I remapped
ebcdic x0a to ascii x15 and
ebcdic x85 to ascii x25 (and vice-versa)
Without these changes, newlines in auto-convert text files appeared
as literal \045.
I'm not sure what effect this remap would have on the MVS and CMS ports, so
I ifdef'd these changes. Hopefully these ifdef's can be removed when the
MVS/CMS folks test the new mappings.
Christian Spieler <spieler@ikp.tu-darmstadt.de>, 27-Apr-1998
The problem mentioned by Paul von Behren was already observed previously
on VM/CMS, during the preparation of the CMS&MVS port of UnZip 5.20 in
1996. At that point, the ebcdic tables were not changed since they seemed
to be an adopted standard (to my knowledge, these tables are still used
as presented in mainfraime KERMIT). Instead, the "end-of-line" conversion
feature of Zip's and UnZip's "text-translation" mode was used to force
correct mappings between ASCII and EBCDIC newline markers.
Before interchanging the ASCII mappings of the EBCDIC control characters
"NL" 0x25 and "LF" 0x15 according to the OS/390 setting, we have to
make sure that EBCDIC 0x15 is never used as line termination.
---------------------------------------------------------------------------*/
#ifndef __ebcdic_h /* prevent multiple inclusions */
#define __ebcdic_h
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef EBCDIC
#ifndef MTS /* MTS uses a slightly "special" EBCDIC code page */
ZCONST uch ebcdic[] = {
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
#ifdef OS390
0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#else
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#endif
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, /* 58 - 5F */
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
#ifdef OS390
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, /* 80 - 87 */
#else
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
#endif
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC, /* A8 - AF */
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59, /* D8 - DF */
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
};
#if (defined(ZIP) || CRYPT)
ZCONST uch ascii[] = {
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#ifdef OS390
0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, /* 10 - 17 */
#else
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
#endif
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
#ifdef OS390
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, /* 20 - 27 */
#else
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
#endif
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, /* 58 - 5F */
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE, /* A8 - AF */
0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7, /* B8 - BF */
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
};
#endif /* ZIP || CRYPT */
#else /* MTS */
/*
* This is the MTS ASCII->EBCDIC translation table. It provides a 1-1
* translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC.
*/
ZCONST uch ebcdic[] = {
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, /* 58 - 5F */
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
0xBD, 0xB4, 0x9A, 0x8A, 0x5F, 0xCA, 0xAF, 0xBC, /* A8 - AF */
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xAD, 0xAE, 0x59, /* D8 - DF */
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
};
#if (defined(ZIP) || CRYPT)
ZCONST uch ascii[] = {
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAC, /* 58 - 5F */
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0xDD, 0xDE, 0xAE, /* A8 - AF */
0x5E, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
0xBD, 0xBE, 0x5B, 0x5D, 0xAF, 0xA8, 0xB4, 0xD7, /* B8 - BF */
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
};
#endif /* ZIP || CRYPT */
#endif /* ?MTS */
#endif /* EBCDIC */
/*---------------------------------------------------------------------------
The following conversion tables translate between IBM PC CP 850
(OEM codepage) and the "Western Europe & America" Windows codepage 1252.
The Windows codepage 1252 contains the ISO 8859-1 "Latin 1" codepage,
with some additional printable characters in the range (0x80 - 0x9F),
that is reserved to control codes in the ISO 8859-1 character table.
The ISO <--> OEM conversion tables were constructed with the help
of the WIN32 (Win16?) API's OemToAnsi() and AnsiToOem() conversion
functions and have been checked against the CP850 and LATIN1 tables
provided in the MS-Kermit 3.14 distribution.
---------------------------------------------------------------------------*/
#ifdef IZ_ISO2OEM_ARRAY
ZCONST uch Far iso2oem[] = {
0x3F, 0x3F, 0x27, 0x9F, 0x22, 0x2E, 0xC5, 0xCE, /* 80 - 87 */
0x5E, 0x25, 0x53, 0x3C, 0x4F, 0x3F, 0x3F, 0x3F, /* 88 - 8F */
0x3F, 0x27, 0x27, 0x22, 0x22, 0x07, 0x2D, 0x2D, /* 90 - 97 */
0x7E, 0x54, 0x73, 0x3E, 0x6F, 0x3F, 0x3F, 0x59, /* 98 - 9F */
0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, /* A0 - A7 */
0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, /* A8 - AF */
0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, /* B0 - B7 */
0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8, /* B8 - BF */
0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80, /* C0 - C7 */
0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8, /* C8 - CF */
0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E, /* D0 - D7 */
0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1, /* D8 - DF */
0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87, /* E0 - E7 */
0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, /* E8 - EF */
0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6, /* F0 - F7 */
0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98 /* F8 - FF */
};
#endif /* IZ_ISO2OEM_ARRAY */
#ifdef IZ_OEM2ISO_ARRAY
ZCONST uch Far oem2iso[] = {
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7, /* 80 - 87 */
0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5, /* 88 - 8F */
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9, /* 90 - 97 */
0xFF, 0xD6, 0xDC, 0xF8, 0xA3, 0xD8, 0xD7, 0x83, /* 98 - 9F */
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA, /* A0 - A7 */
0xBF, 0xAE, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB, /* A8 - AF */
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xC1, 0xC2, 0xC0, /* B0 - B7 */
0xA9, 0xA6, 0xA6, 0x2B, 0x2B, 0xA2, 0xA5, 0x2B, /* B8 - BF */
0x2B, 0x2D, 0x2D, 0x2B, 0x2D, 0x2B, 0xE3, 0xC3, /* C0 - C7 */
0x2B, 0x2B, 0x2D, 0x2D, 0xA6, 0x2D, 0x2B, 0xA4, /* C8 - CF */
0xF0, 0xD0, 0xCA, 0xCB, 0xC8, 0x69, 0xCD, 0xCE, /* D0 - D7 */
0xCF, 0x2B, 0x2B, 0xA6, 0x5F, 0xA6, 0xCC, 0xAF, /* D8 - DF */
0xD3, 0xDF, 0xD4, 0xD2, 0xF5, 0xD5, 0xB5, 0xFE, /* E0 - E7 */
0xDE, 0xDA, 0xDB, 0xD9, 0xFD, 0xDD, 0xAF, 0xB4, /* E8 - EF */
0xAD, 0xB1, 0x3D, 0xBE, 0xB6, 0xA7, 0xF7, 0xB8, /* F0 - F7 */
0xB0, 0xA8, 0xB7, 0xB9, 0xB3, 0xB2, 0xA6, 0xA0 /* F8 - FF */
};
#endif /* IZ_OEM2ISO_ARRAY */
#if defined(THEOS) || defined(THEOS_SUPPORT)
# include "theos/charconv.h"
#endif
#endif /* __ebcdic_h */

317
unzip/unzip-5.52/envargs.c Normal file
View File

@ -0,0 +1,317 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*----------------------------------------------------------------*
| envargs - add default options from environment to command line
|----------------------------------------------------------------
| Author: Bill Davidsen, original 10/13/91, revised 23 Oct 1991.
| This program is in the public domain.
|----------------------------------------------------------------
| Minor program notes:
| 1. Yes, the indirection is a tad complex
| 2. Parentheses were added where not needed in some cases
| to make the action of the code less obscure.
|----------------------------------------------------------------
| UnZip notes: 24 May 92 ("v1.4"):
| 1. #include "unzip.h" for prototypes (24 May 92)
| 2. changed ch to type char (24 May 92)
| 3. added an ifdef to avoid Borland warnings (24 May 92)
| 4. included Rich Wales' mksargs() routine (for MS-DOS, maybe
| OS/2? NT?) (4 Dec 93)
| 5. added alternate-variable string envstr2 (21 Apr 94)
| 6. added support for quoted arguments (6 Jul 96)
*----------------------------------------------------------------*/
#define __ENVARGS_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef __EMX__ /* emx isspace() returns TRUE on extended ASCII !! */
# define ISspace(c) ((c) & 0x80 ? 0 : isspace((unsigned)c))
#else
# define ISspace(c) isspace((unsigned)c)
#endif /* ?__EMX__ */
#ifndef RISCOS
extern char *getenv();
#endif
static int count_args OF((ZCONST char *));
/* envargs() returns PK-style error code */
int envargs(Pargc, Pargv, envstr, envstr2)
int *Pargc;
char ***Pargv;
ZCONST char *envstr, *envstr2;
{
char *envptr; /* value returned by getenv */
char *bufptr; /* copy of env info */
int argc = 0; /* internal arg count */
register int ch; /* spare temp value */
char **argv; /* internal arg vector */
char **argvect; /* copy of vector address */
/* see if anything in the environment */
if ((envptr = getenv(envstr)) != (char *)NULL) /* usual var */
while (ISspace(*envptr)) /* must discard leading spaces */
envptr++;
if (envptr == (char *)NULL || *envptr == '\0')
if ((envptr = getenv(envstr2)) != (char *)NULL) /* alternate var */
while (ISspace(*envptr))
envptr++;
if (envptr == (char *)NULL || *envptr == '\0')
return PK_OK;
bufptr = malloc(1 + strlen(envptr));
if (bufptr == (char *)NULL)
return PK_MEM;
#if ((defined(WIN32) || defined(WINDLL)) && !defined(_WIN32_WCE))
# ifdef WIN32
if (IsWinNT()) {
/* SPC: don't know codepage of 'real' WinNT console */
strcpy(bufptr, envptr);
} else {
/* Win95 environment is DOS and uses OEM character coding */
OEM_TO_INTERN(envptr, bufptr);
}
# else /* !WIN32 */
/* DOS (Win 3.x) environment uses OEM codepage */
OEM_TO_INTERN(envptr, bufptr);
# endif
#else /* !((WIN32 || WINDLL) && !_WIN32_WCE) */
strcpy(bufptr, envptr);
#endif /* ?((WIN32 || WINDLL) && !_WIN32_WCE) */
/* count the args so we can allocate room for them */
argc = count_args(bufptr);
/* allocate a vector large enough for all args */
argv = (char **)malloc((argc + *Pargc + 1) * sizeof(char *));
if (argv == (char **)NULL) {
free(bufptr);
return PK_MEM;
}
argvect = argv;
/* copy the program name first, that's always true */
*(argv++) = *((*Pargv)++);
/* copy the environment args next, may be changed */
do {
#if defined(AMIGA) || defined(UNIX)
if (*bufptr == '"') {
char *argstart = ++bufptr;
*(argv++) = argstart;
for (ch = *bufptr; ch != '\0' && ch != '\"';
ch = *PREINCSTR(bufptr))
if (ch == '\\' && bufptr[1] != '\0')
++bufptr; /* advance to char after backslash */
if (ch != '\0')
*(bufptr++) = '\0'; /* overwrite trailing " */
/* remove escape characters */
while ((argstart = MBSCHR(argstart, '\\')) != (char *)NULL) {
strcpy(argstart, argstart + 1);
if (*argstart)
++argstart;
}
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
INCSTR(bufptr);
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
#ifdef DOS_FLX_NLM_OS2_W32
/* we do not support backslash-quoting of quotes in quoted
* strings under DOS_FLX_NLM_OS2_W32, because backslashes are
* directory separators and double quotes are illegal in filenames */
if (*bufptr == '"') {
*(argv++) = ++bufptr;
while ((ch = *bufptr) != '\0' && ch != '\"')
INCSTR(bufptr);
if (ch != '\0')
*(bufptr++) = '\0';
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
INCSTR(bufptr);
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
INCSTR(bufptr);
if (ch != '\0')
*(bufptr++) = '\0';
#endif /* ?DOS_FLX_NLM_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *bufptr) != '\0' && ISspace(ch))
INCSTR(bufptr);
} while (ch);
/* now save old argc and copy in the old args */
argc += *Pargc;
while (--(*Pargc))
*(argv++) = *((*Pargv)++);
/* finally, add a NULL after the last arg, like Unix */
*argv = (char *)NULL;
/* save the values and return, indicating succes */
*Pargv = argvect;
*Pargc = argc;
return PK_OK;
}
static int count_args(s)
ZCONST char *s;
{
int count = 0;
char ch;
do {
/* count and skip args */
++count;
#if defined(AMIGA) || defined(UNIX)
if (*s == '\"') {
for (ch = *PREINCSTR(s); ch != '\0' && ch != '\"';
ch = *PREINCSTR(s))
if (ch == '\\' && s[1] != '\0')
++s;
if (*s)
++s; /* trailing quote */
} else
#else
#ifdef DOS_FLX_NLM_OS2_W32
if (*s == '\"') {
++s; /* leading quote */
while ((ch = *s) != '\0' && ch != '\"')
INCSTR(s);
if (*s)
++s; /* trailing quote */
} else
#endif /* DOS_FLX_NLM_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *s) != '\0' && !ISspace(ch)) /* note else-clauses above */
INCSTR(s);
while ((ch = *s) != '\0' && ISspace(ch))
INCSTR(s);
} while (ch);
return count;
}
#ifdef TEST
int main(argc, argv)
int argc;
char **argv;
{
int err;
printf("Orig argv: %p\n", argv);
dump_args(argc, argv);
if ((err = envargs(&argc, &argv, "ENVTEST")) != PK_OK) {
perror("envargs: cannot get memory for arguments");
EXIT(err);
}
printf(" New argv: %p\n", argv);
dump_args(argc, argv);
}
void dump_args(argc, argv)
int argc;
char *argv[];
{
int i;
printf("\nDump %d args:\n", argc);
for (i = 0; i < argc; ++i)
printf("%3d %s\n", i, argv[i]);
}
#endif /* TEST */
#ifdef MSDOS /* DOS_OS2? DOS_OS2_W32? */
/*
* void mksargs(int *argcp, char ***argvp)
*
* Substitutes the extended command line argument list produced by
* the MKS Korn Shell in place of the command line info from DOS.
*
* The MKS shell gets around DOS's 128-byte limit on the length of
* a command line by passing the "real" command line in the envi-
* ronment. The "real" arguments are flagged by prepending a tilde
* (~) to each one.
*
* This "mksargs" routine creates a new argument list by scanning
* the environment from the beginning, looking for strings begin-
* ning with a tilde character. The new list replaces the original
* "argv" (pointed to by "argvp"), and the number of arguments
* in the new list replaces the original "argc" (pointed to by
* "argcp").
*
* Rich Wales
*/
void mksargs(argcp, argvp)
int *argcp;
char ***argvp;
{
#ifndef MSC /* declared differently in MSC 7.0 headers, at least */
#ifndef __WATCOMC__
extern char **environ; /* environment */
#endif
#endif
char **envp; /* pointer into environment */
char **newargv; /* new argument list */
char **argp; /* pointer into new arg list */
int newargc; /* new argument count */
/* sanity check */
if (environ == NULL || argcp == NULL || argvp == NULL || *argvp == NULL)
return;
/* find out how many environment arguments there are */
for (envp = environ, newargc = 0;
*envp != NULL && (*envp)[0] == '~';
envp++, newargc++)
;
if (newargc == 0)
return; /* no environment arguments */
/* set up new argument list */
newargv = (char **) malloc(sizeof(char **) * (newargc+1));
if (newargv == NULL)
return; /* malloc failed */
for (argp = newargv, envp = environ; *envp != NULL && (*envp)[0] == '~';
*argp++ = &(*envp++)[1])
;
*argp = NULL; /* null-terminate the list */
/* substitute new argument list in place of old one */
*argcp = newargc;
*argvp = newargv;
}
#endif /* MSDOS */

615
unzip/unzip-5.52/explode.c Normal file
View File

@ -0,0 +1,615 @@
/*
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* explode.c -- by Mark Adler
version c15, 6 July 1996 */
/* Copyright history:
- Starting with UnZip 5.41 of 16-April-2000, this source file
is covered by the Info-Zip LICENSE cited above.
- Prior versions of this source file, found in UnZip source packages
up to UnZip 5.40, were put in the public domain.
The original copyright note by Mark Adler was:
"You can do whatever you like with this source file,
though I would prefer that if you modify it and
redistribute it that you include comments to that effect
with your name and the date. Thank you."
History:
vers date who what
---- --------- -------------- ------------------------------------
c1 30 Mar 92 M. Adler explode that uses huft_build from inflate
(this gives over a 70% speed improvement
over the original unimplode.c, which
decoded a bit at a time)
c2 4 Apr 92 M. Adler fixed bug for file sizes a multiple of 32k.
c3 10 Apr 92 M. Adler added a little memory tracking if DEBUG
c4 11 Apr 92 M. Adler added NOMEMCPY do kill use of memcpy()
c5 21 Apr 92 M. Adler added the WSIZE #define to allow reducing
the 32K window size for specialized
applications.
c6 31 May 92 M. Adler added typecasts to eliminate some warnings
c7 27 Jun 92 G. Roelofs added more typecasts.
c8 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch.
c9 19 Jul 93 J. Bush added more typecasts (to return values);
made l[256] array static for Amiga.
c10 8 Oct 93 G. Roelofs added used_csize for diagnostics; added
buf and unshrink arguments to flush();
undef'd various macros at end for Turbo C;
removed NEXTBYTE macro (now in unzip.h)
and bytebuf variable (not used); changed
memset() to memzero().
c11 9 Jan 94 M. Adler fixed incorrect used_csize calculation.
c12 9 Apr 94 G. Roelofs fixed split comments on preprocessor lines
to avoid bug in Encore compiler.
c13 25 Aug 94 M. Adler fixed distance-length comment (orig c9 fix)
c14 22 Nov 95 S. Maxwell removed unnecessary "static" on auto array
c15 6 Jul 96 W. Haidinger added ulg typecasts to flush() calls.
c16 8 Feb 98 C. Spieler added ZCONST modifiers to const tables
and #ifdef DEBUG around debugging code.
c16b 25 Mar 98 C. Spieler modified DLL code for slide redirection.
c16d 05 Jul 99 C. Spieler take care of flush() return values and
stop processing in case of errors
c17 04 Feb 01 C. Spieler reorganized code to reduce repetitions
of large code parts; adapted huft decoding
to the changes in inflate's huft_build()
due to support of deflate64; fixed memory
leaks (huft tables were not free'd when
get_tree() failed).
c17b 16 Feb 02 C. Spieler changed type of the "extra lengths" array
"extra" from ush into uch (to save space)
*/
/*
Explode imploded (PKZIP method 6 compressed) data. This compression
method searches for as much of the current string of bytes (up to a length
of ~320) in the previous 4K or 8K bytes. If it doesn't find any matches
(of at least length 2 or 3), it codes the next byte. Otherwise, it codes
the length of the matched string and its distance backwards from the
current position. Single bytes ("literals") are preceded by a one (a
single bit) and are either uncoded (the eight bits go directly into the
compressed stream for a total of nine bits) or Huffman coded with a
supplied literal code tree. If literals are coded, then the minimum match
length is three, otherwise it is two.
There are therefore four kinds of imploded streams: 8K search with coded
literals (min match = 3), 4K search with coded literals (min match = 3),
8K with uncoded literals (min match = 2), and 4K with uncoded literals
(min match = 2). The kind of stream is identified in two bits of a
general purpose bit flag that is outside of the compressed stream.
Distance-length pairs for matched strings are preceded by a zero bit (to
distinguish them from literals) and are always coded. The distance comes
first and is either the low six (4K) or low seven (8K) bits of the
distance (uncoded), followed by the high six bits of the distance coded.
Then the length is six bits coded (0..63 + min match length), and if the
maximum such length is coded, then it's followed by another eight bits
(uncoded) to be added to the coded length. This gives a match length
range of 2..320 or 3..321 bytes.
The literal, length, and distance codes are all represented in a slightly
compressed form themselves. What is sent are the lengths of the codes for
each value, which is sufficient to construct the codes. Each byte of the
code representation is the code length (the low four bits representing
1..16), and the number of values sequentially with that length (the high
four bits also representing 1..16). There are 256 literal code values (if
literals are coded), 64 length code values, and 64 distance code values,
in that order at the beginning of the compressed stream. Each set of code
values is preceded (redundantly) with a byte indicating how many bytes are
in the code description that follows, in the range 1..256.
The codes themselves are decoded using tables made by huft_build() from
the bit lengths. That routine and its comments are in the inflate.c
module.
*/
#define __EXPLODE_C /* identifies this source module */
#define UNZIP_INTERNAL
#include "unzip.h" /* must supply slide[] (uch) array and NEXTBYTE macro */
#ifndef WSIZE
# define WSIZE 0x8000 /* window size--must be a power of two, and */
#endif /* at least 8K for zip's implode method */
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
# define wszimpl (unsigned)(G._wsize)
#else
# if defined(USE_DEFLATE64) && defined(INT_16BIT)
# define wszimpl (unsigned)(WSIZE>>1)
# else /* !(USE_DEFLATE64 && INT_16BIT) */
# define wszimpl WSIZE
# endif /* !(USE_DEFLATE64 && INT_16BIT) */
#endif
/* routines here */
static int get_tree OF((__GPRO__ unsigned *l, unsigned n));
static int explode_lit OF((__GPRO__ struct huft *tb, struct huft *tl,
struct huft *td, unsigned bb, unsigned bl,
unsigned bd, unsigned bdl));
static int explode_nolit OF((__GPRO__ struct huft *tl, struct huft *td,
unsigned bl, unsigned bd, unsigned bdl));
int explode OF((__GPRO));
/* The implode algorithm uses a sliding 4K or 8K byte window on the
uncompressed stream to find repeated byte strings. This is implemented
here as a circular buffer. The index is updated simply by incrementing
and then and'ing with 0x0fff (4K-1) or 0x1fff (8K-1). Here, the 32K
buffer of inflate is used, and it works just as well to always have
a 32K circular buffer, so the index is anded with 0x7fff. This is
done to allow the window to also be used as the output buffer. */
/* This must be supplied in an external module useable like "uch slide[8192];"
or "uch *slide;", where the latter would be malloc'ed. In unzip, slide[]
is actually a 32K area for use by inflate, which uses a 32K sliding window.
*/
#define INVALID_CODE 99
#define IS_INVALID_CODE(c) ((c) == INVALID_CODE)
/* Tables for length and distance */
static ZCONST ush cplen2[] =
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65};
static ZCONST ush cplen3[] =
{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66};
static ZCONST uch extra[] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8};
static ZCONST ush cpdist4[] =
{1, 65, 129, 193, 257, 321, 385, 449, 513, 577, 641, 705,
769, 833, 897, 961, 1025, 1089, 1153, 1217, 1281, 1345, 1409, 1473,
1537, 1601, 1665, 1729, 1793, 1857, 1921, 1985, 2049, 2113, 2177,
2241, 2305, 2369, 2433, 2497, 2561, 2625, 2689, 2753, 2817, 2881,
2945, 3009, 3073, 3137, 3201, 3265, 3329, 3393, 3457, 3521, 3585,
3649, 3713, 3777, 3841, 3905, 3969, 4033};
static ZCONST ush cpdist8[] =
{1, 129, 257, 385, 513, 641, 769, 897, 1025, 1153, 1281,
1409, 1537, 1665, 1793, 1921, 2049, 2177, 2305, 2433, 2561, 2689,
2817, 2945, 3073, 3201, 3329, 3457, 3585, 3713, 3841, 3969, 4097,
4225, 4353, 4481, 4609, 4737, 4865, 4993, 5121, 5249, 5377, 5505,
5633, 5761, 5889, 6017, 6145, 6273, 6401, 6529, 6657, 6785, 6913,
7041, 7169, 7297, 7425, 7553, 7681, 7809, 7937, 8065};
/* Macros for inflate() bit peeking and grabbing.
The usage is:
NEEDBITS(j)
x = b & mask_bits[j];
DUMPBITS(j)
where NEEDBITS makes sure that b has at least j bits in it, and
DUMPBITS removes the bits from b. The macros use the variable k
for the number of bits in b. Normally, b and k are register
variables for speed.
*/
#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE)<<k;k+=8;}}
#define DUMPBITS(n) {b>>=(n);k-=(n);}
#define DECODEHUFT(htab, bits, mask) {\
NEEDBITS((unsigned)(bits))\
t = (htab) + ((~(unsigned)b)&(mask));\
while (1) {\
DUMPBITS(t->b)\
if ((e=t->e) <= 32) break;\
if (IS_INVALID_CODE(e)) return 1;\
e &= 31;\
NEEDBITS(e)\
t = t->v.t + ((~(unsigned)b)&mask_bits[e]);\
}\
}
static int get_tree(__G__ l, n)
__GDEF
unsigned *l; /* bit lengths */
unsigned n; /* number expected */
/* Get the bit lengths for a code representation from the compressed
stream. If get_tree() returns 4, then there is an error in the data.
Otherwise zero is returned. */
{
unsigned i; /* bytes remaining in list */
unsigned k; /* lengths entered */
unsigned j; /* number of codes */
unsigned b; /* bit length for those codes */
/* get bit lengths */
i = NEXTBYTE + 1; /* length/count pairs to read */
k = 0; /* next code */
do {
b = ((j = NEXTBYTE) & 0xf) + 1; /* bits in code (1..16) */
j = ((j & 0xf0) >> 4) + 1; /* codes with those bits (1..16) */
if (k + j > n)
return 4; /* don't overflow l[] */
do {
l[k++] = b;
} while (--j);
} while (--i);
return k != n ? 4 : 0; /* should have read n of them */
}
static int explode_lit(__G__ tb, tl, td, bb, bl, bd, bdl)
__GDEF
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
unsigned bb, bl, bd; /* number of bits decoded by those */
unsigned bdl; /* number of distance low bits */
/* Decompress the imploded data using coded literals and a sliding
window (of size 2^(6+bdl) bytes). */
{
ulg s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned mb, ml, md; /* masks for bb, bl, and bd bits */
unsigned mdl; /* mask for bdl (distance lower) bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
int retval = 0; /* error code returned: initialized to "no error" */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
mb = mask_bits[bb]; /* precompute masks for speed */
ml = mask_bits[bl];
md = mask_bits[bd];
mdl = mask_bits[bdl];
s = G.lrec.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--decode it */
{
DUMPBITS(1)
s--;
DECODEHUFT(tb, bb, mb) /* get coded literal */
redirSlide[w++] = (uch)t->v.n;
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(bdl) /* get distance low bits */
d = (unsigned)b & mdl;
DUMPBITS(bdl)
DECODEHUFT(td, bd, md) /* get coded distance high bits */
d = w - d - t->v.n; /* construct offset */
DECODEHUFT(tl, bl, ml) /* get coded length */
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s = (s > (ulg)n ? s - (ulg)n : 0);
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wszimpl not needed and wrong if redirect */
if (d >= wszimpl)
return 1;
e = wszimpl - (d > w ? d : w);
} else
#endif
e = wszimpl - ((d &= wszimpl-1) > w ? d : w);
if (e > n) e = n;
n -= e;
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
static int explode_nolit(__G__ tl, td, bl, bd, bdl)
__GDEF
struct huft *tl, *td; /* length and distance decoder tables */
unsigned bl, bd; /* number of bits decoded by tl[] and td[] */
unsigned bdl; /* number of distance low bits */
/* Decompress the imploded data using uncoded literals and a sliding
window (of size 2^(6+bdl) bytes). */
{
ulg s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned ml, md; /* masks for bl and bd bits */
unsigned mdl; /* mask for bdl (distance lower) bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
int retval = 0; /* error code returned: initialized to "no error" */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
ml = mask_bits[bl]; /* precompute masks for speed */
md = mask_bits[bd];
mdl = mask_bits[bdl];
s = G.lrec.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--get eight bits */
{
DUMPBITS(1)
s--;
NEEDBITS(8)
redirSlide[w++] = (uch)b;
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
DUMPBITS(8)
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(bdl) /* get distance low bits */
d = (unsigned)b & mdl;
DUMPBITS(bdl)
DECODEHUFT(td, bd, md) /* get coded distance high bits */
d = w - d - t->v.n; /* construct offset */
DECODEHUFT(tl, bl, ml) /* get coded length */
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s = (s > (ulg)n ? s - (ulg)n : 0);
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wszimpl not needed and wrong if redirect */
if (d >= wszimpl)
return 1;
e = wszimpl - (d > w ? d : w);
} else
#endif
e = wszimpl - ((d &= wszimpl-1) > w ? d : w);
if (e > n) e = n;
n -= e;
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wszimpl)
{
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
if ((retval = flush(__G__ redirSlide, (ulg)w, 0)) != 0)
return retval;
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
int explode(__G)
__GDEF
/* Explode an imploded compressed stream. Based on the general purpose
bit flag, decide on coded or uncoded literals, and an 8K or 4K sliding
window. Construct the literal (if any), length, and distance codes and
the tables needed to decode them (using huft_build() from inflate.c),
and call the appropriate routine for the type of data in the remainder
of the stream. The four routines are nearly identical, differing only
in whether the literal is decoded or simply read in, and in how many
bits are read in, uncoded, for the low distance bits. */
{
unsigned r; /* return codes */
struct huft *tb; /* literal code table */
struct huft *tl; /* length code table */
struct huft *td; /* distance code table */
unsigned bb; /* bits for tb */
unsigned bl; /* bits for tl */
unsigned bd; /* bits for td */
unsigned bdl; /* number of uncoded lower distance bits */
unsigned l[256]; /* bit lengths for codes */
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide)
/* For 16-bit systems, it has already been checked at DLL entrance that
* the buffer size in G.redirect_size does not exceed unsigned range.
*/
G._wsize = G.redirect_size, redirSlide = G.redirect_buffer;
else
#if defined(USE_DEFLATE64) && defined(INT_16BIT)
/* For systems using 16-bit ints, reduce the used buffer size below
* the limit of "unsigned int" numbers range.
*/
G._wsize = WSIZE>>1, redirSlide = slide;
#else /* !(USE_DEFLATE64 && INT_16BIT) */
G._wsize = WSIZE, redirSlide = slide;
#endif /* !(USE_DEFLATE64 && INT_16BIT) */
#endif /* DLL && !NO_SLIDE_REDIR */
/* Tune base table sizes. Note: I thought that to truly optimize speed,
I would have to select different bl, bd, and bb values for different
compressed file sizes. I was surprised to find out that the values of
7, 7, and 9 worked best over a very wide range of sizes, except that
bd = 8 worked marginally better for large compressed sizes. */
bl = 7;
bd = (G.csize + G.incnt) > 200000L ? 8 : 7;
#ifdef DEBUG
G.hufts = 0; /* initialize huft's malloc'ed */
#endif
if (G.lrec.general_purpose_bit_flag & 4)
/* With literal tree--minimum match length is 3 */
{
bb = 9; /* base table size for literals */
if ((r = get_tree(__G__ l, 256)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 256, 256, NULL, NULL, &tb, &bb)) != 0)
{
if (r == 1)
huft_free(tb);
return (int)r;
}
if ((r = get_tree(__G__ l, 64)) != 0) {
huft_free(tb);
return (int)r;
}
if ((r = huft_build(__G__ l, 64, 0, cplen3, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
huft_free(tb);
return (int)r;
}
}
else
/* No literal tree--minimum match length is 2 */
{
tb = (struct huft *)NULL;
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 64, 0, cplen2, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
return (int)r;
}
}
if ((r = get_tree(__G__ l, 64)) != 0) {
huft_free(tl);
if (tb != (struct huft *)NULL) huft_free(tb);
return (int)r;
}
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
bdl = 7;
r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd);
}
else /* else 4K */
{
bdl = 6;
r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd);
}
if (r != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
if (tb != (struct huft *)NULL) huft_free(tb);
return (int)r;
}
if (tb != NULL) {
r = explode_lit(__G__ tb, tl, td, bb, bl, bd, bdl);
huft_free(tb);
} else {
r = explode_nolit(__G__ tl, td, bl, bd, bdl);
}
huft_free(td);
huft_free(tl);
Trace((stderr, "<%u > ", G.hufts));
return (int)r;
}
/* so explode.c and inflate.c can be compiled together into one object: */
#undef DECODEHUFT
#undef NEEDBITS
#undef DUMPBITS
#undef wszimpl

2403
unzip/unzip-5.52/extract.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
Info-ZIP's UnZip 5.52: generic C sources
Complete C source code for Info-ZIP's
PKUNZIP-compatible .zip extractor, for
all supported compilers and platforms
(Unix, OS/2, MS-DOS, NT, VMS, Amiga,
Atari, Mac, Acorn, VM/CMS, etc.), plus
lots of pretty decent documentation.
This is FREE (but copyrighted) software.
See LICENSE for details on distribution
and reuse.

2575
unzip/unzip-5.52/fileio.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
Contents of the "flexos" subdirectory for UnZip 5.32 and later:
Contents this file
README notes about limitations and assumptions of the FlexOS port
flexos.c OS-dependent UnZip routines for FlexOS
flxcfg.h OS-dependent configuration, included by unzpriv.h
hc.pro profile for MetaWare High C
makefile makefile for MetaWare High C, PAMAKE

View File

@ -0,0 +1,39 @@
This should be considered an initial port - there will probably be some
bugs and non-functioning features.
The only functionality that has had any real testing is "unzip filename",
anything else is basically untested.
This has been cross-compiled from DOS using Metaware's High C compiler
and the DOS version of pamake (v3.0). It should compile with the FlexOS
hosted version of HighC, and the makefile could be converted to work
with the native FlexOS make.
The following considerations apply:
)Compiled against and linked with portlib.
)Used on FlexOS 286 v2.32
)Volume labels are not supported - this is due to the way FlexOS decides
if a drive has case-sensitive filenames based upon the contents of the
volume label.
)No special handling for case-sensitive media (see above).
)Not using the PORTLIB wildarg routine (i.e., UnZip does its own globbing).
)Based upon the MSDOS port.
)Filenames are in FAT format.
)The current version of getch is a cheat (simply using getchar()). I
should interrogate stdin and if it's a FlexOS console use special code
to turn off echo and just read one char.
)Only the basic MSDOS FAT file attributes are saved/restored. There is
currently no support for the FlexOS extended file attributes.
)There is some code that should attempt to do the correct thing when a
pathspec with a logical name definition is used (e.g., "system:path/to/it");
however it again has not been stress-tested.
)There is no special handling for floppy drives, there probably should
be.
)The dateformat is compiled in as DMY (shoot me I'm British), I'm not
sure if there is actually a way to get locale info.
)The assembler speedups haven't yet been ported to ASM86 (should simply
be a change of syntax)
--
D.Fawcus 17 July 1997

View File

@ -0,0 +1,932 @@
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
flexos.c
FlexOS-specific routines for use with Info-ZIP's UnZip 5.2 and later.
Based upon the MSDOS version of this file (msdos/msdos.c)
Contains: do_wild()
mapattr()
mapname()
map2fat()
checkdir()
close_outfile()
dateformat()
version()
_wildarg()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#include <flexif.h>
/* The following should really be a static declaration, but the compiler
complains (crappy compiler can't cope with a static forward declaration).
*/
extern void map2fat OF((char *pathcomp, char *last_dot));
static int created_dir; /* used by mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
/*****************************/
/* Strings used in flexos.c */
/*****************************/
#ifndef SFX
static ZCONST char Far CantAllocateWildcard[] =
"warning: cannot allocate wildcard buffers\n";
#endif
static ZCONST char Far WarnDirTraversSkip[] =
"warning: skipped \"../\" path component(s) in %s\n";
static ZCONST char Far Creating[] = " creating: %s\n";
static ZCONST char Far ConversionFailed[] =
"mapname: conversion of %s failed\n";
static ZCONST char Far PathTooLong[] = "checkdir error: path too long: %s\n";
static ZCONST char Far CantCreateDir[] = "checkdir error: cannot create %s\n\
unable to process %s.\n";
static ZCONST char Far DirIsntDirectory[] =
"checkdir error: %s exists but is not directory\n\
unable to process %s.\n";
static ZCONST char Far PathTooLongTrunc[] =
"checkdir warning: path too long; truncating\n %s\n\
-> %s\n";
#if (!defined(SFX) || defined(SFX_EXDIR))
static ZCONST char Far CantCreateExtractDir[] =
"checkdir: cannot create extraction directory: %s\n";
#endif
#include <dirent.h>
#ifndef SFX
/************************/
/* Function do_wild() */ /* identical to OS/2 version */
/************************/
char *do_wild(__G__ wildspec)
__GDEF
ZCONST char *wildspec; /* only used first time on a given dir */
{
static DIR *wild_dir = (DIR *)NULL;
static ZCONST char *wildname;
static char *dirname, matchname[FILNAMSIZ];
static int notfirstcall=FALSE, have_dirname, dirnamelen;
char *fnamestart;
struct dirent *file;
/* Even when we're just returning wildspec, we *always* do so in
* matchname[]--calling routine is allowed to append four characters
* to the returned string, and wildspec may be a pointer to argv[].
*/
if (!notfirstcall) { /* first call: must initialize everything */
notfirstcall = TRUE;
if (!iswild(wildspec)) {
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
have_dirname = FALSE;
dir = NULL;
return matchname;
}
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '/')) == (ZCONST char *)NULL &&
(wildname = strrchr(wildspec, ':')) == (ZCONST char *)NULL) {
dirname = ".";
dirnamelen = 1;
have_dirname = FALSE;
wildname = wildspec;
} else {
++wildname; /* point at character after '/' or ':' */
dirnamelen = (int)(wildname - wildspec);
if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
Info(slide, 1, ((char *)slide,
LoadFarString(CantAllocateWildcard)));
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname; /* but maybe filespec was not a wildcard */
}
/* GRR: cannot strip trailing char for opendir since might be "d:/" or "d:"
* (would have to check for "./" at end--let opendir handle it instead) */
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
Trace((stderr, "do_wild: dirname = [%s]\n", FnFilter1(dirname)));
if ((wild_dir = opendir(dirname)) != (DIR *)NULL) {
if (have_dirname) {
strcpy(matchname, dirname);
fnamestart = matchname + dirnamelen;
} else
fnamestart = matchname;
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
Trace((stderr, "do_wild: readdir returns %s\n",
FnFilter1(file->d_name)));
strcpy(fnamestart, file->d_name);
if (strrchr(fnamestart, '.') == (char *)NULL)
strcat(fnamestart, ".");
if (match(fnamestart, wildname, 1 WISEP) && /* 1=ignore case */
/* skip "." and ".." directory entries */
strcmp(fnamestart, ".") && strcmp(fnamestart, "..")) {
Trace((stderr, "do_wild: match() succeeds\n"));
/* remove trailing dot */
fnamestart += strlen(fnamestart) - 1;
if (*fnamestart == '.')
*fnamestart = '\0';
return matchname;
}
}
/* if we get to here directory is exhausted, so close it */
closedir(wild_dir);
wild_dir = (DIR *)NULL;
}
#ifdef DEBUG
else {
Trace((stderr, "do_wild: opendir(%s) returns NULL\n",
FnFilter1(dirname)));
}
#endif /* DEBUG */
/* return the raw wildspec in case that works (e.g., directory not
* searchable, but filespec was not wild and file is readable) */
strncpy(matchname, wildspec, FILNAMSIZ);
matchname[FILNAMSIZ-1] = '\0';
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (wild_dir == (DIR *)NULL) {
notfirstcall = FALSE; /* nothing left to try--reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
}
/* If we've gotten this far, we've read and matched at least one entry
* successfully (in a previous call), so dirname has been copied into
* matchname already.
*/
if (have_dirname) {
/* strcpy(matchname, dirname); */
fnamestart = matchname + dirnamelen;
} else
fnamestart = matchname;
while ((file = readdir(wild_dir)) != (struct dirent *)NULL) {
Trace((stderr, "do_wild: readdir returns %s\n",
FnFilter1(file->d_name)));
strcpy(fnamestart, file->d_name);
if (strrchr(fnamestart, '.') == (char *)NULL)
strcat(fnamestart, ".");
if (match(fnamestart, wildname, 1 WISEP)) { /* 1 == ignore case */
Trace((stderr, "do_wild: match() succeeds\n"));
/* remove trailing dot */
fnamestart += strlen(fnamestart) - 1;
if (*fnamestart == '.')
*fnamestart = '\0';
return matchname;
}
}
closedir(wild_dir); /* have read at least one entry; nothing left */
wild_dir = (DIR *)NULL;
notfirstcall = FALSE; /* reset for new wildspec */
if (have_dirname)
free(dirname);
return (char *)NULL;
} /* end function do_wild() */
#endif /* !SFX */
/**********************/
/* Function mapattr() */
/**********************/
int mapattr(__G)
__GDEF
{
/* set archive bit (file is not backed up): */
G.pInfo->file_attr = (unsigned)(G.crec.external_file_attributes & 7) | 32;
return 0;
}
/**********************/
/* Function mapname() */
/**********************/
int mapname(__G__ renamed)
__GDEF
int renamed;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - caution (truncated filename)
* MPN_INF_SKIP - info "skip entry" (dir doesn't exist)
* MPN_ERR_SKIP - error -> skip entry
* MPN_ERR_TOOLONG - error -> path is too long
* MPN_NOMEM - error (memory allocation failed) -> skip entry
* [also MPN_VOL_LABEL, MPN_CREATED_DIR]
*/
{
char pathcomp[FILNAMSIZ]; /* path-component buffer */
char *pp, *cp=(char *)NULL; /* character pointers */
char *lastsemi=(char *)NULL; /* pointer to last semi-colon in pathcomp */
char *last_dot=(char *)NULL; /* last dot not converted to underscore */
int dotname = FALSE; /* path component begins with dot? */
int killed_ddot = FALSE; /* is set when skipping "../" pathcomp */
int error = MPN_OK;
register unsigned workch; /* hold the character being tested */
if (G.pInfo->vollabel)
return MPN_VOL_LABEL; /* Cannot set disk volume labels in FlexOS */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!uO.fflag || renamed);
created_dir = FALSE; /* not yet */
renamed_fullpath = FALSE;
if (renamed) {
cp = G.filename - 1; /* point to beginning of renamed name... */
while (*++cp)
if (*cp == '\\') /* convert backslashes to forward */
*cp = '/';
cp = G.filename;
/* use temporary rootpath if user gave full pathname */
if (G.filename[0] == '/') {
renamed_fullpath = TRUE;
pathcomp[0] = '/'; /* copy the '/' and terminate */
pathcomp[1] = '\0';
++cp;
} else if (isalpha((uch)G.filename[0]) && G.filename[1] == ':') {
renamed_fullpath = TRUE;
pp = pathcomp;
*pp++ = *cp++; /* copy the "d:" (+ '/', possibly) */
*pp++ = *cp++;
if (*cp == '/')
*pp++ = *cp++; /* otherwise add "./"? */
*pp = '\0';
}
}
/* pathcomp is ignored unless renamed_fullpath is TRUE: */
if ((error = checkdir(__G__ pathcomp, INIT)) != 0) /* initialize path buf */
return error; /* ...unless no mem or vol label on hard disk */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (!renamed) { /* cp already set if renamed */
if (uO.jflag) /* junking directories */
cp = (char *)strrchr(G.filename, '/');
if (cp == (char *)NULL) /* no '/' or not junking dirs */
cp = G.filename; /* point to internal zipfile-member pathname */
else
++cp; /* point to start of last component of path */
}
/*---------------------------------------------------------------------------
Begin main loop through characters in filename.
---------------------------------------------------------------------------*/
while ((workch = (uch)*cp++) != 0) {
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
map2fat(pathcomp, last_dot); /* 8.3 truncation (in place) */
last_dot = (char *)NULL;
if (strcmp(pathcomp, ".") == 0) {
/* don't bother appending "./" to the path */
*pathcomp = '\0';
} else if (!uO.ddotflag && strcmp(pathcomp, "..") == 0) {
/* "../" dir traversal detected, skip over it */
*pathcomp = '\0';
killed_ddot = TRUE; /* set "show message" flag */
}
/* when path component is not empty, append it now */
if (*pathcomp != '\0' &&
((error = checkdir(__G__ pathcomp, APPEND_DIR))
& MPN_MASK) > MPN_INF_TRUNC)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave direct. semi-colons alone */
break;
case '.':
if (pp == pathcomp) { /* nothing appended yet... */
if (*cp == '.' && cp[1] == '/') { /* "../" */
*pp++ = '.'; /* add first dot, unchanged... */
++cp; /* skip second dot, since it will */
} else { /* be "added" at end of if-block */
*pp++ = '_'; /* FAT doesn't allow null filename */
dotname = TRUE; /* bodies, so map .exrc -> _.exrc */
} /* (extra '_' now, "dot" below) */
} else if (dotname) { /* found a second dot, but still */
dotname = FALSE; /* have extra leading underscore: */
*pp = '\0'; /* remove it by shifting chars */
pp = pathcomp + 1; /* left one space (e.g., .p1.p2: */
while (pp[1]) { /* __p1 -> _p1_p2 -> _p1.p2 when */
*pp = pp[1]; /* finished) [opt.: since first */
++pp; /* two chars are same, can start */
} /* shifting at second position] */
}
last_dot = pp; /* point at last dot so far... */
*pp++ = '_'; /* convert dot to underscore for now */
break;
/* drive names are not stored in zipfile, so no colons allowed;
* no brackets or most other punctuation either (all of which
* can appear in Unix-created archives; backslash is particularly
* bad unless all necessary directories exist) */
case '[': /* these punctuation characters forbidden */
case ']': /* only on plain FAT file systems */
case '+':
case ',':
case '=':
case ':': /* special shell characters of command.com */
case '\\': /* (device and directory limiters, wildcard */
case '"': /* characters, stdin/stdout redirection and */
case '<': /* pipe indicators and the quote sign) are */
case '>': /* never allowed in filenames on (V)FAT */
case '|':
case '*':
case '?':
*pp++ = '_';
break;
case ';': /* start of VMS version? */
lastsemi = pp;
break;
case ' ': /* change spaces to underscores */
if (uO.sflag) /* only if requested */
*pp++ = '_';
else
*pp++ = (char)workch;
break;
default:
/* allow ASCII 255 and European characters in filenames: */
if (isprint(workch) || workch >= 127)
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
/* Show warning when stripping insecure "parent dir" path components */
if (killed_ddot && QCOND2) {
Info(slide, 0, ((char *)slide, LoadFarString(WarnDirTraversSkip),
FnFilter1(G.filename)));
if (!(error & ~MPN_MASK))
error = (error & MPN_MASK) | PK_WARN;
}
/*---------------------------------------------------------------------------
Report if directory was created (and no file to create: filename ended
in '/'), check name to be sure it exists, and combine path and name be-
fore exiting.
---------------------------------------------------------------------------*/
if (G.filename[strlen(G.filename) - 1] == '/') {
checkdir(__G__ G.filename, GETPATH);
if (created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, LoadFarString(Creating),
FnFilter1(G.filename)));
}
/* set dir time (note trailing '/') */
return (error & ~MPN_MASK) | MPN_CREATED_DIR;
}
/* dir existed already; don't look for data to extract */
return (error & ~MPN_MASK) | MPN_INF_SKIP;
}
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!uO.V_flag && lastsemi) {
pp = lastsemi; /* semi-colon was omitted: expect all #'s */
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
map2fat(pathcomp, last_dot); /* 8.3 truncation (in place) */
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, LoadFarString(ConversionFailed),
FnFilter1(G.filename)));
return (error & ~MPN_MASK) | MPN_ERR_SKIP;
}
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH);
return error;
} /* end function mapname() */
/**********************/
/* Function map2fat() */
/**********************/
static void map2fat(pathcomp, last_dot)
char *pathcomp, *last_dot;
{
char *pEnd = pathcomp + strlen(pathcomp);
/*---------------------------------------------------------------------------
Case 1: filename has no dot, so figure out if we should add one. Note
that the algorithm does not try to get too fancy: if there are no dots
already, the name either gets truncated at 8 characters or the last un-
derscore is converted to a dot (only if more characters are saved that
way). In no case is a dot inserted between existing characters.
GRR: have problem if filename is volume label??
---------------------------------------------------------------------------*/
/* pEnd = pathcomp + strlen(pathcomp); */
if (last_dot == (char *)NULL) { /* no dots: check for underscores... */
char *plu = strrchr(pathcomp, '_'); /* pointer to last underscore */
if (plu == (char *)NULL) { /* no dots, no underscores: truncate at */
if (pEnd > pathcomp+8) /* 8 chars (could insert '.' and keep 11) */
*(pEnd = pathcomp+8) = '\0';
} else if (MIN(plu - pathcomp, 8) + MIN(pEnd - plu - 1, 3) > 8) {
last_dot = plu; /* be lazy: drop through to next if-block */
} else if ((pEnd - pathcomp) > 8) /* more fits into just basename */
pathcomp[8] = '\0'; /* than if convert last underscore to dot */
/* else whole thing fits into 8 chars or less: no change */
}
/*---------------------------------------------------------------------------
Case 2: filename has dot in it, so truncate first half at 8 chars (shift
extension if necessary) and second half at three.
---------------------------------------------------------------------------*/
if (last_dot != (char *)NULL) { /* one dot (or two, in the case of */
*last_dot = '.'; /* "..") is OK: put it back in */
if ((last_dot - pathcomp) > 8) {
char *p=last_dot, *q=pathcomp+8;
int i;
for (i = 0; (i < 4) && *p; ++i) /* too many chars in basename: */
*q++ = *p++; /* shift extension left and */
*q = '\0'; /* truncate/terminate it */
} else if ((pEnd - last_dot) > 4)
last_dot[4] = '\0'; /* too many chars in extension */
/* else filename is fine as is: no change */
}
} /* end function map2fat() */
/***********************/
/* Function checkdir() */
/***********************/
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns:
* MPN_OK - no problem detected
* MPN_INF_TRUNC - (on APPEND_NAME) truncated filename
* MPN_INF_SKIP - path doesn't exist, not allowed to create
* MPN_ERR_SKIP - path doesn't exist, tried to create and failed; or path
* exists and is not a directory, but is supposed to be
* MPN_ERR_TOOLONG - path is too long
* MPN_NOMEM - can't allocate memory for filename buffers
*/
{
static int rootlen = 0; /* length of rootpath */
static char *rootpath; /* user's "extract-to" directory */
static char *buildpath; /* full path (so far) to extracted file */
static char *end; /* pointer to end of buildpath ('\0') */
# define FN_MASK 7
# define FUNCTION (flag & FN_MASK)
/*---------------------------------------------------------------------------
APPEND_DIR: append the path component to the path being built and check
for its existence. If doesn't exist and we are creating directories, do
so for this one; else signal success or error as appropriate.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_DIR) {
int too_long = FALSE;
Trace((stderr, "appending dir segment [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0')
++end;
/* GRR: could do better check, see if overrunning buffer as we go:
* check end-buildpath after each append, set warning variable if
* within 20 of FILNAMSIZ; then if var set, do careful check when
* appending. Clear variable when begin new path. */
if ((end-buildpath) > FILNAMSIZ-3) /* need '/', one-char name, '\0' */
too_long = TRUE; /* check if extracting directory? */
if (stat(buildpath, &G.statbuf)) /* path doesn't exist */
{
if (!G.create_dirs) { /* told not to create (freshening) */
free(buildpath);
return MPN_INF_SKIP; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide, LoadFarString(CantCreateDir),
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path didn't exist, tried to create, failed */
return MPN_ERR_SKIP;
}
created_dir = TRUE;
} else if (!S_ISDIR(G.statbuf.st_mode)) {
Info(slide, 1, ((char *)slide, LoadFarString(DirIsntDirectory),
FnFilter2(buildpath), FnFilter1(G.filename)));
free(buildpath);
/* path existed but wasn't dir */
return MPN_ERR_SKIP;
}
if (too_long) {
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLong),
FnFilter1(buildpath)));
free(buildpath);
/* no room for filenames: fatal */
return MPN_ERR_TOOLONG;
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
return MPN_OK;
} /* end if (FUNCTION == APPEND_DIR) */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
buildpath.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
strcpy(pathcomp, buildpath);
Trace((stderr, "getting and freeing path [%s]\n",
FnFilter1(pathcomp)));
free(buildpath);
buildpath = end = (char *)NULL;
return MPN_OK;
}
/*---------------------------------------------------------------------------
APPEND_NAME: assume the path component is the filename; append it and
return without checking for existence.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_NAME) {
Trace((stderr, "appending filename [%s]\n", FnFilter1(pathcomp)));
while ((*end = *pathcomp++) != '\0') {
++end;
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 1, ((char *)slide, LoadFarString(PathTooLongTrunc),
FnFilter1(G.filename), FnFilter2(buildpath)));
return MPN_INF_TRUNC; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", FnFilter1(buildpath)));
/* could check for existence here, prompt for new name... */
return MPN_OK;
}
/*---------------------------------------------------------------------------
INIT: allocate and initialize buffer space for the file currently being
extracted. If file was renamed with an absolute path, don't prepend the
extract-to path.
---------------------------------------------------------------------------*/
if (FUNCTION == INIT) {
Trace((stderr, "initializing buildpath to "));
/* allocate space for full filename, root path, and maybe "./" */
if ((buildpath = (char *)malloc(strlen(G.filename)+rootlen+3)) ==
(char *)NULL)
return MPN_NOMEM;
if (renamed_fullpath) { /* pathcomp = valid data */
end = buildpath;
while ((*end = *pathcomp++) != '\0')
++end;
} else if (rootlen > 0) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", FnFilter1(buildpath)));
return MPN_OK;
}
/*---------------------------------------------------------------------------
ROOT: if appropriate, store the path in rootpath and create it if neces-
sary; else assume it's a zipfile member and return. This path segment
gets used in extracting all members from every zipfile specified on the
command line. Note that under FlexOS, if a candidate extract-to
directory specification includes a drive letter (leading "x:"), it is
treated just as if it had a trailing '/'--that is, one directory level
will be created if the path doesn't exist, unless this is otherwise pro-
hibited (e.g., freshening).
---------------------------------------------------------------------------*/
#if (!defined(SFX) || defined(SFX_EXDIR))
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n",
FnFilter1(pathcomp)));
if (pathcomp == (char *)NULL) {
rootlen = 0;
return MPN_OK;
}
if (rootlen > 0) /* rootpath was already set, nothing to do */
return MPN_OK;
if ((rootlen = strlen(pathcomp)) > 0) {
int had_trailing_pathsep=FALSE, add_dot=FALSE;
char *tmproot;
if ((tmproot = (char *)malloc(rootlen+3)) == (char *)NULL) {
rootlen = 0;
return MPN_NOMEM;
}
strcpy(tmproot, pathcomp);
if (tmproot[rootlen-1] == '/' || tmproot[rootlen-1] == '\\') {
tmproot[--rootlen] = '\0';
had_trailing_pathsep = TRUE;
}
if (tmproot[rootlen-1] == ':') {
if (!had_trailing_pathsep) /* i.e., original wasn't "xxx:/" */
add_dot = TRUE; /* relative path: add '.' before '/' */
} else if (rootlen > 0) && /* need not check "xxx:." and "xxx:/" */
(SSTAT(tmproot, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))
{
/* path does not exist */
if (!G.create_dirs /* || iswild(tmproot) */ ) {
free(tmproot);
rootlen = 0;
/* treat as stored file */
return MPN_INF_SKIP;
}
/* GRR: scan for wildcard characters? OS-dependent...
* if find any, return MPN_INF_SKIP: treat as stored file(s) */
/* create directory (could add loop here scanning tmproot
* to create more than one level, but really necessary?) */
if (mkdir(tmproot, 0777) == -1) {
Info(slide, 1, ((char *)slide,
LoadFarString(CantCreateExtractDir),
FnFilter1(tmproot)));
free(tmproot);
rootlen = 0;
/* path didn't exist, tried to create, and failed: */
/* file exists, or 2+ subdir levels required */
return MPN_ERR_SKIP;
}
}
if (add_dot) /* had just "x:", make "x:." */
tmproot[rootlen++] = '.';
tmproot[rootlen++] = '/';
tmproot[rootlen] = '\0';
if ((rootpath = (char *)realloc(tmproot, rootlen+1)) == NULL) {
free(tmproot);
rootlen = 0;
return MPN_NOMEM;
}
Trace((stderr, "rootpath now = [%s]\n", FnFilter1(rootpath)));
}
return MPN_OK;
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
/*
* FlexOS VERSION
*
* Set the output file date/time stamp according to information from the
* zipfile directory record for this member, then close the file and set
* its permissions (archive, hidden, read-only, system). Aside from closing
* the file, this routine is optional (but most compilers support it).
*/
{
DISKFILE df;
LONG fnum;
struct { /* date and time words */
union { /* DOS file modification time word */
ush ztime;
struct {
unsigned zt_se : 5;
unsigned zt_mi : 6;
unsigned zt_hr : 5;
} _tf;
} _t;
union { /* DOS file modification date word */
ush zdate;
struct {
unsigned zd_dy : 5;
unsigned zd_mo : 4;
unsigned zd_yr : 7;
} _df;
} _d;
} zt;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
struct tm *t;
#endif /* ?USE_EF_UT_TIME */
fclose(G.outfile);
if ((fnum = s_open(A_SET, G.filename)) < 0) {
Info(slide, 0x201, ((char *)slide,
"warning: cannot open %s to set the time\n",
FnFilter1(G.filename)));
return;
}
if (s_get(T_FILE, fnum, &df, DSKFSIZE) < 0) {
s_close(0, fnum);
Info(slide, 0x201, ((char *)slide,
"warning: cannot get info on %s\n", FnFilter1(G.filename)));
return;
}
/*---------------------------------------------------------------------------
Copy and/or convert time and date variables, if necessary; then fill in
the file time/date.
---------------------------------------------------------------------------*/
#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.lrec.extra_field_length, 0,
G.lrec.last_mod_dos_datetime, &z_utime, NULL) & EB_UT_FL_MTIME))
{
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
z_utime.mtime));
t = localtime(&(z_utime.mtime));
} else
t = (struct tm *)NULL;
if (t != (struct tm *)NULL) {
if (t->tm_year < 80) {
df.df_modyear = 1980;
df.df_modmonth = 1;
df.df_modday = 1;
df.df_modhr = 0;
df.df_modmin = 0;
df.df_modsec = 0;
} else {
df.df_modyear = t->tm_year + 1900;
df.df_modmonth = t->tm_mon + 1;
df.df_modday = t->tm_mday;
df.df_modhr = t->tm_hour;
df.df_modmin = t->tm_min;
df.df_modsec = t->tm_sec;
}
} else
#endif /* ?USE_EF_UX_TIME */
{
zt._t.ztime = (ush)(G.lrec.last_mod_dos_datetime) & 0xffff;
zt._d.zdate = (ush)(G.lrec.last_mod_dos_datetime >> 16);
df.df_modyear = 1980 + zt._d._df.zd_yr;
df.df_modmonth = zt._d._df.zd_mo;
df.df_modday = zt._d._df.zd_dy;
df.df_modhr = zt._t._tf.zt_hr;
df.df_modmin = zt._t._tf.zt_mi;
df.df_modsec = zt._t._tf.zt_se << 1;
}
/*---------------------------------------------------------------------------
Fill in the file attributes.
---------------------------------------------------------------------------*/
df.df_attr1 = (UBYTE)G.pInfo->file_attr;
/*---------------------------------------------------------------------------
Now we try to set the attributes & date/time.
---------------------------------------------------------------------------*/
if (s_set(T_FILE, fnum, &df, DSKFSIZE) < 0)
Info(slide, 0x201, ((char *)slide,
"warning: cannot set info for %s\n", FnFilter1(G.filename)));
s_close(0, fnum);
}
#ifndef SFX
/*************************/
/* Function dateformat() */
/*************************/
int dateformat()
{
return DF_DMY; /* default for systems without locale info */
}
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
int len;
len = sprintf((char *)slide, LoadFarString(CompiledWith),
"MetaWare High C",
"",
"FlexOS",
" (16-bit, big)",
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
(*G.message)((zvoid *)&G, slide, (ulg)len, 0);
}
#endif /* !SFX */
/************************/
/* Function _wildarg() */
/************************/
/* This prevents the PORTLIB startup code from preforming argument globbing */
_wildarg() {}

View File

@ -0,0 +1,30 @@
/*
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2000-Apr-09 or later
(the contents of which are also included in unzip.h) for terms of use.
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
FlexOS specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __flxcfg_h
#define __flxcfg_h
#define __16BIT__
#define MED_MEM
#define EXE_EXTENSION ".286"
#ifndef nearmalloc
# define nearmalloc malloc
# define nearfree free
#endif
#define CRTL_CP_IS_OEM
#define near
#define far
#endif /* !__flxcfg_h */

Some files were not shown because too many files have changed in this diff Show More