Flatten InfoZIP directory and fix build issues

This commit is contained in:
Justine Tunney 2022-04-20 21:59:25 -07:00
parent ae638c0850
commit 87396f43bc
66 changed files with 869 additions and 5763 deletions

View file

@ -150,7 +150,7 @@ include third_party/sqlite3/sqlite3.mk
include third_party/mbedtls/test/test.mk
include third_party/quickjs/quickjs.mk
include third_party/lz4cli/lz4cli.mk
include third_party/infozip/infozip.mk
include third_party/zip/zip.mk
include tool/build/lib/buildlib.mk
include third_party/chibicc/chibicc.mk
include third_party/chibicc/test/test.mk

Binary file not shown.

View file

@ -40,7 +40,8 @@ CONFIG_CCFLAGS += \
$(BACKTRACES) \
$(FTRACE) \
-DSYSDEBUG \
-O3
-O3 \
-fmerge-all-constants
TARGET_ARCH ?= \
-march=native
endif
@ -60,7 +61,7 @@ CONFIG_CPPFLAGS += \
-Wa,-msse2avx \
-DSUPPORT_VECTOR=1
CONFIG_CCFLAGS += \
-O3
-O3 -fmerge-all-constants
DEFAULT_COPTS += \
-mred-zone
TARGET_ARCH ?= \

View file

@ -135,12 +135,12 @@ o/$(MODE)/examples/nesemu1.com.dbg: \
o/$(MODE)/examples/nesemu1.com: \
o/$(MODE)/examples/nesemu1.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/examples/.nesemu1/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/examples/.nesemu1/.symtab
o/$(MODE)/examples/hello.com.dbg: \

View file

