mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
added zip from Info-ZIP
This commit is contained in:
parent
98c53ae526
commit
4ce5664c4b
363 changed files with 119113 additions and 0 deletions
7
third_party/infozip/README.cosmo
vendored
Normal file
7
third_party/infozip/README.cosmo
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
zip utility from Info-ZIP:
|
||||
|
||||
http://infozip.sourceforge.net/Zip.html
|
||||
|
||||
source code obtained as zip30.tar.gz from:
|
||||
|
||||
https://sourceforge.net/projects/infozip/files/
|
6
third_party/infozip/zip/BUGS
vendored
Normal file
6
third_party/infozip/zip/BUGS
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
- zip sometimes crashes on some versions of NetBSD (0.8, 0.9 and early
|
||||
0.9-current), FreeBSD (<= 1.1) and BSDI (< 1.1) . This is due to a
|
||||
bug in stdio.
|
||||
Upgrading the stdio package in /usr/src/lib/libc/stdio should
|
||||
fix the problem. See *BSD mirrors in src/lib/libc/stdio
|
||||
You must at least replace setvbuf.o in all the libc's with a newer version.
|
17
third_party/infozip/zip/Betas_Readme.txt
vendored
Normal file
17
third_party/infozip/zip/Betas_Readme.txt
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
Betas are works in progress. When a beta has a seemingly stable set
|
||||
of features, we may post a public beta so outside developers can see
|
||||
where the code is going and make contributions or comment.
|
||||
|
||||
A Release Candidate is a beta that we believe has the full feature
|
||||
set that will be released. It's still being tested, and things can
|
||||
still change, but we thought it close when we posted it.
|
||||
|
||||
We take suggestions, bug fixes, and patches at any time, so send them in.
|
||||
|
||||
We make no guarantees as to the state of betas so use at your own risk.
|
||||
All code, including releases, are released under the Info-ZIP license.
|
||||
|
||||
Enjoy!
|
||||
|
||||
Ed Gordon
|
||||
20 April 2008
|
3460
third_party/infozip/zip/CHANGES
vendored
Normal file
3460
third_party/infozip/zip/CHANGES
vendored
Normal file
File diff suppressed because it is too large
Load diff
368
third_party/infozip/zip/INSTALL
vendored
Normal file
368
third_party/infozip/zip/INSTALL
vendored
Normal file
|
@ -0,0 +1,368 @@
|
|||
HOW TO INSTALL ZIP
|
||||
|
||||
Zip is distributed as C source code that can be compiled on a
|
||||
wide range of systems: Unix, VMS, MSDOS, OS/2, NT, Amiga, Atari,
|
||||
BeOS, VM/CMS, ... You will need Unzip 5.0p1 or later (under any
|
||||
system) or PKUNZIP 2.04g or later (under MSDOS) to unpack the
|
||||
distribution file, in this case zip30.zip. But since you read this,
|
||||
you have unpacked it already, or you cheated and got a tar.Z file...
|
||||
|
||||
Note: Zip 3.0 distribution kits (unlike previously distributed
|
||||
Zip 2.x kits) are created with a top-level directory ("zip30") in
|
||||
the archive, making the creating of the zipsrc directory optional.
|
||||
|
||||
Installation on Unix (see below for installation on other systems)
|
||||
|
||||
Let's assume that you start from scratch and have not yet unpacked
|
||||
the sources. First step, then, is to unpack Zip. The following
|
||||
assumes that you have zip30.zip in the current directory.
|
||||
|
||||
For example, to extract to a new zipsrc directory (assuming
|
||||
zip30.zip is in the current directory):
|
||||
|
||||
mkdir zipsrc
|
||||
cd zipsrc
|
||||
cp ../zip30.zip .
|
||||
unzip zip30.zip
|
||||
cd zip30
|
||||
|
||||
To extract in an existing directory, such as /usr/local/src/zip:
|
||||
|
||||
cd /usr/local/src/zip
|
||||
(copy zip30.zip here)
|
||||
unzip zip30.zip
|
||||
cd zip30
|
||||
|
||||
The first extracts all source files and documentation to the
|
||||
directory "zipsrc/zip30". The second places the zip30 directory
|
||||
in the "/usr/local/src/zip" directory. Both then cd in to the
|
||||
zip30 directory where Zip will be built.
|
||||
|
||||
Note: This release now includes the standard encryption code
|
||||
previously in the separate package zcrypt29.zip, but you still
|
||||
can decide whether to activate the crypt code or not. Crypt is
|
||||
enabled by default, but you may disable it by specifying the
|
||||
option -DNO_CRYPT in the LOCAL_ZIP environment variable (or by
|
||||
adding this option to the compilation options in the appropiate
|
||||
makefile). See README.CR for more on crypt.
|
||||
|
||||
You then do:
|
||||
|
||||
make -f unix/Makefile system
|
||||
|
||||
where "system" is one of: generic, generic_gcc,
|
||||
att6300, coherent, cray_v3, minix, sco_x286, xenix, zilog.
|
||||
|
||||
For Unix systems where "cc" is the preferred C compiler command,
|
||||
try
|
||||
|
||||
make -f unix/Makefile generic
|
||||
|
||||
first. If "gcc" is preferred, specify "generic_gcc" instead of
|
||||
"generic". This should work on most systems and automatically
|
||||
selects compilation options based on a set of tests (in
|
||||
unix/configure), including detection of large file support
|
||||
sufficient to enable Zip64 large archive features. If "generic"
|
||||
(or "generic_gcc" if that is used) fail, then one of the special
|
||||
targets given above may work.
|
||||
|
||||
Among other special systems are Cray Unicos, Zilog Zeus and MINIX.
|
||||
|
||||
The optimization settings for many systems should be close, but
|
||||
if you see optimization for your system is not ideal, send in
|
||||
the changes so we can improve it.
|
||||
|
||||
By default, Zip uses the "deflate" compression method. To add
|
||||
the additional optional "bzip2" compression method, see the file
|
||||
bzip2/install.txt. Note that bzip2 support is provided by
|
||||
compiling or linking in the bzip2 library. See the bzip2 site
|
||||
(http://www.bzip.org/) for more on bzip2.
|
||||
|
||||
If you get error messages such as "constant expected" in
|
||||
deflate.c, add -DDYN_ALLOC to CFLAGS in your makefile entry.
|
||||
|
||||
If you have lots of memory, try compiling with -DBIG_MEM. If your
|
||||
system supports mmap(), try compiling with -DMMAP. This generally
|
||||
gives faster compression but uses more memory. See the unix/Makefile
|
||||
entry mmap_gcc for an example.
|
||||
|
||||
If none of these compiles, links, and functions properly on
|
||||
your Unix system, then your system apparently has specific
|
||||
requirements we did not account for. See the file README for how
|
||||
to get help.
|
||||
|
||||
If the appropriate system was selected, then the executables zip,
|
||||
zipnote, zipcloak, and zipsplit will be created. You can copy
|
||||
them to an appropriate directory in the search path using:
|
||||
|
||||
make -f unix/Makefile install
|
||||
|
||||
The defaults are /usr/local/bin for the executables and
|
||||
/usr/local/man/man1 for the manual pages. Change the macros
|
||||
BINDIR and MANDIR in makefile to change these if needed.
|
||||
|
||||
If necessary, add the directory with the Zip executables to your
|
||||
shell's PATH (or "path") variable. (C-shell users may need to
|
||||
use the "rehash" command so csh can find the new command in the
|
||||
path.) You should now be ready to use Zip.
|
||||
|
||||
You can get rid of the now unnecessary source and object files
|
||||
with:
|
||||
|
||||
cd ..
|
||||
rm -r zip30
|
||||
|
||||
This will remove the directory zip30 and its contents created
|
||||
by unzip. You should keep the zip30.zip file around though,
|
||||
in case you need to build it again or want to give it to a
|
||||
colleague.
|
||||
|
||||
You can add the following lines to the file /etc/magic for
|
||||
usage by the 'file' command:
|
||||
|
||||
0 string PK Zip archive
|
||||
>4 byte 011 (at least v0.9 to extract)
|
||||
>4 byte 012 (at least v1.0 to extract)
|
||||
>4 byte 013 (at least v1.1 to extract)
|
||||
>4 byte 024 (at least v2.0 to extract)
|
||||
>4 byte 025 (at least v2.1 to extract)
|
||||
|
||||
|
||||
Installation on other systems
|
||||
|
||||
The steps for installation under VMS, MSDOS, OS/2, NT, Amiga and
|
||||
Atari are similar to the above: first unzip the distribution
|
||||
files into their own directory. The system-dependent files are
|
||||
stored in special subdirectories.
|
||||
|
||||
For all the non-Unix ports which support the creation of "UT" extra
|
||||
fields (these ports contain USE_EF_UT_TIME in the list of optional
|
||||
features displayed with "zip -v"), the timezone environment variable TZ
|
||||
should be set according to the local timezone in order for the -f, -u,
|
||||
-o, and similar options to work correctly. This is not needed for the
|
||||
WIN32 and WinDLL ports, since they get the timezone information from
|
||||
the OS by other means.
|
||||
|
||||
|
||||
MSDOS:
|
||||
|
||||
Do one of:
|
||||
|
||||
make msdos\makefile.msc (Microsoft C 5.1)
|
||||
nmake -f msdos\makefile.msc (Microsoft C 6.0 and newer)
|
||||
make -fmsdos\makefile.bor -DCC_REV=1 (Borland Turbo C++ 1.0)
|
||||
make -fmsdos\makefile.bor (Borland C++ 2.0 and newer)
|
||||
make -fmsdos\makefile.tc (Borland Turbo C 2.0x)
|
||||
make -f msdos/makefile.dj1 (DJGPP v1.12m4)
|
||||
make -f msdos/makefile.dj2 (DJGPP v2.01 and newer)
|
||||
make -f msdos/makefile.emx (gcc/emx 0.9b and newer)
|
||||
make -f os2/makefile.os2 gccdos (gcc/emx 0.9b and newer)
|
||||
wmake -f msdos\makefile.wat (Watcom C 11.x 16-bit)
|
||||
wmake -f msdos\makefile.wat PM=1 (Watcom C 11.x 32-bit, PMODE/W)
|
||||
|
||||
for Microsoft, Borland C++ and Turbo C, Watcom C/C++ and the various
|
||||
free GNU C implementations, respectively. More detailed instructions
|
||||
can be found in the respective makefiles.
|
||||
|
||||
|
||||
WIN32 (Windows NT/2K/XP/2K3 and Windows 95/98/ME):
|
||||
|
||||
Supported compilers are Microsoft Visual C++, Borland C++, Watcom C/C++,
|
||||
and miscellaneous free GNU C implementations (gcc/mingw, CygWin, ...).
|
||||
The makefiles supplied in the win32/ subdirectory contain further
|
||||
information.
|
||||
|
||||
|
||||
Windows DLL (WIN32):
|
||||
|
||||
Supported environments are Visual C++ (32-bit only, 5.x and newer).
|
||||
For instructions how to build the DLLs and where find the makefiles,
|
||||
look into windll/contents.
|
||||
|
||||
|
||||
OS/2:
|
||||
|
||||
Type
|
||||
|
||||
{make} -f os2/makefile.os2
|
||||
|
||||
to get a list of supported targets/compiling environments.
|
||||
(replace "{make}" with the name of your OS/2 make utility.)
|
||||
|
||||
To initiate the actual compiling process, you have to specify
|
||||
a system target:
|
||||
|
||||
{make} -f os2/makefile.os2 {system}
|
||||
|
||||
An example: type
|
||||
|
||||
nmake -f os2/makefile.os2 msc
|
||||
|
||||
for Microsoft C 6.00.
|
||||
|
||||
|
||||
VMS (OpenVMS):
|
||||
|
||||
The most complete information on building and installing Zip on VMS
|
||||
is in [.vms]install_vms.txt. Optimists in a hurry may wish to try
|
||||
commands like these:
|
||||
|
||||
@ [.VMS]BUILD_ZIP.COM
|
||||
or:
|
||||
MMS /DESCRIP = [.VMS]DESCRIP.MMS CLEAN ! Or MMK ...
|
||||
MMS /DESCRIP = [.VMS]DESCRIP.MMS ! Or MMK ...
|
||||
|
||||
When the executables have been created (or located if already installed),
|
||||
most users define foreign command symbols for the Zip executables, like
|
||||
this:
|
||||
|
||||
ZIP :== $ dev:[dir]ZIP.EXE ! UNIX-like command line.
|
||||
or:
|
||||
ZIP :== $ dev:[dir]ZIP_CLI.EXE ! VMS-like command line.
|
||||
|
||||
Such symbol definitions are often added to a user's
|
||||
SYS$LOGIN:LOGIN.COM procedure, or to a common, site-specific
|
||||
procedure, like SYS$MANAGER:SYLOGIN.COM.
|
||||
|
||||
Additional installation options are described in install_vms.txt.
|
||||
|
||||
The builders create help text files, ZIP.HLP and ZIP_CLI.HLP. Also
|
||||
see install_vms.txt for how to create the help libraries.
|
||||
|
||||
|
||||
Mac OS:
|
||||
|
||||
Mac OS X is part of the Unix port, so use the Unix installation above.
|
||||
|
||||
Mac OS before Mac OS X use the Mac OS port, though little testing has
|
||||
been done for that port recently. See macos/README.TXT for more on
|
||||
this port.
|
||||
|
||||
|
||||
Compiler Flags
|
||||
|
||||
Zip should compile fine out of the box for your port. In particular,
|
||||
for Unix the command
|
||||
make -f unix/Makefile generic
|
||||
should automatically detect the features available on your system and
|
||||
set the flags appropriately. In some cases, however, you may need to
|
||||
set one or more compiler flags yourself to get Zip to compile or to
|
||||
add features you want or remove features that cause trouble for your
|
||||
port. Below are the more common compiler macros you can set.
|
||||
|
||||
LARGE_FILE_SUPPORT
|
||||
Tell Zip that the OS supports large files (generally files larger
|
||||
than 4 GB). Zip will try to compile in the large file calls
|
||||
(typically 64-bit) for the OS instead of using the standard
|
||||
(typically 32-bit) file calls. On Unix Zip tries to switch over to
|
||||
the 64-bit file environment. If setting this flag causes errors
|
||||
or Zip still can't handle large files on that port, then probably
|
||||
either Zip doesn't have the code to support large files on your OS
|
||||
(write a patch and send it in to us) or your OS doesn't support large
|
||||
files.
|
||||
|
||||
Note that the flag ZIP64_SUPPORT must also be set to create archives
|
||||
with large files.
|
||||
|
||||
This flag should be set automatically on Unix, Win32, and some
|
||||
other ports. Setting NO_LARGE_FILE_SUPPORT turns this flag off.
|
||||
|
||||
ZIP64_SUPPORT
|
||||
Enable the Zip64 code in Zip that supports the Zip64 extensions noted
|
||||
in the PKWare AppNote. These extensions allow storing files larger
|
||||
than 4 GB in archives and the creating of archives larger than 4 GB.
|
||||
They also allow storing more than 64K files in an archive. Currently
|
||||
Zip does not handle archives of PKZip version 4.5 or later unless
|
||||
this flag is set.
|
||||
|
||||
To enable large file support in Zip, you generally need to set both
|
||||
LARGE_FILE_SUPPORT (to read and write large files) and ZIP64_SUPPORT
|
||||
(to store them in and read them from archives). Files larger than
|
||||
4 GB may be invisible to Zip (directory scans don't see them) if
|
||||
LARGE_FILE_SUPPORT is not enabled.
|
||||
|
||||
Keeping LARGE_FILE_SUPPORT and ZIP64_SUPPORT separate allows easier
|
||||
debugging of these features. When testing large file support on an
|
||||
OS, first set just LARGE_FILE_SUPPORT to test the file calls (all
|
||||
should compile and work as before with small files), then turn on
|
||||
ZIP64_SUPPORT to let Zip recognize and handle large files.
|
||||
|
||||
This flag should be set automatically on most ports if
|
||||
LARGE_FILE_SUPPORT is set. Setting NO_ZIP64_SUPPORT turns this flag
|
||||
off.
|
||||
|
||||
UNICODE_SUPPORT
|
||||
Enable storing and using UTF-8 paths. These paths are stored in
|
||||
a backward-compatible way so that archives with UTF-8 paths still
|
||||
work on zips and unzips that don't support Unicode. This support
|
||||
follows the recent additions to the PKWare AppNote for Unicode
|
||||
support, except that Unicode comments on systems where UTF-8 is
|
||||
not the current character set is not implemented in this release.
|
||||
|
||||
On some ports UNICODE_SUPPORT is set automatically if wide characters
|
||||
are supported. Setting NO_UNICODE_SUPPORT turns off this flag.
|
||||
|
||||
USE_EF_UT_TIME
|
||||
Enables storing UT time in an extra field. This becomes useful
|
||||
for ports that normally store file times as local time, resulting
|
||||
in problems when files are moved across time zones and when
|
||||
there are daylight savings time changes. Zip and UnZip will
|
||||
automatically correct for time zone changes when UT time is stored.
|
||||
|
||||
This is usually set by default. Use NO_EF_UT_TIME to turn this off.
|
||||
|
||||
NTSD_EAS (Win32 only)
|
||||
Enable storing Windows NT file security descriptors. This allows
|
||||
restoring the descriptors (file ACL's, etc.).
|
||||
|
||||
This is on by default for Win32. Use NO_NTSD_EAS to turn this off.
|
||||
|
||||
BZIP2_SUPPORT
|
||||
Enable compressing zip entries using the bzip2 library. You must get
|
||||
the bzip2 library from somewhere else as we only provide a way to
|
||||
compile or link the library in and compress files using bzip2. Enables
|
||||
a new compression method, bzip2, that can be used instead of the default
|
||||
Zip compression method deflate.
|
||||
|
||||
This flag is set on Unix, including Mac OS X, when compiling using
|
||||
generic if the bzip2 library is found. Set on Win32 if the bzip2
|
||||
projects are used. See the VMS documentation for when VMS sets this
|
||||
flag. Setting NO_BZIP2_SUPPORT turns this off.
|
||||
|
||||
See bzip2/install.txt for more on installing bzip2 support.
|
||||
|
||||
WIN32_OEM (Win32 only)
|
||||
Enable saving paths on Win32 in the OEM character set. Zip has stored
|
||||
paths using the standard ANSI local character set, but other zips have
|
||||
used the OEM character set on MSDOS and Win32. This flag should make
|
||||
Zip more compatible with other DOS and Win32 zips and unzips. It also
|
||||
enables the translation of OEM paths in DOS archives to ANSI and should
|
||||
eliminate some problems with funny characters showing up in path names.
|
||||
|
||||
If Unicode is enabled and used, Unicode paths generally override
|
||||
local paths using OEM character sets.
|
||||
|
||||
This flag is on by default on most Win32 ports. Some ports apparently
|
||||
have problems with OEM conversions. If your port or compiler does
|
||||
funny things with file names, you may want to turn this off. Defining
|
||||
NO_WIN32_OEM turns this flag off.
|
||||
|
||||
NO_STREAMING_STORE
|
||||
Because storing zip archives inside a zip entry adds "false" signatures
|
||||
and this causes problems when using data descriptors if the archive
|
||||
needs fixing, this option is provided to force deflating when streaming.
|
||||
This version of Zip includes an advanced algorithm for correctly finding
|
||||
these signatures, but if an archive is "broke", there is no telling
|
||||
what's where. This is only a problem if an archive becomes broke for
|
||||
some reason, but to be safe define this.
|
||||
|
||||
ALLOW_REGEX
|
||||
For MSDOS and Windows, now "[list]" wildcard matching (where any
|
||||
character between [ and ] can be used to match the character at that
|
||||
position) is turned off unless the new -RE option is used. Defining
|
||||
this flag forces "[list]" matching to be always on as in previous
|
||||
releases.
|
||||
|
||||
|
||||
For command help on any of the zip* utilities, simply enter
|
||||
the name with no arguments.
|
60
third_party/infozip/zip/LICENSE
vendored
Normal file
60
third_party/infozip/zip/LICENSE
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
This is version 2007-Mar-4 of the Info-ZIP license.
|
||||
The definitive version of this document should be available at
|
||||
ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
|
||||
a copy at http://www.info-zip.org/pub/infozip/license.html.
|
||||
|
||||
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
For the purposes of this copyright and license, "Info-ZIP" is defined as
|
||||
the following set of individuals:
|
||||
|
||||
Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
|
||||
Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
|
||||
Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
|
||||
David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
|
||||
Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
|
||||
Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
|
||||
Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
|
||||
Rich Wales, Mike White.
|
||||
|
||||
This software is provided "as is," without warranty of any kind, express
|
||||
or implied. In no event shall Info-ZIP or its contributors be held liable
|
||||
for any direct, indirect, incidental, special or consequential damages
|
||||
arising out of the use of or inability to use this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the above disclaimer and the following restrictions:
|
||||
|
||||
1. Redistributions of source code (in whole or in part) must retain
|
||||
the above copyright notice, definition, disclaimer, and this list
|
||||
of conditions.
|
||||
|
||||
2. Redistributions in binary form (compiled executables and libraries)
|
||||
must reproduce the above copyright notice, definition, disclaimer,
|
||||
and this list of conditions in documentation and/or other materials
|
||||
provided with the distribution. The sole exception to this condition
|
||||
is redistribution of a standard UnZipSFX binary (including SFXWiz) as
|
||||
part of a self-extracting archive; that is permitted without inclusion
|
||||
of this license, as long as the normal SFX banner has not been removed
|
||||
from the binary or disabled.
|
||||
|
||||
3. Altered versions--including, but not limited to, ports to new operating
|
||||
systems, existing ports with new graphical interfaces, versions with
|
||||
modified or added functionality, and dynamic, shared, or static library
|
||||
versions not from Info-ZIP--must be plainly marked as such and must not
|
||||
be misrepresented as being the original source or, if binaries,
|
||||
compiled from the original source. Such altered versions also must not
|
||||
be misrepresented as being Info-ZIP releases--including, but not
|
||||
limited to, labeling of the altered versions with the names "Info-ZIP"
|
||||
(or any variation thereof, including, but not limited to, different
|
||||
capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
|
||||
explicit permission of Info-ZIP. Such altered versions are further
|
||||
prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
|
||||
e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
|
||||
will provide support for the altered versions.
|
||||
|
||||
4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
|
||||
"UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
|
||||
own source and binary releases.
|
234
third_party/infozip/zip/README
vendored
Normal file
234
third_party/infozip/zip/README
vendored
Normal file
|
@ -0,0 +1,234 @@
|
|||
Zip 3.0 is the first Zip update adding large file support. For now Zip 2.3x
|
||||
remains available and supported, but users should switch to this new release.
|
||||
|
||||
Testing for Zip 3.0 has focused mainly on Unix, VMS, Max OS X, and Win32,
|
||||
and some other ports may not be fully supported yet. If you find your
|
||||
favorite port is broke, send us the details or, better, send bug fixes. It's
|
||||
possible that support for some older ports may be dropped in the future.
|
||||
|
||||
|
||||
|
||||
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE (the contents of which are also included
|
||||
in unzip.h, zip.h and wiz.h) for terms of use. If, for some reason, all
|
||||
of these files are missing, the Info-ZIP license also may be found at:
|
||||
ftp://ftp.info-zip.org/pub/infozip/license.html and
|
||||
http://www.info-zip.org/pub/infozip/license.html.
|
||||
|
||||
|
||||
Zip 3.0 is a compression and file packaging utility. It is compatible with
|
||||
PKZIP 2.04g (Phil Katz ZIP) for MSDOS systems. There is a companion to zip
|
||||
called unzip (of course) which you should be able to find in the same place
|
||||
you got zip. See the file 'WHERE' for details on ftp sites and mail
|
||||
servers.
|
||||
|
||||
So far zip has been ported to a wide array of Unix and other mainframes,
|
||||
minis, and micros including VMS, OS/2, Minix, MSDOS, Windows, Atari, Amiga,
|
||||
BeOS and VM/CMS. Although highly compatible with PKware's PKZIP and PKUNZIP
|
||||
utilities of MSDOS fame, our primary objective has been one of portability
|
||||
and other-than-MSDOS functionality. Features not found in the PKWare version
|
||||
include creation of zip files in a pipe or on a device; VMS, BeOS and OS/2
|
||||
extended file attributes; conversion from Unix to MSDOS text file format; and,
|
||||
of course, the ability to run on most of your favorite operating systems. And
|
||||
it's free.
|
||||
|
||||
See the file zip30.ann for a summary of new features in Zip 3.0 and WhatsNew
|
||||
for the detailed list of new features and changes since Zip 2.32. The file
|
||||
CHANGES details all day-to-day changes during development.
|
||||
|
||||
Notes:
|
||||
|
||||
Multi-volume support. This version does not support multi-volume spanned
|
||||
archives as in pkzip 2.04g, and there is no intention at this point to support
|
||||
spanned archives, but Zip 3.0 supports split archives. A split archive is an
|
||||
archive split into a set of files, each file a piece of the archive and each
|
||||
file using an extension, such as .z02 as in the file name archive.z02, that
|
||||
provides the order of the splits. In contrast, a spanned archive is the
|
||||
original multi-floppy archive supported by pkzip 2.0g where the split order
|
||||
is contained in the volume labels. The contents of split and spanned archives
|
||||
are mostly identical and there is a simple procedure to convert between the
|
||||
formats. Many current unzips now support split archives.
|
||||
|
||||
Zip64 support. This version supports Zip64 archives as described in the
|
||||
PKWare AppNote. These archives use additional fields to support archives
|
||||
greater than 2 GB and files in archives over the 2 GB previous limit (4 GB
|
||||
on some ports). The Zip64 format also allows more than 64k entries in an
|
||||
archive. Support by the OS for files larger than 4 GB is needed for Zip to
|
||||
create and read large files and archives. On Unix, Win32, and some other
|
||||
ports, large file and Zip64 support is automatically checked for and
|
||||
compiled in if available. Use of Zip64 by Zip is automatic and to maximize
|
||||
backward compatibility the Zip64 fields will only be used if needed. A
|
||||
Zip64 archive requires a pkzip 4.5 compatible unzip, such as UnZip 6.0.
|
||||
|
||||
Unicode support. This version has initial Unicode support. This allows
|
||||
paths and names of files in other character sets to be accurately recreated
|
||||
on OS that have sufficient character set support. On Win32, if wide
|
||||
character calls are supported (not Win 9x unless Unicode support has been
|
||||
added) all files (including paths with illegal characters in the current
|
||||
character set) should now be readable by zip. Unicode support is provided
|
||||
using a new set of UTF-8 path and comment extra fields and a new UTF-8 bit
|
||||
for flagging when the current character set is already UTF-8. Zip 3.0
|
||||
maintains backward compatibility with older archives and is mostly compliant
|
||||
with the new Unicode additions in the latest PKWare AppNote. The exception
|
||||
is UTF-8 comments, which are not supported if UTF-8 is not the native
|
||||
character set, but should be fully implemented in Zip 3.1.
|
||||
|
||||
16-bit OS support. Though Zip 3.0 is designed to support the latest zip
|
||||
standards and modern OS, some effort has been made to maintain support
|
||||
for older and smaller systems. If you find Zip 3.0 does not fit on or
|
||||
otherwise does not work well on a particular OS, send in the details and
|
||||
we might be able to help.
|
||||
|
||||
Compression methods. In addition to the standard store and deflate methods,
|
||||
Zip now can use the bzip2 compression format using the bzip2 library. Though
|
||||
bzip2 compression generally takes longer, in many cases using bzip2 results
|
||||
in much better compression. However, many unzips may not yet support
|
||||
bzip2 compressed entries in archives, so test your unzip first before using
|
||||
bzip2 compression.
|
||||
|
||||
Installation. Please read the file INSTALL for information on how to compile
|
||||
and install zip, zipsplit, zipcloak, and zipnote and please read the manual
|
||||
pages ZIP.txt, ZIPSPLIT.txt, ZIPCLOAK.txt, and ZIPNOTE.txt for information on
|
||||
how to use them. Also, if you are using MSDOS or Windows, note that text
|
||||
files in the distribution are generally in Unix line end format (LF only)
|
||||
and Windows and DOS users will need to either convert the files as needed to
|
||||
DOS line ends (CR LF) or extract the distribution contents using unzip -a.
|
||||
|
||||
Utilities. At this point zipsplit, zipcloak, and zipnote should work with
|
||||
large files, but they currently do not handle split archives. A work around
|
||||
is to use zip to convert a split archive to a single file archive and then use
|
||||
the utilities on that archive.
|
||||
|
||||
Encryption. This version supports standard zip encryption. Until recently
|
||||
the encryption code was distributed separately because of the US export
|
||||
regulations but now is part of the main distribution. See crypt.c for
|
||||
details. Decryption can be made with unzip 5.0p1 or later, or with zipcloak.
|
||||
|
||||
Bug reports. All bug reports or patches should go to zip-bugs via the web
|
||||
site contact form at http://www.info-zip.org/zip-bug.html (we have discontinued
|
||||
the old email address zip-bugs@lists.wku.edu because of too much spam lately)
|
||||
and suggestions for new features can be submitted there also (although we don't
|
||||
promise to use all of them). We also are on SourceForge at
|
||||
http://sourceforge.net/projects/infozip/ and now automatically get Bug Reports
|
||||
and Feature Requests submitted there. In addition, a new Info-ZIP discussion
|
||||
forum is available as well. See below. Though bug reports can be posted there,
|
||||
we don't have automatic monitoring of all postings set up yet so you may want
|
||||
to use the web form or SoureForge for a quicker response. A good approach may
|
||||
be to post the details on the forum so others can benefit from the posting,
|
||||
then use the web reply form to let us know you did that if you don't get a
|
||||
reply in a reasonable time.
|
||||
|
||||
Ports. If you're considering a port, please check in with zip-bugs FIRST,
|
||||
since the code is constantly being updated behind the scenes. We'll
|
||||
arrange to give you access to the latest source.
|
||||
|
||||
Discussion group. If you'd like to keep up to date with our Zip (and companion
|
||||
UnZip utility) development, join the ranks of BETA testers, add your own
|
||||
thoughts and contributions, etc., check out the new discussion forum. This is
|
||||
the latest offering, after the various Info-ZIP mailing-lists on
|
||||
mxserver@lists.wku.edu (courtesy of Hunter Goatley) were no longer available
|
||||
and the temporary QuickTopic discussion group for Info-ZIP issues at
|
||||
http://www.quicktopic.com/27/H/V6ZQZ54uKNL died a horrible death due to large
|
||||
amounts of spam. The new discussion forum is now available at
|
||||
http://www.info-zip.org/board/board.pl (thanks again to Hunter Goatley) and
|
||||
can be used to discuss issues, request features, and is one place new betas
|
||||
and releases are announced. It also is a place to post bug reports, and
|
||||
patches can be submitted as attachments. However, we don't yet get
|
||||
automatic notification of all postings there so try one of the other methods
|
||||
if you don't get a response. You can also post Bug Reports and Feature
|
||||
Requests at Source Forge. However, the web site contact form remains
|
||||
available if you would rather not post on the public forums.
|
||||
|
||||
Frequently asked questions on zip and unzip:
|
||||
|
||||
Q. When unzipping I get an error message about "compression method 8".
|
||||
|
||||
A. This is standard deflate, which has been around for awhile. Please
|
||||
get a current version of unzip. See the file 'WHERE' for details.
|
||||
|
||||
|
||||
Q. How about "compression method 12"?
|
||||
|
||||
A. Compression method 12 is bzip2 and requires a relatively modern unzip.
|
||||
Please get the latest version of unzip.
|
||||
|
||||
|
||||
Q. I can't extract this zip file that I just downloaded. I get
|
||||
"zipfile is part of multi-disk archive" or some other message.
|
||||
|
||||
A. Please make sure that you made the transfer in binary mode. Check
|
||||
in particular that your copy has exactly the same size as the original.
|
||||
Note that the above message also may actually mean you have only part
|
||||
of a multi-part archive. Also note that UnZip 5.x does not and UnZip 6.0
|
||||
probably won't have multi-disk (split) archive support. A work around
|
||||
is to use Zip 3.0 to convert the split archive to a single-file archive
|
||||
then use UnZip on that archive. As a last result, if there's something
|
||||
readable in what you have, zip -FF should be able to recover it.
|
||||
|
||||
|
||||
Q. When running unzip, I get a message about "End-of-central-directory
|
||||
signature not found".
|
||||
|
||||
A. This usually means that your zip archive is damaged, or that you
|
||||
have an uncompressed file with the same name in the same directory.
|
||||
In the first case, it makes more sense to contact the person you
|
||||
obtained the zip file from rather than the Info-ZIP software
|
||||
developers, and to make sure that your copy is strictly identical to
|
||||
the original. In the second case, use "unzip zipfile.zip" instead
|
||||
of "unzip zipfile", to let unzip know which file is the zip archive
|
||||
you want to extract.
|
||||
|
||||
|
||||
Q. Why doesn't zip do <something> just like PKZIP does?
|
||||
|
||||
A. Zip is not a PKZIP clone and is not intended to be one. In some
|
||||
cases we feel PKZIP does not do the right thing (e.g., not
|
||||
including pathnames by default); in some cases the operating system
|
||||
itself is responsible (e.g., under Unix it is the shell which
|
||||
expands wildcards, not zip). Info-ZIP's and PKWARE's zipfiles
|
||||
are interchangeable, not the programs.
|
||||
|
||||
For example, if you are used to the following PKZIP command:
|
||||
pkzip -rP foo *.c
|
||||
you must use instead on Unix:
|
||||
zip -R foo "*.c"
|
||||
(the quotes are needed to let the shell know that it should
|
||||
not expand the *.c argument but instead pass it on to the program,
|
||||
but are not needed on ports that do not expand file paths like
|
||||
MSDOS)
|
||||
|
||||
|
||||
Q. Can I distribute zip and unzip sources and/or executables?
|
||||
|
||||
A. You may redistribute the latest official distributions without any
|
||||
modification, without even asking us for permission. You can charge
|
||||
for the cost of the media (CDROM, diskettes, etc...) and a small copying
|
||||
fee. If you want to distribute modified versions please contact us at
|
||||
www.Info-ZIP.org first. You must not distribute beta versions.
|
||||
The latest official distributions are always on ftp.Info-ZIP.org in
|
||||
directory /pub/infozip and subdirectories and at SourceForge.
|
||||
|
||||
|
||||
Q. Can I use the executables of zip and unzip to distribute my software?
|
||||
|
||||
A. Yes, so long as it is made clear in the product documentation that
|
||||
zip or 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 inclusion with the commercial product. See the
|
||||
Info-ZIP license for more. 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
|
||||
freely distributed under the Info-ZIP license and can be obtained as
|
||||
source code or executables from various anonymous-ftp sites,
|
||||
including ftp://ftp.info-zip.org/pub/infozip.
|
||||
|
||||
|
||||
Q. Can I use the source code of zip and unzip in my commercial application?
|
||||
|
||||
A. Yes, as long as the conditions in the Info-ZIP license are met. We
|
||||
recommend you include in your product documentation an acknowledgment
|
||||
and note that the original compression sources are available at
|
||||
www.Info-ZIP.org. If you have special requirements contact us.
|
119
third_party/infozip/zip/README.CR
vendored
Normal file
119
third_party/infozip/zip/README.CR
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
_____________________________________________________________________________
|
||||
|
||||
This is Info-ZIP's README.CR for zcrypt29.zip, last updated 27 March 2008.
|
||||
_____________________________________________________________________________
|
||||
|
||||
|
||||
The files described below contain the encryption/decryption code for Zip 2.31,
|
||||
UnZip 5.52, and WiZ 5.02 (and later). These files are included in the main
|
||||
source distributions for all of these now, but the encryption patch is still
|
||||
available for earlier versions of these. This file both describes the history
|
||||
of the encryption package and notes the current conditions for use. Check
|
||||
the comments at the top of crypt.c and crypt.h for additional information.
|
||||
|
||||
As of version 2.9, this encryption source code is copyrighted by Info-ZIP;
|
||||
see the enclosed LICENSE file for details. Older versions remain in the pub-
|
||||
lic domain. Zcrypt was originally written in Europe and, as of April 2000,
|
||||
can be freely distributed from the US as well as other countries.
|
||||
|
||||
(The ability to export from the US is new and is due to a change in the Bureau
|
||||
of Export Administration's regulations, as published in Volume 65, Number
|
||||
10, of the Federal Register [14 January 2000]. Info-ZIP filed the required
|
||||
notification via e-mail on 9 April 2000; see the USexport.msg file in this
|
||||
archive. However, as of June 2002, it can now be freely distributed in both
|
||||
source and object forms from any country, including the USA under License
|
||||
Exception TSU of the U.S. Export Administration Regulations (section 740.13(e))
|
||||
of 6 June 2002.)
|
||||
|
||||
LIKE ANYTHING ELSE THAT IS FREE, ZIP, UNZIP AND THEIR ASSOCIATED
|
||||
UTILITIES ARE PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND,
|
||||
EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE AUTHORS BE LIABLE
|
||||
FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
|
||||
The encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file is distributed with the PKZIP program (even in the version without
|
||||
encryption capabilities). Note that the encryption will probably resist
|
||||
attacks by amateurs if the password is well chosen and long enough (at
|
||||
least 8 characters) but it will probably not resist attacks by experts.
|
||||
Paul Kocher has made available information concerning a known-plaintext
|
||||
attack for the PKWARE encryption scheme; see http://www.cryptography.com/
|
||||
for details.) Short passwords consisting of lowercase letters only can be
|
||||
recovered in a few hours on any workstation. But for casual cryptography
|
||||
designed to keep your mother from reading your mail, it's OK.
|
||||
|
||||
For more serious encryption, check into PGP (Pretty Good Privacy), a
|
||||
public-key-based encryption system available from various Internet sites.
|
||||
PGP has Zip and UnZip built into it. The most recent version at the time
|
||||
this was originally written was 6.5, although older versions were still
|
||||
widespread. At the time of this writing there are now GPG, PGP Universal
|
||||
2.0, and various others based on OpenPGP.
|
||||
|
||||
We are looking at adding AES strong encryption to future versions of Zip and
|
||||
UnZip.
|
||||
|
||||
Zip 2.3x and UnZip 5.5x and later are compatible with PKZIP 2.04g. (Thanks
|
||||
to Phil Katz for accepting our suggested minor changes to the zipfile format.)
|
||||
|
||||
IMPORTANT NOTE:
|
||||
|
||||
Zip archives produced by Zip 2.0 or later must not be *updated* by
|
||||
Zip 1.1 or PKZIP 1.10 or PKZIP 1.93a, if they contain encrypted members
|
||||
or if they have been produced in a pipe or on a non-seekable device.
|
||||
The old versions of Zip or PKZIP would destroy the zip structure. The
|
||||
old versions can list the contents of the zipfile but cannot extract
|
||||
it anyway (because of the new compression algorithm). If you do not
|
||||
use encryption and compress regular disk files, you need not worry about
|
||||
this problem.
|
||||
|
||||
|
||||
Contents that were distributed and now are part of the main source files:
|
||||
|
||||
file what it is
|
||||
---- ----------
|
||||
README.CR this file
|
||||
LICENSE Info-ZIP license (terms of reuse and redistribution)
|
||||
USexport.msg export notice sent to US Bureau of Export Administration
|
||||
WHERE where Zip/UnZip/WiZ and related utilities can be found
|
||||
crypt.c code for encryption and decryption
|
||||
crypt.h code for encryption and decryption
|
||||
file_id.diz description file for some BBSes
|
||||
|
||||
Most all of the files are in Unix (LF only) format. On MSDOS systems, you
|
||||
can use the -a option of UnZip to convert the source files to CRLF
|
||||
format. This is only necessary if you wish to edit the files -- they
|
||||
will compile as is with Microsoft C and Turbo/Borland C++ 1.0 or
|
||||
later. However, you will have to convert the files (using "unzip -a")
|
||||
to the CRLF format to compile with the older Turbo C 1.0 or 2.0. You
|
||||
should be able to find Zip and UnZip in the same place you found this
|
||||
(see ftp://ftp.info-zip.org/pub/infozip/Info-ZIP.html or the file
|
||||
"WHERE" for details).
|
||||
|
||||
Current releases all have encryption built in. To update previous versions
|
||||
using the zcrypt sources:
|
||||
|
||||
(1) Get the main sources (e.g., Zip 2.3) and unpack into a working
|
||||
directory, as usual.
|
||||
|
||||
(2) Overwrite the dummy crypt.c and crypt.h from the main sources with
|
||||
the versions from this package. If you want to overwrite directly
|
||||
out of the zcrypt29 archive, do not use UnZip's freshen/updating
|
||||
option; the dummy files may be newer than the real sources in
|
||||
zcrypt29. ("unzip -o zcrypt29 -d /your/working/dir" will do the
|
||||
Right Thing in most cases, although it may overwrite a newer WHERE
|
||||
file under some circumstances.)
|
||||
|
||||
(3) Read the main INSTALL document and compile normally! No makefile
|
||||
changes are necessary on account of the zcrypt sources. You can
|
||||
check that the version you just compiled has encryption or decryption
|
||||
support enabled by typing "zip -v" or "unzip -v" and verifying that
|
||||
the last "special compilation option" says encryption or decryption
|
||||
is included.
|
||||
|
||||
Encryption enables new "-e" and "-P password" options in Zip, and a new
|
||||
"-P password" option in UnZip--see the normal Zip and UnZip documentation
|
||||
for details. (Note that passing a plaintext password on the command line
|
||||
is potentially much more insecure than being prompted for it interactively,
|
||||
which is the default for UnZip and for Zip with "-e". Also note that the
|
||||
interactive method allows UnZip to deal with archives that use different
|
||||
passwords for different files.)
|
142
third_party/infozip/zip/TODO
vendored
Normal file
142
third_party/infozip/zip/TODO
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
Todo list (last updated 12 June 2008).
|
||||
|
||||
Features for next official version:
|
||||
|
||||
- Extended attributes for Windows, Linux, and Mac OS X.
|
||||
- Win32 ACL rewrite to use backup api to create new and more useful extra
|
||||
field (need unzip support) (Kai).
|
||||
- Allow -d@ to read in a list of names to delete (11/17/2005).
|
||||
- AES encryption (3/19/05).
|
||||
|
||||
Features that may make the next release:
|
||||
|
||||
- Allow reading in list of files using @filename.
|
||||
- When -R, -x, or -i pattern ends in a directory add / to the end
|
||||
(11/5/2004 Nehal).
|
||||
- Decide if -R, -i and -x should use external rather than internal patterns.
|
||||
Also, change pattern matching to not do ex2in() and then in2ex() if
|
||||
appropriate. (12/26/2005 SMS)
|
||||
- Though Unicode paths have been implemented and tested, Unicode comments
|
||||
are not yet supported (except for comments on UTF-8 native systems which
|
||||
are supported).
|
||||
- Verbose mode -v may still need work.
|
||||
|
||||
- Add C# example for Zip 3.0 (need to be converted to new DLLs) - original
|
||||
C# example added with note.
|
||||
- Path Prefix maybe, so entries added to an archive can have a directory
|
||||
path string prepended to each path so can zip multiple drives and avoid
|
||||
name conflicts (4/17/2006).
|
||||
- UNC paths like \\server\path (4/26/2005).
|
||||
- Support for other languages maybe.
|
||||
|
||||
- Add About page option similar to -h2 and -v but lists Info-ZIP
|
||||
information (could be -sa) (4/29/2006).
|
||||
- Update utilities ZipSplit, ZipNote, and ZipCloak to handle split archives.
|
||||
- Update ziperr and finish if needed.
|
||||
- Review memory allocation and fill in memory leaks if any.
|
||||
- Enhance -FF to fix common problems such as archives ftp in text mode
|
||||
and fixing checksums so entries can be extracted if that makes
|
||||
sense (6/17/2007).
|
||||
- Add \ to / conversion in zipsplit to fix problem in
|
||||
1/29/2004 email.
|
||||
- Encryption bug with small stored file (12/27/2005) (fixed?).
|
||||
|
||||
- When updating large archives with few entries being
|
||||
updated maybe display something in large periods of
|
||||
quiet (1/23/2006).
|
||||
- Windows OEM comments (5/17/2006).
|
||||
- Example of using MVS zip and unzip (3/30/2004) (Need one).
|
||||
- UTF-8 comments need to be implemented (6/17/2007)
|
||||
- Maybe convert ../ in archive (5/20/2006).
|
||||
- Per so many buffers dll callback (12/23/2005 Ale).
|
||||
- Allow rename stdin "-" to something else (12/27/2005 gregor).
|
||||
- Check for possible buffer overrun weaknesses while reading zip files.
|
||||
- Do Active Template Library (ATL) (4/27/2005).
|
||||
- Flush Win16 support - to be determined (Mike).
|
||||
- Way to convert file names on input, converting foo.c to dir/foo_bar.c
|
||||
for instance (4/8/2004, 3/12/2004).
|
||||
- French WiZ (not a Zip thing actually but dependent on zip and unzip).
|
||||
- Then there is that wierd ^D being converted to \000 error reported
|
||||
in 6/21/2003 email when Zip is outputted into a pipe on Windows ports.
|
||||
|
||||
Old list:
|
||||
|
||||
Main features still missing for next official version (last updated 2/11/2001):
|
||||
|
||||
- what about the binary/text detection ? (seems done)
|
||||
- -b and -t options in help screen (covered in -h2)
|
||||
- findfirst/findnext and after that LSSTAT (performance!!)
|
||||
- use IS_EXEC from djgpp stat.h
|
||||
- use install in unix/Makefile instead of mkdir -p, look at install sh script.
|
||||
- #elif for those ports that can handle it.
|
||||
- what about zopen vs. fopen ?
|
||||
- Add zcreate or zfcreate for win32.
|
||||
- Assembler stuff in match.S (subexpressions)
|
||||
- zipping huge files (> 2G, unsigned 32bit) (done)
|
||||
- Testsuite for zip and unzip (John D. Mitchell)
|
||||
- make a version.c or version.h that includes all the compiler names
|
||||
- run utils with dmalloc().
|
||||
- what to do with zip -F and zip -FF (readzipfile2()) ? (done?)
|
||||
- profiling of the code
|
||||
- multi disk zip files (could be done)
|
||||
- zipfile modification tool (Greg)
|
||||
- Implement -- option (Thomas Klauser, wiz@danbala.tuwien.ac.at) (could be done)
|
||||
- don't add files with "Archive bit" or add files with "Archive bit"
|
||||
(uwe.becher@metronet.de) (could be done with -AS and -AC)
|
||||
- 32 bit file attributes
|
||||
- generate output without having to seek at all (this seems to be stream output)
|
||||
- remove contractions from zip error messages, make them clearer (Steve)
|
||||
- display "[text]" for ascii files when not quiet (no -q) (Timo Salmi)
|
||||
- does zipnote accept names with version number?
|
||||
- for a WORM, zip should create temp file only when updating; new archives
|
||||
should be created directly.
|
||||
- APPNOTE.TXT specifies "4) The entries in the central directory may
|
||||
not necessarily be in the same order that files appear in the zipfile"
|
||||
but readzipfile() relies on same order. (new read does not, and now
|
||||
the read for -FF searches for central directory matches rather than
|
||||
rely on the order)
|
||||
- on Mac, MPW C 3.3.1 requires #if (a || b) ["#if a || b" taken as "#if a"]
|
||||
- on Unix, let -S be "include non-regular files without reading from them"
|
||||
(as pkzip on Unix). This requires unzip support.
|
||||
- zip -l should do ebcdic->ascii translation on CMS and MVS
|
||||
- zip as subroutine (zdig/241) (some work done on this)
|
||||
- accept k and M in zipsplit
|
||||
- store / (part of file name) as ! in OS/2 (problem only with -E ?)
|
||||
- in addition to -l (LF to CR LF) and -ll (CR LF to LF) add -lc
|
||||
(LF to CR LF but CR LF remains unchanged)
|
||||
|
||||
Known bugs:
|
||||
|
||||
- On VMS, zip fails reading some files with "byte record too large for
|
||||
user's buffer". You must use the "-V" option for such files.
|
||||
(many changes to VMS so may be fixed)
|
||||
|
||||
- on MSDOS, zip386.exe does not like "zip -bc: foo ..."
|
||||
|
||||
- on MSDOS, zip386.exe is sometimes much slower than zip.exe. This is
|
||||
probably a problem with DJGPP (to be investigated).
|
||||
|
||||
- on NT with C shell, zip should not do file name expansion again.
|
||||
|
||||
- zip zipfile ... ignores existing zipfile if name does not have an extension
|
||||
(except for the -A option, generally used on self-extracting files).
|
||||
(archives should probably have extensions. Things like archive.jar work)
|
||||
|
||||
- For an sfx file without extension, "zip -A sfx" works but "zip sfx -A"
|
||||
doesn't. (because options were required first, but now both OK)
|
||||
|
||||
- When storing files in a zipfile (-0), zip marks all of them as binary.
|
||||
|
||||
- On VMS, some indexed files are not restored correctly after zip -V and unzip.
|
||||
(This is now known to be a problem of UnZip. The workaround for Zip 2.2
|
||||
and newer is to use PK-style VMS extra fields; this is now the default.
|
||||
NOTE that UnZip 5.32 has been fixed [971019]!) (many VMS changes so
|
||||
this may be fixed)
|
||||
|
||||
- zip and unzip should use the same pattern matching rules, particularly
|
||||
on MSDOS and OS/2. On OS/2, "zip foo *.*" should also match files
|
||||
without extension.
|
||||
Partially DONE (OS/2 "*.*" matches "*".)
|
||||
|
||||
- there should be a way to avoid updating archive members (only addition
|
||||
of new files allowed)
|
75
third_party/infozip/zip/USexport.msg
vendored
Normal file
75
third_party/infozip/zip/USexport.msg
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
From roelofs (at) sonic.net Tue Jun 17 08:26:55 2003
|
||||
Date: Tue, 17 Jun 2003 08:26:50 -0700
|
||||
Message-Id: <200306171526.h5HFQoaw014091 (at) bolt.sonic.net>
|
||||
From: Greg Roelofs <newt (at) pobox.com>
|
||||
Reply-To: Greg Roelofs <newt (at) pobox.com>
|
||||
To: crypt (at) bis.doc.gov, enc (at) ncsc.mil, web_site (at) bis.doc.gov
|
||||
Subject: TSU NOTIFICATION - Encryption (Info-ZIP zcrypt.zip)
|
||||
Cc: newt (at) pobox.com, zip-bugs (at) lists.wku.edu
|
||||
|
||||
|
||||
SUBMISSION TYPE: TSU
|
||||
SUBMITTED BY: Greg Roelofs
|
||||
SUBMITTED FOR: the Info-ZIP group (an informal, Internet-based
|
||||
collection of software developers with the contact
|
||||
address given in next item)
|
||||
POINT OF CONTACT: Zip-Bugs (at) lists.wku.edu
|
||||
PHONE and/or FAX: n/a
|
||||
MANUFACTURER: n/a
|
||||
PRODUCT NAME/MODEL #: zcrypt
|
||||
ECCN: 5D002
|
||||
|
||||
NOTIFICATION:
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/src/zcrypt.zip
|
||||
|
||||
|
||||
FURTHER COMMENTS:
|
||||
|
||||
(1) This notice is being sent in order to ensure that we may legally
|
||||
take advantage of the 6 June 2002 amendment to 740.13 regarding
|
||||
"corresponding object code." The encryption code in question is
|
||||
unchanged since our original notification of 9 April 2000, appended
|
||||
below and also reproduced within the above zcrypt.zip archive.
|
||||
(Indeed, there has been no change to the core encryption/decryption
|
||||
code in well over five years.)
|
||||
|
||||
(2) The (larger) source archives for Zip, UnZip, MacZip, WiZ, and
|
||||
potentially other packages, currently available in the same ftp
|
||||
directory given above, also contain (or may contain) copies of
|
||||
the same zcrypt source code.
|
||||
|
||||
(3) ftp.info-zip.org currently points to a site in Germany, so techni-
|
||||
cally it is not involved in "US export" in any direct way. However,
|
||||
we encourage other sites to "mirror" our software, and some of these
|
||||
mirror sites may be US-based (and therefore involved in reexport of
|
||||
the code in question). In addition, some Info-ZIP members reside in
|
||||
the US, and www.info-zip.org currently points to a site in Kentucky.
|
||||
|
||||
|
||||
ORIGINAL NOTIFICATION:
|
||||
|
||||
From roelofs (at) sonic.net Sun Apr 9 15:11:45 2000
|
||||
Date: Sun, 9 Apr 2000 15:11:27 -0700
|
||||
Message-Id: <200004092211.PAA20023 (at) sonic.net>
|
||||
From: Greg Roelofs <newt (at) pobox.com>
|
||||
To: crypt (at) bxa.doc.gov
|
||||
Subject: notice of export of unrestricted encryption source code
|
||||
Cc: newt (at) pobox.com, zip-bugs (at) lists.wku.edu
|
||||
|
||||
The Info-ZIP group, an informal, Internet-based collection of software
|
||||
developers with contact address Zip-Bugs (at) lists.wku.edu, hereby notifies
|
||||
the US Bureau of Export Administration (BXA) of the posting of freely
|
||||
available encryption source code on the Internet under License Exception
|
||||
TSU, to commence later today at this location:
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/src/zcrypt.zip
|
||||
|
||||
This notification is in accordance with section 740.13(e) of the amended
|
||||
Export Administration Regulations, as published in the 14 January 2000
|
||||
issue of the Federal Register.
|
||||
|
||||
--
|
||||
Greg Roelofs newt (at) pobox.com http://pobox.com/~newt/
|
||||
Newtware, PNG Group, Info-ZIP, Philips Research, ...
|
||||
|
333
third_party/infozip/zip/WHATSNEW
vendored
Normal file
333
third_party/infozip/zip/WHATSNEW
vendored
Normal file
|
@ -0,0 +1,333 @@
|
|||
What's New
|
||||
|
||||
Last updated 1 July 2008
|
||||
|
||||
This file is the full list of new features and major changes for Zip 3.0
|
||||
by beta release. See the announcement file zip30.ann for a quick summary
|
||||
of all features and changes in Zip 3.0. Also see the file README for
|
||||
release information, INSTALL for installation procedures, and the manual
|
||||
pages zip.txt, zipsplit.txt, zipcloak.txt, and zipnote.txt for how to use
|
||||
the new features. The file CHANGES has all the day-to-day changes made
|
||||
during development.
|
||||
|
||||
|
||||
Below are some of the more significant items on the list for Zip 3.1
|
||||
(see ToDo for a more complete list):
|
||||
|
||||
- AES encryption.
|
||||
- Extended attributes for Windows, Linux, and Mac OS X.
|
||||
- Support -d@ for deleting list of files.
|
||||
- Decide if -R, -i and -x should use external rather than internal patterns.
|
||||
- Though Unicode paths have been implemented and tested, Unicode comments
|
||||
are not yet supported (except for comments on UTF-8 native systems which
|
||||
are supported).
|
||||
- Verbose mode -v may still need work.
|
||||
- When pattern is directory add end / automatically.
|
||||
- Add C# example for Zip 3.0 (need to be converted to new DLLs) - original
|
||||
C# example added with note.
|
||||
- Path Prefix maybe, so entries added to an archive can have a directory
|
||||
path string prepended to each path.
|
||||
- UNC path support maybe.
|
||||
- Support for other languages maybe.
|
||||
- Send in your suggestions.
|
||||
- ...
|
||||
|
||||
|
||||
MAJOR CHANGES BY BETA VERSION
|
||||
-----------------------------
|
||||
|
||||
New things in Zip 3.0 since Zip 3.0h:
|
||||
|
||||
- Unicode fixes.
|
||||
- Test and fix various ports as needed.
|
||||
- Update Win32 resource to support more Windows ports.
|
||||
- Add djgpp 2.x makefile that includes bzip2.
|
||||
- Add Win32 version resource to Win32 executable.
|
||||
- Bug fixes.
|
||||
- Documentation updates.
|
||||
- Package for release.
|
||||
|
||||
|
||||
New things in Zip 3.0h
|
||||
|
||||
- Allow -@ and -x to work together.
|
||||
- Unicode code cleanup.
|
||||
- Allow forcing use of UTF-8 storage in standard path and comment.
|
||||
- Update symbolic link checks.
|
||||
- Add support for storing 32-bit UIDs/GIDs using new extra field.
|
||||
Backward compatible support for the old 16-bit UID/GID extra field
|
||||
remains if Zip is compiled on an OS that has 16-bit UID/GID
|
||||
storage.
|
||||
- Update VMS notes.
|
||||
- Directory scan using -AS (include only files with Windows archive
|
||||
bit set) now ignores archive bit on directories to include all files
|
||||
with archive bit set in all directories. Also, to avoid empty
|
||||
directories being created, -AS now does not store directory
|
||||
entries.
|
||||
- Add Unix IBM support.
|
||||
- Change -W to -ws to free -W for later use.
|
||||
- Fix large file support for MinGW.
|
||||
- Fix large file support for bzip2.
|
||||
- Fix compile error in ZipCloak when UNICODE_SUPPORT is not enabled.
|
||||
- Fix Unicode bug in ZipCloak involving Unicode paths.
|
||||
- Long Unicode escapes changed from #Lxxxxxxxx to #Lxxxxxx to shorten
|
||||
paths with escaped Unicode.
|
||||
- Bug fixes.
|
||||
|
||||
|
||||
New things in Zip 3.0g
|
||||
|
||||
- Add split support to VB project for Zip64.
|
||||
- Disable reading of Unix FIFOs unless new -FI option used to avoid an
|
||||
archiving operation stopping when it hits an active unfed FIFO.
|
||||
- The "[list]" wildcard expression (regular expression matching of any
|
||||
character or range of characters in list) is now disabled on DOS and
|
||||
Windows as it has caused confusion when filenames have [ and ] in
|
||||
them. The new -RE option reenables it.
|
||||
- Add negation to many display options such as -dc and -db.
|
||||
- Allow -FF to read and fix archives having local entries that appear
|
||||
after central directory entries.
|
||||
- Bug fixes.
|
||||
|
||||
|
||||
New things in Zip 3.0f
|
||||
|
||||
- bzip2 - The bzip2 compression method looks supported for at least
|
||||
Windows, Unix, and VMS using the bzip2 library. A new option, -Z cm,
|
||||
selects the compression method.
|
||||
|
||||
- Split archives - Can now use -s to create a split archive. The
|
||||
default is to update split files as the archive is being written,
|
||||
which requires all splits to remain open until the archive is done.
|
||||
This should be no problem when writing the archive to a hard drive,
|
||||
for example, and this approach creates archives that should be
|
||||
supported by all unzips that support splits. Adding the -sp option
|
||||
enables split pause mode that instead writes splits that do not
|
||||
need updating and pauses Zip after each split. This allows splits
|
||||
to be written directly to removable media, however -sp archives
|
||||
may not be as universally compatible.
|
||||
|
||||
- Unicode support - Zip now stores Unicode paths that should be more
|
||||
portable across character sets and languages. The unzip must have
|
||||
Unicode support enabled or the Unicode paths are ignored. If
|
||||
reading an archive with Unicode paths, unsupported characters are
|
||||
replaced by #Uxxxx and #Lxxxxxxxx escapes in the file name. Option
|
||||
-UN controls how Unicode is handled. Also, on systems where the
|
||||
current character set is UTF-8, preliminary support for the new
|
||||
General Purpose Bit Flag, bit 11, UTF-8 flag, that indicates UTF-8
|
||||
is stored in the path and comment fields is implemented for paths.
|
||||
- Unicode on Win32 - On WIN32 systems that support the wide character
|
||||
calls (mainly NT and later systems using NTFS), when UNICODE SUPPORT
|
||||
is enabled Zip will now do directory scans using Unicode and convert
|
||||
the Unicode paths to the local character set for storage in the standard
|
||||
path field and store UTF-8 in the Unicode extra field. This allows
|
||||
directory scans to complete successfully regardless of the character
|
||||
set the path is in. On Win9x systems wide character scans are not
|
||||
generally supported and Zip automatically uses a local character scan
|
||||
instead.
|
||||
|
||||
- Keep extra fields option - The default operation has been, and continues
|
||||
to be, to read then strip old extra fields when reading entries from an
|
||||
existing archive and then recreate the extra fields that Zip knows about.
|
||||
Extra fields specific to each operating system get added by default also.
|
||||
The new option -X- (negated -X) keeps any old extra fields, copying
|
||||
them to the updated archive unchanged (unless Zip has updated them).
|
||||
The unnegated -X still strips most all extra fields except Zip64,
|
||||
Unicode, and UT time.
|
||||
|
||||
- License - minor updates to the license.
|
||||
|
||||
- Windows OEM - When compiled with WIN32_OEM (the default for WIN32),
|
||||
Zip on WIN32 now stores OEM paths, which should be more compatible
|
||||
with other zips and should fix some character set problems.
|
||||
- Windows Archive Bit support - On Windows can now use new -AS
|
||||
(include if archive bit set) option to select files with the DOS
|
||||
archive bit set and use new -AC (clear archive bits) option to clear
|
||||
the archive bits on files after the archive has been created.
|
||||
But -DF is probably better.
|
||||
|
||||
- Difference mode - A new option -DF (--dif) creates an output archive
|
||||
that includes only files changed or new since the input archive was
|
||||
created. Can use to create incremental backups.
|
||||
- File Sync - The new option -FS enables File Sync, a new mode that
|
||||
synchronizes the entries in an archive with the files on the file
|
||||
system, adding updating, and deleting entries as needed. This
|
||||
should create the same results as creating a new archive, but
|
||||
since existing entries are copied, may be much faster.
|
||||
|
||||
- Copy Mode - A new --out option allows creating a new archive with a
|
||||
different name than the input archive, leaving the input archive
|
||||
unchanged. This allows updating split archives. It also allows
|
||||
for a new copy mode to select entries in one archive and copy them
|
||||
directly to a new archive.
|
||||
- Empty archives - Now an empty archive is created when -i or -i@ is used
|
||||
and the file patterns given do not match anything. This has been
|
||||
requested to support scripts.
|
||||
|
||||
- Global dots - A new -dg option now displays progress dots as -dd does,
|
||||
but instead of displaying them for each file, the dots track the total
|
||||
bytes read for the archive. The -dg option also works when -q is used
|
||||
to disable most output, which allows for something like zip -qdgds 100m
|
||||
to be used to not display specific files but display a dot every 100 MB
|
||||
as a global status.
|
||||
- Date range - Can now use -t and -tt to set a date range
|
||||
- Fix options - Option -F redone and can recover files from an archive
|
||||
with a mostly complete central directory more reliably, but no longer
|
||||
can handle truncated archives. Option -FF redone and now can salvage
|
||||
files from slightly more damaged archives, including truncated archives.
|
||||
In some ways -F is less powerful but more stable than it was and -FF will
|
||||
be needed where -F in Zip 2.32 was enough. One big change is -F and -FF
|
||||
both now support split archives.
|
||||
- Console writing - Updates to how messages are written to the console have
|
||||
been made including more consistent handling of line breaks.
|
||||
- Show Files options - Option -sf lists the files that would be operated
|
||||
on. This option can be used alone to list the files in an archive.
|
||||
Also see options -su and -sU for showing Unicode paths.
|
||||
- UnZip Check - Now check that UnZip 6.00 or later is being used for
|
||||
unzip if testing a Zip64 archive. A new option -TT can be used to set
|
||||
the unzip to use with the -T check. Currently UnZip does not support
|
||||
split archives so split archives can't be tested by UnZip.
|
||||
- Streaming - Directories are now handled better when streaming.
|
||||
- Case matching - Normally all matching against archive entries is case
|
||||
sensitive, so *.BAR will not match or find foo.bar in an archive
|
||||
when deleting, copying, or freshening entries (deleting and copying
|
||||
only on VMS). New option -ic (--ignore-case) enables case insensitive
|
||||
matching. Currently -ic is only implemented on WIN32 and VMS.
|
||||
|
||||
- Delete date bug fixed - Bug when using -d to delete files while
|
||||
using -t or -tt to select the files based on date is fixed
|
||||
- Large file encryption bug fixed - Fix for bug that very rarely
|
||||
results in bad data being stored when deflating and encrypting
|
||||
uncompressable data and resulting in CRC errors when extracting,
|
||||
but the chance of error increases with file size (thanks to
|
||||
WinZip for finding this bug). See CHANGES for details.
|
||||
|
||||
|
||||
New things in Zip 3.0e
|
||||
|
||||
- Bugs described in Debian patches 004 (unix configure script update) and
|
||||
005 (large path bug) fixed
|
||||
- Various fixes
|
||||
- Add optional running stats and also end stats if not all files could
|
||||
be read
|
||||
- Options -l and -ll now do quick binary check on first buffer and skip
|
||||
formatting if first buffer has binary - still check at end to note
|
||||
if formatting was done on file that was later determined to be binary,
|
||||
but now potential file corruption is generally avoided
|
||||
- Main binary check now uses new algorithm that should also treat UTF-8 and
|
||||
other similar encodings as text, allowing proper line end translation
|
||||
for UTF-8 files
|
||||
- When output is not updatable by seeking back and Zip64 is enabled, output
|
||||
is forced to Zip64 to avoid possible later need for Zip64 when not enabled
|
||||
- More work on splits, but still not usable
|
||||
- Fixes for djgpp
|
||||
- Add log file capability to save all errors and optionally messages
|
||||
- Add code to test for a Zip64 archive when compiled without Zip64 support
|
||||
- New VC6 projects for Win32 and WinDLL
|
||||
- Updates to extended help
|
||||
- Changes to force-zip64 option
|
||||
- ZE_BIG error now given also for files too big to read or write
|
||||
- Fix file delete bug
|
||||
- Update license
|
||||
- Update export documentation
|
||||
- Add VMS extended filename support
|
||||
- Add directory traversal improvements, some for Win32 ports and some for
|
||||
all ports, that can result in a 10 times increase in speed in some cases
|
||||
|
||||
|
||||
New things in Zip 3.0d
|
||||
|
||||
- Some large file crypt fixes
|
||||
- Some updates to support WiZ
|
||||
- On VMS, changed -V (/VMS) processing to truncate file at EOF, allowing
|
||||
greater compatability with non-VMS systems. New -VV (/VMS=ALL) option
|
||||
saves all allocated blocks in a file. (Previously, -V did neither.)
|
||||
- On VMS, pushed 2GB file size limit with -V out to 4GB
|
||||
- On VMS (recent, non-VAX), with SET PROCESS /PARSE = EXTEND,
|
||||
command-line case is preserved. This obviates quoting upper-case
|
||||
options, like -V, when enabled
|
||||
- On VMS, fixed problems with mixed-case directory names. Also changed
|
||||
to keep ODS5 extended file name escape characters ("^") out of the
|
||||
archived names in simple cases
|
||||
- Changes to the display dots
|
||||
- Option -W should now force wildcard matching to not cross directory
|
||||
separators. For example, a/b*r/d will match a/bar/d but not a/ba/r/d
|
||||
- Option -nw should turn off all wildcard matching so foo[bar] is matched
|
||||
literally and [bar] is not considered a regular expression
|
||||
- Atheos port
|
||||
- Debugging of Unix and VMS large file ports. Most features may work now
|
||||
on these ports for large files. Still need to fix 2 GB to 4 GB when not
|
||||
compiled with large file support
|
||||
- On VMS, added an open callback function which (where supported) senses
|
||||
the process RMS_DEFAULT values for file extend quantity (deq)
|
||||
multi-block count (mbc), and multi-buffer count (mbf), and sets the
|
||||
FAB/RAB parameters accordingly. The default deq is now much larger
|
||||
than before (16384 blocks, was none), and the default mbc is now 127
|
||||
(up from 64), speeding creation of a large archive file. The "-v"
|
||||
option shows some of the activity. On old VMS versions, RMS_DEFAULT
|
||||
sensing (GETJPI) fails (silently, without "-v"), and no changes will
|
||||
be made. Even there, (DCL) SET RMS /EXTEND = <big> can help
|
||||
performance. RMS_DEFAULT values override built-in default values.
|
||||
|
||||
|
||||
New things in Zip 3.0c
|
||||
|
||||
- Converted to using 64-bit file environment instead of transitional functions
|
||||
like fseeko64 for ports that support it
|
||||
- Added "--" argument to read all following arguments as paths
|
||||
- Second help page added
|
||||
- Binary detection adjusted from 20% binary is binary to 2%
|
||||
- When -R and -i used together now -i has precedence over -R
|
||||
- Archive names with spaces can now be tested on MSDOS and Win32
|
||||
|
||||
|
||||
New things in Zip 3.0b
|
||||
|
||||
- Fixed ifdefs so can test base code by compiling with NO_LARGE_FILE_SUPPORT, then
|
||||
compiling with NO_ZIP64_SUPPORT to test 64-bit file calls (if port enables) but
|
||||
otherwise use base code, and compiling normally to enable Zip64 code
|
||||
- Unix Zip64 fixes - should now be able to create and read large files
|
||||
- WinDLL changes to support Zip64. Zip 3.0 dll named Zip32z64.dll
|
||||
- New VB example to show use of Zip32z64.dll
|
||||
- New options -sc (show final command line and exit) and -sd (show each
|
||||
step zip is doing, a little different than verbose which is still there) added
|
||||
to help debug but both or at least -sd might go away in the release
|
||||
- Some minor posted bugs fixed (see Changes)
|
||||
|
||||
|
||||
New things in Zip 3.0a
|
||||
|
||||
- Initial Zip64 support allowing large files and large numbers of files
|
||||
- New command line processor
|
||||
- Other changes, see file Changes
|
||||
|
||||
|
||||
Note: Zip 2.4 was never released. That code was the start of the Zip 3.0
|
||||
effort above.
|
||||
|
||||
|
||||
New things in Zip 2.3
|
||||
|
||||
- IBM OS/390 port (Unix like, but EBCDIC) by Paul von Behren
|
||||
- Apple Macintosh (MACOS) port by Dirk Haase
|
||||
- Theos port by Jean-Michel Dubois
|
||||
- Multibyte characterset support by Yoshioka Tsuneo
|
||||
- Support for ISO 8601 date format with -t and -tt options
|
||||
- Info-ZIP license
|
||||
|
||||
|
||||
New things in Zip 2.2
|
||||
|
||||
- BEOS port by Chris Herborth
|
||||
- QDOS port by Jonathan Hudson
|
||||
- TANDEM port by Dave Smith
|
||||
- WINDLL port (16-bit Win 3.x and 32-bit WinNT/Win95) by Mike White
|
||||
- SYSV packages support by John Bush
|
||||
- zip -P SeCrEt encrypts entries in the zip file with password SeCrEt
|
||||
(WARNING: THIS IS INSECURE, use at your own risk)
|
||||
- zip -R recurses into subdirectories of current dir like "PKZIP -rP"
|
||||
- zip -x@exclude.lst excludes files specified in the file exclude.lst
|
||||
- zip -i@include.lst includes files specified in the file include.lst
|
||||
- zip -@ only handles one filename per line, but supports whitespace in names
|
||||
- zip -t mmddyyyy, 4 digit year number for uniqueness of years beyond 2000
|
||||
- zip -tt mmddyyyy only includes files before a specified date
|
261
third_party/infozip/zip/WHERE
vendored
Normal file
261
third_party/infozip/zip/WHERE
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
__________________________________________________________________________
|
||||
|
||||
This is the Info-ZIP file ``WHERE,'' last updated on 1 March 2005.
|
||||
__________________________________________________________________________
|
||||
|
||||
This file is out of date. We plan to update the structure of the ftp
|
||||
site shortly and should be updating this file as soon as that's done.
|
||||
|
||||
The latest version of this file can be found online at:
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/doc/WHERE
|
||||
|
||||
Note that some ftp sites may not yet have the latest versions of Zip
|
||||
and UnZip when you read this. The latest versions always appear in
|
||||
ftp://ftp.info-zip.org/pub/infozip/ (and subdirectories thereof) first,
|
||||
except for encryption binaries, which always appear in
|
||||
ftp://ftp.icce.rug.nl/infozip/ (and subdirectories) first.
|
||||
|
||||
IF YOU FIND AN ERROR: please let us know! We don't have time to
|
||||
check each and every site personally (or even collectively), so any
|
||||
number of the sites listed below may have moved or disappeared en-
|
||||
tirely. E-mail to Zip-Bugs@lists.wku.edu and we'll update this file.
|
||||
__________________________________________________________________________
|
||||
|
||||
|
||||
Info-ZIP's home WWW site is listed on Yahoo and is at:
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/Info-ZIP.html (master version)
|
||||
http://ftp.info-zip.org/pub/infozip/ (master version)
|
||||
http://www.info-zip.org/
|
||||
|
||||
Note that the old sites at http://www.cdrom.com/pub/infozip/ and
|
||||
http://www.freesoftware.com/pub/infozip are PERMANENTLY BROKEN. They
|
||||
cannot be updated or removed, apparently.
|
||||
|
||||
The Zip and UnZip pages have links to most known mirror sites carrying our
|
||||
source and/or binary distributions, and they generally are more up-to-date
|
||||
and have better information than what you are reading:
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/Zip.html
|
||||
ftp://ftp.info-zip.org/pub/infozip/UnZip.html
|
||||
|
||||
The related zlib package by Info-ZIP's Jean-loup Gailly and Mark Adler is at:
|
||||
|
||||
http://www.zlib.net/
|
||||
|
||||
Source-code archives for Info-ZIP's portable Zip, UnZip, and related
|
||||
utilities:
|
||||
|
||||
zip231.zip Zip 2.31 (deflation; includes zipnote/zipsplit/zipcloak)
|
||||
zip231.tar.Z ditto, compress'd tar format
|
||||
|
||||
zip11.zip Zip 1.1 (shrinking, implosion; compatible w. PKUNZIP 1.1)
|
||||
zip11.tar.Z ditto, compress'd tar format
|
||||
|
||||
unzip552.zip UnZip 5.52 (all methods[*]; unzip/funzip/unzipsfx/zipgrep)
|
||||
unzip552.tar.gz ditto, gzip'd tar format
|
||||
unzip552.tar.Z ditto, compress'd tar format
|
||||
|
||||
unred552.zip UnZip 5.52 add-on, contains copyrighted unreduce support
|
||||
|
||||
zcrypt29.zip encryption support for Zip 2.3[**]
|
||||
zcrypt10.zip encryption support for Zip 1.1
|
||||
|
||||
MacZip106src.zip contains all the GUI stuff and the project files to build
|
||||
the MacZip main-app. To build MacZip successfully, both
|
||||
the Zip 2.31 and UnZip 5.52 sources are required, too.
|
||||
|
||||
wiz502.zip WiZ 5.02, Windows 9x/NT GUI front-end for Info-ZIP DLLs
|
||||
wiz502+dlls.zip WiZ 5.02, Windows 9x/NT GUI front-end plus DLL sources
|
||||
|
||||
[*] Unreducing is disabled by default, but is available as add-on.
|
||||
As of July 2004, Unisys's LZW patent was expired worldwide, and
|
||||
unshrinking is turned on by default since the release of UnZip 5.52.
|
||||
See UnZip's INSTALL file for details.
|
||||
|
||||
[**] As of January 2000, US export regulations were amended to allow export
|
||||
of free encryption source code from the US. As of June 2002, these
|
||||
regulations were further relaxed to allow export of encryption binaries
|
||||
associated with free encryption source code. The Zip 2.31, UnZip 5.52
|
||||
and Wiz 5.02 archives now include full crypto source code. As of the
|
||||
Zip 2.31 release, all official binaries include encryption support; the
|
||||
former "zcr" archives ceased to exist.
|
||||
(Note that restrictions may still exist in other countries, of course.)
|
||||
|
||||
Executables archives (and related files) for Info-ZIP's software; not all
|
||||
of these will be immediately available due to lack of access to appropriate
|
||||
systems on the part of Info-ZIP members.
|
||||
|
||||
zip231x.zip MSDOS executables and docs
|
||||
zip231x1.zip OS/2 1.x (16-bit) executables and docs
|
||||
zip231x2.zip OS/2 2/3/4.x (32-bit) executables and docs
|
||||
zip231xA.zip Amiga executables and docs
|
||||
zip231xB.zip BeOS executables and docs
|
||||
zip231xC.zip VM/CMS executable and docs
|
||||
zip231xK.zip Tandem NSK executables and docs
|
||||
zip231xM.xmit MVS classic executable
|
||||
zip231xM-docs.zip MVS classic port, docs only
|
||||
zip231dN.zip WinNT/Win9x (Intel) DLL, header files, docs
|
||||
zip231xN.zip WinNT/Win9x (Intel) executables and docs
|
||||
zip231xN-axp.zip WinNT (Alpha AXP) executables and docs
|
||||
zip231xN-mip.zip WinNT (MIPS R4000) executables and docs
|
||||
zip231xN-ppc.zip WinNT (PowerPC) executables and docs
|
||||
zip231xO.zip IBM OS/390 Open Edition binaries and docs
|
||||
zip231xQ.zip SMS/QDOS executables and docs
|
||||
zip231xR.zip Acorn RISC OS executables and docs
|
||||
zip231xT.zip Atari TOS executables and docs
|
||||
zip231-vms-axp-obj.zip
|
||||
VMS (Alpha AXP) object libs, link procedure and docs
|
||||
zip231-vms-axp-exe.zip
|
||||
VMS (Alpha AXP) executables for VMS 6.1 or later and docs
|
||||
zip231-vms-vax-decc-obj.zip
|
||||
VMS (VAX) object libs (new DEC C), link procedure and docs
|
||||
zip231-vms-vax-decc-exe.zip
|
||||
VMS (VAX) executables (DEC C) for VMS 6.1 or later; docs
|
||||
zip231-vms-vax-vaxc-obj.zip
|
||||
VMS (VAX) object libs (old VAX C), link procedure and docs
|
||||
zip231x.hqx Macintosh BinHex'd executables and docs
|
||||
|
||||
unz552x.exe MSDOS self-extracting executable (16-bit unzip, ..., docs)
|
||||
unz552x3.exe MSDOS self-extracting executable (16-, 32-bit unzip, docs)
|
||||
unz552x1.exe OS/2 1.x (16-bit) self-extracting executables and docs
|
||||
unz552x2.exe OS/2 2/3/4.x (32-bit) self-extracting executables and docs
|
||||
unz552d2.zip OS/2 2/3/4.x (32-bit) DLL, header file, demo exe and docs
|
||||
unz552xA.ami Amiga self-extracting executables and docs
|
||||
unz552xA.lha Amiga executables and docs, LHa archive
|
||||
unz552xB.sfx BeOS self-extracting executables and docs
|
||||
unz552xB.tar.gz BeOS executables and docs, gzip'd tar archive
|
||||
unz552xC.mod VM/CMS executable module in "packed" format
|
||||
unz552xC-docs.zip VM/CMS docs, only
|
||||
unz552xF.zip FlexOS executable and docs
|
||||
unz552xK.zip Tandem NSK executable and docs
|
||||
unz552xM.xmit MVS classic executable
|
||||
unz552xM-docs.zip MVS classic port, docs only
|
||||
unz552dN.zip NT4/W2K/XP/2K3/W9x (32-bit Intel) DLL, header files, docs
|
||||
unz552xN.exe NT/2K/XP/2K3/W9x self-extracting i386 executables and docs
|
||||
unz552xN-axp.exe WinNT (Alpha AXP) self-extracting executables and docs
|
||||
unz552xN-mip.exe WinNT (MIPS R4000) self-extracting executables and docs
|
||||
unz552xN-ppc.exe WinNT (PowerPC) self-extracting executables and docs
|
||||
unz552xQ.sfx SMS/QDOS self-extracting executables and docs
|
||||
unz552xO.tar.Z IBM OS/390 Open edition (Unix-like), exes and docs
|
||||
unz552xR.exe Acorn RISC OS self-extracting executables and docs
|
||||
unz552xR.spk Acorn RISC OS Spark'd executables and docs
|
||||
unz552xT.tos Atari TOS self-extracting executables and docs
|
||||
unz552x-vms-axp-obj.bck VMS backup saveset,
|
||||
contains UnZip (Alpha) obj libs, link procedure, docs
|
||||
unz552x-vms-axp-obj.exe VMS (Alpha AXP) SFX archive (statically linked),
|
||||
contains UnZip (Alpha) obj libs, link procedure, docs
|
||||
unz552x-vms-axp-exe.exe VMS (Alpha AXP) SFX archive (dynamically linked),
|
||||
contains UnZip (Alpha AXP, DEC C) executables and docs,
|
||||
smaller than object archive, but requires VMS 6.1
|
||||
unz552x-vms-vax-decc-obj.bck VMS backup saveset,
|
||||
contains UnZip (new DEC C) obj libs, link procedure, docs
|
||||
unz552x-vms-vax-decc-obj.exe VMS (VAX) SFX archive (statically linked),
|
||||
contains UnZip (new DEC C) obj libs, link procedure, docs
|
||||
unz552x-vms-vax-decc-exe.exe VMS (VAX) SFX archive (dynamically linked),
|
||||
contains UnZip (new DEC C) executables and docs,
|
||||
smaller than object archive, but requires VMS 6.1
|
||||
unz552x-vms-vax-vaxc-obj.bck VMS backup saveset,
|
||||
contains UnZip (old VAX C) obj libs, link procedure, docs
|
||||
unz552x-vms-vax-vaxc-obj.exe VMS (VAX) SFX archive (statically linked),
|
||||
contains UnZip (old VAX C) obj libs, link procedure, docs
|
||||
unz552x.hqx Macintosh BinHex'd executables and docs for unzip
|
||||
(unz552x.tar.{Z,gz} Unix exes/docs for Solaris 2.x, SCO Unix, Linux, etc.,
|
||||
depending on directory/location; generally only provided
|
||||
in cases where the OS does *not* ship with a bundled C
|
||||
compiler)
|
||||
|
||||
MacZip106nc.hqx Macintosh combined Zip&UnZip application with GUI,
|
||||
executables and docs (no encryption)
|
||||
MacZip106c.hqx Macintosh combined Zip&UnZip application with GUI,
|
||||
executables and docs (with encryption)
|
||||
|
||||
wiz502xN.exe WiZ 5.02 32-bit (Win9x/NT/2K/XP/2K3) app+docs (self-extr.)
|
||||
|
||||
UnzpHist.zip complete changes-history of UnZip and its precursors
|
||||
ZipHist.zip complete changes-history of Zip
|
||||
|
||||
ftp/web sites for the US-exportable sources and executables:
|
||||
|
||||
NOTE: Look for the Info-ZIP file names given above (not PKWARE or third-
|
||||
party stuff) in the following locations. Some sites like to use slightly
|
||||
different names, such as zip-2.31.tar.gz instead of zip231.tar.Z.
|
||||
|
||||
ftp://ftp.info-zip.org/pub/infozip/ [THE INFO-ZIP HOME SITE]
|
||||
ftp://sunsite.doc.ic.ac.uk/packages/zip/ [MIRRORS THE INFO-ZIP HOME SITE]
|
||||
ftp://unix.hensa.ac.uk/mirrors/uunet/pub/archiving/zip/
|
||||
|
||||
ftp://ftp.cmdl.noaa.gov/aerosol/doc/archiver/{all,dos,os2,mac,vax_alpha}/
|
||||
ftp://garbo.uwasa.fi/pc/arcers/ [AND OTHER GARBO MIRRORS]
|
||||
ftp://garbo.uwasa.fi/unix/arcers/ [AND OTHER GARBO MIRRORS]
|
||||
ftp://ftp.elf.stuba.sk/pub/pc/pack/ [AND OTHER STUBA MIRRORS]
|
||||
ftp://ftp-os2.cdrom.com/pub/os2/archiver/
|
||||
ftp://ftp-os2.nmsu.edu/os2/archiver/
|
||||
ftp://ftp.informatik.tu-muenchen.de/pub/comp/os/os2/archiver/
|
||||
ftp://sumex-aim.stanford.edu/info-mac/cmp/
|
||||
ftp://ftp.wustl.edu/pub/aminet/util/arc/ [AND OTHER AMINET MIRRORS]
|
||||
ftp://atari.archive.umich.edu/pub/Archivers/ [AND OTHER UMICH MIRRORS]
|
||||
http://www.umich.edu/~archive/atari/Archivers/
|
||||
ftp://jake.educom.com.au/pub/infozip/acorn/ [Acorn RISC OS]
|
||||
http://www.sitec.net/maczip/ [MacZip port]
|
||||
|
||||
ftp/web sites for the encryption and decryption sources and/or executables:
|
||||
|
||||
Outside the US:
|
||||
ftp://ftp.info-zip.org/pub/infozip/ [THE INFO-ZIP HOME SITE]
|
||||
ftp://ftp.icce.rug.nl/infozip/ [THE INFO-ZIP ENCRYPTION HOME SITE]
|
||||
ftp://ftp.elf.stuba.sk/pub/pc/pack/
|
||||
ftp://garbo.uwasa.fi/pc/arcers/
|
||||
ftp://ftp.inria.fr/system/arch-compr/
|
||||
ftp://ftp.leo.org/pub/comp/os/os2/leo/archiver/
|
||||
(mail server at ftp-mailer@ftp.leo.org)
|
||||
|
||||
ftp://ftp.win.tue.nl/pub/compression/zip/
|
||||
ftp://ftp.uni-erlangen.de/pub/pc/msdos/arc-utils/zip/
|
||||
|
||||
|
||||
The primary distribution site for the MacZip port can be found at:
|
||||
|
||||
http://www.sitec.net/maczip/
|
||||
|
||||
ftp sites for VMS-format Zip and UnZip packages (sources, object files and
|
||||
executables, no encryption/decryption--see also "Mail servers" section below):
|
||||
|
||||
ftp.spc.edu [192.107.46.27] and ftp.wku.edu:
|
||||
|
||||
[.MACRO32]AAAREADME.TXT
|
||||
[.MACRO32.SAVESETS]UNZIP.BCK or UNZIP.ZIP (if already have older version)
|
||||
[.MACRO32.SAVESETS]ZIP.ZIP
|
||||
|
||||
To find other ftp/web sites:
|
||||
|
||||
The "archie" ftp database utility can be used to find an ftp site near
|
||||
you (although the command-line versions always seem to find old ver-
|
||||
sions...the `FTPsearch' server at http://ftpsearch.ntnu.no/ftpsearch
|
||||
--formerly `Archie 95'--is quite up-to-date, however). Or check a stan-
|
||||
dard WWW search engine like AltaVista (http://www.altavista.digital.com/)
|
||||
or Yahoo (http://www.yahoo.com/). If you don't know how to use these,
|
||||
DON'T ASK US--read the web sites' help pages or check the Usenet groups
|
||||
news.announce.newusers or news.answers or some such, or ask your system
|
||||
administrator.
|
||||
|
||||
Mail servers:
|
||||
|
||||
To get the encryption sources by e-mail, send the following commands
|
||||
to ftp-mailer@informatik.tu-muenchen.de:
|
||||
|
||||
get /pub/comp/os/os2/archiver/zcrypt29.zip
|
||||
quit
|
||||
|
||||
To get the VMS Zip/UnZip package by e-mail, send the following
|
||||
commands in the body of a mail message to fileserv@wku.edu (the
|
||||
"HELP" command is also accepted):
|
||||
|
||||
SEND FILESERV_TOOLS
|
||||
SEND UNZIP
|
||||
SEND ZIP
|
||||
|
||||
To get Atari executables by e-mail, send a message to
|
||||
atari@atari.archive.umich.edu for information about the mail server.
|
||||
__________________________________________________________________________
|
130
third_party/infozip/zip/acorn/GMakefile
vendored
Normal file
130
third_party/infozip/zip/acorn/GMakefile
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
|
||||
|
||||
# add -g to CC to debug
|
||||
# add -d to BIND to debug
|
||||
CC = gcc -mlibscl
|
||||
BIND = $(CC)
|
||||
AS = $(CC) -c
|
||||
ASM = AS
|
||||
SQUEEZE = squeeze -v
|
||||
E =
|
||||
|
||||
# flags
|
||||
# CFLAGS flags for C compile
|
||||
# LFLAGS1 flags after output file spec, before obj file list
|
||||
# LFLAGS2 flags after obj file list (libraries, etc)
|
||||
#
|
||||
LIB =
|
||||
CFLAGS = -O2 -mthrowback -DASMV
|
||||
ASMFLAGS = -throwback -objasm -upper
|
||||
LFLAGS1 =
|
||||
LFLAGS2 = $(LIB)
|
||||
|
||||
# Uncomment the following line to enable support for Unix
|
||||
# Extra Field (Timezone)
|
||||
#CFLAGS = $(CFLAGS) -DUSE_EF_UT_TIME
|
||||
|
||||
# object file lists
|
||||
OBJZ = o.zip o.zipfile o.zipup o.fileio o.util o.globals o.crc32 \
|
||||
o.crypt o.ttyio o.riscos o.acornzip o.swiven
|
||||
|
||||
OBJI = o.deflate o.trees
|
||||
OBJA = o.match o.sendbits
|
||||
OBJU = o.zipfile_ o.fileio_ o.util_ o.globals o.riscos o.acornzip_ o.swiven
|
||||
OBJN = o.zipnote $(OBJU)
|
||||
OBJC = o.zipcloak $(OBJU) o.crc32_ o.crypt_ o.ttyio
|
||||
OBJS = o.zipsplit $(OBJU)
|
||||
|
||||
ZIP_H = h.zip h.ziperr h.tailor acorn.h.osdep acorn.h.riscos acorn.h.swiven
|
||||
|
||||
all: zip zipnote zipsplit zipcloak
|
||||
|
||||
install: %.zip %.zipnote %.zipsplit %.zipcloak %.acorn.zipsfx \
|
||||
zip zipnote zipsplit zipcloak acorn.zipsfx
|
||||
$(SQUEEZE) zip %.zip
|
||||
$(SQUEEZE) zipnote %.zipnote
|
||||
$(SQUEEZE) zipsplit %.zipsplit
|
||||
$(SQUEEZE) zipcloak %.zipcloak
|
||||
copy acorn.zipsfx %.zipsfx ~CVF
|
||||
|
||||
# rules for zip, zipnote, zipcloak and zipsplit
|
||||
|
||||
o.api: c.api
|
||||
$(CC) $(CFLAGS) -c c.api -o o.api
|
||||
o.crc32: c.crc32 $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -c c.crc32 -o o.crc32
|
||||
o.crypt: c.crypt $(ZIP_H) h.crypt h.crc32 h.ttyio
|
||||
$(CC) $(CFLAGS) -c c.crypt -o o.crypt
|
||||
o.deflate: c.deflate $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -c c.deflate -o o.deflate
|
||||
o.fileio: c.fileio $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -c c.fileio -o o.fileio
|
||||
o.globals: c.globals $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -c c.globals -o o.globals
|
||||
o.mktime: c.mktime
|
||||
$(CC) $(CFLAGS) -c c.mktime -o o.mktime
|
||||
o.trees: c.trees $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -c c.trees -o o.trees
|
||||
o.ttyio: c.ttyio $(ZIP_H) h.crypt
|
||||
$(CC) $(CFLAGS) -c c.ttyio -o o.ttyio
|
||||
o.util: c.util $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -c c.util -o o.util
|
||||
o.zip: c.zip $(ZIP_H) h.crc32 h.crypt h.revision h.ttyio
|
||||
$(CC) $(CFLAGS) -c c.zip -o o.zip
|
||||
o.zipcloak: c.zipcloak $(ZIP_H) h.crc32 h.crypt h.revision h.ttyio
|
||||
$(CC) $(CFLAGS) -c c.zipcloak -o o.zipcloak
|
||||
o.zipfile: c.zipfile $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -c c.zipfile -o o.zipfile
|
||||
o.zipnote: c.zipnote $(ZIP_H) h.revision
|
||||
$(CC) $(CFLAGS) -c c.zipnote -o o.zipnote
|
||||
o.zipsplit: c.zipsplit $(ZIP_H) h.revision
|
||||
$(CC) $(CFLAGS) -c c.zipsplit -o o.zipsplit
|
||||
o.zipup: c.zipup $(ZIP_H) h.crc32 h.crypt h.revision
|
||||
$(CC) $(CFLAGS) -c c.zipup -o o.zipup
|
||||
|
||||
o.crc32_: c.crc32 $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.crc32 -o o.crc32_
|
||||
o.crypt_: c.crypt $(ZIP_H) h.crypt h.crc32 h.ttyio
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.crypt -o o.crypt_
|
||||
o.util_: c.util $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.util -o o.util_
|
||||
o.fileio_: c.fileio $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.fileio -o o.fileio_
|
||||
o.zipfile_: c.zipfile $(ZIP_H) h.crc32
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.zipfile -o o.zipfile_
|
||||
o.acornzip_: acorn.c.acornzip $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -I@ -DUTIL -c acorn.c.acornzip -o o.acornzip_
|
||||
|
||||
o.riscos: acorn.c.riscos acorn.h.riscos $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -I@ -c acorn.c.riscos -o o.riscos
|
||||
|
||||
o.acornzip: acorn.c.acornzip $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -I@ -c acorn.c.acornzip -o o.acornzip
|
||||
|
||||
o.match: acorn.s.match
|
||||
$(ASM) $(ASMFLAGS) -I@ acorn.s.match -o o.match
|
||||
|
||||
o.sendbits: acorn.s.sendbits
|
||||
$(ASM) $(ASMFLAGS) -I@ acorn.s.sendbits -o o.sendbits
|
||||
|
||||
o.swiven: acorn.s.swiven
|
||||
$(ASM) $(ASMFLAGS) -I@ acorn.s.swiven -o o.swiven
|
||||
|
||||
zip: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(BIND) -o zip$(E) $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
zipnote: $(OBJN)
|
||||
$(BIND) -o zipnote$(E) $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
zipcloak: $(OBJC)
|
||||
$(BIND) -o zipcloak$(E) $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
zipsplit: $(OBJS)
|
||||
$(BIND) -o zipsplit$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
clean:
|
||||
remove zip
|
||||
remove zipcloak
|
||||
remove zipsplit
|
||||
remove zipnote
|
||||
create o.!fake! 0
|
||||
wipe o.* ~cf
|
||||
|
||||
# end of Makefile
|
85
third_party/infozip/zip/acorn/ReadMe
vendored
Normal file
85
third_party/infozip/zip/acorn/ReadMe
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
Acorn-specific compile instructions
|
||||
-----------------------------------
|
||||
|
||||
Use the "RunMe1st" file (it is an Obey file) to convert all the files from
|
||||
"filename/[chs]" to "[chs].filename" (so that zip could be easily compiled
|
||||
under RISC OS). It will also set the correct makefile.
|
||||
|
||||
To compile just set the CSD to the main zip 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 zip.
|
||||
|
||||
The default makefile is configured without the support for the
|
||||
Extended Timestamp Extra Field. If you wan to enable it you have to
|
||||
add "-DUSE_EF_UT_TIME" to CFLAGS (see makefile). Without the Extended
|
||||
Timestamp Field support, zipfiles created by zip are identical to the
|
||||
zipfiles created by SparkFS. However, the Extended Timestamp Field can
|
||||
be useful if you are going to unzip your zipfiles on a non-RISC OS machine
|
||||
since the correct time stamp will be preserved across different timezones.
|
||||
Note that in this case, both the SparkFS Extra Field and the Extended
|
||||
Timestamp Extra Field will be used, so the zipfiles will still be fully
|
||||
compatible with SparkFS and with the RISC OS version of unzip.
|
||||
|
||||
The executables-only distributions will be compiled without the support for
|
||||
the Extended Timestamp Extra Field. If you need it but you can't compile zip
|
||||
yourself, you can contact the authors at the Info-ZIP address who will do it
|
||||
for you.
|
||||
|
||||
|
||||
Acorn-specific usage instructions
|
||||
---------------------------------
|
||||
|
||||
An extra option ('I') has been added to the Acorn port: if it is specified
|
||||
zip will not consider Image files (eg. DOS partitions or Spark archives when
|
||||
SparkFS is loaded) as directories but will store them as single files. This
|
||||
means that if you have, say, SparkFS loaded, zipping a Spark archive will
|
||||
result in a zipfile containing a directory (and its content) while using the
|
||||
'I' option will result in a zipfile containing a Spark archive. Obviously
|
||||
this second case will also be obtained (without the 'I' option) if SparkFS
|
||||
isn't loaded.
|
||||
|
||||
When adding files to a zipfile; to maintain FileCore compliance, all
|
||||
files named "file/ext" will be added to the archive as "file.ext".
|
||||
This presents no problem if you wish to use unzip to extract them on any
|
||||
other machine, as the files are correctly named. This also presents no
|
||||
problem if you use unzip for RISC OS, as the files are converted back to
|
||||
"file/ext" format. The only problem appears when you use SparkFS to
|
||||
decompress the files, as a file called "file.ext" will be extracted as
|
||||
"file_ext", not what it was added as. You must be careful about this.
|
||||
|
||||
Case Specific. Depending on how you type the command, files will be added
|
||||
exactly as named; in this example:
|
||||
*zip new/zip newfile
|
||||
*zip new/zip NewFile
|
||||
*zip new/zip NEWFILE
|
||||
will create an archive containing 3 copies of the same Risc OS file 'newfile'
|
||||
called 'newfile', 'NewFile' and 'NEWFILE'. Please be careful.
|
||||
|
||||
The Acorn port conserves file attributes, including filetype, so if you
|
||||
zip on an Acorn, and unzip on another Acorn, filetypes will be maintained
|
||||
precisely as if you used uncompressed files. If you de-archive on another
|
||||
machine (PC, Mac, Unix etc..), filetypes will be ignored, but the files
|
||||
will be identical despite this. This feature is fully compatible with
|
||||
SparkFS, so zipfiles created by zip will be correctly uncompressed (including
|
||||
filetype, etc.) by SparkFS.
|
||||
|
||||
An additional feature went into this port to cope better with C-code
|
||||
and extensions. This allows the acorn files "c.foo" to be added to the
|
||||
archive as "foo/c", eventually appearing in the archive as "foo.c", allowing
|
||||
for better handling of C or C++ code. Example:
|
||||
*Set Zip$Exts "dir1:dir2:dir3"
|
||||
*zip new/zip dir1.file
|
||||
*zip new/zip dir2.help
|
||||
*zip new/zip dir3.textfile
|
||||
Creates a zipfile new/zip, with entries file.dir1, help.dir2, textfile.dir3.
|
||||
The usual settings for Zip$Exts are "h:o:s:c", allowing C code to be added
|
||||
to the archive in standard form.
|
||||
|
||||
A final note about the Acorn port regards the use of the 'n' option: this is
|
||||
used to specify a list of suffixes that will not be compressed (eg. .ZIP,
|
||||
since it is already a compressed file). Since RISC OS uses filetypes instead
|
||||
of suffixes, this list of suffixes is actually considered as a list of
|
||||
filetypes (3 hex digit format). By default, zip doesn't compress filetypes
|
||||
DDC (Archive, Spark or Zip), D96 (CFS files) and 68E (PackDir).
|
||||
|
16
third_party/infozip/zip/acorn/ReadMe.GMakefile
vendored
Normal file
16
third_party/infozip/zip/acorn/ReadMe.GMakefile
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
GMakefile is for use with Acorn RISC OS and the forthcoming
|
||||
post-Acorn RISC OS for the compilation of both the current release and
|
||||
development versions of zip.
|
||||
|
||||
It is recommended that you use gcc 2.95.4 or higher and you will need a
|
||||
suitable 'make' utility. Both are available from
|
||||
<URL:http://hard-mofo.dsvr.net/gcc/>.
|
||||
|
||||
You will need the files gcc.zip and cc1.zip for the C compiler with the
|
||||
documentation available in the gccdoc.zip archive. GNU make can be
|
||||
found in the utils.zip archive, although most versions of 'make' should be
|
||||
fine.
|
||||
|
||||
When using gcc, check RunMe1st for two lines which need uncommenting.
|
||||
|
||||
|
23
third_party/infozip/zip/acorn/RunMe1st
vendored
Normal file
23
third_party/infozip/zip/acorn/RunMe1st
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
| This Obey file prepares the zip 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 zip 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
|
||||
Copy <Obey$Dir>.makefile <Obey$Dir>.^.makefile ~C ~V F
|
||||
|
||||
| Uncomment the following lines if you're using gcc
|
||||
|| Put the Makefile in its correct place and set the correct filetype
|
||||
|Copy <Obey$Dir>.GMakefile <Obey$Dir>.^.makefile ~C~VF
|
||||
|
||||
SetType <Obey$Dir>.^.makefile FE1
|
||||
SetType <Obey$Dir>.zipsfx Obey
|
592
third_party/infozip/zip/acorn/acornzip.c
vendored
Normal file
592
third_party/infozip/zip/acorn/acornzip.c
vendored
Normal file
|
@ -0,0 +1,592 @@
|
|||
/*
|
||||
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "zip.h"
|
||||
|
||||
#ifndef UTIL
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
|
||||
local int wild_recurse(char *whole, char *wildtail);
|
||||
local int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut);
|
||||
|
||||
extern char *label;
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
char *readd(DIR *d)
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return (e == NULL ? (char *) NULL : e->d_name);
|
||||
}
|
||||
|
||||
/* What we have here is a mostly-generic routine using opend()/readd() and */
|
||||
/* isshexp()/MATCH() to find all the files matching a multi-part filespec */
|
||||
/* using the portable pattern syntax. It shouldn't take too much fiddling */
|
||||
/* to make it usable for any other platform that has directory hierarchies */
|
||||
/* but no shell-level pattern matching. It works for patterns throughout */
|
||||
/* the pathname, such as "foo:*.?/source/x*.[ch]". */
|
||||
|
||||
/* whole is a pathname with wildcards, wildtail points somewhere in the */
|
||||
/* middle of it. All wildcards to be expanded must come AFTER wildtail. */
|
||||
|
||||
local int wild_recurse(whole, wildtail) char *whole; char *wildtail;
|
||||
{
|
||||
DIR *dir;
|
||||
char *subwild, *name, *newwhole = NULL, *glue = NULL, plug = 0, plug2;
|
||||
ush newlen, amatch = 0;
|
||||
struct stat statb;
|
||||
int disk_not_mounted=0;
|
||||
int e = ZE_MISS;
|
||||
|
||||
if (!isshexp(wildtail)) {
|
||||
if (stat(whole,&statb)==0 && (statb.st_mode & S_IREAD)!=0) {
|
||||
return procname(whole, 0);
|
||||
} else
|
||||
return ZE_MISS; /* woops, no wildcards! */
|
||||
}
|
||||
|
||||
/* back up thru path components till existing dir found */
|
||||
do {
|
||||
name = wildtail + strlen(wildtail) - 1;
|
||||
for (;;)
|
||||
if (name-- <= wildtail || *name == '.') {
|
||||
subwild = name + 1;
|
||||
plug2 = *subwild;
|
||||
*subwild = 0;
|
||||
break;
|
||||
}
|
||||
if (glue)
|
||||
*glue = plug;
|
||||
glue = subwild;
|
||||
plug = plug2;
|
||||
dir = opendir(whole);
|
||||
} while (!dir && !disk_not_mounted && subwild > wildtail);
|
||||
wildtail = subwild; /* skip past non-wild components */
|
||||
|
||||
if ((subwild = strchr(wildtail + 1, '.')) != NULL) {
|
||||
/* this "+ 1" dodges the ^^^ hole left by *glue == 0 */
|
||||
*(subwild++) = 0; /* wildtail = one component pattern */
|
||||
newlen = strlen(whole) + strlen(subwild) + 32;
|
||||
} else
|
||||
newlen = strlen(whole) + 31;
|
||||
if (!dir || !(newwhole = malloc(newlen))) {
|
||||
if (glue)
|
||||
*glue = plug;
|
||||
e = dir ? ZE_MEM : ZE_MISS;
|
||||
goto ohforgetit;
|
||||
}
|
||||
strcpy(newwhole, whole);
|
||||
newlen = strlen(newwhole);
|
||||
if (glue)
|
||||
*glue = plug; /* repair damage to whole */
|
||||
if (!isshexp(wildtail)) {
|
||||
e = ZE_MISS; /* non-wild name not found */
|
||||
goto ohforgetit;
|
||||
}
|
||||
|
||||
while (name = readd(dir)) {
|
||||
if (MATCH(wildtail, name, 0)) {
|
||||
strcpy(newwhole + newlen, name);
|
||||
if (subwild) {
|
||||
name = newwhole + strlen(newwhole);
|
||||
*(name++) = '.';
|
||||
strcpy(name, subwild);
|
||||
e = wild_recurse(newwhole, name);
|
||||
} else
|
||||
e = procname(newwhole, 0);
|
||||
newwhole[newlen] = 0;
|
||||
if (e == ZE_OK)
|
||||
amatch = 1;
|
||||
else if (e != ZE_MISS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ohforgetit:
|
||||
if (dir) closedir(dir);
|
||||
if (subwild) *--subwild = '.';
|
||||
if (newwhole) free(newwhole);
|
||||
if (e == ZE_MISS && amatch)
|
||||
e = ZE_OK;
|
||||
return e;
|
||||
}
|
||||
|
||||
int wild(p)
|
||||
char *p;
|
||||
{
|
||||
char *path;
|
||||
int toret;
|
||||
|
||||
/* special handling of stdin request */
|
||||
if (strcmp(p, "-") == 0) /* if compressing stdin */
|
||||
return newname(p, 0, 0);
|
||||
|
||||
path=p;
|
||||
if (strchr(p, ':')==NULL && *p!='@') {
|
||||
if (!(path=malloc(strlen(p)+3))) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcpy(path,"@.");
|
||||
strcat(path,p);
|
||||
}
|
||||
|
||||
toret=wild_recurse(path, path);
|
||||
|
||||
if (path!=p) {
|
||||
free(path);
|
||||
}
|
||||
return toret;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if ((s.st_mode & S_IFDIR) == 0)
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '.')
|
||||
strcpy(a, ".");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t; /* shortened name */
|
||||
char *tmp;
|
||||
int dosflag;
|
||||
char *lastlastdir=NULL; /* pointer to 2 dirs before... */
|
||||
char *lastdir=NULL; /* pointer to last dir... */
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((tmp = malloc(strlen(x) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(tmp, x);
|
||||
|
||||
dosflag = dosify; /* default for non-DOS and non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
for(t=tmp;*t;t++) {
|
||||
if (*t=='/') {
|
||||
*t='.';
|
||||
}
|
||||
else if (*t=='.') {
|
||||
*t='/';
|
||||
lastlastdir=lastdir;
|
||||
lastdir=t+1;
|
||||
}
|
||||
}
|
||||
|
||||
t=strchr(tmp,'$'); /* skip FS name */
|
||||
if (t!=NULL)
|
||||
t+=2; /* skip '.' after '$' */
|
||||
else
|
||||
t=tmp;
|
||||
if (*t=='@') /* skip @. at the beginning of filenames */
|
||||
t+=2;
|
||||
|
||||
/* Make changes, if any, to the copied name (leave original intact) */
|
||||
|
||||
/* return a pointer to '\0' if the file is a directory with the same
|
||||
same name as an extension to swap (eg. 'c', 'h', etc.) */
|
||||
if (isdir && exts2swap!=NULL) {
|
||||
if (lastlastdir==NULL)
|
||||
lastlastdir=t;
|
||||
if (checkext(lastlastdir)) {
|
||||
free((void *)tmp);
|
||||
n=malloc(1);
|
||||
if (n!=NULL)
|
||||
*n='\0';
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
if (exts2swap!=NULL && lastdir!=NULL) {
|
||||
if (lastlastdir==NULL)
|
||||
lastlastdir=t;
|
||||
if (checkext(lastlastdir)) {
|
||||
if (swapext(lastlastdir,lastdir-1)) {
|
||||
free((void *)tmp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL) {
|
||||
free((void *)tmp);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(n, t);
|
||||
|
||||
free((void *)tmp);
|
||||
|
||||
if (dosify)
|
||||
msname(n);
|
||||
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
char *t; /* scans name */
|
||||
char *lastext=NULL; /* pointer to last extension */
|
||||
char *lastdir=NULL; /* pointer to last dir */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
|
||||
for(t=x;*t;t++) {
|
||||
if (*t=='.') {
|
||||
*t='/';
|
||||
lastext=t+1;
|
||||
}
|
||||
else if (*t=='/') {
|
||||
*t='.';
|
||||
lastdir=t+1;
|
||||
}
|
||||
}
|
||||
|
||||
if (exts2swap!=NULL && (int)lastext>(int)lastdir) {
|
||||
if (lastdir==NULL)
|
||||
lastdir=x;
|
||||
if (checkext(lastext)) {
|
||||
if (swapext(lastdir,lastext-1)) {
|
||||
free((void *)x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
local int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut)
|
||||
{
|
||||
unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */
|
||||
unsigned timhi; /* 2 high bytes of acorn file-time */
|
||||
|
||||
timlo = ((unsigned)ut & 0x00ffffffU) * 100 + 0x00996a00U;
|
||||
timhi = ((unsigned)ut >> 24);
|
||||
timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
|
||||
if (timhi & 0xffff0000U)
|
||||
return 1; /* calculation overflow, do not change time */
|
||||
|
||||
/* insert the five time bytes into loadaddr and execaddr variables */
|
||||
*pexadr = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
|
||||
*pldadr = (*pldadr & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU);
|
||||
|
||||
return 0; /* subject to future extension to signal overflow */
|
||||
}
|
||||
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
time_t m_time;
|
||||
unsigned int loadaddr, execaddr;
|
||||
int attr;
|
||||
|
||||
/* Convert DOS time to time_t format in m_time */
|
||||
m_time = dos2unixtime(d);
|
||||
|
||||
/* set the file's modification time */
|
||||
SWI_OS_File_5(f,NULL,&loadaddr,NULL,NULL,&attr);
|
||||
|
||||
if (uxtime2acornftime(&execaddr, &loadaddr, m_time) != 0)
|
||||
return;
|
||||
|
||||
SWI_OS_File_1(f,loadaddr,execaddr,attr);
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
/* convert FNMAX to malloc - 11/8/04 EG */
|
||||
char *name;
|
||||
unsigned int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL) {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '.')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
|
||||
if (strcmp(f, "-") == 0) {
|
||||
/* forge stat values for stdin since Amiga and RISCOS have no fstat() */
|
||||
s.st_mode = (S_IREAD|S_IWRITE|S_IFREG);
|
||||
s.st_size = -1;
|
||||
s.st_mtime = time(&s.st_mtime);
|
||||
} else if (LSSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (a != NULL) {
|
||||
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
|
||||
if ((s.st_mode & S_IFDIR) != 0) {
|
||||
*a |= MSDOS_DIR_ATTR;
|
||||
}
|
||||
}
|
||||
if (n != NULL)
|
||||
*n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = s.st_ctime;
|
||||
}
|
||||
|
||||
return unix2dostime((time_t *) &s.st_mtime);
|
||||
}
|
||||
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
{
|
||||
#ifdef USE_EF_UT_TIME
|
||||
char *eb_ptr;
|
||||
#endif /* USE_EF_UT_TIME */
|
||||
char *name;
|
||||
extra_block *block;
|
||||
|
||||
#define EB_SPARK_LEN 20
|
||||
#define EB_SPARK_SIZE (EB_HEADSIZE+EB_SPARK_LEN)
|
||||
#ifdef USE_EF_UT_TIME
|
||||
# ifdef IZ_CHECK_TZ
|
||||
# define EB_UTTIME_SIZE (zp_tz_is_valid ? EB_HEADSIZE+EB_UT_LEN(1) : 0)
|
||||
# else
|
||||
# define EB_UTTIME_SIZE (EB_HEADSIZE+EB_UT_LEN(1))
|
||||
# endif
|
||||
#else
|
||||
# define EB_UTTIME_SIZE 0
|
||||
#endif
|
||||
#define EF_SPARK_TOTALSIZE (EB_SPARK_SIZE + EB_UTTIME_SIZE)
|
||||
|
||||
if ((name=(char *)malloc(strlen(z->name)+1))==NULL) {
|
||||
fprintf(stderr," set_extra_field: not enough memory for directory name\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
strcpy(name,z->name);
|
||||
|
||||
if (name[strlen(name)-1]=='.') { /* remove the last '.' in directory names */
|
||||
name[strlen(name)-1]=0;
|
||||
}
|
||||
|
||||
z->extra=(char *)malloc(EF_SPARK_TOTALSIZE);
|
||||
if (z->extra==NULL) {
|
||||
fprintf(stderr," set_extra_field: not enough memory\n");
|
||||
free(name);
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = z->extra;
|
||||
z->cext = z->ext = EF_SPARK_TOTALSIZE;
|
||||
|
||||
block=(extra_block *)z->extra;
|
||||
block->ID=SPARKID;
|
||||
block->size=EB_SPARK_LEN;
|
||||
block->ID_2=SPARKID_2;
|
||||
block->zero=0;
|
||||
|
||||
if (SWI_OS_File_5(name,NULL,&block->loadaddr,&block->execaddr,
|
||||
NULL,&block->attr) != NULL) {
|
||||
fprintf(stderr," OS error while set_extra_field of %s\n",name);
|
||||
}
|
||||
|
||||
free(name);
|
||||
|
||||
#ifdef USE_EF_UT_TIME
|
||||
# ifdef IZ_CHECK_TZ
|
||||
if (zp_tz_is_valid) {
|
||||
# endif
|
||||
eb_ptr = z->extra + EB_SPARK_SIZE;
|
||||
|
||||
eb_ptr[0] = 'U';
|
||||
eb_ptr[1] = 'T';
|
||||
eb_ptr[2] = EB_UT_LEN(1); /* length of data part of e.f. */
|
||||
eb_ptr[3] = 0;
|
||||
eb_ptr[4] = EB_UT_FL_MTIME;
|
||||
eb_ptr[5] = (char)(z_utim->mtime);
|
||||
eb_ptr[6] = (char)(z_utim->mtime >> 8);
|
||||
eb_ptr[7] = (char)(z_utim->mtime >> 16);
|
||||
eb_ptr[8] = (char)(z_utim->mtime >> 24);
|
||||
# ifdef IZ_CHECK_TZ
|
||||
}
|
||||
# endif
|
||||
#endif /* USE_EF_UT_TIME */
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
void version_local()
|
||||
{
|
||||
static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
|
||||
|
||||
printf(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
|
||||
);
|
||||
|
||||
} /* end function version_local() */
|
115
third_party/infozip/zip/acorn/makefile
vendored
Normal file
115
third_party/infozip/zip/acorn/makefile
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
|
||||
|
||||
# add -g to CC to debug
|
||||
# add -d to BIND to debug
|
||||
CC = cc
|
||||
BIND = link
|
||||
AS = $(CC) -c
|
||||
ASM = objasm
|
||||
SQUEEZE = squeeze -v
|
||||
E =
|
||||
|
||||
# flags
|
||||
# CFLAGS flags for C compile
|
||||
# LFLAGS1 flags after output file spec, before obj file list
|
||||
# LFLAGS2 flags after obj file list (libraries, etc)
|
||||
#
|
||||
LIB =
|
||||
CBASE = -throwback -wn -DASMV -apcs 3/26
|
||||
CFLAGS = $(CBASE) -IC:,@.
|
||||
ASMFLAGS = -Throwback -Stamp -NoCache -CloseExec -quit -apcs 3/26
|
||||
LFLAGS1 =
|
||||
LFLAGS2 = $(LIB) C:o.Stubs
|
||||
|
||||
# Uncomment the following line to enable support for Unix
|
||||
# Extra Field (Timezone)
|
||||
#CFLAGS = $(CFLAGS) -DUSE_EF_UT_TIME
|
||||
|
||||
# object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crc32.o \
|
||||
crypt.o ttyio.o riscos.o acornzip.o swiven.o
|
||||
|
||||
OBJI = deflate.o trees.o
|
||||
OBJA = match.o sendbits.o
|
||||
OBJU = zipfile_.o fileio_.o util_.o globals.o riscos.o acornzip_.o swiven.o
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
ZIP_H = zip.h ziperr.h tailor.h acorn/osdep.h acorn/riscos.h acorn/swiven.h
|
||||
|
||||
all: zip zipnote zipsplit zipcloak
|
||||
|
||||
|
||||
install: %.zip %.zipnote %.zipsplit %.zipcloak %.zipsfx \
|
||||
zip zipnote zipsplit zipcloak zipsfx
|
||||
$(SQUEEZE) zip %.zip
|
||||
$(SQUEEZE) zipnote %.zipnote
|
||||
$(SQUEEZE) zipsplit %.zipsplit
|
||||
$(SQUEEZE) zipcloak %.zipcloak
|
||||
copy acorn.zipsfx %.zipsfx ~CVF
|
||||
|
||||
# suffix rules
|
||||
.SUFFIXES: _.o .o .c
|
||||
.c_.o:
|
||||
$(CC) $(CFLAGS) -DUTIL -c $*.c -o $*_.o
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
.s.o:
|
||||
$(ASM) $(ASMFLAGS) -from @*.s -to @*.o
|
||||
|
||||
# rules for zip, zipnote, zipcloak and zipsplit
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
|
||||
crc32_.o: crc32.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.crc32 -o o.crc32_
|
||||
crypt_.o: crypt.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.crypt -o o.crypt_
|
||||
util_.o: util.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.util -o o.util_
|
||||
fileio_.o: fileio.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.fileio -o o.fileio_
|
||||
zipfile_.o: zipfile.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c c.zipfile -o o.zipfile_
|
||||
acornzip_.o: acorn/acornzip.c $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -DUTIL -c acorn/acornzip.c -o o.acornzip_
|
||||
|
||||
riscos.o: acorn/riscos.c acorn/riscos.h
|
||||
$(CC) $(CFLAGS) -c acorn/riscos.c
|
||||
|
||||
acornzip.o: acorn/acornzip.c $(ZIP_H)
|
||||
$(CC) $(CFLAGS) -c acorn/acornzip.c
|
||||
|
||||
match.o: acorn/match.s
|
||||
$(ASM) $(ASMFLAGS) -from acorn.s.match -to o.match
|
||||
|
||||
sendbits.o: acorn/sendbits.s
|
||||
$(ASM) $(ASMFLAGS) -from acorn.s.sendbits -to o.sendbits
|
||||
|
||||
swiven.o: acorn/swiven.s
|
||||
$(ASM) $(ASMFLAGS) -from acorn.s.swiven -to o.swiven
|
||||
|
||||
zip: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(BIND) -o zip$(E) $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
zipnote: $(OBJN)
|
||||
$(BIND) -o zipnote$(E) $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
zipcloak: $(OBJC)
|
||||
$(BIND) -o zipcloak$(E) $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
zipsplit: $(OBJS)
|
||||
$(BIND) -o zipsplit$(E) $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
clean: ;remove zip; remove zipcloak;
|
||||
remove zipsplit; remove zipnote;
|
||||
create o.!fake! 0
|
||||
wipe o.* ~cf
|
||||
|
||||
# end of Makefile
|
217
third_party/infozip/zip/acorn/match.s
vendored
Normal file
217
third_party/infozip/zip/acorn/match.s
vendored
Normal file
|
@ -0,0 +1,217 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; match.s for ARM by Sergio Monesi.
|
||||
|
||||
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
|
||||
sl RN 10
|
||||
fp RN 11
|
||||
ip RN 12
|
||||
sp RN 13
|
||||
lr RN 14
|
||||
pc RN 15
|
||||
|
||||
MAX_DIST EQU 32506
|
||||
WMASK EQU 32767
|
||||
MAX_MATCH EQU 258
|
||||
|
||||
AREA |C$$code|, CODE, READONLY
|
||||
|
||||
|
||||
; r1 = chain_lenght
|
||||
; r2 = scan
|
||||
; r3 = match
|
||||
; r4 = len (tmp)
|
||||
; r5 = best_len
|
||||
; r6 = limit
|
||||
; r7 = strend
|
||||
; r8 = scan_end1
|
||||
; r9 = scan_end
|
||||
; lr = window
|
||||
; fp = prev
|
||||
|
||||
|__max_chain_length|
|
||||
IMPORT max_chain_length
|
||||
DCD max_chain_length
|
||||
|__window|
|
||||
IMPORT window
|
||||
DCD window
|
||||
|__prev|
|
||||
IMPORT prev
|
||||
DCD prev
|
||||
|__prev_length|
|
||||
IMPORT prev_length
|
||||
DCD prev_length
|
||||
|__strstart|
|
||||
IMPORT strstart
|
||||
DCD strstart
|
||||
|__good_match|
|
||||
IMPORT good_match
|
||||
DCD good_match
|
||||
|__nice_match|
|
||||
IMPORT nice_match
|
||||
DCD nice_match
|
||||
|__match_start|
|
||||
IMPORT match_start
|
||||
DCD match_start
|
||||
|
||||
DCB "longest_match"
|
||||
DCB &00,&00,&00
|
||||
DCD &ff000010
|
||||
|
||||
EXPORT longest_match
|
||||
longest_match
|
||||
STMFD sp!, {r4-r9,fp,lr}
|
||||
|
||||
LDR fp, [pc, #|__prev|-.-8]
|
||||
|
||||
LDR r1, [pc, #|__max_chain_length|-.-8]
|
||||
LDR r1, [r1]
|
||||
LDR lr, [pc, #|__window|-.-8]
|
||||
|
||||
LDR ip, [pc, #|__strstart|-.-8]
|
||||
LDR ip, [ip]
|
||||
ADD r2, lr, ip
|
||||
LDR r5, [pc, #|__prev_length|-.-8]
|
||||
LDR r5, [r5]
|
||||
SUBS ip, ip, #MAX_DIST-250 ; if r6 > MAX_DIST
|
||||
SUBCSS r6, ip, #250 ; r6 = r6 - MAXDIST
|
||||
MOVLS r6, #0 ; else r6 = 0
|
||||
|
||||
ADD r7, r2, #MAX_MATCH-256
|
||||
ADD r7, r7, #256 ; r7 = r2 + MAX_MATCH (=258);
|
||||
|
||||
SUB ip, r5, #1
|
||||
LDRB r8, [r2, ip]
|
||||
LDRB r9, [r2, r5]
|
||||
|
||||
LDR ip, [pc, #|__good_match|-.-8]
|
||||
LDR ip, [ip]
|
||||
CMP r5, ip
|
||||
MOVCS r1, r1, LSR #2
|
||||
|
||||
cycle
|
||||
ADD r3, lr, r0
|
||||
|
||||
LDRB ip, [r3, r5]
|
||||
CMP ip, r9
|
||||
BNE cycle_end
|
||||
|
||||
SUB ip, r5, #1
|
||||
LDRB ip, [r3, ip]
|
||||
CMP ip, r8
|
||||
BNE cycle_end
|
||||
|
||||
LDRB ip, [r2]
|
||||
LDRB r4, [r3]
|
||||
CMP ip, r4
|
||||
BNE cycle_end
|
||||
|
||||
LDRB ip, [r3, #1]
|
||||
LDRB r4, [r2, #1]
|
||||
CMP ip, r4
|
||||
BNE cycle_end
|
||||
|
||||
ADD r2, r2, #2
|
||||
ADD r3, r3, #2
|
||||
|
||||
inn_cycle
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
LDRB ip, [r2, #1]!
|
||||
LDRB r4, [r3, #1]!
|
||||
CMP ip, r4
|
||||
BNE exit_inn_cycle
|
||||
|
||||
CMP r2, r7
|
||||
BCC inn_cycle
|
||||
|
||||
exit_inn_cycle
|
||||
SUB r4, r2, r7 ; len = MAX_MATCH - (int)(strend - scan);
|
||||
ADD r4, r4, #MAX_MATCH-256
|
||||
ADD r4, r4, #256
|
||||
|
||||
SUB r2, r2, r4 ; scan = strend - MAX_MATCH
|
||||
|
||||
CMP r4, r5 ; if (len > best_len) {
|
||||
BLE cycle_end
|
||||
|
||||
LDR ip, [pc, #|__match_start|-.-8] ; match_start = cur_match;
|
||||
STR r0, [ip]
|
||||
MOV r5, r4 ; best_len = len;
|
||||
|
||||
LDR ip, [pc, #|__nice_match|-.-8] ; if (len >= nice_match)
|
||||
LDR ip, [ip]
|
||||
CMP r4, ip
|
||||
BGE exit_match ; break;
|
||||
|
||||
SUB ip, r5, #1 ; scan_end1 = scan[best_len-1];
|
||||
LDRB r8, [r2, ip]
|
||||
LDRB r9, [r2, r5] ; scan_end = scan[best_len];
|
||||
|
||||
cycle_end
|
||||
MOV ip, r0, LSL #17 ; cur_match & WMASK
|
||||
MOV ip, ip, LSR #17
|
||||
|
||||
LDR r0, [fp, ip, ASL #1] ; cur_match = prev[cur_match & WMASK]
|
||||
MOV r0, r0, ASL #16
|
||||
MOV r0, r0, LSR #16
|
||||
|
||||
CMP r0, r6 ; cur_match > limit
|
||||
BLS exit_match
|
||||
SUBS r1, r1, #1 ; --chain_length
|
||||
BNE cycle ; chain_length != 0
|
||||
|
||||
exit_match
|
||||
MOV r0, r5
|
||||
|
||||
LDMFD sp!, {r4-r9,fp,pc}^
|
||||
|
||||
END
|
28
third_party/infozip/zip/acorn/osdep.h
vendored
Normal file
28
third_party/infozip/zip/acorn/osdep.h
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
#include "riscos.h"
|
||||
|
||||
#define RISCOS
|
||||
#define NO_SYMLINKS
|
||||
#define NO_FCNTL_H
|
||||
#define NO_UNISTD_H
|
||||
#define NO_MKTEMP
|
||||
|
||||
#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \
|
||||
procname(n, 1))
|
||||
|
||||
#define isatty(a) 1
|
||||
#define fseek(f,o,t) riscos_fseek((f),(o),(t))
|
||||
|
||||
#define localtime riscos_localtime
|
||||
#define gmtime riscos_gmtime
|
||||
|
||||
#ifdef ZCRYPT_INTERNAL
|
||||
# define ZCR_SEED2 (unsigned)3141592654L /* use PI as seed pattern */
|
||||
#endif
|
394
third_party/infozip/zip/acorn/riscos.c
vendored
Normal file
394
third_party/infozip/zip/acorn/riscos.c
vendored
Normal file
|
@ -0,0 +1,394 @@
|
|||
/*
|
||||
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* riscos.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "zip.h"
|
||||
#include "riscos.h"
|
||||
|
||||
#define MAXEXT 256
|
||||
|
||||
/* External globals */
|
||||
extern int scanimage;
|
||||
|
||||
/* Local globals (!?!?) */
|
||||
char *exts2swap = NULL; /* Extensions to swap (actually, directory names) */
|
||||
|
||||
int stat(char *filename,struct stat *res)
|
||||
{
|
||||
int attr; /* object attributes */
|
||||
unsigned int load; /* load address */
|
||||
unsigned int exec; /* exec address */
|
||||
int type; /* type: 0 not found, 1 file, 2 dir, 3 image */
|
||||
|
||||
if (!res)
|
||||
return -1;
|
||||
|
||||
if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
|
||||
return -1;
|
||||
|
||||
if (type==0)
|
||||
return -1;
|
||||
|
||||
res->st_dev=0;
|
||||
res->st_ino=0;
|
||||
res->st_nlink=0;
|
||||
res->st_uid=1;
|
||||
res->st_gid=1;
|
||||
res->st_rdev=0;
|
||||
res->st_blksize=1024;
|
||||
|
||||
res->st_mode = ((attr & 0001) << 8) | ((attr & 0002) << 6) |
|
||||
((attr & 0020) >> 2) | ((attr & 0040) >> 4);
|
||||
|
||||
switch (type) {
|
||||
case 1: /* File */
|
||||
res->st_mode |= S_IFREG;
|
||||
break;
|
||||
case 2: /* Directory */
|
||||
res->st_mode |= S_IFDIR | 0700;
|
||||
break;
|
||||
case 3: /* Image file */
|
||||
if (scanimage)
|
||||
res->st_mode |= S_IFDIR | 0700;
|
||||
else
|
||||
res->st_mode |= S_IFREG;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((((unsigned int) load) >> 20) == 0xfff) { /* date stamped file */
|
||||
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 && !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 deletedir(char *d)
|
||||
{
|
||||
int objtype;
|
||||
char *s;
|
||||
int len;
|
||||
os_error *er;
|
||||
|
||||
len = strlen(d);
|
||||
if ((s = malloc(len + 1)) == NULL)
|
||||
return -1;
|
||||
|
||||
strcpy(s,d);
|
||||
if (s[len-1]=='.')
|
||||
s[len-1]=0;
|
||||
|
||||
if (er=SWI_OS_File_5(s,&objtype,NULL,NULL,NULL,NULL),er!=NULL) {
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
if (objtype<2 || (!scanimage && objtype==3)) {
|
||||
/* this is a file or it doesn't exist */
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (er=SWI_OS_File_6(s),er!=NULL) {
|
||||
/* maybe this is a problem with the DDEUtils module, try to canonicalise the path */
|
||||
char canon[256];
|
||||
int size=255;
|
||||
|
||||
if (er=SWI_OS_FSControl_37(s,canon,&size),er!=NULL) {
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
if (er=SWI_OS_File_6(canon),er!=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;
|
||||
|
||||
if (extptr != NULL) 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;
|
||||
}
|
||||
|
||||
int swapext(char *name, char *exptr)
|
||||
{
|
||||
char *ext;
|
||||
char *p1=exptr;
|
||||
char *p2;
|
||||
int extchar=*exptr;
|
||||
unsigned int i=0;
|
||||
|
||||
while(*++p1 && *p1!='.' && *p1!='/')
|
||||
;
|
||||
ext=malloc(i=p1-exptr);
|
||||
if (!ext)
|
||||
return 1;
|
||||
memcpy(ext, exptr+1, i);
|
||||
p2=exptr-1;
|
||||
p1=exptr+i-1;
|
||||
while(p2 >= name)
|
||||
*p1--=*p2--;
|
||||
strcpy(name,ext);
|
||||
*p1=(extchar=='/'?'.':'/');
|
||||
free(ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
int riscos_fseek(FILE *fd, long offset, int whence)
|
||||
{
|
||||
int ret;
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_END:
|
||||
ret = (fseek) (fd, 0, SEEK_END);
|
||||
if (ret)
|
||||
return ret;
|
||||
/* fall through */
|
||||
case SEEK_CUR:
|
||||
offset += ftell (fd);
|
||||
/* fall through */
|
||||
default: /* SEEK_SET */
|
||||
return (fseek) (fd, offset < 0 ? 0 : offset, SEEK_SET);
|
||||
}
|
||||
}
|
119
third_party/infozip/zip/acorn/riscos.h
vendored
Normal file
119
third_party/infozip/zip/acorn/riscos.h
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* riscos.h */
|
||||
|
||||
#ifndef __riscos_h
|
||||
#define __riscos_h
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.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;
|
||||
|
||||
#define dstrm DIR
|
||||
|
||||
struct dirent {
|
||||
unsigned int d_off; /* offset of next disk directory entry */
|
||||
int d_fileno; /* file number of entry */
|
||||
size_t d_reclen; /* length of this record */
|
||||
size_t d_namlen; /* length of d_name */
|
||||
char d_name[MAXFILENAMELEN]; /* name */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned int load_addr;
|
||||
unsigned int exec_addr;
|
||||
int lenght;
|
||||
int attrib;
|
||||
int objtype;
|
||||
char name[13];
|
||||
} riscos_direntry;
|
||||
|
||||
#define SPARKID 0x4341 /* = "AC" */
|
||||
#define SPARKID_2 0x30435241 /* = "ARC0" */
|
||||
|
||||
typedef struct {
|
||||
short ID;
|
||||
short size;
|
||||
int ID_2;
|
||||
unsigned int loadaddr;
|
||||
unsigned int execaddr;
|
||||
int attr;
|
||||
int zero;
|
||||
} extra_block;
|
||||
|
||||
|
||||
#define S_IFMT 0770000
|
||||
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFREG 0100000 /* 0200000 in UnixLib !?!?!?!? */
|
||||
|
||||
#ifndef S_IEXEC
|
||||
# define S_IEXEC 0000100
|
||||
# define S_IWRITE 0000200
|
||||
# define S_IREAD 0000400
|
||||
#endif
|
||||
|
||||
extern char *exts2swap; /* Extensions to swap */
|
||||
|
||||
int stat(char *filename,struct stat *res);
|
||||
DIR *opendir(char *dirname);
|
||||
struct dirent *readdir(DIR *d);
|
||||
char *readd(DIR *d);
|
||||
void closedir(DIR *d);
|
||||
int unlink(char *f);
|
||||
int chmod(char *file, int mode);
|
||||
void setfiletype(char *fname,int ftype);
|
||||
void getRISCOSexts(char *envstr);
|
||||
int checkext(char *suff);
|
||||
int 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);
|
||||
|
||||
int riscos_fseek(FILE *fd, long offset, int whence);
|
||||
/* work around broken assumption that fseek() is OK with -ve file offsets */
|
||||
|
||||
#endif /* !__riscos_h */
|
105
third_party/infozip/zip/acorn/sendbits.s
vendored
Normal file
105
third_party/infozip/zip/acorn/sendbits.s
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; sendbits.s for ARM by Sergio Monesi and Darren Salt.
|
||||
|
||||
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
|
||||
sl RN 10
|
||||
fp RN 11
|
||||
ip RN 12
|
||||
sp RN 13
|
||||
lr RN 14
|
||||
pc RN 15
|
||||
|
||||
AREA |Asm$$Code|, CODE, READONLY
|
||||
|
||||
= "send_bits",0
|
||||
ALIGN
|
||||
& &FF00000C
|
||||
|
||||
IMPORT __rt_stkovf_split_small
|
||||
IMPORT flush_outbuf
|
||||
|
||||
IMPORT bi_valid
|
||||
IMPORT bi_buf
|
||||
IMPORT out_size
|
||||
IMPORT out_offset
|
||||
IMPORT out_buf
|
||||
|
||||
EXPORT send_bits
|
||||
send_bits
|
||||
MOV ip,sp
|
||||
STMDB sp!,{r4,r5,fp,ip,lr,pc}
|
||||
SUB fp,ip,#4
|
||||
LDR r5,=bi_buf
|
||||
LDR r3,=bi_valid
|
||||
LDR r4,[r5]
|
||||
LDR r2,[r3]
|
||||
ORR r4,r4,r0,LSL r2 ; |= value<<bi_valid
|
||||
ADD r2,r2,r1 ; += length
|
||||
CMP r2,#&10
|
||||
STRLE r2,[r3] ; short? store & return
|
||||
STRLE r4,[r5]
|
||||
LDMLEDB fp,{r4,r5,fp,sp,pc}^
|
||||
|
||||
SUB r2,r2,#&10 ; adjust bi_valid, bi_buf
|
||||
MOV ip,r4,LSR #16 ; (done early, keeping the old bi_buf
|
||||
STR r2,[r3] ; in R4 for later storage)
|
||||
STR ip,[r5]
|
||||
|
||||
LDR r0,=out_size
|
||||
LDR r1,=out_offset
|
||||
LDR r0,[r0]
|
||||
LDR r2,[r1]
|
||||
SUB r0,r0,#1
|
||||
CMP r2,r0 ; if out_offset >= out_size-1
|
||||
LDRHS r0,=out_buf
|
||||
LDRHS r0,[r0]
|
||||
BLHS flush_outbuf ; then flush the buffer
|
||||
LDR r0,=out_buf
|
||||
LDR r1,=out_offset
|
||||
LDR r0,[r0]
|
||||
LDR r2,[r1]
|
||||
MOV r5,r4,LSR #8
|
||||
STRB r4,[r0,r2]! ; store 'old' bi_buf
|
||||
STRB r5,[r0,#1]
|
||||
ADD r2,r2,#2
|
||||
STR r2,[r1]
|
||||
|
||||
LDMDB fp,{r4,r5,fp,sp,pc}^
|
||||
|
||||
|
||||
ptr_bi & bi_valid
|
||||
& bi_buf
|
||||
|
||||
|
||||
= "bi_reverse",0
|
||||
ALIGN
|
||||
& &FF00000C
|
||||
|
||||
EXPORT bi_reverse
|
||||
bi_reverse
|
||||
MOV r2,#0
|
||||
loop MOVS r0,r0,LSR #1
|
||||
ADCS r2,r2,r2
|
||||
SUBS r1,r1,#1
|
||||
BNE loop
|
||||
MOV r0,r2
|
||||
MOVS pc,lr
|
||||
|
||||
|
||||
END
|
BIN
third_party/infozip/zip/acorn/srcrename
vendored
Normal file
BIN
third_party/infozip/zip/acorn/srcrename
vendored
Normal file
Binary file not shown.
59
third_party/infozip/zip/acorn/swiven.h
vendored
Normal file
59
third_party/infozip/zip/acorn/swiven.h
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/* swiven.h */
|
||||
|
||||
#ifndef __swiven_h
|
||||
#define __swiven_h
|
||||
|
||||
os_error *SWI_OS_FSControl_26(char *source, char *dest, int actionmask);
|
||||
/* copy */
|
||||
|
||||
os_error *SWI_OS_FSControl_27(char *filename, int actionmask);
|
||||
/* wipe */
|
||||
|
||||
os_error *SWI_OS_GBPB_9(char *dirname, void *buf, int *number,
|
||||
int *offset, int size, char *match);
|
||||
/* read dir */
|
||||
|
||||
os_error *SWI_OS_File_1(char *filename, unsigned int loadaddr,
|
||||
unsigned int execaddr, int attrib);
|
||||
/* write file attributes */
|
||||
|
||||
os_error *SWI_OS_File_5(char *filename, int *objtype, unsigned int *loadaddr,
|
||||
unsigned int *execaddr, int *length, int *attrib);
|
||||
/* read file info */
|
||||
|
||||
os_error *SWI_OS_File_6(char *filename);
|
||||
/* delete */
|
||||
|
||||
os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size);
|
||||
/* create an empty file */
|
||||
|
||||
os_error *SWI_OS_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 /* !__swiven_h */
|
276
third_party/infozip/zip/acorn/swiven.s
vendored
Normal file
276
third_party/infozip/zip/acorn/swiven.s
vendored
Normal file
|
@ -0,0 +1,276 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; SWI veneers used by Zip/Unzip
|
||||
;
|
||||
|
||||
r0 RN 0
|
||||
r1 RN 1
|
||||
r2 RN 2
|
||||
r3 RN 3
|
||||
r4 RN 4
|
||||
r5 RN 5
|
||||
r6 RN 6
|
||||
r7 RN 7
|
||||
r8 RN 8
|
||||
r9 RN 9
|
||||
r10 RN 10
|
||||
r11 RN 11
|
||||
r12 RN 12
|
||||
sp RN 13
|
||||
lr RN 14
|
||||
pc RN 15
|
||||
|
||||
sl RN 10
|
||||
fp RN 11
|
||||
ip RN 12
|
||||
|
||||
|
||||
XOS_Bit EQU &020000
|
||||
|
||||
OS_GBPB EQU &00000C
|
||||
OS_File EQU &000008
|
||||
OS_FSControl EQU &000029
|
||||
OS_CLI EQU &000005
|
||||
OS_ReadC EQU &000004
|
||||
OS_ReadVarVal EQU &000023
|
||||
DDEUtils_Prefix EQU &042580
|
||||
Territory_ReadCurrentTimeZone EQU &043048
|
||||
|
||||
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_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
|
9
third_party/infozip/zip/acorn/zipsfx
vendored
Normal file
9
third_party/infozip/zip/acorn/zipsfx
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
| zipsfx 0.1
|
||||
| Written by Darren Salt
|
||||
| Assumes that unzipsfx is on Run$Path (eg. in !Boot.Library)
|
||||
| Assumes that IfThere is available as either *command or utility
|
||||
|
||||
If "%1" = "" Then Error 220 Syntax: zipsfx |<archive> |<SEA>
|
||||
If "%0" = "" Then Error 220 Syntax: zipsfx |<archive> |<SEA>
|
||||
Copy Run:unzipsfx %1 A~C~D~F~L~N~R~S~T~V
|
||||
Print %0 { >> %1 }
|
16
third_party/infozip/zip/acorn/zipup.h
vendored
Normal file
16
third_party/infozip/zip/acorn/zipup.h
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#define fhow "r"
|
||||
#define fbad (NULL)
|
||||
typedef FILE *ftype;
|
||||
#define zopen(n,p) fopen(n,p)
|
||||
#define zread(f,b,n) fread((b),1,(n),(FILE*)(f))
|
||||
#define zclose(f) fclose(f)
|
||||
#define zerr(f) (k==(extent)(-1L))
|
||||
#define zstdin 0
|
117
third_party/infozip/zip/amiga/LMKfile
vendored
Normal file
117
third_party/infozip/zip/amiga/LMKfile
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
# Makefile for Zip, ZipNote, ZipCloak and ZipSplit, Amiga SAS/C 5.10b
|
||||
# See the master Makefile under the top level Zip/Unzip source directory
|
||||
# for more information on compiler macros and flags for this version.
|
||||
# Last update: Jan 07, 2007
|
||||
# -John Bush, <J.Bush@MD-B.Prime.COM>, <JBush@BIX.COM>
|
||||
|
||||
|
||||
#######################
|
||||
# MACROBE DEFINITIONS #
|
||||
#######################
|
||||
|
||||
# Compiler and loader debug flags. Omit comments as req'd.
|
||||
# Do not set when building production version.
|
||||
# CDBG = -d3
|
||||
# LDBG = ADDSYM
|
||||
|
||||
DEFINES = -DNO_MKTEMP
|
||||
CC = lc
|
||||
OPT = -O
|
||||
CFLAGS = $(OPT) $(DEFINES) $(CDBG) -v -mat -cuisf -b0 -j85i86i87i100i
|
||||
|
||||
LD = blink
|
||||
LDSTART = LIB:c.o
|
||||
LDFLAGS = LIB LIB:lc.lib+LIB:amiga.lib
|
||||
|
||||
TMPFILE = ram:MakeZip.tmp
|
||||
|
||||
###############################################
|
||||
# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
|
||||
###############################################
|
||||
|
||||
# default C rules
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o$@ $*.c
|
||||
|
||||
# Alternate rules for routines containing entries needed by utilities
|
||||
.c.oo:
|
||||
$(CC) $(CFLAGS) -DUTIL -o$*.oo $*.c
|
||||
|
||||
# object file macrough lists
|
||||
|
||||
HFILES = zip.h ziperr.h tailor.h revision.h crc32.h crypt.h ttyio.h \
|
||||
amiga/amiga.h amiga/zipup.h amiga/osdep.h
|
||||
|
||||
OBJA = zipfile.o zipup.o fileio.o util.o globals.o crc32.o crypt.o \
|
||||
timezone.o ttyio.o amiga.o amigazip.o filedate.o
|
||||
OBJI = deflate.o trees.o
|
||||
OBJU = zipfile.oo fileio.oo util.oo globals.o timezone.o \
|
||||
amiga.o amigazip.oo filedate.o
|
||||
|
||||
OBJZ = zip.o $(OBJA) $(OBJI)
|
||||
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32.oo crypt.oo ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
ZIPS = zip zipnote zipcloak zipsplit
|
||||
|
||||
all: Message $(ZIPS)
|
||||
|
||||
Message:
|
||||
-echo " "
|
||||
-echo "WARNING: Lattice 5.x HAS NOT BEEN TESTED WITH THIS ZIP VERSION"
|
||||
-echo "Report problems to <zip-bugs@lists.wku.edu>"
|
||||
-echo " "
|
||||
|
||||
zip: $(OBJZ) $(HFILES)
|
||||
-echo "$(OBJZ)" > $(TMPFILE)
|
||||
$(LD) TO Zip FROM $(LDSTART) WITH $(TMPFILE) $(LDFLAGS) $(LDBG)
|
||||
-delete $(TMPFILE) Zip.info
|
||||
|
||||
zipnote: $(OBJN) $(HFILES)
|
||||
-echo "$(OBJN)" > $(TMPFILE)
|
||||
$(LD) TO ZipNote FROM $(LDSTART) WITH $(TMPFILE) $(LDFLAGS) $(LDBG)
|
||||
-delete $(TMPFILE) ZipNote.info
|
||||
|
||||
zipcloak: $(OBJC) $(HFILES)
|
||||
-echo "$(OBJC)" > $(TMPFILE)
|
||||
$(LD) TO ZipCloak FROM $(LDSTART) WITH $(TMPFILE) $(LDFLAGS) $(LDBG)
|
||||
-delete $(TMPFILE) ZipCloak.info
|
||||
|
||||
zipsplit: $(OBJS) $(HFILES)
|
||||
-echo "$(OBJS)" > $(TMPFILE)
|
||||
$(LD) TO ZipSplit FROM $(LDSTART) WITH $(TMPFILE) $(LDFLAGS) $(LDBG)
|
||||
-delete $(TMPFILE) ZipSplit.info
|
||||
|
||||
clean:
|
||||
-delete $(OBJZ) all quiet force >nil:
|
||||
-delete $(OBJU) all quiet force >nil:
|
||||
-delete $(OBJA) all quiet force >nil:
|
||||
-delete $(OBJI) all quiet force >nil:
|
||||
-delete $(OBJN) all quiet force >nil:
|
||||
-delete $(OBJC) all quiet force >nil:
|
||||
-delete $(OBJS) all quiet force >nil:
|
||||
|
||||
zip.o: zip.c $(HFILES)
|
||||
zipnote.o: zipnote.c $(HFILES)
|
||||
zipcloak.o: zipcloak.c $(HFILES)
|
||||
crypt.o: crypt.c $(HFILES)
|
||||
ttyio.o: ttyio.c $(HFILES)
|
||||
zipsplit.o: zipsplit.c $(HFILES)
|
||||
deflate.o: deflate.c $(HFILES)
|
||||
trees.o: trees.c $(HFILES)
|
||||
zipfile.o: zipfile.c $(HFILES)
|
||||
zipup.o: zipup.c $(HFILES)
|
||||
fileio.o: fileio.c $(HFILES)
|
||||
util.o: util.c $(HFILES)
|
||||
timezone.o: timezone.c $(HFILES) timezone.h
|
||||
crc32.o: crc32.c $(HFILES)
|
||||
crctab.o: crctab.c $(HFILES)
|
||||
globals.o: globals.c $(HFILES)
|
||||
|
||||
# Amiga specific objects
|
||||
amiga.o: amiga/amiga.c $(HFILES)
|
||||
amigazip.o: amiga/amigazip.c $(HFILES)
|
||||
|
||||
# end of Makefile
|
1
third_party/infozip/zip/amiga/README
vendored
Normal file
1
third_party/infozip/zip/amiga/README
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
the -A option currently does not work for the amiga.
|
138
third_party/infozip/zip/amiga/amiga.c
vendored
Normal file
138
third_party/infozip/zip/amiga/amiga.c
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2005-Feb-10 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* OS specific routines for AMIGA platform.
|
||||
*
|
||||
* John Bush <John.Bush@east.sun.com> BIX: jbush
|
||||
* Paul Kienitz <kie@pacbell.net>
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Date DoBee Comments
|
||||
* ------- -------- -----------------------------------------------
|
||||
* 21Jan93 JBush Original coding.
|
||||
* Incorporated filedate.c (existing routine).
|
||||
*
|
||||
* 31Jan93 JBush Made filedate.c include unconditional.
|
||||
*
|
||||
* 18Jul93 PaulK Moved Aztec _abort() here from stat.c because we
|
||||
* can't share the same one between Zip and UnZip.
|
||||
* Added close_leftover_open_dirs() call to it.
|
||||
*
|
||||
* 17Apr95 PaulK Added Amiga internal version string so that
|
||||
* installer programs can compare the version being
|
||||
* installed to see if the copy the user already has
|
||||
* is older or newer. Added Prestart_Hook to support
|
||||
* debug tracing in deflate.a.
|
||||
*
|
||||
* 6May95 PaulK Added GetComment() for filenote support.
|
||||
*
|
||||
* 12Nov95 PaulK Added #define ZIP in front of filedate.c, for
|
||||
* new options in there; removed declare of set_con()
|
||||
* since echon() no longer expands to it (or anything).
|
||||
*
|
||||
* 12Feb96 PaulK Removed call of echon() entirely.
|
||||
*
|
||||
* 12Jul97 PaulK Made both Aztec and SAS define USE_TIME_LIB for filedate.c
|
||||
*
|
||||
* 26Aug97 PaulK Added ClearIOErr_exit()
|
||||
*
|
||||
* 2Jan98 HWalt Adapted for SAS/C using stat.c replacement functions
|
||||
*
|
||||
* 6Jun00 PaulK Removed references to time_lib, since new filedate.c
|
||||
* supercedes it
|
||||
*/
|
||||
|
||||
#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 <pragmas/exec_lib.h>
|
||||
# include <pragmas/dos_lib.h>
|
||||
#else
|
||||
# include <proto/exec.h>
|
||||
# include <proto/dos.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include "ziperr.h"
|
||||
void ziperr(int c, const char *h);
|
||||
|
||||
#define ZIP
|
||||
#if !defined(UTIL)
|
||||
# define NO_MKTIME
|
||||
#endif
|
||||
|
||||
#ifdef AZTEC_C
|
||||
|
||||
/* ============================================================= */
|
||||
/* filedate.c is an external file, since it's shared with UnZip. */
|
||||
/* Aztec includes it here, but SAS/C now compiles it separately. */
|
||||
# include "amiga/filedate.c"
|
||||
|
||||
/* the same applies to stat.c */
|
||||
# include "amiga/stat.c"
|
||||
|
||||
# define setenv BOGUS_INCOMPATIBLE_setenv
|
||||
# include <fcntl.h>
|
||||
# undef setenv
|
||||
# ifdef DEBUG
|
||||
# define PRESTART_HOOK
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern void close_leftover_open_dirs(void);
|
||||
|
||||
|
||||
/* the following handles cleanup when a ^C interrupt happens: */
|
||||
|
||||
void _abort(void) /* called when ^C is pressed */
|
||||
{
|
||||
close_leftover_open_dirs();
|
||||
ziperr(ZE_ABORT, "^C");
|
||||
}
|
||||
|
||||
void ClearIOErr_exit(int e) /* EXIT is defined as this */
|
||||
{
|
||||
if (!e)
|
||||
((struct Process *) FindTask(NULL))->pr_Result2 = 0;
|
||||
/* we clear IoErr() since we are successful, in a 1.x-compatible way */
|
||||
exit(e);
|
||||
}
|
||||
|
||||
|
||||
/* Make sure the version number here matches the number in revision.h */
|
||||
/* as closely as possible in strict decimal "#.#" form: */
|
||||
const char version_id[] = "\0$VER: Zip 2.3 ("
|
||||
# include "env:VersionDate"
|
||||
")\r\n";
|
||||
|
||||
/* call this with an arg of NULL to free storage: */
|
||||
|
||||
char *GetComment(char *filename)
|
||||
{
|
||||
BPTR lk;
|
||||
static struct FileInfoBlock *fib = NULL;
|
||||
|
||||
if (!filename) {
|
||||
if (fib) FreeMem(fib, sizeof(*fib));
|
||||
fib = NULL;
|
||||
return NULL;
|
||||
}
|
||||
if (!fib) {
|
||||
if (!(fib = AllocMem(sizeof(*fib), MEMF_PUBLIC)))
|
||||
ziperr(ZE_MEM, "was checking filenotes");
|
||||
}
|
||||
if (!(lk = Lock(filename, ACCESS_READ)))
|
||||
return NULL;
|
||||
if (!Examine(lk, fib))
|
||||
fib->fib_Comment[0] = '\0';
|
||||
UnLock(lk);
|
||||
return fib->fib_Comment[0] ? &fib->fib_Comment[0] : NULL;
|
||||
}
|
54
third_party/infozip/zip/amiga/amiga.h
vendored
Normal file
54
third_party/infozip/zip/amiga/amiga.h
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef __amiga_amiga_h
|
||||
#define __amiga_amiga_h
|
||||
|
||||
/* 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 version is for use with Zip. It is not globally included, but used
|
||||
* only by functions in amiga/amigazip.c. Much material that was needed for
|
||||
* UnZip is absent here.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
|
||||
#include "amiga/z-stat.h" /* substitute for <stat.h> and <dire(c|n)t.h> */
|
||||
#define direct dirent
|
||||
|
||||
#ifndef MODERN
|
||||
# define MODERN
|
||||
#endif
|
||||
|
||||
#ifdef AZTEC_C /* Manx Aztec C, 5.0 or newer only */
|
||||
# include <clib/dos_protos.h>
|
||||
# include <pragmas/dos_lib.h> /* do inline dos.library calls */
|
||||
# define O_BINARY 0
|
||||
#endif /* AZTEC_C */
|
||||
|
||||
|
||||
#ifdef __SASC
|
||||
# include <dirent.h>
|
||||
# include <dos.h>
|
||||
# define disk_not_mounted 0
|
||||
# if ( (!defined(O_BINARY)) && defined(O_RAW))
|
||||
# define O_BINARY O_RAW
|
||||
# endif
|
||||
#endif /* SASC */
|
||||
|
||||
|
||||
/* Funkshine Prough Toe Taipes */
|
||||
|
||||
LONG FileDate (char *, time_t[]);
|
||||
|
||||
#endif /* __amiga_amiga_h */
|
507
third_party/infozip/zip/amiga/amigazip.c
vendored
Normal file
507
third_party/infozip/zip/amiga/amigazip.c
vendored
Normal file
|
@ -0,0 +1,507 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#include "zip.h"
|
||||
#include "amiga/amiga.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#define utime FileDate
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
/* Local globals (kinda like "military intelligence" or "broadcast quality") */
|
||||
|
||||
extern char *label; /* still declared in fileio.c */
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
/* Local functions */
|
||||
local char *readd OF((DIR *));
|
||||
local int wild_recurse OF((char *, char *));
|
||||
|
||||
|
||||
local char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
|
||||
/* What we have here is a mostly-generic routine using opendir()/readd() and */
|
||||
/* isshexp()/MATCH() to find all the files matching a multi-part filespec */
|
||||
/* using the portable pattern syntax. It shouldn't take too much fiddling */
|
||||
/* to make it usable for any other platform that has directory hierarchies */
|
||||
/* but no shell-level pattern matching. It works for patterns throughout */
|
||||
/* the pathname, such as "foo:*.?/source/x*.[ch]". */
|
||||
|
||||
#define ONENAMELEN 30
|
||||
/* the length of one filename component on the Amiga */
|
||||
|
||||
/* whole is a pathname with wildcards, wildtail points somewhere in the */
|
||||
/* middle of it. All wildcards to be expanded must come AFTER wildtail. */
|
||||
|
||||
local int wild_recurse(whole, wildtail) char *whole; char *wildtail;
|
||||
{
|
||||
DIR *dir;
|
||||
char *subwild, *name, *newwhole = NULL, *glue = NULL, plug = 0, plug2;
|
||||
ush newlen, amatch = 0;
|
||||
BPTR lok;
|
||||
int e = ZE_MISS;
|
||||
|
||||
if (!isshexp(wildtail))
|
||||
if (lok = Lock(whole, ACCESS_READ)) { /* p exists? */
|
||||
UnLock(lok);
|
||||
return procname(whole, 0);
|
||||
} else
|
||||
return ZE_MISS; /* woops, no wildcards! */
|
||||
|
||||
/* back up thru path components till existing dir found */
|
||||
do {
|
||||
name = wildtail + strlen(wildtail) - 1;
|
||||
for (;;)
|
||||
if (name-- <= wildtail || *name == PATH_END) {
|
||||
subwild = name + 1;
|
||||
plug2 = *subwild;
|
||||
*subwild = 0;
|
||||
break;
|
||||
}
|
||||
if (glue)
|
||||
*glue = plug;
|
||||
glue = subwild;
|
||||
plug = plug2;
|
||||
dir = opendir(whole);
|
||||
} while (!dir && !disk_not_mounted && subwild > wildtail);
|
||||
wildtail = subwild; /* skip past non-wild components */
|
||||
|
||||
if ((subwild = strchr(wildtail + 1, PATH_END)) != NULL) {
|
||||
/* this "+ 1" dodges the ^^^ hole left by *glue == 0 */
|
||||
*(subwild++) = 0; /* wildtail = one component pattern */
|
||||
newlen = strlen(whole) + strlen(subwild) + (ONENAMELEN + 2);
|
||||
} else
|
||||
newlen = strlen(whole) + (ONENAMELEN + 1);
|
||||
if (!dir || !(newwhole = malloc(newlen))) {
|
||||
if (glue)
|
||||
*glue = plug;
|
||||
|
||||
e = dir ? ZE_MEM : ZE_MISS;
|
||||
goto ohforgetit;
|
||||
}
|
||||
strcpy(newwhole, whole);
|
||||
newlen = strlen(newwhole);
|
||||
if (glue)
|
||||
*glue = plug; /* repair damage to whole */
|
||||
if (!isshexp(wildtail)) {
|
||||
e = ZE_MISS; /* non-wild name not found */
|
||||
goto ohforgetit;
|
||||
}
|
||||
|
||||
while (name = readd(dir)) {
|
||||
if (MATCH(wildtail, name, 0)) {
|
||||
strcpy(newwhole + newlen, name);
|
||||
if (subwild) {
|
||||
name = newwhole + strlen(newwhole);
|
||||
*(name++) = PATH_END;
|
||||
strcpy(name, subwild);
|
||||
e = wild_recurse(newwhole, name);
|
||||
} else
|
||||
e = procname(newwhole, 0);
|
||||
newwhole[newlen] = 0;
|
||||
if (e == ZE_OK)
|
||||
amatch = 1;
|
||||
else if (e != ZE_MISS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ohforgetit:
|
||||
if (dir) closedir(dir);
|
||||
if (subwild) *--subwild = PATH_END;
|
||||
if (newwhole) free(newwhole);
|
||||
if (e == ZE_MISS && amatch)
|
||||
e = ZE_OK;
|
||||
return e;
|
||||
}
|
||||
|
||||
int wild(p) char *p;
|
||||
{
|
||||
char *use;
|
||||
|
||||
/* special handling of stdin request */
|
||||
if (strcmp(p, "-") == 0) /* if compressing stdin */
|
||||
return newname(p, 0, 0);
|
||||
|
||||
/* wild_recurse() can't handle colons in wildcard part: */
|
||||
if (use = strchr(p, ':')) {
|
||||
if (strchr(++use, ':'))
|
||||
return ZE_PARMS;
|
||||
} else
|
||||
use = p;
|
||||
|
||||
return wild_recurse(p, use);
|
||||
}
|
||||
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if ((s.st_mode & S_IFDIR) == 0)
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (*p && a[-1] != '/' && a[-1] != ':')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t; /* shortened name */
|
||||
int dosflag;
|
||||
|
||||
dosflag = dosify; /* default for non-DOS and non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
if ((t = strrchr(x, ':')) != NULL) /* reject ":" */
|
||||
t++;
|
||||
else
|
||||
t = x;
|
||||
{ /* reject "//" */
|
||||
char *tt = t;
|
||||
while (tt = strchr(tt, '/'))
|
||||
while (*++tt == '/')
|
||||
t = tt;
|
||||
}
|
||||
while (*t == '/') /* reject leading "/" on what's left */
|
||||
t++;
|
||||
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
|
||||
if (dosify)
|
||||
msname(n);
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
time_t u[2]; /* argument for utime() */
|
||||
|
||||
/* Convert DOS time to time_t format in u */
|
||||
u[0] = u[1] = dos2unixtime(d);
|
||||
|
||||
/* Set updated and accessed times of f */
|
||||
utime(f, u);
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
/* convert FNMAX to malloc - 11/8/04 EG */
|
||||
char *name;
|
||||
int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL) {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '/')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
|
||||
if (strcmp(f, "-") == 0) {
|
||||
if (fstat(fileno(stdin), &s) != 0)
|
||||
error("fstat(stdin)");
|
||||
} else if (SSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (a != NULL) {
|
||||
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
|
||||
if ((s.st_mode & S_IFDIR) != 0) {
|
||||
*a |= MSDOS_DIR_ATTR;
|
||||
}
|
||||
}
|
||||
if (n != NULL)
|
||||
*n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = s.st_ctime;
|
||||
}
|
||||
|
||||
return unix2dostime(&s.st_mtime);
|
||||
}
|
||||
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* create extra field and change z->att if desired */
|
||||
{
|
||||
#ifdef USE_EF_UT_TIME
|
||||
#ifdef IZ_CHECK_TZ
|
||||
if (!zp_tz_is_valid) return ZE_OK; /* skip silently if no valid TZ info */
|
||||
#endif
|
||||
|
||||
if ((z->extra = (char *)malloc(EB_HEADSIZE+EB_UT_LEN(1))) == NULL)
|
||||
return ZE_MEM;
|
||||
|
||||
z->extra[0] = 'U';
|
||||
z->extra[1] = 'T';
|
||||
z->extra[2] = EB_UT_LEN(1); /* length of data part of e.f. */
|
||||
z->extra[3] = 0;
|
||||
z->extra[4] = EB_UT_FL_MTIME;
|
||||
z->extra[5] = (char)(z_utim->mtime);
|
||||
z->extra[6] = (char)(z_utim->mtime >> 8);
|
||||
z->extra[7] = (char)(z_utim->mtime >> 16);
|
||||
z->extra[8] = (char)(z_utim->mtime >> 24);
|
||||
|
||||
z->cextra = z->extra;
|
||||
z->cext = z->ext = (EB_HEADSIZE+EB_UT_LEN(1));
|
||||
|
||||
return ZE_OK;
|
||||
#else /* !USE_EF_UT_TIME */
|
||||
return (int)(z-z);
|
||||
#endif /* ?USE_EF_UT_TIME */
|
||||
}
|
||||
|
||||
int deletedir(d)
|
||||
char *d; /* directory to delete */
|
||||
/* Delete the directory *d if it is empty, do nothing otherwise.
|
||||
Return the result of rmdir(), delete(), or system().
|
||||
For VMS, d must be in format [x.y]z.dir;1 (not [x.y.z]).
|
||||
*/
|
||||
{
|
||||
return rmdir(d);
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
|
||||
/* NOTE: the following include depends upon the environment
|
||||
* variable $Workbench to be set correctly. (Set by
|
||||
* default, by Version command in Startup-sequence.)
|
||||
*/
|
||||
int WBversion = (int)
|
||||
#include "ENV:Workbench"
|
||||
;
|
||||
|
||||
void version_local()
|
||||
{
|
||||
static ZCONST char CompiledWith[] = "Compiled with %s%s under %s%s%s%s.\n\n";
|
||||
|
||||
/* 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 above.
|
||||
* ("Compiled with %s%s under %s%s%s%s.")
|
||||
*/
|
||||
|
||||
printf(CompiledWith,
|
||||
buf1,
|
||||
buf2,
|
||||
buf3,
|
||||
buf4,
|
||||
/* buf5, */ "",
|
||||
"" ); /* buf6 not used */
|
||||
|
||||
} /* end function version_local() */
|
144
third_party/infozip/zip/amiga/crc_68.a
vendored
Normal file
144
third_party/infozip/zip/amiga/crc_68.a
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, all these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; crc_68 created by Paul Kienitz, last modified 04 Jan 96.
|
||||
;
|
||||
; Return an updated 32 bit CRC value, given the old value and a block of data.
|
||||
; The CRC table used to compute the value is gotten by calling get_crc_table().
|
||||
; This replaces the older updcrc() function used in Zip and fUnZip. The
|
||||
; prototype of the function is:
|
||||
;
|
||||
; ulg crc32(ulg crcval, uch *text, extent textlen);
|
||||
;
|
||||
; On the Amiga, type extent is always unsigned long, not unsigned int, because
|
||||
; int can be short or long at whim, but size_t is long.
|
||||
;
|
||||
; If using this source on a non-Amiga 680x0 system, note that we treat
|
||||
; a0/a1/d0/d1 as scratch registers not preserved across function calls.
|
||||
; We do not bother to support registerized arguments for crc32() -- the
|
||||
; textlen parm is usually large enough so that savings outside the loop
|
||||
; are pointless.
|
||||
;
|
||||
; Define NO_UNROLLED_LOOPS to use a simple short loop which might be more
|
||||
; efficient on certain machines with dinky instruction caches ('020?), or for
|
||||
; processing short strings. If loops are unrolled, the textlen parm must be
|
||||
; less than 512K; if not unrolled, it must be less than 64K.
|
||||
|
||||
xdef _crc32 ; (ulg val, uch *buf, extent bufsize)
|
||||
|
||||
DO_CRC0 MACRO
|
||||
moveq #0,ltemp
|
||||
move.b (textbuf)+,ltemp
|
||||
eor.b crcval,ltemp
|
||||
lsl.w #2,ltemp
|
||||
move.l (crc_table,ltemp.w),ltemp
|
||||
lsr.l #8,crcval
|
||||
eor.l ltemp,crcval
|
||||
ENDM
|
||||
|
||||
machine mc68020
|
||||
|
||||
DO_CRC2 MACRO
|
||||
move.b (textbuf)+,btemp
|
||||
eor.b crcval,btemp
|
||||
lsr.l #8,crcval
|
||||
move.l (crc_table,btemp.w*4),ltemp
|
||||
eor.l ltemp,crcval
|
||||
ENDM
|
||||
|
||||
crc_table equr a0 array of unsigned long
|
||||
crcval equr d0 unsigned long initial value
|
||||
textbuf equr a1 array of unsigned char
|
||||
textbufsize equr d1 unsigned long (count of bytes in textbuf)
|
||||
btemp equr d2
|
||||
ltemp equr d3
|
||||
|
||||
|
||||
xref _get_crc_table ; ulg *get_crc_table(void)
|
||||
|
||||
NOLIST
|
||||
INCLUDE 'exec/execbase.i'
|
||||
LIST
|
||||
xref _SysBase ; struct ExecBase *
|
||||
|
||||
|
||||
_crc32:
|
||||
move.l 8(sp),d0
|
||||
bne.s valid
|
||||
moveq #0,d0
|
||||
rts
|
||||
valid: movem.l btemp/ltemp,-(sp)
|
||||
jsr _get_crc_table
|
||||
move.l d0,ltemp
|
||||
move.l 12(sp),crcval
|
||||
move.l 16(sp),textbuf
|
||||
move.l 20(sp),textbufsize
|
||||
not.l crcval
|
||||
move.l _SysBase,crc_table
|
||||
move.w AttnFlags(crc_table),btemp
|
||||
move.l ltemp,crc_table
|
||||
btst #AFB_68020,btemp
|
||||
bne twenty
|
||||
|
||||
IFD NO_UNROLLED_LOOPS
|
||||
|
||||
bra.s decr
|
||||
loop: DO_CRC0
|
||||
decr: dbra textbufsize,loop
|
||||
bra.s done
|
||||
|
||||
twenty: moveq #0,btemp
|
||||
bra.s decr2
|
||||
loop2: DO_CRC2
|
||||
decr2: dbra textbufsize,loop2
|
||||
|
||||
ELSE ; !NO_UNROLLED_LOOPS
|
||||
|
||||
move.l textbufsize,btemp
|
||||
lsr.l #3,textbufsize
|
||||
bra decr8
|
||||
loop8: DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
DO_CRC0
|
||||
decr8: dbra textbufsize,loop8
|
||||
and.w #7,btemp
|
||||
bra.s decr1
|
||||
loop1: DO_CRC0
|
||||
decr1: dbra btemp,loop1
|
||||
bra done
|
||||
|
||||
twenty: moveq #0,btemp
|
||||
move.l textbufsize,-(sp)
|
||||
lsr.l #3,textbufsize
|
||||
bra decr82
|
||||
loop82: DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
DO_CRC2
|
||||
decr82: dbra textbufsize,loop82
|
||||
move.l (sp)+,textbufsize
|
||||
and.w #7,textbufsize
|
||||
bra.s decr12
|
||||
loop12: DO_CRC2
|
||||
decr12: dbra textbufsize,loop12
|
||||
|
||||
ENDC ; ?NO_UNROLLED_LOOPS
|
||||
|
||||
done: movem.l (sp)+,btemp/ltemp
|
||||
not.l crcval
|
||||
;;;;; move.l crcval,d0 ; crcval already is d0
|
||||
rts
|
1053
third_party/infozip/zip/amiga/deflate.a
vendored
Normal file
1053
third_party/infozip/zip/amiga/deflate.a
vendored
Normal file
File diff suppressed because it is too large
Load diff
599
third_party/infozip/zip/amiga/filedate.c
vendored
Normal file
599
third_party/infozip/zip/amiga/filedate.c
vendored
Normal file
|
@ -0,0 +1,599 @@
|
|||
/*
|
||||
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* Low-level Amiga routines shared between Zip and UnZip.
|
||||
*
|
||||
* Contains: FileDate()
|
||||
* getenv() [replaces inadequate standard library version]
|
||||
* setenv() [SAS/C only, replaces standard library version]
|
||||
* set_TZ() [SAS/C only]
|
||||
* GetPlatformLocalTimezone() [callback from timezone.c tzset()]
|
||||
* time()
|
||||
* sendpkt()
|
||||
* Agetch()
|
||||
*
|
||||
* The first five are used by most Info-ZIP programs except fUnZip.
|
||||
* The last two are used by all except the non-CRYPT version of fUnZip.
|
||||
* Probably some of the stuff in here is unused by ZipNote and ZipSplit too...
|
||||
* sendpkt() is used by Agetch() and FileDate(), and by screensize() in
|
||||
* amiga/amiga.c (UnZip); time() is used only by Zip.
|
||||
*/
|
||||
|
||||
|
||||
/* HISTORY/CHANGES
|
||||
* 2 Sep 92, Greg Roelofs, Original coding.
|
||||
* 6 Sep 92, John Bush, Incorporated into UnZip 5.1
|
||||
* 6 Sep 92, John Bush, Interlude "FileDate()" defined, which calls or
|
||||
* redefines SetFileDate() depending upon AMIGADOS2 definition.
|
||||
* 11 Oct 92, John Bush, Eliminated AMIGADOS2 switch by determining
|
||||
* revision via OpenLibrary() call. Now only one version of
|
||||
* the program runs on both platforms (1.3.x vs. 2.x)
|
||||
* 11 Oct 92, John Bush, Merged with Zip version and changed arg passing
|
||||
* to take time_t input instead of struct DateStamp.
|
||||
* Arg passing made to conform with utime().
|
||||
* 22 Nov 92, Paul Kienitz, fixed includes for Aztec and cleaned up some
|
||||
* lint-ish errors; simplified test for AmigaDOS version.
|
||||
* 11 Nov 95, Paul Kienitz, added Agetch() for crypt password input and
|
||||
* UnZip's "More" prompt -- simplifies crypt.h and avoids
|
||||
* use of library code redundant with sendpkt(). Made it
|
||||
* available to fUnZip, which does not use FileDate().
|
||||
* 22 Nov 95, Paul Kienitz, created a new tzset() that gets the current
|
||||
* timezone from the Locale preferences. These exist only under
|
||||
* AmigaDOS 2.1 and up, but it is probably correctly set on more
|
||||
* Amigas than the TZ environment variable is. We check that
|
||||
* only if TZ is not validly set. We do not parse daylight
|
||||
* savings syntax except to check for presence vs. absence of a
|
||||
* DST part; United States rules are assumed. This is better
|
||||
* than the tzset()s in the Amiga compilers' libraries do.
|
||||
* 15 Jan 96, Chr. Spieler, corrected the logic when to select low level
|
||||
* sendpkt() (when FileDate(), Agetch() or windowheight() is used),
|
||||
* and AMIGA's Agetch() (CRYPT, and UnZip(SFX)'s UzpMorePause()).
|
||||
* 10 Feb 96, Paul Kienitz, re-fiddled that selection logic again, moved
|
||||
* stuff around for clarity.
|
||||
* 16 Mar 96, Paul Kienitz, created a replacement localtime() to go with the
|
||||
* new tzset(), because Aztec's is hopelessly broken. Also
|
||||
* gmtime(), which localtime() calls.
|
||||
* 12 Apr 96, Paul Kienitz, daylight savings was being handled incorrectly.
|
||||
* 21 Apr 96, Paul Kienitz, had to replace time() as well, Aztec's returns
|
||||
* local time instead of GMT. That's why their localtime() was bad,
|
||||
* because it assumed time_t was already local, and gmtime() was
|
||||
* the one that checked TZ.
|
||||
* 23 Apr 96, Chr. Spieler, deactivated time() replacement for UnZip stuff.
|
||||
* Currently, the UnZip sources do not make use of time() (and do
|
||||
* not supply the working mktime() replacement, either!).
|
||||
* 29 Apr 96, Paul Kienitz, created a replacement getenv() out of code that
|
||||
* was previously embedded in tzset(), for reliable global test
|
||||
* of whether TZ is set or not.
|
||||
* 19 Jun 96, Haidinger Walter, re-adapted for current SAS/C compiler.
|
||||
* 7 Jul 96, Paul Kienitz, smoothed together compiler-related changes.
|
||||
* 4 Feb 97, Haidinger Walter, added set_TZ() for SAS/C.
|
||||
* 23 Apr 97, Paul Kienitz, corrected Unix->Amiga DST error by adding
|
||||
* mkgmtime() so localtime() could be used.
|
||||
* 28 Apr 97, Christian Spieler, deactivated mkgmtime() definition for ZIP;
|
||||
* the Zip sources supply this function as part of util.c.
|
||||
* 24 May 97, Haidinger Walter, added time_lib support for SAS/C and moved
|
||||
* set_TZ() to time_lib.c.
|
||||
* 12 Jul 97, Paul Kienitz, adapted time_lib stuff for Aztec.
|
||||
* 26 Jul 97, Chr. Spieler, old mkgmtime() fixed (ydays[] def, sign vs unsign).
|
||||
* 30 Dec 97, Haidinger Walter, adaptation for SAS/C using z-stat.h functions.
|
||||
* 19 Feb 98, Haidinger Walter, removed alloc_remember, more SAS.C fixes.
|
||||
* 23 Apr 98, Chr. Spieler, removed mkgmtime(), changed FileDate to convert to
|
||||
* Amiga file-time directly.
|
||||
* 24 Apr 98, Paul Kienitz, clip Unix dates earlier than 1978 in FileDate().
|
||||
* 02 Sep 98, Paul Kienitz, C. Spieler, always include zip.h to get a defined
|
||||
* header inclusion sequence that resolves all header dependencies.
|
||||
* 06 Jun 00, Paul Kienitz, removed time_lib.c due to its incompatible license,
|
||||
* moved set_TZ() back here, replaced minimal tzset() and localtime()
|
||||
* with new versions derived from GNU glibc source. Gave locale_TZ()
|
||||
* reasonable European defaults for daylight savings.
|
||||
* 17 Jun 00, Paul Kienitz, threw out GNU code because of objections to the GPL
|
||||
* virus, replaced with similar functions based on the public domain
|
||||
* timezone code at ftp://elsie.nci.nih.gov/pub. As with the GNU
|
||||
* stuff, support for timezone files and leap seconds was removed.
|
||||
* 23 Aug 00, Paul Kienitz, moved timezone code out from here into separate
|
||||
* platform-independent module 'timezone.c'.
|
||||
* 31 Dec 00, Christian Spieler, moved system-specific timezone help funcions
|
||||
* back in here, from 'timezone.c'.
|
||||
* 07 Jan 01, Paul Kienitz, Chr. Spieler, added missing #include "timezone.h"
|
||||
* and "symbolic" preprocessor constants for time calculations.
|
||||
* 15 Jan 02, Paul Kienitz, excluded all time handling code from compilation
|
||||
* for Zip utilities (when "defined(UTIL)")
|
||||
*/
|
||||
|
||||
#ifndef __amiga_filedate_c
|
||||
#define __amiga_filedate_c
|
||||
|
||||
|
||||
#include "zip.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <exec/execbase.h>
|
||||
#include <exec/memory.h>
|
||||
#include <dos/dosextens.h>
|
||||
|
||||
#ifdef AZTEC_C
|
||||
# include <libraries/dos.h>
|
||||
# include <libraries/dosextens.h>
|
||||
# include <clib/exec_protos.h>
|
||||
# include <clib/dos_protos.h>
|
||||
# include <clib/locale_protos.h>
|
||||
# include <pragmas/exec_lib.h>
|
||||
# include <pragmas/dos_lib.h>
|
||||
# include <pragmas/locale_lib.h>
|
||||
# define ESRCH ENOENT
|
||||
# define EOSERR EIO
|
||||
#endif
|
||||
|
||||
#ifdef __SASC
|
||||
# include <stdlib.h>
|
||||
# if (defined(_M68020) && (!defined(__USE_SYSBASE)))
|
||||
/* on 68020 or higher processors it is faster */
|
||||
# define __USE_SYSBASE /* to use the pragma libcall instead of syscall */
|
||||
# endif /* to access functions of the exec.library */
|
||||
# include <proto/exec.h> /* see SAS/C manual:part 2,chapter 2,pages 6-7 */
|
||||
# include <proto/dos.h>
|
||||
# include <proto/locale.h>
|
||||
# ifdef DEBUG
|
||||
# include <sprof.h>
|
||||
# endif
|
||||
# ifdef MWDEBUG
|
||||
# include <stdio.h> /* include both before memwatch.h again just */
|
||||
# include <stdlib.h> /* to be safe */
|
||||
# include "memwatch.h"
|
||||
# endif /* MWDEBUG */
|
||||
#endif /* __SASC */
|
||||
|
||||
#include "crypt.h" /* just so we can tell if CRYPT is supported */
|
||||
|
||||
|
||||
#if (!defined(FUNZIP) && !defined(UTIL))
|
||||
|
||||
#include "timezone.h" /* for AMIGA-specific timezone callbacks */
|
||||
|
||||
#ifndef SUCCESS
|
||||
# define SUCCESS (-1L)
|
||||
# define FAILURE 0L
|
||||
#endif
|
||||
|
||||
#define ReqVers 36L /* required library version for SetFileDate() */
|
||||
#define ENVSIZE 100 /* max space allowed for an environment var */
|
||||
|
||||
extern struct ExecBase *SysBase;
|
||||
|
||||
#ifndef min
|
||||
# define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
# define max(a, b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
#if defined(ZIP) || defined(HAVE_MKTIME)
|
||||
static const unsigned short ydays[] =
|
||||
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
|
||||
#else
|
||||
extern const unsigned short ydays[]; /* in unzip's fileio.c */
|
||||
#endif
|
||||
|
||||
#define LEAP(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)
|
||||
#define YDAYS(m, y) (ydays[m] + (m > 1 && LEAP(y)))
|
||||
/* Number of leap years from 1978 to `y' (not including `y' itself). */
|
||||
#define ANLEAP(y) (((y) - 1977) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)
|
||||
#define SECSPERMIN 60
|
||||
#define MINSPERHOUR 60
|
||||
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
||||
#define SECSPERDAY 86400L
|
||||
|
||||
/* prototypes */
|
||||
char *getenv(const char *var);
|
||||
#ifdef __SASC
|
||||
/* XXX !! We have really got to find a way to operate without these. */
|
||||
int setenv(const char *var, const char *value, int overwrite);
|
||||
void set_TZ(long time_zone, int day_light);
|
||||
#endif
|
||||
|
||||
LONG FileDate(char *filename, time_t u[]);
|
||||
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
|
||||
int Agetch(void);
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
/***********************/
|
||||
/* Function filedate() */
|
||||
/***********************/
|
||||
|
||||
/* FileDate() (originally utime.c), by Paul Wells. Modified by John Bush
|
||||
* and others (see also sendpkt() comments, below); NewtWare SetFileDate()
|
||||
* clone cheaply ripped off from utime().
|
||||
*/
|
||||
|
||||
/* DESCRIPTION
|
||||
* This routine chooses between 2 methods to set the file date on AMIGA.
|
||||
* Since AmigaDOS 2.x came out, SetFileDate() was available in ROM (v.36
|
||||
* and higher). Under AmigaDOS 1.3.x (less than v.36 ROM), SetFileDate()
|
||||
* must be accomplished by constructing a message packet and sending it
|
||||
* to the file system handler of the file to be stamped.
|
||||
*
|
||||
* The system's ROM version is extracted from the external system Library
|
||||
* base.
|
||||
*
|
||||
* NOTE: although argument passing conforms with utime(), note the
|
||||
* following differences:
|
||||
* - Return value is boolean success/failure.
|
||||
* - If a structure or array is passed, only the first value
|
||||
* is used, which *may* correspond to date accessed and not
|
||||
* date modified.
|
||||
*/
|
||||
|
||||
LONG FileDate(filename, u)
|
||||
char *filename;
|
||||
time_t u[];
|
||||
{
|
||||
LONG SetFileDate(UBYTE *filename, struct DateStamp *pDate);
|
||||
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
|
||||
struct MsgPort *taskport;
|
||||
BPTR dirlock, lock;
|
||||
struct FileInfoBlock *fib;
|
||||
LONG pktargs[4];
|
||||
UBYTE *ptr;
|
||||
long ret;
|
||||
|
||||
struct DateStamp pDate;
|
||||
struct tm *ltm;
|
||||
int years;
|
||||
|
||||
tzset();
|
||||
/* Amiga file date is based on 01-Jan-1978 00:00:00 (local time):
|
||||
* 8 years and 2 leapdays difference from Unix time.
|
||||
*/
|
||||
ltm = localtime(&u[0]);
|
||||
years = ltm->tm_year + 1900;
|
||||
if (years < 1978)
|
||||
pDate.ds_Days = pDate.ds_Minute = pDate.ds_Tick = 0;
|
||||
else {
|
||||
pDate.ds_Days = (years - 1978) * 365L + (ANLEAP(years)) +
|
||||
YDAYS(ltm->tm_mon, years) + (ltm->tm_mday - 1);
|
||||
pDate.ds_Minute = ltm->tm_hour * 60 + ltm->tm_min;
|
||||
pDate.ds_Tick = ltm->tm_sec * TICKS_PER_SECOND;
|
||||
}
|
||||
|
||||
if (SysBase->LibNode.lib_Version >= ReqVers)
|
||||
{
|
||||
return (SetFileDate(filename,&pDate)); /* native routine at 2.0+ */
|
||||
}
|
||||
else /* !(SysBase->lib_Version >=ReqVers) */
|
||||
{
|
||||
if( !(taskport = (struct MsgPort *)DeviceProc(filename)) )
|
||||
{
|
||||
errno = ESRCH; /* no such process */
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if( !(lock = Lock(filename,SHARED_LOCK)) )
|
||||
{
|
||||
errno = ENOENT; /* no such file */
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if( !(fib = (struct FileInfoBlock *)AllocMem(
|
||||
(long)sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR)) )
|
||||
{
|
||||
errno = ENOMEM; /* insufficient memory */
|
||||
UnLock(lock);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if( Examine(lock,fib)==FAILURE )
|
||||
{
|
||||
errno = EOSERR; /* operating system error */
|
||||
UnLock(lock);
|
||||
FreeMem(fib,(long)sizeof(*fib));
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
dirlock = ParentDir(lock);
|
||||
ptr = (UBYTE *)AllocMem(64L,MEMF_PUBLIC);
|
||||
strcpy((ptr+1),fib->fib_FileName);
|
||||
*ptr = strlen(fib->fib_FileName);
|
||||
FreeMem(fib,(long)sizeof(*fib));
|
||||
UnLock(lock);
|
||||
|
||||
/* now fill in argument array */
|
||||
|
||||
pktargs[0] = 0;
|
||||
pktargs[1] = (LONG)dirlock;
|
||||
pktargs[2] = (LONG)&ptr[0] >> 2;
|
||||
pktargs[3] = (LONG)&pDate;
|
||||
|
||||
errno = ret = sendpkt(taskport,ACTION_SET_DATE,pktargs,4L);
|
||||
|
||||
FreeMem(ptr,64L);
|
||||
UnLock(dirlock);
|
||||
|
||||
return SUCCESS;
|
||||
} /* ?(SysBase->lib_Version >= ReqVers) */
|
||||
} /* FileDate() */
|
||||
|
||||
|
||||
char *getenv(const char *var) /* not reentrant! */
|
||||
{
|
||||
static char space[ENVSIZE];
|
||||
struct Process *me = (void *) FindTask(NULL);
|
||||
void *old_window = me->pr_WindowPtr;
|
||||
char *ret = NULL;
|
||||
|
||||
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
|
||||
if (SysBase->LibNode.lib_Version >= ReqVers) {
|
||||
if (GetVar((char *) var, space, ENVSIZE - 1, /*GVF_GLOBAL_ONLY*/ 0) > 0)
|
||||
ret = space;
|
||||
} else { /* early AmigaDOS, get env var the crude way */
|
||||
BPTR hand, foot, spine;
|
||||
int z = 0;
|
||||
if (foot = Lock("ENV:", ACCESS_READ)) {
|
||||
spine = CurrentDir(foot);
|
||||
if (hand = Open((char *) var, MODE_OLDFILE)) {
|
||||
z = Read(hand, space, ENVSIZE - 1);
|
||||
Close(hand);
|
||||
}
|
||||
UnLock(CurrentDir(spine));
|
||||
}
|
||||
if (z > 0) {
|
||||
space[z] = '\0';
|
||||
ret = space;
|
||||
}
|
||||
}
|
||||
me->pr_WindowPtr = old_window;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __SASC
|
||||
int setenv(const char *var, const char *value, int overwrite)
|
||||
{
|
||||
struct Process *me = (void *) FindTask(NULL);
|
||||
void *old_window = me->pr_WindowPtr;
|
||||
int ret = -1;
|
||||
|
||||
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
|
||||
if (SysBase->LibNode.lib_Version >= ReqVers)
|
||||
ret = !SetVar((char *)var, (char *)value, -1, GVF_GLOBAL_ONLY | LV_VAR);
|
||||
else {
|
||||
BPTR hand, foot, spine;
|
||||
long len = value ? strlen(value) : 0;
|
||||
if (foot = Lock("ENV:", ACCESS_READ)) {
|
||||
spine = CurrentDir(foot);
|
||||
if (len) {
|
||||
if (hand = Open((char *) var, MODE_NEWFILE)) {
|
||||
ret = Write(hand, (char *) value, len + 1) >= len;
|
||||
Close(hand);
|
||||
}
|
||||
} else
|
||||
ret = DeleteFile((char *) var);
|
||||
UnLock(CurrentDir(spine));
|
||||
}
|
||||
}
|
||||
me->pr_WindowPtr = old_window;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Stores data from timezone and daylight to ENV:TZ. */
|
||||
/* ENV:TZ is required to exist by some other SAS/C library functions, */
|
||||
/* like stat() or fstat(). */
|
||||
void set_TZ(long time_zone, int day_light)
|
||||
{
|
||||
char put_tz[MAXTIMEZONELEN]; /* string for putenv: "TZ=aaabbb:bb:bbccc" */
|
||||
int offset;
|
||||
void *exists; /* dummy ptr to see if global envvar TZ already exists */
|
||||
exists = (void *)getenv(TZ_ENVVAR);
|
||||
/* see if there is already an envvar TZ_ENVVAR. If not, create it */
|
||||
if (exists == NULL) {
|
||||
/* create TZ string by pieces: */
|
||||
sprintf(put_tz, "GMT%+ld", time_zone / 3600L);
|
||||
if (time_zone % 3600L) {
|
||||
offset = (int) labs(time_zone % 3600L);
|
||||
sprintf(put_tz + strlen(put_tz), ":%02d", offset / 60);
|
||||
if (offset % 60)
|
||||
sprintf(put_tz + strlen(put_tz), ":%02d", offset % 60);
|
||||
}
|
||||
if (day_light)
|
||||
strcat(put_tz,"DST");
|
||||
setenv(TZ_ENVVAR, put_tz, 1);
|
||||
}
|
||||
}
|
||||
#endif /* __SASC */
|
||||
|
||||
/* set state as well as possible from settings found in locale.library */
|
||||
int GetPlatformLocalTimezone(sp, fill_tzstate_from_rules)
|
||||
register struct state * ZCONST sp;
|
||||
void (*fill_tzstate_from_rules)(struct state * ZCONST sp_res,
|
||||
ZCONST struct rule * ZCONST start,
|
||||
ZCONST struct rule * ZCONST end);
|
||||
{
|
||||
struct Library *LocaleBase;
|
||||
struct Locale *ll;
|
||||
struct Process *me = (void *) FindTask(NULL);
|
||||
void *old_window = me->pr_WindowPtr;
|
||||
BPTR eh;
|
||||
int z, valid = FALSE;
|
||||
|
||||
/* read timezone from locale.library if TZ envvar missing */
|
||||
me->pr_WindowPtr = (void *) -1; /* suppress any "Please insert" popups */
|
||||
if (LocaleBase = OpenLibrary("locale.library", 0)) {
|
||||
if (ll = OpenLocale(NULL)) {
|
||||
z = ll->loc_GMTOffset; /* in minutes */
|
||||
if (z == -300) {
|
||||
if (eh = Lock("ENV:sys/locale.prefs", ACCESS_READ)) {
|
||||
UnLock(eh);
|
||||
valid = TRUE;
|
||||
} else
|
||||
z = 300; /* bug: locale not initialized, default bogus! */
|
||||
} else
|
||||
valid = TRUE;
|
||||
if (valid) {
|
||||
struct rule startrule, stoprule;
|
||||
|
||||
sp->timecnt = 0;
|
||||
sp->typecnt = 1;
|
||||
sp->charcnt = 2;
|
||||
sp->chars[0] = sp->chars[1] = '\0';
|
||||
sp->ttis[0].tt_abbrind = 0;
|
||||
sp->ttis[1].tt_abbrind = 1;
|
||||
sp->ttis[0].tt_gmtoff = -z * MINSPERHOUR;
|
||||
sp->ttis[1].tt_gmtoff = -z * MINSPERHOUR + SECSPERHOUR;
|
||||
sp->ttis[0].tt_isdst = 0;
|
||||
sp->ttis[1].tt_isdst = 1;
|
||||
stoprule.r_type = MONTH_NTH_DAY_OF_WEEK;
|
||||
stoprule.r_day = 0;
|
||||
stoprule.r_week = 5;
|
||||
stoprule.r_mon = 10;
|
||||
stoprule.r_time = 2 * SECSPERHOUR;
|
||||
startrule = stoprule;
|
||||
startrule.r_mon = 4;
|
||||
startrule.r_week = 1;
|
||||
if (z >= -180 && z < 150) {
|
||||
/* At this point we make a really gratuitous assumption: */
|
||||
/* if the time zone could be Europe, we use the European */
|
||||
/* Union rules without checking what country we're in. */
|
||||
/* The AmigaDOS locale country codes do not, at least in */
|
||||
/* 2.x versions of the OS, recognize very many countries */
|
||||
/* outside of Europe and North America. */
|
||||
sp->typecnt = 2;
|
||||
startrule.r_mon = 3; /* one week earlier than US DST */
|
||||
startrule.r_week = 5;
|
||||
} else if (z >= 150 && z <= 480 &&
|
||||
/* no DST in alaska, hawaii */
|
||||
(ll->loc_CountryCode == 0x55534100 /*"USA"*/ ||
|
||||
ll->loc_CountryCode == 0x43414E00 /*"CAN"*/))
|
||||
sp->typecnt = 2;
|
||||
/* We check the country code for U.S. or Canada because */
|
||||
/* most of Latin America has no DST. Even in these two */
|
||||
/* countries there are some exceptions... */
|
||||
/* else if... Feel free to add more cases here! */
|
||||
|
||||
if (sp->typecnt > 1)
|
||||
(*fill_tzstate_from_rules)(sp, &startrule, &stoprule);
|
||||
}
|
||||
CloseLocale(ll);
|
||||
}
|
||||
CloseLibrary(LocaleBase);
|
||||
}
|
||||
me->pr_WindowPtr = old_window;
|
||||
return valid;
|
||||
}
|
||||
|
||||
#ifdef ZIP
|
||||
time_t time(time_t *tp)
|
||||
{
|
||||
time_t t;
|
||||
struct DateStamp ds;
|
||||
DateStamp(&ds);
|
||||
t = ds.ds_Tick / TICKS_PER_SECOND + ds.ds_Minute * 60
|
||||
+ (ds.ds_Days + 2922) * SECSPERDAY;
|
||||
t = mktime(gmtime(&t));
|
||||
/* gmtime leaves ds in the local timezone, mktime converts it to GMT */
|
||||
if (tp) *tp = t;
|
||||
return t;
|
||||
}
|
||||
#endif /* ZIP */
|
||||
|
||||
#endif /* !FUNZIP && !UTIL */
|
||||
|
||||
|
||||
#if CRYPT || !defined(FUNZIP)
|
||||
|
||||
/* sendpkt.c
|
||||
* by A. Finkel, P. Lindsay, C. Sheppner
|
||||
* returns Res1 of the reply packet
|
||||
*/
|
||||
/*
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <libraries/dos.h>
|
||||
#include <libraries/dosextens.h>
|
||||
#include <proto/exec.h>
|
||||
#include <proto/dos.h>
|
||||
*/
|
||||
|
||||
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
|
||||
|
||||
LONG sendpkt(pid,action,args,nargs)
|
||||
struct MsgPort *pid; /* process identifier (handler message port) */
|
||||
LONG action, /* packet type (desired action) */
|
||||
*args, /* a pointer to argument list */
|
||||
nargs; /* number of arguments in list */
|
||||
{
|
||||
|
||||
struct MsgPort *replyport, *CreatePort(UBYTE *, long);
|
||||
void DeletePort(struct MsgPort *);
|
||||
struct StandardPacket *packet;
|
||||
LONG count, *pargs, res1;
|
||||
|
||||
replyport = CreatePort(NULL,0L);
|
||||
if( !replyport ) return(0);
|
||||
|
||||
packet = (struct StandardPacket *)AllocMem(
|
||||
(long)sizeof(struct StandardPacket),MEMF_PUBLIC|MEMF_CLEAR);
|
||||
if( !packet )
|
||||
{
|
||||
DeletePort(replyport);
|
||||
return(0);
|
||||
}
|
||||
|
||||
packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt);
|
||||
packet->sp_Pkt.dp_Link = &(packet->sp_Msg);
|
||||
packet->sp_Pkt.dp_Port = replyport;
|
||||
packet->sp_Pkt.dp_Type = action;
|
||||
|
||||
/* copy the args into the packet */
|
||||
pargs = &(packet->sp_Pkt.dp_Arg1); /* address of 1st argument */
|
||||
for( count=0; count<nargs; count++ )
|
||||
pargs[count] = args[count];
|
||||
|
||||
PutMsg(pid,(struct Message *)packet); /* send packet */
|
||||
|
||||
WaitPort(replyport);
|
||||
GetMsg(replyport);
|
||||
|
||||
res1 = packet->sp_Pkt.dp_Res1;
|
||||
|
||||
FreeMem((char *)packet,(long)sizeof(*packet));
|
||||
DeletePort(replyport);
|
||||
|
||||
return(res1);
|
||||
|
||||
} /* sendpkt() */
|
||||
|
||||
#endif /* CRYPT || !FUNZIP */
|
||||
|
||||
|
||||
#if CRYPT || (defined(UNZIP) && !defined(FUNZIP))
|
||||
|
||||
/* Agetch() reads one raw keystroke -- uses sendpkt() */
|
||||
|
||||
int Agetch(void)
|
||||
{
|
||||
LONG sendpkt(struct MsgPort *pid, LONG action, LONG *args, LONG nargs);
|
||||
struct Task *me = FindTask(NULL);
|
||||
struct CommandLineInterface *cli = BADDR(((struct Process *) me)->pr_CLI);
|
||||
BPTR fh = cli->cli_StandardInput; /* this is immune to < redirection */
|
||||
void *conp = ((struct FileHandle *) BADDR(fh))->fh_Type;
|
||||
char longspace[8];
|
||||
long *flag = (long *) ((ULONG) &longspace[4] & ~3); /* LONGWORD ALIGNED! */
|
||||
UBYTE c;
|
||||
|
||||
*flag = 1;
|
||||
sendpkt(conp, ACTION_SCREEN_MODE, flag, 1); /* assume success */
|
||||
Read(fh, &c, 1);
|
||||
*flag = 0;
|
||||
sendpkt(conp, ACTION_SCREEN_MODE, flag, 1);
|
||||
if (c == 3) /* ^C in input */
|
||||
Signal(me, SIGBREAKF_CTRL_C);
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif /* CRYPT || (UNZIP && !FUNZIP) */
|
||||
|
||||
#endif /* __amiga_filedate_c*/
|
304
third_party/infozip/zip/amiga/makefile.azt
vendored
Normal file
304
third_party/infozip/zip/amiga/makefile.azt
vendored
Normal file
|
@ -0,0 +1,304 @@
|
|||
# Makefile for Zip, ZipNote, ZipCloak, ZipSplit for Aztec C 5.2
|
||||
# Also ZipLM, a version of Zip that needs much less free memory
|
||||
# -- Paul Kienitz, last updated 07 Jan 2007
|
||||
|
||||
# Make sure platform is defined correctly, and select memory usage options:
|
||||
DEFINES = -d AMIGA -d DYN_ALLOC -d ASM_CRC
|
||||
|
||||
CC = cc
|
||||
AS = as
|
||||
LD = ln
|
||||
LDLIBS = -lc16
|
||||
|
||||
|
||||
# -------- RELEASE VERSION:
|
||||
CFLAGS = -psb0e -sabfmnpu -wcr0u $(DEFINES)
|
||||
# -pbs means unsigned chars and short ints, -sabfmnpu is various small
|
||||
# optimizations, -wcr0u adjusts type checking strictness
|
||||
ASOPTS = -n -eAMIGA -eDYN_ALLOC -eCPUTEST -eINT16
|
||||
LDFLAGS = -m +q
|
||||
|
||||
# -------- DEBUG VERSION:
|
||||
CFLAGD = -bs -psb0e -s0f0n -wcr0u $(DEFINES)
|
||||
# -bs is include source debugging info, -s0f0n is avoid hard-to-debug
|
||||
# optimizations
|
||||
LDFLAGD = -m +q -g -w
|
||||
|
||||
# -------- MINIMUM MEMORY USAGE RELEASE VERSION:
|
||||
WSIZ = WSIZE=4096
|
||||
LOWFLAGS = $(CFLAGS) -d $(WSIZ) -d SMALL_MEM
|
||||
LOWASOPTS = $(ASOPTS) -e$(WSIZ) -eSMALL_MEM
|
||||
# Options used for assembling amiga/deflate.a; must generally match the
|
||||
# settings in DEFINES.
|
||||
|
||||
# -------- MINIMUM MEMORY USAGE DEBUG VERSION:
|
||||
LOWFLAGD = $(CFLAGD) -d $(WSIZ) -d SMALL_MEM
|
||||
|
||||
# the directory where we stick all the object files:
|
||||
O = obA/
|
||||
|
||||
|
||||
# default C rules
|
||||
.c.o :
|
||||
$(CC) $(CFLAGS) -o $@ $*.c
|
||||
|
||||
# rules for routines containing entries needed by utilities
|
||||
.c.oo :
|
||||
$(CC) $(CFLAGS) -d UTIL -o $@ $*.c
|
||||
|
||||
# rules for the low-memory version:
|
||||
|
||||
.c.ol :
|
||||
$(CC) $(LOWFLAGS) -o $@ $*.c
|
||||
|
||||
# default C rules for debugging
|
||||
.c.od :
|
||||
$(CC) $(CFLAGD) -o $@ $*.c
|
||||
|
||||
# debugging rules for routines containing entries needed by utilities
|
||||
.c.dd :
|
||||
$(CC) $(CFLAGD) -d UTIL -o $@ $*.c
|
||||
|
||||
# rules for the debugging low-memory version:
|
||||
|
||||
.c.dl :
|
||||
$(CC) $(LOWFLAGD) -o $@ $*.c
|
||||
|
||||
|
||||
# object file lists
|
||||
|
||||
ZIP_H = zip.h ziperr.h tailor.h amiga/osdep.h amiga/z-stat.h
|
||||
|
||||
|
||||
OBJZ = $(O)zip.o $(O)deflate.o \
|
||||
$(O)trees.o $(O)zipfile.o $(O)zipup.o $(O)util.o $(O)timezone.o \
|
||||
$(O)fileio.o $(O)globals.o $(O)crc32.o $(O)crypt.o $(O)ttyio.o \
|
||||
$(O)amiga.o $(O)amigazip.o $(O)crc_68.o
|
||||
|
||||
OBJL = $(O)zip.ol $(O)deflate.ol \
|
||||
$(O)trees.ol $(O)zipfile.ol $(O)zipup.ol $(O)util.ol $(O)timezone.ol \
|
||||
$(O)fileio.ol $(O)globals.ol $(O)crc32.ol $(O)crypt.ol $(O)ttyio.ol \
|
||||
$(O)amiga.ol $(O)amigazip.ol $(O)crc_68.o
|
||||
|
||||
OBJU = $(O)zipfile.oo $(O)fileio.oo \
|
||||
$(O)util.oo $(O)globals.o $(O)amiga.oo $(O)amigazip.oo
|
||||
OBJN = $(O)zipnote.o $(OBJU)
|
||||
OBJC = $(O)zipcloak.o $(OBJU) $(O)crc32.oo \
|
||||
$(O)crypt.oo $(O)ttyio.o
|
||||
OBJS = $(O)zipsplit.o $(OBJU)
|
||||
|
||||
# These are the debuggable versions:
|
||||
|
||||
DBJZ = $(O)zip.od $(O)deflate.od \
|
||||
$(O)trees.od $(O)zipfile.od $(O)zipup.od $(O)util.od $(O)timezone.od \
|
||||
$(O)fileio.od $(O)globals.od $(O)crc32.od $(O)crypt.od $(O)ttyio.od \
|
||||
$(O)amiga.od $(O)amigazip.od $(O)crc_68.o
|
||||
|
||||
DBJL = $(O)zip.dl $(O)deflate.dl \
|
||||
$(O)trees.dl $(O)zipfile.dl $(O)zipup.dl $(O)util.dl $(O)timezone.dl \
|
||||
$(O)fileio.dl $(O)globals.dl $(O)crc32.dl $(O)crypt.dl $(O)ttyio.dl \
|
||||
$(O)amiga.dl $(O)amigazip.dl $(O)crc_68.o
|
||||
|
||||
DBJU = $(O)zipfile.dd $(O)fileio.dd \
|
||||
$(O)util.dd $(O)globals.od $(O)amiga.dd $(O)amigazip.dd
|
||||
DBJN = $(O)zipnote.od $(DBJU)
|
||||
DBJC = $(O)zipcloak.od $(DBJU) $(O)crc32.dd \
|
||||
$(O)crypt.dd $(O)ttyio.od
|
||||
DBJS = $(O)zipsplit.od $(DBJU)
|
||||
|
||||
|
||||
# HERE WE GO:
|
||||
|
||||
all : Zip ZipNote ZipSplit ZipCloak ZipLM
|
||||
|
||||
z : Zip
|
||||
|
||||
n : ZipNote
|
||||
|
||||
s : ZipSplit
|
||||
|
||||
c : ZipCloak
|
||||
|
||||
l : ZipLM
|
||||
|
||||
# Debug versions:
|
||||
|
||||
dall : Zip.dbg ZipNote.dbg ZipSplit.dbg ZipCloak.dbg ZipLM.dbg
|
||||
|
||||
dz : Zip.dbg
|
||||
|
||||
dn : ZipNote.dbg
|
||||
|
||||
ds : ZipSplit.dbg
|
||||
|
||||
dc : ZipCloak.dbg
|
||||
|
||||
dl : ZipLM.dbg
|
||||
|
||||
|
||||
Zip : $(OBJZ) $(ZIP_H)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJZ) $(LDLIBS)
|
||||
-@delete Zip.dbg
|
||||
|
||||
ZipNote : $(OBJN) $(ZIP_H)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJN) $(LDLIBS)
|
||||
-@delete ZipNote.dbg
|
||||
|
||||
ZipSplit : $(OBJS) $(ZIP_H)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
||||
-@delete ZipSplit.dbg
|
||||
|
||||
ZipCloak : $(OBJC) $(ZIP_H)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJC) $(LDLIBS)
|
||||
-@delete ZipCloak.dbg
|
||||
|
||||
ZipLM : $(OBJL) $(ZIP_H)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJL) $(LDLIBS)
|
||||
-@delete ZipLM.dbg
|
||||
|
||||
|
||||
Zip.dbg : $(DBJZ) $(ZIP_H)
|
||||
$(LD) $(LDFLAGD) -o Zip $(DBJZ) $(LDLIBS)
|
||||
|
||||
ZipNote.dbg : $(DBJN) $(ZIP_H)
|
||||
$(LD) $(LDFLAGD) -o ZipNote $(DBJN) $(LDLIBS)
|
||||
|
||||
ZipSplit.dbg : $(DBJS) $(ZIP_H)
|
||||
$(LD) $(LDFLAGD) -o ZipSplit $(DBJS) $(LDLIBS)
|
||||
|
||||
ZipCloak.dbg : $(DBJC) $(ZIP_H)
|
||||
$(LD) $(LDFLAGD) -o ZipCloak $(DBJC) $(LDLIBS)
|
||||
|
||||
ZipLM.dbg : $(DBJL) $(ZIP_H)
|
||||
$(LD) $(LDFLAGD) -o ZipLM $(DBJL) $(LDLIBS)
|
||||
|
||||
|
||||
clean : bugclean
|
||||
-delete quiet $(OBJZ)
|
||||
-delete quiet $(OBJL)
|
||||
-delete quiet $(O)zipnote.o $(O)zipcloak.o $(O)zipsplit.o \
|
||||
$(O)crypt.oo $(OBJU)
|
||||
|
||||
bugclean :
|
||||
-delete quiet $(DBJZ)
|
||||
-delete quiet $(DBJL)
|
||||
-delete quiet $(O)zipnote.od $(O)zipcloak.od $(O)zipsplit.od \
|
||||
$(O)crypt.dd $(DBJU)
|
||||
|
||||
cleaner : clean
|
||||
-delete quiet Zip ZipNote ZipSplit ZipCloak ZipLM
|
||||
-delete quiet Zip.dbg ZipNote.dbg ZipSplit.dbg ZipCloak.dbg ZipLM.dbg
|
||||
|
||||
|
||||
# header dependencies:
|
||||
|
||||
$(O)zip.o $(O)zipnote.o $(O)zipcloak.o $(O)zipsplit.o $(O)crypt.o $(O)ttyio.o \
|
||||
$(O)deflate.o $(O)trees.o $(O)zipfile.o $(O)zipup.o $(O)fileio.o $(O)util.o \
|
||||
$(O)timezone.o $(O)crc32.o $(O)globals.o $(O)amiga.o : $(ZIP_H)
|
||||
|
||||
$(O)zip.ol $(O)zipnote.ol $(O)zipcloak.ol $(O)zipsplit.ol $(O)crypt.ol \
|
||||
$(O)ttyio.ol $(O)deflate.ol $(O)trees.ol $(O)zipfile.ol $(O)zipup.ol \
|
||||
$(O)fileio.ol $(O)util.ol $(O)timezone.ol $(O)crc32.ol $(O)globals.ol \
|
||||
$(O)amiga.ol : $(ZIP_H)
|
||||
|
||||
$(O)crc32.oo $(O)crypt.oo $(O)zipfile.oo $(O)fileio.oo $(O)util.oo : $(ZIP_H)
|
||||
|
||||
$(O)amigazip.o $(O)amigazip.ol $(O)amigazip.oo : amiga/amiga.h $(ZIP_H)
|
||||
|
||||
$(O)zip.o $(O)zipnote.o $(O)zipcloak.o $(O)zipsplit.o $(O)zipup.o \
|
||||
$(O)zip.ol $(O)zipnote.ol $(O)zipcloak.ol $(O)zipsplit.ol \
|
||||
$(O)zipup.ol : revision.h
|
||||
|
||||
$(O)amiga.o $(O)amiga.ol : crypt.h
|
||||
|
||||
$(O)crc32.o $(O)crc32.oo $(O)crc32.ol $(O)crypt.o $(O)crypt.oo $(O)crypt.ol \
|
||||
$(O)zipcloak.o $(O)zipcloak.ol $(O)zip.o $(O)zip.ol \
|
||||
$(O)zipup.o $(O)zipup.ol \
|
||||
$(O)zipfile.o $(O)zipfile.oo $(O)zipfile.ol \
|
||||
$(O)fileio.o $(O)fileio.oo $(O)fileio.ol : crc32.h
|
||||
|
||||
$(O)crypt.o $(O)crypt.oo $(O)crypt.ol $(O)ttyio.o $(O)ttyio.ol \
|
||||
$(O)zipcloak.o $(O)zipcloak.ol $(O)zip.o $(O)zip.ol \
|
||||
$(O)zipup.o $(O)zipup.ol : crypt.h ttyio.h
|
||||
|
||||
$(O)timezone.o $(O)timezone.ol $(O)timezone.od $(O)timezone.dl \
|
||||
$(O)amiga.o $(O)amiga.ol $(O)amiga.oo : timezone.h
|
||||
|
||||
$(O)zipup.o $(O)zipup.ol : amiga/zipup.h
|
||||
|
||||
|
||||
# SPECIAL CASES:
|
||||
|
||||
# -mr changes expression parsing; avoids a bogus "expression too complex" error:
|
||||
$(O)trees.o : trees.c
|
||||
$(CC) $(CFLAGS) -mr -o $@ trees.c
|
||||
|
||||
$(O)trees.ol : trees.c
|
||||
$(CC) $(LOWFLAGS) -mr -o $@ trees.c
|
||||
|
||||
$(O)trees.od : trees.c
|
||||
$(CC) $(CFLAGD) -mr -o $@ trees.c
|
||||
|
||||
$(O)trees.ld : trees.c
|
||||
$(CC) $(LOWFLAGD) -mr -o $@ trees.c
|
||||
|
||||
# Substitute the assembly version of deflate.c: (but not in debug version)
|
||||
$(O)deflate.o : amiga/deflate.a
|
||||
$(AS) $(ASOPTS) -o $@ amiga/deflate.a
|
||||
|
||||
$(O)deflate.ol : amiga/deflate.a
|
||||
$(AS) $(LOWASOPTS) -o $@ amiga/deflate.a
|
||||
|
||||
# The assembly CRC function:
|
||||
$(O)crc_68.o : amiga/crc_68.a
|
||||
$(AS) -n -o $@ amiga/crc_68.a
|
||||
|
||||
# Put the Amiga internal version data with today's date into amiga.c:
|
||||
$(O)amiga.o : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(CFLAGS) -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
$(O)amiga.ol : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(LOWFLAGS) -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
$(O)amiga.od : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(CFLAGD) -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
$(O)amiga.ld : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(LOWFLAGD) -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
$(O)amiga.oo : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(CFLAGS) -d UTIL -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
$(O)amiga.dd : amiga/amiga.c amiga/filedate.c amiga/stat.c
|
||||
rx > env:VersionDate "say '""'translate(date('E'), '.', '/')'""'"
|
||||
$(CC) $(CFLAGD) -d UTIL -o $@ amiga/amiga.c
|
||||
delete env:VersionDate
|
||||
|
||||
# Put the compiler version number into amigazip.c:
|
||||
$(O)amigazip.o : amiga/amigazip.c
|
||||
$(CC) $(CFLAGS) -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
||||
|
||||
$(O)amigazip.ol : amiga/amigazip.c
|
||||
$(CC) $(LOWFLAGS) -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
||||
|
||||
$(O)amigazip.od : amiga/amigazip.c
|
||||
$(CC) $(CFLAGD) -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
||||
|
||||
$(O)amigazip.ld : amiga/amigazip.c
|
||||
$(CC) $(LOWFLAGD) -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
||||
|
||||
$(O)amigazip.oo : amiga/amigazip.c
|
||||
$(CC) $(CFLAGS) -d UTIL -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
||||
|
||||
$(O)amigazip.dd : amiga/amigazip.c
|
||||
$(CC) $(CFLAGD) -d UTIL -o $@ -d __VERSION__=5 -d __REVISION__=2 amiga/amigazip.c
|
182
third_party/infozip/zip/amiga/match.a
vendored
Normal file
182
third_party/infozip/zip/amiga/match.a
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; match.a -- optional optimized asm version of longest match in deflate.c
|
||||
; Written by Jean-loup Gailly
|
||||
; Adapted for the Amiga by Carsten Steger <stegerc@informatik.tu-muenchen.de>
|
||||
; using the code in match.S.
|
||||
; The major change in this code consists of removing all unaligned
|
||||
; word accesses, because they cause 68000-based Amigas to crash.
|
||||
; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc.
|
||||
; The program will then only run on 68020-based Amigas, though.
|
||||
; If you have reduced WSIZE in zip.h, then make sure this is
|
||||
; assembled with an equivalent -dWSIZE=<whatever>.
|
||||
;
|
||||
; This code will run with registerized parameters too, unless SAS
|
||||
; changes parameter passing conventions between new releases of SAS/C.
|
||||
|
||||
|
||||
Cur_Match reg d0 ; Must be in d0!
|
||||
Best_Len reg d1
|
||||
Loop_Counter reg d2
|
||||
Scan_Start reg d3
|
||||
Scan_End reg d4
|
||||
Limit reg d5
|
||||
Chain_Length reg d6
|
||||
Scan_Test reg d7
|
||||
Scan reg a0
|
||||
Match reg a1
|
||||
Prev_Address reg a2
|
||||
Scan_Ini reg a3
|
||||
Match_Ini reg a4
|
||||
|
||||
MAX_MATCH equ 258
|
||||
MIN_MATCH equ 3
|
||||
ifnd WSIZE
|
||||
WSIZE equ 32768
|
||||
endc
|
||||
MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1
|
||||
|
||||
|
||||
xref _max_chain_length
|
||||
xref _prev_length
|
||||
xref _prev
|
||||
xref _window
|
||||
xref _strstart
|
||||
xref _good_match
|
||||
xref _match_start
|
||||
xref _nice_match
|
||||
|
||||
|
||||
section match,code
|
||||
|
||||
xdef _match_init
|
||||
xdef @match_init
|
||||
xdef _longest_match
|
||||
xdef @longest_match
|
||||
|
||||
|
||||
_match_init:
|
||||
@match_init:
|
||||
rts
|
||||
|
||||
|
||||
_longest_match:
|
||||
move.l 4(sp),Cur_Match
|
||||
@longest_match:
|
||||
ifd UNALIGNED_OK
|
||||
movem.l d2-d6/a2-a4,-(sp)
|
||||
else
|
||||
movem.l d2-d7/a2-a4,-(sp)
|
||||
endc
|
||||
move.l _max_chain_length,Chain_Length
|
||||
move.l _prev_length,Best_Len
|
||||
lea _prev,Prev_Address
|
||||
lea _window+MIN_MATCH,Match_Ini
|
||||
move.l _strstart,Limit
|
||||
move.l Match_Ini,Scan_Ini
|
||||
add.l Limit,Scan_Ini
|
||||
subi.w #MAX_DIST,Limit
|
||||
bhi.b limit_ok
|
||||
moveq #0,Limit
|
||||
limit_ok:
|
||||
cmp.l _good_match,Best_Len
|
||||
bcs.b length_ok
|
||||
lsr.l #2,Chain_Length
|
||||
length_ok:
|
||||
subq.l #1,Chain_Length
|
||||
|
||||
ifd UNALIGNED_OK
|
||||
|
||||
move.w -MIN_MATCH(Scan_Ini),Scan_Start
|
||||
move.w -MIN_MATCH-1(Scan_Ini,Best_Len.L),Scan_End
|
||||
|
||||
else
|
||||
|
||||
move.b -MIN_MATCH(Scan_Ini),Scan_Start
|
||||
lsl.w #8,Scan_Start
|
||||
move.b -MIN_MATCH+1(Scan_Ini),Scan_Start
|
||||
move.b -MIN_MATCH-1(Scan_Ini,Best_Len.L),Scan_End
|
||||
lsl.w #8,Scan_End
|
||||
move.b -MIN_MATCH(Scan_Ini,Best_Len.L),Scan_End
|
||||
|
||||
endc
|
||||
|
||||
bra.b do_scan
|
||||
|
||||
long_loop:
|
||||
|
||||
ifd UNALIGNED_OK
|
||||
|
||||
move.w -MIN_MATCH-1(Scan_Ini,Best_Len.L),Scan_End
|
||||
|
||||
else
|
||||
|
||||
move.b -MIN_MATCH-1(Scan_Ini,Best_Len.L),Scan_End
|
||||
lsl.w #8,Scan_End
|
||||
move.b -MIN_MATCH(Scan_Ini,Best_Len.L),Scan_End
|
||||
|
||||
endc
|
||||
|
||||
short_loop:
|
||||
lsl.w #1,Cur_Match
|
||||
move.w 0(Prev_Address,Cur_Match.L),Cur_Match
|
||||
cmp.w Limit,Cur_Match
|
||||
dbls Chain_Length,do_scan
|
||||
bra.b return
|
||||
|
||||
do_scan:
|
||||
move.l Match_Ini,Match
|
||||
add.l Cur_Match,Match
|
||||
|
||||
ifd UNALIGNED_OK
|
||||
|
||||
cmp.w -MIN_MATCH-1(Match,Best_Len.L),Scan_End
|
||||
bne.b short_loop
|
||||
cmp.w -MIN_MATCH(Match),Scan_Start
|
||||
bne.b short_loop
|
||||
|
||||
else
|
||||
|
||||
move.b -MIN_MATCH-1(Match,Best_Len.L),Scan_Test
|
||||
lsl.w #8,Scan_Test
|
||||
move.b -MIN_MATCH(Match,Best_Len.L),Scan_Test
|
||||
cmp.w Scan_Test,Scan_End
|
||||
bne.b short_loop
|
||||
move.b -MIN_MATCH(Match),Scan_Test
|
||||
lsl.w #8,Scan_Test
|
||||
move.b -MIN_MATCH+1(Match),Scan_Test
|
||||
cmp.w Scan_Test,Scan_Start
|
||||
bne.b short_loop
|
||||
|
||||
endc
|
||||
|
||||
move.w #(MAX_MATCH-MIN_MATCH),Loop_Counter
|
||||
move.l Scan_Ini,Scan
|
||||
scan_loop:
|
||||
cmpm.b (Match)+,(Scan)+
|
||||
dbne Loop_Counter,scan_loop
|
||||
|
||||
sub.l Scan_Ini,Scan
|
||||
addq.l #(MIN_MATCH-1),Scan
|
||||
cmp.l Best_Len,Scan
|
||||
bls.b short_loop
|
||||
move.l Scan,Best_Len
|
||||
move.l Cur_Match,_match_start
|
||||
cmp.l _nice_match,Best_Len
|
||||
bcs.b long_loop
|
||||
return:
|
||||
move.l Best_Len,d0
|
||||
ifd UNALIGNED_OK
|
||||
movem.l (sp)+,d2-d6/a2-a4
|
||||
else
|
||||
movem.l (sp)+,d2-d7/a2-a4
|
||||
endc
|
||||
rts
|
||||
|
||||
end
|
273
third_party/infozip/zip/amiga/match_68.a
vendored
Normal file
273
third_party/infozip/zip/amiga/match_68.a
vendored
Normal file
|
@ -0,0 +1,273 @@
|
|||
;===========================================================================
|
||||
; Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
;
|
||||
; See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
; (the contents of which are also included in zip.h) for terms of use.
|
||||
; If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
;===========================================================================
|
||||
; This is a 68000 assembly language version of the Zip function
|
||||
; longest_match(). It is written for any 680x0 based computer, but at this
|
||||
; time the feature for runtime testing of CPU type is only supported for the
|
||||
; Amiga. Hopefully a similar test for the Macintosh is possible, and for any
|
||||
; other system that supports both 68000 and 68020+ CPUs. This is written by
|
||||
; Paul Kienitz, partially derived from a simpler version by Carsten Steger,
|
||||
; derived in turn from a 386 assembly function by Jean-loup Gailly and Kai Uwe
|
||||
; Rommel... but also based directly on the C original.
|
||||
;
|
||||
; The main difference of this from other longest_match() implementations is
|
||||
; that it includes both byte based and word based versions of the function,
|
||||
; and various symbols can be defined to select whether to use one routine or
|
||||
; the other, or to do a platform-specific test at runtime. The symbols that
|
||||
; can be used to select behavior are as follows:
|
||||
;
|
||||
; CPU020 if defined, use 68020 instructions always
|
||||
; CPUTEST if defined, check at runtime for CPU type. Another symbol
|
||||
; specifying the platform-specific test must be used with this.
|
||||
; If neither of these is defined, use 68000 instructions only.
|
||||
; AMIGA use Amiga-specific test for 68020, if CPUTEST defined. Also
|
||||
; tells it to let a0/a1/d1 be clobbered by functions.
|
||||
; ATSIGN define entry symbols in @foo form as well as _foo, with
|
||||
; @longest_match taking its parm in d0 instead of on the stack.
|
||||
; WSIZE if defined, determines the sliding window size for deflate;
|
||||
; the default is 32K. If you have reduced WSIZE for the C code,
|
||||
; make sure that this module is assembled with an equivalent
|
||||
; "-dWSIZE=<whatever>" (or "-e...") switch.
|
||||
;
|
||||
; NOTE: no provision is made for 16 bit ints. All external int variables are
|
||||
; treated as 32 bit values. This also assumes that longest_match's result is
|
||||
; returned in D0.
|
||||
|
||||
IFND CPU020
|
||||
IFND CPUTEST
|
||||
CPU000 equ 1
|
||||
ENDC
|
||||
ENDC
|
||||
|
||||
; global variables:
|
||||
xref _max_chain_length ; unsigned int
|
||||
xref _prev_length ; unsigned int
|
||||
xref _match_start ; unsigned int
|
||||
xref _strstart ; unsigned int
|
||||
xref _good_match ; signed int
|
||||
xref _nice_match ; signed int
|
||||
xref _window ; array of unsigned char
|
||||
xref _prev ; array of unsigned short
|
||||
|
||||
; our entry points:
|
||||
xdef _match_init ; void match_init(void);
|
||||
xdef _longest_match ; int longest_match(unsigned cur_match);
|
||||
IFD ATSIGN
|
||||
xdef @match_init ; for SAS assembler
|
||||
xdef @longest_match ; ditto
|
||||
ENDC
|
||||
|
||||
; flag variable for remembering CPU type:
|
||||
IFD CPUTEST
|
||||
section cpuflag,data
|
||||
is020: ds.w 1
|
||||
ENDC
|
||||
|
||||
|
||||
section match,code
|
||||
_match_init:
|
||||
IFD ATSIGN
|
||||
@match_init:
|
||||
ENDC
|
||||
|
||||
IFD CPUTEST ; now check for platform type
|
||||
IFD AMIGA ; Amiga specific test for '020 CPU:
|
||||
|
||||
xref _SysBase
|
||||
|
||||
NOLIST
|
||||
INCLUDE 'exec/execbase.i'
|
||||
LIST
|
||||
|
||||
clr.w is020 ; default value is 68000
|
||||
move.l _SysBase,a0
|
||||
btst #AFB_68020,AttnFlags+1(a0)
|
||||
beq.s cheap
|
||||
move.w #1,is020
|
||||
|
||||
cheap:
|
||||
ELSE ; !AMIGA
|
||||
|
||||
!! Write an '020-detector for your system here!
|
||||
|
||||
ENDC ; AMIGA
|
||||
ENDC ; CPUTEST
|
||||
rts ; match_init consists only of rts if CPUTEST unset
|
||||
|
||||
|
||||
IFD AMIGA
|
||||
SAVEREGS reg d3-d7/a2/a3/a5 ; don't protect d0/d1/a0/a1
|
||||
ELSE
|
||||
SAVEREGS reg d1/d3-d7/a0-a3/a5 ; protect all but d0 return val
|
||||
ENDC
|
||||
|
||||
Cur_Match equr d0 ; Must be in d0!
|
||||
Best_Len equr d1
|
||||
Scan_Start equr d3
|
||||
Scan_End equr d4
|
||||
Limit equr d5
|
||||
Chain_Length equr d6
|
||||
Scan_Test equr d7
|
||||
Scan equr a0
|
||||
Match equr a1
|
||||
Prev_Address equr a2
|
||||
Scan_Ini equr a3
|
||||
Match_Ini equr a5
|
||||
|
||||
|
||||
MAX_MATCH equ 258
|
||||
MIN_MATCH equ 3
|
||||
IFND WSIZE
|
||||
WSIZE equ 32768
|
||||
ENDC
|
||||
MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1
|
||||
|
||||
_longest_match:
|
||||
move.l 4(sp),Cur_Match ; stack arg to register
|
||||
IFD ATSIGN
|
||||
@longest_match:
|
||||
ENDC
|
||||
movem.l SAVEREGS,-(sp)
|
||||
|
||||
; setup steps common to byte and word versions:
|
||||
move.l _max_chain_length,Chain_Length
|
||||
move.l _prev_length,Best_Len
|
||||
lea _prev,Prev_Address
|
||||
lea _window,Match_Ini
|
||||
move.l _strstart,Limit
|
||||
move.l Match_Ini,Scan_Ini
|
||||
addq #MIN_MATCH,Match_Ini
|
||||
add.l Limit,Scan_Ini
|
||||
subi.w #MAX_DIST,Limit
|
||||
bhi.s limit_ok
|
||||
moveq #0,Limit
|
||||
limit_ok:
|
||||
cmp.l _good_match,Best_Len
|
||||
bcs.s length_ok
|
||||
lsr.l #2,Chain_Length
|
||||
length_ok:
|
||||
subq.l #1,Chain_Length
|
||||
|
||||
IFD CPUTEST
|
||||
tst.w is020 ; can we use '020 stuff today?
|
||||
bne WORD_match
|
||||
ENDC
|
||||
|
||||
IFND CPU020
|
||||
|
||||
; for 68000 or 68010, use byte operations:
|
||||
moveq #0,Scan_Start ; clear 2nd and 4th bytes, use 1st & 3rd
|
||||
moveq #0,Scan_End
|
||||
moveq #0,Scan_Test
|
||||
move.b (Scan_Ini),Scan_Start
|
||||
swap Scan_Start
|
||||
move.b 1(Scan_Ini),Scan_Start
|
||||
move.b -1(Scan_Ini,Best_Len),Scan_End
|
||||
swap Scan_End
|
||||
move.b 0(Scan_Ini,Best_Len),Scan_End
|
||||
bra.s bdo_scan
|
||||
|
||||
blong_loop:
|
||||
move.b -1(Scan_Ini,Best_Len),Scan_End
|
||||
swap Scan_End
|
||||
move.b 0(Scan_Ini,Best_Len),Scan_End
|
||||
|
||||
bshort_loop:
|
||||
add.w Cur_Match,Cur_Match
|
||||
move.w 0(Prev_Address,Cur_Match.l),Cur_Match
|
||||
cmp.l Limit,Cur_Match
|
||||
dbls Chain_Length,bdo_scan
|
||||
bra return
|
||||
|
||||
bdo_scan:
|
||||
move.l Match_Ini,Match
|
||||
add.l Cur_Match,Match
|
||||
move.b -MIN_MATCH-1(Match,Best_Len),Scan_Test
|
||||
swap Scan_Test
|
||||
move.b -MIN_MATCH(Match,Best_Len),Scan_Test
|
||||
cmp.l Scan_Test,Scan_End
|
||||
bne.s bshort_loop
|
||||
move.b -MIN_MATCH(Match),Scan_Test
|
||||
swap Scan_Test
|
||||
move.b -MIN_MATCH+1(Match),Scan_Test
|
||||
cmp.l Scan_Test,Scan_Start
|
||||
bne.s bshort_loop
|
||||
move.w #(MAX_MATCH-MIN_MATCH),Scan_Test
|
||||
lea MIN_MATCH(Scan_Ini),Scan
|
||||
|
||||
bscan_loop:
|
||||
cmpm.b (Match)+,(Scan)+
|
||||
dbne Scan_Test,bscan_loop
|
||||
subq #1,Scan
|
||||
|
||||
sub.l Scan_Ini,Scan
|
||||
cmp.l Best_Len,Scan
|
||||
bls.s bshort_loop
|
||||
move.l Scan,Best_Len
|
||||
move.l Cur_Match,_match_start
|
||||
cmp.l _nice_match,Best_Len
|
||||
bcs.s blong_loop
|
||||
IFD CPUTEST
|
||||
bra return
|
||||
ENDC
|
||||
|
||||
ENDC ; !CPU020
|
||||
|
||||
IFND CPU000
|
||||
|
||||
; for 68020 or higher, use word operations even on odd addresses:
|
||||
WORD_match:
|
||||
move.w (Scan_Ini),Scan_Start
|
||||
move.w -1(Scan_Ini,Best_Len),Scan_End
|
||||
bra.s wdo_scan
|
||||
|
||||
wlong_loop:
|
||||
move.w -1(Scan_Ini,Best_Len),Scan_End
|
||||
|
||||
wshort_loop:
|
||||
add.w Cur_Match,Cur_Match
|
||||
move.w (Prev_Address,Cur_Match.l),Cur_Match
|
||||
cmp.l Limit,Cur_Match
|
||||
dbls Chain_Length,wdo_scan
|
||||
bra.s return
|
||||
|
||||
wdo_scan:
|
||||
move.l Match_Ini,Match
|
||||
add.l Cur_Match,Match
|
||||
cmp.w -MIN_MATCH-1(Match,Best_Len),Scan_End
|
||||
bne.s wshort_loop
|
||||
cmp.w -MIN_MATCH(Match),Scan_Start
|
||||
bne.s wshort_loop
|
||||
moveq #((MAX_MATCH-MIN_MATCH)/2),Scan_Test ; value = 127
|
||||
lea MIN_MATCH(Scan_Ini),Scan
|
||||
|
||||
wscan_loop:
|
||||
cmpm.w (Match)+,(Scan)+
|
||||
dbne Scan_Test,wscan_loop
|
||||
subq #2,Scan
|
||||
move.b -MIN_MATCH+1(Match),Scan_Test
|
||||
cmp.b (Scan),Scan_Test
|
||||
bne steven
|
||||
addq #1,Scan
|
||||
steven:
|
||||
sub.l Scan_Ini,Scan
|
||||
cmp.l Best_Len,Scan
|
||||
bls.s wshort_loop
|
||||
move.l Scan,Best_Len
|
||||
move.l Cur_Match,_match_start
|
||||
cmp.l _nice_match,Best_Len
|
||||
bcs.s wlong_loop
|
||||
|
||||
ENDC ; !CPU000
|
||||
|
||||
return:
|
||||
move.l Best_Len,d0 ; function return value
|
||||
movem.l (sp)+,SAVEREGS
|
||||
rts
|
||||
|
||||
end
|
119
third_party/infozip/zip/amiga/osdep.h
vendored
Normal file
119
third_party/infozip/zip/amiga/osdep.h
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2005-Feb-10 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef __amiga_osdep_h
|
||||
#define __amiga_osdep_h
|
||||
|
||||
/* default to MEDIUM_MEM, but allow makefile override */
|
||||
#if ( (!defined(BIG_MEM)) && (!defined(SMALL_MEM)))
|
||||
# define MEDIUM_MEM
|
||||
#endif
|
||||
|
||||
/* check that TZ environment variable is defined before using UTC times */
|
||||
#if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ))
|
||||
# define IZ_CHECK_TZ
|
||||
#endif
|
||||
|
||||
#ifndef IZTZ_GETLOCALETZINFO
|
||||
# define IZTZ_GETLOCALETZINFO GetPlatformLocalTimezone
|
||||
#endif
|
||||
|
||||
/* AmigaDOS can't even support disk partitions over 4GB, let alone files */
|
||||
#define NO_LARGE_FILE_SUPPORT
|
||||
#ifdef LARGE_FILE_SUPPORT
|
||||
# undef LARGE_FILE_SUPPORT
|
||||
#endif
|
||||
|
||||
#define USE_CASE_MAP
|
||||
#define USE_EF_UT_TIME
|
||||
#define HANDLE_AMIGA_SFX
|
||||
#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \
|
||||
procname(n, 1))
|
||||
#define EXIT(e) ClearIOErr_exit(e)
|
||||
void ClearIOErr_exit(int e);
|
||||
|
||||
#include "amiga/z-stat.h"
|
||||
|
||||
#ifdef __SASC
|
||||
# include <sys/types.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>
|
||||
# if (defined(_M68020) && !defined(UNALIGNED_OK))
|
||||
# define UNALIGNED_OK
|
||||
# endif
|
||||
# ifndef REENTRANT
|
||||
# define REENTRANT
|
||||
# endif
|
||||
# if (defined(_NEAR_DATA) && !defined(DYN_ALLOC))
|
||||
# define DYN_ALLOC
|
||||
# endif
|
||||
# ifdef DEBUG
|
||||
# include <sprof.h> /* profiler header file */
|
||||
# endif
|
||||
# ifndef IZTZ_SETLOCALTZINFO
|
||||
/* XXX !! We have really got to find a way to operate without these. */
|
||||
# define IZTZ_SETLOCALTZINFO
|
||||
# endif
|
||||
|
||||
/*
|
||||
A word on short-integers and SAS/C (a bug of [mc]alloc?)
|
||||
Using short integers (i.e. compiling with option SHORT-INTEGERS) is
|
||||
*not* recommended. To get maximum compression ratio the window size stored
|
||||
in WSIZE should be 32k (0x8000). However, since the size of the window[]
|
||||
array is 2*WSIZE, 65536 bytes must be allocated. The calloc function can
|
||||
only allocate UINT_MAX (defined in limits.h) bytes which is one byte short
|
||||
(65535) of the maximum window size if you are compiling with short-ints.
|
||||
You'll get an error message "Out of memory (window allocation)" whenever
|
||||
you try to deflate. Note that the compiler won't produce any warning.
|
||||
The maximum window size with short-integers is therefore 32768 bytes.
|
||||
The following is only implemented to allow the use of short-integers but
|
||||
it is once again not recommended because of a loss in compression ratio.
|
||||
*/
|
||||
# if (defined(_SHORTINT) && !defined(WSIZE))
|
||||
# define WSIZE 0x4000 /* only half of maximum window size */
|
||||
# endif /* possible with short-integers */
|
||||
#endif /* __SASC */
|
||||
/*
|
||||
With Aztec C, using short integers imposes no size limits and makes
|
||||
the program run faster, even with 32 bit CPUs, so it's recommended.
|
||||
*/
|
||||
#ifdef AZTEC_C
|
||||
# define NO_UNISTD_H
|
||||
# define NO_RMDIR
|
||||
# define BROKEN_FSEEK
|
||||
# ifndef IZTZ_DEFINESTDGLOBALS
|
||||
# define IZTZ_DEFINESTDGLOBALS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int real_timezone_is_set;
|
||||
void tzset(void);
|
||||
#define VALID_TIMEZONE(tempvar) (tzset(), real_timezone_is_set)
|
||||
|
||||
#ifdef ZCRYPT_INTERNAL
|
||||
# ifndef CLIB_EXEC_PROTOS_H
|
||||
void *FindTask(void *);
|
||||
# endif
|
||||
# define ZCR_SEED2 (unsigned)(ulg)FindTask(NULL)
|
||||
#endif
|
||||
|
||||
int Agetch(void); /* getch() like function, in amiga/filedate.c */
|
||||
char *GetComment(char *);
|
||||
|
||||
#define FOPR "rb"
|
||||
#define FOPM "rb+"
|
||||
#define FOPW "wb"
|
||||
/* prototype for ctrl-C trap function */
|
||||
void _abort(void);
|
||||
|
||||
#endif /* !__amiga_osdep_h */
|
662
third_party/infozip/zip/amiga/smakefile
vendored
Normal file
662
third_party/infozip/zip/amiga/smakefile
vendored
Normal file
|
@ -0,0 +1,662 @@
|
|||
#===========================================================================
|
||||
# Makefile for Zip, ZipNote, ZipCloak, ZipSplit AMIGA SAS/C Version 6.58
|
||||
# Version: 2.3 last revised: 07 Jan 2007
|
||||
#===========================================================================
|
||||
# -John Bush, <John.Bush@East.Sun.COM>
|
||||
# or: <JBush@Bix.COM>
|
||||
|
||||
# updated for SAS/C Version 6.56+ and AmigaDOS 3.1 (V40)
|
||||
# by Haidinger Walter, <walthaid@unix.ict.tuwien.ac.at>
|
||||
|
||||
# additional supplements and maintenance by Paul Kienitz
|
||||
|
||||
# This makefile should work with at least AmigaDOS 2.04 (V37) (not tested)
|
||||
# and will probably not work with AmigaDOS 1.3 (V34)
|
||||
|
||||
# If you have any improvements, critics or else please feel free to mail.
|
||||
# Any response is appreciated. Haidinger Walter <walthaid@unix.ict.tuwien.ac.at>
|
||||
|
||||
# Available targets:
|
||||
# all builds all executeables below
|
||||
# zip builds zip executeable
|
||||
# zipsplit builds zipsplit executeable
|
||||
# zipcloak builds zipcloak executeable
|
||||
# zipnote builds zipnote executeable
|
||||
# ziplm builds low memory version of zip executable
|
||||
# clean remove all files created by the compilation
|
||||
# spotless like clean target but removes binaries too
|
||||
|
||||
|
||||
##########################
|
||||
# USER MACRO DEFINITIONS #
|
||||
##########################
|
||||
|
||||
# *** NOTE ***
|
||||
# The assembly version is not implemented yet.
|
||||
# (Un)commenting the assembler macros has no effect unless the
|
||||
# file dependencies are changed too.
|
||||
# Most of the amiga/*.a files do not assmble with 68000 instructions.
|
||||
# Any help is appreciated, of course.
|
||||
|
||||
# Set the processor to generate code for.
|
||||
# Compiler: ANY 68000 68010 68020 68030 68040 68060
|
||||
# Assembler: 0 0 1 2 3 4 n/a
|
||||
# Defaults: ANY and 0
|
||||
#
|
||||
CUSECPU = ANY
|
||||
AUSECPU = 0
|
||||
|
||||
# UNCOMMENT to use 68020 instructions in the assembly version of deflate.o
|
||||
# Only use if code is generated for 68020 or higher processors above.
|
||||
# Note: You could use CPUTEST too to enable runtime cpu detection.
|
||||
# However, it is not recommended since both 68000 and 68020 code will be
|
||||
# included which would be an unnecessary increase in size.
|
||||
# (see amiga/deflate.a for more information)
|
||||
#
|
||||
#AUSE020 = CPU020
|
||||
|
||||
# To disable the assembler replacements and use the standard C source,
|
||||
# you have to change the Zip and ZipLM dependencies. See below for details.
|
||||
# (remember that assembler use is *not* implemented yet)
|
||||
|
||||
# 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 programs if you raise your stack to 10000 (which I'd
|
||||
# recommend as a minimum default stack for all applications) or more using the
|
||||
# shell stack command. Type 'Stack 20000' or add it to your S:Shell-Startup.
|
||||
# BTW: Typing 'Stack' prints your current stack size.
|
||||
#
|
||||
CSTACK = NOSTACKCHECK STACKEXTEND # slow, but always works
|
||||
#CSTACK = STACKCHECK NOSTACKEXTEND # slow, requester & graceful exit
|
||||
#CSTACK = NOSTACKCHECK NOSTACKEXTEND # faster but relies on larger stack (>=10K)
|
||||
|
||||
|
||||
#
|
||||
# LIBRARIES
|
||||
# ---------
|
||||
|
||||
# Choose one DATAOPTS , SASLIB , ASMOPTS 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
|
||||
#ASMOPTS = -dINT16
|
||||
#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
|
||||
ASMOPTS =
|
||||
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
|
||||
#ASMOPTS = -dINT16
|
||||
#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
|
||||
#ASMOPTS =
|
||||
#LSTARTUP = c.o
|
||||
|
||||
|
||||
#
|
||||
# DEBUGGING
|
||||
# ---------
|
||||
|
||||
# Default: No debugging information added.
|
||||
# The three macros below will be overwritten if you choose to add
|
||||
# debug info, therefore no need to comment.
|
||||
|
||||
CDBG = NODEBUG NOPROFILE NOCOVERAGE # default: no debug info
|
||||
ADBG =
|
||||
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, ADBG and LDBG to include debugging information
|
||||
|
||||
#CDBG = $(CDBG1) $(CDBG2) $(CDBG3) ADDSYM DEBUG=FULLFLUSH STACKCHECK NOOPT
|
||||
#ADBG = DEBUG
|
||||
#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 memwatch.library has a small bug: MWTerm() displays always
|
||||
# the first entry.
|
||||
# Get the latest version from aminet (dev/debug/memlib.lha) or
|
||||
# contact me to get the patch. Uncomment all macros to use.
|
||||
#CMEMLIB = DEFINE=MWDEBUG=1 # define to enable library
|
||||
#LMEMLIB = SC:LIB/memwatch.lib # path to library
|
||||
#LSTARTUP = c.o # must use c.o with memlib!
|
||||
|
||||
|
||||
#
|
||||
# MAPPING
|
||||
# -------
|
||||
|
||||
# Map filenames used when mapping (no need to comment)
|
||||
#
|
||||
MAPFZ = zip.map # Zip map filename
|
||||
MAPFN = zipnote.map # ZipNote map filename
|
||||
MAPFC = zipcloak.map # ZipCloak map filename
|
||||
MAPFS = zipsplit.map # ZipSplit map filename
|
||||
MAPFL = ziplm.map # Zip low memory version 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
|
||||
#LMAPZ = $(MAPFSTYLE) MAP $(MAPFZ) f,h,l,o,s,x # Zip maps
|
||||
#LMAPN = $(MAPFSTYLE) MAP $(MAPFN) f,h,l,o,s,x # ZipNote maps
|
||||
#LMAPC = $(MAPFSTYLE) MAP $(MAPFC) f,h,l,o,s,x # ZipCloak maps
|
||||
#LMAPS = $(MAPFSTYLE) MAP $(MAPFS) f,h,l,o,s,x # ZipSplit maps
|
||||
#LMAPL = $(MAPFSTYLE) MAP $(MAPFL) f,h,l,o,s,x # Zip lowmem maps
|
||||
|
||||
#
|
||||
# LISTINGS
|
||||
# --------
|
||||
|
||||
# Listfile-extensions for each executable (enter *with* dot)
|
||||
#
|
||||
LISTEXTZ = .lst # extension for Zip listfiles
|
||||
LISTEXTU = .ulst # extension for utility listfiles (ZipNote,ZipCloak,ZipSplit)
|
||||
LISTEXTL = .llst # extension for Zip low memory listfiles
|
||||
|
||||
|
||||
# List files and cross references for each OBJECT.
|
||||
# Add/remove flags as needed. Not all listed by default.
|
||||
# Use LISTINCLUDES 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 # extension for Zip objects
|
||||
OU = .uo # extension for utility objects (ZipNote, ZipSplit and ZipCloak)
|
||||
OL = .lo # extension for low memory Zip objects
|
||||
|
||||
|
||||
# Filename used to store converted options from environment variable
|
||||
# LOCAL_ZIP. Default: scoptions_local_zip
|
||||
#
|
||||
CWITHOPT = scoptions_local_zip
|
||||
|
||||
|
||||
# Filenames to store compiler options to prevent command line overflow
|
||||
#
|
||||
# Common options file for Zip and other executables
|
||||
CFILE = scoptions-zip
|
||||
|
||||
|
||||
# Temp filenames for object lists to load using linker "WITH" command.
|
||||
OBJLISTZ = zip_objlist.with # Zip object list
|
||||
OBJLISTN = zipnote_objlist.with # ZipNote object list
|
||||
OBJLISTC = zipcloak_objlist.with # ZipCloak object list
|
||||
OBJLISTS = zipsplit_objlist.with # ZipSplit object list
|
||||
OBJLISTL = ziplm_objlist.with # Zip low-mem object list
|
||||
|
||||
|
||||
# Filenames to store linker options
|
||||
#
|
||||
LWITHZ = zip.lnk # zip linker options
|
||||
LWITHN = zipnote.lnk # zipnote linker options
|
||||
LWITHC = zipcloak.lnk # zipcloak linker options
|
||||
LWITHS = zipsplit.lnk # zipsplit linker options
|
||||
LWITHL = ziplm.lnk # zip low-mem linker options
|
||||
|
||||
|
||||
# Define AMIGA_BETA to print "Beta Notice" up front. See tailor.h.
|
||||
# Undefine AMIGA_BETA when building a released version.
|
||||
#CDEFBETA = DEF=AMIGA_BETA
|
||||
|
||||
#####################################
|
||||
# NOTHING TO CHANGE BEYOND HERE ... #
|
||||
#####################################
|
||||
# (except for C/asm dependencies)
|
||||
|
||||
# Define MEDIUM_MEM for production release (per Paul Kienitz).
|
||||
# This reduces runtime memory requirement but not speed or compression.
|
||||
# Note: Do *not* use BIG_MEM or MMAP since it isn't yet supported by the
|
||||
assembler version of deflate.c : amiga/deflate.a
|
||||
CUSEMEM = DEF=MEDIUM_MEM
|
||||
AUSEMEM = -DMEDIUM_MEM # for asm deflate.o, must match above
|
||||
|
||||
|
||||
# Defines for building low-memory use version of Zip
|
||||
WSIZEL = WSIZE=4096 # deflate.c window size for low-mem version
|
||||
CLOWMEM = DEF=SMALL_MEM DEF=$(WSIZEL)
|
||||
ALOWMEM = -DSMALL_MEM -D$(WSIZEL) # for asm deflate.o, must match above
|
||||
|
||||
|
||||
# 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
|
||||
#
|
||||
CDEFINES = $(CMEMLIB) $(CDEFBETA) DEF=AMIGA
|
||||
COPTIONS = $(DATAOPTS) CODE=NEAR CPU=$(CUSECPU) VERBOSE PARAMETERS=BOTH NOMINC
|
||||
COPTIONS = $(COPTIONS) ERRORREXX NOERRORCONSOLE MEMSIZE=HUGE $(CLIST) $(CXREF)
|
||||
COPTIONS = $(COPTIONS) $(CSTACK) $(CUTIL) STRICT UNSCHAR NOICONS STRINGMERGE
|
||||
CFLAGS = $(CDEFINES) $(COPTIONS) $(OPT) $(CDBG) $(CIGNORE)
|
||||
|
||||
|
||||
# Linker definitions
|
||||
# See SASLIB definition above
|
||||
#
|
||||
LD = slink
|
||||
# special linker flags for 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)
|
||||
LIBFLAGS = LIB $(LMEMLIB) SC:LIB/$(SASLIB).lib SC:LIB/amiga.lib
|
||||
|
||||
|
||||
# Assembler definitions
|
||||
#
|
||||
ASM = asm
|
||||
#
|
||||
# Options used for assembling amiga/deflate.a
|
||||
# Must match defines in C-Source.
|
||||
#
|
||||
AFLAGS0 = -d__SASC -dSASC -dAMIGA
|
||||
AFLAGS1 = $(AUSE020) $(ASMOPTS) $(ADBG)
|
||||
AFLAGS2 = -m$(AUSECPU) -jm -iINCLUDE:
|
||||
AFLAGS = $(AFLAGS0) $(AFLAGS1) $(AFLAGS2)
|
||||
ASMOPTSZ = $(AFLAGS) $(AUSEMEM) -dDYN_ALLOC # Zip asm flags
|
||||
ASMOPTSL = $(AFLAGS) $(ALOWMEM) # Zip low-mem version asm flags
|
||||
|
||||
|
||||
##################
|
||||
# TARGET OBJECTS #
|
||||
##################
|
||||
|
||||
|
||||
# Zip objects
|
||||
OBJZ1 = zip$(O) zipfile$(O) zipup$(O) fileio$(O) util$(O) globals$(O)
|
||||
OBJZ2 = crc32$(O) crypt$(O) timezone$(O) ttyio$(O)
|
||||
OBJZI = deflate$(O) trees$(O)
|
||||
OBJZA = amiga$(O) amigazip$(O) stat$(O) filedate$(O)
|
||||
OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZI) $(OBJZA)
|
||||
|
||||
# Shared utility objects for ZipNote, ZipCloak and ZipSplit
|
||||
OBJU1 = globals$(O)
|
||||
OBJUU = zipfile$(OU) fileio$(OU) timezone$(O) util$(OU)
|
||||
OBJUA = amigazip$(OU) amiga$(O) stat$(O) filedate$(O)
|
||||
OBJU = $(OBJU1) $(OBJUU) $(OBJUA)
|
||||
|
||||
# ZipNote objects
|
||||
OBJN1 = zipnote$(O)
|
||||
OBJN = $(OBJN1) $(OBJU)
|
||||
|
||||
# ZipCloak objects
|
||||
OBJC1 = zipcloak$(O)
|
||||
OBJCU = $(OBJU) crypt$(OU)
|
||||
OBJCS = crc32$(OU) ttyio$(O)
|
||||
OBJC = $(OBJC1) $(OBJCU) $(OBJCS)
|
||||
|
||||
#ZipSplit objects
|
||||
OBJS1 = zipsplit$(O)
|
||||
OBJS = $(OBJS1) $(OBJU)
|
||||
|
||||
# ZipLM objects
|
||||
OBJL1 = zip$(OL) zipfile$(OL) zipup$(OL) fileio$(OL) util$(OL) globals$(OL)
|
||||
OBJL2 = crc32$(OL) crypt$(OL) timezone$(OL) ttyio$(OL)
|
||||
OBJLI = deflate$(OL) trees$(OL)
|
||||
OBJLA = amiga$(OL) amigazip$(OL) stat$(OL) filedate$(OL)
|
||||
OBJL = $(OBJL1) $(OBJL2) $(OBJLI) $(OBJLA)
|
||||
|
||||
# Common header files
|
||||
ZIP_H1 = zip.h ziperr.h tailor.h
|
||||
ZIP_HA = amiga/osdep.h amiga/z-stat.h
|
||||
ZIP_H = $(ZIP_H1) $(ZIP_HA)
|
||||
|
||||
# Output targets
|
||||
ZIPS = Zip ZipNote ZipCloak ZipSplit ZipLM
|
||||
|
||||
|
||||
# Temp filenames for object lists to load using linker "WITH" command.
|
||||
OBJLISTZ = zip_objlist.with # Zip object list
|
||||
OBJLISTN = zipnote_objlist.with # ZipNote object list
|
||||
OBJLISTC = zipcloak_objlist.with # ZipCloak object list
|
||||
OBJLISTS = zipsplit_objlist.with # ZipSplit object list
|
||||
OBJLISTL = ziplm_objlist.with # Zip low-mem object list
|
||||
|
||||
#######################################
|
||||
# DEFAULT TARGET AND PROCESSING RULES #
|
||||
#######################################
|
||||
|
||||
all: request flush $(ZIPS)
|
||||
|
||||
# Zip transformation rules
|
||||
#
|
||||
.c$(O):
|
||||
$(CC) WITH=$(CFILE) $(CUSEMEM) LISTFILE=$>$(LISTEXTZ) OBJNAME=$@ $*.c
|
||||
|
||||
# Zip low-memory version transformation rules
|
||||
#
|
||||
.c$(OL):
|
||||
$(CC) WITH=$(CFILE) $(CLOWMEM) LISTFILE=$>$(LISTEXTL) OBJNAME=$@ $*.c
|
||||
|
||||
# Utilities (ZipNote, ZipCloak and ZipSplit) transformation rules
|
||||
#
|
||||
.c$(OU):
|
||||
$(CC) WITH=$(CFILE) $(CUSEMEM) DEF=UTIL LISTFILE=$>$(LISTEXTU) OBJNAME=$@ $*.c
|
||||
|
||||
|
||||
#########################
|
||||
# Final output targets. #
|
||||
#########################
|
||||
|
||||
|
||||
zip: local_zip CommonFlags $(OBJZ)
|
||||
@Echo "$(OBJZ)" > $(OBJLISTZ)
|
||||
Type $(OBJLISTZ)
|
||||
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTZ) $(LIBFLAGS)" \
|
||||
"$(LDFLAGS2) $(LMAPZ)" >$(LWITHZ)
|
||||
Type $(LWITHZ)
|
||||
$(LD) TO Zip WITH $(LWITHZ)
|
||||
|
||||
zipnote: local_zip CommonFlags $(OBJN)
|
||||
@Echo "$(OBJN)" > $(OBJLISTN)
|
||||
Type $(OBJLISTN)
|
||||
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTN) $(LIBFLAGS) " \
|
||||
"$(LDFLAGS2) $(LMAPN)" >$(LWITHN)
|
||||
Type $(LWITHN)
|
||||
$(LD) TO ZipNote WITH $(LWITHN)
|
||||
|
||||
zipcloak: local_zip CommonFlags $(OBJC)
|
||||
@Echo "$(OBJC)" > $(OBJLISTC)
|
||||
Type $(OBJLISTC)
|
||||
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTC) $(LIBFLAGS) " \
|
||||
"$(LDFLAGS2) $(LMAPC)" >$(LWITHC)
|
||||
Type $(LWITHC)
|
||||
$(LD) TO ZipCloak WITH $(LWITHC)
|
||||
|
||||
zipsplit: local_zip CommonFlags $(OBJS)
|
||||
@Echo "$(OBJS)" > $(OBJLISTS)
|
||||
Type $(OBJLISTS)
|
||||
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTS) $(LIBFLAGS) " \
|
||||
"$(LDFLAGS2) $(LMAPS)" >$(LWITHS)
|
||||
Type $(LWITHS)
|
||||
$(LD) TO ZipSplit WITH $(LWITHS)
|
||||
|
||||
ziplm: local_zip CommonFlags $(OBJL)
|
||||
@Echo "$(OBJL)" > $(OBJLISTL)
|
||||
Type $(OBJLISTL)
|
||||
@Echo "$(LDFLAGSS) $(LUTIL) WITH $(OBJLISTL) $(LIBFLAGS) " \
|
||||
"$(LDFLAGS2) $(LMAPL)" >$(LWITHL)
|
||||
Type $(LWITHL)
|
||||
$(LD) TO ZipLM WITH $(LWITHL)
|
||||
|
||||
|
||||
clean:
|
||||
-Delete >nil: $(OBJZ) quiet
|
||||
-Delete >nil: $(OBJN) quiet
|
||||
-Delete >nil: $(OBJC) quiet
|
||||
-Delete >nil: $(OBJS) quiet
|
||||
-Delete >nil: $(OBJL) quiet
|
||||
-Delete >nil: $(OBJLISTZ) $(OBJLISTL) $(OBJLISTN) $(OBJLISTS) $(OBJLISTC) quiet
|
||||
-Delete >nil: $(MAPFZ) $(MAPFN) $(MAPFC) $(MAPFS) $(MAPFL) quiet
|
||||
-Delete >nil: \#?$(LISTEXTZ) \#?$(LISTEXTU) \#?$(LISTEXTL) quiet
|
||||
-Delete >nil: $(CWITHOPT) $(CFILE) quiet
|
||||
-Delete >nil: $(LWITHZ) $(LWITHN) $(LWITHC) $(LWITHS) $(LWITHL) quiet
|
||||
-Delete >nil: env:VersionDate quiet
|
||||
-Delete >nil: \#?.q.?? \#?.tmp \#?.cov quiet
|
||||
|
||||
spotless: clean
|
||||
-Delete >nil: $(ZIPS) quiet
|
||||
|
||||
|
||||
################
|
||||
# DEPENDENCIES #
|
||||
################
|
||||
|
||||
# To change between the assembler and C sources, you have to comment/uncomment
|
||||
# the approprite lines. C sources are marked by #C-src and assembler sources
|
||||
# #asm-src at the end.
|
||||
# Zip dependencies:
|
||||
#
|
||||
|
||||
zip$(O): zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
|
||||
zipup$(O): zipup.c $(ZIP_H) revision.h crc32.h crypt.h amiga/zipup.h
|
||||
zipfile$(O): zipfile.c $(ZIP_H) revision.h crc32.h
|
||||
crypt$(O): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
|
||||
ttyio$(O): ttyio.c $(ZIP_H) crypt.h ttyio.h
|
||||
deflate$(O): deflate.c $(ZIP_H) #C-src
|
||||
trees$(O): trees.c $(ZIP_H)
|
||||
fileio$(O): fileio.c $(ZIP_H) crc32.h
|
||||
util$(O): util.c $(ZIP_H)
|
||||
crc32$(O): crc32.c $(ZIP_H) crc32.h
|
||||
globals$(O): globals.c $(ZIP_H)
|
||||
timezone$(O): timezone.c $(ZIP_H) timezone.h
|
||||
# Amiga specific objects
|
||||
stat$(O): amiga/stat.c amiga/z-stat.h
|
||||
filedate$(O): amiga/filedate.c crypt.h timezone.h
|
||||
amiga$(O): amiga/amiga.c ziperr.h
|
||||
amigazip$(O): amiga/amigazip.c $(ZIP_H) amiga/amiga.h env:Workbench
|
||||
# Substitute assembly version of deflate.c:
|
||||
#deflate$(O): amiga/deflate.a #asm-src
|
||||
# $(ASM) $(ASMOPTSZ) -o$@ $*.a #asm-src
|
||||
|
||||
|
||||
# Utility (ZipNote, ZipCloak, ZipSplit) dependencies:
|
||||
#
|
||||
zipnote$(O): zipnote.c $(ZIP_H) revision.h
|
||||
zipcloak$(O): zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
|
||||
zipsplit$(O): zipsplit.c $(ZIP_H) revision.h
|
||||
zipfile$(OU): zipfile.c $(ZIP_H) revision.h crc32.h
|
||||
fileio$(OU): fileio.c $(ZIP_H) crc32.h
|
||||
util$(OU): util.c $(ZIP_H)
|
||||
crc32$(OU): crc32.c $(ZIP_H) crc32.h
|
||||
crypt$(OU): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
|
||||
# Amiga specific objects
|
||||
amigazip$(OU): amiga/amigazip.c $(ZIP_H) amiga/amiga.h env:Workbench
|
||||
|
||||
# ZipLM dependencies:
|
||||
#
|
||||
zip$(OL): zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
|
||||
zipup$(OL): zipup.c $(ZIP_H) revision.h crc32.h crypt.h amiga/zipup.h
|
||||
zipfile$(OL): zipfile.c $(ZIP_H) revision.h crc32.h
|
||||
crypt$(OL): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
|
||||
ttyio$(OL): ttyio.c $(ZIP_H) crypt.h ttyio.h
|
||||
deflate$(OL): deflate.c $(ZIP_H)
|
||||
trees$(OL): trees.c $(ZIP_H)
|
||||
fileio$(OL): fileio.c $(ZIP_H) crc32.h
|
||||
util$(OL): util.c $(ZIP_H)
|
||||
crc32$(OL): crc32.c $(ZIP_H)
|
||||
globals$(OL): globals.c $(ZIP_H)
|
||||
timezone$(OL): timezone.c $(ZIP_H) timezone.h
|
||||
# Amiga specific objects
|
||||
stat$(OL): amiga/stat.c amiga/z-stat.h
|
||||
filedate$(OL): amiga/filedate.c crypt.h timezone.h
|
||||
amiga$(OL): amiga/amiga.c ziperr.h
|
||||
# Substitute assembly version of deflate.c:
|
||||
#deflate$(OL): amiga/deflate.a
|
||||
# $(ASM) $(ASMOPTSL) -o$@ $*.a
|
||||
|
||||
|
||||
########################
|
||||
# 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 "$(CFLAGS)" >$(CFILE)
|
||||
@Type "$(CWITHOPT)" >>$(CFILE)
|
||||
-Type $(CFILE)
|
||||
|
||||
|
||||
# special rules for adding Amiga internal version number to amiga/amiga.c
|
||||
amiga$(O):
|
||||
rx > env:VersionDate "say '""'translate(date('E'),'.','/')'""'"
|
||||
$(CC) WITH=$(CFILE) $(CUSEMEM) LISTFILE=$>$(LISTEXTZ) OBJNAME=$@ $*.c
|
||||
-Delete env:VersionDate
|
||||
|
||||
amiga$(OL):
|
||||
rx > env:VersionDate "say '""'translate(date('E'),'.','/')'""'"
|
||||
$(CC) WITH=$(CFILE) $(CLOWMEM) LISTFILE=$>$(LISTEXTL) OBJNAME=$@ $*.c
|
||||
-Delete env:VersionDate
|
||||
|
||||
|
||||
# needed in amiga/amigazip.c
|
||||
# should be set in startup-sequence, but just in case:
|
||||
# (only works with OS 2.0 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_ZIP and convert options to SAS format
|
||||
#
|
||||
# e.g.: to define FOO_ONE and FOO_TWO enter:
|
||||
#
|
||||
# SetEnv LOCAL_ZIP "-DFOO_ONE -DFOO_TWO"
|
||||
#
|
||||
# Put the statement into your startup-sequence or (for AmigaDOS 2.0 or higher
|
||||
# only) make sure LOCAL_ZIP is stored in the ENVARC: directory
|
||||
# ( Copy ENV:LOCAL_ZIP ENVARC: )
|
||||
#
|
||||
|
||||
local_zip:
|
||||
@Execute < < (Local_Zip_smk.tmp)
|
||||
Failat 21
|
||||
If exists ENV:LOCAL_ZIP
|
||||
Echo "Using environment variable LOCAL_ZIP !"
|
||||
Copy >NIL: ENV:LOCAL_ZIP SASCOPTS
|
||||
Else
|
||||
Echo "You could use envvar ZIP_OPT to set your special compilation options."
|
||||
Delete >nil: SASCOPTS quiet
|
||||
Endif
|
||||
; Do not remove the lctosc command! If LOCAL_ZIP is unset, an
|
||||
; empty file is created which needed by CommonFlags !
|
||||
lctosc >$(CWITHOPT)
|
||||
<
|
||||
|
||||
|
||||
|
||||
# Echo request to the user
|
||||
#
|
||||
request:
|
||||
@Echo ""
|
||||
@Echo " This makefile is for use with SAS/C version 6.58."
|
||||
@Echo " If you still have an older version, please upgrade!"
|
||||
@Echo " Patches are available on the Aminet under biz/patch/sc\#?."
|
||||
@Echo ""
|
||||
@Echo " Just a simple request..."
|
||||
@Echo " Please give me a mail that you compiled whether you encounter any errors"
|
||||
@Echo " or not. I'd just like to know how many Amiga users actually make use of"
|
||||
@Echo " this makefile."
|
||||
@Echo " If you mail me, I'll put you on my mailing-list and notify you whenever"
|
||||
@Echo " new versions of Info-Zip are released."
|
||||
@Echo " Have a look at the makefile for changes like CPU type, UtilLib, etc."
|
||||
@Echo " Feel free to mail comments, suggestions, etc."
|
||||
@Echo " Enjoy Info-Zip !"
|
||||
@Echo " Haidinger Walter, <walthaid@unix.ict.tuwien.ac.at>"
|
||||
@Echo ""
|
||||
|
||||
|
||||
# Echo help in case of an error
|
||||
#
|
||||
.ONERROR:
|
||||
@Echo ""
|
||||
@Echo "[sigh] An error running this makefile was detected."
|
||||
@Echo "This message may also appear if you interrupted smake by pressing CTRL-C."
|
||||
@Echo "Contact Info-Zip authors at Zip-Bugs@lists.wku.edu or me for help."
|
||||
@Echo "Haidinger Walter, <walthaid@unix.ict.tuwien.ac.at>"
|
||||
|
293
third_party/infozip/zip/amiga/stat.c
vendored
Normal file
293
third_party/infozip/zip/amiga/stat.c
vendored
Normal file
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* Here we have a handmade stat() function because Aztec's c.lib stat() */
|
||||
/* does not support an st_mode field, which we need... also a chmod(). */
|
||||
|
||||
/* This stat() is by Paul Wells, modified by Paul Kienitz. */
|
||||
/* Originally for use with Aztec C >= 5.0 and Lattice C <= 4.01 */
|
||||
/* Adapted for SAS/C 6.5x by Haidinger Walter */
|
||||
|
||||
/* POLICY DECISION: We will not attempt to remove global variables from */
|
||||
/* this source file for Aztec C. These routines are essentially just */
|
||||
/* augmentations of Aztec's c.lib, which is itself not reentrant. If */
|
||||
/* we want to produce a fully reentrant UnZip, we will have to use a */
|
||||
/* suitable startup module, such as purify.a for Aztec by Paul Kienitz. */
|
||||
|
||||
#ifndef __amiga_stat_c
|
||||
#define __amiga_stat_c
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include "amiga/z-stat.h" /* fake version of stat.h */
|
||||
#include <string.h>
|
||||
|
||||
#ifdef AZTEC_C
|
||||
# include <libraries/dos.h>
|
||||
# include <libraries/dosextens.h>
|
||||
# include <clib/exec_protos.h>
|
||||
# include <clib/dos_protos.h>
|
||||
# include <pragmas/exec_lib.h>
|
||||
# include <pragmas/dos_lib.h>
|
||||
#endif
|
||||
#ifdef __SASC
|
||||
# include <sys/dir.h> /* SAS/C dir function prototypes */
|
||||
# include <sys/types.h>
|
||||
# include <proto/exec.h>
|
||||
# include <proto/dos.h>
|
||||
#endif
|
||||
|
||||
#ifndef SUCCESS
|
||||
# define SUCCESS (-1)
|
||||
# define FAILURE (0)
|
||||
#endif
|
||||
|
||||
|
||||
void close_leftover_open_dirs(void); /* prototype */
|
||||
|
||||
static DIR *dir_cleanup_list = NULL; /* for resource tracking */
|
||||
|
||||
/* CALL THIS WHEN HANDLING CTRL-C OR OTHER UNEXPECTED EXIT! */
|
||||
void close_leftover_open_dirs(void)
|
||||
{
|
||||
while (dir_cleanup_list)
|
||||
closedir(dir_cleanup_list);
|
||||
}
|
||||
|
||||
|
||||
unsigned short disk_not_mounted;
|
||||
|
||||
extern int stat(const char *file, struct stat *buf);
|
||||
|
||||
stat(file,buf)
|
||||
const char *file;
|
||||
struct stat *buf;
|
||||
{
|
||||
|
||||
struct FileInfoBlock *inf;
|
||||
BPTR lock;
|
||||
time_t ftime;
|
||||
struct tm local_tm;
|
||||
|
||||
if( (lock = Lock((char *)file,SHARED_LOCK))==0 )
|
||||
/* file not found */
|
||||
return(-1);
|
||||
|
||||
if( !(inf = (struct FileInfoBlock *)AllocMem(
|
||||
(long)sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR)) )
|
||||
{
|
||||
UnLock(lock);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if( Examine(lock,inf)==FAILURE )
|
||||
{
|
||||
FreeMem((char *)inf,(long)sizeof(*inf));
|
||||
UnLock(lock);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* fill in buf */
|
||||
buf->st_dev =
|
||||
buf->st_nlink =
|
||||
buf->st_uid =
|
||||
buf->st_gid =
|
||||
buf->st_rdev = 0;
|
||||
buf->st_ino = inf->fib_DiskKey;
|
||||
buf->st_blocks = inf->fib_NumBlocks;
|
||||
buf->st_size = inf->fib_Size;
|
||||
|
||||
/* now the date. AmigaDOS has weird datestamps---
|
||||
* ds_Days is the number of days since 1-1-1978;
|
||||
* however, as Unix wants date since 1-1-1970...
|
||||
*/
|
||||
|
||||
ftime =
|
||||
(inf->fib_Date.ds_Days * 86400 ) +
|
||||
(inf->fib_Date.ds_Minute * 60 ) +
|
||||
(inf->fib_Date.ds_Tick / TICKS_PER_SECOND ) +
|
||||
(86400 * 8 * 365 ) +
|
||||
(86400 * 2 ); /* two leap years */
|
||||
|
||||
/* tzset(); */ /* this should be handled by mktime(), instead */
|
||||
/* ftime += timezone; */
|
||||
local_tm = *gmtime(&ftime);
|
||||
local_tm.tm_isdst = -1;
|
||||
ftime = mktime(&local_tm);
|
||||
|
||||
buf->st_ctime =
|
||||
buf->st_atime =
|
||||
buf->st_mtime = ftime;
|
||||
|
||||
buf->st_mode = (inf->fib_DirEntryType < 0 ? S_IFREG : S_IFDIR);
|
||||
|
||||
/* lastly, throw in the protection bits */
|
||||
buf->st_mode |= ((inf->fib_Protection ^ 0xF) & 0xFF);
|
||||
|
||||
FreeMem((char *)inf, (long)sizeof(*inf));
|
||||
UnLock((BPTR)lock);
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
int fstat(int handle, struct stat *buf)
|
||||
{
|
||||
/* fake some reasonable values for stdin */
|
||||
buf->st_mode = (S_IREAD|S_IWRITE|S_IFREG);
|
||||
buf->st_size = -1;
|
||||
buf->st_mtime = time(&buf->st_mtime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* opendir(), readdir(), closedir(), rmdir(), and chmod() by Paul Kienitz. */
|
||||
|
||||
DIR *opendir(const char *path)
|
||||
{
|
||||
DIR *dd = AllocMem(sizeof(DIR), MEMF_PUBLIC);
|
||||
if (!dd) return NULL;
|
||||
if (!(dd->d_parentlock = Lock((char *)path, MODE_OLDFILE))) {
|
||||
disk_not_mounted = IoErr() == ERROR_DEVICE_NOT_MOUNTED;
|
||||
FreeMem(dd, sizeof(DIR));
|
||||
return NULL;
|
||||
} else
|
||||
disk_not_mounted = 0;
|
||||
if (!Examine(dd->d_parentlock, &dd->d_fib) || dd->d_fib.fib_EntryType < 0) {
|
||||
UnLock(dd->d_parentlock);
|
||||
FreeMem(dd, sizeof(DIR));
|
||||
return NULL;
|
||||
}
|
||||
dd->d_cleanuplink = dir_cleanup_list; /* track them resources */
|
||||
if (dir_cleanup_list)
|
||||
dir_cleanup_list->d_cleanupparent = &dd->d_cleanuplink;
|
||||
dd->d_cleanupparent = &dir_cleanup_list;
|
||||
dir_cleanup_list = dd;
|
||||
return dd;
|
||||
}
|
||||
|
||||
void closedir(DIR *dd)
|
||||
{
|
||||
if (dd) {
|
||||
if (dd->d_cleanuplink)
|
||||
dd->d_cleanuplink->d_cleanupparent = dd->d_cleanupparent;
|
||||
*(dd->d_cleanupparent) = dd->d_cleanuplink;
|
||||
if (dd->d_parentlock)
|
||||
UnLock(dd->d_parentlock);
|
||||
FreeMem(dd, sizeof(DIR));
|
||||
}
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dd)
|
||||
{
|
||||
return (ExNext(dd->d_parentlock, &dd->d_fib) ? (struct dirent *)dd : NULL);
|
||||
}
|
||||
|
||||
|
||||
#ifdef AZTEC_C
|
||||
|
||||
int rmdir(const char *path)
|
||||
{
|
||||
return (DeleteFile((char *)path) ? 0 : IoErr());
|
||||
}
|
||||
|
||||
int chmod(const char *filename, int bits) /* bits are as for st_mode */
|
||||
{
|
||||
long protmask = (bits & 0xFF) ^ 0xF;
|
||||
return !SetProtection((char *)filename, protmask);
|
||||
}
|
||||
|
||||
|
||||
/* This here removes unnecessary bulk from the executable with Aztec: */
|
||||
void _wb_parse(void) { }
|
||||
|
||||
/* fake a unix function that does not apply to amigados: */
|
||||
int umask(void) { return 0; }
|
||||
|
||||
|
||||
# include <signal.h>
|
||||
|
||||
/* C library signal() messes up debugging yet adds no actual usefulness */
|
||||
typedef void (*__signal_return_type)(int);
|
||||
__signal_return_type signal() { return SIG_ERR; }
|
||||
|
||||
|
||||
/* The following replaces Aztec's argv-parsing function for compatibility with
|
||||
Unix-like syntax used on other platforms. It also fixes the problem the
|
||||
standard _cli_parse() has of accepting only lower-ascii characters. */
|
||||
|
||||
int _argc, _arg_len;
|
||||
char **_argv, *_arg_lin;
|
||||
|
||||
void _cli_parse(struct Process *pp, long alen, register UBYTE *aptr)
|
||||
{
|
||||
register UBYTE *cp;
|
||||
register struct CommandLineInterface *cli;
|
||||
register short c;
|
||||
register short starred = 0;
|
||||
# ifdef PRESTART_HOOK
|
||||
void Prestart_Hook(void);
|
||||
# endif
|
||||
|
||||
cli = (struct CommandLineInterface *) (pp->pr_CLI << 2);
|
||||
cp = (UBYTE *) (cli->cli_CommandName << 2);
|
||||
_arg_len = cp[0] + alen + 2;
|
||||
if (!(_arg_lin = AllocMem((long) _arg_len, 0L)))
|
||||
return;
|
||||
c = cp[0];
|
||||
strncpy(_arg_lin, cp + 1, c);
|
||||
_arg_lin[c] = 0;
|
||||
for (cp = _arg_lin + c + 1; alen && (*aptr < '\n' || *aptr > '\r'); alen--)
|
||||
*cp++ = *aptr++;
|
||||
*cp = 0;
|
||||
aptr = cp = _arg_lin + c + 1;
|
||||
for (_argc = 1; ; _argc++) {
|
||||
while (*cp == ' ' || *cp == '\t')
|
||||
cp++;
|
||||
if (!*cp)
|
||||
break;
|
||||
if (*cp == '"') {
|
||||
cp++;
|
||||
while (c = *cp++) {
|
||||
if (c == '"' && !starred) {
|
||||
*aptr++ = 0;
|
||||
starred = 0;
|
||||
break;
|
||||
} else if (c == '\\' && !starred)
|
||||
starred = 1;
|
||||
else {
|
||||
*aptr++ = c;
|
||||
starred = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((c = *cp++) && c != ' ' && c != '\t')
|
||||
*aptr++ = c;
|
||||
*aptr++ = 0;
|
||||
}
|
||||
if (c == 0)
|
||||
--cp;
|
||||
}
|
||||
*aptr = 0;
|
||||
if (!(_argv = AllocMem((_argc + 1) * sizeof(*_argv), 0L))) {
|
||||
_argc = 0;
|
||||
return;
|
||||
}
|
||||
for (c = 0, cp = _arg_lin; c < _argc; c++) {
|
||||
_argv[c] = cp;
|
||||
cp += strlen(cp) + 1;
|
||||
}
|
||||
_argv[c] = NULL;
|
||||
# ifdef PRESTART_HOOK
|
||||
Prestart_Hook();
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif /* AZTEC_C */
|
||||
|
||||
#endif /* __amiga_stat_c */
|
95
third_party/infozip/zip/amiga/z-stat.h
vendored
Normal file
95
third_party/infozip/zip/amiga/z-stat.h
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef __amiga_z_stat_h
|
||||
#define __amiga_z_stat_h
|
||||
|
||||
/* Since older versions of the Lattice C compiler for Amiga, and all current */
|
||||
/* versions of the Manx Aztec C compiler for Amiga, either provide no stat() */
|
||||
/* function or provide one inadequate for unzip (Aztec's has no st_mode */
|
||||
/* field), we provide our own stat() function in stat.c by Paul Wells, and */
|
||||
/* this fake stat.h file by Paul Kienitz. Paul Wells originally used the */
|
||||
/* Lattice stat.h but that does not work for Aztec and is not distributable */
|
||||
/* with this package, so I made a separate one. This has to be pulled into */
|
||||
/* unzip.h when compiling an Amiga version, as "amiga/z-stat.h". */
|
||||
|
||||
/* We also provide here a "struct dirent" for use with opendir() & readdir() */
|
||||
/* functions included in amiga/stat.c. If you use amiga/stat.c, this must */
|
||||
/* be included wherever you use either readdir() or stat(). */
|
||||
|
||||
#ifdef AZTEC_C
|
||||
# define __STAT_H
|
||||
#else /* __SASC */
|
||||
/* do not include the following header, replacement definitions are here */
|
||||
# define _STAT_H /* do not include SAS/C <stat.h> */
|
||||
# define _DIRENT_H /* do not include SAS/C <dirent.h> */
|
||||
# define _SYS_DIR_H /* do not include SAS/C <sys/dir.h> */
|
||||
# define _COMMIFMT_H /* do not include SAS/C <sys/commifmt.h> */
|
||||
# include <dos.h>
|
||||
#endif
|
||||
#include <libraries/dos.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
struct stat {
|
||||
unsigned short st_mode;
|
||||
time_t st_ctime, st_atime, st_mtime;
|
||||
long st_size;
|
||||
long st_ino;
|
||||
long st_blocks;
|
||||
short st_attr, st_dev, st_nlink, st_uid, st_gid, st_rdev;
|
||||
};
|
||||
|
||||
#define S_IFDIR (1<<11)
|
||||
#define S_IFREG (1<<10)
|
||||
|
||||
#if 0
|
||||
/* these values here are totally random: */
|
||||
# define S_IFLNK (1<<14)
|
||||
# define S_IFSOCK (1<<13)
|
||||
# define S_IFCHR (1<<8)
|
||||
# define S_IFIFO (1<<7)
|
||||
# define S_IFMT (S_IFDIR|S_IFREG|S_IFCHR|S_IFLNK)
|
||||
#else
|
||||
# define S_IFMT (S_IFDIR|S_IFREG)
|
||||
#endif
|
||||
|
||||
#define S_IHIDDEN (1<<7)
|
||||
#define S_ISCRIPT (1<<6)
|
||||
#define S_IPURE (1<<5)
|
||||
#define S_IARCHIVE (1<<4)
|
||||
#define S_IREAD (1<<3)
|
||||
#define S_IWRITE (1<<2)
|
||||
#define S_IEXECUTE (1<<1)
|
||||
#define S_IDELETE (1<<0)
|
||||
|
||||
int stat(const char *name, struct stat *buf);
|
||||
int fstat(int handle, struct stat *buf); /* returns dummy values */
|
||||
|
||||
typedef struct dirent {
|
||||
struct dirent *d_cleanuplink,
|
||||
**d_cleanupparent;
|
||||
BPTR d_parentlock;
|
||||
struct FileInfoBlock d_fib;
|
||||
} DIR;
|
||||
#define d_name d_fib.fib_FileName
|
||||
|
||||
extern unsigned short disk_not_mounted; /* flag set by opendir() */
|
||||
|
||||
DIR *opendir(const char *);
|
||||
void closedir(DIR *);
|
||||
void close_leftover_open_dirs(void); /* call this if aborted in mid-run */
|
||||
struct dirent *readdir(DIR *);
|
||||
int umask(void);
|
||||
|
||||
#ifdef AZTEC_C
|
||||
int rmdir(const char *);
|
||||
int chmod(const char *filename, int bits);
|
||||
#endif
|
||||
|
||||
#endif /* __amiga_z_stat_h */
|
25
third_party/infozip/zip/amiga/zipup.h
vendored
Normal file
25
third_party/infozip/zip/amiga/zipup.h
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef __amiga_zipup_h
|
||||
#define __amiga_zipup_h
|
||||
|
||||
#ifndef O_RAW
|
||||
# define O_RAW 0
|
||||
#endif
|
||||
#define fhow (O_RDONLY | O_RAW)
|
||||
#define fbad (-1)
|
||||
typedef int ftype;
|
||||
#define zopen(n,p) open(n,p)
|
||||
#define zread(f,b,n) read(f,b,n)
|
||||
#define zclose(f) close(f)
|
||||
#define zerr(f) (k == (extent)(-1L))
|
||||
#define zstdin 0
|
||||
|
||||
#endif /* __amiga_zipup_h */
|
||||
|
659
third_party/infozip/zip/aosvs/aosvs.c
vendored
Normal file
659
third_party/infozip/zip/aosvs/aosvs.c
vendored
Normal file
|
@ -0,0 +1,659 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "zip.h"
|
||||
#include <paru.h> /* parameter definitions */
|
||||
#include <sys_calls.h> /* AOS/VS system call interface */
|
||||
#include <packets/filestatus.h> /* AOS/VS ?FSTAT packet defs */
|
||||
|
||||
#ifndef UTIL /* AOS/VS specific fileio code not needed for UTILs */
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END ':'
|
||||
|
||||
/*
|
||||
* could probably avoid the union -
|
||||
* all are same size & 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 struct zextrafld
|
||||
{
|
||||
char extra_header_id[2]; /* set to VS - in theory, an int */
|
||||
char extra_data_size[2]; /* size of rest, in Intel little-endian order */
|
||||
char extra_sentinel[4]; /* set to FCI w/ trailing null */
|
||||
unsigned char extra_rev; /* set to 10 for rev 1.0 */
|
||||
ZVSFSTAT_STRU fstat_packet; /* the fstat packet */
|
||||
char aclbuf[$MXACL]; /* raw ACL, or link-resolution name */
|
||||
} ZEXTRAFLD;
|
||||
|
||||
#define ZEXTRA_HEADID "VS"
|
||||
#define ZEXTRA_SENTINEL "FCI"
|
||||
#define ZEXTRA_REV (unsigned char) 10
|
||||
|
||||
local ZEXTRAFLD zzextrafld; /* buffer for extra field containing
|
||||
?FSTAT packet & ACL buffer */
|
||||
local char zlinkres[$MXPL]; /* buf for link resolution contents */
|
||||
local char znamebuf[$MXPL]; /* buf for AOS/VS filename */
|
||||
static char vsnamebuf[$MXPL];
|
||||
static char uxnamebuf[FNMAX];
|
||||
static P_FSTAT vsfstatbuf;
|
||||
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
/* Local functions */
|
||||
local char *readd OF((DIR *));
|
||||
|
||||
char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if ((s.st_mode & S_IFDIR) == 0)
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '/')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *strlower(s)
|
||||
char *s; /* string to convert */
|
||||
/* Convert all uppercase letters to lowercase in string s */
|
||||
{
|
||||
char *p; /* scans string */
|
||||
|
||||
for (p = s; *p; p++)
|
||||
if (*p >= 'A' && *p <= 'Z')
|
||||
*p += 'a' - 'A';
|
||||
return s;
|
||||
}
|
||||
|
||||
char *strupper(s)
|
||||
char *s; /* string to convert */
|
||||
/* Convert all lowercase letters to uppercase in string s */
|
||||
{
|
||||
char *p; /* scans string */
|
||||
|
||||
for (p = s; *p; p++)
|
||||
if (*p >= 'a' && *p <= 'z')
|
||||
*p -= 'a' - 'A';
|
||||
return s;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t; /* shortened name */
|
||||
int dosflag;
|
||||
|
||||
dosflag = dosify; /* default for non-DOS and non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
for (t = x; *t == '/'; t++)
|
||||
;
|
||||
|
||||
if (*t == '=') /* AOS/VS for ./ */
|
||||
t++;
|
||||
else if (*t == ':') /* AOS/VS for / */
|
||||
t++;
|
||||
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
if (*t == '^') /* AOS/VS for ../ */
|
||||
{
|
||||
if ((n = malloc(strlen(t) + 3)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, "../");
|
||||
strcpy(n + 3, t + 1);
|
||||
}
|
||||
else if (*t == '@') /* AOS/VS for :PER:, kind of like /dev/ */
|
||||
{
|
||||
if ((n = malloc(strlen(t) + 5)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, "/PER/");
|
||||
strcpy(n + 5, t + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
}
|
||||
/* now turn AOS/VS dir separators (colons) into slashes */
|
||||
for (t = n; *t != '\0'; t++)
|
||||
if (*t == ':')
|
||||
*t = '/';
|
||||
/*
|
||||
* Convert filename to uppercase (for correct matching).
|
||||
* (It may make more sense to patch the matching code, since
|
||||
* we may want those filenames in uppercase on the target system,
|
||||
* but this seems better at present. If we're converting, uppercase
|
||||
* also seems to make sense.)
|
||||
*/
|
||||
strupper(n);
|
||||
|
||||
|
||||
if (dosify)
|
||||
msname(n);
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
time_t u[2]; /* argument for utime() */
|
||||
|
||||
/* Convert DOS time to time_t format in u */
|
||||
u[0] = u[1] = dos2unixtime(d);
|
||||
utime(f, u);
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
/* convert FNMAX to malloc - 11/8/04 EG */
|
||||
char *name;
|
||||
int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL) {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '/')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
|
||||
if (strcmp(f, "-") == 0) {
|
||||
if (fstat(fileno(stdin), &s) != 0)
|
||||
error("fstat(stdin)");
|
||||
} else if (LSSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (a != NULL) {
|
||||
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
|
||||
if ((s.st_mode & S_IFDIR) != 0) {
|
||||
*a |= MSDOS_DIR_ATTR;
|
||||
}
|
||||
}
|
||||
if (n != NULL)
|
||||
*n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = s.st_ctime;
|
||||
}
|
||||
|
||||
return unix2dostime(&s.st_ctime);
|
||||
}
|
||||
|
||||
int deletedir(d)
|
||||
char *d;
|
||||
{
|
||||
return rmdir(d);
|
||||
}
|
||||
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* create extra field and change z->att if desired */
|
||||
/* NOTE: this AOS/VS version assumes the pathname in z->name is an
|
||||
* AOS/VS pathname, not a unix-style one. Since you can zip up using
|
||||
* unix-style pathnames, this may create problems occasionally.
|
||||
* We COULD add code to parse back to AOS/VS format ...
|
||||
* (This might also fail for other reasons such as access denied, but
|
||||
* that should already have occurred.)
|
||||
* We set the central-dir extra fld pointer & length here to the same data.
|
||||
*/
|
||||
{
|
||||
int aclend = 0;
|
||||
/*
|
||||
* use this to simplify because different calls depending on
|
||||
* whether links are resolved
|
||||
*/
|
||||
unsigned short errc;
|
||||
|
||||
z->ext = 0; /* init to no extra field */
|
||||
/* get the ?FSTAT info & the acl - if no errors, get memory & store.
|
||||
* (first, we have to cut off the trailing slash that was added if
|
||||
* it's a dir, since AOS/VS doesn't accept that kind of thing)
|
||||
*/
|
||||
strncpy(znamebuf, z->name, $MXPL);
|
||||
znamebuf[$MXPL-1] = '\0';
|
||||
if (znamebuf[strlen(znamebuf)-1] == '/')
|
||||
znamebuf[strlen(znamebuf)-1] = '\0';
|
||||
if (linkput)
|
||||
errc = sys_fstat(znamebuf, BIT1, &(zzextrafld.fstat_packet));
|
||||
else
|
||||
errc = sys_fstat(znamebuf, 0, &(zzextrafld.fstat_packet));
|
||||
if (errc)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"\n Warning: can't get ?FSTAT info & acl of %s - error %d\n ",
|
||||
znamebuf, errc);
|
||||
perror("sys_fstat()");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* store the ACL - or, if a link (no ACL!), store the resolution name */
|
||||
if (zzextrafld.fstat_packet.norm_fstat_packet.styp_type != $FLNK)
|
||||
{
|
||||
if ((errc = sys_gacl(znamebuf, zzextrafld.aclbuf)) != 0)
|
||||
{
|
||||
fprintf(stderr, "\n Warning: can't get acl of %s - error %d\n ",
|
||||
z->name, errc);
|
||||
perror("sys_gacl()");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* find length of ACL - ends with double-null */
|
||||
while (aclend++ < $MXACL &&
|
||||
(zzextrafld.aclbuf[aclend - 1] != '\0' ||
|
||||
zzextrafld.aclbuf[aclend] != '\0'))
|
||||
/* EMPTY LOOP */ ;
|
||||
if ((z->cextra = z->extra =
|
||||
malloc(sizeof(ZEXTRAFLD) - $MXACL + aclend + 4)) != NULL)
|
||||
{
|
||||
strncpy(zzextrafld.extra_header_id, ZEXTRA_HEADID,
|
||||
sizeof(zzextrafld.extra_header_id));
|
||||
strncpy(zzextrafld.extra_sentinel, ZEXTRA_SENTINEL,
|
||||
sizeof(zzextrafld.extra_sentinel));
|
||||
zzextrafld.extra_rev = ZEXTRA_REV; /* this is a char, no need
|
||||
to worry about byte order */
|
||||
/* set size (Intel (little-endian)) 2-byte int, which we've set
|
||||
as array to make it easier */
|
||||
errc = (unsigned short) (sizeof(ZEXTRAFLD) - $MXACL + aclend + 4 -
|
||||
sizeof(zzextrafld.extra_header_id) -
|
||||
sizeof(zzextrafld.extra_data_size));
|
||||
zzextrafld.extra_data_size[0] = errc & 0xFF; /* low-order byte */
|
||||
zzextrafld.extra_data_size[1] = errc >> 8; /* high-order byte */
|
||||
memcpy((char *) z->extra, (char *) &zzextrafld,
|
||||
sizeof(ZEXTRAFLD) - $MXACL + aclend + 4);
|
||||
z->cext = z->ext = sizeof(ZEXTRAFLD) - $MXACL + aclend + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* a link */
|
||||
{
|
||||
if ((errc = sys_glink(z->name, zzextrafld.aclbuf)) != 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"\n Warning: can't get link-resolution of %s - error %d\n ",
|
||||
z->name, errc);
|
||||
perror("sys_glink()");
|
||||
}
|
||||
else
|
||||
{
|
||||
aclend = strlen(zzextrafld.aclbuf) + 1;
|
||||
if ((z->extra = malloc(sizeof(ZEXTRAFLD) - $MXACL + aclend + 4))
|
||||
!= NULL)
|
||||
{
|
||||
strncpy(zzextrafld.extra_header_id, ZEXTRA_HEADID,
|
||||
sizeof(zzextrafld.extra_header_id));
|
||||
strncpy(zzextrafld.extra_sentinel, ZEXTRA_SENTINEL,
|
||||
sizeof(zzextrafld.extra_sentinel));
|
||||
zzextrafld.extra_rev = ZEXTRA_REV; /* this is a char, no need
|
||||
to worry about byte order */
|
||||
/* set size (Intel (little-endian)) 2-byte int, which we've set
|
||||
as array to make it easier */
|
||||
errc = (unsigned short) (sizeof(ZEXTRAFLD) - $MXACL + aclend + 4 -
|
||||
sizeof(zzextrafld.extra_header_id) -
|
||||
sizeof(zzextrafld.extra_data_size));
|
||||
zzextrafld.extra_data_size[0] = errc & 0xFF; /* low-order byte */
|
||||
zzextrafld.extra_data_size[1] = errc >> 8; /* high-order byte */
|
||||
memcpy((char *) z->extra, (char *) &zzextrafld,
|
||||
sizeof(ZEXTRAFLD) - $MXACL + aclend + 4);
|
||||
z->ext = sizeof(ZEXTRAFLD) - $MXACL + aclend + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
void version_local()
|
||||
{
|
||||
printf("Compiled with %s under %s.\n",
|
||||
"a C compiler",
|
||||
"AOS/VS"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This file defines for AOS/VS two Unix functions relating to links;
|
||||
* the calling code should have the following defines:
|
||||
*
|
||||
* #define lstat(path,buf) zvs_lstat(path,buf)
|
||||
* #define readlink(path,buf,nbytes) zvs_readlink(path,buf,nbytes)
|
||||
*
|
||||
* For these functions, I'm going to define yet 2 MORE filename buffers
|
||||
* and also insert code to change pathnames to Unix & back. This is
|
||||
* easier than changing all the other places this kind of thing happens to
|
||||
* be efficient. This is a kludge. I'm also going to put the functions
|
||||
* here for my immediate convenience rather than somewhere else for
|
||||
* someone else's.
|
||||
*
|
||||
* WARNING: the use of static buffers means that you'd better get your
|
||||
* data out of these buffers before the next call to any of these functions!
|
||||
*
|
||||
*/
|
||||
|
||||
/* =========================================================================
|
||||
* ZVS_LSTAT() - get (or simulate) stat information WITHOUT following symlinks
|
||||
* This is intended to look to the outside like the unix lstat()
|
||||
* function. We do a quick-&-dirty filename conversion.
|
||||
*
|
||||
* If the file is NOT a symbolic link, we can just do a stat() on it and
|
||||
* that should be fine. But if it IS a link, we have to set the elements
|
||||
* of the stat struct ourselves, since AOS/VS doesn't have a built-in
|
||||
* lstat() function.
|
||||
*
|
||||
* RETURNS: 0 on success, or -1 otherwise
|
||||
*
|
||||
*/
|
||||
|
||||
int zvs_lstat(char *path, struct stat *buf)
|
||||
{
|
||||
char *cp_vs = vsnamebuf;
|
||||
char *cp_ux = path;
|
||||
int mm, dd, yy;
|
||||
|
||||
/*
|
||||
* Convert the Unix pathname to an AOS/VS pathname.
|
||||
* This is quick & dirty; it won't handle (for instance) pathnames with
|
||||
* ../ in the middle of them, and may choke on other Unixisms. We hope
|
||||
* they're unlikely.
|
||||
*/
|
||||
if (!strncmp(cp_ux, "../", 3))
|
||||
{
|
||||
*cp_vs++ = '^'; /* AOS/VS for ../ */
|
||||
cp_ux += 3;
|
||||
}
|
||||
else if (!strncmp(cp_ux, "./", 2))
|
||||
{
|
||||
*cp_vs++ = '='; /* AOS/VS for ./ */
|
||||
cp_ux += 2;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (*cp_ux == '/')
|
||||
{
|
||||
*cp_vs++ = ':';
|
||||
}
|
||||
else
|
||||
{
|
||||
*cp_vs++ = (char) toupper(*cp_ux);
|
||||
}
|
||||
|
||||
} while (*cp_ux++ != '\0' && cp_vs - vsnamebuf < sizeof(vsnamebuf));
|
||||
|
||||
/* If Unix name was too long for our buffer, return an error return */
|
||||
if (cp_vs - vsnamebuf >= sizeof(vsnamebuf) && *(cp_vs - 1) != '\0')
|
||||
return (-1); /* error */
|
||||
|
||||
/* Make AOS/VS ?FSTAT call that won't follow links & see if we find
|
||||
* anything. If not, we return error.
|
||||
*/
|
||||
if (sys_fstat(vsnamebuf,
|
||||
BIT1, /* BIT1 says to not resolve links */
|
||||
&vsfstatbuf))
|
||||
return (-1); /* error */
|
||||
|
||||
/* If we DID find the file but it's not a link,
|
||||
* call stat() and return its value.
|
||||
*/
|
||||
if (vsfstatbuf.styp_type != $FLNK)
|
||||
return (stat(path, buf)); /* call with Unix pathname ... */
|
||||
|
||||
/* Otherwise, we have to kludge up values for the stat structure */
|
||||
memset((char *) buf, 0, sizeof(*buf)); /* init to nulls (0 values) */
|
||||
buf->st_mode = S_IFLNK | 0777; /* link and rwxrwxrwx */
|
||||
buf->st_uid = -1; /* this is what we get on AOS/VS
|
||||
anyway (maybe unless we set up
|
||||
a dummy password file?) */
|
||||
buf->st_nlink = 1;
|
||||
/* The DG date we've got is days since 12/31/67 and seconds/2. So we
|
||||
* need to subtract 732 days (if that's not negative), convert to seconds,
|
||||
* and add adjusted seconds.
|
||||
*/
|
||||
if (vsfstatbuf.stch.short_time[0] < 732)
|
||||
buf->st_ctime = buf->st_mtime = buf->st_atime = 0L;
|
||||
else
|
||||
{
|
||||
buf->st_ctime = buf->st_mtime = buf->st_atime =
|
||||
((long) vsfstatbuf.stch.short_time[0] - 732L) * 24L * 3600L +
|
||||
2L * (long) vsfstatbuf.stch.short_time[1];
|
||||
}
|
||||
|
||||
/* And we need to get the filename linked to and use its length as
|
||||
* the file size. We'll use the Unix pathname buffer for this - hope
|
||||
* it's big enough. (We won't overwrite anything, but we could get a
|
||||
* truncated path.) If there's an error, here's our last chance to
|
||||
* say anything.
|
||||
*/
|
||||
if ((buf->st_size = zvs_readlink(vsnamebuf, uxnamebuf, FNMAX)) < 0)
|
||||
return (-1);
|
||||
else
|
||||
return (0);
|
||||
|
||||
} /* end zvs_lstat() */
|
||||
|
||||
/* =========================================================================
|
||||
* ZVS_READLINK() - get pathname pointed to by an AOS/VS link file
|
||||
* This is intended to look to the outside like the unix readlink()
|
||||
* function. We do a quick-&-dirty filename conversion.
|
||||
*
|
||||
* RETURNS: the length of the output path (in bytes), or -1 if an error
|
||||
*
|
||||
*/
|
||||
|
||||
int zvs_readlink(char *path, char *buf, int nbytes)
|
||||
{
|
||||
char *cp_vs = vsnamebuf;
|
||||
char *cp_ux = buf;
|
||||
|
||||
/* This is called with z->name, the filename the user gave, so we'll get
|
||||
* the link-resolution name on the assumption that it's a valid AOS/VS
|
||||
* name. We're also assuming a reasonable value (> 5) for nbytes.
|
||||
*/
|
||||
if (sys_glink(path, vsnamebuf))
|
||||
return (-1); /* readlink() is supposed to return -1 on error */
|
||||
|
||||
/* Now, convert the AOS/VS pathname to a Unix pathname.
|
||||
* Note that sys_glink(), unlike readlink(), does add a null.
|
||||
*/
|
||||
if (*cp_vs == '^') /* AOS/VS for ../ */
|
||||
{
|
||||
strncpy(cp_ux, "../", 3);
|
||||
cp_ux += 3;
|
||||
cp_vs++;
|
||||
}
|
||||
else if (*cp_vs == '@') /* AOS/VS for :PER:, kind of like /dev/ */
|
||||
{
|
||||
strncpy(cp_ux, "/PER/", 5);
|
||||
cp_ux += 5;
|
||||
cp_vs++;
|
||||
}
|
||||
else if (*cp_vs == '=') /* AOS/VS for ./ */
|
||||
{
|
||||
strncpy(cp_ux, "./", 2);
|
||||
cp_ux += 2;
|
||||
cp_vs++;
|
||||
}
|
||||
while (*cp_vs != '\0' && cp_ux - buf < nbytes)
|
||||
{
|
||||
if (*cp_vs == ':')
|
||||
{
|
||||
*cp_ux++ = '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
*cp_ux++ = (char) toupper(*cp_vs);
|
||||
}
|
||||
cp_vs++;
|
||||
}
|
||||
|
||||
return (cp_ux - buf); /* # characters in Unix path (no trailing null) */
|
||||
|
||||
} /* end zvs_readlink() */
|
5
third_party/infozip/zip/aosvs/make.cli
vendored
Normal file
5
third_party/infozip/zip/aosvs/make.cli
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
push
|
||||
prompt pop
|
||||
sea :c_4.10 :c_4.10:lang_rt [!sea]
|
||||
cc%0/%/link/NOUNX AOS_VS/DEFINE NODIR/DEFINE <ZIP CRC32 CRYPT DEFLATE FILEIO GLOBALS MKTIME TREES TTYIO UTIL ZIPFILE ZIPUP AOSVS>.C
|
||||
pop
|
718
third_party/infozip/zip/api.c
vendored
Normal file
718
third_party/infozip/zip/api.c
vendored
Normal file
|
@ -0,0 +1,718 @@
|
|||
/*
|
||||
api.c - Zip 3
|
||||
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
api.c
|
||||
|
||||
This module supplies a Zip dll engine for use directly from C/C++
|
||||
programs.
|
||||
|
||||
The entry points are:
|
||||
|
||||
ZpVer *ZpVersion(void);
|
||||
int EXPENTRY ZpInit(LPZIPUSERFUNCTIONS lpZipUserFunc);
|
||||
int EXPENTRY ZpArchive(ZCL C, LPZPOPT Opts);
|
||||
|
||||
This module is currently only used by the Windows dll, and is not used at
|
||||
all by any of the other platforms, although it should be easy enough to
|
||||
implement this on most platforms.
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
#define __API_C
|
||||
|
||||
#include <malloc.h>
|
||||
#ifdef WINDLL
|
||||
# include <windows.h>
|
||||
# include "windll/windll.h"
|
||||
#endif
|
||||
|
||||
#ifdef OS2
|
||||
# define INCL_DOSMEMMGR
|
||||
# include <os2.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#include <dir.h>
|
||||
#endif
|
||||
#include <direct.h>
|
||||
#include <ctype.h>
|
||||
#include "api.h" /* this includes zip.h */
|
||||
#include "crypt.h"
|
||||
#include "revision.h"
|
||||
#ifdef USE_ZLIB
|
||||
# include "zlib.h"
|
||||
#endif
|
||||
|
||||
|
||||
DLLPRNT *lpZipPrint;
|
||||
DLLPASSWORD *lpZipPassword;
|
||||
extern DLLCOMMENT *lpComment;
|
||||
ZIPUSERFUNCTIONS ZipUserFunctions, far * lpZipUserFunctions;
|
||||
|
||||
int ZipRet;
|
||||
char szOrigDir[PATH_MAX];
|
||||
BOOL fNo_int64 = FALSE; /* flag for DLLSERVICE_NO_INT64 */
|
||||
|
||||
/* Local forward declarations */
|
||||
extern int zipmain OF((int, char **));
|
||||
int AllocMemory(unsigned int, char *, char *, BOOL);
|
||||
int ParseString(LPSTR, unsigned int);
|
||||
void FreeArgVee(void);
|
||||
|
||||
ZPOPT Options;
|
||||
char **argVee;
|
||||
unsigned int argCee;
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Local functions
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
char szRootDir[PATH_MAX], szExcludeList[PATH_MAX], szIncludeList[PATH_MAX], szTempDir[PATH_MAX];
|
||||
|
||||
int ParseString(LPSTR s, unsigned int ArgC)
|
||||
{
|
||||
unsigned int i;
|
||||
int root_flag, m, j;
|
||||
char *str1, *str2, *str3;
|
||||
size_t size;
|
||||
|
||||
i = ArgC;
|
||||
str1 = (char *) malloc(lstrlen(s)+4);
|
||||
lstrcpy(str1, s);
|
||||
lstrcat(str1, " @");
|
||||
|
||||
if ((szRootDir != NULL) && (szRootDir[0] != '\0'))
|
||||
{
|
||||
root_flag = TRUE;
|
||||
if (szRootDir[lstrlen(szRootDir)-1] != '\\')
|
||||
lstrcat(szRootDir, "\\");
|
||||
}
|
||||
else
|
||||
root_flag = FALSE;
|
||||
|
||||
str2 = strchr(str1, '\"'); /* get first occurance of double quote */
|
||||
|
||||
while ((str3 = strchr(str1, '\t')) != NULL)
|
||||
{
|
||||
str3[0] = ' '; /* Change tabs into a single space */
|
||||
}
|
||||
|
||||
/* Note that if a quoted string contains multiple adjacent spaces, they
|
||||
will not be removed, because they could well point to a valid
|
||||
folder/file name.
|
||||
*/
|
||||
while ((str2 = strchr(str1, '\"')) != NULL)
|
||||
/* Found a double quote if not NULL */
|
||||
{
|
||||
str3 = strchr(str2+1, '\"'); /* Get the second quote */
|
||||
if (str3 == NULL)
|
||||
{
|
||||
free(str1);
|
||||
return ZE_PARMS; /* Something is screwy with the
|
||||
string, bail out */
|
||||
}
|
||||
str3[0] = '\0'; /* terminate str2 with a NULL */
|
||||
|
||||
/* strip unwanted fully qualified path from entry */
|
||||
if (root_flag)
|
||||
if ((_strnicmp(szRootDir, str2+1, lstrlen(szRootDir))) == 0)
|
||||
{
|
||||
m = 0;
|
||||
str2++;
|
||||
for (j = lstrlen(szRootDir); j < lstrlen(str2); j++)
|
||||
str2[m++] = str2[j];
|
||||
str2[m] = '\0';
|
||||
str2--;
|
||||
}
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
/* argCee is incremented in AllocMemory */
|
||||
if (AllocMemory(i, str2+1, "Creating file list from string", TRUE) != ZE_OK)
|
||||
{
|
||||
free(str1);
|
||||
return ZE_MEM;
|
||||
}
|
||||
i++;
|
||||
str3+=2; /* Point past the whitespace character */
|
||||
str2[0] = '\0'; /* Terminate str1 */
|
||||
lstrcat(str1, str3);
|
||||
} /* end while */
|
||||
|
||||
/* points to first occurance of a space */
|
||||
str2 = strchr(str1, ' ');
|
||||
|
||||
/* Go through the string character by character, looking for instances
|
||||
of two spaces together. Terminate when you find the trailing @
|
||||
*/
|
||||
while ((str2[0] != '\0') && (str2[0] != '@'))
|
||||
{
|
||||
while ((str2[0] == ' ') && (str2[1] == ' '))
|
||||
{
|
||||
str3 = &str2[1];
|
||||
str2[0] = '\0';
|
||||
lstrcat(str1, str3);
|
||||
}
|
||||
str2++;
|
||||
}
|
||||
|
||||
/* Do we still have a leading space? */
|
||||
if (str1[0] == ' ')
|
||||
{
|
||||
str3 = &str1[1];
|
||||
lstrcpy(str1, str3); /* Dump the leading space */
|
||||
}
|
||||
|
||||
|
||||
/* Okay, now we have gotten rid of any tabs and replaced them with
|
||||
spaces, and have replaced multiple spaces with a single space. We
|
||||
couldn't do this before because the folder names could have actually
|
||||
contained these characters.
|
||||
*/
|
||||
|
||||
str2 = str3 = str1;
|
||||
|
||||
while ((str2[0] != '\0') && (str3[0] != '@'))
|
||||
{
|
||||
str3 = strchr(str2+1, ' ');
|
||||
str3[0] = '\0';
|
||||
/* strip unwanted fully qualified path from entry */
|
||||
if (root_flag)
|
||||
if ((_strnicmp(szRootDir, str2, lstrlen(szRootDir))) == 0)
|
||||
{
|
||||
m = 0;
|
||||
for (j = lstrlen(Options.szRootDir); j < lstrlen(str2); j++)
|
||||
str2[m++] = str2[j];
|
||||
str2[m] = '\0';
|
||||
}
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (AllocMemory(i, str2, "Creating file list from string", TRUE) != ZE_OK)
|
||||
{
|
||||
free(str1);
|
||||
return ZE_MEM;
|
||||
}
|
||||
i++;
|
||||
str3++;
|
||||
str2 = str3;
|
||||
}
|
||||
free(str1);
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
int AllocMemory(unsigned int i, char *cmd, char *str, BOOL IncrementArgCee)
|
||||
{
|
||||
if ((argVee[i] = (char *) malloc( sizeof(char) * strlen(cmd)+1 )) == NULL)
|
||||
{
|
||||
if (IncrementArgCee)
|
||||
argCee++;
|
||||
FreeArgVee();
|
||||
fprintf(stdout, "Unable to allocate memory in zip library at %s\n", str);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcpy( argVee[i], cmd );
|
||||
argCee++;
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
void FreeArgVee(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* Free the arguments in the array */
|
||||
for (i = 0; i < argCee; i++)
|
||||
{
|
||||
free (argVee[i]);
|
||||
argVee[i] = NULL;
|
||||
}
|
||||
/* Then free the array itself */
|
||||
free(argVee);
|
||||
|
||||
/* Restore the original working directory */
|
||||
chdir(szOrigDir);
|
||||
#ifdef __BORLANDC__
|
||||
setdisk(toupper(szOrigDir[0]) - 'A');
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Documented API entry points
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
int EXPENTRY ZpInit(LPZIPUSERFUNCTIONS lpZipUserFunc)
|
||||
{
|
||||
ZipUserFunctions = *lpZipUserFunc;
|
||||
lpZipUserFunctions = &ZipUserFunctions;
|
||||
|
||||
if (!lpZipUserFunctions->print ||
|
||||
!lpZipUserFunctions->comment)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int EXPENTRY ZpArchive(ZCL C, LPZPOPT Opts)
|
||||
/* Add, update, freshen, or delete zip entries in a zip file. See the
|
||||
command help in help() zip.c */
|
||||
{
|
||||
int k, j, m;
|
||||
size_t size;
|
||||
|
||||
Options = *Opts; /* Save off options, and make them available locally */
|
||||
szRootDir[0] = '\0';
|
||||
szExcludeList[0] = '\0';
|
||||
szIncludeList[0] = '\0';
|
||||
szTempDir[0] = '\0';
|
||||
if (Options.szRootDir) lstrcpy(szRootDir, Options.szRootDir);
|
||||
if (Options.szExcludeList) lstrcpy(szExcludeList, Options.szExcludeList);
|
||||
if (Options.szIncludeList) lstrcpy(szIncludeList, Options.szIncludeList);
|
||||
if (Options.szTempDir) lstrcpy(szTempDir, Options.szTempDir);
|
||||
|
||||
getcwd(szOrigDir, PATH_MAX); /* Save current drive and directory */
|
||||
|
||||
if ((szRootDir != NULL) && (szRootDir[0] != '\0'))
|
||||
{
|
||||
/* Make sure there isn't a trailing slash */
|
||||
if (szRootDir[lstrlen(szRootDir)-1] == '\\')
|
||||
szRootDir[lstrlen(szRootDir)-1] = '\0';
|
||||
|
||||
chdir(szRootDir);
|
||||
#ifdef __BORLANDC__
|
||||
setdisk(toupper(szRootDir[0]) - 'A');
|
||||
#endif
|
||||
}
|
||||
|
||||
argCee = 0;
|
||||
|
||||
/* malloc additional 40 to allow for additional command line arguments. Note
|
||||
that we are also adding in the count for the include lists as well as the
|
||||
exclude list. */
|
||||
if ((argVee = (char **)malloc((C.argc+40)*sizeof(char *))) == NULL)
|
||||
{
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if ((argVee[argCee] = (char *) malloc( sizeof(char) * strlen("wiz.exe")+1 )) == NULL)
|
||||
{
|
||||
free(argVee);
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcpy( argVee[argCee], "wiz.exe" );
|
||||
argCee++;
|
||||
|
||||
|
||||
/* Set compression level efficacy -0...-9 */
|
||||
if (AllocMemory(argCee, "-0", "Compression", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
|
||||
/* Check to see if the compression level is set to a valid value. If
|
||||
not, then set it to the default.
|
||||
*/
|
||||
if ((Options.fLevel < '0') || (Options.fLevel > '9'))
|
||||
{
|
||||
Options.fLevel = '6';
|
||||
if (!Options.fDeleteEntries)
|
||||
fprintf(stdout, "Compression level set to invalid value. Setting to default\n");
|
||||
}
|
||||
|
||||
argVee[argCee-1][1] = Options.fLevel;
|
||||
|
||||
if (Options.fOffsets) /* Update offsets for SFX prefix */
|
||||
{
|
||||
if (AllocMemory(argCee, "-A", "Offsets", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fDeleteEntries) /* Delete files from zip file -d */
|
||||
{
|
||||
if (AllocMemory(argCee, "-d", "Delete", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fNoDirEntries) /* Do not add directory entries -D */
|
||||
{
|
||||
if (AllocMemory(argCee, "-D", "No Dir Entries", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fFreshen) /* Freshen zip file--overwrite only -f */
|
||||
{
|
||||
if (AllocMemory(argCee, "-f", "Freshen", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fRepair) /* Fix archive -F or -FF */
|
||||
{
|
||||
if (Options.fRepair == 1)
|
||||
{
|
||||
if (AllocMemory(argCee, "-F", "Repair", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AllocMemory(argCee, "-FF", "Repair", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
}
|
||||
if (Options.fGrow) /* Allow appending to a zip file -g */
|
||||
{
|
||||
if (AllocMemory(argCee, "-g", "Appending", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fJunkDir) /* Junk directory names -j */
|
||||
{
|
||||
if (AllocMemory(argCee, "-j", "Junk Dir Names", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fEncrypt) /* encrypt -e */
|
||||
{
|
||||
if (AllocMemory(argCee, "-e", "Encrypt", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fJunkSFX) /* Junk sfx prefix */
|
||||
{
|
||||
if (AllocMemory(argCee, "-J", "Junk SFX", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (Options.fForce) /* Make entries using DOS names (k for Katz) -k */
|
||||
{
|
||||
if (AllocMemory(argCee, "-k", "Force DOS", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (Options.fLF_CRLF) /* Translate LF_CRLF -l */
|
||||
{
|
||||
if (AllocMemory(argCee, "-l", "LF-CRLF", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fCRLF_LF) /* Translate CR/LF to LF -ll */
|
||||
{
|
||||
if (AllocMemory(argCee, "-ll", "CRLF-LF", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fMove) /* Delete files added to or updated in zip file -m */
|
||||
{
|
||||
if (AllocMemory(argCee, "-m", "Move", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (Options.fLatestTime) /* Set zip file time to time of latest file in it -o */
|
||||
{
|
||||
if (AllocMemory(argCee, "-o", "Time", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (Options.fComment) /* Add archive comment "-z" */
|
||||
{
|
||||
if (AllocMemory(argCee, "-z", "Comment", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (Options.fQuiet) /* quiet operation -q */
|
||||
{
|
||||
if (AllocMemory(argCee, "-q", "Quiet", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fRecurse == 1) /* recurse into subdirectories -r */
|
||||
{
|
||||
if (AllocMemory(argCee, "-r", "Recurse -r", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
else if (Options.fRecurse == 2) /* recurse into subdirectories -R */
|
||||
{
|
||||
if (AllocMemory(argCee, "-R", "Recurse -R", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fSystem) /* include system and hidden files -S */
|
||||
{
|
||||
if (AllocMemory(argCee, "-S", "System", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fExcludeDate) /* Exclude files newer than specified date -tt */
|
||||
{
|
||||
if ((Options.Date != NULL) && (Options.Date[0] != '\0'))
|
||||
{
|
||||
if (AllocMemory(argCee, "-tt", "Date", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if (AllocMemory(argCee, Options.Date, "Date", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.fIncludeDate) /* include files newer than specified date -t */
|
||||
{
|
||||
if ((Options.Date != NULL) && (Options.Date[0] != '\0'))
|
||||
{
|
||||
if (AllocMemory(argCee, "-t", "Date", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if (AllocMemory(argCee, Options.Date, "Date", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.fUpdate) /* Update zip file--overwrite only if newer -u */
|
||||
{
|
||||
if (AllocMemory(argCee, "-u", "Update", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fVerbose) /* Mention oddities in zip file structure -v */
|
||||
{
|
||||
if (AllocMemory(argCee, "-v", "Verbose", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.fVolume) /* Include volume label -$ */
|
||||
{
|
||||
if (AllocMemory(argCee, "-$", "Volume", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.szSplitSize != NULL) /* Turn on archive splitting */
|
||||
{
|
||||
if (AllocMemory(argCee, "-s", "Splitting", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if (AllocMemory(argCee, Options.szSplitSize, "Split size", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (lpZipUserFunctions->split != NULL) /* Turn on archive split destinations select */
|
||||
{
|
||||
if (AllocMemory(argCee, "-sp", "Split Pause Select Destination", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
#ifdef WIN32
|
||||
if (Options.fPrivilege) /* Use privileges -! */
|
||||
{
|
||||
if (AllocMemory(argCee, "-!", "Privileges", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
#endif
|
||||
if (Options.fExtra) /* Exclude extra attributes -X */
|
||||
{
|
||||
if (AllocMemory(argCee, "-X", "Extra", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.IncludeList != NULL) /* Include file list -i */
|
||||
{
|
||||
if (AllocMemory(argCee, "-i", "Include file list", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
k = 0;
|
||||
if (Options.IncludeListCount > 0)
|
||||
while ((Options.IncludeList[k] != NULL) && (Options.IncludeListCount != k+1))
|
||||
{
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (AllocMemory(argCee, Options.IncludeList[k], "Include file list array", TRUE) != ZE_OK)
|
||||
{
|
||||
return ZE_MEM;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
else
|
||||
while (Options.IncludeList[k] != NULL)
|
||||
{
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
FreeArgVee();
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (AllocMemory(argCee, Options.IncludeList[k], "Include file list array", TRUE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
k++;
|
||||
}
|
||||
|
||||
if (AllocMemory(argCee, "@", "End of Include List", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (Options.ExcludeList != NULL) /* Exclude file list -x */
|
||||
{
|
||||
if (AllocMemory(argCee, "-x", "Exclude file list", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
k = 0;
|
||||
if (Options.ExcludeListCount > 0)
|
||||
while ((Options.ExcludeList[k] != NULL) && (Options.ExcludeListCount != k+1))
|
||||
{
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (AllocMemory(argCee, Options.ExcludeList[k], "Exclude file list array", TRUE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
k++;
|
||||
}
|
||||
else
|
||||
while (Options.ExcludeList[k] != NULL)
|
||||
{
|
||||
size = _msize(argVee);
|
||||
if ((argVee = (char **)realloc(argVee, size + sizeof(char *))) == NULL)
|
||||
{
|
||||
FreeArgVee();
|
||||
fprintf(stdout, "Unable to allocate memory in zip dll\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (AllocMemory(argCee, Options.ExcludeList[k], "Exclude file list array", TRUE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
k++;
|
||||
}
|
||||
if (AllocMemory(argCee, "@", "End of Exclude List", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (szIncludeList != NULL && szIncludeList[0] != '\0') /* Include file list -i */
|
||||
{
|
||||
if (AllocMemory(argCee, "-i", "Include file list", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if ((k = ParseString(szIncludeList, argCee)) != ZE_OK)
|
||||
return k; /* Something was screwy with the parsed string
|
||||
bail out */
|
||||
if (AllocMemory(argCee, "@", "End of Include List", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
if (szExcludeList != NULL && szExcludeList[0] != '\0') /* Exclude file list -x */
|
||||
{
|
||||
if (AllocMemory(argCee, "-x", "Exclude file list", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
|
||||
if ((k = ParseString(szExcludeList, argCee)) != ZE_OK)
|
||||
return k; /* Something was screwy with the parsed string
|
||||
bail out */
|
||||
|
||||
if (AllocMemory(argCee, "@", "End of Exclude List", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if ((szTempDir != NULL) && (szTempDir[0] != '\0')
|
||||
&& Options.fTemp) /* Use temporary directory -b */
|
||||
{
|
||||
if (AllocMemory(argCee, "-b", "Temp dir switch command", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if (AllocMemory(argCee, szTempDir, "Temporary directory", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (AllocMemory(argCee, C.lpszZipFN, "Zip file name", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
|
||||
if ((szRootDir != NULL) && (szRootDir[0] != '\0'))
|
||||
{
|
||||
if (szRootDir[lstrlen(szRootDir)-1] != '\\')
|
||||
lstrcat(szRootDir, "\\"); /* append trailing \\ */
|
||||
if (C.FNV != NULL)
|
||||
{
|
||||
for (k = 0; k < C.argc; k++)
|
||||
{
|
||||
if (AllocMemory(argCee, C.FNV[k], "Making argv", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
if ((_strnicmp(szRootDir, C.FNV[k], lstrlen(szRootDir))) == 0)
|
||||
{
|
||||
m = 0;
|
||||
for (j = lstrlen(szRootDir); j < lstrlen(C.FNV[k]); j++)
|
||||
argVee[argCee-1][m++] = C.FNV[k][j];
|
||||
argVee[argCee-1][m] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (C.FNV != NULL)
|
||||
for (k = 0; k < C.argc; k++)
|
||||
{
|
||||
if (AllocMemory(argCee, C.FNV[k], "Making argv", FALSE) != ZE_OK)
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
if (C.lpszAltFNL != NULL)
|
||||
{
|
||||
if ((k = ParseString(C.lpszAltFNL, argCee)) != ZE_OK)
|
||||
return k; /* Something was screwy with the parsed string
|
||||
bail out
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
argVee[argCee] = NULL;
|
||||
|
||||
ZipRet = zipmain(argCee, argVee);
|
||||
|
||||
/* Free the arguments in the array. Note this also restores the
|
||||
current directory
|
||||
*/
|
||||
FreeArgVee();
|
||||
|
||||
return ZipRet;
|
||||
}
|
||||
|
||||
#if CRYPT
|
||||
int encr_passwd(int modeflag, char *pwbuf, int size, const char *zfn)
|
||||
{
|
||||
return (*lpZipUserFunctions->password)(pwbuf, size, ((modeflag == ZP_PW_VERIFY) ?
|
||||
"Verify password: " : "Enter password: "),
|
||||
(char *)zfn);
|
||||
}
|
||||
#endif /* CRYPT */
|
||||
|
||||
void EXPENTRY ZpVersion(ZpVer far * p) /* should be pointer to const struct */
|
||||
{
|
||||
p->structlen = ZPVER_LEN;
|
||||
|
||||
#ifdef BETA
|
||||
p->flag = 1;
|
||||
#else
|
||||
p->flag = 0;
|
||||
#endif
|
||||
#ifdef CRYPT
|
||||
p->fEncryption = TRUE;
|
||||
#else
|
||||
p->fEncryption = FALSE;
|
||||
#endif
|
||||
lstrcpy(p->betalevel, Z_BETALEVEL);
|
||||
lstrcpy(p->date, REVDATE);
|
||||
|
||||
#ifdef ZLIB_VERSION
|
||||
lstrcpy(p->zlib_version, ZLIB_VERSION);
|
||||
p->flag |= 2;
|
||||
#else
|
||||
p->zlib_version[0] = '\0';
|
||||
#endif
|
||||
|
||||
#ifdef ZIP64_SUPPORT
|
||||
p->flag |= 4; /* Flag that ZIP64 was compiled in. */
|
||||
#endif
|
||||
|
||||
p->zip.major = Z_MAJORVER;
|
||||
p->zip.minor = Z_MINORVER;
|
||||
p->zip.patchlevel = Z_PATCHLEVEL;
|
||||
|
||||
#ifdef OS2
|
||||
p->os2dll.major = D2_MAJORVER;
|
||||
p->os2dll.minor = D2_MINORVER;
|
||||
p->os2dll.patchlevel = D2_PATCHLEVEL;
|
||||
#endif
|
||||
#ifdef WINDLL
|
||||
p->windll.major = DW_MAJORVER;
|
||||
p->windll.minor = DW_MINORVER;
|
||||
p->windll.patchlevel = DW_PATCHLEVEL;
|
||||
#endif
|
||||
}
|
184
third_party/infozip/zip/api.h
vendored
Normal file
184
third_party/infozip/zip/api.h
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
api.h - Zip 3
|
||||
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* Only the Windows DLL is currently supported */
|
||||
#ifndef _ZIPAPI_H
|
||||
#define _ZIPAPI_H
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef PATH_MAX
|
||||
# define PATH_MAX 260
|
||||
# endif
|
||||
#else
|
||||
# ifndef PATH_MAX
|
||||
# define PATH_MAX 128
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDLL) || defined(API)
|
||||
#include <windows.h>
|
||||
/* Porting definations between Win 3.1x and Win32 */
|
||||
#ifdef WIN32
|
||||
# define far
|
||||
# define _far
|
||||
# define __far
|
||||
# define near
|
||||
# define _near
|
||||
# define __near
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
Prototypes for public Zip API (DLL) functions.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#define ZPVER_LEN sizeof(ZpVer)
|
||||
/* These defines are set to zero for now, until OS/2 comes out
|
||||
with a dll.
|
||||
*/
|
||||
#define D2_MAJORVER 0
|
||||
#define D2_MINORVER 0
|
||||
#define D2_PATCHLEVEL 0
|
||||
|
||||
/* intended to be a private struct: */
|
||||
typedef struct _zip_ver {
|
||||
uch major; /* e.g., integer 5 */
|
||||
uch minor; /* e.g., 2 */
|
||||
uch patchlevel; /* e.g., 0 */
|
||||
uch not_used;
|
||||
} _zip_version_type;
|
||||
|
||||
typedef struct _ZpVer {
|
||||
ulg structlen; /* length of the struct being passed */
|
||||
ulg flag; /* bit 0: is_beta bit 1: uses_zlib */
|
||||
char betalevel[10]; /* e.g., "g BETA" or "" */
|
||||
char date[20]; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
|
||||
char zlib_version[10]; /* e.g., "0.95" or NULL */
|
||||
BOOL fEncryption; /* TRUE if encryption enabled, FALSE otherwise */
|
||||
_zip_version_type zip;
|
||||
_zip_version_type os2dll;
|
||||
_zip_version_type windll;
|
||||
} ZpVer;
|
||||
|
||||
# ifndef EXPENTRY
|
||||
# define EXPENTRY WINAPI
|
||||
# endif
|
||||
|
||||
#ifndef DEFINED_ONCE
|
||||
#define DEFINED_ONCE
|
||||
typedef int (WINAPI DLLPRNT) (LPSTR, unsigned long);
|
||||
typedef int (WINAPI DLLPASSWORD) (LPSTR, int, LPCSTR, LPCSTR);
|
||||
#endif
|
||||
#ifdef ZIP64_SUPPORT
|
||||
typedef int (WINAPI DLLSERVICE) (LPCSTR, unsigned __int64);
|
||||
typedef int (WINAPI DLLSERVICE_NO_INT64) (LPCSTR, unsigned long, unsigned long);
|
||||
#else
|
||||
typedef int (WINAPI DLLSERVICE) (LPCSTR, unsigned long);
|
||||
#endif
|
||||
typedef int (WINAPI DLLSPLIT) (LPSTR);
|
||||
typedef int (WINAPI DLLCOMMENT)(LPSTR);
|
||||
|
||||
/* Structures */
|
||||
|
||||
typedef struct { /* zip options */
|
||||
LPSTR Date; /* Date to include after */
|
||||
LPSTR szRootDir; /* Directory to use as base for zipping */
|
||||
LPSTR szTempDir; /* Temporary directory used during zipping */
|
||||
BOOL fTemp; /* Use temporary directory '-b' during zipping */
|
||||
BOOL fSuffix; /* include suffixes (not implemented) */
|
||||
BOOL fEncrypt; /* encrypt files */
|
||||
BOOL fSystem; /* include system and hidden files */
|
||||
BOOL fVolume; /* Include volume label */
|
||||
BOOL fExtra; /* Exclude extra attributes */
|
||||
BOOL fNoDirEntries; /* Do not add directory entries */
|
||||
BOOL fExcludeDate; /* Exclude files newer than specified date */
|
||||
BOOL fIncludeDate; /* Include only files newer than specified date */
|
||||
BOOL fVerbose; /* Mention oddities in zip file structure */
|
||||
BOOL fQuiet; /* Quiet operation */
|
||||
BOOL fCRLF_LF; /* Translate CR/LF to LF */
|
||||
BOOL fLF_CRLF; /* Translate LF to CR/LF */
|
||||
BOOL fJunkDir; /* Junk directory names */
|
||||
BOOL fGrow; /* Allow appending to a zip file */
|
||||
BOOL fForce; /* Make entries using DOS names (k for Katz) */
|
||||
BOOL fMove; /* Delete files added or updated in zip file */
|
||||
BOOL fDeleteEntries; /* Delete files from zip file */
|
||||
BOOL fUpdate; /* Update zip file--overwrite only if newer */
|
||||
BOOL fFreshen; /* Freshen zip file--overwrite only */
|
||||
BOOL fJunkSFX; /* Junk SFX prefix */
|
||||
BOOL fLatestTime; /* Set zip file time to time of latest file in it */
|
||||
BOOL fComment; /* Put comment in zip file */
|
||||
BOOL fOffsets; /* Update archive offsets for SFX files */
|
||||
BOOL fPrivilege; /* Use privileges (WIN32 only) */
|
||||
BOOL fEncryption; /* TRUE if encryption supported, else FALSE.
|
||||
this is a read only flag */
|
||||
LPSTR szSplitSize; /* This string contains the size that you want to
|
||||
split the archive into. i.e. 100 for 100 bytes,
|
||||
2K for 2 k bytes, where K is 1024, m for meg
|
||||
and g for gig. If this string is not NULL it
|
||||
will automatically be assumed that you wish to
|
||||
split an archive. */
|
||||
LPSTR szIncludeList; /* Pointer to include file list string (for VB) */
|
||||
long IncludeListCount; /* Count of file names in the include list array */
|
||||
char **IncludeList; /* Pointer to include file list array. Note that the last
|
||||
entry in the array must be NULL */
|
||||
LPSTR szExcludeList; /* Pointer to exclude file list (for VB) */
|
||||
long ExcludeListCount; /* Count of file names in the include list array */
|
||||
char **ExcludeList; /* Pointer to exclude file list array. Note that the last
|
||||
entry in the array must be NULL */
|
||||
int fRecurse; /* Recurse into subdirectories. 1 => -r, 2 => -R */
|
||||
int fRepair; /* Repair archive. 1 => -F, 2 => -FF */
|
||||
char fLevel; /* Compression level (0 - 9) */
|
||||
} ZPOPT, _far *LPZPOPT;
|
||||
|
||||
typedef struct {
|
||||
int argc; /* Count of files to zip */
|
||||
LPSTR lpszZipFN; /* name of archive to create/update */
|
||||
char **FNV; /* array of file names to zip up */
|
||||
LPSTR lpszAltFNL; /* pointer to a string containing a list of file
|
||||
names to zip up, separated by whitespace. Intended
|
||||
for use only by VB users, all others should set this
|
||||
to NULL. */
|
||||
} ZCL, _far *LPZCL;
|
||||
|
||||
typedef struct {
|
||||
DLLPRNT *print;
|
||||
DLLCOMMENT *comment;
|
||||
DLLPASSWORD *password;
|
||||
DLLSPLIT *split; /* This MUST be set to NULL unless you want to be queried
|
||||
for a destination for each split archive. */
|
||||
#ifdef ZIP64_SUPPORT
|
||||
DLLSERVICE *ServiceApplication64;
|
||||
DLLSERVICE_NO_INT64 *ServiceApplication64_No_Int64;
|
||||
#else
|
||||
DLLSERVICE *ServiceApplication;
|
||||
#endif
|
||||
} ZIPUSERFUNCTIONS, far * LPZIPUSERFUNCTIONS;
|
||||
|
||||
extern LPZIPUSERFUNCTIONS lpZipUserFunctions;
|
||||
|
||||
void EXPENTRY ZpVersion(ZpVer far *);
|
||||
int EXPENTRY ZpInit(LPZIPUSERFUNCTIONS lpZipUserFunc);
|
||||
int EXPENTRY ZpArchive(ZCL C, LPZPOPT Opts);
|
||||
|
||||
#if defined(ZIPLIB) || defined(COM_OBJECT)
|
||||
# define ydays zp_ydays
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Functions not yet supported */
|
||||
#if 0
|
||||
int EXPENTRY ZpMain (int argc, char **argv);
|
||||
int EXPENTRY ZpAltMain (int argc, char **argv, ZpInit *init);
|
||||
#endif
|
||||
#endif /* WINDLL? || API? */
|
||||
|
||||
#endif /* _ZIPAPI_H */
|
111
third_party/infozip/zip/atari/Makefile
vendored
Normal file
111
third_party/infozip/zip/atari/Makefile
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
# Makefile for Zip, ZipNote, ZipCloak and ZipSplit
|
||||
|
||||
MAKE = make
|
||||
SHELL = /bin/sh
|
||||
|
||||
# (to use the Gnu compiler, change cc to gcc in CC and BIND)
|
||||
CC = cc
|
||||
BIND = $(CC)
|
||||
AS = $(CC) -c
|
||||
E =
|
||||
CPP = /lib/cpp
|
||||
|
||||
# probably can change this to 'install' if you have it
|
||||
INSTALL = cp
|
||||
|
||||
# target directories - where to install executables and man pages to
|
||||
BINDIR = /usr/local/bin
|
||||
manext=1
|
||||
MANDIR = /usr/local/man/man$(manext)
|
||||
|
||||
# flags
|
||||
# CFLAGS flags for C compile
|
||||
# LFLAGS1 flags after output file spec, before obj file list
|
||||
# LFLAGS2 flags after obj file list (libraries, etc)
|
||||
CFLAGS = -O
|
||||
LFLAGS1 =
|
||||
LFLAGS2 = -s
|
||||
|
||||
# object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o crc32.o globals.o \
|
||||
crypt.o ttyio.o atari.o
|
||||
|
||||
OBJI = deflate.o trees.o
|
||||
OBJA =
|
||||
OBJU = zipfile_.o fileio_.o util_.o globals.o atari_.o
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
ZIP_H = zip.h ziperr.h tailor.h atari/osdep.h
|
||||
|
||||
# suffix rules
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: _.o .o .c .doc .1
|
||||
.c_.o:
|
||||
rm -f $*_.c; ln $< $*_.c
|
||||
$(CC) $(CFLAGS) -DUTIL -c $*_.c
|
||||
rm -f $*_.c
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
.1.doc:
|
||||
nroff -man $< | col -b | uniq > $@
|
||||
|
||||
# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
zipup.o: atari/zipup.h
|
||||
|
||||
match.o: match.s
|
||||
$(CPP) match.s > _match.s
|
||||
$(AS) _match.s
|
||||
mv _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
ZIPS = zip$E zipnote$E zipsplit$E zipcloak$E
|
||||
|
||||
zips: $(ZIPS)
|
||||
zipsman: $(ZIPS) $(ZIPMANUAL)
|
||||
|
||||
zip$E: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
zipnote$E: $(OBJN)
|
||||
$(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
zipcloak$E: $(OBJC)
|
||||
$(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
zipsplit$E: $(OBJS)
|
||||
$(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
$(ZIPMANUAL): man/zip.1
|
||||
nroff -man man/zip.1 | col -b | uniq > $(ZIPMANUAL)
|
||||
|
||||
# install
|
||||
install: $(ZIPS)
|
||||
$(INSTALL) $(ZIPS) $(BINDIR)
|
||||
$(INSTALL) man/zip.1 $(MANDIR)/zip.$(manext)
|
||||
|
||||
uninstall:
|
||||
-cd $(BINDIR); rm -f $(ZIPS)
|
||||
-cd $(MANDIR); rm -f zip.$(manext)
|
||||
|
||||
dist: $(ZIPMANUAL)
|
||||
zip -u9T zip`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' \
|
||||
-e s/[.]//g -e q revision.h` \
|
||||
`awk '/^Makefile/,/vms_zip.rnh/ {print $$1}' < contents`
|
||||
|
||||
# ATARI version (gcc 2.5.8 and Mintlibs PL46)
|
||||
atari:
|
||||
$(MAKE) zips CFLAGS="-O -DATARI" OBJA=atari/atari.o CC=gcc E=.ttp
|
||||
|
||||
# clean up after making stuff and installing it
|
||||
clean:
|
||||
rm -f *.o $(ZIPS) flags
|
5
third_party/infozip/zip/atari/README
vendored
Normal file
5
third_party/infozip/zip/atari/README
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
From: harry@hal.westfalen.de (Harald Denker)
|
||||
|
||||
The old zip ATARI port is based on TurboC which is no more
|
||||
supported (for more than 3 years). I used the GNU gcc 2.5.8 and
|
||||
MiNTlibs PL46.
|
681
third_party/infozip/zip/atari/atari.c
vendored
Normal file
681
third_party/infozip/zip/atari/atari.c
vendored
Normal file
|
@ -0,0 +1,681 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#include "zip.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <mintbind.h>
|
||||
#include <osbind.h>
|
||||
#include <ostruct.h>
|
||||
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
extern char *label; /* defined in fileio.c */
|
||||
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
|
||||
local char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
local char *getVolumeLabel(drive, vtime, vmode, utim)
|
||||
int drive; /* drive name: 'A' .. 'Z' or '\0' for current drive */
|
||||
ulg *vtime; /* volume label creation time (DOS format) */
|
||||
ulg *vmode; /* volume label file mode */
|
||||
time_t utim;/* volume label creation time (UNIX format) */
|
||||
|
||||
/* If a volume label exists for the given drive, return its name and
|
||||
set its time and mode. The returned name must be static data. */
|
||||
{
|
||||
static char vol[14];
|
||||
_DTA *dtaptr;
|
||||
|
||||
if (drive) {
|
||||
vol[0] = (char)drive;
|
||||
strcpy(vol+1, ":/");
|
||||
} else {
|
||||
strcpy(vol, "/");
|
||||
}
|
||||
strcat(vol, "*.*");
|
||||
if (Fsfirst(vol, FA_LABEL) == 0) {
|
||||
dtaptr = Fgetdta();
|
||||
strncpy(vol, dtaptr->dta_name, sizeof(vol)-1);
|
||||
*vtime = ((ulg)dtaptr->dta_date << 16) |
|
||||
((ulg)dtaptr->dta_time & 0xffff);
|
||||
*vmode = (ulg)dtaptr->dta_attribute;
|
||||
return vol;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char GetFileMode(char *name)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
sb.st_attr = 0;
|
||||
Fxattr(linkput ? 1 : 0, name, &sb);
|
||||
if (errno == EINVAL) {
|
||||
_DTA *dtaptr, *old;
|
||||
old = Fgetdta();
|
||||
Fsfirst(name, FA_RDONLY+FA_HIDDEN+FA_SYSTEM+FA_DIR);
|
||||
dtaptr = Fgetdta();
|
||||
sb.st_attr = dtaptr->dta_attribute;
|
||||
Fsetdta(old);
|
||||
}
|
||||
return sb.st_attr & 0x3f;
|
||||
}
|
||||
|
||||
|
||||
int wild2(w)
|
||||
char *w; /* path/pattern to match */
|
||||
/* If not in exclude mode, expand the pattern based on the contents of the
|
||||
file system. Return an error code in the ZE_ class. */
|
||||
{
|
||||
DIR *d; /* stream for reading directory */
|
||||
char *e; /* name found in directory */
|
||||
int r; /* temporary variable */
|
||||
char *n; /* constructed name from directory */
|
||||
int f; /* true if there was a match */
|
||||
char *a; /* alloc'ed space for name */
|
||||
char *p; /* path */
|
||||
char *q; /* name */
|
||||
char v[5]; /* space for device current directory */
|
||||
|
||||
if (volume_label == 1) {
|
||||
volume_label = 2;
|
||||
label = getVolumeLabel(w[1] == ':' ? to_up(w[0]) : '\0',
|
||||
&label_time, &label_mode, &label_utim);
|
||||
if (label != NULL) {
|
||||
newname(label, 0, 0);
|
||||
}
|
||||
if (w[1] == ':' && w[2] == '\0') return ZE_OK;
|
||||
/* "zip -$ foo a:" can be used to force drive name */
|
||||
}
|
||||
|
||||
/* special handling of stdin request */
|
||||
if (strcmp(w, "-") == 0) /* if compressing stdin */
|
||||
return newname(w, 0, 0);
|
||||
|
||||
/* Allocate and copy pattern */
|
||||
if ((p = a = malloc(strlen(w) + 1)) == NULL)
|
||||
return ZE_MEM;
|
||||
strcpy(p, w);
|
||||
|
||||
/* Normalize path delimiter as '/'. */
|
||||
for (q = p; *q; q++) /* use / consistently */
|
||||
if (*q == '\\')
|
||||
*q = '/';
|
||||
|
||||
/* Only name can have special matching characters */
|
||||
if ((q = isshexp(p)) != NULL &&
|
||||
(strrchr(q, '/') != NULL || strrchr(q, ':') != NULL))
|
||||
{
|
||||
free((zvoid *)a);
|
||||
return ZE_PARMS;
|
||||
}
|
||||
|
||||
/* Separate path and name into p and q */
|
||||
if ((q = strrchr(p, '/')) != NULL && (q == p || q[-1] != ':'))
|
||||
{
|
||||
*q++ = '\0'; /* path/name -> path, name */
|
||||
if (*p == '\0') /* path is just / */
|
||||
p = strcpy(v, "/.");
|
||||
}
|
||||
else if ((q = strrchr(p, ':')) != NULL)
|
||||
{ /* has device and no or root path */
|
||||
*q++ = '\0';
|
||||
p = strcat(strcpy(v, p), ":"); /* copy device as path */
|
||||
if (*q == '/') /* -> device:/., name */
|
||||
{
|
||||
strcat(p, "/");
|
||||
q++;
|
||||
}
|
||||
strcat(p, ".");
|
||||
}
|
||||
else if (recurse && (strcmp(p, ".") == 0 || strcmp(p, "..") == 0))
|
||||
{ /* current or parent directory */
|
||||
/* I can't understand Mark's code so I am adding a hack here to get
|
||||
* "zip -r foo ." to work. Allow the dubious "zip -r foo .." but
|
||||
* reject "zip -rm foo ..".
|
||||
*/
|
||||
if (dispose && strcmp(p, "..") == 0)
|
||||
ziperr(ZE_PARMS, "cannot remove parent directory");
|
||||
q = "*.*";
|
||||
}
|
||||
else /* no path or device */
|
||||
{
|
||||
q = p;
|
||||
p = strcpy(v, ".");
|
||||
}
|
||||
if (recurse && *q == '\0') {
|
||||
q = "*.*";
|
||||
}
|
||||
/* Search that level for matching names */
|
||||
if ((d = opendir(p)) == NULL)
|
||||
{
|
||||
free((zvoid *)a);
|
||||
return ZE_MISS;
|
||||
}
|
||||
if ((r = strlen(p)) > 1 &&
|
||||
(strcmp(p + r - 2, ":.") == 0 || strcmp(p + r - 2, "/.") == 0))
|
||||
*(p + r - 1) = '\0';
|
||||
f = 0;
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, "..") && MATCH(q, e, 0))
|
||||
{
|
||||
f = 1;
|
||||
if (strcmp(p, ".") == 0) { /* path is . */
|
||||
r = procname(e, 0); /* name is name */
|
||||
if (r) {
|
||||
f = 0;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if ((n = malloc(strlen(p) + strlen(e) + 2)) == NULL)
|
||||
{
|
||||
free((zvoid *)a);
|
||||
closedir(d);
|
||||
return ZE_MEM;
|
||||
}
|
||||
n = strcpy(n, p);
|
||||
if (n[r = strlen(n) - 1] != '/' && n[r] != ':')
|
||||
strcat(n, "/");
|
||||
r = procname(strcat(n, e), 0); /* name is path/name */
|
||||
free((zvoid *)n);
|
||||
if (r) {
|
||||
f = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
|
||||
/* Done */
|
||||
free((zvoid *)a);
|
||||
return f ? ZE_OK : ZE_MISS;
|
||||
}
|
||||
|
||||
|
||||
#include <regexp.h>
|
||||
#include <osbind.h>
|
||||
|
||||
void regerror( char ZCONST *msg ) {
|
||||
perror( msg );
|
||||
}
|
||||
|
||||
static int ret;
|
||||
static regexp *regptr;
|
||||
static short is_w, ind_w;
|
||||
static char fullpath[FILENAME_MAX], file_arg[FILENAME_MAX];
|
||||
|
||||
#define FTW_F 0
|
||||
#define FTW_D 1
|
||||
#define FTW_DNR 2
|
||||
#define FTW_NS 3
|
||||
|
||||
static int ftwfunc( struct stat *stats, int ftw_status )
|
||||
{
|
||||
char *path = &fullpath[0];
|
||||
|
||||
if (strncmp(path, "./", 2) == 0) path += 2;
|
||||
switch (ftw_status) {
|
||||
case FTW_NS:
|
||||
zipwarn("can't stat file: ", path);
|
||||
ret = ZE_MISS;
|
||||
return 0;
|
||||
case FTW_F:
|
||||
if (!is_w || regexec(regptr, path, 1)) {
|
||||
#if 0
|
||||
char fn[FILENAME_MAX];
|
||||
int k;
|
||||
if (S_ISLNK(stats->st_mode) &&
|
||||
(k = readlink(path, fn, FILENAME_MAX)) > 0) {
|
||||
int l = strlen(path);
|
||||
fn[k] = '\0';
|
||||
strcat(strcat(path, " -> "), fn);
|
||||
ret = newname(path, 0, 0); /* procname(path, 0); */
|
||||
path[l] = '\0';
|
||||
} else
|
||||
#endif
|
||||
ret = newname(path, 0, 0); /* procname(path, 0); */
|
||||
}
|
||||
return 0;
|
||||
case FTW_DNR:
|
||||
zipwarn("can't open directory: ", path);
|
||||
ret = ZE_MISS;
|
||||
return 0;
|
||||
case FTW_D:
|
||||
if (strcmp(path, ".") == 0) return 0;
|
||||
if (is_w && ind_w > 0 && strncmp(path, file_arg, ind_w) != 0)
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int myftw( int depth )
|
||||
{
|
||||
register DIR *dirp;
|
||||
struct dirent *entp;
|
||||
struct stat stats;
|
||||
register char *p,*q;
|
||||
register long i;
|
||||
|
||||
if (LSSTAT(fullpath, &stats) < 0)
|
||||
return ftwfunc(&stats, FTW_NS);
|
||||
|
||||
if (!S_ISDIR(stats.st_mode))
|
||||
return ftwfunc(&stats, FTW_F);
|
||||
|
||||
if ((dirp = opendir(fullpath)) == NULL)
|
||||
return ftwfunc(&stats, FTW_DNR);
|
||||
|
||||
if (i = ftwfunc(&stats, FTW_D)) {
|
||||
closedir(dirp);
|
||||
return (i == 4 ? 0 : (int)i);
|
||||
}
|
||||
i = strlen(fullpath);
|
||||
p = &fullpath[i];
|
||||
*p++ = '/'; *p = '\0';
|
||||
if (dirnames && i > 1) {
|
||||
q = (strncmp(fullpath, "./", 2) == 0 ? &fullpath[2] : &fullpath[0]);
|
||||
ret = newname(q, 1, 0);
|
||||
}
|
||||
i = 0;
|
||||
while (depth > 0 && (entp = readdir(dirp)) != 0)
|
||||
if (strcmp(entp->d_name,".") != 0 && strcmp(entp->d_name,"..") != 0) {
|
||||
strcpy(p, entp->d_name);
|
||||
if (i = myftw(depth-1))
|
||||
depth = 0; /* force User's finish */
|
||||
}
|
||||
closedir(dirp);
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
int wild( char *p )
|
||||
{
|
||||
char *d;
|
||||
|
||||
ret = ZE_OK;
|
||||
if (p == NULL) p = "*";
|
||||
|
||||
if (strcmp(p, "-") == 0) /* if compressing stdin */
|
||||
ret = newname(p, 0, 0);
|
||||
|
||||
strcpy(fullpath, p);
|
||||
/* now turning UNIX-Wildcards into basic regular expressions */
|
||||
for (is_w = ind_w = 0, d = &file_arg[0]; *p; d++, p++)
|
||||
switch (*p) {
|
||||
case '*': *d++ = '.'; *d = *p; is_w = 1; break;
|
||||
case '?': *d = '.'; is_w = 1; break;
|
||||
case '[': *d = *p;
|
||||
if (*(p+1) == '!') {
|
||||
*++d = '^'; p++;
|
||||
} is_w = 1; break;
|
||||
case '.': *d++ = '\\'; *d = *p; break;
|
||||
default : *d = *p;
|
||||
if (!is_w) ind_w++;
|
||||
}
|
||||
*++d = '\0';
|
||||
if (is_w) {
|
||||
strcat( file_arg, "$" ); /* to get things like *.[ch] work */
|
||||
if ((regptr = regcomp( file_arg )) == NULL)
|
||||
return ZE_MEM;
|
||||
strcpy( fullpath, "." );
|
||||
myftw( recurse ? 99 : 1 );
|
||||
free(regptr);
|
||||
} else if (recurse) {
|
||||
myftw( 99 );
|
||||
} else
|
||||
myftw( 1 ); /* ret = procname( fullpath, 0 ); */
|
||||
return ret;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
for (p = n; *p; p++) /* use / consistently */
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
if (!S_ISDIR(s.st_mode))
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '/')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t, *p; /* shortened name */
|
||||
int dosflag;
|
||||
|
||||
dosflag = 0;
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
t = *x && *(x + 1) == ':' ? x + 2 : x;
|
||||
while (*t == '/' || *t == '\\')
|
||||
t++;
|
||||
|
||||
/* Make changes, if any, to the copied name (leave original intact) */
|
||||
for (n = t; *n; n++)
|
||||
if (*n == '\\')
|
||||
*n = '/';
|
||||
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
#if 0
|
||||
if (p = strstr(t, " -> ")) /* shorten "link -> data" to "link" */
|
||||
*p = '\0';
|
||||
#endif
|
||||
if (dosify)
|
||||
msname(n);
|
||||
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
struct utimbuf u; /* argument for utime() const ?? */
|
||||
|
||||
/* Convert DOS time to time_t format in u[0] and u[1] */
|
||||
u.actime = u.modtime = dos2unixtime(d);
|
||||
|
||||
/* Set updated and accessed times of f */
|
||||
utime(f, &u);
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
/* convert FNMAX to malloc - 11/8/04 EG */
|
||||
char *name;
|
||||
int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL) {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '/')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
|
||||
if (strcmp(f, "-") == 0) {
|
||||
if (fstat(fileno(stdin), &s) != 0) {
|
||||
free(name);
|
||||
error("fstat(stdin)");
|
||||
}
|
||||
} else if (LSSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a != NULL) {
|
||||
/* *a = ((ulg)s.st_mode << 16) | (ulg)GetFileMode(name); */
|
||||
*a = ((ulg)s.st_mode << 16) | (ulg)s.st_attr;
|
||||
}
|
||||
free(name);
|
||||
if (n != NULL)
|
||||
*n = S_ISREG(s.st_mode) ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = s.st_ctime;
|
||||
}
|
||||
|
||||
return unix2dostime(&s.st_mtime);
|
||||
}
|
||||
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* create extra field and change z->att if desired */
|
||||
{
|
||||
#ifdef USE_EF_UT_TIME
|
||||
#ifdef IZ_CHECK_TZ
|
||||
if (!zp_tz_is_valid) return ZE_OK; /* skip silently if no valid TZ info */
|
||||
#endif
|
||||
|
||||
if ((z->extra = (char *)malloc(EB_HEADSIZE+EB_UT_LEN(2))) == NULL)
|
||||
return ZE_MEM;
|
||||
if ((z->cextra = (char *)malloc(EB_HEADSIZE+EB_UT_LEN(1))) == NULL)
|
||||
return ZE_MEM;
|
||||
|
||||
z->extra[0] = 'U';
|
||||
z->extra[1] = 'T';
|
||||
z->extra[2] = EB_UT_LEN(2); /* length of data part of e.f. */
|
||||
z->extra[3] = 0;
|
||||
z->extra[4] = EB_UT_FL_MTIME | EB_UT_FL_ATIME;
|
||||
z->extra[5] = (char)(z_utim->mtime);
|
||||
z->extra[6] = (char)(z_utim->mtime >> 8);
|
||||
z->extra[7] = (char)(z_utim->mtime >> 16);
|
||||
z->extra[8] = (char)(z_utim->mtime >> 24);
|
||||
z->extra[9] = (char)(z_utim->atime);
|
||||
z->extra[10] = (char)(z_utim->atime >> 8);
|
||||
z->extra[11] = (char)(z_utim->atime >> 16);
|
||||
z->extra[12] = (char)(z_utim->atime >> 24);
|
||||
|
||||
z->ext = (EB_HEADSIZE+EB_UX_LEN(2));
|
||||
|
||||
memcpy(z->cextra, z->extra, (EB_HEADSIZE+EB_UT_LEN(1)));
|
||||
z->cextra[EB_LEN] = EB_UT_LEN(1);
|
||||
z->cext = (EB_HEADSIZE+EB_UX_LEN(1));
|
||||
|
||||
return ZE_OK;
|
||||
#else /* !USE_EF_UT_TIME */
|
||||
return (int)(z-z);
|
||||
#endif /* ?USE_EF_UT_TIME */
|
||||
}
|
||||
|
||||
int deletedir(d)
|
||||
char *d; /* directory to delete */
|
||||
/* Delete the directory *d if it is empty, do nothing otherwise.
|
||||
Return the result of rmdir(), delete(), or system().
|
||||
For VMS, d must be in format [x.y]z.dir;1 (not [x.y.z]).
|
||||
*/
|
||||
{
|
||||
return rmdir(d);
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
void version_local()
|
||||
{
|
||||
static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
|
||||
#ifdef __TURBOC__
|
||||
char buf[40];
|
||||
#endif
|
||||
|
||||
printf(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
|
||||
);
|
||||
|
||||
} /* end function version_local() */
|
7
third_party/infozip/zip/atari/make_all.mup
vendored
Normal file
7
third_party/infozip/zip/atari/make_all.mup
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
rm -f *.o *.sym *.ttp
|
||||
make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-O -DATARI" E=.ttp OBJA=atari.o zips
|
||||
#make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.ttp OBJA=atari.o zip.ttp
|
||||
#make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.sym OBJA=atari.o zip.sym LFLAGS2="-B/bin/sym-"
|
||||
#make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-O -DATARI" E=.ttp OBJA=atari.o -n zips > make_all.mup
|
||||
#fixstk 32K pgp.ttp
|
||||
prgflags 017 007 *.ttp
|
7
third_party/infozip/zip/atari/make_zip.mup
vendored
Normal file
7
third_party/infozip/zip/atari/make_zip.mup
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
#rm -f *.o *.sym *.ttp
|
||||
#make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-O -DATARI" E=.ttp OBJA=atari.o zips
|
||||
make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.ttp OBJA=atari.o zip.ttp
|
||||
make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-g -D__NO_INLINE__ -DATARI" E=.sym OBJA=atari.o zip.sym LFLAGS2="-B/bin/sym-"
|
||||
#make370 SHELL=/bin/mupfel.ttp CC=gcc CFLAGS="-O -DATARI" E=.ttp OBJA=atari.o -n zips > make_all.mup
|
||||
#fixstk 32K pgp.ttp
|
||||
prgflags 017 007 *.ttp
|
20
third_party/infozip/zip/atari/osdep.h
vendored
Normal file
20
third_party/infozip/zip/atari/osdep.h
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#define FOPR "rb"
|
||||
#define FOPM "r+b"
|
||||
#define FOPW "wb"
|
||||
|
||||
#define DIRENT
|
||||
#define NO_TERMIO
|
||||
#define USE_CASE_MAP
|
||||
#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \
|
||||
procname(n, 1))
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
19
third_party/infozip/zip/atari/zipup.h
vendored
Normal file
19
third_party/infozip/zip/atari/zipup.h
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef O_RDONLY
|
||||
# define O_RDONLY 0
|
||||
#endif
|
||||
#define fhow O_RDONLY
|
||||
#define fbad (-1)
|
||||
typedef int ftype;
|
||||
#define zopen(n,p) open(n,p)
|
||||
#define zread(f,b,n) read(f,b,n)
|
||||
#define zclose(f) close(f)
|
||||
#define zerr(f) (k == (extent)(-1L))
|
||||
#define zstdin 0
|
146
third_party/infozip/zip/atheos/Makefile
vendored
Normal file
146
third_party/infozip/zip/atheos/Makefile
vendored
Normal file
|
@ -0,0 +1,146 @@
|
|||
######################################################################
|
||||
#
|
||||
# Makefile for Info-ZIP's zip, zipcloak, zipnote, and zipsplit on AtheOS
|
||||
#
|
||||
# Copyright (C) 1999-2007 Info-ZIP
|
||||
# Chris Herborth (chrish@pobox.com)
|
||||
# Ruslan Nickolaev (nruslan@hotbox.ru)
|
||||
#
|
||||
######################################################################
|
||||
# Things that don't change:
|
||||
|
||||
# Punish people who don't have SMP hardware.
|
||||
MAKE = make -j 4 -f atheos/Makefile
|
||||
SHELL = /bin/sh
|
||||
|
||||
LN = ln -s
|
||||
RM = rm -f
|
||||
|
||||
BIND = $(CC)
|
||||
AS = as
|
||||
|
||||
INSTALL = install
|
||||
|
||||
# Target directories
|
||||
prefix = /usr
|
||||
BINDIR = $(prefix)/bin
|
||||
manext = 1
|
||||
MANDIR = $(prefix)/man/man$(manext)
|
||||
ZIPMANUAL = MANUAL
|
||||
|
||||
VERSION = Version 2.3 of __DATE__
|
||||
|
||||
######################################################################
|
||||
|
||||
CC:=gcc
|
||||
CFLAGS:=-O3 -march=i586 -Wall -I. -DHAVE_DIRENT_H -DPASSWD_FROM_STDIN -DASMV -DASM_CRC
|
||||
LFLAGS1:=
|
||||
LFLAGS2:=
|
||||
TARGET=$(ZIPS)
|
||||
|
||||
######################################################################
|
||||
# Helpful targets
|
||||
all:
|
||||
$(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" \
|
||||
LFLAGS1="$(LFLAGS1)" LFLAGS2="$(LFLAGS2)" \
|
||||
$(TARGET)
|
||||
|
||||
######################################################################
|
||||
# Object file lists and other build goodies
|
||||
|
||||
# Object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crc32.o crypt.o \
|
||||
ttyio.o atheos.o
|
||||
OBJI = deflate.o trees.o
|
||||
OBJA = match.o crc_i386.o
|
||||
OBJU = zipfile_.o fileio_.o util_.o globals.o atheos_.o
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
# Headers
|
||||
ZIP_H = zip.h ziperr.h tailor.h atheos/osdep.h
|
||||
|
||||
# What to build?
|
||||
ZIPS = zip zipnote zipsplit zipcloak
|
||||
|
||||
# suffix rules
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: _.o .o .c .doc .1
|
||||
.c_.o:
|
||||
$(RM) $*_.c; $(LN) $< $*_.c
|
||||
$(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
$(RM) $*_.c
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
.1.doc:
|
||||
groff -man -Tascii $< > $@
|
||||
|
||||
# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
zipup.o: atheos/zipup.h
|
||||
|
||||
match.o: match.S
|
||||
$(CC) -E match.S > matchs.s
|
||||
$(AS) -o $@ matchs.s
|
||||
$(RM) matchs.s
|
||||
|
||||
crc_i386.o: crc_i386.S
|
||||
$(CC) -E crc_i386.S > crc_i386s.s
|
||||
$(AS) -o $@ crc_i386s.s
|
||||
$(RM) crc_i386s.s
|
||||
|
||||
atheos.o: atheos/atheos.c
|
||||
$(CC) -c $(CFLAGS) atheos/atheos.c
|
||||
|
||||
atheos_.o: atheos/atheos.c
|
||||
$(RM) $*_.c; $(LN) atheos/atheos.c $*_.c
|
||||
$(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
$(RM) $*_.c
|
||||
|
||||
zips: $(ZIPS)
|
||||
zipsman: $(ZIPS) $(ZIPMANUAL)
|
||||
|
||||
zip: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(BIND) -o zip $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
zipnote: $(OBJN)
|
||||
$(BIND) -o zipnote $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
zipcloak: $(OBJC)
|
||||
$(BIND) -o zipcloak $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
zipsplit: $(OBJS)
|
||||
$(BIND) -o zipsplit $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
$(ZIPMANUAL): man/zip.1
|
||||
groff -man -Tascii man/zip.1 > $(ZIPMANUAL)
|
||||
|
||||
# install
|
||||
install: $(ZIPS)
|
||||
$(INSTALL) -m755 $(ZIPS) $(BINDIR)
|
||||
mkdir -p $(MANDIR)
|
||||
$(INSTALL) -m644 man/zip.1 $(MANDIR)/zip.$(manext)
|
||||
|
||||
uninstall:
|
||||
-cd $(BINDIR); $(RM) $(ZIPS)
|
||||
-cd $(MANDIR); $(RM) zip.$(manext)
|
||||
|
||||
dist: $(ZIPMANUAL)
|
||||
zip -u9T zip`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' \
|
||||
-e s/[.]//g -e q revision.h` \
|
||||
`awk '/^Makefile/,/vms_zip.rnh/ {print $$1}' < contents`
|
||||
|
||||
# clean up after making stuff and installing it
|
||||
clean:
|
||||
$(RM) *.o $(ZIPS) flags
|
||||
|
||||
# end of Makefile
|
21
third_party/infozip/zip/atheos/README
vendored
Normal file
21
third_party/infozip/zip/atheos/README
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
Info-ZIP's zip for AtheOS/Syllable
|
||||
|
||||
FEATURES
|
||||
stores AtheOS/Syllable file attributes, compressing them if possible
|
||||
|
||||
TODO
|
||||
----
|
||||
There is only one thing to be fixed:
|
||||
write_attr() should return count of writed bytes. However that's bug related with AFS only.
|
||||
|
||||
Please report any bugs to Info-ZIP at www.info-zip.org.
|
||||
If this bug related with AtheOS/Syllable only, you can mail me directly: nruslan@hotbox.ru.
|
||||
|
||||
Visit the Info-ZIP web site (http://www.info-zip.org) for all the
|
||||
latest zip and unzip information, FAQs, source code and ready-to-run
|
||||
executables.
|
||||
|
||||
- Ruslan Nickolaev (nruslan@hotbox.ru)
|
||||
Sep 06/2004
|
||||
|
||||
(updated 12 November 2004)
|
885
third_party/infozip/zip/atheos/atheos.c
vendored
Normal file
885
third_party/infozip/zip/atheos/atheos.c
vendored
Normal file
|
@ -0,0 +1,885 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
|
||||
This AtheOS - specific file is based on unix.c and beos.c;
|
||||
changes by Ruslan Nickolaev (nruslan@hotbox.ru)
|
||||
*/
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atheos/fs_attribs.h>
|
||||
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
/* Library functions not in (most) header files */
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
# include <utime.h>
|
||||
#else
|
||||
int utime OF((char *, time_t *));
|
||||
#endif
|
||||
|
||||
extern char *label;
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
/* Local functions */
|
||||
local char *readd OF((DIR *));
|
||||
local int get_attr_dir( const char *, char **, off_t * );
|
||||
local int add_UT_ef( struct zlist far * );
|
||||
local int add_Ux_ef( struct zlist far * );
|
||||
local int add_At_ef( struct zlist far * );
|
||||
|
||||
local char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if ((s.st_mode & S_IFREG) == S_IFREG ||
|
||||
(s.st_mode & S_IFLNK) == S_IFLNK)
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
}
|
||||
else if ((s.st_mode & S_IFDIR) == S_IFDIR)
|
||||
{
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '/')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) */
|
||||
else
|
||||
zipwarn("ignoring special file: ", n);
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t = NULL; /* shortened name */
|
||||
int dosflag;
|
||||
|
||||
dosflag = dosify; /* default for non-DOS and non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
/* Strip "//host/share/" part of a UNC name */
|
||||
if (!strncmp(x,"//",2) && (x[2] != '\0' && x[2] != '/')) {
|
||||
n = x + 2;
|
||||
while (*n != '\0' && *n != '/')
|
||||
n++; /* strip host name */
|
||||
if (*n != '\0') {
|
||||
n++;
|
||||
while (*n != '\0' && *n != '/')
|
||||
n++; /* strip `share' name */
|
||||
}
|
||||
if (*n != '\0')
|
||||
t = n + 1;
|
||||
} else
|
||||
t = x;
|
||||
while (*t == '/')
|
||||
t++; /* strip leading '/' chars to get a relative path */
|
||||
while (*t == '.' && t[1] == '/')
|
||||
t += 2; /* strip redundant leading "./" sections */
|
||||
|
||||
/* Make changes, if any, to the copied name (leave original intact) */
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
|
||||
if (isdir == 42) return n; /* avoid warning on unused variable */
|
||||
|
||||
if (dosify)
|
||||
msname(n);
|
||||
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX use ztimbuf in both POSIX and non POSIX cases ?
|
||||
*/
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
#ifdef _POSIX_VERSION
|
||||
struct utimbuf u; /* argument for utime() const ?? */
|
||||
#else
|
||||
time_t u[2]; /* argument for utime() */
|
||||
#endif
|
||||
|
||||
/* Convert DOS time to time_t format in u */
|
||||
#ifdef _POSIX_VERSION
|
||||
u.actime = u.modtime = dos2unixtime(d);
|
||||
utime(f, &u);
|
||||
#else
|
||||
u[0] = u[1] = dos2unixtime(d);
|
||||
utime(f, u);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
char *name;
|
||||
int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '/')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
if (strcmp(f, "-") == 0) {
|
||||
if (fstat(fileno(stdin), &s) != 0) {
|
||||
free(name);
|
||||
error("fstat(stdin)");
|
||||
}
|
||||
}
|
||||
else if (LSSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (a != NULL) {
|
||||
#ifndef OS390
|
||||
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
|
||||
#else
|
||||
/*
|
||||
** The following defines are copied from the unizip source and represent the
|
||||
** legacy Unix mode flags. These fixed bit masks are no longer required
|
||||
** by XOPEN standards - the S_IS### macros being the new recommended method.
|
||||
** The approach here of setting the legacy flags by testing the macros should
|
||||
** work under any _XOPEN_SOURCE environment (and will just rebuild the same bit
|
||||
** mask), but is required if the legacy bit flags differ from legacy Unix.
|
||||
*/
|
||||
#define UNX_IFDIR 0040000 /* Unix directory */
|
||||
#define UNX_IFREG 0100000 /* Unix regular file */
|
||||
#define UNX_IFSOCK 0140000 /* Unix socket (BSD, not SysV or Amiga) */
|
||||
#define UNX_IFLNK 0120000 /* Unix symbolic link (not SysV, Amiga) */
|
||||
#define UNX_IFBLK 0060000 /* Unix block special (not Amiga) */
|
||||
#define UNX_IFCHR 0020000 /* Unix character special (not Amiga) */
|
||||
#define UNX_IFIFO 0010000 /* Unix fifo (BCC, not MSC or Amiga) */
|
||||
{
|
||||
mode_t legacy_modes;
|
||||
|
||||
/* Initialize with permission bits - which are not implementation optional */
|
||||
legacy_modes = s.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);
|
||||
if (S_ISDIR(s.st_mode))
|
||||
legacy_modes |= UNX_IFDIR;
|
||||
if (S_ISREG(s.st_mode))
|
||||
legacy_modes |= UNX_IFREG;
|
||||
if (S_ISLNK(s.st_mode))
|
||||
legacy_modes |= UNX_IFLNK;
|
||||
if (S_ISBLK(s.st_mode))
|
||||
legacy_modes |= UNX_IFBLK;
|
||||
if (S_ISCHR(s.st_mode))
|
||||
legacy_modes |= UNX_IFCHR;
|
||||
if (S_ISFIFO(s.st_mode))
|
||||
legacy_modes |= UNX_IFIFO;
|
||||
if (S_ISSOCK(s.st_mode))
|
||||
legacy_modes |= UNX_IFSOCK;
|
||||
*a = ((ulg)legacy_modes << 16) | !(s.st_mode & S_IWRITE);
|
||||
}
|
||||
#endif
|
||||
if ((s.st_mode & S_IFMT) == S_IFDIR) {
|
||||
*a |= MSDOS_DIR_ATTR;
|
||||
}
|
||||
}
|
||||
if (n != NULL)
|
||||
*n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = t->mtime; /* best guess, (s.st_ctime: last status change!!) */
|
||||
}
|
||||
return unix2dostime(&s.st_mtime);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Return a malloc()'d buffer containing all of the attributes and their names
|
||||
for the file specified in name. You have to free() this yourself. The length
|
||||
of the buffer is also returned.
|
||||
|
||||
If get_attr_dir() fails, the buffer will be NULL, total_size will be 0,
|
||||
and an error will be returned:
|
||||
|
||||
EOK - no errors occurred
|
||||
EINVAL - attr_buff was pointing at a buffer
|
||||
ENOMEM - insufficient memory for attribute buffer
|
||||
|
||||
Other errors are possible (whatever is returned by the fs_attrib.h functions).
|
||||
|
||||
PROBLEMS:
|
||||
|
||||
- pointers are 32-bits; attributes are limited to ssize_t in size so it's
|
||||
possible to overflow... in practice, this isn't too likely... your
|
||||
machine will thrash like hell before that happens
|
||||
|
||||
*/
|
||||
|
||||
#define INITIAL_BUFF_SIZE 65536
|
||||
|
||||
int get_attr_dir( const char *name, char **attr_buff, off_t *total_size )
|
||||
{
|
||||
int retval = EOK;
|
||||
int fd;
|
||||
DIR *fa_dir;
|
||||
struct dirent *fa_ent;
|
||||
off_t attrs_size = 0;
|
||||
size_t entname_size;
|
||||
char *ptr;
|
||||
struct attr_info fa_info;
|
||||
|
||||
*total_size = 0;
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Sanity-check. */
|
||||
if( *attr_buff != NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Can we open the file/directory? */
|
||||
/* */
|
||||
/* linkput is a zip global; it's set to 1 if we're storing symbolic */
|
||||
/* links as symbolic links (instead of storing the thing the link */
|
||||
/* points to)... if we're storing the symbolic link as a link, we'll */
|
||||
/* want the link's file attributes, otherwise we want the target's. */
|
||||
|
||||
fd = open( name, linkput ? O_RDONLY | O_NOTRAVERSE : O_RDONLY );
|
||||
if( fd < 0 ) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Allocate an initial buffer; 64k should usually be enough. */
|
||||
*attr_buff = (char *)malloc( INITIAL_BUFF_SIZE );
|
||||
ptr = *attr_buff;
|
||||
if( ptr == NULL ) {
|
||||
close( fd );
|
||||
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Open the attributes directory for this file. */
|
||||
fa_dir = open_attrdir( fd );
|
||||
if( fa_dir == NULL ) {
|
||||
close( fd );
|
||||
|
||||
free( ptr );
|
||||
*attr_buff = NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Read all the attributes; the buffer could grow > 64K if there are */
|
||||
/* many and/or they are large. */
|
||||
while( ( fa_ent = read_attrdir( fa_dir ) ) != NULL ) {
|
||||
retval = stat_attr( fd, fa_ent->d_name, &fa_info );
|
||||
/* TODO: check retval != EOK */
|
||||
|
||||
entname_size = strlen( fa_ent->d_name ) + 1;
|
||||
attrs_size += entname_size + sizeof( struct attr_info ) + fa_info.ai_size;
|
||||
|
||||
if( attrs_size > INITIAL_BUFF_SIZE ) {
|
||||
unsigned long offset = ptr - *attr_buff;
|
||||
|
||||
*attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
if( *attr_buff == NULL ) {
|
||||
retval = close_attrdir( fa_dir );
|
||||
/* TODO: check retval != EOK */
|
||||
close( fd );
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ptr = *attr_buff + offset;
|
||||
}
|
||||
|
||||
/* Now copy the data for this attribute into the buffer. */
|
||||
strcpy( ptr, fa_ent->d_name );
|
||||
ptr += entname_size;
|
||||
|
||||
memcpy( ptr, &fa_info, sizeof( struct attr_info ) );
|
||||
ptr += sizeof( struct attr_info );
|
||||
|
||||
if( fa_info.ai_size > 0 ) {
|
||||
ssize_t read_bytes = read_attr( fd, fa_ent->d_name, fa_info.ai_type, ptr, 0, fa_info.ai_size );
|
||||
if( read_bytes != fa_info.ai_size ) {
|
||||
/* print a warning about mismatched sizes */
|
||||
char buff[80];
|
||||
sprintf( buff, "read %d, expected %d", read_bytes, (ssize_t)fa_info.ai_size );
|
||||
zipwarn( "attribute size mismatch: ", buff );
|
||||
}
|
||||
|
||||
ptr += fa_info.ai_size;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Close the attribute directory. */
|
||||
retval = close_attrdir( fa_dir );
|
||||
/* TODO: check retval != EOK */
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* If the buffer is too big, shrink it. */
|
||||
if( attrs_size < INITIAL_BUFF_SIZE ) {
|
||||
*attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
if( *attr_buff == NULL ) {
|
||||
close( fd );
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
*total_size = attrs_size;
|
||||
|
||||
close( fd );
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'UT' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(2))
|
||||
#define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1))
|
||||
|
||||
local int add_UT_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
struct stat s;
|
||||
|
||||
#ifdef IZ_CHECK_TZ
|
||||
if (!zp_tz_is_valid)
|
||||
return ZE_OK; /* skip silently if no valid TZ info */
|
||||
#endif
|
||||
|
||||
/* We can't work if there's no entry to work on. */
|
||||
if( z == NULL ) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_UT_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_UT_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* stat() the file (or the symlink) to get the data; if we can't get */
|
||||
/* the data, there's no point in trying to fill out the fields. */
|
||||
if(LSSTAT( z->name, &s ) ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_UT_SIZE );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_UT_SIZE );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_UT_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_UT_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'U';
|
||||
*l_ef++ = 'T';
|
||||
*l_ef++ = (char)(EB_UT_LEN(2)); /* length of data in local EF */
|
||||
*l_ef++ = (char)0;
|
||||
*l_ef++ = (char)(EB_UT_FL_MTIME | EB_UT_FL_ATIME);
|
||||
*l_ef++ = (char)(s.st_mtime);
|
||||
*l_ef++ = (char)(s.st_mtime >> 8);
|
||||
*l_ef++ = (char)(s.st_mtime >> 16);
|
||||
*l_ef++ = (char)(s.st_mtime >> 24);
|
||||
*l_ef++ = (char)(s.st_atime);
|
||||
*l_ef++ = (char)(s.st_atime >> 8);
|
||||
*l_ef++ = (char)(s.st_atime >> 16);
|
||||
*l_ef++ = (char)(s.st_atime >> 24);
|
||||
|
||||
z->ext += EB_L_UT_SIZE;
|
||||
|
||||
/* Now add the central version. */
|
||||
memcpy(c_ef, l_ef-EB_L_UT_SIZE, EB_C_UT_SIZE);
|
||||
c_ef[EB_LEN] = (char)(EB_UT_LEN(1)); /* length of data in central EF */
|
||||
|
||||
z->cext += EB_C_UT_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'Ux' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_UX2_SIZE (EB_HEADSIZE + EB_UX2_MINLEN)
|
||||
#define EB_C_UX2_SIZE (EB_HEADSIZE)
|
||||
|
||||
local int add_Ux_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
struct stat s;
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_UX2_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_UX2_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* stat() the file (or the symlink) to get the data; if we can't get */
|
||||
/* the data, there's no point in trying to fill out the fields. */
|
||||
if(LSSTAT( z->name, &s ) ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_UX2_SIZE );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_UX2_SIZE );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_UX2_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_UX2_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'U';
|
||||
*l_ef++ = 'x';
|
||||
*l_ef++ = (char)(EB_UX2_MINLEN);
|
||||
*l_ef++ = (char)(EB_UX2_MINLEN >> 8);
|
||||
*l_ef++ = (char)(s.st_uid);
|
||||
*l_ef++ = (char)(s.st_uid >> 8);
|
||||
*l_ef++ = (char)(s.st_gid);
|
||||
*l_ef++ = (char)(s.st_gid >> 8);
|
||||
|
||||
z->ext += EB_L_UX2_SIZE;
|
||||
|
||||
/* Now add the central version of the field. */
|
||||
*c_ef++ = 'U';
|
||||
*c_ef++ = 'x';
|
||||
*c_ef++ = 0;
|
||||
*c_ef++ = 0;
|
||||
|
||||
z->cext += EB_C_UX2_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'At' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_AT_SIZE (EB_HEADSIZE + EB_L_AT_LEN) /* + attr size */
|
||||
#define EB_C_AT_SIZE (EB_HEADSIZE + EB_C_AT_LEN)
|
||||
|
||||
#define MEMCOMPRESS_HEADER 6 /* ush compression type, ulg CRC */
|
||||
#define DEFLAT_WORSTCASE_ADD 5 /* byte blocktype, 2 * ush blocklength */
|
||||
#define MEMCOMPRESS_OVERHEAD (MEMCOMPRESS_HEADER + DEFLAT_WORSTCASE_ADD)
|
||||
|
||||
local int add_At_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
char *attrbuff = NULL;
|
||||
off_t attrsize = 0;
|
||||
char *compbuff = NULL;
|
||||
ush compsize = 0;
|
||||
uch flags = 0;
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_AT_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_AT_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* Attempt to load up a buffer full of the file's attributes. */
|
||||
{
|
||||
if (get_attr_dir( z->name, &attrbuff, &attrsize) != EOK ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
if (attrsize == 0) {
|
||||
return ZE_OK;
|
||||
}
|
||||
if (attrbuff == NULL) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
/* Check for way too much data. */
|
||||
if (attrsize > (off_t)ULONG_MAX) {
|
||||
zipwarn( "uncompressed attributes truncated", "" );
|
||||
attrsize = (off_t)(ULONG_MAX - MEMCOMPRESS_OVERHEAD);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
printf( "\t[in=%lu]", (unsigned long)attrsize );
|
||||
}
|
||||
|
||||
/* Try compressing the data */
|
||||
compbuff = (char *)malloc( (size_t)attrsize + MEMCOMPRESS_OVERHEAD );
|
||||
if( compbuff == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
compsize = memcompress( compbuff,
|
||||
(size_t)attrsize + MEMCOMPRESS_OVERHEAD,
|
||||
attrbuff,
|
||||
(size_t)attrsize );
|
||||
if (verbose) {
|
||||
printf( " [out=%u]", compsize );
|
||||
}
|
||||
|
||||
/* Attempt to optimise very small attributes. */
|
||||
if (compsize > attrsize) {
|
||||
free( compbuff );
|
||||
compsize = (ush)attrsize;
|
||||
compbuff = attrbuff;
|
||||
|
||||
flags = EB_AT_FL_NATURAL;
|
||||
}
|
||||
|
||||
/* Check to see if we really have enough room in the EF for the data. */
|
||||
if( ( z->ext + compsize + EB_L_AT_LEN ) > USHRT_MAX ) {
|
||||
compsize = USHRT_MAX - EB_L_AT_LEN - z->ext;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_AT_SIZE + compsize );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_AT_SIZE + compsize );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_AT_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_AT_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'A';
|
||||
*l_ef++ = 't';
|
||||
*l_ef++ = (char)(compsize + EB_L_AT_LEN);
|
||||
*l_ef++ = (char)((compsize + EB_L_AT_LEN) >> 8);
|
||||
*l_ef++ = (char)((unsigned long)attrsize);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 8);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 16);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 24);
|
||||
*l_ef++ = flags;
|
||||
memcpy( l_ef, compbuff, (size_t)compsize );
|
||||
|
||||
z->ext += EB_L_AT_SIZE + compsize;
|
||||
|
||||
/* And the central version. */
|
||||
*c_ef++ = 'A';
|
||||
*c_ef++ = 't';
|
||||
*c_ef++ = (char)(EB_C_AT_LEN);
|
||||
*c_ef++ = (char)(EB_C_AT_LEN >> 8);
|
||||
*c_ef++ = (char)compsize;
|
||||
*c_ef++ = (char)(compsize >> 8);
|
||||
*c_ef++ = (char)(compsize >> 16);
|
||||
*c_ef++ = (char)(compsize >> 24);
|
||||
*c_ef++ = flags;
|
||||
|
||||
z->cext += EB_C_AT_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* Extra field info:
|
||||
- 'UT' - UNIX time extra field
|
||||
- 'Ux' - UNIX uid/gid extra field
|
||||
- 'At' - AtheOS file attributes extra field
|
||||
|
||||
This is done the same way ../unix/unix.c stores the 'UT'/'Ux' fields
|
||||
(full data in local header, only modification time in central header),
|
||||
with the 'At' field added to the end and the size of the 'At' field
|
||||
in the central header.
|
||||
|
||||
See the end of atheos/osdep.h for a simple explanation of the 'At' EF
|
||||
layout.
|
||||
*/
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* store full data in local header but just modification time stamp info
|
||||
in central header */
|
||||
{
|
||||
int retval;
|
||||
|
||||
/* Check to make sure z is valid. */
|
||||
if( z == NULL ) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
retval = add_UT_ef(z);
|
||||
if( retval != ZE_OK ) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = add_Ux_ef(z);
|
||||
if( retval != ZE_OK ) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
return add_At_ef(z); /* last function; we can use return value directly */
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Set a file's MIME type. */
|
||||
void setfiletype(const char *file, const char *type)
|
||||
{
|
||||
int fd;
|
||||
off_t nLen;
|
||||
ssize_t nError;
|
||||
|
||||
fd = open( file, O_RDWR );
|
||||
|
||||
if (fd < 0) {
|
||||
zipwarn( "can't open zipfile to write file type", "" );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
nLen = strlen( type );
|
||||
/* FIXME: write_attr() should return count of writed bytes */
|
||||
nError = write_attr( fd, "os::MimeType", O_TRUNC, ATTR_TYPE_STRING, type, 0, nLen );
|
||||
if (nError < 0) {
|
||||
zipwarn( "couldn't write complete file type", "" );
|
||||
}
|
||||
close( fd );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
void version_local()
|
||||
{
|
||||
static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
|
||||
|
||||
printf(CompiledWith,
|
||||
|
||||
#ifdef __GNUC__
|
||||
"gcc ", __VERSION__,
|
||||
#else
|
||||
"(unknown compiler)", "",
|
||||
#endif
|
||||
|
||||
"Syllable",
|
||||
|
||||
#if defined(i486) || defined(__i486) || defined(__i486__) || defined(i386) || defined(__i386) || defined(__i386__)
|
||||
" (x86)",
|
||||
#else
|
||||
" (unknown platform)",
|
||||
#endif
|
||||
|
||||
#ifdef __DATE__
|
||||
" on ", __DATE__
|
||||
#else
|
||||
"", ""
|
||||
#endif
|
||||
);
|
||||
|
||||
} /* end function version_local() */
|
64
third_party/infozip/zip/atheos/osdep.h
vendored
Normal file
64
third_party/infozip/zip/atheos/osdep.h
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
|
||||
#ifndef _OSDEP_H_
|
||||
#define _OSDEP_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/unistd.h>
|
||||
|
||||
#define USE_EF_UT_TIME /* Enable use of "UT" extra field time info */
|
||||
|
||||
#define EB_L_AT_LEN 5 /* min size is an unsigned long and flag */
|
||||
#define EB_C_AT_LEN 5 /* Length of data in local EF and flag. */
|
||||
|
||||
#define EB_AT_FL_NATURAL 0x01 /* data is 'natural' (not compressed) */
|
||||
#define EB_AT_FL_BADBITS 0xfe /* bits currently undefined */
|
||||
|
||||
#ifndef ZP_NEED_MEMCOMPR
|
||||
define ZP_NEED_MEMCOMPR
|
||||
#endif
|
||||
|
||||
#define deletedir(d) rmdir(d);
|
||||
|
||||
/* Set a file's MIME type. */
|
||||
void setfiletype( const char *file, const char *type );
|
||||
|
||||
/*
|
||||
'At' extra-field layout:
|
||||
|
||||
'At' - signature
|
||||
ef_size - size of data in this EF (little-endian unsigned short)
|
||||
full_size - uncompressed data size (little-endian unsigned long)
|
||||
flag - flags (byte)
|
||||
flags & EB_AT_FL_NATURAL = the data is not compressed
|
||||
flags & EB_AT_FL_BADBITS = the data is corrupted or we
|
||||
can't handle it properly
|
||||
data - compressed or uncompressed file attribute data
|
||||
|
||||
If flag & EB_AT_FL_NATURAL, the data is not compressed; this optimisation is
|
||||
necessary to prevent wasted space for files with small attributes. In this
|
||||
case, there should be ( ef_size - EB_L_AT_LEN ) bytes of data, and full_size
|
||||
should equal ( ef_size - EB_L_AT_LEN ).
|
||||
|
||||
If the data is compressed, there will be ( ef_size - EB_L_AT_LEN ) bytes of
|
||||
compressed data, and full_size bytes of uncompressed data.
|
||||
|
||||
If a file has absolutely no attributes, there will not be a 'At' extra field.
|
||||
|
||||
The uncompressed data is arranged like this:
|
||||
|
||||
attr_name\0 - C string
|
||||
struct attr_info (little-endian)
|
||||
attr_data (length in attr_info.ai_size)
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
24
third_party/infozip/zip/atheos/zipup.h
vendored
Normal file
24
third_party/infozip/zip/atheos/zipup.h
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef _ZIPUP_H_
|
||||
#define _ZIPUP_H_
|
||||
|
||||
#ifndef O_RDONLY
|
||||
# include <sys/fcntl.h>
|
||||
#endif
|
||||
#define fhow O_RDONLY
|
||||
#define fbad (-1)
|
||||
typedef int ftype;
|
||||
#define zopen(n,p) open(n,p)
|
||||
#define zread(f,b,n) read(f,b,n)
|
||||
#define zclose(f) close(f)
|
||||
#define zerr(f) (k == (extent)(-1L))
|
||||
#define zstdin 0
|
||||
|
||||
#endif /* _ZIPUP_H_ */
|
14
third_party/infozip/zip/beos/Contents
vendored
Normal file
14
third_party/infozip/zip/beos/Contents
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
Contents of the "beos" sub-directory for Zip 2.2 and later:
|
||||
|
||||
Contents this file
|
||||
README Notes from the author of the BeOS port
|
||||
Makefile makefile for building (sorry, no project files)
|
||||
beos.c BeOS-specific routines (similar to the UNIX ones)
|
||||
osdep.h BeOS-specific includes and whatnot
|
||||
zipup.h Definitions for zip routines
|
||||
|
||||
This port supports both Metrowerks CodeWarrior and GNU C as the compiler,
|
||||
and PowerPC and x86 architectures.
|
||||
|
||||
- Chris Herborth (chrish@pobox.com)
|
||||
June 24, 1998
|
182
third_party/infozip/zip/beos/Makefile
vendored
Normal file
182
third_party/infozip/zip/beos/Makefile
vendored
Normal file
|
@ -0,0 +1,182 @@
|
|||
######################################################################
|
||||
#
|
||||
# Makefile for Info-ZIP's zip, zipcloak, zipnote, and zipsplit on BeOS
|
||||
#
|
||||
# Copyright © 1999 Info-ZIP
|
||||
# Chris Herborth (chrish@pobox.com)
|
||||
#
|
||||
# This is the new New and Improved Makefile for BeOS; it automatically
|
||||
# detects your platform and uses the appropriate compiler and compiler
|
||||
# flags.
|
||||
|
||||
######################################################################
|
||||
# Things that don't change:
|
||||
|
||||
# Punish people who don't have SMP hardware.
|
||||
MAKE = make -j 4 -f beos/Makefile
|
||||
SHELL = /bin/sh
|
||||
|
||||
LN = ln -s
|
||||
|
||||
BIND = $(CC)
|
||||
AS = $(CC) -c
|
||||
CPP = $(CC) -E
|
||||
|
||||
INSTALL = install
|
||||
|
||||
# Target directories
|
||||
prefix = /boot/home/config
|
||||
BINDIR = $(prefix)/bin
|
||||
manext = 1
|
||||
MANDIR = $(prefix)/man/man$(manext)
|
||||
ZIPMANUAL = MANUAL
|
||||
|
||||
VERSION = Version 2.3 of __DATE__
|
||||
|
||||
######################################################################
|
||||
# Things that change:
|
||||
|
||||
# PowerPC system
|
||||
ifeq "$(BE_HOST_CPU)" "ppc"
|
||||
|
||||
CC:=mwcc
|
||||
|
||||
ifeq "$(shell uname -r)" "4.0"
|
||||
|
||||
CFLAGS:=-O7 -opt schedule604 -rostr -w9 \
|
||||
-I. -DHAVE_DIRENT_H -DPASSWD_FROM_STDIN
|
||||
LFLAGS1:=-warn
|
||||
|
||||
else
|
||||
|
||||
CFLAGS:=-O7 -proc 604e -w9 -I. -DHAVE_DIRENT_H -DPASSWD_FROM_STDIN
|
||||
LFLAGS1:=-nodup
|
||||
|
||||
endif
|
||||
|
||||
LFLAGS2:=-L/boot/develop/lib/ppc -lbe -lroot
|
||||
OBJA =
|
||||
TARGET=$(ZIPS)
|
||||
|
||||
# x86 system
|
||||
else
|
||||
|
||||
CC:=gcc
|
||||
|
||||
# Removed -Wconversion and -Wshadow because of the unnecessary warnings
|
||||
# they generate. - Sept. 28, 1999
|
||||
CFLAGS:=-O3 -mpentiumpro \
|
||||
-Wall -Wno-multichar -Wno-ctor-dtor-privacy \
|
||||
-Wbad-function-cast -Woverloaded-virtual \
|
||||
-I. -I/boot/develop/headers/be/support \
|
||||
-I/boot/develop/headers/be/storage \
|
||||
-DHAVE_DIRENT_H -DPASSWD_FROM_STDIN # -DASMV
|
||||
LFLAGS1:=
|
||||
LFLAGS2:=-L/boot/develop/lib/x86 -lbe -lroot
|
||||
OBJA = #match.o
|
||||
TARGET=$(ZIPS)
|
||||
|
||||
endif
|
||||
|
||||
######################################################################
|
||||
# Helpful targets
|
||||
all:
|
||||
$(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" \
|
||||
LFLAGS1="$(LFLAGS1)" LFLAGS2="$(LFLAGS2)" \
|
||||
$(TARGET)
|
||||
|
||||
######################################################################
|
||||
# Object file lists and other build goodies
|
||||
|
||||
# Object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
|
||||
beos.o crc32.o
|
||||
OBJI = deflate.o trees.o
|
||||
# OBJA moved into ifeq block above; we'll use assembly for x86
|
||||
OBJU = zipfile_.o fileio_.o util_.o globals.o beos_.o
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
# Headers
|
||||
ZIP_H = zip.h ziperr.h tailor.h beos/osdep.h
|
||||
|
||||
# What to build?
|
||||
ZIPS = zip zipnote zipsplit zipcloak
|
||||
|
||||
# suffix rules
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: _.o .o .c .doc .1
|
||||
.c_.o:
|
||||
rm -f $*_.c; $(LN) $< $*_.c
|
||||
$(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
rm -f $*_.c
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
.1.doc:
|
||||
groff -man -Tascii $< > $@
|
||||
|
||||
# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
zipup.o: beos/zipup.h
|
||||
|
||||
match.o: match.S
|
||||
$(CPP) match.S > _match.s
|
||||
$(AS) _match.s
|
||||
mv -f _match.o match.o
|
||||
rm -f _match.s
|
||||
|
||||
beos.o: beos/beos.c
|
||||
$(CC) -c $(CFLAGS) beos/beos.c
|
||||
|
||||
beos_.o: beos/beos.c
|
||||
rm -f $*_.c; $(LN) beos/beos.c $*_.c
|
||||
$(CC) -c $(CFLAGS) -DUTIL $*_.c
|
||||
rm -f $*_.c
|
||||
|
||||
zips: $(ZIPS)
|
||||
zipsman: $(ZIPS) $(ZIPMANUAL)
|
||||
|
||||
zip: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(BIND) -o zip $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
|
||||
zipnote: $(OBJN)
|
||||
$(BIND) -o zipnote $(LFLAGS1) $(OBJN) $(LFLAGS2)
|
||||
zipcloak: $(OBJC)
|
||||
$(BIND) -o zipcloak $(LFLAGS1) $(OBJC) $(LFLAGS2)
|
||||
zipsplit: $(OBJS)
|
||||
$(BIND) -o zipsplit $(LFLAGS1) $(OBJS) $(LFLAGS2)
|
||||
|
||||
$(ZIPMANUAL): man/zip.1
|
||||
groff -man -Tascii man/zip.1 > $(ZIPMANUAL)
|
||||
|
||||
# install
|
||||
install: $(ZIPS)
|
||||
$(INSTALL) -m755 $(ZIPS) $(BINDIR)
|
||||
mkdir -p $(MANDIR)
|
||||
$(INSTALL) -m644 man/zip.1 $(MANDIR)/zip.$(manext)
|
||||
|
||||
uninstall:
|
||||
-cd $(BINDIR); rm -f $(ZIPS)
|
||||
-cd $(MANDIR); rm -f zip.$(manext)
|
||||
|
||||
dist: $(ZIPMANUAL)
|
||||
zip -u9T zip`sed -e '/VERSION/!d' -e 's/.*"\(.*\)".*/\1/' \
|
||||
-e s/[.]//g -e q revision.h` \
|
||||
`awk '/^Makefile/,/vms_zip.rnh/ {print $$1}' < contents`
|
||||
|
||||
# clean up after making stuff and installing it
|
||||
clean:
|
||||
rm -f *.o $(ZIPS) flags
|
||||
|
||||
# end of Makefile
|
31
third_party/infozip/zip/beos/README
vendored
Normal file
31
third_party/infozip/zip/beos/README
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
Info-ZIP's zip for BeOS
|
||||
|
||||
KNOWN BUGS
|
||||
|
||||
- None! (as of zip 2.21)
|
||||
|
||||
- building on x86 BeOS generates a hell of a lot of bugs; I'm not going to
|
||||
worry about them until Be fixes their headers though...
|
||||
|
||||
FEATURES
|
||||
|
||||
- stores BeOS file attributes, compressing them if possible (as of 2.21,
|
||||
this works properly for symbolic links, too; as of 2.3, this works
|
||||
properly for symbolic links whether you're storing them as links or not)
|
||||
|
||||
- zip files are created with the correct file type (application/zip)
|
||||
|
||||
- supports both Metrowerks CodeWarrior (PowerPC platform) and GNU C
|
||||
(x86 platform), automatically picking the default compiler for each
|
||||
architecture
|
||||
|
||||
Please report any bugs to the Zip-Bugs mailing list; our email address is
|
||||
zip-bugs@lists.wku.edu. If it's something BeOS-specific, you could email
|
||||
me directly.
|
||||
|
||||
Visit the Info-ZIP web site (http://www.cdrom.com/pub/infozip/) for all the
|
||||
latest zip and unzip information, FAQs, source code and ready-to-run
|
||||
executables.
|
||||
|
||||
- Chris Herborth (chrish@pobox.com)
|
||||
April 2/1999
|
945
third_party/infozip/zip/beos/beos.c
vendored
Normal file
945
third_party/infozip/zip/beos/beos.c
vendored
Normal file
|
@ -0,0 +1,945 @@
|
|||
/*
|
||||
Copyright (c) 1990-2002 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
|
||||
This BeOS-specific file is based on unix.c in the unix directory; changes
|
||||
by Chris Herborth (chrish@pobox.com).
|
||||
|
||||
*/
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include <kernel/fs_attr.h>
|
||||
#include <storage/Mime.h>
|
||||
#include <support/byteorder.h>
|
||||
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
/* Library functions not in (most) header files */
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
# include <utime.h>
|
||||
#else
|
||||
int utime OF((char *, time_t *));
|
||||
#endif
|
||||
|
||||
extern char *label;
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
/* Local functions */
|
||||
local char *readd OF((DIR *));
|
||||
local int get_attr_dir( const char *, char **, off_t * );
|
||||
local int add_UT_ef( struct zlist far * );
|
||||
local int add_Ux_ef( struct zlist far * );
|
||||
local int add_Be_ef( struct zlist far * );
|
||||
|
||||
|
||||
#ifdef NO_DIR /* for AT&T 3B1 */
|
||||
#include <sys/dir.h>
|
||||
#ifndef dirent
|
||||
# define dirent direct
|
||||
#endif
|
||||
typedef FILE DIR;
|
||||
/*
|
||||
** Apparently originally by Rich Salz.
|
||||
** Cleaned up and modified by James W. Birdsall.
|
||||
*/
|
||||
|
||||
#define opendir(path) fopen(path, "r")
|
||||
|
||||
struct dirent *readdir(dirp)
|
||||
DIR *dirp;
|
||||
{
|
||||
static struct dirent entry;
|
||||
|
||||
if (dirp == NULL)
|
||||
return NULL;
|
||||
for (;;)
|
||||
if (fread (&entry, sizeof (struct dirent), 1, dirp) == 0)
|
||||
return NULL;
|
||||
else if (entry.d_ino)
|
||||
return (&entry);
|
||||
} /* end of readdir() */
|
||||
|
||||
#define closedir(dirp) fclose(dirp)
|
||||
#endif /* NO_DIR */
|
||||
|
||||
|
||||
local char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (LSSTAT(n, &s))
|
||||
{
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if ((s.st_mode & S_IFDIR) == 0)
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '/')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t; /* shortened name */
|
||||
int dosflag;
|
||||
|
||||
dosflag = dosify; /* default for non-DOS and non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
for (t = x; *t == '/'; t++)
|
||||
; /* strip leading '/' chars to get a relative path */
|
||||
while (*t == '.' && t[1] == '/')
|
||||
t += 2; /* strip redundant leading "./" sections */
|
||||
|
||||
/* Make changes, if any, to the copied name (leave original intact) */
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
|
||||
if (isdir == 42) return n; /* avoid warning on unused variable */
|
||||
|
||||
if (dosify)
|
||||
msname(n);
|
||||
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strcpy(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX use ztimbuf in both POSIX and non POSIX cases ?
|
||||
*/
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
#ifdef _POSIX_VERSION
|
||||
struct utimbuf u; /* argument for utime() const ?? */
|
||||
#else
|
||||
time_t u[2]; /* argument for utime() */
|
||||
#endif
|
||||
|
||||
/* Convert DOS time to time_t format in u */
|
||||
#ifdef _POSIX_VERSION
|
||||
u.actime = u.modtime = dos2unixtime(d);
|
||||
utime(f, &u);
|
||||
#else
|
||||
u[0] = u[1] = dos2unixtime(d);
|
||||
utime(f, u);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
/* If file *f does not exist, return 0. Else, return the file's last
|
||||
modified date and time as an MSDOS date and time. The date and
|
||||
time is returned in a long with the date most significant to allow
|
||||
unsigned integer comparison of absolute times. Also, if a is not
|
||||
a NULL pointer, store the file attributes there, with the high two
|
||||
bytes being the Unix attributes, and the low byte being a mapping
|
||||
of that to DOS attributes. If n is not NULL, store the file size
|
||||
there. If t is not NULL, the file's access, modification and creation
|
||||
times are stored there as UNIX time_t values.
|
||||
If f is "-", use standard input as the file. If f is a device, return
|
||||
a file size of -1 */
|
||||
{
|
||||
struct stat s; /* results of stat() */
|
||||
/* convert FNAMX to malloc - 11/8/04 EG */
|
||||
char *name;
|
||||
int len = strlen(f);
|
||||
|
||||
if (f == label) {
|
||||
if (a != NULL)
|
||||
*a = label_mode;
|
||||
if (n != NULL)
|
||||
*n = -2L; /* convention for a label name */
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = label_utim;
|
||||
return label_time;
|
||||
}
|
||||
if ((name = malloc(len + 1)) == NULL) {
|
||||
ZIPERR(ZE_MEM, "filetime");
|
||||
}
|
||||
strcpy(name, f);
|
||||
if (name[len - 1] == '/')
|
||||
name[len - 1] = '\0';
|
||||
/* not all systems allow stat'ing a file with / appended */
|
||||
if (strcmp(f, "-") == 0) {
|
||||
if (fstat(fileno(stdin), &s) != 0) {
|
||||
free(name);
|
||||
error("fstat(stdin)");
|
||||
}
|
||||
} else if (LSSTAT(name, &s) != 0) {
|
||||
/* Accept about any file kind including directories
|
||||
* (stored with trailing / with -r option)
|
||||
*/
|
||||
free(name);
|
||||
return 0;
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (a != NULL) {
|
||||
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
|
||||
if ((s.st_mode & S_IFMT) == S_IFDIR) {
|
||||
*a |= MSDOS_DIR_ATTR;
|
||||
}
|
||||
}
|
||||
if (n != NULL)
|
||||
*n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
|
||||
if (t != NULL) {
|
||||
t->atime = s.st_atime;
|
||||
t->mtime = s.st_mtime;
|
||||
t->ctime = s.st_mtime; /* best guess (s.st_ctime: last status change!) */
|
||||
}
|
||||
|
||||
return unix2dostime(&s.st_mtime);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Return a malloc()'d buffer containing all of the attributes and their names
|
||||
for the file specified in name. You have to free() this yourself. The length
|
||||
of the buffer is also returned.
|
||||
|
||||
If get_attr_dir() fails, the buffer will be NULL, total_size will be 0,
|
||||
and an error will be returned:
|
||||
|
||||
EOK - no errors occurred
|
||||
EINVAL - attr_buff was pointing at a buffer
|
||||
ENOMEM - insufficient memory for attribute buffer
|
||||
|
||||
Other errors are possible (whatever is returned by the fs_attr.h functions).
|
||||
|
||||
PROBLEMS:
|
||||
|
||||
- pointers are 32-bits; attributes are limited to off_t in size so it's
|
||||
possible to overflow... in practice, this isn't too likely... your
|
||||
machine will thrash like hell before that happens
|
||||
|
||||
*/
|
||||
|
||||
#define INITIAL_BUFF_SIZE 65536
|
||||
|
||||
int get_attr_dir( const char *name, char **attr_buff, off_t *total_size )
|
||||
{
|
||||
int retval = EOK;
|
||||
int fd;
|
||||
DIR *fa_dir;
|
||||
struct dirent *fa_ent;
|
||||
off_t attrs_size;
|
||||
off_t this_size;
|
||||
char *ptr;
|
||||
struct attr_info fa_info;
|
||||
struct attr_info big_fa_info;
|
||||
|
||||
retval = EOK;
|
||||
attrs_size = 0; /* gcc still says this is used uninitialized... */
|
||||
*total_size = 0;
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Sanity-check. */
|
||||
if( *attr_buff != NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Can we open the file/directory? */
|
||||
/* */
|
||||
/* linkput is a zip global; it's set to 1 if we're storing symbolic */
|
||||
/* links as symbolic links (instead of storing the thing the link */
|
||||
/* points to)... if we're storing the symbolic link as a link, we'll */
|
||||
/* want the link's file attributes, otherwise we want the target's. */
|
||||
if( linkput ) {
|
||||
fd = open( name, O_RDONLY | O_NOTRAVERSE );
|
||||
} else {
|
||||
fd = open( name, O_RDONLY );
|
||||
}
|
||||
if( fd < 0 ) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Allocate an initial buffer; 64k should usually be enough. */
|
||||
*attr_buff = (char *)malloc( INITIAL_BUFF_SIZE );
|
||||
ptr = *attr_buff;
|
||||
if( ptr == NULL ) {
|
||||
close( fd );
|
||||
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Open the attributes directory for this file. */
|
||||
fa_dir = fs_fopen_attr_dir( fd );
|
||||
if( fa_dir == NULL ) {
|
||||
close( fd );
|
||||
|
||||
free( ptr );
|
||||
*attr_buff = NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Read all the attributes; the buffer could grow > 64K if there are */
|
||||
/* many and/or they are large. */
|
||||
fa_ent = fs_read_attr_dir( fa_dir );
|
||||
while( fa_ent != NULL ) {
|
||||
retval = fs_stat_attr( fd, fa_ent->d_name, &fa_info );
|
||||
/* TODO: check retval != EOK */
|
||||
|
||||
this_size = strlen( fa_ent->d_name ) + 1;
|
||||
this_size += sizeof( struct attr_info );
|
||||
this_size += fa_info.size;
|
||||
|
||||
attrs_size += this_size;
|
||||
|
||||
if( attrs_size > INITIAL_BUFF_SIZE ) {
|
||||
unsigned long offset = ptr - *attr_buff;
|
||||
|
||||
*attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
if( *attr_buff == NULL ) {
|
||||
retval = fs_close_attr_dir( fa_dir );
|
||||
/* TODO: check retval != EOK */
|
||||
close( fd );
|
||||
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ptr = *attr_buff + offset;
|
||||
}
|
||||
|
||||
/* Now copy the data for this attribute into the buffer. */
|
||||
strcpy( ptr, fa_ent->d_name );
|
||||
ptr += strlen( fa_ent->d_name );
|
||||
*ptr++ = '\0';
|
||||
|
||||
/* We need to put a big-endian version of the fa_info data into */
|
||||
/* the archive. */
|
||||
big_fa_info.type = B_HOST_TO_BENDIAN_INT32( fa_info.type );
|
||||
big_fa_info.size = B_HOST_TO_BENDIAN_INT64( fa_info.size );
|
||||
memcpy( ptr, &big_fa_info, sizeof( struct attr_info ) );
|
||||
ptr += sizeof( struct attr_info );
|
||||
|
||||
if( fa_info.size > 0 ) {
|
||||
ssize_t read_bytes;
|
||||
|
||||
read_bytes = fs_read_attr( fd, fa_ent->d_name, fa_info.type, 0,
|
||||
ptr, fa_info.size );
|
||||
if( read_bytes != fa_info.size ) {
|
||||
/* print a warning about mismatched sizes */
|
||||
char buff[80];
|
||||
|
||||
sprintf( buff, "read %ld, expected %ld",
|
||||
(ssize_t)read_bytes, (ssize_t)fa_info.size );
|
||||
zipwarn( "attribute size mismatch: ", buff );
|
||||
}
|
||||
|
||||
/* Wave my magic wand... this swaps all the Be types to big- */
|
||||
/* endian automagically. */
|
||||
(void)swap_data( fa_info.type, ptr, fa_info.size,
|
||||
B_SWAP_HOST_TO_BENDIAN );
|
||||
|
||||
ptr += fa_info.size;
|
||||
}
|
||||
|
||||
fa_ent = fs_read_attr_dir( fa_dir );
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Close the attribute directory. */
|
||||
retval = fs_close_attr_dir( fa_dir );
|
||||
/* TODO: check retval != EOK */
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* If the buffer is too big, shrink it. */
|
||||
if( attrs_size < INITIAL_BUFF_SIZE ) {
|
||||
*attr_buff = (char *)realloc( *attr_buff, attrs_size );
|
||||
if( *attr_buff == NULL ) {
|
||||
/* This really shouldn't happen... */
|
||||
close( fd );
|
||||
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
*total_size = attrs_size;
|
||||
|
||||
close( fd );
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'UT' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(2))
|
||||
#define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1))
|
||||
|
||||
local int add_UT_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
struct stat s;
|
||||
|
||||
#ifdef IZ_CHECK_TZ
|
||||
if (!zp_tz_is_valid)
|
||||
return ZE_OK; /* skip silently if no valid TZ info */
|
||||
#endif
|
||||
|
||||
/* We can't work if there's no entry to work on. */
|
||||
if( z == NULL ) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_UT_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_UT_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* stat() the file (or the symlink) to get the data; if we can't get */
|
||||
/* the data, there's no point in trying to fill out the fields. */
|
||||
if(LSSTAT( z->name, &s ) ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_UT_SIZE );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_UT_SIZE );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_UT_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_UT_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'U';
|
||||
*l_ef++ = 'T';
|
||||
*l_ef++ = (char)(EB_UT_LEN(2)); /* length of data in local EF */
|
||||
*l_ef++ = (char)0;
|
||||
*l_ef++ = (char)(EB_UT_FL_MTIME | EB_UT_FL_ATIME);
|
||||
*l_ef++ = (char)(s.st_mtime);
|
||||
*l_ef++ = (char)(s.st_mtime >> 8);
|
||||
*l_ef++ = (char)(s.st_mtime >> 16);
|
||||
*l_ef++ = (char)(s.st_mtime >> 24);
|
||||
*l_ef++ = (char)(s.st_atime);
|
||||
*l_ef++ = (char)(s.st_atime >> 8);
|
||||
*l_ef++ = (char)(s.st_atime >> 16);
|
||||
*l_ef++ = (char)(s.st_atime >> 24);
|
||||
|
||||
z->ext += EB_L_UT_SIZE;
|
||||
|
||||
/* Now add the central version. */
|
||||
memcpy(c_ef, l_ef-EB_L_UT_SIZE, EB_C_UT_SIZE);
|
||||
c_ef[EB_LEN] = (char)(EB_UT_LEN(1)); /* length of data in central EF */
|
||||
|
||||
z->cext += EB_C_UT_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'Ux' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_UX2_SIZE (EB_HEADSIZE + EB_UX2_MINLEN)
|
||||
#define EB_C_UX2_SIZE (EB_HEADSIZE)
|
||||
|
||||
local int add_Ux_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
struct stat s;
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_UX2_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_UX2_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* stat() the file (or the symlink) to get the data; if we can't get */
|
||||
/* the data, there's no point in trying to fill out the fields. */
|
||||
if(LSSTAT( z->name, &s ) ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_UX2_SIZE );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_UX2_SIZE );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_UX2_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_UX2_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'U';
|
||||
*l_ef++ = 'x';
|
||||
*l_ef++ = (char)(EB_UX2_MINLEN);
|
||||
*l_ef++ = (char)(EB_UX2_MINLEN >> 8);
|
||||
*l_ef++ = (char)(s.st_uid);
|
||||
*l_ef++ = (char)(s.st_uid >> 8);
|
||||
*l_ef++ = (char)(s.st_gid);
|
||||
*l_ef++ = (char)(s.st_gid >> 8);
|
||||
|
||||
z->ext += EB_L_UX2_SIZE;
|
||||
|
||||
/* Now add the central version of the field. */
|
||||
*c_ef++ = 'U';
|
||||
*c_ef++ = 'x';
|
||||
*c_ef++ = 0;
|
||||
*c_ef++ = 0;
|
||||
|
||||
z->cext += EB_C_UX2_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Add a 'Be' extra field to the zlist data pointed to by z. */
|
||||
|
||||
#define EB_L_BE_SIZE (EB_HEADSIZE + EB_L_BE_LEN) /* + attr size */
|
||||
#define EB_C_BE_SIZE (EB_HEADSIZE + EB_C_BE_LEN)
|
||||
|
||||
/* maximum memcompress overhead is the sum of the compression header length */
|
||||
/* (6 = ush compression type, ulg CRC) and the worstcase deflate overhead */
|
||||
/* when uncompressible data are kept in 2 "stored" blocks (5 per block = */
|
||||
/* byte blocktype + 2 * ush blocklength) */
|
||||
#define MEMCOMPRESS_OVERHEAD (EB_MEMCMPR_HSIZ + EB_DEFLAT_EXTRA)
|
||||
|
||||
local int add_Be_ef( struct zlist far *z )
|
||||
{
|
||||
char *l_ef = NULL;
|
||||
char *c_ef = NULL;
|
||||
char *attrbuff = NULL;
|
||||
off_t attrsize = 0;
|
||||
char *compbuff = NULL;
|
||||
ush compsize = 0;
|
||||
uch flags = 0;
|
||||
|
||||
/* Check to make sure we've got enough room in the extra fields. */
|
||||
if( z->ext + EB_L_BE_SIZE > USHRT_MAX ||
|
||||
z->cext + EB_C_BE_SIZE > USHRT_MAX ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
|
||||
/* Attempt to load up a buffer full of the file's attributes. */
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = get_attr_dir( z->name, &attrbuff, &attrsize );
|
||||
if( retval != EOK ) {
|
||||
return ZE_OPEN;
|
||||
}
|
||||
if( attrsize == 0 ) {
|
||||
return ZE_OK;
|
||||
}
|
||||
if( attrbuff == NULL ) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
/* Check for way too much data. */
|
||||
if( attrsize > (off_t)ULONG_MAX ) {
|
||||
zipwarn( "uncompressed attributes truncated", "" );
|
||||
attrsize = (off_t)(ULONG_MAX - MEMCOMPRESS_OVERHEAD);
|
||||
}
|
||||
}
|
||||
|
||||
if( verbose ) {
|
||||
printf( "\t[in=%lu]", (unsigned long)attrsize );
|
||||
}
|
||||
|
||||
/* Try compressing the data */
|
||||
compbuff = (char *)malloc( (size_t)attrsize + MEMCOMPRESS_OVERHEAD );
|
||||
if( compbuff == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
compsize = memcompress( compbuff,
|
||||
(size_t)attrsize + MEMCOMPRESS_OVERHEAD,
|
||||
attrbuff,
|
||||
(size_t)attrsize );
|
||||
if( verbose ) {
|
||||
printf( " [out=%u]", compsize );
|
||||
}
|
||||
|
||||
/* Attempt to optimise very small attributes. */
|
||||
if( compsize > attrsize ) {
|
||||
free( compbuff );
|
||||
compsize = (ush)attrsize;
|
||||
compbuff = attrbuff;
|
||||
|
||||
flags = EB_BE_FL_NATURAL;
|
||||
}
|
||||
|
||||
/* Check to see if we really have enough room in the EF for the data. */
|
||||
if( ( z->ext + compsize + EB_L_BE_LEN ) > USHRT_MAX ) {
|
||||
compsize = USHRT_MAX - EB_L_BE_LEN - z->ext;
|
||||
}
|
||||
|
||||
/* Allocate memory for the local and central extra fields. */
|
||||
if( z->extra && z->ext != 0 ) {
|
||||
l_ef = (char *)realloc( z->extra, z->ext + EB_L_BE_SIZE + compsize );
|
||||
} else {
|
||||
l_ef = (char *)malloc( EB_L_BE_SIZE + compsize );
|
||||
z->ext = 0;
|
||||
}
|
||||
if( l_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->extra = l_ef;
|
||||
l_ef += z->ext;
|
||||
|
||||
if( z->cextra && z->cext != 0 ) {
|
||||
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_BE_SIZE );
|
||||
} else {
|
||||
c_ef = (char *)malloc( EB_C_BE_SIZE );
|
||||
z->cext = 0;
|
||||
}
|
||||
if( c_ef == NULL ) {
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cextra = c_ef;
|
||||
c_ef += z->cext;
|
||||
|
||||
/* Now add the local version of the field. */
|
||||
*l_ef++ = 'B';
|
||||
*l_ef++ = 'e';
|
||||
*l_ef++ = (char)(compsize + EB_L_BE_LEN);
|
||||
*l_ef++ = (char)((compsize + EB_L_BE_LEN) >> 8);
|
||||
*l_ef++ = (char)((unsigned long)attrsize);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 8);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 16);
|
||||
*l_ef++ = (char)((unsigned long)attrsize >> 24);
|
||||
*l_ef++ = flags;
|
||||
memcpy( l_ef, compbuff, (size_t)compsize );
|
||||
|
||||
z->ext += EB_L_BE_SIZE + compsize;
|
||||
|
||||
/* And the central version. */
|
||||
*c_ef++ = 'B';
|
||||
*c_ef++ = 'e';
|
||||
*c_ef++ = (char)(EB_C_BE_LEN);
|
||||
*c_ef++ = (char)(EB_C_BE_LEN >> 8);
|
||||
*c_ef++ = (char)compsize;
|
||||
*c_ef++ = (char)(compsize >> 8);
|
||||
*c_ef++ = (char)(compsize >> 16);
|
||||
*c_ef++ = (char)(compsize >> 24);
|
||||
*c_ef++ = flags;
|
||||
|
||||
z->cext += EB_C_BE_SIZE;
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* Extra field info:
|
||||
- 'UT' - UNIX time extra field
|
||||
- 'Ux' - UNIX uid/gid extra field
|
||||
- 'Be' - BeOS file attributes extra field
|
||||
|
||||
This is done the same way ../unix/unix.c stores the 'UT'/'Ux' fields
|
||||
(full data in local header, only modification time in central header),
|
||||
with the 'Be' field added to the end and the size of the 'Be' field
|
||||
in the central header.
|
||||
|
||||
See the end of beos/osdep.h for a simple explanation of the 'Be' EF
|
||||
layout.
|
||||
*/
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* store full data in local header but just modification time stamp info
|
||||
in central header */
|
||||
{
|
||||
int retval;
|
||||
|
||||
/* Tell picky compilers to shut up about unused variables. */
|
||||
z_utim = z_utim;
|
||||
|
||||
/* Check to make sure z is valid. */
|
||||
if( z == NULL ) {
|
||||
return ZE_LOGIC;
|
||||
}
|
||||
|
||||
/* This function is much simpler now that I've moved the extra fields */
|
||||
/* out... it simplified the 'Be' code, too. */
|
||||
retval = add_UT_ef( z );
|
||||
if( retval != ZE_OK ) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = add_Ux_ef( z );
|
||||
if( retval != ZE_OK ) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = add_Be_ef( z );
|
||||
if( retval != ZE_OK ) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Set a file's MIME type. */
|
||||
void setfiletype( const char *file, const char *type )
|
||||
{
|
||||
int fd;
|
||||
attr_info fa;
|
||||
ssize_t wrote_bytes;
|
||||
|
||||
fd = open( file, O_RDWR );
|
||||
if( fd < 0 ) {
|
||||
zipwarn( "can't open zipfile to write file type", "" );
|
||||
return;
|
||||
}
|
||||
|
||||
fa.type = B_MIME_STRING_TYPE;
|
||||
fa.size = (off_t)(strlen( type ) + 1);
|
||||
|
||||
wrote_bytes = fs_write_attr( fd, BE_FILE_TYPE_NAME, fa.type, 0,
|
||||
type, fa.size );
|
||||
if( wrote_bytes != (ssize_t)fa.size ) {
|
||||
zipwarn( "couldn't write complete file type", "" );
|
||||
}
|
||||
|
||||
close( fd );
|
||||
}
|
||||
|
||||
int deletedir(d)
|
||||
char *d; /* directory to delete */
|
||||
/* Delete the directory *d if it is empty, do nothing otherwise.
|
||||
Return the result of rmdir(), delete(), or system().
|
||||
For VMS, d must be in format [x.y]z.dir;1 (not [x.y.z]).
|
||||
*/
|
||||
{
|
||||
# ifdef NO_RMDIR
|
||||
/* code from Greg Roelofs, who horked it from Mark Edwards (unzip) */
|
||||
int r, len;
|
||||
char *s; /* malloc'd string for system command */
|
||||
|
||||
len = strlen(d);
|
||||
if ((s = malloc(len + 34)) == NULL)
|
||||
return 127;
|
||||
|
||||
sprintf(s, "IFS=\" \t\n\" /bin/rmdir %s 2>/dev/null", d);
|
||||
r = system(s);
|
||||
free(s);
|
||||
return r;
|
||||
# else /* !NO_RMDIR */
|
||||
return rmdir(d);
|
||||
# endif /* ?NO_RMDIR */
|
||||
}
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
void version_local()
|
||||
{
|
||||
static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
|
||||
|
||||
printf(CompiledWith,
|
||||
|
||||
#ifdef __MWERKS__
|
||||
"Metrowerks CodeWarrior", "",
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
"gcc ", __VERSION__,
|
||||
# endif
|
||||
#endif
|
||||
|
||||
"BeOS",
|
||||
|
||||
#ifdef __POWERPC__
|
||||
" (PowerPC)",
|
||||
#else
|
||||
# ifdef __INTEL__
|
||||
" (x86)",
|
||||
# else
|
||||
" (UNKNOWN!)",
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __DATE__
|
||||
" on ", __DATE__
|
||||
#else
|
||||
"", ""
|
||||
#endif
|
||||
);
|
||||
|
||||
} /* end function version_local() */
|
59
third_party/infozip/zip/beos/osdep.h
vendored
Normal file
59
third_party/infozip/zip/beos/osdep.h
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <support/Errors.h> /* for B_NO_ERROR */
|
||||
|
||||
#define USE_EF_UT_TIME /* Enable use of "UT" extra field time info */
|
||||
|
||||
#define EB_L_BE_LEN 5 /* min size is an unsigned long and flag */
|
||||
#define EB_C_BE_LEN 5 /* Length of data in local EF and flag. */
|
||||
|
||||
#define EB_BE_FL_NATURAL 0x01 /* data is 'natural' (not compressed) */
|
||||
#define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */
|
||||
|
||||
#ifndef ZP_NEED_MEMCOMPR
|
||||
# define ZP_NEED_MEMCOMPR
|
||||
#endif
|
||||
|
||||
/* Set a file's MIME type. */
|
||||
#define BE_FILE_TYPE_NAME "BEOS:TYPE"
|
||||
void setfiletype( const char *file, const char *type );
|
||||
|
||||
/*
|
||||
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 (big-endian)
|
||||
attr_data (length in attr_info.size)
|
||||
*/
|
19
third_party/infozip/zip/beos/zipup.h
vendored
Normal file
19
third_party/infozip/zip/beos/zipup.h
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#ifndef O_RDONLY
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#define fhow O_RDONLY
|
||||
#define fbad (-1)
|
||||
typedef int ftype;
|
||||
#define zopen(n,p) open(n,p)
|
||||
#define zread(f,b,n) read(f,b,n)
|
||||
#define zclose(f) close(f)
|
||||
#define zerr(f) (k == (extent)(-1L))
|
||||
#define zstdin 0
|
258
third_party/infozip/zip/bzip2/install.txt
vendored
Normal file
258
third_party/infozip/zip/bzip2/install.txt
vendored
Normal file
|
@ -0,0 +1,258 @@
|
|||
HOW TO ADD BZIP2 SUPPORT TO ZIP
|
||||
|
||||
This document describes how to add bzip2 support to Zip.
|
||||
|
||||
Compiling or linking in the bzip2 library adds an additional bzip2
|
||||
compression method to Zip. This new method can be selected instead
|
||||
of the Zip traditional compression method deflation to compress files
|
||||
and often gives a better compression ratio (perhaps at the cost of
|
||||
greater CPU time). The compression method is specified using the
|
||||
"-Z method" command-line option, where "method" may be either "deflate"
|
||||
(the default), or "bzip2" (if Zip is built with bzip2 support). Zip
|
||||
has been tested with bzip2 library 1.0.5 and earlier.
|
||||
|
||||
Notes
|
||||
|
||||
Compression method bzip2 requires a modern unzip. Before using bzip2
|
||||
compression in Zip, verify that a modern UnZip program with bzip2 support
|
||||
will be used to read the resulting zip archive so that entries compressed
|
||||
with bzip2 (compression method 12) can be read. Older unzips probably
|
||||
won't recognize the compression method and will skip those entries.
|
||||
|
||||
The Zip source kit does not include the bzip2 library or source files, but
|
||||
these can be found at "http://www.bzip.org/" for example. See below for
|
||||
how to add bzip2 to Zip for various operating systems.
|
||||
|
||||
Zip using bzip2 compression is not compatible with the bzip2 application,
|
||||
but instead provides an additional way to compress files before adding
|
||||
them to a Zip archive. It does not replace the bzip2 program itself,
|
||||
which creates bzip2 archives in a different format that are not
|
||||
compatible with zip or unzip.
|
||||
|
||||
The bzip2 code and algorithms are provided under the bzip2 license
|
||||
(provided in the bzip2 source kit) and what is not covered by that license
|
||||
is covered under the Info-ZIP license. Info-ZIP will look at issues
|
||||
involving the use of bzip2 compression in Zip, but any questions about
|
||||
the bzip2 code and algorithms or bzip2 licensing, for example, should be
|
||||
directed to the bzip2 maintainer.
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
To build Zip with bzip2 support, Zip generally needs one bzip2 header
|
||||
file, "bzlib.h", and the object library, typically "libbz2.a", except
|
||||
in cases where the source files are compiled in directly. If you
|
||||
are either compiling the bzip2 library or compiling in the bzip2
|
||||
source files, we recommend defining the C macro BZ_NO_STDIO, which
|
||||
excludes a lot of standalone error code (not used when bzip2 is
|
||||
used as a library and makes the library smaller) and provides hooks
|
||||
that Zip can use to provide better error handling. However, a
|
||||
standard bzip2 object library will work, though any errors that bzip2
|
||||
generates may be more cryptic.
|
||||
|
||||
Building the bzip2 library from the bzip2 source files (recommended):
|
||||
|
||||
Download the latest bzip2 package (from "http://www.bzip.org/", for
|
||||
example).
|
||||
|
||||
Unpack the bzip2 source kit (bzip2-1.0.5.tar.gz was current as of
|
||||
this writing, but the latest should work).
|
||||
|
||||
Read the README file in the bzip2 source kit.
|
||||
|
||||
Compile the bzip2 library for your OS, preferably defining
|
||||
BZ_NO_STDIO. Note: On UNIX systems, this may be done automatically
|
||||
when building Zip, as explained below.
|
||||
|
||||
|
||||
Installation on UNIX (see below for installation on other systems):
|
||||
|
||||
Note: Zip on UNIX uses the "bzlib.h" include file and the compiled
|
||||
"libbz2.a" library to static link to bzip2. Currently we do not
|
||||
support using the shared library (patches welcome).
|
||||
|
||||
The easiest approach may be to drop the two above files in the
|
||||
bzip2 directory of the Zip source tree and build Zip using the
|
||||
"generic" target, that is, using a command like
|
||||
make -f unix/Makefile generic
|
||||
If all goes well, make should confirm that it found the files and
|
||||
will be compiling in bzip2 by setting the BZIP2_SUPPORT flag and
|
||||
then including the libraries while compiling and linking Zip.
|
||||
|
||||
To use bzlib.h and libbz2.a from somewhere else on your system,
|
||||
define the "make" macro IZ_BZIP2 to point to that directory. For
|
||||
example:
|
||||
make -f unix/Makefile generic IZ_BZIP2=/mybz2
|
||||
where /mybz2 might be "/usr/local/src/bzip2/bzip2-1.0.5" on some
|
||||
systems. Only a compiled bzip2 library can be pointed to using
|
||||
IZ_BZIP2 and Zip will not compile bzip2 source in other than the
|
||||
bzip2 directory.
|
||||
|
||||
If IZ_BZIP2 is not defined, Zip will look for the bzip2 files in
|
||||
the "bzip2" directory in the Zip source directory. The bzip2
|
||||
directory is empty in the Zip source distribution (except for
|
||||
this install.txt file) and is provided as a place to put the
|
||||
bzip2 files. To use this directory, either drop bzlib.h and
|
||||
libbz2.a in it to use the compiled library as noted above or drop
|
||||
the contents of the bzip2 source kit in this directory so that
|
||||
bzlib.h is directly in the bzip2 directory and Zip will try to
|
||||
compile it if no compiled library is already there.
|
||||
|
||||
|
||||
Unpacking bzip2 so Zip compiles it:
|
||||
|
||||
To make this work, the bzip2 source kit must be unpacked directly
|
||||
into the Zip "bzip2" directory. For example:
|
||||
|
||||
# Unpack the Zip source kit.
|
||||
gzip -cd zip30.tar-gz | tar xfo -
|
||||
# Move down to the Zip kit's "bzip2" directory, ...
|
||||
cd zip30/bzip2
|
||||
# ... and unpack the bzip2 source kit there.
|
||||
gzip -cd ../../bzip2-1.0.5.tar.gz | tar xfo -
|
||||
# Move the bzip2 source files up to the Zip kit's bzip2 directory.
|
||||
cd bzip2-1.0.5
|
||||
mv * ..
|
||||
# Return to the Zip source kit directory, ready to build.
|
||||
cd ../..
|
||||
# Build Zip.
|
||||
make -f unix/Makefile generic
|
||||
|
||||
|
||||
Using a system bzip2 library:
|
||||
|
||||
If IZ_BZIP2 is not defined and both a compiled library and the bzip2
|
||||
source files are missing from the Zip bzip2 directory, Zip will test
|
||||
to see if bzip2 is globally defined on the system in the default
|
||||
include and library paths and, if found, link in the system bzip2
|
||||
library. This is automatic.
|
||||
|
||||
|
||||
Preventing inclusion of bzip2:
|
||||
|
||||
To build Zip with _no_ bzip2 support on a system where the automatic
|
||||
bzip2 detection scheme will find bzip2, you can specify a bad
|
||||
IZ_BZIP2 directory. For example:
|
||||
|
||||
make -f unix/Makefile generic IZ_BZIP2=no_such_directory
|
||||
|
||||
You can also define NO_BZIP2_SUPPORT to exclude bzip2.
|
||||
|
||||
|
||||
Verifying bzip2 support in Zip:
|
||||
|
||||
When the Zip build is complete, verify that bzip2 support has been
|
||||
enabled by checking the feature list:
|
||||
|
||||
./zip -v
|
||||
|
||||
If all went well, bzip2 (and its library version) should be listed.
|
||||
|
||||
|
||||
Installation on other systems
|
||||
|
||||
MSDOS:
|
||||
|
||||
Thanks to Robert Riebisch, the DJGPP 2.x Zip port now supports bzip2.
|
||||
To include bzip2, first install bzip2. The new msdos/makebz2.dj2
|
||||
makefile then looks in the standard bzip2 installation directories
|
||||
for the needed files. As he says:
|
||||
It doesn't try to be clever about finding libbz2.a. It just
|
||||
expects bzip2 stuff installed to the default include and library
|
||||
folders, e.g., "C:\DJGPP\include" and "C:\DJGPP\lib" on DOS.
|
||||
|
||||
Given a standard DJGPP 2.x installation, this should create a
|
||||
version of Zip 3.0 with bzip2 support.
|
||||
|
||||
The bzip2 library for DJGPP can be found on any DJGPP mirror in
|
||||
"current/v2apps" (or "beta/v2apps/" for the latest beta). This
|
||||
library has been ported to MSDOS/DJGPP by Juan Manuel Guerrero.
|
||||
|
||||
|
||||
WIN32 (Windows NT/2K/XP/2K3/... and Windows 95/98/ME):
|
||||
|
||||
For Windows there seems to be two approaches, either use bzip2
|
||||
as a dynamic link library or compile the bzip2 source in directly.
|
||||
I have not gotten the static library libbz2.lib to work, but that
|
||||
may be me.
|
||||
|
||||
Using bzip2 as a dynamic link library:
|
||||
|
||||
Building bzip2:
|
||||
|
||||
If you have the needed bzlib.h, libbz2.lib, and libbz2.dll files
|
||||
you can skip building bzip2. If not, open the libbz2.dsp project
|
||||
and build libbz2.dll
|
||||
|
||||
This creates
|
||||
debug/libbz2.lib
|
||||
and
|
||||
libbz2.dll
|
||||
|
||||
|
||||
Building Zip:
|
||||
|
||||
Copy libbz2.lib to the bzip2 directory in the Zip source tree. This
|
||||
is needed to compile Zip with bzip2 support. Also copy the matching
|
||||
bzlib.h from the bzip2 source to the same directory.
|
||||
|
||||
Add libbz2.lib to the link list for whatever you are building. Also
|
||||
define the compiler define BZIP2_SUPPORT.
|
||||
|
||||
Build Zip.
|
||||
|
||||
|
||||
Using Zip with bzip2 as dll:
|
||||
|
||||
Put libbz2.dll in your command path. This is needed to run Zip with
|
||||
bzip2 support.
|
||||
|
||||
Verify that bzip2 is enabled with the command
|
||||
|
||||
zip -v
|
||||
|
||||
You should see bzip2 listed.
|
||||
|
||||
Compiling in bzip2 from the bzip2 source:
|
||||
|
||||
This approach compiles in the bzip2 code directly. No external
|
||||
library is needed.
|
||||
|
||||
Get a copy of the bzip2 source and copy the contents to the bzip2
|
||||
directory in the Zip source tree so that bzlib.h is directly in
|
||||
the bzip2 directory.
|
||||
|
||||
Use the vc6bz2 project to build Zip. This project knows of the
|
||||
added bzip2 files.
|
||||
|
||||
Verify that bzip2 is enabled with the command
|
||||
|
||||
zip -v
|
||||
|
||||
|
||||
Windows DLL (WIN32):
|
||||
|
||||
Nothing yet.
|
||||
|
||||
|
||||
Mac OS X:
|
||||
|
||||
Follow the standard UNIX build procedure. Mac OS X includes bzip2
|
||||
and the UNIX builders should find the bzip2 files in the standard
|
||||
places. Note that the version of bzip2 on your OS may not be
|
||||
current and you can instead specify a different library or compile
|
||||
your own bzip2 library as noted in the Unix procedures above.
|
||||
|
||||
|
||||
OS/2:
|
||||
|
||||
Nothing yet.
|
||||
|
||||
|
||||
VMS (OpenVMS):
|
||||
|
||||
See [.vms]install_vms.txt for how to enable bzip2 support on VMS.
|
||||
|
||||
|
||||
Last updated 26 March 2007, 15 July 2007, 9 April 2008, 27 June 2008
|
||||
S. Schweda, E. Gordon
|
434
third_party/infozip/zip/cmsmvs/README.CMS
vendored
Normal file
434
third_party/infozip/zip/cmsmvs/README.CMS
vendored
Normal file
|
@ -0,0 +1,434 @@
|
|||
Using ZIP and UNZIP on VM/CMS
|
||||
=============================
|
||||
|
||||
|
||||
Installing executables
|
||||
----------------------
|
||||
|
||||
The following CMS MODULEs are available:
|
||||
ZIP
|
||||
ZIPNOTE
|
||||
ZIPCLOAK
|
||||
ZIPSPLIT
|
||||
UNZIP
|
||||
|
||||
In addition to these, each MODULE file also has an EXEC with the same
|
||||
name. These EXECs are front-ends to the MODULES that will attempt to
|
||||
set up the required runtime libraries before running the MODULE.
|
||||
All the EXECs are identical. Only their names are different.
|
||||
They are stored as plain text files.
|
||||
|
||||
The CMS MODULE files have been packed using the COPYFILE command to
|
||||
allow their file format to be properly restored, since variable length
|
||||
binary files will not currently unzip properly (see below for details).
|
||||
The MODULEs are shipped with a filetype or extension of CMO (for CMS
|
||||
MODULE). Their names may vary on the distribution disk to indicate
|
||||
their level, etc.
|
||||
|
||||
To restore them to executable MODULEs on CMS, do the following:
|
||||
1. Upload them to CMS with a Fixed record length with LRECL 1024.
|
||||
Example, from a DOS or OS/2 window, type this:
|
||||
SEND unzip.cmo A:unzip module a (RECFM F LRECL 1024
|
||||
|
||||
Example, using FTP from CMS, type this:
|
||||
BINARY FIXED 1024
|
||||
GET unzip.cmo unzip.module.a
|
||||
|
||||
Note: Replace "unzip.cmo" with the actual name.
|
||||
|
||||
2. Use COPYFILE to unpack the file.
|
||||
Example, in CMS type this:
|
||||
COPYFILE UNZIP MODULE A (UNPACK REPLACE OLDDATE
|
||||
|
||||
3. Repeat steps 1-2 for each of the programs.
|
||||
|
||||
4. Build the ZIPINFO module by typing this:
|
||||
COPYFILE UNZIP MODULE A ZIPINFO MODULE A (OLDDATE
|
||||
|
||||
5. Upload the EXECs to CMS as text files (with ASCII-to-EBCDIC
|
||||
translation).
|
||||
Example, from a DOS or OS/2 window, type this:
|
||||
SEND unzip.exc A:unzip exec a (CRLF
|
||||
|
||||
Example, using FTP from CMS, type this:
|
||||
GET unzip.exc unzip.exec.a
|
||||
|
||||
6. Repeat steps 4 for each of the EXECs.
|
||||
|
||||
|
||||
Preparing the environment
|
||||
-------------------------
|
||||
|
||||
The executables provided were compiled with IBM C 3.1.0 and
|
||||
require the the Language Environment (LE) runtime libraries.
|
||||
|
||||
To provide access to the runtime libraries:
|
||||
1. Link to the disk containing the Language Environment files,
|
||||
if necessary.
|
||||
|
||||
2. Use the command "GLOBAL LOADLIB SCEERUN"
|
||||
|
||||
These commands can be placed in your PROFILE EXEC.
|
||||
|
||||
Note: EXECs have been provided called ZIP, UNZIP, etc. that
|
||||
issue the GLOBAL LOADLIB statement. This was done to alleviate
|
||||
frustration of users that don't have the GLOBAL LOADLIB statement
|
||||
in their PROFILE EXEC. These EXECs may require changing for
|
||||
your system.
|
||||
|
||||
Unfortunately, there is no way, using IBM C, to produce a MODULE
|
||||
that doesn't require a runtime library.
|
||||
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
To test the MODULEs, just type ZIP or UNZIP. They should
|
||||
show help information on using the commands.
|
||||
|
||||
If you see something like this:
|
||||
DMSLIO201W The following names are undefined:
|
||||
CEEEV003
|
||||
DMSABE155T User abend 4093 called from 00DCD298 reason code 000003EB
|
||||
|
||||
Then you don't have access to the proper runtime libraries, as
|
||||
described above.
|
||||
|
||||
Here is additional information on the ZIP and UNZIP programs that
|
||||
may assist support personnel:
|
||||
- Compiled with IBM C V3R1M0 on VM/ESA 2.2.0 with
|
||||
CMS level 13 Service Level 702.
|
||||
|
||||
- Require the SCEERUN LOADLIB runtime library. This is
|
||||
part of the Language Environment (LE).
|
||||
|
||||
- Linked with options RMODE ANY AMODE ANY RLDSAVE.
|
||||
|
||||
If you continue to have trouble, report the problem to Zip-Bugs
|
||||
(see the bottom of this document).
|
||||
|
||||
|
||||
|
||||
Compiling the source on VM/CMS
|
||||
------------------------------
|
||||
|
||||
The source has been successfully compiled previously using
|
||||
C/370 2.1 and 2.2. The source has been recently compiled using
|
||||
IBM C 3.1.0 on VM/ESA 2.2.0 with CMS level 13. I don't have
|
||||
access to an MVS system so the code hasn't been tested there
|
||||
in a while.
|
||||
|
||||
1. Unzip the source files required for CMS. The root-level files
|
||||
inside the ZIP file and the files in the CMSMVS subdirectory are
|
||||
needed. Example (use both commands):
|
||||
unzip -aj zip23.zip -x */* -dc
|
||||
unzip -aj zip23.zip cmsmvs/* -dc
|
||||
|
||||
This example unzips the files to the C-disk, while translating
|
||||
character data and ignoring paths.
|
||||
|
||||
If you don't already have a working UNZIP MODULE on CMS you will
|
||||
have to unzip the files on another system and transport them
|
||||
to CMS. All the required files are plain text so they can
|
||||
be transferred with ASCII-to-EBCDIC translations.
|
||||
|
||||
2. Repeat step 1 with the zip file containing the UNZIP code.
|
||||
Unzip the files to a different disk than the disk used for the ZIP
|
||||
code.
|
||||
|
||||
3. To compile the ZIP code, run the supplied CCZIP EXEC.
|
||||
To compile the UNZIP code, run the supplied CCUNZIP EXEC.
|
||||
|
||||
NOTE:
|
||||
Some of the ZIP and UNZIP source files have the same name. It is
|
||||
recommended that you keep the source from each on separate disks and
|
||||
move the disk you are building from ahead of the other in the search
|
||||
order.
|
||||
|
||||
For example, you may have a 192 disk with the ZIP source code and
|
||||
a 193 disk with the UNZIP source code. To compile ZIP, access
|
||||
the 192 disk as B, then run CCZIP. This will create the following
|
||||
modules: ZIP, ZIPNOTE, ZIPSPLIT, ZIPCLOAK.
|
||||
|
||||
To compile UNZIP, access 193 as B, then run CCUNZIP. This will create
|
||||
the following modules: UNZIP, ZIPINFO (a copy of UNZIP).
|
||||
|
||||
|
||||
=========================================================================
|
||||
|
||||
|
||||
Using ZIP/UNZIP
|
||||
---------------
|
||||
|
||||
Documentation for the commands is in MANUAL NONAME (for ZIP) and in
|
||||
UNZIP DOC UNZIP. INFOZIP DOC describes the use of the -Z option of
|
||||
UNZIP.
|
||||
|
||||
The rest of this section explains special notes concerning the VM/CMS
|
||||
version of ZIP and UNZIP.
|
||||
|
||||
|
||||
Filenames and directories
|
||||
-------------------------
|
||||
|
||||
1. Specifying filenames
|
||||
|
||||
a. When specifying CMS files, use filename.filetype.filemode format
|
||||
(separate the three parts of the name with a period and use no
|
||||
spaces). Example: profile.exec.a
|
||||
|
||||
Unfortunately, this prevents you from using ZIP from
|
||||
FILELIST. To unzip a zip file, however, you can type something
|
||||
like this next to it in FILELIST:
|
||||
unzip /n -d c
|
||||
|
||||
This will unzip the contents of the current file to a C-disk.
|
||||
|
||||
b. It is possible to use DD names with ZIP and UNZIP on CMS, though
|
||||
it can be cumbersome. Example:
|
||||
filedef out disk myzip zip a
|
||||
zip dd:out file1.txt file2.txt
|
||||
|
||||
While you can also use a DD name for the input files, ZIP
|
||||
currently does not correctly resolve the filename and will
|
||||
store something like "dd:in" inside the ZIP file. A file stored
|
||||
in this manor cannot easily be unzipped, as "dd:in" is an invalid
|
||||
filename.
|
||||
|
||||
c. In places where a directory name would be used on a PC, such as
|
||||
for the ZIP -b (work path) option or the UNZIP -d (destination
|
||||
path) options, use a filemode letter for CMS. For example,
|
||||
to unzip files onto a C-disk, you might type something like this:
|
||||
unzip myzip.zip -d c
|
||||
|
||||
Currently, ZIP uses the A-disk for work files. When zipping
|
||||
large files, you may want to specify a larger disk for work files.
|
||||
This example will use a C-disk for work files.
|
||||
zip -b C myzip.zip.c test.dat.a
|
||||
|
||||
|
||||
2. Filename conversions
|
||||
|
||||
a. Filemode letters are never stored into the zip file or take from
|
||||
a zip file. Only the filename and filetype are used.
|
||||
ZIP removes the filemode when storing the filename into the
|
||||
zip file. UNZIP assumes "A" for the filemode unless the -d
|
||||
option is used.
|
||||
|
||||
b. When unzipping, any path names are removed from the fileid
|
||||
and the last two period-separated words are used as the
|
||||
filename and filetype. These are truncated to a maximum of
|
||||
eight characters, if necessary. If the filetype (extension)
|
||||
is missing, then UNZIP uses "NONAME" for the filetype.
|
||||
Any '(' or ')' characters are removed from the fileid.
|
||||
|
||||
c. All files are created in upper-case. Files in mixed-case
|
||||
cannot currently be stored into a ZIP file.
|
||||
|
||||
d. Shared File System (SFS) directories are not supported.
|
||||
Files are always accessed by fn.ft.fm. To use an SFS disk,
|
||||
Assign it a filemode, then it can be used.
|
||||
|
||||
|
||||
3. Wildcards in file names
|
||||
|
||||
a. Wildcards are not supported in the zip filename. The full
|
||||
filename of the zip file must be given (but the .zip is not
|
||||
necessary). So, you can't do this:
|
||||
unzip -t *.zip
|
||||
|
||||
b. Wildcards CAN be used with UNZIP to select (or exclude) files
|
||||
inside a zip file. Examples:
|
||||
unzip myzip *.c - Unzip all .c files.
|
||||
unzip myzip *.c -x z*.c - Unzip all .c files but those
|
||||
starting with Z.
|
||||
|
||||
c. Wildcards cannot currently be used to select files with ZIP.
|
||||
So, you can't do this:
|
||||
zip -a myzip *.exec
|
||||
|
||||
I expect to fix this for CMS in the future.
|
||||
|
||||
|
||||
4. File timestamps
|
||||
|
||||
a. The dates and times of files being zipped or unzipped are not
|
||||
currently read or set. When a file is zipped, the timestamp
|
||||
inside the zip file will always be the current system date and
|
||||
time. Likewise, when unzipping, the date and time of files
|
||||
being unzipped will always be the current system date/time.
|
||||
|
||||
b. Existing files are assumed to be newer than files inside a zip
|
||||
file when using the -f freshen option of UNZIP. This will prevent
|
||||
overwriting files that may be newer than the files inside the
|
||||
zip file, but also effectively prevents the -f option from working.
|
||||
|
||||
|
||||
5. ASCII, EBCDIC, and binary data
|
||||
|
||||
Background
|
||||
----------
|
||||
Most systems create data files as just a stream of bytes. Record
|
||||
breaks happen when certain characters (new line and/or carriage
|
||||
return characters) are encountered in the data. How to interpret
|
||||
the data in a file is up to the user. The system must be told
|
||||
to either notice new line characters in the data or to assume
|
||||
that the data in the file is binary data and should be read or
|
||||
written as-is.
|
||||
|
||||
CMS and MVS are record-based systems. All files are composed
|
||||
of data records. These can be stored in fixed-length files or
|
||||
in variable length files. With fixed-length files, each record
|
||||
is the same length. The record breaks are implied by the
|
||||
LRECL (logical record length) attribute associated with the file.
|
||||
With variable-length files, each record contains the length of
|
||||
that record. The separation of records are not part of the
|
||||
data, but part of the file structure.
|
||||
|
||||
This means you can store any type of data in either type of file
|
||||
structure without having to worry about the data being interpreted
|
||||
as a record break. Fixed-length files may have padding at the
|
||||
end of the file to make up a full record. Variable-length files
|
||||
have no padding, but require extra record length data be stored
|
||||
with the file data.
|
||||
|
||||
Storing fixed-length files into a zip file is simple, because all
|
||||
the data can just be dumped into the zip file and the record
|
||||
format (RECFM) and logical record length (LRECL) can be stored
|
||||
in the extra data area of the zip file so they can be restored
|
||||
when UNZIP is used.
|
||||
|
||||
Storing variable-length data is harder. There is no place to put
|
||||
the record length data needed for each record of the file. This
|
||||
data could be written to the zip file as the first two bytes of
|
||||
each record and interpreted that way by UNZIP. That would make
|
||||
the data unusable on systems other than CMS and MVS, though.
|
||||
|
||||
Currently, there isn't a solution to this problem. Each record is
|
||||
written to the zip file and the record length information is
|
||||
discarded. Binary data stored in variable-length files can't be put
|
||||
into a zip file then later unzipped back into the proper records.
|
||||
This is fine for binary data that will be read as a stream of bytes
|
||||
but not OK where the records matter, such as with CMS MODULEs.
|
||||
|
||||
If the data is text (character data), there is a solution.
|
||||
This data can be converted into ASCII when it's stored into
|
||||
a zip file. The end of each record is now marked in the file
|
||||
by new line characters. Another advantage of this method is
|
||||
that the data is now accessible to non-EBCDIC systems. When
|
||||
the data is unzipped on CMS or MVS, it is converted back into
|
||||
EBCDIC and the records are recreated into a variable-length file.
|
||||
|
||||
|
||||
So, here's what we have...
|
||||
|
||||
a. To store readable text data into a zip file that can be used
|
||||
on other platforms, use the -a option with ZIP to convert the
|
||||
data to ASCII. These files will unzip into variable-length
|
||||
files on CMS and should not contain binary data or corruption
|
||||
may occur.
|
||||
|
||||
b. Files that were zipped on an ASCII-based system will be
|
||||
automatically translated to EBCDIC when unzipped. To prevent
|
||||
this (to unzip binary data on CMS that was sent from an
|
||||
ASCII-based system), use the -B option with UNZIP to force Binary
|
||||
mode. To zip binary files on CMS, use the -B option with ZIP to
|
||||
force Binary mode. This will prevent any data conversions from
|
||||
taking place.
|
||||
|
||||
c. When using the ZIP program without specifying the "-a" or "-B"
|
||||
option, ZIP defaults to "native" (EBCDIC) mode and tries to
|
||||
preserve the file information (RECFM, LRECL, and BLKSIZE). So
|
||||
when you unzip a file zipped with ZIP under CMS or MVS, UNZIP
|
||||
restores the file info. The output will be fixed-length if the
|
||||
original was fixed and variable-length if the original was
|
||||
variable.
|
||||
|
||||
If UNZIP gives a "write error (disk full?)" message, you may be
|
||||
trying to unzip a binary file that was zipped as a text file
|
||||
(without using the -B option)
|
||||
|
||||
|
||||
Summary
|
||||
-------
|
||||
Here's how to ZIP the different types of files.
|
||||
|
||||
RECFM F text
|
||||
Use the -a option with ZIP to convert to ASCII for use with other
|
||||
platforms or no options for use on EBCDIC systems only.
|
||||
|
||||
RECFM V text
|
||||
Use the -a option with ZIP to convert to ASCII for use with other
|
||||
platforms or no options for use on EBCDIC systems only.
|
||||
|
||||
|
||||
RECFM F binary
|
||||
Use the -B option with ZIP (upper-case "B").
|
||||
|
||||
RECFM V binary
|
||||
Use the -B option with ZIP. Can be zipped OK but the record
|
||||
structure is destroyed when unzipped. This is OK for data files
|
||||
read as binary streams but not OK for files such as CMS MODULEs.
|
||||
|
||||
|
||||
6. Character Sets
|
||||
|
||||
If you are used to running UNZIP on systems like UNIX, DOS, OS/2 or
|
||||
Windows, you will may have some problems with differences in the
|
||||
character set.
|
||||
|
||||
There are a number of different EBCDIC code pages, like there are a
|
||||
number of different ASCII code pages. For example, there is a US
|
||||
EBCDIC, a German EBCDIC, and a Swedish EBCDIC. As long as you are
|
||||
working with other people who use the same EBCDIC code page, you
|
||||
will have no trouble. If you work with people who use ASCII, or who
|
||||
use a different EBCDIC code page, you may need to do some
|
||||
translation.
|
||||
|
||||
UNZIP translates ASCII text files to and from Open Systems EBCDIC
|
||||
(IBM-1047), which may not be the EBCDIC that you are using. For
|
||||
example, US EBCDIC (IBM-037) uses different character codes for
|
||||
square brackets. In such cases, you can use the ICONV utility
|
||||
(supplied with IBM C) to translate between your EBCDIC character set
|
||||
and IBM-1047.
|
||||
|
||||
If your installation does not use IBM-1047 EBCDIC, messages from
|
||||
UNZIP may look a little odd. For example, in a US EBCDIC
|
||||
installation, an opening square bracket will become an i-acute and a
|
||||
closing square bracket will become a u-grave.
|
||||
|
||||
The supplied ZIP and UNZIP EXECs attempt to correct this by setting
|
||||
CMS INPUT and OUTPUT translations to adjust the display of left and
|
||||
right brackets. You may need to change this if brackets don't
|
||||
display correctly on your system.
|
||||
|
||||
|
||||
7. You can unzip using VM/CMS PIPELINES so unzip can be used as
|
||||
a pipeline filter. Example:
|
||||
'PIPE COMMAND UNZIP -p test.zip george.test | Count Lines | Cons'
|
||||
|
||||
|
||||
|
||||
|
||||
Please report all bugs and problems to:
|
||||
Zip-Bugs@lists.wku.edu
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Original CMS/MVS port by George Petrov.
|
||||
e-mail: c888090@nlevdpsb.snads.philips.nl
|
||||
tel: +31-40-781155
|
||||
|
||||
Philips C&P
|
||||
Eindhoven
|
||||
The Netherlands
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Additional fixes and README re-write (4/98) by Greg Hartwig.
|
||||
e-mail: ghartwig@ix.netcom.com
|
||||
ghartwig@vnet.ibm.com
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Additional notes from Ian E. Gorman.
|
||||
e-mail: ian@iosphere.net
|
||||
|
92
third_party/infozip/zip/cmsmvs/README.MVS
vendored
Normal file
92
third_party/infozip/zip/cmsmvs/README.MVS
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
Thank you for trying this first port of ZIP for VM/CMS and MVS!
|
||||
|
||||
|
||||
Using under MVS:
|
||||
---------------------------
|
||||
|
||||
1. To use the Info-ZIP's ZIP 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 zip22.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.ZIP.C
|
||||
|
||||
- Copy all the .H files in the PDS called youruserid.ZIP.H
|
||||
|
||||
- adjust the job ZIPMVSC.JOB to work on your size. Change my
|
||||
userid - C888090 to yours
|
||||
|
||||
- execute the job ZIPMVSC to compile and link all the sources.
|
||||
|
||||
- maybe you have to preallocate PDS datasets named:
|
||||
youruserid.ZIP.OBJ and youruserid.ZIP.LOAD
|
||||
|
||||
- execute ZIPVMC to compile and link all the sources.
|
||||
|
||||
- if everything is ok you will get an ZIP MODULE
|
||||
|
||||
- the warnings about the duplicated ASCII and EBCDIC symbols
|
||||
are OK :-)
|
||||
|
||||
3. Using ZIP
|
||||
|
||||
- Just read MANUAL
|
||||
|
||||
- A few exceptions concerning MVS
|
||||
|
||||
3.1. if you want to make a portable zip file that is to be unzipped
|
||||
on ASCII based systems use the -a option
|
||||
|
||||
3.2. If you want to zip the input files as binary ebcdic files
|
||||
use the -B (capital letter) option
|
||||
|
||||
3.3. The date/end the time of the input files is set in the zip's
|
||||
dir to the current system date/time
|
||||
|
||||
3.4. Without specifying the "-a" or "-B" option, the ZIP program
|
||||
defaults to "native" (EBCDIC) mode and tries to preserve 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.5. No wildcards are supported as input file names:
|
||||
|
||||
So you CAN'T use things like: zip myzip *.c
|
||||
|
||||
3.6. You can use DD names for zipfilename for example:
|
||||
|
||||
under tso/rexx:
|
||||
|
||||
"alloc fi(input) da('myzip.zip')"
|
||||
"zip dd:input file1.txt file2.txt ..."
|
||||
|
||||
under Batch:
|
||||
|
||||
//MYZIP JOB (account)
|
||||
//STEP1 EXEC PGM=ZIP,PARM='dd:input file1.txt file2.txt'
|
||||
//STEPLIB DD DSN=userid.UNZIP.LOAD,DISP=SHR
|
||||
//INPUT DD DSN=userid.MYZIP.ZIP,DISP=NEW,
|
||||
// SPACE=(15000,(15000,10000),RLSE),
|
||||
// DCB=(LRECL=80,RECFM=F)
|
||||
//SYSPRINT DD SYSOUT=*
|
||||
|
||||
|
||||
Please report all bugs and problems to :
|
||||
zip-bugs@lists.wku.edu
|
||||
|
||||
That's all for now.
|
||||
|
||||
Have fun!
|
||||
|
||||
|
||||
George Petrov
|
286
third_party/infozip/zip/cmsmvs/README.MVS.LE
vendored
Normal file
286
third_party/infozip/zip/cmsmvs/README.MVS.LE
vendored
Normal file
|
@ -0,0 +1,286 @@
|
|||
Notes on Zip under MVS Language Environment (LE).
|
||||
|
||||
First see README.MVS. This note describes just one beta test on OS/390
|
||||
V2R5 using IBM's C compiler (5647A01), V2R4. The major difference is
|
||||
the use of LE on the beta site, together with some MVS native mode
|
||||
fixes. Changes have not been tested on CMS.
|
||||
|
||||
Some of the notes are to clarify things that were not clear from the
|
||||
MANUAL or README.MVS.
|
||||
|
||||
1. By default, IBM C generates the same csect name for each input
|
||||
source. The prelink stage does not rename them and the linkage
|
||||
editor throws away all but the first occurrence of each duplicate.
|
||||
Oops, my code just disappeared :(.
|
||||
|
||||
To get around this "feature", compile with the CSECT option to
|
||||
force sensible names on the code and data sections of each csect.
|
||||
The name of the static data csect defaults to the source name in
|
||||
lower case, the code csect defaults to the source name in upper
|
||||
case. These csect names still have to be unique, they cannot be
|
||||
the same as function names. Of course, several csects have a
|
||||
function which is the same name as the source in lower case, not
|
||||
exactly an unusual occurrence. Therefore to make the csect name
|
||||
unique, some of the sources have
|
||||
|
||||
#ifdef MVS
|
||||
# pragma csect(STATIC,xxxx_s)
|
||||
#endif
|
||||
|
||||
Where xxxx is an abbreviation of the source name. There has to be
|
||||
a better way!
|
||||
|
||||
2. The prelink step always gets cond code 4. It complains about
|
||||
unresolved references, ignore it unless the linker also complains.
|
||||
Prelink also complains about duplicate @@PPA2 sections and so does
|
||||
the linker, but it seems to do no harm. Compile and link steps
|
||||
should get 0, just prelink gets 4. See JCL at the bottom.
|
||||
|
||||
3. Under MVS native mode (not Open Edition), tmpnam() returns a quoted
|
||||
name of 5 qualifiers. The first is a HLQ chosen according to the
|
||||
MVS LE algorithm (see below), the other qualifiers are time stamps.
|
||||
If running on MVS and tmpnam() returns a quoted name with at leat
|
||||
one '.', it is only safe to let the user change the high level
|
||||
qualifier. Therefore -b insists on a single qualifier without '.'
|
||||
in the MVS native environment.
|
||||
|
||||
4. In Open Edition (OE) mode, the manual says that tmpnam() returns a
|
||||
fully qualified name in directory TMPDIR or /tmp if TMPDIR is not
|
||||
set. There is no point in zip trying to override that name so -b
|
||||
is ignored in MVS OE mode (untested). The user should specify
|
||||
environment variable TMPDIR instead.
|
||||
|
||||
5. The MVS LE algorithm for choosing the high level qualifier for
|
||||
native filenames is interesting, as in "May you live in interesting
|
||||
times". The HLQ varies according to the environment the program is
|
||||
running in, sometimes it is userid, sometimes it is TSO prefix.
|
||||
See OS/390 C/C++ Programming Guide, Using a Data Set Name,
|
||||
somewhere around section 2.9.
|
||||
|
||||
If in doubt, use fully qualified and quoted names. Instead of
|
||||
archive.zip, use 'prefix.archive.zip'. For input files, instead of
|
||||
filename, use 'prefix.filename'. For PARM= in JCL, double up the
|
||||
quotes. You even have to quote filenames in stdin.
|
||||
|
||||
6. If your PARM includes any '/', make sure the PARM starts with '/'.
|
||||
LE assumes anything before the first '/' is LE run time parameters.
|
||||
It does no harm to always code a leading '/' for LE parms.
|
||||
|
||||
7. JCL limits a PARM= to 100 characters total with approx. 65 on a
|
||||
single line. Alas the syntax for continuing PARM= always embeds an
|
||||
extra ',' somewhere in the parameters that the program finally
|
||||
gets. No workaround, limit your PARM to a single line. With the
|
||||
extra quotes around filenames, that does not leave much room. In
|
||||
most cases, you will have to use '-@' to read the list of filenames
|
||||
from SYSIN (stdin), it will not fit on a single PARM line.
|
||||
|
||||
8. Filenames can be dataset names or you can refer to a ddname with
|
||||
'DD:name', case insensitive for external files, case sensitive for
|
||||
OE files. You can even specify 'dd:name(mem)'. No wildcards, to
|
||||
zip a complete pds you have to specify each member individually.
|
||||
Directory recursion in OE does not appear to work at the moment.
|
||||
|
||||
9. Zip attempts to map MVS filenames to Unix style names. It did not
|
||||
work correctly for quoted names, fixed. Although you can pick up
|
||||
an external (non-OE) file with a name using any case, be aware that
|
||||
the mapping to a Unix style name faithfully follows the case you
|
||||
supply.
|
||||
|
||||
10. The archive file was being created with recfm=V and lrecl=32760.
|
||||
32760 is not valid for recfm=V under MVS, I originally changed it
|
||||
to lrecl=32756. Then zip broke trying to fseek() over a record
|
||||
boundary, I do not know whether this was a zip or LE bug. Trial
|
||||
and error showed that recfm=U with byteseek seems to work on MVS.
|
||||
No BDW or RDW, just a byte stream. The blocksize is always 6144.
|
||||
|
||||
NOTE: This is an incompatible change from the previous beta,
|
||||
archive files used to be recfm=V. That should not matter
|
||||
because we just transfer the data, ignoring BDW and RDW
|
||||
anyway.
|
||||
|
||||
11. Zip used to complain about preallocated but empty archives, wrong
|
||||
length records, no signature etc. The usual IBM/360 problem of no
|
||||
end of file marker in a new, unopened dataset. Fixed, see routine
|
||||
readzipfile in zipfile.c for the gory details. PARM= works fine.
|
||||
|
||||
12. Several source files have records that are more than 80 bytes long.
|
||||
It works if you transfer to mainframe datasets with a larger lrecl,
|
||||
I used recfm=fb,lrecl=120 for the .C and .H files. To compile with
|
||||
anything longer than 72 bytes, you need MVS C options NOMARGINS and
|
||||
NOSEQUENCE (NOMAR,NOSEQ).
|
||||
|
||||
13. cmsmvs was still using zname instead of name for open. Fixed.
|
||||
|
||||
14. zip has to jump through a lot of hoops to see if an existing
|
||||
zipfile actually contains data. A side effect of this is that
|
||||
creating a zipfile with the RLSE parameter is a waste of time.
|
||||
|
||||
Keith Owens <kaos@ocs.com.au>. Not a maintainer, just a beta tester.
|
||||
Mon Sep 14 19:31:30 EST 1998
|
||||
|
||||
|
||||
Sample JCL to compile Zip under MVS LE. You might need a large region,
|
||||
I used REGION=128M on the job card. Also watch the output lines,
|
||||
75,000 with OPT(2), 100,000+ with OPT(2) replaced with DEF(DEBUG). You
|
||||
need to allocate prefix.ZIP.C.OBJ (recfm=FB, lrecl=80) and
|
||||
prefix.ZIP.LOAD (recfm=U, blksize is site defined).
|
||||
|
||||
//CBC JCLLIB ORDER=CBC.SCBCPRC
|
||||
//ZIP EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(ZIP)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(ZIP),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//CRYPT EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(CRYPT)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(CRYPT),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//TTYIO EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(TTYIO)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(TTYIO),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//TREES EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(TREES)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(TREES),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//DEFLATE EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(DEFLATE)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(DEFLATE),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//FILEIO EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(FILEIO)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(FILEIO),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//GLOBALS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(GLOBALS)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(GLOBALS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//UTIL EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(UTIL)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(UTIL),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//CRC32 EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(CRC32)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(CRC32),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//CRCTAB EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(CRCTAB)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(CRCTAB),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//ZIPFILE EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(ZIPFILE)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(ZIPFILE),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//ZIPUP EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(ZIPUP)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(ZIPUP),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//CMSMVS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(CMSMVS)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(CMSMVS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//MVS EXEC EDCC,COND=(0,NE),CREGSIZ='4M',
|
||||
// INFILE='prefix.ZIP.C(MVS)',
|
||||
// OUTFILE='prefix.ZIP.C.OBJ(MVS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE',
|
||||
// CPARM2='OPT(2),DEF(MVS),NOMAR,NOSEQ,CSECT'
|
||||
//COMPILE.USERLIB DD DSN=prefix.ZIP.H,DISP=SHR
|
||||
//PLINK EXEC PROC=EDCPL,
|
||||
// OUTFILE='prefix.ZIP.LOAD(ZIP),DISP=SHR',
|
||||
// PREGSIZ=6M,
|
||||
// PPARM='NONCAL,MAP,MEMORY',
|
||||
// LPARM='LIST,MAP,XREF'
|
||||
//PLKED.SYSIN DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIP)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRYPT)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(TREES)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(DEFLATE)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(FILEIO)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(GLOBALS)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(UTIL)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRC32)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(CRCTAB)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIPFILE)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(ZIPUP)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(MVS)
|
||||
// DD DISP=SHR,DSN=prefix.ZIP.C.OBJ(CMSMVS)
|
||||
//LKED.SYSLIB DD DISP=SHR,DSN=CEE.SCEELKED
|
||||
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(2,2))
|
||||
//
|
||||
|
||||
Sample JCL to zip the mainframe .C and .H files as ASCII (-a). Delete
|
||||
any existing archive first, point the temporary file at a particular
|
||||
prefix (-b), use 'prefix.ARCHIVE.ZIP' for the archive file, read the
|
||||
list of files to zip from stdin (SYSIN).
|
||||
|
||||
//DELETE EXEC PGM=IDCAMS
|
||||
//SYSPRINT DD SYSOUT=*
|
||||
//SYSIN DD *
|
||||
DELETE prefix.ARCHIVE.ZIP
|
||||
SET MAXCC = 0
|
||||
//ZIP EXEC PGM=ZIP,
|
||||
// PARM='/-a -v -b temppref ''prefix.ARCHIVE.ZIP'' -@'
|
||||
//STEPLIB DD DSN=prefix.ZIP.LOAD,DISP=SHR
|
||||
//SYSPRINT DD SYSOUT=*
|
||||
//SYSOUT DD SYSOUT=*
|
||||
//CEEDUMP DD SYSOUT=*
|
||||
//ZIPC DD DISP=SHR,DSN=prefix.ZIP.C
|
||||
//ZIPH DD DISP=SHR,DSN=prefix.ZIP.H
|
||||
//SYSIN DD *
|
||||
dd:zipc(api)
|
||||
dd:zipc(cms)
|
||||
dd:zipc(cmsmvs)
|
||||
dd:zipc(crctab)
|
||||
dd:zipc(crc32)
|
||||
dd:zipc(crypt)
|
||||
dd:zipc(deflate)
|
||||
dd:zipc(fileio)
|
||||
dd:zipc(globals)
|
||||
dd:zipc(mktime)
|
||||
dd:zipc(mvs)
|
||||
dd:zipc(trees)
|
||||
dd:zipc(ttyio)
|
||||
dd:zipc(util)
|
||||
dd:zipc(zip)
|
||||
dd:zipc(zipcloak)
|
||||
dd:zipc(zipfile)
|
||||
dd:zipc(zipnote)
|
||||
dd:zipc(zipsplit)
|
||||
dd:zipc(zipup)
|
||||
dd:ziph(api)
|
||||
dd:ziph(cmsmvs)
|
||||
dd:ziph(crypt)
|
||||
dd:ziph(cstat)
|
||||
dd:ziph(ebcdic)
|
||||
dd:ziph(mvs)
|
||||
dd:ziph(revision)
|
||||
dd:ziph(stat)
|
||||
dd:ziph(tailor)
|
||||
dd:ziph(ttyio)
|
||||
dd:ziph(zip)
|
||||
dd:ziph(ziperr)
|
||||
dd:ziph(zipup)
|
123
third_party/infozip/zip/cmsmvs/cczip.exec
vendored
Normal file
123
third_party/infozip/zip/cmsmvs/cczip.exec
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
/* CCZIP EXEC Compile zip for VM/CMS */
|
||||
/* Author: George Petrov, 11 Apr 1995 (VMCOMPIL EXEC) */
|
||||
/* Modified for IBM C V3R1 by Ian E. Gorman, 2 Nov 1998
|
||||
Facilities for compiling and testing were provided by
|
||||
OmniMark Technologies Corporation, Ottawa, Canada
|
||||
*/
|
||||
Address Command
|
||||
Signal On Error
|
||||
|
||||
/* Allow longnames, compile re-entrant code.
|
||||
globals.c and cmsmvs.c require EXTENDED features */
|
||||
CCopts = 'LONGNAME RENT LANGLVL(EXTENDED) NOEXECOPS'
|
||||
|
||||
/* ZIP options -- VM_CMS, REENTRANT */
|
||||
CCopts = CCopts 'DEFINE(VM_CMS,REENTRANT)'
|
||||
|
||||
/* Link the load module to run in more or less than 16MB memory */
|
||||
LINKopts = 'AMODE ANY RMODE ANY RLDSAVE'
|
||||
|
||||
/* resources needed to build */
|
||||
'GLOBAL TXTLIB SCEELKED CMSLIB'
|
||||
'GLOBAL LOADLIB SCEERUN'
|
||||
|
||||
/* produce the TEXT (object) files */
|
||||
linklist=''
|
||||
modname='ZIP'
|
||||
Say 'Building' modname 'MODULE...'
|
||||
Call Compile 'ZIP'
|
||||
Call Compile 'CRC32'
|
||||
Call Compile 'CRYPT'
|
||||
Call Compile 'DEFLATE'
|
||||
Call Compile 'FILEIO'
|
||||
Call Compile 'GLOBALS'
|
||||
Call Compile 'TREES'
|
||||
Call Compile 'TTYIO'
|
||||
Call Compile 'UTIL'
|
||||
Call Compile 'ZIPUP'
|
||||
Call Compile 'ZIPFILE'
|
||||
Call Compile 'CMSMVS'
|
||||
Call Compile 'CMS'
|
||||
|
||||
Say 'Linking...'
|
||||
'EXEC CMOD' linklist '(MODNAME' modname LINKopts
|
||||
Say modname 'built successfully.'
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* Build utility programs */
|
||||
/*---------------------------------------------------------------------*/
|
||||
CCopts = CCopts 'DEFINE(UTIL)'
|
||||
|
||||
|
||||
linklist=''
|
||||
modname='ZIPNOTE'
|
||||
Say
|
||||
Say 'Building' modname 'MODULE...'
|
||||
Call Compile 'ZIPNOTE'
|
||||
Call Compile 'ZIPFILE'
|
||||
Call Compile 'FILEIO'
|
||||
Call Compile 'UTIL'
|
||||
Call Compile 'GLOBALS'
|
||||
Call Compile 'CMSMVS'
|
||||
|
||||
Say 'Linking...'
|
||||
'EXEC CMOD' linklist '(MODNAME' modname LINKopts
|
||||
Say modname 'built successfully.'
|
||||
|
||||
|
||||
linklist=''
|
||||
modname='ZIPSPLIT'
|
||||
Say
|
||||
Say 'Building' modname 'MODULE...'
|
||||
Call Compile 'ZIPSPLIT'
|
||||
Call Compile 'ZIPFILE'
|
||||
Call Compile 'FILEIO'
|
||||
Call Compile 'UTIL'
|
||||
Call Compile 'GLOBALS'
|
||||
Call Compile 'CMSMVS'
|
||||
|
||||
Say 'Linking...'
|
||||
'EXEC CMOD' linklist '(MODNAME' modname LINKopts
|
||||
Say modname 'built successfully.'
|
||||
|
||||
|
||||
linklist=''
|
||||
modname='ZIPCLOAK'
|
||||
Say
|
||||
Say 'Building' modname 'MODULE...'
|
||||
Call Compile 'ZIPCLOAK'
|
||||
Call Compile 'ZIPFILE'
|
||||
Call Compile 'FILEIO'
|
||||
Call Compile 'UTIL'
|
||||
Call Compile 'GLOBALS'
|
||||
Call Compile 'CRC32'
|
||||
Call Compile 'CRYPT'
|
||||
Call Compile 'TTYIO'
|
||||
Call Compile 'CMSMVS'
|
||||
|
||||
Say 'Linking...'
|
||||
'EXEC CMOD' linklist '(MODNAME' modname LINKopts
|
||||
Say modname 'built successfully.'
|
||||
Say 'Done.'
|
||||
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
error:
|
||||
Say 'Error' rc 'during compilation!'
|
||||
Say 'Error in line' sigl':'
|
||||
Say ' 'Sourceline(sigl)
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
Compile: Procedure Expose CCopts LINKopts linklist
|
||||
Parse arg filename filetype filemode .
|
||||
If filetype='' Then filetype='C'
|
||||
linklist = linklist filename
|
||||
|
||||
Say 'Compiling' filename filetype filemode '...'
|
||||
'EXEC CC' filename filetype filemode '('CCopts
|
||||
Return rc
|
34
third_party/infozip/zip/cmsmvs/cms.c
vendored
Normal file
34
third_party/infozip/zip/cmsmvs/cms.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* VM/CMS specific things.
|
||||
*/
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
FILE *stream;
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else {
|
||||
if ((stream = fopen(n, "r")) != (FILE *)NULL)
|
||||
{
|
||||
fclose(stream);
|
||||
return newname(n, 0, caseflag);
|
||||
}
|
||||
else return ZE_MISS;
|
||||
}
|
||||
return ZE_OK;
|
||||
}
|
442
third_party/infozip/zip/cmsmvs/cmsmvs.c
vendored
Normal file
442
third_party/infozip/zip/cmsmvs/cmsmvs.c
vendored
Normal file
|
@ -0,0 +1,442 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* routines common to VM/CMS and MVS
|
||||
*/
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef MVS /* MVS has perfectly good definitions of the following */
|
||||
int stat(const char *path, struct stat *buf)
|
||||
{
|
||||
if ((buf->fp = fopen(path, "r")) != NULL) {
|
||||
fldata_t fdata;
|
||||
if (fldata( buf->fp, buf->fname, &fdata ) == 0) {
|
||||
buf->st_dev = fdata.__device;
|
||||
buf->st_mode = *(short *)(&fdata);
|
||||
}
|
||||
strcpy( buf->fname, path );
|
||||
fclose(buf->fp);
|
||||
}
|
||||
return (buf->fp != NULL ? 0 : 1);
|
||||
}
|
||||
#endif /* MVS */
|
||||
|
||||
|
||||
#ifndef UTIL /* the companion #endif is a bit of ways down ... */
|
||||
|
||||
#define PAD 0
|
||||
#define PATH_END '/'
|
||||
|
||||
/* Library functions not in (most) header files */
|
||||
|
||||
#ifdef USE_ZIPMAIN
|
||||
int main OF((void));
|
||||
#endif
|
||||
|
||||
int utime OF((char *, ztimbuf *));
|
||||
|
||||
extern char *label;
|
||||
local ulg label_time = 0;
|
||||
local ulg label_mode = 0;
|
||||
local time_t label_utim = 0;
|
||||
|
||||
#ifndef MVS /* MVS has perfectly good definitions of the following */
|
||||
int fstat(int fd, struct stat *buf)
|
||||
{
|
||||
fldata_t fdata;
|
||||
|
||||
if ((fd != -1) && (fldata( (FILE *)fd, buf->fname, &fdata ) == 0)) {
|
||||
buf->st_dev = fdata.__device;
|
||||
buf->st_mode = *(short *)(&fdata);
|
||||
buf->fp = (FILE *)fd;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* MVS */
|
||||
|
||||
|
||||
char *ex2in(x, isdir, pdosflag)
|
||||
char *x; /* external file name */
|
||||
int isdir; /* input: x is a directory */
|
||||
int *pdosflag; /* output: force MSDOS file attributes? */
|
||||
/* Convert the external file name to a zip file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *n; /* internal file name (malloc'ed) */
|
||||
char *t; /* shortened name */
|
||||
int dosflag;
|
||||
char mem[10] = ""; /* member name */
|
||||
char ext[10] = ""; /* extension name */
|
||||
|
||||
dosflag = dosify; /* default for non-DOS non-OS/2 */
|
||||
|
||||
/* Find starting point in name before doing malloc */
|
||||
for (t = x; *t == '/'; t++)
|
||||
;
|
||||
|
||||
/* Make changes, if any, to the copied name (leave original intact) */
|
||||
if (!pathput)
|
||||
t = last(t, PATH_END);
|
||||
|
||||
/* Malloc space for internal name and copy it */
|
||||
if ((n = malloc(strlen(t) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy(n, t);
|
||||
|
||||
#ifdef MVS
|
||||
/* strip quotes from name, non-OE format */
|
||||
if (*n == '\'' && (t = strrchr(n, '\'')) != n) {
|
||||
if (!*(t+1)) {
|
||||
/* yes, it is a quoted name */
|
||||
int l = strlen(n) - 2;
|
||||
memmove(n, n+1, l);
|
||||
*(n+l) = '\0';
|
||||
}
|
||||
}
|
||||
/* Change member names to fn.ext */
|
||||
if (t = strrchr(n, '(')) {
|
||||
*t = '\0';
|
||||
strcpy(mem,t+1); /* Save member name */
|
||||
if (t = strchr(mem, ')')) *t = '\0'; /* Set end of mbr */
|
||||
/* Save extension */
|
||||
if (t = strrchr(n, '.')) t++;
|
||||
else t = n;
|
||||
strcpy(ext,t);
|
||||
/* Build name as "member.ext" */
|
||||
strcpy(t,mem);
|
||||
strcat(t,".");
|
||||
strcat(t,ext);
|
||||
}
|
||||
|
||||
/* Change all but the last '.' to '/' */
|
||||
if (t = strrchr(n, '.')) {
|
||||
while (--t > n)
|
||||
if (*t == '.')
|
||||
*t = '/';
|
||||
}
|
||||
#else
|
||||
/* On CMS, remove the filemode (all past 2nd '.') */
|
||||
if (t = strchr(n, '.'))
|
||||
if (t = strchr(t+1, '.'))
|
||||
*t = '\0';
|
||||
t = n;
|
||||
#endif
|
||||
|
||||
strcpy(n, t);
|
||||
|
||||
if (isdir == 42) return n; /* avoid warning on unused variable */
|
||||
|
||||
if (dosify)
|
||||
msname(n); /* msname() needs string in native charset */
|
||||
|
||||
strtoasc(n, n);
|
||||
|
||||
/* Returned malloc'ed name */
|
||||
if (pdosflag)
|
||||
*pdosflag = dosflag;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
char *in2ex(n)
|
||||
char *n; /* internal file name */
|
||||
/* Convert the zip file name to an external file name, returning the malloc'ed
|
||||
string or NULL if not enough memory. */
|
||||
{
|
||||
char *x; /* external file name */
|
||||
|
||||
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
|
||||
return NULL;
|
||||
strtoebc(x, n);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
void stamp(f, d)
|
||||
char *f; /* name of file to change */
|
||||
ulg d; /* dos-style time to change it to */
|
||||
/* Set last updated and accessed time of file f to the DOS time d. */
|
||||
{
|
||||
ztimbuf u; /* argument for utime() */
|
||||
|
||||
/* Convert DOS time to time_t format in u.actime and u.modtime */
|
||||
u.actime = u.modtime = dos2unixtime(d);
|
||||
|
||||
utime(f, &u);
|
||||
}
|
||||
|
||||
|
||||
ulg filetime(f, a, n, t)
|
||||
char *f; /* name of file to get info on */
|
||||
ulg *a; /* return value: file attributes */
|
||||
long *n; /* return value: file size */
|
||||
iztimes *t; /* return value: access, modific. and creation times */
|
||||
{
|
||||
FILE *stream;
|
||||
time_t ltime;
|
||||
|
||||
if (strcmp(f, "-") != 0) { /* if not compressing stdin */
|
||||
Trace((mesg, "opening file '%s' with '%s'\n", f, FOPR));
|
||||
if ((stream = fopen(f, FOPR)) == (FILE *)NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
if (n != NULL) {
|
||||
/* With byteseek, this will work */
|
||||
fseek(stream, 0L, SEEK_END);
|
||||
*n = ftell(stream);
|
||||
Trace((mesg, "file size = %lu\n", *((ulg *)n)));
|
||||
}
|
||||
fclose(stream);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Reading from stdin */
|
||||
if (n != NULL) {
|
||||
*n = -1L;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return current time for all the times -- for now */
|
||||
time(<ime);
|
||||
if (t != NULL)
|
||||
t->atime = t->mtime = t->ctime = ltime;
|
||||
|
||||
/* Set attributes (always a file) */
|
||||
if (a != NULL)
|
||||
*a = 0;
|
||||
|
||||
return unix2dostime(<ime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_extra_field(z, z_utim)
|
||||
struct zlist far *z;
|
||||
iztimes *z_utim;
|
||||
/* create extra field and change z->att if desired */
|
||||
{
|
||||
fldata_t fdata;
|
||||
FILE *stream;
|
||||
char *eb_ptr;
|
||||
#ifdef USE_EF_UT_TIME
|
||||
extent ef_l_len = (EB_HEADSIZE+EB_UT_LEN(1));
|
||||
#else /* !USE_EF_UT_TIME */
|
||||
extent ef_l_len = 0;
|
||||
#endif /* ?USE_EF_UT_TIME */
|
||||
int set_cmsmvs_eb = 0;
|
||||
|
||||
/*translate_eol = 0;*/
|
||||
if (aflag == ASCII) {
|
||||
z->att = ASCII;
|
||||
} else {
|
||||
if (bflag)
|
||||
z->att = BINARY;
|
||||
else
|
||||
z->att = __EBCDIC;
|
||||
ef_l_len += sizeof(fdata)+EB_HEADSIZE;
|
||||
set_cmsmvs_eb = 1;
|
||||
}
|
||||
|
||||
if (ef_l_len > 0) {
|
||||
z->extra = (char *)malloc(ef_l_len);
|
||||
if (z->extra == NULL) {
|
||||
printf("\nFLDATA : Unable to allocate memory !\n");
|
||||
return ZE_MEM;
|
||||
}
|
||||
z->cext = z->ext = ef_l_len;
|
||||
eb_ptr = z->cextra = z->extra;
|
||||
|
||||
if (set_cmsmvs_eb) {
|
||||
if (bflag)
|
||||
/*** stream = fopen(z->zname,"rb,type=record"); $RGH$ ***/
|
||||
stream = fopen(z->name,"rb");
|
||||
else
|
||||
stream = fopen(z->name,"r");
|
||||
if (stream == NULL) {
|
||||
printf("\nFLDATA : Could not open file : %s !\n",z->name);
|
||||
printf("Error %d: '%s'\n", errno, strerror(errno));
|
||||
return ZE_NONE;
|
||||
}
|
||||
|
||||
fldata(stream,z->name,&fdata);
|
||||
/*put the system ID */
|
||||
#ifdef VM_CMS
|
||||
*(eb_ptr) = EF_VMCMS & 0xFF;
|
||||
*(eb_ptr+1) = EF_VMCMS >> 8;
|
||||
#else
|
||||
*(eb_ptr) = EF_MVS & 0xFF;
|
||||
*(eb_ptr+1) = EF_MVS >> 8;
|
||||
#endif
|
||||
*(eb_ptr+2) = sizeof(fdata) & 0xFF;
|
||||
*(eb_ptr+3) = sizeof(fdata) >> 8;
|
||||
|
||||
memcpy(eb_ptr+EB_HEADSIZE,&fdata,sizeof(fdata));
|
||||
fclose(stream);
|
||||
#ifdef USE_EF_UT_TIME
|
||||
eb_ptr += (sizeof(fdata)+EB_HEADSIZE);
|
||||
#endif /* USE_EF_UT_TIME */
|
||||
}
|
||||
#ifdef USE_EF_UT_TIME
|
||||
eb_ptr[0] = 0x55; /* ascii[(unsigned)('U')] */
|
||||
eb_ptr[1] = 0x54; /* ascii[(unsigned)('T')] */
|
||||
eb_ptr[2] = EB_UT_LEN(1); /* length of data part of e.f. */
|
||||
eb_ptr[3] = 0;
|
||||
eb_ptr[4] = EB_UT_FL_MTIME;
|
||||
eb_ptr[5] = (char)(z_utim->mtime);
|
||||
eb_ptr[6] = (char)(z_utim->mtime >> 8);
|
||||
eb_ptr[7] = (char)(z_utim->mtime >> 16);
|
||||
eb_ptr[8] = (char)(z_utim->mtime >> 24);
|
||||
#endif /* USE_EF_UT_TIME */
|
||||
}
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
int deletedir(d)
|
||||
char *d; /* directory to delete */
|
||||
/* Delete the directory *d if it is empty, do nothing otherwise.
|
||||
Return the result of rmdir(), delete(), or system().
|
||||
For VMS, d must be in format [x.y]z.dir;1 (not [x.y.z]).
|
||||
*/
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_ZIPMAIN
|
||||
/* This function is called as main() to parse arguments */
|
||||
/* into argc and argv. This is required for stand-alone */
|
||||
/* execution. This calls the "real" main() when done. */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int argc=0;
|
||||
char *argv[50];
|
||||
|
||||
int iArgLen;
|
||||
char argstr[256];
|
||||
char **pEPLIST, *pCmdStart, *pArgStart, *pArgEnd;
|
||||
|
||||
/* Get address of extended parameter list from S/370 Register 0 */
|
||||
pEPLIST = (char **)__xregs(0);
|
||||
|
||||
/* Null-terminate the argument string */
|
||||
pCmdStart = *(pEPLIST+0);
|
||||
pArgStart = *(pEPLIST+1);
|
||||
pArgEnd = *(pEPLIST+2);
|
||||
iArgLen = pArgEnd - pCmdStart + 1;
|
||||
|
||||
/* Make a copy of the command string */
|
||||
memcpy(argstr, pCmdStart, iArgLen);
|
||||
argstr[iArgLen] = '\0'; /* Null-terminate */
|
||||
|
||||
/* Store first token (cmd) */
|
||||
argv[argc++] = strtok(argstr, " ");
|
||||
|
||||
/* Store the rest (args) */
|
||||
while (argv[argc-1])
|
||||
argv[argc++] = strtok(NULL, " ");
|
||||
argc--; /* Back off last NULL entry */
|
||||
|
||||
/* Call "real" main() function */
|
||||
return zipmain(argc, argv);
|
||||
|
||||
}
|
||||
#endif /* USE_ZIPMAIN */
|
||||
|
||||
#endif /* !UTIL */
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Function version_local() */
|
||||
/******************************/
|
||||
|
||||
void version_local()
|
||||
{
|
||||
char liblvlmsg [50+1];
|
||||
char *compiler = "?";
|
||||
char *platform = "?";
|
||||
char complevel[64];
|
||||
|
||||
/* Map the runtime library level information */
|
||||
union {
|
||||
unsigned int iVRM;
|
||||
struct {
|
||||
unsigned int pd:4; /* Product designation */
|
||||
unsigned int vv:4; /* Version */
|
||||
unsigned int rr:8; /* Release */
|
||||
unsigned int mm:16; /* Modification level */
|
||||
} xVRM;
|
||||
} VRM;
|
||||
|
||||
|
||||
/* Break down the runtime library level */
|
||||
VRM.iVRM = __librel();
|
||||
sprintf(liblvlmsg, "Using runtime library level %s V%dR%dM%d",
|
||||
(VRM.xVRM.pd==1 ? "LE" : "CE"),
|
||||
VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm);
|
||||
/* Note: LE = Language Environment, CE = Common Env. (C/370). */
|
||||
/* This refers ONLY to the current runtimes, not the compiler. */
|
||||
|
||||
|
||||
#ifdef VM_CMS
|
||||
platform = "VM/CMS";
|
||||
#ifdef __IBMC__
|
||||
compiler = "IBM C";
|
||||
#else
|
||||
compiler = "C/370";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MVS
|
||||
platform = "MVS";
|
||||
#ifdef __IBMC__
|
||||
compiler = "IBM C/C++";
|
||||
#else
|
||||
compiler = "C/370";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __COMPILER_VER__
|
||||
VRM.iVRM = __COMPILER_VER__;
|
||||
sprintf(complevel," V%dR%dM%d",
|
||||
VRM.xVRM.vv, VRM.xVRM.rr, VRM.xVRM.mm);
|
||||
#else
|
||||
#ifdef __IBMC__
|
||||
sprintf(complevel," V%dR%d", __IBMC__ / 100, (__IBMC__ % 100)/10);
|
||||
#else
|
||||
complevel[0] = '\0';
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
printf("Compiled with %s%s for %s%s%s.\n\n",
|
||||
|
||||
/* Add compiler name and level */
|
||||
compiler, complevel,
|
||||
|
||||
/* Add platform */
|
||||
platform,
|
||||
|
||||
/* Add timestamp */
|
||||
#ifdef __DATE__
|
||||
" on " __DATE__
|
||||
#ifdef __TIME__
|
||||
" at " __TIME__
|
||||
#endif
|
||||
#endif
|
||||
".\n",
|
||||
liblvlmsg
|
||||
);
|
||||
} /* end function version_local() */
|
123
third_party/infozip/zip/cmsmvs/cmsmvs.h
vendored
Normal file
123
third_party/infozip/zip/cmsmvs/cmsmvs.h
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/* Include file for VM/CMS and MVS */
|
||||
|
||||
/* This is normally named osdep.h on most systems. Since CMS */
|
||||
/* generally doesn't support directories, it's been given a unique */
|
||||
/* name to avoid confusion. */
|
||||
|
||||
|
||||
#ifndef __cmsmvs_h /* prevent multiple inclusions */
|
||||
#define __cmsmvs_h
|
||||
|
||||
#ifdef MVS
|
||||
# define _POSIX_SOURCE /* tell MVS we want full definitions */
|
||||
# include <features.h>
|
||||
#endif /* MVS */
|
||||
|
||||
#include <time.h> /* the usual non-BSD time functions */
|
||||
/* cstat.h is not required for MVS and actually gets in the way. Is it
|
||||
* needed for CMS?
|
||||
*/
|
||||
#ifdef MVS
|
||||
# include <sys/stat.h>
|
||||
# include <sys/modes.h>
|
||||
#else /* !MVS */
|
||||
# include "cstat.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Newer compiler version defines something for us */
|
||||
#if defined(__VM__) && !defined(VM_CMS)
|
||||
# define VM_CMS
|
||||
#endif
|
||||
|
||||
#define CMS_MVS
|
||||
#define EBCDIC
|
||||
|
||||
#ifndef MVS /* MVS has perfectly good definitions for the following */
|
||||
# define NO_UNISTD_H
|
||||
# define NO_FCNTL_H
|
||||
#endif /*MVS */
|
||||
|
||||
/* If we're generating a stand-alone CMS module, patch in */
|
||||
/* a new main() function before the real main() for arg parsing. */
|
||||
#ifdef CMS_STAND_ALONE
|
||||
# define USE_ZIPMAIN
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#define PASSWD_FROM_STDIN
|
||||
/* Kludge until we know how to open a non-echo tty channel */
|
||||
|
||||
/* definition for ZIP */
|
||||
#define getch() getc(stdin)
|
||||
#define MAXPATHLEN 128
|
||||
#define NO_RMDIR
|
||||
#define NO_MKTEMP
|
||||
#define USE_CASE_MAP
|
||||
#define isatty(t) 1
|
||||
|
||||
#ifndef MVS /* MVS has perfectly good definitions for the following */
|
||||
# define fileno(x) (char *)(x)
|
||||
# define fdopen fopen
|
||||
# define unlink remove
|
||||
# define link rename
|
||||
# define utime(f,t)
|
||||
#endif /*MVS */
|
||||
#ifdef ZCRYPT_INTERNAL
|
||||
# define ZCR_SEED2 (unsigned)3141592654L /* use PI as seed pattern */
|
||||
#endif
|
||||
|
||||
#ifdef MVS
|
||||
# if defined(__CRC32_C)
|
||||
# pragma csect(STATIC,"crc32_s")
|
||||
# elif defined(__DEFLATE_C)
|
||||
# pragma csect(STATIC,"deflat_s")
|
||||
# elif defined(__ZIPFILE_C)
|
||||
# pragma csect(STATIC,"zipfil_s")
|
||||
# elif defined(__ZIPUP_C)
|
||||
# pragma csect(STATIC,"zipup_s")
|
||||
# endif
|
||||
#endif /* MVS */
|
||||
|
||||
/* end defines for ZIP */
|
||||
|
||||
|
||||
|
||||
#if 0 /*$RGH$*/
|
||||
/* RECFM=F, LRECL=1 works for sure */
|
||||
#define FOPR "rb,recfm=fb"
|
||||
#define FOPM "r+"
|
||||
#define FOPW "wb,recfm=fb,lrecl=1"
|
||||
#define FOPWT "w"
|
||||
#endif
|
||||
|
||||
/* Try allowing ZIP files to be RECFM=V with "byteseek" for CMS, recfm=U for MVS */
|
||||
#define FOPR "rb,byteseek"
|
||||
#define FOPM "r+,byteseek"
|
||||
#ifdef MVS
|
||||
#define FOPW "wb,recfm=u,byteseek"
|
||||
#else /* !MVS */
|
||||
#define FOPW "wb,recfm=v,lrecl=32760,byteseek"
|
||||
#endif /* MVS */
|
||||
|
||||
#if 0
|
||||
#define FOPW_TMP "w,byteseek"
|
||||
#else
|
||||
#define FOPW_TMP "w,type=memory(hiperspace)"
|
||||
#endif
|
||||
|
||||
#define CBSZ 0x40000
|
||||
#define ZBSZ 0x40000
|
||||
|
||||
#endif /* !__cmsmvs_h */
|
53
third_party/infozip/zip/cmsmvs/cstat.h
vendored
Normal file
53
third_party/infozip/zip/cmsmvs/cstat.h
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/* cstat.h
|
||||
|
||||
Definitions used for file status functions
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __STAT_H
|
||||
#define __STAT_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define S_IFMT 0xF000 /* file type mask */
|
||||
#define S_IFDIR 0x4000 /* directory */
|
||||
#define S_IFIFO 0x1000 /* FIFO special */
|
||||
#define S_IFCHR 0x2000 /* character special */
|
||||
#define S_IFBLK 0x3000 /* block special */
|
||||
#define S_IFREG 0x8000 /* or just 0x0000, regular */
|
||||
#define S_IREAD 0x0100 /* owner may read */
|
||||
#define S_IWRITE 0x0080 /* owner may write */
|
||||
#define S_IEXEC 0x0040 /* owner may execute <directory search> */
|
||||
|
||||
struct stat
|
||||
{
|
||||
short st_dev; /* Drive number of disk containing the */
|
||||
/* file or file handle if the file is */
|
||||
/* on device */
|
||||
short st_ino; /* Not meaningfull for VM/CMS */
|
||||
short st_mode; /* Bit mask giving information about */
|
||||
/* the file's mode */
|
||||
short st_nlink; /* Set to the integer constant 1 */
|
||||
int st_uid; /* Not meaningfull for VM/CMS */
|
||||
int st_gid; /* Not meaningfull for VM/CMS */
|
||||
short st_rdev; /* Same as st_dev */
|
||||
long st_size; /* Size of the file in bytes */
|
||||
long st_atime; /* Most recent access */
|
||||
long st_mtime; /* Same as st_atime */
|
||||
long st_ctime; /* Same as st_atime */
|
||||
FILE *fp;
|
||||
char fname[FILENAME_MAX];
|
||||
};
|
||||
|
||||
int stat(const char *path, struct stat *sb);
|
||||
int fstat(int fd, struct stat *sb);
|
||||
|
||||
#endif /* __STAT_H */
|
95
third_party/infozip/zip/cmsmvs/mc.exec
vendored
Normal file
95
third_party/infozip/zip/cmsmvs/mc.exec
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* 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:',
|
||||
'| strip both',
|
||||
'| 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' DMSCSL | > 'fn' LINK A'
|
||||
'set cmstype ht'
|
||||
'state 'fn' LINK A'
|
||||
rcc = rc
|
||||
'set cmstype rt'
|
||||
if rcc = 0 then do
|
||||
say ''
|
||||
say 'ERRORS discovered during linking!'
|
||||
say 'See: 'fn' LINK A for more info'
|
||||
end
|
||||
exit rc
|
||||
error:
|
||||
say 'Error in REXX detected!'
|
||||
Say 'Syntax error on line' Sigl':' Sourceline(Sigl)
|
||||
Say 'Error was:' Errortext(RC)
|
||||
return rc
|
221
third_party/infozip/zip/cmsmvs/mvs.c
vendored
Normal file
221
third_party/infozip/zip/cmsmvs/mvs.c
vendored
Normal file
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* MVS specific things
|
||||
*/
|
||||
#include "zip.h"
|
||||
#include "mvs.h"
|
||||
#include <errno.h>
|
||||
|
||||
static int gen_node( DIR *dirp, RECORD *recptr )
|
||||
{
|
||||
char *ptr, *name, ttr[TTRLEN];
|
||||
int skip, count = 2;
|
||||
unsigned int info_byte, alias, ttrn;
|
||||
struct dirent *new;
|
||||
|
||||
ptr = recptr->rest;
|
||||
while (count < recptr->count) {
|
||||
if (!memcmp( ptr, endmark, NAMELEN ))
|
||||
return 1;
|
||||
name = ptr; /* member name */
|
||||
ptr += NAMELEN;
|
||||
memcpy( ttr, ptr, TTRLEN ); /* ttr name */
|
||||
ptr += TTRLEN;
|
||||
info_byte = (unsigned int) (*ptr); /* info byte */
|
||||
if ( !(info_byte & ALIAS_MASK) ) { /* no alias */
|
||||
new = malloc( sizeof(struct dirent) );
|
||||
if (dirp->D_list == NULL)
|
||||
dirp->D_list = dirp->D_curpos = new;
|
||||
else
|
||||
dirp->D_curpos = (dirp->D_curpos->d_next = new);
|
||||
new->d_next = NULL;
|
||||
memcpy( new->d_name, name, NAMELEN );
|
||||
new->d_name[NAMELEN] = '\0';
|
||||
if ((name = strchr( new->d_name, ' ' )) != NULL)
|
||||
*name = '\0'; /* skip trailing blanks */
|
||||
}
|
||||
skip = (info_byte & SKIP_MASK) * 2 + 1;
|
||||
ptr += skip;
|
||||
count += (TTRLEN + NAMELEN + skip);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DIR *opendir(const char *dirname)
|
||||
{
|
||||
int bytes, list_end = 0;
|
||||
DIR *dirp;
|
||||
FILE *fp;
|
||||
RECORD rec;
|
||||
|
||||
fp = fopen( dirname, "rb" );
|
||||
if (fp != NULL) {
|
||||
dirp = malloc( sizeof(DIR) );
|
||||
if (dirp != NULL) {
|
||||
dirp->D_list = dirp->D_curpos = NULL;
|
||||
strcpy( dirp->D_path, dirname );
|
||||
do {
|
||||
bytes = fread( &rec, 1, sizeof(rec), fp );
|
||||
if (bytes == sizeof(rec))
|
||||
list_end = gen_node( dirp, &rec );
|
||||
} while (!feof(fp) && !list_end);
|
||||
fclose( fp );
|
||||
dirp->D_curpos = dirp->D_list;
|
||||
return dirp;
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dirp)
|
||||
{
|
||||
struct dirent *cur;
|
||||
|
||||
cur = dirp->D_curpos;
|
||||
dirp->D_curpos = dirp->D_curpos->d_next;
|
||||
return cur;
|
||||
}
|
||||
|
||||
void rewinddir(DIR *dirp)
|
||||
{
|
||||
dirp->D_curpos = dirp->D_list;
|
||||
}
|
||||
|
||||
int closedir(DIR *dirp)
|
||||
{
|
||||
struct dirent *node;
|
||||
|
||||
while (dirp->D_list != NULL) {
|
||||
node = dirp->D_list;
|
||||
dirp->D_list = dirp->D_list->d_next;
|
||||
free( node );
|
||||
}
|
||||
free( dirp );
|
||||
return 0;
|
||||
}
|
||||
|
||||
local char *readd(d)
|
||||
DIR *d; /* directory stream to read from */
|
||||
/* Return a pointer to the next name in the directory stream d, or NULL if
|
||||
no more entries or an error occurs. */
|
||||
{
|
||||
struct dirent *e;
|
||||
|
||||
e = readdir(d);
|
||||
return e == NULL ? (char *) NULL : e->d_name;
|
||||
}
|
||||
|
||||
int procname(n, caseflag)
|
||||
char *n; /* name to process */
|
||||
int caseflag; /* true to force case-sensitive match */
|
||||
/* Process a name or sh expression to operate on (or exclude). Return
|
||||
an error code in the ZE_ class. */
|
||||
{
|
||||
char *a; /* path and name for recursion */
|
||||
DIR *d; /* directory stream from opendir() */
|
||||
char *e; /* pointer to name from readd() */
|
||||
int m; /* matched flag */
|
||||
char *p; /* path for recursion */
|
||||
struct stat s; /* result of stat() */
|
||||
struct zlist far *z; /* steps through zfiles list */
|
||||
int exists; /* 1 if file exists */
|
||||
|
||||
if (strcmp(n, "-") == 0) /* if compressing stdin */
|
||||
return newname(n, 0, caseflag);
|
||||
else if (!(exists = (LSSTAT(n, &s) == 0)))
|
||||
{
|
||||
#ifdef MVS
|
||||
/* special case for MVS. stat does not work on non-HFS files so if
|
||||
* stat fails with ENOENT, try to open the file for reading anyway.
|
||||
* If the user has no OMVS segment, stat gets an initialization error,
|
||||
* even on external files.
|
||||
*/
|
||||
if (errno == ENOENT || errno == EMVSINITIAL) {
|
||||
FILE *f = fopen(n, "r");
|
||||
if (f) {
|
||||
/* stat got ENOENT but fopen worked, external file */
|
||||
fclose(f);
|
||||
exists = 1;
|
||||
memset(&s, '\0', sizeof(s)); /* stat data is unreliable for externals */
|
||||
s.st_mode = S_IFREG; /* fudge it */
|
||||
}
|
||||
}
|
||||
#endif /* MVS */
|
||||
}
|
||||
if (! exists) {
|
||||
/* Not a file or directory--search for shell expression in zip file */
|
||||
p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */
|
||||
m = 1;
|
||||
for (z = zfiles; z != NULL; z = z->nxt) {
|
||||
if (MATCH(p, z->iname, caseflag))
|
||||
{
|
||||
z->mark = pcount ? filter(z->zname, caseflag) : 1;
|
||||
if (verbose)
|
||||
fprintf(mesg, "zip diagnostic: %scluding %s\n",
|
||||
z->mark ? "in" : "ex", z->name);
|
||||
m = 0;
|
||||
}
|
||||
}
|
||||
free((zvoid *)p);
|
||||
return m ? ZE_MISS : ZE_OK;
|
||||
}
|
||||
|
||||
/* Live name--use if file, recurse if directory */
|
||||
if (!S_ISDIR(s.st_mode))
|
||||
{
|
||||
/* add or remove name of file */
|
||||
if ((m = newname(n, 0, caseflag)) != ZE_OK)
|
||||
return m;
|
||||
} else {
|
||||
/* Add trailing / to the directory name */
|
||||
if ((p = malloc(strlen(n)+2)) == NULL)
|
||||
return ZE_MEM;
|
||||
if (strcmp(n, ".") == 0) {
|
||||
*p = '\0'; /* avoid "./" prefix and do not create zip entry */
|
||||
} else {
|
||||
strcpy(p, n);
|
||||
a = p + strlen(p);
|
||||
if (a[-1] != '/')
|
||||
strcpy(a, "/");
|
||||
if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) {
|
||||
free((zvoid *)p);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
/* recurse into directory */
|
||||
if (recurse && (d = opendir(n)) != NULL)
|
||||
{
|
||||
while ((e = readd(d)) != NULL) {
|
||||
if (strcmp(e, ".") && strcmp(e, ".."))
|
||||
{
|
||||
if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
|
||||
{
|
||||
closedir(d);
|
||||
free((zvoid *)p);
|
||||
return ZE_MEM;
|
||||
}
|
||||
strcat(strcpy(a, p), e);
|
||||
if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */
|
||||
{
|
||||
if (m == ZE_MISS)
|
||||
zipwarn("name not matched: ", a);
|
||||
else
|
||||
ziperr(m, a);
|
||||
}
|
||||
free((zvoid *)a);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
free((zvoid *)p);
|
||||
} /* (s.st_mode & S_IFDIR) == 0) */
|
||||
return ZE_OK;
|
||||
}
|
40
third_party/infozip/zip/cmsmvs/mvs.h
vendored
Normal file
40
third_party/infozip/zip/cmsmvs/mvs.h
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
/* <dirent.h> definitions */
|
||||
|
||||
#define NAMELEN 8
|
||||
|
||||
struct dirent {
|
||||
struct dirent *d_next;
|
||||
char d_name[NAMELEN+1];
|
||||
};
|
||||
|
||||
typedef struct _DIR {
|
||||
struct dirent *D_list;
|
||||
struct dirent *D_curpos;
|
||||
char D_path[FILENAME_MAX];
|
||||
} DIR;
|
||||
|
||||
DIR * opendir(const char *dirname);
|
||||
struct dirent *readdir(DIR *dirp);
|
||||
void rewinddir(DIR *dirp);
|
||||
int closedir(DIR *dirp);
|
||||
char * readd(DIR *dirp);
|
||||
|
||||
#define ALIAS_MASK (unsigned int) 0x80
|
||||
#define SKIP_MASK (unsigned int) 0x1F
|
||||
#define TTRLEN 3
|
||||
#define RECLEN 254
|
||||
|
||||
typedef _Packed struct {
|
||||
unsigned short int count;
|
||||
char rest[RECLEN];
|
||||
} RECORD;
|
||||
|
||||
char *endmark = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
|
125
third_party/infozip/zip/cmsmvs/mvs.mki
vendored
Normal file
125
third_party/infozip/zip/cmsmvs/mvs.mki
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
# Makefile for the MVS (OS/390 Base) version of ZIP 2.3
|
||||
# Produced for C/C++ V3R2 in OS/390 1.2.0 by Ian E. Gorman, 2 Nov 1998
|
||||
# Facilities for compiling and testing were made available by
|
||||
# OmniMark Technologies Corporation, Ottawa, Canada
|
||||
|
||||
# NOTES
|
||||
#
|
||||
# The only tabs in this file are in the first character of each recipe
|
||||
# line, where they are required by make.
|
||||
#
|
||||
# Run this makefile in OpenMVS (OS/390 POSIX) using source files in the
|
||||
# HFS file system. You can write the load module to either HFS file
|
||||
# system or to a PDS in the native MVS file system. The PDS must have
|
||||
# sufficient free space to hold the load module.
|
||||
#
|
||||
# To compile to a member of a PDS:
|
||||
# make
|
||||
# or
|
||||
# make zip.mvs
|
||||
#
|
||||
# To compile a test version into the HFS file system:
|
||||
# make hfs
|
||||
|
||||
# ZIP options -- MVS, REENTRANT
|
||||
ZIPOPTS=-DMVS -DREENTRANT
|
||||
|
||||
# directories
|
||||
|
||||
# generic source code
|
||||
SRC=..
|
||||
SRC_P=$(SRC)/
|
||||
|
||||
# source code for MVS
|
||||
CMSMVS=../cmsmvs
|
||||
CMSMVS_P=$(CMSMVS)/
|
||||
|
||||
# include files
|
||||
INCLS=-I$(SRC) -I$(CMSMVS)
|
||||
|
||||
# object files and load modules
|
||||
BLD_P=../mvs/
|
||||
|
||||
# Other options
|
||||
|
||||
# Suffixes (E and O must be different)
|
||||
E=
|
||||
O=.o
|
||||
|
||||
# Need EXTENDED features for global.c and vmvms.c, so not using c89
|
||||
CC=cc
|
||||
CFLAGS=-D_OPEN_SYS $(ZIPOPTS) $(INCLS)
|
||||
|
||||
LD=cc
|
||||
LDFLAGS=
|
||||
|
||||
# Files
|
||||
|
||||
# object (TEXT) files
|
||||
OBJECTS= $(BLD_P)zip$(O) $(BLD_P)trees$(O) \
|
||||
$(BLD_P)crypt$(O) $(BLD_P)ttyio$(O) $(BLD_P)deflate$(O) \
|
||||
$(BLD_P)fileio$(O) $(BLD_P)globals$(O) $(BLD_P)util$(O) \
|
||||
$(BLD_P)crc32$(O) $(BLD_P)zipfile$(O) \
|
||||
$(BLD_P)zipup$(O) $(BLD_P)cmsmvs$(O) $(BLD_P)mvs$(O)
|
||||
|
||||
# Header files
|
||||
HFILES= $(SRC_P)api.h $(SRC_P)crc32.h $(SRC_P)crypt.h $(SRC_P)ebcdic.h \
|
||||
$(SRC_P)revision.h $(SRC_P)tailor.h $(SRC_P)ttyio.h \
|
||||
$(SRC_P)zip.h $(SRC_P)ziperr.h $(CMSMVS_P)cmsmvs.h \
|
||||
$(CMSMVS_P)cstat.h $(CMSMVS_P)mvs.h $(CMSMVS_P)zipup.h
|
||||
|
||||
# Rules
|
||||
|
||||
all: $(BLD_P)zip.mvs$(E)
|
||||
hfs: $(BLD_P)zip$(E)
|
||||
|
||||
# link
|
||||
|
||||
$(BLD_P)zip.mvs$(E): $(OBJECTS)
|
||||
$(LD) -o "//INFOZIP.LOAD(ZIP)" $(LDFLAGS) $^
|
||||
echo "tso call \"infozip(zip)\" \"'\"\"""$$""@""\"\"'\"" > $%
|
||||
chmod a+x $%
|
||||
|
||||
$(BLD_P)zip$(E): $(OBJECTS)
|
||||
$(LD) -o $% $(LDFLAGS) $^
|
||||
|
||||
# compile
|
||||
|
||||
$(BLD_P)trees$(O): $(SRC_P)trees.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)trees.c
|
||||
|
||||
$(BLD_P)crypt$(O): $(SRC_P)crypt.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)crypt.c
|
||||
|
||||
$(BLD_P)ttyio$(O): $(SRC_P)ttyio.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)ttyio.c
|
||||
|
||||
$(BLD_P)deflate$(O): $(SRC_P)deflate.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)deflate.c
|
||||
|
||||
$(BLD_P)fileio$(O): $(SRC_P)fileio.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)fileio.c
|
||||
|
||||
$(BLD_P)globals$(O): $(SRC_P)globals.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)globals.c
|
||||
|
||||
$(BLD_P)zip$(O): $(SRC_P)zip.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)zip.c
|
||||
|
||||
$(BLD_P)util$(O): $(SRC_P)util.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)util.c
|
||||
|
||||
$(BLD_P)crc32$(O): $(SRC_P)crc32.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)crc32.c
|
||||
|
||||
$(BLD_P)zipfile$(O): $(SRC_P)zipfile.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)zipfile.c
|
||||
|
||||
$(BLD_P)zipup$(O): $(SRC_P)zipup.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(SRC_P)zipup.c
|
||||
|
||||
$(BLD_P)cmsmvs$(O): $(CMSMVS_P)cmsmvs.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(CMSMVS_P)cmsmvs.c
|
||||
|
||||
$(BLD_P)mvs$(O): $(CMSMVS_P)mvs.c $(HFILES)
|
||||
$(CC) -c -o $% $(CFLAGS) $(CMSMVS_P)mvs.c
|
27
third_party/infozip/zip/cmsmvs/pipzip.rexx
vendored
Normal file
27
third_party/infozip/zip/cmsmvs/pipzip.rexx
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* PIPZIP REXX Rexx filter to use ZIP */
|
||||
/* Author : George Petrov, 8 May 1995 */
|
||||
|
||||
parse arg opts
|
||||
'callpipe *:',
|
||||
'| specs w1 1 /./ n w2 n',
|
||||
'| join * / /',
|
||||
'| specs /zip 'opts'/ 1 1-* nw',
|
||||
'| cms',
|
||||
'| *:'
|
||||
|
||||
exit rc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
66
third_party/infozip/zip/cmsmvs/zip.exec
vendored
Normal file
66
third_party/infozip/zip/cmsmvs/zip.exec
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* Front-end EXEC to set up linkage to the C runtime libraries */
|
||||
/* before executing a MODULE generated from C code. */
|
||||
/* */
|
||||
/* Copy this file as an EXEC with a filename matching the C MODULE. */
|
||||
/* */
|
||||
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
Address Command
|
||||
Parse Arg argstring
|
||||
Parse Source . . myname .
|
||||
|
||||
/* Set output and input character translation so brackets show up */
|
||||
'SET OUTPUT AD' 'BA'x
|
||||
'SET OUTPUT BD' 'BB'x
|
||||
'SET INPUT BA AD'
|
||||
'SET INPUT BB BD'
|
||||
|
||||
Call CLIB
|
||||
If rc<>0 Then Do
|
||||
Say 'The required C runtime libraries don''t appear to be available.'
|
||||
Say myname 'can not run.'
|
||||
Exit 12
|
||||
End
|
||||
|
||||
/* Run the command */
|
||||
myname argstring
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
|
||||
/* Contents of the CLIB EXEC, modified for RC checking. */
|
||||
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
|
||||
CLIB:
|
||||
/***************************************************/
|
||||
/* SET UP LIBRARIES FOR LE for MVS & VM */
|
||||
/***************************************************/
|
||||
Address COMMAND
|
||||
|
||||
loadlib ='EDCLINK' /* C/370 runtime */
|
||||
loadlib ='SCEERUN' /* LE runtime */
|
||||
|
||||
|
||||
theirs=queued() /* old stack contentsM068*/
|
||||
'QUERY LOADLIB ( LIFO' /* old setting M068*/
|
||||
LoadlibList='' /* init list M068*/
|
||||
rc=0
|
||||
Do while queued()^=theirs /* all lines from cmdM068*/
|
||||
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
|
||||
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
|
||||
End /*M068*/
|
||||
If loadlibList='NONE' ,
|
||||
Then Do
|
||||
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
|
||||
End
|
||||
Else Do
|
||||
Do xx=1 to Words(loadlib)
|
||||
If Find(loadliblist,word(loadlib,xx)) = 0 ,
|
||||
then loadliblist = loadliblist word(loadlib,xx)
|
||||
End
|
||||
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
|
||||
End
|
||||
Return
|
21
third_party/infozip/zip/cmsmvs/zip.makefile
vendored
Normal file
21
third_party/infozip/zip/cmsmvs/zip.makefile
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
* This is a comment
|
||||
* this makefile compiles filter ZIPME
|
||||
|
||||
GLOBALS:
|
||||
long def(VM_CMS)
|
||||
TEXT:
|
||||
trees c
|
||||
crypt c
|
||||
ttyio c
|
||||
deflate c
|
||||
fileio c
|
||||
globals c
|
||||
zip c
|
||||
util c
|
||||
crc32.c
|
||||
zipfile c
|
||||
zipup c
|
||||
cmsmvs c
|
||||
cms c
|
||||
MODULE:
|
||||
zip module
|
66
third_party/infozip/zip/cmsmvs/zipcloak.exec
vendored
Normal file
66
third_party/infozip/zip/cmsmvs/zipcloak.exec
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* Front-end EXEC to set up linkage to the C runtime libraries */
|
||||
/* before executing a MODULE generated from C code. */
|
||||
/* */
|
||||
/* Copy this file as an EXEC with a filename matching the C MODULE. */
|
||||
/* */
|
||||
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
Address Command
|
||||
Parse Arg argstring
|
||||
Parse Source . . myname .
|
||||
|
||||
/* Set output and input character translation so brackets show up */
|
||||
'SET OUTPUT AD' 'BA'x
|
||||
'SET OUTPUT BD' 'BB'x
|
||||
'SET INPUT BA AD'
|
||||
'SET INPUT BB BD'
|
||||
|
||||
Call CLIB
|
||||
If rc<>0 Then Do
|
||||
Say 'The required C runtime libraries don''t appear to be available.'
|
||||
Say myname 'can not run.'
|
||||
Exit 12
|
||||
End
|
||||
|
||||
/* Run the command */
|
||||
myname argstring
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
|
||||
/* Contents of the CLIB EXEC, modified for RC checking. */
|
||||
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
|
||||
CLIB:
|
||||
/***************************************************/
|
||||
/* SET UP LIBRARIES FOR LE for MVS & VM */
|
||||
/***************************************************/
|
||||
Address COMMAND
|
||||
|
||||
loadlib ='EDCLINK' /* C/370 runtime */
|
||||
loadlib ='SCEERUN' /* LE runtime */
|
||||
|
||||
|
||||
theirs=queued() /* old stack contentsM068*/
|
||||
'QUERY LOADLIB ( LIFO' /* old setting M068*/
|
||||
LoadlibList='' /* init list M068*/
|
||||
rc=0
|
||||
Do while queued()^=theirs /* all lines from cmdM068*/
|
||||
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
|
||||
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
|
||||
End /*M068*/
|
||||
If loadlibList='NONE' ,
|
||||
Then Do
|
||||
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
|
||||
End
|
||||
Else Do
|
||||
Do xx=1 to Words(loadlib)
|
||||
If Find(loadliblist,word(loadlib,xx)) = 0 ,
|
||||
then loadliblist = loadliblist word(loadlib,xx)
|
||||
End
|
||||
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
|
||||
End
|
||||
Return
|
89
third_party/infozip/zip/cmsmvs/zipmvsc.job
vendored
Normal file
89
third_party/infozip/zip/cmsmvs/zipmvsc.job
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
//CCZIP JOB (BI09255),
|
||||
// MSGLEVEL=(1,1),MSGCLASS=C,CLASS=D,NOTIFY=C888090
|
||||
//PROCLIB JCLLIB ORDER=(SYS1.C370.PROCLIB.M24)
|
||||
//ZIP EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(ZIP)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(ZIP),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//CRYPT EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(CRYPT)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(CRYPT),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//TTYIO EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(TTYIO)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(TTYIO),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//TREES EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(TREES)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(TREES),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//DEFLATE EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(DEFLATE)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(DEFLATE),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//FILEIO EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(FILEIO)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(FILEIO),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//GLOBALS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(GLOBALS)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(GLOBALS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//UTIL EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(UTIL)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(UTIL),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//CRC32 EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(CRC32)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(CRC32),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//ZIPFILE EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(ZIPFILE)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(ZIPFILE),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//ZIPUP EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(ZIPUP)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(ZIPUP),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//CMSMVS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(CMSMVS)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(CMSMVS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//MVS EXEC EDCC,COND=(12,LE),CREGSIZ='4M',
|
||||
// INFILE='C888090.ZIP.C(MVS)',
|
||||
// OUTFILE='C888090.ZIP.C.OBJ(MVS),DISP=SHR',
|
||||
// CPARM='LONG,NOTERM,LIST,XREF,SOURCE,OPT(2),DEF(MVS)'
|
||||
//COMPILE.USERLIB DD DSN=C888090.ZIP.H,DISP=SHR
|
||||
//PLINK EXEC PROC=EDCPL,COND=(12,LE),
|
||||
// OUTFILE='C888090.ZIP.LOAD(ZIP),DISP=SHR',
|
||||
// PPARM='NONCAL,MAP',
|
||||
// LPARM='LIST,MAP,XREF'
|
||||
//SYSPRINT DD SYSOUT=*
|
||||
//PLKED.SYSIN DD DSN=C888090.ZIP.C.OBJ(ZIP),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(BITS),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(CRYPT),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(TREES),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(DEFLATE),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(FILEIO),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(GLOBALS),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(UTIL),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(CRC32),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(ZIPFILE),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(ZIPUP),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(CMSMVS),DISP=SHR
|
||||
// DD DSN=C888090.ZIP.C.OBJ(MVS),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
|
200
third_party/infozip/zip/cmsmvs/zipname.conven
vendored
Normal file
200
third_party/infozip/zip/cmsmvs/zipname.conven
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
|
||||
Zip file/directories name convention under MVS
|
||||
---------------------------------------------------
|
||||
Draft 1.1
|
||||
|
||||
|
||||
1. Translating native file names to Zip filenames.
|
||||
|
||||
1.1 Zipping a PDS
|
||||
|
||||
On MVS there are directories called PDS (Partition Data Set) which have
|
||||
the following format : name1.name2.name3(mname)
|
||||
for example: myuserid.unzip.c(unzip)
|
||||
|
||||
So as you see the path delimiter is '.'. Each dir name can be max 8
|
||||
chars long beginning with a number.
|
||||
|
||||
Between '(' and ')' there is the so called member name - it is also 8
|
||||
chars long. This is the actual file name.
|
||||
|
||||
|
||||
1.1.1 Converting MVS PDS name to zip path/filename (status: not implemented)
|
||||
|
||||
The PDS name is converted to zippath as follows:
|
||||
in the zip : name1/name2/mname.name3
|
||||
becomes on MVS: name1.name2.name3(mname)
|
||||
|
||||
|
||||
1.2 Unzipping as PDS (status: implemented)
|
||||
|
||||
When you unzip the file name myuserid/unzip/unzip.c the same process
|
||||
is done backwards, so you get : myuserid.unzip.c(unzip)
|
||||
|
||||
Notice that the file extension is used as last dirname!
|
||||
|
||||
|
||||
1.2 Unzipping to a different PDS (status: implemented)
|
||||
|
||||
You can also use -d option while unzipping for example:
|
||||
unzip mytest myuserid/unzip/unzip.c -dnewdest.test
|
||||
|
||||
then the new name will become:
|
||||
newdest.test.myuserid.unzip.c(unzip)
|
||||
|
||||
Second example:
|
||||
|
||||
unzip mytest myuserid/unzip/*.c -dnewdest.test
|
||||
|
||||
then you get a PDS:
|
||||
newdest.test.myuserid.unzip.c(...)
|
||||
|
||||
with all *.c files in it.
|
||||
|
||||
|
||||
1.3 Zipping a Sequential Dataset (status: not implemented)
|
||||
|
||||
Sequential dataset is a dataset with NO members.
|
||||
Such a dataset is translated from native MVS to zip format by replacing
|
||||
the '.' (points) with '/' (backslash).
|
||||
|
||||
Example:
|
||||
on MVS: name1.name2.name3
|
||||
becomes in the zip : name1/name2/name3
|
||||
|
||||
NOTE : The new filename in the zip has NO extension this way it can be
|
||||
recognised as a Sequential dataset and not a PDS.
|
||||
But this also means that all files in the zip archive that have
|
||||
no extension will be unzipped as Sequential datasets!
|
||||
|
||||
|
||||
1.4 Using a DDNAMES for input. (status: not implemented)
|
||||
|
||||
To use DDNAMES as input file names put a 'dd:' before the ddname:
|
||||
example: zip myzip dd:name1 dd:name2 dd:sales
|
||||
|
||||
In the Zip archive the ddnames are saved as name.DDNAME so if you try
|
||||
the example above you will get in your zip file (when listing it) :
|
||||
|
||||
..size .. date time .. crc .. NAME1.DDNAME
|
||||
..size .. date time .. crc .. NAME2.DDNAME
|
||||
..size .. date time .. crc .. SALES.DDNAME
|
||||
|
||||
|
||||
1.4 Using a DDNAMES as zip name (status: implemented)
|
||||
|
||||
It is allowed to use a DDNAME as zipfile, just put dd: before it
|
||||
example: unzip dd:myzip *.c
|
||||
this will unzip all .c files from ddname myzip
|
||||
|
||||
example2: ZIP DD:MYZIP DD:MANE1 MYSOURCE.C MYDOC.TEXT(ZIPPING)
|
||||
this will zip ddname name1 file mysource.c and PDS mydoc.text(zipping)
|
||||
into as a zip file in the ddname myzip
|
||||
|
||||
|
||||
2. Converting longer path names (unix like) (status: not implemented)
|
||||
to native MVS names.
|
||||
|
||||
When in the zip archive there are dirnames longer that 8 chars they are
|
||||
chopped at the 8 position. For example
|
||||
MyLongZippath/WithLongFileName.text
|
||||
is translated to:
|
||||
MYLONGZI.TEXT(WITHLONG)
|
||||
|
||||
Notice that all chars are converted to uppercase.
|
||||
|
||||
|
||||
2.1 Using special characters (status: implemented)
|
||||
|
||||
Also all '_' (underscore), '+' (plus), '-' (minus), '(' and ')'
|
||||
from the file name/path in the zip archive are skipped because they
|
||||
are not valid in the MVS filenames.
|
||||
|
||||
|
||||
2.2 Numeric file names (status: not implemented)
|
||||
|
||||
On MVS no name can begin with a number, so when a dir/file name begins with
|
||||
one, a leading letter 'N' is inserted. For example:
|
||||
Contents.512
|
||||
becomes:
|
||||
CONTENTS.N512
|
||||
|
||||
|
||||
|
||||
|
||||
Zip file/directories name convention under VM/CMS
|
||||
---------------------------------------------------
|
||||
|
||||
1. Translating native file names to Zip filenames.
|
||||
|
||||
On VM/CMS (not ESA ) there are NO directories so you got only disks
|
||||
and files.
|
||||
|
||||
The file names are delimited with spaces. But for use with unzip/zip
|
||||
you have to use '.' points as delimiters.
|
||||
|
||||
For example on your A disk you have file called PROFILE EXEC
|
||||
if you want to zip it type : zip myzip profile.exec
|
||||
|
||||
If the same file is on your F disk you have to type:
|
||||
zip myzip profile.exec.f
|
||||
|
||||
So as you can see the general format is fname.ftype.fmode
|
||||
|
||||
In the zipfile the disk from which the file comes is not saved!
|
||||
So only the fname.ftype is saved.
|
||||
|
||||
If you unzip and you want to give a different destination disk just use
|
||||
the -d option like:
|
||||
|
||||
unzip mytest *.c -df
|
||||
|
||||
This will unzip all *.c files to your F disk.
|
||||
|
||||
|
||||
2. Converting longer path names (unix like) to native VM/CMS names.
|
||||
|
||||
When in the zip archive there are dirnames longer that 8 chars they are
|
||||
chopped at the 8 position. Also the path is removed. For example
|
||||
Zippath/WithLongFileName.text
|
||||
is translated to:
|
||||
WITHLONG.TEXT
|
||||
|
||||
Notice that all chars are converted to uppercase.
|
||||
|
||||
Also all '+' (plus), '-' (minus), '(' and ')'
|
||||
from the file name/path in the zip archive are skipped because they
|
||||
are not valid in the VM/CMS filenames.
|
||||
|
||||
If there is no extension for the file name in the zip archive, unzip
|
||||
will add .NONAME for example:
|
||||
mypath/dir1/testfile
|
||||
becomes:
|
||||
TESTFILE.NONAME
|
||||
|
||||
3. Future?
|
||||
|
||||
There is also discussion for a new option on ZIP that you can give
|
||||
a virtual directory to be added before each file name that is zipped.
|
||||
|
||||
For example you want to zip a few .c file and put them in the zip
|
||||
structure under the directory 'mydir/test', but you can't create dirs on
|
||||
VM/CMS so you have to the something like:
|
||||
|
||||
ZIP myzip file1.c file2.c -dmydir/test
|
||||
|
||||
and you get in the zip archive files:
|
||||
|
||||
mydir/test/file1.c
|
||||
mydir/test/file2.c
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
|
||||
NOTE: Not all of those functions are implemented in the first beta
|
||||
release of VM/MVS UNZIP/ZIP.
|
||||
|
||||
Every ideas/corrections/bugs will be appreciated.
|
||||
Mail to maillist: Info-ZIP@LISTS.WKU.EDU
|
||||
|
||||
George Petrov
|
66
third_party/infozip/zip/cmsmvs/zipnote.exec
vendored
Normal file
66
third_party/infozip/zip/cmsmvs/zipnote.exec
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* Front-end EXEC to set up linkage to the C runtime libraries */
|
||||
/* before executing a MODULE generated from C code. */
|
||||
/* */
|
||||
/* Copy this file as an EXEC with a filename matching the C MODULE. */
|
||||
/* */
|
||||
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
Address Command
|
||||
Parse Arg argstring
|
||||
Parse Source . . myname .
|
||||
|
||||
/* Set output and input character translation so brackets show up */
|
||||
'SET OUTPUT AD' 'BA'x
|
||||
'SET OUTPUT BD' 'BB'x
|
||||
'SET INPUT BA AD'
|
||||
'SET INPUT BB BD'
|
||||
|
||||
Call CLIB
|
||||
If rc<>0 Then Do
|
||||
Say 'The required C runtime libraries don''t appear to be available.'
|
||||
Say myname 'can not run.'
|
||||
Exit 12
|
||||
End
|
||||
|
||||
/* Run the command */
|
||||
myname argstring
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
|
||||
/* Contents of the CLIB EXEC, modified for RC checking. */
|
||||
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
|
||||
CLIB:
|
||||
/***************************************************/
|
||||
/* SET UP LIBRARIES FOR LE for MVS & VM */
|
||||
/***************************************************/
|
||||
Address COMMAND
|
||||
|
||||
loadlib ='EDCLINK' /* C/370 runtime */
|
||||
loadlib ='SCEERUN' /* LE runtime */
|
||||
|
||||
|
||||
theirs=queued() /* old stack contentsM068*/
|
||||
'QUERY LOADLIB ( LIFO' /* old setting M068*/
|
||||
LoadlibList='' /* init list M068*/
|
||||
rc=0
|
||||
Do while queued()^=theirs /* all lines from cmdM068*/
|
||||
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
|
||||
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
|
||||
End /*M068*/
|
||||
If loadlibList='NONE' ,
|
||||
Then Do
|
||||
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
|
||||
End
|
||||
Else Do
|
||||
Do xx=1 to Words(loadlib)
|
||||
If Find(loadliblist,word(loadlib,xx)) = 0 ,
|
||||
then loadliblist = loadliblist word(loadlib,xx)
|
||||
End
|
||||
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
|
||||
End
|
||||
Return
|
66
third_party/infozip/zip/cmsmvs/zipsplit.exec
vendored
Normal file
66
third_party/infozip/zip/cmsmvs/zipsplit.exec
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* Front-end EXEC to set up linkage to the C runtime libraries */
|
||||
/* before executing a MODULE generated from C code. */
|
||||
/* */
|
||||
/* Copy this file as an EXEC with a filename matching the C MODULE. */
|
||||
/* */
|
||||
/* Greg Hartwig (ghartwig@vnet.ibm.com) 7/31/97, 4/24/98. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
Address Command
|
||||
Parse Arg argstring
|
||||
Parse Source . . myname .
|
||||
|
||||
/* Set output and input character translation so brackets show up */
|
||||
'SET OUTPUT AD' 'BA'x
|
||||
'SET OUTPUT BD' 'BB'x
|
||||
'SET INPUT BA AD'
|
||||
'SET INPUT BB BD'
|
||||
|
||||
Call CLIB
|
||||
If rc<>0 Then Do
|
||||
Say 'The required C runtime libraries don''t appear to be available.'
|
||||
Say myname 'can not run.'
|
||||
Exit 12
|
||||
End
|
||||
|
||||
/* Run the command */
|
||||
myname argstring
|
||||
Exit rc
|
||||
|
||||
|
||||
|
||||
|
||||
/* Contents of the CLIB EXEC, modified for RC checking. */
|
||||
/* Removed TXTLIB setting. Only LOADLIB needed for execution. */
|
||||
CLIB:
|
||||
/***************************************************/
|
||||
/* SET UP LIBRARIES FOR LE for MVS & VM */
|
||||
/***************************************************/
|
||||
Address COMMAND
|
||||
|
||||
loadlib ='EDCLINK' /* C/370 runtime */
|
||||
loadlib ='SCEERUN' /* LE runtime */
|
||||
|
||||
|
||||
theirs=queued() /* old stack contentsM068*/
|
||||
'QUERY LOADLIB ( LIFO' /* old setting M068*/
|
||||
LoadlibList='' /* init list M068*/
|
||||
rc=0
|
||||
Do while queued()^=theirs /* all lines from cmdM068*/
|
||||
Parse upper pull 'LOADLIB' '=' Ltemp /* get one line M068*/
|
||||
LoadlibList= Ltemp Loadliblist /* was stacked LIFO M068*/
|
||||
End /*M068*/
|
||||
If loadlibList='NONE' ,
|
||||
Then Do
|
||||
'GLOBAL LOADLIB' Loadlib /* enforce what we need */
|
||||
End
|
||||
Else Do
|
||||
Do xx=1 to Words(loadlib)
|
||||
If Find(loadliblist,word(loadlib,xx)) = 0 ,
|
||||
then loadliblist = loadliblist word(loadlib,xx)
|
||||
End
|
||||
'GLOBAL LOADLIB' loadliblist /* enforce what we need */
|
||||
End
|
||||
Return
|
18
third_party/infozip/zip/cmsmvs/zipup.h
vendored
Normal file
18
third_party/infozip/zip/cmsmvs/zipup.h
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 1999-Oct-05 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
|
||||
*/
|
||||
#define fhow "r,byteseek"
|
||||
#define fhowb "rb,byteseek"
|
||||
|
||||
#define fbad NULL
|
||||
typedef FILE *ftype;
|
||||
#define zopen(n,p) (ftype)fopen((n),(p))
|
||||
#define zread(f,b,n) fread((b),1,(n),(FILE*)(f))
|
||||
#define zclose(f) fclose((FILE*)(f))
|
||||
#define zerr(f) ferror((FILE*)(f))
|
||||
#define zstdin stdin
|
48
third_party/infozip/zip/cmsmvs/zipvmc.exec
vendored
Normal file
48
third_party/infozip/zip/cmsmvs/zipvmc.exec
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* VMCOMPIL EXEC Unzip compile for VM/CMS */
|
||||
/* Author : George Petrov, 11 Apr 1995 */
|
||||
|
||||
signal on error
|
||||
|
||||
parms = '(long def(VM_CMS)'
|
||||
|
||||
/* Add local parms */
|
||||
parms = parms 'TARGET(COMPAT) SOURCE'
|
||||
|
||||
|
||||
say 'Compiling TREES C...'
|
||||
'cc trees c 'parms
|
||||
say 'Compiling CRYPT C...'
|
||||
'cc crypt c 'parms
|
||||
say 'Compiling TTYIO C...'
|
||||
'cc ttyio c 'parms
|
||||
say 'Compiling DEFLATE C...'
|
||||
'cc deflate c 'parms
|
||||
say 'Compiling FILEIO C...'
|
||||
'cc fileio c 'parms
|
||||
say 'Compiling GLOBALS C...'
|
||||
'cc globals c 'parms
|
||||
say 'Compiling ZIP C...'
|
||||
'cc zip c 'parms
|
||||
say 'Compiling UTIL C...'
|
||||
'cc util c 'parms
|
||||
say 'Compiling CRC32 C...'
|
||||
'cc crc32 c 'parms
|
||||
say 'Compiling ZIPFILE C...'
|
||||
'cc zipfile c 'parms
|
||||
say 'Compiling ZIPUP C...'
|
||||
'cc zipup c 'parms
|
||||
say 'Compiling CMSMVS C...'
|
||||
'cc cmsmvs c 'parms
|
||||
say 'Compiling CMS C...'
|
||||
'cc cms c 'parms
|
||||
|
||||
say 'Linking all files...'
|
||||
'cmod zip zip trees crypt deflate fileio globals ttyio',
|
||||
'util crc32 zipfile zipup cmsmvs cms'
|
||||
say 'All Done!'
|
||||
say "To run enter : ZIP parms"
|
||||
exit rc
|
||||
|
||||
error:
|
||||
say 'Error durring compilation!'
|
||||
exit rc
|
732
third_party/infozip/zip/crc32.c
vendored
Normal file
732
third_party/infozip/zip/crc32.c
vendored
Normal file
|
@ -0,0 +1,732 @@
|
|||
/*
|
||||
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* crc32.c -- compute the CRC-32 of a data stream
|
||||
* Copyright (C) 1995 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
||||
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
|
||||
* tables for updating the shift register in one step with three exclusive-ors
|
||||
* instead of four steps with four exclusive-ors. This results about a factor
|
||||
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
|
||||
*/
|
||||
|
||||
/* $Id: crc32.c,v 2.0 2007/01/07 05:20:36 spc Exp $ */
|
||||
|
||||
#define __CRC32_C /* identifies this source module */
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
|
||||
|
||||
#ifndef ZCONST
|
||||
# define ZCONST const
|
||||
#endif
|
||||
|
||||
#include "crc32.h"
|
||||
|
||||
/* When only the table of precomputed CRC values is needed, only the basic
|
||||
system-independent table containing 256 entries is created; any support
|
||||
for "unfolding" optimization is disabled.
|
||||
*/
|
||||
#if (defined(USE_ZLIB) || defined(CRC_TABLE_ONLY))
|
||||
# ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
# undef IZ_CRCOPTIM_UNFOLDTBL
|
||||
# endif
|
||||
#endif /* (USE_ZLIB || CRC_TABLE_ONLY) */
|
||||
|
||||
#if defined(IZ_CRCOPTIM_UNFOLDTBL)
|
||||
# define CRC_TBLS 4
|
||||
#else
|
||||
# define CRC_TBLS 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Generate tables 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 first (or only) 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.
|
||||
The remaining 3 tables (if IZ_CRCOPTIM_UNFOLDTBL is enabled) allow for
|
||||
word-at-a-time CRC calculation, where a word is four bytes.
|
||||
*/
|
||||
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
|
||||
/* =========================================================================
|
||||
* Make the crc table. This function is needed only if you want to compute
|
||||
* the table dynamically.
|
||||
*/
|
||||
|
||||
local void make_crc_table OF((void));
|
||||
|
||||
#if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT))
|
||||
error: Dynamic allocation of CRC table not safe with reentrant code.
|
||||
#endif /* DYNALLOC_CRCTAB && REENTRANT */
|
||||
|
||||
#ifdef DYNALLOC_CRCTAB
|
||||
local ulg near *crc_table = NULL;
|
||||
# if 0 /* not used, since sizeof("near *") <= sizeof(int) */
|
||||
/* Use this section when access to a "local int" is faster than access to
|
||||
a "local pointer" (e.g.: i86 16bit code with far pointers). */
|
||||
local int crc_table_empty = 1;
|
||||
# define CRC_TABLE_IS_EMPTY (crc_table_empty != 0)
|
||||
# define MARK_CRCTAB_FILLED crc_table_empty = 0
|
||||
# define MARK_CRCTAB_EMPTY crc_table_empty = 1
|
||||
# else
|
||||
/* Use this section on systems where the size of pointers and ints is
|
||||
equal (e.g.: all 32bit systems). */
|
||||
# define CRC_TABLE_IS_EMPTY (crc_table == NULL)
|
||||
# define MARK_CRCTAB_FILLED crc_table = crctab_p
|
||||
# define MARK_CRCTAB_EMPTY crc_table = NULL
|
||||
# endif
|
||||
#else /* !DYNALLOC_CRCTAB */
|
||||
local ulg near crc_table[CRC_TBLS*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 ZCONST 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 (n = 0; n < sizeof(p)/sizeof(uch); n++)
|
||||
xor |= 1L << (31 - p[n]);
|
||||
#else
|
||||
# define xor 0xedb88320L
|
||||
#endif
|
||||
|
||||
#ifdef DYNALLOC_CRCTAB
|
||||
crctab_p = (ulg near *) nearmalloc (CRC_TBLS*256*sizeof(ulg));
|
||||
if (crctab_p == NULL) {
|
||||
ziperr(ZE_MEM, "crc_table allocation");
|
||||
}
|
||||
#endif /* DYNALLOC_CRCTAB */
|
||||
|
||||
/* generate a crc for every 8-bit value */
|
||||
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] = REV_BE(c);
|
||||
}
|
||||
|
||||
#ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
/* generate crc for each value followed by one, two, and three zeros */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crctab_p[n];
|
||||
for (k = 1; k < 4; k++) {
|
||||
c = CRC32(c, 0, crctab_p);
|
||||
crctab_p[k*256+n] = c;
|
||||
}
|
||||
}
|
||||
#endif /* IZ_CRCOPTIM_UNFOLDTBL */
|
||||
|
||||
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[CRC_TBLS*256] = {
|
||||
# ifdef IZ_CRC_BE_OPTIMIZ
|
||||
0x00000000L, 0x96300777L, 0x2c610eeeL, 0xba510999L, 0x19c46d07L,
|
||||
0x8ff46a70L, 0x35a563e9L, 0xa395649eL, 0x3288db0eL, 0xa4b8dc79L,
|
||||
0x1ee9d5e0L, 0x88d9d297L, 0x2b4cb609L, 0xbd7cb17eL, 0x072db8e7L,
|
||||
0x911dbf90L, 0x6410b71dL, 0xf220b06aL, 0x4871b9f3L, 0xde41be84L,
|
||||
0x7dd4da1aL, 0xebe4dd6dL, 0x51b5d4f4L, 0xc785d383L, 0x56986c13L,
|
||||
0xc0a86b64L, 0x7af962fdL, 0xecc9658aL, 0x4f5c0114L, 0xd96c0663L,
|
||||
0x633d0ffaL, 0xf50d088dL, 0xc8206e3bL, 0x5e10694cL, 0xe44160d5L,
|
||||
0x727167a2L, 0xd1e4033cL, 0x47d4044bL, 0xfd850dd2L, 0x6bb50aa5L,
|
||||
0xfaa8b535L, 0x6c98b242L, 0xd6c9bbdbL, 0x40f9bcacL, 0xe36cd832L,
|
||||
0x755cdf45L, 0xcf0dd6dcL, 0x593dd1abL, 0xac30d926L, 0x3a00de51L,
|
||||
0x8051d7c8L, 0x1661d0bfL, 0xb5f4b421L, 0x23c4b356L, 0x9995bacfL,
|
||||
0x0fa5bdb8L, 0x9eb80228L, 0x0888055fL, 0xb2d90cc6L, 0x24e90bb1L,
|
||||
0x877c6f2fL, 0x114c6858L, 0xab1d61c1L, 0x3d2d66b6L, 0x9041dc76L,
|
||||
0x0671db01L, 0xbc20d298L, 0x2a10d5efL, 0x8985b171L, 0x1fb5b606L,
|
||||
0xa5e4bf9fL, 0x33d4b8e8L, 0xa2c90778L, 0x34f9000fL, 0x8ea80996L,
|
||||
0x18980ee1L, 0xbb0d6a7fL, 0x2d3d6d08L, 0x976c6491L, 0x015c63e6L,
|
||||
0xf4516b6bL, 0x62616c1cL, 0xd8306585L, 0x4e0062f2L, 0xed95066cL,
|
||||
0x7ba5011bL, 0xc1f40882L, 0x57c40ff5L, 0xc6d9b065L, 0x50e9b712L,
|
||||
0xeab8be8bL, 0x7c88b9fcL, 0xdf1ddd62L, 0x492dda15L, 0xf37cd38cL,
|
||||
0x654cd4fbL, 0x5861b24dL, 0xce51b53aL, 0x7400bca3L, 0xe230bbd4L,
|
||||
0x41a5df4aL, 0xd795d83dL, 0x6dc4d1a4L, 0xfbf4d6d3L, 0x6ae96943L,
|
||||
0xfcd96e34L, 0x468867adL, 0xd0b860daL, 0x732d0444L, 0xe51d0333L,
|
||||
0x5f4c0aaaL, 0xc97c0dddL, 0x3c710550L, 0xaa410227L, 0x10100bbeL,
|
||||
0x86200cc9L, 0x25b56857L, 0xb3856f20L, 0x09d466b9L, 0x9fe461ceL,
|
||||
0x0ef9de5eL, 0x98c9d929L, 0x2298d0b0L, 0xb4a8d7c7L, 0x173db359L,
|
||||
0x810db42eL, 0x3b5cbdb7L, 0xad6cbac0L, 0x2083b8edL, 0xb6b3bf9aL,
|
||||
0x0ce2b603L, 0x9ad2b174L, 0x3947d5eaL, 0xaf77d29dL, 0x1526db04L,
|
||||
0x8316dc73L, 0x120b63e3L, 0x843b6494L, 0x3e6a6d0dL, 0xa85a6a7aL,
|
||||
0x0bcf0ee4L, 0x9dff0993L, 0x27ae000aL, 0xb19e077dL, 0x44930ff0L,
|
||||
0xd2a30887L, 0x68f2011eL, 0xfec20669L, 0x5d5762f7L, 0xcb676580L,
|
||||
0x71366c19L, 0xe7066b6eL, 0x761bd4feL, 0xe02bd389L, 0x5a7ada10L,
|
||||
0xcc4add67L, 0x6fdfb9f9L, 0xf9efbe8eL, 0x43beb717L, 0xd58eb060L,
|
||||
0xe8a3d6d6L, 0x7e93d1a1L, 0xc4c2d838L, 0x52f2df4fL, 0xf167bbd1L,
|
||||
0x6757bca6L, 0xdd06b53fL, 0x4b36b248L, 0xda2b0dd8L, 0x4c1b0aafL,
|
||||
0xf64a0336L, 0x607a0441L, 0xc3ef60dfL, 0x55df67a8L, 0xef8e6e31L,
|
||||
0x79be6946L, 0x8cb361cbL, 0x1a8366bcL, 0xa0d26f25L, 0x36e26852L,
|
||||
0x95770cccL, 0x03470bbbL, 0xb9160222L, 0x2f260555L, 0xbe3bbac5L,
|
||||
0x280bbdb2L, 0x925ab42bL, 0x046ab35cL, 0xa7ffd7c2L, 0x31cfd0b5L,
|
||||
0x8b9ed92cL, 0x1daede5bL, 0xb0c2649bL, 0x26f263ecL, 0x9ca36a75L,
|
||||
0x0a936d02L, 0xa906099cL, 0x3f360eebL, 0x85670772L, 0x13570005L,
|
||||
0x824abf95L, 0x147ab8e2L, 0xae2bb17bL, 0x381bb60cL, 0x9b8ed292L,
|
||||
0x0dbed5e5L, 0xb7efdc7cL, 0x21dfdb0bL, 0xd4d2d386L, 0x42e2d4f1L,
|
||||
0xf8b3dd68L, 0x6e83da1fL, 0xcd16be81L, 0x5b26b9f6L, 0xe177b06fL,
|
||||
0x7747b718L, 0xe65a0888L, 0x706a0fffL, 0xca3b0666L, 0x5c0b0111L,
|
||||
0xff9e658fL, 0x69ae62f8L, 0xd3ff6b61L, 0x45cf6c16L, 0x78e20aa0L,
|
||||
0xeed20dd7L, 0x5483044eL, 0xc2b30339L, 0x612667a7L, 0xf71660d0L,
|
||||
0x4d476949L, 0xdb776e3eL, 0x4a6ad1aeL, 0xdc5ad6d9L, 0x660bdf40L,
|
||||
0xf03bd837L, 0x53aebca9L, 0xc59ebbdeL, 0x7fcfb247L, 0xe9ffb530L,
|
||||
0x1cf2bdbdL, 0x8ac2bacaL, 0x3093b353L, 0xa6a3b424L, 0x0536d0baL,
|
||||
0x9306d7cdL, 0x2957de54L, 0xbf67d923L, 0x2e7a66b3L, 0xb84a61c4L,
|
||||
0x021b685dL, 0x942b6f2aL, 0x37be0bb4L, 0xa18e0cc3L, 0x1bdf055aL,
|
||||
0x8def022dL
|
||||
# ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
,
|
||||
0x00000000L, 0x41311b19L, 0x82623632L, 0xc3532d2bL, 0x04c56c64L,
|
||||
0x45f4777dL, 0x86a75a56L, 0xc796414fL, 0x088ad9c8L, 0x49bbc2d1L,
|
||||
0x8ae8effaL, 0xcbd9f4e3L, 0x0c4fb5acL, 0x4d7eaeb5L, 0x8e2d839eL,
|
||||
0xcf1c9887L, 0x5112c24aL, 0x1023d953L, 0xd370f478L, 0x9241ef61L,
|
||||
0x55d7ae2eL, 0x14e6b537L, 0xd7b5981cL, 0x96848305L, 0x59981b82L,
|
||||
0x18a9009bL, 0xdbfa2db0L, 0x9acb36a9L, 0x5d5d77e6L, 0x1c6c6cffL,
|
||||
0xdf3f41d4L, 0x9e0e5acdL, 0xa2248495L, 0xe3159f8cL, 0x2046b2a7L,
|
||||
0x6177a9beL, 0xa6e1e8f1L, 0xe7d0f3e8L, 0x2483dec3L, 0x65b2c5daL,
|
||||
0xaaae5d5dL, 0xeb9f4644L, 0x28cc6b6fL, 0x69fd7076L, 0xae6b3139L,
|
||||
0xef5a2a20L, 0x2c09070bL, 0x6d381c12L, 0xf33646dfL, 0xb2075dc6L,
|
||||
0x715470edL, 0x30656bf4L, 0xf7f32abbL, 0xb6c231a2L, 0x75911c89L,
|
||||
0x34a00790L, 0xfbbc9f17L, 0xba8d840eL, 0x79dea925L, 0x38efb23cL,
|
||||
0xff79f373L, 0xbe48e86aL, 0x7d1bc541L, 0x3c2ade58L, 0x054f79f0L,
|
||||
0x447e62e9L, 0x872d4fc2L, 0xc61c54dbL, 0x018a1594L, 0x40bb0e8dL,
|
||||
0x83e823a6L, 0xc2d938bfL, 0x0dc5a038L, 0x4cf4bb21L, 0x8fa7960aL,
|
||||
0xce968d13L, 0x0900cc5cL, 0x4831d745L, 0x8b62fa6eL, 0xca53e177L,
|
||||
0x545dbbbaL, 0x156ca0a3L, 0xd63f8d88L, 0x970e9691L, 0x5098d7deL,
|
||||
0x11a9ccc7L, 0xd2fae1ecL, 0x93cbfaf5L, 0x5cd76272L, 0x1de6796bL,
|
||||
0xdeb55440L, 0x9f844f59L, 0x58120e16L, 0x1923150fL, 0xda703824L,
|
||||
0x9b41233dL, 0xa76bfd65L, 0xe65ae67cL, 0x2509cb57L, 0x6438d04eL,
|
||||
0xa3ae9101L, 0xe29f8a18L, 0x21cca733L, 0x60fdbc2aL, 0xafe124adL,
|
||||
0xeed03fb4L, 0x2d83129fL, 0x6cb20986L, 0xab2448c9L, 0xea1553d0L,
|
||||
0x29467efbL, 0x687765e2L, 0xf6793f2fL, 0xb7482436L, 0x741b091dL,
|
||||
0x352a1204L, 0xf2bc534bL, 0xb38d4852L, 0x70de6579L, 0x31ef7e60L,
|
||||
0xfef3e6e7L, 0xbfc2fdfeL, 0x7c91d0d5L, 0x3da0cbccL, 0xfa368a83L,
|
||||
0xbb07919aL, 0x7854bcb1L, 0x3965a7a8L, 0x4b98833bL, 0x0aa99822L,
|
||||
0xc9fab509L, 0x88cbae10L, 0x4f5def5fL, 0x0e6cf446L, 0xcd3fd96dL,
|
||||
0x8c0ec274L, 0x43125af3L, 0x022341eaL, 0xc1706cc1L, 0x804177d8L,
|
||||
0x47d73697L, 0x06e62d8eL, 0xc5b500a5L, 0x84841bbcL, 0x1a8a4171L,
|
||||
0x5bbb5a68L, 0x98e87743L, 0xd9d96c5aL, 0x1e4f2d15L, 0x5f7e360cL,
|
||||
0x9c2d1b27L, 0xdd1c003eL, 0x120098b9L, 0x533183a0L, 0x9062ae8bL,
|
||||
0xd153b592L, 0x16c5f4ddL, 0x57f4efc4L, 0x94a7c2efL, 0xd596d9f6L,
|
||||
0xe9bc07aeL, 0xa88d1cb7L, 0x6bde319cL, 0x2aef2a85L, 0xed796bcaL,
|
||||
0xac4870d3L, 0x6f1b5df8L, 0x2e2a46e1L, 0xe136de66L, 0xa007c57fL,
|
||||
0x6354e854L, 0x2265f34dL, 0xe5f3b202L, 0xa4c2a91bL, 0x67918430L,
|
||||
0x26a09f29L, 0xb8aec5e4L, 0xf99fdefdL, 0x3accf3d6L, 0x7bfde8cfL,
|
||||
0xbc6ba980L, 0xfd5ab299L, 0x3e099fb2L, 0x7f3884abL, 0xb0241c2cL,
|
||||
0xf1150735L, 0x32462a1eL, 0x73773107L, 0xb4e17048L, 0xf5d06b51L,
|
||||
0x3683467aL, 0x77b25d63L, 0x4ed7facbL, 0x0fe6e1d2L, 0xccb5ccf9L,
|
||||
0x8d84d7e0L, 0x4a1296afL, 0x0b238db6L, 0xc870a09dL, 0x8941bb84L,
|
||||
0x465d2303L, 0x076c381aL, 0xc43f1531L, 0x850e0e28L, 0x42984f67L,
|
||||
0x03a9547eL, 0xc0fa7955L, 0x81cb624cL, 0x1fc53881L, 0x5ef42398L,
|
||||
0x9da70eb3L, 0xdc9615aaL, 0x1b0054e5L, 0x5a314ffcL, 0x996262d7L,
|
||||
0xd85379ceL, 0x174fe149L, 0x567efa50L, 0x952dd77bL, 0xd41ccc62L,
|
||||
0x138a8d2dL, 0x52bb9634L, 0x91e8bb1fL, 0xd0d9a006L, 0xecf37e5eL,
|
||||
0xadc26547L, 0x6e91486cL, 0x2fa05375L, 0xe836123aL, 0xa9070923L,
|
||||
0x6a542408L, 0x2b653f11L, 0xe479a796L, 0xa548bc8fL, 0x661b91a4L,
|
||||
0x272a8abdL, 0xe0bccbf2L, 0xa18dd0ebL, 0x62defdc0L, 0x23efe6d9L,
|
||||
0xbde1bc14L, 0xfcd0a70dL, 0x3f838a26L, 0x7eb2913fL, 0xb924d070L,
|
||||
0xf815cb69L, 0x3b46e642L, 0x7a77fd5bL, 0xb56b65dcL, 0xf45a7ec5L,
|
||||
0x370953eeL, 0x763848f7L, 0xb1ae09b8L, 0xf09f12a1L, 0x33cc3f8aL,
|
||||
0x72fd2493L
|
||||
,
|
||||
0x00000000L, 0x376ac201L, 0x6ed48403L, 0x59be4602L, 0xdca80907L,
|
||||
0xebc2cb06L, 0xb27c8d04L, 0x85164f05L, 0xb851130eL, 0x8f3bd10fL,
|
||||
0xd685970dL, 0xe1ef550cL, 0x64f91a09L, 0x5393d808L, 0x0a2d9e0aL,
|
||||
0x3d475c0bL, 0x70a3261cL, 0x47c9e41dL, 0x1e77a21fL, 0x291d601eL,
|
||||
0xac0b2f1bL, 0x9b61ed1aL, 0xc2dfab18L, 0xf5b56919L, 0xc8f23512L,
|
||||
0xff98f713L, 0xa626b111L, 0x914c7310L, 0x145a3c15L, 0x2330fe14L,
|
||||
0x7a8eb816L, 0x4de47a17L, 0xe0464d38L, 0xd72c8f39L, 0x8e92c93bL,
|
||||
0xb9f80b3aL, 0x3cee443fL, 0x0b84863eL, 0x523ac03cL, 0x6550023dL,
|
||||
0x58175e36L, 0x6f7d9c37L, 0x36c3da35L, 0x01a91834L, 0x84bf5731L,
|
||||
0xb3d59530L, 0xea6bd332L, 0xdd011133L, 0x90e56b24L, 0xa78fa925L,
|
||||
0xfe31ef27L, 0xc95b2d26L, 0x4c4d6223L, 0x7b27a022L, 0x2299e620L,
|
||||
0x15f32421L, 0x28b4782aL, 0x1fdeba2bL, 0x4660fc29L, 0x710a3e28L,
|
||||
0xf41c712dL, 0xc376b32cL, 0x9ac8f52eL, 0xada2372fL, 0xc08d9a70L,
|
||||
0xf7e75871L, 0xae591e73L, 0x9933dc72L, 0x1c259377L, 0x2b4f5176L,
|
||||
0x72f11774L, 0x459bd575L, 0x78dc897eL, 0x4fb64b7fL, 0x16080d7dL,
|
||||
0x2162cf7cL, 0xa4748079L, 0x931e4278L, 0xcaa0047aL, 0xfdcac67bL,
|
||||
0xb02ebc6cL, 0x87447e6dL, 0xdefa386fL, 0xe990fa6eL, 0x6c86b56bL,
|
||||
0x5bec776aL, 0x02523168L, 0x3538f369L, 0x087faf62L, 0x3f156d63L,
|
||||
0x66ab2b61L, 0x51c1e960L, 0xd4d7a665L, 0xe3bd6464L, 0xba032266L,
|
||||
0x8d69e067L, 0x20cbd748L, 0x17a11549L, 0x4e1f534bL, 0x7975914aL,
|
||||
0xfc63de4fL, 0xcb091c4eL, 0x92b75a4cL, 0xa5dd984dL, 0x989ac446L,
|
||||
0xaff00647L, 0xf64e4045L, 0xc1248244L, 0x4432cd41L, 0x73580f40L,
|
||||
0x2ae64942L, 0x1d8c8b43L, 0x5068f154L, 0x67023355L, 0x3ebc7557L,
|
||||
0x09d6b756L, 0x8cc0f853L, 0xbbaa3a52L, 0xe2147c50L, 0xd57ebe51L,
|
||||
0xe839e25aL, 0xdf53205bL, 0x86ed6659L, 0xb187a458L, 0x3491eb5dL,
|
||||
0x03fb295cL, 0x5a456f5eL, 0x6d2fad5fL, 0x801b35e1L, 0xb771f7e0L,
|
||||
0xeecfb1e2L, 0xd9a573e3L, 0x5cb33ce6L, 0x6bd9fee7L, 0x3267b8e5L,
|
||||
0x050d7ae4L, 0x384a26efL, 0x0f20e4eeL, 0x569ea2ecL, 0x61f460edL,
|
||||
0xe4e22fe8L, 0xd388ede9L, 0x8a36abebL, 0xbd5c69eaL, 0xf0b813fdL,
|
||||
0xc7d2d1fcL, 0x9e6c97feL, 0xa90655ffL, 0x2c101afaL, 0x1b7ad8fbL,
|
||||
0x42c49ef9L, 0x75ae5cf8L, 0x48e900f3L, 0x7f83c2f2L, 0x263d84f0L,
|
||||
0x115746f1L, 0x944109f4L, 0xa32bcbf5L, 0xfa958df7L, 0xcdff4ff6L,
|
||||
0x605d78d9L, 0x5737bad8L, 0x0e89fcdaL, 0x39e33edbL, 0xbcf571deL,
|
||||
0x8b9fb3dfL, 0xd221f5ddL, 0xe54b37dcL, 0xd80c6bd7L, 0xef66a9d6L,
|
||||
0xb6d8efd4L, 0x81b22dd5L, 0x04a462d0L, 0x33cea0d1L, 0x6a70e6d3L,
|
||||
0x5d1a24d2L, 0x10fe5ec5L, 0x27949cc4L, 0x7e2adac6L, 0x494018c7L,
|
||||
0xcc5657c2L, 0xfb3c95c3L, 0xa282d3c1L, 0x95e811c0L, 0xa8af4dcbL,
|
||||
0x9fc58fcaL, 0xc67bc9c8L, 0xf1110bc9L, 0x740744ccL, 0x436d86cdL,
|
||||
0x1ad3c0cfL, 0x2db902ceL, 0x4096af91L, 0x77fc6d90L, 0x2e422b92L,
|
||||
0x1928e993L, 0x9c3ea696L, 0xab546497L, 0xf2ea2295L, 0xc580e094L,
|
||||
0xf8c7bc9fL, 0xcfad7e9eL, 0x9613389cL, 0xa179fa9dL, 0x246fb598L,
|
||||
0x13057799L, 0x4abb319bL, 0x7dd1f39aL, 0x3035898dL, 0x075f4b8cL,
|
||||
0x5ee10d8eL, 0x698bcf8fL, 0xec9d808aL, 0xdbf7428bL, 0x82490489L,
|
||||
0xb523c688L, 0x88649a83L, 0xbf0e5882L, 0xe6b01e80L, 0xd1dadc81L,
|
||||
0x54cc9384L, 0x63a65185L, 0x3a181787L, 0x0d72d586L, 0xa0d0e2a9L,
|
||||
0x97ba20a8L, 0xce0466aaL, 0xf96ea4abL, 0x7c78ebaeL, 0x4b1229afL,
|
||||
0x12ac6fadL, 0x25c6adacL, 0x1881f1a7L, 0x2feb33a6L, 0x765575a4L,
|
||||
0x413fb7a5L, 0xc429f8a0L, 0xf3433aa1L, 0xaafd7ca3L, 0x9d97bea2L,
|
||||
0xd073c4b5L, 0xe71906b4L, 0xbea740b6L, 0x89cd82b7L, 0x0cdbcdb2L,
|
||||
0x3bb10fb3L, 0x620f49b1L, 0x55658bb0L, 0x6822d7bbL, 0x5f4815baL,
|
||||
0x06f653b8L, 0x319c91b9L, 0xb48adebcL, 0x83e01cbdL, 0xda5e5abfL,
|
||||
0xed3498beL
|
||||
,
|
||||
0x00000000L, 0x6567bcb8L, 0x8bc809aaL, 0xeeafb512L, 0x5797628fL,
|
||||
0x32f0de37L, 0xdc5f6b25L, 0xb938d79dL, 0xef28b4c5L, 0x8a4f087dL,
|
||||
0x64e0bd6fL, 0x018701d7L, 0xb8bfd64aL, 0xddd86af2L, 0x3377dfe0L,
|
||||
0x56106358L, 0x9f571950L, 0xfa30a5e8L, 0x149f10faL, 0x71f8ac42L,
|
||||
0xc8c07bdfL, 0xada7c767L, 0x43087275L, 0x266fcecdL, 0x707fad95L,
|
||||
0x1518112dL, 0xfbb7a43fL, 0x9ed01887L, 0x27e8cf1aL, 0x428f73a2L,
|
||||
0xac20c6b0L, 0xc9477a08L, 0x3eaf32a0L, 0x5bc88e18L, 0xb5673b0aL,
|
||||
0xd00087b2L, 0x6938502fL, 0x0c5fec97L, 0xe2f05985L, 0x8797e53dL,
|
||||
0xd1878665L, 0xb4e03addL, 0x5a4f8fcfL, 0x3f283377L, 0x8610e4eaL,
|
||||
0xe3775852L, 0x0dd8ed40L, 0x68bf51f8L, 0xa1f82bf0L, 0xc49f9748L,
|
||||
0x2a30225aL, 0x4f579ee2L, 0xf66f497fL, 0x9308f5c7L, 0x7da740d5L,
|
||||
0x18c0fc6dL, 0x4ed09f35L, 0x2bb7238dL, 0xc518969fL, 0xa07f2a27L,
|
||||
0x1947fdbaL, 0x7c204102L, 0x928ff410L, 0xf7e848a8L, 0x3d58149bL,
|
||||
0x583fa823L, 0xb6901d31L, 0xd3f7a189L, 0x6acf7614L, 0x0fa8caacL,
|
||||
0xe1077fbeL, 0x8460c306L, 0xd270a05eL, 0xb7171ce6L, 0x59b8a9f4L,
|
||||
0x3cdf154cL, 0x85e7c2d1L, 0xe0807e69L, 0x0e2fcb7bL, 0x6b4877c3L,
|
||||
0xa20f0dcbL, 0xc768b173L, 0x29c70461L, 0x4ca0b8d9L, 0xf5986f44L,
|
||||
0x90ffd3fcL, 0x7e5066eeL, 0x1b37da56L, 0x4d27b90eL, 0x284005b6L,
|
||||
0xc6efb0a4L, 0xa3880c1cL, 0x1ab0db81L, 0x7fd76739L, 0x9178d22bL,
|
||||
0xf41f6e93L, 0x03f7263bL, 0x66909a83L, 0x883f2f91L, 0xed589329L,
|
||||
0x546044b4L, 0x3107f80cL, 0xdfa84d1eL, 0xbacff1a6L, 0xecdf92feL,
|
||||
0x89b82e46L, 0x67179b54L, 0x027027ecL, 0xbb48f071L, 0xde2f4cc9L,
|
||||
0x3080f9dbL, 0x55e74563L, 0x9ca03f6bL, 0xf9c783d3L, 0x176836c1L,
|
||||
0x720f8a79L, 0xcb375de4L, 0xae50e15cL, 0x40ff544eL, 0x2598e8f6L,
|
||||
0x73888baeL, 0x16ef3716L, 0xf8408204L, 0x9d273ebcL, 0x241fe921L,
|
||||
0x41785599L, 0xafd7e08bL, 0xcab05c33L, 0x3bb659edL, 0x5ed1e555L,
|
||||
0xb07e5047L, 0xd519ecffL, 0x6c213b62L, 0x094687daL, 0xe7e932c8L,
|
||||
0x828e8e70L, 0xd49eed28L, 0xb1f95190L, 0x5f56e482L, 0x3a31583aL,
|
||||
0x83098fa7L, 0xe66e331fL, 0x08c1860dL, 0x6da63ab5L, 0xa4e140bdL,
|
||||
0xc186fc05L, 0x2f294917L, 0x4a4ef5afL, 0xf3762232L, 0x96119e8aL,
|
||||
0x78be2b98L, 0x1dd99720L, 0x4bc9f478L, 0x2eae48c0L, 0xc001fdd2L,
|
||||
0xa566416aL, 0x1c5e96f7L, 0x79392a4fL, 0x97969f5dL, 0xf2f123e5L,
|
||||
0x05196b4dL, 0x607ed7f5L, 0x8ed162e7L, 0xebb6de5fL, 0x528e09c2L,
|
||||
0x37e9b57aL, 0xd9460068L, 0xbc21bcd0L, 0xea31df88L, 0x8f566330L,
|
||||
0x61f9d622L, 0x049e6a9aL, 0xbda6bd07L, 0xd8c101bfL, 0x366eb4adL,
|
||||
0x53090815L, 0x9a4e721dL, 0xff29cea5L, 0x11867bb7L, 0x74e1c70fL,
|
||||
0xcdd91092L, 0xa8beac2aL, 0x46111938L, 0x2376a580L, 0x7566c6d8L,
|
||||
0x10017a60L, 0xfeaecf72L, 0x9bc973caL, 0x22f1a457L, 0x479618efL,
|
||||
0xa939adfdL, 0xcc5e1145L, 0x06ee4d76L, 0x6389f1ceL, 0x8d2644dcL,
|
||||
0xe841f864L, 0x51792ff9L, 0x341e9341L, 0xdab12653L, 0xbfd69aebL,
|
||||
0xe9c6f9b3L, 0x8ca1450bL, 0x620ef019L, 0x07694ca1L, 0xbe519b3cL,
|
||||
0xdb362784L, 0x35999296L, 0x50fe2e2eL, 0x99b95426L, 0xfcdee89eL,
|
||||
0x12715d8cL, 0x7716e134L, 0xce2e36a9L, 0xab498a11L, 0x45e63f03L,
|
||||
0x208183bbL, 0x7691e0e3L, 0x13f65c5bL, 0xfd59e949L, 0x983e55f1L,
|
||||
0x2106826cL, 0x44613ed4L, 0xaace8bc6L, 0xcfa9377eL, 0x38417fd6L,
|
||||
0x5d26c36eL, 0xb389767cL, 0xd6eecac4L, 0x6fd61d59L, 0x0ab1a1e1L,
|
||||
0xe41e14f3L, 0x8179a84bL, 0xd769cb13L, 0xb20e77abL, 0x5ca1c2b9L,
|
||||
0x39c67e01L, 0x80fea99cL, 0xe5991524L, 0x0b36a036L, 0x6e511c8eL,
|
||||
0xa7166686L, 0xc271da3eL, 0x2cde6f2cL, 0x49b9d394L, 0xf0810409L,
|
||||
0x95e6b8b1L, 0x7b490da3L, 0x1e2eb11bL, 0x483ed243L, 0x2d596efbL,
|
||||
0xc3f6dbe9L, 0xa6916751L, 0x1fa9b0ccL, 0x7ace0c74L, 0x9461b966L,
|
||||
0xf10605deL
|
||||
# endif /* IZ_CRCOPTIM_UNFOLDTBL */
|
||||
# else /* !IZ_CRC_BE_OPTIMIZ */
|
||||
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
|
||||
# ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
,
|
||||
0x00000000L, 0x191b3141L, 0x32366282L, 0x2b2d53c3L, 0x646cc504L,
|
||||
0x7d77f445L, 0x565aa786L, 0x4f4196c7L, 0xc8d98a08L, 0xd1c2bb49L,
|
||||
0xfaefe88aL, 0xe3f4d9cbL, 0xacb54f0cL, 0xb5ae7e4dL, 0x9e832d8eL,
|
||||
0x87981ccfL, 0x4ac21251L, 0x53d92310L, 0x78f470d3L, 0x61ef4192L,
|
||||
0x2eaed755L, 0x37b5e614L, 0x1c98b5d7L, 0x05838496L, 0x821b9859L,
|
||||
0x9b00a918L, 0xb02dfadbL, 0xa936cb9aL, 0xe6775d5dL, 0xff6c6c1cL,
|
||||
0xd4413fdfL, 0xcd5a0e9eL, 0x958424a2L, 0x8c9f15e3L, 0xa7b24620L,
|
||||
0xbea97761L, 0xf1e8e1a6L, 0xe8f3d0e7L, 0xc3de8324L, 0xdac5b265L,
|
||||
0x5d5daeaaL, 0x44469febL, 0x6f6bcc28L, 0x7670fd69L, 0x39316baeL,
|
||||
0x202a5aefL, 0x0b07092cL, 0x121c386dL, 0xdf4636f3L, 0xc65d07b2L,
|
||||
0xed705471L, 0xf46b6530L, 0xbb2af3f7L, 0xa231c2b6L, 0x891c9175L,
|
||||
0x9007a034L, 0x179fbcfbL, 0x0e848dbaL, 0x25a9de79L, 0x3cb2ef38L,
|
||||
0x73f379ffL, 0x6ae848beL, 0x41c51b7dL, 0x58de2a3cL, 0xf0794f05L,
|
||||
0xe9627e44L, 0xc24f2d87L, 0xdb541cc6L, 0x94158a01L, 0x8d0ebb40L,
|
||||
0xa623e883L, 0xbf38d9c2L, 0x38a0c50dL, 0x21bbf44cL, 0x0a96a78fL,
|
||||
0x138d96ceL, 0x5ccc0009L, 0x45d73148L, 0x6efa628bL, 0x77e153caL,
|
||||
0xbabb5d54L, 0xa3a06c15L, 0x888d3fd6L, 0x91960e97L, 0xded79850L,
|
||||
0xc7cca911L, 0xece1fad2L, 0xf5facb93L, 0x7262d75cL, 0x6b79e61dL,
|
||||
0x4054b5deL, 0x594f849fL, 0x160e1258L, 0x0f152319L, 0x243870daL,
|
||||
0x3d23419bL, 0x65fd6ba7L, 0x7ce65ae6L, 0x57cb0925L, 0x4ed03864L,
|
||||
0x0191aea3L, 0x188a9fe2L, 0x33a7cc21L, 0x2abcfd60L, 0xad24e1afL,
|
||||
0xb43fd0eeL, 0x9f12832dL, 0x8609b26cL, 0xc94824abL, 0xd05315eaL,
|
||||
0xfb7e4629L, 0xe2657768L, 0x2f3f79f6L, 0x362448b7L, 0x1d091b74L,
|
||||
0x04122a35L, 0x4b53bcf2L, 0x52488db3L, 0x7965de70L, 0x607eef31L,
|
||||
0xe7e6f3feL, 0xfefdc2bfL, 0xd5d0917cL, 0xcccba03dL, 0x838a36faL,
|
||||
0x9a9107bbL, 0xb1bc5478L, 0xa8a76539L, 0x3b83984bL, 0x2298a90aL,
|
||||
0x09b5fac9L, 0x10aecb88L, 0x5fef5d4fL, 0x46f46c0eL, 0x6dd93fcdL,
|
||||
0x74c20e8cL, 0xf35a1243L, 0xea412302L, 0xc16c70c1L, 0xd8774180L,
|
||||
0x9736d747L, 0x8e2de606L, 0xa500b5c5L, 0xbc1b8484L, 0x71418a1aL,
|
||||
0x685abb5bL, 0x4377e898L, 0x5a6cd9d9L, 0x152d4f1eL, 0x0c367e5fL,
|
||||
0x271b2d9cL, 0x3e001cddL, 0xb9980012L, 0xa0833153L, 0x8bae6290L,
|
||||
0x92b553d1L, 0xddf4c516L, 0xc4eff457L, 0xefc2a794L, 0xf6d996d5L,
|
||||
0xae07bce9L, 0xb71c8da8L, 0x9c31de6bL, 0x852aef2aL, 0xca6b79edL,
|
||||
0xd37048acL, 0xf85d1b6fL, 0xe1462a2eL, 0x66de36e1L, 0x7fc507a0L,
|
||||
0x54e85463L, 0x4df36522L, 0x02b2f3e5L, 0x1ba9c2a4L, 0x30849167L,
|
||||
0x299fa026L, 0xe4c5aeb8L, 0xfdde9ff9L, 0xd6f3cc3aL, 0xcfe8fd7bL,
|
||||
0x80a96bbcL, 0x99b25afdL, 0xb29f093eL, 0xab84387fL, 0x2c1c24b0L,
|
||||
0x350715f1L, 0x1e2a4632L, 0x07317773L, 0x4870e1b4L, 0x516bd0f5L,
|
||||
0x7a468336L, 0x635db277L, 0xcbfad74eL, 0xd2e1e60fL, 0xf9ccb5ccL,
|
||||
0xe0d7848dL, 0xaf96124aL, 0xb68d230bL, 0x9da070c8L, 0x84bb4189L,
|
||||
0x03235d46L, 0x1a386c07L, 0x31153fc4L, 0x280e0e85L, 0x674f9842L,
|
||||
0x7e54a903L, 0x5579fac0L, 0x4c62cb81L, 0x8138c51fL, 0x9823f45eL,
|
||||
0xb30ea79dL, 0xaa1596dcL, 0xe554001bL, 0xfc4f315aL, 0xd7626299L,
|
||||
0xce7953d8L, 0x49e14f17L, 0x50fa7e56L, 0x7bd72d95L, 0x62cc1cd4L,
|
||||
0x2d8d8a13L, 0x3496bb52L, 0x1fbbe891L, 0x06a0d9d0L, 0x5e7ef3ecL,
|
||||
0x4765c2adL, 0x6c48916eL, 0x7553a02fL, 0x3a1236e8L, 0x230907a9L,
|
||||
0x0824546aL, 0x113f652bL, 0x96a779e4L, 0x8fbc48a5L, 0xa4911b66L,
|
||||
0xbd8a2a27L, 0xf2cbbce0L, 0xebd08da1L, 0xc0fdde62L, 0xd9e6ef23L,
|
||||
0x14bce1bdL, 0x0da7d0fcL, 0x268a833fL, 0x3f91b27eL, 0x70d024b9L,
|
||||
0x69cb15f8L, 0x42e6463bL, 0x5bfd777aL, 0xdc656bb5L, 0xc57e5af4L,
|
||||
0xee530937L, 0xf7483876L, 0xb809aeb1L, 0xa1129ff0L, 0x8a3fcc33L,
|
||||
0x9324fd72L
|
||||
,
|
||||
0x00000000L, 0x01c26a37L, 0x0384d46eL, 0x0246be59L, 0x0709a8dcL,
|
||||
0x06cbc2ebL, 0x048d7cb2L, 0x054f1685L, 0x0e1351b8L, 0x0fd13b8fL,
|
||||
0x0d9785d6L, 0x0c55efe1L, 0x091af964L, 0x08d89353L, 0x0a9e2d0aL,
|
||||
0x0b5c473dL, 0x1c26a370L, 0x1de4c947L, 0x1fa2771eL, 0x1e601d29L,
|
||||
0x1b2f0bacL, 0x1aed619bL, 0x18abdfc2L, 0x1969b5f5L, 0x1235f2c8L,
|
||||
0x13f798ffL, 0x11b126a6L, 0x10734c91L, 0x153c5a14L, 0x14fe3023L,
|
||||
0x16b88e7aL, 0x177ae44dL, 0x384d46e0L, 0x398f2cd7L, 0x3bc9928eL,
|
||||
0x3a0bf8b9L, 0x3f44ee3cL, 0x3e86840bL, 0x3cc03a52L, 0x3d025065L,
|
||||
0x365e1758L, 0x379c7d6fL, 0x35dac336L, 0x3418a901L, 0x3157bf84L,
|
||||
0x3095d5b3L, 0x32d36beaL, 0x331101ddL, 0x246be590L, 0x25a98fa7L,
|
||||
0x27ef31feL, 0x262d5bc9L, 0x23624d4cL, 0x22a0277bL, 0x20e69922L,
|
||||
0x2124f315L, 0x2a78b428L, 0x2bbade1fL, 0x29fc6046L, 0x283e0a71L,
|
||||
0x2d711cf4L, 0x2cb376c3L, 0x2ef5c89aL, 0x2f37a2adL, 0x709a8dc0L,
|
||||
0x7158e7f7L, 0x731e59aeL, 0x72dc3399L, 0x7793251cL, 0x76514f2bL,
|
||||
0x7417f172L, 0x75d59b45L, 0x7e89dc78L, 0x7f4bb64fL, 0x7d0d0816L,
|
||||
0x7ccf6221L, 0x798074a4L, 0x78421e93L, 0x7a04a0caL, 0x7bc6cafdL,
|
||||
0x6cbc2eb0L, 0x6d7e4487L, 0x6f38fadeL, 0x6efa90e9L, 0x6bb5866cL,
|
||||
0x6a77ec5bL, 0x68315202L, 0x69f33835L, 0x62af7f08L, 0x636d153fL,
|
||||
0x612bab66L, 0x60e9c151L, 0x65a6d7d4L, 0x6464bde3L, 0x662203baL,
|
||||
0x67e0698dL, 0x48d7cb20L, 0x4915a117L, 0x4b531f4eL, 0x4a917579L,
|
||||
0x4fde63fcL, 0x4e1c09cbL, 0x4c5ab792L, 0x4d98dda5L, 0x46c49a98L,
|
||||
0x4706f0afL, 0x45404ef6L, 0x448224c1L, 0x41cd3244L, 0x400f5873L,
|
||||
0x4249e62aL, 0x438b8c1dL, 0x54f16850L, 0x55330267L, 0x5775bc3eL,
|
||||
0x56b7d609L, 0x53f8c08cL, 0x523aaabbL, 0x507c14e2L, 0x51be7ed5L,
|
||||
0x5ae239e8L, 0x5b2053dfL, 0x5966ed86L, 0x58a487b1L, 0x5deb9134L,
|
||||
0x5c29fb03L, 0x5e6f455aL, 0x5fad2f6dL, 0xe1351b80L, 0xe0f771b7L,
|
||||
0xe2b1cfeeL, 0xe373a5d9L, 0xe63cb35cL, 0xe7fed96bL, 0xe5b86732L,
|
||||
0xe47a0d05L, 0xef264a38L, 0xeee4200fL, 0xeca29e56L, 0xed60f461L,
|
||||
0xe82fe2e4L, 0xe9ed88d3L, 0xebab368aL, 0xea695cbdL, 0xfd13b8f0L,
|
||||
0xfcd1d2c7L, 0xfe976c9eL, 0xff5506a9L, 0xfa1a102cL, 0xfbd87a1bL,
|
||||
0xf99ec442L, 0xf85cae75L, 0xf300e948L, 0xf2c2837fL, 0xf0843d26L,
|
||||
0xf1465711L, 0xf4094194L, 0xf5cb2ba3L, 0xf78d95faL, 0xf64fffcdL,
|
||||
0xd9785d60L, 0xd8ba3757L, 0xdafc890eL, 0xdb3ee339L, 0xde71f5bcL,
|
||||
0xdfb39f8bL, 0xddf521d2L, 0xdc374be5L, 0xd76b0cd8L, 0xd6a966efL,
|
||||
0xd4efd8b6L, 0xd52db281L, 0xd062a404L, 0xd1a0ce33L, 0xd3e6706aL,
|
||||
0xd2241a5dL, 0xc55efe10L, 0xc49c9427L, 0xc6da2a7eL, 0xc7184049L,
|
||||
0xc25756ccL, 0xc3953cfbL, 0xc1d382a2L, 0xc011e895L, 0xcb4dafa8L,
|
||||
0xca8fc59fL, 0xc8c97bc6L, 0xc90b11f1L, 0xcc440774L, 0xcd866d43L,
|
||||
0xcfc0d31aL, 0xce02b92dL, 0x91af9640L, 0x906dfc77L, 0x922b422eL,
|
||||
0x93e92819L, 0x96a63e9cL, 0x976454abL, 0x9522eaf2L, 0x94e080c5L,
|
||||
0x9fbcc7f8L, 0x9e7eadcfL, 0x9c381396L, 0x9dfa79a1L, 0x98b56f24L,
|
||||
0x99770513L, 0x9b31bb4aL, 0x9af3d17dL, 0x8d893530L, 0x8c4b5f07L,
|
||||
0x8e0de15eL, 0x8fcf8b69L, 0x8a809decL, 0x8b42f7dbL, 0x89044982L,
|
||||
0x88c623b5L, 0x839a6488L, 0x82580ebfL, 0x801eb0e6L, 0x81dcdad1L,
|
||||
0x8493cc54L, 0x8551a663L, 0x8717183aL, 0x86d5720dL, 0xa9e2d0a0L,
|
||||
0xa820ba97L, 0xaa6604ceL, 0xaba46ef9L, 0xaeeb787cL, 0xaf29124bL,
|
||||
0xad6fac12L, 0xacadc625L, 0xa7f18118L, 0xa633eb2fL, 0xa4755576L,
|
||||
0xa5b73f41L, 0xa0f829c4L, 0xa13a43f3L, 0xa37cfdaaL, 0xa2be979dL,
|
||||
0xb5c473d0L, 0xb40619e7L, 0xb640a7beL, 0xb782cd89L, 0xb2cddb0cL,
|
||||
0xb30fb13bL, 0xb1490f62L, 0xb08b6555L, 0xbbd72268L, 0xba15485fL,
|
||||
0xb853f606L, 0xb9919c31L, 0xbcde8ab4L, 0xbd1ce083L, 0xbf5a5edaL,
|
||||
0xbe9834edL
|
||||
,
|
||||
0x00000000L, 0xb8bc6765L, 0xaa09c88bL, 0x12b5afeeL, 0x8f629757L,
|
||||
0x37def032L, 0x256b5fdcL, 0x9dd738b9L, 0xc5b428efL, 0x7d084f8aL,
|
||||
0x6fbde064L, 0xd7018701L, 0x4ad6bfb8L, 0xf26ad8ddL, 0xe0df7733L,
|
||||
0x58631056L, 0x5019579fL, 0xe8a530faL, 0xfa109f14L, 0x42acf871L,
|
||||
0xdf7bc0c8L, 0x67c7a7adL, 0x75720843L, 0xcdce6f26L, 0x95ad7f70L,
|
||||
0x2d111815L, 0x3fa4b7fbL, 0x8718d09eL, 0x1acfe827L, 0xa2738f42L,
|
||||
0xb0c620acL, 0x087a47c9L, 0xa032af3eL, 0x188ec85bL, 0x0a3b67b5L,
|
||||
0xb28700d0L, 0x2f503869L, 0x97ec5f0cL, 0x8559f0e2L, 0x3de59787L,
|
||||
0x658687d1L, 0xdd3ae0b4L, 0xcf8f4f5aL, 0x7733283fL, 0xeae41086L,
|
||||
0x525877e3L, 0x40edd80dL, 0xf851bf68L, 0xf02bf8a1L, 0x48979fc4L,
|
||||
0x5a22302aL, 0xe29e574fL, 0x7f496ff6L, 0xc7f50893L, 0xd540a77dL,
|
||||
0x6dfcc018L, 0x359fd04eL, 0x8d23b72bL, 0x9f9618c5L, 0x272a7fa0L,
|
||||
0xbafd4719L, 0x0241207cL, 0x10f48f92L, 0xa848e8f7L, 0x9b14583dL,
|
||||
0x23a83f58L, 0x311d90b6L, 0x89a1f7d3L, 0x1476cf6aL, 0xaccaa80fL,
|
||||
0xbe7f07e1L, 0x06c36084L, 0x5ea070d2L, 0xe61c17b7L, 0xf4a9b859L,
|
||||
0x4c15df3cL, 0xd1c2e785L, 0x697e80e0L, 0x7bcb2f0eL, 0xc377486bL,
|
||||
0xcb0d0fa2L, 0x73b168c7L, 0x6104c729L, 0xd9b8a04cL, 0x446f98f5L,
|
||||
0xfcd3ff90L, 0xee66507eL, 0x56da371bL, 0x0eb9274dL, 0xb6054028L,
|
||||
0xa4b0efc6L, 0x1c0c88a3L, 0x81dbb01aL, 0x3967d77fL, 0x2bd27891L,
|
||||
0x936e1ff4L, 0x3b26f703L, 0x839a9066L, 0x912f3f88L, 0x299358edL,
|
||||
0xb4446054L, 0x0cf80731L, 0x1e4da8dfL, 0xa6f1cfbaL, 0xfe92dfecL,
|
||||
0x462eb889L, 0x549b1767L, 0xec277002L, 0x71f048bbL, 0xc94c2fdeL,
|
||||
0xdbf98030L, 0x6345e755L, 0x6b3fa09cL, 0xd383c7f9L, 0xc1366817L,
|
||||
0x798a0f72L, 0xe45d37cbL, 0x5ce150aeL, 0x4e54ff40L, 0xf6e89825L,
|
||||
0xae8b8873L, 0x1637ef16L, 0x048240f8L, 0xbc3e279dL, 0x21e91f24L,
|
||||
0x99557841L, 0x8be0d7afL, 0x335cb0caL, 0xed59b63bL, 0x55e5d15eL,
|
||||
0x47507eb0L, 0xffec19d5L, 0x623b216cL, 0xda874609L, 0xc832e9e7L,
|
||||
0x708e8e82L, 0x28ed9ed4L, 0x9051f9b1L, 0x82e4565fL, 0x3a58313aL,
|
||||
0xa78f0983L, 0x1f336ee6L, 0x0d86c108L, 0xb53aa66dL, 0xbd40e1a4L,
|
||||
0x05fc86c1L, 0x1749292fL, 0xaff54e4aL, 0x322276f3L, 0x8a9e1196L,
|
||||
0x982bbe78L, 0x2097d91dL, 0x78f4c94bL, 0xc048ae2eL, 0xd2fd01c0L,
|
||||
0x6a4166a5L, 0xf7965e1cL, 0x4f2a3979L, 0x5d9f9697L, 0xe523f1f2L,
|
||||
0x4d6b1905L, 0xf5d77e60L, 0xe762d18eL, 0x5fdeb6ebL, 0xc2098e52L,
|
||||
0x7ab5e937L, 0x680046d9L, 0xd0bc21bcL, 0x88df31eaL, 0x3063568fL,
|
||||
0x22d6f961L, 0x9a6a9e04L, 0x07bda6bdL, 0xbf01c1d8L, 0xadb46e36L,
|
||||
0x15080953L, 0x1d724e9aL, 0xa5ce29ffL, 0xb77b8611L, 0x0fc7e174L,
|
||||
0x9210d9cdL, 0x2aacbea8L, 0x38191146L, 0x80a57623L, 0xd8c66675L,
|
||||
0x607a0110L, 0x72cfaefeL, 0xca73c99bL, 0x57a4f122L, 0xef189647L,
|
||||
0xfdad39a9L, 0x45115eccL, 0x764dee06L, 0xcef18963L, 0xdc44268dL,
|
||||
0x64f841e8L, 0xf92f7951L, 0x41931e34L, 0x5326b1daL, 0xeb9ad6bfL,
|
||||
0xb3f9c6e9L, 0x0b45a18cL, 0x19f00e62L, 0xa14c6907L, 0x3c9b51beL,
|
||||
0x842736dbL, 0x96929935L, 0x2e2efe50L, 0x2654b999L, 0x9ee8defcL,
|
||||
0x8c5d7112L, 0x34e11677L, 0xa9362eceL, 0x118a49abL, 0x033fe645L,
|
||||
0xbb838120L, 0xe3e09176L, 0x5b5cf613L, 0x49e959fdL, 0xf1553e98L,
|
||||
0x6c820621L, 0xd43e6144L, 0xc68bceaaL, 0x7e37a9cfL, 0xd67f4138L,
|
||||
0x6ec3265dL, 0x7c7689b3L, 0xc4caeed6L, 0x591dd66fL, 0xe1a1b10aL,
|
||||
0xf3141ee4L, 0x4ba87981L, 0x13cb69d7L, 0xab770eb2L, 0xb9c2a15cL,
|
||||
0x017ec639L, 0x9ca9fe80L, 0x241599e5L, 0x36a0360bL, 0x8e1c516eL,
|
||||
0x866616a7L, 0x3eda71c2L, 0x2c6fde2cL, 0x94d3b949L, 0x090481f0L,
|
||||
0xb1b8e695L, 0xa30d497bL, 0x1bb12e1eL, 0x43d23e48L, 0xfb6e592dL,
|
||||
0xe9dbf6c3L, 0x516791a6L, 0xccb0a91fL, 0x740cce7aL, 0x66b96194L,
|
||||
0xde0506f1L
|
||||
# endif /* IZ_CRCOPTIM_UNFOLDTBL */
|
||||
# endif /* ? IZ_CRC_BE_OPTIMIZ */
|
||||
};
|
||||
#endif /* ?DYNAMIC_CRC_TABLE */
|
||||
|
||||
/* use "OF((void))" here to work around a Borland TC++ 1.0 problem */
|
||||
#ifdef USE_ZLIB
|
||||
ZCONST uLongf *get_crc_table OF((void))
|
||||
#else
|
||||
ZCONST ulg near *get_crc_table OF((void))
|
||||
#endif
|
||||
{
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (CRC_TABLE_IS_EMPTY)
|
||||
make_crc_table();
|
||||
#endif
|
||||
#ifdef USE_ZLIB
|
||||
return (ZCONST uLongf *)crc_table;
|
||||
#else
|
||||
return crc_table;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DYNALLOC_CRCTAB
|
||||
void free_crc_table()
|
||||
{
|
||||
if (!CRC_TABLE_IS_EMPTY)
|
||||
{
|
||||
nearfree((ulg near *)crc_table);
|
||||
MARK_CRCTAB_EMPTY;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ZLIB
|
||||
#ifndef CRC_TABLE_ONLY
|
||||
#ifndef ASM_CRC
|
||||
|
||||
#define DO1(crc, buf) crc = CRC32(crc, *buf++, crc_32_tab)
|
||||
#define DO2(crc, buf) DO1(crc, buf); DO1(crc, buf)
|
||||
#define DO4(crc, buf) DO2(crc, buf); DO2(crc, buf)
|
||||
#define DO8(crc, buf) DO4(crc, buf); DO4(crc, buf)
|
||||
|
||||
#if (defined(IZ_CRC_BE_OPTIMIZ) || defined(IZ_CRC_LE_OPTIMIZ))
|
||||
|
||||
# ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
# ifdef IZ_CRC_BE_OPTIMIZ
|
||||
# define DO_OPT4(c, buf4) c ^= *(buf4)++; \
|
||||
c = crc_32_tab[c & 0xff] ^ crc_32_tab[256+((c>>8) & 0xff)] ^ \
|
||||
crc_32_tab[2*256+((c>>16) & 0xff)] ^ crc_32_tab[3*256+(c>>24)]
|
||||
# else /* !IZ_CRC_BE_OPTIMIZ */
|
||||
# define DO_OPT4(c, buf4) c ^= *(buf4)++; \
|
||||
c = crc_32_tab[3*256+(c & 0xff)] ^ crc_32_tab[2*256+((c>>8) & 0xff)] \
|
||||
^ crc_32_tab[256+((c>>16) & 0xff)] ^ crc_32_tab[c>>24]
|
||||
# endif /* ?IZ_CRC_BE_OPTIMIZ */
|
||||
# else /* !IZ_CRCOPTIM_UNFOLDTBL */
|
||||
# define DO_OPT4(c, buf4) c ^= *(buf4)++; \
|
||||
c = CRC32UPD(c, crc_32_tab); \
|
||||
c = CRC32UPD(c, crc_32_tab); \
|
||||
c = CRC32UPD(c, crc_32_tab); \
|
||||
c = CRC32UPD(c, crc_32_tab)
|
||||
# endif /* ?IZ_CRCOPTIM_UNFOLDTBL */
|
||||
|
||||
# define DO_OPT16(crc, buf4) DO_OPT4(crc, buf4); DO_OPT4(crc, buf4); \
|
||||
DO_OPT4(crc, buf4); DO_OPT4(crc, buf4);
|
||||
|
||||
#endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */
|
||||
|
||||
|
||||
/* ========================================================================= */
|
||||
ulg crc32(crc, buf, len)
|
||||
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 z_uint4 c;
|
||||
register ZCONST ulg near *crc_32_tab;
|
||||
|
||||
if (buf == NULL) return 0L;
|
||||
|
||||
crc_32_tab = get_crc_table();
|
||||
|
||||
c = (REV_BE((z_uint4)crc) ^ 0xffffffffL);
|
||||
|
||||
#if (defined(IZ_CRC_BE_OPTIMIZ) || defined(IZ_CRC_LE_OPTIMIZ))
|
||||
/* Align buf pointer to next DWORD boundary. */
|
||||
while (len && ((ptrdiff_t)buf & 3)) {
|
||||
DO1(c, buf);
|
||||
len--;
|
||||
}
|
||||
{
|
||||
ZCONST z_uint4 *buf4 = (ZCONST z_uint4 *)buf;
|
||||
while (len >= 16) {
|
||||
DO_OPT16(c, buf4);
|
||||
len -= 16;
|
||||
}
|
||||
while (len >= 4) {
|
||||
DO_OPT4(c, buf4);
|
||||
len -= 4;
|
||||
}
|
||||
buf = (ZCONST uch *)buf4;
|
||||
}
|
||||
#else /* !(IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */
|
||||
#ifndef NO_UNROLLED_LOOPS
|
||||
while (len >= 8) {
|
||||
DO8(c, buf);
|
||||
len -= 8;
|
||||
}
|
||||
#endif /* !NO_UNROLLED_LOOPS */
|
||||
#endif /* ?(IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */
|
||||
if (len) do {
|
||||
DO1(c, buf);
|
||||
} while (--len);
|
||||
|
||||
return REV_BE(c) ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
|
||||
}
|
||||
#endif /* !ASM_CRC */
|
||||
#endif /* !CRC_TABLE_ONLY */
|
||||
#endif /* !USE_ZLIB */
|
||||
#endif /* !USE_ZLIB || USE_OWN_CRCTAB */
|
60
third_party/infozip/zip/crc32.h
vendored
Normal file
60
third_party/infozip/zip/crc32.h
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/* crc32.h -- 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
|
||||
*/
|
||||
|
||||
#ifndef __crc32_h
|
||||
#define __crc32_h /* identifies this source module */
|
||||
|
||||
/* This header should be read AFTER zip.h resp. unzip.h
|
||||
* (the latter with UNZIP_INTERNAL defined...).
|
||||
*/
|
||||
|
||||
#ifndef OF
|
||||
# define OF(a) a
|
||||
#endif
|
||||
#ifndef ZCONST
|
||||
# define ZCONST const
|
||||
#endif
|
||||
|
||||
#ifdef DYNALLOC_CRCTAB
|
||||
void free_crc_table OF((void));
|
||||
#endif
|
||||
#ifndef USE_ZLIB
|
||||
ZCONST ulg near *get_crc_table OF((void));
|
||||
#endif
|
||||
#if (defined(USE_ZLIB) || defined(CRC_TABLE_ONLY))
|
||||
# ifdef IZ_CRC_BE_OPTIMIZ
|
||||
# undef IZ_CRC_BE_OPTIMIZ
|
||||
# endif
|
||||
#else /* !(USE_ZLIB || CRC_TABLE_ONLY) */
|
||||
ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len));
|
||||
#endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */
|
||||
|
||||
#ifndef CRC_32_TAB
|
||||
# define CRC_32_TAB crc_32_tab
|
||||
#endif
|
||||
|
||||
#ifdef CRC32
|
||||
# undef CRC32
|
||||
#endif
|
||||
#ifdef IZ_CRC_BE_OPTIMIZ
|
||||
# define CRC32UPD(c, crctab) (crctab[((c) >> 24)] ^ ((c) << 8))
|
||||
# define CRC32(c, b, crctab) (crctab[(((int)(c) >> 24) ^ (b))] ^ ((c) << 8))
|
||||
# define REV_BE(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
|
||||
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
|
||||
#else
|
||||
# define CRC32UPD(c, crctab) (crctab[((int)(c)) & 0xff] ^ ((c) >> 8))
|
||||
# define CRC32(c, b, crctab) (crctab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
|
||||
# define REV_BE(w) w
|
||||
#endif
|
||||
|
||||
#endif /* !__crc32_h */
|
304
third_party/infozip/zip/crc_i386.S
vendored
Normal file
304
third_party/infozip/zip/crc_i386.S
vendored
Normal file
|
@ -0,0 +1,304 @@
|
|||
/*
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2000-Apr-09 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* crc_i386.S, optimized CRC calculation function for Zip and UnZip,
|
||||
* created by Paul Kienitz and Christian Spieler. Last revised 07 Jan 2007.
|
||||
*
|
||||
* GRR 961110: incorporated Scott Field optimizations from win32/crc_i386.asm
|
||||
* => overall 6% speedup in "unzip -tq" on 9MB zipfile (486-66)
|
||||
*
|
||||
* SPC 970402: revised for Rodney Brown's optimizations (32-bit-wide
|
||||
* aligned reads for most of the data from buffer), can be
|
||||
* disabled by defining the macro NO_32_BIT_LOADS
|
||||
*
|
||||
* SPC 971012: added Rodney Brown's additional tweaks for 32-bit-optimized
|
||||
* CPUs (like the Pentium Pro, Pentium II, and probably some
|
||||
* Pentium clones). This optimization is controlled by the
|
||||
* preprocessor switch "__686" and is disabled by default.
|
||||
* (This default is based on the assumption that most users
|
||||
* do not yet work on a Pentium Pro or Pentium II machine ...)
|
||||
*
|
||||
* COS 050116: Enabled the 686 build by default, because there are hardly any
|
||||
* pre-686 CPUs in serious use nowadays. (See SPC 970402 above.)
|
||||
*
|
||||
* SPC 060103: Updated code to incorporate newer optimizations found in zlib.
|
||||
*
|
||||
* SPC 070107: Added conditional switch to deactivate crc32() compilation.
|
||||
*
|
||||
* FLAT memory model assumed. Calling interface:
|
||||
* - args are pushed onto the stack from right to left,
|
||||
* - return value is given in the EAX register,
|
||||
* - all other registers (with exception of EFLAGS) are preserved. (With
|
||||
* GNU C 2.7.x, %edx and %ecx are `scratch' registers, but preserving
|
||||
* them nevertheless adds only 4 single byte instructions.)
|
||||
*
|
||||
* This source generates the function
|
||||
* ulg crc32(ulg crc, ZCONST uch *buf, extent len).
|
||||
*
|
||||
* Loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS.
|
||||
* This results in shorter code at the expense of reduced performance.
|
||||
*/
|
||||
|
||||
/* This file is NOT used in conjunction with zlib, or when only creation of
|
||||
* the basic CRC_32_Table (for other purpose) is requested.
|
||||
*/
|
||||
#if !defined(USE_ZLIB) && !defined(CRC_TABLE_ONLY)
|
||||
|
||||
/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix
|
||||
* external symbols with an underline character '_'.
|
||||
*/
|
||||
#if defined(NO_UNDERLINE) || defined(__ELF__)
|
||||
# define _crc32 crc32
|
||||
# define _get_crc_table get_crc_table
|
||||
#endif
|
||||
/* Use 16-byte alignment if your assembler supports it. Warning: gas
|
||||
* uses a log(x) parameter (.align 4 means 16-byte alignment). On SVR4
|
||||
* the parameter is a number of bytes.
|
||||
*/
|
||||
#ifndef ALIGNMENT
|
||||
# define ALIGNMENT .align 4,0x90
|
||||
#endif
|
||||
|
||||
#if defined(i386) || defined(_i386) || defined(_I386) || defined(__i386)
|
||||
|
||||
/* This version is for 386 Unix, OS/2, MSDOS in 32 bit mode (gcc & gas).
|
||||
* Warning: it uses the AT&T syntax: mov source,dest
|
||||
* This file is only optional. If you want to use the C version,
|
||||
* remove -DASM_CRC from CFLAGS in Makefile and set OBJA to an empty string.
|
||||
*/
|
||||
|
||||
.file "crc_i386.S"
|
||||
|
||||
#if !defined(PRE_686) && !defined(__686)
|
||||
/* Optimize for Pentium Pro and compatible CPUs by default. */
|
||||
# define __686
|
||||
#endif
|
||||
|
||||
#if defined(NO_STD_STACKFRAME) && defined(USE_STD_STACKFRAME)
|
||||
# undef USE_STACKFRAME
|
||||
#else
|
||||
/* The default is to use standard stack frame entry, because it
|
||||
* results in smaller code!
|
||||
*/
|
||||
# ifndef USE_STD_STACKFRAME
|
||||
# define USE_STD_STACKFRAME
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_STD_STACKFRAME
|
||||
# define _STD_ENTRY pushl %ebp ; movl %esp,%ebp
|
||||
# define arg1 8(%ebp)
|
||||
# define arg2 12(%ebp)
|
||||
# define arg3 16(%ebp)
|
||||
# define _STD_LEAVE popl %ebp
|
||||
#else /* !USE_STD_STACKFRAME */
|
||||
# define _STD_ENTRY
|
||||
# define arg1 24(%esp)
|
||||
# define arg2 28(%esp)
|
||||
# define arg3 32(%esp)
|
||||
# define _STD_LEAVE
|
||||
#endif /* ?USE_STD_STACKFRAME */
|
||||
|
||||
/*
|
||||
* These two (three) macros make up the loop body of the CRC32 cruncher.
|
||||
* registers modified:
|
||||
* eax : crc value "c"
|
||||
* esi : pointer to next data byte (or lword) "buf++"
|
||||
* registers read:
|
||||
* edi : pointer to base of crc_table array
|
||||
* scratch registers:
|
||||
* ebx : index into crc_table array
|
||||
* (requires upper three bytes = 0 when __686 is undefined)
|
||||
*/
|
||||
#ifndef __686 /* optimize for 386, 486, Pentium */
|
||||
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
|
||||
movb %al, %bl ;/* tmp = c & 0xFF */\
|
||||
shrl $8, %eax ;/* c = (c >> 8) */\
|
||||
xorl (%edi, %ebx, 4), %eax ;/* c ^= table[tmp] */
|
||||
#else /* __686 : optimize for Pentium Pro and compatible CPUs */
|
||||
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
|
||||
movzbl %al, %ebx ;/* tmp = c & 0xFF */\
|
||||
shrl $8, %eax ;/* c = (c >> 8) */\
|
||||
xorl (%edi, %ebx, 4), %eax ;/* c ^=table[tmp] */
|
||||
#endif /* ?__686 */
|
||||
|
||||
#define Do_CRC_byte /* c = (c >> 8) ^ table[(c^*buf++)&0xFF] */\
|
||||
xorb (%esi), %al ;/* c ^= *buf */\
|
||||
incl %esi ;/* buf++ */\
|
||||
Do_CRC
|
||||
|
||||
#define Do_CRC_byteof(ofs) /* c = (c >> 8) ^ table[(c^*buf++)&0xFF] */\
|
||||
xorb ofs(%esi), %al ;/* c ^= *buf */\
|
||||
incl %esi ;/* buf++ */\
|
||||
Do_CRC
|
||||
|
||||
#ifndef NO_32_BIT_LOADS
|
||||
# ifdef IZ_CRCOPTIM_UNFOLDTBL
|
||||
/* the edx register is needed in crc calculation */
|
||||
# define SavLen arg3
|
||||
# define UpdCRC_lword \
|
||||
movzbl %al, %ebx ; \
|
||||
movl 3072(%edi,%ebx,4), %edx ; \
|
||||
movzbl %ah, %ebx ; \
|
||||
shrl $16, %eax ; \
|
||||
xor 2048(%edi,%ebx,4), %edx ; \
|
||||
movzbl %al, %ebx ; \
|
||||
shrl $8,%eax ; \
|
||||
xorl 1024(%edi,%ebx,4), %edx ; \
|
||||
movl (%edi,%eax,4), %eax ; \
|
||||
xorl %edx,%eax ;
|
||||
# define UpdCRC_lword_sh(dwPtrIncr) \
|
||||
movzbl %al, %ebx ; \
|
||||
movl 3072(%edi,%ebx,4), %edx ; \
|
||||
movzbl %ah, %ebx ; \
|
||||
shrl $16, %eax ; \
|
||||
xor 2048(%edi,%ebx,4), %edx ; \
|
||||
movzbl %al, %ebx ; \
|
||||
addl $4*(dwPtrIncr), %esi ;/* ((ulg *)buf)+=dwPtrIncr */\
|
||||
shrl $8,%eax ; \
|
||||
xorl 1024(%edi,%ebx,4), %edx ; \
|
||||
movl (%edi,%eax,4),%eax ; \
|
||||
xorl %edx,%eax ;
|
||||
# else /* !IZ_CRCOPTIM_UNFOLDTBL */
|
||||
/* the edx register is not needed anywhere else */
|
||||
# define SavLen %edx
|
||||
# define UpdCRC_lword \
|
||||
Do_CRC \
|
||||
Do_CRC \
|
||||
Do_CRC \
|
||||
Do_CRC
|
||||
# define UpdCRC_lword_sh(dwPtrIncr) \
|
||||
Do_CRC \
|
||||
Do_CRC \
|
||||
addl $4*(dwPtrIncr), %esi ;/* ((ulg *)buf)++ */\
|
||||
Do_CRC \
|
||||
Do_CRC
|
||||
# endif /* ?IZ_CRCOPTIM_UNFOLDTBL */
|
||||
#define Do_CRC_lword \
|
||||
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */\
|
||||
UpdCRC_lword_sh(1) /* ... ((ulg *)buf)++ */
|
||||
#define Do_CRC_4lword \
|
||||
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */\
|
||||
UpdCRC_lword \
|
||||
xorl 4(%esi), %eax ;/* c ^= *((ulg *)buf+1) */\
|
||||
UpdCRC_lword \
|
||||
xorl 8(%esi), %eax ;/* c ^= *((ulg *)buf+2) */\
|
||||
UpdCRC_lword \
|
||||
xorl 12(%esi), %eax ;/* c ^= *((ulg *)buf]+3 */\
|
||||
UpdCRC_lword_sh(4) /* ... ((ulg *)buf)+=4 */
|
||||
#endif /* !NO_32_BIT_LOADS */
|
||||
|
||||
|
||||
.text
|
||||
|
||||
.globl _crc32
|
||||
|
||||
_crc32: /* ulg crc32(ulg crc, uch *buf, extent len) */
|
||||
_STD_ENTRY
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %ebx
|
||||
pushl %edx
|
||||
pushl %ecx
|
||||
|
||||
movl arg2, %esi /* 2nd arg: uch *buf */
|
||||
subl %eax, %eax /* > if (!buf) */
|
||||
testl %esi, %esi /* > return 0; */
|
||||
jz .L_fine /* > else { */
|
||||
call _get_crc_table
|
||||
movl %eax, %edi
|
||||
movl arg1, %eax /* 1st arg: ulg crc */
|
||||
#ifndef __686
|
||||
subl %ebx, %ebx /* ebx=0; bl usable as dword */
|
||||
#endif
|
||||
movl arg3, %ecx /* 3rd arg: extent len */
|
||||
notl %eax /* > c = ~crc; */
|
||||
|
||||
testl %ecx, %ecx
|
||||
#ifndef NO_UNROLLED_LOOPS
|
||||
jz .L_bail
|
||||
# ifndef NO_32_BIT_LOADS
|
||||
/* Assert now have positive length */
|
||||
.L_align_loop:
|
||||
testl $3, %esi /* Align buf on lword boundary */
|
||||
jz .L_aligned_now
|
||||
Do_CRC_byte
|
||||
decl %ecx
|
||||
jnz .L_align_loop
|
||||
.L_aligned_now:
|
||||
# endif /* !NO_32_BIT_LOADS */
|
||||
movl %ecx, SavLen /* save current value of len */
|
||||
shrl $4, %ecx /* ecx = len / 16 */
|
||||
jz .L_No_Sixteens
|
||||
/* align loop head at start of 486 internal cache line !! */
|
||||
ALIGNMENT
|
||||
.L_Next_Sixteen:
|
||||
# ifndef NO_32_BIT_LOADS
|
||||
Do_CRC_4lword
|
||||
# else /* NO_32_BIT_LOADS */
|
||||
Do_CRC_byteof(0)
|
||||
Do_CRC_byteof(1)
|
||||
Do_CRC_byteof(2)
|
||||
Do_CRC_byteof(3)
|
||||
Do_CRC_byteof(4)
|
||||
Do_CRC_byteof(5)
|
||||
Do_CRC_byteof(6)
|
||||
Do_CRC_byteof(7)
|
||||
Do_CRC_byteof(8)
|
||||
Do_CRC_byteof(9)
|
||||
Do_CRC_byteof(10)
|
||||
Do_CRC_byteof(11)
|
||||
Do_CRC_byteof(12)
|
||||
Do_CRC_byteof(13)
|
||||
Do_CRC_byteof(14)
|
||||
Do_CRC_byteof(15)
|
||||
addl $16,%esi ;/* buf += 16 */
|
||||
# endif /* ?NO_32_BIT_LOADS */
|
||||
decl %ecx
|
||||
jnz .L_Next_Sixteen
|
||||
|
||||
.L_No_Sixteens:
|
||||
movl SavLen, %ecx
|
||||
andl $15, %ecx /* ecx = len % 16 */
|
||||
# ifndef NO_32_BIT_LOADS
|
||||
shrl $2,%ecx /* ecx = len / 4 */
|
||||
jz .L_No_Fours
|
||||
.L_Next_Four:
|
||||
Do_CRC_lword
|
||||
decl %ecx
|
||||
jnz .L_Next_Four
|
||||
.L_No_Fours:
|
||||
movl SavLen,%ecx
|
||||
andl $3,%ecx /* ecx = len % 4 */
|
||||
# endif /* !NO_32_BIT_LOADS */
|
||||
#endif /* !NO_UNROLLED_LOOPS */
|
||||
jz .L_bail /* > if (len) */
|
||||
/* align loop head at start of 486 internal cache line !! */
|
||||
ALIGNMENT
|
||||
.L_loupe: /* > do { */
|
||||
Do_CRC_byte /* c = CRC32(c,*buf++,crctab);*/
|
||||
decl %ecx /* > } while (--len); */
|
||||
jnz .L_loupe
|
||||
|
||||
.L_bail: /* > } */
|
||||
notl %eax /* > return ~c; */
|
||||
.L_fine:
|
||||
popl %ecx
|
||||
popl %edx
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
_STD_LEAVE
|
||||
ret
|
||||
|
||||
#else
|
||||
error: this asm version is for 386 only
|
||||
#endif /* i386 || _i386 || _I386 || __i386 */
|
||||
|
||||
#endif /* !USE_ZLIB && !CRC_TABLE_ONLY */
|
690
third_party/infozip/zip/crypt.c
vendored
Normal file
690
third_party/infozip/zip/crypt.c
vendored
Normal file
|
@ -0,0 +1,690 @@
|
|||
/*
|
||||
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
|
||||
|
||||
The main encryption/decryption source code for Info-Zip software was
|
||||
originally written in Europe. To the best of our knowledge, it can
|
||||
be freely distributed in both source and object forms from any country,
|
||||
including the USA under License Exception TSU of the U.S. Export
|
||||
Administration Regulations (section 740.13(e)) of 6 June 2002.
|
||||
|
||||
NOTE on copyright history:
|
||||
Previous versions of this source package (up to version 2.8) were
|
||||
not copyrighted and put in the public domain. If you cannot comply
|
||||
with the Info-Zip LICENSE, you may want to look for one of those
|
||||
public domain versions.
|
||||
*/
|
||||
|
||||
/*
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
*/
|
||||
|
||||
#define ZCRYPT_INTERNAL
|
||||
#include "zip.h"
|
||||
#include "crypt.h"
|
||||
#include "ttyio.h"
|
||||
|
||||
#if CRYPT
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef ZIP
|
||||
/* For the encoding task used in Zip (and ZipCloak), we want to initialize
|
||||
the crypt algorithm with some reasonably unpredictable bytes, see
|
||||
the crypthead() function. The standard rand() library function is
|
||||
used to supply these `random' bytes, which in turn is initialized by
|
||||
a srand() call. The srand() function takes an "unsigned" (at least 16bit)
|
||||
seed value as argument to determine the starting point of the rand()
|
||||
pseudo-random number generator.
|
||||
This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with
|
||||
Seed1 supplied by the current time (= "(unsigned)time()") and Seed2
|
||||
as some (hopefully) nondeterministic bitmask. On many (most) systems,
|
||||
we use some "process specific" number, as the PID or something similar,
|
||||
but when nothing unpredictable is available, a fixed number may be
|
||||
sufficient.
|
||||
NOTE:
|
||||
1.) This implementation requires the availability of the following
|
||||
standard UNIX C runtime library functions: time(), rand(), srand().
|
||||
On systems where some of them are missing, the environment that
|
||||
incorporates the crypt routines must supply suitable replacement
|
||||
functions.
|
||||
2.) It is a very bad idea to use a second call to time() to set the
|
||||
"Seed2" number! In this case, both "Seed1" and "Seed2" would be
|
||||
(almost) identical, resulting in a (mostly) "zero" constant seed
|
||||
number passed to srand().
|
||||
|
||||
The implementation environment defined in the "zip.h" header should
|
||||
supply a reasonable definition for ZCR_SEED2 (an unsigned number; for
|
||||
most implementations of rand() and srand(), only the lower 16 bits are
|
||||
significant!). An example that works on many systems would be
|
||||
"#define ZCR_SEED2 (unsigned)getpid()".
|
||||
The default definition for ZCR_SEED2 supplied below should be regarded
|
||||
as a fallback to allow successful compilation in "beta state"
|
||||
environments.
|
||||
*/
|
||||
# include <time.h> /* time() function supplies first part of crypt seed */
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */
|
||||
# endif
|
||||
# ifdef GLOBAL /* used in Amiga system headers, maybe others too */
|
||||
# undef GLOBAL
|
||||
# endif
|
||||
# define GLOBAL(g) g
|
||||
#else /* !ZIP */
|
||||
# define GLOBAL(g) G.g
|
||||
#endif /* ?ZIP */
|
||||
|
||||
|
||||
#ifdef UNZIP
|
||||
/* char *key = (char *)NULL; moved to globals.h */
|
||||
# ifndef FUNZIP
|
||||
local int testp OF((__GPRO__ ZCONST uch *h));
|
||||
local int testkey OF((__GPRO__ ZCONST uch *h, ZCONST char *key));
|
||||
# endif
|
||||
#else /* def UNZIP */ /* moved to globals.h for UnZip */
|
||||
local z_uint4 keys[3]; /* keys defining the pseudo-random sequence */
|
||||
#endif /* def UNZIP [else] */
|
||||
|
||||
#ifndef Trace
|
||||
# ifdef CRYPT_DEBUG
|
||||
# define Trace(x) fprintf x
|
||||
# else
|
||||
# define Trace(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "crc32.h"
|
||||
|
||||
#ifdef IZ_CRC_BE_OPTIMIZ
|
||||
local z_uint4 near crycrctab[256];
|
||||
local z_uint4 near *cry_crctb_p = NULL;
|
||||
local z_uint4 near *crytab_init OF((__GPRO));
|
||||
# define CRY_CRC_TAB cry_crctb_p
|
||||
# undef CRC32
|
||||
# define CRC32(c, b, crctab) (crctab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
|
||||
#else
|
||||
# define CRY_CRC_TAB CRC_32_TAB
|
||||
#endif /* ?IZ_CRC_BE_OPTIMIZ */
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
int decrypt_byte(__G)
|
||||
__GDEF
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
int update_keys(__G__ c)
|
||||
__GDEF
|
||||
int c; /* byte of plain text */
|
||||
{
|
||||
GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c, CRY_CRC_TAB);
|
||||
GLOBAL(keys[1]) = (GLOBAL(keys[1])
|
||||
+ (GLOBAL(keys[0]) & 0xff))
|
||||
* 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)(GLOBAL(keys[1]) >> 24);
|
||||
GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift, CRY_CRC_TAB);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
void init_keys(__G__ passwd)
|
||||
__GDEF
|
||||
ZCONST char *passwd; /* password string with which to modify keys */
|
||||
{
|
||||
#ifdef IZ_CRC_BE_OPTIMIZ
|
||||
if (cry_crctb_p == NULL) {
|
||||
cry_crctb_p = crytab_init(__G);
|
||||
}
|
||||
#endif
|
||||
GLOBAL(keys[0]) = 305419896L;
|
||||
GLOBAL(keys[1]) = 591751049L;
|
||||
GLOBAL(keys[2]) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(__G__ (int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the local copy of the table of precomputed crc32 values.
|
||||
* Whereas the public crc32-table is optimized for crc32 calculations
|
||||
* on arrays of bytes, the crypt code needs the crc32 values in an
|
||||
* byte-order-independent form as 32-bit unsigned numbers. On systems
|
||||
* with Big-Endian byte order using the optimized crc32 code, this
|
||||
* requires inverting the byte-order of the values in the
|
||||
* crypt-crc32-table.
|
||||
*/
|
||||
#ifdef IZ_CRC_BE_OPTIMIZ
|
||||
local z_uint4 near *crytab_init(__G)
|
||||
__GDEF
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
crycrctab[i] = REV_BE(CRC_32_TAB[i]);
|
||||
}
|
||||
return crycrctab;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ZIP
|
||||
|
||||
/***********************************************************************
|
||||
* Write encryption header to file zfile using the password passwd
|
||||
* and the cyclic redundancy check crc.
|
||||
*/
|
||||
void crypthead(passwd, crc)
|
||||
ZCONST char *passwd; /* password string */
|
||||
ulg crc; /* crc of file being encrypted */
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
uch header[RAND_HEAD_LEN]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1) {
|
||||
srand((unsigned)time(NULL) ^ ZCR_SEED2);
|
||||
}
|
||||
init_keys(passwd);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (uch)zencode(c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++) {
|
||||
header[n] = (uch)zencode(header[n], t);
|
||||
}
|
||||
header[RAND_HEAD_LEN-2] = (uch)zencode((int)(crc >> 16) & 0xff, t);
|
||||
header[RAND_HEAD_LEN-1] = (uch)zencode((int)(crc >> 24) & 0xff, t);
|
||||
bfwrite(header, 1, RAND_HEAD_LEN, BFWRITE_DATA);
|
||||
}
|
||||
|
||||
|
||||
#ifdef UTIL
|
||||
|
||||
/***********************************************************************
|
||||
* Encrypt the zip entry described by z from file in_file to file y
|
||||
* using the password passwd. Return an error code in the ZE_ class.
|
||||
*/
|
||||
int zipcloak(z, passwd)
|
||||
struct zlist far *z; /* zip entry to encrypt */
|
||||
ZCONST char *passwd; /* password string */
|
||||
{
|
||||
int c; /* input byte */
|
||||
int res; /* result code */
|
||||
zoff_t n; /* holds offset and counts size */
|
||||
int t; /* temporary */
|
||||
struct zlist far *localz; /* local header */
|
||||
uch buf[1024]; /* write buffer */
|
||||
int b; /* bytes in buffer */
|
||||
|
||||
/* Set encrypted bit, clear extended local header bit and write local
|
||||
header to output file */
|
||||
if ((n = (zoff_t)zftello(y)) == (zoff_t)-1L) return ZE_TEMP;
|
||||
|
||||
/* assume this archive is one disk and the file is open */
|
||||
|
||||
/* read the local header */
|
||||
res = readlocal(&localz, z);
|
||||
|
||||
/* update disk and offset */
|
||||
z->dsk = 0;
|
||||
z->off = n;
|
||||
|
||||
/* Set encryption and unset any extended local header */
|
||||
z->flg |= 1, z->flg &= ~8;
|
||||
localz->lflg |= 1, localz->lflg &= ~8;
|
||||
|
||||
/* Add size of encryption header */
|
||||
localz->siz += RAND_HEAD_LEN;
|
||||
z->siz = localz->siz;
|
||||
|
||||
/* Put the local header */
|
||||
if ((res = putlocal(localz, PUTLOCAL_WRITE)) != ZE_OK) return res;
|
||||
|
||||
/* Initialize keys with password and write random header */
|
||||
crypthead(passwd, localz->crc);
|
||||
|
||||
/* Encrypt data */
|
||||
b = 0;
|
||||
for (n = z->siz - RAND_HEAD_LEN; n; n--) {
|
||||
if ((c = getc(in_file)) == EOF) {
|
||||
return ferror(in_file) ? ZE_READ : ZE_EOF;
|
||||
}
|
||||
buf[b] = (uch)zencode(c, t);
|
||||
b++;
|
||||
if (b >= 1024) {
|
||||
/* write the buffer */
|
||||
bfwrite(buf, 1, b, BFWRITE_DATA);
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
if (b) {
|
||||
/* write the buffer */
|
||||
bfwrite(buf, 1, b, BFWRITE_DATA);
|
||||
b = 0;
|
||||
}
|
||||
|
||||
/* Since we seek to the start of each local header can skip
|
||||
reading any extended local header */
|
||||
/*
|
||||
if ((flag & 8) != 0 && zfseeko(in_file, 16L, SEEK_CUR)) {
|
||||
return ferror(in_file) ? ZE_READ : ZE_EOF;
|
||||
}
|
||||
if (fflush(y) == EOF) return ZE_TEMP;
|
||||
*/
|
||||
|
||||
/* Update number of bytes written to output file */
|
||||
tempzn += (4 + LOCHEAD) + localz->nam + localz->ext + localz->siz;
|
||||
|
||||
/* Free local header */
|
||||
if (localz->ext) free(localz->extra);
|
||||
if (localz->nam) free(localz->iname);
|
||||
if (localz->nam) free(localz->name);
|
||||
#ifdef UNICODE_SUPPORT
|
||||
if (localz->uname) free(localz->uname);
|
||||
#endif
|
||||
free(localz);
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Decrypt the zip entry described by z from file in_file to file y
|
||||
* using the password passwd. Return an error code in the ZE_ class.
|
||||
*/
|
||||
int zipbare(z, passwd)
|
||||
struct zlist far *z; /* zip entry to encrypt */
|
||||
ZCONST char *passwd; /* password string */
|
||||
{
|
||||
#ifdef ZIP10
|
||||
int c0 /* byte preceding the last input byte */
|
||||
#endif
|
||||
int c1; /* last input byte */
|
||||
/* all file offset and size now zoff_t - 8/28/04 EG */
|
||||
zoff_t size; /* size of input data */
|
||||
struct zlist far *localz; /* local header */
|
||||
uch buf[1024]; /* write buffer */
|
||||
int b; /* bytes in buffer */
|
||||
zoff_t n;
|
||||
int r; /* size of encryption header */
|
||||
int res; /* return code */
|
||||
|
||||
/* Save position */
|
||||
if ((n = (zoff_t)zftello(y)) == (zoff_t)-1L) return ZE_TEMP;
|
||||
|
||||
/* Read local header */
|
||||
res = readlocal(&localz, z);
|
||||
|
||||
/* Update disk and offset */
|
||||
z->dsk = 0;
|
||||
z->off = n;
|
||||
|
||||
/* Initialize keys with password */
|
||||
init_keys(passwd);
|
||||
|
||||
/* Decrypt encryption header, save last two bytes */
|
||||
c1 = 0;
|
||||
for (r = RAND_HEAD_LEN; r; r--) {
|
||||
#ifdef ZIP10
|
||||
c0 = c1;
|
||||
#endif
|
||||
if ((c1 = getc(in_file)) == EOF) {
|
||||
return ferror(in_file) ? ZE_READ : ZE_EOF;
|
||||
}
|
||||
Trace((stdout, " (%02x)", c1));
|
||||
zdecode(c1);
|
||||
Trace((stdout, " %02x", c1));
|
||||
}
|
||||
Trace((stdout, "\n"));
|
||||
|
||||
/* If last two bytes of header don't match crc (or file time in the
|
||||
* case of an extended local header), back up and just copy. For
|
||||
* pkzip 2.0, the check has been reduced to one byte only.
|
||||
*/
|
||||
#ifdef ZIP10
|
||||
if ((ush)(c0 | (c1<<8)) !=
|
||||
(z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) {
|
||||
#else
|
||||
if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) {
|
||||
#endif
|
||||
if (zfseeko(in_file, n, SEEK_SET)) {
|
||||
return ferror(in_file) ? ZE_READ : ZE_EOF;
|
||||
}
|
||||
if ((res = zipcopy(z)) != ZE_OK) {
|
||||
ziperr(res, "was copying an entry");
|
||||
}
|
||||
return ZE_MISS;
|
||||
}
|
||||
|
||||
z->siz -= RAND_HEAD_LEN;
|
||||
localz->siz = z->siz;
|
||||
|
||||
localz->flg = z->flg &= ~9;
|
||||
z->lflg = localz->lflg &= ~9;
|
||||
|
||||
if ((res = putlocal(localz, PUTLOCAL_WRITE)) != ZE_OK) return res;
|
||||
|
||||
/* Decrypt data */
|
||||
b = 0;
|
||||
for (size = z->siz; size; size--) {
|
||||
if ((c1 = getc(in_file)) == EOF) {
|
||||
return ferror(in_file) ? ZE_READ : ZE_EOF;
|
||||
}
|
||||
zdecode(c1);
|
||||
buf[b] = c1;
|
||||
b++;
|
||||
if (b >= 1024) {
|
||||
/* write the buffer */
|
||||
bfwrite(buf, 1, b, BFWRITE_DATA);
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
if (b) {
|
||||
/* write the buffer */
|
||||
bfwrite(buf, 1, b, BFWRITE_DATA);
|
||||
b = 0;
|
||||
}
|
||||
/* Since we seek to the start of each local header can skip
|
||||
reading any extended local header */
|
||||
|
||||
/* Update number of bytes written to output file */
|
||||
tempzn += (4 + LOCHEAD) + localz->nam + localz->ext + localz->siz;
|
||||
|
||||
/* Free local header */
|
||||
if (localz->ext) free(localz->extra);
|
||||
if (localz->nam) free(localz->iname);
|
||||
if (localz->nam) free(localz->name);
|
||||
#ifdef UNICODE_SUPPORT
|
||||
if (localz->uname) free(localz->uname);
|
||||
#endif
|
||||
free(localz);
|
||||
|
||||
return ZE_OK;
|
||||
}
|
||||
|
||||
|
||||
#else /* !UTIL */
|
||||
|
||||
/***********************************************************************
|
||||
* If requested, encrypt the data in buf, and in any case call fwrite()
|
||||
* with the arguments to zfwrite(). Return what fwrite() returns.
|
||||
*
|
||||
* now write to global y
|
||||
*
|
||||
* A bug has been found when encrypting large files that don't
|
||||
* compress. See trees.c for the details and the fix.
|
||||
*/
|
||||
unsigned zfwrite(buf, item_size, nb)
|
||||
zvoid *buf; /* data buffer */
|
||||
extent item_size; /* size of each item in bytes */
|
||||
extent nb; /* number of items */
|
||||
#if 0
|
||||
FILE *f; /* file to write to */
|
||||
#endif
|
||||
{
|
||||
int t; /* temporary */
|
||||
|
||||
if (key != (char *)NULL) { /* key is the global password pointer */
|
||||
ulg size; /* buffer size */
|
||||
char *p = (char *)buf; /* steps through buffer */
|
||||
|
||||
/* Encrypt data in buffer */
|
||||
for (size = item_size*(ulg)nb; size != 0; p++, size--) {
|
||||
*p = (char)zencode(*p, t);
|
||||
}
|
||||
}
|
||||
/* Write the buffer out */
|
||||
return bfwrite(buf, item_size, nb, BFWRITE_DATA);
|
||||
}
|
||||
|
||||
#endif /* ?UTIL */
|
||||
#endif /* ZIP */
|
||||
|
||||
|
||||
#if (defined(UNZIP) && !defined(FUNZIP))
|
||||
|
||||
/***********************************************************************
|
||||
* Get the password and set up keys for current zipfile member.
|
||||
* Return PK_ class error.
|
||||
*/
|
||||
int decrypt(__G__ passwrd)
|
||||
__GDEF
|
||||
ZCONST char *passwrd;
|
||||
{
|
||||
ush b;
|
||||
int n, r;
|
||||
uch h[RAND_HEAD_LEN];
|
||||
|
||||
Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt)));
|
||||
|
||||
/* get header once (turn off "encrypted" flag temporarily so we don't
|
||||
* try to decrypt the same data twice) */
|
||||
GLOBAL(pInfo->encrypted) = FALSE;
|
||||
defer_leftover_input(__G);
|
||||
for (n = 0; n < RAND_HEAD_LEN; n++) {
|
||||
b = NEXTBYTE;
|
||||
h[n] = (uch)b;
|
||||
Trace((stdout, " (%02x)", h[n]));
|
||||
}
|
||||
undefer_input(__G);
|
||||
GLOBAL(pInfo->encrypted) = TRUE;
|
||||
|
||||
if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */
|
||||
GLOBAL(newzip) = FALSE;
|
||||
if (passwrd != (char *)NULL) { /* user gave password on command line */
|
||||
if (!GLOBAL(key)) {
|
||||
if ((GLOBAL(key) = (char *)malloc(strlen(passwrd)+1)) ==
|
||||
(char *)NULL)
|
||||
return PK_MEM2;
|
||||
strcpy(GLOBAL(key), passwrd);
|
||||
GLOBAL(nopwd) = TRUE; /* inhibit password prompting! */
|
||||
}
|
||||
} else if (GLOBAL(key)) { /* get rid of previous zipfile's key */
|
||||
free(GLOBAL(key));
|
||||
GLOBAL(key) = (char *)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* if have key already, test it; else allocate memory for it */
|
||||
if (GLOBAL(key)) {
|
||||
if (!testp(__G__ h))
|
||||
return PK_COOL; /* existing password OK (else prompt for new) */
|
||||
else if (GLOBAL(nopwd))
|
||||
return PK_WARN; /* user indicated no more prompting */
|
||||
} else if ((GLOBAL(key) = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL)
|
||||
return PK_MEM2;
|
||||
|
||||
/* try a few keys */
|
||||
n = 0;
|
||||
do {
|
||||
r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), IZ_PWLEN+1,
|
||||
GLOBAL(zipfn), GLOBAL(filename));
|
||||
if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */
|
||||
free (GLOBAL(key));
|
||||
GLOBAL(key) = NULL;
|
||||
return PK_MEM2;
|
||||
}
|
||||
if (r != IZ_PW_ENTERED) { /* user replied "skip" or "skip all" */
|
||||
*GLOBAL(key) = '\0'; /* We try the NIL password, ... */
|
||||
n = 0; /* and cancel fetch for this item. */
|
||||
}
|
||||
if (!testp(__G__ h))
|
||||
return PK_COOL;
|
||||
if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */
|
||||
GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */
|
||||
} while (n > 0);
|
||||
|
||||
return PK_WARN;
|
||||
|
||||
} /* end function decrypt() */
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Test the password. Return -1 if bad, 0 if OK.
|
||||
*/
|
||||
local int testp(__G__ h)
|
||||
__GDEF
|
||||
ZCONST uch *h;
|
||||
{
|
||||
int r;
|
||||
char *key_translated;
|
||||
|
||||
/* On systems with "obscure" native character coding (e.g., EBCDIC),
|
||||
* the first test translates the password to the "main standard"
|
||||
* character coding. */
|
||||
|
||||
#ifdef STR_TO_CP1
|
||||
/* allocate buffer for translated password */
|
||||
if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
|
||||
return -1;
|
||||
/* first try, test password translated "standard" charset */
|
||||
r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key)));
|
||||
#else /* !STR_TO_CP1 */
|
||||
/* first try, test password as supplied on the extractor's host */
|
||||
r = testkey(__G__ h, GLOBAL(key));
|
||||
#endif /* ?STR_TO_CP1 */
|
||||
|
||||
#ifdef STR_TO_CP2
|
||||
if (r != 0) {
|
||||
#ifndef STR_TO_CP1
|
||||
/* now prepare for second (and maybe third) test with translated pwd */
|
||||
if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
|
||||
return -1;
|
||||
#endif
|
||||
/* second try, password translated to alternate ("standard") charset */
|
||||
r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key)));
|
||||
#ifdef STR_TO_CP3
|
||||
if (r != 0)
|
||||
/* third try, password translated to another "standard" charset */
|
||||
r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key)));
|
||||
#endif
|
||||
#ifndef STR_TO_CP1
|
||||
free(key_translated);
|
||||
#endif
|
||||
}
|
||||
#endif /* STR_TO_CP2 */
|
||||
|
||||
#ifdef STR_TO_CP1
|
||||
free(key_translated);
|
||||
if (r != 0) {
|
||||
/* last resort, test password as supplied on the extractor's host */
|
||||
r = testkey(__G__ h, GLOBAL(key));
|
||||
}
|
||||
#endif /* STR_TO_CP1 */
|
||||
|
||||
return r;
|
||||
|
||||
} /* end function testp() */
|
||||
|
||||
|
||||
local int testkey(__G__ h, key)
|
||||
__GDEF
|
||||
ZCONST uch *h; /* decrypted header */
|
||||
ZCONST char *key; /* decryption password to test */
|
||||
{
|
||||
ush b;
|
||||
#ifdef ZIP10
|
||||
ush c;
|
||||
#endif
|
||||
int n;
|
||||
uch *p;
|
||||
uch hh[RAND_HEAD_LEN]; /* decrypted header */
|
||||
|
||||
/* set keys and save the encrypted header */
|
||||
init_keys(__G__ key);
|
||||
memcpy(hh, h, RAND_HEAD_LEN);
|
||||
|
||||
/* check password */
|
||||
for (n = 0; n < RAND_HEAD_LEN; n++) {
|
||||
zdecode(hh[n]);
|
||||
Trace((stdout, " %02x", hh[n]));
|
||||
}
|
||||
|
||||
/* use fzofft to format zoff_t as strings - 10/19/04 from SMS */
|
||||
Trace((stdout,
|
||||
"\n lrec.crc= %08lx crec.crc= %08lx pInfo->ExtLocHdr= %s\n",
|
||||
GLOBAL(lrec.crc32), GLOBAL(pInfo->crc),
|
||||
GLOBAL(pInfo->ExtLocHdr) ? "true":"false"));
|
||||
Trace((stdout, " incnt = %d unzip offset into zipfile = %s\n",
|
||||
GLOBAL(incnt),
|
||||
fzofft(GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf)),
|
||||
NULL, NULL)));
|
||||
|
||||
/* same test as in zipbare(): */
|
||||
|
||||
#ifdef ZIP10 /* check two bytes */
|
||||
c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1];
|
||||
Trace((stdout,
|
||||
" (c | (b<<8)) = %04x (crc >> 16) = %04x lrec.time = %04x\n",
|
||||
(ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16),
|
||||
((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff))));
|
||||
if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ?
|
||||
((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff) :
|
||||
(ush)(GLOBAL(lrec.crc32) >> 16)))
|
||||
return -1; /* bad */
|
||||
#else
|
||||
b = hh[RAND_HEAD_LEN-1];
|
||||
Trace((stdout, " b = %02x (crc >> 24) = %02x (lrec.time >> 8) = %02x\n",
|
||||
b, (ush)(GLOBAL(lrec.crc32) >> 24),
|
||||
((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff));
|
||||
if (b != (GLOBAL(pInfo->ExtLocHdr) ?
|
||||
((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff :
|
||||
(ush)(GLOBAL(lrec.crc32) >> 24)))
|
||||
return -1; /* bad */
|
||||
#endif
|
||||
/* password OK: decrypt current buffer contents before leaving */
|
||||
for (n = (zoff_t)GLOBAL(incnt) > GLOBAL(csize) ?
|
||||
(int)GLOBAL(csize) : GLOBAL(incnt),
|
||||
p = GLOBAL(inptr); n--; p++)
|
||||
zdecode(*p);
|
||||
return 0; /* OK */
|
||||
|
||||
} /* end function testkey() */
|
||||
|
||||
#endif /* UNZIP && !FUNZIP */
|
||||
|
||||
#else /* !CRYPT */
|
||||
|
||||
/* something "externally visible" to shut up compiler/linker warnings */
|
||||
int zcr_dummy;
|
||||
|
||||
#endif /* ?CRYPT */
|
169
third_party/infozip/zip/crypt.h
vendored
Normal file
169
third_party/infozip/zip/crypt.h
vendored
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE]
|
||||
|
||||
The main encryption/decryption source code for Info-Zip software was
|
||||
originally written in Europe. To the best of our knowledge, it can
|
||||
be freely distributed in both source and object forms from any country,
|
||||
including the USA under License Exception TSU of the U.S. Export
|
||||
Administration Regulations (section 740.13(e)) of 6 June 2002.
|
||||
|
||||
NOTE on copyright history:
|
||||
Previous versions of this source package (up to version 2.8) were
|
||||
not copyrighted and put in the public domain. If you cannot comply
|
||||
with the Info-Zip LICENSE, you may want to look for one of those
|
||||
public domain versions.
|
||||
*/
|
||||
|
||||
#ifndef __crypt_h /* don't include more than once */
|
||||
#define __crypt_h
|
||||
|
||||
#ifdef CRYPT
|
||||
# undef CRYPT
|
||||
#endif
|
||||
/*
|
||||
Logic of selecting "full crypt" code:
|
||||
a) default behaviour:
|
||||
- dummy crypt code when compiling UnZipSFX stub, to minimize size
|
||||
- full crypt code when used to compile Zip, UnZip and fUnZip
|
||||
b) USE_CRYPT defined:
|
||||
- always full crypt code
|
||||
c) NO_CRYPT defined:
|
||||
- never full crypt code
|
||||
NO_CRYPT takes precedence over USE_CRYPT
|
||||
*/
|
||||
#if defined(NO_CRYPT)
|
||||
# define CRYPT 0 /* dummy version */
|
||||
#else
|
||||
#if defined(USE_CRYPT)
|
||||
# define CRYPT 1 /* full version */
|
||||
#else
|
||||
#if !defined(SFX)
|
||||
# define CRYPT 1 /* full version for zip and main unzip */
|
||||
#else
|
||||
# define CRYPT 0 /* dummy version for unzip sfx */
|
||||
#endif
|
||||
#endif /* ?USE_CRYPT */
|
||||
#endif /* ?NO_CRYPT */
|
||||
|
||||
#if CRYPT
|
||||
/* full version */
|
||||
|
||||
#ifdef CR_BETA
|
||||
# undef CR_BETA /* this is not a beta release */
|
||||
#endif
|
||||
|
||||
#define CR_MAJORVER 2
|
||||
#define CR_MINORVER 91
|
||||
#ifdef CR_BETA
|
||||
# define CR_BETA_VER "c BETA"
|
||||
# define CR_VERSION_DATE "05 Jan 2007" /* last real code change */
|
||||
#else
|
||||
# define CR_BETA_VER ""
|
||||
# define CR_VERSION_DATE "05 Jan 2007" /* last public release date */
|
||||
# define CR_RELEASE
|
||||
#endif
|
||||
|
||||
#ifndef __G /* UnZip only, for now (DLL stuff) */
|
||||
# define __G
|
||||
# define __G__
|
||||
# define __GDEF
|
||||
# define __GPRO void
|
||||
# define __GPRO__
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
|
||||
# ifndef DOS_OS2_W32
|
||||
# define DOS_OS2_W32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(DOS_OS2_W32) || defined(__human68k__)
|
||||
# ifndef DOS_H68_OS2_W32
|
||||
# define DOS_H68_OS2_W32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(VM_CMS) || defined(MVS)
|
||||
# ifndef CMS_MVS
|
||||
# define CMS_MVS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* To allow combining of Zip and UnZip static libraries in a single binary,
|
||||
* the Zip and UnZip versions of the crypt core functions have to be named
|
||||
* differently.
|
||||
*/
|
||||
#ifdef ZIP
|
||||
# ifdef REALLY_SHORT_SYMS
|
||||
# define decrypt_byte zdcrby
|
||||
# else
|
||||
# define decrypt_byte zp_decrypt_byte
|
||||
# endif
|
||||
# define update_keys zp_update_keys
|
||||
# define init_keys zp_init_keys
|
||||
#else /* !ZIP */
|
||||
# ifdef REALLY_SHORT_SYMS
|
||||
# define decrypt_byte dcrbyt
|
||||
# endif
|
||||
#endif /* ?ZIP */
|
||||
|
||||
#define IZ_PWLEN 80 /* input buffer size for reading encryption key */
|
||||
#ifndef PWLEN /* for compatibility with previous zcrypt release... */
|
||||
# define PWLEN IZ_PWLEN
|
||||
#endif
|
||||
#define RAND_HEAD_LEN 12 /* length of encryption random header */
|
||||
|
||||
/* the crc_32_tab array has to be provided externally for the crypt calculus */
|
||||
|
||||
/* encode byte c, using temp t. Warning: c must not have side effects. */
|
||||
#define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c))
|
||||
|
||||
/* decode byte c in place */
|
||||
#define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G))
|
||||
|
||||
int decrypt_byte OF((__GPRO));
|
||||
int update_keys OF((__GPRO__ int c));
|
||||
void init_keys OF((__GPRO__ ZCONST char *passwd));
|
||||
|
||||
#ifdef ZIP
|
||||
void crypthead OF((ZCONST char *, ulg));
|
||||
# ifdef UTIL
|
||||
int zipcloak OF((struct zlist far *, ZCONST char *));
|
||||
int zipbare OF((struct zlist far *, ZCONST char *));
|
||||
# else
|
||||
unsigned zfwrite OF((zvoid *, extent, extent));
|
||||
extern char *key;
|
||||
# endif
|
||||
#endif /* ZIP */
|
||||
|
||||
#if (defined(UNZIP) && !defined(FUNZIP))
|
||||
int decrypt OF((__GPRO__ ZCONST char *passwrd));
|
||||
#endif
|
||||
|
||||
#ifdef FUNZIP
|
||||
extern int encrypted;
|
||||
# ifdef NEXTBYTE
|
||||
# undef NEXTBYTE
|
||||
# endif
|
||||
# define NEXTBYTE \
|
||||
(encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
|
||||
#endif /* FUNZIP */
|
||||
|
||||
#else /* !CRYPT */
|
||||
/* dummy version */
|
||||
|
||||
#define zencode
|
||||
#define zdecode
|
||||
|
||||
#define zfwrite(b,s,c) bfwrite(b,s,c,BFWRITE_DATA)
|
||||
|
||||
#endif /* ?CRYPT */
|
||||
#endif /* !__crypt_h */
|
929
third_party/infozip/zip/deflate.c
vendored
Normal file
929
third_party/infozip/zip/deflate.c
vendored
Normal file
|
@ -0,0 +1,929 @@
|
|||
/*
|
||||
deflate.c - Zip 3
|
||||
|
||||
Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2005-Feb-10 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* deflate.c by Jean-loup Gailly.
|
||||
*
|
||||
* PURPOSE
|
||||
*
|
||||
* Identify new text as repetitions of old text within a fixed-
|
||||
* length sliding window trailing behind the new text.
|
||||
*
|
||||
* DISCUSSION
|
||||
*
|
||||
* The "deflation" process depends on being able to identify portions
|
||||
* of the input text which are identical to earlier input (within a
|
||||
* sliding window trailing behind the input currently being processed).
|
||||
*
|
||||
* The most straightforward technique turns out to be the fastest for
|
||||
* most input files: try all possible matches and select the longest.
|
||||
* The key feature of this algorithm is that insertions into the string
|
||||
* dictionary are very simple and thus fast, and deletions are avoided
|
||||
* completely. Insertions are performed at each input character, whereas
|
||||
* string matches are performed only when the previous match ends. So it
|
||||
* is preferable to spend more time in matches to allow very fast string
|
||||
* insertions and avoid deletions. The matching algorithm for small
|
||||
* strings is inspired from that of Rabin & Karp. A brute force approach
|
||||
* is used to find longer strings when a small match has been found.
|
||||
* A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
|
||||
* (by Leonid Broukhis).
|
||||
* A previous version of this file used a more sophisticated algorithm
|
||||
* (by Fiala and Greene) which is guaranteed to run in linear amortized
|
||||
* time, but has a larger average cost, uses more memory and is patented.
|
||||
* However the F&G algorithm may be faster for some highly redundant
|
||||
* files if the parameter max_chain_length (described below) is too large.
|
||||
*
|
||||
* ACKNOWLEDGEMENTS
|
||||
*
|
||||
* The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
|
||||
* I found it in 'freeze' written by Leonid Broukhis.
|
||||
* Thanks to many info-zippers for bug reports and testing.
|
||||
*
|
||||
* REFERENCES
|
||||
*
|
||||
* APPNOTE.TXT documentation file in PKZIP 1.93a distribution.
|
||||
*
|
||||
* A description of the Rabin and Karp algorithm is given in the book
|
||||
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
|
||||
*
|
||||
* Fiala,E.R., and Greene,D.H.
|
||||
* Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
|
||||
*
|
||||
* INTERFACE
|
||||
*
|
||||
* void lm_init (int pack_level, ush *flags)
|
||||
* Initialize the "longest match" routines for a new file
|
||||
*
|
||||
* ulg deflate (void)
|
||||
* Processes a new input file and return its compressed length. Sets
|
||||
* the compressed length, crc, deflate flags and internal file
|
||||
* attributes.
|
||||
*/
|
||||
|
||||
#define __DEFLATE_C
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#ifndef USE_ZLIB
|
||||
|
||||
/* ===========================================================================
|
||||
* Configuration parameters
|
||||
*/
|
||||
|
||||
/* Compile with MEDIUM_MEM to reduce the memory requirements or
|
||||
* with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the
|
||||
* entire input file can be held in memory (not possible on 16 bit systems).
|
||||
* Warning: defining these symbols affects HASH_BITS (see below) and thus
|
||||
* affects the compression ratio. The compressed output
|
||||
* is still correct, and might even be smaller in some cases.
|
||||
*/
|
||||
|
||||
#ifdef SMALL_MEM
|
||||
# define HASH_BITS 13 /* Number of bits used to hash strings */
|
||||
#endif
|
||||
#ifdef MEDIUM_MEM
|
||||
# define HASH_BITS 14
|
||||
#endif
|
||||
#ifndef HASH_BITS
|
||||
# define HASH_BITS 15
|
||||
/* For portability to 16 bit machines, do not use values above 15. */
|
||||
#endif
|
||||
|
||||
#define HASH_SIZE (unsigned)(1<<HASH_BITS)
|
||||
#define HASH_MASK (HASH_SIZE-1)
|
||||
#define WMASK (WSIZE-1)
|
||||
/* HASH_SIZE and WSIZE must be powers of two */
|
||||
|
||||
#define NIL 0
|
||||
/* Tail of hash chains */
|
||||
|
||||
#define FAST 4
|
||||
#define SLOW 2
|
||||
/* speed options for the general purpose bit flag */
|
||||
|
||||
#ifndef TOO_FAR
|
||||
# define TOO_FAR 4096
|
||||
#endif
|
||||
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
|
||||
|
||||
#if (defined(ASMV) && !defined(MSDOS16) && defined(DYN_ALLOC))
|
||||
error: DYN_ALLOC not yet supported in match.S or match32.asm
|
||||
#endif
|
||||
|
||||
#ifdef MEMORY16
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Local data used by the "longest match" routines.
|
||||
*/
|
||||
|
||||
#if defined(MMAP) || defined(BIG_MEM)
|
||||
typedef unsigned Pos; /* must be at least 32 bits */
|
||||
#else
|
||||
typedef ush Pos;
|
||||
#endif
|
||||
typedef unsigned IPos;
|
||||
/* A Pos is an index in the character window. We use short instead of int to
|
||||
* save space in the various tables. IPos is used only for parameter passing.
|
||||
*/
|
||||
|
||||
#ifndef DYN_ALLOC
|
||||
uch window[2L*WSIZE];
|
||||
/* Sliding window. Input bytes are read into the second half of the window,
|
||||
* and move to the first half later to keep a dictionary of at least WSIZE
|
||||
* bytes. With this organization, matches are limited to a distance of
|
||||
* WSIZE-MAX_MATCH bytes, but this ensures that IO is always
|
||||
* performed with a length multiple of the block size. Also, it limits
|
||||
* the window size to 64K, which is quite useful on MSDOS.
|
||||
* To do: limit the window size to WSIZE+CBSZ if SMALL_MEM (the code would
|
||||
* be less efficient since the data would have to be copied WSIZE/CBSZ times)
|
||||
*/
|
||||
Pos prev[WSIZE];
|
||||
/* Link to older string with same hash index. To limit the size of this
|
||||
* array to 64K, this link is maintained only for the last 32K strings.
|
||||
* An index in this array is thus a window index modulo 32K.
|
||||
*/
|
||||
Pos head[HASH_SIZE];
|
||||
/* Heads of the hash chains or NIL. If your compiler thinks that
|
||||
* HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC.
|
||||
*/
|
||||
#else
|
||||
uch far * near window = NULL;
|
||||
Pos far * near prev = NULL;
|
||||
Pos far * near head;
|
||||
#endif
|
||||
ulg window_size;
|
||||
/* window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the
|
||||
* input file length plus MIN_LOOKAHEAD.
|
||||
*/
|
||||
|
||||
long block_start;
|
||||
/* window position at the beginning of the current output block. Gets
|
||||
* negative when the window is moved backwards.
|
||||
*/
|
||||
|
||||
local int sliding;
|
||||
/* Set to false when the input file is already in memory */
|
||||
|
||||
local unsigned ins_h; /* hash index of string to be inserted */
|
||||
|
||||
#define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
|
||||
/* Number of bits by which ins_h and del_h must be shifted at each
|
||||
* input step. It must be such that after MIN_MATCH steps, the oldest
|
||||
* byte no longer takes part in the hash key, that is:
|
||||
* H_SHIFT * MIN_MATCH >= HASH_BITS
|
||||
*/
|
||||
|
||||
unsigned int near prev_length;
|
||||
/* Length of the best match at previous step. Matches not greater than this
|
||||
* are discarded. This is used in the lazy match evaluation.
|
||||
*/
|
||||
|
||||
unsigned near strstart; /* start of string to insert */
|
||||
unsigned near match_start; /* start of matching string */
|
||||
local int eofile; /* flag set at end of input file */
|
||||
local unsigned lookahead; /* number of valid bytes ahead in window */
|
||||
|
||||
unsigned near max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this length.
|
||||
* A higher limit improves compression ratio but degrades the speed.
|
||||
*/
|
||||
|
||||
local unsigned int max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly
|
||||
* smaller than this value. This mechanism is used only for compression
|
||||
* levels >= 4.
|
||||
*/
|
||||
#define max_insert_length max_lazy_match
|
||||
/* Insert new strings in the hash table only if the match length
|
||||
* is not greater than this length. This saves time but degrades compression.
|
||||
* max_insert_length is used only for compression levels <= 3.
|
||||
*/
|
||||
|
||||
unsigned near good_match;
|
||||
/* Use a faster search when the previous match is longer than this */
|
||||
|
||||
#ifdef FULL_SEARCH
|
||||
# define nice_match MAX_MATCH
|
||||
#else
|
||||
int near nice_match; /* Stop searching when current match exceeds this */
|
||||
#endif
|
||||
|
||||
|
||||
/* Values for max_lazy_match, good_match, nice_match and max_chain_length,
|
||||
* depending on the desired pack level (0..9). The values given below have
|
||||
* been tuned to exclude worst case performance for pathological files.
|
||||
* Better values may be found for specific files.
|
||||
*/
|
||||
|
||||
typedef struct config {
|
||||
ush good_length; /* reduce lazy search above this match length */
|
||||
ush max_lazy; /* do not perform lazy search above this match length */
|
||||
ush nice_length; /* quit search above this match length */
|
||||
ush max_chain;
|
||||
} config;
|
||||
|
||||
local config configuration_table[10] = {
|
||||
/* good lazy nice chain */
|
||||
/* 0 */ {0, 0, 0, 0}, /* store only */
|
||||
/* 1 */ {4, 4, 8, 4}, /* maximum speed, no lazy matches */
|
||||
/* 2 */ {4, 5, 16, 8},
|
||||
/* 3 */ {4, 6, 32, 32},
|
||||
|
||||
/* 4 */ {4, 4, 16, 16}, /* lazy matches */
|
||||
/* 5 */ {8, 16, 32, 32},
|
||||
/* 6 */ {8, 16, 128, 128},
|
||||
/* 7 */ {8, 32, 128, 256},
|
||||
/* 8 */ {32, 128, 258, 1024},
|
||||
/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */
|
||||
|
||||
/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
|
||||
* For deflate_fast() (levels <= 3) good is ignored and lazy has a different
|
||||
* meaning.
|
||||
*/
|
||||
|
||||
#define EQUAL 0
|
||||
/* result of memcmp for equal strings */
|
||||
|
||||
/* ===========================================================================
|
||||
* Prototypes for local functions.
|
||||
*/
|
||||
|
||||
local void fill_window OF((void));
|
||||
|
||||
local uzoff_t deflate_fast OF((void)); /* now use uzoff_t 7/24/04 EG */
|
||||
|
||||
int longest_match OF((IPos cur_match));
|
||||
#if defined(ASMV) && !defined(RISCOS)
|
||||
void match_init OF((void)); /* asm code initialization */
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
local void check_match OF((IPos start, IPos match, int length));
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Update a hash value with the given input byte
|
||||
* IN assertion: all calls to to UPDATE_HASH are made with consecutive
|
||||
* input characters, so that a running hash key can be computed from the
|
||||
* previous key instead of complete recalculation each time.
|
||||
*/
|
||||
#define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
|
||||
|
||||
/* ===========================================================================
|
||||
* Insert string s in the dictionary and set match_head to the previous head
|
||||
* of the hash chain (the most recent string with same hash key). Return
|
||||
* the previous length of the hash chain.
|
||||
* IN assertion: all calls to to INSERT_STRING are made with consecutive
|
||||
* input characters and the first MIN_MATCH bytes of s are valid
|
||||
* (except for the last MIN_MATCH-1 bytes of the input file).
|
||||
*/
|
||||
#define INSERT_STRING(s, match_head) \
|
||||
(UPDATE_HASH(ins_h, window[(s) + (MIN_MATCH-1)]), \
|
||||
prev[(s) & WMASK] = match_head = head[ins_h], \
|
||||
head[ins_h] = (s))
|
||||
|
||||
/* ===========================================================================
|
||||
* Initialize the "longest match" routines for a new file
|
||||
*
|
||||
* IN assertion: window_size is > 0 if the input file is already read or
|
||||
* mmap'ed in the window[] array, 0 otherwise. In the first case,
|
||||
* window_size is sufficient to contain the whole input file plus
|
||||
* MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end
|
||||
* of window[] when looking for matches towards the end).
|
||||
*/
|
||||
void lm_init (pack_level, flags)
|
||||
int pack_level; /* 0: store, 1: best speed, 9: best compression */
|
||||
ush *flags; /* general purpose bit flag */
|
||||
{
|
||||
register unsigned j;
|
||||
|
||||
if (pack_level < 1 || pack_level > 9) error("bad pack level");
|
||||
|
||||
/* Do not slide the window if the whole input is already in memory
|
||||
* (window_size > 0)
|
||||
*/
|
||||
sliding = 0;
|
||||
if (window_size == 0L) {
|
||||
sliding = 1;
|
||||
window_size = (ulg)2L*WSIZE;
|
||||
}
|
||||
|
||||
/* Use dynamic allocation if compiler does not like big static arrays: */
|
||||
#ifdef DYN_ALLOC
|
||||
if (window == NULL) {
|
||||
window = (uch far *) zcalloc(WSIZE, 2*sizeof(uch));
|
||||
if (window == NULL) ziperr(ZE_MEM, "window allocation");
|
||||
}
|
||||
if (prev == NULL) {
|
||||
prev = (Pos far *) zcalloc(WSIZE, sizeof(Pos));
|
||||
head = (Pos far *) zcalloc(HASH_SIZE, sizeof(Pos));
|
||||
if (prev == NULL || head == NULL) {
|
||||
ziperr(ZE_MEM, "hash table allocation");
|
||||
}
|
||||
}
|
||||
#endif /* DYN_ALLOC */
|
||||
|
||||
/* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
|
||||
* prev[] will be initialized on the fly.
|
||||
*/
|
||||
head[HASH_SIZE-1] = NIL;
|
||||
memset((char*)head, NIL, (unsigned)(HASH_SIZE-1)*sizeof(*head));
|
||||
|
||||
/* Set the default configuration parameters:
|
||||
*/
|
||||
max_lazy_match = configuration_table[pack_level].max_lazy;
|
||||
good_match = configuration_table[pack_level].good_length;
|
||||
#ifndef FULL_SEARCH
|
||||
nice_match = configuration_table[pack_level].nice_length;
|
||||
#endif
|
||||
max_chain_length = configuration_table[pack_level].max_chain;
|
||||
if (pack_level <= 2) {
|
||||
*flags |= FAST;
|
||||
} else if (pack_level >= 8) {
|
||||
*flags |= SLOW;
|
||||
}
|
||||
/* ??? reduce max_chain_length for binary files */
|
||||
|
||||
strstart = 0;
|
||||
block_start = 0L;
|
||||
#if defined(ASMV) && !defined(RISCOS)
|
||||
match_init(); /* initialize the asm code */
|
||||
#endif
|
||||
|
||||
j = WSIZE;
|
||||
#ifndef MAXSEG_64K
|
||||
if (sizeof(int) > 2) j <<= 1; /* Can read 64K in one step */
|
||||
#endif
|
||||
lookahead = (*read_buf)((char*)window, j);
|
||||
|
||||
if (lookahead == 0 || lookahead == (unsigned)EOF) {
|
||||
eofile = 1, lookahead = 0;
|
||||
return;
|
||||
}
|
||||
eofile = 0;
|
||||
/* Make sure that we always have enough lookahead. This is important
|
||||
* if input comes from a device such as a tty.
|
||||
*/
|
||||
if (lookahead < MIN_LOOKAHEAD) fill_window();
|
||||
|
||||
ins_h = 0;
|
||||
for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
|
||||
/* If lookahead < MIN_MATCH, ins_h is garbage, but this is
|
||||
* not important since only literal bytes will be emitted.
|
||||
*/
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Free the window and hash table
|
||||
*/
|
||||
void lm_free()
|
||||
{
|
||||
#ifdef DYN_ALLOC
|
||||
if (window != NULL) {
|
||||
zcfree(window);
|
||||
window = NULL;
|
||||
}
|
||||
if (prev != NULL) {
|
||||
zcfree(prev);
|
||||
zcfree(head);
|
||||
prev = head = NULL;
|
||||
}
|
||||
#endif /* DYN_ALLOC */
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Set match_start to the longest match starting at the given string and
|
||||
* return its length. Matches shorter or equal to prev_length are discarded,
|
||||
* in which case the result is equal to prev_length and match_start is
|
||||
* garbage.
|
||||
* IN assertions: cur_match is the head of the hash chain for the current
|
||||
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
|
||||
*/
|
||||
#ifndef ASMV
|
||||
/* For 80x86 and 680x0 and ARM, an optimized version is in match.asm or
|
||||
* match.S. The code is functionally equivalent, so you can use the C version
|
||||
* if desired.
|
||||
*/
|
||||
int longest_match(cur_match)
|
||||
IPos cur_match; /* current match */
|
||||
{
|
||||
unsigned chain_length = max_chain_length; /* max hash chain length */
|
||||
register uch far *scan = window + strstart; /* current string */
|
||||
register uch far *match; /* matched string */
|
||||
register int len; /* length of current match */
|
||||
int best_len = prev_length; /* best match length so far */
|
||||
IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
|
||||
/* Stop when cur_match becomes <= limit. To simplify the code,
|
||||
* we prevent matches with the string of window index 0.
|
||||
*/
|
||||
|
||||
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
|
||||
* It is easy to get rid of this optimization if necessary.
|
||||
*/
|
||||
#if HASH_BITS < 8 || MAX_MATCH != 258
|
||||
error: Code too clever
|
||||
#endif
|
||||
|
||||
#ifdef UNALIGNED_OK
|
||||
/* Compare two bytes at a time. Note: this is not always beneficial.
|
||||
* Try with and without -DUNALIGNED_OK to check.
|
||||
*/
|
||||
register uch far *strend = window + strstart + MAX_MATCH - 1;
|
||||
register ush scan_start = *(ush far *)scan;
|
||||
register ush scan_end = *(ush far *)(scan+best_len-1);
|
||||
#else
|
||||
register uch far *strend = window + strstart + MAX_MATCH;
|
||||
register uch scan_end1 = scan[best_len-1];
|
||||
register uch scan_end = scan[best_len];
|
||||
#endif
|
||||
|
||||
/* Do not waste too much time if we already have a good match: */
|
||||
if (prev_length >= good_match) {
|
||||
chain_length >>= 2;
|
||||
}
|
||||
|
||||
Assert(strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead");
|
||||
|
||||
do {
|
||||
Assert(cur_match < strstart, "no future");
|
||||
match = window + cur_match;
|
||||
|
||||
/* Skip to next match if the match length cannot increase
|
||||
* or if the match length is less than 2:
|
||||
*/
|
||||
#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
|
||||
/* This code assumes sizeof(unsigned short) == 2. Do not use
|
||||
* UNALIGNED_OK if your compiler uses a different size.
|
||||
*/
|
||||
if (*(ush far *)(match+best_len-1) != scan_end ||
|
||||
*(ush far *)match != scan_start) continue;
|
||||
|
||||
/* It is not necessary to compare scan[2] and match[2] since they are
|
||||
* always equal when the other bytes match, given that the hash keys
|
||||
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
||||
* strstart+3, +5, ... up to strstart+257. We check for insufficient
|
||||
* lookahead only every 4th comparison; the 128th check will be made
|
||||
* at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
|
||||
* necessary to put more guard bytes at the end of the window, or
|
||||
* to check more often for insufficient lookahead.
|
||||
*/
|
||||
scan++, match++;
|
||||
do {
|
||||
} while (*(ush far *)(scan+=2) == *(ush far *)(match+=2) &&
|
||||
*(ush far *)(scan+=2) == *(ush far *)(match+=2) &&
|
||||
*(ush far *)(scan+=2) == *(ush far *)(match+=2) &&
|
||||
*(ush far *)(scan+=2) == *(ush far *)(match+=2) &&
|
||||
scan < strend);
|
||||
/* The funny "do {}" generates better code on most compilers */
|
||||
|
||||
/* Here, scan <= window+strstart+257 */
|
||||
Assert(scan <= window+(unsigned)(window_size-1), "wild scan");
|
||||
if (*scan == *match) scan++;
|
||||
|
||||
len = (MAX_MATCH - 1) - (int)(strend-scan);
|
||||
scan = strend - (MAX_MATCH-1);
|
||||
|
||||
#else /* UNALIGNED_OK */
|
||||
|
||||
if (match[best_len] != scan_end ||
|
||||
match[best_len-1] != scan_end1 ||
|
||||
*match != *scan ||
|
||||
*++match != scan[1]) continue;
|
||||
|
||||
/* The check at best_len-1 can be removed because it will be made
|
||||
* again later. (This heuristic is not always a win.)
|
||||
* It is not necessary to compare scan[2] and match[2] since they
|
||||
* are always equal when the other bytes match, given that
|
||||
* the hash keys are equal and that HASH_BITS >= 8.
|
||||
*/
|
||||
scan += 2, match++;
|
||||
|
||||
/* We check for insufficient lookahead only every 8th comparison;
|
||||
* the 256th check will be made at strstart+258.
|
||||
*/
|
||||
do {
|
||||
} while (*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
*++scan == *++match && *++scan == *++match &&
|
||||
scan < strend);
|
||||
|
||||
Assert(scan <= window+(unsigned)(window_size-1), "wild scan");
|
||||
|
||||
len = MAX_MATCH - (int)(strend - scan);
|
||||
scan = strend - MAX_MATCH;
|
||||
|
||||
#endif /* UNALIGNED_OK */
|
||||
|
||||
if (len > best_len) {
|
||||
match_start = cur_match;
|
||||
best_len = len;
|
||||
if (len >= nice_match) break;
|
||||
#ifdef UNALIGNED_OK
|
||||
scan_end = *(ush far *)(scan+best_len-1);
|
||||
#else
|
||||
scan_end1 = scan[best_len-1];
|
||||
scan_end = scan[best_len];
|
||||
#endif
|
||||
}
|
||||
} while ((cur_match = prev[cur_match & WMASK]) > limit
|
||||
&& --chain_length != 0);
|
||||
|
||||
return best_len;
|
||||
}
|
||||
#endif /* ASMV */
|
||||
|
||||
#ifdef DEBUG
|
||||
/* ===========================================================================
|
||||
* Check that the match at match_start is indeed a match.
|
||||
*/
|
||||
local void check_match(start, match, length)
|
||||
IPos start, match;
|
||||
int length;
|
||||
{
|
||||
/* check that the match is indeed a match */
|
||||
if (memcmp((char*)window + match,
|
||||
(char*)window + start, length) != EQUAL) {
|
||||
fprintf(mesg,
|
||||
" start %d, match %d, length %d\n",
|
||||
start, match, length);
|
||||
error("invalid match");
|
||||
}
|
||||
if (verbose > 1) {
|
||||
fprintf(mesg,"\\[%d,%d]", start-match, length);
|
||||
#ifndef WINDLL
|
||||
do { putc(window[start++], mesg); } while (--length != 0);
|
||||
#else
|
||||
do { fprintf(stdout,"%c",window[start++]); } while (--length != 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define check_match(start, match, length)
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the current block, with given end-of-file flag.
|
||||
* IN assertion: strstart is set to the end of the current match.
|
||||
*/
|
||||
#define FLUSH_BLOCK(eof) \
|
||||
flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
|
||||
(char*)NULL, (ulg)strstart - (ulg)block_start, (eof))
|
||||
|
||||
/* ===========================================================================
|
||||
* Fill the window when the lookahead becomes insufficient.
|
||||
* Updates strstart and lookahead, and sets eofile if end of input file.
|
||||
*
|
||||
* IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
|
||||
* OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
|
||||
* At least one byte has been read, or eofile is set; file reads are
|
||||
* performed for at least two bytes (required for the translate_eol option).
|
||||
*/
|
||||
local void fill_window()
|
||||
{
|
||||
register unsigned n, m;
|
||||
unsigned more; /* Amount of free space at the end of the window. */
|
||||
|
||||
do {
|
||||
more = (unsigned)(window_size - (ulg)lookahead - (ulg)strstart);
|
||||
|
||||
/* If the window is almost full and there is insufficient lookahead,
|
||||
* move the upper half to the lower one to make room in the upper half.
|
||||
*/
|
||||
if (more == (unsigned)EOF) {
|
||||
/* Very unlikely, but possible on 16 bit machine if strstart == 0
|
||||
* and lookahead == 1 (input done one byte at time)
|
||||
*/
|
||||
more--;
|
||||
|
||||
/* For MMAP or BIG_MEM, the whole input file is already in memory so
|
||||
* we must not perform sliding. We must however call (*read_buf)() in
|
||||
* order to compute the crc, update lookahead and possibly set eofile.
|
||||
*/
|
||||
} else if (strstart >= WSIZE+MAX_DIST && sliding) {
|
||||
|
||||
#ifdef FORCE_METHOD
|
||||
/* When methods "stored" or "store_block" are requested, the
|
||||
* current block must be flushed before sliding the window.
|
||||
*/
|
||||
if (level <= 2) FLUSH_BLOCK(0), block_start = strstart;
|
||||
#endif
|
||||
/* By the IN assertion, the window is not empty so we can't confuse
|
||||
* more == 0 with more == 64K on a 16 bit machine.
|
||||
*/
|
||||
memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
|
||||
match_start -= WSIZE;
|
||||
strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
|
||||
|
||||
block_start -= (long) WSIZE;
|
||||
|
||||
for (n = 0; n < HASH_SIZE; n++) {
|
||||
m = head[n];
|
||||
head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
|
||||
}
|
||||
for (n = 0; n < WSIZE; n++) {
|
||||
m = prev[n];
|
||||
prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
|
||||
/* If n is not on any hash chain, prev[n] is garbage but
|
||||
* its value will never be used.
|
||||
*/
|
||||
}
|
||||
more += WSIZE;
|
||||
if (dot_size > 0 && !display_globaldots) {
|
||||
/* initial space */
|
||||
if (noisy && dot_count == -1) {
|
||||
#ifndef WINDLL
|
||||
putc(' ', mesg);
|
||||
fflush(mesg);
|
||||
#else
|
||||
fprintf(stdout,"%c",' ');
|
||||
#endif
|
||||
dot_count++;
|
||||
}
|
||||
dot_count++;
|
||||
if (dot_size <= (dot_count + 1) * WSIZE) dot_count = 0;
|
||||
}
|
||||
if ((verbose || noisy) && dot_size && !dot_count) {
|
||||
#ifndef WINDLL
|
||||
putc('.', mesg);
|
||||
fflush(mesg);
|
||||
#else
|
||||
fprintf(stdout,"%c",'.');
|
||||
#endif
|
||||
mesg_line_started = 1;
|
||||
}
|
||||
}
|
||||
if (eofile) return;
|
||||
|
||||
/* If there was no sliding:
|
||||
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
||||
* more == window_size - lookahead - strstart
|
||||
* => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
|
||||
* => more >= window_size - 2*WSIZE + 2
|
||||
* In the MMAP or BIG_MEM case (not yet supported in gzip),
|
||||
* window_size == input_size + MIN_LOOKAHEAD &&
|
||||
* strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD.
|
||||
* Otherwise, window_size == 2*WSIZE so more >= 2.
|
||||
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
|
||||
*/
|
||||
Assert(more >= 2, "more < 2");
|
||||
|
||||
n = (*read_buf)((char*)window+strstart+lookahead, more);
|
||||
if (n == 0 || n == (unsigned)EOF) {
|
||||
eofile = 1;
|
||||
} else {
|
||||
lookahead += n;
|
||||
}
|
||||
} while (lookahead < MIN_LOOKAHEAD && !eofile);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Processes a new input file and return its compressed length. This
|
||||
* function does not perform lazy evaluation of matches and inserts
|
||||
* new strings in the dictionary only for unmatched strings or for short
|
||||
* matches. It is used only for the fast compression options.
|
||||
*/
|
||||
local uzoff_t deflate_fast()
|
||||
{
|
||||
IPos hash_head = NIL; /* head of the hash chain */
|
||||
int flush; /* set if current block must be flushed */
|
||||
unsigned match_length = 0; /* length of best match */
|
||||
|
||||
prev_length = MIN_MATCH-1;
|
||||
while (lookahead != 0) {
|
||||
/* Insert the string window[strstart .. strstart+2] in the
|
||||
* dictionary, and set hash_head to the head of the hash chain:
|
||||
*/
|
||||
#ifndef DEFL_UNDETERM
|
||||
if (lookahead >= MIN_MATCH)
|
||||
#endif
|
||||
INSERT_STRING(strstart, hash_head);
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
* At this point we have always match_length < MIN_MATCH
|
||||
*/
|
||||
if (hash_head != NIL && strstart - hash_head <= MAX_DIST) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
#ifndef HUFFMAN_ONLY
|
||||
# ifndef DEFL_UNDETERM
|
||||
/* Do not look for matches beyond the end of the input.
|
||||
* This is necessary to make deflate deterministic.
|
||||
*/
|
||||
if ((unsigned)nice_match > lookahead) nice_match = (int)lookahead;
|
||||
# endif
|
||||
match_length = longest_match (hash_head);
|
||||
/* longest_match() sets match_start */
|
||||
if (match_length > lookahead) match_length = lookahead;
|
||||
#endif
|
||||
}
|
||||
if (match_length >= MIN_MATCH) {
|
||||
check_match(strstart, match_start, match_length);
|
||||
|
||||
flush = ct_tally(strstart-match_start, match_length - MIN_MATCH);
|
||||
|
||||
lookahead -= match_length;
|
||||
|
||||
/* Insert new strings in the hash table only if the match length
|
||||
* is not too large. This saves time but degrades compression.
|
||||
*/
|
||||
if (match_length <= max_insert_length
|
||||
#ifndef DEFL_UNDETERM
|
||||
&& lookahead >= MIN_MATCH
|
||||
#endif
|
||||
) {
|
||||
match_length--; /* string at strstart already in hash table */
|
||||
do {
|
||||
strstart++;
|
||||
INSERT_STRING(strstart, hash_head);
|
||||
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
|
||||
* always MIN_MATCH bytes ahead.
|
||||
*/
|
||||
#ifdef DEFL_UNDETERM
|
||||
/* If lookahead < MIN_MATCH these bytes are garbage,
|
||||
* but it does not matter since the next lookahead bytes
|
||||
* will be emitted as literals.
|
||||
*/
|
||||
#endif
|
||||
} while (--match_length != 0);
|
||||
strstart++;
|
||||
} else {
|
||||
strstart += match_length;
|
||||
match_length = 0;
|
||||
ins_h = window[strstart];
|
||||
UPDATE_HASH(ins_h, window[strstart+1]);
|
||||
#if MIN_MATCH != 3
|
||||
Call UPDATE_HASH() MIN_MATCH-3 more times
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
/* No match, output a literal byte */
|
||||
Tracevv((stderr,"%c",window[strstart]));
|
||||
flush = ct_tally (0, window[strstart]);
|
||||
lookahead--;
|
||||
strstart++;
|
||||
}
|
||||
if (flush) FLUSH_BLOCK(0), block_start = strstart;
|
||||
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need MAX_MATCH bytes
|
||||
* for the next match, plus MIN_MATCH bytes to insert the
|
||||
* string following the next match.
|
||||
*/
|
||||
if (lookahead < MIN_LOOKAHEAD) fill_window();
|
||||
}
|
||||
return FLUSH_BLOCK(1); /* eof */
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Same as above, but achieves better compression. We use a lazy
|
||||
* evaluation for matches: a match is finally adopted only if there is
|
||||
* no better match at the next window position.
|
||||
*/
|
||||
uzoff_t deflate()
|
||||
{
|
||||
IPos hash_head = NIL; /* head of hash chain */
|
||||
IPos prev_match; /* previous match */
|
||||
int flush; /* set if current block must be flushed */
|
||||
int match_available = 0; /* set if previous match exists */
|
||||
register unsigned match_length = MIN_MATCH-1; /* length of best match */
|
||||
#ifdef DEBUG
|
||||
extern uzoff_t isize; /* byte length of input file, for debug only */
|
||||
#endif
|
||||
|
||||
if (level <= 3) return deflate_fast(); /* optimized for speed */
|
||||
|
||||
/* Process the input block. */
|
||||
while (lookahead != 0) {
|
||||
/* Insert the string window[strstart .. strstart+2] in the
|
||||
* dictionary, and set hash_head to the head of the hash chain:
|
||||
*/
|
||||
#ifndef DEFL_UNDETERM
|
||||
if (lookahead >= MIN_MATCH)
|
||||
#endif
|
||||
INSERT_STRING(strstart, hash_head);
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
*/
|
||||
prev_length = match_length, prev_match = match_start;
|
||||
match_length = MIN_MATCH-1;
|
||||
|
||||
if (hash_head != NIL && prev_length < max_lazy_match &&
|
||||
strstart - hash_head <= MAX_DIST) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
#ifndef HUFFMAN_ONLY
|
||||
# ifndef DEFL_UNDETERM
|
||||
/* Do not look for matches beyond the end of the input.
|
||||
* This is necessary to make deflate deterministic.
|
||||
*/
|
||||
if ((unsigned)nice_match > lookahead) nice_match = (int)lookahead;
|
||||
# endif
|
||||
match_length = longest_match (hash_head);
|
||||
/* longest_match() sets match_start */
|
||||
if (match_length > lookahead) match_length = lookahead;
|
||||
#endif
|
||||
|
||||
#ifdef FILTERED
|
||||
/* Ignore matches of length <= 5 */
|
||||
if (match_length <= 5) {
|
||||
#else
|
||||
/* Ignore a length 3 match if it is too distant: */
|
||||
if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){
|
||||
#endif
|
||||
/* If prev_match is also MIN_MATCH, match_start is garbage
|
||||
* but we will ignore the current match anyway.
|
||||
*/
|
||||
match_length = MIN_MATCH-1;
|
||||
}
|
||||
}
|
||||
/* If there was a match at the previous step and the current
|
||||
* match is not better, output the previous match:
|
||||
*/
|
||||
if (prev_length >= MIN_MATCH && match_length <= prev_length) {
|
||||
#ifndef DEFL_UNDETERM
|
||||
unsigned max_insert = strstart + lookahead - MIN_MATCH;
|
||||
|
||||
#endif
|
||||
check_match(strstart-1, prev_match, prev_length);
|
||||
|
||||
flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH);
|
||||
|
||||
/* Insert in hash table all strings up to the end of the match.
|
||||
* strstart-1 and strstart are already inserted.
|
||||
*/
|
||||
lookahead -= prev_length-1;
|
||||
prev_length -= 2;
|
||||
#ifndef DEFL_UNDETERM
|
||||
do {
|
||||
if (++strstart <= max_insert) {
|
||||
INSERT_STRING(strstart, hash_head);
|
||||
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
|
||||
* always MIN_MATCH bytes ahead.
|
||||
*/
|
||||
}
|
||||
} while (--prev_length != 0);
|
||||
strstart++;
|
||||
#else /* DEFL_UNDETERM */
|
||||
do {
|
||||
strstart++;
|
||||
INSERT_STRING(strstart, hash_head);
|
||||
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
|
||||
* always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
|
||||
* these bytes are garbage, but it does not matter since the
|
||||
* next lookahead bytes will always be emitted as literals.
|
||||
*/
|
||||
} while (--prev_length != 0);
|
||||
strstart++;
|
||||
#endif /* ?DEFL_UNDETERM */
|
||||
match_available = 0;
|
||||
match_length = MIN_MATCH-1;
|
||||
|
||||
if (flush) FLUSH_BLOCK(0), block_start = strstart;
|
||||
|
||||
} else if (match_available) {
|
||||
/* If there was no match at the previous position, output a
|
||||
* single literal. If there was a match but the current match
|
||||
* is longer, truncate the previous match to a single literal.
|
||||
*/
|
||||
Tracevv((stderr,"%c",window[strstart-1]));
|
||||
if (ct_tally (0, window[strstart-1])) {
|
||||
FLUSH_BLOCK(0), block_start = strstart;
|
||||
}
|
||||
strstart++;
|
||||
lookahead--;
|
||||
} else {
|
||||
/* There is no previous match to compare with, wait for
|
||||
* the next step to decide.
|
||||
*/
|
||||
match_available = 1;
|
||||
strstart++;
|
||||
lookahead--;
|
||||
}
|
||||
Assert(strstart <= isize && lookahead <= isize, "a bit too far");
|
||||
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need MAX_MATCH bytes
|
||||
* for the next match, plus MIN_MATCH bytes to insert the
|
||||
* string following the next match.
|
||||
*/
|
||||
if (lookahead < MIN_LOOKAHEAD) fill_window();
|
||||
}
|
||||
if (match_available) ct_tally (0, window[strstart-1]);
|
||||
|
||||
return FLUSH_BLOCK(1); /* eof */
|
||||
}
|
||||
#endif /* !USE_ZLIB */
|
328
third_party/infozip/zip/ebcdic.h
vendored
Normal file
328
third_party/infozip/zip/ebcdic.h
vendored
Normal file
|
@ -0,0 +1,328 @@
|
|||
/*
|
||||
ebcdic.h
|
||||
|
||||
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2005-Feb-10 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, both of these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/licen
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
ebcdic.h
|
||||
|
||||
The CECP 1047 (Extended de-facto EBCDIC) <-> ISO 8859-1 conversion tables,
|
||||
from ftp://aix1.segi.ulg.ac.be/pub/docs/iso8859/iso8859.networking
|
||||
|
||||
NOTES:
|
||||
<Paul_von_Behren@stortek.com> (OS/390 port 12/97)
|
||||
These table no longer represent the standard mappings (for example in the
|
||||
OS/390 iconv utility). In order to follow current standards I remapped
|
||||
ebcdic x0a to ascii x15 and
|
||||
ebcdic x85 to ascii x25 (and vice-versa)
|
||||
Without these changes, newlines in auto-convert text files appeared
|
||||
as literal \045.
|
||||
I'm not sure what effect this remap would have on the MVS and CMS ports, so
|
||||
I ifdef'd these changes. Hopefully these ifdef's can be removed when the
|
||||
MVS/CMS folks test the new mappings.
|
||||
|
||||
Christian Spieler <spieler@ikp.tu-darmstadt.de>, 27-Apr-1998
|
||||
The problem mentioned by Paul von Behren was already observed previously
|
||||
on VM/CMS, during the preparation of the CMS&MVS port of UnZip 5.20 in
|
||||
1996. At that point, the ebcdic tables were not changed since they seemed
|
||||
to be an adopted standard (to my knowledge, these tables are still used
|
||||
as presented in mainfraime KERMIT). Instead, the "end-of-line" conversion
|
||||
feature of Zip's and UnZip's "text-translation" mode was used to force
|
||||
correct mappings between ASCII and EBCDIC newline markers.
|
||||
Before interchanging the ASCII mappings of the EBCDIC control characters
|
||||
"NL" 0x25 and "LF" 0x15 according to the OS/390 setting, we have to
|
||||
make sure that EBCDIC 0x15 is never used as line termination.
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ebcdic_h /* prevent multiple inclusions */
|
||||
#define __ebcdic_h
|
||||
|
||||
|
||||
#ifndef ZCONST
|
||||
# define ZCONST const
|
||||
#endif
|
||||
|
||||
#ifdef EBCDIC
|
||||
#ifndef MTS /* MTS uses a slightly "special" EBCDIC code page */
|
||||
|
||||
ZCONST uch ebcdic[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
|
||||
#ifdef OS390
|
||||
0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
|
||||
#else
|
||||
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
|
||||
#endif
|
||||
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
|
||||
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
|
||||
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
|
||||
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
|
||||
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
|
||||
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
|
||||
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
|
||||
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
|
||||
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
|
||||
0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, /* 58 - 5F */
|
||||
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
|
||||
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
|
||||
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
|
||||
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
|
||||
#ifdef OS390
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, /* 80 - 87 */
|
||||
#else
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
|
||||
#endif
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
|
||||
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
|
||||
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
|
||||
0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC, /* A8 - AF */
|
||||
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
|
||||
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
|
||||
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
|
||||
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
|
||||
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
|
||||
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59, /* D8 - DF */
|
||||
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
|
||||
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
|
||||
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
|
||||
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
|
||||
};
|
||||
|
||||
#if (defined(ZIP) || CRYPT)
|
||||
ZCONST uch ascii[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
|
||||
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
|
||||
#ifdef OS390
|
||||
0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, /* 10 - 17 */
|
||||
#else
|
||||
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
|
||||
#endif
|
||||
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
|
||||
#ifdef OS390
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, /* 20 - 27 */
|
||||
#else
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
|
||||
#endif
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
|
||||
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
|
||||
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
|
||||
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
|
||||
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
|
||||
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
|
||||
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, /* 58 - 5F */
|
||||
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
|
||||
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
|
||||
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
|
||||
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
|
||||
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
|
||||
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
|
||||
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
|
||||
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
|
||||
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
|
||||
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE, /* A8 - AF */
|
||||
0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
|
||||
0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7, /* B8 - BF */
|
||||
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
|
||||
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
|
||||
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
|
||||
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
|
||||
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
|
||||
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
|
||||
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
|
||||
};
|
||||
#endif /* ZIP || CRYPT */
|
||||
|
||||
#else /* MTS */
|
||||
|
||||
/*
|
||||
* This is the MTS ASCII->EBCDIC translation table. It provides a 1-1
|
||||
* translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC.
|
||||
*/
|
||||
|
||||
ZCONST uch ebcdic[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
|
||||
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
|
||||
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
|
||||
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
|
||||
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
|
||||
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
|
||||
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
|
||||
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
|
||||
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
|
||||
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
|
||||
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
|
||||
0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, /* 58 - 5F */
|
||||
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
|
||||
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
|
||||
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
|
||||
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
|
||||
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
|
||||
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
|
||||
0xBD, 0xB4, 0x9A, 0x8A, 0x5F, 0xCA, 0xAF, 0xBC, /* A8 - AF */
|
||||
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
|
||||
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
|
||||
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
|
||||
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
|
||||
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
|
||||
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xAD, 0xAE, 0x59, /* D8 - DF */
|
||||
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
|
||||
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
|
||||
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
|
||||
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
|
||||
};
|
||||
|
||||
#if (defined(ZIP) || CRYPT)
|
||||
ZCONST uch ascii[] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
|
||||
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
|
||||
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
|
||||
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
|
||||
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
|
||||
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
|
||||
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
|
||||
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
|
||||
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
|
||||
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAC, /* 58 - 5F */
|
||||
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
|
||||
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
|
||||
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
|
||||
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
|
||||
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
|
||||
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
|
||||
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
|
||||
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
|
||||
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
|
||||
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0xDD, 0xDE, 0xAE, /* A8 - AF */
|
||||
0x5E, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
|
||||
0xBD, 0xBE, 0x5B, 0x5D, 0xAF, 0xA8, 0xB4, 0xD7, /* B8 - BF */
|
||||
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
|
||||
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
|
||||
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
|
||||
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
|
||||
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
|
||||
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
|
||||
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
|
||||
};
|
||||
#endif /* ZIP || CRYPT */
|
||||
|
||||
#endif /* ?MTS */
|
||||
#endif /* EBCDIC */
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
|
||||
The following conversion tables translate between IBM PC CP 850
|
||||
(OEM codepage) and the "Western Europe & America" Windows codepage 1252.
|
||||
The Windows codepage 1252 contains the ISO 8859-1 "Latin 1" codepage,
|
||||
with some additional printable characters in the range (0x80 - 0x9F),
|
||||
that is reserved to control codes in the ISO 8859-1 character table.
|
||||
|
||||
The ISO <--> OEM conversion tables were constructed with the help
|
||||
of the WIN32 (Win16?) API's OemToAnsi() and AnsiToOem() conversion
|
||||
functions and have been checked against the CP850 and LATIN1 tables
|
||||
provided in the MS-Kermit 3.14 distribution.
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef IZ_ISO2OEM_ARRAY
|
||||
#ifdef OEM_RUSS
|
||||
ZCONST uch Far iso2oem[] = {
|
||||
0x3F, 0x3F, 0x27, 0x9F, 0x22, 0x2E, 0xC5, 0xCE, /* 80 - 87 */
|
||||
0xFD, 0x25, 0x53, 0x3C, 0x4F, 0x3F, 0x3F, 0x3F, /* 88 - 8F */
|
||||
0x3F, 0x27, 0x27, 0x22, 0x22, 0xF9, 0x2D, 0x2D, /* 90 - 97 */
|
||||
0x7E, 0x54, 0x73, 0x3E, 0x6F, 0x3F, 0x3F, 0x59, /* 98 - 9F */
|
||||
0xFF, 0xF6, 0xF7, 0x9C, 0xCF, 0xBE, 0xFE, 0xF5, /* A0 - A7 */
|
||||
0xF0, 0xB8, 0xF2, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, /* A8 - AF */
|
||||
0xF8, 0xFB, 0xF4, 0xF5, 0xEF, 0xE6, 0xF4, 0xFA, /* B0 - B7 */
|
||||
0xF1, 0xFC, 0xF3, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8, /* B8 - BF */
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x86, 0x86, 0x87, /* C0 - C7 */
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, /* C8 - CF */
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* D0 - D7 */
|
||||
0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, /* D8 - DF */
|
||||
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, /* E0 - E7 */
|
||||
0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, /* E8 - EF */
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, /* F0 - F7 */
|
||||
0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF /* F8 - FF */
|
||||
};
|
||||
#else /* OEM_RUS */
|
||||
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 /* OEM_RUS */
|
||||
#endif /* IZ_ISO2OEM_ARRAY */
|
||||
|
||||
#ifdef IZ_OEM2ISO_ARRAY
|
||||
#ifdef OEM_RUSS
|
||||
ZCONST uch Far oem2iso[] = {
|
||||
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 80 - 87 */
|
||||
0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, /* 88 - 8F */
|
||||
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, /* 90 - 97 */
|
||||
0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, /* 98 - 9F */
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, /* A0 - A7 */
|
||||
0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, /* 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 */
|
||||
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* E0 - E7 */
|
||||
0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, /* E8 - EF */
|
||||
0xA8, 0xB8, 0xAA, 0xBA, 0xB2, 0xB3, 0xA1, 0xA2, /* F0 - F7 */
|
||||
0xB0, 0x95, 0xB7, 0xB1, 0xB9, 0x88, 0xA6, 0xA0 /* F8 - FF */
|
||||
};
|
||||
#else /* OEM_RUS */
|
||||
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 /* OEM_RUS */
|
||||
#endif /* IZ_OEM2ISO_ARRAY */
|
||||
|
||||
#if defined(THEOS) || defined(THEOS_SUPPORT)
|
||||
# include "theos/charconv.h"
|
||||
#endif
|
||||
|
||||
#endif /* __ebcdic_h */
|
15
third_party/infozip/zip/file_id.diz
vendored
Normal file
15
third_party/infozip/zip/file_id.diz
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
Info-ZIP's Zip 3.0: generic C sources.
|
||||
Complete C source code for Info-ZIP's
|
||||
PKZIP-compatible .zip archiver, for
|
||||
all supported compilers and platforms
|
||||
(Unix, OS/2, MS-DOS, NT, VMS, Amiga,
|
||||
Atari, Mac, Acorn, VM/CMS, etc.), plus
|
||||
lots of pretty decent documentation.
|
||||
Includes Info-ZIP's ZCrypt 2.9 for
|
||||
PKWARE-compatible standard encryption
|
||||
and decryption support for Info-ZIP's
|
||||
Zip 2.32, Zip 3.0, UnZip 5.52,
|
||||
UnZip 6.0, and WiZ 5.02 (and later).
|
||||
This is FREE (but copyrighted) software.
|
||||
See LICENSE for details on distribution
|
||||
and reuse.
|
4903
third_party/infozip/zip/fileio.c
vendored
Normal file
4903
third_party/infozip/zip/fileio.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
253
third_party/infozip/zip/globals.c
vendored
Normal file
253
third_party/infozip/zip/globals.c
vendored
Normal file
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
globals.c - Zip 3
|
||||
|
||||
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2007-Mar-4 or later
|
||||
(the contents of which are also included in zip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*
|
||||
* globals.c by Mark Adler
|
||||
*/
|
||||
#define __GLOBALS_C
|
||||
|
||||
#define GLOBALS /* include definition of errors[] in zip.h */
|
||||
#ifndef UTIL
|
||||
#define UTIL /* do not declare the read_buf variable */
|
||||
#endif
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
|
||||
/* Handy place to build error messages */
|
||||
char errbuf[FNMAX+4081];
|
||||
|
||||
/* Argument processing globals */
|
||||
int recurse = 0; /* 1=recurse into directories encountered */
|
||||
int dispose = 0; /* 1=remove files after put in zip file */
|
||||
int pathput = 1; /* 1=store path with name */
|
||||
#ifdef RISCOS
|
||||
int scanimage = 1; /* 1=scan through image files */
|
||||
#endif
|
||||
int method = BEST; /* one of BEST, DEFLATE (only), or STORE (only) */
|
||||
int dosify = 0; /* 1=make new entries look like MSDOS */
|
||||
int verbose = 0; /* 1=report oddities in zip file structure */
|
||||
int fix = 0; /* 1=fix the zip file, 2=FF, 3=ZipNote */
|
||||
int filesync = 0; /* 1=file sync, delete entries not on file system */
|
||||
int adjust = 0; /* 1=adjust offsets for sfx'd file (keep preamble) */
|
||||
int level = 6; /* 0=fastest compression, 9=best compression */
|
||||
int translate_eol = 0; /* Translate end-of-line LF -> CR LF */
|
||||
#ifdef VMS
|
||||
int vmsver = 0; /* 1=append VMS version number to file names */
|
||||
int vms_native = 0; /* 1=store in VMS format */
|
||||
int vms_case_2 = 0; /* ODS2 file name case in VMS. -1: down. */
|
||||
int vms_case_5 = 0; /* ODS5 file name case in VMS. +1: preserve. */
|
||||
#endif /* VMS */
|
||||
#if defined(OS2) || defined(WIN32)
|
||||
int use_longname_ea = 0; /* 1=use the .LONGNAME EA as the file's name */
|
||||
#endif
|
||||
/* 9/26/04 */
|
||||
int no_wild = 0; /* 1 = wildcards are disabled */
|
||||
int allow_regex = 0; /* 1 = allow [list] matching */
|
||||
#ifdef WILD_STOP_AT_DIR
|
||||
int wild_stop_at_dir = 1; /* default wildcards do not include / in matches */
|
||||
#else
|
||||
int wild_stop_at_dir = 0; /* default wildcards do include / in matches */
|
||||
#endif
|
||||
|
||||
#ifdef UNICODE_SUPPORT
|
||||
int using_utf8 = 0; /* 1 if current character set UTF-8 */
|
||||
# ifdef WIN32
|
||||
int no_win32_wide = -1; /* 1 = no wide functions, like GetFileAttributesW() */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
ulg skip_this_disk = 0;
|
||||
int des_good = 0; /* Good data descriptor found */
|
||||
ulg des_crc = 0; /* Data descriptor CRC */
|
||||
uzoff_t des_csize = 0; /* Data descriptor csize */
|
||||
uzoff_t des_usize = 0; /* Data descriptor usize */
|
||||
|
||||
/* dots 10/20/04 */
|
||||
zoff_t dot_size = 0; /* bytes processed in deflate per dot, 0 = no dots */
|
||||
zoff_t dot_count = 0; /* buffers seen, recyles at dot_size */
|
||||
/* status 10/30/04 */
|
||||
int display_counts = 0; /* display running file count */
|
||||
int display_bytes = 0; /* display running bytes remaining */
|
||||
int display_globaldots = 0; /* display dots for archive instead of each file */
|
||||
int display_volume = 0; /* display current input and output volume (disk) numbers */
|
||||
int display_usize = 0; /* display uncompressed bytes */
|
||||
ulg files_so_far = 0; /* files processed so far */
|
||||
ulg bad_files_so_far = 0; /* bad files skipped so far */
|
||||
ulg files_total = 0; /* files total to process */
|
||||
uzoff_t bytes_so_far = 0; /* bytes processed so far (from initial scan) */
|
||||
uzoff_t good_bytes_so_far = 0;/* good bytes read so far */
|
||||
uzoff_t bad_bytes_so_far = 0; /* bad bytes skipped so far */
|
||||
uzoff_t bytes_total = 0; /* total bytes to process (from initial scan) */
|
||||
|
||||
/* logfile 6/5/05 */
|
||||
int logall = 0; /* 0 = warnings/errors, 1 = all */
|
||||
FILE *logfile = NULL; /* pointer to open logfile or NULL */
|
||||
int logfile_append = 0; /* append to existing logfile */
|
||||
char *logfile_path = NULL; /* pointer to path of logfile */
|
||||
|
||||
int hidden_files = 0; /* process hidden and system files */
|
||||
int volume_label = 0; /* add volume label */
|
||||
int dirnames = 1; /* include directory entries by default */
|
||||
int filter_match_case = 1; /* 1=match case when filter() */
|
||||
int diff_mode = 0; /* 1=require --out and only store changed and add */
|
||||
#if defined(WIN32)
|
||||
int only_archive_set = 0; /* include only files with DOS archive bit set */
|
||||
int clear_archive_bits = 0; /* clear DOS archive bit of included files */
|
||||
#endif
|
||||
int linkput = 0; /* 1=store symbolic links as such */
|
||||
int noisy = 1; /* 0=quiet operation */
|
||||
int extra_fields = 1; /* 0=create minimum, 1=don't copy old, 2=keep old */
|
||||
int use_descriptors = 0; /* 1=use data descriptors 12/29/04 */
|
||||
int zip_to_stdout = 0; /* output zipfile to stdout 12/30/04 */
|
||||
int allow_empty_archive = 0; /* if no files, create empty archive anyway 12/28/05 */
|
||||
int copy_only = 0; /* 1=copying archive entries only */
|
||||
int allow_fifo = 0; /* 1=allow reading Unix FIFOs, waiting if pipe open */
|
||||
int show_files = 0; /* show files to operate on and exit (=2 log only) */
|
||||
|
||||
int output_seekable = 1; /* 1 = output seekable 3/13/05 EG */
|
||||
|
||||
#ifdef ZIP64_SUPPORT /* zip64 support 10/4/03 */
|
||||
int force_zip64 = -1; /* if 1 force entries to be zip64, 0 force not zip64 */
|
||||
/* mainly for streaming from stdin */
|
||||
int zip64_entry = 0; /* current entry needs Zip64 */
|
||||
int zip64_archive = 0; /* if 1 then at least 1 entry needs zip64 */
|
||||
#endif
|
||||
|
||||
#ifdef NTSD_EAS
|
||||
int use_privileges = 0; /* 1=use security privilege overrides */
|
||||
#endif
|
||||
#ifndef RISCOS
|
||||
#ifndef QDOS
|
||||
#ifndef TANDEM
|
||||
char *special = ".Z:.zip:.zoo:.arc:.lzh:.arj"; /* List of special suffixes */
|
||||
#else /* TANDEM */
|
||||
char *special = " Z: zip: zoo: arc: lzh: arj"; /* List of special suffixes */
|
||||
#endif
|
||||
#else /* QDOS */
|
||||
char *special = "_Z:_zip:_zoo:_arc:_lzh:_arj"; /* List of special suffixes */
|
||||
#endif
|
||||
#else /* RISCOS */
|
||||
char *special = "DDC:D96:68E";
|
||||
#endif /* ?RISCOS */
|
||||
char *key = NULL; /* Scramble password if scrambling */
|
||||
char *tempath = NULL; /* Path for temporary files */
|
||||
FILE *mesg; /* stdout by default, stderr for piping */
|
||||
|
||||
#ifdef UNICODE_SUPPORT
|
||||
int utf8_force = 0; /* 1=force storing UTF-8 as standard per AppNote bit 11 */
|
||||
#endif
|
||||
int unicode_escape_all = 0; /* 1=escape all non-ASCII characters in paths */
|
||||
int unicode_mismatch = 1; /* unicode mismatch is 0=error, 1=warn, 2=ignore, 3=no */
|
||||
|
||||
time_t scan_delay = 5; /* seconds before display Scanning files message */
|
||||
time_t scan_dot_time = 2; /* time in seconds between Scanning files dots */
|
||||
time_t scan_start = 0; /* start of scan */
|
||||
time_t scan_last = 0; /* time of last message */
|
||||
int scan_started = 0; /* scan has started */
|
||||
uzoff_t scan_count = 0; /* Used for Scanning files ... message */
|
||||
|
||||
ulg before = 0; /* 0=ignore, else exclude files before this time */
|
||||
ulg after = 0; /* 0=ignore, else exclude files newer than this time */
|
||||
|
||||
/* Zip file globals */
|
||||
char *zipfile; /* New or existing zip archive (zip file) */
|
||||
|
||||
/* zip64 support 08/31/2003 R.Nausedat */
|
||||
/* all are across splits - subtract bytes_prev_splits to get offsets for current disk */
|
||||
uzoff_t zipbeg; /* Starting offset of zip structures */
|
||||
uzoff_t cenbeg; /* Starting offset of central dir */
|
||||
uzoff_t tempzn; /* Count of bytes written to output zip files */
|
||||
|
||||
/* 10/28/05 */
|
||||
char *tempzip = NULL; /* name of temp file */
|
||||
FILE *y = NULL; /* output file now global so can change in splits */
|
||||
FILE *in_file = NULL; /* current input file for splits */
|
||||
char *in_path = NULL; /* base name of input archive file */
|
||||
char *in_split_path = NULL; /* in split path */
|
||||
char *out_path = NULL; /* base name of output file, usually same as zipfile */
|
||||
int zip_attributes = 0;
|
||||
|
||||
/* in split globals */
|
||||
|
||||
ulg total_disks = 0; /* total disks in archive */
|
||||
ulg current_in_disk = 0; /* current read split disk */
|
||||
uzoff_t current_in_offset = 0; /* current offset in current read disk */
|
||||
ulg skip_current_disk = 0; /* if != 0 and fix then skip entries on this disk */
|
||||
|
||||
|
||||
/* out split globals */
|
||||
|
||||
ulg current_local_disk = 0; /* disk with current local header */
|
||||
|
||||
ulg current_disk = 0; /* current disk number */
|
||||
ulg cd_start_disk = (ulg)-1; /* central directory start disk */
|
||||
uzoff_t cd_start_offset = 0; /* offset of start of cd on cd start disk */
|
||||
uzoff_t cd_entries_this_disk = 0; /* cd entries this disk */
|
||||
uzoff_t total_cd_entries = 0; /* total cd entries in new/updated archive */
|
||||
ulg zip64_eocd_disk = 0; /* disk with Zip64 End Of Central Directory Record */
|
||||
uzoff_t zip64_eocd_offset = 0; /* offset for Zip64 EOCD Record */
|
||||
|
||||
/* for split method 1 (keep split with local header open and update) */
|
||||
char *current_local_tempname = NULL; /* name of temp file */
|
||||
FILE *current_local_file = NULL; /* file pointer for current local header */
|
||||
uzoff_t current_local_offset = 0; /* offset to start of current local header */
|
||||
|
||||
/* global */
|
||||
uzoff_t bytes_this_split = 0; /* bytes written to the current split */
|
||||
int read_split_archive = 0; /* 1=scanzipf_reg detected spanning signature */
|
||||
int split_method = 0; /* 0=no splits, 1=seekable, 2=data desc, -1=no */
|
||||
uzoff_t split_size = 0; /* how big each split should be */
|
||||
int split_bell = 0; /* when pause for next split ring bell */
|
||||
uzoff_t bytes_prev_splits = 0; /* total bytes written to all splits before this */
|
||||
uzoff_t bytes_this_entry = 0; /* bytes written for this entry across all splits */
|
||||
int noisy_splits = 0; /* note when splits are being created */
|
||||
int mesg_line_started = 0; /* 1=started writing a line to mesg */
|
||||
int logfile_line_started = 0; /* 1=started writing a line to logfile */
|
||||
|
||||
#ifdef WIN32
|
||||
int nonlocal_name = 0; /* Name has non-local characters */
|
||||
int nonlocal_path = 0; /* Path has non-local characters */
|
||||
#endif
|
||||
#ifdef UNICODE_SUPPORT
|
||||
int use_wide_to_mb_default = 0;
|
||||
#endif
|
||||
|
||||
struct zlist far *zfiles = NULL; /* Pointer to list of files in zip file */
|
||||
/* The limit for number of files using the Zip64 format is 2^64 - 1 (8 bytes)
|
||||
but extent is used for many internal sorts and other tasks and is generally
|
||||
long on 32-bit systems. Because of that, but more because of various memory
|
||||
utilization issues limiting the practical number of central directory entries
|
||||
that can be sorted, the number of actual entries that can be stored probably
|
||||
can't exceed roughly 2^30 on 32-bit systems so extent is probably sufficient. */
|
||||
extent zcount; /* Number of files in zip file */
|
||||
int zipfile_exists = 0; /* 1 if zipfile exists */
|
||||
ush zcomlen; /* Length of zip file comment */
|
||||
char *zcomment = NULL; /* Zip file comment (not zero-terminated) */
|
||||
struct zlist far **zsort; /* List of files sorted by name */
|
||||
#ifdef UNICODE_SUPPORT
|
||||
struct zlist far **zusort; /* List of files sorted by zuname */
|
||||
#endif
|
||||
|
||||
/* Files to operate on that are not in zip file */
|
||||
struct flist far *found = NULL; /* List of names found */
|
||||
struct flist far * far *fnxt = &found;
|
||||
/* Where to put next name in found list */
|
||||
extent fcount; /* Count of files in list */
|
||||
|
||||
/* Patterns to be matched */
|
||||
struct plist *patterns = NULL; /* List of patterns to be matched */
|
||||
unsigned pcount = 0; /* number of patterns */
|
||||
unsigned icount = 0; /* number of include only patterns */
|
||||
unsigned Rcount = 0; /* number of -R include patterns */
|
||||
|
||||
#ifdef IZ_CHECK_TZ
|
||||
int zp_tz_is_valid; /* signals "timezone info is available" */
|
||||
#endif
|
95
third_party/infozip/zip/human68k/Makefile
vendored
Normal file
95
third_party/infozip/zip/human68k/Makefile
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
# Makefile for Zip, ZipCloak, ZipNote and ZipSplit for human68k
|
||||
# Written by NIIMI Satoshi <a01309@cfi.waseda.ac.jp>
|
||||
#
|
||||
# 1999/09/23: Modified by Shimazaki Ryo.
|
||||
|
||||
ifeq "$(TARGET)" "X68030"
|
||||
COPT = -m68020-40
|
||||
AOPT = -m68020 -sCPU020
|
||||
LDFLAGS = -L/usr/local/lib/lib060
|
||||
endif
|
||||
|
||||
VPATH = human68k
|
||||
|
||||
CC = gcc2
|
||||
CFLAGS = $(COPT) -I. -Wall -O2 -fomit-frame-pointer -fstrength-reduce \
|
||||
-DASM_CRC -D__DOS_INLINE__
|
||||
#LDFLAGS = -Wl,-x
|
||||
LIBS = -lhmem -lttyi -lsignal
|
||||
|
||||
AS = g2as
|
||||
ASFLAGS = $(AOPT) -1 -c4 -y -w2
|
||||
|
||||
# object file lists
|
||||
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
|
||||
crc32.o human68k.o crc_68.o
|
||||
OBJI = deflate.o trees.o
|
||||
OBJA =
|
||||
OBJU = zipfile_.o fileio_.o util_.o globals.o human68k_.o
|
||||
OBJN = zipnote.o $(OBJU)
|
||||
OBJC = zipcloak.o $(OBJU) crc32_.o crypt_.o ttyio.o
|
||||
OBJS = zipsplit.o $(OBJU)
|
||||
|
||||
ZIP_H = zip.h ziperr.h tailor.h human68k/osdep.h
|
||||
|
||||
all: zips
|
||||
|
||||
.SUFFIXES: _.o .o .c
|
||||
.c_.o:
|
||||
$(CC) $(CFLAGS) -DUTIL -c $< -o $@
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
ZIPS = zip.x zipnote.x zipsplit.x zipcloak.x
|
||||
|
||||
zips: $(ZIPS)
|
||||
|
||||
zip.x: $(OBJZ) $(OBJI) $(OBJA)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJZ) $(OBJI) $(OBJA) $(LIBS)
|
||||
zipnote.x: $(OBJN)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJN) $(LIBS)
|
||||
zipcloak.x: $(OBJC)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJC) $(LIBS)
|
||||
zipsplit.x: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
|
||||
human68k.o: human68k/human68k.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
human68k_.o: human68k/human68k.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $< -DUTIL
|
||||
|
||||
#match.o: human68k/match.s
|
||||
# $(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
deflate.o: human68k/deflate.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
crc_68.o: human68k/crc_68.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o $(ZIPS)
|
||||
|
||||
zip.bfd: $(ZIPS)
|
||||
rm -f $@
|
||||
for file in $(ZIPS); do \
|
||||
bdif -A -R uploaded/$$file $$file $@; \
|
||||
done
|
||||
|
||||
# rules for zip, zipnote, zipcloak, zipsplit.
|
||||
$(OBJZ): $(ZIP_H)
|
||||
$(OBJI): $(ZIP_H)
|
||||
$(OBJN): $(ZIP_H)
|
||||
$(OBJS): $(ZIP_H)
|
||||
$(OBJC): $(ZIP_H)
|
||||
zip.o crc32.o crypt.o fileio.o zipfile.o zipup.o: crc32.h
|
||||
zipcloak.o crc32_.o crypt_.o fileio_.o zipfile_.o: crc32.h
|
||||
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
|
||||
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
|
||||
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
|
||||
zipup.o: human68k/zipup.h
|
||||
|
||||
# EOF
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue