summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile165
-rw-r--r--unix/Packaging/pkginfo.in4
-rw-r--r--[-rwxr-xr-x]unix/Packaging/postinstall41
-rw-r--r--[-rwxr-xr-x]unix/Packaging/preinstall.in39
-rw-r--r--unix/Packaging/prototype17
-rw-r--r--[-rwxr-xr-x]unix/configure450
-rw-r--r--unix/osdep.h73
-rw-r--r--unix/unix.c395
-rw-r--r--unix/zipup.h4
9 files changed, 1010 insertions, 178 deletions
diff --git a/unix/Makefile b/unix/Makefile
index e1780a0..abd0c44 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -4,24 +4,29 @@
all:
@echo ''
@echo 'Make what? You must say what system to make Zip for--e.g.'
- @echo '"make generic". Choices: generic, generic_gcc,'
- @echo 'att6300nodir, coherent, cray_v3, cygwin, lynx, minix,'
- @echo 'os390, qnx, qnxnto, solaris, solaris_gcc'
+ @echo '"make generic".'
+ @echo 'Choices: generic, generic_gcc, att6300nodir,'
+ @echo 'coherent, cray_v3, cygwin, lynx, minix, os390,'
+ @echo 'qnx, qnxnto, solaris, solaris_gcc'
+ @echo 'Try first "make -f unix/Makefile generic" as'
+ @echo 'it should autodetect and set the proper flags.'
+ @echo 'To make the manuals use "make zipsman" after Zip is made.'
@echo 'See the files INSTALL and zip.txt for more information.'
@echo ''
list: all
-MAKE = make -f unix/Makefile
+#MAKE = make -f unix/Makefile
+MAKEF = -f unix/Makefile
SHELL = /bin/sh
LN = ln -s
-# (to use the Gnu compiler, change cc to gcc in CC)
+# (to use the GNU compiler, change cc to gcc in CC)
CC = cc
BIND = $(CC)
AS = $(CC) -c
CPP = /lib/cpp
-EXE =
+E =
# probably can change this to 'install' if you have it
INSTALL_PROGRAM = cp
@@ -35,28 +40,38 @@ MANFLAGS = 644
# target directories - where to install executables and man pages to
prefix = /usr/local
BINDIR = $(prefix)/bin
-manext=1
-MANDIR = $(prefix)/man/man$(manext)
-ZIPMANUAL = MANUAL
+MANEXT=1
+MANDIR = $(prefix)/man/man$(MANEXT)
+ZIPMANUAL = zip.txt
+ZIPMANUALcloak = zipcloak.txt
+ZIPMANUALnote = zipnote.txt
+ZIPMANUALsplit = zipsplit.txt
+ZIPMANUALs = zip.txt zipcloak.txt zipnote.txt zipsplit.txt
PKGDIR = IZzip
-VERSION = Version 2.31
+VERSION = Version 3.0
+
+# Our bzip2 directory
+IZ_OUR_BZIP2_DIR = bzip2
# flags
# CFLAGS flags for C compile
# LFLAGS1 flags after output file spec, before obj file list
# LFLAGS2 flags after obj file list (libraries, etc)
-CFLAGS = -O2 -I. -DUNIX $(LOCAL_ZIP)
+CFLAGS_NOOPT = -I. -DUNIX $(LOCAL_ZIP)
+CFLAGS = -O2 $(CFLAGS_NOOPT)
LFLAGS1 =
LFLAGS2 = -s
# object file lists
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
- unix.o crc32.o crctab.o
+ unix.o crc32.o zbz2err.o
OBJI = deflate.o trees.o
OBJA =
-OBJU = zipfile_.o fileio_.o util_.o globals.o unix_.o
+OCRCU8 =
+OCRCTB = crc32_.o
+OBJU = zipfile_.o fileio_.o util_.o globals.o unix_.o $(OCRCU8)
OBJN = zipnote.o $(OBJU)
-OBJC = zipcloak.o $(OBJU) crctab.o crypt_.o ttyio.o
+OBJC = zipcloak.o $(OBJU) $(OCRCTB) crypt_.o ttyio.o
OBJS = zipsplit.o $(OBJU)
ZIP_H = zip.h ziperr.h tailor.h unix/osdep.h
@@ -65,21 +80,22 @@ ZIP_H = zip.h ziperr.h tailor.h unix/osdep.h
.SUFFIXES:
.SUFFIXES: _.o .o .c .doc .1
.c_.o:
- rm -f $*_.c; $(LN) $< $*_.c
- $(CC) -c $(CFLAGS) -DUTIL $*_.c
- rm -f $*_.c
+ $(CC) -c $(CFLAGS) -DUTIL -o $@ $<
+
.c.o:
$(CC) -c $(CFLAGS) $<
.1.doc:
nroff -man $< | col -bx | uniq > $@
-# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUAL.
+# rules for zip, zipnote, zipcloak, zipsplit, and the Zip MANUALs.
$(OBJZ): $(ZIP_H)
$(OBJI): $(ZIP_H)
$(OBJN): $(ZIP_H)
$(OBJS): $(ZIP_H)
$(OBJC): $(ZIP_H)
+zip.o zipup.o zipfile.o fileio.o crc32.o crypt.o: crc32.h
+zipcloak.o zipfile_.o fileio_.o crc32_.o crypt_.o: crc32.h
zip.o zipup.o crypt.o ttyio.o zipcloak.o crypt_.o: crypt.h
zip.o zipup.o zipnote.o zipcloak.o zipsplit.o: revision.h
zip.o crypt.o ttyio.o zipcloak.o crypt_.o: ttyio.h
@@ -101,27 +117,43 @@ unix.o: unix/unix.c
$(CC) -c $(CFLAGS) unix/unix.c
unix_.o: unix/unix.c
- rm -f unix_.c; $(LN) unix/unix.c unix_.c
- $(CC) -c $(CFLAGS) -DUTIL unix_.c
- rm -f unix_.c
+ $(CC) -c $(CFLAGS) -DUTIL -o $@ unix/unix.c
-ZIPS = zip$(EXE) zipnote$(EXE) zipsplit$(EXE) zipcloak$(EXE)
+ZIPS = zip$E zipcloak$E zipnote$E zipsplit$E
zips: $(ZIPS)
-zipsman: $(ZIPS) $(ZIPMANUAL)
+zipsman: $(ZIPS) $(ZIPMANUALs)
-zip$(EXE): $(OBJZ) $(OBJI) $(OBJA)
- $(BIND) -o zip$(EXE) $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
-zipnote$(EXE): $(OBJN)
- $(BIND) -o zipnote$(EXE) $(LFLAGS1) $(OBJN) $(LFLAGS2)
-zipcloak$(EXE): $(OBJC)
- $(BIND) -o zipcloak$(EXE) $(LFLAGS1) $(OBJC) $(LFLAGS2)
-zipsplit$(EXE): $(OBJS)
- $(BIND) -o zipsplit$(EXE) $(LFLAGS1) $(OBJS) $(LFLAGS2)
+zip$E: $(OBJZ) $(OBJI) $(OBJA) $(LIB_BZ)
+ $(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
+zipnote$E: $(OBJN)
+ $(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
+zipcloak$E: $(OBJC) $(OCRCTB)
+ $(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
+zipsplit$E: $(OBJS)
+ $(BIND) -o zipsplit$E $(LFLAGS1) $(OBJS) $(LFLAGS2)
$(ZIPMANUAL): man/zip.1
nroff -man man/zip.1 | col -bx | uniq > $(ZIPMANUAL)
+$(ZIPMANUALcloak): man/zipcloak.1
+ nroff -man man/zipcloak.1 | col -bx | uniq > $(ZIPMANUALcloak)
+
+$(ZIPMANUALnote): man/zipnote.1
+ nroff -man man/zipnote.1 | col -bx | uniq > $(ZIPMANUALnote)
+
+$(ZIPMANUALsplit): man/zipsplit.1
+ nroff -man man/zipsplit.1 | col -bx | uniq > $(ZIPMANUALsplit)
+
+
+# bzip2 object library
+
+$(IZ_OUR_BZIP2_DIR)/libbz2.a : $(IZ_OUR_BZIP2_DIR)/Makefile
+ @echo "Building bzip2 object library..."
+ ( cd $(IZ_OUR_BZIP2_DIR); \
+ $(MAKE) CC="$(CC_BZ)" CFLAGS="$(CFLAGS_BZ)" libbz2.a )
+ @echo " bzip2 object library created."
+
# install
install: $(ZIPS)
@@ -129,15 +161,23 @@ install: $(ZIPS)
$(INSTALL_PROGRAM) $(ZIPS) $(BINDIR)
-cd $(BINDIR); $(CHMOD) $(BINFLAGS) $(ZIPS)
-$(INSTALL_D) $(MANDIR)
- $(INSTALL) man/zip.1 $(MANDIR)/zip.$(manext)
- $(CHMOD) $(MANFLAGS) $(MANDIR)/zip.$(manext)
+ $(INSTALL_PROGRAM) man/zip.1 $(MANDIR)/zip.$(MANEXT)
+ $(CHMOD) $(MANFLAGS) $(MANDIR)/zip.$(MANEXT)
+ $(INSTALL_PROGRAM) man/zipcloak.1 $(MANDIR)/zipcloak.$(MANEXT)
+ $(CHMOD) $(MANFLAGS) $(MANDIR)/zipcloak.$(MANEXT)
+ $(INSTALL_PROGRAM) man/zipnote.1 $(MANDIR)/zipnote.$(MANEXT)
+ $(CHMOD) $(MANFLAGS) $(MANDIR)/zipnote.$(MANEXT)
+ $(INSTALL_PROGRAM) man/zipsplit.1 $(MANDIR)/zipsplit.$(MANEXT)
+ $(CHMOD) $(MANFLAGS) $(MANDIR)/zipsplit.$(MANEXT)
uninstall:
-cd $(BINDIR); rm -f $(ZIPS)
- -cd $(MANDIR); rm -f zip.$(manext)
+ -cd $(MANDIR); rm -f \
+ zip.$(MANEXT) zipcloak.$(MANEXT) zipnote.$(MANEXT) zipsplit.$(MANEXT)
+
flags: unix/configure
- sh unix/configure "${CC}" "${CFLAGS}"
+ sh unix/configure "${CC}" "${CFLAGS_NOOPT}" "${IZ_BZIP2}"
# These symbols, when #defined using -D have these effects on compilation:
# ZMEM - includes C language versions of memset(), memcpy(),
@@ -151,18 +191,22 @@ flags: unix/configure
# NO_RMDIR - remove directories using a system("rmdir ...") call.
# NO_PROTO - cannot handle ANSI prototypes
# NO_CONST - cannot handle ANSI const
+# NO_LARGE_FILE_SUPPORT - do not enable Large File support even if available.
+# NO_ZIP64_SUPPORT - do not enable Zip64 archive support even if available.
+# NO_UNICODE_SUPPORT - do not enable Unicode support even if available.
+# NO_BZIP2_SUPPORT - do not compile in bzip2 code even if available.
# Generic targets:
generic: flags
- eval $(MAKE) zips `cat flags`
+ eval $(MAKE) $(MAKEF) zips `cat flags`
generic_gcc:
- $(MAKE) generic CC=gcc CPP="gcc -E"
+ $(MAKE) $(MAKEF) generic CC=gcc CPP="gcc -E"
# AT&T 6300 PLUS (don't know yet how to allocate 64K bytes):
att6300nodir:
- $(MAKE) zips LFLAGS1="-Ml -s" \
+ $(MAKE) $(MAKEF) zips LFLAGS1="-Ml -s" \
CFLAGS="-DUNIX -I. -O -Ml -DNO_RMDIR -DDYN_ALLOC -DMEDIUM_MEM \
-DWSIZE=16384 -DNO_STDLIB_H -DNO_STDDEF_H -DNO_RENAME \
-DNO_MKTIME -DNO_SIZE_T -DNO_VOID -DNO_PROTO -DNO_DIR \
@@ -171,38 +215,41 @@ att6300nodir:
# Coherent (AS definition not needed for gcc)
coherent:
- $(MAKE) zips CFLAGS="-DUNIX -I. -O -DDIRENT -DASMV" AS="as -gx" \
- OBJA=match.o
+ $(MAKE) $(MAKEF) zips CFLAGS="-DUNIX -I. -O -DDIRENT -DASMV" \
+ AS="as -gx" OBJA=match.o
# Cray Unicos 6.1, Standard C compiler 3.0 (all routines except trees.c
# may be compiled with vector3; internal compiler bug in 3.0.2.3 and
# earlier requires vector2 for trees.c)
cray_v3:
- $(MAKE) zips CC="scc" \
+ $(MAKE) $(MAKEF) zips CC="scc" \
CFLAGS="-DUNIX -I. -O -h vector2 -h scalar3 -DHAVE_DIRENT_H"
# Cygwin
cygwin:
- $(MAKE) generic CC="gcc" CPP="gcc -E" EXE=".exe"
+ $(MAKE) $(MAKEF) generic CC="gcc" CPP="gcc -E" EXE=".exe"
# LynxOS
lynx:
- $(MAKE) generic CC=gcc CPP="gcc -E" CFLAGS="$(CFLAGS) -DNO_UNDERLINE -DLynx -DLYNX LFLAGS2="$LFLAGS2 -lc_p"
+ $(MAKE) $(MAKEF) generic CC=gcc CPP="gcc -E" CFLAGS="$(CFLAGS) \
+ -DNO_UNDERLINE -DLynx -DLYNX LFLAGS2="$LFLAGS2 -lc_p"
# MINIX 1.5.10 with Bruce Evans 386 patches and gcc/GNU make
minix:
- $(MAKE) zips CFLAGS="-DUNIX -I. -O -DDIRENT -DMINIX" CC=gcc
+ $(MAKE) $(MAKEF) zips CFLAGS="-DUNIX -I. -O -DDIRENT -DMINIX" CC=gcc
chmem =262144 zip
# IBM OS/390 (formerly MVS) compiled under "OpenEdition" shell
# You can make the zip executable with IBM's make, but you will
# get errors dealing with the _.o targets for the other executables
# (zipcloak, etc). GNU make will build all the executables.
-# If you have GNU make in your path as gmake, uncomment the following:
-#MAKE = gmake -f unix/Makefile
+# If you have GNU make in your path as gmake, you can uncomment
+# the following, but it shouldn't be needed:
+#MAKE = gmake
+
os390:
- ${MAKE} zips CFLAGS="$(CF) -I. -DUNIX -DOS390 -DEBCDIC -DSYSV \
--DSYSV -DNO_PARAM_H" LFLAGS2=""
+ $(MAKE) $(MAKEF) zips CFLAGS="$(CF) -I. -DUNIX -DOS390 -DEBCDIC \
+ -DSYSV -DNO_PARAM_H" LFLAGS2=""
# QNX is "special" because out /bin/sh is ksh and it doesn't grok the
# configure script properly, generating a bad flags file. D'oh! [cjh]
@@ -212,20 +259,20 @@ os390:
# to produce x86, PowerPC (big- or little-endian) and MIPS (big-
# or little-endian) using gcc. [cjh]
qnx:
- $(MAKE) zips LN=ln CC=cc CFLAGS="-DUNIX -I. -O -DHAVE_DIRENT_H \
--DHAVE_TERMIOS_H -DNO_MKTEMP"
+ $(MAKE) $(MAKEF) zips LN=ln CC=cc CFLAGS="-DUNIX -I. -O \
+ -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -DNO_MKTEMP"
qnxnto:
@if [ "$(ARCH)" = "" ] ; then \
echo "You didn't set ARCH; I'll assume you meant ARCH=x86..." ; \
echo "" ; \
- $(MAKE) zips LN=ln CC="qcc -Vgcc_ntox86" \
+ $(MAKE) $(MAKEF) zips LN=ln CC="qcc -Vgcc_ntox86" \
CFLAGS="-g -DUNIX -I. -O -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -DNO_MKTEMP" \
LFLAGS2=-g ; \
else \
echo "Making zip for $(ARCH)..." ; \
echo "" ; \
- $(MAKE) zips LN=ln CC="qcc -Vgcc_nto$(ARCH)" \
+ $(MAKE) $(MAKEF) zips LN=ln CC="qcc -Vgcc_nto$(ARCH)" \
CFLAGS="-g -DUNIX -I. -O -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -DNO_MKTEMP" \
LFLAGS2=-g ; \
fi
@@ -266,3 +313,17 @@ clean:
rm -f *.o $(ZIPS) flags
rm -rf $(PKGDIR)
+clean_bzip2 :
+ @if test -f "$(IZ_OUR_BZIP2_DIR)/Makefile"; then \
+ ( cd $(IZ_OUR_BZIP2_DIR); make clean ); \
+ else \
+ if test -z "$(IZ_OUR_BZIP2_DIR)"; then \
+ echo "No bzip2 directory (\"IZ_OUR_BZIP2_DIR\") specified."; \
+ else \
+ echo "No bzip2 make file found: $(IZ_OUR_BZIP2_DIR)/Makefile."; \
+ fi; \
+ fi
+
+clean_exe :
+ rm -f $(ZIPS)
+#
diff --git a/unix/Packaging/pkginfo.in b/unix/Packaging/pkginfo.in
index 875e144..c31395d 100644
--- a/unix/Packaging/pkginfo.in
+++ b/unix/Packaging/pkginfo.in
@@ -2,8 +2,8 @@ PKG=IZzip
NAME=Info-ZIP Zip Utilities
CATEGORY=application
VENDOR=Info-ZIP
-EMAIL=Zip-Bugs@lists.wku.edu
-HOTLINE=Zip-Bugs@lists.wku.edu
+EMAIL=http://info-zip.org/zip-bug.html
+HOTLINE=http://info-zip.org/zip-bug.html
DESC=Copyrighted FREEWARE. See README, WHERE, and docs in pkg's doc dir.
CLASSES=none
BASEDIR=/opt/Info-ZIP
diff --git a/unix/Packaging/postinstall b/unix/Packaging/postinstall
index 030067d..086ec26 100755..100644
--- a/unix/Packaging/postinstall
+++ b/unix/Packaging/postinstall
@@ -1,22 +1,29 @@
#!/bin/sh
#
+# Info-ZIP Zip post-installation script.
+#
+# Last revised: 2007-09-29 SMS. Zip 3.0.
+#
# Post installation script (simply inform installer about PATH etc)
#
-echo " "
-echo " "
-echo "Installation is complete. Now, you should add the following"
-echo "(or equivalnet) commands to the appropriate initial user shell"
-echo "scripts (such as .profile, .login, etc) -- "
-echo " "
-echo " For korn or bourne shell:"
-echo " PATH=\${PATH}:${BASEDIR}/${PKG}/bin"
-echo " MANPATH=\${MANPATH}:${BASEDIR}/${PKG}/man"
-echo " export PATH MANPATH"
-echo " "
-echo " For C shell:"
-echo " set path=(\$path ${BASEDIR}/${PKG}/bin)"
-echo " setenv MANPATH \$MANPATH:${BASEDIR}/${PKG}/man"
-echo " "
-echo " See the files under ${BASEDIR}/${PKG}/doc for more information."
-echo " "
+echo ''
+echo 'Installation is complete. Users should adjust their environment'
+echo 'variables to include these directories:'
+echo " PATH: ${BASEDIR}/${PKG}/bin"
+echo " MANPATH: ${BASEDIR}/${PKG}/man"
+echo ''
+echo "Commands like the following may be added to a user's shell start-up"
+echo 'file (.cshrc, .login, .profile, ...) to do this:'
+echo ''
+echo ' For a Bourne-like shell:'
+echo " PATH=\"\${PATH}:${BASEDIR}/${PKG}/bin\""
+echo " MANPATH=\"\${MANPATH}:${BASEDIR}/${PKG}/man\""
+echo ' export PATH MANPATH'
+echo ''
+echo ' For a C shell:'
+echo " setenv PATH \"\${PATH}:${BASEDIR}/${PKG}/bin\""
+echo " setenv MANPATH \"\${MANPATH}:${BASEDIR}/${PKG}/man\""
+echo ''
+echo "See the files under ${BASEDIR}/${PKG}/doc for more information."
+echo ''
exit 0
diff --git a/unix/Packaging/preinstall.in b/unix/Packaging/preinstall.in
index 86c4b93..de1961b 100755..100644
--- a/unix/Packaging/preinstall.in
+++ b/unix/Packaging/preinstall.in
@@ -1,26 +1,29 @@
#!/bin/sh
-echo " "
-echo "REPORT ALL BUGS, PROBLEMS, AND ACCOLADES TO:"
-echo " "
-echo " Zip-Bugs@lists.wku.edu"
-echo " "
-echo "Checking architecture platform for .ARCH. ..."
+#
+# Info-ZIP Zip pre-installation script.
+#
+# Last revised: 2007-09-29 SMS. Zip 3.0.
+#
+# pkgadd should set a good PATH, but just in case, ...
+PATH="/sbin:/usr/bin:${PATH}"
+export PATH
+echo ''
+echo 'Please report problems to Info-ZIP using:'
+echo ''
+echo ' http://info-zip.org/zip-bug.html'
+echo ''
arch=`uname -p`
if [ "arch_${arch}" != "arch_.ARCH." ]; then
- echo " "
- echo "This product MUST be installed on a Solaris .ARCH. platform."
- echo "Your machine looks like it is a ${arch} platform."
- echo "Please install the version for the .ARCH. architecture."
- echo "Aborting the installation because of this. "
- echo " "
+ echo "This product MUST be installed on a Solaris \".ARCH.\" system."
+ echo "This system appears to have \"${arch}\" architecture, not \".ARCH.\"."
+ echo "Please install the version for the \".ARCH.\" architecture."
+ echo 'Aborting installation...'
returncode=1
- else
- echo " "
- echo "This product works on .ARCH., which you happen to have!"
- echo " "
+else
+ echo "Installing on \".ARCH.\" architecture..."
returncode=0
fi
-echo " "
-/usr/bin/sleep 4
+echo ''
+sleep 4
exit ${returncode:-1}
#
diff --git a/unix/Packaging/prototype b/unix/Packaging/prototype
index 10e48d8..002eaf6 100644
--- a/unix/Packaging/prototype
+++ b/unix/Packaging/prototype
@@ -1,22 +1,27 @@
d none $BASEDIR 0755 root bin
-d none $BASEDIR/$PKG 0755 root bin
+d none $PKG 0755 root bin
d none $PKG/doc 0755 root bin
f none $PKG/doc/BUGS=BUGS 0644 root bin
+f none $PKG/doc/CHANGES=CHANGES 0644 root bin
+f none $PKG/doc/INSTALL=INSTALL 0644 root bin
+f none $PKG/doc/LICENSE=LICENSE 0644 root bin
f none $PKG/doc/README=README 0644 root bin
f none $PKG/doc/TODO=TODO 0644 root bin
-f none $PKG/doc/WHERE=WHERE 0644 root bin
-f none $PKG/doc/CHANGES=CHANGES 0644 root bin
+f none $PKG/doc/USexport.msg=USexport.msg 0644 root bin
f none $PKG/doc/WHATSNEW=WHATSNEW 0644 root bin
-f none $PKG/doc/INSTALL=INSTALL 0644 root bin
-f none $PKG/doc/MANUAL=MANUAL 0644 root bin
+f none $PKG/doc/WHERE=WHERE 0644 root bin
+f none $PKG/doc/zip.txt=zip.txt 0644 root bin
d none $PKG/man 0755 root bin
d none $PKG/man/man1 0755 root bin
f none $PKG/man/man1/zip.1=man/zip.1 0644 root bin
+f none $PKG/man/man1/zipcloak.1=man/zipcloak.1 0644 root bin
+f none $PKG/man/man1/zipnote.1=man/zipnote.1 0644 root bin
+f none $PKG/man/man1/zipsplit.1=man/zipsplit.1 0644 root bin
d none $PKG/bin 0755 root bin
f none $PKG/bin/zip=zip 0755 root bin
+f none $PKG/bin/zipcloak=zipcloak 0755 root bin
f none $PKG/bin/zipnote=zipnote 0755 root bin
f none $PKG/bin/zipsplit=zipsplit 0755 root bin
-f none $PKG/bin/zipcloak=zipcloak 0755 root bin
i README
i pkginfo
i prototype
diff --git a/unix/configure b/unix/configure
index 35ccbb7..73ba803 100755..100644
--- a/unix/configure
+++ b/unix/configure
@@ -1,10 +1,15 @@
:
-#!/bin/sh
+#!/bin/sh -x
# The above : is necessary on some buggy systems.
# configure: Guess values for system-dependent variables
# Output the flag definitions to the file "flags".
-# Parameters: $1 = $CC, $2 = $CFLAGS
+#
+# Parameters: $1 = $CC, $2 = $CFLAGS, $3 = $IZ_BZIP2
+#
+# This file is typically called from Makefile rather than executed
+# from the command line.
+#
# To construct zip automatically using this file, type
# "make -f unix/Makefile generic".
# If this fails, then type "make list" to get a list of special targets.
@@ -12,10 +17,206 @@
trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
CC=${1-cc}
-CFLAGS=${2-"-O2 -I. -DUNIX"}
-LFLAGS1=""
+CFLAGS=${2-"-I. -DUNIX"}
+LFLAGS1=''
+LFLAGS2=''
LN="ln -s"
+CFLAGS_OPT=''
+
+# bzip2
+IZ_BZIP2=${3-}
+CFLAGS_BZ=''
+
+
+echo 'Check C compiler type (optimization options)'
+# Sun C?
+cat > conftest.c << _EOF_
+int main()
+{
+#ifndef __SUNPRO_C
+ bad code
+#endif
+ return 0;
+}
+_EOF_
+$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+if test $? -eq 0; then
+ CFLAGS_OPT='-xO3'
+ echo " Sun C ($CFLAGS_OPT)"
+else
+ # Tru64 DEC/Compaq/HP C?
+ cat > conftest.c << _EOF_
+int main()
+{
+#ifndef __DECC
+ bad code
+#endif
+ return 0;
+}
+_EOF_
+ $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+ if test $? -eq 0; then
+ CFLAGS_OPT='-O3'
+ echo " DEC C ($CFLAGS_OPT)"
+ else
+ # HP-UX HP C?
+ cat > conftest.c << _EOF_
+int main()
+{
+#ifdef __GNUC__
+ bad code
+#endif
+#ifndef __hpux
+ bad code
+#endif
+ return 0;
+}
+_EOF_
+ $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+ if test $? -eq 0; then
+ # HP-UX, not GCC. Lame bundled or real ANSI compiler?
+ CFLAGS_OPT_TRY="+O3 +Onolimit"
+ $CC $CFLAGS $CFLAGS_OPT_TRY -c conftest.c 2>&1 | \
+ grep '(Bundled)' > /dev/null
+ if test $? -ne 0; then
+ CFLAGS_OPT="$CFLAGS_OPT_TRY"
+ echo " HP-UX ANSI C ($CFLAGS_OPT)"
+ else
+ echo ' HP-UX Bundled C (no opt)'
+ fi
+ else
+ # GNU C?
+ cat > conftest.c << _EOF_
+int main()
+{
+#ifndef __GNUC__
+ bad code
+#endif
+ return 0;
+}
+_EOF_
+ $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
+ if test $? -eq 0; then
+ CFLAGS_OPT='-O3'
+ echo " GNU C ($CFLAGS_OPT)"
+ # Special Mac OS X shared library "ld" option?
+ if test ` uname -s 2> /dev/null ` = 'Darwin'; then
+ lf='-Wl,-search_paths_first'
+ $CC $CFLAGS $lf conftest.c > /dev/null 2>/dev/null
+ if test $? -eq 0; then
+ LFLAGS2="${LFLAGS2} ${lf}"
+ fi
+ rm -f conftest
+ fi
+ else
+ CFLAGS_OPT='-O'
+ echo " Other-unknown C ($CFLAGS_OPT)"
+ fi
+ fi
+ fi
+fi
+
+# optimization flags
+if test -n "${CFLAGS_OPT}"; then
+ CFLAGS="${CFLAGS} ${CFLAGS_OPT}"
+ CFLAGS_BZ="${CFLAGS_BZ} ${CFLAGS_OPT}"
+fi
+
+
+# bzip2
+
+echo "Check bzip2 support"
+CC_BZ="${CC}"
+LIB_BZ=''
+if test -n "${IZ_BZIP2}"; then
+ echo " Check for bzip2 compiled library in IZ_BZIP2 (${IZ_BZIP2})"
+ if test -f "${IZ_BZIP2}/libbz2.a"; then
+#
+# A bzip2 library built with BZ_NO_STDIO should have an
+# unresolved external, "bz_internal_error". The default,
+# full-function library will not mention it.
+#
+ nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
+ if test $? -eq 0; then
+ echo " Found bzip2 BZ_NO_STDIO library, ${IZ_BZIP2}/libbz2.a"
+ else
+ echo " Found bzip2 library, ${IZ_BZIP2}/libbz2.a,"
+ echo " but library not compiled with BZ_NO_STDIO"
+ echo " WARNING: We recommend using a bzip2 library compiled"
+ echo " with BZ_NO_STDIO defined for proper error handling"
+ echo " Please see the Zip installation instructions in bzip2/install.txt"
+ echo " Continuing anyway with standard bzip2 library..."
+ fi
+ if test -f "${IZ_BZIP2}/bzlib.h"; then
+ CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
+ LFLAGS2="${LFLAGS2} -L${IZ_BZIP2} -lbz2"
+ echo "-- Found bzip2 library - linking in bzip2"
+ else
+ echo " ${IZ_BZIP2}/bzlib.h not found"
+ echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 dir checks - no bzip2"
+ fi
+ else
+ echo " ${IZ_BZIP2}/libbz2.a not found"
+ echo "-- Since IZ_BZIP2 defined, skipping OS and bzip2 checks - no bzip2"
+ fi
+else
+ echo " Check for bzip2 in bzip2 directory"
+ IZ_BZIP2=bzip2
+ if test -f "${IZ_BZIP2}/libbz2.a"; then
+ nm ${IZ_BZIP2}/libbz2.a | grep bz_internal_error > /dev/null
+ if test $? -eq 0; then
+ echo " Found bzip2 BZ_NO_STDIO library in bzip2 directory"
+ else
+ echo " Found bzip2 library in bzip2 directory,"
+ echo " but not built with the BZ_NO_STDIO option"
+ echo " WARNING: We recommend using a bzip2 library compiled"
+ echo " with BZ_NO_STDIO defined for proper error handling"
+ echo " Please see the Zip installation instructions"
+ echo " Continuing anyway with standard bzip2 library..."
+ fi
+ fi
+ if test -f "bzip2/bzlib.h" -a -f "bzip2/libbz2.a"; then
+ CFLAGS="${CFLAGS} -I${IZ_BZIP2} -DBZIP2_SUPPORT"
+ LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
+ echo "-- Found bzip2 library - linking in bzip2"
+ else
+ if test -f "bzip2/bzlib.c" -a -f "bzip2/bzlib.h"; then
+ echo "-- No library, but found bzip2 source in bzip2 directory"
+ echo "-- Will try to build bzip2 library from source and link in"
+#
+# Arrange to build a BZ_NO_STDIO bzip2 object library using the
+# same compiler and optimization options as used for Zip, and
+# to compile and link Zip with bzip2.
+#
+ CFLAGS_BZ="${CFLAGS_BZ} -DBZ_NO_STDIO"
+ LIB_BZ="bzip2/libbz2.a"
+ CFLAGS="${CFLAGS} -Ibzip2 -DBZIP2_SUPPORT"
+ LFLAGS2="${LFLAGS2} -Lbzip2 -lbz2"
+ else
+ echo " Check if OS already has bzip2 library installed"
+ cat > conftest.c << _EOF_
+#include "bzlib.h"
+int main()
+{
+ bz_stream strm;
+ BZ2_bzCompressEnd(&strm);
+ return 0;
+}
+_EOF_
+ $CC $CFLAGS -o conftest conftest.c -lbz2 > /dev/null 2>/dev/null
+ if test $? -eq 0; then
+ echo "-- OS supports bzip2 - linking in bzip2"
+ CFLAGS="${CFLAGS} -DBZIP2_SUPPORT"
+ LFLAGS2="${LFLAGS2} -lbz2"
+ else
+ echo "-- Either bzlib.h or libbz2.a not found - no bzip2"
+ fi
+ fi
+ fi
+fi
+
+
echo Check for the C preprocessor
# on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
CPP="${CC} -E"
@@ -30,8 +231,10 @@ CPP="${CC} -E"
echo "#include <stdio.h>" > conftest.c
$CPP conftest.c >/dev/null 2>/dev/null || CPP="${CC} -E"
+
echo Check if we can use asm code
OBJA=""
+OCRCU8=""
if eval "$CPP match.S > _match.s 2>/dev/null"; then
if test ! -s _match.s || grep error < _match.s > /dev/null; then
:
@@ -47,6 +250,7 @@ if eval "$CPP match.S > _match.s 2>/dev/null"; then
if eval "$CC -c _crc_i386.s >/dev/null 2>/dev/null" && [ -f _crc_i386.o ]
then
OBJA="$OBJA crc_i386.o"
+ OCRCU8="crc_i386.o"
CFLAGS="${CFLAGS} -DASM_CRC"
fi
fi
@@ -54,6 +258,7 @@ if eval "$CPP match.S > _match.s 2>/dev/null"; then
fi
rm -f _match.s _match.o _crc_i386.s _crc_i386.o
+
# ANSI options for compilers that don't have __STDC__ defined by default
# Currently HPUX, pyramid, Dynix, AIX, OSF/1 and ultrix
@@ -69,13 +274,14 @@ int main()
_EOF_
$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
- for OPT in "-Aa -D_HPUX_SOURCE" -Xa -qlanglvl=ansi -std1 -std
+ for OPT in -Ae -Xa -qlanglvl=ansi -std1 -std
do
$CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
[ $? -eq 0 ] && CFLAGS="${CFLAGS} ${OPT}" && break
done
fi
+
echo Check for prototypes
echo "int main(int argc, char *argv[]) { return 0; }" > conftest.c
$CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
@@ -96,6 +302,7 @@ _EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_CONST"
+
echo Check for time_t
cat > conftest.c << _EOF_
#include <sys/types.h>
@@ -109,6 +316,7 @@ _EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_TIME_T"
+
echo Check for size_t
cat > conftest.c << _EOF_
#include <sys/types.h>
@@ -121,6 +329,167 @@ _EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_SIZE_T"
+
+echo Check for off_t
+cat > conftest.c << _EOF_
+#include <sys/types.h>
+int main()
+{
+ off_t s;
+ return 0;
+}
+_EOF_
+$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_OFF_T"
+
+
+echo Check size of UIDs and GIDs
+echo "(Now zip stores variable size UIDs/GIDs using a new extra field. This"
+echo " tests if this OS uses 16-bit UIDs/GIDs and so if the old 16-bit storage"
+echo " should also be used for backward compatibility.)"
+# Added 2008-04-15 CS
+cat > conftest.c << _EOF_
+# define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
+# define _LARGEFILE64_SOURCE
+# define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
+# define _LARGE_FILES /* some OSes need this for 64-bit off_t */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+int main()
+{
+ struct stat s;
+
+ printf(" s.st_uid is %u bytes\n", sizeof(s.st_uid));
+ printf(" s.st_gid is %u bytes\n", sizeof(s.st_gid));
+
+ /* see if have 16-bit UID */
+ if (sizeof(s.st_uid) != 2) {
+ return 1;
+ }
+ /* see if have 16-bit GID */
+ if (sizeof(s.st_gid) != 2) {
+ return 2;
+ }
+ return 3;
+}
+_EOF_
+# compile it
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo -- UID/GID test failed on compile - disabling old 16-bit UID/GID support
+ CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
+else
+# run it
+ ./conftest
+ r=$?
+ if [ $r -eq 1 ]; then
+ echo -- UID not 2 bytes - disabling old 16-bit UID/GID support
+ CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
+ elif [ $r -eq 2 ]; then
+ echo -- GID not 2 bytes - disabling old 16-bit UID/GID support
+ CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
+ elif [ $r -eq 3 ]; then
+ echo -- 16-bit UIDs and GIDs - keeping old 16-bit UID/GID support
+ else
+ echo -- test failed - conftest returned $r - disabling old 16-bit UID/GID support
+ CFLAGS="${CFLAGS} -DUIDGID_NOT_16BIT"
+ fi
+fi
+
+
+# Now we set the 64-bit file environment and check the size of off_t
+# Added 11/4/2003 EG
+# Revised 8/12/2004 EG
+
+echo Check for Large File Support
+cat > conftest.c << _EOF_
+# define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
+# define _LARGEFILE64_SOURCE
+# define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
+# define _LARGE_FILES /* some OSes need this for 64-bit off_t */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+int main()
+{
+ off_t offset;
+ struct stat s;
+ /* see if have 64-bit off_t */
+ if (sizeof(offset) < 8)
+ return 1;
+ printf(" off_t is %d bytes\n", sizeof(off_t));
+ /* see if have 64-bit stat */
+ if (sizeof(s.st_size) < 8) {
+ printf(" s.st_size is %d bytes\n", sizeof(s.st_size));
+ return 2;
+ }
+ return 3;
+}
+_EOF_
+# compile it
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo -- no Large File Support
+else
+# run it
+ ./conftest
+ r=$?
+ if [ $r -eq 1 ]; then
+ echo -- no Large File Support - no 64-bit off_t
+ elif [ $r -eq 2 ]; then
+ echo -- no Large File Support - no 64-bit stat
+ elif [ $r -eq 3 ]; then
+ echo -- yes we have Large File Support!
+ CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
+ else
+ echo -- no Large File Support - conftest returned $r
+ fi
+fi
+
+
+# Check for wide char for Unicode support
+# Added 11/24/2005 EG
+
+echo Check for wide char support
+cat > conftest.c << _EOF_
+#include <stdlib.h>
+#include <stdio.h>
+int main()
+{
+ int wsize;
+ wchar_t *wide_string;
+
+ if ((wide_string = (wchar_t *)malloc(4 * sizeof(wchar_t))) == NULL) {
+ return 0;
+ }
+ /* get wide string */
+ wsize = mbstowcs(wide_string, "foo", 3);
+ wide_string[wsize] = (wchar_t) NULL;
+ return 1;
+}
+_EOF_
+# compile it
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+# OCRCU8 is used by all utilities if Unicode is enabled
+# OCRCTB is only used by zipcloak
+if [ $? -ne 0 ]; then
+ echo -- no Unicode support
+ OCRCU8=""
+ OCRCTB="crc32_.o"
+else
+# have wide char support
+ echo -- have wchar_t - enabling Unicode support
+ CFLAGS="${CFLAGS} -DUNICODE_SUPPORT"
+ OCRCU8="crc32_.o ${OCRCU8}"
+ OCRCTB=""
+fi
+
+
+# from configure 2.4i (Onno) 12/5/04
+
echo Check for gcc no-builtin flag
# -fno-builtin since version 2
cat > conftest.c << _EOF_
@@ -136,8 +505,10 @@ _EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -eq 0 ] && BFLAG="-fno-builtin"
+
# Check for missing functions
# add NO_'function_name' to flags if missing
+
for func in rmdir strchr strrchr rename mktemp mktime mkstemp
do
echo Check for $func
@@ -146,11 +517,30 @@ do
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
done
+
echo Check for memset
echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
$CC -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
+
+echo Check for memmove
+cat > conftest.c << _EOF_
+#include <string.h>
+int main() { int a; int b = 0; memmove( &a, &b, sizeof( a)); return a; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_MEMMOVE"
+
+
+echo Check for strerror
+cat > conftest.c << _EOF_
+#include <string.h>
+int main() { strerror( 0); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNEED_STRERROR"
+
echo Check for errno declaration
cat > conftest.c << _EOF_
#include <errno.h>
@@ -163,6 +553,7 @@ _EOF_
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO"
+
echo Check for directory libraries
cat > conftest.c << _EOF_
int main() { return closedir(opendir(".")); }
@@ -183,7 +574,9 @@ if [ $? -ne 0 ]; then
fi
fi
+
# Dynix/ptx 1.3 needed this
+
echo Check for readlink
echo "int main(){ return readlink(); }" > conftest.c
$CC -o conftest conftest.c >/dev/null 2>/dev/null
@@ -192,6 +585,7 @@ if [ $? -ne 0 ]; then
[ $? -eq 0 ] && LFLAGS2="${LFLAGS2} -lseq"
fi
+
echo Check for directory include file
OPT=""
for inc in dirent.h sys/ndir.h ndir.h sys/dir.h
@@ -202,7 +596,8 @@ do
done
CFLAGS="${CFLAGS} ${OPT}"
-echo Check for non existent include files
+
+echo Check for nonexistent include files
for inc in stdlib.h stddef.h unistd.h fcntl.h string.h
do
echo "#include <$inc>" > conftest.c
@@ -210,7 +605,8 @@ do
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
done
-echo Check for terminal I/O include file
+
+echo Check for term I/O include file
OPT=""
for inc in termios.h termio.h sgtty.h
do
@@ -220,7 +616,9 @@ do
done
CFLAGS="${CFLAGS} ${OPT}"
+
# needed for AIX (and others ?) when mmap is used
+
echo Check for valloc
cat > conftest.c << _EOF_
main()
@@ -230,23 +628,9 @@ main()
#endif
}
_EOF_
-$CC ${CFLAGS} conftest.c > /dev/null 2>/dev/null
+$CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC"
-echo Check for 64bit fseek
-for func in fseeko fseek64
-do
-cat > conftest.c << _EOF_
-#include <stdio.h>
-main()
-{
-$func(stdin, 0, 0);
-}
-_EOF_
-$CC ${CFLAGS} conftest.c > /dev/null 2>/dev/null
-[ $? -eq 0 ] && OPT="-DHAVE_`echo $func | tr '[a-z]' '[A-Z]'`" && break
-done
-CFLAGS="${CFLAGS} ${OPT}"
echo Check for /usr/local/bin and /usr/local/man
BINDIR=$HOME/bin
@@ -257,6 +641,7 @@ MANDIR=manl
[ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
[ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1
+
echo Check for OS-specific flags
if [ -f /usr/bin/hostinfo ]; then
if /usr/bin/hostinfo | grep NeXT > /dev/null; then
@@ -283,19 +668,28 @@ else
$CC ${CFLAGS} -Olimit 1000 -o conftest conftest.c >/dev/null 2>/dev/null
[ $? -eq 0 ] && CFLAGS="${CFLAGS} -Olimit 1000"
;;
- HP-UX)
- echo Check for +Onolimit option
- $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
- [ $? -eq 0 ] && CFLAGS="${CFLAGS} +Onolimit"
- ;;
+### HP-UX)
+### echo Check for +Onolimit option
+### $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
+### [ $? -eq 0 ] && CFLAGS="${CFLAGS} +Onolimit"
+### ;;
+### SunOS)
+### CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
+### ;;
esac
fi
+
echo Check for symbolic links
ln -s /dev/null null > /dev/null 2>/dev/null || LN=ln
+
rm -f a.out conftest.c conftest.o conftest null
echo CC=\"${CC}\" CFLAGS=\"${CFLAGS}\" CPP=\"${CPP}\" OBJA=\"${OBJA}\" \
+ OCRCU8=\"${OCRCU8}\" OCRCTB=\"${OCRCTB}\" \
BINDIR=${BINDIR} MANDIR=${MANDIR} LFLAGS1=\"${LFLAGS1}\" \
- LFLAGS2=\"${LFLAGS2}\" LN=\"${LN}\" > flags
+ LFLAGS2=\"${LFLAGS2}\" LN=\"${LN}\" \
+ CC_BZ=\"${CC_BZ}\" CFLAGS_BZ=\"${CFLAGS_BZ}\" \
+ IZ_BZIP2=\"${IZ_BZIP2}\" LIB_BZ=\"${LIB_BZ}\" > flags
+
diff --git a/unix/osdep.h b/unix/osdep.h
index bfb5d4d..10f8ee9 100644
--- a/unix/osdep.h
+++ b/unix/osdep.h
@@ -1,30 +1,77 @@
/*
+ unix/osdep.h - Zip 3
+
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
- See the accompanying file LICENSE, version 2004-May-22 or later
+ See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/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 */
+
+ /* The following Large File Summit (LFS) defines turn on large file support on
+ Linux (probably 2.4 or later kernel) and many other unixen */
+
+# define _LARGEFILE_SOURCE /* some OSes need this for fseeko */
+# define _LARGEFILE64_SOURCE
+# define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */
+# define _LARGE_FILES /* some OSes need this for 64-bit off_t */
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
+/* printf format size prefix for zoff_t values */
+#ifdef LARGE_FILE_SUPPORT
+# define ZOFF_T_FORMAT_SIZE_PREFIX "ll"
+#else
+# define ZOFF_T_FORMAT_SIZE_PREFIX "l"
+#endif
+
+#ifdef NO_OFF_T
+ typedef long zoff_t;
+ typedef unsigned long uzoff_t;
+#else
+ typedef off_t zoff_t;
+# if defined(LARGE_FILE_SUPPORT) && !(defined(__alpha) && defined(__osf__))
+ typedef unsigned long long uzoff_t;
+# else
+ typedef unsigned long uzoff_t;
+# endif
+#endif
+ typedef struct stat z_stat;
-#ifdef __CYGWIN__
-/* File operations:
- * use "b" for binary;
- * use "S" for sequential access on NT to prevent the NT file cache
- * eating up memory with large .zip files.
- */
-# define FOPR "rb"
-# define FOPM "r+b"
-# define FOPW "wbS"
+/* Automatically set ZIP64_SUPPORT if LFS */
-/* Cygwin is not Win32. */
-# undef WIN32
+#ifdef LARGE_FILE_SUPPORT
+# ifndef NO_ZIP64_SUPPORT
+# ifndef ZIP64_SUPPORT
+# define ZIP64_SUPPORT
+# endif
+# else
+# ifdef ZIP64_SUPPORT
+# undef ZIP64_SUPPORT
+# endif
+# endif
+#endif
-#endif /* ?__CYGWIN__ */
+
+/* Process files in binary mode */
+#if defined(__DJGPP__) || defined(__CYGWIN__)
+# define FOPR "rb"
+# define FOPM "r+b"
+# define FOPW "wb"
+#endif
/* Enable the "UT" extra field (time info) */
diff --git a/unix/unix.c b/unix/unix.c
index 024b735..f4d655d 100644
--- a/unix/unix.c
+++ b/unix/unix.c
@@ -1,9 +1,11 @@
/*
- Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
+ unix/unix.c - Zip 3
- See the accompanying file LICENSE, version 2004-May-22 or later
+ Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
+
+ See the accompanying file LICENSE, version 2007-Mar-4 or later
(the contents of which are also included in zip.h) for terms of use.
- If, for some reason, both of these files are missing, the Info-ZIP license
+ If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
#include "zip.h"
@@ -113,7 +115,7 @@ int caseflag; /* true to force case-sensitive match */
char *e; /* pointer to name from readd() */
int m; /* matched flag */
char *p; /* path for recursion */
- struct stat s; /* result of stat() */
+ z_stat s; /* result of stat() */
struct zlist far *z; /* steps through zfiles list */
if (strcmp(n, "-") == 0) /* if compressing stdin */
@@ -200,6 +202,24 @@ int caseflag; /* true to force case-sensitive match */
}
free((zvoid *)p);
} /* (s.st_mode & S_IFDIR) */
+#ifdef OS390
+ else if (S_ISFIFO(s.st_mode))
+#else
+ else if ((s.st_mode & S_IFIFO) == S_IFIFO)
+#endif
+ {
+ if (allow_fifo) {
+ /* FIFO (Named Pipe) - handle as normal file */
+ /* add or remove name of FIFO */
+ /* zip will stop if FIFO is open and wait for pipe to be fed and closed */
+ if (noisy) zipwarn("Reading FIFO (Named Pipe): ", n);
+ if ((m = newname(n, 0, caseflag)) != ZE_OK)
+ return m;
+ } else {
+ zipwarn("ignoring FIFO (Named Pipe) - use -FI to read: ", n);
+ return ZE_OK;
+ }
+ } /* S_IFIFO */
else
zipwarn("ignoring special file: ", n);
return ZE_OK;
@@ -216,7 +236,7 @@ int *pdosflag; /* output: force MSDOS file attributes? */
char *t = NULL; /* shortened name */
int dosflag;
- dosflag = dosify; /* default for non-DOS and non-OS/2 */
+ dosflag = dosify; /* default for non-DOS and non-OS/2 */
/* Find starting point in name before doing malloc */
/* Strip "//host/share/" part of a UNC name */
@@ -247,18 +267,18 @@ int *pdosflag; /* output: force MSDOS file attributes? */
return NULL;
strcpy(n, t);
- if (isdir == 42) return n; /* avoid warning on unused variable */
-
if (dosify)
msname(n);
#ifdef EBCDIC
- strtoasc(n, n); /* here because msname() needs native coding */
+ strtoasc(n, n); /* here because msname() needs native coding */
#endif
/* Returned malloc'ed name */
if (pdosflag)
*pdosflag = dosflag;
+
+ if (isdir) return n; /* avoid warning on unused variable */
return n;
}
@@ -307,7 +327,7 @@ ulg d; /* dos-style time to change it to */
ulg filetime(f, a, n, t)
char *f; /* name of file to get info on */
ulg *a; /* return value: file attributes */
- long *n; /* return value: file size */
+ zoff_t *n; /* return value: file size */
iztimes *t; /* return value: access, modific. and creation times */
/* If file *f does not exist, return 0. Else, return the file's last
modified date and time as an MSDOS date and time. The date and
@@ -321,7 +341,7 @@ ulg filetime(f, a, n, t)
If f is "-", use standard input as the file. If f is a device, return
a file size of -1 */
{
- struct stat s; /* results of stat() */
+ z_stat s; /* results of stat() */
/* converted to pointer from using FNMAX - 11/8/04 EG */
char *name;
int len = strlen(f);
@@ -343,7 +363,7 @@ ulg filetime(f, a, n, t)
name[len - 1] = '\0';
/* not all systems allow stat'ing a file with / appended */
if (strcmp(f, "-") == 0) {
- if (fstat(fileno(stdin), &s) != 0) {
+ if (zfstat(fileno(stdin), &s) != 0) {
free(name);
error("fstat(stdin)");
}
@@ -409,20 +429,146 @@ ulg filetime(f, a, n, t)
t->mtime = s.st_mtime;
t->ctime = t->mtime; /* best guess, (s.st_ctime: last status change!!) */
}
-
return unix2dostime(&s.st_mtime);
}
#ifndef QLZIP /* QLZIP Unix2QDOS cross-Zip supplies an extended variant */
+int set_new_unix_extra_field(z, s)
+ struct zlist far *z;
+ z_stat *s;
+ /* New unix extra field.
+ Currently only UIDs and GIDs are stored. */
+{
+ int uid_size;
+ int gid_size;
+ int ef_data_size;
+ char *extra;
+ char *cextra;
+ ulg id;
+ int b;
+
+ uid_size = sizeof(s->st_uid);
+ gid_size = sizeof(s->st_gid);
+
+/* New extra field
+ tag (2 bytes)
+ size (2 bytes)
+ version (1 byte)
+ uid_size (1 byte - size in bytes)
+ uid (variable)
+ gid_size (1 byte - size in bytes)
+ gid (variable)
+ */
+
+ ef_data_size = 1 + 1 + uid_size + 1 + gid_size;
+
+ if ((extra = (char *)malloc(z->ext + 4 + ef_data_size)) == NULL)
+ return ZE_MEM;
+ if ((cextra = (char *)malloc(z->ext + 4 + ef_data_size)) == NULL)
+ return ZE_MEM;
+
+ if (z->ext)
+ memcpy(extra, z->extra, z->ext);
+ if (z->cext)
+ memcpy(cextra, z->cextra, z->cext);
+
+ free(z->extra);
+ z->extra = extra;
+ free(z->cextra);
+ z->cextra = cextra;
+
+ z->extra[z->ext + 0] = 'u';
+ z->extra[z->ext + 1] = 'x';
+ z->extra[z->ext + 2] = (char)ef_data_size; /* length of data part */
+ z->extra[z->ext + 3] = 0;
+ z->extra[z->ext + 4] = 1; /* version */
+
+ /* UID */
+ z->extra[z->ext + 5] = (char)(uid_size); /* uid size in bytes */
+ b = 6;
+ id = (ulg)(s->st_uid);
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (uid_size > 1) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (uid_size > 2) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (uid_size == 8) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ }
+ }
+ }
+
+ /* GID */
+ b++;
+ z->extra[z->ext + b] = (char)(gid_size); /* gid size in bytes */
+ b++;
+ id = (ulg)(s->st_gid);
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (gid_size > 1) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (gid_size > 2) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ if (gid_size == 8) {
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ b++;
+ id = id >> 8;
+ z->extra[z->ext + b] = (char)(id & 0xFF);
+ }
+ }
+ }
+
+ /* copy local extra field to central directory extra field */
+ memcpy((z->cextra) + z->cext, (z->extra) + z->ext, 4 + ef_data_size);
+
+ z->ext = z->ext + 4 + ef_data_size;
+ z->cext = z->cext + 4 + ef_data_size;
+
+ return ZE_OK;
+}
+
+
int set_extra_field(z, z_utim)
struct zlist far *z;
iztimes *z_utim;
/* store full data in local header but just modification time stamp info
in central header */
{
- struct stat s;
+ z_stat s;
char *name;
int len = strlen(z->name);
@@ -444,10 +590,33 @@ int set_extra_field(z, z_utim)
#define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(2))
#define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1))
-#define EB_L_UX2_SIZE (EB_HEADSIZE + EB_UX2_MINLEN)
-#define EB_C_UX2_SIZE EB_HEADSIZE
-#define EF_L_UNIX_SIZE (EB_L_UT_SIZE + EB_L_UX2_SIZE)
-#define EF_C_UNIX_SIZE (EB_C_UT_SIZE + EB_C_UX2_SIZE)
+
+/* The flag UIDGID_NOT_16BIT should be set by the pre-compile configuration
+ script when it detects st_uid or st_gid sizes differing from 16-bit.
+ */
+#ifndef UIDGID_NOT_16BIT
+ /* The following "second-level" check for st_uid and st_gid members being
+ 16-bit wide is only added as a safety precaution in case the "first-level"
+ check failed to define the UIDGID_NOT_16BIT symbol.
+ The first-level check should have been implemented in the automatic
+ compile configuration process.
+ */
+# ifdef UIDGID_ARE_16B
+# undef UIDGID_ARE_16B
+# endif
+ /* The following expression is a compile-time constant and should (hopefully)
+ get optimized away by any sufficiently intelligent compiler!
+ */
+# define UIDGID_ARE_16B (sizeof(s.st_uid) == 2 && sizeof(s.st_gid) == 2)
+
+# define EB_L_UX2_SIZE (EB_HEADSIZE + EB_UX2_MINLEN)
+# define EB_C_UX2_SIZE EB_HEADSIZE
+# define EF_L_UNIX_SIZE (EB_L_UT_SIZE + (UIDGID_ARE_16B ? EB_L_UX2_SIZE : 0))
+# define EF_C_UNIX_SIZE (EB_C_UT_SIZE + (UIDGID_ARE_16B ? EB_C_UX2_SIZE : 0))
+#else
+# define EF_L_UNIX_SIZE EB_L_UT_SIZE
+# define EF_C_UNIX_SIZE EB_C_UT_SIZE
+#endif /* !UIDGID_NOT_16BIT */
if ((z->extra = (char *)malloc(EF_L_UNIX_SIZE)) == NULL)
return ZE_MEM;
@@ -467,20 +636,33 @@ int set_extra_field(z, z_utim)
z->extra[10] = (char)(s.st_atime >> 8);
z->extra[11] = (char)(s.st_atime >> 16);
z->extra[12] = (char)(s.st_atime >> 24);
- z->extra[13] = 'U';
- z->extra[14] = 'x';
- z->extra[15] = (char)EB_UX2_MINLEN; /* length of data part of local e.f. */
- z->extra[16] = 0;
- z->extra[17] = (char)(s.st_uid);
- z->extra[18] = (char)(s.st_uid >> 8);
- z->extra[19] = (char)(s.st_gid);
- z->extra[20] = (char)(s.st_gid >> 8);
+
+#ifndef UIDGID_NOT_16BIT
+ /* Only store the UID and GID in the old Ux extra field if the runtime
+ system provides them in 16-bit wide variables. */
+ if (UIDGID_ARE_16B) {
+ z->extra[13] = 'U';
+ z->extra[14] = 'x';
+ z->extra[15] = (char)EB_UX2_MINLEN; /* length of data part of local e.f. */
+ z->extra[16] = 0;
+ z->extra[17] = (char)(s.st_uid);
+ z->extra[18] = (char)(s.st_uid >> 8);
+ z->extra[19] = (char)(s.st_gid);
+ z->extra[20] = (char)(s.st_gid >> 8);
+ }
+#endif /* !UIDGID_NOT_16BIT */
+
z->ext = EF_L_UNIX_SIZE;
memcpy(z->cextra, z->extra, EB_C_UT_SIZE);
z->cextra[EB_LEN] = (char)EB_UT_LEN(1);
- memcpy(z->cextra+EB_C_UT_SIZE, z->extra+EB_L_UT_SIZE, EB_C_UX2_SIZE);
- z->cextra[EB_LEN+EB_C_UT_SIZE] = 0;
+#ifndef UIDGID_NOT_16BIT
+ if (UIDGID_ARE_16B) {
+ /* Copy header of Ux extra field from local to central */
+ memcpy(z->cextra+EB_C_UT_SIZE, z->extra+EB_L_UT_SIZE, EB_C_UX2_SIZE);
+ z->cextra[EB_LEN+EB_C_UT_SIZE] = 0;
+ }
+#endif
z->cext = EF_C_UNIX_SIZE;
#if 0 /* UID/GID presence is now signaled by central EF_IZUNIX2 field ! */
@@ -494,6 +676,10 @@ int set_extra_field(z, z_utim)
*/
z->atx |= 0x4000;
#endif /* never */
+
+ /* new unix extra field */
+ set_new_unix_extra_field(z, &s);
+
return ZE_OK;
}
@@ -548,8 +734,21 @@ void version_local()
char compiler_name[80];
# endif
#else
-# if ((defined(CRAY) || defined(cray)) && defined(_RELEASE))
+# if (defined( __SUNPRO_C))
+ char compiler_name[33];
+# else
+# if (defined( __HP_cc) || defined( __IBMC__))
+ char compiler_name[33];
+# else
+# if (defined( __DECC_VER))
+ char compiler_name[33];
+ int compiler_typ;
+# else
+# if ((defined(CRAY) || defined(cray)) && defined(_RELEASE))
char compiler_name[40];
+# endif
+# endif
+# endif
# endif
#endif
@@ -573,21 +772,55 @@ void version_local()
#ifdef __GNUC__
# ifdef NX_CURRENT_COMPILER_RELEASE
sprintf(compiler_name, "NeXT DevKit %d.%02d (gcc " __VERSION__ ")",
- NX_CURRENT_COMPILER_RELEASE/100, NX_CURRENT_COMPILER_RELEASE%100);
+ NX_CURRENT_COMPILER_RELEASE/100, NX_CURRENT_COMPILER_RELEASE%100);
# define COMPILER_NAME compiler_name
# else
# define COMPILER_NAME "gcc " __VERSION__
# endif
#else /* !__GNUC__ */
-# if ((defined(CRAY) || defined(cray)) && defined(_RELEASE))
- sprintf(compiler_name, "cc version %d", _RELEASE);
+# if defined(__SUNPRO_C)
+ sprintf( compiler_name, "Sun C version %x", __SUNPRO_C);
# define COMPILER_NAME compiler_name
# else
-# ifdef __VERSION__
-# define COMPILER_NAME "cc " __VERSION__
-# else
-# define COMPILER_NAME "cc "
-# endif
+# if (defined( __HP_cc))
+ if ((__HP_cc% 100) == 0)
+ {
+ sprintf( compiler_name, "HP C version A.%02d.%02d",
+ (__HP_cc/ 10000), ((__HP_cc% 10000)/ 100));
+ }
+ else
+ {
+ sprintf( compiler_name, "HP C version A.%02d.%02d.%02d",
+ (__HP_cc/ 10000), ((__HP_cc% 10000)/ 100), (__HP_cc% 100));
+ }
+# define COMPILER_NAME compiler_name
+# else
+# if (defined( __DECC_VER))
+ sprintf( compiler_name, "DEC C version %c%d.%d-%03d",
+ ((compiler_typ = (__DECC_VER / 10000) % 10) == 6 ? 'T' :
+ (compiler_typ == 8 ? 'S' : 'V')),
+ __DECC_VER / 10000000,
+ (__DECC_VER % 10000000) / 100000, __DECC_VER % 1000);
+# define COMPILER_NAME compiler_name
+# else
+# if ((defined(CRAY) || defined(cray)) && defined(_RELEASE))
+ sprintf(compiler_name, "cc version %d", _RELEASE);
+# define COMPILER_NAME compiler_name
+# else
+# ifdef __IBMC__
+ sprintf( compiler_name, "IBM C version %d.%d.%d",
+ (__IBMC__/ 100), ((__IBMC__/ 10)% 10), (__IBMC__% 10));
+# define COMPILER_NAME compiler_name
+# else
+# ifdef __VERSION__
+# define COMPILER_NAME "cc " __VERSION__
+# else
+# define COMPILER_NAME "cc "
+# endif
+# endif
+# endif
+# endif
+# endif
# endif
#endif /* ?__GNUC__ */
@@ -599,9 +832,9 @@ void version_local()
#ifdef sun
# ifdef sparc
# ifdef __SVR4
-# define OS_NAME "Sun Sparc/Solaris"
+# define OS_NAME "Sun SPARC/Solaris"
# else /* may or may not be SunOS */
-# define OS_NAME "Sun Sparc"
+# define OS_NAME "Sun SPARC"
# endif
# else
# if defined(sun386) || defined(i386)
@@ -616,7 +849,7 @@ void version_local()
# endif
#else
#ifdef __hpux
-# define OS_NAME "HP/UX"
+# define OS_NAME "HP-UX"
#else
#ifdef __osf__
# define OS_NAME "DEC OSF/1"
@@ -742,7 +975,19 @@ void version_local()
# define OS_NAME "QNX Neutrino"
#else
#ifdef __APPLE__
-# define OS_NAME "Mac OS X"
+# ifdef __i386__
+# define OS_NAME "Mac OS X Intel"
+# else /* __i386__ */
+# ifdef __ppc__
+# define OS_NAME "Mac OS X PowerPC"
+# else /* __ppc__ */
+# ifdef __ppc64__
+# define OS_NAME "Mac OS X PowerPC64"
+# else /* __ppc64__ */
+# define OS_NAME "Mac OS X"
+# endif /* __ppc64__ */
+# endif /* __ppc__ */
+# endif /* __i386__ */
#else
# define OS_NAME "Unknown"
#endif /* Apple */
@@ -769,7 +1014,7 @@ void version_local()
#endif /* RT/AIX */
#endif /* AIX */
#endif /* OSF/1 */
-#endif /* HP/UX */
+#endif /* HP-UX */
#endif /* Sun */
#endif /* SGI */
@@ -785,3 +1030,71 @@ void version_local()
COMPILER_NAME, OS_NAME, COMPILE_DATE);
} /* end function version_local() */
+
+
+/* 2006-03-23 SMS.
+ * Emergency replacement for strerror(). (Useful on SunOS 4.*.)
+ * Enable by specifying "LOCAL_UNZIP=-DNEED_STRERROR=1" on the "make"
+ * command line.
+ */
+
+#ifdef NEED_STRERROR
+
+char *strerror( err)
+ int err;
+{
+ extern char *sys_errlist[];
+ extern int sys_nerr;
+
+ static char no_msg[ 64];
+
+ if ((err >= 0) && (err < sys_nerr))
+ {
+ return sys_errlist[ err];
+ }
+ else
+ {
+ sprintf( no_msg, "(no message, code = %d.)", err);
+ return no_msg;
+ }
+}
+
+#endif /* def NEED_STRERROR */
+
+
+/* 2006-03-23 SMS.
+ * Emergency replacement for memmove(). (Useful on SunOS 4.*.)
+ * Enable by specifying "LOCAL_UNZIP=-DNEED_MEMMOVE=1" on the "make"
+ * command line.
+ */
+
+#ifdef NEED_MEMMOVE
+
+/* memmove.c -- copy memory.
+ Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
+ In the public domain.
+ By David MacKenzie <djm@gnu.ai.mit.edu>.
+ Adjusted by SMS.
+*/
+
+void *memmove(dest0, source0, length)
+ void *dest0;
+ void const *source0;
+ size_t length;
+{
+ char *dest = dest0;
+ char const *source = source0;
+ if (source < dest)
+ /* Moving from low mem to hi mem; start at end. */
+ for (source += length, dest += length; length; --length)
+ *--dest = *--source;
+ else if (source != dest)
+ {
+ /* Moving from hi mem to low mem; start at beginning. */
+ for (; length; --length)
+ *dest++ = *source++;
+ }
+ return dest0;
+}
+
+#endif /* def NEED_MEMMOVE */
diff --git a/unix/zipup.h b/unix/zipup.h
index fbec842..0fc3f89 100644
--- a/unix/zipup.h
+++ b/unix/zipup.h
@@ -1,7 +1,9 @@
/*
+ unix/zipup.h - Zip 3
+
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
- See the accompanying file LICENSE, version 2004-May-22 or later
+ See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html