@ -23,6 +23,7 @@
#include "libc/calls/strace.internal.h"
#include "libc/calls/struct/iovec.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sysv/errfuns.h"
@ -44,7 +45,9 @@
ssize_t pread(int fd, void *buf, size_t size, int64_t offset) {
ssize_t rc;
if (fd == -1 || offset < 0) return einval();
if (__isfdkind(fd, kFdZip)) {
if (IsAsan() && !__asan_is_valid(buf, size)) {
rc = efault();
} else if (__isfdkind(fd, kFdZip)) {
rc =
weaken(__zipos_read)((struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle,
(struct iovec[]){{buf, size}}, 1, offset);

View file

@ -25,19 +25,13 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/macros.internal.h"
#include "libc/sysv/consts/iov.h"
#include "libc/sysv/errfuns.h"
#include "libc/zipos/zipos.internal.h"
/**
* Reads with maximum generality.
*
* @return number of bytes actually read, or -1 w/ errno
* @asyncsignalsafe
* @vforksafe
*/
ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
static ssize_t Preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
static bool once, demodernize;
int i, err;
ssize_t rc;
@ -106,3 +100,27 @@ ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
return toto;
}
/**
* Reads with maximum generality.
*
* @return number of bytes actually read, or -1 w/ errno
* @asyncsignalsafe
* @vforksafe
*/
ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
ssize_t rc;
rc = Preadv(fd, iov, iovlen, off);
#if defined(SYSDEBUG) && _DATATRACE
if (__strace > 0) {
if (rc == -1 && errno == EFAULT) {
STRACE("preadv(%d, %p, %d, %'ld) → %'zd% m", fd, iov, iovlen, off, rc);
} else {
kprintf(STRACE_PROLOGUE "preadv(%d, [", fd);
__strace_iov(iov, iovlen, rc != -1 ? rc : 0);
kprintf("], %d, %'ld) → %'ld% m%n", iovlen, off, rc);
}
}
#endif
return rc;
}

View file

@ -22,6 +22,7 @@
#include "libc/calls/strace.internal.h"
#include "libc/calls/struct/iovec.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/macros.internal.h"
#include "libc/sysv/errfuns.h"
@ -43,7 +44,9 @@ ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) {
size_t wrote;
if (fd == -1 || offset < 0) return einval();
size = MIN(size, 0x7ffff000);
if (!IsWindows()) {
if (IsAsan() && !__asan_is_valid(buf, size)) {
rc = efault();
} else if (!IsWindows()) {
rc = sys_pwrite(fd, buf, size, offset, offset);
} else if (__isfdkind(fd, kFdFile)) {
rc = sys_write_nt(fd, (struct iovec[]){{buf, size}}, 1, offset);

View file

@ -24,24 +24,14 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/macros.internal.h"
#include "libc/sysv/consts/iov.h"
#include "libc/sysv/errfuns.h"
#include "libc/zipos/zipos.internal.h"
/**
* Writes data from multiple buffers to offset.
*
* Please note that it's not an error for a short write to happen. This
* can happen in the kernel if EINTR happens after some of the write has
* been committed. It can also happen if we need to polyfill this system
* call using pwrite().
*
* @return number of bytes actually sent, or -1 w/ errno
* @asyncsignalsafe
* @vforksafe
*/
ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
static ssize_t Pwritev(int fd, const struct iovec *iov, int iovlen,
int64_t off) {
static bool once, demodernize;
int i, err;
ssize_t rc;
@ -110,3 +100,32 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
return toto;
}
/**
* Writes data from multiple buffers to offset.
*
* Please note that it's not an error for a short write to happen. This
* can happen in the kernel if EINTR happens after some of the write has
* been committed. It can also happen if we need to polyfill this system
* call using pwrite().
*
* @return number of bytes actually sent, or -1 w/ errno
* @asyncsignalsafe
* @vforksafe
*/
ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
ssize_t rc;
rc = Pwritev(fd, iov, iovlen, off);
#if defined(SYSDEBUG) && _DATATRACE
if (__strace > 0) {
if (rc == -1 && errno == EFAULT) {
STRACE("pwritev(%d, %p, %d, %'ld) → %'zd% m", fd, iov, iovlen, off, rc);
} else {
kprintf(STRACE_PROLOGUE "readv(%d, ", fd);
__strace_iov(iov, iovlen, rc != -1 ? rc : 0);
kprintf(", %d, %'ld) → %'ld% m%n", iovlen, off, rc);
}
}
#endif
return rc;
}

View file

@ -118,7 +118,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) {
if (todo > len) {
todo = len;
}
memcpy(&b2b->block.bytes[b2b->block_used], data, todo);
if (todo) memcpy(&b2b->block.bytes[b2b->block_used], data, todo);
b2b->block_used += todo;
data += todo;
len -= todo;
@ -137,7 +137,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) {
data += BLAKE2B_CBLOCK;
len -= BLAKE2B_CBLOCK;
}
memcpy(b2b->block.bytes, data, len);
if (len) memcpy(b2b->block.bytes, data, len);
b2b->block_used = len;
return 0;
}

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/nexgen32e.h"
#include "libc/runtime/runtime.h"

View file

@ -8,8 +8,8 @@ o/$(MODE)/test/libc/release/cosmopolitan.zip: \
o/$(MODE)/ape/ape.o \
o/$(MODE)/ape/ape-no-modify-self.o \
o/$(MODE)/cosmopolitan.a \
o/$(MODE)/third_party/infozip/zip.com
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -qj $@ o/cosmopolitan.h o/$(MODE)/ape/ape.lds o/$(MODE)/libc/crt/crt.o o/$(MODE)/ape/ape.o o/$(MODE)/ape/ape-no-modify-self.o o/$(MODE)/cosmopolitan.a
o/$(MODE)/third_party/zip/zip.com
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -qj $@ o/cosmopolitan.h o/$(MODE)/ape/ape.lds o/$(MODE)/libc/crt/crt.o o/$(MODE)/ape/ape.o o/$(MODE)/ape/ape-no-modify-self.o o/$(MODE)/cosmopolitan.a
o/$(MODE)/test/libc/release/smoke.com: \
o/$(MODE)/test/libc/release/smoke.com.dbg

View file

@ -125,7 +125,7 @@ TEST(mmap, fileOffset) {
TEST(mmap, mapPrivate_writesDontChangeFile) {
int fd;
char *map, buf[5];
char *map, buf[6];
ASSERT_NE(-1, (fd = open("bar", O_CREAT | O_RDWR, 0644)));
EXPECT_NE(-1, ftruncate(fd, FRAMESIZE));
EXPECT_NE(-1, pwrite(fd, "hello", 5, 0));

View file

@ -41,5 +41,9 @@ TEST(strclen, testAegeanNumberSupplementaryPlane) {
}
TEST(strlen16, testCoolKidNulTerminator) {
EXPECT_EQ(2, strlen16((const char16_t *)"\x00\xd8\x00\xdc\x00"));
union {
uint8_t s8[6];
char16_t s16[3];
} u = {.s8 = {0x00, 0xd8, 0x00, 0xdc, 0x00, 0x00}};
EXPECT_EQ(2, strlen16(u.s16));
}

View file

@ -111,12 +111,12 @@ o/$(MODE)/third_party/chibicc/chibicc2.com.dbg: \
o/$(MODE)/third_party/chibicc/chibicc.com: \
o/$(MODE)/third_party/chibicc/chibicc.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/chibicc/.chibicc/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/chibicc/.chibicc/.symtab
o/$(MODE)/third_party/chibicc/as.com.dbg: \

View file

@ -1,148 +0,0 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += THIRD_PARTY_ZIP
THIRD_PARTY_ZIP_FILES := \
$(wildcard third_party/infozip/zip/*) \
$(wildcard third_party/infozip/zip/unix/*)
THIRD_PARTY_ZIP_SRCS = $(filter %.c,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_HDRS = $(filter %.h,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_INCS = $(filter %.inc,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_COMS = \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/infozip/zipsplit.com \
o/$(MODE)/third_party/infozip/zipnote.com \
o/$(MODE)/third_party/infozip/zipcloak.com
THIRD_PARTY_ZIP_BINS = \
$(THIRD_PARTY_ZIP_COMS) \
$(THIRD_PARTY_ZIP_COMS:%=%.dbg)
THIRD_PARTY_ZIP_OBJS = $(sort \
$(THIRD_PARTY_ZIP_COM_OBJS) \
$(THIRD_PARTY_ZIPCLOAK_OBJS) \
$(THIRD_PARTY_ZIPNOTE_OBJS) \
$(THIRD_PARTY_ZIPSPLIT_OBJS) \
)
THIRD_PARTY_ZIP_UTIL_OBJS1 = \
o/$(MODE)/third_party/infozip/zip/globals.o \
o/$(MODE)/third_party/infozip/zip/unix/unix_.o \
o/$(MODE)/third_party/infozip/zip/zipfile_.o \
o/$(MODE)/third_party/infozip/zip/fileio_.o \
o/$(MODE)/third_party/infozip/zip/util_.o
THIRD_PARTY_ZIP_UTIL_OBJS2 = \
o/$(MODE)/third_party/infozip/zip/crypt_.o \
o/$(MODE)/third_party/infozip/zip/crc32_.o
THIRD_PARTY_ZIP_UTIL_OBJS = \
$(THIRD_PARTY_ZIP_UTIL_OBJS1) \
$(THIRD_PARTY_ZIP_UTIL_OBJS2)
THIRD_PARTY_ZIP_COM_OBJS = \
o/$(MODE)/third_party/infozip/zip/zip.o \
o/$(MODE)/third_party/infozip/zip/zipfile.o \
o/$(MODE)/third_party/infozip/zip/zipup.o \
o/$(MODE)/third_party/infozip/zip/fileio.o \
o/$(MODE)/third_party/infozip/zip/util.o \
o/$(MODE)/third_party/infozip/zip/globals.o \
o/$(MODE)/third_party/infozip/zip/crypt.o \
o/$(MODE)/third_party/infozip/zip/ttyio.o \
o/$(MODE)/third_party/infozip/zip/unix/unix.o \
o/$(MODE)/third_party/infozip/zip/crc32.o \
o/$(MODE)/third_party/infozip/zip/zbz2err.o \
o/$(MODE)/third_party/infozip/zip/deflate.o \
o/$(MODE)/third_party/infozip/zip/trees.o
THIRD_PARTY_ZIPSPLIT_OBJS = \
o/$(MODE)/third_party/infozip/zip/zipsplit.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1)
THIRD_PARTY_ZIPNOTE_OBJS = \
o/$(MODE)/third_party/infozip/zip/zipnote.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1)
THIRD_PARTY_ZIPCLOAK_OBJS = \
o/$(MODE)/third_party/infozip/zip/zipcloak.o \
o/$(MODE)/third_party/infozip/zip/ttyio.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1) \
$(THIRD_PARTY_ZIP_UTIL_OBJS2)
THIRD_PARTY_ZIP_LARGE_OBJS = \
o/$(MODE)/third_party/infozip/zip/zip.o \
o/$(MODE)/third_party/infozip/zip/zipsplit.o \
o/$(MODE)/third_party/infozip/zip/fileio.o \
o/$(MODE)/third_party/infozip/zip/fileio_.o
o/$(MODE)/third_party/infozip/zip/%_.o: \
third_party/infozip/zip/%.c \
o/$(MODE)/third_party/infozip/zip/%.o
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) -DUTIL $<
$(THIRD_PARTY_ZIP_OBJS): \
OVERRIDE_CPPFLAGS += \
-DUNIX \
-DMMAP \
-DUNICODE_SUPPORT \
-DUSE_EF_UT_TIME \
-DLARGE_FILE_SUPPORT \
-DHAVE_DIRENT_H \
-DHAVE_TERMIOS_H \
-DNO_BZIP2_SUPPORT \
-DZIP64_SUPPORT
$(THIRD_PARTY_ZIP_LARGE_OBJS): \
OVERRIDE_CPPFLAGS += \
-DSTACK_FRAME_UNLIMITED
THIRD_PARTY_ZIP_DIRECTDEPS = \
LIBC_ERRNO \
LIBC_LIMITS \
LIBC_ALG \
LIBC_FMT \
LIBC_STR \
LIBC_MEM \
LIBC_LOG \
LIBC_CALLS \
LIBC_STDIO \
LIBC_TIME \
LIBC_UNICODE
THIRD_PARTY_ZIP_DEPS := \
$(call uniq,$(foreach x,$(THIRD_PARTY_ZIP_DIRECTDEPS),$($(x))))
o/$(MODE)/third_party/infozip/zip.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIP_COM_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/infozip/zipsplit.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPSPLIT_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/infozip/zipnote.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPNOTE_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/infozip/zipcloak.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPCLOAK_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
.PHONY: o/$(MODE)/third_party/infozip
o/$(MODE)/third_party/infozip: \
$(THIRD_PARTY_ZIP_BINS)

View file

@ -1,6 +0,0 @@
- 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.

File diff suppressed because it is too large Load diff

View file

@ -1,234 +0,0 @@
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.

View file

@ -1,119 +0,0 @@
_____________________________________________________________________________
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.)

View file

@ -1,142 +0,0 @@
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)

View file

@ -1,75 +0,0 @@
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, ...

View file

@ -1,333 +0,0 @@
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

View file

@ -1,261 +0,0 @@
__________________________________________________________________________
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.
__________________________________________________________________________

View file

@ -1,230 +0,0 @@
/* clang-format off */
/*
ttyio.h - Zip 3
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
*/
/*
ttyio.h
*/
#ifndef __ttyio_h /* don't include more than once */
#define __ttyio_h
#ifndef __crypt_h
# include "third_party/infozip/zip/crypt.h" /* ensure that encryption header file has been seen */
#endif
#if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
/*
* Non-echo keyboard/console input support is needed and enabled.
*/
#ifndef __G /* UnZip only, for now (DLL stuff) */
# define __G
# define __G__
# define __GDEF
# define __GPRO void
# define __GPRO__
#endif
#ifndef ZCONST /* UnZip only (until have configure script like Zip) */
# define ZCONST const
#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(DOS_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_OS2_W32
# define DOS_FLX_OS2_W32
# endif
#endif
#if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_H68_OS2_W32
# define DOS_FLX_H68_OS2_W32
# endif
#endif
#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX))
# ifndef ATH_BEO_UNX
# define ATH_BEO_UNX
# endif
#endif
#if (defined(VM_CMS) || defined(MVS))
# ifndef CMS_MVS
# define CMS_MVS
# endif
#endif
/* Function prototypes */
/* The following systems supply a `non-echo' character input function "getch()"
* (or an alias) and do not need the echoff() / echon() function pair.
*/
#ifdef AMIGA
# define echoff(f)
# define echon()
# define getch() Agetch()
# define HAVE_WORKING_GETCH
#endif /* AMIGA */
#ifdef ATARI
# define echoff(f)
# define echon()
# include <osbind.h>
# define getch() (Cnecin() & 0x000000ff)
# define HAVE_WORKING_GETCH
#endif
#ifdef MACOS
# define echoff(f)
# define echon()
# define getch() macgetch()
# define HAVE_WORKING_GETCH
#endif
#ifdef NLM
# define echoff(f)
# define echon()
# define HAVE_WORKING_GETCH
#endif
#ifdef QDOS
# define echoff(f)
# define echon()
# define HAVE_WORKING_GETCH
#endif
#ifdef RISCOS
# define echoff(f)
# define echon()
# define getch() SWI_OS_ReadC()
# define HAVE_WORKING_GETCH
#endif
#ifdef DOS_H68_OS2_W32
# define echoff(f)
# define echon()
# ifdef WIN32
# ifndef getch
# define getch() getch_win32()
# endif
# else /* !WIN32 */
# ifdef __EMX__
# ifndef getch
# define getch() _read_kbd(0, 1, 0)
# endif
# else /* !__EMX__ */
# ifdef __GO32__
# include <pc.h>
# define getch() getkey()
# else /* !__GO32__ */
# include <conio.h>
# endif /* ?__GO32__ */
# endif /* ?__EMX__ */
# endif /* ?WIN32 */
# define HAVE_WORKING_GETCH
#endif /* DOS_H68_OS2_W32 */
#ifdef FLEXOS
# define echoff(f)
# define echon()
# define getch() getchar() /* not correct, but may not be on a console */
# define HAVE_WORKING_GETCH
#endif
/* For VM/CMS and MVS, we do not (yet) have any support to switch terminal
* input echo on and off. The following "fake" definitions allow inclusion
* of crypt support and UnZip's "pause prompting" features, but without
* any echo suppression.
*/
#ifdef CMS_MVS
# define echoff(f)
# define echon()
#endif
#ifdef TANDEM
# define echoff(f)
# define echon()
# define getch() zgetch() /* defined in TANDEMC */
# define HAVE_WORKING_GETCH
#endif
/* The THEOS C runtime library supplies the function conmask() to toggle
* terminal input echo on (conmask("e")) and off (conmask("n")). But,
* since THEOS C RTL also contains a working non-echo getch() function,
* the echo toggles are not needed.
*/
#ifdef THEOS
# define echoff(f)
# define echon()
# define HAVE_WORKING_GETCH
#endif
/* VMS has a single echo() function in ttyio.c to toggle terminal
* input echo on and off.
*/
#ifdef VMS
# define echoff(f) echo(0)
# define echon() echo(1)
# define getch() tt_getch()
# define FGETCH(f) tt_getch()
int echo OF((int));
int tt_getch OF((void));
#endif
/* For all other systems, ttyio.c supplies the two functions Echoff() and
* Echon() for suppressing and (re)enabling console input echo.
*/
#ifndef echoff
# define echoff(f) Echoff(__G__ f)
# define echon() Echon(__G)
void Echoff OF((__GPRO__ int f));
void Echon OF((__GPRO));
#endif
/* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
#if (defined(UNZIP) && !defined(FUNZIP))
# ifdef HAVE_WORKING_GETCH
# define FGETCH(f) getch()
# endif
# ifndef FGETCH
/* default for all systems where no getch()-like function is available */
int zgetch OF((__GPRO__ int f));
# define FGETCH(f) zgetch(__G__ f)
# endif
#endif /* UNZIP && !FUNZIP */
#if (CRYPT && !defined(WINDLL))
char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
#endif
#else /* !(CRYPT || (UNZIP && !FUNZIP)) */
/*
* No need for non-echo keyboard/console input; provide dummy definitions.
*/
#define echoff(f)
#define echon()
#endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
#endif /* !__ttyio_h */

View file

@ -72,12 +72,12 @@ o/$(MODE)/third_party/lua/luac.com.dbg: \
o/$(MODE)/third_party/lua/lua.com: \
o/$(MODE)/third_party/lua/lua.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/lua/.lua/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/lua/.lua/.symtab
o/$(MODE)/third_party/lua/lauxlib.o: \

View file

@ -126,12 +126,12 @@ o/$(MODE)/third_party/make/hash.o: \
o/$(MODE)/third_party/make/make.com: \
o/$(MODE)/third_party/make/make.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/make/.make/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/make/.make/.symtab
$(THIRD_PARTY_MAKE_OBJS): \

View file

@ -4192,12 +4192,12 @@ o/$(MODE)/third_party/python/python.com.dbg: \
o/$(MODE)/third_party/python/python.com: \
o/$(MODE)/third_party/python/python.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/python/.python/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/python/.python/.symtab
################################################################################

View file

@ -149,12 +149,12 @@ o/$(MODE)/third_party/quickjs/qjs.com.dbg: \
o/$(MODE)/third_party/quickjs/qjs.com: \
o/$(MODE)/third_party/quickjs/qjs.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/quickjs/.qjs/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/quickjs/.qjs/.symtab
o/$(MODE)/third_party/quickjs/qjsc.com.dbg: \
@ -204,8 +204,8 @@ o/$(MODE)/third_party/quickjs/quickjs.o: \
OVERRIDE_CPPFLAGS += \
-DSTACK_FRAME_UNLIMITED
o/$(MODE)/third_party/quickjs/call.o: QUOTA = -M1024m -C16
o/$(MODE)/third_party/quickjs/quickjs.o: QUOTA = -M512m -C16
o/$(MODE)/third_party/quickjs/call.o: QUOTA = -M1024m -C32
o/$(MODE)/third_party/quickjs/quickjs.o: QUOTA = -M512m -C32
.PHONY: o/$(MODE)/third_party/quickjs
o/$(MODE)/third_party/quickjs: \

View file

@ -78,12 +78,12 @@ o/$(MODE)/third_party/sqlite3/sqlite3.com.dbg: \
o/$(MODE)/third_party/sqlite3/sqlite3.com: \
o/$(MODE)/third_party/sqlite3/sqlite3.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/third_party/sqlite3/.sqlite3/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/third_party/sqlite3/.sqlite3/.symtab
$(THIRD_PARTY_SQLITE3_A): \

View file

@ -10,7 +10,6 @@ o/$(MODE)/third_party: \
o/$(MODE)/third_party/dlmalloc \
o/$(MODE)/third_party/gdtoa \
o/$(MODE)/third_party/getopt \
o/$(MODE)/third_party/infozip \
o/$(MODE)/third_party/libcxx \
o/$(MODE)/third_party/linenoise \
o/$(MODE)/third_party/lua \
@ -26,4 +25,5 @@ o/$(MODE)/third_party: \
o/$(MODE)/third_party/sqlite3 \
o/$(MODE)/third_party/stb \
o/$(MODE)/third_party/xed \
o/$(MODE)/third_party/zip \
o/$(MODE)/third_party/zlib

View file

@ -1,32 +1,11 @@
/* clang-format off */
/*
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 "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
/* clang-format off */
#define MAXPATH 1024
#if defined(WINDLL) || defined(API)
/* 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.

View file

@ -23,7 +23,7 @@
#define __CRC32_C /* identifies this source module */
#include "libc/nexgen32e/crc32.h"
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
@ -31,7 +31,7 @@
# define ZCONST const
#endif
#include "third_party/infozip/zip/crc32.h"
#include "third_party/zip/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

View file

@ -1,6 +1,6 @@
#ifndef __crc32_h
#define __crc32_h
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
/* clang-format off */
#ifndef OF

View file

@ -31,9 +31,9 @@
*/
#define ZCRYPT_INTERNAL
#include "third_party/infozip/zip/zip.h"
#include "third_party/infozip/zip/crypt.h"
#include "third_party/infozip/zip/ttyio.h"
#include "third_party/zip/zip.h"
#include "third_party/zip/crypt.h"
#include "third_party/zip/ttyio.h"
#include "libc/rand/rand.h"
#if CRYPT
@ -76,7 +76,7 @@
as a fallback to allow successful compilation in "beta state"
environments.
*/
# include "libc/time/time.h" /* time() function supplies first part of crypt seed */
#include "libc/time/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 */
@ -108,7 +108,7 @@
# endif
#endif
#include "third_party/infozip/zip/crc32.h"
#include "third_party/zip/crc32.h"
#ifdef IZ_CRC_BE_OPTIMIZ
local z_uint4 near crycrctab[256];

View file

@ -1,30 +1,6 @@
/* clang-format off */
/*
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 */
#ifndef __crypt_h /* don't include more than once */
#define __crypt_h
/* clang-format off */
#ifdef CRYPT
# undef CRYPT

View file

@ -70,7 +70,7 @@
#define __DEFLATE_C
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#ifndef USE_ZLIB

View file

@ -14,18 +14,9 @@
*/
#define __FILEIO_C
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#include "libc/calls/struct/stat.macros.h"
#include "third_party/infozip/zip/crc32.h"
#ifdef MACOS
# include "helpers.h"
#endif
#ifdef VMS
# include "vms/vms.h"
#endif /* def VMS */
#include "third_party/zip/crc32.h"
#include "libc/fmt/fmt.h"
#include "libc/alg/alg.h"
#include "libc/stdio/temp.h"

View file

@ -19,7 +19,7 @@
#define UTIL /* do not declare the read_buf variable */
#endif
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
/* Handy place to build error messages */

View file

@ -10,12 +10,6 @@
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#ifdef NO_LARGE_FILE_SUPPORT
# ifdef LARGE_FILE_SUPPORT
# undef LARGE_FILE_SUPPORT
# endif
#endif
#ifdef LARGE_FILE_SUPPORT
/* 64-bit Large File Support */

View file

@ -37,7 +37,7 @@
#endif
#include "libc/str/str.h"
#include "third_party/infozip/zip/unix/osdep.h"
#include "third_party/zip/osdep.h"
/* generic LARGE_FILE_SUPPORT defines
@ -149,7 +149,7 @@
#endif /* !NO_STDDEF_H */
#ifndef NO_STDLIB_H
# include "libc/mem/mem.h"
#include "libc/mem/mem.h"
#endif /* !NO_STDLIB_H */
#ifndef NO_UNISTD_H
@ -165,11 +165,7 @@
#include "libc/sysv/consts/f.h"
#endif /* !NO_FNCTL_H */
#ifndef NO_STRING_H
# include "libc/str/str.h"
#else
# include "libc/str/str.h"
#endif /* NO_STRING_H */
#include "libc/str/str.h"
#ifdef NO_VOID
# define void int
@ -262,9 +258,9 @@ IZ_IMP char *mktemp();
*/
#ifdef UNICODE_SUPPORT
# if defined( UNIX) || defined( VMS)
# include "libc/unicode/locale.h"
#include "libc/unicode/locale.h"
# endif /* defined( UNIX) || defined( VMS) */
# include "libc/str/str.h"
#include "libc/str/str.h"
#endif /* def UNICODE_SUPPORT */
#ifdef _MBCS

View file

@ -38,8 +38,8 @@
#define __timezone_c
#include "third_party/infozip/zip/zip.h"
#include "third_party/infozip/zip/timezone.h"
#include "third_party/zip/zip.h"
#include "third_party/zip/timezone.h"
#include "libc/str/str.h"
#include "libc/errno.h"

View file

@ -122,7 +122,7 @@
defines off_t and then while other files are using an 8-byte off_t this
file gets a 4-byte off_t. Once zip.h sets the large file defines can
then include ctype.h and get 8-byte off_t. 8/14/04 EG */
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#include "libc/str/str.h"
#ifndef USE_ZLIB

View file

@ -29,8 +29,8 @@
#define __TTYIO_C /* identifies this source module */
#include "third_party/infozip/zip/zip.h"
#include "third_party/infozip/zip/crypt.h"
#include "third_party/zip/zip.h"
#include "third_party/zip/crypt.h"
#if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
/* Non-echo console/keyboard input is needed for (en/de)cryption's password
@ -38,7 +38,7 @@
* (The corresponding #endif is found at the end of this module.)
*/
#include "third_party/infozip/zip/ttyio.h"
#include "third_party/zip/ttyio.h"
#ifndef PUTC
# define PUTC putc
@ -108,12 +108,6 @@
# endif
#endif
#if (defined(UNZIP) && !defined(FUNZIP) && defined(UNIX) && defined(MORE))
# include <sys/ioctl.h>
# define GOT_IOCTL_H
/* int ioctl OF((int, int, zvoid *)); GRR: may need for some systems */
#endif
#ifndef HAVE_WORKING_GETCH
/* include system support for switching of console echo */
# ifdef VMS

115
third_party/zip/ttyio.h vendored Normal file
View file

@ -0,0 +1,115 @@
/* clang-format off */
/*
ttyio.h - Zip 3
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
*/
/*
ttyio.h
*/
#ifndef __ttyio_h /* don't include more than once */
#define __ttyio_h
#ifndef __crypt_h
#include "third_party/zip/crypt.h" /* ensure that encryption header file has been seen */
#endif
#if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
/*
* Non-echo keyboard/console input support is needed and enabled.
*/
#ifndef __G /* UnZip only, for now (DLL stuff) */
# define __G
# define __G__
# define __GDEF
# define __GPRO void
# define __GPRO__
#endif
#ifndef ZCONST /* UnZip only (until have configure script like Zip) */
# define ZCONST const
#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(DOS_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_OS2_W32
# define DOS_FLX_OS2_W32
# endif
#endif
#if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_H68_OS2_W32
# define DOS_FLX_H68_OS2_W32
# endif
#endif
#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX))
# ifndef ATH_BEO_UNX
# define ATH_BEO_UNX
# endif
#endif
#if (defined(VM_CMS) || defined(MVS))
# ifndef CMS_MVS
# define CMS_MVS
# endif
#endif
/* Function prototypes */
/* For all other systems, ttyio.c supplies the two functions Echoff() and
* Echon() for suppressing and (re)enabling console input echo.
*/
#ifndef echoff
# define echoff(f) Echoff(__G__ f)
# define echon() Echon(__G)
void Echoff OF((__GPRO__ int f));
void Echon OF((__GPRO));
#endif
/* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
#if (defined(UNZIP) && !defined(FUNZIP))
# ifdef HAVE_WORKING_GETCH
# define FGETCH(f) getch()
# endif
# ifndef FGETCH
/* default for all systems where no getch()-like function is available */
int zgetch OF((__GPRO__ int f));
# define FGETCH(f) zgetch(__G__ f)
# endif
#endif /* UNZIP && !FUNZIP */
#if (CRYPT && !defined(WINDLL))
char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
#endif
#else /* !(CRYPT || (UNZIP && !FUNZIP)) */
/*
* No need for non-echo keyboard/console input; provide dummy definitions.
*/
#define echoff(f)
#define echon()
#endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
#endif /* !__ttyio_h */

View file

@ -10,7 +10,7 @@
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#include "libc/calls/struct/dirent.h"
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#ifndef UTIL /* the companion #endif is a bit of ways down ... */

View file

@ -14,22 +14,11 @@
*/
#define __UTIL_C
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#include "libc/str/str.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/conv.h"
#ifdef MSDOS16
# include <dos.h>
#endif
#ifdef NO_MKTIME
# ifndef IZ_MKTIME_ONLY
# define IZ_MKTIME_ONLY /* only mktime() related code is pulled in */
# endif
# include "timezone.c"
#endif
uch upper[256], lower[256];
/* Country-dependent case map table */

View file

@ -30,19 +30,9 @@
#define __ZBZ2ERR_C /* identifies this source module */
#include "third_party/infozip/zip/zip.h"
#ifdef BZIP2_SUPPORT
# ifdef BZIP2_USEBZIP2DIR
# include "bzip2/bzlib.h"
# else
/* If IZ_BZIP2 is defined as the location of the bzip2 files then
assume the location has been added to include path. For Unix
this is done by the configure script. */
/* Also do not need path for bzip2 include if OS includes support
for bzip2 library. */
# include "bzlib.h"
# endif
#include "libc/fmt/fmt.h"
#include "third_party/zip/zip.h"
#include "third_party/bzip2/bzlib.h"
/**********************************/
/* Function bz_internal_error() */
@ -58,5 +48,3 @@ void bz_internal_error(errcode)
sprintf(errbuf, "fatal error (code %d) in bzip2 library", errcode);
ziperr(ZE_LOGIC, errbuf);
} /* end function bz_internal_error() */
#endif /* def BZIP2_SUPPORT */

View file

@ -14,70 +14,30 @@
*/
#define __ZIP_C
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#include "libc/time/time.h" /* for tzset() declaration */
#if defined(WIN32) || defined(WINDLL)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
#ifdef WINDLL
# include <setjmp.h>
# include "windll/windll.h"
#endif
#define DEFCPYRT /* main module: enable copyright string defines! */
#include "third_party/infozip/zip/revision.h"
#include "third_party/infozip/zip/crc32.h"
#include "third_party/infozip/zip/crypt.h"
#include "third_party/infozip/zip/ttyio.h"
#include "third_party/zip/revision.h"
#include "third_party/zip/crc32.h"
#include "third_party/zip/crypt.h"
#include "third_party/zip/ttyio.h"
#include "libc/str/str.h"
#include "libc/log/log.h"
#include "libc/dce.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/sysv/consts/sig.h"
#include "libc/calls/calls.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#ifdef VMS
# include <stsdef.h>
# include "vms/vmsmunch.h"
# include "vms/vms.h"
#endif
#ifdef MACOS
# include "macglob.h"
extern MacZipGlobals MacZip;
extern int error_level;
#endif
#if (defined(MSDOS) && !defined(__GO32__)) || defined(__human68k__)
# include <process.h>
# if (!defined(P_WAIT) && defined(_P_WAIT))
# define P_WAIT _P_WAIT
# endif
#endif
#include "libc/calls/calls.h"
#include "libc/fmt/fmt.h"
#include "libc/log/log.h"
#include "libc/stdio/stdio.h"
#include "libc/stdio/temp.h"
#ifdef UNICODE_TEST
# ifdef WIN32
# include <direct.h>
# endif
#endif
#ifdef BZIP2_SUPPORT
/* If IZ_BZIP2 is defined as the location of the bzip2 files then
assume the location has been added to include path. For Unix
this is done by the configure script. */
/* Also do not need path for bzip2 include if OS includes support
for bzip2 library. */
# include "bzlib.h"
#endif
#include "third_party/bzip2/bzlib.h"
#define MAXCOM 256 /* Maximum one-line comment size */
/* Local option flags */
#ifndef DELETE
#define DELETE 0
@ -452,24 +412,14 @@ void error(h)
ziperr(ZE_LOGIC, h);
}
#if (!defined(MACOS) && !defined(WINDLL))
local void handler(s)
int s; /* signal number (ignored) */
/* Upon getting a user interrupt, turn echo back on for tty and abort
cleanly using ziperr(). */
{
#if defined(AMIGA) && defined(__SASC)
_abort();
#else
#if !defined(MSDOS) && !defined(__human68k__) && !defined(RISCOS)
echon();
putc('\n', mesg);
#endif /* !MSDOS */
#endif /* AMIGA && __SASC */
ziperr(ZE_ABORT, "aborting");
s++; /* keep some compilers happy */
}
#endif /* !MACOS && !WINDLL */
void zipmessage_nl(a, nl)
ZCONST char *a; /* message string to output */
@ -696,6 +646,13 @@ local void help()
}
}
static const char *GetPagerPath(char path[PATH_MAX]) {
const char *s;
if ((s = commandv("less", path))) return s;
if ((s = commandv("more", path))) return s;
return 0;
}
#ifdef VMSCLI
void help_extended()
#else
@ -706,342 +663,351 @@ local void help_extended()
extent i; /* counter for help array */
/* help array */
static ZCONST char *text[] = {
"",
"Extended Help for Zip",
"",
"See the Zip Manual for more detailed help",
"",
"",
"Zip stores files in zip archives. The default action is to add or replace",
"zipfile entries.",
"",
"Basic command line:",
" zip options archive_name file file ...",
"",
"Some examples:",
" Add file.txt to z.zip (create z if needed): zip z file.txt",
" Zip all files in current dir: zip z *",
" Zip files in current dir and subdirs also: zip -r z .",
"",
"Basic modes:",
" External modes (selects files from file system):",
" add - add new files/update existing files in archive (default)",
" -u update - add new files/update existing files only if later date",
" -f freshen - update existing files only (no files added)",
" -FS filesync - update if date or size changed, delete if no OS match",
" Internal modes (selects entries in archive):",
" -d delete - delete files from archive (see below)",
" -U copy - select files in archive to copy (use with --out)",
"",
"Basic options:",
" -r recurse into directories (see Recursion below)",
" -m after archive created, delete original files (move into archive)",
" -j junk directory names (store just file names)",
" -q quiet operation",
" -v verbose operation (just \"zip -v\" shows version information)",
" -c prompt for one-line comment for each entry",
" -z prompt for comment for archive (end with just \".\" line or EOF)",
" -@ read names to zip from stdin (one path per line)",
" -o make zipfile as old as latest entry",
"",
"",
"Syntax:",
" The full command line syntax is:",
"",
" zip [-shortopts ...] [--longopt ...] [zipfile [path path ...]] [-xi list]",
"",
" Any number of short option and long option arguments are allowed",
" (within limits) as well as any number of path arguments for files",
" to zip up. If zipfile exists, the archive is read in. If zipfile",
" is \"-\", stream to stdout. If any path is \"-\", zip stdin.",
"",
"Options and Values:",
" For short options that take values, use -ovalue or -o value or -o=value",
" For long option values, use either --longoption=value or --longoption value",
" For example:",
" zip -ds 10 --temp-dir=path zipfile path1 path2 --exclude pattern pattern",
" Avoid -ovalue (no space between) to avoid confusion",
" In particular, be aware of 2-character options. For example:",
" -d -s is (delete, split size) while -ds is (dot size)",
" Usually better to break short options across multiple arguments by function",
" zip -r -dbdcds 10m -lilalf logfile archive input_directory -ll",
"",
" All args after just \"--\" arg are read verbatim as paths and not options.",
" zip zipfile path path ... -- verbatimpath verbatimpath ...",
" Use -nw to also disable wildcards, so paths are read literally:",
" zip zipfile -nw -- \"-leadingdashpath\" \"a[path].c\" \"path*withwildcard\"",
" You may still have to escape or quote arguments to avoid shell expansion",
"",
"Wildcards:",
" Internally zip supports the following wildcards:",
" ? (or %% or #, depending on OS) matches any single character",
" * matches any number of characters, including zero",
" [list] matches char in list (regex), can do range [ac-f], all but [!bf]",
" If port supports [], must escape [ as [[] or use -nw to turn off wildcards",
" For shells that expand wildcards, escape (\\* or \"*\") so zip can recurse",
" zip zipfile -r . -i \"*.h\"",
"",
" Normally * crosses dir bounds in path, e.g. 'a*b' can match 'ac/db'. If",
" -ws option used, * does not cross dir bounds but ** does",
"",
" For DOS and Windows, [list] is now disabled unless the new option",
" -RE enable [list] (regular expression) matching",
" is used to avoid problems with file paths containing \"[\" and \"]\":",
" zip files_ending_with_number -RE foo[0-9].c",
"",
"Include and Exclude:",
" -i pattern pattern ... include files that match a pattern",
" -x pattern pattern ... exclude files that match a pattern",
" Patterns are paths with optional wildcards and match paths as stored in",
" archive. Exclude and include lists end at next option, @, or end of line.",
" zip -x pattern pattern @ zipfile path path ...",
"",
"Case matching:",
" On most OS the case of patterns must match the case in the archive, unless",
" the -ic option is used.",
" -ic ignore case of archive entries",
" This option not available on case-sensitive file systems. On others, case",
" ignored when matching files on file system but matching against archive",
" entries remains case sensitive for modes -f (freshen), -U (archive copy),",
" and -d (delete) because archive paths are always case sensitive. With",
" -ic, all matching ignores case, but it's then possible multiple archive",
" entries that differ only in case will match.",
"",
"End Of Line Translation (text files only):",
" -l change CR or LF (depending on OS) line end to CR LF (Unix->Win)",
" -ll change CR LF to CR or LF (depending on OS) line end (Win->Unix)",
" If first buffer read from file contains binary the translation is skipped",
"",
"Recursion:",
" -r recurse paths, include files in subdirs: zip -r a path path ...",
" -R recurse current dir and match patterns: zip -R a ptn ptn ...",
" Use -i and -x with either to include or exclude paths",
" Path root in archive starts at current dir, so if /a/b/c/file and",
" current dir is /a/b, 'zip -r archive .' puts c/file in archive",
"",
"Date filtering:",
" -t date exclude before (include files modified on this date and later)",
" -tt date include before (include files modified before date)",
" Can use both at same time to set a date range",
" Dates are mmddyyyy or yyyy-mm-dd",
"",
"Deletion, File Sync:",
" -d delete files",
" Delete archive entries matching internal archive paths in list",
" zip archive -d pattern pattern ...",
" Can use -t and -tt to select files in archive, but NOT -x or -i, so",
" zip archive -d \"*\" -t 2005-12-27",
" deletes all files from archive.zip with date of 27 Dec 2005 and later",
" Note the * (escape as \"*\" on Unix) to select all files in archive",
"",
" -FS file sync",
" Similar to update, but files updated if date or size of entry does not",
" match file on OS. Also deletes entry from archive if no matching file",
" on OS.",
" zip archive_to_update -FS -r dir_used_before",
" Result generally same as creating new archive, but unchanged entries",
" are copied instead of being read and compressed so can be faster.",
" WARNING: -FS deletes entries so make backup copy of archive first",
"",
"Compression:",
" -0 store files (no compression)",
" -1 to -9 compress fastest to compress best (default is 6)",
" -Z cm set compression method to cm:",
" store - store without compression, same as option -0",
" deflate - original zip deflate, same as -1 to -9 (default)",
" if bzip2 is enabled:",
" bzip2 - use bzip2 compression (need modern unzip)",
"",
"Encryption:",
" -e use standard (weak) PKZip 2.0 encryption, prompt for password",
" -P pswd use standard encryption, password is pswd",
"",
"Splits (archives created as a set of split files):",
" -s ssize create split archive with splits of size ssize, where ssize nm",
" n number and m multiplier (kmgt, default m), 100k -> 100 kB",
" -sp pause after each split closed to allow changing disks",
" WARNING: Archives created with -sp use data descriptors and should",
" work with most unzips but may not work with some",
" -sb ring bell when pause",
" -sv be verbose about creating splits",
" Split archives CANNOT be updated, but see --out and Copy Mode below",
"",
"Using --out (output to new archive):",
" --out oa output to new archive oa",
" Instead of updating input archive, create new output archive oa.",
" Result is same as without --out but in new archive. Input archive",
" unchanged.",
" WARNING: --out ALWAYS overwrites any existing output file",
" For example, to create new_archive like old_archive but add newfile1",
" and newfile2:",
" zip old_archive newfile1 newfile2 --out new_archive",
" Cannot update split archive, so use --out to out new archive:",
" zip in_split_archive newfile1 newfile2 --out out_split_archive",
" If input is split, output will default to same split size",
" Use -s=0 or -s- to turn off splitting to convert split to single file:",
" zip in_split_archive -s 0 --out out_single_file_archive",
" WARNING: If overwriting old split archive but need less splits,",
" old splits not overwritten are not needed but remain",
"",
"Copy Mode (copying from archive to archive):",
" -U (also --copy) select entries in archive to copy (reverse delete)",
" Copy Mode copies entries from old to new archive with --out and is used by",
" zip when either no input files on command line or -U (--copy) used.",
" zip inarchive --copy pattern pattern ... --out outarchive",
" To copy only files matching *.c into new archive, excluding foo.c:",
" zip old_archive --copy \"*.c\" --out new_archive -x foo.c",
" If no input files and --out, copy all entries in old archive:",
" zip old_archive --out new_archive",
"",
"Streaming and FIFOs:",
" prog1 | zip -ll z - zip output of prog1 to zipfile z, converting CR LF",
" zip - -R \"*.c\" | prog2 zip *.c files in current dir and stream to prog2 ",
" prog1 | zip | prog2 zip in pipe with no in or out acts like zip - -",
" If Zip is Zip64 enabled, streaming stdin creates Zip64 archives by default",
" that need PKZip 4.5 unzipper like UnZip 6.0",
" WARNING: Some archives created with streaming use data descriptors and",
" should work with most unzips but may not work with some",
" Can use -fz- to turn off Zip64 if input not large (< 4 GB):",
" prog_with_small_output | zip archive -fz-",
"",
" Zip now can read Unix FIFO (named pipes). Off by default to prevent zip",
" from stopping unexpectedly on unfed pipe, use -FI to enable:",
" zip -FI archive fifo",
"",
"Dots, counts:",
" -db display running count of bytes processed and bytes to go",
" (uncompressed size, except delete and copy show stored size)",
" -dc display running count of entries done and entries to go",
" -dd display dots every 10 MB (or dot size) while processing files",
" -dg display dots globally for archive instead of for each file",
" zip -qdgds 10m will turn off most output except dots every 10 MB",
" -ds siz each dot is siz processed where siz is nm as splits (0 no dots)",
" -du display original uncompressed size for each entry as added",
" -dv display volume (disk) number in format in_disk>out_disk",
" Dot size is approximate, especially for dot sizes less than 1 MB",
" Dot options don't apply to Scanning files dots (dot/2sec) (-q turns off)",
"",
"Logging:",
" -lf path open file at path as logfile (overwrite existing file)",
" -la append to existing logfile",
" -li include info messages (default just warnings and errors)",
"",
"Testing archives:",
" -T test completed temp archive with unzip before updating archive",
" -TT cmd use command cmd instead of 'unzip -tqq' to test archive",
" On Unix, to use unzip in current directory, could use:",
" zip archive file1 file2 -T -TT \"./unzip -tqq\"",
" In cmd, {} replaced by temp archive path, else temp appended.",
" The return code is checked for success (0 on Unix)",
"",
"Fixing archives:",
" -F attempt to fix a mostly intact archive (try this first)",
" -FF try to salvage what can (may get more but less reliable)",
" Fix options copy entries from potentially bad archive to new archive.",
" -F tries to read archive normally and copy only intact entries, while",
" -FF tries to salvage what can and may result in incomplete entries.",
" Must use --out option to specify output archive:",
" zip -F bad.zip --out fixed.zip",
" Use -v (verbose) with -FF to see details:",
" zip reallybad.zip -FF -v --out fixed.zip",
" Currently neither option fixes bad entries, as from text mode ftp get.",
"",
"Difference mode:",
" -DF (also --dif) only include files that have changed or are",
" new as compared to the input archive",
" Difference mode can be used to create incremental backups. For example:",
" zip --dif full_backup.zip -r somedir --out diff.zip",
" will store all new files, as well as any files in full_backup.zip where",
" either file time or size have changed from that in full_backup.zip,",
" in new diff.zip. Output archive not excluded automatically if exists,",
" so either use -x to exclude it or put outside what is being zipped.",
"",
"DOS Archive bit (Windows only):",
" -AS include only files with the DOS Archive bit set",
" -AC after archive created, clear archive bit of included files",
" WARNING: Once the archive bits are cleared they are cleared",
" Use -T to test the archive before the bits are cleared",
" Can also use -sf to save file list before zipping files",
"",
"Show files:",
" -sf show files to operate on and exit (-sf- logfile only)",
" -su as -sf but show escaped UTF-8 Unicode names also if exist",
" -sU as -sf but show escaped UTF-8 Unicode names instead",
" Any character not in the current locale is escaped as #Uxxxx, where x",
" is hex digit, if 16-bit code is sufficient, or #Lxxxxxx if 24-bits",
" are needed. If add -UN=e, Zip escapes all non-ASCII characters.",
"",
"Unicode:",
" If compiled with Unicode support, Zip stores UTF-8 path of entries.",
" This is backward compatible. Unicode paths allow better conversion",
" of entry names between different character sets.",
"",
" New Unicode extra field includes checksum to verify Unicode path",
" goes with standard path for that entry (as utilities like ZipNote",
" can rename entries). If these do not match, use below options to",
" set what Zip does:",
" -UN=Quit - if mismatch, exit with error",
" -UN=Warn - if mismatch, warn, ignore UTF-8 (default)",
" -UN=Ignore - if mismatch, quietly ignore UTF-8",
" -UN=No - ignore any UTF-8 paths, use standard paths for all",
" An exception to -UN=N are entries with new UTF-8 bit set (instead",
" of using extra fields). These are always handled as Unicode.",
"",
" Normally Zip escapes all chars outside current char set, but leaves",
" as is supported chars, which may not be OK in path names. -UN=Escape",
" escapes any character not ASCII:",
" zip -sU -UN=e archive",
" Can use either normal path or escaped Unicode path on command line",
" to match files in archive.",
"",
" Zip now stores UTF-8 in entry path and comment fields on systems",
" where UTF-8 char set is default, such as most modern Unix, and",
" and on other systems in new extra fields with escaped versions in",
" entry path and comment fields for backward compatibility.",
" Option -UN=UTF8 will force storing UTF-8 in entry path and comment",
" fields:",
" -UN=UTF8 - store UTF-8 in entry path and comment fields",
" This option can be useful for multi-byte char sets on Windows where",
" escaped paths and comments can be too long to be valid as the UTF-8",
" versions tend to be shorter.",
"",
" Only UTF-8 comments on UTF-8 native systems supported. UTF-8 comments",
" for other systems planned in next release.",
"",
"Self extractor:",
" -A Adjust offsets - a self extractor is created by prepending",
" the extractor executable to archive, but internal offsets",
" are then off. Use -A to fix offsets.",
" -J Junk sfx - removes prepended extractor executable from",
" self extractor, leaving a plain zip archive.",
"",
"More option highlights (see manual for additional options and details):",
" -b dir when creating or updating archive, create the temp archive in",
" dir, which allows using seekable temp file when writing to a",
" write once CD, such archives compatible with more unzips",
" (could require additional file copy if on another device)",
" -MM input patterns must match at least one file and matched files",
" must be readable or exit with OPEN error and abort archive",
" (without -MM, both are warnings only, and if unreadable files",
" are skipped OPEN error (18) returned after archive created)",
" -nw no wildcards (wildcards are like any other character)",
" -sc show command line arguments as processed and exit",
" -sd show debugging as Zip does each step",
" -so show all available options on this system",
" -X default=strip old extra fields, -X- keep old, -X strip most",
" -ws wildcards don't span directory boundaries in paths",
""
};
const char *text = "\n\
Extended Help for Zip\n\
\n\
See the Zip Manual for more detailed help\n\
\n\
\n\
Zip stores files in zip archives. The default action is to add or replace\n\
zipfile entries.\n\
\n\
Basic command line:\n\
zip options archive_name file file ...\n\
\n\
Some examples:\n\
Add file.txt to z.zip (create z if needed): zip z file.txt\n\
Zip all files in current dir: zip z *\n\
Zip files in current dir and subdirs also: zip -r z .\n\
\n\
Basic modes:\n\
External modes (selects files from file system):\n\
add - add new files/update existing files in archive (default)\n\
-u update - add new files/update existing files only if later date\n\
-f freshen - update existing files only (no files added)\n\
-FS filesync - update if date or size changed, delete if no OS match\n\
Internal modes (selects entries in archive):\n\
-d delete - delete files from archive (see below)\n\
-U copy - select files in archive to copy (use with --out)\n\
\n\
Basic options:\n\
-r recurse into directories (see Recursion below)\n\
-m after archive created, delete original files (move into archive)\n\
-j junk directory names (store just file names)\n\
-q quiet operation\n\
-v verbose operation (just \"zip -v\" shows version information)\n\
-c prompt for one-line comment for each entry\n\
-z prompt for comment for archive (end with just \".\" line or EOF)\n\
-@ read names to zip from stdin (one path per line)\n\
-o make zipfile as old as latest entry\n\
\n\
\n\
Syntax:\n\
The full command line syntax is:\n\
\n\
zip [-shortopts ...] [--longopt ...] [zipfile [path path ...]] [-xi list]\n\
\n\
Any number of short option and long option arguments are allowed\n\
(within limits) as well as any number of path arguments for files\n\
to zip up. If zipfile exists, the archive is read in. If zipfile\n\
is \"-\", stream to stdout. If any path is \"-\", zip stdin.\n\
\n\
Options and Values:\n\
For short options that take values, use -ovalue or -o value or -o=value\n\
For long option values, use either --longoption=value or --longoption value\n\
For example:\n\
zip -ds 10 --temp-dir=path zipfile path1 path2 --exclude pattern pattern\n\
Avoid -ovalue (no space between) to avoid confusion\n\
In particular, be aware of 2-character options. For example:\n\
-d -s is (delete, split size) while -ds is (dot size)\n\
Usually better to break short options across multiple arguments by function\n\
zip -r -dbdcds 10m -lilalf logfile archive input_directory -ll\n\
\n\
All args after just \"--\" arg are read verbatim as paths and not options.\n\
zip zipfile path path ... -- verbatimpath verbatimpath ...\n\
Use -nw to also disable wildcards, so paths are read literally:\n\
zip zipfile -nw -- \"-leadingdashpath\" \"a[path].c\" \"path*withwildcard\"\n\
You may still have to escape or quote arguments to avoid shell expansion\n\
\n\
Wildcards:\n\
Internally zip supports the following wildcards:\n\
? (or %% or #, depending on OS) matches any single character\n\
* matches any number of characters, including zero\n\
[list] matches char in list (regex), can do range [ac-f], all but [!bf]\n\
If port supports [], must escape [ as [[] or use -nw to turn off wildcards\n\
For shells that expand wildcards, escape (\\* or \"*\") so zip can recurse\n\
zip zipfile -r . -i \"*.h\"\n\
\n\
Normally * crosses dir bounds in path, e.g. 'a*b' can match 'ac/db'. If\n\
-ws option used, * does not cross dir bounds but ** does\n\
\n\
For DOS and Windows, [list] is now disabled unless the new option\n\
-RE enable [list] (regular expression) matching\n\
is used to avoid problems with file paths containing \"[\" and \"]\":\n\
zip files_ending_with_number -RE foo[0-9].c\n\
\n\
Include and Exclude:\n\
-i pattern pattern ... include files that match a pattern\n\
-x pattern pattern ... exclude files that match a pattern\n\
Patterns are paths with optional wildcards and match paths as stored in\n\
archive. Exclude and include lists end at next option, @, or end of line.\n\
zip -x pattern pattern @ zipfile path path ...\n\
\n\
Case matching:\n\
On most OS the case of patterns must match the case in the archive, unless\n\
the -ic option is used.\n\
-ic ignore case of archive entries\n\
This option not available on case-sensitive file systems. On others, case\n\
ignored when matching files on file system but matching against archive\n\
entries remains case sensitive for modes -f (freshen), -U (archive copy),\n\
and -d (delete) because archive paths are always case sensitive. With\n\
-ic, all matching ignores case, but it's then possible multiple archive\n\
entries that differ only in case will match.\n\
\n\
End Of Line Translation (text files only):\n\
-l change CR or LF (depending on OS) line end to CR LF (Unix->Win)\n\
-ll change CR LF to CR or LF (depending on OS) line end (Win->Unix)\n\
If first buffer read from file contains binary the translation is skipped\n\
\n\
Recursion:\n\
-r recurse paths, include files in subdirs: zip -r a path path ...\n\
-R recurse current dir and match patterns: zip -R a ptn ptn ...\n\
Use -i and -x with either to include or exclude paths\n\
Path root in archive starts at current dir, so if /a/b/c/file and\n\
current dir is /a/b, 'zip -r archive .' puts c/file in archive\n\
\n\
Date filtering:\n\
-t date exclude before (include files modified on this date and later)\n\
-tt date include before (include files modified before date)\n\
Can use both at same time to set a date range\n\
Dates are mmddyyyy or yyyy-mm-dd\n\
\n\
Deletion, File Sync:\n\
-d delete files\n\
Delete archive entries matching internal archive paths in list\n\
zip archive -d pattern pattern ...\n\
Can use -t and -tt to select files in archive, but NOT -x or -i, so\n\
zip archive -d \"*\" -t 2005-12-27\n\
deletes all files from archive.zip with date of 27 Dec 2005 and later\n\
Note the * (escape as \"*\" on Unix) to select all files in archive\n\
\n\
-FS file sync\n\
Similar to update, but files updated if date or size of entry does not\n\
match file on OS. Also deletes entry from archive if no matching file\n\
on OS.\n\
zip archive_to_update -FS -r dir_used_before\n\
Result generally same as creating new archive, but unchanged entries\n\
are copied instead of being read and compressed so can be faster.\n\
WARNING: -FS deletes entries so make backup copy of archive first\n\
\n\
Compression:\n\
-0 store files (no compression)\n\
-1 to -9 compress fastest to compress best (default is 6)\n\
-Z cm set compression method to cm:\n\
store - store without compression, same as option -0\n\
deflate - original zip deflate, same as -1 to -9 (default)\n\
bzip2 - use bzip2 compression (need modern unzip)\n\
\n\
Encryption:\n\
-e use standard (weak) PKZip 2.0 encryption, prompt for password\n\
-P pswd use standard encryption, password is pswd\n\
\n\
Splits (archives created as a set of split files):\n\
-s ssize create split archive with splits of size ssize, where ssize nm\n\
n number and m multiplier (kmgt, default m), 100k -> 100 kB\n\
-sp pause after each split closed to allow changing disks\n\
WARNING: Archives created with -sp use data descriptors and should\n\
work with most unzips but may not work with some\n\
-sb ring bell when pause\n\
-sv be verbose about creating splits\n\
Split archives CANNOT be updated, but see --out and Copy Mode below\n\
\n\
Using --out (output to new archive):\n\
--out oa output to new archive oa\n\
Instead of updating input archive, create new output archive oa.\n\
Result is same as without --out but in new archive. Input archive\n\
unchanged.\n\
WARNING: --out ALWAYS overwrites any existing output file\n\
For example, to create new_archive like old_archive but add newfile1\n\
and newfile2:\n\
zip old_archive newfile1 newfile2 --out new_archive\n\
Cannot update split archive, so use --out to out new archive:\n\
zip in_split_archive newfile1 newfile2 --out out_split_archive\n\
If input is split, output will default to same split size\n\
Use -s=0 or -s- to turn off splitting to convert split to single file:\n\
zip in_split_archive -s 0 --out out_single_file_archive\n\
WARNING: If overwriting old split archive but need less splits,\n\
old splits not overwritten are not needed but remain\n\
\n\
Copy Mode (copying from archive to archive):\n\
-U (also --copy) select entries in archive to copy (reverse delete)\n\
Copy Mode copies entries from old to new archive with --out and is used by\n\
zip when either no input files on command line or -U (--copy) used.\n\
zip inarchive --copy pattern pattern ... --out outarchive\n\
To copy only files matching *.c into new archive, excluding foo.c:\n\
zip old_archive --copy \"*.c\" --out new_archive -x foo.c\n\
If no input files and --out, copy all entries in old archive:\n\
zip old_archive --out new_archive\n\
\n\
Streaming and FIFOs:\n\
prog1 | zip -ll z - zip output of prog1 to zipfile z, converting CR LF\n\
zip - -R \"*.c\" | prog2 zip *.c files in current dir and stream to prog2 \n\
prog1 | zip | prog2 zip in pipe with no in or out acts like zip - -\n\
If Zip is Zip64 enabled, streaming stdin creates Zip64 archives by default\n\
that need PKZip 4.5 unzipper like UnZip 6.0\n\
WARNING: Some archives created with streaming use data descriptors and\n\
should work with most unzips but may not work with some\n\
Can use -fz- to turn off Zip64 if input not large (< 4 GB):\n\
prog_with_small_output | zip archive -fz-\n\
\n\
Zip now can read Unix FIFO (named pipes). Off by default to prevent zip\n\
from stopping unexpectedly on unfed pipe, use -FI to enable:\n\
zip -FI archive fifo\n\
\n\
Dots, counts:\n\
-db display running count of bytes processed and bytes to go\n\
(uncompressed size, except delete and copy show stored size)\n\
-dc display running count of entries done and entries to go\n\
-dd display dots every 10 MB (or dot size) while processing files\n\
-dg display dots globally for archive instead of for each file\n\
zip -qdgds 10m will turn off most output except dots every 10 MB\n\
-ds siz each dot is siz processed where siz is nm as splits (0 no dots)\n\
-du display original uncompressed size for each entry as added\n\
-dv display volume (disk) number in format in_disk>out_disk\n\
Dot size is approximate, especially for dot sizes less than 1 MB\n\
Dot options don't apply to Scanning files dots (dot/2sec) (-q turns off)\n\
\n\
Logging:\n\
-lf path open file at path as logfile (overwrite existing file)\n\
-la append to existing logfile\n\
-li include info messages (default just warnings and errors)\n\
\n\
Testing archives:\n\
-T test completed temp archive with unzip before updating archive\n\
-TT cmd use command cmd instead of 'unzip -tqq' to test archive\n\
On Unix, to use unzip in current directory, could use:\n\
zip archive file1 file2 -T -TT \"./unzip -tqq\"\n\
In cmd, {} replaced by temp archive path, else temp appended.\n\
The return code is checked for success (0 on Unix)\n\
\n\
Fixing archives:\n\
-F attempt to fix a mostly intact archive (try this first)\n\
-FF try to salvage what can (may get more but less reliable)\n\
Fix options copy entries from potentially bad archive to new archive.\n\
-F tries to read archive normally and copy only intact entries, while\n\
-FF tries to salvage what can and may result in incomplete entries.\n\
Must use --out option to specify output archive:\n\
zip -F bad.zip --out fixed.zip\n\
Use -v (verbose) with -FF to see details:\n\
zip reallybad.zip -FF -v --out fixed.zip\n\
Currently neither option fixes bad entries, as from text mode ftp get.\n\
\n\
Difference mode:\n\
-DF (also --dif) only include files that have changed or are\n\
new as compared to the input archive\n\
Difference mode can be used to create incremental backups. For example:\n\
zip --dif full_backup.zip -r somedir --out diff.zip\n\
will store all new files, as well as any files in full_backup.zip where\n\
either file time or size have changed from that in full_backup.zip,\n\
in new diff.zip. Output archive not excluded automatically if exists,\n\
so either use -x to exclude it or put outside what is being zipped.\n\
\n\
DOS Archive bit (Windows only):\n\
-AS include only files with the DOS Archive bit set\n\
-AC after archive created, clear archive bit of included files\n\
WARNING: Once the archive bits are cleared they are cleared\n\
Use -T to test the archive before the bits are cleared\n\
Can also use -sf to save file list before zipping files\n\
\n\
Show files:\n\
-sf show files to operate on and exit (-sf- logfile only)\n\
-su as -sf but show escaped UTF-8 Unicode names also if exist\n\
-sU as -sf but show escaped UTF-8 Unicode names instead\n\
Any character not in the current locale is escaped as #Uxxxx, where x\n\
is hex digit, if 16-bit code is sufficient, or #Lxxxxxx if 24-bits\n\
are needed. If add -UN=e, Zip escapes all non-ASCII characters.\n\
\n\
Unicode:\n\
If compiled with Unicode support, Zip stores UTF-8 path of entries.\n\
This is backward compatible. Unicode paths allow better conversion\n\
of entry names between different character sets.\n\
\n\
New Unicode extra field includes checksum to verify Unicode path\n\
goes with standard path for that entry (as utilities like ZipNote\n\
can rename entries). If these do not match, use below options to\n\
set what Zip does:\n\
-UN=Quit - if mismatch, exit with error\n\
-UN=Warn - if mismatch, warn, ignore UTF-8 (default)\n\
-UN=Ignore - if mismatch, quietly ignore UTF-8\n\
-UN=No - ignore any UTF-8 paths, use standard paths for all\n\
An exception to -UN=N are entries with new UTF-8 bit set (instead\n\
of using extra fields). These are always handled as Unicode.\n\
\n\
Normally Zip escapes all chars outside current char set, but leaves\n\
as is supported chars, which may not be OK in path names. -UN=Escape\n\
escapes any character not ASCII:\n\
zip -sU -UN=e archive\n\
Can use either normal path or escaped Unicode path on command line\n\
to match files in archive.\n\
\n\
Zip now stores UTF-8 in entry path and comment fields on systems\n\
where UTF-8 char set is default, such as most modern Unix, and\n\
and on other systems in new extra fields with escaped versions in\n\
entry path and comment fields for backward compatibility.\n\
Option -UN=UTF8 will force storing UTF-8 in entry path and comment\n\
fields:\n\
-UN=UTF8 - store UTF-8 in entry path and comment fields\n\
This option can be useful for multi-byte char sets on Windows where\n\
escaped paths and comments can be too long to be valid as the UTF-8\n\
versions tend to be shorter.\n\
\n\
Only UTF-8 comments on UTF-8 native systems supported. UTF-8 comments\n\
for other systems planned in next release.\n\
\n\
Self extractor:\n\
-A Adjust offsets - a self extractor is created by prepending\n\
the extractor executable to archive, but internal offsets\n\
are then off. Use -A to fix offsets.\n\
-J Junk sfx - removes prepended extractor executable from\n\
self extractor, leaving a plain zip archive.\n\
\n\
More option highlights (see manual for additional options and details):\n\
-b dir when creating or updating archive, create the temp archive in\n\
dir, which allows using seekable temp file when writing to a\n\
write once CD, such archives compatible with more unzips\n\
(could require additional file copy if on another device)\n\
-MM input patterns must match at least one file and matched files\n\
must be readable or exit with OPEN error and abort archive\n\
(without -MM, both are warnings only, and if unreadable files\n\
are skipped OPEN error (18) returned after archive created)\n\
-nw no wildcards (wildcards are like any other character)\n\
-sc show command line arguments as processed and exit\n\
-sd show debugging as Zip does each step\n\
-so show all available options on this system\n\
-X default=strip old extra fields, -X- keep old, -X strip most\n\
-ws wildcards don't span directory boundaries in paths\n\
";
for (i = 0; i < sizeof(text)/sizeof(char *); i++)
{
printf(text[i]);
putchar('\n');
int pip[2];
char *args[2] = {0};
char pathbuf[PATH_MAX];
if (isatty(0) && isatty(1) && (args[0] = GetPagerPath(pathbuf))) {
sigaction(SIGPIPE, &(struct sigaction){.sa_handler = SIG_IGN}, 0);
close(0);
pipe(pip);
if (!fork()) {
close(pip[1]);
execv(args[0], args);
_Exit(127);
}
close(0);
write(pip[1], text, strlen(text));
close(pip[1]);
wait(0);
} else {
fputs(text, stdout);
}
#ifdef DOS
check_for_windows("Zip");
#endif
exit(0);
}
/*
@ -2195,8 +2161,6 @@ char **argv; /* command line tokens */
char **args = NULL; /* could be wide argv */
if (!IsTiny()) ShowCrashReports();
#ifdef THEOS
/* the argument expansion from the standard library is full of bugs */
/* use mine instead */
@ -2607,6 +2571,8 @@ char **argv; /* command line tokens */
NLMsignals();
#endif
if (!IsTiny()) ShowCrashReports();
#if defined(UNICODE_SUPPORT) && defined(WIN32)
/* check if this Win32 OS has support for wide character calls */
@ -3662,14 +3628,6 @@ char **argv; /* command line tokens */
filterlist_to_patterns();
}
#if (defined(MSDOS) || defined(OS2)) && !defined(WIN32)
if ((kk == 3 || kk == 4) && volume_label == 1) {
/* read volume label */
PROCNAME(NULL);
kk = 4;
}
#endif
if (have_out && kk == 3) {
copy_only = 1;
action = ARCHIVE;

View file

@ -86,11 +86,7 @@ typedef unsigned short ush; /* unsigned 16-bit value */
typedef unsigned long ulg; /* unsigned 32-bit value */
/* Set up portability */
#include "third_party/infozip/zip/tailor.h"
#ifdef USE_ZLIB
# include "third_party/zlib/zlib.h"
#endif
#include "third_party/zip/tailor.h"
/* In the utilities, the crc32() function is only used for UNICODE_SUPPORT. */
#if defined(UTIL) && !defined(UNICODE_SUPPORT)
@ -278,7 +274,7 @@ struct plist {
#define ZP_PW_VERIFY 1 /* request for reentering password */
/* Error return codes and PERR macro */
#include "third_party/infozip/zip/ziperr.h"
#include "third_party/zip/ziperr.h"
#if 0 /* Optimization: use the (const) result of crc32(0L,NULL,0) */
# define CRCVAL_INITIAL crc32(0L, (uch *)NULL, 0)
@ -878,7 +874,7 @@ void bi_init OF((char *, unsigned int, int));
/*---------------------------------------------------------------------------
Prototypes for public Zip API (DLL) functions.
---------------------------------------------------------------------------*/
#include "third_party/infozip/zip/api.h"
#include "third_party/zip/api.h"
#endif /* WINDLL || DLL_ZIPAPI */

189
third_party/zip/zip.mk vendored Normal file
View file

@ -0,0 +1,189 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += THIRD_PARTY_ZIP
THIRD_PARTY_ZIP_FILES := $(wildcard third_party/zip/*)
THIRD_PARTY_ZIP_SRCS = $(filter %.c,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_HDRS = $(filter %.h,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_INCS = $(filter %.inc,$(THIRD_PARTY_ZIP_FILES))
THIRD_PARTY_ZIP_COMS = \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/third_party/zip/zipsplit.com \
o/$(MODE)/third_party/zip/zipnote.com \
o/$(MODE)/third_party/zip/zipcloak.com
THIRD_PARTY_ZIP_BINS = \
$(THIRD_PARTY_ZIP_COMS) \
$(THIRD_PARTY_ZIP_COMS:%=%.dbg)
THIRD_PARTY_ZIP_CHECKS = \
o/$(MODE)/third_party/zip/zip.pkg
THIRD_PARTY_ZIP_OBJS = $(sort \
$(THIRD_PARTY_ZIP_ZIP_OBJS) \
$(THIRD_PARTY_ZIPCLOAK_OBJS) \
$(THIRD_PARTY_ZIPNOTE_OBJS) \
$(THIRD_PARTY_ZIPSPLIT_OBJS) \
)
THIRD_PARTY_ZIP_UTIL_OBJS1 = \
o/$(MODE)/third_party/zip/globals.o \
o/$(MODE)/third_party/zip/unix_.o \
o/$(MODE)/third_party/zip/zipfile_.o \
o/$(MODE)/third_party/zip/fileio_.o \
o/$(MODE)/third_party/zip/util_.o
THIRD_PARTY_ZIP_UTIL_OBJS2 = \
o/$(MODE)/third_party/zip/crypt_.o
THIRD_PARTY_ZIP_UTIL_OBJS = \
$(THIRD_PARTY_ZIP_UTIL_OBJS1) \
$(THIRD_PARTY_ZIP_UTIL_OBJS2)
THIRD_PARTY_ZIP_ZIP_OBJS = \
o/$(MODE)/third_party/zip/zip.o \
o/$(MODE)/third_party/zip/zipfile.o \
o/$(MODE)/third_party/zip/zipup.o \
o/$(MODE)/third_party/zip/fileio.o \
o/$(MODE)/third_party/zip/util.o \
o/$(MODE)/third_party/zip/globals.o \
o/$(MODE)/third_party/zip/crypt.o \
o/$(MODE)/third_party/zip/ttyio.o \
o/$(MODE)/third_party/zip/unix.o \
o/$(MODE)/third_party/zip/crc32.o \
o/$(MODE)/third_party/zip/zbz2err.o \
o/$(MODE)/third_party/zip/deflate.o \
o/$(MODE)/third_party/zip/trees.o
THIRD_PARTY_ZIPSPLIT_OBJS = \
o/$(MODE)/third_party/zip/zipsplit.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1)
THIRD_PARTY_ZIPNOTE_OBJS = \
o/$(MODE)/third_party/zip/zipnote.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1)
THIRD_PARTY_ZIPCLOAK_OBJS = \
o/$(MODE)/third_party/zip/zipcloak.o \
o/$(MODE)/third_party/zip/crc32.o \
o/$(MODE)/third_party/zip/ttyio.o \
$(THIRD_PARTY_ZIP_UTIL_OBJS1) \
$(THIRD_PARTY_ZIP_UTIL_OBJS2)
THIRD_PARTY_ZIP_LARGE_OBJS = \
o/$(MODE)/third_party/zip/zip.o \
o/$(MODE)/third_party/zip/zipsplit.o \
o/$(MODE)/third_party/zip/fileio.o \
o/$(MODE)/third_party/zip/fileio_.o
THIRD_PARTY_ZIP_DIRECTDEPS = \
LIBC_CALLS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_LOG \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_RAND \
LIBC_RUNTIME \
LIBC_STDIO \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_TIME \
LIBC_UNICODE \
THIRD_PARTY_BZIP2
THIRD_PARTY_ZIP_DEPS := \
$(call uniq,$(foreach x,$(THIRD_PARTY_ZIP_DIRECTDEPS),$($(x))))
o/$(MODE)/third_party/zip/zip.pkg: \
$(THIRD_PARTY_ZIP_ZIP_OBJS) \
$(foreach x,$(THIRD_PARTY_ZIP_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/third_party/zip/zip.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIP_ZIP_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/zip/zipsplit.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPSPLIT_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/zip/zipnote.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPNOTE_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/zip/zipcloak.com.dbg: \
$(THIRD_PARTY_ZIP_DEPS) \
$(THIRD_PARTY_ZIPCLOAK_OBJS) \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
o/$(MODE)/third_party/zip/crypt.o \
o/$(MODE)/third_party/zip/crypt_.o \
o/$(MODE)/third_party/zip/fileio.o \
o/$(MODE)/third_party/zip/fileio_.o \
o/$(MODE)/third_party/zip/globals.o \
o/$(MODE)/third_party/zip/timezone.o \
o/$(MODE)/third_party/zip/ttyio.o \
o/$(MODE)/third_party/zip/unix.o \
o/$(MODE)/third_party/zip/unix_.o \
o/$(MODE)/third_party/zip/util.o \
o/$(MODE)/third_party/zip/util_.o \
o/$(MODE)/third_party/zip/zbz2err.o \
o/$(MODE)/third_party/zip/zip.o \
o/$(MODE)/third_party/zip/crc32.o \
o/$(MODE)/third_party/zip/trees.o \
o/$(MODE)/third_party/zip/deflate.o \
o/$(MODE)/third_party/zip/zipcloak.o \
o/$(MODE)/third_party/zip/zipfile.o \
o/$(MODE)/third_party/zip/zipfile_.o \
o/$(MODE)/third_party/zip/zipnote.o \
o/$(MODE)/third_party/zip/zipsplit.o \
o/$(MODE)/third_party/zip/zipup.o: \
OVERRIDE_CPPFLAGS += \
-DUNIX \
-DMMAP \
-DUNICODE_SUPPORT \
-DUSE_EF_UT_TIME \
-DLARGE_FILE_SUPPORT \
-DHAVE_DIRENT_H \
-DHAVE_TERMIOS_H \
-DZIP64_SUPPORT \
-DBZIP2_SUPPORT
o/$(MODE)/third_party/zip/crypt_.o \
o/$(MODE)/third_party/zip/unix_.o \
o/$(MODE)/third_party/zip/zipfile_.o \
o/$(MODE)/third_party/zip/fileio_.o \
o/$(MODE)/third_party/zip/util_.o: \
OVERRIDE_CPPFLAGS += \
-DUTIL
o/$(MODE)/third_party/zip/zip.o \
o/$(MODE)/third_party/zip/zipsplit.o \
o/$(MODE)/third_party/zip/fileio.o \
o/$(MODE)/third_party/zip/fileio_.o: \
OVERRIDE_CPPFLAGS += \
-DSTACK_FRAME_UNLIMITED
o/$(MODE)/third_party/zip/%_.o: \
third_party/zip/%.c \
o/$(MODE)/third_party/zip/%.o
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
.PHONY: o/$(MODE)/third_party/zip
o/$(MODE)/third_party/zip: \
$(THIRD_PARTY_ZIP_BINS) \
$(THIRD_PARTY_ZIP_CHECKS)

View file

@ -22,19 +22,19 @@
#ifndef UTIL
# define UTIL
#endif
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#define DEFCPYRT /* main module: enable copyright string defines! */
#include "third_party/infozip/zip/revision.h"
#include "third_party/infozip/zip/crc32.h"
#include "third_party/infozip/zip/crypt.h"
#include "third_party/infozip/zip/ttyio.h"
#include "third_party/zip/revision.h"
#include "third_party/zip/crc32.h"
#include "third_party/zip/crypt.h"
#include "third_party/zip/ttyio.h"
#include "libc/calls/calls.h"
#include "libc/log/log.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/sysv/consts/sig.h"
#include "libc/stdio/temp.h"
#ifndef NO_STDLIB_H
# include "libc/mem/mem.h"
#include "libc/mem/mem.h"
#endif
#if CRYPT /* defined (as TRUE or FALSE) in crypt.h */

View file

@ -14,10 +14,10 @@
*/
#define __ZIPFILE_C
#include "third_party/infozip/zip/zip.h"
#include "third_party/infozip/zip/revision.h"
#include "third_party/zip/zip.h"
#include "third_party/zip/revision.h"
#ifdef UNICODE_SUPPORT
# include "third_party/infozip/zip/crc32.h"
#include "third_party/zip/crc32.h"
#endif
/* for realloc 2/6/2005 EG */
@ -33,17 +33,6 @@
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#ifdef VMS
# include "vms/vms.h"
# include "vms/vmsmunch.h"
# include "vms/vmsdefs.h"
#endif
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
/*
* XXX start of zipfile.h
*/

View file

@ -17,9 +17,9 @@
#ifndef UTIL
#define UTIL
#endif
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#define DEFCPYRT /* main module: enable copyright string defines! */
#include "third_party/infozip/zip/revision.h"
#include "third_party/zip/revision.h"
#include "libc/calls/calls.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/conv.h"

View file

@ -17,9 +17,9 @@
#ifndef UTIL
#define UTIL
#endif
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#define DEFCPYRT /* main module: enable copyright string defines! */
#include "third_party/infozip/zip/revision.h"
#include "third_party/zip/revision.h"
#include "libc/calls/calls.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/conv.h"

View file

@ -1,3 +1,4 @@
// -*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-
/* clang-format off */
/*
zipup.c - Zip 3
@ -19,7 +20,7 @@
is 8 bytes while off_t here is 4 bytes, and this makes the zlist struct
different sizes and needless to say leads to segmentation faults. Putting
zip.h first seems to fix this. 8/14/04 EG */
#include "third_party/infozip/zip/zip.h"
#include "third_party/zip/zip.h"
#include "libc/errno.h"
#include "libc/str/str.h"
#include "libc/log/log.h"
@ -30,116 +31,14 @@
#ifndef UTIL /* This module contains no code for Zip Utilities */
#include "third_party/infozip/zip/revision.h"
#include "third_party/infozip/zip/crc32.h"
#include "third_party/infozip/zip/crypt.h"
#ifdef USE_ZLIB
# include "third_party/zlib/zlib.h"
#endif
#ifdef BZIP2_SUPPORT
# ifdef BZIP2_USEBZIP2DIR
# include "bzip2/bzlib.h"
# else
# include "bzlib.h"
# endif
#endif
#ifdef OS2
# include "os2/os2zip.h"
#endif
#if defined(MMAP)
#include "third_party/zip/revision.h"
#include "third_party/zip/crc32.h"
#include "third_party/zip/crypt.h"
#include "third_party/bzip2/bzlib.h"
#include "libc/calls/calls.h"
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/mremap.h"
# ifndef PAGESIZE /* used to be SYSV, what about pagesize on SVR3 ? */
# define PAGESIZE getpagesize()
# endif
# if defined(NO_VALLOC) && !defined(valloc)
# define valloc malloc
# endif
#endif
/* Use the raw functions for MSDOS and Unix to save on buffer space.
They're not used for VMS since it doesn't work (raw is weird on VMS).
*/
#ifdef AMIGA
# include "amiga/zipup.h"
#endif /* AMIGA */
#ifdef AOSVS
# include "aosvs/zipup.h"
#endif /* AOSVS */
#ifdef ATARI
# include "atari/zipup.h"
#endif
#ifdef __BEOS__
# include "beos/zipup.h"
#endif
#ifdef __ATHEOS__
# include "atheos/zipup.h"
#endif /* __ATHEOS__ */
#ifdef __human68k__
# include "human68k/zipup.h"
#endif /* __human68k__ */
#ifdef MACOS
# include "macos/zipup.h"
#endif
#ifdef DOS
# include "msdos/zipup.h"
#endif /* DOS */
#ifdef NLM
# include "novell/zipup.h"
# include <nwfattr.h>
#endif
#ifdef OS2
# include "os2/zipup.h"
#endif /* OS2 */
#ifdef RISCOS
# include "acorn/zipup.h"
#endif
#ifdef TOPS20
# include "tops20/zipup.h"
#endif
#ifdef UNIX
# include "unix/zipup.h"
#endif
#ifdef CMS_MVS
# include "zipup.h"
#endif /* CMS_MVS */
#ifdef TANDEM
# include "zipup.h"
#endif /* TANDEM */
#ifdef VMS
# include "vms/zipup.h"
#endif /* VMS */
#ifdef QDOS
# include "qdos/zipup.h"
#endif /* QDOS */
#ifdef WIN32
# include "win32/zipup.h"
#endif
#ifdef THEOS
# include "theos/zipup.h"
#endif
#include "third_party/zip/zipup.h"
/* Local functions */
#ifndef RISCOS
@ -1771,21 +1670,21 @@ int *cmpr_method;
#if defined(MMAP) || defined(BIG_MEM)
if (remain != (ulg)-1L) {
bstrm.next_in = (Bytef *)window;
bstrm.next_in = (void *)window;
ibuf_sz = (unsigned)WSIZE;
} else
#endif /* MMAP || BIG_MEM */
{
bstrm.next_in = (char *)f_ibuf;
bstrm.next_in = f_ibuf;
}
bstrm.avail_in = file_read(bstrm.next_in, ibuf_sz);
bstrm.avail_in = file_read((char *)bstrm.next_in, ibuf_sz);
if (file_binary_final == 0) {
/* check for binary as library does not */
if (!is_text_buf(bstrm.next_in, ibuf_sz))
if (!is_text_buf((char *)bstrm.next_in, ibuf_sz))
file_binary_final = 1;
}
if (bstrm.avail_in < ibuf_sz) {
unsigned more = file_read(bstrm.next_in + bstrm.avail_in,
unsigned more = file_read((char *)(bstrm.next_in + bstrm.avail_in),
(ibuf_sz - bstrm.avail_in));
if (more == (unsigned) EOF || more == 0) {
maybe_stored = TRUE;
@ -1793,7 +1692,7 @@ int *cmpr_method;
bstrm.avail_in += more;
}
}
bstrm.next_out = (char *)f_obuf;
bstrm.next_out = (void *)f_obuf;
bstrm.avail_out = OBUF_SZ;
if (!maybe_stored) {
@ -1807,7 +1706,7 @@ int *cmpr_method;
if (zfwrite(f_obuf, 1, OBUF_SZ) != OBUF_SZ) {
ziperr(ZE_TEMP, "error writing to zipfile");
}
bstrm.next_out = (char *)f_obuf;
bstrm.next_out = f_obuf;
bstrm.avail_out = OBUF_SZ;
}
/* $TODO what about high 32-bits of total-in??? */
@ -1849,14 +1748,14 @@ int *cmpr_method;
}
#if defined(MMAP) || defined(BIG_MEM)
if (remain == (ulg)-1L)
bstrm.next_in = (char *)f_ibuf;
bstrm.next_in = f_ibuf;
#else
bstrm.next_in = (char *)f_ibuf;
#endif
bstrm.avail_in = file_read(bstrm.next_in, ibuf_sz);
bstrm.avail_in = file_read((char *)bstrm.next_in, ibuf_sz);
if (file_binary_final == 0) {
/* check for binary as library does not */
if (!is_text_buf(bstrm.next_in, ibuf_sz))
if (!is_text_buf((char *)bstrm.next_in, ibuf_sz))
file_binary_final = 1;
}
}
@ -1901,7 +1800,7 @@ int *cmpr_method;
if (zfwrite(f_obuf, 1, len_out) != len_out) {
ziperr(ZE_TEMP, "error writing to zipfile");
}
bstrm.next_out = (char *)f_obuf;
bstrm.next_out = f_obuf;
bstrm.avail_out = OBUF_SZ;
}
} while (err == BZ_FINISH_OK);

