This commit was generated by cvs2svn to compensate for changes in r5402,

which included commits to RCS files with non-trunk default branches.

git-svn-id: svn://10.65.10.50/trunk@5403 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-10-20 15:51:36 +00:00
parent a767213989
commit f0d81ffd1c
403 changed files with 117309 additions and 0 deletions

83
zip/unzip/BUGS Executable file
View File

@ -0,0 +1,83 @@
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):
---------------------------
- MSC 7.0 timezone bug: USE_EF_UT_TIME results in all 1-1-1980 timestamps
[should be fixed in 5.30]
- [OS/2 DLL] when trying to use the REXX function UzUnZipToStem to extract a
file with `&' in its name, the DLL crashes (UzUnZipToVar 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]
- VMS: UnZip fails to extract some indexed files that were stored with
IM-style VMS extra field (zip "-V" for Zip 2.0 through 2.1)
- 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)
- MS-DOS: Borland executables don't allow other than 80-column, 25/43/50-line
screen modes (Borland bug) [Michael Stillwell]

198
zip/unzip/COPYING Executable file
View File

@ -0,0 +1,198 @@
__________________________________________________________________________
This is the Info-ZIP file COPYING (for UnZip), last updated 22 May 97.
__________________________________________________________________________
There are currently five explicit copyrights on portions of UnZip
code (at least, of which Info-ZIP is aware): the original Sam Smith
copyright on unzip 2.0, upon which Info-ZIP's UnZip 3.0 was based;
Igor Mandrichenko's copyright on his routines in vms.c; Greg Roelofs'
copyright on zipinfo.c and the new version of unshrink.c; Mike White's
copyright on the Windows DLL code (windll/*); and Steve P. Miller's
copyright on the Pocket UnZip GUI (wince/*). In addition, Mark Adler
has placed inflate.h, inflate.c, explode.c and funzip.c into the public
domain; i.e., these files may be used without any restrictions beyond
those of simple courtesy (credit where it's due). All of these are
discussed immediately below; the remaining code is covered by an im-
plicit copyright under US law. 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 lone
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, the only remaining code that is substantially similar to
Mr. Smith's is that in the file unreduce.c, which now by default
is NOT compiled. The following copyright applies to unreduce.c:
* 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 applies to most of the VMS code in vms.c,
distributed with UnZip versions 4.2 and later:
* Copyright (c) 1992 Igor Mandrichenko.
* Permission is granted to any individual or institution to use,
* copy, or redistribute this software so long as all of the orig-
* inal files are included unmodified, that it is not sold for
* profit, and that this copyright notice is retained.
The following copyright applies to the new version of unshrink.c,
distributed with UnZip versions 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 applies to the Windows DLL code (windll/*),
distributed with UnZip versions 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 applies to the Windows CE GUI port, ``Pocket
UnZip,'' distributed with UnZip versions 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, etc.) and
others. See the file CONTRIBS in the source distribution for a much
more complete list of contributors. As noted above, Mark Adler's
inflate.[ch], explode.c and funzip.c are in the public domain, and
everything that isn't otherwise accounted for is implicitly copy-
righted by Info-ZIP. In other words, use it with our blessings, but
it's still our code. Thank you!
--------------------------------------------------------------------------
Frequently Asked Questions about distributing Zip and UnZip:
Q. Can I distribute Zip and UnZip sources and/or executables?
A. You may redistribute the latest official distributions without
any modification, and without even asking us for permission.
(Note that an "executable distribution" includes documentation,
even if it's in a separate zipfile; plain executables do NOT
count.) You can charge for the cost of the media (CDROM, disk-
ettes, etc.), the compilation (e.g., of a software archive),
and a small copying fee. Distributed archives should follow
the naming conventions used in the `Where' file. If you want
to distribute modified versions, please contact us at
Zip-Bugs@lists.wku.edu first. You must not distribute beta
versions without explicit permission to do so.
Q. Can I use the executables (or DLLs) of Zip and UnZip to distribute
my software?
A. Yes, so long as it is clear that Zip and UnZip are not being
sold, that the source code is freely available, and that there
are no extra or hidden charges resulting from its use by or in-
clusion with the commercial product. Here is an example of a
suitable notice:
NOTE: <Product> is packaged on this CD using Info-ZIP's
compression utility. The installation program uses UnZip
to read zip files from the CD. Info-ZIP's software (Zip,
UnZip and related utilities) is free and can be obtained
as source code or executables from various bulletin board
services and Internet/WWW sites, including CompuServe's
IBMPRO forum and ftp://ftp.cdrom.com/pub/infozip/ .
If the distribution is being done with UnZipSFX instead of a DLL
or stand-alone copy of UnZip (i.e., as one or more self-extracting
archives), no notice is required as long as the normal UnZipSFX
banner has not been removed.
Q. Can I use the source code of Zip and UnZip in my commercial
application?
A. Yes, so long as you include in your product an acknowledgment
and an offer of the original compression sources for free or for
a small copying fee, and make clear that there are no extra or
hidden charges resulting from the use of the compression code by
your product (see below for an example). The acknowledgment should
appear in at least one piece of human-readable documentation (e.g.,
a README file or man page), although additionally putting it in
the executable(s) is OK, too. In other words, you are allowed to
sell only your own work, not ours, and we'd like a little credit.
(Note the additional restrictions above on the code in unreduce.c,
unshrink.c and vms.c.) Contact us at zip-bugs@lists.wku.edu if
you have special requirements. We also like to know when our code
is being used, but we don't require that.
<Product> incorporates compression code by the Info-ZIP group.
There are no extra charges or costs due to the use of this code,
and the original compression sources are freely available from
ftp://ftp.cdrom.com/pub/infozip/ on the Internet. We will also,
upon request, mail you the full sources on a 3.5" MSDOS-format
diskette for the cost of mailing. Send $2 to <address> and ...
If you only need compression capability, not full zipfile support,
you might want to look at zlib instead; it has fewer restrictions
on commercial use. See http://www.cdrom.com/pub/infozip/zlib/ .
__________________________________________________________________________

75
zip/unzip/Contents Executable file
View File

@ -0,0 +1,75 @@
Contents of the UnZip 5.31 source archive. The OS-specific subdirectories
at the end contain their own Contents listings:
Contents this file
README what UnZip is; general information
COPYING copyrights and distribution policy
INSTALL how to compile and install UnZip and related utilities
Where where Zip/UnZip and encryption/decryption support can be found
History.530 new features and fixes in this release
History.531 more new features and fixes in this 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.doc UnZip manual page, human-readable format
unzipsfx.doc UnZipSFX manual page, human-readable format
zipinfo.doc ZipInfo manual page, human-readable format
zipgrep.doc zipgrep manual page, human-readable format
funzip.doc 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 dummy decryption routines (required*)
crypt.h dummy decryption 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
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*)
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*)
version.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
beos/ support files for compiling under BeOS
cmsmvs/ support files for compiling under VM/CMS and MVS
human68k/ support files for compiling under X68000/Human68K
mac/ support files for compiling under Macintosh OS
msdos/ support files for compiling under MS-DOS
novell/ support files for compiling for Novell Netware NLM (preliminary)
os2/ support files for compiling under OS/2 (includes DLL stuff)
qdos/ support files for compiling under SMS/QDOS
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 95 and Windows NT
wince/ support files for compiling under Windows CE (GUI version)
windll/ support files for compiling Windows 3.x/95/NT DLLs
proginfo/ programming docs and additional technical info
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.doc for usage).

441
zip/unzip/History.530 Executable file
View File

@ -0,0 +1,441 @@
UnZip, version 5.3, 22 April 1997
New features, you betcha:
5.21a:
- restrict ^S pause function to extraction only [GRR, Doug Dougherty]
- enable -C for ZipInfo mode, too [GRR, Steven Levine]
- VMS: VMSCLI usage used only with VMS `/' options; if `-' option, use
standard Unix-style usage [Patrick Ellis, Christian, GRR]
- Mac: created mac/README file with timezone info [GRR, Johnny]
- Acorn: added README, included compiler notes in Contents [Sergio]
- added FlashPoint Unzip95 derivative to Where file [GRR]
- Amiga: added -N info to unzip.1 [Paul, GRR]
- Unix: added UNIXBACKUP (-B) option (not well-tested) [Peter Chang]
- Amiga, Unix: extended envargs.c to allow quoted arguments [Haidinger Walter]
- Win32: updated version() info for MSC [Steve]
- DOS: updated msdos/README to note PMODE/W bugs [GRR, Doug Dougherty]
- VMS: new 00binary.vms README file [Christian]
- updated all files except wingui/* with new e-mail host (lists.wku.edu) [GRR]
- DOS: added proginfo/perform.dos file (Christian's test results) [GRR]
- WinDLL/WinGUI: lots of code rearranging to separate GUI code out into a
completely separate archive [Mike]
- BeBox/BeOS: new port! [Chris]
5.21b:
- WinDLL: most remaining GUI parts removed, "wizdll" stuff renamed to "windll"
[Mike, GRR]
5.21c:
- Unix: created testmake.zip for "check" target; fixed check target [GRR]
- WinDLL: new makefiles, headers and even some docs! [Mike]
5.30d:
- SMS/QDOS: new port! [Jonathan Hudson]
- boosted version number to 5.3 (new BeBox, QDOS ports) [GRR]
- added recognition for compression types 9 and 10 ("enhanced deflate" and
"Data Compression Library imploding") [GRR]
5.30e:
- began updating README file [GRR]
- updated msdos/README file with more PMODE/W problems [GRR, Doug Dougherty]
- BeBox: added BeOS extra-field support [Chris]
- Unix: made -O3 default for gcc target [GRR]
- non-VMS: new VMS_TEXT_CONV option to convert VMS native variable-length
text files to local text files (experimental) [GRR]
- Unix: added code to set directory times/perms/UIDs/GIDs (finally!) [GRR]
- added special warning if -Z detected in UnZip options [GRR, Dave Genzel]
- Unix: boosted optimization on linux and linux_asm targets; commented extra
optimizations for Pentium (Pro) [Bill Davidsen, GRR]
- OS/2: changed DLL calling convention to generic EXPENTRY mode [Kai Uwe, GRR]
- WinGUI: removed CRC and compression method from list box [Mike]
- DOS/Win32: improved DOS-mode VFAT support with dynamic detection of VFAT
vs. normal FAT file systems [Eli Zaretskii]
- DOS/Unix: removed 5KB of djgpp targets and 3KB of MSC and Borland targets
from unix/Makefile [GRR]
- partially updated INSTALL [GRR]
- DOS: added Watcom support for volume labels and country info [Paul]
- DOS: added support for djgpp 2.x executable compressor to makefile.dj2
[Frank Donahoe]
- added new extra-field detection to ZipInfo: PKWARE Unix, new Info-ZIP Unix,
Macintosh, extended timestamps [GRR]
5.30f:
- extended Zipinfo verbose-mode reporting of various extra-field types [GRR]
5.30g:
- QDOS: added non-echo password support [Jonathan Hudson]
- DOS: added makefile.emx [E-Yen Tan]
- Win32: optimized crc_i386.asm for speed [Scott Field]
- DOS, Unix: added same optimizations to crc_i386.S [GRR]
- Unix: made linux_asm default target; old "linux" now "linux_noasm" [GRR]
- DOS: modified makefile.dj2 to make unzipsfx smaller [Frank Donahoe]
- NT: added support for NT security descriptors (ACLs) [Scott Field]
5.30h:
- WinDLL: integration with NTSD code; other updates [Mike]
- NT: added NT SD documentation file to proginfo directory [Scott Field]
- Unix: updated BUGS section of unzip.1 [GRR]
5.30i:
- added AOS/VS extra-field info to ZipInfo [GRR]
- added proginfo/extra.fld documentation [GRR]
- updated Where file for new locations [GRR]
- added WinZip bug to proginfo/pkbugs [GRR]
- Unix: added ISC targets; updated BSDI targets; changed CP from cp to ln in
Makefile; removed UNZIPS dependency from install target and removed
install_asm target [Larry Jones]
- DOS: updated msdos/README to note possible new problem with go32 extender
(not PMODE/W?) [GRR, Michael Webb]
- updated crypt.[ch] [Christian]
- Christian monster patch #2:
* global support for new "time" and "Unix2" extra field blocks
* appnote.iz updates (-> extra.fld)
* various fixes
- Unix: added (updated version of) Jean-loup's zipgrep script to unix dir;
wrote new man page; updated unix/Makefile accordingly [GRR]
- updated "unzip -v" line with new ftp and web sites [GRR]
5.30j:
- DOS, Win32: Watcom makefile updates [Paul]
- WinDLL: updated directory [Mike]
- USE_EF_UX_TIME changed to USE_EF_UT_TIME globally; qdos/unix.c merged with
unix/unix.c [Christian]
- added ZipIt extra field detection (incomplete, undocumented) [GRR]
5.30k:
- added report of ZipIt extra-field info; corrected proginfo/extra.fld [GRR]
- updated Where with new zcrypt site, various fixes [GRR]
- OS/2, Win32: added emx+gcc+RSXNT cross-compilation target to makefile.os2
[Kai Uwe]
- updated COPYING file (final time?) [GRR]
- made LZW_CLEAN (no unshrinking) default [GRR]
5.30m:
- renamed bebox/* to beos/* (including all macros, etc.) [GRR, Chris]
- QDOS: updated README; added beta-version hack to qdos.c [Jonathan Hudson]
- WinCE: new port! [Steve P. Miller]
- added -P option for command-line passwords (Ye People have Spoken, sigh)
[GRR]
- VMS: updated README [Christian]
- Win32: optimization: use unsigned long long (if available) for 64-bit time
calculations [Christian]
- DOS: added paragraph on djgpp 2.x [Frank Donahoe, GRR]
- added explicit compression-method info to "unsupported method" warnings in
extract.c (replaces method number) [GRR, Mark]
5.30n:
- BeOS: updated for release 1.1DR8.2 [Chris]
- QNX: updated unix.c version() for Neutrino [Chris]
- added "OS made by" type 17 for Tandem/NSK; updated ZipInfo [GRR, Dave D.
Smith]
5.30o:
- added IZ_PW* macros to crypt_dummy.h for DLL-using apps [Mike W]
- VMS: added foreign-symbol help line if no options given [GRR]
- BeOS: updates for latest OS release; unified makefile; install zipgrep
[Chris]
- renamed proginfo/pkbugs to 3rdparty.bug (includes WinZip info, etc.) [GRR]
5.30p:
- updated all man pages (UnZip -A, -P, -bb, -o; footer; dates; versions; etc);
built new *.doc versions [GRR]
- cleaned up extra-field dots handling and hex dumping in zipinfo.c [GRR]
- updated main Contents [GRR]
- updated COPYING with WinCE, unshrink info [GRR]
- added two new exit codes: IZ_UNSUP (no files processed due to unsupported
compression or encryption) and IZ_BADPWD (no files processed due to bad
password(s)) [GRR, Mike W]
- moved all return/exit codes into (public) unzip.h [Christian]
- Mac: updated; new version of rsrc.hqx [Antoine]
- Win32: added (or restored) MSVC 4.2 makefile [Mike W]
- Win32: added MSVC 5.0 "build file" [Mike Strock]
- updated file_id.* files [GRR]
- updated README [GRR]
- WinCE: added partial support for help file [Steve M]
5.30q:
- updated README again [GRR]
- updated INSTALL, msdos/README [GRR]
5.30r:
- updated various file_id.diz files (again) [GRR]
- Unix: updated Solaris/SVR4 package stuff [John Bush]
- WinDLL: added example file and null sound function [Mike W]
- WinCE: finished(?) port [Steve M]:
- Completed Help File (HTML)
- Cleaned up Christian's changes in my code
- Fixed one bug (I was incorrectly setting C_flag)
- Removed all the CE/NT emulation project stuff since it never built
correctly anyway.
- Added a few more low memory checks and messages.
- Cleaned up some comments.
- Removed MATCH.C from project and wrote my own match() and iswild().
- Internally store true file name instead of fnfilter'd name.
- Convert non-printable characters in file names and comments when
displaying them on the screen.
- Use Info() flags to detect when to insert new lines.
- changed all "#ifdef CRYPT" to "#if CRYPT" for better error-catching
[Christian, GRR]
- Unix: removed svr4package dependency from default solaris target; added
new solaris_pkg target [Jean-loup, John B, GRR]
- updated proginfo/CONTRIBS, README, History.530, etc. [GRR]
5.30s:
- documented UNIXBACKUP compile option in INSTALL [GRR, Marty Leisner]
- Unix: added freebsd target (assembly-language CRC) [GRR]
- updated Where [Christian, GRR]
5.30t:
- added support for UNIXBACKUP on "unzip -v" info screen; documented TIMESTAMP
and UNIXBACKUP options in UnZip man page [GRR, Frank Donahoe]
- added some tips, warnings and corrections to INSTALL [Frank Donahoe, GRR]
- updated remaining Contents files and unzip.c comments [GRR]
Bugs fixed:
5.21a:
- DOS, Mac: corrected for weird time_t basis dates (i.e., not 1970) [GRR,
Steve S, Johnny]
- OS/2: fixed API_DOC code and updated with missing functions [GRR]
- OS/2: fixed ASCII-mode -p operation under IBM C Set++/Visual Age C++ com-
pilers [GRR, Kai Uwe]
- return 80 on user abort (^C) [Nick Smith, GRR]
- Acorn: fixed missing comma in version() [Thomas Esken]
- Unix: updated amdahl Makefile target [GRR, Jeroen Staal]
- DOS: included TZDIR info in msdos/README [GRR, Onno]
- WinGUI: WM_ACTIVATE work-around, .hlp updates [Mike]
- WinDLL: ttyio.h, password.c crypt changes [Mike]
- Amiga: UnZipSFX updates [Paul]
- DOS: fixed Watcom date-crash bug [Paul]
- Amiga: lots of updates for SAS/C [Haidinger Walter]
- changed a size_t to extent in extract.c [GRR]
- Unix: added prototype for time_stamp() [GRR]
- Unix: rearranged ioctl stuff in ttyio.c to avoid compiler warnings [GRR]
- fixed behaviour of negating -z option to comply with docs [??]
5.21b:
- all but Amiga/Unix: fixed envargs.c bug introduced by own self (sigh) [GRR]
- fixed typo in History file [GRR]
5.21c:
- Amiga: fixed long-unnoticed defect in Amiga command-line parsing [Paul]
- rewrote envargs, added WIN32 quote support (probably should be extended
to DOS, OS/2) [Paul]
- OS/2: fixed Borland version numbers (apparently offset by three from DOS?)
[GRR, Kai Uwe]
- Win32: ifdef'd out buf2 in version() unless recent version of MSC; changed
"v2.0/2.1" to "v2.x" for Visual C++ [Steve]
- added/fixed some typecasts in crypt.c [Paul]
- Amiga/Win32: lots of fixes [Paul]
- Be: replaced bebox/ directory, fixed ttyio.c [Chris]
- DOS: fixed Borland C _timezone bug [Jochen Roderburg, GRR]
- Win: changed WINDLL_MAX_PATH to PATH_MAX (extract.c) [Mike]
- Amiga: SAS/C fixes [Haidinger Walter]
- VM/CMS: final(?) fixes [Greg Hartwig]
5.30d:
- fixed random-data-bomb bug in inflate [Mark]
- Unix: updated/expanded Solaris (or SVR4) package support [John Bush]
5.30e:
- fixed missing params in third ZipInfo usage line [GRR, Kevin]
- Unix: added -D_INCLUDE_BSD_SOURCE and -D_INCLUDE_XOPEN_SOURCE to apollo
target [Gordon Fox]
- Windows: removed unnecessary MSWIN stuff from ttyio.c and zip.h [Mike]
- disallow -M ("more") for ZipInfo mode if !isatty(1) (UnZip mode already
done) [Stan Brown]
- changed funzip.c main() to return int instead of void [GRR, Peter Seebach]
- Unix: fixed (mostly) extracted-dir permissions [GRR, Piet Plomp]
- fixed "extra N bytes preceding" bug in ZipInfo -v output [GRR]
- changed overlooked QDOS_MAYBE_ macro to QDOS_ in qdos/qdos.c [Jonathan
Hudson]
- Unix: fixed install target so BINDIR and MANDIR are created if necessary
[Christian Carey]
- Unix: moved chmod() from before chown() to after it [Piet]
- Unix: fixed chmod/utime warning messages [GRR]
- Amiga: fixed fUnZip/REENTRANT bug in flate.a [Paul]
- DOS, Win32: worked around Watcom stat() bug [Paul]
- WinDLL: various REENTRANT fixes; changed DLL names to unzip16.dll and
unzip32.dll [Mike]
- Unix: use dumb screenlines() function for SCO Unix [??]
- OS/2: changed OS2API macro to OS2DLL; changed DLL name to unzip32.dll for
consistency [GRR]
- Unix: fixes for SCO Xenix 286 and SunOS 3.x systems [Tom Schmidt]
- Amiga: various SAS/C fixes/cleanups [Haidinger Walter]
- DOS: worked around Borland 5.0 stat() bug (open_outfile()) [Mike]
5.30f:
- ifdef'd dircomp() declaration to avoid warnings [GRR, Michael Lawler]
- DOS: USE_LFN fix for djgpp 2.0- and 2.1-compatibility [Eli Zaretskii,
Douglas Wegscheid]
- DOS: cleaned up USE_VFAT stuff to avoid compilation warnings on
non-USE_VFAT systems [GRR]
- Unix: define SYSNDIR for SCO Xenix only (not SCO Unix) [Jim Lill]
- WinDLL: added "RECHEAT" code (kludge?) to globals.c; fixed unzver.h [Mike]
5.30g:
- added typecasts to various strncmp() calls [GRR, Michael Lawler, Mike W]
- added tzset() call to top of zipinfo() [GRR]
- OS/2: moved <os2.h> from os2/os2.h to unzip.h and put "os2/os2.h" back in
unzpriv.h [GRR]
- BeOS: updated unzip.h to make use of __BEOS__ macro; minor fixes for future
expansion of extra field [Chris]
- Win32: fixed DIR_END problem with ZipInfo and VC++ 4.0 [Kimio Itoh]
- DLL: changed EXPENTRY tag in prototypes to UZ_EXP, defined as EXPENTRY for
OS/2; removed windows.h from unzip.h [GRR]
- OS/2 DLL: no, wait: defined UZ_EXP as empty for emx, _System for all other
compilers: no more os2.h inclusion in unzip.h [GRR, Kai Uwe]
- WinDLL: many updates [Mike W]
- BeOS: more fixes for Be extra field [Chris]
5.30h:
- Win32: fixed reference to XX_flag [Brad Clarke, GRR]
- Win32: changed all nt_unzip.*, ntsd.* to nt.*; updated Watcom makefile for
security descriptor code [GRR]
- Win32: moved TruncNTSD extern declaration back into win32.c from nt.h
[Steve, GRR]
- corrected zipcloak, VFAT/djgpp info in INSTALL [Frank Donahoe]
- Win: cleaned up various oversights from NTSD merge, windll stuff [Mike]
- VMS: ifdef'd out tzset() in zipinfo.c [Mike Freeman]
- Unix: turned on execute bit for extracted DOS/whatever subdirectories
[Marty Leisner, GRR]
- Win32: fixed IsWinNT() function (was always returning TRUE) [Mike]
- corrected some locations in the Where file [GRR, Matthias Dietmar Beier]
- OS/2: various small fixes to makefile and to sources to avoid compiler
warnings [Kai Uwe]
- Amiga: updated stat.c for SAS/C (corresponding to Zip); cleaned up
smakefile [Walter Haidinger]
5.30i:
- Win32: moved NTSD prototypes below unzip.h in win32.c [Paul, Mike]
- Win32: globals fixes for extract.c [Mike]
- minor corrections to COPYING file [GRR]
- Unix: modified crc_i386.S to work with AT&T's assembler; added ptem.h to
ttyio.c for SVR3.2 [Larry Jones]
- Amiga: missing filedate patch [Paul]
- Christian monster patch #1:
* crypt.c: purely cosmetic change (shorten name of dummy var)
* crypt.h: removed last atom of encryption-specific info
* ttyio.[ch]: modifications of getp() (no used for WINDLL, QDOS version in
QDOS-specific source); simple check of zcrypt ver
* removed TABs and trailing invisible spaces from several source files
* fixed VMS-specific bug (undefined string for VMSCLI option)
* replaced MSWIN macro name with new WINDLL almost everywhere
* zipinfo.c:
- rearranged extra-field info in zi_long() to shorten the code
- disk numbers of multi-part archives are displayed starting at "1"
(not "0"). This is now compatible with the PKZIP behaviour.
* fileio.c New function UzpPassword() used as default for the decr_passwd()
callback (tty interface, not for WINDLL)
* adapted WINDLL port to the new (changed) decr_password callback
(This is untested, but I hope I did not break anything...)
* fixed some typos and code indentations.
- WinDLL: globals.c UzpPassword fix [Mike]
- Christian patch #3: various WINDLL fixes
- WinDLL: various fixes to Christian's patches [Mike]
- Christian patch #4: various DLL and WINDLL fixes/optimizations/cleanups
- cosmetic fixes to ttyio.c [GRR]
5.30j:
- Win32: fixed two typos in win32.c and nt.c [Mike Strock]
- BeOS: fixed two typos in bebox.c [Chris]
- VMS: removed spurious right parenthesis [Mike Freeman]
- EF_TIME fixes, typo fixes [Christian]
- WinCE: fileio.c change of (zipfd < 0) test to (zipfd == -1) [Steve Miller]
5.30k:
- fixed illicit ANSIfication of EB_UT_FL_*TIME macros; clarified comment in
Unix makefile [GRR, Phil Ritzenthaler]
- fixed (I think) most "const"-related warnings [GRR, Christian, others]
- Unix: changed lurking strdup() to malloc/strcpy() [GRR, Mark]
- plugged MALLOC_WORK memory leak [Walter Haidinger]
- fixed CRYPT typo in free_G_buffers() [GRR]
- fixed ush temp value in decrypt_byte (could overflow with undefined results)
[GRR]
5.30m:
- OS/2, Win32: fixed MIME "=3D" in makefile.os2 gccwin32 target [Kai Uwe]
- fixed missing ZPIT typecast in zipinfo.c [Mike, Chris]
- QDOS: updated [Jonathan]
- Novell: made a few blind corrections to the old Watcom makefile [GRR]
- added ef_id info to zipinfo.c ExtraFieldTrunc error message; send to stderr
[GRR]
- monster OEM vs. ISO-8859-1 vs. EBCDIC patch #1 (plus assorted fixes)
[Christian]
- Amiga: reentrancy fixes, makefile updates, SAS/C timezone fixes, etc.
[Paul, Walter]
- return NULL if unable to malloc globals struct with REENTRANT [Steve Miller]
- monster OEM vs. ISO-8859-1 vs. EBCDIC patch #2 (cleanup, EBCDIC passwords,
ZipInfo pInfo bug) [Christian]
- Mac: added real installation info to INSTALL [Harry Nyberg, GRR]
- OEM vs. ISO-8859-1 vs. EBCDIC patch #3 (cleanup, more EBCDIC passwords, etc.)
[Christian]
- OEM vs. ISO-8859-1 vs. EBCDIC patch #4 (minor passwords cleanup) [Christian]
- OEM vs. ISO-8859-1 vs. EBCDIC patch #5 (bugfixes) [Christian]
- close outfile if disk is full (so can be deleted before UnZip[.dll] exits)
and warn user about truncated file [Steve Miller, GRR]
- DOS/OS2/Win32: error message if can't unlink old version of file [Steve
Miller, GRR]
- updated unzip.1/unzip.doc to note 8-bit-password incompatibilities [GRR]
- WinDLL: updated makefiles, modified to use UZ_ version numbers [Mike, GRR]
- OS/2: USE_EF_UT_TIME fixes [Christian]
- Win32: work-around for Win32 timezone bug (uses current state of daylight
savings time to adjust file times, instead of state at time file was last
modified) [Christian, Steve S]
5.30n:
- Win32: added user32.lib to makefile [Steve S]
- more bugfixes, cleanups, 8-bit mods, etc. [Christian]
- Win32: minor TZBUG bugfix [Christian]
- fixed some missing newlines in error strings [Steve M, GRR]
- WinCE: more fixes and enhancements [Steve M]
5.30o:
- corrected misinformation in unix/unzip.1 regarding 8-bit passwords [GRR]
- OS/2: added experimental code to write directory EAs if -o option given
[GRR, Bernard Chan, Larry Martin, Kai Uwe]
- BeOS: bugfix for ZipInfo crash (timezone-related) [Chris]
- fixes for 8-bit file comments; vms/vms.c cosmetic fixes (error msgs); use
ZCONST in ttyio.c [Christian]
- Acorn: extension-pointer bugfix; assembler version of mkdir to work around
bug in system() implementation [Sergio]
- 8-bit fnfilter() support; global Fnfilter1/Fnfilter2 consistency fixes
[Christian]
- Watcom makefile updates; replacement for Watcom getch() [Paul]
- WinCE: various minor fixes, documentation updates, etc. [Steve M]
- WinDLL: fix for version-number handling [Mike W]
- BeOS: bugfix for version() garbage; PowerPC-vs.-other detection [Chris]
5.30p:
- Unix: added zipgrep docs to Makefile where missing [GRR]
- WinCE: updated copyright/disclaimer notices for consistency [Steve M]
- MVS: reformatted lines > 80 characters [Bill Gould, GRR]
- return error code when option(s) given without zipfile (except -h, -v) [GRR,
Mike F]
- QNX: added work-around to unix/Makefile install target for broken QNX mkdir
[Chris]
- added fileio.c typecast to avoid Borland warning [Mike W]
- regularized exit codes (envargs, fileio, globals, process, inflate) [GRR]
- Unix: updated ISC makefile targets [Larry Jones]
- docs fixes, cosmetic Acorn fixes [Christian]
- bugfix for CRC-table deallocation (==> CRC errors, etc., on Mac) [Antoine]
- BeOS: cosmetic fix for version(); fileio fixes to avoid compiler warnings
[Chris]
- WinCE: UI bugfixes [Steve M]
5.30q:
- fixed unzip man page w.r.t. OEM vs. ISO/ANSI info [Christian, GRR]
- WinCE: provisional OEM/ISO fixes for passwords [Christian]
- dynamic CRC-table fixes for Antoine's patch; cosmetic changes for VMS help
screen, ZipInfo extra-field/block code, IZ_PW_ERROR vs. PK_MEM2 in crypt.c,
etc. [Christian]
- Win32: OEM/ISO fixes; getch() fixes [Paul]
5.30r:
- Amiga: updated dates/comments in makefiles [Paul]
- WinDLL: changed "Wiz" references in windll/example.* to "WiZ" for internal
consistency [GRR]
- VMS: fixed too-big-usage-screen problem by pointing at maintainer/e-mail
info in "unzip -v" screen [Christian]
- Win32: final(?) ISO-vs.-OEM character-set fix [Christian, Paul]
- WinCE: final Purify-type bugfixes/cleanups [Steve M]
- fixed crypt memory leak in process.c (free(key) was effectively ifdef'd out)
and removed superfluous instruction [Steve M, GRR, Mike W, Christian]
5.30s:
- Unix: fixed test target for ZipInfo timezone mismatches (added extra
commentary) [GRR]
- minor cosmetic fixes to funzip messages [GRR]
- fixed overlooked or overwritten "#if[n]def CRYPT" in extract.c, windll.c
and wince/winmain.cpp [Steve M, GRR]
- Amiga: ifdef'd out unused string variable [GRR, Walter]
- Win32: bugfix to truncate file times earlier than 1980 if output file system
can't represent them (FAT, VFAT, HPFS?) [GRR, Christian, Mike W, Paul]
- Amiga: fixed REENTRANT/DYNALLOC_CRCTAB problem for SAS/C; minor smakefile
optimization tweak [Walter]
- initialized v[] in huft_build() of inflate.c to avoid out-of-bounds error
with some piped data under Win32 (may be corrupted input) [Jeffrey Altman]
- WinCE: fixed personal URLs [Steve M]
- fixed REENTRANT/DYNALLOC_CRCTAB problem globally (unzip.h instead of zip.h);
fixed zcrypt version in windll.c comments [Christian]
- Amiga: CRYPT bugfix in flate.a; minor makefile fixes [Paul]
5.30t:
- OS/2: removed -Zsmall-conv from gccdyn target [Kai Uwe]
- Win32: better fix for pre-1980 timestamp problem (now compiles without
NT_TZBUG_WORKAROUND defined) [Christian]
- Win32: added extra workaround for Borland C++ 5.x pre-1980 bug [GRR]
- WinCE: incorporated DST and pre-1980 bugfixes for native NT flavor [Steve M]
==================
These changes occurred in beta versions 5.21a to 5.30t. This list may have
left out some bugfixes and even some features...the brain cell is going,
folks (as Mark would say). Apologies, etc.
Greg Roelofs

89
zip/unzip/History.531 Executable file
View File

@ -0,0 +1,89 @@
UnZip, version 5.31, 31 May 1997
New or removed features, you betcha:
5.31a:
- OS/2, Win32: added Watcom Win32 cross-compilation target to makefile.os2
[Kai Uwe]
- Win32: minor performance fix in UTCtime2Localtime() [GRR]
- Amiga: same performance fix in mkgmtime() [Christian Spieler]
- removed some unnecessary code from UnZipSFX (TestExtraField(), long strings,
end-of-central-dir check, backslash check, etc.) [GRR]
- Amiga, Win32: made ydays[] array global const to avoid duplicate data [GRR]
- WinDLL: removed bogus Unz_CreateGlobals() and Unz_DestroyGlobals() [Mike
White]
5.31b:
- Unix: made TIMESTAMP default option (oversight in 5.30); updated INSTALL
and unzip.{1,doc} appropriately [GRR]
- updated INSTALL with emx/gcc+RSX 5.1 USE_VFAT info [GRR, E-Yen Tan]
- updated various docs with projected release date [GRR]
5.31c:
- updated Where, COPYING, CONTRIBS [GRR]
- Acorn: simplified RunMe1st script with small srcrename exe [Sergio Monesi]
- removed proginfo/porting.zip (oversight in 5.30) [GRR]
- BeOS: updates for DR9, including extra-field changes [Chris]
- BeOS: removed zipinfo script (symlinks now supported) [GRR]
- Unix: updated linux_shlib target to use .pic.o suffix on shared-library
objects [GRR]
5.31d:
- WinDLL: added encryption info to message function [Mike]
- BeOS: updated extra-field support (flag byte, etc.) [Chris]
Bugs fixed:
5.31a:
- VMS: typo bugfix (missing comma) in cmdline.c [Hunter Goatley]
- VMS: portability bugfix for DEC C detection in make_unz.com [Brian Tillman]
- Amiga: bugfix for same old DST/localtime bug [Paul Kienitz]
- WinCE: corrected bugfix for DST/localtime bug, on both native and FAT file
systems [Steve Miller]
- WinCE: bugfixes for root-directory extraction, various error messages, typos
[Steve M]
- VMS: portability bugfix for non-standard "edit" definitions [Ian Miller]
- eliminated bogus comment about "coming" QDOS port from main README [Jonathan
Hudson]
- DOS, OS/2: ifdef'd out Borland version-debug code in msdos.c and os2.c
[Brad Clarke, GRR]
- Acorn: fixed typo in INSTALL [Sergio]
- Acorn: fixed pair of typos in acorn.c [Johnny Lee, GRR]
- QDOS: fixed typo in qdos.c [Johnny]
- OS/2: updated BUGS to note REXX problem with `&' filenames [Daniel H, GRR]
- Unix/DOS: fixed bogus "msdos\msdos.c" in Unix makefile (cross-compilation)
[Fred Smith]
- Acorn: bugfix to remove some signed/unsigned warnings [Sergio]
- Amiga: bugfix for oversight in Amiga perf patch [Paul]
- WinDLL: bugfixes for missing MSVC macro and weird initialization code [Mike]
5.31b:
- ifdef'd out -Z test for UnZipSFX (compilation error) [Mike Freeman, Frank
Donahoe, GRR]
- ifdef'd out unused UnZipSFX tmp variable [GRR]
- Unix: made "ln" of UnZipSFX and fUnZip sources non-fatal if error occurs
(typically due to left-over link from a previous failed compilation);
added linked sources to clean target [GRR, Frank D]
- Amiga: removed bogus line from filedate.c; updated Aztec makefile [Paul]
- DOS: updated makefile.emx with RSX 5.1 info; removed OS/2 stuff [E-Yen Tan]
5.31c:
- Unix: fixed SVR4 packaging to include zipgrep [Eric Baatz, GRR]
- DLL: fixed calling conventions on default (public) I/O functions to use
UZ_EXP keyword, unless otherwise handled [Russell Lang, GRR, Mike]
- WinDLL: removed bogus function calls from docs and header files [Mike]
- BeOS: fixed ZipInfo reporting of BeOS extra field [GRR]
- Unix: fixed linux_shlib target for new(er) binutils (libunzip.so symlink)
[GRR]
5.31d:
- Unix: fixed zipgrep location in SVR4 packaging [Eric Baatz]
- WinDLL: added list.c typecast to avoid compiler warning [Mike]
- Amiga: ifdef'd out Aztec C replacements for localtime(), gmtime(), etc.,
to avoid conflicts with SAS/C functions [GRR, Walter Haidinger]
- Amiga: fixed test for out-of-range dates in filedate.c [Walter, Paul, GRR]
- Amiga: typedef'd shrint as short to avoid SAS/C crashes [Walter]
- added typecasts to unreduce.c (flush() calls) to avoid warnings [Walter]
- OS/2: fixed order of UZ_EXP and "*" in function-pointer prototypes [Kai Uwe]
==================
These changes occurred in beta versions 5.31a to 5.31d. This list may have
left out some bugfixes and even some features...void where prohibited, your
mileage may vary, etc., etc.
Greg Roelofs

472
zip/unzip/INSTALL Executable file
View File

@ -0,0 +1,472 @@
__________________________________________________________________________
This is the Info-ZIP file INSTALL (for UnZip), last updated 17 May 97.
__________________________________________________________________________
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).
(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.
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.
If you wish to compile with decryption enabled, you must get the zcrypt
package (see the "Where" file). Unpack crypt.c and crypt.h from the
zcrypt archive, overwriting the dummy versions supplied with UnZip. If
you don't have any sort of unzipper available, you'll have to compile the
non-crypt version first and use that to unpack the full crypt sources,
then recompile.
(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: a few MS-DOS targets are in non-MSDOS make-
files. In particular, for DOS emx+gcc use the gccdos target of the OS/2
makefile (os2/makefile.os2). [The old djgpp, djgpp1 and gcc_dos targets
in unix/Makefile have been removed in 5.3; use msdos/makefile.dj* instead.]
In addition, OS/2 users of MSC can cross-compile to MS-DOS with the mscdos
target in os2/makefile.os2.
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". Thus "*.*.*" could be
used (albeit awkwardly) to specify all filenames with at least one
dot in them, and "*." matches all filenames with no dots in them.
[The default method of specifying these would be "*.*" and "* -x *.*",
respectively, where the second example makes use of UnZip's exclude-
files option.] All other regular expressions (including "?" and
"[range_of_chars]") retain their Unix-like behavior.
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 was added quite late
in the beta cycle and isn't fully tested, so some features may not
work as expected. Also, it doesn't affect options stored in environ-
ment variables (UNZIP_OPTS or ZIPINFO_OPTS); those use the Unix style
regardless.
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 Open-
VMS 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 text files archived with the "-V" option are only semi-readable at
best when extracted on other systems. Defining this option enables
UnZip's -aa option to attempt to convert such files to native text
format. Non-VMS UnZips don't actually detect the precise VMS format
of the files, however, but instead rely on some reasonably good
heuristics (i.e., guesses). Therefore this option is not enabled by
default, but it can be extremely useful on those rare occasions when
a VMS text file must be extracted as normal text.
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.]
TIMESTAMP (default; Unix only for now)
NOTIMESTAMP
This option enables a -T option that 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), except that,
unlike Zip, UnZip supports wildcard specifications for the archive
name: "unzip -T \*.zip" will set the dates of all zipfiles in the
current directory. (UnZip's option is also much faster.)
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. By default it is
disabled so as to generate the smallest possible executable stub, but
for use with automated installation scripts and the like it may be
useful to enable -d.
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.)
LZW_CLEAN (now default)
USE_UNSHRINK
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.) Therefore un-
shrinking is disabled by default, but those with LZW licenses can
enable it by defining USE_UNSHRINK. (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. Note that this
subjects UnZip to any and all restrictions in Smith's copyright; see
the UnZip COPYING file for details.
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 -DOLD_EXDIR
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
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!)
For repeated makes or other hacker-like tinkering with the sources,
or to create a custom version of UnZip (especially with VMSCLI), 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
Think C is the only currently supported compiler, although the Mac
Programmer's Workbench (MPW) was supported at one time and still has
hooks in unzip.h. For Think C, un-BinHex the Think C 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.
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.doc). 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 ".doc". 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
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.
Human68K, TOPS-20, AOS/VS, MVS, VM/CMS, etc.
Dunno, sorry...

171
zip/unzip/README Executable file
View File

@ -0,0 +1,171 @@
This is the README file for the 31 May 1997 (5.31, get it?) public release
of the Info-ZIP group's portable UnZip zipfile-extraction program (and related
utilities).
unzip531.zip portable UnZip, version 5.31, source code distribution
unzip531.tar.Z same as above, but compress'd tar format
unzip531.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, 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);
OS/2, VMS, Unix, RISC OS, Macintosh and BeOS 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.doc 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.31 release includes 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're really *only* for C programmers; they have not been tested with Visual
Basic and need help to work with Borland Delphi. Anything else is Right Out.
INTERNET RESOURCES
------------------
Info-ZIP's web site is at http://www.cdrom.com/pub/infozip/ and contains the
most up-to-date information about coming releases, links to binaries, and
common problems. (See http://www.cdrom.com/pub/infozip/FAQ.html for the
latter.) Files may also be retrieved via ftp://ftp.cdrom.com/pub/infozip/ .
Thanks to Walnut Creek CD-ROM 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, 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.doc 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.) "Dumb questions" that aren't adequately answered in the docu-
mentation should also be directed here 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 sent to info-zip@lists.wku.edu, a
mailing list for the Info-ZIP beta testers, for discussion (the authors
hang out here as well, of course). 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 somewhat short on time.
(Please do NOT send patches or encoded zipfiles to the info-zip address.
Please DO read the ZipPorts file before sending any large patch. It would
be difficult to emphasize this point too much...)
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, VMOS,
VxWorks and Netware ports are 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 sub-archive 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 con-
tributions, etc., send a two-line mail message containing the commands HELP
and LIST (on separate lines in the body of the message, not on the subject
line) to mxserver@lists.wku.edu. You'll receive two messages listing the
various Info-ZIP mailing-list formats that are available (and also various
unrelated lists) and instructions on how to subscribe to one or more of them
(courtesy of Hunter Goatley). As of mid-1997, subscribing to the announce-
ments list requires a command of the form
SUBSCRIBE Info-ZIP-announce "Joe Isuzu"
The discussion list is called Info-ZIP; it can be set for either normal or
digest-style delivery.
-- Greg Roelofs (sometimes known as Cave Newt), principal UnZip developer guy,
with inspiration from David Kirschbaum

111
zip/unzip/ToDo Executable file
View File

@ -0,0 +1,111 @@
================================
For UnZip 6.0/6.1/who knows:
================================
o add multi-part zipfile handling
top of the list for 6.0!
o add new low-level, binary API; rewrite "normal" (command-line) UnZip
to use it
very soon (maybe 6.1)
o use (simple!) configure script in combination with Unix Makefile
very soon
o rewrite to use fread/fseek/etc. [eventually: test
write(bytes) vs. fwrite(words), especially on Crays/Alphas]
soon (in conjunction with multi-part handling, probably)
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
soon
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 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)
=======================================
o miscellaneous little stuff: whenever
--------------------------
- 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 remain mapname() routines
- 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?
- 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?
- add OS/2 .INF format helpfiles for UnZip and ZipInfo?

293
zip/unzip/Where Executable file
View File

@ -0,0 +1,293 @@
__________________________________________________________________________
This is the Info-ZIP file ``Where,'' last updated on 17 May 1997.
__________________________________________________________________________
The latest version of this file can be found online at:
http://www.cdrom.com/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.cdrom.com/pub/infozip/ (and subdirectories thereof) first,
except for encryption sources and binaries, which always appear in
ftp://ftp.icce.rug.nl/infozip/ (and subdirs) 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:
http://www.cdrom.com/pub/infozip/
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:
http://www.cdrom.com/pub/infozip/Zip.html
http://www.cdrom.com/pub/infozip/UnZip.html
The related zlib package by Info-ZIP's Jean-loup Gailly and Mark Adler is at:
http://www.cdrom.com/pub/infozip/zlib/
Source-code archives for Info-ZIP's portable Zip, UnZip, and related
utilities:
zip21.zip Zip 2.1 (deflation; includes zipnote, zipsplit, zipcloak)
zip21.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
unzip531.zip UnZip 5.31 (all methods supported; unzip, funzip, unzipsfx)
unzip531.tar.Z ditto, compress'd tar format
zcrypt27.zip encryption/decryption support for Zip 2.2 and UnZip 5.3x
zcrypt26.zip encryption support for Zip 2.1
zcrypt10.zip encryption support for Zip 1.1
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. See the BBS section below for
special CompuServe (6.3) filenames:
zip21x.zip MSDOS executables and docs (with 386 vers., no encryption)
zcr21x.zip MSDOS executables and docs (with encryption, no 386 vers.)
zip21x1.zip OS/2 1.x (16-bit) executables and docs (no encryption)
zcr21x1.zip OS/2 1.x (16-bit) executables and docs (with encryption)
zip21x2.zip OS/2 2/3/4.x (32-bit) executables and docs (no encryption)
zcr21x2.zip OS/2 2/3/4.x (32-bit) executables and docs (w/encryption)
zip21xA.zip Amiga executables and docs (no encryption)
zcr21xA.zip Amiga executables and docs (with encryption)
zip21xN.zip WinNT/Win95 (Intel) executables and docs (no encryption)
zcr21xN.zip WinNT/Win95 (Intel) executables and docs (with encryption)
zip21xN-axp.zip WinNT (Alpha AXP) executables and docs (no encryption)
zcr21xN-axp.zip WinNT (Alpha AXP) executables and docs (with encryption)
zip21xN-mips.zip WinNT (MIPS) executables and docs (no encryption)
zcr21xN-mips.zip WinNT (MIPS) executables and docs (with encryption)
zip21xN-ppc.zip WinNT (PowerPC) executables and docs (no encryption)
zcr21xN-ppc.zip WinNT (PowerPC) executables and docs (with encryption)
zip21xR.zip Acorn RISC OS executables and docs (no encryption)
zcr21xR.zip Acorn RISC OS executables and docs (with encryption)
zip21xT.zip Atari TOS executables and docs (no encryption)
zcr21xT.zip Atari TOS executables and docs (with encryption)
zip21-vms-axp-obj.zip
VMS (Alpha AXP) object libs, link procedure and docs
zip21-vms-axp-exe.zip
VMS (Alpha AXP) executables for VMS 6.1 or later and docs
zip21-vms-vax-decc-obj.zip
VMS (VAX) object libs (new DEC C), link procedure and docs
zip21-vms-vax-decc-exe.zip
VMS (VAX) executables (DEC C) for VMS 6.1 or later; docs
zip21-vms-vax-vaxc-obj.zip
VMS (VAX) object libs (old VAX C), link procedure and docs
unz531x.exe MSDOS self-extracting executable (16-bit unzip, ..., docs)
unz531x3.exe MSDOS self-extracting executable (16-, 32-bit unzip, docs)
unz531x1.exe OS/2 1.x (16-bit) self-extracting executables and docs
unz531x2.exe OS/2 2/3/4.x (32-bit) self-extracting executables and docs
unz531d2.zip OS/2 2/3/4.x (32-bit) DLL, header file, demo exe and docs
unz531xA.ami Amiga self-extracting executables and docs
unz531xA.lha Amiga executables and docs, LHa archive
unz531xN.exe WinNT/Win95 self-extracting Intel executables and docs
unz531xN-axp.exe WinNT (Alpha AXP) self-extracting executables and docs
unz531xN-mips.exe WinNT (MIPS) self-extracting executables and docs
unz531xN-ppc.exe WinNT (PowerPC) self-extracting executables and docs
unz531xR.exe Acorn RISC OS self-extracting executables and docs
unz531xR.spk Acorn RISC OS Spark'd executables and docs
unz531xT.tos Atari TOS self-extracting executables and docs
unz531x-vms-axp-obj.bck VMS backup saveset,
contains UnZip (Alpha) obj libs, link procedure, docs
unz531x-vms-axp-obj.exe VMS (Alpha AXP) SFX archive (statically linked),
contains UnZip (Alpha) obj libs, link procedure, docs
unz531x-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
unz531x-vms-vax-decc-obj.bck VMS backup saveset,
contains UnZip (new DEC C) obj libs, link procedure, docs
unz531x-vms-vax-decc-obj.exe VMS (VAX) SFX archive (statically linked),
contains UnZip (new DEC C) obj libs, link procedure, docs
unz531x-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
unz531x-vms-vax-vaxc-obj.bck VMS backup saveset,
contains UnZip (old VAX C) obj libs, link procedure, docs
unz531x-vms-vax-vaxc-obj.exe VMS (VAX) SFX archive (statically linked),
contains UnZip (old VAX C) obj libs, link procedure, docs
unz531x.hqx Macintosh BinHex'd executables and docs for unzip
(unz531x.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)
wiz31x.exe WizUnZip 3.1 16-bit (Win3) app+docs (self-extracting)
wiz31xN.exe WizUnZip 3.1 32-bit (Win95/NT) app+docs (self-extracting)
wiz31d.zip WizUnZip 16-bit UnZip 5.2 DLL+docs (no WizUnZip app)
wiz31dN.zip WizUnZip 32-bit UnZip 5.2 DLL+docs (no WizUnZip app)
UnzpHist.zip complete changes-history of UnZip and its precursors
ZipHist.zip complete changes-history of Zip
The latest from PKWARE (the guys who started it all):
pkz204g.exe MS-DOS PKZIP/PKUNZIP 2.04g (self-extracting archive)
pkz110eu.exe MS-DOS PKZIP/PKUNZIP 1.1 (self-extracting)
pkz206-2.exe OS/2 PKZIP/PKUNZIP 2.06 (IBM internal only; same as 2.04g)
pkz102-2.exe OS/2 PKZIP/PKUNZIP 1.02 (self-extracting)
pk250w16.exe Windows 16-bit PKZIP/PKUNZIP 2.50 (self-extracting)
pk250w32.exe Windows 32-bit PKZIP/PKUNZIP 2.50 (self-extracting)
Third-party software that incorporates Info-ZIP code:
OS/2: Warp 3.0 BonusPak, FileJet, The UnZip Shell, zipmeister (PMZip),
ZipFly(?)
NT: WinZip
Windows: Nico Mak WinZip, InnerMedia DynaZIP DLL, NewVision Zip[Shell] Pro,
FlashPoint ZIP Navigator and Unzip95, Z (port of ZipInfo; z101.zip)
MS-DOS: FileJet
Macintosh: ZipIt
generic Unix: lzpip103.zip
Third-party software that uses (or can use) Info-ZIP software:
OS/2: Zip Control, ZiPMe, Workplace Shell UnZip (WUZ), Drop and Zip,
Archive Front End, Archive Manager, Archive Viewer, File Manager/2,
FileStar/2, ZTreeBold, PMZipper, simple zipshell, HyperView, XBBS-OS/2,
LiveWire
MS-DOS: SHEZ archiver shell
NeXTStep 3.x: Opener
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.1.tar.gz instead of zip21.tar.Z.
ftp://ftp.cdrom.com/pub/infozip/ [THE INFO-ZIP HOME SITE]
ftp://ftp.uu.net/pub/archiving/zip/ [MIRRORS THE INFO-ZIP HOME SITE]
ftp://ftp.simtel.net/pub/simtelnet/infozip/ [MIRRORS 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]
ftp://lpuds.oea.ihep.su/ ... ?
ftp/web sites for the encryption and decryption sources and/or executables:
NOTE: Non-US users, please do NOT ftp from the US sites (US regulations
and all that). Likewise, US users, please do not ftp from the European
sites if it can be avoided (it's not illegal, but it is a waste of
expensive trans-Atlantic bandwidth).
From the US:
ftp://ftp.wustl.edu/mirrors/garbo.uwasa.fi/arcers/
Outside the US:
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@informatik.tu-muenchen.de) (?)
ftp://ftp.win.tue.nl/pub/compression/zip/
ftp://ftp.uni-erlangen.de/pub/pc/msdos/arc-utils/zip/
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.
UUCP sites:
uunet!~/pub/archiving/zip/ ...
Bulletin boards (commercial and otherwise):
Sources, MS-DOS executables:
CompuServe IBMPRO forum, Library 10, Data Compression (unz53.zip,
sources; unz53.exe, self-extracting executables and docs)
CompuServe (ZiffNet) PBSUTIL forum and Public Brand Software BBS
[US, membership required; V.32 line, (317) 856-1490]
(unz53.zip, sources; unz53.exe, self-extracting exes and docs)
America Online OS/2 Forum, Free Uploading area; also Top Picks lib-
rary, File/Disk Utilities library, and OS/2 1.x library (do key-
word search via ctrl-K: FILE SEARCH on "INFOZIP")
FidoNet node 1:124/2113, Lunatic Fringe [Richardson, Texas; BBS
(214) 235-5288; sysop john.stewart@lunatic.com; complete mirror
of Info-ZIP home site]
FidoNet node 1:246/74, Metal Shoppe BBS [Windsor, Ontario; CLink
node 911:6510/0; BBS (519) 256-0278; sysop rakey@cyberspace.net
(Ray Akey); micro-based files but no Unix/VMS/NT stuff]
Drealm Conference System [London, UK; V.22bis, subscriber lines
to V.32bis, etc.; (+44) 81 568 2204]
Compulink Information eXchange (CIX) [London, UK; BBS 14.4 and 28.8
lines, (+44) 181 390-1244, -1255 and -9787; executables in "the
filepool," sources in free_software/sources]
Windows sources and executables (filenames, locations not yet final):
CompuServe ZENITH forum (wiz30a.zip, WizUnZip 16-bit version)
CompuServe CRAFTS forum (wiz30b.zip, WizUnZip 32-bit version)
OS/2 executables:
CompuServe OS2USER forum (zip21.zip and unz53.exe, OS/2 16- and
32-bit exes and docs)
Amiga executables:
BIX in AMIGA files section (perform keyword search on "info-zip")
[requires account; telnet bix.com, or "C BIX" via local Sprint
X.25 PAD, or dial direct in US at (617) 491-5410]
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/zcrypt26.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.
__________________________________________________________________________

24
zip/unzip/acorn/Contents Executable file
View File

@ -0,0 +1,24 @@
Contents of the "acorn" subdirectory for UnZip 5.3 and later:
acorn.c.acorn Acorn-specific resources
acorn.c.riscos mainly file-handling routines for FileCore-based filesystems
acorn.Contents this file
acorn.h.riscos
acorn.h.swiven
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.

57
zip/unzip/acorn/ReadMe Executable file
View File

@ -0,0 +1,57 @@
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, a la
DOSFILE.TXT, unix-filename.tar.gz . What was decided that they would
be extracted as DOSFILE/TXT and unix-filename/tar/gz, and then truncated
to 10-characters, for FileCore compliance. This can quickly be altered
for any new releases of FileCore that Acorn may make for longer filenames.
Unfortunately, this means that 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".
To cope with this, a colon-separated environment variable has been
set up called "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"
will extract all the files called 'foo.c' to a directory called '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).

17
zip/unzip/acorn/RunMe1st Executable file
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

749
zip/unzip/acorn/acorn.c Executable file
View File

@ -0,0 +1,749 @@
/*---------------------------------------------------------------------------
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()
isRISCOSexfield()
setRISCOSexfield()
printRISCOSexfield()
close_outfile()
version()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "^.unzip.h"
#include "riscos.h"
#define FTYPE_FFF (1<<17) /* set filetype to &FFF when extracting */
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
extern int mkdir(char *path, int mode);
#ifndef SFX
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
/**********************/
char *do_wild(__G__ wildspec)
__GDEF
char *wildspec; /* only used first time on a given dir */
{
static DIR *dir = (DIR *)NULL;
static char *dirname, *wildname, matchname[FILNAMSIZ];
static int firstcall=TRUE, 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 (firstcall) { /* first call: must initialize everything */
firstcall = FALSE;
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '.')) == (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: can't allocate wildcard buffers\n"));
strcpy(matchname, wildspec);
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(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)) { /* 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(dir);
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) */
strcpy(matchname, wildspec);
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (dir == (DIR *)NULL) {
firstcall = TRUE; /* 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(dir)) != (struct dirent *)NULL)
if (match(file->d_name, wildname, 0)) { /* 0 == don't ignore case */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
closedir(dir); /* have read at least one dir entry; nothing left */
dir = (DIR *)NULL;
firstcall = TRUE; /* 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 UNIX_:
case VMS_:
case ACORN_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
break;
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case ATARI_: /* (used to set = 0666) */
case TOPS20_:
default:
tmp = !(tmp & 1) << 1; /* read-only bit --> write perms bits */
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 (G.filename[strlen(G.filename)-4]==',') {
int ftype=strtol(G.filename+strlen(G.filename)-3,NULL,16)&0xFFF;
G.pInfo->file_attr&=0x000FFFFF;
G.pInfo->file_attr|=(ftype<<20);
}
else if (G.crec.internal_file_attributes & 1) {
G.pInfo->file_attr&=0x000FFFFF;
G.pInfo->file_attr|=(0xFFFu<<20);
}
return 0;
} /* end function mapattr() */
/************************/
/* Function mapname() */
/************************/
/* return 0 if no error, 1 if caution (filename */
int mapname(__G__ renamed) /* truncated), 2 if warning (skip file because */
__GDEF /* dir doesn't exist), 3 if error (skip file), */
int renamed; /* or 10 if out of memory (skip file) */
{ /* [also IZ_VOL_LABEL, IZ_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 quote = FALSE; /* flags */
int error = 0;
register unsigned workch; /* hold the character being tested */
char *checkswap=NULL; /* pointer the the extension to check or NULL */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return IZ_VOL_LABEL; /* can't set disk volume labels in Unix */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!G.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) == 10)
return 10; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (G.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) {
if (quote) { /* if character quoted, */
*pp++ = (char)workch; /* include it literally */
quote = FALSE;
} else
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if ((error = checkdir(__G__ pathcomp, APPEND_DIR)) > 1)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave directory semi-colons alone */
checkswap=NULL; /* reset checking when starting a new leafname */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
case '\026': /* control-V quote for special chars */
quote = TRUE; /* set flag for next character */
break;
case ' ': /* change spaces to hard-spaces */
*pp++ = 160;
break;
case ':': /* change ':' to '¦' */
*pp++ = '¦';
break;
case '&': /* change '&' to 'E' */
*pp++ = 'E';
break;
case '@': /* change '@' to 'A' */
*pp++ = 'A';
break;
case '.':
*pp++ = '/';
checkswap=pp;
break;
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!G.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
/*---------------------------------------------------------------------------
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",
G.filename));
}
return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
}
return 2; /* dir existed already; don't look for data to extract */
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
G.filename));
return 3;
}
if (checkswap!=NULL) {
if (checkext(checkswap)) {
if ((error = checkdir(__G__ checkswap, APPEND_DIR)) > 1)
return error;
*(checkswap-1)=0; /* remove extension from pathcomp */
}
}
if (pathcomp[strlen(pathcomp)-4]==',') {
/* remove the filetype extension */
/* 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: 1 - (on APPEND_NAME) truncated filename
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - 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", 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. */
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 2; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
fflush(stderr);
free(buildpath);
return 4; /* no room for filenames: fatal */
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: can't create %s\n\
unable to process %s.\n", buildpath, G.filename));
free(buildpath);
return 3; /* path didn't exist, tried to create, failed */
}
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", buildpath, G.filename));
free(buildpath);
return 3; /* path existed but wasn't dir */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
*end++ = '.'; /************* was '/' *************/
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0;
} /* 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", pathcomp));
free(buildpath);
buildpath = end = (char *)NULL;
return 0;
}
/*---------------------------------------------------------------------------
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", 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", G.filename, buildpath));
return 1; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0; /* could check for existence here, prompt for new name... */
}
/*---------------------------------------------------------------------------
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 10;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", buildpath));
return 0;
}
/*---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------*/
#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 0;
}
if ((rootlen = strlen(pathcomp)) > 0) {
if (pathcomp[rootlen-1] == '.') { /****** was '/' ********/
pathcomp[--rootlen] = '\0';
}
if (rootlen > 0 && (stat(pathcomp, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))) {
/* path does not exist */
if (!G.create_dirs /* || isshexp(pathcomp) */ ) {
rootlen = 0;
return 2; /* skip (or treat as stored file) */
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (mkdir(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: can't create extraction directory: %s\n",
pathcomp));
rootlen = 0; /* path didn't exist, tried to create, and */
return 3; /* failed: file exists, or 2+ levels required */
}
}
if ((rootpath = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return 10;
}
strcpy(rootpath, pathcomp);
rootpath[rootlen++] = '.'; /*********** was '/' *************/
rootpath[rootlen] = '\0';
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return 0;
}
#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);
return 0;
}
return 99; /* should never reach */
} /* end function checkdir() */
/********************/
/* Function mkdir() */
/********************/
int mkdir(path, mode)
char *path;
int mode; /* ignored */
/*
* returns: 0 - successful
* -1 - failed (errno not set, however)
*/
{
return (SWI_OS_File_8(path) == NULL)? 0 : -1;
}
/*********************************/
/* extra_field-related functions */
/*********************************/
int isRISCOSexfield(void *extra_field)
{
if (extra_field!=NULL) {
extra_block *block=(extra_block *)extra_field;
return(block->ID==SPARKID && (block->size==24 || block->size==20) && block->ID_2==SPARKID_2);
}
else
return FALSE;
}
void setRISCOSexfield(char *path, void *extra_field)
{
if (extra_field!=NULL) {
extra_block *block=(extra_block *)extra_field;
SWI_OS_File_1(path,block->loadaddr,block->execaddr,block->attr);
}
}
void printRISCOSexfield(int isdir, 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");
}
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
{
fclose(G.outfile);
if (isRISCOSexfield(G.extra_field)) {
setRISCOSexfield(G.filename, G.extra_field);
}
else {
int loadaddr,execaddr,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 &&
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
&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_file_date,
G.lrec.last_mod_file_time);
/* set the file's modification time */
SWI_OS_File_5(G.filename,NULL,&loadaddr,NULL,NULL,&attr);
loadaddr=0xfff00000U | ((((m_time>>8) * 100)>>24) + 0x33);
execaddr=m_time * 100 + 0x6e996a00U;
loadaddr|=((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() */
#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 */

114
zip/unzip/acorn/makefile Executable file
View File

@ -0,0 +1,114 @@
# Makefile for UnZip, UnZipSFX, ZipInfo and fUnZip (5.2 or later)
# last modified: 18 Apr 96
# 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 =
CFLAGS = -throwback -wn
CFLAGS = $(CFLAGS) -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 crypt_.o globals_.o inflate_.o ttyio_.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 version.h consts.h
zipinfo.o: zipinfo.c $(UNZIP_H)
crypt_.o: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) $(CFLAGS) -DFUNZIP -c c.crypt -o o.crypt_
extract_.o: extract.c $(UNZIP_H) crypt.h
$(CC) $(CFLAGS) -DSFX -c c.extract -o o.extract_
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 version.h consts.h
$(CC) $(CFLAGS) -DSFX -c c.unzip -o o.unzipsfx
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

350
zip/unzip/acorn/riscos.c Executable file
View File

@ -0,0 +1,350 @@
/* 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 = ""; /* Extensions to swap (actually, directory names) */
int stat(char *filename,struct stat *res)
{
int attr; /* object attributes */
int load; /* load address */
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 (G.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 && !G.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);
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 || (!G.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;
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);
}

123
zip/unzip/acorn/riscos.h Executable file
View File

@ -0,0 +1,123 @@
/* 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 {
int load_addr;
int exec_addr;
int lenght;
int attrib;
int objtype;
char name[13];
} riscos_direntry;
#define SPARKID 0x4341 /* = "AC" */
#define SPARKID_2 0x30435241 /* = "ARC0" */
typedef struct {
short ID;
short size;
int ID_2;
int loadaddr;
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>
# define DATE_FORMAT DF_DMY
# 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
# 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

BIN
zip/unzip/acorn/srcrename Executable file

Binary file not shown.

53
zip/unzip/acorn/swiven.h Executable file
View File

@ -0,0 +1,53 @@
/* 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, int loadaddr, int execaddr, int attrib);
/* write file attributes */
os_error *SWI_OS_File_5(char *filename, int *objtype, int *loadaddr,
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_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) */
#endif

281
zip/unzip/acorn/swiven.s Executable file
View File

@ -0,0 +1,281 @@
; 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
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_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
END

72
zip/unzip/amiga/Contents Executable file
View File

@ -0,0 +1,72 @@
Contents of the "amiga" directory for UnZip 5.3 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)
mkGoff.c source for MkGoff which generates include file used by flate.a
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.20 neither of these wants args in
registers.
The DICE makefile has been removed since no one is supporting that
compiler anymore.
It was discovered on release of UnZip 5.1 that the latest SAS compiler
revision (6.50 or 6.51) changed the timezone handling. The result is
that UnZip can extract files with the wrong times, usually off by an
offset of a few hours which is a function of the how the TZ environment
variable is set. Now the TZ variable needs to be set according to the
timezone you are in, because the tzname() function operates correctly
now (it didn't used to). In UnZip 5.2, handling of the TZ variable is now
independent of the compiler library used in creating UnZip.
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. To set the TZ environment variable, place the following line in your
startup sequence:
setenv TZ XXXNYYY
where XXX is the 3-character timezone notation
N is the offset from Greenwich mean time
YYY is an optional 3-character daylight savings notation
example:
setenv TZ PST8PDT ; for California time
Daylight savings time is currently handled according to United States
calendar rules only -- one hour's difference starting on the first Sunday
in April and ending on the last Sunday in October. If you set TZ with no
characters after the number, for example "MST7", then daylight savings will
not be applied. (This would be a valid setting for Arizona.) If the
timezone is derived from your Locale preferences, daylight savings time is
applied if the time zone is in the Americas, otherwise not. Fractional
hours can be indicated by putting minutes after the hours offset, like
this: "NST3:30NDT", which might be used for Newfoundland. The exact text
before and after the number does not matter; the only thing that is checked
is whether the optional second part is present or absent. UnZip 5.1 and
older had no daylight savings support at all.
Timezone translation will have no effect on files which are zipped on
MS-DOS or similar systems which only store a local timestamp without time
zone information. Archives from Unix systems, and some others, include
timestamps given in universal (Greenwich) time. Such timestamps will be
converted according to the local time zone. Amiga Zip can, if desired, be
compiled to produce such Unix-style timestamps, but by default it does not.

845
zip/unzip/amiga/amiga.c Executable file
View File

@ -0,0 +1,845 @@
/*------------------------------------------------------------------------
amiga.c
Amiga-specific routines for use with Info-ZIP's UnZip 5.1 and later.
See History.5xx for revision history.
Contents: mapattr()
mapname()
do_wild()
checkdir()
close_outfile()
_abort() (Aztec C only)
[dateformat()] (currently not used)
windowheight()
version()
------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
/* Globular varibundus -- now declared in SYSTEM_SPECIFIC_GLOBALS in amiga.h */
/* static int created_dir; */ /* used in mapname(), checkdir() */
/* static int renamed_fullpath; */ /* ditto */
#define PERMS 0777
#define MKDIR(path,mode) mkdir(path)
#ifndef S_ISCRIPT /* not having one implies you have none */
# define S_IARCHIVE 0020 /* not modified since this bit was last set */
# define S_IREAD 0010 /* can be opened for reading */
# define S_IWRITE 0004 /* can be opened for writing */
# define S_IDELETE 0001 /* can be deleted */
#endif /* S_ISCRIPT */
#ifndef S_IRWD
# define S_IRWD 0015 /* useful combo of Amiga privileges */
#endif /* !S_IRWD */
#ifndef S_IHIDDEN
# define S_IHIDDEN 0200 /* hidden supported in future AmigaDOS (someday) */
#endif /* !S_HIDDEN */
#ifndef SFX
/* Make sure the number here matches version.h in the *EXACT* form */
/* UZ_MAJORVER "." UZ_MINORVER PATCHLEVEL vvvv No non-digits! */
const char version_id[] = "\0$VER: UnZip 5.30 ("
#include "env:VersionDate"
")\r\n";
#endif /* SFX */
/**********************/
/* Function mapattr() */
/**********************/
int mapattr(__G) /* Amiga version */
__GDEF
{
ulg tmp = G.crec.external_file_attributes;
/* Amiga attributes = hsparwed = hidden, script, pure, archive,
* read, write, execute, delete */
switch (G.pInfo->hostnum) {
case AMIGA_:
if ((tmp & 1) == (tmp>>18 & 1))
tmp ^= 0x000F0000; /* PKAZip compatibility kluge */
/* turn off archive bit for restored Amiga files */
G.pInfo->file_attr = (unsigned)((tmp>>16) & (~S_IARCHIVE));
break;
case UNIX_: /* preserve read, write, execute: use logical-OR of */
case VMS_: /* user, group, and other; if writable, set delete bit */
tmp >>= 16;
tmp = (( tmp>>6 | tmp>>3 | tmp) & 07) << 1;
G.pInfo->file_attr = (unsigned)(tmp&S_IWRITE? tmp|S_IDELETE : tmp);
break;
/* all other platforms: assume read-only bit in DOS half of attribute
* word is set correctly ==> will become READ or READ+WRITE+DELETE */
case FS_FAT_:
case FS_HPFS_: /* can add S_IHIDDEN check to MSDOS/OS2/NT eventually */
case FS_NTFS_:
case MAC_:
case ATARI_:
case TOPS20_:
default:
G.pInfo->file_attr = (unsigned)(tmp&1? S_IREAD : S_IRWD);
break;
} /* end switch (host-OS-created-by) */
G.pInfo->file_attr &= 0xff; /* mask off all but lower eight bits */
return 0;
} /* end function mapattr() */
/************************/
/* Function mapname() */
/************************/
int mapname(__G__ renamed) /* return 0 if no error, 1 if caution (truncate), */
__GDEF /* 2 if warning (skip because dir doesn't exist), */
int renamed; /* 3 if error (skip file), 10 if no memory (skip) */
{ /* [also IZ_CREATED_DIR] */
char pathcomp[FILNAMSIZ]; /* path-component buffer */
char *pp, *cp=NULL; /* character pointers */
char *lastsemi = NULL; /* pointer to last semi-colon in pathcomp */
int error = 0;
register unsigned workch; /* hold the character being tested */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!G.fflag || renamed);
G.created_dir = FALSE; /* not yet */
/* user gave full pathname: don't prepend G.rootpath */
G.renamed_fullpath = (renamed && strchr(G.filename, ':'));
if (checkdir(__G__ (char *)NULL, INIT) == 10)
return 10; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (G.jflag) /* junking directories */
cp = (char *)strrchr(G.filename, '/');
if (cp == 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)) > 1)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = NULL; /* leave directory semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp; /* keep for now; remove VMS ";##" */
*pp++ = (char)workch; /* later, if requested */
break;
default:
/* allow ISO European characters in filenames: */
if (isprint(workch) || (160 <= workch && workch <= 255))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove with VMS version numbers (appended ";###") */
if (!G.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
/*---------------------------------------------------------------------------
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 (G.created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, " creating: %s\n",
G.filename));
}
return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
}
return 2; /* dir existed already; don't look for data to extract */
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
G.filename));
return 3;
}
if ((error = checkdir(__G__ pathcomp, APPEND_NAME)) == 1) {
/* GRR: OK if truncated here: warn and continue */
/* (warn in checkdir?) */
}
checkdir(__G__ G.filename, GETPATH);
return error;
} /* end function mapname() */
static int ispattern(char *p)
{
register char c;
while (c = *p++)
if (c == '\\') {
if (!*++p)
return FALSE;
} else if (c == '?' || c == '*')
return TRUE;
else if (c == '[') {
for (;;) {
if (!(c = *p++))
return FALSE;
else if (c == '\\') {
if (!*++p)
return FALSE;
} else if (c == ']')
return TRUE;
}
}
return FALSE;
}
/**********************/
/* Function do_wild() */
/**********************/
char *do_wild(__G__ wildspec)
__GDEF
char *wildspec; /* only used first time on a given dir */
{
/* these statics are now declared in SYSTEM_SPECIFIC_GLOBALS in amiga.h:
static DIR *wild_dir = NULL;
static char *dirname, *wildname, matchname[FILNAMSIZ];
static int notfirstcall = FALSE, dirnamelen;
*/
struct dirent *file;
BPTR lok = 0;
/* 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 (!G.notfirstcall) { /* first call: must initialize everything */
G.notfirstcall = TRUE;
/* avoid needless readdir() scans: */
if (!ispattern(wildspec) || (lok = Lock(wildspec, ACCESS_READ))) {
if (lok) UnLock(lok); /* ^^ we ignore wildcard chars if */
G.dirnamelen = 0; /* the name matches a real file */
strcpy(G.matchname, wildspec);
return G.matchname;
}
/* break the wildspec into a directory part and a wildcard filename */
if ((G.wildname = strrchr(wildspec, '/')) == NULL
&& (G.wildname = strrchr(wildspec, ':')) == NULL) {
G.dirname = ""; /* current dir */
G.dirnamelen = 0;
G.wildname = wildspec;
} else {
++G.wildname; /* point at character after '/' or ':' */
G.dirnamelen = G.wildname - wildspec;
if ((G.dirname = (char *)malloc(G.dirnamelen+1)) == NULL) {
Info(slide, 1, ((char *)slide,
"warning: can't allocate wildcard buffers\n"));
strcpy(G.matchname, wildspec);
return G.matchname; /* but maybe filespec was not a wildcard */
}
strncpy(G.dirname, wildspec, G.dirnamelen);
G.dirname[G.dirnamelen] = 0;
}
if ((G.wild_dir = opendir(G.dirname)) != NULL) {
while ((file = readdir(G.wild_dir)) != NULL) {
if (match(file->d_name, G.wildname, 1)) { /* ignore case */
strcpy(G.matchname, G.dirname);
strcpy(G.matchname + G.dirnamelen, file->d_name);
return G.matchname;
}
}
/* if we get to here directory is exhausted, so close it */
closedir(G.wild_dir);
G.wild_dir = NULL;
}
/* return the raw wildspec in case that works (e.g., directory not
* searchable, but filespec was not wild and file is readable) */
strcpy(G.matchname, wildspec);
return G.matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (G.wild_dir == NULL) {
G.notfirstcall = FALSE; /* nothing left to try -- reset */
if (G.dirnamelen > 0)
free(G.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(G.wild_dir)) != NULL)
if (match(file->d_name, G.wildname, 1)) { /* 1 == ignore case */
/* strcpy(G.matchname, dirname); */
strcpy(G.matchname + G.dirnamelen, file->d_name);
return G.matchname;
}
closedir(G.wild_dir); /* have read at least one dir entry; nothing left */
G.wild_dir = NULL;
G.notfirstcall = FALSE; /* reset for new wildspec */
if (G.dirnamelen > 0)
free(G.dirname);
return (char *)NULL;
} /* end function do_wild() */
/***********************/
/* Function checkdir() */
/***********************/
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns: 1 - (on APPEND_xxx) truncated path component
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - can't allocate memory for filename buffers
*/
{
/* these statics are now declared in SYSTEM_SPECIFIC_GLOBALS in amiga.h: */
/* 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.
---------------------------------------------------------------------------*/
/* GRR: check path length after each segment: warn about truncation */
if (FUNCTION == APPEND_DIR) {
int too_long = FALSE;
Trace((stderr, "appending dir segment [%s]\n", pathcomp));
while ((*G.build_end = *pathcomp++))
++G.build_end;
/* Truncate components over 30 chars? Nah, the filesystem handles it. */
if ((G.build_end-G.buildpath) > FILNAMSIZ-3) /* room for "/a\0" */
too_long = TRUE; /* check if extracting directory? */
if (stat(G.buildpath, &G.statbuf)) { /* path doesn't exist */
if (!G.create_dirs) { /* told not to create (freshening) */
free(G.buildpath);
return 2; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", G.buildpath));
free(G.buildpath);
return 4; /* no room for filenames: fatal */
}
if (MKDIR(G.buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: can't create %s\n\
unable to process %s.\n", G.buildpath, G.filename));
free(G.buildpath);
return 3; /* path didn't exist, tried to create, failed */
}
G.created_dir = TRUE;
} else if (!S_ISDIR(G.statbuf.st_mode)) {
Info(slide, 1, ((char *)slide,
"checkdir error: %s exists but is not a directory\n\
unable to process %s.\n", G.buildpath, G.filename));
free(G.buildpath);
return 3; /* path existed but wasn't dir */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", G.buildpath));
free(G.buildpath);
return 4; /* no room for filenames: fatal */
}
*G.build_end++ = '/';
*G.build_end = '\0';
Trace((stderr, "buildpath now = [%s]\n", G.buildpath));
return 0;
} /* end if (FUNCTION == APPEND_DIR) */
/*---------------------------------------------------------------------------
GETPATH: copy full path to the string pointed at by pathcomp, and free
G.buildpath. Not our responsibility to worry whether pathcomp has room.
---------------------------------------------------------------------------*/
if (FUNCTION == GETPATH) {
strcpy(pathcomp, G.buildpath);
Trace((stderr, "getting and freeing path [%s]\n", pathcomp));
free(G.buildpath);
G.buildpath = G.build_end = NULL;
return 0;
}
/*---------------------------------------------------------------------------
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", pathcomp));
while ((*G.build_end = *pathcomp++)) {
++G.build_end;
if ((G.build_end-G.buildpath) >= FILNAMSIZ) {
*--G.build_end = '\0';
Info(slide, 1, ((char *)slide,
"checkdir warning: path too long; truncating\n\
%s\n -> %s\n", G.filename, G.buildpath));
return 1; /* filename truncated */
}
}
Trace((stderr, "buildpath static now = [%s]\n", G.buildpath));
return 0; /* could check for existence here, prompt for new name... */
}
/*---------------------------------------------------------------------------
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 static to "));
if ((G.buildpath = (char *)malloc(strlen(G.filename)+G.rootlen+1))
== NULL)
return 10;
if ((G.rootlen > 0) && !G.renamed_fullpath) {
strcpy(G.buildpath, G.rootpath);
G.build_end = G.buildpath + G.rootlen;
} else {
*G.buildpath = '\0';
G.build_end = G.buildpath;
}
Trace((stderr, "[%s]\n", G.buildpath));
return 0;
}
/*---------------------------------------------------------------------------
ROOT: if appropriate, store the path in G.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 == NULL) {
G.rootlen = 0;
return 0;
}
if ((G.rootlen = strlen(pathcomp)) > 0) {
if (stat(pathcomp, &G.statbuf) || !S_ISDIR(G.statbuf.st_mode)) {
/* path does not exist */
if (!G.create_dirs) {
G.rootlen = 0;
return 2; /* treat as stored file */
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (MKDIR(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: can't create extraction directory: %s\n",
pathcomp));
G.rootlen = 0; /* path didn't exist, tried to create, and */
return 3; /* failed: file exists, or 2+ levels required */
}
}
if ((G.rootpath = (char *)malloc(G.rootlen+2)) == NULL) {
G.rootlen = 0;
return 10;
}
strcpy(G.rootpath, pathcomp);
if (G.rootpath[G.rootlen-1] != ':' && G.rootpath[G.rootlen-1] != '/')
G.rootpath[G.rootlen++] = '/';
G.rootpath[G.rootlen] = '\0';
Trace((stderr, "rootpath now = [%s]\n", G.rootpath));
}
return 0;
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
END: free G.rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (G.rootlen > 0)
free(G.rootpath);
return 0;
}
return 99; /* should never reach */
} /* end function checkdir() */
/**************************************/
/* Function close_outfile() */
/**************************************/
/* this part differs slightly with Zip */
/*-------------------------------------*/
void close_outfile(__G)
__GDEF
{
time_t m_time;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
LONG FileDate();
if (G.cflag) /* can't set time or filenote on stdout */
return;
/* close the file *before* setting its time under AmigaDos */
fclose(G.outfile);
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
&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 {
/* Convert DOS time to time_t format */
m_time = dos_to_unix_time(G.lrec.last_mod_file_date,
G.lrec.last_mod_file_time);
}
#else /* !USE_EF_UT_TIME */
/* Convert DOS time to time_t format */
m_time = dos_to_unix_time(G.lrec.last_mod_file_date,
G.lrec.last_mod_file_time);
#endif /* ?USE_EF_UT_TIME */
#ifdef DEBUG
Info(slide, 1, ((char *)slide, "\nclose_outfile(): m_time=%s\n",
ctime(&m_time)));
#endif
if (!FileDate(G.filename, &m_time))
Info(slide, 1, ((char *)slide,
"warning: can't set the time for %s\n", G.filename));
/* set file perms after closing (not done at creation)--see mapattr() */
chmod(G.filename, G.pInfo->file_attr);
/* give it a filenote from the zipfile comment, if appropriate */
if (G.N_flag && G.filenotes[G.filenote_slot]) {
SetComment(G.filename, G.filenotes[G.filenote_slot]);
free(G.filenotes[G.filenote_slot]);
G.filenotes[G.filenote_slot] = NULL;
}
} /* end function close_outfile() */
/********************************************************************/
/* Load filedate as a separate external file; it's used by Zip, too.*/
/* */
#include "amiga/filedate.c" /* */
/* */
/********************************************************************/
/********************* do linewise with stat.c **********************/
# include "amiga/stat.c"
/* this is the exact same stat.c used by Zip */
# include <stdio.h>
void _abort(void) /* called when ^C is pressed */
{
/* echon(); */
close_leftover_open_dirs();
fflush(stdout);
fputs("\n^C\n", stderr);
exit(1);
}
/**************************************************************/
/* function windowheight() -- uses sendpkt() from filedate.c: */
/**************************************************************/
#include <devices/conunit.h>
#include <dos/dosextens.h>
#include <exec/memory.h>
#include <clib/exec_protos.h>
extern long sendpkt(struct MsgPort *pid, long action, long *args, long nargs);
int windowheight(BPTR fh)
{
if (fh && IsInteractive(fh)) {
struct ConUnit *conunit = NULL;
void *conp = ((struct FileHandle *) (fh << 2))->fh_Type;
struct InfoData *ind = AllocMem(sizeof(*ind), MEMF_PUBLIC);
long argp = ((unsigned long) ind) >> 2;
if (ind && conp && sendpkt(conp, ACTION_DISK_INFO, &argp, 1))
conunit = (void *) ((struct IOStdReq *) ind->id_InUse)->io_Unit;
if (ind)
FreeMem(ind, sizeof(*ind));
if (conunit)
return conunit->cu_YMax + 1;
}
return INT_MAX;
}
#ifdef AMIGA_VOLUME_LABELS
/* This function is for if we someday implement -$ on the Amiga. */
# include <dos/dosextens.h>
# include <dos/filehandler.h>
# include <clib/macros.h>
BOOL is_floppy(char *path)
{
BOOL okay = FALSE;
char devname[32], *debna;
ushort i;
BPTR lok = Lock(path, ACCESS_READ), pok;
struct FileSysStartupMsg *fart;
struct DeviceNode *debb, devlist = (void *) BADDR((struct DosInfo *)
BADDR(DOSBase->dl_Root->rn_Info)->di_DevInfo);
if (!lok)
return FALSE; /* should not happen */
if (pok = ParentDir(path)) {
UnLock(lok);
UnLock(pok);
return FALSE; /* it's not a root directory path */
}
Forbid();
for (debb = devlist; debb; debb = BADDR(debb->dn_Next))
if (debb->dn_Type == DLT_DEVICE && (debb->dn_Task == lick->fl_Task))
if (fart = BADDR(debb->dn_Startup)) {
debna = (char *) BADDR(fart->fssm_Device) + 1;
if ((i = debna[-1]) > 31) i = 30;
strncpy(devname, debna, i);
devname[i] = 0;
okay = !strcmp(devname, "trackdisk.device")
|| !strcmp(devname, "mfm.device")
|| !strcmp(devname, "messydisk.device");
break; /* We only support obvious floppy drives, not tricky */
} /* things like removable cartrige hard drives, or */
Permit(); /* any unusual kind of floppy device driver. */
return okay;
}
#endif /* AMIGA_VOLUME_LABELS */
#ifndef SFX
# if 0
/* As far as I can tell, all the locales AmigaDOS 2.1 knows about all */
/* happen to use DF_MDY ordering, so there's no point in using this. */
/*************************/
/* Function dateformat() */
/*************************/
#include <clib/locale_protos.h>
#ifdef AZTEC_C
# include <pragmas/locale_lib.h>
#endif
int dateformat()
{
/*---------------------------------------------------------------------------
For those operating systems which support it, this function returns a
value which tells how national convention says that numeric dates are
displayed. Return values are DF_YMD, DF_DMY and DF_MDY (the meanings
should be fairly obvious).
---------------------------------------------------------------------------*/
struct Library *LocaleBase;
struct Locale *ll;
int result = DF_MDY; /* the default */
if ((LocaleBase = OpenLibrary("locale.library", 0))) {
if (ll = OpenLocale(NULL)) {
uch *f = ll->loc_ShortDateFormat;
/* In this string, %y|%Y is year, %b|%B|%h|%m is month, */
/* %d|%e is day day, and %D|%x is short for mo/da/yr. */
if (!strstr(f, "%D") && !strstr(f, "%x")) {
uch *da, *mo, *yr;
if (!(mo = strstr(f, "%b")) && !(mo = strstr(f, "%B"))
&& !(mo = strstr(f, "%h")))
mo = strstr(f, "%m");
if (!(da = strstr(f, "%d")))
da = strstr(f, "%e");
if (!(yr = strstr(f, "%y")))
yr = strstr(f, "%Y");
if (yr && yr < mo)
result = DF_YMD;
else if (da && da < mo)
result = DF_DMY;
}
CloseLocale(ll);
}
CloseLibrary(LocaleBase);
}
return result;
}
# endif /* 0 */
/************************/
/* Function version() */
/************************/
/* NOTE: the following include depends upon the environment
* variable $Workbench to be set correctly. (Set by
* default, by kickstart during startup)
*/
int WBversion = (int)
#include "ENV:Workbench"
;
void version(__G)
__GDEF
{
/* Define buffers. */
char buf1[16]; /* compiler name */
char buf2[16]; /* revstamp */
char buf3[16]; /* OS */
char buf4[16]; /* Date */
/* char buf5[16]; /* Time */
/* format "with" name strings */
#ifdef AMIGA
# ifdef __SASC
strcpy(buf1,"SAS/C ");
# else
# ifdef LATTICE
strcpy(buf1,"Lattice C ");
# else
# ifdef AZTEC_C
strcpy(buf1,"Manx Aztec C ");
# else
strcpy(buf1,"UNKNOWN ");
# endif
# endif
# endif
/* "under" */
sprintf(buf3,"AmigaDOS v%d",WBversion);
#else
strcpy(buf1,"Unknown compiler ");
strcpy(buf3,"Unknown OS");
#endif
/* Define revision, date, and time strings.
* NOTE: Do not calculate run time, be sure to use time compiled.
* Pass these strings via your makefile if undefined.
*/
#if defined(__VERSION__) && defined(__REVISION__)
sprintf(buf2,"version %d.%d",__VERSION__,__REVISION__);
#else
# ifdef __VERSION__
sprintf(buf2,"version %d",__VERSION__);
# else
sprintf(buf2,"unknown version");
# endif
#endif
#ifdef __DATE__
sprintf(buf4," on %s",__DATE__);
#else
strcpy(buf4," unknown date");
#endif
/******
#ifdef __TIME__
sprintf(buf5," at %s",__TIME__);
#else
strcpy(buf5," unknown time");
#endif
******/
/* Print strings using "CompiledWith" mask defined in unzip.c (used by all).
* ("Compiled with %s%s under %s%s%s%s.")
*/
printf(LoadFarString(CompiledWith),
buf1,
buf2,
buf3,
buf4,
"", /* buf5 not used */
"" ); /* buf6 not used */
} /* end function version() */
#endif /* !SFX */

140
zip/unzip/amiga/amiga.h Executable file
View File

@ -0,0 +1,140 @@
/* 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 unzip.h
*
*/
#ifndef __amiga_amiga_h
#define __amiga_amiga_h
#include <time.h>
#include <fcntl.h>
#include <limits.h>
#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
# include "amiga/z-stat.h" /* substitute for <stat.h> and <direct.h> */
# define direct dirent
# define DECLARE_TIMEZONE
# define ASM_INFLATECODES
# define ASM_CRC
/* 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/stat.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 */
#if 0 /* disabled for now - we don't have alloc_remember() yet */
/* SAS/C built-in getenv() calls malloc to store the envvar string. */
/* Therefore we need to remember the allocation in order to free it later */
# include <stdlib.h> /* getenv() prototype in stdlib.h */
# ifdef getenv
# undef getenv /* remove previously preprocessor symbol */
# endif
# ifndef MWDEBUG
/* # define getenv(name) ((char *)remember_alloc((zvoid *)getenv(name))) */
# else /* MWGetEnv() ripped from memlib's memwatch.h */
# define getenv(name) ((char *)remember_alloc((zvoid *)MWGetEnv(name, __FILE__, __LINE__)))
# endif
#endif /* 0 */
#endif /* SASC */
#define MALLOC_WORK
#define USE_EF_UT_TIME
#define AMIGA_FILENOTELEN 80
#define DATE_FORMAT DF_MDY
#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 */
LONG FileDate (char *, time_t[]);
void tzset(void);
int windowheight (BPTR fh);
void _abort(void); /* ctrl-C trap */
#define SCREENLINES windowheight(Output())
/* Static variables that we have to add to struct Globals: */
#define SYSTEM_SPECIFIC_GLOBALS \
int N_flag;\
int filenote_slot;\
char *(filenotes[DIR_BLKSIZ]);\
int created_dir, renamed_fullpath, rootlen;\
char *rootpath, *buildpath, *build_end;\
DIR *wild_dir;\
char *dirname, *wildname, matchname[FILNAMSIZ];\
int dirnamelen, notfirstcall;
/* N_flag, filenotes[], and filenote_slot are for the -N option that */
/* restores zipfile comments 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 */

671
zip/unzip/amiga/filedate.c Executable file
View File

@ -0,0 +1,671 @@
/* Low-level Amiga routines shared between Zip and UnZip.
*
* Contains: FileDate()
* set_TZ() [SAS/C only]
* locale_TZ()
* getenv() [Aztec C only; replaces bad C library versions]
* tzset() [ditto]
* gmtime() [ditto]
* localtime() [ditto]
* time() [ditto]
* mkgmtime()
* sendpkt()
* Agetch()
*
* The first five are used by all 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 windowheight() 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.
*/
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <exec/types.h>
#include <exec/execbase.h>
#include <exec/memory.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"
#if 0 /* remember_alloc currently unavailable */
# ifdef getenv
# undef getenv /* remove previously preprocessor symbol */
# endif
# define getenv(name) ((char *)remember_alloc((zvoid *)MWGetEnv(name, __FILE__, __LINE__)))
#endif
# endif /* MWDEBUG */
#endif
#ifndef OF
#define OF(x) x /* so crypt.h prototypes compile okay */
#endif
#if defined(ZIP) || defined(FUNZIP)
void zipwarn OF((char *, char *)); /* add zipwarn prototype from zip.h */
# define near /* likewise */
typedef unsigned long ulg; /* likewise */
typedef size_t extent; /* likewise */
typedef void zvoid; /* likewise */
#endif
#include "crypt.h" /* just so we can tell if CRYPT is supported */
int zone_is_set = FALSE; /* set by tzset() */
#ifndef FUNZIP
/***********************/
/* 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.
*/
# 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;
#ifdef AZTEC_C /* should be pretty safe for reentrancy */
long timezone = 0; /* already declared SAS/C external */
int daylight = 0; /* likewise */
#endif
/* prototypes */
LONG FileDate (char *filename, time_t u[]);
int locale_TZ(void);
void tzset(void);
char *getenv(const char *var);
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
int Agetch(void);
#ifdef AZTEC_C
struct tm *gmtime(const time_t *when);
struct tm *localtime(const time_t *when);
#endif
time_t mkgmtime(struct tm *tm);
#ifdef ZIP
int is_zone_set(void); /* used by HAS_VALID_TIMEZONE macro */
time_t time(time_t *tp);
#endif
#ifdef __SASC
void set_TZ(char *TZstr);
#endif
#if 0 /* not used YET */
extern zvoid *remember_alloc OF((zvoid *memptr));
#endif
/* =============================================================== */
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;
time_t mtime;
/* tzset(); */
/* mtime = u[0] - timezone; */
mtime = mkgmtime(localtime(&u[0]));
/* magic number = 2922 = 8 years + 2 leaps between 1970 - 1978 */
pDate.ds_Days = (mtime / 86400L) - 2922L;
mtime = mtime % 86400L;
pDate.ds_Minute = mtime / 60L;
mtime = mtime % 60L;
pDate.ds_Tick = mtime * 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() */
#ifdef ZIP
int is_zone_set(void) /* used by HAS_VALID_TIMEZONE macro */
{
tzset(); /* sets global zone_is_set */
return zone_is_set;
}
#endif
/* set timezone and daylight to settings found in locale.library */
int locale_TZ(void)
{
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;
if (z == -5) {
if (eh = Lock("ENV:sys/locale.prefs", ACCESS_READ))
UnLock(eh);
else
z = 5; /* bug: locale not initialized, default is bogus! */
} else
zone_is_set = TRUE;
timezone = z * 60;
daylight = (z >= 4*60 && z <= 9*60); /* apply in the Americas */
valid = TRUE;
CloseLocale(ll);
}
CloseLibrary(LocaleBase);
}
me->pr_WindowPtr = old_window;
return valid;
}
#ifdef __SASC
/* Stores data from timezone and daylight to ENV:TZ. */
/* Only set if TZ string is absent or empty */
/* ENV:TZ is required to exist by some other SAS/C library functions, */
/* e.g. stat(), that call tzset() again rather than using already set */
/* timezone and daylight. */
void set_TZ(char *TZstr)
{
char put_tz[13]; /* string for putenv: "TZ=aaabbbccc" */
int offset;
if ((TZstr == NULL) || (TZstr && (*TZstr == '\0'))) {
offset = timezone / 3600;
/* create TZ string and make sure hours range from 0-24 */
sprintf(put_tz,"TZ=UTC%+03dDST",abs(offset)>24 ? 0 : offset);
if (daylight == 0)
put_tz[9] = '\0'; /* truncate daylight savings part */
/* Now store TZ to ENV:TZ. Will match values from locale.library */
/* or "UTC+00" if no valid information was found at all. */
putenv(put_tz);
__tzset(); /* initialize _TZ */
}
}
#endif /* __SASC */
void tzset(void) {
char *p,*TZstring;
int z,valid = FALSE;
if (zone_is_set)
return;
timezone = 0; /* default is GMT0 which means no offsets */
daylight = 0; /* from local system time */
TZstring = getenv("TZ"); /* read TZ envvar */
if (TZstring && TZstring[0]) { /* TZ exists and has contents? */
z = 3600;
for (p = TZstring; *p && !isdigit(*p) && *p != '-'; p++) ;
if (*p == '-')
z = -3600, p++;
if (*p) {
timezone = 0;
do {
while (isdigit(*p))
timezone = timezone * 10 + z * (*p++ - '0'), valid = TRUE;
if (*p == ':') p++;
} while (isdigit(*p) && (z /= 60) > 0);
}
while (isspace(*p)) p++; /* probably not needed */
if (valid)
zone_is_set = TRUE, daylight = !!*p; /* a DST name part exists */
}
if (!valid)
locale_TZ(); /* read locale.library */
#ifdef __SASC
/* Some SAS/C library functions, e.g. stat(), call library */
/* __tzset() themselves. So envvar TZ *must* exist in order */
/* to get the right offset from GMT. */
set_TZ(TZstring);
#endif /* __SASC */
}
#ifdef AZTEC_C /* SAS/C uses library getenv() */
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, **varp = &var; /* <= NECESSARY to prevent "loss of" */
/* const/volatile info" errors */
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
if (SysBase->LibNode.lib_Version >= ReqVers) {
if (GetVar(*varp, 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(*varp, 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;
}
#endif /* AZTEC_C */
#if (!defined(ZIP) || !defined(NO_MKTIME))
/* this mkgmtime() code is a simplified version taken from Zip's mktime.c */
/* Return the equivalent in seconds past 12:00:00 a.m. Jan 1, 1970 GMT
of the Greenwich Mean time and date in the exploded time structure `tm',
and set `tm->tm_yday' and `tm->tm_wday', but not `tm->tm_isdst'.
Return -1 if any of the other fields in `tm' has an invalid value. */
/* Nonzero if `y' is a leap year, else zero. */
#define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
/* Number of leap years from 1970 to `y' (not including `y' itself). */
#define nleap(y) (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)
/* Accumulated number of days from 01-Jan up to start of current month. */
extern const ush ydays[]; /* in fileio.c */
time_t mkgmtime(struct tm *tm)
{
int years, months, days, hours, minutes, seconds;
years = tm->tm_year + 1900; /* year - 1900 -> year */
months = tm->tm_mon; /* 0..11 */
days = tm->tm_mday - 1; /* 1..31 -> 0..30 */
hours = tm->tm_hour; /* 0..23 */
minutes = tm->tm_min; /* 0..59 */
seconds = tm->tm_sec; /* 0..61 in ANSI C. */
if (years < 1970
|| months < 0 || months > 11
|| days < 0
|| days >= (months == 11? 365 : ydays[months + 1]) - ydays[months]
+ (months == 1 && leap(years))
|| hours < 0 || hours > 23
|| minutes < 0 || minutes > 59
|| seconds < 0 || seconds > 61)
return -1;
/* Set `days' to the number of days into the year. */
days += ydays[months] + (months > 1 && leap(years));
tm->tm_yday = days;
/* Now set `days' to the number of days since Jan 1, 1970. */
days += 365 * (years - 1970) + nleap(years);
tm->tm_wday = (days + 4) % 7; /* Jan 1, 1970 was Thursday. */
/* tm->tm_isdst = 0; */
return (time_t)(86400L * (unsigned long)days + 3600L * (unsigned long)hours +
(unsigned long)(60 * minutes + seconds));
}
#endif /* !ZIP || !NO_MKTIME */
#ifdef AZTEC_C /* SAS/C uses library gmtime() */
struct tm *gmtime(const time_t *when)
{
static struct tm tbuf; /* this function is intrinsically non-reentrant */
static short smods[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long days = *when / 86400;
long secs = *when % 86400;
short yell, yday;
tbuf.tm_wday = (days + 4) % 7; /* 1/1/70 is a Thursday */
tbuf.tm_year = 70 + 4 * (days / 1461);
yday = days % 1461;
while (yday >= (yell = (tbuf.tm_year & 3 ? 365 : 366)))
yday -= yell, tbuf.tm_year++;
smods[1] = (tbuf.tm_year & 3 ? 28 : 29);
tbuf.tm_mon = 0;
tbuf.tm_yday = yday;
while (yday >= smods[tbuf.tm_mon])
yday -= smods[tbuf.tm_mon++];
tbuf.tm_mday = yday + 1;
tbuf.tm_isdst = 0;
tbuf.tm_sec = secs % 60;
tbuf.tm_min = (secs / 60) % 60;
tbuf.tm_hour = secs / 3600;
#ifdef AZTEC_C
tbuf.tm_hsec = 0;
#endif
return &tbuf;
}
#endif /* AZTEC_C */
#ifdef AZTEC_C /* SAS/C uses library localtime() */
struct tm *localtime(const time_t *when)
{
struct tm *t;
time_t localwhen;
int dst = FALSE, sundays, lastweekday;
tzset();
localwhen = *when - timezone;
t = gmtime(&localwhen);
/* So far we support daylight savings correction by the USA rule only: */
if (daylight && t->tm_mon >= 3 && t->tm_mon <= 9) {
if (t->tm_mon > 3 && t->tm_mon < 9) /* May Jun Jul Aug Sep: yes */
dst = TRUE;
else {
sundays = (t->tm_mday + 6 - t->tm_wday) / 7;
if (t->tm_wday == 0 && t->tm_hour < 2 && sundays)
sundays--; /* a Sunday does not count until 2:00am */
if (t->tm_mon == 3 && sundays > 0) /* first sunday in April */
dst = TRUE;
else if (t->tm_mon == 9) {
lastweekday = (t->tm_wday + 31 - t->tm_mday) % 7;
if (sundays < (37 - lastweekday) / 7)
dst = TRUE; /* last sunday in October */
}
}
if (dst) {
localwhen += 3600;
t = gmtime(&localwhen); /* crude but effective */
t->tm_isdst = 1;
}
}
return t;
}
#endif /* AZTEC_C */
#ifdef AZTEC_C /* SAS/C uses library gmtime() */
#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) * 86400;
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 /* AZTEC_C */
#endif /* !FUNZIP */
#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) */

128
zip/unzip/amiga/makefile.azt Executable file
View File

@ -0,0 +1,128 @@
# Makefile for UnZip 5.30 using Manx Aztec C 5.2, last revised 15 May 97.
# 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 process.o crypt.o ttyio.o envargs.o explode.o \
unshrink.o extract.o zipinfo.o inflate.o match.o unreduce.o \
fileio.o list.o globals.o crctab.o amiga/amiga.o amiga/crc_68.o \
amiga/flate.o
XOBJS = unzip.xo process.xo crypt.o ttyio.o extract.xo fileio.o \
inflate.o match.o globals.o crctab.o amiga/flate.o amiga/amiga.xo \
amiga/crc_68.o
FOBJS = funzip.o crypt.fo ttyio.fo inflate.fo globals.fo \
amiga/flate.fo amiga/crc_68.o amiga/filedate.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/mkGoff amiga/FmkGoff
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 ttyio.o ttyio.fo : zip.h
inflate.o inflate.fo : inflate.h
fileio.o : ebcdic.h
funzip.o : tables.h
crypt.o crypt.fo ttyio.o ttyio.fo unzip.o unzip.xo funzip.o : crypt.h
fileio.o extract.o extract.xo inflate.o inflate.fo amiga/filedate.fo : crypt.h
amiga/mkGoff amiga/FmkGoff : crypt.h
crypt.o crypt.fo ttyio.o ttyio.fo funzip.o fileio.o : ttyio.h
unzip.o unzip.xo : version.h consts.h
# Special case object files:
amiga/amiga.o : amiga/filedate.c amiga/stat.c amiga/amiga.c
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
$(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/G_offs.a
as -n -o amiga/flate.o -eINT16 amiga/flate.a
amiga/flate.fo : amiga/flate.a amiga/G_offs.fa
as -n -o amiga/flate.fo -eINT16 -eFUNZIP -eAZTEC amiga/flate.a
# These special files are generated on the fly by a program we compile and
# then run, and then included into amiga/flate.a to provide definitions for it:
amiga/G_offs.a : amiga/mkGoff
amiga/mkGoff > amiga/G_offs.a
amiga/G_offs.fa : amiga/FmkGoff
amiga/FmkGoff > amiga/G_offs.fa
amiga/mkGoff : amiga/mkGoff.c globals.h crypt.h
$(CC) -o t:mkgoff.o $(CFLAGS) amiga/mkGoff.c
$(LD) $(LDFLAGS) -o amiga/mkGoff t:mkgoff.o $(LDLIBS)
-@delete t:mkgoff.o
amiga/FmkGoff : amiga/mkGoff.c globals.h crypt.h
$(CC) -o t:mkgoff.o $(CFLAGS) -d FUNZIP amiga/mkGoff.c
$(LD) $(LDFLAGS) -o amiga/FmkGoff t:mkgoff.o $(LDLIBS)
-@delete t:mkgoff.o

171
zip/unzip/amiga/makesfx.c Executable file
View File

@ -0,0 +1,171 @@
/* 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>
#include <dos/dos.h>
#include <clib/dos_protos.h>
#if (defined(DEBUG) && defined(__SASC))
# include <sprof.h>
#endif
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

34
zip/unzip/amiga/mkGoff.c Executable file
View File

@ -0,0 +1,34 @@
/* Write out a fragment of assembly source giving offsets in globals.h: */
#define UNZIP_INTERNAL
#include "unzip.h"
#include "crypt.h"
#include <stdio.h>
/* Keep this in sync with the definition of redirSlide in unzpriv.h: */
#ifdef DLL
# define pG_redirSlide pG->redirect_pointer
#else
# define pG_redirSlide pG->area.Slide
#endif
void main(void)
{
struct Globals *pG = (void *) 0L;
printf("bb EQU %lu\n", &pG->bb);
printf("bk EQU %lu\n", &pG->bk);
printf("wp EQU %lu\n", &pG->wp);
#ifdef FUNZIP
printf("in EQU %lu\n", &pG->in);
#else
printf("incnt EQU %lu\n", &pG->incnt);
printf("inptr EQU %lu\n", &pG->inptr);
printf("csize EQU %lu\n", &pG->csize);
printf("mem_mode EQU %lu\n", &pG->mem_mode);
#endif
printf("slide EQU %lu\n", &pG_redirSlide);
printf("SIZEOF_slide EQU %lu\n", sizeof(pG_redirSlide));
printf("CRYPT EQU %d\n", CRYPT);
exit(0);
}

570
zip/unzip/amiga/smakefile Executable file
View File

@ -0,0 +1,570 @@
#===========================================================================
# Makefile for UnZip, ZipInfo, fUnZip, MakeSFX AMIGA SAS/C Version 6.57
# Version: 5.30 last revised: 16 Apr 97
#===========================================================================
# from John Bush <john.bush@east.sun.com>
# updated for SAS/C Version 6.56+ and AmigaDOS 3.1 (V40)
# by Haidinger Walter <e9225662@stud1.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) (not tested either)
# If you have any improvements, critics or else please feel free to mail.
# Any response is appreciated. Haidinger Walter <e9225662@stud1.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 (>=20K)
#
# 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.
# 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
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)
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJSA)
# UnZipSFX Objects
OBJX1 = unzip$(OX) extract$(OX) inflate$(OX) match$(OX) process$(OX)
OBJXI = crypt$(O) crc32$(O) crctab$(O) fileio$(O) globals$(O) ttyio$(O)
OBJXA = amiga$(OX)
OBJX = $(OBJX1) $(OBJXI) $(OBJXA)
# fUnZip Objects
OBJF1 = funzip$(O)
OBJF2 = crc32$(OF) crypt$(OF) globals$(OF) inflate$(OF) ttyio$(OF) filedate$(OF)
OBJF = $(OBJF1) $(OBJF2)
# MakeSFX Objects
OBJM = makesfx$(O)
# Common header files
UNZIP_H1 = unzip.h unzpriv.h globals.h
UNZIP_HA = amiga/amiga.h #included by unzip.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: SASCOPTS $(CWITHOPT) $(CFILEC) $(CFILEX) $(CFILEM) 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 env:Workbench
#api$(O): api.c $(UNZIP_H) version.h #zlib.h
#apihelp$(O): apihelp.c $(UNZIP_H) version.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)
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 version.h consts.h #zlib.h
#unzipstb$(O): unzipstb.c $(UNZIP_H) version.h
zipinfo$(O): zipinfo.c $(UNZIP_H)
# UnZipSFX dependencies:
#
# special rule for adding Amiga internal version number to UnZipSFX
amiga$(OX): amiga/amiga.c $(UNZIP_H) amiga/filedate.c amiga/stat.c crypt.h
unzip$(OX): unzip.c $(UNZIP_H) crypt.h version.h consts.h
extract$(OX): extract.c $(UNZIP_H) crypt.h
inflate$(OX): inflate.c $(UNZIP_H) inflate.h #zlib.h
match$(OX): match.c $(UNZIP_H)
process$(OX): process.c $(UNZIP_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
<
# Read environment variable LOCAL_UNZIP and convert options to SAS format
#
# e.g.: to define FOO_ONE and FOO_TWO enter:
#
# SetEnv LOCAL_UNZIP "-DFOO_ONE -DFOO_TWO"
#
# Put the statement into your startup-sequence or (for AmigaDOS 2.04 or higher
# only) make sure LOCAL_UNZIP is stored in the ENVARC: directory
# ( Copy ENV:LOCAL_UNZIP ENVARC: )
#
local_unzip:
@Execute < < (Local_UnZip_smk.tmp)
Failat 21
If exists ENV:LOCAL_UNZIP
Echo "Using environment variable LOCAL_UNZIP !"
Copy >NIL: ENV:LOCAL_UNZIP SASCOPTS
Else
Echo "Note: This makefile supports envvar LOCAL_UNZIP. See INSTALL for details"
Delete >nil: SASCOPTS quiet
Endif
; Do not remove the lctosc command! If LOCAL_UNZIP is unset, an
; empty file is created which needed by CommonFlags !
lctosc >$(CWITHOPT)
<
# Echo request to the user
#
request:
@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. Have a look at the makefile for changes like CPU type, etc."
@Echo " Enjoy Info-ZIP's UnZip!"
@Echo " Haidinger Walter, <e9225662@stud1.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, <e9225662@stud1.tuwien.ac.at>"

285
zip/unzip/amiga/stat.c Executable file
View File

@ -0,0 +1,285 @@
/* 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. */
/* for use with Aztec C >= 5.0 and Lattice C <= 4.01 */
/* 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
#ifdef AZTEC_C
# include <exec/types.h>
# include <exec/memory.h>
# 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>
# include "amiga/z-stat.h" /* fake version of stat.h */
# include <string.h>
#else /* __SASC */
/* Uncomment define of USE_REPLACEMENTS to use the directory functions below */
/* #define USE_REPLACEMENTS */
# include <sys/stat.h>
# ifndef USE_REPLACEMENTS
# include <sys/dir.h> /* SAS/C dir function prototypes */
# include <dos.h>
# else
# include <exec/types.h>
# include <exec/memory.h>
# include <sys/types.h>
# include <proto/exec.h>
# include <proto/dos.h>
# include <string.h>
# endif
#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);
}
#if defined(AZTEC_C) || defined(USE_REPLACEMENTS)
unsigned short disk_not_mounted;
extern int stat(char *file,struct stat *buf);
stat(file,buf)
char *file;
struct stat *buf;
{
struct FileInfoBlock *inf;
BPTR lock;
long ftime;
void tzset(void);
if( (lock = Lock(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();
ftime += timezone;
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);
}
/* opendir(), readdir(), closedir() and rmdir() by Paul Kienitz. */
DIR *opendir(char *path)
{
DIR *dd = AllocMem(sizeof(DIR), MEMF_PUBLIC);
if (!dd) return NULL;
if (!(dd->d_parentlock = Lock(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);
}
int rmdir(char *path)
{
return (DeleteFile(path) ? 0 : IoErr());
}
int chmod(char *filename, int bits) /* bits are as for st_mode */
{
long protmask = (bits & 0xFF) ^ 0xF;
return !SetProtection(filename, protmask);
}
#endif /* AZTEC_C || USE_REPLACEMENTS */
#ifdef AZTEC_C
/* 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 */
/* remove local define */
#ifdef USE_REPLACEMENTS
# undef USE_REPLACEMENTS
#endif
#endif /* __amiga_stat_c */

85
zip/unzip/amiga/z-stat.h Executable file
View File

@ -0,0 +1,85 @@
#ifndef __Z_STAT_H
#define __Z_STAT_H
#define __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(). */
/* This include file should ONLY be loaded if AZTEC_C is defined, and
* you are using the substitute version of stat() from amiga/stat.c.
* Bit definitions are based on those in headers for SAS/C v6.0
*/
#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(char *name, struct stat *buf);
#include <libraries/dos.h>
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(char *);
void closedir(DIR *);
void close_leftover_open_dirs(void); /* call this if aborted in mid-run */
struct dirent *readdir(DIR *);
int rmdir(char *);
# ifdef AZTEC_C
void tzset(void);
int umask(void);
int chmod(char *filename, int bits);
# endif
#endif /* __Z_STAT_H */

7
zip/unzip/aosvs/Contents Executable file
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

145
zip/unzip/aosvs/README Executable file
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.
------------------------------------------------------------------

1320
zip/unzip/aosvs/aosvs.c Executable file

File diff suppressed because it is too large Load Diff

57
zip/unzip/aosvs/aosvs.h Executable file
View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------
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(char *fname, long cretim, long modtim, long acctim,
char *pacl, int ftyp, int eltsize, int maxindlev);
extern int zvs_credir(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, 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;

5
zip/unzip/aosvs/make_unz.cli Executable file
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

224
zip/unzip/api.c Executable file
View File

@ -0,0 +1,224 @@
/*---------------------------------------------------------------------------
api.c
This module supplies an UnZip engine for use directly from C/C++
programs. The functions are:
UzpVer *UzpVersion(void);
int UzpMain(int argc, char *argv[]);
int UzpAltMain(int argc, char *argv[], UzpInit *init);
int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);
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
#define UNZIP_INTERNAL
#include "unzip.h"
#include "version.h"
#ifdef USE_ZLIB
# include "zlib.h"
#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 = BETALEVEL;
version.date = 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 = PATCHLEVEL;
version.zipinfo.major = ZI_MAJORVER;
version.zipinfo.minor = ZI_MINORVER;
version.zipinfo.patchlevel = PATCHLEVEL;
/* these are retained for backward compatibility only: */
version.os2dll.major = UZ_MAJORVER;
version.os2dll.minor = UZ_MINORVER;
version.os2dll.patchlevel = PATCHLEVEL;
version.windll.major = UZ_MAJORVER;
version.windll.minor = UZ_MINORVER;
version.windll.patchlevel = PATCHLEVEL;
return &version;
}
#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
int UZ_EXP UzpUnzipToMemory(char *zip,char *file,UzpBuffer *retstr)
{
int r;
CONSTRUCTGLOBALS();
G.redirect_data = 1;
r = unzipToMemory(__G__ zip,file,retstr)==0;
DESTROYGLOBALS()
return r;
}
#ifdef OS2DLL
int UZ_EXP UzpFileTree(char *name, cbList(callBack), char *cpInclude[],
char *cpExclude[])
{
int r;
CONSTRUCTGLOBALS();
G.qflag = 2;
G.vflag = 1;
G.C_flag = 1;
G.wildzipfn = name;
G.process_all_files = TRUE;
if (cpInclude)
G.pfnames = cpInclude, G.process_all_files = FALSE;
if (cpExclude)
G.pxnames = cpExclude, G.process_all_files = FALSE;
G.processExternally = callBack;
r = process_zipfiles(__G)==0;
DESTROYGLOBALS()
return r;
}
#endif /* OS2DLL */
/*---------------------------------------------------------------------------
Helper functions
---------------------------------------------------------------------------*/
void setFileNotFound(__G)
__GDEF
{
G.filenotfound++;
}
int unzipToMemory(__GPRO__ char *zip, char *file, UzpBuffer *retstr)
{
int r;
char *incname[2];
G.process_all_files = FALSE;
G.extract_flag = TRUE;
G.qflag = 2;
G.C_flag = 1;
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;
}
r |= G.filenotfound;
if (r)
return r; /* GRR: these two lines don't make much sense... */
return r;
}
int redirect_outfile(__G)
__GDEF
{
G.redirect_size = G.lrec.ucsize;
#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(G.redirect_size+1);
#endif
if (!G.redirect_buffer)
return FALSE;
G.redirect_pointer[G.redirect_size] = 0;
return TRUE;
}
int writeToMemory(__GPRO__ uch *rawbuf, ulg size)
{
if (rawbuf != G.redirect_pointer)
memcpy(G.redirect_pointer,rawbuf,size);
G.redirect_pointer += size;
return 0;
}

144
zip/unzip/apihelp.c Executable file
View File

@ -0,0 +1,144 @@
/* apihelp.c */
#ifdef API_DOC
#define UNZIP_INTERNAL
#include "unzip.h"
#include "version.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 don't 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. UzpUnzipToMemory calls\n"
"\t\tthe callback 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 }
};
int function_help(__G__ doc, fname)
__GDEF
APIDocStruct *doc;
char *fname;
{
strcpy(slide, fname);
strupr(slide);
while (doc->compare && strcmp(doc->compare,slide))
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 */

12
zip/unzip/atari/Contents Executable file
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.

899
zip/unzip/atari/Makefile Executable file
View File

@ -0,0 +1,899 @@
#==============================================================================
# Makefile for UnZip, UnZipSFX and fUnZip: Unix and MS-DOS ("real" makes only)
# Version: 5.20 11 February 1996
#==============================================================================
# INSTRUCTIONS (such as they are):
#
# "make vax" -- makes UnZip on a generic Unix VAX in the current directory
# "make list" -- lists all supported systems (targets)
# "make help" -- provides pointers on what targets to try if problems occur
# "make wombat" -- chokes and dies if you haven't added the specifics for your
# Wombat 68000 (or whatever) to the systems list
#
# 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).
#
# Some versions of make do not define the macro "$(MAKE)"; this is rare, but
# if things don't work, try using "make" instead of "$(MAKE)" in your system's
# makerule. Or try adding the following line to your .login file:
# setenv MAKE "make"
# (That never works--makes which are too stupid to define MAKE are also too
# stupid to look in the environment--but try it anyway for kicks. :-) )
#
# Memcpy and memset are provided for those systems that don't have them; they
# are in fileio.c and will be used if -DZMEM is included in CF. These days
# almost all systems have them.
#
# 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 crypt_$O globals_$O inflate_$O ttyio_$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 = unix/unzip.1 unix/unzipsfx.1 unix/zipinfo.1 unix/funzip.1
DOCS = unzip.doc unzipsfx.doc zipinfo.doc funzip.doc
# list of supported systems/targets in this version
SYSTEMS1 = 386i 3Bx 7300 7300_gcc aix aix_rt amdahl amdahl_eft apollo
SYSTEMS2 = aviion bcc_dos bsd bsd386 bull coherent convex cray cray_opt
SYSTEMS3 = cyber_sgi dec djgpp djgpp1 dnix encore eta gcc gcc_dos generic
SYSTEMS4 = generic2 generic3 gould hk68 hp hpux linux linux_dos linux_lib
SYSTEMS5 = linux_zlib minix mips msc_dos next next10 next2x next3x nextfat
SYSTEMS6 = osf1 pixel ptx pyramid realix regulus rs6000 sco sco_dos sco_sl
SYSTEMS7 = sco_x286 sequent sgi solaris stardent stellar sun sysv sysv_gcc
SYSTEMS8 = sysv6300 tahoe ti_sysv ultrix vax v7 wombat xenix xos
####################
# DEFAULT HANDLING #
####################
# By default, print help on which makefile targets to try. (The SYSTEM
# variable is no longer supported; use "make <target>" instead.)
help:
@echo ""
@echo\
" If you're not sure about the characteristics of your system, try typing"
@echo\
' "make generic". If the compiler barfs and says something unpleasant about'
@echo\
' "timezone redefined," try typing "make clean" followed by "make generic2".'
@echo\
' If, on the other hand, it complains about an undefined symbol _ftime, try'
@echo\
' typing "make clean" followed by "make generic3". One of these actions'
@echo\
' should produce a working copy of unzip on most Unix systems. If you know'
@echo\
' a bit more about the machine on which you work, you might try "make list"'
@echo\
' for a list of the specific systems supported herein. (Many of them do'
@echo\
" exactly the same thing, so don't agonize too much over which to pick if"
@echo\
' two or more sound equally likely.) Also check out the INSTALL file for'
@echo\
' notes on compiling various targets. As a last resort, feel free to read'
@echo\
' the numerous comments within the Makefile itself. Note that to compile'
@echo\
' the decryption version of UnZip, you must obtain the full versions of'
@echo\
' crypt.c and crypt.h (see the "Where" file for ftp and mail-server sites).'
@echo\
' Have a mostly pretty good day.'
@echo ""
list:
@echo ""
@echo\
'Type "make <system>", where <system> is one of the following:'
@echo ""
@echo " $(SYSTEMS1)"
@echo ""
@echo " $(SYSTEMS2)"
@echo " $(SYSTEMS3)"
@echo " $(SYSTEMS4)"
@echo " $(SYSTEMS5)"
@echo " $(SYSTEMS6)"
@echo " $(SYSTEMS7)"
@echo " $(SYSTEMS8)"
# @echo ""
# @echo\
# 'Targets for related utilities (ZipInfo and fUnZip) include:'
# @echo ""
# @echo " $(SYS_UTIL1)"
# @echo " $(SYS_UTIL2)"
@echo ""
@echo\
'For further (very useful) information, please read the comments in Makefile.'
@echo ""
generic_msg:
@echo ""
@echo\
' Attempting "make generic" now. If this fails for some reason, type'
@echo\
' "make help" and/or "make list" for suggestions.'
@echo ""
###############################################
# 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
# this doesn't work...directories are always a pain with implicit rules
#.1.doc: unix/$<
# nroff -Tman -man $< | col -b | uniq | \
# sed 's/Sun Release ..../Info-ZIP /' > $@
# these rules are specific to Suns and are really intended only for the
# authors' use in creating non-Unix documentation files (which are pro-
# vided with both source and binary distributions). We should probably
# add a ".1.man" rule for more generic systems...
unzip.doc: unix/unzip.1
nroff -Tman -man unix/unzip.1 | col -b | uniq | \
sed 's/Sun Release ..../Info-ZIP /' > $@
unzipsfx.doc: unix/unzipsfx.1
nroff -Tman -man unix/unzipsfx.1 | col -b | uniq | \
sed 's/Sun Release ..../Info-ZIP /' > $@
zipinfo.doc: unix/zipinfo.1
nroff -Tman -man unix/zipinfo.1 | col -b | uniq | \
sed 's/Sun Release ..../Info-ZIP /' > $@
funzip.doc: unix/funzip.1
nroff -Tman -man unix/funzip.1 | col -b | uniq | \
sed 's/Sun Release ..../Info-ZIP /' > $@
all: generic_msg generic
unzips: $(UNZIPS)
objs: $(OBJS)
objsdll: $(OBJSDLL)
docs: $(DOCS)
unzipsman: unzips docs
unzipsdocs: unzips docs
# EDIT HERE FOR PARALLEL MAKES on Sequent (and others?)--screws up MS-DOS
# make utilities if default: change "unzip$E:" to "unzip$E:&"
unzip$E: $(OBJS) # add `&' for parallel makes
$(LD) $(LF) $(LOBJS) $(LF2)
unzipsfx$E: $(OBJX) # add `&' for parallel makes
$(LD) $(SL) $(LOBJX) $(SL2)
funzip$E: $(OBJF) # add `&' for parallel makes
$(LD) $(FL) $(OBJF) $(FL2)
zipinfo$E: unzip$E # `&' is pointless here...
@echo\
' This is a Unix-specific target. ZipInfo is not enabled in some MS-DOS'
@echo\
' versions of UnZip; if it is in yours, copy unzip.exe to zipinfo.exe'
@echo\
' or else invoke as "unzip -Z" (in a batch file, for example).'
$(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 version.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) -DFUNZIP 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
globals_$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globals_.c
$(CC) -c $(CF) -DFUNZIP globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) -DFUNZIP inflate_.c
$(RM) inflate_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) -DFUNZIP ttyio_.c
$(RM) ttyio_.c
msdos$O: msdos/msdos.c $(UNZIP_H) version.h # DOS only
$(CC) -c $(CF) msdos/msdos.c
# version() not used by unzipsfx, so no version.h dependency
msdos_$O: msdos/msdos.c $(UNZIP_H) # DOS unzipsfx
$(CP) msdos\msdos.c msdos_.c > nul
$(CC) -c $(CF) -DSFX msdos_.c
$(RM) msdos_.c
#os2$O: os2/os2.c $(UNZIP_H) # OS/2 only
# $(CC) -c $(CF) os2/os2.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) -DSFX process_.c
$(RM) process_.c
unix$O: unix/unix.c $(UNZIP_H) version.h # Unix only
$(CC) -c $(CF) unix/unix.c
# version() not used by unzipsfx, so no version.h dependency
unix_$O: unix/unix.c $(UNZIP_H) # Unix unzipsfx
$(CP) unix/unix.c unix_.c
$(CC) -c $(CF) -DSFX unix_.c
$(RM) unix_.c
atari_$O: atari.c $(UNZIP_H)
$(CP) atari.c atari_.c
$(CC) -c $(CF) -DSFX atari_.c
$(RM) atari_.c
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h # unzipsfx only
$(CP) unzip.c unzipsfx.c
$(CC) -c $(CF) -DSFX unzipsfx.c
$(RM) unzipsfx.c
unix_make:
# @echo\
# '(Ignore any errors from `make'"' due to the following command; it's harmless.)"
-@2>&1 $(LN) unix/Makefile . > /dev/null || echo > /dev/null
# 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) unix/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) unix/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) unix/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) unix/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 #
################################
#----------------------------------------------------------------------------
# Generic targets (can't assume make utility groks "$(MAKE)")
#----------------------------------------------------------------------------
generic: unzips # first try if unknown
generic2: unix_make # second try if unknown: hope make is called "make"
make -f unix/Makefile unzips CF="$(CF) -DBSD"
generic3: unix_make # third try if unknown: hope make is called "make"
make -f unix/Makefile unzips CF="$(CF) -DSYSV"
#----------------------------------------------------------------------------
# "Normal" group (BSD vs. SysV may be set in unzip.h via predefined macros):
#----------------------------------------------------------------------------
386i: unzips # sun386i, SunOS 4.0.2
3Bx: unzips # AT&T 3B2/1000-80; should work on any WE32XXX machine
#aix_rt: unzips # IBM RT 6150 under AIX 2.2.1
apollo: unzips # Apollo Domain/OS machines
bull: unzips # Bull DPX/2, BOS 2.00.45 (doesn't require -Xk switch)
convex: unzips # Convex C-120 and C-210 (-O is enough; -ext is default)
cray: unzips # Cray-2 and Y-MP, using default (possibly old) compiler
dec: unzips # DEC 5820 (MIPS RISC), test version of Ultrix v4.0
encore: unzips # Multimax
eta: unzips # ETA-10P*, hybrid SysV with BSD 4.3 enhancements
gould: unzips # Gould PN9000 running UTX/32 2.1Bu01
hp: unzips # HP 9000 series (68020), 4.3BSD or HP-UX A.B3.10 Ver D
hpux: unzips # (to match zip's makefile entry)
mips: unzips # MIPS M120-5(?), SysV.3 [error in sys/param.h file?]
next10: unzips # NeXT (generic; use next2x or next3x for better opt.)
osf1: unzips # DECstation, including Alpha-based; DEC OSF/1 v1.x
pyr_: unzips # [failsafe target for pyramid target below]
pyr_ucb: unzips # Pyramids running BSD universe by default (see below)
realix: unzips # Modcomp Real/IX (SysV.3); note "gcc" = GLS C, not GNU
sco: unzips # Xenix/386 (tested on 2.3.1); SCO Unix 3.2.0.
sgi: unzips # Silicon Graphics; Irix 3.3.2, 4.0.x, 5.2, etc.
stellar: unzips # gs-2000
sun: unzips # old target; no good with solaris...use "sunos" now
sunos: unzips # Sun 3, 4; SunOS 4.x (SOME SYSTEMS ARE SYSTEM V!)
tahoe: unzips # tahoe (CCI Power6/32), 4.3BSD
ultrix: unzips # VAXen, DEC 58x0 (MIPS guts), DECstation 2100; v4.x
vax: unzips # general-purpose VAX target (not counting VMS)
#----------------------------------------------------------------------------
# BSD group (for timezone structs [struct timeb]):
#----------------------------------------------------------------------------
bsd: _bsd # generic BSD (BSD 4.2 & Ultrix handled in unzip.h)
bsd386: _bsd # BSDI BSD/386 version 1.0
_bsd: unix_make
$(MAKE) unzips CF="$(CF) -DBSD"
#----------------------------------------------------------------------------
# SysV group (for extern long timezone and ioctl.h instead of sgtty.h):
#----------------------------------------------------------------------------
aix_rt: _sysv # IBM RT 6150 under AIX 2.2.1
amdahl: _sysv # Amdahl (IBM) mainframe, UTS (SysV) 1.2.4 and 2.0.1
aviion: _sysv # Data General AViiONs, DG/UX 4.3x
pyr_att: _sysv # Pyramids running AT&T (SysV) universe by default
solaris: _sysv # Sun SPARC & x86, Solaris 2.x
stardent: _sysv # Stardent ...
sysv: _sysv # generic System V Unix (Xenix handled in unzip.h)
xos: _sysv # Olivetti LSX-3005..3045, X/OS 2.3 and 2.4
_sysv: unix_make
$(MAKE) unzips CF="$(CF) -DSYSV"
#----------------------------------------------------------------------------
# Version 7 group (old/obsolescent):
#----------------------------------------------------------------------------
pixel: _v7 # Pixel 80, 100 (68000-based, V7/mostly BSD4.1 compat.)
v7: _v7 # generic Unix Version 7 box (prob. only Pixel...)
_v7:
make -f unix/Makefile unzips \
CF="$(CF) -DV7 -DNO_PARAM_H -DSHORT_NAMES -DBSD -DZMEM"
#----------------------------------------------------------------------------
# "Unique" group (require non-standard options):
#----------------------------------------------------------------------------
# AT&T 7300 (M68000/SysV.3) (add -DSYSV? -DNO_LIMITS?)
7300: unix_make
$(MAKE) unzips CF="$(CF) -DNO_DIR -DNO_MKDIR -DNO_STRNICMP"
7300_gcc: unix_make
$(MAKE) unzips CC=gcc LD=gcc LF2="" \
CF="-O2 -I. -DNO_DIR -DNO_MKDIR -DNO_STDLIB_H -DNO_STRNICMP $(LOC)"
$(STRIP) $(UNZIPS)
# IBM AIX 3.x on an RS/6000: see rs6000 target below
aix: rs6000
# Amdahl UTS 2.1.4 with "extended file types" filesystem (aarrrggghhhh...)
amdahl_eft: unix_make
$(MAKE) unzips CF="$(CF) -eft -DSYSV"
# MS-DOS: Borland C++ 3.0 (can change UnZip memory model to small for more
# speed but no ZipInfo support [-ml -> -ms in _bcc_dos], but may run out of
# memory when inflating--should not be true anymore in 5.11)
bcc_dos: _bcc_dos fu_bcc sfx_bcc
_bcc_dos: bcc_rsp # v-- change to -ml for large model
$(MAKE) unzip.exe CF="-w -ms -O2 -I. $(LOC)" CC=bcc LD=bcc E=.exe\
O=.obj M=msdos LOBJS="" LF="@bcc_rsp" LF2=""
del bcc_rsp
bcc_rsp:
echo $(OBJS1:.o=.obj) > bcc_rsp
echo msdos.obj $(OBJS2:.o=.obj) >> bcc_rsp
fu_bcc:
$(MAKE) funzip.exe CF="-w -ms -O2 -I. $(LOC)" CC=bcc LD=bcc E=.exe\
O=.obj FL="" FL2="" CP=copy RM=del
sfx_bcc:
$(MAKE) unzipsfx.exe CF="-w -ms -O2 -I. $(LOC)" CC=bcc LD=bcc E=.exe\
O=.obj SL="" SL2="" CP=copy RM=del
# Coherent 3.x/4.x, Mark Williams C. ``For Coherent's CC, it needs either
# -T0 or -T150000 (or bigger) added to the CFLAGS, otherwise the compiler
# runs out of memory and dies in zipinfo.c.'' [Fred "Fredex" Smith, 940719]
coherent: unix_make
$(MAKE) unzips CF="$(CF) -T0"
# Cray-2, Y-MP or C90, running Unicos 5.x to 8.x (SysV + BSD enhancements)
# and Standard (ANSI) C compiler 3.0 or later.
cray_opt: unix_make
$(MAKE) unzips CF="$(CF) -h scalar3 -h vector3"
# The unzip41 build on a Cyber 910/SGI running Irix v3.3.3 was successful
# with the following change to Makefile:
cyber_sgi: unix_make
$(MAKE) unzips CF="$(CF) -I/usr/include/bsd"\
LF="-lbsd $(LF)" SL="-lbsd $(SL)"
# 680x0, DIAB dnix 5.2/5.3 (a Swedish System V clone)
#
# Options for the dnix cc:
# -X7 = cc is strict ANSI C
# -X9 = warnings if a function is used without a declaration
#
dnix: unix_make
$(MAKE) unzips CF="$(CF) -X7 -X9 -DDNIX"
# Generic BSDish Unix gcc. ``The -O2 only works with the latest version of
# gcc; you may have to use -O only for earlier versions. I have no idea why
# -s causes this bug in gcc.'' [Bug: "nm: unzip: no name list", "collect:
# /usr/bin/nm returned 1 exit status".] If you don't have strip, don't
# worry about it (it just makes the executable smaller and can be replaced
# with "echo" instead).
#
gcc: unix_make
$(MAKE) unzips CC=gcc LD=gcc CF="-O2 -I. $(LOC)" LF2=""
$(STRIP) $(UNZIPS)
# MS-DOS with D.J. Delorie's djgpp 1.12. Note that earlier versions of go32
# (< 1.11) don't support DOS function 0x38 (necessary for "unzip -v foobar").
# Note also that this set of targets has work-arounds for three bugs in the
# older version (3.69) of GNU make formerly distributed with djgpp: (1) it
# sets the MAKE variable incorrectly for spawning with COMMAND.COM (forward
# slashes instead of backslashes--fixed in 3.71 by not spawning COMMAND.COM),
# so the usual $(MAKE) has been replaced by "make"; (2) it doesn't handle
# makefile continuation lines correctly, most likely because of the MS-DOS
# CR-LF line-endings (seems to be fixed in 3.71?), so long lines are used;
# and (3) it doesn't handle quotes as in CF="-O2 -Wall etc." correctly, so
# these macros have been changed to "CF=-O2 -Wall etc." where necessary.
# The newer GNU make (version 3.71) does not handle quotes correctly, but
# prepending "command /c" to each make line is reported by E-Yen Tan
# <e-yen.tan@brasenose.oxford.ac.uk> to be a successful work-around. The
# emx version of GNU make 3.71 which is maintained by Kai Uwe Rommel has
# other fatal bugs involving the shell (necessary for recursive targets
# like this one). GRR 940430, 940723, 940814, 951230
#
djgpp1: _gcc_dos1 fu_gcc1 sfx_gcc1 # djgpp v1.x with GO32 extender
gcc_dos1: _gcc_dos1 fu_gcc1 sfx_gcc1 # djgpp v1.x with GO32 extender
_gcc_dos1: gcc_rsp
# this line works with GNU make 3.69:
# make unzip CC=gcc LD=gcc M=msdos "CF=-O2 -Wall -I. $(LOC)" LOBJS="" "LF=-o unzip @gcc_rsp" LF2=""
#
# this line should work with GNU make 3.71:
command /c make unzip CC=gcc LD=gcc M=msdos "CF=-O2 -Wall -I. $(LOC)" LOBJS="" "LF=-o unzip @gcc_rsp" LF2=""
#
# these lines don't work at all, to our knowledge:
# $(MAKE) unzip CC=gcc LD=gcc M=msdos "CF=-O2 -Wall -I. $(LOC)"\
# LOBJS="" LF="-o unzip @gcc_rsp" LF2=""
#
$(STRIP) unzip
coff2exe unzip
# use this instead if you want to create a stand-alone executable (bigger;
# may require full path to go32.exe):
# coff2exe -s go32.exe unzip
stubedit unzip.exe globbing=no
del gcc_rsp
del unzip
#
coff2exe -g zipinfo
stubedit zipinfo.exe runfile=unzip.exe globbing=no
del zipinfo
fu_gcc1:
# this line works with GNU make 3.69:
# make funzip CC=gcc LD=gcc "CF=-Wall -O2 -I. $(LOC)" FL2="" CP=copy RM=del
#
# this line should work with GNU make 3.71:
command /c make funzip CC=gcc LD=gcc "CF=-Wall -O2 -I. $(LOC)" FL2="" CP=copy RM=del
#
# these lines don't work at all, to our knowledge:
# $(MAKE) funzip CC=gcc LD=gcc "CF=-Wall -O2 -I. $(LOC)" FL2=""\
# CP=copy RM=del
#
$(STRIP) funzip
coff2exe funzip
# use this instead if you want to create a stand-alone executable (bigger;
# may require full path to go32.exe):
# coff2exe -s go32.exe funzip
del funzip
sfx_gcc1:
# this line works with GNU make 3.69:
# make unzipsfx CC=gcc LD=gcc M=msdos "CF=-Wall -O2 -I. $(LOC)" SL2="" CP=copy RM=del
#
# this line should work with GNU make 3.71:
command /c make unzipsfx CC=gcc LD=gcc M=msdos "CF=-Wall -O2 -I. $(LOC)" SL2="" CP=copy RM=del
#
# these lines don't work at all, to our knowledge:
# $(MAKE) unzipsfx CC=gcc LD=gcc M=msdos "CF=-Wall -O2 -I. $(LOC)"\
# SL2="" CP=copy RM=del
#
$(STRIP) unzipsfx
coff2exe unzipsfx
# use this instead if you want to create a stand-alone executable (bigger;
# may require full path to go32.exe):
# coff2exe -s go32.exe unzipsfx
stubedit unzipsfx.exe globbing=no
del unzipsfx
gcc_rsp:
echo $(OBJS1) > gcc_rsp
echo $(OBJS2) msdos.o >> gcc_rsp
# MS-DOS with D.J. Delorie's djgpp 2.0. See above for comments about make
# utilities (may or may not still be relevant). All executables are now
# stand-alone, but can provide Charles W. Sandmann's (alternate?) DPMI server
# if needed via "stubedit unzip.exe dpmi=cwsdpmi.exe" (for example). 950816
djgpp: _gcc_dos fu_gcc sfx_gcc # djgpp v2.x
djgpp2: _gcc_dos fu_gcc sfx_gcc # djgpp v2.x
gcc_dos: _gcc_dos fu_gcc sfx_gcc # djgpp v2.x
_gcc_dos: gcc_rsp
make unzip CC=gcc LD=gcc M=msdos "CF=-O2 -Wall -I. $(LOC)" LOBJS="" "LF=-o unzip @gcc_rsp" LF2=""
# $(MAKE) unzip CC=gcc LD=gcc M=msdos "CF=-O2 -Wall -I. $(LOC)"\
# LOBJS="" LF="-o unzip @gcc_rsp" LF2=""
$(STRIP) unzip
stubify unzip
del gcc_rsp
del unzip
stubify -g zipinfo.exe
stubedit zipinfo.exe runfile=unzip argv0=zipinfo
fu_gcc:
make funzip CC=gcc LD=gcc "CF=-Wall -O2 -I. $(LOC)" FL2="" CP=copy RM=del
# $(MAKE) funzip CC=gcc LD=gcc "CF=-Wall -O2 -I. $(LOC)" FL2=""\
# CP=copy RM=del
$(STRIP) funzip
stubify funzip
del funzip
sfx_gcc:
make unzipsfx CC=gcc LD=gcc M=msdos "CF=-Wall -O2 -I. $(LOC)" SL2="" CP=copy RM=del
# $(MAKE) unzipsfx CC=gcc LD=gcc M=msdos "CF=-Wall -O2 -I. $(LOC)"\
# SL2="" CP=copy RM=del
$(STRIP) unzipsfx
stubify unzipsfx
del unzipsfx
# Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000
hk68: unix_make
$(MAKE) unzips CC="gcc" LD="gcc"\
LF="-n $(LF)" SL="-n $(SL)" FL="-n $(FL)"\
CF="-ga -X138 -I. $(LOC) -Dlocaltime=localti -Dtimezone=timezon"
# Linux (Posix, approximately SysV): virtually any version since before 0.96.
linux: unix_make
$(MAKE) unzips CC=gcc LD=gcc
# Linux host with go32 (djgpp) cross-compiler (go32crs.tgz) for 32-bit DOS.
# Change msdos_$O target (near line 303 above) from msdos\msdos to msdos/msdos.
linux_dos: unix_make
$(MAKE) unzips CC=go32gcc LD=go32gcc M=msdos CF="-Wall -O2 -I. $(LOC)"
# go32-strip unzip
# Due to limitations of the cross-compiling package, this has to be
# done manually:
@echo Copy $(UNZIPS) to your DOS partition and use coff2exe.
# Linux ELF shared library (ooo, it's so easy). This is a test target for
# now, and it only makes the UnZip/ZipInfo stuff (not fUnZip or UnZipSFX).
# Do "make clean" before using this target the first time, eh? The version
# number may change to match the UnZip version. Or not. Whatever. Also
# do "setenv LD_LIBRARY_PATH `pwd`" or similar to test the DLL in place
# (with unzip, which is now the version linked with the shared library).
#
linux_shlib: unix_make
$(MAKE) objsdll CC=gcc CF="$(CF) -DDLL -fPIC"
gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.2 $(OBJSDLL)
ln -sf libunzip.so.0.2 libunzip.so.0
gcc -c -O unzipstb.c
gcc -o unzip unzipstb.o -L. -lunzip
# Linux ELF shared library, as above, but using inflate() from zlib (libz.so)
# instead of the original UnZip version. (libz was libgz prior to 0.94)
linux_shlibz: unix_make
$(MAKE) objsdll CC=gcc CF="$(CF) -DDLL -DUSE_ZLIB -fPIC"
gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.2 $(OBJSDLL)
ln -sf libunzip.so.0.2 libunzip.so.0
gcc -c -O unzipstb.c
gcc -o unzip unzipstb.o -L. -lunzip -lz
# Minix 1.5 PC for the 386. Invoke as is to use default cc, or as "make
# minix CC=gcc" to use gcc. Try "make linux" if you have a working termios.h.
minix: unix_make
$(MAKE) unzips CF="$(CF) -DMINIX -DSHORT_NAMES" CC=$(CC) LD=$(CC)
# MS-DOS: Microsoft C 6.0 and NMAKE. "nmake msc_dos" works fine, aside
# from an irrelevant message (possibly) about the creation of a temporary
# file. Environment variable LOCAL_UNZIP (or CL) should be set via "SET
# LOCAL_UNZIP=-FPi87" if you use the 80x87 library; also add -G2 or -G3 if
# using a 286/386/486. Note that setting too many things via LOCAL_UNZIP
# may make the command line too long for the default COMMAND.COM shell, so
# use CL instead in that case. With VC++ Pro, -O2 instead of -Oait seems to
# work OK and makes the executables slightly faster. Use at your own risk.
#
msc_dos: _msc_dos fu_msc sfx_msc
# can change UnZip memory model (-AS) to large (-AL) if necessary, but should
# no longer be necessary in UnZip 5.11 and later
_msc_dos: msc_rsp
$(MAKE) unzip.exe CF="-AS -W3 -Oait -Gs -nologo -I. $(LOC)" CC=cl\
LD=link E=.exe O=.obj M=msdos LOBJS="" LF="@msc_rsp" LF2=""
del msc_rsp
msc_rsp:
echo $(OBJS1:.o=.obj) + > msc_rsp
echo msdos.obj $(OBJS2:.o=.obj)/noi/e/st:0x0c00; >> msc_rsp
fu_msc:
set CL=-AS -Oait -Gs -nologo -I.
$(MAKE) funzip.exe CF="$(LOC)" CC=cl LD=link E=.exe O=.obj\
FL="/noi/nol/e" FL2=",funzip;" RM=del CP=copy
sfx_msc:
set CL=-AS -Oait -Gs -nologo -I.
$(MAKE) unzipsfx.exe CF="$(LOC)" CC=cl LD=link E=.exe O=.obj M=msdos\
SL="/noi/nol/e" SL2=",unzipsfx;" RM=del CP=copy
# $(NOD): intended to be used as SET NOD=-link /nod:slibcep to allow the
# use of default library names (slibce.lib) instead of protected-mode
# names (slibcep.lib), but it fails: MSC adds its own /nod qualifier,
# and there seems to be no way to override this. Typical...
#
# THIS TARGET RETAINED AS AN EXAMPLE ONLY. USE MAKEFILE.OS2.
#
#msc_os2: # 16-bit OS/2 (1.x) with MSC 6.00 (use makefile.os2)
# $(MAKE) -nologo unzips CC=cl LD=cl E=.exe O=.obj\
# OBJS="$(OBJS_OS2)" OBJZ="$(OBJZ_OS2)"\
# CF="-nologo -AC -Ocegit -G2s -DOS2 -DMSC $(LOC)"\
# LF="-nologo -AC $(LOC) -Lp -F 2000"\
# LF2="unzip.def -o unzip.exe $(NOD)" CP=copy RM=del\
# ZL="-nologo -AC $(LOC) -Lp -Fb" ZL2="zipinfo.def -o zipinfo.exe"
# NeXT info.
next:
@echo
@echo\
' Please pick a specific NeXT target: "make next10" will create a generic'
@echo\
' NeXT executable; "make next2x" will create a smaller executable (for'
@echo\
' NeXTstep 2.0 and higher); "make next3x" will create a small executable'
@echo\
' with significantly better optimization (NeXTstep 3.0 and higher only);'
@echo\
' "make nextfat" will create a fat, multi-architecture (NeXT plus Intel)'
@echo\
' executable (NeXTstep 3.1 and higher only).'
@echo
# 68030 BSD 4.3+Mach. NeXT 2.x: make the executable smaller.
next2x: unix_make
$(MAKE) unzips LF2="-object -s"
# NeXT 3.x: as above, plus better optimization.
next3x: unix_make
$(MAKE) unzips CF="-O2 -I. $(LOC)" LF2="-object -s"
# NeXT 3.1+: make the executable fat (multi-architecture binary [MAB],
# for "black" [NeXT] and "white" [x86] hardware, so far).
nextfat: unix_make
$(MAKE) unzips CF="-O2 -I. $(LOC) -arch i386 -arch m68k" \
LF2="-arch i386 -arch m68k -object -s"
# Sequent Symmetry running Dynix/ptx (sort of SysV.3): needs to link
# with libseq to get symlink().
ptx: unix_make
$(MAKE) unzips CF="$(CF) -DSYSV -DTERMIO -DPTX" LF2="$(LF2) -lseq"
# Pyramid 90X (probably all) under >= OSx4.1, either universe. (This is an
# experimental target! If it fails, use either pyr_ucb or pyr_att instead.)
# The make in the BSD half is too stupid to understand $(MAKE), sigh...
pyramid: unix_make
-make -f unix/Makefile pyr_`universe`
# REGULUS: 68040-based, "real-time" SysV.3 mutant; uses gcc, with "REGULUS"
# predefined.
regulus: unix_make
$(MAKE) unzips CF="$(CF) -traditional -DSYSV -DNO_MKDIR"
# IBM RS/6000 under AIX 3.2
rs6000: unix_make
$(MAKE) unzips CF="$(CF) -DBSD -D_BSD -DUNIX" LF2="-lbsd"
# SCO cross compile from Unix to DOS. Tested with Xenix/386 and OpenDeskTop.
# Should work with Xenix/286 as well. (davidsen) Note that you *must* remove
# the Unix objects and executable before doing this! (Piet Plomp: gcc won't
# recognize the -M0 flag which forces 8086 code.) (GRR: may need to reduce
# stack to 0c00h if using 286/small-model code...?)
sco_dos: unix_make
$(MAKE) unzips CF="-O -I. $(LOC) -dos -M0" M=msdos\
LF="-dos -F 2000" LF2="-o unzip.exe"\
FL="-dos" FL2="-o funzip.exe" SL="-dos" SL2="-o unzipsfx.exe"
# SCO UNIX with shared libraries and no international support. If you are
# not using a USA-style keyboard and display, you may want to remove -nointl
# to get support. It adds quite a bit to the size of the executable.
sco_sl: unix_make
$(MAKE) unzips LF="$(LF) -nointl" LF2="$(LF2) -lc_s"\
SL="$(SL) -nointl" FL="$(FL) -nointl"
# SCO Xenix/286 2.3.3 with 2.2.1 development system
sco_x286: unix_make
$(MAKE) unzips CF="$(CF) -Mel2 -LARGE -DTERMIO" LF="$(LF) -Mel2 -LARGE"
# Sequent Symmetry with Dynix. (386, but needs -DZMEM)
# This should also work on Balance but I can't test it just yet.
sequent: unix_make
$(MAKE) unzips CF="$(CF) -DBSD -DZMEM"
# Generic System V + GNU C
sysv_gcc: unix_make
$(MAKE) unzips CC=gcc LD=gcc CF="-O2 -I. -DSYSV $(LOC)" LF2=""
$(STRIP) $(UNZIPS)
# AT&T 6300+, System V.2 Unix: run-time out-of-memory error if don't use -Ml;
# also compile-time error if work arrays dimensioned at HSIZE+2 (>32K)
sysv6300: unix_make
$(MAKE) unzips CF="$(CF) -Ml -DSYSV" LF="$(LF) -Ml"\
SL="$(SL) -Ml" FL="$(FL) -Ml"
# Texas Instruments System V.3 (running on HP 9000-1500)
ti_sysv: unix_make
$(MAKE) unzips CF="$(CF) -DSYSV -DNO_UID_GID -DUID_USHORT"
# SCO Xenix (Joe Foster 950508: "unzip needs to be linked with -lx [for the
# opendir(), readdir(), telldir(), rewinddir(), and closedir() calls]")
xenix: unix_make
$(MAKE) unzips LF2="$(LF2) -lx"
# Wombat 68000 (or whatever).
# I didn't do this. I swear. No, really.
wombat: unix_make
@echo
@echo ' Ha ha! Just kidding.'
@echo

722
zip/unzip/atari/atari.c Executable file
View File

@ -0,0 +1,722 @@
/*---------------------------------------------------------------------------
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()
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
char *wildspec; /* only used first time on a given dir */
{
static DIR *dir = (DIR *)NULL;
static char *dirname, *wildname, matchname[FILNAMSIZ];
static int firstcall=TRUE, 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 (firstcall) { /* first call: must initialize everything */
firstcall = FALSE;
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '/')) == (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: can't allocate wildcard buffers\n"));
strcpy(matchname, wildspec);
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(dir)) != (struct dirent *)NULL) {
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)) { /* 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(dir);
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) */
strcpy(matchname, wildspec);
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (dir == (DIR *)NULL) {
firstcall = TRUE; /* 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(dir)) != (struct dirent *)NULL)
/* May need special TOS handling here. [cjh] */
if (match(file->d_name, wildname, 0)) { /* 0 == don't ignore case */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
closedir(dir); /* have read at least one dir entry; nothing left */
dir = (DIR *)NULL;
firstcall = TRUE; /* 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 UNIX_:
case ATARI_:
/* minix filesystem under MiNT on Atari [cjh] */
case VMS_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
return 0;
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case TOPS20_:
default:
tmp = !(tmp & 1) << 1; /* read-only bit --> write perms bits */
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() */
/************************/
/* return 0 if no error, 1 if caution (filename */
int mapname(__G__ renamed) /* truncated), 2 if warning (skip file because */
__GDEF /* dir doesn't exist), 3 if error (skip file), */
int renamed; /* or 10 if out of memory (skip file) */
{ /* [also IZ_VOL_LABEL, IZ_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 quote = FALSE; /* flags */
int error = 0;
register unsigned workch; /* hold the character being tested */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return IZ_VOL_LABEL; /* can't set disk volume labels in Unix */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!G.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) == 10)
return 10; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (G.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) {
if (quote) { /* if character quoted, */
*pp++ = (char)workch; /* include it literally */
quote = FALSE;
} else
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if ((error = checkdir(__G__ pathcomp, APPEND_DIR)) > 1)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave directory semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp; /* keep for now; remove VMS ";##" */
*pp++ = (char)workch; /* later, if requested */
break;
case '\026': /* control-V quote for special chars */
quote = TRUE; /* set flag for next character */
break;
#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 */
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!G.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
/*---------------------------------------------------------------------------
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",
G.filename));
}
return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
}
return 2; /* dir existed already; don't look for data to extract */
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
G.filename));
return 3;
}
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: 1 - (on APPEND_NAME) truncated filename
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - 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", 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 2; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: can't create %s\n\
unable to process %s.\n", buildpath, G.filename));
free(buildpath);
return 3; /* path didn't exist, tried to create, failed */
}
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", buildpath, G.filename));
free(buildpath);
return 3; /* path existed but wasn't dir */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0;
} /* 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", pathcomp));
free(buildpath);
buildpath = end = (char *)NULL;
return 0;
}
/*---------------------------------------------------------------------------
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", 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", G.filename, buildpath));
return 1; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0; /* could check for existence here, prompt for new name... */
}
/*---------------------------------------------------------------------------
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 10;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", buildpath));
return 0;
}
/*---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------*/
#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 0;
}
if ((rootlen = strlen(pathcomp)) > 0) {
if (pathcomp[rootlen-1] == '/') {
pathcomp[--rootlen] = '\0';
}
if (rootlen > 0 && (stat(pathcomp, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))) /* path does not exist */
{
if (!G.create_dirs /* || iswild(pathcomp) */ ) {
rootlen = 0;
return 2; /* skip (or treat as stored file) */
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (mkdir(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: can't create extraction directory: %s\n",
pathcomp));
rootlen = 0; /* path didn't exist, tried to create, and */
return 3; /* failed: file exists, or 2+ levels required */
}
}
if ((rootpath = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return 10;
}
strcpy(rootpath, pathcomp);
rootpath[rootlen++] = '/';
rootpath[rootlen] = '\0';
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return 0;
}
#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);
return 0;
}
return 99; /* 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_flags;
iztimes zt;
#endif
ztimbuf tp;
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate a storage area, put the uncom-
pressed "data" in it, and create the link. 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;
char *linktarget = (char *)malloc((unsigned)G.lrec.ucsize+1);
fclose(G.outfile); /* close "data" file... */
G.outfile = fopen(G.filename, FOPR); /* ...and reopen for reading */
if (!linktarget || (fread(linktarget, 1, ucsize, G.outfile) !=
(int)ucsize)) {
Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed\n", G.filename));
if (linktarget)
free(linktarget);
fclose(G.outfile);
return;
}
fclose(G.outfile); /* close "data" file for good... */
unlink(G.filename); /* ...and delete it */
linktarget[ucsize] = '\0';
Info(slide, 0, ((char *)slide, "-> %s ", linktarget));
if (symlink(linktarget, G.filename)) /* create the real link */
perror("symlink error");
free(linktarget);
return; /* can't set time on symlinks */
}
fclose(G.outfile);
/*---------------------------------------------------------------------------
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 ?
ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
&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_file_date,
G.lrec.last_mod_file_time);
}
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_file_date,
G.lrec.last_mod_file_time);
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: can't set the time for %s\n", 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() */
#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 */

8
zip/unzip/atari/make_unz.mup Executable file
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

11
zip/unzip/beos/Contents Executable file
View File

@ -0,0 +1,11 @@
Contents of the "beos" sub-directory for UnZip 5.31 and later:
Contents this file
README notes from the author of the BeOS port
Makefile makefile for building UnZip (sorry, no project files)
beos.c BeOS-specific routines (similar to the Unix ones)
beos.h structures for the BeOS extra field
This port supports both Metrowerks CodeWarrior and GNU C.
- Chris Herborth (chrish@qnx.com)

306
zip/unzip/beos/Makefile Executable file
View File

@ -0,0 +1,306 @@
#==============================================================================
# Makefile for UnZip, UnZipSFX and fUnZip: BeOS
# Version: 5.31 25 May 1997
#==============================================================================
# INSTRUCTIONS (such as they are):
#
# "make list" - lists all supported compilers (targets)
# "make foo" - makes UnZip in current directory using the foo compiler
#
# 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.
#
# You might want to go down to the "installation" section and set the prefix
# to something else; not everyone is as strange as me, and you might not want
# to put your Info-ZIP executables in /boot/usr/local/bin. [cjh]
all:
@echo ''
@echo 'Make what? You must say what compiler you want to use -- '
@echo 'for example, "make -f beos/Makefile mwcc".'
@echo ''
@echo 'The supported compilers are:'
@echo ''
@echo ' gcc GNU C'
@echo ' mwcc Metrowerks CodeWarrior'
@echo ''
list: all
#####################
# MACRO DEFINITIONS #
#####################
MAKE = make -j 2 -f beos/Makefile
# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
# such as -DDOSWILD).
# UnZip flags
MW_CC = mwcc
GNU_CC = gcc
LD = $(CC)
LOC = $(LOCAL_UNZIP) -DPASSWD_FROM_STDIN
AF = $(LOC)
# -ansi strict doesn't work with the AADR9 stdio.h... d'oh!
#MW_CF = -w9 -ansi strict -O7 -rostr -I. $(LOC)
MW_CF = -w9 -O7 -rostr -I. $(LOC)
MW_LF = -o unzip
MW_LF2 =
GNU_CF = -Wall -ansi -mcpu=604 -O3 -I. $(LOC)
GNU_LF = -o unzip
GNU_LF2 =
# 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
SHELL = /bin/sh
# defaults for crc32 stuff and system-dependent headers
CRC32 = crc32
OSDEP_H = beos/beos.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
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 crypt_$O globals_$O inflate_$O ttyio_$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/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 zipinfo$E
# this is a little ugly...well, no, it's a lot ugly:
MANS = unix/unzip.1 unix/unzipsfx.1 unix/zipinfo.1 unix/funzip.1
DOCS = unzip.doc unzipsfx.doc zipinfo.doc funzip.doc
###############################################
# 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)
$(LD) $(LF) $(LOBJS) $(LF2)
unzipsfx$E: $(OBJX)
$(LD) $(SL) $(LOBJX) $(SL2)
funzip$E: $(OBJF)
$(LD) $(FL) $(OBJF) $(FL2)
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 version.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) crypt.c crypt_.c
$(CC) -c $(CF) -DFUNZIP 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
globals_$O: globals.c $(UNZIP_H) # funzip only
$(CP) globals.c globals_.c
$(CC) -c $(CF) -DFUNZIP globals_.c
$(RM) globals_.c
inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CP) inflate.c inflate_.c
$(CC) -c $(CF) -DFUNZIP inflate_.c
$(RM) inflate_.c
ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CP) ttyio.c ttyio_.c
$(CC) -c $(CF) -DFUNZIP ttyio_.c
$(RM) ttyio_.c
process_$O: process.c $(UNZIP_H) # unzipsfx only
$(CP) process.c process_.c
$(CC) -c $(CF) -DSFX process_.c
$(RM) process_.c
beos$O: beos/beos.c $(UNZIP_H) version.h # BeOS only
$(CC) -c $(CF) beos/beos.c
# version() not used by unzipsfx, so no version.h dependency
beos_$O: beos/beos.c $(UNZIP_H) # unzipsfx only
$(CP) beos/beos.c beos_.c
$(CC) -c $(CF) -Ibeos -DSFX beos_.c
$(RM) beos_.c
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h # unzipsfx only
$(CP) unzip.c unzipsfx.c
$(CC) -c $(CF) -DSFX unzipsfx.c
$(RM) unzipsfx.c
# 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
install: $(UNZIPS) $(MANS)
$(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 unix/unzip.1 $(MANDIR)/unzip.$(manext)
$(INSTALL) -m 644 unix/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
$(INSTALL) -m 644 unix/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
$(INSTALL) -m 644 unix/funzip.1 $(MANDIR)/funzip.$(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.'
######################################################################
# Make rules for the supported compilers
gcc:
@echo ''
@echo 'WARNING: GNU C support is completely untested right now!'
@echo ' It is not likely even to compile yet.'
@echo ''
@echo ' You might want to contact chrish@qnx.com to see'
@echo ' if there are any GNU C patches for UnZip 5.31'
@echo ' before trying this.'
@echo ''
@echo 'Sleeping for 15 seconds so you can read this, then we'll try...'
@sleep 15s
@echo ''
@echo 'Making with GNU C...'
@echo ''
$(MAKE) $(UNZIPS) CC=$(GNU_CC) CF="$(GNU_CF)" LF="$(GNU_LF)" \
LF2="$(GNU_LF2)"
mwcc:
@echo 'Making with Metrowerks CodeWarrior...'
@echo ''
$(MAKE) $(UNZIPS) CC=$(MW_CC) CF="$(MW_CF)" LF="$(MW_LF)" \
LF2="$(MW_LF2)"
foo: list
@echo 'I was kidding about the "foo" compiler.'
@echo ''

38
zip/unzip/beos/README Executable file
View File

@ -0,0 +1,38 @@
UnZip 5.31 for BeOS
UnZip 5.30 was the first official release of Info-ZIP's UnZip to support
the filesystem in BeOS.
UnZip 5.31 supports the new filesystem present in Advanced Access Release
DR9 of BeOS.
*** WARNING ***
The format of the data stored for the BeOS file attributes had to change
between unzip 5.31b and unzip 5.31c! This makes the new unzip incompatible
with the old zip's BeOS file attributes.
You can still unpack the _data_ in older zip files (and there are several
floating around, even though the unzip 5.31b for DR9 beta was only available
for a week), but you won't be able to recover the file attributes in those
archives.
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.
Please report any bugs to Zip-Bugs@lists.wku.edu.
- Chris Herborth (chrish@qnx.com)
May 29/1997

947
zip/unzip/beos/beos.c Executable file
View File

@ -0,0 +1,947 @@
/*---------------------------------------------------------------------------
beos.c
BeOS-specific routines for use with Info-ZIP's UnZip 5.30 and later.
(based on unix/unix.c)
Contains: readdir()
do_wild() <-- generic enough to put in fileio.c?
mapattr()
mapname()
checkdir()
mkdir()
close_outfile()
version()
scanBeOSexfield()
isBeOSexfield()
set_file_attrs()
setBeOSexfield()
printBeOSexfield()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#include "beos.h"
#include <errno.h> /* Just make sure we've got a few things... */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
/* For the new post-DR8 file attributes */
#include <fs_attr.h>
int set_file_attrs( const char *, const unsigned char *, const off_t );
/* I haven't gotten gcc for DR9 yet... */
#ifdef __GNUC__
#warn GNU C is not supported right now, you have been warned!
#endif
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
char *wildspec; /* only used first time on a given dir */
{
static DIR *dir = (DIR *)NULL;
static char *dirname, *wildname, matchname[FILNAMSIZ];
static int firstcall=TRUE, 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 (firstcall) { /* first call: must initialize everything */
firstcall = FALSE;
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '/')) == (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: can't allocate wildcard buffers\n"));
strcpy(matchname, wildspec);
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((dir = opendir(dirname)) != (DIR *)NULL) {
while ((file = readdir(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)) { /* 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(dir);
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) */
strcpy(matchname, wildspec);
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (dir == (DIR *)NULL) {
firstcall = TRUE; /* 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(dir)) != (struct dirent *)NULL)
if (match(file->d_name, wildname, 0)) { /* 0 == don't ignore case */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
closedir(dir); /* have read at least one dir entry; nothing left */
dir = (DIR *)NULL;
firstcall = TRUE; /* 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 UNIX_:
case VMS_:
case BEOS_:
G.pInfo->file_attr = (unsigned)(tmp >> 16);
return 0;
case AMIGA_:
tmp = (unsigned)(tmp>>17 & 7); /* Amiga RWE bits */
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
break;
/* all remaining cases: expand MSDOS read-only bit into write perms */
case FS_FAT_:
case FS_HPFS_:
case FS_NTFS_:
case MAC_:
case ATARI_: /* (used to set = 0666) */
case TOPS20_:
default:
tmp = !(tmp & 1) << 1; /* read-only bit --> write perms bits */
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() */
/************************/
/* return 0 if no error, 1 if caution (filename */
int mapname(__G__ renamed) /* truncated), 2 if warning (skip file because */
__GDEF /* dir doesn't exist), 3 if error (skip file), */
int renamed; /* or 10 if out of memory (skip file) */
{ /* [also IZ_VOL_LABEL, IZ_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 quote = FALSE; /* flags */
int error = 0;
register unsigned workch; /* hold the character being tested */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return IZ_VOL_LABEL; /* can't set disk volume labels in Unix */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!G.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) == 10)
return 10; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (G.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) {
if (quote) { /* if character quoted, */
*pp++ = (char)workch; /* include it literally */
quote = FALSE;
} else
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if ((error = checkdir(__G__ pathcomp, APPEND_DIR)) > 1)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave directory semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
case '\026': /* control-V quote for special chars */
quote = TRUE; /* set flag for next character */
break;
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!G.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
/*---------------------------------------------------------------------------
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",
G.filename));
}
return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
}
return 2; /* dir existed already; don't look for data to extract */
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
G.filename));
return 3;
}
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: 1 - (on APPEND_NAME) truncated filename
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - 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", 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. */
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 2; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
if (mkdir(buildpath, 0777) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: can't create %s\n\
unable to process %s.\n", buildpath, G.filename));
free(buildpath);
return 3; /* path didn't exist, tried to create, failed */
}
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", buildpath, G.filename));
free(buildpath);
return 3; /* path existed but wasn't dir */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n", buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0;
} /* 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", pathcomp));
free(buildpath);
buildpath = end = (char *)NULL;
return 0;
}
/*---------------------------------------------------------------------------
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", 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", G.filename, buildpath));
return 1; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0; /* could check for existence here, prompt for new name... */
}
/*---------------------------------------------------------------------------
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 10;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", buildpath));
return 0;
}
/*---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------*/
#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 0;
}
if ((rootlen = strlen(pathcomp)) > 0) {
if (pathcomp[rootlen-1] == '/') {
pathcomp[--rootlen] = '\0';
}
if (rootlen > 0 && (stat(pathcomp, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))) /* path does not exist */
{
if (!G.create_dirs /* || iswild(pathcomp) */ ) {
rootlen = 0;
return 2; /* skip (or treat as stored file) */
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (mkdir(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: can't create extraction directory: %s\n",
pathcomp));
rootlen = 0; /* path didn't exist, tried to create, and */
return 3; /* failed: file exists, or 2+ levels required */
}
}
if ((rootpath = (char *)malloc(rootlen+2)) == (char *)NULL) {
rootlen = 0;
return 10;
}
strcpy(rootpath, pathcomp);
rootpath[rootlen++] = '/';
rootpath[rootlen] = '\0';
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return 0;
}
#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);
return 0;
}
return 99; /* should never reach */
} /* end function checkdir() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
iztimes zt;
ush z_uidgid[2];
unsigned eb_izux_flg;
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate a storage area, put the uncom-
pressed "data" in it, and create the link. Since we know it's a symbolic
link to start with, we shouldn't have to worry about overflowing unsigned
ints with unsigned longs.
---------------------------------------------------------------------------*/
#ifdef SYMLINKS
if (G.symlnk) {
unsigned ucsize = (unsigned)G.lrec.ucsize;
char *linktarget = (char *)malloc((unsigned)G.lrec.ucsize+1);
fclose(G.outfile); /* close "data" file... */
G.outfile = fopen(G.filename, FOPR); /* ...and reopen for reading */
if (!linktarget || fread(linktarget, 1, ucsize, G.outfile) !=
(int)ucsize)
{
Info(slide, 0x201, ((char *)slide,
"warning: symbolic link (%s) failed\n", G.filename));
if (linktarget)
free(linktarget);
fclose(G.outfile);
return;
}
fclose(G.outfile); /* close "data" file for good... */
unlink(G.filename); /* ...and delete it */
linktarget[ucsize] = '\0';
Info(slide, 0, ((char *)slide, "-> %s ", linktarget));
if (symlink(linktarget, G.filename)) /* create the real link */
perror("symlink error");
free(linktarget);
return; /* can't set time on symlinks */
}
#endif /* SYMLINKS */
fclose(G.outfile);
/*---------------------------------------------------------------------------
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
/*---------------------------------------------------------------------------
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. If we have a Unix extra field, however,
we're laughing: both mtime and atime are ours. On the other hand, we
then have to check for restoration of UID/GID.
---------------------------------------------------------------------------*/
eb_izux_flg = (G.extra_field ?
ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length,
0, &zt, z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nclose_outfile: Unix e.f. modif. time = %ld\n",
zt.mtime));
} else {
zt.mtime = dos_to_unix_time(G.lrec.last_mod_file_date,
G.lrec.last_mod_file_time);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "close_outfile: Unix e.f. access time = %ld\n",
zt.atime));
} else {
zt.atime = zt.mtime;
TTrace((stderr, "\nclose_outfile: modification/access times = %ld\n",
zt.mtime));
}
/* if -X option was specified and we have UID/GID info, restore it */
if (G.X_flag && eb_izux_flg & EB_UX2_VALID) {
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n"));
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
{
Info(slide, 0x201, ((char *)slide,
"warning: can't set UID %d and/or GID %d for %s\n",
z_uidgid[0], z_uidgid[1], G.filename));
/* GRR: change return type to int and set up to return warning after utime() */
}
}
/* set the file's access and modification times */
if (utime(G.filename, (struct utimbuf *)&zt)) {
Info(slide, 0x201, ((char *)slide,
"warning: can't set the time for %s\n", G.filename));
}
/* handle the BeOS extra field if present */
{
void *ptr = scanBeOSexfield( G.extra_field,
G.lrec.extra_field_length );
if( ptr ) {
setBeOSexfield( G.filename, ptr );
}
}
} /* end function close_outfile() */
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
sprintf((char *)slide, LoadFarString(CompiledWith),
#ifdef __MWERKS__
"Metrowerks CodeWarrior", "",
#else
# ifdef __GNUC__
"GNU C/C++", "",
# endif
#endif
"BeOS ",
#ifdef __POWERPC__
"(PowerPC)",
#else
/* Some day we may have other architectures... */
"(unknown)",
#endif
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);
} /* end function version() */
#endif /* !SFX */
/******************************/
/* Extra field functions */
/******************************/
/*
** Scan the extra fields in extra_field, and look for a BeOS EF; return a
** pointer to that EF, or NULL if it's not there.
*/
uch *scanBeOSexfield( uch *extra_field, unsigned ef_len )
{
uch *ptr = extra_field;
while( ptr < extra_field + ef_len ) {
if( isBeOSexfield( ptr ) ) {
return ptr;
} else {
ush size;
ptr += 2; /* skip over the ID */
size = makeword( ptr ); /* find the size of this EF */
ptr += 2;
ptr += size; /* skip this EF */
}
}
return NULL;
}
int isBeOSexfield( uch *extra_field )
{
if( extra_field != NULL ) {
uch *ptr = extra_field;
ush id = 0;
ush size = 0;
id = makeword( ptr );
ptr += 2;
size = makeword( ptr );
ptr += 2;
if( id == EF_BE_ID && size >= EF_BE_SIZE ) {
return TRUE;
}
}
return FALSE;
}
/* Used by setBeOSexfield():
Set a file/directory's attributes to the attributes passed in.
If set_file_attrs() fails, an error will be returned:
EOK - no errors occurred
(other values will be whatever the failed function returned; no docs
yet, or I'd list a few)
*/
int set_file_attrs( const char *name,
const unsigned char *attr_buff,
const off_t attr_size )
{
int retval = EOK;
unsigned char *ptr;
const unsigned char *guard;
int fd;
ptr = (unsigned char *)attr_buff;
guard = ptr + attr_size;
fd = open( name, O_RDWR );
if( fd < 0 ) {
return errno; /* should it be -fd ? */
}
while( ptr < guard ) {
ssize_t wrote_bytes;
struct attr_info fa_info;
const char *attr_name;
const unsigned char *attr_data;
attr_name = (char *)&(ptr[0]);
ptr += strlen( attr_name ) + 1;
memcpy( &fa_info, ptr, sizeof( struct attr_info ) );
ptr += sizeof( struct attr_info );
attr_data = ptr;
ptr += fa_info.size;
if( ptr > guard ) {
/* We've got a truncated attribute. */
Info(slide, 0x201, ((char *)slide,
"warning: truncated attribute\n"));
break;
}
wrote_bytes = fs_write_attr( fd, attr_name, fa_info.type, 0,
attr_data, fa_info.size );
if( wrote_bytes != fa_info.size ) {
Info(slide, 0x201, ((char *)slide,
"warning: wrote %ld attribute bytes of %ld\n",(unsigned long)wrote_bytes,(unsigned long)fa_info.size));
}
}
close( fd );
return retval;
}
void setBeOSexfield( char *path, uch *extra_field )
{
uch *ptr = extra_field;
ush id = 0;
ush size = 0;
ulg full_size = 0;
uch flags = 0;
uch *attrbuff = NULL;
int retval;
if( extra_field == NULL ) {
return;
}
/* Collect the data from the extra field buffer. */
id = makeword( ptr ); ptr += 2; /* we don't use this... */
size = makeword( ptr ); ptr += 2;
full_size = makelong( ptr ); ptr += 4;
flags = *ptr; ptr++;
/* Do a little sanity checking. */
if( flags & EF_BE_FL_BADBITS ) {
/* corrupted or unsupported */
Info(slide, 0x201, ((char *)slide,
"Unsupported flags set for this BeOS extra field, skipping.\n"));
return;
}
if( size <= EF_BE_SIZE ) {
/* corrupted, unsupported, or truncated */
Info(slide, 0x201, ((char *)slide,
"BeOS extra field is %d bytes, should be at least %d.\n",size,EF_BE_SIZE));
return;
}
/* Find the BeOS file attribute data. */
if( flags & EF_BE_FL_NATURAL ) {
/* Uncompressed data */
attrbuff = ptr;
} else {
/* Compressed data */
attrbuff = (uch *)malloc( full_size );
if( attrbuff == NULL ) {
/* No memory to uncompress attributes */
Info(slide, 0x201, ((char *)slide,
"Can't allocate memory to uncompress file attributes.\n"));
return;
}
retval = memextract( __G__ attrbuff, full_size,
ptr, size - EF_BE_SIZE );
if( retval != PK_OK ) {
/* error uncompressing attributes */
Info(slide, 0x201, ((char *)slide,
"Error uncompressing file attributes.\n"));
/* Some errors here might not be so bad; we should expect */
/* some truncated data, for example. If the data was */
/* corrupt, we should _not_ attempt to restore the attrs */
/* for this file... there's no way to detect what attrs */
/* are good and which are bad. */
free( attrbuff );
return;
}
}
/* Now attempt to set the file attributes on the extracted file. */
retval = set_file_attrs( path, attrbuff, (off_t)full_size );
if( retval != EOK ) {
Info(slide, 0x201, ((char *)slide,
"Error writing file attributes.\n"));
}
/* Clean up, if necessary */
if( attrbuff != ptr ) {
free( attrbuff );
}
return;
}
void printBeOSexfield( int isdir, uch *extra_field )
{
uch *ptr = extra_field;
ush id = 0;
ush size = 0;
ulg full_size = 0;
uch flags = 0;
/* Tell picky compilers to be quiet. */
isdir = isdir;
if( extra_field == NULL ) {
return;
}
/* Collect the data from the buffer. */
id = makeword( ptr ); ptr += 2;
size = makeword( ptr ); ptr += 2;
full_size = makelong( ptr ); ptr += 4;
flags = *ptr; ptr++;
if( id != EF_BE_ID ) {
/* not a 'Be' field */
printf( "\t*** Unknown field type (0x%04x, '%c%c')\n", id,
(char)(id >> 8), (char)id );
}
if( flags & EF_BE_FL_BADBITS ) {
/* corrupted or unsupported */
printf( "\t*** Corrupted BeOS extra field:\n" );
printf( "\t*** unknown bits set in the flags\n" );
printf( "\t*** (Possibly created by an old version of zip for BeOS.\n" );
}
if( size <= EF_BE_SIZE ) {
/* corrupted, unsupported, or truncated */
printf( "\t*** Corrupted BeOS extra field:\n" );
printf( "\t*** size is %d, should be larger than %d\n", size,
EF_BE_SIZE );
}
if( flags & EF_BE_FL_NATURAL ) {
/* Uncompressed data */
printf( "\tBeOS extra field data (uncompressed):\n" );
printf( "\t\t%d data bytes\n", full_size );
} else {
/* Compressed data */
printf( "\tBeOS extra field data (compressed):\n" );
printf( "\t\t%d compressed bytes\n", size - EF_BE_SIZE );
printf( "\t\t%d uncompressed bytes\n", full_size );
}
}

39
zip/unzip/beos/beos.h Executable file
View File

@ -0,0 +1,39 @@
/* 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_ID 0x6542 /* 'Be' in little-endian form */
#define EF_BE_SIZE 5 /* at least unsigned long + flag */
#define EF_BE_FL_NATURAL 0x01 /* data is 'natural' (not compressed) */
#define EF_BE_FL_BADBITS 0xfe /* bits currently undefined */
/*
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_NATURAL = 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_NATURAL, 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_L_BE_LEN ) bytes of data, and full_size
should equal ( ef_size - EB_L_BE_LEN ).
If the data is compressed, there will be ( ef_size - EB_L_BE_LEN ) 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
attr_data (length in attr_info.size)
*/

140
zip/unzip/cmsmvs/README.CMS Executable file
View File

@ -0,0 +1,140 @@
[Notes accompanying first beta of VM/CMS port; still mostly applicable
to the UnZip 5.2 release. Somebody with a VM/CMS system will have to
update this file.]
Thank you for trying this first port of UNZIP for VM/CMS and MVS!
This is the first beta so there might be some bugs in it.
-----------------------------------------------------------------------
Additional notes from Greg Hartwig (7/96):
The UNZIP MODULE has been packed to preserve CMS line ends
and is shipped as UNZIP.MOD.
To restore it to an executable module on CMS, do the following:
1. Upload it to CMS as a Fixed file with LRECL 1024.
Example, from a DOS or OS/2 window, type this:
SEND unzip.mod A:unzip module a (RECFM F LRECL 1024
2. Use COPYFILE to unpack the file.
Example, in CMS type this:
COPYFILE UNZIP MODULE A (UNPACK REPLACE OLDDATE
'+' and '-' are valid characters in CMS file names, so the code
to remove them for CMS is only done for MVS now.
I don't have access to an MVS system, so my changes to the
code have only been tested on CMS. C/370 version 2.2 was used
to compile the code.
Greg Hartwig
e-mail: ghartwig@ix.netcom.com
ghartwig@vnet.ibm.com
-----------------------------------------------------------------------
Using under VM/CMS:
---------------------------
1. To use the Info-ZIP's UNZIP under VM/CMS you need:
- C/370 ver 2.1 compiler or another compatible compiler supporting
long names for function/variable names.
- that the disk where the compiler is on is accessed
- at least the following nucleus extensions (display of NUCXMAP):
NAME ENTRY USERWORD ORIGIN BYTES AMODE (Attributes)
EDCX24 0038B000 00000000 0038B000 00002FD8 ANY SYSTEM
EDCXV 001D1000 00000000 001D1000 000824C8 31 SYSTEM
2. To compile the program under VM/CMS do :
- unzip all the files from unz512vm.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.
- execute UNZVMC to compile and link all the sources.
- if everything is ok you will get an UNZIP MODULE
3. Using UNZIP
- Just read the UNZIP.DOC
- A few exceptions concerning VM/CMS
3.1. use always filename.filetype.mdisk format to specify
vm/cms files
3.2. 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 :-)
3.3. The date and the time of the output files is set to the
current system date/time - not according the date/time in
the zip file.
3.4. You can even unzip using VM/CMS 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.5. If you got also the ZIP program (see ZIP201VM.ZIP) you can
do zipping and unzipping without translating to ASCII
the ZIP also preserves the file information (LRECL,BLKSIZE..)
So when you UNZIP a file zipped with ZIP under VM/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.6. 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.7. 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.8. A filename translations is being done in some cases:
- when there is no filetype (extension) the name becomes
firstname.NONAME
3.9. When you unzip a file all of your currently accessed disks
are checked for the existence of this file if it exist
somewhere you get a reply if you want to overwright it ot no
3.10. If you have CMS PIPELINES installed you can use the MC EXEC
as a MAKE utility to conditional compile all the sources
using as input UNZIP MAKEFILE.
3.11. NO SFS is supported if you are using VM/ESA - everything is
extracted to the current directory.
3.12. You can specify destination minidisk for unzip using the -d
option. Example : UNZIP myzip *.c -d b
This will unzip all .c files on your B disk.
3.9. All '+' or '-' signs are skipped from the filenames
Please report 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

129
zip/unzip/cmsmvs/README.MVS Executable file
View File

@ -0,0 +1,129 @@
[Notes accompanying first beta of the MVS port; still mostly applicable
to the UnZip 5.2 release. Somebody with an MVS system will have to
update this file.]
Thank you for trying this first port of UNZIP for VM/CMS and MVS!
This is the first beta so there might be some bugs in it.
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 unz52vm.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 youruserid.UNZIP.C
- Copy all the .H files in the PDS called youruserid.UNZIP.H
- adjust the job UNZMVSC.JOB to work on your size. Change my
userid - C888090 to yours
- execute the job UNZMVSC to compile and link all the sources.
- maybe you have to preallocate PDS datasets named:
youruserid.UNZIP.OBJ and youruserid.UNZIP.LOAD
- if everything is ok you will get an UNZIP MODULE
3. Using UNZIP
- Just read the UNZIP.DOC
- 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 :-)
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 after the zip name
for example:
UNZIP myzip *.c -dmyzip
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)'
3.8. All text files under MVS are created with record length 133.
This is due to a bug in the fopen that makes it always 1028
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

85
zip/unzip/cmsmvs/mc.exec Executable file
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

26
zip/unzip/cmsmvs/unzip.makefile Executable file
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

119
zip/unzip/cmsmvs/unzmvsc.job Executable file
View File

@ -0,0 +1,119 @@
//CCUNZIP JOB (BI09255), JOB15798
// MSGLEVEL=(1,1),MSGCLASS=C,CLASS=D,NOTIFY=C888090
//PROCLIB JCLLIB ORDER=(SYS1.C370.PROCLIB.M24)
//UNZIP EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(UNZIP)',
// OUTFILE='C888090.UNZIP.OBJ(UNZIP),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//CRC32 EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(CRC32)',
// OUTFILE='C888090.UNZIP.OBJ(CRC32),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//CRCTAB EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(CRCTAB)',
// OUTFILE='C888090.UNZIP.OBJ(CRCTAB),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//CRYPT EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(CRYPT)',
// OUTFILE='C888090.UNZIP.OBJ(CRYPT),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//ENVARGS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(ENVARGS)',
// OUTFILE='C888090.UNZIP.OBJ(ENVARGS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//EXPLODE EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(EXPLODE)',
// OUTFILE='C888090.UNZIP.OBJ(EXPLODE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//EXTRACT EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(EXTRACT)',
// OUTFILE='C888090.UNZIP.OBJ(EXTRACT),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//FILEIO EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(FILEIO)',
// OUTFILE='C888090.UNZIP.OBJ(FILEIO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//GLOBALS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(GLOBALS)',
// OUTFILE='C888090.UNZIP.OBJ(GLOBALS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//INFLATE EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(INFLATE)',
// OUTFILE='C888090.UNZIP.OBJ(INFLATE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//LIST EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(LIST)',
// OUTFILE='C888090.UNZIP.OBJ(LIST),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//MATCH EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(MATCH)',
// OUTFILE='C888090.UNZIP.OBJ(MATCH),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//PROCESS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(PROCESS)',
// OUTFILE='C888090.UNZIP.OBJ(PROCESS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//TTYIO EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(TTYIO)',
// OUTFILE='C888090.UNZIP.OBJ(TTYIO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//UNREDUCE EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(UNREDUCE)',
// OUTFILE='C888090.UNZIP.OBJ(UNREDUCE),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//UNSHRINK EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(UNSHRINK)',
// OUTFILE='C888090.UNZIP.OBJ(UNSHRINK),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//ZIPINFO EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(ZIPINFO)',
// OUTFILE='C888090.UNZIP.OBJ(ZIPINFO),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//VMMVS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
// INFILE='C888090.UNZIP.C(VMMVS)',
// OUTFILE='C888090.UNZIP.OBJ(VMMVS),DISP=SHR',
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
//COMPILE.USERLIB DD DSN=C888090.UNZIP.H,DISP=SHR
//PLINK EXEC PROC=EDCPL,COND=(12,LE),
// OUTFILE='C888090.UNZIP.LOAD(UNZIP),DISP=SHR',
// PPARM='NONCAL,MAP',
// LPARM='LIST,MAP,XREF'
//SYSPRINT DD SYSOUT=*
//PLKED.SYSIN DD DSN=C888090.UNZIP.OBJ(UNZIP),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(CRC32),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(CRCTAB),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(CRYPT),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(ENVARGS),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(EXPLODE),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(EXTRACT),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(FILEIO),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(GLOBALS),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(INFLATE),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(LIST),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(MATCH),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(PROCESS),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(TTYIO),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(UNREDUCE),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(UNSHRINK),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(ZIPINFO),DISP=SHR
// DD DSN=C888090.UNZIP.OBJ(VMMVS),DISP=SHR
//PLKED.SYSLIB DD DSN=SYS1.C370.SEDCBASE,DISP=SHR
// DD DSN=SYS1.PL1.SIBMBASE,DISP=SHR
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,2)),DISP=NEW

58
zip/unzip/cmsmvs/unzvmc.exc Executable file
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

510
zip/unzip/cmsmvs/vmmvs.c Executable file
View File

@ -0,0 +1,510 @@
/*---------------------------------------------------------------------------
vmmvs.c (for both VM/CMS and MVS)
Contains: vmmvs_open_infile()
open_outfile()
find_vms_attrs()
flush()
close_outfile()
close_infile()
getVMMVSexfield()
do_wild()
mapattr()
mapname()
checkdir()
check_for_newer()
stat()
version()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
/********************************/
/* Function vmmvs_open_infile() */
/********************************/
FILE *vmmvs_open_infile(__G)
__GDEF
{
FILE *fzip;
G.tempfn = NULL;
if ((fzip = fopen(G.zipfn,"rb,recfm=fb")) == (FILE *)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 == (FILE *)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);
}
return fzip;
}
/***************************/
/* Function open_outfile() */
/***************************/
int open_outfile(__G) /* return 1 if fail */
__GDEF
{
char type[100];
char *mode = NULL;
if (G.pInfo->textmode)
mode = FOPWT;
else {
if (G.lrec.extra_field_length > EB_HEADSIZE) {
ush leb_id = makeword(&G.extra_field[EB_ID]);
ush leb_dlen = makeword(&G.extra_field[EB_LEN]);
if ((leb_id == EF_VMCMS || leb_id == EF_MVS) &&
(leb_dlen <= (G.lrec.extra_field_length - EB_HEADSIZE)) &&
(getVMMVSexfield(type, G.extra_field, (unsigned)leb_dlen) > 0))
mode = type;
}
}
if (mode == NULL) mode = FOPW;
if ((G.outfile = fopen(G.filename, mode)) == (FILE *)NULL) {
Info(slide, 0x401, ((char *)slide, "\nerror: cannot create %s\n",
G.filename));
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);
sprintf(type+strlen(type), ",blksize=%ld", fdata->__blksize);
return strlen(type);
} /* end function getVMMVSexfield() */
#ifndef SFX
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */
/**********************/
char *do_wild(__G__ wld)
__GDEF
char *wld; /* only used first time on a given dir */
{
static int First = 0;
static char filename[256];
if (First == 0) {
First = 1;
strcpy( filename, wld );
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)
/* returns: */
/* 0 (PK_COOL) if no error, */
/* 1 (PK_WARN) if caution (filename trunc), */
/* 2 (PK_ERR) if warning (skip file because dir doesn't exist), */
/* 3 (PK_BADERR) if error (skip file), */
/* 10 if no memory (skip file) */
__GDEF
int renamed;
{
char newname[68], *lbar;
#ifdef MVS
char *pmember;
#endif
int name_changed = 0;
#ifdef MVS
while ((lbar = strrchr(G.filename,'_')) != NULL) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
/* '-' and '+' ARE valid chars for CMS. --RGH */
while ((lbar = strrchr(G.filename,'+')) != NULL) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
while ((lbar = strrchr(G.filename,'-')) != NULL) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
#endif
while ((lbar = strrchr(G.filename,'(')) != NULL) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
while ((lbar = strrchr(G.filename,')')) != NULL) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
#ifdef VM_CMS
if ((lbar = strrchr(G.filename,'/')) != NULL) {
strcpy((char *)newname,(char *)((lbar)+1));
printf("WARNING: file '%s' renamed as '%s'\n",G.filename,newname);
strcpy(G.filename,(char *)newname);
name_changed = 1;
}
#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) {
strcpy(lbar,(lbar)+1);
name_changed = 1;
}
/* 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,'.')) == (char *)NULL) {
printf("WARNING: file '%s' has NO extension - renamed as '%s.NONAME'\n"\
,G.filename,G.filename);
strcat(G.filename,".NONAME");
name_changed = 1;
}
#endif
checkdir(__G__ G.filename, GETPATH);
return name_changed;
} /* end function mapname() */
int checkdir(__G__ pathcomp, flag)
__GDEF
char *pathcomp;
int flag;
/*
* returns: 1 - (on APPEND_NAME) truncated filename
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - 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)
#if (!defined(SFX) || defined(SFX_EXDIR))
if (FUNCTION == ROOT) {
Trace((stderr, "initializing root path to [%s]\n", pathcomp));
if (pathcomp == (char *)NULL) {
rootlen = 0;
}
else if ((rootlen = strlen(pathcomp)) > 0) {
if ((rootpath = (char *)malloc(rootlen+1)) == NULL) {
rootlen = 0;
return 10;
}
strcpy(rootpath, pathcomp);
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return 0;
}
#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;
strcpy(newfilename,rootpath);
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);
}
Trace((stdout, "new dataset : %s\n", newfilename));
strcpy(pathcomp,newfilename);
#endif /* ?VM_CMS */
}
return 0;
}
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0)
free(rootpath);
return 0;
}
return 99; /* 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, "r")) != (FILE *)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, "rb")) != 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;
}
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
int len;
char liblvlmsg [50+1];
union {
unsigned int iVRM;
struct {
unsigned int v:8;
unsigned int r:8;
unsigned int m:8;
} xVRM;
} VRM;
/* Break down the runtime library level */
VRM.iVRM = __librel();
sprintf(liblvlmsg, ". Runtime level V%dR%dM%d",
VRM.xVRM.v, VRM.xVRM.r, VRM.xVRM.m);
/* 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 */
"C/370", "", /* Assumed. Can't get compiler lvl(?) */
/* Add compile environment */
#ifdef VM_CMS
"VM/CMS",
#else
"MVS",
#endif
/* Add timestamp */
#ifdef __TIMESTAMP
" on ", __TIMESTAMP,
#else
"", "",
#endif
liblvlmsg
);
(*G.message)((zvoid *)&G, slide, (ulg)len, 0);
} /* end function version() */
#endif /* !SFX */

49
zip/unzip/cmsmvs/vmmvs.h Executable file
View File

@ -0,0 +1,49 @@
/* 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
#include <time.h> /* the usual non-BSD time functions */
#include "vmstat.h"
#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. */
/* 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 REALLY_SHORT_SYMS
#define PATH_MAX 128
#define DATE_FORMAT DF_MDY
#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 */

49
zip/unzip/cmsmvs/vmstat.h Executable file
View File

@ -0,0 +1,49 @@
#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 */

46
zip/unzip/consts.h Executable file
View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------
consts.h
This file contains global, initialized variables that never change. It is
included by unzip.c and windll/dllsetup.c.
---------------------------------------------------------------------------*/
/* And'ing with mask_bits[n] masks the lower n bits */
ZCONST ush near mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
char Far VersionDate[] = VERSION_DATE; /* now defined in version.h */
#ifndef SFX
char Far EndSigMsg[] =
"\nnote: didn't find end-of-central-dir signature at end of central dir.\n";
#endif
char Far CentSigMsg[] =
"error: expected central file header signature not found (file #%u).\n";
char Far SeekMsg[] =
"error [%s]: attempt to seek before beginning of zipfile\n%s";
char Far FilenameNotMatched[] = "caution: filename not matched: %s\n";
char Far ExclFilenameNotMatched[] =
"caution: excluded filename not matched: %s\n";
#ifdef VMS
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
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
char Far Zipnfo[] = "zipinfo";
char Far CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
#endif

54
zip/unzip/crc32.c Executable file
View File

@ -0,0 +1,54 @@
/* 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.1.1.1 1997-10-20 15:50:07 alex Exp $ */
#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 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 */

163
zip/unzip/crc_i386.S Executable file
View File

@ -0,0 +1,163 @@
/*
* crc_i386.S, optimized CRC calculation function for Zip and UnZip, not
* copyrighted by Paul Kienitz and Christian Spieler. Last revised 10 Nov 96.
*
* GRR 961110: incorporated Scott Field optimizations from win32/crc_i386.asm
* => overall 6% speedup in "unzip -tq" on 9MB zipfile (486-66)
*
* 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 does only cost 4 single byte instructions.)
*
* This source generates the function
* ulg crc32(ulg oldcrc, ZCONST uch *text, ulg textlen).
*
* The loop unroolling 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(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 */
/*
* This is the loop body of the CRC32 cruncher.
* registers modified:
* ebx : crc value "c"
* esi : pointer to next data byte "text++"
* registers read:
* edi : pointer to base of crc_table array
* scratch registers:
* eax : requires upper three bytes of eax = 0, uses al
*/
#define Do_CRC \
movb (%esi),%al ;/* al <-- *text */\
incl %esi ;/* text++ */\
xorb %bl,%al ;/* (c ^ *text++) & 0xFF */\
shrl $8,%ebx ;/* c = (c >> 8) */\
xorl (%edi,%eax,4),%ebx ;/* ^table[(c^(*text++))&0xFF] */
.text
.globl _crc32
_crc32: /* ulg crc32(ulg crc, uch *text, extent len) */
_STD_ENTRY
pushl %edi
pushl %esi
pushl %ebx
pushl %edx
pushl %ecx
movl arg2,%esi /* 2nd arg: uch *text */
subl %eax,%eax /* > if (!text) */
testl %esi,%esi /* > return 0; */
jz fine /* > else { */
call _get_crc_table
movl %eax,%edi
movl arg1,%ebx /* 1st arg: ulg crc */
subl %eax,%eax /* eax=0; al usable as dword */
movl arg3,%ecx /* 3rd arg: extent textlen */
notl %ebx /* > c = ~crc; */
#ifndef NO_UNROLLED_LOOPS
movl %ecx,%edx /* save textlen in edx */
andl $7,%edx /* edx = textlen % 8 */
shrl $3,%ecx /* ecx = textlen / 8 */
jz No_Eights
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
Next_Eight:
Do_CRC
Do_CRC
Do_CRC
Do_CRC
Do_CRC
Do_CRC
Do_CRC
Do_CRC
decl %ecx
jnz Next_Eight
No_Eights:
movl %edx,%ecx
#endif /* NO_UNROLLED_LOOPS */
jecxz bail /* > if (textlen) */
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
loupe: /* > do { */
Do_CRC /* c = CRC32(c, *text++); */
decl %ecx /* > } while (--textlen); */
jnz loupe
bail: /* > } */
movl %ebx,%eax
notl %eax /* > return ~c; */
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 */

216
zip/unzip/crctab.c Executable file
View File

@ -0,0 +1,216 @@
/* 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.1.1.1 1997-10-20 15:50:07 alex 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.
*/
#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 && 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[] = {
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 */
#ifdef USE_ZLIB
uLongf *get_crc_table()
#else
ulg near *get_crc_table()
#endif
{
#ifdef DYNAMIC_CRC_TABLE
if (CRC_TABLE_IS_EMPTY)
make_crc_table();
#endif
#ifdef USE_ZLIB
return (uLongf *)crc_table;
#else
return (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 */

12
zip/unzip/crypt.c Executable file
View File

@ -0,0 +1,12 @@
/*
crypt.c (dummy version) by Info-ZIP. Last revised: 18 Mar 97
This is a non-functional version of Info-ZIP's crypt.c encryption/
decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is
not copyrighted and may be distributed freely. :-) See the "Where"
file for sites from which to obtain the full encryption/decryption
sources (zcrypt27.zip or later).
*/
/* something "externally visible" to shut up compiler/linker warnings */
int zcr_dummy;

24
zip/unzip/crypt.h Executable file
View File

@ -0,0 +1,24 @@
/*
crypt.h (dummy version) by Info-ZIP. Last revised: 13 Apr 97
This is a non-functional version of Info-ZIP's crypt.h encryption/
decryption header file for Zip, ZipCloak, UnZip and fUnZip. This
file is not copyrighted and may be distributed without restriction.
See the "Where" file for sites from which to obtain the full crypt
sources (zcrypt27.zip or later).
*/
#ifndef __crypt_h /* don't include more than once */
#define __crypt_h
#ifdef CRYPT
# undef CRYPT
#endif
#define CRYPT 0 /* dummy version */
#define zencode
#define zdecode
#define zfwrite fwrite
#endif /* !__crypt_h */

232
zip/unzip/ebcdic.h Executable file
View File

@ -0,0 +1,232 @@
/*---------------------------------------------------------------------------
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
---------------------------------------------------------------------------*/
#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 */
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, 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 */
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 */
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 */
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, 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 tranlate 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 */
#endif /* __ebcdic_h */

312
zip/unzip/envargs.c Executable file
View File

@ -0,0 +1,312 @@
/*----------------------------------------------------------------*
| 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
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef __EMX__ /* emx isspace() returns TRUE on extended ASCII !! */
# define ISspace(c) ((c) & 0x80 ? 0 : isspace(c))
#else
# define ISspace(c) isspace(c)
#endif /* ?__EMX__ */
static int count_args OF((char *));
static void mem_err OF((__GPRO));
static char Far NoMemArguments[] = "envargs: can't get memory for arguments";
void envargs(__G__ Pargc, Pargv, envstr, envstr2)
__GDEF
int *Pargc;
char ***Pargv, *envstr, *envstr2;
{
#ifndef RISCOS
char *getenv();
#endif
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;
bufptr = malloc(1 + strlen(envptr));
if (bufptr == (char *)NULL)
mem_err(__G);
#if (defined(WIN32) || defined(WINDLL))
# 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 environment uses OEM codepage */
OEM_TO_INTERN(envptr, bufptr);
# endif
#else /* !(WIN32 || WINDLL) */
strcpy(bufptr, envptr);
#endif /* ?(WIN32 || WINDLL) */
/* 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);
mem_err(__G);
}
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 = *(++bufptr))
if (ch == '\\' && bufptr[1] != '\0')
++bufptr; /* skip char after backslash */
if (ch != '\0')
*(bufptr++) = '\0'; /* overwrite trailing " */
/* remove escape characters */
while ((argstart = strchr(argstart, '\\')) != (char *)NULL) {
strcpy(argstart, argstart + 1);
if (*argstart)
++argstart;
}
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
#ifdef DOS_OS2_W32
/* we do not support backslash-quoting of quotes in quoted
* strings under DOS_OS2_W32, because backslashes are directory
* separators and double quotes are illegal in filenames */
if (*bufptr == '"') {
*(argv++) = ++bufptr;
while ((ch = *bufptr) != '\0' && ch != '\"')
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
#endif /* ?DOS_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *bufptr) != '\0' && ISspace(ch))
++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 */
*Pargv = argvect;
*Pargc = argc;
}
static int count_args(s)
char *s;
{
int count = 0;
char ch;
do {
/* count and skip args */
++count;
#if defined(AMIGA) || defined(UNIX)
if (*s == '\"') {
for (ch = *(++s); ch != '\0' && ch != '\"'; ch = *(++s))
if (ch == '\\' && s[1] != '\0')
++s;
if (*s)
++s; /* trailing quote */
} else
#else
#ifdef DOS_OS2_W32
if (*s == '\"') {
++s; /* leading quote */
while ((ch = *s) != '\0' && ch != '\"')
++s;
if (*s)
++s; /* trailing quote */
} else
#endif /* DOS_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *s) != '\0' && !ISspace(ch)) /* note else-clauses above */
++s;
while ((ch = *s) != '\0' && ISspace(ch))
++s;
} while (ch);
return count;
}
static void mem_err(__G)
__GDEF
{
perror(LoadFarString(NoMemArguments));
DESTROYGLOBALS()
EXIT(PK_MEM);
}
#ifdef TEST
main(argc, argv)
int argc;
char **argv;
{
int i;
printf("Orig argv: %p\n", argv);
dump_args(argc, argv);
envargs(__G__ &argc, &argv, "ENVTEST");
printf(" New argv: %p\n", argv);
dump_args(argc, argv);
}
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 */

856
zip/unzip/explode.c Executable file
View File

@ -0,0 +1,856 @@
/* explode.c -- put in the public domain by Mark Adler
version c15, 6 July 1996 */
/* 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
*/
/*
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 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 */
#ifdef DLL
# define wsize G._wsize
#else
# define wsize WSIZE
#endif
/* routines here */
static int get_tree OF((__GPRO__ unsigned *l, unsigned n));
static int explode_lit8 OF((__GPRO__ struct huft *tb, struct huft *tl,
struct huft *td, int bb, int bl, int bd));
static int explode_lit4 OF((__GPRO__ struct huft *tb, struct huft *tl,
struct huft *td, int bb, int bl, int bd));
static int explode_nolit8 OF((__GPRO__ struct huft *tl, struct huft *td,
int bl, int bd));
static int explode_nolit4 OF((__GPRO__ struct huft *tl, struct huft *td,
int bl, int bd));
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.
*/
/* Tables for length and distance */
static 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 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 ush 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 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 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);}
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_lit8(__G__ tb, tl, td, bb, bl, bd)
__GDEF
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
int bb, bl, bd; /* number of bits decoded by those */
/* Decompress the imploded data using coded literals and an 8K sliding
window. */
{
long 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 */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* 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];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--decode it */
{
DUMPBITS(1)
s--;
NEEDBITS((unsigned)bb) /* get coded literal */
if ((e = (t = tb + ((~(unsigned)b) & mb))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
redirSlide[w++] = (uch)t->v.n;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(7) /* get distance low bits */
d = (unsigned)b & 0x7f;
DUMPBITS(7)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#ifdef DLL
if (G.redirect_data) /* &= w/ wsize not needed and wrong if redirect */
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > 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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
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_lit4(__G__ tb, tl, td, bb, bl, bd)
__GDEF
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
int bb, bl, bd; /* number of bits decoded by those */
/* Decompress the imploded data using coded literals and a 4K sliding
window. */
{
long 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 */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* 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];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--decode it */
{
DUMPBITS(1)
s--;
NEEDBITS((unsigned)bb) /* get coded literal */
if ((e = (t = tb + ((~(unsigned)b) & mb))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
redirSlide[w++] = (uch)t->v.n;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(6) /* get distance low bits */
d = (unsigned)b & 0x3f;
DUMPBITS(6)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#ifdef DLL
if (G.redirect_data) /* &= w/ wsize not needed and wrong if redirect */
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > 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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
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_nolit8(__G__ tl, td, bl, bd)
__GDEF
struct huft *tl, *td; /* length and distance decoder tables */
int bl, bd; /* number of bits decoded by tl[] and td[] */
/* Decompress the imploded data using uncoded literals and an 8K sliding
window. */
{
long 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 */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* 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];
s = G.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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
DUMPBITS(8)
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(7) /* get distance low bits */
d = (unsigned)b & 0x7f;
DUMPBITS(7)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#ifdef DLL
if (G.redirect_data) /* &= w/ wsize not needed and wrong if redirect */
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > 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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
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_nolit4(__G__ tl, td, bl, bd)
__GDEF
struct huft *tl, *td; /* length and distance decoder tables */
int bl, bd; /* number of bits decoded by tl[] and td[] */
/* Decompress the imploded data using uncoded literals and a 4K sliding
window. */
{
long 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 */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* 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];
s = G.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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
DUMPBITS(8)
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(6) /* get distance low bits */
d = (unsigned)b & 0x3f;
DUMPBITS(6)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#ifdef DLL
if (G.redirect_data) /* &= w/ wsize not needed and wrong if redirect */
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > 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 == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
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 */
int bb; /* bits for tb */
int bl; /* bits for tl */
int bd; /* bits for td */
unsigned l[256]; /* bit lengths for codes */
#ifdef DLL
if (G.redirect_data)
wsize = G.redirect_size, redirSlide = G.redirect_buffer;
else
wsize = WSIZE, redirSlide = slide;
#endif
/* 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 suprised to find out the 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;
/* With literal tree--minimum match length is 3 */
G.hufts = 0; /* initialize huft's malloc'ed */
if (G.lrec.general_purpose_bit_flag & 4)
{
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)
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;
}
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
huft_free(tb);
return (int)r;
}
r = explode_lit8(__G__ tb, tl, td, bb, bl, bd);
}
else /* else 4K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
huft_free(tb);
return (int)r;
}
r = explode_lit4(__G__ tb, tl, td, bb, bl, bd);
}
huft_free(td);
huft_free(tl);
huft_free(tb);
}
else
/* No literal tree--minimum match length is 2 */
{
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)
return (int)r;
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
return (int)r;
}
r = explode_nolit8(__G__ tl, td, bl, bd);
}
else /* else 4K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
return (int)r;
}
r = explode_nolit4(__G__ tl, td, bl, bd);
}
huft_free(td);
huft_free(tl);
}
#ifdef DEBUG
fprintf(stderr, "<%u > ", G.hufts);
#endif /* DEBUG */
return (int)r;
}
/* so explode.c and inflate.c can be compiled together into one object: */
#undef NEXTBYTE
#undef NEEDBITS
#undef DUMPBITS

1872
zip/unzip/extract.c Executable file

File diff suppressed because it is too large Load Diff

10
zip/unzip/file_id.diz Executable file
View File

@ -0,0 +1,10 @@
Info-ZIP's UnZip 5.31: 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 cool documentation.
This is FREE (but copyrighted) software.
See COPYING for details on distribution
and reuse.

1972
zip/unzip/fileio.c Executable file

File diff suppressed because it is too large Load Diff

463
zip/unzip/funzip.c Executable file
View File

@ -0,0 +1,463 @@
/* funzip.c -- put in the public domain by Mark Adler */
#define VERSION "3.92 of 31 May 1997"
/* 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
---- --------- -------------- ------------------------------------
1.0 13 Aug 92 M. Adler really simple unzip filter.
1.1 13 Aug 92 M. Adler cleaned up somewhat, give help if
stdin not redirected, warn if more
zip file entries after the first.
1.2 15 Aug 92 M. Adler added check of lengths for stored
entries, added more help.
1.3 16 Aug 92 M. Adler removed redundant #define's, added
decryption.
1.4 27 Aug 92 G. Roelofs added exit(0).
1.5 1 Sep 92 K. U. Rommel changed read/write modes for OS/2.
1.6 6 Sep 92 G. Roelofs modified to use dummy crypt.c and
crypt.h instead of -DCRYPT.
1.7 23 Sep 92 G. Roelofs changed to use DOS_OS2; included
crypt.c under MS-DOS.
1.8 9 Oct 92 M. Adler improved inflation error msgs.
1.9 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch;
renamed inflate_entry() to inflate();
adapted to use new, in-place zdecode.
2.0 22 Oct 92 M. Adler allow filename argument, prompt for
passwords and don't echo, still allow
command-line password entry, but as an
option.
2.1 23 Oct 92 J-l. Gailly fixed crypt/store bug,
G. Roelofs removed crypt.c under MS-DOS, fixed
decryption check to compare single byte.
2.2 28 Oct 92 G. Roelofs removed declaration of key.
2.3 14 Dec 92 M. Adler replaced fseek (fails on stdin for SCO
Unix V.3.2.4). added quietflg for
inflate.c.
3.0 11 May 93 M. Adler added gzip support
3.1 9 Jul 93 K. U. Rommel fixed OS/2 pipe bug (PIPE_ERROR)
3.2 4 Sep 93 G. Roelofs moved crc_32_tab[] to tables.h; used FOPx
from unzip.h; nuked OUTB macro and outbuf;
replaced flush(); inlined FlushOutput();
renamed decrypt to encrypted
3.3 29 Sep 93 G. Roelofs replaced ReadByte() with NEXTBYTE macro;
revised (restored?) flush(); added FUNZIP
3.4 21 Oct 93 G. Roelofs renamed quietflg to qflag; changed outcnt,
H. Gessau second updcrc() arg and flush() arg to ulg;
added inflate_free(); added "g =" to null
getc(in) to avoid compiler warnings
3.5 31 Oct 93 H. Gessau changed DOS_OS2 to DOS_NT_OS2
3.6 6 Dec 93 H. Gessau added "near" to mask_bits[]
3.7 9 Dec 93 G. Roelofs added extent typecasts to fwrite() checks
3.8 28 Jan 94 GRR/JlG initialized g variable in main() for gcc
3.81 22 Feb 94 M. Hanning-Lee corrected usage message
3.82 27 Feb 94 G. Roelofs added some typecasts to avoid warnings
3.83 22 Jul 94 G. Roelofs changed fprintf to macro for DLLs
- 2 Aug 94 - public release with UnZip 5.11
- 28 Aug 94 - public release with UnZip 5.12
3.84 1 Oct 94 K. U. Rommel changes for Metaware High C
3.85 29 Oct 94 G. Roelofs changed fprintf macro to Info
3.86 7 May 95 K. Davis RISCOS patches;
P. Kienitz Amiga patches
3.87 12 Aug 95 G. Roelofs inflate_free(), DESTROYGLOBALS fixes
3.88 4 Sep 95 C. Spieler reordered macro to work around MSC 5.1 bug
3.89 22 Nov 95 PK/CS ifdef'd out updcrc() for ASM_CRC
3.9 17 Dec 95 G. Roelofs modified for USE_ZLIB (new fillinbuf())
- 30 Apr 96 - public release with UnZip 5.2
3.91 17 Aug 96 G. Roelofs main() -> return int (Peter Seebach)
3.92 13 Apr 97 G. Roelofs minor cosmetic fixes to messages
- 22 Apr 97 - public release with UnZip 5.3
- 31 May 97 - public release with UnZip 5.31
*/
/*
All funzip does is take a zipfile from stdin and decompress the
first entry to stdout. The entry has to be either deflated or
stored. If the entry is encrypted, then the decryption password
must be supplied on the command line as the first argument.
funzip needs to be linked with inflate.o and crypt.o compiled from
the unzip source. If decryption is desired, the full version of
crypt.c (and crypt.h) from zcrypt21.zip or later must be used.
*/
#define FUNZIP
#define UNZIP_INTERNAL
#include "unzip.h"
#include "crypt.h"
#include "ttyio.h"
#ifdef EBCDIC
# undef EBCDIC /* don't need ebcdic[] */
#endif
#include "tables.h" /* crc_32_tab[] */
#ifndef USE_ZLIB /* zlib's function is called inflate(), too */
# define UZinflate inflate
#endif
/* PKZIP header definitions */
#define ZIPMAG 0x4b50 /* two-byte zip lead-in */
#define LOCREM 0x0403 /* remaining two bytes in zip signature */
#define LOCSIG 0x04034b50L /* full signature */
#define LOCFLG 4 /* offset of bit flag */
#define CRPFLG 1 /* bit for encrypted entry */
#define EXTFLG 8 /* bit for extended local header */
#define LOCHOW 6 /* offset of compression method */
#define LOCTIM 8 /* file mod time (for decryption) */
#define LOCCRC 12 /* offset of crc */
#define LOCSIZ 16 /* offset of compressed size */
#define LOCLEN 20 /* offset of uncompressed length */
#define LOCFIL 24 /* offset of file name field length */
#define LOCEXT 26 /* offset of extra field length */
#define LOCHDR 28 /* size of local header, including LOCREM */
#define EXTHDR 16 /* size of extended local header, inc sig */
/* GZIP header definitions */
#define GZPMAG 0x8b1f /* two-byte gzip lead-in */
#define GZPHOW 0 /* offset of method number */
#define GZPFLG 1 /* offset of gzip flags */
#define GZPMUL 2 /* bit for multiple-part gzip file */
#define GZPISX 4 /* bit for extra field present */
#define GZPISF 8 /* bit for filename present */
#define GZPISC 16 /* bit for comment present */
#define GZPISE 32 /* bit for encryption */
#define GZPTIM 2 /* offset of Unix file modification time */
#define GZPEXF 6 /* offset of extra flags */
#define GZPCOS 7 /* offset of operating system compressed on */
#define GZPHDR 8 /* length of minimal gzip header */
/* Macros for getting two-byte and four-byte header values */
#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8))
#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16))
/* Function prototypes */
void err OF((int, char *));
int main OF((int, char **));
/* Globals */
FILE *out; /* output file (*in moved to G struct) */
ulg outsiz; /* total bytes written to out */
int encrypted; /* flag to turn on decryption */
/* Masks for inflate.c */
ZCONST ush near mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
#ifdef USE_ZLIB
int fillinbuf(__G)
__GDEF
/* Fill input buffer for pull-model inflate() in zlib. Return the number of
* bytes in inbuf. */
{
/* GRR: check return value from fread(): same as read()? check errno? */
if ((G.incnt = fread((char *)G.inbuf, 1, INBUFSIZ, G.in)) <= 0)
return 0;
G.inptr = G.inbuf;
#if CRYPT
if (encrypted) {
uch *p;
int n;
for (n = G.incnt, p = G.inptr; n--; p++)
zdecode(*p);
}
#endif /* CRYPT */
return G.incnt;
}
#endif /* USE_ZLIB */
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
#ifdef USE_ZLIB
uLongf *get_crc_table()
{
return (uLongf *)crc_32_tab;
}
#else /* !USE_ZLIB */
ulg near *get_crc_table()
{
return crc_32_tab;
}
#endif /* ?USE_ZLIB */
#endif /* !USE_ZLIB || USE_OWN_CRCTAB */
void err(n, m)
int n;
char *m;
/* Exit on error with a message and a code */
{
Info(slide, 1, ((char *)slide, "funzip error: %s\n", m));
DESTROYGLOBALS()
EXIT(n);
}
int flush(w) /* used by inflate.c (FLUSH macro) */
ulg w; /* number of bytes to flush */
{
G.crc32val = crc32(G.crc32val, slide, (extent)w);
if (fwrite((char *)slide,1,(extent)w,out) != (extent)w && !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += w;
return 0;
}
int main(argc, argv)
int argc;
char **argv;
/* Given a zipfile on stdin, decompress the first entry to stdout. */
{
ush n;
uch h[LOCHDR]; /* first local header (GZPHDR < LOCHDR) */
int g = 0; /* true if gzip format */
#if CRYPT
char *s = " [-password]";
char *p; /* password */
#else /* !CRYPT */
char *s = "";
#endif /* ?CRYPT */
CONSTRUCTGLOBALS();
/* skip executable name */
argc--;
argv++;
#if CRYPT
/* get the command line password, if any */
p = (char *)NULL;
if (argc && **argv == '-')
{
argc--;
p = 1 + *argv++;
}
#endif /* CRYPT */
#ifdef MALLOC_WORK
G.area.Slide = (uch *)calloc(8193, sizeof(short)+sizeof(char)+sizeof(char));
#endif
/* if no file argument and stdin not redirected, give the user help */
if (argc == 0 && isatty(0))
{
Info(slide, 1, ((char *)slide, "fUnZip (filter UnZip), version %s\n",
VERSION));
Info(slide, 1, ((char *)slide, "usage: ... | funzip%s | ...\n", s));
Info(slide, 1, ((char *)slide, " ... | funzip%s > outfile\n", s));
Info(slide, 1, ((char *)slide, " funzip%s infile.zip > outfile\n",s));
Info(slide, 1, ((char *)slide, " funzip%s infile.gz > outfile\n", s));
Info(slide, 1, ((char *)slide, "Extracts to stdout the gzip file or first\
zip entry of stdin or the given file.\n"));
DESTROYGLOBALS()
EXIT(3);
}
/* prepare to be a binary filter */
if (argc)
{
if ((G.in = fopen(*argv, FOPR)) == (FILE *)NULL)
err(2, "cannot find input file");
}
else
{
#ifdef DOS_H68_OS2_W32
#ifdef __HIGHC__
setmode(stdin, _BINARY);
#else
setmode(0, O_BINARY); /* some buggy C libraries require BOTH setmode() */
#endif /* call AND the fdopen() in binary mode :-( */
#endif /* DOS_H68_OS2_W32 */
#ifdef RISCOS
G.in = stdin;
#else
if ((G.in = fdopen(0, FOPR)) == (FILE *)NULL)
err(2, "cannot find stdin");
#endif
}
#ifdef DOS_H68_OS2_W32
#ifdef __HIGHC__
setmode(stdout, _BINARY);
#else
setmode(1, O_BINARY);
#endif
#endif /* DOS_H68_OS2_W32 */
#ifdef RISCOS
out = stdout;
#else
if ((out = fdopen(1, FOPW)) == (FILE *)NULL)
err(2, "cannot write to stdout");
#endif
/* read local header, check validity, and skip name and extra fields */
n = getc(G.in); n |= getc(G.in) << 8;
if (n == ZIPMAG)
{
if (fread((char *)h, 1, LOCHDR, G.in) != LOCHDR || SH(h) != LOCREM)
err(3, "invalid zipfile");
if (SH(h + LOCHOW) != STORED && SH(h + LOCHOW) != DEFLATED)
err(3, "first entry not deflated or stored--can't funzip");
for (n = SH(h + LOCFIL); n--; ) g = getc(G.in);
for (n = SH(h + LOCEXT); n--; ) g = getc(G.in);
g = 0;
encrypted = h[LOCFLG] & CRPFLG;
}
else if (n == GZPMAG)
{
if (fread((char *)h, 1, GZPHDR, G.in) != GZPHDR)
err(3, "invalid gzip file");
if (h[GZPHOW] != DEFLATED)
err(3, "gzip file not deflated");
if (h[GZPFLG] & GZPMUL)
err(3, "cannot handle multi-part gzip files");
if (h[GZPFLG] & GZPISX)
{
n = getc(G.in); n |= getc(G.in) << 8;
while (n--) g = getc(G.in);
}
if (h[GZPFLG] & GZPISF)
while ((g = getc(G.in)) != 0 && g != EOF) ;
if (h[GZPFLG] & GZPISC)
while ((g = getc(G.in)) != 0 && g != EOF) ;
g = 1;
encrypted = h[GZPFLG] & GZPISE;
}
else
err(3, "input not a zip or gzip file");
/* if entry encrypted, decrypt and validate encryption header */
if (encrypted)
#if CRYPT
{
ush i, e;
if (p == (char *)NULL)
if ((p = (char *)malloc(PWLEN+1)) == (char *)NULL)
err(1, "out of memory");
else if ((p = getp("Enter password: ", p, PWLEN+1)) == (char *)NULL)
err(1, "no tty to prompt for password");
#if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB))
/* initialize crc_32_tab pointer for decryption */
crc_32_tab = (ulg near *)get_crc_table();
#endif
init_keys(p);
for (i = 0; i < RAND_HEAD_LEN; i++)
e = NEXTBYTE;
if (e != (ush)(h[LOCFLG] & EXTFLG ? h[LOCTIM + 1] : h[LOCCRC + 3]))
err(3, "incorrect password for first entry");
}
#else /* !CRYPT */
err(3, "cannot decrypt entry (need to recompile with full crypt.c)");
#endif /* ?CRYPT */
/* prepare output buffer and crc */
G.outptr = slide;
G.outcnt = 0L;
outsiz = 0L;
G.crc32val = CRCVAL_INITIAL;
/* decompress */
if (g || h[LOCHOW])
{ /* deflated entry */
int r;
#ifdef USE_ZLIB
/* need to allocate and prepare input buffer */
if ((G.inbuf = (uch *)malloc(INBUFSIZ)) == (uch *)NULL)
err(1, "out of memory");
#endif /* USE_ZLIB */
if ((r = UZinflate(__G)) != 0)
if (r == 3)
err(1, "out of memory");
else
err(4, "invalid compressed data--format violated");
inflate_free(__G);
}
else
{ /* stored entry */
register ulg n;
n = LG(h + LOCLEN);
#if CRYPT
if (n != LG(h + LOCSIZ) - (encrypted ? RAND_HEAD_LEN : 0)) {
#else
if (n != LG(h + LOCSIZ)) {
#endif
Info(slide, 1, ((char *)slide, "len %ld, siz %ld\n", n, LG(h + LOCSIZ)));
err(4, "invalid compressed data--length mismatch");
}
while (n--) {
ush c = getc(G.in);
#if CRYPT
if (encrypted)
zdecode(c);
#endif
*G.outptr++ = (uch)c;
if (++G.outcnt == WSIZE) /* do FlushOutput() */
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
G.outptr = slide;
G.outcnt = 0L;
}
}
}
if (G.outcnt) /* flush one last time; no need to reset G.outptr/outcnt */
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
}
fflush(out);
/* if extended header, get it */
if (g)
{
if (fread((char *)h + LOCCRC, 1, 8, G.in) != 8)
err(3, "gzip file ended prematurely");
}
else
if ((h[LOCFLG] & EXTFLG) &&
fread((char *)h + LOCCRC - 4, 1, EXTHDR, G.in) != EXTHDR)
err(3, "zipfile ended prematurely");
/* validate decompression */
if (LG(h + LOCCRC) != G.crc32val)
err(4, "invalid compressed data--crc error");
if (LG((g ? (h + LOCSIZ) : (h + LOCLEN))) != outsiz)
err(4, "invalid compressed data--length error");
/* check if there are more entries */
if (!g && fread((char *)h, 1, 4, G.in) == 4 && LG(h) == LOCSIG)
Info(slide, 1, ((char *)slide,
"funzip warning: zipfile has more than one entry--rest ignored\n"));
DESTROYGLOBALS()
RETURN (0);
}

100
zip/unzip/funzip.doc Executable file
View File

@ -0,0 +1,100 @@
FUNZIP(1L) FUNZIP(1L)
NAME
funzip - filter for extracting from a ZIP archive in a
pipe
SYNOPSIS
[...] | funzip [-password] | [...]
funzip [-password] input.zip | [...] funzip [-password]
input.gz | [...]
ARGUMENTS
[-password]
Optional password to be used if ZIP archive is
encrypted. Decryption may not be supported at some
sites. See DESCRIPTION for more details.
DESCRIPTION
funzip acts as a filter; that is, it assumes that a ZIP
archive (or a gzip'd(1) file) is being piped into standard
input, and it extracts the first member from the archive
to stdout. If there is an argument, then the input comes
from the specified file instead of from stdin. A password
for encrypted zip files can be specified on the command
line (preceding the file name, if any) by prefixing the
password with a dash. Note that this constitutes a secu-
rity risk on many systems; currently running processes are
often visible via simple commands (e.g., ps(1) under
Unix), and command-line histories can be read. If the
first entry of the zip file is encrypted and no password
is specified on the command line, then the user is
prompted for a password and the password is not echoed on
the console.
Given the limitation on single-member extraction, funzip
is most useful in conjunction with a secondary archiver
program such as tar(1). The following section includes an
example illustrating this usage in the case of disk back-
ups to tape.
EXAMPLES
To use funzip to extract the first member file of the
archive test.zip and to pipe it into more(1):
funzip test.zip | more
To use funzip to test the first member file of test.zip
(any errors will be reported on standard error):
funzip test.zip > /dev/null
To use zip and funzip in place of compress(1) and zcat(1)
(or gzip(1L) and gzcat(1L)) for tape backups:
tar cf - . | zip -7 | dd of=/dev/nrst0 obs=8k
Info-ZIP 31 May 1997 (v3.92) 1
FUNZIP(1L) FUNZIP(1L)
dd if=/dev/nrst0 ibs=8k | funzip | tar xf -
(where, for example, nrst0 is a SCSI tape drive).
BUGS
When piping an encrypted file into more and allowing fun-
zip to prompt for password, the terminal may sometimes be
reset to a non-echo mode. This is apparently due to a
race condition between the two programs; funzip changes
the terminal mode to non-echo before more reads its state,
and more then ``restores'' the terminal to this mode
before exiting. To recover, run funzip on the same file
but redirect to /dev/null rather than piping into more;
after prompting again for the password, funzip will reset
the terminal properly.
There is presently no way to extract any member but the
first from a ZIP archive. This would be useful in the
case where a ZIP archive is included within another
archive. In the case where the first member is a direc-
tory, funzip simply creates the directory and exits.
The functionality of funzip should be incorporated into
unzip itself (future release).
SEE ALSO
gzip(1L), unzip(1L), unzipsfx(1L), zip(1L), zipcloak(1L),
zipinfo(1L), zipnote(1L), zipsplit(1L)
URL
The Info-ZIP home page is currently at
http://www.cdrom.com/pub/infozip/ .
AUTHOR
Mark Adler (Info-ZIP)
Info-ZIP 31 May 1997 (v3.92) 2

195
zip/unzip/globals.c Executable file
View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------
globals.c
Routines to allocate and initialize globals, with or without threads.
Contents: registerGlobalPointer()
deregisterGlobalPointer()
getGlobalPointer()
globalsCtor()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
char *fnames[2] = {"*", NULL}; /* default filenames vector */
#ifndef REENTRANT
struct Globals G;
#else /* REENTRANT */
# ifndef USETHREADID
struct Globals *GG;
# else /* USETHREADID */
# define THREADID_ENTRIES 0x40
int lastScan;
struct Globals *threadPtrTable[THREADID_ENTRIES];
ulg threadIdTable [THREADID_ENTRIES] = {
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, /* Make sure there are */
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* THREADID_ENTRIES 0s */
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
};
static char Far TooManyThreads[] =
"error: more than %d simultaneous threads.\n\
Some threads are probably not calling DESTROYTHREAD()\n";
static char Far EntryNotFound[] =
"error: couldn't find global pointer in table.\n\
Maybe somebody accidentally called DESTROYTHREAD() twice.\n";
static char Far GlobalPointerMismatch[] =
"error: global pointer in table does not match pointer passed as\
parameter\n";
static void registerGlobalPointer OF((__GPRO));
static void registerGlobalPointer(__G)
__GDEF
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] && scan < THREADID_ENTRIES)
scan++;
if (scan == THREADID_ENTRIES) {
char *tooMany = LoadFarString(TooManyThreads);
Info(slide, 0x421, ((char *)slide, tooMany, THREADID_ENTRIES));
free(pG);
EXIT(PK_MEM); /* essentially memory error before we've started */
}
threadIdTable [scan] = tid;
threadPtrTable[scan] = pG;
lastScan = scan;
}
void deregisterGlobalPointer(__G)
__GDEF
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
scan++;
/*---------------------------------------------------------------------------
There are two things we can do if we can't find the entry: ignore it or
scream. The most likely reason for it not to be here is the user calling
this routine twice. Since this could cause BIG problems if any globals
are accessed after the first call, we'd better scream.
---------------------------------------------------------------------------*/
if (scan == THREADID_ENTRIES || threadPtrTable[scan] != pG) {
char *noEntry;
if (scan == THREADID_ENTRIES)
noEntry = LoadFarString(EntryNotFound);
else
noEntry = LoadFarString(GlobalPointerMismatch);
Info(slide, 0x421, ((char *)slide, noEntry));
EXIT(PK_WARN); /* programming error, but after we're all done */
}
threadIdTable [scan] = 0;
lastScan = scan;
free(threadPtrTable[scan]);
}
struct Globals *getGlobalPointer()
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
scan++;
/*---------------------------------------------------------------------------
There are two things we can do if we can't find the entry: ignore it or
scream. The most likely reason for it not to be here is the user calling
this routine twice. Since this could cause BIG problems if any globals
are accessed after the first call, we'd better scream.
---------------------------------------------------------------------------*/
if (scan == THREADID_ENTRIES) {
char *noEntry;
noEntry = LoadFarString(EntryNotFound);
fprintf(stderr, noEntry); /* can't use Info w/o a global pointer */
EXIT(PK_ERR); /* programming error while still working */
}
return threadPtrTable[scan];
}
# endif /* ?USETHREADID */
#endif /* ?REENTRANT */
struct Globals *globalsCtor()
{
#ifdef REENTRANT
struct Globals *pG = (struct Globals *)malloc(sizeof(struct Globals));
if (!pG)
return (struct Globals *)NULL;
#endif /* REENTRANT */
/* for REENTRANT version, G is defined as (*pG) */
memzero(&G, sizeof(struct Globals));
#ifdef CMS_MVS
G.aflag=1;
G.C_flag=1;
#endif
G.lflag=(-1);
G.wildzipfn = "";
G.pfnames = fnames;
G.pxnames = &fnames[1];
G.pInfo = G.info;
G.sol = TRUE; /* at start of line */
#ifndef FUNZIP
G.message = UzpMessagePrnt;
G.input = UzpInput; /* not used by anyone at the moment... */
#if defined(WINDLL) || defined(MACOS)
G.mpause = NULL; /* has scrollbars: no need for pausing */
#else
G.mpause = UzpMorePause;
#endif
G.decr_passwd = UzpPassword;
#endif /* !FUNZIP */
#if (!defined(DOS_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
G.echofd = -1;
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_H68_OS2_W32 || AMIGA || RISCOS) */
#ifdef SYSTEM_SPECIFIC_CTOR
SYSTEM_SPECIFIC_CTOR(__G);
#endif
#ifdef REENTRANT
#ifdef USETHREADID
registerGlobalPointer(__G);
#else
GG = &G;
#endif /* ?USETHREADID */
#endif /* REENTRANT */
return &G;
}

408
zip/unzip/globals.h Executable file
View File

@ -0,0 +1,408 @@
/*---------------------------------------------------------------------------
globals.h
There is usually no need to include this file since unzip.h includes it.
This header file is used by all of the UnZip source files. It contains
a struct definition that is used to "house" all of the global variables.
This is done to allow for multithreaded environments (OS/2, NT, Win95,
Unix) to call UnZip through an API without a semaphore. REENTRANT should
be defined for all platforms that require this.
GLOBAL CONSTRUCTOR AND DESTRUCTOR (API WRITERS READ THIS!!!)
------------------------------------------------------------
No, it's not C++, but it's as close as we can get with K&R.
The main() of each process that uses these globals must include the
CONSTRUCTGLOBALS; statement. This will malloc enough memory for the
structure and initialize any variables that require it. This must
also be done by any API function that jumps into the middle of the
code.
The DESTROYGLOBALS; statement should be inserted before EVERY "EXIT(n)".
Naturally, it also needs to be put before any API returns as well.
In fact, it's much more important in API functions since the process
will NOT end, and therefore the memory WON'T automatically be freed
by the operating system.
USING VARIABLES FROM THE STRUCTURE
----------------------------------
All global variables must now be prefixed with `G.' which is either a
global struct (in which case it should be the only global variable) or
a macro for the value of a local pointer variable that is passed from
function to function. Yes, this is a pain. But it's the only way to
allow full reentrancy.
ADDING VARIABLES TO THE STRUCTURE
---------------------------------
If you make the inclusion of any variables conditional, be sure to only
check macros that are GUARANTEED to be included in every module. For
instance, newzip, P_flag and pwdarg are needed only if CRYPT is TRUE,
but this is defined after unzip.h has been read. If you are not careful,
some modules will expect your variable to be part of this struct while
others won't. This will cause BIG problems. (Inexplicable crashes at
strange times, car fires, etc.) When in doubt, always include it!
Note also that UnZipSFX needs a few variables that UnZip doesn't. However,
it also includes some object files from UnZip. If we were to conditionally
include the extra variables that UnZipSFX needs, the object files from
UnZip would not mesh with the UnZipSFX object files. Result: we just
include the UnZipSFX variables every time. (It's only an extra 4 bytes
so who cares!)
ADDING FUNCTIONS
----------------
To support this new global struct, all functions must now conditionally
pass the globals pointer (pG) to each other. This is supported by 5 macros:
__GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other
parameters would look like this:
int extract_or_test_files(__G)
__GDEF
{
... stuff ...
}
A function with other parameters would look like:
int memextract(__G__ tgt, tgtsize, src, srcsize)
__GDEF
uch *tgt, *src;
ulg tgtsize, srcsize;
{
... stuff ...
}
In the Function Prototypes section of unzpriv.h, you should use __GPRO and
__GPRO__ instead:
int uz_opts OF((__GPRO__ int *pargc, char ***pargv));
int process_zipfiles OF((__GPRO));
Note that there is NO comma after __G__ or __GPRO__ and no semi-colon after
__GDEF. I wish there was another way but I don't think there is.
TESTING THE CODE
-----------------
Whether your platform requires reentrancy or not, you should always try
building with REENTRANT defined if any functions have been added. It is
pretty easy to forget a __G__ or a __GDEF and this mistake will only show
up if REENTRANT is defined. All platforms should run with REENTRANT
defined. Platforms that can't take advantage of it will just be paying
a performance penalty needlessly.
SIGNAL MADNESS
--------------
This whole pointer passing scheme falls apart when it comes to SIGNALs.
I handle this situation 2 ways right now. If you define USETHREADID,
UnZip will include a 64-entry table. Each entry can hold a global
pointer and thread ID for one thread. This should allow up to 64
threads to access UnZip simultaneously. Calling DESTROYGLOBALS()
will free the global struct and zero the table entry. If somebody
forgets to call DESTROYGLOBALS(), this table will eventually fill up
and UnZip will exit with an error message. A good way to test your
code to make sure you didn't forget a DESTROYGLOBALS() is to change
THREADID_ENTRIES to 3 or 4 in globals.c, making the table real small.
Then make a small test program that calls your API a dozen times.
Those platforms that don't have threads still need to be able to compile
with REENTRANT defined to test and see if new code is correctly written
to work either way. For these platforms, I simply keep a global pointer
called GG that points to the Globals structure. Good enough for testing.
I believe that NT has thread level storage. This could probably be used
to store a global pointer for the sake of the signal handler more cleanly
than my table approach.
---------------------------------------------------------------------------*/
#ifndef __globals_h
#define __globals_h
#ifdef USE_ZLIB
# include "zlib.h"
#endif
/*************/
/* Globals */
/*************/
struct Globals {
int zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */
int aflag; /* -a: do ASCII-EBCDIC and/or end-of-line translation */
#ifdef VMS
int bflag; /* -b: force fixed record format for binary files */
#endif
#ifdef UNIXBACKUP
int B_flag; /* -B: back up existing files by renaming to *~ first */
#endif
int cflag; /* -c: output to stdout */
int C_flag; /* -C: match filenames case-insensitively */
int dflag; /* -d: all args are files/dirs to be extracted */
int fflag; /* -f: "freshen" (extract only newer files) */
int hflag; /* -h: header line (zipinfo) */
#ifdef RISCOS
int scanimage; /* -I: scan image files */
#endif
int jflag; /* -j: junk pathnames (unzip) */
int lflag; /* -12slmv: listing format (zipinfo) */
int L_flag; /* -L: convert filenames from some OSes to lowercase */
#ifdef MORE
int M_flag; /* -M: built-in "more" function */
int height; /* check for SIGWINCH, etc., eventually... */
#endif /* (take line-wrapping into account?) */
int overwrite_none; /* -n: never overwrite files (no prompting) */
int overwrite_all; /* -o: OK to overwrite files without prompting */
int P_flag; /* -P: give password on command line (ARGH!) */
int qflag; /* -q: produce a lot less output */
#ifdef DOS_OS2_W32
int sflag; /* -s: convert spaces in filenames to underscores */
int volflag; /* -$: extract volume labels */
#endif
int tflag; /* -t: test (unzip) or totals line (zipinfo) */
int T_flag; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */
int uflag; /* -u: "update" (extract only newer/brand-new files) */
int vflag; /* -v: (verbosely) list directory */
int V_flag; /* -V: don't strip VMS version numbers */
#if defined(VMS) || defined(UNIX) || defined(OS2_W32) || defined(__BEOS__)
int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */
#endif
int zflag; /* -z: display the zipfile comment (only, for unzip) */
#ifdef MACOS
int HFSFlag;
#endif
int noargs; /* did true command line have *any* arguments? */
int filespecs; /* number of real file specifications to be matched */
int xfilespecs; /* number of excluded filespecs to be matched */
int process_all_files;
int create_dirs; /* used by main(), mapname(), checkdir() */
int extract_flag;
int newzip; /* reset in extract.c; used in crypt.c */
LONGINT real_ecrec_offset;
LONGINT expect_ecrec_offset;
long csize; /* used by decompr. (NEXTBYTE): must be signed */
long ucsize; /* used by unReduce(), explode() */
long used_csize; /* used by extract_or_test_member(), explode() */
#ifdef DLL
int filenotfound;
int redirect_data; /* redirect data to memory buffer */
int redirect_text; /* redirect text output to buffer */
# ifdef OS2DLL
cbList(processExternally); /* call-back list */
# endif
unsigned _wsize;
int stem_len;
int putchar_idx;
uch *redirect_pointer;
uch *redirect_buffer;
unsigned redirect_size;
#endif /* DLL */
char **pfnames;
char **pxnames;
char sig[5];
char answerbuf[10];
min_info info[DIR_BLKSIZ];
min_info *pInfo;
union work area; /* see unzpriv.h for definition of work */
#ifndef FUNZIP
ulg near *crc_32_tab;
#endif
ulg crc32val; /* CRC shift reg. (was static in funzip) */
uch *inbuf; /* input buffer (any size is OK) */
uch *inptr; /* pointer into input buffer */
int incnt;
ulg bitbuf;
int bits_left; /* unreduce and unshrink only */
int zipeof;
char *argv0; /* used for NT and EXE_EXTENSION */
char *wildzipfn;
char *zipfn; /* GRR: WINDLL: must nuke any malloc'd zipfn... */
#ifdef USE_STRM_INPUT
FILE *zipfd; /* zipfile file descriptor */
#else
int zipfd; /* zipfile file handle */
#endif
LONGINT ziplen;
LONGINT cur_zipfile_bufstart; /* extract_or_test, readbuf, ReadByte */
LONGINT extra_bytes; /* used in unzip.c, misc.c */
uch *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */
uch *hold;
char local_hdr_sig[5]; /* initialize sigs at runtime so unzip */
char central_hdr_sig[5]; /* executable won't look like a zipfile */
char end_central_sig[5];
/* char extd_local_sig[5]; NOT USED YET */
local_file_hdr lrec; /* used in unzip.c, extract.c */
cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */
ecdir_rec ecrec; /* used in unzip.c, extract.c */
struct stat statbuf; /* used by main, mapname, check_for_newer */
int mem_mode;
uch *outbufptr; /* extract.c static */
ulg outsize; /* extract.c static */
int reported_backslash; /* extract.c static */
int disk_full;
int newfile;
int didCRlast; /* fileio static */
ulg numlines; /* fileio static: number of lines printed */
int sol; /* fileio static: at start of line */
int no_ecrec; /* process static */
#ifdef SYMLINKS
int symlnk;
#endif
#ifdef NOVELL_BUG_FAILSAFE
int dne; /* true if stat() says file doesn't exist */
#endif
#ifdef FUNZIP
FILE *in;
#endif
FILE *outfile;
uch *outbuf;
uch *realbuf;
#ifndef VMS /* if SMALL_MEM, outbuf2 is initialized in */
uch *outbuf2; /* process_zipfiles() (never changes); */
#endif /* else malloc'd ONLY if unshrink and -a */
uch *outptr;
ulg outcnt; /* number of chars stored in outbuf */
char filename[FILNAMSIZ]; /* also used by NT for temporary SFX path */
#ifdef CMS_MVS
char *tempfn; /* temp file used; erase on close */
#endif
#ifdef MACOS
short gnVRefNum;
long glDirID;
OSType gostCreator;
OSType gostType;
int fMacZipped;
int macflag;
short giCursor;
CursHandle rghCursor[4]; /* status cursors */
#endif
char *pwdarg; /* pointer to command-line password (-P option) */
int nopwd; /* crypt static */
ulg keys[3]; /* crypt static: keys defining pseudo-random sequence */
char *key; /* crypt static: decryption password or NULL */
#if (!defined(DOS_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
int echofd; /* crypt static: file descriptor whose echo is off */
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_H68_OS2_W32 || AMIGA || RISCOS) */
unsigned hufts; /* track memory usage */
#ifdef USE_ZLIB
int inflInit; /* inflate static: zlib inflate() initialized */
z_stream dstrm; /* inflate global: decompression stream */
#else
struct huft *fixed_tl; /* inflate static */
struct huft *fixed_td; /* inflate static */
int fixed_bl, fixed_bd; /* inflate static */
unsigned wp; /* inflate static: current position in slide */
ulg bb; /* inflate static: bit buffer */
unsigned bk; /* inflate static: bits in bit buffer */
#endif /* ?USE_ZLIB */
#ifdef SMALL_MEM
char rgchBigBuffer[512];
char rgchSmallBuffer[96];
char rgchSmallBuffer2[160]; /* boosted to 160 for local3[] in unzip.c */
#endif
MsgFn *message;
InputFn *input;
PauseFn *mpause;
PasswdFn *decr_passwd;
#ifdef WINDLL
ReplaceFn *replace;
SoundFn *sound;
#endif
int incnt_leftover; /* so improved NEXTBYTE does not waste input */
uch *inptr_leftover;
#ifdef VMS_TEXT_CONV
int VMS_line_state; /* so native VMS variable-length text files are */
int VMS_line_length; /* readable on other platforms */
int VMS_line_pad;
#endif
#ifdef SYSTEM_SPECIFIC_GLOBALS
SYSTEM_SPECIFIC_GLOBALS
#endif
}; /* end of struct Globals */
/***************************************************************************/
#ifdef FUNZIP
# if !defined(USE_ZLIB) || defined(USE_OWN_CRCTAB)
extern ulg near crc_32_tab[];
# else
extern ulg near *crc_32_tab;
# endif
# define CRC_32_TAB crc_32_tab
#else
# define CRC_32_TAB G.crc_32_tab
#endif
struct Globals *globalsCtor OF((void));
#ifdef REENTRANT
# define G (*pG)
# define __G pG
# define __G__ pG,
# define __GPRO struct Globals *pG
# define __GPRO__ struct Globals *pG,
# define __GDEF struct Globals *pG;
# ifdef USETHREADID
extern int lastScan;
void deregisterGlobalPointer OF((__GPRO));
struct Globals *getGlobalPointer OF((void));
# define GETGLOBALS() struct Globals *pG = getGlobalPointer();
# define DESTROYGLOBALS() {free_G_buffers(pG); deregisterGlobalPointer(pG);}
# else
extern struct Globals *GG;
# define GETGLOBALS() struct Globals *pG = GG;
# define DESTROYGLOBALS() {free_G_buffers(pG); free(pG);}
# endif /* ?USETHREADID */
# define CONSTRUCTGLOBALS() struct Globals *pG = globalsCtor()
#else /* !REENTRANT */
extern struct Globals G;
# define __G
# define __G__
# define __GPRO void
# define __GPRO__
# define __GDEF
# define GETGLOBALS()
# define CONSTRUCTGLOBALS() globalsCtor()
# define DESTROYGLOBALS()
#endif /* ?REENTRANT */
#endif /* __globals_h */

11
zip/unzip/human68k/Contents Executable file
View File

@ -0,0 +1,11 @@
Contents of the "human68k" sub-archive for UnZip 5.3 and later:
Contents this file
Makefile.gcc (shorter) makefile for GNU C on X68000
human68k.c Human68K-specific routines for UnZip
options.s TwentyOne option checker (assembler routines) for Human68K
Note that options.s contains high-order ASCII characters; it must be
treated as a binary file when e-mailing or posting via Usenet.
This port has not been tested since version 5.12.

106
zip/unzip/human68k/Makefile.gcc Executable file
View File

@ -0,0 +1,106 @@
# Makefile for UnZip 5.20 and later: Human68K with gcc NIIMI Satoshi
#
# The original Makefile maybe works fine, but X68000 is too slow
# to process it. So I split out needed part.
#
# Last revised: 11 Feb 96
VPATH = HUMAN68K
CC = gcc
CFLAGS = -Wall -O -I. -fomit-frame-pointer -fstrength-reduce
LDFLAGS = -s
LIBS = -lsignal -ldos -lmb
# UnZipSFX flags
XC = -DSFX
# fUnZip flags
FC = -DFUNZIP
# object files
OBJS = unzip.o crc32.o crctab.o crypt.o envargs.o explode.o extract.o \
fileio.o globals.o inflate.o list.o match.o process.o ttyio.o \
unreduce.o unshrink.o zipinfo.o human68k.o options.o
OBJX = unzipsfx.o crc32.o crctab.o crypt.o extract_.o fileio.o inflate.o \
match.o process_.o ttyio.o human68_.o
OBJF = funzip.o crc32.o crypt_.o globals_.o inflate_.o ttyio_.o
UNZIP_H = unzip.h unzpriv.h globals.h
UNZIPS = unzip.x unzipsfx.x funzip.x
.c.o:
$(CC) $(CFLAGS) -I. -c $< -o $@
# for debugging
.c.s:
$(CC) $(CFLAGS) -c $< -o $@
all: unzips
unzips: $(UNZIPS)
docs: $(DOCS)
unzipsman: unzips docs
unzipsdocs: unzips docs
clean:
rm -f $(OBJS) $(OBJF) $(OBJX) $(UNZIPS)
unzip.x: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
unzipsfx.x: $(OBJX)
$(CC) $(LDFLAGS) -o $@ $(OBJX) $(LIBS)
funzip.x: $(OBJF)
$(CC) $(LDFLAGS) -o $@ $(OBJF) $(LIBS)
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 version.h consts.h
zipinfo.o: zipinfo.c $(UNZIP_H)
crypt_.o: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip
$(CC) $(CFLAGS) $(FC) -c $< -o $@
extract_.o: extract.c $(UNZIP_H) crypt.h # unzipsfx
$(CC) $(CFLAGS) $(XC) -c $< -o $@
globals_.o: globals.c $(UNZIP_H) # funzip
$(CC) $(CFLAGS) $(FC) -c $< -o $@
human68k.o: human68k/human68k.c $(UNZIP_H)
$(CC) $(CFLAGS) -I. -c human68k/human68k.c -o $@
human68_.o: human68k/human68k.c $(UNZIP_H) # unzipsfx
$(CC) $(CFLAGS) $(XC) -I. -c human68k/human68k.c -o $@
inflate_.o: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip
$(CC) $(CFLAGS) $(FC) -c $< -o $@
process_.o: process.c $(UNZIP_H) # unzipsfx
$(CC) $(CFLAGS) $(XC) -c $< -o $@
ttyio_.o: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip
$(CC) $(CFLAGS) $(FC) -c $< -o $@
unzipsfx.o: unzip.c $(UNZIP_H) crypt.h version.h consts.h # unzipsfx
$(CC) $(CFLAGS) $(XC) -c $< -o $@
diff:
-(cd ..; diff -cNr unz52h unz52h-x68k -x GNUmakefile -x "*.[ox]" > unzip68k.dif)

714
zip/unzip/human68k/human68k.c Executable file
View File

@ -0,0 +1,714 @@
/*---------------------------------------------------------------------------
human68k.c
Human68K-specific routines for use with Info-ZIP's UnZip 5.1 and later.
Contains: do_wild()
mapattr()
mapname()
checkdir()
close_outfile()
version()
TwentyOne()
normalize_name()
---------------------------------------------------------------------------*/
#include <dirent.h>
#include <sys/dos.h>
#include <sys/xunistd.h>
#include <jstring.h>
#define UNZIP_INTERNAL
#include "unzip.h"
static void normalize_name(char *);
static int created_dir; /* used in mapname(), checkdir() */
static int renamed_fullpath; /* ditto */
#ifndef SFX
/**********************/
/* Function do_wild() */
/**********************/
char *do_wild(__G__ wildspec)
__GDEF
char *wildspec; /* only used first time on a given dir */
{
static DIR *dir = NULL;
static char *dirname, *wildname, matchname[FILNAMSIZ];
static int firstcall=TRUE, 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 (firstcall) { /* first call: must initialize everything */
firstcall = FALSE;
/* break the wildspec into a directory part and a wildcard filename */
if ((wildname = strrchr(wildspec, '/')) == NULL) {
dirname = ".";
dirnamelen = 1;
have_dirname = FALSE;
wildname = wildspec;
} else {
++wildname; /* point at character after '/' */
dirnamelen = wildname - wildspec;
if ((dirname = (char *)malloc(dirnamelen+1)) == NULL) {
Info(slide, 1, ((char *)slide,
"warning: can't allocate wildcard buffers\n"));
strcpy(matchname, wildspec);
return matchname; /* but maybe filespec was not a wildcard */
}
strncpy(dirname, wildspec, dirnamelen);
dirname[dirnamelen] = '\0'; /* terminate for strcpy below */
have_dirname = TRUE;
}
if ((dir = opendir(dirname)) != NULL) {
while ((file = readdir(dir)) != NULL) {
if (file->d_name[0] == '.' && wildname[0] != '.')
continue; /* Unix: '*' and '?' do not match leading dot */
if (match(file->d_name, wildname, 0)) { /* 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(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) */
strcpy(matchname, wildspec);
return matchname;
}
/* last time through, might have failed opendir but returned raw wildspec */
if (dir == NULL) {
firstcall = TRUE; /* 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(dir)) != NULL)
if (match(file->d_name, wildname, 0)) { /* 0 == don't ignore case */
if (have_dirname) {
/* strcpy(matchname, dirname); */
strcpy(matchname+dirnamelen, file->d_name);
} else
strcpy(matchname, file->d_name);
return matchname;
}
closedir(dir); /* have read at least one dir entry; nothing left */
dir = NULL;
firstcall = TRUE; /* 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;
if (G.pInfo->hostnum == UNIX_ || G.pInfo->hostnum == VMS_)
G.pInfo->file_attr = _mode2dos(tmp >> 16);
else
/* set archive bit (file is not backed up): */
G.pInfo->file_attr = (unsigned)(G.crec.external_file_attributes|32) &
0xff;
return 0;
} /* end function mapattr() */
/**********************/
/* Function mapname() */
/**********************/
/* return 0 if no error, 1 if caution (filename */
int mapname(__G__ renamed) /* truncated), 2 if warning (skip file because */
__GDEF /* dir doesn't exist), 3 if error (skip file), */
int renamed; /* or 10 if out of memory (skip file) */
{ /* [also IZ_VOL_LABEL, IZ_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 quote = FALSE; /* flags */
int error = 0;
register unsigned workch; /* hold the character being tested */
/*---------------------------------------------------------------------------
Initialize various pointers and counters and stuff.
---------------------------------------------------------------------------*/
if (G.pInfo->vollabel)
return IZ_VOL_LABEL; /* can't set disk volume labels in Unix */
/* can create path as long as not just freshening, or if user told us */
G.create_dirs = (!G.fflag || renamed);
created_dir = FALSE; /* not yet */
/* user gave full pathname: don't prepend rootpath */
renamed_fullpath = (renamed && (*filename == '/'));
if (checkdir(__G__ (char *)NULL, INIT) == 10)
return 10; /* initialize path buffer, unless no memory */
*pathcomp = '\0'; /* initialize translation buffer */
pp = pathcomp; /* point to translation buffer */
if (G.jflag) /* junking directories */
cp = (char *)strrchr(G.filename, '/');
if (cp == 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) {
if (iskanji(workch)) {
*pp++ = (char)workch;
quote = TRUE;
} else if (quote) { /* if character quoted, */
*pp++ = (char)workch; /* include it literally */
quote = FALSE;
} else
switch (workch) {
case '/': /* can assume -j flag not given */
*pp = '\0';
if ((error = checkdir(__G__ pathcomp, APPEND_DIR)) > 1)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = NULL; /* leave directory semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp; /* keep for now; remove VMS ";##" */
*pp++ = (char)workch; /* later, if requested */
break;
case '\026': /* control-V quote for special chars */
quote = TRUE; /* set flag for next character */
break;
case ' ': /* change spaces to underscore under */
*pp++ = '_'; /* MTS; leave as spaces under Unix */
break;
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!G.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
/*---------------------------------------------------------------------------
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",
G.filename));
}
return IZ_CREATED_DIR; /* set dir time (note trailing '/') */
}
return 2; /* dir existed already; don't look for data to extract */
}
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
G.filename));
return 3;
}
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: 1 - (on APPEND_NAME) truncated filename
* 2 - path doesn't exist, not allowed to create
* 3 - path doesn't exist, tried to create and failed; or
* path exists and is not a directory, but is supposed to be
* 4 - path is too long
* 10 - 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;
char *old_end = end;
Trace((stderr, "appending dir segment [%s]\n", pathcomp));
while ((*end = *pathcomp++) != '\0')
++end;
normalize_name(old_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 2; /* path doesn't exist: nothing to do */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
if (MKDIR(buildpath, 0666) == -1) { /* create the directory */
Info(slide, 1, ((char *)slide,
"checkdir error: can't create %s\n\
unable to process %s.\n",
buildpath, G.filename));
free(buildpath);
return 3; /* path didn't exist, tried to create, failed */
}
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",
buildpath, G.filename));
free(buildpath);
return 3; /* path existed but wasn't dir */
}
if (too_long) {
Info(slide, 1, ((char *)slide,
"checkdir error: path too long: %s\n",
buildpath));
free(buildpath);
return 4; /* no room for filenames: fatal */
}
*end++ = '/';
*end = '\0';
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0;
} /* 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", pathcomp));
free(buildpath);
buildpath = end = (char *)NULL;
return 0;
}
/*---------------------------------------------------------------------------
APPEND_NAME: assume the path component is the filename; append it and
return without checking for existence.
---------------------------------------------------------------------------*/
if (FUNCTION == APPEND_NAME) {
char *old_end = end;
Trace((stderr, "appending filename [%s]\n", pathcomp));
while ((*end = *pathcomp++) != '\0') {
++end;
normalize_name(old_end);
if ((end-buildpath) >= FILNAMSIZ) {
*--end = '\0';
Info(slide, 1, ((char *)slide,
"checkdir warning: path too long; truncating\n\
%s\n -> %s\n",
G.filename, buildpath));
return 1; /* filename truncated */
}
}
Trace((stderr, "buildpath now = [%s]\n", buildpath));
return 0; /* could check for existence here, prompt for new name... */
}
/*---------------------------------------------------------------------------
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 10;
if ((rootlen > 0) && !renamed_fullpath) {
strcpy(buildpath, rootpath);
end = buildpath + rootlen;
} else {
*buildpath = '\0';
end = buildpath;
}
Trace((stderr, "[%s]\n", buildpath));
return 0;
}
/*---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------*/
#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 0;
}
if ((rootlen = strlen(pathcomp)) > 0) {
int had_trailing_pathsep=FALSE;
if (pathcomp[rootlen-1] == '/') {
pathcomp[--rootlen] = '\0';
had_trailing_pathsep = TRUE;
}
if (rootlen > 0 && (SSTAT(pathcomp, &G.statbuf) ||
!S_ISDIR(G.statbuf.st_mode))) /* path does not exist */
{
if (!G.create_dirs /* || iswild(pathcomp) */ ) {
rootlen = 0;
return 2; /* skip (or treat as stored file) */
}
/* create the directory (could add loop here to scan pathcomp
* and create more than one level, but why really necessary?) */
if (MKDIR(pathcomp, 0777) == -1) {
Info(slide, 1, ((char *)slide,
"checkdir: can't create extraction directory: %s\n",
pathcomp));
rootlen = 0; /* path didn't exist, tried to create, and */
return 3; /* failed: file exists, or 2+ levels required */
}
}
if ((rootpath = (char *)malloc(rootlen+2)) == NULL) {
rootlen = 0;
return 10;
}
strcpy(rootpath, pathcomp);
rootpath[rootlen++] = '/';
rootpath[rootlen] = '\0';
Trace((stderr, "rootpath now = [%s]\n", rootpath));
}
return 0;
}
#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);
return 0;
}
return 99; /* should never reach */
} /* end function checkdir() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
{
#ifdef USE_EF_UT_TIME
iztimes z_utime;
/* The following DOS date/time structure is machine dependent as it
* assumes "little endian" byte order. For MSDOS specific code, which
* is run on ix86 CPUs (or emulators), this assumption is valid; but
* care should be taken when using this code as template for other ports.
*/
union {
ulg z_dostime;
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;
} dos_dt;
#endif /* USE_EF_UT_TIME */
if (G.cflag) {
fclose(G.outfile);
return;
}
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
&z_utime, NULL) & EB_UT_FL_MTIME)) {
struct tm *t;
TTrace((stderr, "close_outfile: Unix e.f. modif. time = %ld\n",
z_utime.mtime));
/* round up to even seconds */
z_utime.mtime = (z_utime.mtime + 1) & (~1);
t = localtime(&(z_utime.mtime));
if (t->tm_year < 80) {
dos_dt.zt._t._tf.zt_se = 0;
dos_dt.zt._t._tf.zt_mi = 0;
dos_dt.zt._t._tf.zt_hr = 0;
dos_dt.zt._d._df.zd_dy = 1;
dos_dt.zt._d._df.zd_mo = 1;
dos_dt.zt._d._df.zd_yr = 0;
} else {
dos_dt.zt._t._tf.zt_se = t->tm_sec >> 1;
dos_dt.zt._t._tf.zt_mi = t->tm_min;
dos_dt.zt._t._tf.zt_hr = t->tm_hour;
dos_dt.zt._d._df.zd_dy = t->tm_mday;
dos_dt.zt._d._df.zd_mo = t->tm_mon + 1;
dos_dt.zt._d._df.zd_yr = t->tm_year - 80;
}
} else {
dos_dt.zt._t.ztime = G.lrec.last_mod_file_time;
dos_dt.zt._d.zdate = G.lrec.last_mod_file_date;
}
_dos_filedate(fileno(G.outfile), dos_dt.z_dostime);
#else /* !USE_EF_UT_TIME */
_dos_filedate(fileno(G.outfile),
(ulg)G.lrec.last_mod_file_date << 16 | G.lrec.last_mod_file_time);
#endif /* ?USE_EF_UT_TIME */
fclose(G.outfile);
_dos_chmod(G.filename, G.pInfo->file_attr);
} /* end function close_outfile() */
#ifndef SFX
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
int len;
#if 0
char buf[40];
#endif
len = sprintf((char *)slide, LoadFarString(CompiledWith),
#ifdef __GNUC__
"gcc ", __VERSION__,
#else
# if 0
"cc ", (sprintf(buf, " version %d", _RELEASE), buf),
# else
"unknown compiler", "",
# endif
#endif
"Human68k", " (X68000)",
#ifdef __DATE__
" on ", __DATE__
#else
"", ""
#endif
);
(*G.message)((zvoid *)&G, slide, (ulg)len, 0);
} /* end function version() */
#endif /* !SFX */
/* Human68K-specific routines */
#define VALID_CHAR "&#()@_^{}!"
extern ulg TwentyOneOptions(void);
static int multi_period = 0;
static int special_char = 0;
void
InitTwentyOne(void)
{
ulg stat;
stat = TwentyOneOptions();
if (stat == 0 || stat == (unsigned long) -1) {
special_char = 0;
multi_period = 0;
return;
}
if (stat & (1UL << 29))
special_char = 1;
if (stat & (1UL << 28))
multi_period = 1;
}
static void
normalize_name(char *name)
{
char *dot;
char *p;
if (strlen(name) > 18) { /* too long */
char base[18 + 1];
char ext[4 + 1];
if ((dot = jstrrchr(name, '.')) != NULL)
*dot = '\0';
strncpy(base, name, 18);
base[18] = '\0';
if (dot) {
*dot = '.';
strncpy(ext, dot, 4);
ext[4] = '\0';
} else
*ext = '\0';
strcpy(name, base);
strcat(name, ext);
}
dot = NULL;
for (p = name; *p; p++) {
if (iskanji((unsigned char)*p) && p[1] != '\0')
p++;
else if (*p == '.') {
if (!multi_period) {
dot = p;
*p = '_';
}
} else if (!special_char && !isalnum (*p)
&& strchr(VALID_CHAR, *p) == NULL)
*p = '_';
}
if (dot != NULL) {
*dot = '.';
if (strlen(dot) > 4)
dot[4] = '\0';
}
}

142
zip/unzip/human68k/options.s Executable file
View File

@ -0,0 +1,142 @@
*****************************************
* *
* TwentyOne.x *
* patch for human Ver 2.02,2.03 *
* *
*****************************************
*
* file name: options.s
* author: (T.Kawamoto)
* last modify: 92/3/1
* 92/3/17 thanks YUU(HARUKA)
*
blpeek: macro
moveq.l #$84,d0
trap #15
endm
*
getpdb: macro
dc.w $ff51
endm
*
.xdef _TwentyOneOptions
*
.text
*
_TwentyOneOptions:
movem.l a0-a2,-(sp)
bsr search_memory_blindly
tst.l d0
bne return
bsr search_device_blindly
return:
movem.l (sp)+,a0-a2
rts
*
search_device_blindly:
lea $00006800,a1
search_NUL_device_loop:
cmp.l #$00020000,a1
bcc sd_not_found
blpeek
cmp.l #'NUL ',d0
beq found_NUL_device
* lea 4(a1),a1 *
*
* 1992.03.17 YUU(HARUKA).
cmp.w #'NU',d0
bne search_NUL_device_loop
lea -2(a1),a1
bra search_NUL_device_loop
*
found_NUL_device:
* lea -14(a1),a1 *
lea -18(a1),a1 * IOCS B_LPEEK a1
* d0 + 4
*
* -18(a1) 1992.03.17 YUU.
search_device:
blpeek
sd_loop:
move.l d0,a0
lea $000E(a0),a2
bsr check_TW
tst.l d0
bne sd_end
lea.l (a0),a1
blpeek
cmp.l #$ffffffff,d0
bne sd_loop
sd_not_found:
moveq.l #0,d0
sd_end:
rts
*
search_memory_blindly:
getpdb
move.l d0,a1
lea -16(a1),a1
search_top_loop:
lea 4(a1),a1
blpeek
tst.l d0
beq found_top
move.l d0,a1
bra search_top_loop
*
found_top:
lea -8(a1),a1 *
* lea 8(a1),a1 *
* 1992.03.17 YUU(HARUKA).
search_memory:
lea 12(a1),a1
blpeek
sm_loop:
move.l d0,a0
lea $010E(a0),a2
bsr check_TW
tst.l d0
bne sm_end
lea $000C(a0),a1
blpeek
tst.l d0
bne sm_loop
moveq.l #0,d0
sm_end:
rts
*
check_TW:
lea (a2),a1
blpeek
cmp.l #'?Twe',d0
beq check_new
cmp.l #'*Twe',d0
bne check_error
check_old:
lea $0004(a2),a1
blpeek
cmp.l #'nty*',d0
bne check_error
moveq.l #-1,d0
rts
*
check_new:
lea $0004(a2),a1
blpeek
cmp.l #'nty?',d0
beq check_new_E
cmp.l #'ntyE',d0
bne check_error
check_new_E:
lea $0008(a2),a1
blpeek
rts
*
check_error:
moveq.l #0,d0
rts
*
dc.b 'TwentyOne Option Checker Ver 1.00 '
dc.b 'Copyright 1991,92 (.awamoto)',0
*
.end

1292
zip/unzip/inflate.c Executable file

File diff suppressed because it is too large Load Diff

24
zip/unzip/inflate.h Executable file
View File

@ -0,0 +1,24 @@
/* inflate.h for UnZip -- put in the public domain by Mark Adler
version c14f, 23 November 1995 */
/* 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
---- --------- -------------- ------------------------------------
c14 12 Mar 93 M. Adler made inflate.c standalone with the
introduction of inflate.h.
c14d 28 Aug 93 G. Roelofs replaced flush/FlushOutput with new version
c14e 29 Sep 93 G. Roelofs moved everything into unzip.h; added crypt.h
c14f 23 Nov 95 G. Roelofs added UNZIP_INTERNAL to accommodate newly
split unzip.h
*/
#define UNZIP_INTERNAL
#include "unzip.h" /* provides slide[], typedefs and macros */
#ifdef FUNZIP
# include "crypt.h" /* provides NEXTBYTE macro for crypt version of funzip */
#endif

635
zip/unzip/list.c Executable file
View File

@ -0,0 +1,635 @@
/*---------------------------------------------------------------------------
list.c
This file contains the non-ZipInfo-specific listing routines for UnZip.
Contains: list_files()
time_stamp() [still experimental and Unix-only]
ratio()
fnprint()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef WINDLL
# ifdef POCKET_UNZIP
# include "wince/intrface.h"
# else
# include "windll/windll.h"
# endif
#endif
#ifdef TIME_STAMP
static int fn_is_dir OF((__GPRO));
#endif
/* GRR 970327: Headers*[] formerly referenced in WinGUI code; no longer? */
#ifdef OS2_EAS
char Far HeadersS[] = " Length EAs ACLs Date Time Name";
char Far HeadersS1[] = " ------ --- ---- ---- ---- ----";
#else
char Far HeadersS[] = " Length Date Time Name";
char Far HeadersS1[] = " ------ ---- ---- ----";
#endif
static char Far CompFactorStr[] = "%c%d%%";
static char Far CompFactor100[] = "100%%";
#ifndef WINDLL
char Far HeadersL[] =
" Length Method Size Ratio Date Time CRC-32 Name";
char Far HeadersL1[] =
" ------ ------ ---- ----- ---- ---- ------ ----";
char Far *Headers[][2] = { {HeadersS, HeadersS1}, {HeadersL, HeadersL1} };
static char Far CaseConversion[] = "%s (\"^\" ==> case\n%s conversion)\n";
static char Far LongHdrStats[] =
"%7lu %-7s%7lu %4s %02u-%02u-%02u %02u:%02u %08lx %c";
static char Far LongFileTrailer[] =
" ------ ------ --- \
-------\n%7lu %7lu %4s %u file%s\n";
#ifdef OS2_EAS
static char Far ShortHdrStats[] =
"%7lu %6lu %6lu %02u-%02u-%02u %02u:%02u %c";
static char Far ShortFileTrailer[] = " ------ ----- ----- \
-------\n%7lu %6lu %6lu %u file%s\n";
static char Far OS2ExtAttrTrailer[] =
"%ld file%s %ld bytes of OS/2 extended attributes attached.\n";
static char Far OS2ACLTrailer[] =
"%ld file%s %ld bytes of access control lists attached.\n";
#else
static char Far ShortHdrStats[] = "%7lu %02u-%02u-%02u %02u:%02u %c";
static char Far ShortFileTrailer[] =
" ------ -------\n%7lu %u file%s\n";
#endif /* ?OS2_EAS */
#endif /* ?WINDLL */
/*************************/
/* Function list_files() */
/*************************/
int list_files(__G) /* return PK-type error code */
__GDEF
{
char sgn, cfactorstr[10];
int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
#ifndef WINDLL
int longhdr=(G.vflag>1);
#endif
int date_format;
unsigned methnum;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
ush j, yr, mo, dy, hh, mm, members=0;
ulg csiz, tot_csize=0L, tot_ucsize=0L;
#ifdef OS2_EAS
ulg ea_size, tot_easize=0L, tot_eafiles=0L;
ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L;
#endif
min_info info;
char methbuf[8];
static char dtype[]="NXFS"; /* see zi_short() */
static char Far method[NUM_METHODS+1][8] =
{"Stored", "Shrunk", "Reduce1", "Reduce2", "Reduce3", "Reduce4",
"Implode", "Token", "Defl:#", "EnhDefl", "ImplDCL", "Unk:###"};
/*---------------------------------------------------------------------------
Unlike extract_or_test_files(), this routine confines itself to the cen-
tral directory. Thus its structure is somewhat simpler, since we can do
just a single loop through the entire directory, listing files as we go.
So to start off, print the heading line and then begin main loop through
the central directory. The results will look vaguely like the following:
Length Method Size Ratio Date Time CRC-32 Name ("^" ==> case
------ ------ ---- ----- ---- ---- ------ ---- conversion)
44004 Implode 13041 71% 11-02-89 19:34 8b4207f7 Makefile.UNIX
3438 Shrunk 2209 36% 09-15-90 14:07 a2394fd8 ^dos-file.ext
---------------------------------------------------------------------------*/
G.pInfo = &info;
date_format = DATE_FORMAT;
#ifndef WINDLL
if (G.qflag < 2)
if (G.L_flag)
Info(slide, 0, ((char *)slide, LoadFarString(CaseConversion),
LoadFarStringSmall(Headers[longhdr][0]),
LoadFarStringSmall2(Headers[longhdr][1])));
else
Info(slide, 0, ((char *)slide, "%s\n%s\n",
LoadFarString(Headers[longhdr][0]),
LoadFarStringSmall(Headers[longhdr][1])));
#endif /* !WINDLL */
for (j = 0; j < G.ecrec.total_entries_central_dir; ++j) {
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, G.central_hdr_sig, 4)) { /* just to make sure */
Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
return PK_BADERR;
}
/* process_cdir_file_hdr() sets pInfo->lcflag: */
if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
return error; /* only PK_EOF defined */
/*
* We could DISPLAY the filename instead of storing (and possibly trun-
* cating, in the case of a very long name) and printing it, but that
* has the disadvantage of not allowing case conversion--and it's nice
* to be able to see in the listing precisely how you have to type each
* filename in order for unzip to consider it a match. Speaking of
* which, if member names were specified on the command line, check in
* with match() to see if the current file is one of them, and make a
* note of it if it is.
*/
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
PK_COOL) /* ^--(uses pInfo->lcflag) */
{
error_in_archive = error;
if (error > PK_WARN) /* fatal: can't continue */
return error;
}
if (G.extra_field != (uch *)NULL) {
free(G.extra_field);
G.extra_field = (uch *)NULL;
}
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
!= 0)
{
error_in_archive = error;
if (error > PK_WARN) /* fatal */
return error;
}
if (!G.process_all_files) { /* check if specified on command line */
char **pfn = G.pfnames-1;
do_this_file = FALSE;
while (*++pfn)
if (match(G.filename, *pfn, G.C_flag)) {
do_this_file = TRUE;
break; /* found match, so stop looping */
}
if (do_this_file) { /* check if this is an excluded file */
char **pxn = G.pxnames-1;
while (*++pxn)
if (match(G.filename, *pxn, G.C_flag)) {
do_this_file = FALSE; /* ^-- ignore case in match */
break;
}
}
}
/*
* If current file was specified on command line, or if no names were
* specified, do the listing for this file. Otherwise, get rid of the
* file comment and go back for the next file.
*/
if (G.process_all_files || do_this_file) {
#ifdef OS2DLL
/* this is used by UzpFileTree() to allow easy processing of lists
* of zip directory contents */
if (G.processExternally)
if ((G.processExternally)(G.filename, &G.crec))
break;
else
continue;
#endif
#ifdef OS2_EAS
{
uch *ef_ptr = G.extra_field;
int ef_size, ef_len = G.crec.extra_field_length;
ea_size = acl_size = 0;
while (ef_len >= EB_HEADSIZE) {
ef_size = makeword(&ef_ptr[EB_LEN]);
switch (makeword(&ef_ptr[EB_ID])) {
case EF_OS2:
ea_size = makelong(&ef_ptr[EB_HEADSIZE]);
break;
case EF_ACL:
acl_size = makelong(&ef_ptr[EB_HEADSIZE]);
break;
}
ef_ptr += (ef_size + EB_HEADSIZE);
ef_len -= (ef_size + EB_HEADSIZE);
}
}
#endif
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
&z_utime, NULL) & EB_UT_FL_MTIME))
{
struct tm *t;
TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0, Mac */
t = localtime(&(z_utime.mtime));
switch (date_format) {
case DF_YMD:
mo = (ush)(t->tm_year);
dy = (ush)(t->tm_mon + 1);
yr = (ush)(t->tm_mday);
break;
case DF_DMY:
mo = (ush)(t->tm_mday);
dy = (ush)(t->tm_mon + 1);
yr = (ush)(t->tm_year);
break;
default:
mo = (ush)(t->tm_mon + 1);
dy = (ush)(t->tm_mday);
yr = (ush)(t->tm_year);
}
hh = (ush)(t->tm_hour);
mm = (ush)(t->tm_min);
} else
#endif /* USE_EF_UT_TIME */
{
yr = (ush)((((G.crec.last_mod_file_date >> 9) & 0x7f) + 80) %
(unsigned)100);
mo = (ush)((G.crec.last_mod_file_date >> 5) & 0x0f);
dy = (ush)(G.crec.last_mod_file_date & 0x1f);
/* permute date so it displays according to nat'l convention */
switch (date_format) {
case DF_YMD:
hh = mo; mo = yr; yr = dy; dy = hh;
break;
case DF_DMY:
hh = mo; mo = dy; dy = hh;
}
hh = (ush)((G.crec.last_mod_file_time >> 11) & 0x1f);
mm = (ush)((G.crec.last_mod_file_time >> 5) & 0x3f);
}
csiz = G.crec.csize;
if (G.crec.general_purpose_bit_flag & 1)
csiz -= 12; /* if encrypted, don't count encryption header */
if ((cfactor = ratio(G.crec.ucsize, csiz)) < 0) {
sgn = '-';
cfactor = (-cfactor + 5) / 10;
} else {
sgn = ' ';
cfactor = (cfactor + 5) / 10;
}
if (cfactor == 100)
sprintf(cfactorstr, LoadFarString(CompFactor100));
else
sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
methnum = MIN(G.crec.compression_method, NUM_METHODS);
zfstrcpy(methbuf, method[methnum]);
if (methnum == DEFLATED) {
methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
} else if (methnum >= NUM_METHODS) {
sprintf(&methbuf[4], "%03u", G.crec.compression_method);
}
#if 0 /* GRR/Euro: add this? */
#if defined(DOS_OS2_W32) || defined(UNIX)
for (p = G.filename; *p; ++p)
if (!isprint(*p))
*p = '?'; /* change non-printable chars to '?' */
#endif /* DOS_OS2_W32 || UNIX */
#endif /* 0 */
#ifdef WINDLL
/* send data to application for formatting and printing */
(*lpUserFunctions->SendApplicationMessage)(G.crec.ucsize, csiz,
(ush)cfactor, mo, dy, yr, hh, mm,
(char)(G.pInfo->lcflag ? '^' : ' '),
fnfilter(G.filename, slide), methbuf, G.crec.crc32,
(G.crec.general_purpose_bit_flag & 1)? 'E' : ' ');
#else /* !WINDLL */
if (longhdr)
Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats),
G.crec.ucsize, methbuf, csiz, cfactorstr, mo, dy,
yr, hh, mm, G.crec.crc32, (G.pInfo->lcflag? '^':' ')));
else
#ifdef OS2_EAS
Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
G.crec.ucsize, ea_size, acl_size,
mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
#else
Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
G.crec.ucsize,
mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
#endif
fnprint(__G);
#endif /* ?WINDLL */
if ((error = do_string(__G__ G.crec.file_comment_length,
QCOND? DISPL_8 : SKIP)) != 0)
{
error_in_archive = error; /* might be just warning */
if (error > PK_WARN) /* fatal */
return error;
}
tot_ucsize += G.crec.ucsize;
tot_csize += csiz;
++members;
#ifdef OS2_EAS
if (ea_size) {
tot_easize += ea_size;
++tot_eafiles;
}
if (acl_size) {
tot_aclsize += acl_size;
++tot_aclfiles;
}
#endif
} else { /* not listing this file */
SKIP_(G.crec.file_comment_length)
}
} /* end for-loop (j: files in central directory) */
/*---------------------------------------------------------------------------
Print footer line and totals (compressed size, uncompressed size, number
of members in zipfile).
---------------------------------------------------------------------------*/
if (G.qflag < 2) {
if ((cfactor = ratio(tot_ucsize, tot_csize)) < 0) {
sgn = '-';
cfactor = (-cfactor + 5) / 10;
} else {
sgn = ' ';
cfactor = (cfactor + 5) / 10;
}
if (cfactor == 100)
sprintf(cfactorstr, LoadFarString(CompFactor100));
else
sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
#ifdef WINDLL
/* pass the totals back to the calling application */
lpUserFunctions->TotalSizeComp = tot_csize;
lpUserFunctions->TotalSize = tot_ucsize;
lpUserFunctions->CompFactor = cfactor;
lpUserFunctions->NumMembers = members;
#else /* !WINDLL */
if (longhdr) {
Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer),
tot_ucsize, tot_csize, cfactorstr, members, members==1? "":"s"));
#ifdef OS2_EAS
if (tot_easize || tot_aclsize)
Info(slide, 0, ((char *)slide, "\n"));
if (tot_eafiles && tot_easize)
Info(slide, 0, ((char *)slide, LoadFarString(OS2ExtAttrTrailer),
tot_eafiles, tot_eafiles == 1? " has" : "s have a total of",
tot_easize));
if (tot_aclfiles && tot_aclsize)
Info(slide, 0, ((char *)slide, LoadFarString(OS2ACLTrailer),
tot_aclfiles, tot_aclfiles == 1? " has" : "s have a total of",
tot_aclsize));
#endif /* OS2_EAs */
} else
#ifdef OS2_EAS
Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
tot_ucsize, tot_easize, tot_aclsize, members, members == 1?
"" : "s"));
#else
Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
tot_ucsize, members, members == 1? "" : "s"));
#endif /* OS2_EAs */
#endif /* ?WINDLL */
}
/*---------------------------------------------------------------------------
Double check that we're back at the end-of-central-directory record.
---------------------------------------------------------------------------*/
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, G.end_central_sig, 4)) { /* just to make sure again */
Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
error_in_archive = PK_WARN;
}
if (members == 0 && error_in_archive <= PK_WARN)
error_in_archive = PK_FIND;
return error_in_archive;
} /* end function list_files() */
#ifdef TIMESTAMP
/************************/
/* Function fn_is_dir() */
/************************/
static int fn_is_dir(__G) /* returns TRUE if G.filename is directory */
__GDEF
{
extent fn_len = strlen(G.filename);
register char endc;
return fn_len > 0 &&
((endc = G.filename[fn_len-1]) == '/' ||
(G.pInfo->hostnum == FS_FAT_ && !strchr(G.filename, '/') &&
endc == '\\'));
}
/*************************/
/* Function time_stamp() */
/*************************/
int time_stamp(__G) /* return PK-type error code */
__GDEF
{
int do_this_file=FALSE, error, error_in_archive=PK_COOL;
iztimes z_utime;
time_t last_modtime=0L; /* assuming no zipfile data older than 1970 */
ush j, members=0;
min_info info;
/*---------------------------------------------------------------------------
Unlike extract_or_test_files() but like list_files(), this function works
on information in the central directory alone. Thus we have a single,
large loop through the entire directory, searching for the latest time
stamp.
---------------------------------------------------------------------------*/
G.pInfo = &info;
for (j = 0; j < G.ecrec.total_entries_central_dir; ++j) {
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, G.central_hdr_sig, 4)) { /* just to make sure */
Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
return PK_BADERR;
}
/* process_cdir_file_hdr() sets pInfo->lcflag: */
if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
return error; /* only PK_EOF defined */
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) != PK_OK)
{ /* ^-- (uses pInfo->lcflag) */
error_in_archive = error;
if (error > PK_WARN) /* fatal: can't continue */
return error;
}
if (G.extra_field != (uch *)NULL) {
free(G.extra_field);
G.extra_field = (uch *)NULL;
}
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
!= 0)
{
error_in_archive = error;
if (error > PK_WARN) /* fatal */
return error;
}
if (!G.process_all_files) { /* check if specified on command line */
char **pfn = G.pfnames-1;
do_this_file = FALSE;
while (*++pfn)
if (match(G.filename, *pfn, G.C_flag)) {
do_this_file = TRUE;
break; /* found match, so stop looping */
}
if (do_this_file) { /* check if this is an excluded file */
char **pxn = G.pxnames-1;
while (*++pxn)
if (match(G.filename, *pxn, G.C_flag)) {
do_this_file = FALSE; /* ^-- ignore case in match */
break;
}
}
}
/* If current file was specified on command line, or if no names were
* specified, check the time for this file. Either way, get rid of the
* file comment and go back for the next file.
* Directory entries are always ignored, to stay compatible with both
* Zip and PKZIP.
*/
if ((G.process_all_files || do_this_file) && !fn_is_dir(__G)) {
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
&z_utime, NULL) & EB_UT_FL_MTIME))
{
if (last_modtime < z_utime.mtime)
last_modtime = z_utime.mtime;
} else
#endif /* USE_EF_UT_TIME */
{
time_t modtime = dos_to_unix_time(G.crec.last_mod_file_date,
G.crec.last_mod_file_time);
if (last_modtime < modtime)
last_modtime = modtime;
}
++members;
}
SKIP_(G.crec.file_comment_length)
} /* end for-loop (j: files in central directory) */
/*---------------------------------------------------------------------------
Set the modification (and access) time on the zipfile, assuming we have
a modification time to set.
---------------------------------------------------------------------------*/
if (members > 0) {
z_utime.mtime = z_utime.atime = last_modtime;
if (utime(G.zipfn, (ztimbuf *)&z_utime))
Info(slide, 0x201, ((char *)slide,
"warning: can't set time for %s\n", G.zipfn));
}
/*---------------------------------------------------------------------------
Double check that we're back at the end-of-central-directory record.
---------------------------------------------------------------------------*/
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, G.end_central_sig, 4)) { /* just to make sure again */
Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
error_in_archive = PK_WARN;
}
if (members == 0 && error_in_archive <= PK_WARN)
error_in_archive = PK_FIND;
return error_in_archive;
} /* end function time_stamp() */
#endif /* TIMESTAMP */
/********************/
/* Function ratio() */ /* also used by ZipInfo routines */
/********************/
int ratio(uc, c)
ulg uc, c;
{
ulg denom;
if (uc == 0)
return 0;
if (uc > 2000000L) { /* risk signed overflow if multiply numerator */
denom = uc / 1000L;
return ((uc >= c) ?
(int) ((uc-c + (denom>>1)) / denom) :
-((int) ((c-uc + (denom>>1)) / denom)));
} else { /* ^^^^^^^^ rounding */
denom = uc;
return ((uc >= c) ?
(int) ((1000L*(uc-c) + (denom>>1)) / denom) :
-((int) ((1000L*(c-uc) + (denom>>1)) / denom)));
} /* ^^^^^^^^ rounding */
}
/************************/
/* Function fnprint() */ /* also used by ZipInfo routines */
/************************/
void fnprint(__G) /* print filename (after filtering) and newline */
__GDEF
{
char *name = fnfilter(G.filename, slide);
(*G.message)((zvoid *)&G, (uch *)name, (ulg)strlen(name), 0);
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
} /* end function fnprint() */

20
zip/unzip/mac/Contents Executable file
View File

@ -0,0 +1,20 @@
Contents of the "mac" sub-archive for UnZip 5.3 and later:
Contents this file
mac.c Mac-specific filesystem code
macdir.c Macintosh Unix-style directory emulation
macdir.h header file for directory emulation
macscreen.c Macintosh window handling routines
macstat.c Macintosh stat() emulation
macstat.h header file for stat() emulation
macunzip.c Macintosh standalone version main program
rsrc.hqx resource file for Macintosh unzip (BinHex)
thinkc.hqx Think C project file (BinHex)
The resource file and the Think C project file are in BinHex form because
they contain Macintosh resource forks (only) and as such can not be simply
stored a normal file on a non-Macintosh system. BinHex form is the
traditional way for transferring such files via non-Macintosh systems. It's
also the safest since it uses only printable characters. Both of the ".hqx"
files must be converted with StuffitExpander or BinHex 4.0 (or equivalent)
on a Macintosh system before using them.

11
zip/unzip/mac/README Executable file
View File

@ -0,0 +1,11 @@
UnZip requires the host computer to have proper timezone information in
order to handle certain tasks correctly (see unzip.doc). To set the
timezone on the Macintosh, go to the Map Control Panel and enter the
correct number of hours (and, in a few locales, minutes) offset from
Universal Time/Greenwich Mean Time. For example, the US Pacific timezone
is -8 hours from UTC/GMT during standard (winter) time and -7 hours from
UTC/GMT during Daylight Savings Time. The US Eastern timezone is -5 hours
during the winter and -4 hours during the summer.
(Corrections welcome...description is loosely based on information from
Johnny Lee.)

1150
zip/unzip/mac/mac.c Executable file

File diff suppressed because it is too large Load Diff

140
zip/unzip/mac/macdir.c Executable file
View File

@ -0,0 +1,140 @@
#include <Errors.h>
#include <Files.h>
#ifndef THINK_C
#include <Strings.h>
#endif
#ifndef FSFCBLen
#define FSFCBLen (*(short *)0x3F6)
#endif
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "macdir.h"
int closedir(dPtr) DIR *dPtr; {
free(dPtr);
return 0;
}
DIR *opendir(dirName) char *dirName; {
int fullPath, pathLen;
char *s, pName[256];
HParamBlockRec hPB;
CInfoPBRec cPB;
DIR *dPtr;
OSErr err;
if (dirName == NULL || *dirName == '\0' || (pathLen = strlen(dirName)) > 255) {
errno = EINVAL;
return NULL;
}
if (FSFCBLen <= 0) {
errno = ENOTDIR;
return NULL;
}
/* Get information about volume. */
memset(&hPB, '\0', sizeof(hPB));
strcpy(pName, dirName);
if (((s = strchr(pName, ':')) == NULL) || (*pName == ':')) {
fullPath = false;
} else {
*(s + 1) = '\0';
c2pstr(pName);
hPB.volumeParam.ioVolIndex = -1;
fullPath = true;
}
hPB.volumeParam.ioNamePtr = (StringPtr)pName;
err = PBHGetVInfo(&hPB, 0);
if ((err != noErr) || (hPB.volumeParam.ioVFSID != 0)) {
errno = ENOENT;
return NULL;
}
/* Get information about file. */
memset(&cPB, '\0', sizeof(cPB));
strcpy(pName, dirName);
c2pstr(pName);
if (fullPath)
cPB.hFileInfo.ioVRefNum = hPB.volumeParam.ioVRefNum;
cPB.hFileInfo.ioNamePtr = (StringPtr)pName;
err = PBGetCatInfo(&cPB, false);
if (err != noErr) {
errno = (err == fnfErr) ? ENOENT : EIO;
return NULL;
}
if (!(cPB.hFileInfo.ioFlAttrib & ioDirMask)) {
errno = ENOTDIR;
return NULL;
}
/* Get space for, and fill in, DIR structure. */
if ((dPtr = (DIR *)malloc(sizeof(DIR))) == NULL) {
return NULL;
}
dPtr->ioVRefNum = cPB.dirInfo.ioVRefNum;
dPtr->ioDrDirID = cPB.dirInfo.ioDrDirID;
dPtr->ioFDirIndex = 1;
dPtr->flags = 0;
return dPtr;
}
struct dirent *readdir(dPtr) DIR *dPtr; {
struct dirent *dirPtr;
CInfoPBRec cPB;
char name[32];
OSErr err;
if (dPtr->flags) {
return NULL;
}
/* Get information about file. */
memset(&cPB, '\0', sizeof(cPB));
cPB.hFileInfo.ioNamePtr = (StringPtr)name;
cPB.hFileInfo.ioFDirIndex = dPtr->ioFDirIndex;
cPB.hFileInfo.ioVRefNum = dPtr->ioVRefNum;
cPB.hFileInfo.ioDirID = dPtr->ioDrDirID;
err = PBGetCatInfo(&cPB, false);
if (err != noErr) {
dPtr->flags = 0xff;
errno = (err == fnfErr) ? ENOENT : EIO;
return NULL;
}
p2cstr((StringPtr)name);
dirPtr = &dPtr->currEntry;
dirPtr->d_fileno = dPtr->ioFDirIndex++;
dirPtr->d_namlen = strlen(name);
strcpy(dirPtr->d_name, name);
dirPtr->d_reclen = sizeof(struct dirent) - sizeof(dirPtr->d_name) + dirPtr->d_namlen;
return dirPtr;
}

41
zip/unzip/mac/macdir.h Executable file
View File

@ -0,0 +1,41 @@
/*****************************************************************
*
* dirent.h
*
*****************************************************************/
#ifndef __DIRENT_H
#define __DIRENT_H
#include <errno.h>
#ifndef ENOTDIR
#define ENOTDIR 20
#endif
#ifndef NAME_MAX
#define NAME_MAX 31
#endif
struct dirent {
unsigned long d_fileno;
short d_reclen;
short d_namlen;
char d_name[NAME_MAX + 1];
};
typedef struct {
short ioFDirIndex;
short ioVRefNum;
long ioDrDirID;
short flags;
struct dirent currEntry;
} DIR;
#define direct dirent
DIR *opendir(char *);
struct dirent *readdir(DIR *);
void rewinddir(DIR *);
int closedir(DIR *);
#endif

324
zip/unzip/mac/macscreen.c Executable file
View File

@ -0,0 +1,324 @@
#include <QuickDraw.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#define bufferSize 1024
#define screenWindow 128
static Rect scrollRect, pauseRect;
static WindowPtr theWindow;
static RgnHandle scrollRgn;
static short fontHeight, fontWidth, screenHeight, screenWidth;
static short currentPosition, maxPosition, pausePosition;
static short *screenLength, startLine, endLine;
static char *screenImage, **screenLine;
static int screenOptions;
#define pauseOption 0x0001
#define scrollOption 0x0002
void screenOpen(char *Title) {
FontInfo fontInfo;
int n;
theWindow = GetNewWindow(screenWindow, nil, (WindowPtr)(-1));
if ((Title != NULL) && (*Title != '\0')) {
c2pstr(Title);
SetWTitle(theWindow, (StringPtr)Title);
p2cstr(Title);
}
ShowWindow(theWindow);
SetPort(theWindow);
TextFont(monaco);
TextSize(9);
GetFontInfo(&fontInfo);
fontHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
fontWidth = fontInfo.widMax;
scrollRgn = NewRgn();
screenWidth = (theWindow->portRect.right - theWindow->portRect.left - 10) /
fontWidth;
screenHeight = (theWindow->portRect.bottom - theWindow->portRect.top) /
fontHeight;
maxPosition = screenHeight * fontHeight;
pausePosition = maxPosition - (currentPosition = fontHeight);
SetRect(&scrollRect, theWindow->portRect.left, theWindow->portRect.top + fontInfo.descent,
theWindow->portRect.right, theWindow->portRect.bottom);
SetRect(&pauseRect, theWindow->portRect.left, pausePosition + fontInfo.descent,
theWindow->portRect.right, theWindow->portRect.bottom);
MoveTo(5, currentPosition);
n = (sizeof(char *) + sizeof(short) + screenWidth) * screenHeight;
screenLine = (char **)NewPtr(n);
screenLength = (short *)&screenLine[screenHeight];
screenImage = (char *)&screenLength[screenHeight];
for (n = 0; n < screenHeight; n++) {
screenLine[n] = &screenImage[n * screenWidth];
screenLength[n] = 0;
}
startLine = endLine = 0;
screenOptions = 0;
return;
}
void screenControl(options, setting) char *options; int setting; {
int n = 0;
while (*options) {
switch (*options) {
case 'p':
n |= pauseOption;
break;
case 'r':
currentPosition = maxPosition;
break;
case 's':
n |= scrollOption;
break;
default:
break;
}
options += 1;
}
if (setting == 0)
screenOptions &= (n ^ (-1));
else
screenOptions |= n;
if ((pausePosition = maxPosition - currentPosition) == 0)
pausePosition = maxPosition - fontHeight;
return;
}
void screenClose(void) {
DisposPtr((Ptr)screenLine);
DisposeWindow(theWindow);
return;
}
void screenUpdate(WindowPtr window) {
GrafPort *savePort;
int m, n;
if (window == theWindow) {
BeginUpdate(window);
if (!EmptyRgn(window->visRgn)) {
GetPort(&savePort);
SetPort(window);
n = startLine;
for (m = 1; ; m++) {
MoveTo(5, m * fontHeight);
if (screenLength[n] != 0)
DrawText(screenLine[n], 0, screenLength[n]);
if (n == endLine) break;
if ((n += 1) == screenHeight) n = 0;
}
SetPort(savePort);
}
EndUpdate(window);
}
return;
}
static void screenNewline(void) {
MoveTo(5, currentPosition += fontHeight);
if (currentPosition > maxPosition) {
if (screenOptions & scrollOption) {
ScrollRect(&scrollRect, 0, -fontHeight, scrollRgn);
MoveTo(5, currentPosition = maxPosition);
if ((startLine += 1) == screenHeight) startLine = 0;
} else {
ScrollRect(&scrollRect, 0, -maxPosition + fontHeight, scrollRgn);
MoveTo(5, currentPosition = fontHeight + fontHeight);
startLine = endLine;
}
}
pausePosition -= fontHeight;
if ((endLine += 1) == screenHeight) endLine = 0;
screenLength[endLine] = 0;
return;
}
static char waitChar(void) {
WindowPtr whichWindow;
EventRecord theEvent;
for ( ; ; ) {
SystemTask();
if (GetNextEvent(everyEvent, &theEvent)) {
switch (theEvent.what) {
case keyDown:
if ((theEvent.modifiers & cmdKey) &&
((theEvent.message & charCodeMask) == '.'))
ExitToShell();
return(theEvent.message & charCodeMask);
case mouseDown:
if (FindWindow(theEvent.where, &whichWindow) == inSysWindow)
SystemClick(&theEvent, whichWindow);
break;
case updateEvt:
screenUpdate((WindowPtr)theEvent.message);
break;
}
}
}
}
static void screenPause(void) {
if (pausePosition == 0) {
if (screenOptions & pauseOption) {
DrawText("Press any key to continue ...", 0, 29);
memcpy(screenLine[endLine], "Press any key to continue ...", 29);
screenLength[endLine] = 29;
(void)waitChar();
EraseRect(&pauseRect);
MoveTo(5, currentPosition);
screenLength[endLine] = 0;
}
pausePosition = maxPosition - fontHeight;
}
return;
}
void screenDisplay(char *s) {
GrafPort *savePort;
int m, n;
char *t;
GetPort(&savePort);
SetPort(theWindow);
while (*s) {
screenPause();
for (t = s; (*s) && (*s != '\n') && (*s != '\r'); s++);
if ((n = s - t) > (m = screenWidth - screenLength[endLine])) n = m;
if (n > 0) {
DrawText(t, 0, n);
memcpy(screenLine[endLine] + screenLength[endLine], t, n);
screenLength[endLine] += n;
}
if ((*s == '\n') || (*s == '\r')) {
screenNewline();
s += 1;
}
}
SetPort(savePort);
return;
}
void screenDump(char *s, long n) {
GrafPort *savePort;
int k, m;
char *t;
GetPort(&savePort);
SetPort(theWindow);
while (n) {
screenPause();
for (t = s; (n) && (*s != '\n') && (*s != '\r'); s++, n--);
if ((k = s - t) > (m = screenWidth - screenLength[endLine])) k = m;
if (k > 0) {
DrawText(t, 0, k);
memcpy(screenLine[endLine] + screenLength[endLine], t, k);
screenLength[endLine] += k;
}
if ((*s == '\n') || (*s == '\r')) {
screenNewline();
s += 1;
n -= 1;
}
}
SetPort(savePort);
return;
}
char *wfgets(char *s, int n, FILE *stream) {
GrafPort *savePort;
char c, *t = s;
GetPort(&savePort);
SetPort(theWindow);
for (n -= 1; (n > 0) && ((c = waitChar()) != '\r'); n -= 1) {
DrawChar(*t++ = c);
if (screenLength[endLine] < screenWidth)
screenLine[endLine][screenLength[endLine]++] = c;
}
if (c == '\r') screenNewline();
*t = '\0';
SetPort(savePort);
return(s);
}
void wfprintf(FILE *stream, char *format, ...) {
char buffer[bufferSize];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
va_end(ap);
screenDisplay(buffer);
return;
}
void wprintf(char *format, ...) {
char buffer[bufferSize];
va_list ap;
va_start(ap, format);
vsprintf(buffer, format, ap);
va_end(ap);
screenDisplay(buffer);
return;
}

204
zip/unzip/mac/macstat.c Executable file
View File

@ -0,0 +1,204 @@
#ifdef THINK_C
#define MACOS
#include <pascal.h>
#endif
#ifdef MPW
#define MACOS
#include <Files.h>
#include <Errors.h>
#define FSFCBLen (*(short *)0x3F6)
#endif
#ifdef MACOS
#include <string.h>
#include "macstat.h"
int macstat(char *path, struct stat *buf, short nVRefNum, long lDirID );
#define unixTime(t) ((t) = ((t) < (time_t)0x7c25b080) ? 0 : (t) - (time_t)0x7c25b080)
/* assume that the path will contain a Mac-type pathname, i.e. ':'s, etc. */
int macstat(char *path, struct stat *buf, short nVRefNum, long lDirID )
{
char temp[256];
short nVRefNumT;
long lDirIDT;
short fIsHFS = false;
OSErr err;
short fUseDefault = ((nVRefNum == 0) && (lDirID == 0));
if (buf == (struct stat *)0L || path == (char *)0L) {
SysBeep(1);
return -1;
}
if (path[0] == '\0' || strlen(path)>255) {
return -1;
}
if ( fUseDefault )
{
if (GetVol((StringPtr)&temp[0], &nVRefNumT) != noErr) {
SysBeep(1);
return -1;
}
}
/* get info about the specified volume */
if (FSFCBLen > 0) /* HFS Disk? */
{
HParamBlockRec hpbr;
if ( fUseDefault )
{
WDPBRec wdpb;
wdpb.ioCompletion = 0;
wdpb.ioNamePtr = (StringPtr)temp;
err = PBHGetVol(&wdpb, 0);
nVRefNumT = wdpb.ioWDVRefNum;
lDirIDT = wdpb.ioWDDirID;
}
else
{
nVRefNumT = nVRefNum;
lDirIDT = lDirID;
err = noErr;
}
if (err == noErr)
{
hpbr.volumeParam.ioCompletion = 0;
hpbr.volumeParam.ioNamePtr = (StringPtr)temp;
hpbr.volumeParam.ioVRefNum = nVRefNumT;
hpbr.volumeParam.ioVolIndex = 0;
err = PBHGetVInfo(&hpbr, 0);
if (err == noErr && hpbr.volumeParam.ioVFSID == 0
&& hpbr.volumeParam.ioVSigWord == 0x4244) {
fIsHFS = true;
}
}
}
/* number of links, at least in System 6.0x, 0 */
buf->st_nlink = 0;
/* user id */
buf->st_uid = 0;
/* group id */
buf->st_gid = 0;
if (fIsHFS == true) /* HFS? */
{
CInfoPBRec cPB;
HParamBlockRec hPB;
/* get information about file */
cPB.hFileInfo.ioCompletion = (ProcPtr)0L;
c2pstr(path);
strncpy(temp,path, path[0]+1);
p2cstr(path);
cPB.hFileInfo.ioNamePtr = (StringPtr)temp;
cPB.hFileInfo.ioVRefNum = nVRefNumT;
cPB.hFileInfo.ioDirID = lDirIDT;
cPB.hFileInfo.ioFDirIndex = 0;
err = PBGetCatInfo(&cPB, false);
if (err != noErr) {
if ((err != fnfErr) && (err != dirNFErr)) {
SysBeep(1);
}
return -1;
}
/* Type of file: directory or regular file + access */
buf->st_mode = (cPB.hFileInfo.ioFlAttrib & ioDirMask) ? S_IFDIR : S_IFREG |
(cPB.hFileInfo.ioFlAttrib & 0x01) ? S_IREAD : (S_IREAD | S_IWRITE);
/* last access time, modification time and creation time(?) */
buf->st_atime = buf->st_mtime = cPB.hFileInfo.ioFlMdDat;
buf->st_ctime = cPB.hFileInfo.ioFlCrDat;
/* dev number */
buf->st_dev = (long)cPB.hFileInfo.ioVRefNum;
/* inode number */
buf->st_ino = cPB.hFileInfo.ioDirID;
/* size of file - use only the data fork */
buf->st_size = cPB.hFileInfo.ioFlLgLen;
/* size of disk block */
hPB.volumeParam.ioCompletion = (ProcPtr)0L;
hPB.volumeParam.ioNamePtr = (StringPtr)temp;
hPB.volumeParam.ioVRefNum = nVRefNumT;
hPB.volumeParam.ioVolIndex = 0;
err = PBHGetVInfo(&hPB, false);
if (err != noErr) {
SysBeep(1);
return -1;
}
buf->st_blksize = cPB.hFileInfo.ioFlPyLen / hPB.volumeParam.ioVAlBlkSiz;
}
else /* MFS? */
{
ParamBlockRec pPB;
ParamBlockRec hPB;
c2pstr(path);
strncpy(temp, path, path[0]+1);
p2cstr(path);
pPB.fileParam.ioCompletion = (ProcPtr)0;
pPB.fileParam.ioNamePtr = (StringPtr)temp;
pPB.fileParam.ioVRefNum = nVRefNumT;
pPB.fileParam.ioFVersNum = 0;
pPB.fileParam.ioFDirIndex = 0;
err = PBGetFInfo(&pPB, false);
if (err != noErr) {
SysBeep(1);
return -1;
}
/* Type of file: either directory or regular file + access */
buf->st_mode = (pPB.fileParam.ioFlAttrib & ioDirMask) ? S_IFDIR : S_IFREG;
(pPB.fileParam.ioFlAttrib & 0x01) ? S_IREAD : (S_IREAD | S_IWRITE);
/* last access time, modification time and creation time(?) */
buf->st_atime = buf->st_mtime = pPB.fileParam.ioFlMdDat;
buf->st_ctime = pPB.fileParam.ioFlCrDat;
/* dev number */
buf->st_dev = (long)pPB.fileParam.ioVRefNum;
/* inode number */
buf->st_ino = pPB.fileParam.ioFlNum;
/* size of file - use only the data fork */
buf->st_size = pPB.fileParam.ioFlLgLen;
/* size of disk block */
hPB.volumeParam.ioCompletion = (ProcPtr)0;
hPB.volumeParam.ioNamePtr = (StringPtr)temp;
hPB.volumeParam.ioVRefNum = nVRefNumT;
hPB.volumeParam.ioVolIndex = 0;
err = PBGetVInfo(&hPB, false);
if (err != noErr) {
SysBeep(1);
return -1;
}
buf->st_blksize = pPB.fileParam.ioFlPyLen / hPB.volumeParam.ioVAlBlkSiz;
}
/* Convert from Macintosh time format to Unix time format. */
unixTime(buf->st_atime);
unixTime(buf->st_mtime);
unixTime(buf->st_ctime);
return 0;
}
#else
#error 1
#endif

40
zip/unzip/mac/macstat.h Executable file
View File

@ -0,0 +1,40 @@
/*****************************************************************
*
* stat.h
*
*****************************************************************/
#include <time.h>
extern int macstat(char *path, struct stat *buf, short nVRefNum, long lDirID );
typedef long dev_t;
typedef long ino_t;
typedef long off_t;
struct stat {
dev_t st_dev;
ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime, st_mtime, st_ctime;
long st_blksize;
long st_blocks;
};
#define S_IFMT 0xF000
#define S_IFIFO 0x1000
#define S_IFCHR 0x2000
#define S_IFDIR 0x4000
#define S_IFBLK 0x6000
#define S_IFREG 0x8000
#define S_IFLNK 0xA000
#define S_IFSOCK 0xC000
#define S_ISUID 0x800
#define S_ISGID 0x400
#define S_ISVTX 0x200
#define S_IREAD 0x100
#define S_IWRITE 0x80
#define S_IEXEC 0x40

736
zip/unzip/mac/macunzip.c Executable file
View File

@ -0,0 +1,736 @@
#define UNZIP_INTERNAL
#include "unzip.h"
#include "version.h"
#include <Traps.h>
#include <Values.h>
char UnzipVersion[32], ZipinfoVersion[32];
void MacFSTest (int);
void ResolveMacVol (short, short *, long *, StringPtr);
void screenOpen(char *);
void screenControl(char *, int);
void screenClose(void);
#define aboutAlert 128
#define selectDialog 129
#define okItem 1
#define cancelItem 2
#define editItem 3
#define staticItem 4
#define unzipMenuBar 128
#define appleMenu 128
#define aboutItem 1
#define fileMenu 129
#define extractItem 1
#define infoItem 2
#define listItem 3
#define testItem 4
#define commentItem 6
#define freshenItem 8
#define updateItem 9
#define quitItem 11
#define editMenu 130
#define cutItem 1
#define copyItem 2
#define pasteItem 3
#define modifierMenu 131
#define excludeItem 1
#define selectItem 2
#define quietItem 9
#define verboseItem 10
#define screenMenu 132
#define pauseItem 1
#define scrollItem 2
#define extractMenu 133
#define screenItem 3
#define junkItem 5
#define caseMenu 134
#define insensitiveItem 1
#define lowercaseItem 2
#define convertMenu 135
#define autoItem 1
#define binaryItem 2
#define textItem 3
#define overwriteMenu 136
#define alwaysItem 1
#define neverItem 2
#define promptItem 3
#define infoMenu 137
#define prtCommentItem 2
#define prtHeaderItem 3
#define prtTotalsItem 4
#define formatMenu 138
#define filenameItem 1
#define longItem 2
#define mediumItem 3
#define shortItem 4
long modifiers, modifierMask;
#define allFlags 0x000FFFFF
#define quietFlag 0x00000001
#define verboseFlag 0x00000002
#define pauseFlag 0x00080000
#define scrollFlag 0x00040000
#define screenFlag 0x00000004
#define junkFlag 0x00000008
#define insensitiveFlag 0x00000010
#define lowercaseFlag 0x00000020
#define autoFlag 0x00000040
#define textFlag 0x00000080
#define neverFlag 0x00000100
#define overwriteFlag 0x00000200
#define prtCommentFlag 0x00000400
#define prtHeaderFlag 0x00000800
#define prtTotalsFlag 0x00001000
#define filenameFlag 0x00002000
#define longFlag 0x00004000
#define mediumFlag 0x00008000
#define shortFlag 0x00010000
#define extractMask 0x000003FD
#define infoMask 0x0001FE02
#define listMask 0x00000001
#define testMask 0x00000001
#define commentMask 0x00000000
#define freshenMask 0x000003FD
#define updateMask 0x000003FD
EventRecord myevent;
MenuHandle appleHandle, modifierHandle, screenHandle, extractHandle;
MenuHandle caseHandle, convertHandle, overwriteHandle, infoHandle;
MenuHandle formatHandle;
Handle menubar, itemHandle;
short itemType;
Rect itemRect;
char command, fileList[256];
Boolean stop;
SysEnvRec sysRec;
char *macgetenv(s) char *s; {
if (s == NULL) return(fileList);
return(NULL);
}
Boolean TrapAvailable(machineType, trapNumber, trapType)
short machineType;
short trapNumber;
TrapType trapType;
{
if (machineType < 0)
return (false);
if ((trapType == ToolTrap) &&
(machineType > envMachUnknown) &&
(machineType < envMacII)) {
if ((trapNumber &= 0x03FF) > 0x01FF)
trapNumber = _Unimplemented;
}
return (NGetTrapAddress(trapNumber, trapType) !=
GetTrapAddress(_Unimplemented));
}
void domenu(menucommand) long menucommand;
{
short themenu, theitem;
DialogPtr thedialog;
Str255 name;
long check;
themenu = HiWord(menucommand);
theitem = LoWord(menucommand);
switch (themenu) {
case appleMenu:
if (theitem == aboutItem) {
ParamText((StringPtr)UnzipVersion, (StringPtr)ZipinfoVersion, nil, nil);
Alert(aboutAlert, nil);
} else {
GetItem(appleHandle, theitem, name);
theitem = OpenDeskAcc(name);
}
break;
case fileMenu:
switch (theitem) {
case extractItem:
if (modifiers & screenFlag)
command = 'c';
else
command = 'x';
modifierMask = extractMask;
break;
case infoItem:
command = 'Z';
modifierMask = infoMask;
break;
case listItem:
if (modifiers & verboseFlag)
command = 'v';
else
command = 'l';
modifierMask = listMask;
break;
case testItem:
command = 't';
modifierMask = testMask;
break;
case commentItem:
command = 'z';
modifierMask = commentMask;
break;
case freshenItem:
command = 'f';
modifierMask = freshenMask;
break;
case updateItem:
command = 'u';
modifierMask = updateMask;
break;
case quitItem:
stop = true;
break;
default:
break;
}
break;
case editMenu:
break;
case modifierMenu:
switch (theitem) {
case excludeItem:
check = -1;
break;
case selectItem:
thedialog = GetNewDialog(selectDialog, nil, (WindowPtr)(-1));
SetPort(thedialog);
do
ModalDialog(nil, &theitem);
while ((theitem != okItem) && (theitem != cancelItem));
if (theitem == okItem) {
GetDItem(thedialog, editItem, &itemType, &itemHandle, &itemRect);
GetIText(itemHandle, (StringPtr)&fileList);
p2cstr(fileList);
}
DisposDialog(thedialog);
check = -1;
break;
case quietItem:
check = (modifiers ^= quietFlag) & quietFlag;
break;
case verboseItem:
check = (modifiers ^= verboseFlag) & verboseFlag;
break;
default:
break;
}
if (check == 0)
CheckItem(modifierHandle, theitem, false);
else if (check > 0)
CheckItem(modifierHandle, theitem, true);
break;
case screenMenu:
switch (theitem) {
case pauseItem:
check = (modifiers ^= pauseFlag) & pauseFlag;
screenControl("p", check);
break;
case scrollItem:
check = (modifiers ^= scrollFlag) & scrollFlag;
screenControl("s", check);
break;
default:
break;
}
if (check == 0)
CheckItem(screenHandle, theitem, false);
else if (check > 0)
CheckItem(screenHandle, theitem, true);
break;
case extractMenu:
switch (theitem) {
case screenItem:
check = (modifiers ^= screenFlag) & screenFlag;
break;
case junkItem:
check = (modifiers ^= junkFlag) & junkFlag;
break;
default:
break;
}
if (check == 0)
CheckItem(extractHandle, theitem, false);
else if (check > 0)
CheckItem(extractHandle, theitem, true);
break;
case caseMenu:
switch (theitem) {
case insensitiveItem:
check = (modifiers ^= insensitiveFlag) & insensitiveFlag;
break;
case lowercaseItem:
check = (modifiers ^= lowercaseFlag) & lowercaseFlag;
break;
default:
break;
}
if (check == 0)
CheckItem(caseHandle, theitem, false);
else if (check > 0)
CheckItem(caseHandle, theitem, true);
break;
case convertMenu:
switch (theitem) {
case autoItem:
CheckItem(convertHandle, autoItem, true);
CheckItem(convertHandle, binaryItem, false);
CheckItem(convertHandle, textItem, false);
modifiers &= (allFlags ^ textFlag);
modifiers |= autoFlag;
break;
case binaryItem:
CheckItem(convertHandle, autoItem, false);
CheckItem(convertHandle, binaryItem, true);
CheckItem(convertHandle, textItem, false);
modifiers &= (allFlags ^ (autoFlag | textFlag));
break;
case textItem:
CheckItem(convertHandle, autoItem, false);
CheckItem(convertHandle, binaryItem, false);
CheckItem(convertHandle, textItem, true);
modifiers &= (allFlags ^ autoFlag);
modifiers |= textFlag;
break;
default:
break;
}
break;
case overwriteMenu:
switch (theitem) {
case alwaysItem:
CheckItem(overwriteHandle, alwaysItem, true);
CheckItem(overwriteHandle, neverItem, false);
CheckItem(overwriteHandle, promptItem, false);
modifiers &= (allFlags ^ neverFlag);
modifiers |= overwriteFlag;
break;
case neverItem:
CheckItem(overwriteHandle, alwaysItem, false);
CheckItem(overwriteHandle, neverItem, true);
CheckItem(overwriteHandle, promptItem, false);
modifiers &= (allFlags ^ overwriteFlag);
modifiers |= neverFlag;
break;
case promptItem:
CheckItem(overwriteHandle, alwaysItem, false);
CheckItem(overwriteHandle, neverItem, false);
CheckItem(overwriteHandle, promptItem, true);
modifiers &= (allFlags ^ (neverFlag | overwriteFlag));
break;
default:
break;
}
break;
case infoMenu:
switch (theitem) {
case prtCommentItem:
check = (modifiers ^= prtCommentFlag) & prtCommentFlag;
break;
case prtHeaderItem:
check = (modifiers ^= prtHeaderFlag) & prtHeaderFlag;
break;
case prtTotalsItem:
check = (modifiers ^= prtTotalsFlag) & prtTotalsFlag;
break;
default:
break;
}
if (check == 0)
CheckItem(infoHandle, theitem, false);
else if (check > 0)
CheckItem(infoHandle, theitem, true);
break;
case formatMenu:
switch (theitem) {
case filenameItem:
CheckItem(formatHandle, filenameItem, true);
CheckItem(formatHandle, longItem, false);
CheckItem(formatHandle, mediumItem, false);
CheckItem(formatHandle, shortItem, false);
modifiers &= (allFlags ^ (longFlag | mediumFlag | shortFlag));
modifiers |= filenameFlag;
break;
case longItem:
CheckItem(formatHandle, filenameItem, false);
CheckItem(formatHandle, longItem, true);
CheckItem(formatHandle, mediumItem, false);
CheckItem(formatHandle, shortItem, false);
modifiers &= (allFlags ^ (filenameFlag | mediumFlag | shortFlag));
modifiers |= longFlag;
break;
case mediumItem:
CheckItem(formatHandle, filenameItem, false);
CheckItem(formatHandle, longItem, false);
CheckItem(formatHandle, mediumItem, true);
CheckItem(formatHandle, shortItem, false);
modifiers &= (allFlags ^ (filenameFlag | longFlag | shortFlag));
modifiers |= mediumFlag;
break;
case shortItem:
CheckItem(formatHandle, filenameItem, false);
CheckItem(formatHandle, longItem, false);
CheckItem(formatHandle, mediumItem, false);
CheckItem(formatHandle, shortItem, true);
modifiers &= (allFlags ^ (filenameFlag | longFlag | mediumFlag));
modifiers |= shortFlag;
break;
default:
break;
}
break;
default:
break;
}
HiliteMenu(0);
return;
}
void dokey(myevent) EventRecord *myevent;
{
char code;
code = (char)(myevent->message & charCodeMask);
if (myevent->modifiers & cmdKey) {
if (myevent->what != autoKey) {
domenu(MenuKey(code));
}
}
return;
}
void domousedown(myevent) EventRecord *myevent;
{
WindowPtr whichwindow;
long code;
code = FindWindow(myevent->where, &whichwindow);
switch (code) {
case inSysWindow:
SystemClick(myevent, whichwindow);
break;
case inMenuBar:
domenu(MenuSelect(myevent->where));
break;
}
return;
}
int main(argc, argv) int argc; char *argv[];
{
struct Globals saveGlobals;
Boolean haveEvent, useWNE;
short markChar;
FILE *fp;
FlushEvents(everyEvent, 0);
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
CONSTRUCTGLOBALS();
sprintf(UnzipVersion, "%d.%d%d%s of %s", UZ_MAJORVER, UZ_MINORVER,
PATCHLEVEL, BETALEVEL, VERSION_DATE);
sprintf(ZipinfoVersion, "%d.%d%d%s of %s", ZI_MAJORVER, ZI_MINORVER,
PATCHLEVEL, BETALEVEL, VERSION_DATE);
c2pstr(UnzipVersion);
c2pstr(ZipinfoVersion);
SysEnvirons(1, &sysRec);
useWNE = TrapAvailable(sysRec.machineType, _WaitNextEvent, ToolTrap);
SetMenuBar(menubar = GetNewMBar(unzipMenuBar));
DisposeHandle(menubar);
InsertMenu(GetMenu(screenMenu), -1);
InsertMenu(GetMenu(extractMenu), -1);
InsertMenu(GetMenu(caseMenu), -1);
InsertMenu(GetMenu(convertMenu), -1);
InsertMenu(GetMenu(overwriteMenu), -1);
InsertMenu(GetMenu(infoMenu), -1);
InsertMenu(GetMenu(formatMenu), -1);
AddResMenu(appleHandle = GetMHandle(appleMenu), 'DRVR');
modifierHandle = GetMHandle(modifierMenu);
screenHandle = GetMHandle(screenMenu);
extractHandle = GetMHandle(extractMenu);
caseHandle = GetMHandle(caseMenu);
convertHandle = GetMHandle(convertMenu);
overwriteHandle = GetMHandle(overwriteMenu);
infoHandle = GetMHandle(infoMenu);
formatHandle = GetMHandle(formatMenu);
DrawMenuBar();
screenOpen("Unzip");
modifiers = 0;
GetItemMark(modifierHandle, quietItem, &markChar);
if (markChar) modifiers ^= quietFlag;
GetItemMark(modifierHandle, verboseItem, &markChar);
if (markChar) modifiers ^= verboseFlag;
GetItemMark(screenHandle, pauseItem, &markChar);
if (markChar) modifiers ^= pauseFlag;
screenControl("p", markChar);
GetItemMark(screenHandle, scrollItem, &markChar);
if (markChar) modifiers ^= scrollFlag;
screenControl("s", markChar);
GetItemMark(extractHandle, screenItem, &markChar);
if (markChar) modifiers ^= screenFlag;
GetItemMark(extractHandle, junkItem, &markChar);
if (markChar) modifiers ^= junkFlag;
GetItemMark(caseHandle, insensitiveItem, &markChar);
if (markChar) modifiers ^= insensitiveFlag;
GetItemMark(caseHandle, lowercaseItem, &markChar);
if (markChar) modifiers ^= lowercaseFlag;
GetItemMark(convertHandle, autoItem, &markChar);
if (markChar) modifiers ^= autoFlag;
GetItemMark(convertHandle, textItem, &markChar);
if (markChar) modifiers ^= textFlag;
if ((modifiers & (autoFlag | textFlag)) == (autoFlag | textFlag)) {
CheckItem(convertHandle, textItem, false);
modifiers &= (allFlags ^ textFlag);
} else if (modifiers & (autoFlag | textFlag))
CheckItem(convertHandle, binaryItem, false);
else
CheckItem(convertHandle, binaryItem, true);
GetItemMark(overwriteHandle, alwaysItem, &markChar);
if (markChar) modifiers ^= overwriteFlag;
GetItemMark(overwriteHandle, neverItem, &markChar);
if (markChar) modifiers ^= neverFlag;
if ((modifiers & (neverFlag | overwriteFlag)) == (neverFlag | overwriteFlag)) {
CheckItem(overwriteHandle, alwaysItem, false);
CheckItem(overwriteHandle, neverItem, false);
CheckItem(overwriteHandle, promptItem, true);
modifiers &= (allFlags ^ (neverFlag | overwriteFlag));
} else if (modifiers & (neverFlag | overwriteFlag))
CheckItem(overwriteHandle, promptItem, false);
else
CheckItem(overwriteHandle, promptItem, true);
GetItemMark(infoHandle, prtCommentItem, &markChar);
if (markChar) modifiers ^= prtCommentFlag;
GetItemMark(infoHandle, prtHeaderItem, &markChar);
if (markChar) modifiers ^= prtHeaderFlag;
GetItemMark(infoHandle, prtTotalsItem, &markChar);
if (markChar) modifiers ^= prtTotalsFlag;
GetItemMark(formatHandle, filenameItem, &markChar);
if (markChar) modifiers ^= filenameFlag;
GetItemMark(formatHandle, longItem, &markChar);
if (markChar) modifiers ^= longFlag;
GetItemMark(formatHandle, mediumItem, &markChar);
if (markChar) modifiers ^= mediumFlag;
GetItemMark(formatHandle, shortItem, &markChar);
if (markChar) modifiers ^= shortFlag;
if (modifiers & longFlag) {
CheckItem(formatHandle, filenameItem, false);
CheckItem(formatHandle, mediumItem, false);
CheckItem(formatHandle, shortItem, false);
modifiers &= (allFlags ^ (filenameFlag | mediumFlag | shortFlag));
} else if (modifiers & mediumFlag) {
CheckItem(formatHandle, filenameItem, false);
CheckItem(formatHandle, shortItem, false);
modifiers &= (allFlags ^ (filenameFlag | shortFlag));
} else if (modifiers & shortFlag) {
CheckItem(formatHandle, filenameItem, false);
modifiers &= (allFlags ^ filenameFlag);
}
command = ' ';
stop = false;
while (!stop) {
SetCursor(&qd.arrow);
if (useWNE) {
haveEvent = WaitNextEvent(everyEvent, &myevent, MAXLONG, NULL);
} else {
SystemTask();
haveEvent = GetNextEvent(everyEvent, &myevent);
}
if (haveEvent) {
switch (myevent.what) {
case activateEvt:
break;
case keyDown:
case autoKey:
dokey(&myevent);
break;
case mouseDown:
domousedown(&myevent);
break;
case updateEvt:
screenUpdate(myevent.message);
break;
case mouseUp:
case keyUp:
break;
default:
break;
}
}
if (command != ' ') {
char *s, **v, modifierString[32];
SFReply fileRep;
Point p;
int m, n;
SetPt(&p, 40, 40);
SFGetFile(p, "\pSpecify ZIP file:", 0L, -1, nil, 0L, &fileRep);
if (fileRep.good) {
MacFSTest(fileRep.vRefNum);
ResolveMacVol(fileRep.vRefNum, &G.gnVRefNum, &G.glDirID, NULL);
p2cstr((Ptr)fileRep.fName);
modifierMask &= modifiers;
s = modifierString;
*s++ = '-';
if ((command != 'x') && (command != 'Z')) *s++ = command;
if (modifierMask) {
if (modifierMask & (autoFlag | textFlag)) *s++ = 'a';
if (modifierMask & textFlag) *s++ = 'a';
if (modifierMask & insensitiveFlag) *s++ = 'C';
if (!G.HFSFlag || (modifierMask & junkFlag)) *s++ = 'j';
if (modifierMask & lowercaseFlag) *s++ = 'L';
if (modifierMask & neverFlag) *s++ = 'n';
if (modifierMask & overwriteFlag) *s++ = 'o';
if (modifierMask & quietFlag) *s++ = 'q';
if (modifierMask & verboseFlag) *s++ = 'v';
if (modifierMask & prtCommentFlag) *s++ = 'z';
if (modifierMask & prtHeaderFlag) *s++ = 'h';
if (modifierMask & prtTotalsFlag) *s++ = 't';
if (modifierMask & filenameFlag) *s++ = '2';
if (modifierMask & longFlag) *s++ = 'l';
if (modifierMask & mediumFlag) *s++ = 'm';
if (modifierMask & shortFlag) *s++ = 's';
}
if (*(s - 1) == '-') s -= 1;
*s = '\0';
v = (char **)malloc(sizeof(char *));
*v = "unzip";
argc = 1;
envargs(&argc, &v, NULL, NULL);
argv = (char **)malloc((argc + 3) * sizeof(char *));
argv[m = 0] = (command == 'Z') ? "zipinfo" : "unzip";
if (*modifierString) argv[++m] = modifierString;
argv[++m] = (char *)fileRep.fName;
for (n = 1; n < argc; n++) argv[n + m] = v[n];
argv[argc += m] = NULL;
free(v);
for (n = 0; argv[n] != NULL; n++) printf("%s ", argv[n]);
printf("...\n\n");
memcpy(&saveGlobals, &G, sizeof(struct Globals));
unzip(__G__ argc, argv);
memcpy(&G, &saveGlobals, sizeof(struct Globals));
printf("\nDone\n");
screenControl("r", 0);
}
fileList[0] = '\0';
command = ' ';
}
}
screenClose();
DESTROYGLOBALS()
ExitToShell();
}

121
zip/unzip/mac/rsrc.hqx Executable file
View File

@ -0,0 +1,121 @@
(This file must be converted with BinHex 4.0)
:%A9ZHQP`,R4SD@jVBbjbFh*M!(*cFQ058d9%!*!)(2lVl`#3"!%!N!-D&`!!'4F
!!!,RFR)T$3N*)#"l$3N*)*!%HLdqE%4TFNP%)$dJF'eT,4&eERTTF#jdD'PZDf-
ZFR0bB`)!!J"bFh*M8P0&4!%!!J"bFh*M8P0&4!%!!6J!3!#3%UlTlQ`!N!BFrQP
cG#!UF(ST$AX0)#"0B@0*EQC[)#T`E@NJ25"MB@aXEf-S)$%X)(0THQ9[CL!SFh4
bG@0d)%eKBdPZCQmT+6X0)#!0)#"TCL!SF'eT+3dJ)(X0)*!%3dPZCQp33P*PBb"
MDA"LFMX0)*!%8'&bB@e#E'pMDe*PBb"`BR)l$5!J!*!$8`8`J!#3!aK*EQC[,9T
TF#Gc)&9ZHQP`)'C[FL"0B@-c5@jQEbeDDA!RFb"9ERTTF#"QEh)JG'KP)%eKBfP
ZG'pcD#`J3fp`HA*TCfKd)+Na16Nh!*!$4!I!(c!r#(m%I`6r![m#rrk"rS(q3Ia
"r#(i'I!(`!!!"m!Im$riIrarr2rqrrlrr[rq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$6NC(!!-"4P0*@N8!!!&f4%*69!!!!B*%3PG6!!!"MN0
548`!!`'D4%*94`!$!FT66&08!!!"qNCA58i!!!)'!!%!N!G'SF3!!2rr!!!(6!"
'SJ3!!2rr!!!%$J"'SHJ!!2rr!!!$p!"'ST3!!2rr!!"28!"'SX!!!2rr!!"9P!"
'SP!!![rr!!!&N!!!4U*8!!6rr`!!"P-!4U-!!!2rr`!!"PX!4U,m!!Arr`!!"Q-
!4U+d!!(rra3!9IJ!4U*N!!$rr`!!"CJ!4U-%!!$rr`!!"QX!4U*%!!$rr`!!"Qm
!4U*`!!$rr`!!"R-!4U+)!!crr`!!"C`!4U(!5U`!"J!!"TF!N!4$q3!8!!!'R3#
3"$AR!"`!!!EB!*!%rrm!*J!!"!!!4U+S!)$rr`!!"B!!4U(d!)$rr`!!"MN!4U,
-!!,rr`!!"RF!4U0m!!6rr`!!"RX!4U)J!!2rr`!!"Rm!4U,B!!Arr`!!"S-!4U)
8!!,rr`!!"SF!4U,`!!6rr`!!"SX!4U,8!!2rr`!!"Sm!4U)d!!Arr`!!"T-!4U0
X!!$rr`!!"A!!4U+3!!#!rrm!!!9X!%DKf!9YDf&SE!dJ,QmJ3fpZGQ9bG'9b"e4
)58j,)%-*9%K*6NXJ8Q9k!6`M'`:

293
zip/unzip/match.c Executable file
View File

@ -0,0 +1,293 @@
/*---------------------------------------------------------------------------
match.c
The match() routine recursively compares a string to a "pattern" (regular
expression), returning TRUE if a match is found or FALSE if not. This
version is specifically for use with unzip.c: as did the previous match()
routines from SEA and J. Kercheval, it leaves the case (upper, lower, or
mixed) of the string alone, but converts any uppercase characters in the
pattern to lowercase if indicated by the global var pInfo->lcflag (which
is to say, string is assumed to have been converted to lowercase already,
if such was necessary).
GRR: reversed order of text, pattern in matche() (now same as match());
added ignore_case/ic flags, Case() macro.
PaulK: replaced matche() with recmatch() from Zip, modified to have an
ignore_case argument; replaced test frame with simpler one.
---------------------------------------------------------------------------
Copyright on recmatch() from Zip's util.c (although recmatch() was almost
certainly written by Mark Adler...ask me how I can tell :-) ):
Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly,
Kai Uwe Rommel and 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, that it is not sold for profit, and that this copy-
right notice is retained.
---------------------------------------------------------------------------
Match the pattern (wildcard) against the string (fixed):
match(string, pattern, ignore_case);
returns TRUE if string matches pattern, FALSE otherwise. In the pattern:
`*' matches any sequence of characters (zero or more)
`?' matches any single character
[SET] matches any character in the specified set,
[!SET] or [^SET] matches any character not in the specified set.
A set is composed of characters or ranges; a range looks like ``character
hyphen character'' (as in 0-9 or A-Z). [0-9a-zA-Z_] is the minimal set of
characters allowed in the [..] pattern construct. Other characters are
allowed (i.e., 8-bit characters) if your system will support them.
To suppress the special syntactic significance of any of ``[]*?!^-\'', in-
side or outside a [..] construct, and match the character exactly, precede
it with a ``\'' (backslash).
Note that "*.*" and "*." are treated specially under MS-DOS if DOSWILD is
defined. See the DOSWILD section below for an explanation. Note also
that with VMSWILD defined, '%' is used instead of '?', and sets (ranges)
are delimited by () instead of [].
---------------------------------------------------------------------------*/
/* define ToLower() in here (for Unix, define ToLower to be macro (using
* isupper()); otherwise just use tolower() */
#define UNZIP_INTERNAL
#include "unzip.h"
#if 0 /* this is not useful until it matches Amiga names insensitively */
#ifdef AMIGA /* some other platforms might also want to use this */
# define ANSI_CHARSET /* MOVE INTO UNZIP.H EVENTUALLY */
#endif
#endif /* 0 */
#ifdef ANSI_CHARSET
# ifdef ToLower
# undef ToLower
# endif
/* uppercase letters are values 41 thru 5A, C0 thru D6, and D8 thru DE */
# define IsUpper(c) (c>=0xC0 ? c<=0xDE && c!=0xD7 : c>=0x41 && c<=0x5A)
# define ToLower(c) (IsUpper((uch) c) ? (unsigned) c | 0x20 : (unsigned) c)
#endif
#define Case(x) (ic? ToLower(x) : (x))
#ifdef VMSWILD
# define WILDCHAR '%'
# define BEG_RANGE '('
# define END_RANGE ')'
#else
# define WILDCHAR '?'
# define BEG_RANGE '['
# define END_RANGE ']'
#endif
#if 0 /* GRR: add this to unzip.h someday... */
#if !(defined(MSDOS) && defined(DOSWILD))
#define match(s,p,ic) (recmatch((uch *)p,(uch *)s,ic) == 1)
int recmatch OF((uch *pattern, uch *string, int ignore_case));
#endif
#endif /* 0 */
static int recmatch OF((uch *pattern, uch *string, int ignore_case));
/* match() is a shell to recmatch() to return only Boolean values. */
int match(string, pattern, ignore_case)
char *string, *pattern;
int ignore_case;
{
#if (defined(MSDOS) && defined(DOSWILD))
char *dospattern;
int j = strlen(pattern);
/*---------------------------------------------------------------------------
Optional MS-DOS preprocessing section: compare last three chars of the
wildcard to "*.*" and translate to "*" if found; else compare the last
two characters to "*." and, if found, scan the non-wild string for dots.
If in the latter case a dot is found, return failure; else translate the
"*." to "*". In either case, continue with the normal (Unix-like) match
procedure after translation. (If not enough memory, default to normal
match.) This causes "a*.*" and "a*." to behave as MS-DOS users expect.
---------------------------------------------------------------------------*/
if ((dospattern = (char *)malloc(j+1)) != NULL) {
strcpy(dospattern, pattern);
if (!strcmp(dospattern+j-3, "*.*")) {
dospattern[j-2] = '\0'; /* nuke the ".*" */
} else if (!strcmp(dospattern+j-2, "*.")) {
char *p = strchr(string, '.');
if (p) { /* found a dot: match fails */
free(dospattern);
return 0;
}
dospattern[j-1] = '\0'; /* nuke the end "." */
}
j = recmatch((uch *)dospattern, (uch *)string, ignore_case);
free(dospattern);
return j == 1;
} else
#endif /* MSDOS && DOSWILD */
return recmatch((uch *)pattern, (uch *)string, ignore_case) == 1;
}
static int recmatch(p, s, ic)
uch *p; /* sh pattern to match */
uch *s; /* string to which to match it */
int ic; /* true for case insensitivity */
/* Recursively compare the sh pattern p with the string s and return 1 if
* they match, and 0 or 2 if they don't or if there is a syntax error in the
* pattern. This routine recurses on itself no more deeply than the number
* of characters in the pattern. */
{
unsigned int c; /* pattern char or start of range in [-] loop */
/* Get first character, the pattern for new recmatch calls follows */
c = *p++;
/* If that was the end of the pattern, match if string empty too */
if (c == 0)
return *s == 0;
/* '?' (or '%') matches any character (but not an empty string) */
if (c == WILDCHAR)
return *s ? recmatch(p, s + 1, ic) : 0;
/* '*' matches any number of characters, including zero */
#ifdef AMIGA
if (c == '#' && *p == '?') /* "#?" is Amiga-ese for "*" */
c = '*', p++;
#endif /* AMIGA */
if (c == '*') {
if (*p == 0)
return 1;
for (; *s; s++)
if ((c = recmatch(p, s, ic)) != 0)
return (int)c;
return 2; /* 2 means give up--match will return false */
}
/* Parse and process the list of characters and ranges in brackets */
if (c == BEG_RANGE) {
int e; /* flag true if next char to be taken literally */
uch *q; /* pointer to end of [-] group */
int r; /* flag true to match anything but the range */
if (*s == 0) /* need a character to match */
return 0;
p += (r = (*p == '!' || *p == '^')); /* see if reverse */
for (q = p, e = 0; *q; q++) /* find closing bracket */
if (e)
e = 0;
else
if (*q == '\\') /* GRR: change to ^ for MS-DOS, OS/2? */
e = 1;
else if (*q == END_RANGE)
break;
if (*q != END_RANGE) /* nothing matches if bad syntax */
return 0;
for (c = 0, e = *p == '-'; p < q; p++) { /* go through the list */
if (e == 0 && *p == '\\') /* set escape flag if \ */
e = 1;
else if (e == 0 && *p == '-') /* set start of range if - */
c = *(p-1);
else {
unsigned int cc = Case(*s);
if (*(p+1) != '-')
for (c = c ? c : *p; c <= *p; c++) /* compare range */
if ((unsigned)Case(c) == cc) /* typecast for MSC bug */
return r ? 0 : recmatch(q + 1, s + 1, ic);
c = e = 0; /* clear range, escape flags */
}
}
return r ? recmatch(q + 1, s + 1, ic) : 0; /* bracket match failed */
}
/* if escape ('\'), just compare next character */
if (c == '\\' && (c = *p++) == 0) /* if \ at end, then syntax error */
return 0;
/* just a character--compare it */
#ifdef QDOS
return QMatch(Case((uch)c), Case(*s)) ? recmatch(p, ++s, ic) : 0;
#else
return Case((uch)c) == Case(*s) ? recmatch(p, ++s, ic) : 0;
#endif
} /* end function recmatch() */
int iswild(p) /* originally only used for stat()-bug workaround in */
char *p; /* VAX C, Turbo/Borland C, Watcom C, Atari MiNT libs; */
{ /* now used in process_zipfiles() as well */
for (; *p; ++p)
if (*p == '\\' && *(p+1))
++p;
#ifdef VMS
else if (*p == '%' || *p == '*')
#else /* !VMS */
#ifdef AMIGA
else if (*p == '?' || *p == '*' || (*p=='#' && p[1]=='?') || *p == '[')
#else /* !AMIGA */
else if (*p == '?' || *p == '*' || *p == '[')
#endif /* ?AMIGA */
#endif /* ?VMS */
#ifdef QDOS
return (int)p;
#else
return TRUE;
#endif
return FALSE;
} /* end function iswild() */
#ifdef TEST_MATCH
#define put(s) {fputs(s,stdout); fflush(stdout);}
void main()
{
char pat[256], str[256];
for (;;) {
put("Pattern (return to exit): ");
gets(pat);
if (!pat[0])
break;
for (;;) {
put("String (return for new pattern): ");
gets(str);
if (!str[0])
break;
printf("Case sensitive: %s insensitive: %s\n",
match(str, pat, 0) ? "YES" : "NO",
match(str, pat, 1) ? "YES" : "NO");
}
}
exit(0);
}
#endif /* TEST_MATCH */

35
zip/unzip/msdos/Contents Executable file
View File

@ -0,0 +1,35 @@
Contents of the "msdos" subdirectory for UnZip 5.3 and later:
Contents this file
README notes about quirks in MS-DOS executables and compilers
crc_i86.asm optimized 8086/80286 assembler version of generic crc32.c
doscfg.h OS-dependent configuration, included by unzpriv.h
msdos.c OS-dependent UnZip routines for MS-DOS
makefile.bc makefile for Borland C++ and Turbo C++
makefile.msc makefile for Microsoft C and make or nmake
makefile.tc makefile for Turbo C and make
makefile.wat makefile for Watcom C
makefile.dj1 makefile for GNU C, djgpp v1.12m4 port
makefile.dj2 makefile for GNU C, djgpp v2.x port
makefile.emx makefile for GNU C, emx 0.9c port, gnu make
Notes:
(1) Two makefiles for djgpp/GNU make are provided, one for djgpp 1.12 and one
for djgpp v2.x. In addition, the Unix makefile (unix/Makefile) contains
a djgpp v2.x target using the go32-gcc cross compiler on Linux. Read the
appropriate makefile sections for details.
(2) The makefile for emx+gcc has been used with GNU Make ports from DJGPP and
the GNUish MS-DOS project. Other make utilities may work, too. The
resulting executables require emx.exe or rsx.exe to run (akin to djgpp
1.x's go32.exe).
(3) The OS/2 makefile includes several (cross compilation ?) targets to
generate MS-DOS executables which can be used with MSC 6.0 or later
(`mscdos', 16-bit), Watcom C/C++ 9.0 or later (`watcom16dos', 16-bit;
`watcomdos' and `pmodew', 32-bit) and emx+gcc 0.9c or later (`gccdos',
32-bit). These targets have only been tested in cross-compilation from
OS/2 to MS-DOS, but they may work on a plain MS-DOS system, when a proper
make utility is available.

117
zip/unzip/msdos/README Executable file
View File

@ -0,0 +1,117 @@
Notes about MS-DOS executables and compilers:
- Borland start-up code is reported to switch the screen mode auto-
matically if it's not 80 columns (or possibly 40) and either 25, 43
or 50 lines. In particular, extended modes such as 100x40 are not
retained.
- Borland start-up code also uses interrupt 1Ah, causing incorrect
behavior (including lock-ups) on some Japanese MS-DOS machines such
as the Fujitsu FMR series, which lack this interrupt.
- Some(?) Borland compilers are apparently incapable of putting static
data into far memory; this means all of UnZip's strings are in near
memory, and there is not enough room to enable ZipInfo in the small
memory model. The medium memory model is the default for now, but
it may be necessary in some cases to use the large model.
- Older Borland compilers do not understand source files with Unix
line-endings (LF rather than CR/LF). Use "flip" or a similar utility
to convert the line endings before compiling.
- The Borland 5.00 compiler is simply too buggy to use on WizUnZip, both
16-bit and 32-bit versions, and we recommend avoiding it for now even
on the commmand-line version of UnZip.
- Microsoft C 5.1 large-model code is more than an order of magnitude
slower than the identical code compiled with MSC 6 or 7 (a factor of
15 in our tests, actually). This may be due to a lousy optimizer or
lousy libraries; regardless, since UnZip is hovering at the doorstep
of the large memory model, we recommend upgrading to a later version
of the compiler.
For these reasons, Info-ZIP's distributed versions of the 16-bit MS-DOS
executables are compiled with MSC 6 or 7.
- djgpp 2.x (currently 2.01) is no longer distributed with the go32 extender.
Instead, a 2K stub bound into the executable searches for a DPMI server;
if none is found, it loads the default DPMI server while executing UnZip.
Both djgpp 1.x and 2.x are capable of substituting a list of files in an
ASCII file (say, `foo') on the command line; for example, "unzip archive
@foo" will extract from `archive' all of the files listed in `foo'. Note,
however, that djgpp 2.x is considerably slower than 1.x at file extraction
(roughly twice as slow, in fact); see proginfo/perform.dos in the UnZip 5.3
source distribution for details.
- djgpp 2.0's long-filename support is somewhat flaky; users should upgrade
to version 2.01 instead.
- The default wildcard ("globbing") behavior of djgpp 1.x/go32 is disabled
by default in UnZip, but this can be overridden if the GO32 environment
variable is set to "glob". This will cause UnZip to fail with various
odd errors about "filename not matched" and the like; to avoid this, set
the GO32 variable to "noglob" or unset it altogether. (The documented
method of avoiding this by quoting wildcards with single quotes was
buggy in djgpp 1.11 but is reported fixed in 1.12; not tested.)
- djgpp 1.x's handling of timezones, necessary for the correct conversion of
MS-DOS file times to those used in the Unix-like C library, is completely
broken in djgpp 1.12 and probably earlier versions as well. It is fixed
(or very close to it) in the 1.12m4 patch release and reportedly in the
2.x series, so be sure to use one of those when compiling. Otherwise
UnZip's -f and -u (freshen/update) functions will not work correctly.
It is reportedly necessary to set the TZDIR environment variable correctly
with 1.12m4; for example, add `set TZDIR=c:/djgpp/zoneinfo' or similar to
autoexec.bat.
- djgpp 1.x/go32 executables, when run in a DOS box under OS/2 *and* extrac-
ting to an HPFS disk *and* overwriting existing files (intentionally, that
is), do not set the files' timestamps correctly. Instead, the timestamps
remain set to whatever the original files' stamps were. This is a pretty
obscure bug, but it does *not* occur in the 16-bit version so it seems
to be go32's fault somehow.
- According to notes found in another package, there was a known conflict
between djgpp 1.x's go32 extender and QEMM's DPMI; this was apparently
fixed in QEMM 7.04/QDPMI 1.05, but if you still have an older version
(1.03 or 1.01), add "set GO32=nodpmi" to your autoexec.bat to avoid the
conflict.)
- [For Zip only, the djgpp/go32 extender goes nuts with the copying and/or
deletion of some sort of a temporary file (swap file?) after compression
is finished; this can take 30 seconds or more and really hurts perfor-
mance. It doesn't affect UnZip, apparently.]
- [Also apparently for Zip only, djgpp/go32 is reported to have problems
when EMM386 is set to NOEMS; it sometimes gives the error message, "CPU
must be in REAL mode (not V86 mode) to run this program without VCPI.
(If you are using an EMS emulator, make sure that EMS isn't disabled)"
Sometimes Zip works correctly, however, possibly due to other software
having been run previously.]
- emx+gcc's DOS extender does not understand DPMI, and while there is an
alternative extender called RSX available (found in dpmigcc4.zip as of
August 1994), its setup is somewhat kludgy when the local memory manager
supports both DPMI and VCPI (or something else). It's also not yet as
widely known or available as djgpp.
- The free PMODE/W extender, used in conjunction with executables compiled
with Watcom C 10.x and run in an OS/2 DOS box, appears to use up some
critical DPMI resource and will fail to run after a few dozen executions
("PMODE/W: DPMI error" and/or SYS 3176). Some newer versions of PMODE/W,
in combination with "unzip -v" on certain zipfiles (e.g., APMTST.ZIP from
IBM/EWS), fail immediately (SYS 3176). And on some OS/2 systems, *any*
use of the PMODE/W executables causes the machine to lock up.
- PMODE/W is also reported to lock up pure DOS systems if QEMM is running.
- At least older versions of PMODE/W, used in conjunction with Microsoft's
EMM386, cause UnZip to start up extremely slowly. (This problem does not
occur with QEMM.)
For these reasons Info-ZIP's distributed 32-bit MS-DOS executables will
probably be compiled with djgpp 2.01, mainly because of its nice long-filename
support when running in a Win32 DOS box. The cwsdpmi DPMI server will be
bundled if necessary.
GRR 970330

400
zip/unzip/msdos/crc_i86.asm Executable file
View File

@ -0,0 +1,400 @@
; Not copyrighted by Christian Spieler, 11 Feb 1996.
;
TITLE crc_i86.asm
NAME crc_i86
;
; Optimized 8086 assembler version of the CRC32 calculation loop, intended
; for real mode Info-ZIP programs (Zip 2.1, UnZip 5.2, and later versions).
; Supported compilers are Microsoft C (DOS real mode) and Borland C(++)
; (Turbo C). Watcom C (16bit) should also work.
; This module was inspired by a similar module for the Amiga (Paul Kienitz).
;
; It replaces the `ulg crc32(ulg crc, ZCONST uch *buf, extent len)' function
; in crc32.c.
;
; The code in this module should work with all kinds of C memory models
; (except Borland's __HUGE__ model), as long as the following
; restrictions are not violated:
;
; - The implementation assumes that the char buffer is confined to a
; 64k segment. The pointer `s' to the buffer must be in a format that
; all bytes can be accessed by manipulating the offset part, only.
; This means:
; + no huge pointers
; + char buffer size < 64 kByte
;
; - Since the buffer size argument `n' is of type `size_t' (= unsigned short)
; for this routine, the char buffer size is limited to less than 64 kByte,
; anyway. So, the assumption above should be easily fulfilled.
;
;==============================================================================
;
; Do NOT assemble this source if external crc32 routine from zlib gets used.
;
ifndef USE_ZLIB
;
; Setup of amount of assemble time informational messages:
;
ifdef DEBUG
VERBOSE_INFO EQU 1
else
ifdef _AS_MSG_
VERBOSE_INFO EQU 1
else
VERBOSE_INFO EQU 0
endif
endif
;
; Selection of memory model, and initialization of memory model
; related macros:
;
ifndef __SMALL__
ifndef __COMPACT__
ifndef __MEDIUM__
ifndef __LARGE__
ifndef __HUGE__
; __SMALL__ EQU 1
endif
endif
endif
endif
endif
ifdef __HUGE__
; .MODEL Huge
@CodeSize EQU 1
@DataSize EQU 1
Save_DS EQU 1
if VERBOSE_INFO
if1
%out Assembling for C, Huge memory model
endif
endif
else
ifdef __LARGE__
; .MODEL Large
@CodeSize EQU 1
@DataSize EQU 1
if VERBOSE_INFO
if1
%out Assembling for C, Large memory model
endif
endif
else
ifdef __COMPACT__
; .MODEL Compact
@CodeSize EQU 0
@DataSize EQU 1
if VERBOSE_INFO
if1
%out Assembling for C, Compact memory model
endif
endif
else
ifdef __MEDIUM__
; .MODEL Medium
@CodeSize EQU 1
@DataSize EQU 0
if VERBOSE_INFO
if1
%out Assembling for C, Medium memory model
endif
endif
else
; .MODEL Small
@CodeSize EQU 0
@DataSize EQU 0
if VERBOSE_INFO
if1
%out Assembling for C, Small memory model
endif
endif
endif
endif
endif
endif
if @CodeSize
LCOD_OFS EQU 2
else
LCOD_OFS EQU 0
endif
IF @DataSize
LDAT_OFS EQU 2
else
LDAT_OFS EQU 0
endif
ifdef Save_DS
; (di,si,ds)+(size, return address)
SAVE_REGS EQU 6+(4+LCOD_OFS)
else
; (di,si)+(size, return address)
SAVE_REGS EQU 4+(4+LCOD_OFS)
endif
;
; Selection of the supported CPU instruction set and initialization
; of CPU type related macros:
;
ifdef __586
Use_286_code EQU 1
Align_Size EQU 16 ; paragraph alignment on Pentium
Alig_PARA EQU 1 ; paragraph aligned code segment
else
ifdef __486
Use_286_code EQU 1
Align_Size EQU 4 ; dword alignment on 32 bit processors
Alig_PARA EQU 1 ; paragraph aligned code segment
else
ifdef __386
Use_286_code EQU 1
Align_Size EQU 4 ; dword alignment on 32 bit processors
Alig_PARA EQU 1 ; paragraph aligned code segment
else
ifdef __286
Use_286_code EQU 1
Align_Size EQU 2 ; word alignment on 16 bit processors
Alig_PARA EQU 0 ; word aligned code segment
else
ifdef __186
Use_186_code EQU 1
Align_Size EQU 2 ; word alignment on 16 bit processors
Alig_PARA EQU 0 ; word aligned code segment
else
Align_Size EQU 2 ; word alignment on 16 bit processors
Alig_PARA EQU 0 ; word aligned code segment
endif ;?__186
endif ;?__286
endif ;?__386
endif ;?__486
endif ;?__586
ifdef Use_286_code
.286
Have_80x86 EQU 1
else
ifdef Use_186_code
.186
Have_80x86 EQU 1
else
.8086
Have_80x86 EQU 0
endif ;?Use_186_code
endif ;?Use_286_code
;
; Declare the segments used in this module:
;
if @CodeSize
if Alig_PARA
CRC32_TEXT SEGMENT PARA PUBLIC 'CODE'
else
CRC32_TEXT SEGMENT WORD PUBLIC 'CODE'
endif
CRC32_TEXT ENDS
else ;!@CodeSize
if Alig_PARA
_TEXT SEGMENT PARA PUBLIC 'CODE'
else
_TEXT SEGMENT WORD PUBLIC 'CODE'
endif
_TEXT ENDS
endif ;?@CodeSize
_DATA SEGMENT WORD PUBLIC 'DATA'
_DATA ENDS
_BSS SEGMENT WORD PUBLIC 'BSS'
_BSS ENDS
DGROUP GROUP _BSS, _DATA
if @DataSize
ASSUME DS: nothing, SS: DGROUP
else
ASSUME DS: DGROUP, SS: DGROUP
endif
if @CodeSize
EXTRN _get_crc_table:FAR
else
EXTRN _get_crc_table:NEAR
endif
Do_CRC MACRO
mov bl,al
if @DataSize
xor bl,BYTE PTR es:[di]
else
xor bl,BYTE PTR [di]
endif
inc di
sub bh,bh
if Have_80x86
shl bx,2
else
shl bx,1
shl bx,1
endif
mov al,ah
mov ah,dl
mov dl,dh
sub dh,dh
xor ax,WORD PTR [bx][si]
xor dx,WORD PTR [bx+2][si]
ENDM
;
Do_2 MACRO
Do_CRC
Do_CRC
ENDM
Do_4 MACRO
Do_2
Do_2
ENDM
;
IF @CodeSize
CRC32_TEXT SEGMENT
ASSUME CS: CRC32_TEXT
else
_TEXT SEGMENT
ASSUME CS: _TEXT
endif
; Line 37
;
;ulg crc32(ulg crc,
; ZCONST uch *buf,
; extend len)
;
PUBLIC _crc32
if @CodeSize
_crc32 PROC FAR
else
_crc32 PROC NEAR
endif
if Have_80x86
enter WORD PTR 0,0
else
push bp
mov bp,sp
endif
push di
push si
if @DataSize
; crc = 4+LCOD_OFS DWORD (unsigned long)
; buf = 8+LCOD_OFS DWORD PTR BYTE (uch *)
; len = 12+LCOD_OFS WORD (unsigned int)
else
; crc = 4+LCOD_OFS DWORD (unsigned long)
; buf = 8+LCOD_OFS WORD PTR BYTE (uch *)
; len = 10+LCOD_OFS WORD (unsigned int)
endif
;
if @DataSize
mov ax,WORD PTR [bp+8+LCOD_OFS] ; buf
or ax,WORD PTR [bp+10+LCOD_OFS] ; == NULL ?
else
cmp WORD PTR [bp+8+LCOD_OFS],0 ; buf == NULL ?
endif
jne crc_update
sub ax,ax ; crc = 0
cwd
ifndef NO_UNROLLED_LOOPS
jmp fine
else
jmp SHORT fine
endif
;
crc_update:
call _get_crc_table
; When used with compilers that conform to the Microsoft/Borland standard
; C calling convention, model-dependent handling is not needed, because
; _get_crc_table returns NEAR pointer.
; But Watcom C is different and does not allow one to assume DS pointing to
; DGROUP. So, we load DS with DGROUP, to be safe.
;if @DataSize
; push ds
; mov ds,dx
; ASSUME DS: nothing
;endif
mov si,ax ;crc_table
if @DataSize
push ds
mov ax,SEG DGROUP
mov ds,ax
ASSUME DS: DGROUP
endif
;
mov ax,WORD PTR [bp+4+LCOD_OFS] ;crc
mov dx,WORD PTR [bp+6+LCOD_OFS]
not ax
not dx
if @DataSize
les di,DWORD PTR [bp+8+LCOD_OFS] ;buf
mov cx,WORD PTR [bp+12+LCOD_OFS] ;len
else
mov di,WORD PTR [bp+8+LCOD_OFS] ;buf
mov cx,WORD PTR [bp+10+LCOD_OFS] ;len
endif
;
ifndef NO_UNROLLED_LOOPS
if Have_80x86
shr cx,2
else
shr cx,1
shr cx,1
endif
jcxz No_Fours
;
align Align_Size ; align destination of branch
Next_Four:
Do_4
loop Next_Four
;
No_Fours:
if @DataSize
mov cx,WORD PTR [bp+12+LCOD_OFS] ;len
else
mov cx,WORD PTR [bp+10+LCOD_OFS] ;len
endif
and cx,00003H
endif ; NO_UNROLLED_LOOPS
jcxz done
;
align Align_Size ; align destination of branch
Next_Byte:
Do_CRC
loop Next_Byte
;
done:
if @DataSize
pop ds
; ASSUME DS: DGROUP
ASSUME DS: nothing
endif
not ax
not dx
;
fine:
pop si
pop di
if Have_80x86
leave
else
mov sp,bp
pop bp
endif
ret
_crc32 ENDP
if @CodeSize
CRC32_TEXT ENDS
else
_TEXT ENDS
endif
;
endif ;!USE_ZLIB
;
END

241
zip/unzip/msdos/doscfg.h Executable file
View File

@ -0,0 +1,241 @@
/*---------------------------------------------------------------------------
MS-DOS specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __doscfg_h
#define __doscfg_h
#include <dos.h> /* for REGS macro (TC) or _dos_setftime (MSC) */
#ifdef __TURBOC__ /* includes Power C */
# include <sys/timeb.h> /* for structure ftime */
# ifndef __BORLANDC__ /* there appears to be a bug (?) in Borland's */
# include <mem.h> /* MEM.H related to __STDC__ and far poin- */
# endif /* ters. (dpk) [mem.h included for memcpy] */
#endif
#ifdef WINDLL
# if (defined(MSC) || defined(__WATCOMC__))
# include <sys/utime.h>
# else /* !(MSC || __WATCOMC__) ==> may be BORLANDC, or GNU environment */
# include <utime.h>
# endif /* ?(MSC || __WATCOMC__) */
#endif
#ifdef __WATCOMC__
# undef SSTAT
# define SSTAT stat_bandaid
int stat_bandaid(const char *path, struct stat *buf);
# ifdef __386__
# ifndef WATCOMC_386
# define WATCOMC_386
# endif
# define __32BIT__
# undef far
# define far
# undef near
# define near
/* Get asm routines to link properly without using "__cdecl": */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
# pragma aux get_crc_table "_*" parm caller [] value [eax] \
modify [eax ecx edx]
# endif /* !USE_ZLIB */
# else /* !__386__ */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [ax dx] \
modify [ax cx dx bx]
# pragma aux get_crc_table "_*" parm caller [] value [ax] \
modify [ax cx dx bx]
# endif /* !USE_ZLIB */
# endif /* ?__386__ */
# ifndef EPIPE
# define EPIPE -1
# endif
# define PIPE_ERROR (errno == EPIPE)
#endif /* __WATCOMC__ */
#ifdef __EMX__
# ifndef __32BIT__
# define __32BIT__
# endif
# define far
#endif
#if defined(__GO32__) || defined(__DJGPP__) /* MS-DOS compiler, not OS/2 */
# ifndef __32BIT__
# define __32BIT__
# endif
# ifndef __GO32__
# define __GO32__
# endif
# include <sys/timeb.h> /* for structure ftime */
# if (defined(__DJGPP__) && (__DJGPP__ > 1))
# include <unistd.h> /* for prototypes for read/write etc. */
# include <dir.h> /* for FA_LABEL */
# if ((__DJGPP__ == 2) && (__DJGPP_MINOR__ == 0))
# include <libc/dosio.h> /* for _USE_LFN, djgpp 2.0 only */
# endif
# define USE_LFN _USE_LFN /* runtime test: support long filenames? */
# else
int setmode(int, int); /* not in older djgpp's include files */
# endif
#endif
#ifndef __32BIT__
# define __16BIT__
#endif
#if (defined(M_I86CM) || defined(M_I86LM)) || defined(WINDLL)
# define MED_MEM
#endif
#if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
# define MED_MEM
#endif
#ifdef __16BIT__
# ifndef MED_MEM
# define SMALL_MEM
# endif
#endif
#define EXE_EXTENSION ".exe" /* OS/2 has GetLoadPath() function instead */
#ifdef __16BIT__
# if defined(MSC) || defined(__WATCOMC__)
# include <malloc.h>
# define nearmalloc _nmalloc
# define nearfree _nfree
# endif
# if defined(__TURBOC__) && defined(DYNALLOC_CRCTAB)
# if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
# undef DYNALLOC_CRCTAB
# endif
# endif
# ifndef nearmalloc
# define nearmalloc malloc
# define nearfree free
# endif
# if defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB)
# define USE_OWN_CRCTAB
# endif
#endif
/* another stat()/fopen() bug with some 16-bit compilers on Novell drives;
* very dangerous (silently overwrites executables in other directories)
*/
#define NOVELL_BUG_WORKAROUND
/* enables additional test and message code that directs UnZip to fail safely
* in case the "workaround" enabled above does not work as intended
*/
#define NOVELL_BUG_FAILSAFE
/* The optional "long filename" support available with some MSDOS compiler
* environment running under VFAT systems (Win95) is controlled with the
* help of the two preprocessor symbols USE_VFAT and USE_LFN:
* - USE_VFAT is a compile time switch that selects the long filename
* semantics in mapname()
* - USE_LFN is a macro equating to a boolean expression indicating
* whether long filenames are supported. If available, this
* macro should make use of a runtime function checking the
* LFN support.
*
* The code in msdos.c distinguishes three cases:
* 1.) USE_VFAT is not defined:
* No support of LFN is included; filenames are mapped to 8+3 plain FAT
* syntax unconditionally.
* This is achieved by ``#define MAYBE_PLAIN_FAT'' to include the plain
* FAT name mapping code and by ``#undef USE_LFN'' to disable bypassing
* of the FAT mapping at runtime.
* 2.) USE_VFAT is defined:
* Support for LFN is enabled.
* a) USE_LFN is undefined:
* There is no (runtime) check available to distinguish between OS
* environments that support VFAT extensions and those that do not.
* In this case, filenames are mapped to the more liberal VFAT LFN
* syntax unconditionally. The internal switch MAYBE_PLAIN_FAT remains
* undefined to exclude to "map to plain FAT" code parts.
* b) USE_LFN is defined (hopefully to a boolean runtime LFN check function):
* "#define MAYBE_PLAIN_FAT" is applied to include the plain FAT mapping
* code; the programs checks at runtime whether the OS supports LFN and
* uses the appropiate mapping syntax.
*/
/* Some environments, like DJGPP v2, can support long filenames on VFAT
* systems and DOS 8.3 filenames on FAT systems in the same executable. If
* such support is available, USE_LFN should be defined to an expression
* that will return non-zero when long filenames API should be used, zero
* otherwise.
*/
#ifndef USE_VFAT
# ifdef USE_LFN
# undef USE_LFN
# endif
# ifndef MAYBE_PLAIN_FAT
# define MAYBE_PLAIN_FAT
# endif
#endif
#ifdef USE_LFN
# define MAYBE_PLAIN_FAT
#endif
/* handlers for OEM <--> ANSI string conversions */
#ifdef WINDLL
# if 1
/* C RTL's file system support assumes OEM-coded strings */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
# else
/* C RTL's file system support assumes ISO-coded strings */
# ifndef CRTL_CP_IS_ISO
# define CRTL_CP_IS_ISO
# endif
# ifdef CRTL_CP_IS_OEM
# undef CRTL_CP_IS_OEM
# endif
# endif /* ?(code page of 16bit Windows compilers) */
/* include Win API declarations only in sources where conversion is
* actually used (skip EXTRACT_C, extract.c includes windll.h instead)
*/
# if defined(ENVARGS_C) || defined(UNZIP_C) || defined(ZCRYPT_INTERNAL)
# include <windows.h>
# endif
/* use conversion functions of Windows API */
# ifdef CRTL_CP_IS_ISO
# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst)
# endif
# ifdef CRTL_CP_IS_OEM
# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# endif
# define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
# define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
/* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
/* dummy defines to disable these functions, they are not needed */
# define STR_TO_ISO
# define STR_TO_OEM
#else
/* use home-brewed conversion functions; internal charset is OEM */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
#endif
#endif /* !__doscfg_h */

259
zip/unzip/msdos/makefile.bc Executable file
View File

@ -0,0 +1,259 @@
# Makefile for UnZip(SFX) and fUnZip for Borland C++ 2.x-4.x and Turbo C++ 1.0
# Version: 5.20 and later Alvin Koh, Jim Knoble, Christian Spieler, etc.
#
# Last revised: 8 Apr 96
#
# To compile with Turbo C++ 1.0, set the macro CC_REV to 1 at the command line
# (make -fmsdos/makefile.bc -DCC_REV=1).
# GNU make doesn't like the return value from "rem"
#STRIP=rem
STRIP=echo Ignore this line.
# If you don't have LZEXE or PKLITE, get one of them. Then define:
#STRIP=lzexe
# or
#STRIP=pklite
# This makes a big difference in .exe size (and possibly load time).
# Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
# should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_UNZIP)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 0
# (De)Select inclusion of optimized assembler CRC32 routine:
USE_ASMCRC = 1
!if $(CC_REV) == 1
# Turbo C++ 1.0
CC = tcc
!else
# Borland C++ 2.0, 3.0, 3.1 ...
! if !$(CC_REV)
CC_REV = 3
! endif
CC = bcc
!endif
AS = tasm
# "near data" model is sufficient for UnZip and ZipInfo, now that strings moved
# switched to medium model; UnZip code has grown beyond the 64k limit.
UNMODEL = m # medium model for UnZip and ZipInfo
ASUNMODEL=__MEDIUM__ # keep in sync with UNMODEL definition !!
FUMODEL = s # always use small model for fUnZip
ASFUMODEL=__SMALL__ # keep in sync with FUMODEL definition !!
!if $(USE_ASMCRC)
ASMFLG = -DASM_CRC
ASMOBJS = crc_i86.obj
ASMOBJF = crc_i86_.obj
!else
ASMFLG =
ASMOBJS =
ASMOBJF =
!endif
# compiler flags
ASCPUFLAG = __$(CPU_TYP)86
!if $(CPU_TYP) != 0
CC_CPUFLG = -$(CPU_TYP)
!endif
ASFLAGS = -ml -m2 -w0 -D$(ASCPUFLAG) $(LOC)
!if $(CC_REV) == 1
CFLAGS = -O -G -Z -a -d $(CC_CPUFLG) -ff- -k- -P-.C -I. $(ASMFLG) $(LOC)
LDFLAGS = -lxncd # for tcc
!else
CFLAGS = -O2 $(CC_CPUFLG) -ff- -k- -P-.C -I. $(ASMFLG) $(LOC)
LDFLAGS = -lxncd -l-P # for bcc
!endif
UNFLAGS = -m$(UNMODEL) $(CFLAGS)
FUFLAGS = -m$(FUMODEL) $(CFLAGS) -K -d
# implicit rules
.asm.obj:
$(AS) $(ASFLAGS) -D$(ASUNMODEL) $<
.c.obj:
$(CC) -c $(UNFLAGS) {$< }
# list macros
unzip_dependencies = \
unzip.obj \
crc32.obj \
crctab.obj \
crypt.obj \
envargs.obj \
explode.obj \
extract.obj \
fileio.obj \
globals.obj \
inflate.obj \
list.obj \
match.obj \
process.obj \
ttyio.obj \
unreduce.obj \
unshrink.obj \
zipinfo.obj \
msdos.obj \
$(ASMOBJS)
funzip_dependencies = \
funzip.obj \
crc32_.obj \
crypt_.obj \
globals_.obj \
inflate_.obj \
ttyio_.obj \
$(ASMOBJF)
unzipsfx_dependencies = \
unzipsfx.obj \
crc32.obj \
crctab.obj \
crypt.obj \
extract_.obj \
fileio.obj \
globals.obj \
inflate.obj \
match.obj \
process_.obj \
ttyio.obj \
msdos_.obj \
$(ASMOBJS)
UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
# explicit rules
all: unzip.exe funzip.exe unzipsfx.exe
unzip.exe: $(unzip_dependencies)
$(CC) -m$(UNMODEL) $(LDFLAGS) -eunzip.exe @&&|
unzip.obj
crc32.obj
crctab.obj
crypt.obj
envargs.obj
explode.obj
extract.obj
fileio.obj
$(ASMOBJS)
globals.obj
inflate.obj
list.obj
match.obj
process.obj
ttyio.obj
unreduce.obj
unshrink.obj
zipinfo.obj
msdos.obj
|
$(STRIP) unzip.exe
funzip.exe: $(funzip_dependencies)
$(CC) -m$(FUMODEL) $(LDFLAGS) -efunzip.exe @&&|
funzip.obj
$(ASMOBJF)
crc32_.obj
crypt_.obj
globals_.obj
inflate_.obj
ttyio_.obj
|
$(STRIP) funzip.exe
unzipsfx.exe: $(unzipsfx_dependencies)
$(CC) -m$(UNMODEL) $(LDFLAGS) -eunzipsfx.exe @&&|
unzipsfx.obj
crc32.obj
crctab.obj
crypt.obj
extract_.obj
fileio.obj
$(ASMOBJS)
globals.obj
inflate.obj
match.obj
process_.obj
ttyio.obj
msdos_.obj
|
$(STRIP) unzipsfx.exe
clean:
rem Ignore any errors in the following...
-del *.obj
-del unzip.exe
-del funzip.exe
-del unzipsfx.exe
# individual file dependencies
crc32.obj: crc32.c $(UNZIP_H) zip.h
crctab.obj: crctab.c $(UNZIP_H) zip.h
crypt.obj: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
envargs.obj: envargs.c $(UNZIP_H)
explode.obj: explode.c $(UNZIP_H)
extract.obj: extract.c $(UNZIP_H) crypt.h
fileio.obj: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
globals.obj: globals.c $(UNZIP_H)
inflate.obj: inflate.c inflate.h $(UNZIP_H)
list.obj: list.c $(UNZIP_H)
match.obj: match.c $(UNZIP_H)
process.obj: process.c $(UNZIP_H)
ttyio.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce.obj: unreduce.c $(UNZIP_H)
unshrink.obj: unshrink.c $(UNZIP_H)
unzip.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
zipinfo.obj: zipinfo.c $(UNZIP_H)
crc_i86.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASUNMODEL) msdos\crc_i86.asm, $*.obj ;
crc_i86_.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASFUMODEL) msdos\crc_i86.asm, $*.obj ;
msdos.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) msdos/msdos.c
funzip.obj: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
$(CC) -c $(FUFLAGS) funzip.c
crc32_.obj: crc32.c $(UNZIP_H) zip.h
$(CC) -c $(FUFLAGS) -DFUNZIP -ocrc32_.obj crc32.c
crypt_.obj: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) -c $(FUFLAGS) -DFUNZIP -ocrypt_.obj crypt.c
globals_.obj: globals.c $(UNZIP_H)
$(CC) -c $(FUFLAGS) -DFUNZIP -oglobals_.obj globals.c
inflate_.obj: inflate.c inflate.h $(UNZIP_H) crypt.h
$(CC) -c $(FUFLAGS) -DFUNZIP -oinflate_.obj inflate.c
unzipsfx.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
$(CC) -c $(UNFLAGS) -DSFX -ounzipsfx.obj unzip.c
extract_.obj: extract.c $(UNZIP_H) crypt.h
$(CC) -c $(UNFLAGS) -DSFX -oextract_.obj extract.c
process_.obj: process.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) -DSFX -oprocess_.obj process.c
ttyio_.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) -c $(FUFLAGS) -DFUNZIP -ottyio_.obj ttyio.c
msdos_.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) -DSFX -omsdos_.obj msdos/msdos.c

202
zip/unzip/msdos/makefile.dj1 Executable file
View File

@ -0,0 +1,202 @@
# Makefile for Info-ZIP's unzip, zipinfo, funzip and unzipsfx
# using djgpp v1.12m4. Tested with unz520p by Christian Spieler
#
# This Makefile is specifically tailored for GNU Make and GNU C and
# may not work with a generic UNIX compatible Make utility.
# Features use:
# - pattern rules (%.o : %.c, etc.)
# - GNUMake conditionals and functions (ifeq, $(patsubst,,),...)
#
# To allow mixed use of real mode (16bit) vs. GO32 (32bit protected mode)
# GNUMake utility and GCC driver, precautions have been taken to
# limit command lines to the DOS 126 bytes limit.
# In case you have an environment that supports long command lines
# at all "interface" levels (e.g.: DJGPPv1 Gmake 3.71 and GO32 gcc.exe),
# you may define the Makefile macro LONGARGS to take advantage of the
# "long command lines" capability.
# I have archived the fastest compilation (with LONGARGS support!) by
# using both a real mode gnumake (private port) and the real mode
# gcc.exe driver.
#
# The Makefile allows the optional creation of standalone exectutables.
# This has the advantage that unzip.exe does not rely on any other file,
# but results in much larger executables.
#
# Separators colon and <sp> are used in U**X, semi-colon and <sp> in DOS.
VPATH=. msdos
ifdef NOASM
USE_ASMCRC=
else
USE_ASMCRC=1
endif
# UnZip flags
LOC=-DDOS $(ASMFLG) $(LOCAL_UNZIP)
CC=gcc
LD=$(CC)
CPPFLAGS=-I. $(LOC)
ASFLAGS=$(CPPFLAGS)
CFLAGS=-Wall -O2 -m486 $(CPPFLAGS)
FUN_FLAGS=$(CFLAGS) -DFUNZIP
SFX_FLAGS=$(CFLAGS) -DSFX
LDFLAGS=-s -v
STRIP=strip
# Define the STANDALONE macro to create executables which can be
# used without any external extender file.
# >>> NOTE: Either copy the go32 extender into your build directory, or
# >>> edit the STUBIFY macro and add the correct path to "go32.exe".
ifdef STANDALONE
STUBIFY=coff2exe -s go32.exe
else
STUBIFY=coff2exe
endif
# general-purpose stuff
# If cp.exe is not found change to CP=copy /Y .
CP = cp -f
# If install.exe is not found change to INSTALL=$(CP) .
INSTALL=install
# The default value of RM is "rm -f" . If rm.exe is not found, uncomment
# the following:
RM=del
E = .exe
O = .o
M=msdos
# defaults for crc32 stuff and system dependent headers
ifdef USE_ASMCRC
ASMFLG = -DASM_CRC
CRC32 = crc_gcc
else
ASMFLG =
CRC32 = crc32
endif
# 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
OBJX1 = unzipsfx$O $(CRC32)$O crctab$O crypt$O extract_$O fileio$O globals$O
OBJX2 = inflate$O match$O process_$O ttyio$O $M_$O
OBJX = $(OBJX1) $(OBJX2)
OBJF = funzip$O $(CRC32)$O crypt-$O globals-$O inflate-$O ttyio-$O
OBJECTS_ALL = $(sort $(OBJS) $(OBJX) $(OBJF) crc32$O crc_gcc$O)
# Common header files included by all C sources:
UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
# executable files
UNZIPS = unzip$E zipinfo$E funzip$E unzipsfx$E
# pattern rules to compile the sources:
%$O : %.c
$(CC) $(CFLAGS) -c $< -o $@
%-$O: %.c
$(CC) $(FUN_FLAGS) -c $< -o $@
%_$O: %.c
$(CC) $(SFX_FLAGS) -c $< -o $@
%sfx$O: %.c
$(CC) $(SFX_FLAGS) -c $< -o $@
all: unzips
unzips: unzip$E zipinfo$E funzip$E unzipsfx$E
unzip$E: $(OBJS)
ifdef LONGARGS
$(LD) $(LDFLAGS) $(OBJS) -o unzip
else
echo $(OBJS1) > unzip.rsp
echo $(OBJS2) >> unzip.rsp
echo $(OBJS3) $M$O >> unzip.rsp
$(LD) $(LDFLAGS) -o unzip @unzip.rsp
$(RM) unzip.rsp
endif
$(STRIP) unzip
$(STUBIFY) unzip
stubedit $@ globbing=no
$(RM) unzip
zipinfo$E: unzip$E
coff2exe -g zipinfo
stubedit $@ runfile=unzip globbing=no
funzip$E: $(OBJF)
$(LD) $(LDFLAGS) $(OBJF) -o funzip
$(STRIP) funzip
$(STUBIFY) funzip
$(RM) funzip
unzipsfx$E: $(OBJX)
ifdef LONGARGS
$(LD) $(LDFLAGS) $(OBJX) -o unzipsfx
else
echo $(OBJX1) > unzipsfx.rsp
echo $(OBJX2) >> unzipsfx.rsp
$(LD) $(LDFLAGS) -o unzipsfx @unzipsfx.rsp
$(RM) unzipsfx.rsp
endif
$(STRIP) unzipsfx
$(STUBIFY) unzipsfx
stubedit $@ globbing=no
$(RM) unzipsfx
# explicit compilation instructions:
crc_gcc$O: crc_i386.S # 32bit, GNU AS
$(CC) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
# BIN_PATH may be defined in djgpp.env [make] or defined above.
install:
$(INSTALL) $(UNZIPS) $(BIN_PATH)
uninstall:
cd $(BIN_PATH); $(RM) $(UNZIPS)
clean:
ifeq ($(firstword $(RM)), del)
$(RM) *$O
$(RM) *.zip
else
$(RM) $(OBJECTS_ALL) *.zip
endif
# Source dependencies:
crc_gcc$O: crc_i386.S
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
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
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)
globals-$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
inflate-$O: inflate.c inflate.h $(UNZIP_H) crypt.h
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
msdos$O: msdos/msdos.c $(UNZIP_H)
msdos_$O: msdos/msdos.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
process_$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.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 version.h consts.h
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)

207
zip/unzip/msdos/makefile.dj2 Executable file
View File

@ -0,0 +1,207 @@
# Makefile for Info-ZIP's UnZip, UnZipSFX and fUnZip using djgpp v2.0, by
# Frank Donahoe. Last updated: 10 Nov 96
# This Makefile is specifically tailored for GNU make and GNU C and
# may not work with a generic Unix-compatible make utility.
# Features used:
# - pattern rules (%.o : %.c, etc.)
# - GNU-specific conditionals and functions (ifeq, $(patsubst,,),...)
#
# The stand-alone executable requires DPMI services to run. If running
# in a DOS window under Windows 3.1 or later, the dpmi server is auto-
# matically present. Under DOS, if a DPMI server is not loaded, the
# program will look for "cwsdpmi.exe." If found, it will be loaded for
# the duration of the program.
#
# cwsdpmi is a "free" dpmi server written by Charles W. Sandmann
# (sandman@clio.rice.edu). It may be found, among other sites, on SimTel
# Net at the URL:
#
# ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/csdpmi?[b,s].zip
#
# and on its mirrors worldwide. The latest version as of this writing is 3.
# Archives with the b postscript contain the binaries. An alternate server
# is found, l.c., in the archive pmode??[b,s].zip. The latest (960908) is
# v1.1.
# Separators colon and <sp> are used in Unix, semi-colon and <sp> in DOS.
VPATH=. msdos
ifdef NOASM
USE_ASMCRC=
else
USE_ASMCRC=1
endif
# UnZip flags
# LOCAL_UNZIP may be set in AUTOEXEC.BAT or defined in djgpp.env [make].
# See, for example, DOSWILD, in the file INSTALL.
# [make]
# LOCAL_UNZIP=-DDOSWILD
# BUTT=-m486
# BUTT may also be defined to specify the target system. At present, -m386
# and -m486 are the only supported options. Either will produce code which
# will run on the other microprocessor, though possibly not so fast.
# In any case, omitting BUTT will result in a slightly smaller executable.
LOC=-DDOS -DUSE_VFAT $(ASMFLG) $(LOCAL_UNZIP)
CC=gcc
LD=$(CC)
CPPFLAGS=-I. $(LOC)
ASFLAGS=$(CPPFLAGS)
CFLAGS=-Wall -O2 $(BUTT) $(CPPFLAGS)
# See INSTALL for discussion of SFX_EXDIR.
# EXDIR=-DSFX_EXDIR
FUN_FLAGS=$(CFLAGS) -DFUNZIP
# Include OFP for a modest decrease in size of unzipsfx.exe.
OFP=-fomit-frame-pointer
SFX_FLAGS=-Wall -O2 $(CPPFLAGS) -DSFX $(EXDIR) $(OFP)
LDFLAGS=-s
# general-purpose stuff
# If cp.exe is not found change to CP=copy /Y .
CP = cp -f
# If install.exe is not found change to INSTALL=$(CP) .
INSTALL=install
# The default value of RM is "rm -f" . If rm.exe is not found, uncomment
# the following:
# RM=del
# If "djp.exe," which is Laszlo Molnar's executable file packer, is in the
# path, uncomment the three lines found far below containing $(DJP). The
# executable files will be converted to self-extracting compressed files.
# Look for "djp.exe" in the directory v2misc in the archive mlp???b.zip.
# Do not add the option -s to DJP without making the required changes to
# the targets zipinfo$E and unzipsfx$E.
DJP = djp -bq
E = .exe
O = .o
M=msdos
# defaults for crc32 stuff and system dependent headers
ifdef USE_ASMCRC
ASMFLG = -DASM_CRC
CRC32 = crc_gcc
else
ASMFLG =
CRC32 = crc32
endif
# 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
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 crypt-$O globals-$O inflate-$O ttyio-$O
OBJECTS_ALL = $(sort $(OBJS) $(OBJX) $(OBJF) crc32$O crc_gcc$O)
# Common header files included by all C sources:
UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
# executable files
UNZIPS = unzip$E zipinfo$E funzip$E unzipsfx$E
# pattern rules to compile the sources:
%$O : %.c
$(CC) $(CFLAGS) -c $< -o $@
%-$O: %.c
$(CC) $(FUN_FLAGS) -c $< -o $@
%_$O: %.c
$(CC) $(SFX_FLAGS) -c $< -o $@
%sfx$O: %.c
$(CC) $(SFX_FLAGS) -c $< -o $@
all: unzips
unzips: unzip$E zipinfo$E funzip$E unzipsfx$E
unzip$E: $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $@
# $(DJP) $@
zipinfo$E: unzip$E
stubify -g $@
stubedit $@ runfile=unzip argv0=zipinfo
funzip$E: $(OBJF)
$(LD) $(LDFLAGS) $(OBJF) -o $@
# $(DJP) $@
unzipsfx$E: $(OBJX)
$(LD) $(LDFLAGS) $(OBJX) -o $@
# $(DJP) -s $@
# explicit compilation instructions:
crc_gcc$O: crc_i386.S # 32bit, GNU AS
$(CC) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
# BIN_PATH may be defined in djgpp.env [make] or defined below. If the
# installation is to the directory containing gcc.exe etc. place the
# following in djgpp.env:
# [make]
# BIN_PATH=%\>;BIN_PATH%%\DJDIR%\bin
# Even if so placed, it can be over-ridden here by, say:
# BIN_PATH=c:\usr\bin
install: $(UNZIPS)
-@if not exist $(BIN_PATH)\nul mkdir $(BIN_PATH)
for %%f in ($(UNZIPS)) do $(INSTALL) %%f $(BIN_PATH)
uninstall:
for %%f in ($(UNZIPS)) do $(RM) $(BIN_PATH)\%%f
clean:
ifeq ($(firstword $(RM)), del)
$(RM) *$O
$(RM) *.~
$(RM) *.exe
else
$(RM) $(OBJECTS_ALL) *.~ *.exe
endif
# Source dependencies:
crc_gcc$O: crc_i386.S
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
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
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)
globals-$O: globals.c $(UNZIP_H)
inflate$O: inflate.c inflate.h $(UNZIP_H)
inflate-$O: inflate.c inflate.h $(UNZIP_H) crypt.h
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
msdos$O: msdos/msdos.c $(UNZIP_H)
msdos_$O: msdos/msdos.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
process_$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.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 version.h consts.h
unzipsfx$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)

223
zip/unzip/msdos/makefile.emx Executable file
View File

@ -0,0 +1,223 @@
# Makefile for UnZip, fUnZip and UnZipSFX
# for emx 0.9c / gcc under MS-DOS. Derived from makefile.os2
# By E-Yen Tan (with mods by Christian Spieler).
# Last updated 26 April 1997 (E-Yen Tan).
#
# This makefile should work fine with GNU make and hopefully some others.
# Tested with GNU make 3.71 gnuish 16-bit and djgpp 32-bit versions.
#ifdef NOASM
#AS_FLAGS =
#else
AS_FLAGS = -DASM_CRC
#endif
CP=copy
RM=del
CC=gcc -O -I.
# Version 5.1 of the RSX extender provides long file name support under
# Windows 95. If you don't have Windows 95 or use a version of RSX prior
# to 5.1 (or simply don't want LFN support) remove -DUSE_VFAT from CFLAGS.
# Note that if you have a version of RSX prior to 5.1, you can still compile
# with USE_VFAT enabled and upgrade RSX.EXE at a later stage.
#
# If you enable USE_VFAT then long file names under plain DOS will simply be
# truncated to 8.3 format without mapping. See doscfg.h for details.
#
CFLAGS=-Wall -DMSDOS $(AS_FLAGS) $(LOCAL_UNZIP) -DUSE_VFAT -m486
NFLAGS=
DLLFLAG=
AS=gcc
ASFLAGS=-Di386
LDFLAGS=-o ./
LDFLAGS2=-s
OUT=-o
OBJ=.o
#ifdef NOASM
#CRC32=crc32
#CRC32F=crc32f
#CRC32X=crc32_
#else
CRC32=crc_gcc
CRC32F=crc_gcc
CRC32X=crc_gcc
#endif
OBJUS=msdos.o
OBJXS=msdos_.o
OSDEP_H=msdos/doscfg.h
# default settings for target dependent macros:
DIRSEP = /
AS_DIRSEP = /
OBJU1 = unzip$(OBJ) $(CRC32)$(OBJ) crctab$(OBJ) crypt$(OBJ) envargs$(OBJ)
OBJU2 = explode$(OBJ) extract$(OBJ) fileio$(OBJ) globals$(OBJ)
OBJU3 = inflate$(OBJ) list$(OBJ) match$(OBJ) process$(OBJ) ttyio$(OBJ)
OBJU4 = unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ)
OBJU = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJU4) $(OBJUS)
OBJX1 = unzipsf_$(OBJ) $(CRC32X)$(OBJ) crctab_$(OBJ) crypt_$(OBJ)
OBJX2 = extract_$(OBJ) fileio_$(OBJ) globals_$(OBJ) inflate_$(OBJ)
OBJX3 = match_$(OBJ) process_$(OBJ) ttyio_$(OBJ)
OBJX = $(OBJX1) $(OBJX2) $(OBJX3) $(OBJXS)
OBJF = funzip$(OBJ) $(CRC32F)$(OBJ) cryptf$(OBJ) inflatef$(OBJ) \
globalsf$(OBJ) ttyiof$(OBJ)
UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
# rules
.SUFFIXES: .c $(OBJ)
.c$(OBJ):
$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ $<
# targets
all: unzip.exe funzip.exe unzipsfx.exe
# This next bit is nasty, but is needed to overcome the MS-DOS command
# line limit as response files for emx's gcc seem to only work if each
# file is on a different line. DJGPP doesn't do this (if you are at all
# interested).
unzip.exe: $(OBJU)
@ echo off
# -@ $(RM) unzip.rsp
# @ for %f in ($(OBJU1)) do echo %f >> unzip.rsp
# @ for %f in ($(OBJU2)) do echo %f >> unzip.rsp
# @ for %f in ($(OBJU3)) do echo %f >> unzip.rsp
# @ for %f in ($(OBJU4) $(OBJUS)) do echo %f >> unzip.rsp
@ echo unzip.o > unzip.rsp
@ echo $(CRC32)$(OBJ) >> unzip.rsp
@ echo crctab.o >> unzip.rsp
@ echo crypt.o >> unzip.rsp
@ echo envargs.o >> unzip.rsp
@ echo explode.o >> unzip.rsp
@ echo extract.o >> unzip.rsp
@ echo fileio.o >> unzip.rsp
@ echo globals.o >> unzip.rsp
@ echo inflate.o >> unzip.rsp
@ echo list.o >> unzip.rsp
@ echo match.o >> unzip.rsp
@ echo process.o >> unzip.rsp
@ echo ttyio.o >> unzip.rsp
@ echo unreduce.o >> unzip.rsp
@ echo unshrink.o >> unzip.rsp
@ echo zipinfo.o >> unzip.rsp
@ echo msdos.o >> unzip.rsp
$(CC) $(LDFLAGS)$@ $(DEF) @unzip.rsp $(LDFLAGS2)
@ $(RM) unzip.rsp
funzip.exe: $(OBJF)
$(CC) $(LDFLAGS)$@ $(DEF) $(OBJF) $(LDFLAGS2)
unzipsfx.exe: $(OBJX)
@ echo off
# -@ $(RM) unzipsfx.rsp
# @ for %f in ($(OBJX1)) do echo %f >> unzipsfx.rsp
# @ for %f in ($(OBJX2)) do echo %f >> unzipsfx.rsp
# @ for %f in ($(OBJX3)) do echo %f >> unzipsfx.rsp
# @ for %f in ($(OBJXS)) do echo %f >> unzipsfx.rsp
@ echo unzipsf_.o > unzipsfx.rsp
@ echo $(CRC32X)$(OBJ) >> unzipsfx.rsp
@ echo crctab_.o >> unzipsfx.rsp
@ echo crypt_.o >> unzipsfx.rsp
@ echo extract_.o >> unzipsfx.rsp
@ echo fileio_.o >> unzipsfx.rsp
@ echo globals_.o >> unzipsfx.rsp
@ echo inflate_.o >> unzipsfx.rsp
@ echo match_.o >> unzipsfx.rsp
@ echo process_.o >> unzipsfx.rsp
@ echo ttyio_.o >> unzipsfx.rsp
@ echo msdos_.o >> unzipsfx.rsp
$(CC) $(LDFLAGS)$@ $(DEF) @unzipsfx.rsp $(LDFLAGS2)
@ $(RM) unzipsfx.rsp
# dependencies
apihelp$(OBJ): apihelp.c $(UNZIP_H) version.h
crc32$(OBJ): crc32.c $(UNZIP_H) zip.h
crctab$(OBJ): crctab.c $(UNZIP_H) zip.h
envargs$(OBJ): envargs.c $(UNZIP_H)
explode$(OBJ): explode.c $(UNZIP_H)
extract$(OBJ): extract.c $(UNZIP_H) crypt.h
fileio$(OBJ): fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
globals$(OBJ): globals.c $(UNZIP_H)
inflate$(OBJ): inflate.c $(UNZIP_H)
list$(OBJ): list.c $(UNZIP_H)
match$(OBJ): match.c $(UNZIP_H)
process$(OBJ): process.c $(UNZIP_H)
ttyio$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
unreduce$(OBJ): unreduce.c $(UNZIP_H)
unshrink$(OBJ): unshrink.c $(UNZIP_H)
unzip$(OBJ): unzip.c $(UNZIP_H) crypt.h version.h consts.h
api$(OBJ): api.c $(UNZIP_H) version.h
zipinfo$(OBJ): zipinfo.c $(UNZIP_H)
funzip$(OBJ): funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h # funzip only
$(CC) -c $(CFLAGS) $(OUT)$@ funzip.c
msdos$(OBJ): msdos/msdos.c $(UNZIP_H) version.h # DOS only
$(CC) -c $(CFLAGS) msdos$(DIRSEP)msdos.c
msdos_$(OBJ): msdos/msdos.c $(UNZIP_H) # DOS unzipsfx
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ msdos$(DIRSEP)msdos.c
crc_gcc$(OBJ): crc_i386.S # 32bit, GNU AS
$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
# NFLAGS are solely used as work-around for optimization bug in IBM C++ Set
crypt$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(CC) -c $(CFLAGS) $(DLLFLAG) $(NFLAGS) $(OUT)$@ crypt.c
cryptf$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CC) -c $(CFLAGS) $(NFLAGS) -DFUNZIP $(OUT)$@ crypt.c
crc32f$(OBJ): crc32.c $(UNZIP_H) zip.h # funzip only
$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ crc32.c
globalsf$(OBJ): globals.c $(UNZIP_H) # funzip only
$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ globals.c
inflatef$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ inflate.c
ttyiof$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
$(CC) -c $(CFLAGS) $(NFLAGS) -DFUNZIP $(OUT)$@ ttyio.c
crc32_$(OBJ): crc32.c $(UNZIP_H) zip.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ crc32.c
crctab_$(OBJ): crctab.c $(UNZIP_H) zip.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ crctab.c
crypt_$(OBJ): crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ crypt.c
extract_$(OBJ): extract.c $(UNZIP_H) crypt.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ extract.c
fileio_$(OBJ): fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ fileio.c
globals_$(OBJ): globals.c $(UNZIP_H) # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ globals.c
inflate_$(OBJ): inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ inflate.c
match_$(OBJ): match.c $(UNZIP_H) # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ match.c
process_$(OBJ): process.c $(UNZIP_H) # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ process.c
ttyio_$(OBJ): ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ ttyio.c
unzipsf_$(OBJ): unzip.c $(UNZIP_H) crypt.h version.h consts.h # unzipsfx only
$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ unzip.c

216
zip/unzip/msdos/makefile.msc Executable file
View File

@ -0,0 +1,216 @@
#------------------------------------------------------------------------------
# Makefile for UnZip 5.2 and later Greg Roelofs and others
# Version: Microsoft C (5.x and later) 31 Mar 96
#------------------------------------------------------------------------------
# Users of MSC 6/7 and NMAKE can use the Unix Makefile (target msc_dos),
# if desired. This makefile works just fine, too, however. OS/2 users
# can cross-compile using os2/makefile.os2 (target mscdos). Note that
# there is possibly a bug in MSC 6 which screws up funzip (goes into
# infinite loop? --this has not been confirmed in over a year...). There
# is definitely a bug (internal compiler error) in MSC 6.00 while com-
# piling explode.c (fixed in 6.0a, 6.0ax, 6.0ax2, 7.*, 8.*).
# GNU make doesn't like the return value from "rem"
#STRIP=rem
STRIP=echo Ignore this line.
# If you don't have LZEXE or PKLITE, get one of them. Then define:
#STRIP=lzexe
# or
#STRIP=pklite
# and remove /e from LDFLAGS.
# This makes a big difference in .exe size (and possibly load time).
# Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
# should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_UNZIP)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 0
# small model for MSC 6.0 and 7.0?
#UNMODEL=S # small model for UnZip and UnZipSFX
# with MSC 5.1 and 8.x, small model exceeds 64k code segment; use medium instead
UNMODEL=M # medium model for UnZip and UnZipSFX
FUMODEL=S # always use small model for fUnZip
# name of Flag to select memory model for assembler compiles, supported
# values are __SMALL__ , __MEDIUM__ , __COMPACT__ , __LARGE__ :
#ASUNMODEL=__SMALL__ # keep in sync with UNMODEL definition !!
# for MSC 5.1 and 8.x use:
ASUNMODEL=__MEDIUM__ # keep in sync with UNMODEL definition !!
ASFUMODEL=__SMALL__ # keep in sync with FUMODEL definition !!
# Uncomment the following three macros to use the optimized CRC32 assembler
# routine in UnZip and UnZipSFX:
ASMFLG = -DASM_CRC
ASMOBJS = crc_i86.obj
ASMOBJF = crc_i86_.obj
ASCPUFLAG = __$(CPU_TYP)86
CC = cl # -Ox does not work for inflate.c
# add -G2(3,4) for 286 (386, 486) and/or -FPi87 for 80x87:
CFLAGS = -nologo -DMSC $(ASMFLG) $(LOC) -G$(CPU_TYP) -Oait -Gs -I.
AS = masm
ASFLAGS = -ml -D$(ASCPUFLAG) $(LOC)
LD = Link # mixed case to disable special handling by GNU Make
# remove /e if you have LZEXE or PKLITE:
LDFLAGS = /nologo/noi/e/st:0x0c00/farcall/packcode
# "/farcall/packcode" are only useful for `large code' memory models
# but should be a "no-op" for small code models.
LDFLAGS2 = ,$*
LDFLAGS2_UN = $(LDFLAGS2);
LDFLAGS2_FU = $(LDFLAGS2);
OBJS1 = unzip.obj crc32.obj crctab.obj crypt.obj envargs.obj explode.obj
OBJS2 = extract.obj fileio.obj globals.obj inflate.obj list.obj match.obj
OBJS3 = process.obj ttyio.obj unreduce.obj unshrink.obj zipinfo.obj
OBJS4 = msdos.obj $(ASMOBJS)
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4)
OBJX1 = unzipsfx.obj crc32.obj crctab.obj crypt.obj extract_.obj fileio.obj
OBJX2 = globals.obj inflate.obj match.obj process_.obj ttyio.obj
OBJX3 = msdos_.obj $(ASMOBJS)
OBJX = $(OBJX1) $(OBJX2) $(OBJX3)
OBJF = funzip.obj crc32_.obj crypt_.obj globals_.obj inflate_.obj ttyio_.obj \
$(ASMOBJF)
UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
default: unzip.exe funzip.exe unzipsfx.exe
#clean:
# As long as the brain damaged old ``Make'' utility from MSC 5.1 and earlier
# (NMAKE from MSC 6.0 + would work !) remains supported, a "clean" target
# cannot be inserted !!
# pattern rules for implicit dependencies:
.asm.obj:
$(AS) $(ASFLAGS) -D$(ASUNMODEL) $<, $@;
.c.obj:
$(CC) -c -A$(UNMODEL) $(CFLAGS) $*.c
# individual dependencies and action rules:
crc_i86.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASUNMODEL) msdos/crc_i86.asm, $@;
crc_i86_.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASFUMODEL) msdos/crc_i86.asm, $@;
crc32.obj: crc32.c $(UNZIP_H) zip.h
crc32_.obj: crc32.c $(UNZIP_H) zip.h
$(CC) -c -A$(FUMODEL) $(CFLAGS) -DFUNZIP -Focrc32_.obj crc32.c
crctab.obj: crctab.c $(UNZIP_H) zip.h
crypt.obj: crypt.c $(UNZIP_H) crypt.h ttyio.h zip.h
crypt_.obj: crypt.c $(UNZIP_H) crypt.h ttyio.h zip.h
$(CC) -c -A$(FUMODEL) $(CFLAGS) -DFUNZIP -Focrypt_.obj crypt.c
envargs.obj: envargs.c $(UNZIP_H)
explode.obj: explode.c $(UNZIP_H)
extract.obj: extract.c $(UNZIP_H) crypt.h
extract_.obj: extract.c $(UNZIP_H) crypt.h
$(CC) -c -A$(UNMODEL) $(CFLAGS) -DSFX -Foextract_.obj extract.c
fileio.obj: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip.obj: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
$(CC) -c -A$(FUMODEL) $(CFLAGS) funzip.c
globals.obj: globals.c $(UNZIP_H)
globals_.obj: globals.c $(UNZIP_H)
$(CC) -c -A$(FUMODEL) $(CFLAGS) -DFUNZIP -Foglobals_.obj globals.c
inflate.obj: inflate.c inflate.h $(UNZIP_H)
inflate_.obj: inflate.c inflate.h $(UNZIP_H) crypt.h
$(CC) -c -A$(FUMODEL) $(CFLAGS) -DFUNZIP -Foinflate_.obj inflate.c
list.obj: list.c $(UNZIP_H)
match.obj: match.c $(UNZIP_H)
msdos.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c -A$(UNMODEL) $(CFLAGS) msdos/msdos.c
msdos_.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c -A$(UNMODEL) $(CFLAGS) -DSFX -Fomsdos_.obj msdos/msdos.c
process.obj: process.c $(UNZIP_H)
process_.obj: process.c $(UNZIP_H)
$(CC) -c -A$(UNMODEL) $(CFLAGS) -DSFX -Foprocess_.obj process.c
ttyio.obj: ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
ttyio_.obj: ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
$(CC) -c -A$(FUMODEL) $(CFLAGS) -DFUNZIP -Fottyio_.obj ttyio.c
unreduce.obj: unreduce.c $(UNZIP_H)
unshrink.obj: unshrink.c $(UNZIP_H)
unzip.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
unzipsfx.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
$(CC) -c -A$(UNMODEL) $(CFLAGS) -DSFX -Founzipsfx.obj unzip.c
zipinfo.obj: zipinfo.c $(UNZIP_H)
# MS make:
# -------
unzip.exe: $(OBJS)
echo $(OBJS1)+ > unzip.rsp
echo $(OBJS2)+ >> unzip.rsp
echo $(OBJS3)+ >> unzip.rsp
echo $(OBJS4) >> unzip.rsp
echo $(LDFLAGS2_UN) >> unzip.rsp
$(LD) $(LDFLAGS) @unzip.rsp
del unzip.rsp
$(STRIP) unzip.exe
unzipsfx.exe: $(OBJX)
echo $(OBJX1)+ > unzipsfx.rsp
echo $(OBJX2)+ >> unzipsfx.rsp
echo $(OBJX3) >> unzipsfx.rsp
echo $(LDFLAGS2_UN) >> unzipsfx.rsp
$(LD) $(LDFLAGS) @unzipsfx.rsp
del unzipsfx.rsp
$(STRIP) unzipsfx.exe
funzip.exe: $(OBJF)
echo $(OBJF) > funzip.rsp
echo $(LDFLAGS2_FU) >> funzip.rsp
$(LD) $(LDFLAGS) @funzip.rsp
del funzip.rsp
$(STRIP) funzip.exe
# better makes which know how to deal with 128-char limit on command line:
# -----------------------------------------------------------------------
#unzip.exe: $(OBJS)
# $(LD) $(LDFLAGS) $(OBJS) $(LDFLAGS2)
# $(STRIP) unzip.exe
#
#unzipsfx.exe: $(OBJX)
# $(LD) $(LDFLAGS) $(OBJX) $(LDFLAGS2)
# $(STRIP) unzipsfx.exe
#
#funzip.exe: $(OBJF)
# $(LD) $(LDFLAGS) $(OBJF) $(LDFLAGS2_FU)
# $(STRIP) funzip.exe

207
zip/unzip/msdos/makefile.tc Executable file
View File

@ -0,0 +1,207 @@
#------------------------------------------------------------------------------
# Makefile for UnZip 5.2 and later Jean-loup Gailly
# Version: Turbo C (edit and use makefile.bc for Turbo C++) 11 Feb 96
#------------------------------------------------------------------------------
# GNU make doesn't like the return value from "rem"
#STRIP=rem
STRIP=echo Ignore this line.
# If you don't have LZEXE or PKLITE, get one of them. Then define:
#STRIP=lzexe
# or
#STRIP=pklite
# This makes a big difference in .exe size (and possibly load time).
# Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
# should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_UNZIP)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 0
# memory model for UnZip (conflicting reports on whether Turbo C can or
# cannot put strings into far memory; for now assume it can and use small
# model *with* ZipInfo enabled...if fails, either define NO_ZIPINFO or
# use large model) [GRR 940712: sigh, no go--inflate fails. Back to
# large model...]
#UNMODEL = s
UNMODEL = l
# funzip is always small-model
FUMODEL = s
# name of Flag to select memory model for assembler compiles, supported
# values are __SMALL__ , __MEDIUM__ , __COMPACT__ , __LARGE__ :
ASUNMODEL=__LARGE__ # keep in sync with UNMODEL definition !!
ASFUMODEL=__SMALL__ # keep in sync with FUMODEL definition !!
# Uncomment the following three macros to use the optimized CRC32 assembler
# routine in UnZip and UnZipSFX:
ASMFLG = -DASM_CRC
ASMOBJS = crc_i86.obj
ASMOBJF = crc_i86_.obj
CC = tcc
AS = tasm
ASCPUFLAG = __$(CPU_TYP)86
ASFLAGS = -ml -m2 -w0 -D$(ASCPUFLAG) $(LOC)
CFLAGS = -O -Z -I. -DFar= $(ASMFLG) $(LOC)
UCFLAGS = -m$(UNMODEL) $(CFLAGS)
ULDFLAGS = -m$(UNMODEL)
FCFLAGS = -m$(FUMODEL) $(CFLAGS)
FLDFLAGS = -m$(FUMODEL)
LDFLAGS2 =
OBJS = unzip.obj crc32.obj crctab.obj crypt.obj envargs.obj explode.obj \
extract.obj fileio.obj globals.obj inflate.obj list.obj match.obj \
process.obj ttyio.obj unreduce.obj unshrink.obj zipinfo.obj \
msdos.obj $(ASMOBJS)
OBJX = unzipsfx.obj crc32.obj crctab.obj crypt.obj extract_.obj fileio.obj \
globals.obj inflate.obj match.obj process_.obj ttyio.obj \
msdos_.obj $(ASMOBJS)
OBJF = funzip.obj crc32_.obj crypt_.obj globals_.obj inflate_.obj ttyio_.obj \
$(ASMOBJF)
UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
default: unzip.exe funzip.exe unzipsfx.exe
clean:
rem Ignore any errors in the following...
del *.ob
del *.obj
del unzip.exe
del funzip.exe
del unzipsfx.exe
.asm.obj:
$(AS) $(ASFLAGS) -D$(ASUNMODEL) $*.asm
.c.obj:
$(CC) -c $(UCFLAGS) $*.c
crc_i86.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASUNMODEL) msdos\crc_i86.asm, $*.obj ;
crc_i86_.obj: msdos/crc_i86.asm
$(AS) $(ASFLAGS) -D$(ASFUMODEL) msdos\crc_i86.asm, $*.obj ;
crc32.obj: crc32.c $(UNZIP_H) zip.h
crc32_.obj: crc32.c $(UNZIP_H) zip.h
$(CC) -c $(FCFLAGS) -DFUNZIP -ocrc32_.obj crc32.c
crctab.obj: crctab.c $(UNZIP_H) zip.h
crypt.obj: crypt.c $(UNZIP_H) crypt.h ttyio.h zip.h
crypt_.obj: crypt.c $(UNZIP_H) crypt.h ttyio.h zip.h
$(CC) -c $(FCFLAGS) -DFUNZIP -ocrypt_.obj crypt.c
envargs.obj: envargs.c $(UNZIP_H)
explode.obj: explode.c $(UNZIP_H)
extract.obj: extract.c $(UNZIP_H) crypt.h
extract_.obj: extract.c $(UNZIP_H) crypt.h
$(CC) -c $(UCFLAGS) -DSFX -oextract_.obj extract.c
fileio.obj: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
funzip.obj: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
$(CC) -c $(FCFLAGS) funzip.c
globals.obj: globals.c $(UNZIP_H)
globals_.obj: globals.c $(UNZIP_H)
$(CC) -c $(FCFLAGS) -DFUNZIP -oglobals_.obj globals.c
inflate.obj: inflate.c inflate.h $(UNZIP_H)
inflate_.obj: inflate.c inflate.h $(UNZIP_H) crypt.h
$(CC) -c $(FCFLAGS) -DFUNZIP -oinflate_.obj inflate.c
list.obj: list.c $(UNZIP_H)
match.obj: match.c $(UNZIP_H)
msdos.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c $(UCFLAGS) msdos/msdos.c
msdos_.obj: msdos/msdos.c $(UNZIP_H)
$(CC) -c $(UCFLAGS) -DSFX -omsdos_.obj msdos/msdos.c
process.obj: process.c $(UNZIP_H)
process_.obj: process.c $(UNZIP_H)
$(CC) -c $(UCFLAGS) -DSFX -oprocess_.obj process.c
ttyio.obj: ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
ttyio_.obj: ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
$(CC) -c $(FCFLAGS) -DFUNZIP -ottyio_.obj ttyio.c
unreduce.obj: unreduce.c $(UNZIP_H)
unshrink.obj: unshrink.c $(UNZIP_H)
unzip.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
unzipsfx.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
$(CC) -c $(UCFLAGS) -DSFX -ounzipsfx.obj unzip.c
zipinfo.obj: zipinfo.c $(UNZIP_H)
# Turbo Make which cannot deal with the MS-DOS 128-byte limit:
# -----------------------------------------------------------
unzip.exe: $(OBJS)
rem Ignore any warnings in the following commands:
del crc32_.ob
ren crc32_.obj *.ob
del crc_i86_.ob
ren crc_i86_.obj *.ob
del crypt_.ob
ren crypt_.obj *.ob
del extract_.ob
ren extract_.obj *.ob
del funzip.ob
ren funzip.obj *.ob
del globals_.ob
ren globals_.obj *.ob
del inflate_.ob
ren inflate_.obj *.ob
del msdos_.ob
ren msdos_.obj *.ob
del process_.ob
ren process_.obj *.ob
del ttyio_.ob
ren ttyio_.obj *.ob
del unzipsfx.ob
ren unzipsfx.obj *.ob
$(CC) $(ULDFLAGS) -eunzip.exe *.obj
ren *.ob *.obj
$(STRIP) unzip.exe
# better makes which know how to deal with 128-char limit on command line:
# -----------------------------------------------------------------------
#unzip.exe: $(OBJS)
# $(CC) $(ULDFLAGS) $(OBJS) $(LDFLAGS2)
# $(STRIP) unzip.exe
# both makes:
# ----------
funzip.exe: $(OBJF)
$(CC) $(FLDFLAGS) $(OBJF) $(LDFLAGS2)
$(STRIP) funzip.exe
unzipsfx.exe: $(OBJX)
$(CC) $(ULDFLAGS) $(OBJX) $(LDFLAGS2)
$(STRIP) unzipsfx.exe

270
zip/unzip/msdos/makefile.wat Executable file
View File

@ -0,0 +1,270 @@
# WMAKE makefile for 16 bit MSDOS or 32 bit DOS extender (PMODE/W or DOS/4GW)
# using Watcom C/C++ v10.5, by Paul Kienitz, last revised 22 Mar 97. Makes
# UnZip.exe, fUnZip.exe, and UnZipSFX.exe.
#
# Invoke from UnZip source dir with "WMAKE -F MSDOS\MAKEFILE.WAT [targets]".
# To make the PMODE/W version use "WMAKE PM=1 ..."
# To make the DOS/4GW version use "WMAKE GW=1 ..." (overrides PM=1)
# Note: specifying PM or GW without NOASM requires that the win32 source
# directory be present, so it can access the 32 bit assembly source.
# PMODE/W is recommended over DOS/4GW for best performance.
# To build with debug info use "WMAKE DEBUG=1 ..."
# To build with no assembly modules use "WMAKE NOASM=1 ..."
# To support unshrinking and unreducing use "WMAKE LAWSUIT=1 ..."
#
# Other options to be fed to the compiler can be specified in an environment
# variable called LOCAL_UNZIP.
variation = $(%LOCAL_UNZIP)
# Stifle annoying "Delete this file?" questions when errors occur:
.ERASE
.EXTENSIONS:
.EXTENSIONS: .exe .obj .obx .c .h .asm
# We maintain multiple sets of object files in different directories so that
# we can compile msdos, dos/4gw, and win32 versions of UnZip without their
# object files interacting. The following var must be a directory name
# ending with a backslash. All object file names must include this macro
# at the beginning, for example "$(O)foo.obj".
!ifdef GW
PM = 1 # both protected mode formats use the same object files
!endif
!ifdef DEBUG
! ifdef PM
O = od32d\ # comment here so backslash won't continue the line
! else
O = od16d\ # ditto
! endif
!else
! ifdef PM
O = ob32d\ # ditto
! else
O = ob16d\ # ditto
! endif
!endif
!ifdef LAWSUIT
cvars = $+$(cvars)$- -DUSE_SMITH_CODE -DUSE_UNSHRINK
avars = $+$(avars)$- -DUSE_SMITH_CODE -DUSE_UNSHRINK
# "$+$(foo)$-" means expand foo as it has been defined up to now; normally,
# this Make defers inner expansion until the outer macro is expanded.
!endif
# The assembly hot-spot code in crc_i[3]86.asm is optional. This section
# controls its usage.
!ifdef NOASM
crcob = $(O)crc32.obj
crcox = $(O)crc32.obx
!else # !NOASM
cvars = $+$(cvars)$- -DASM_CRC
! ifdef PM
crcob = $(O)crc_i386.obj
crcox = $(O)crc_i386.obx
crc_s = win32\crc_i386.asm # requires that the win32 directory be present
! else
crcob = $(O)crc_i86.obj
crcox = $(O)crc_i86.obx
crc_s = msdos\crc_i86.asm
! endif
!endif
# Our object files: OBJA/OBJB is for UnZip, OBJX for UnZipSFX, OBJF for fUnZip:
OBJA1 = $(O)unzip.obj $(crcob) $(O)crctab.obj $(O)crypt.obj $(O)envargs.obj
OBJA = $(OBJA1) $(O)explode.obj $(O)extract.obj $(O)fileio.obj $(O)globals.obj
OBJB2 = $(O)inflate.obj $(O)list.obj $(O)match.obj $(O)process.obj $(O)ttyio.obj
OBJB = $(OBJB2) $(O)unreduce.obj $(O)unshrink.obj $(O)zipinfo.obj $(O)msdos.obj
OBJX2 = $(O)unzip.obx $(crcox) $(O)crctab.obx $(O)crypt.obx $(O)extract.obx
OBJX1 = $(OBJX2) $(O)fileio.obx $(O)globals.obx $(O)inflate.obx $(O)match.obx
OBJX = $(OBJX1) $(O)process.obx $(O)ttyio.obx $(O)msdos.obx
OBJF1 = $(O)funzip.obj $(crcox) $(O)cryptf.obj $(O)globalsf.obj
OBJF = $(OBJF1) $(O)inflatef.obj $(O)ttyio.obx
# fUnZip uses $(crcox) and $(O)ttyio.obx because they're small-model.
# Common header files included by all C sources:
UNZIP_H = unzip.h unzpriv.h globals.h msdos\doscfg.h
# Now we have to pick out the proper compiler and options for it. This gets
# pretty complicated with the PM, GW, DEBUG, and NOASM options...
link = wlink
asm = wasm
!ifdef PM
cc = wcc386
# Use Pentium timings, flat memory, static strings in code, max strictness:
cflags = -bt=DOS -mf -5r -zt -zq -wx -we
aflags = -bt=DOS -mf -3 -zq
cflagx = $(cflags)
aflagx = $(aflags)
! ifdef GW
lflags = sys DOS4G
! else
# THIS REQUIRES THAT PMODEW.EXE BE FINDABLE IN THE COMMAND PATH.
# It does NOT require you to add a pmodew entry to wlink.lnk or wlsystem.lnk.
defaultlibs = libpath %WATCOM%\lib386 libpath %WATCOM%\lib386\dos
lflags = format os2 le op osname='PMODE/W' op stub=pmodew.exe $(defaultlibs)
! endif
!else # plain 16-bit DOS:
cc = wcc
# Use plain 8086 code, medium memory, static strings in code, max strictness:
cflags = -bt=DOS -mm -0 -zt -zq -wx -we
aflags = -bt=DOS -mm -0 -zq
# for UnZipSFX and fUnZip, use the small memory model:
cflagx = -bt=DOS -ms -0 -zt -zq -wx -we
aflagx = -bt=DOS -ms -0 -zq
lflags = sys DOS
!endif # !PM
cvars = $+$(cvars)$- -DMSDOS $(variation)
avars = $+$(avars)$- $(variation)
# Specify optimizations, or a nonoptimized debugging version:
!ifdef DEBUG
cdebug = -od -d2
cdebux = -od -d2
ldebug = d w all op symf
!else
! ifdef PM
cdebug = -s -oilrt -oe=100 -z4 # longword data alignment in 32 bit version
# note: -ol+ does not help. -oa helps slightly but might be dangerous.
! else
cdebug = -s -oilrt -oe=100
! endif
cdebux = -s -oilrs
ldebug = op el
!endif
# How to compile sources:
.c.obx:
$(cc) $(cdebux) $(cflagx) $(cvars) -DSFX $< -fo=$@
.c.obj:
$(cc) $(cdebug) $(cflags) $(cvars) $< -fo=$@
# Here we go! By default, make all targets, except no UnZipSFX for PMODE:
!ifdef PM
all: UnZip.exe fUnZip.exe
!else
all: UnZip.exe fUnZip.exe UnZipSFX.exe
!endif
# Convenient shorthand options for single targets:
u: UnZip.exe .SYMBOLIC
f: fUnZip.exe .SYMBOLIC
x: UnZipSFX.exe .SYMBOLIC
UnZip.exe: $(OBJA) $(OBJB)
set WLK_VA=file {$(OBJA)}
set WLK_VB=file {$(OBJB)}
$(link) $(lflags) $(ldebug) name $@ @WLK_VA @WLK_VB
set WLK_VA=
set WLK_VB=
# We use WLK_VA/WLK_VB to keep the size of each command under 256 chars.
UnZipSFX.exe: $(OBJX)
set WLK_VX=file {$(OBJX)}
$(link) $(lflags) $(ldebug) name $@ @WLK_VX
set WLK_VX=
fUnZip.exe: $(OBJF)
set WLK_VF=file {$(OBJF)}
$(link) $(lflags) $(ldebug) name $@ @WLK_VF
set WLK_VF=
# Source dependencies:
# for UnZip ...
$(O)crc32.obj: crc32.c $(UNZIP_H) zip.h
$(O)crctab.obj: crctab.c $(UNZIP_H) zip.h
$(O)crypt.obj: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(O)envargs.obj: envargs.c $(UNZIP_H)
$(O)explode.obj: explode.c $(UNZIP_H)
$(O)extract.obj: extract.c $(UNZIP_H) crypt.h
$(O)fileio.obj: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
$(O)globals.obj: globals.c $(UNZIP_H)
$(O)inflate.obj: inflate.c inflate.h $(UNZIP_H)
$(O)list.obj: list.c $(UNZIP_H)
$(O)match.obj: match.c $(UNZIP_H)
$(O)process.obj: process.c $(UNZIP_H)
$(O)ttyio.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(O)unreduce.obj: unreduce.c $(UNZIP_H)
$(O)unshrink.obj: unshrink.c $(UNZIP_H)
$(O)unzip.obj: unzip.c $(UNZIP_H) crypt.h version.h consts.h
$(O)zipinfo.obj: zipinfo.c $(UNZIP_H)
# for UnZipSFX ...
$(O)crc32.obx: crc32.c $(UNZIP_H) zip.h
$(O)crctab.obx: crctab.c $(UNZIP_H) zip.h
$(O)crypt.obx: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(O)extract.obx: extract.c $(UNZIP_H) crypt.h
$(O)fileio.obx: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
$(O)globals.obx: globals.c $(UNZIP_H)
$(O)inflate.obx: inflate.c inflate.h $(UNZIP_H)
$(O)match.obx: match.c $(UNZIP_H)
$(O)process.obx: process.c $(UNZIP_H)
$(O)ttyio.obx: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(O)unzip.obx: unzip.c $(UNZIP_H) crypt.h version.h consts.h
# Special case object files:
$(O)msdos.obj: msdos\msdos.c $(UNZIP_H)
$(cc) $(cdebug) $(cflags) $(cvars) msdos\msdos.c -fo=$@
$(O)msdos.obx: msdos\msdos.c $(UNZIP_H)
$(cc) $(cdebux) $(cflagx) $(cvars) -DSFX msdos\msdos.c -fo=$@
!ifndef NOASM
$(crcob): $(crc_s)
$(asm) $(aflags) $(avars) $(crc_s) -fo=$@
$(crcox): $(crc_s)
$(asm) $(aflagx) $(avars) $(crc_s) -fo=$@
!endif
# Variant object files for fUnZip, using $(cflagx):
$(O)funzip.obj: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
$(cc) $(cdebux) $(cflagx) $(cvars) funzip.c -fo=$@
$(O)cryptf.obj: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(cc) $(cdebux) $(cflagx) $(cvars) -DFUNZIP crypt.c -fo=$@
$(O)globalsf.obj: globals.c $(UNZIP_H)
$(cc) $(cdebux) $(cflagx) $(cvars) -DFUNZIP globals.c -fo=$@
$(O)inflatef.obj: inflate.c inflate.h $(UNZIP_H) crypt.h
$(cc) $(cdebux) $(cflagx) $(cvars) -DFUNZIP inflate.c -fo=$@
$(O)ttyiof.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
$(cc) $(cdebux) $(cflagx) $(cvars) -DFUNZIP ttyio.c -fo=$@
# Unwanted file removal:
clean: .SYMBOLIC
!ifdef PM
del ob32d\*.ob?
!else
del ob16d\*.ob?
!endif
cleaner: clean .SYMBOLIC
del UnZip.exe
del fUnZip.exe
del UnZipSFX.exe

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