View file

@ -91,12 +91,12 @@ o/$(MODE)/tool/build/blinkenlights.com.dbg: \
o/$(MODE)/tool/build/blinkenlights.com: \
o/$(MODE)/tool/build/blinkenlights.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/build/.blinkenlights/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/build/.blinkenlights/.symtab
o/$(MODE)/tool/build/ar.com.dbg: \

View file

@ -32,7 +32,6 @@
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/kprintf.h"
#include "libc/limits.h"
#include "libc/log/color.internal.h"
#include "libc/log/log.h"
@ -101,6 +100,7 @@ FLAGS\n\
-V NUMBER specifies compiler version\n\
-C SECS set cpu limit [default 16]\n\
-L SECS set lat limit [default 90]\n\
-P PROCS set pro limit [default 1024]\n\
-M BYTES set mem limit [default 512m]\n\
-F BYTES set fsz limit [default 256m]\n\
-O BYTES set out limit [default 1m]\n\
@ -158,6 +158,7 @@ int pipefds[2];
long cpuquota;
long fszquota;
long memquota;
long proquota;
long outquota;
char *cmd;
@ -512,6 +513,12 @@ void SetMemLimit(long n) {
setrlimit(RLIMIT_AS, &rlim);
}
void SetProLimit(long n) {
struct rlimit rlim = {n, n};
if (n <= 0) return;
setrlimit(RLIMIT_NPROC, &rlim);
}
bool ArgNeedsShellQuotes(const char *s) {
if (*s) {
for (;;) {
@ -592,6 +599,7 @@ int Launch(void) {
SetCpuLimit(cpuquota);
SetFszLimit(fszquota);
SetMemLimit(memquota);
SetProLimit(proquota);
if (stdoutmustclose) dup2(pipefds[1], 1);
dup2(pipefds[1], 2);
sigprocmask(SIG_SETMASK, &savemask, 0);
@ -734,10 +742,11 @@ int main(int argc, char *argv[]) {
verbose = 4;
timeout = 90; /* secs */
cpuquota = 16; /* secs */
proquota = 1024; /* procs */
fszquota = 256 * 1000 * 1000; /* bytes */
memquota = 512 * 1024 * 1024; /* bytes */
if ((s = getenv("V"))) verbose = atoi(s);
while ((opt = getopt(argc, argv, "hnvstC:M:F:A:T:V:O:L:")) != -1) {
while ((opt = getopt(argc, argv, "hnstvA:C:F:L:M:O:P:T:V:")) != -1) {
switch (opt) {
case 'n':
exit(0);
@ -765,6 +774,9 @@ int main(int argc, char *argv[]) {
case 'V':
ccversion = atoi(optarg);
break;
case 'P':
fszquota = sizetol(optarg, 1000);
break;
case 'F':
fszquota = sizetol(optarg, 1000);
break;
@ -1049,7 +1061,7 @@ int main(int argc, char *argv[]) {
if (!startswith(cmd, "o/")) {
cachedcmd = xstrcat("o/", cmd);
} else {
cachedcmd = xstripext(cmd);
cachedcmd = xstrcat(xstripext(cmd), ".elf");
}
if (FileExistsAndIsNewerThan(cachedcmd, cmd)) {
cmd = cachedcmd;

View file

@ -103,7 +103,7 @@ ifneq ($(MODE),tiny)
ifneq ($(MODE),tinylinux)
o/$(MODE)/tool/net/redbean.com: \
o/$(MODE)/tool/net/redbean.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/net/net.mk \
tool/net/help.txt \
@ -114,7 +114,7 @@ o/$(MODE)/tool/net/redbean.com: \
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/$(MODE)/tool/net/.redbean
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com -o o/$(MODE)/tool/net/.redbean/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean/.ape \
o/$(MODE)/tool/net/.redbean/.symtab \
tool/net/help.txt \
@ -126,7 +126,7 @@ endif
o/tiny/tool/net/redbean.com: \
o/tiny/tool/net/redbean.com.dbg \
o/tiny/third_party/infozip/zip.com \
o/tiny/third_party/zip/zip.com \
tool/net/net.mk \
tool/net/tiny/help.txt \
tool/net/.init.lua \
@ -135,7 +135,7 @@ o/tiny/tool/net/redbean.com: \
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/tiny/tool/net/.redbean
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/tiny/tool/net/.redbean/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -AZIP -T$@ o/tiny/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/tiny/third_party/zip/zip.com -9qj $@ \
o/tiny/tool/net/.redbean/.ape \
tool/net/tiny/help.txt \
tool/net/.init.lua \
@ -144,7 +144,7 @@ o/tiny/tool/net/redbean.com: \
o/tinylinux/tool/net/redbean.com: \
o/tinylinux/tool/net/redbean.com.dbg \
o/tinylinux/third_party/infozip/zip.com \
o/tinylinux/third_party/zip/zip.com \
tool/net/net.mk \
tool/net/tiny/help.txt \
tool/net/.init.lua \
@ -153,7 +153,7 @@ o/tinylinux/tool/net/redbean.com: \
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/tinylinux/tool/net/.redbean
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/tinylinux/tool/net/.redbean/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -AZIP -T$@ o/tinylinux/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/tinylinux/third_party/zip/zip.com -9qj $@ \
o/tinylinux/tool/net/.redbean/.ape \
tool/net/tiny/help.txt \
tool/net/.init.lua \
@ -243,14 +243,14 @@ o/$(MODE)/tool/net/redbean-demo.com.dbg: \
o/$(MODE)/tool/net/redbean-demo.com: \
o/$(MODE)/tool/net/redbean-demo.com.dbg \
o/$(MODE)/tool/build/symtab.com \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
tool/net/help.txt
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/$(MODE)/tool/net/.redbean-demo
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean-demo/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/net/.redbean-demo/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean-demo/.ape \
o/$(MODE)/tool/net/.redbean-demo/.symtab \
tool/net/help.txt
@ -262,7 +262,7 @@ o/$(MODE)/tool/net/redbean-demo.com: \
o/$(MODE)/tool/net/redbean-static.com: \
o/$(MODE)/tool/net/redbean-static.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/net/help.txt \
tool/net/favicon.ico \
@ -272,7 +272,7 @@ o/$(MODE)/tool/net/redbean-static.com: \
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean-static/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/net/.redbean-static/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean-static/.ape \
o/$(MODE)/tool/net/.redbean-static/.symtab \
tool/net/help.txt \
@ -298,7 +298,7 @@ o/$(MODE)/tool/net/redbean-static.o: tool/net/redbean.c o/$(MODE)/tool/net/redbe
o/$(MODE)/tool/net/redbean-unsecure.com: \
o/$(MODE)/tool/net/redbean-unsecure.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/net/help.txt \
tool/net/favicon.ico \
@ -308,7 +308,7 @@ o/$(MODE)/tool/net/redbean-unsecure.com: \
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean-unsecure/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/net/.redbean-unsecure/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean-unsecure/.ape \
o/$(MODE)/tool/net/.redbean-unsecure/.symtab \
tool/net/help.txt \
@ -340,7 +340,7 @@ ifneq ($(MODE),tiny)
ifneq ($(MODE),tinylinux)
o/$(MODE)/tool/net/redbean-original.com: \
o/$(MODE)/tool/net/redbean-original.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/net/help.txt \
tool/net/favicon.ico \
@ -350,7 +350,7 @@ o/$(MODE)/tool/net/redbean-original.com: \
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean-original/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/net/.redbean-original/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean-original/.ape \
o/$(MODE)/tool/net/.redbean-original/.symtab \
tool/net/help.txt \
@ -361,14 +361,14 @@ endif
o/tiny/tool/net/redbean-original.com: \
o/tiny/tool/net/redbean-original.com.dbg \
o/tiny/third_party/infozip/zip.com \
o/tiny/third_party/zip/zip.com \
tool/net/tiny/help.txt \
tool/net/favicon.ico \
tool/net/redbean.png
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/tiny/tool/net/.redbean-original
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/tiny/tool/net/.redbean-original/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -AZIP -T$@ o/tiny/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/tiny/third_party/zip/zip.com -9qj $@ \
o/tiny/tool/net/.redbean-original/.ape \
tool/net/tiny/help.txt \
tool/net/favicon.ico \
@ -376,14 +376,14 @@ o/tiny/tool/net/redbean-original.com: \
o/tinylinux/tool/net/redbean-original.com: \
o/tinylinux/tool/net/redbean-original.com.dbg \
o/tinylinux/third_party/infozip/zip.com \
o/tinylinux/third_party/zip/zip.com \
tool/net/tiny/help.txt \
tool/net/favicon.ico \
tool/net/redbean.png
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/tinylinux/tool/net/.redbean-original
@$(COMPILE) -ADD -T$@ dd if=$@ of=o/tinylinux/tool/net/.redbean-original/.ape bs=64 count=11 conv=notrunc 2>/dev/null
@$(COMPILE) -AZIP -T$@ o/tinylinux/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/tinylinux/third_party/zip/zip.com -9qj $@ \
o/tinylinux/tool/net/.redbean-original/.ape \
tool/net/tiny/help.txt \
tool/net/favicon.ico \
@ -410,7 +410,7 @@ o/$(MODE)/tool/net/redbean-assimilate.com.dbg: \
o/$(MODE)/tool/net/redbean-assimilate.com: \
o/$(MODE)/tool/net/redbean-assimilate.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/net/net.mk \
tool/net/help.txt \
@ -420,7 +420,7 @@ o/$(MODE)/tool/net/redbean-assimilate.com: \
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/$(MODE)/tool/net/.redbean-assimilate
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com -o o/$(MODE)/tool/net/.redbean-assimilate/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/net/.redbean-assimilate/.symtab \
tool/net/help.txt \
tool/net/.init.lua \

View file

@ -49,13 +49,13 @@ o/$(MODE)/tool/plinko/%.com.dbg: \
.PRECIOUS: o/$(MODE)/tool/plinko/plinko.com
o/$(MODE)/tool/plinko/plinko.com: \
o/$(MODE)/tool/plinko/plinko.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com \
tool/plinko/plinko.mk
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -AMKDIR -T$@ mkdir -p o/$(MODE)/tool/plinko/.redbean
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com -o o/$(MODE)/tool/plinko/.plinko/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/plinko/.plinko/.symtab
$(TOOL_PLINKO_OBJS): \

View file

@ -73,12 +73,12 @@ o/$(MODE)/tool/viz/%.com.dbg: \
o/$(MODE)/tool/viz/printvideo.com: \
o/$(MODE)/tool/viz/printvideo.com.dbg \
o/$(MODE)/third_party/infozip/zip.com \
o/$(MODE)/third_party/zip/zip.com \
o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
-o o/$(MODE)/tool/viz/.printvideo/.symtab $<
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/infozip/zip.com -9qj $@ \
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
o/$(MODE)/tool/viz/.printvideo/.symtab
o/$(MODE)/tool/viz/derasterize.o: \