mirror of
https://frontier.innolan.net/rainlance/unzip.git
synced 2026-05-03 07:18:08 +00:00
Initial commit
This commit is contained in:
14
unix/Contents
Normal file
14
unix/Contents
Normal file
@@ -0,0 +1,14 @@
|
||||
Contents of the "unix" subdirectory for UnZip 6.0 and later:
|
||||
|
||||
Contents this file
|
||||
Makefile makefile for UnZip for various architectures and OS's
|
||||
configure automatic build configuration script
|
||||
unix.c Unix-specific support routines
|
||||
unxcfg.h Unix-specific configuration settings
|
||||
zipgrep script to scan zip archive entries for lines matching a pattern
|
||||
Packaging/ subdirectory containing SysV.4 (e.g., Solaris 2.x) package info
|
||||
|
||||
Type "make" or "make help" to get general compile instructions (beyond
|
||||
those in the INSTALL file), or "make list" for a list of makefile targets.
|
||||
Note that there are some MS-DOS and cross-compilation targets thrown in
|
||||
just to make things more exciting.
|
||||
1026
unix/Makefile
Normal file
1026
unix/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
44
unix/Packaging/README
Normal file
44
unix/Packaging/README
Normal file
@@ -0,0 +1,44 @@
|
||||
Solaris packaging
|
||||
-----------------
|
||||
|
||||
To generate a Solaris package for Info-ZIP UnZip utilities,
|
||||
first see the top level INSTALL and README files. Do a
|
||||
"make solaris", which will automatically build two Solaris
|
||||
installable package files for the package, IZunzip.
|
||||
|
||||
IZunzip -- Solaris installable package in directory format.
|
||||
IZunzip_$(arch).pkg -- Solaris installable package in "stream" format.
|
||||
|
||||
Where: $(arch) := system architecture, currently i386, sparc, or ppc.
|
||||
(use "uname -p" to determine)
|
||||
|
||||
The ".pkg" file is a single file datastream that can be compressed
|
||||
and/or ftp'd. This is the recommended form, because all required
|
||||
files are resident in the archive, and it is easily distributed.
|
||||
|
||||
To install, simply:
|
||||
|
||||
1) copy the package to the target system's /tmp directory.
|
||||
2) login or su to root
|
||||
3) pkgadd -d /tmp/IZunzip_$(arch).pkg
|
||||
4) add /opt/Info-ZIP/IZunzip/bin to PATH
|
||||
5) add /opt/Info-ZIP/IZunzip/man to MANPATH
|
||||
|
||||
This works for both SPARC and x86.
|
||||
|
||||
Ongoing maintenance:
|
||||
|
||||
Keep the files, "prototype" and "pkginfo.in" up to date.
|
||||
Observe variable substitutions made by "Makefile".
|
||||
See manpages for pkginfo(1), pkginfo(4), pkgmk(1), pkgproto(1)
|
||||
|
||||
Variations:
|
||||
|
||||
If you wish the base directory to be set to something other than
|
||||
/opt/Info-ZIP, change the setting BASEDIR in pkginfo.in and
|
||||
re-run the make.
|
||||
|
||||
|
||||
-John Bush (John.Bush@East.Sun.COM)
|
||||
July 20, 1996
|
||||
|
||||
13
unix/Packaging/pkginfo.in
Normal file
13
unix/Packaging/pkginfo.in
Normal file
@@ -0,0 +1,13 @@
|
||||
PKG=IZunzip
|
||||
NAME=Info-ZIP UnZip Utilities
|
||||
CATEGORY=application
|
||||
VENDOR=Info-ZIP
|
||||
EMAIL=Zip-Bugs@lists.wku.edu
|
||||
HOTLINE=Zip-Bugs@lists.wku.edu
|
||||
DESC=Copyrighted FREEWARE. See README, WHERE, and LICENSE docs in pkg's doc dir.
|
||||
CLASSES=none
|
||||
BASEDIR=/opt/Info-ZIP
|
||||
#BASEDIR=/usr/local
|
||||
VERSION=".VERSION."
|
||||
PSTAMP=".PSTAMP."
|
||||
ARCH=".ARCH."
|
||||
22
unix/Packaging/postinstall
Executable file
22
unix/Packaging/postinstall
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# 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 " "
|
||||
exit 0
|
||||
26
unix/Packaging/preinstall.in
Normal file
26
unix/Packaging/preinstall.in
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/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. ..."
|
||||
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 " "
|
||||
returncode=1
|
||||
else
|
||||
echo " "
|
||||
echo "This product works on .ARCH., which you happen to have!"
|
||||
echo " "
|
||||
returncode=0
|
||||
fi
|
||||
echo " "
|
||||
/usr/bin/sleep 4
|
||||
exit ${returncode:-1}
|
||||
#
|
||||
33
unix/Packaging/prototype
Normal file
33
unix/Packaging/prototype
Normal file
@@ -0,0 +1,33 @@
|
||||
d none $BASEDIR 0755 root bin
|
||||
d none $BASEDIR/$PKG 0755 root bin
|
||||
d none $PKG/bin 0755 root bin
|
||||
f none $PKG/bin/unzip=unzip 0755 root bin
|
||||
f none $PKG/bin/funzip=funzip 0755 root bin
|
||||
f none $PKG/bin/unzipsfx=unzipsfx 0755 root bin
|
||||
f none $PKG/bin/zipgrep=unix/zipgrep 0755 root bin
|
||||
s none $PKG/bin/zipinfo=unzip
|
||||
d none $PKG/doc 0755 root bin
|
||||
f none $PKG/doc/ZipPorts=proginfo/ZipPorts 0644 root bin
|
||||
f none $PKG/doc/CONTRIBS=proginfo/CONTRIBS 0644 root bin
|
||||
f none $PKG/doc/COPYING.OLD=COPYING.OLD 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/WHERE=WHERE 0644 root bin
|
||||
f none $PKG/doc/INSTALL=INSTALL 0644 root bin
|
||||
f none $PKG/doc/funzip.txt=funzip.txt 0644 root bin
|
||||
f none $PKG/doc/unzip.txt=unzip.txt 0644 root bin
|
||||
f none $PKG/doc/unzipsfx.txt=unzipsfx.txt 0644 root bin
|
||||
f none $PKG/doc/zipgrep.txt=zipgrep.txt 0644 root bin
|
||||
f none $PKG/doc/zipinfo.txt=zipinfo.txt 0644 root bin
|
||||
d none $PKG/man 0755 root bin
|
||||
d none $PKG/man/man1 0755 root bin
|
||||
f none $PKG/man/man1/funzip.1=man/funzip.1 0644 root bin
|
||||
f none $PKG/man/man1/unzip.1=man/unzip.1 0644 root bin
|
||||
f none $PKG/man/man1/unzipsfx.1=man/unzipsfx.1 0644 root bin
|
||||
f none $PKG/man/man1/zipgrep.1=man/zipgrep.1 0644 root bin
|
||||
f none $PKG/man/man1/zipinfo.1=man/zipinfo.1 0644 root bin
|
||||
i pkginfo
|
||||
i prototype
|
||||
i README
|
||||
i preinstall
|
||||
i postinstall
|
||||
652
unix/configure
vendored
Executable file
652
unix/configure
vendored
Executable file
@@ -0,0 +1,652 @@
|
||||
:
|
||||
#!/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), $3 = $(IZ_BZIP2)
|
||||
# To construct unzip automatically using this file, type
|
||||
# "make -f unix/Makefile generic".
|
||||
# If this fails, then type "make list" to get a list of special targets.
|
||||
|
||||
trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
|
||||
|
||||
CC=${1-cc}
|
||||
CFLAGS=${2}
|
||||
CFLAGSR=${CFLAGS}
|
||||
IZ_BZIP2=${3}
|
||||
CFLAGS="${CFLAGS} -I. -DUNIX"
|
||||
LFLAGS1=""
|
||||
LFLAGS2="-s"
|
||||
LN="ln -s"
|
||||
|
||||
CFLAGS_OPT=''
|
||||
CFLAGS_BZ=''
|
||||
BZLF=''
|
||||
|
||||
echo "Check C compiler operation"
|
||||
cat > conftest.c << _EOF_
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c
|
||||
status=$?
|
||||
if test $status -ne 0; then
|
||||
echo ''
|
||||
echo "C compiler \"${CC}\" does not work as expected."
|
||||
echo "Failing command was: $CC $CFLAGS -c conftest.c"
|
||||
exit $status
|
||||
else
|
||||
echo ' Ok'
|
||||
fi
|
||||
|
||||
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
|
||||
BZLF=${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
|
||||
CFLAGSR="${CFLAGSR} ${CFLAGS_OPT}"
|
||||
CFLAGS_BZ="${CFLAGS_BZ} ${CFLAGS_OPT}"
|
||||
fi
|
||||
|
||||
echo Check for the C preprocessor
|
||||
# on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
|
||||
CPP="${CC} -E"
|
||||
# solaris as(1) needs -P, maybe others as well ?
|
||||
[ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
|
||||
[ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
|
||||
[ -f /lib/cpp ] && CPP=/lib/cpp
|
||||
[ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
|
||||
[ -f /xenix ] && CPP="${CC} -E"
|
||||
[ -f /lynx.os ] && 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
|
||||
CRC32OA=""
|
||||
if eval "$CPP crc_i386.S > _crc_i386.s 2>/dev/null"; then
|
||||
if test ! -s _crc_i386.s || grep error < _crc_i386.s > /dev/null; then
|
||||
:
|
||||
elif eval "$CC -c _crc_i386.s >/dev/null 2>/dev/null" && [ -f _crc_i386.o ]; then
|
||||
CFLAGSR="${CFLAGSR} -DASM_CRC"
|
||||
CRC32OA="crc_gcc.o"
|
||||
echo "int foo() { return 0;}" > conftest.c
|
||||
$CC -c conftest.c >/dev/null 2>/dev/null
|
||||
echo Check if compiler generates underlines
|
||||
nm conftest.o | grep "(^|[^_])foo" >/dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && CPP="${CPP} -DNO_UNDERLINE"
|
||||
fi
|
||||
fi
|
||||
rm -f _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
|
||||
|
||||
echo Check for ANSI options
|
||||
cat > conftest.c << _EOF_
|
||||
int main()
|
||||
{
|
||||
#ifndef __STDC__
|
||||
forget it
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
_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
|
||||
do
|
||||
$CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && CFLAGSR="${CFLAGSR} ${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
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_PROTO"
|
||||
|
||||
# const check currently handles mips cc and non ANSI compilers.
|
||||
# does it need more ?
|
||||
echo Check the handling of const
|
||||
cat > conftest.c << _EOF_
|
||||
typedef int charset[2];
|
||||
int main()
|
||||
{
|
||||
const charset x;
|
||||
const char *foo;
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_CONST"
|
||||
|
||||
echo Check for time_t
|
||||
cat > conftest.c << _EOF_
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
int main()
|
||||
{
|
||||
time_t t;
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_TIME_T"
|
||||
|
||||
echo Check for size_t
|
||||
cat > conftest.c << _EOF_
|
||||
#include <sys/types.h>
|
||||
int main()
|
||||
{
|
||||
size_t s;
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -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 ] && CFLAGSR="${CFLAGSR} -DNO_OFF_T"
|
||||
|
||||
# Added 11/4/2003 EG
|
||||
# Revised 8/12/04 EG
|
||||
# Now we set the 64-bit file environment and check the size of off_t
|
||||
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!
|
||||
CFLAGSR="${CFLAGSR} -DLARGE_FILE_SUPPORT"
|
||||
else
|
||||
echo -- no Large File Support - conftest returned $r
|
||||
fi
|
||||
fi
|
||||
|
||||
# Added 11/24/2005 EG
|
||||
# Check for wide char for Unicode support
|
||||
echo Check for wide char support
|
||||
cat > conftest.c << _EOF_
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
int main()
|
||||
{
|
||||
size_t 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;
|
||||
#ifndef __STDC_ISO_10646__
|
||||
return 1;
|
||||
#else
|
||||
printf(" __STDC_ISO_10646__ = %d\n", __STDC_ISO_10646__);
|
||||
return 2;
|
||||
#endif
|
||||
}
|
||||
_EOF_
|
||||
# compile it
|
||||
$CC -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "-- no Unicode (wchar_t) support"
|
||||
else
|
||||
# have wide char support
|
||||
# run it
|
||||
./conftest
|
||||
r=$?
|
||||
if [ $r -eq 0 ]; then
|
||||
echo -- no Unicode wchar_t support - wchar_t allocation error
|
||||
elif [ $r -eq 1 ]; then
|
||||
echo -- no Unicode support - wchar_t encoding unspecified
|
||||
elif [ $r -eq 2 ]; then
|
||||
echo -- have wchar_t with known UCS encoding - enabling Unicode support!
|
||||
CFLAGSR="${CFLAGSR} -DUNICODE_SUPPORT -DUNICODE_WCHAR"
|
||||
else
|
||||
echo "-- no Unicode (wchar_t) support - conftest returned $r"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Check for setlocale support (needed for UNICODE Native check)"
|
||||
cat > conftest.c << _EOF_
|
||||
#include <locale.h>
|
||||
int main()
|
||||
{
|
||||
char *loc = setlocale(LC_CTYPE, "");
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "-- have setlocale, can check for charset type"
|
||||
echo "-- - enabling UTF8-native support!"
|
||||
CFLAGSR="${CFLAGSR} -DUNICODE_SUPPORT -DUTF8_MAYBE_NATIVE"
|
||||
else
|
||||
echo "-- no Unicode (UTF-8 native) support!"
|
||||
CFLAGSR="${CFLAGSR} -DNO_SETLOCALE"
|
||||
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_
|
||||
int main()
|
||||
{
|
||||
#if __GNUC__ >= 2
|
||||
return 0;
|
||||
#else
|
||||
forget it
|
||||
#endif
|
||||
}
|
||||
_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 fchmod fchown lchown nl_langinfo
|
||||
do
|
||||
echo Check for $func
|
||||
echo "int main(){ $func(); return 0; }" > conftest.c
|
||||
$CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
|
||||
done
|
||||
|
||||
# Check (seriously) for a working lchmod.
|
||||
echo 'Check for lchmod'
|
||||
temp_file="/tmp/unzip_test_$$"
|
||||
temp_link="link_$$"
|
||||
( echo '#include <unistd.h>' ; \
|
||||
echo "int main() { lchmod(\"${temp_file}\", 0666); }" \
|
||||
) > conftest.c
|
||||
ln -s "${temp_link}" "${temp_file}" && \
|
||||
$CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null && \
|
||||
./conftest
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_LCHMOD"
|
||||
rm -f "${temp_file}"
|
||||
|
||||
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 ] && CFLAGSR="${CFLAGSR} -DZMEM"
|
||||
|
||||
echo Check for errno declaration
|
||||
cat > conftest.c << _EOF_
|
||||
#include <errno.h>
|
||||
main()
|
||||
{
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
_EOF_
|
||||
$CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_ERRNO"
|
||||
|
||||
echo Check for directory libraries
|
||||
cat > conftest.c << _EOF_
|
||||
int main() { return closedir(opendir(".")); }
|
||||
_EOF_
|
||||
|
||||
$CC -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
OPT=""
|
||||
for lib in ndir dir ucb bsd BSD PW x dirent
|
||||
do
|
||||
$CC -o conftest conftest.c -l$lib >/dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && OPT=-l$lib && break
|
||||
done
|
||||
if [ ${OPT} ]; then
|
||||
LFLAGS2="${LFLAGS2} ${OPT}"
|
||||
else
|
||||
CFLAGSR="${CFLAGSR} -DNO_DIR"
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
$CC -o conftest conftest.c -lseq >/dev/null 2>/dev/null
|
||||
[ $? -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
|
||||
do
|
||||
echo "#include <$inc>" > conftest.c
|
||||
$CPP conftest.c > /dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
|
||||
done
|
||||
CFLAGSR="${CFLAGSR} ${OPT}"
|
||||
|
||||
echo Check for non existent include files
|
||||
for inc in stdlib.h stddef.h unistd.h fcntl.h string.h langinfo.h
|
||||
do
|
||||
echo "#include <$inc>" > conftest.c
|
||||
$CPP conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
|
||||
done
|
||||
|
||||
echo Check for term I/O include file
|
||||
OPT=""
|
||||
for inc in termios.h termio.h sgtty.h
|
||||
do
|
||||
echo "#include <$inc>" > conftest.c
|
||||
$CPP conftest.c > /dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
|
||||
done
|
||||
CFLAGSR="${CFLAGSR} ${OPT}"
|
||||
|
||||
echo Check for MBCS include files
|
||||
OPT=""
|
||||
for inc in mbstring.h mbctype.h
|
||||
do
|
||||
echo "#include <$inc>" > conftest.c
|
||||
$CPP conftest.c > /dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
|
||||
done
|
||||
CFLAGSR="${CFLAGSR} ${OPT}"
|
||||
|
||||
# Check for MBCS support
|
||||
echo Check for MBCS support
|
||||
cat > conftest.c << _EOF_
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#ifdef HAVE_MBSTRING_H
|
||||
# include <mbstring.h>
|
||||
#endif
|
||||
int main()
|
||||
{
|
||||
char *tst;
|
||||
tst = "Hallo";
|
||||
return mblen(tst, MB_CUR_MAX);
|
||||
}
|
||||
_EOF_
|
||||
# compile it
|
||||
$CC ${CFLAGS} ${CFLAGSR} -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "-- no MBCS support"
|
||||
CFLAGSR="${CFLAGSR} -DNO_MBCS"
|
||||
else
|
||||
#
|
||||
echo "-- have MBCS support"
|
||||
CFLAGSR="${CFLAGSR} -D_MBCS"
|
||||
# check for library-supplied functions
|
||||
# add FUNCTION_NAME='function_name' to flags if found
|
||||
for func in mbschr mbsrchr
|
||||
do
|
||||
echo Check for MBCS $func
|
||||
echo "int main() { $func(); return 0; }" > conftest.c
|
||||
$CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && CFLAGSR="${CFLAGSR} -D`echo $func | tr '[a-z]' '[A-Z]'`=$func"
|
||||
done
|
||||
fi
|
||||
|
||||
# needed for AIX (and others ?) when mmap is used
|
||||
echo Check for valloc
|
||||
cat > conftest.c << _EOF_
|
||||
main()
|
||||
{
|
||||
#ifdef MMAP
|
||||
valloc();
|
||||
#endif
|
||||
}
|
||||
_EOF_
|
||||
$CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null
|
||||
[ $? -ne 0 ] && CFLAGSR="${CFLAGSR} -DNO_VALLOC"
|
||||
|
||||
echo Check for /usr/local/bin and /usr/local/man
|
||||
BINDIR=$HOME/bin
|
||||
[ -d /usr/local/bin ] && BINDIR=/usr/local/bin
|
||||
|
||||
MANDIR=manl
|
||||
[ -d /usr/man/manl ] && MANDIR=/usr/man/manl
|
||||
[ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
|
||||
[ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1
|
||||
|
||||
echo Checking for OS specialties
|
||||
if [ -f /usr/bin/hostinfo ]; then
|
||||
if /usr/bin/hostinfo | grep NeXT > /dev/null; then
|
||||
CFLAGSR="${CFLAGSR} -posix"
|
||||
LFLAGS1="${LFLAGS1} -posix -object"
|
||||
fi
|
||||
# XXX ATT6300, Cray
|
||||
elif [ -f /xenix ]; then
|
||||
if uname -p | grep 286 > /dev/null; then
|
||||
CFLAGSR="${CFLAGSR} -LARGE -Mel2 -DMEDIUM_MEM -DWSIZE=16384 -DNO_VOID"
|
||||
LFLAGS1="${LFLAGS1} -LARGE -Mel2"
|
||||
fi
|
||||
elif uname -X >/dev/null 2>/dev/null; then
|
||||
# SCO shared library check
|
||||
echo "int main() { return 0;}" > conftest.c
|
||||
$CC -o conftest conftest.c -lc_s -nointl >/dev/null 2> /dev/null
|
||||
[ $? -eq 0 ] && LFLAGS2="-lc_s -nointl"
|
||||
else
|
||||
SYSTEM=`uname -s 2>/dev/null` || SYSTEM="unknown"
|
||||
echo "int main() { return 0;}" > conftest.c
|
||||
case $SYSTEM in
|
||||
OSF1|ULTRIX)
|
||||
echo Check for -Olimit option
|
||||
$CC ${CFLAGS} -Olimit 1000 -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
[ $? -eq 0 ] && CFLAGSR="${CFLAGSR} -Olimit 1000"
|
||||
;;
|
||||
### HP-UX)
|
||||
### echo Check for +Onolimit option
|
||||
### $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
|
||||
### [ $? -eq 0 ] && CFLAGSR="${CFLAGSR} +Onolimit"
|
||||
### ;;
|
||||
### SunOS)
|
||||
### CFLAGSR="${CFLAGSR} -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
|
||||
|
||||
|
||||
# bzip2
|
||||
|
||||
echo "Check bzip2 support"
|
||||
D_USE_BZ2=""
|
||||
LIBBZ2=""
|
||||
L_BZ2=""
|
||||
CC_BZ="${CC}"
|
||||
|
||||
if test -n "${IZ_BZIP2}" -a "${IZ_BZIP2}" != "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"
|
||||
if test -f "${IZ_BZIP2}/bzlib.h"; then
|
||||
LIBBZ2="${IZ_BZIP2}/libbz2.a"
|
||||
D_USE_BZ2="-DUSE_BZIP2"
|
||||
L_BZ2="${BZLF} -lbz2"
|
||||
echo "-- Found bzip2 library - linking in bzip2"
|
||||
else
|
||||
echo " ${IZ_BZIP2}/bzlib.h not found"
|
||||
echo "-- Since IZ_BZIP2 defined (!= \"bzip2\"),"
|
||||
echo "-- => skipping OS and bzip2 dir checks."
|
||||
echo "-- NO bzip2 support !"
|
||||
fi
|
||||
else
|
||||
echo " Found bzip2 library, ${IZ_BZIP2}/libbz2.a,"
|
||||
echo " but library not compiled with BZ_NO_STDIO."
|
||||
echo " ERROR: This (default) variant of bzip2 library is NOT"
|
||||
echo " supported with UnZip because of its incompatible"
|
||||
echo " error handling!"
|
||||
echo " Please see the UnZip installation instructions in"
|
||||
echo " the INSTALL text file."
|
||||
echo " Skipping bzip2 support..."
|
||||
fi
|
||||
else
|
||||
echo " ${IZ_BZIP2}/libbz2.a not found"
|
||||
echo "-- Since IZ_BZIP2 defined (!= \"bzip2\"),"
|
||||
echo "-- => skipping OS and bzip2 dir checks."
|
||||
echo "-- NO bzip2 support !"
|
||||
fi
|
||||
else
|
||||
echo " Check for bzip2 sources in unzip's bzip2 subdirectory"
|
||||
if test -f "${IZ_BZIP2}/bzlib.c" -a -f "${IZ_BZIP2}/bzlib.h"; then
|
||||
echo "-- Found bzip2 source in ${IZ_BZIP2}/ directory"
|
||||
echo "-- Will try to build bzip2 library from source and link in"
|
||||
LIBBZ2="${IZ_BZIP2}/libbz2.a"
|
||||
D_USE_BZ2="-DUSE_BZIP2"
|
||||
L_BZ2="${BZLF} -lbz2"
|
||||
else
|
||||
echo "-- bzip2 sources not found - no bzip2 support"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo CC=\"${CC}\" CF=\"${CFLAGSR} ${D_USE_BZ2}\" CRCA_O=\"${CRC32OA}\" \
|
||||
AS=\"${CC} -c\" LFLAGS1=\"${LFLAGS1}\" LF2=\"${LFLAGS2}\" \
|
||||
CC_BZ=\"${CC_BZ}\" CFLAGS_BZ=\"${CFLAGS_BZ}\" \
|
||||
IZ_BZIP2=\"${IZ_BZIP2}\" D_USE_BZ2=\"${D_USE_BZ2}\" \
|
||||
L_BZ2=\"${L_BZ2}\" LIBBZ2=\"${LIBBZ2}\" > flags
|
||||
1876
unix/unix.c
Normal file
1876
unix/unix.c
Normal file
File diff suppressed because it is too large
Load Diff
230
unix/unxcfg.h
Normal file
230
unix/unxcfg.h
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
|
||||
|
||||
See the accompanying file LICENSE, version 2009-Jan-02 or later
|
||||
(the contents of which are also included in unzip.h) for terms of use.
|
||||
If, for some reason, all these files are missing, the Info-ZIP license
|
||||
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
||||
*/
|
||||
/*---------------------------------------------------------------------------
|
||||
Unix specific configuration section:
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __unxcfg_h
|
||||
#define __unxcfg_h
|
||||
|
||||
|
||||
/* LARGE FILE SUPPORT - 10/6/04 EG */
|
||||
/* This needs to be set before the includes so they set the right sizes */
|
||||
|
||||
#if (defined(NO_LARGE_FILE_SUPPORT) && defined(LARGE_FILE_SUPPORT))
|
||||
# undef LARGE_FILE_SUPPORT
|
||||
#endif
|
||||
|
||||
/* Automatically set ZIP64_SUPPORT if LFS */
|
||||
#ifdef LARGE_FILE_SUPPORT
|
||||
# if (!defined(NO_ZIP64_SUPPORT) && !defined(ZIP64_SUPPORT))
|
||||
# define ZIP64_SUPPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* NO_ZIP64_SUPPORT takes preceedence over ZIP64_SUPPORT */
|
||||
#if defined(NO_ZIP64_SUPPORT) && defined(ZIP64_SUPPORT)
|
||||
# undef ZIP64_SUPPORT
|
||||
#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 */
|
||||
|
||||
/* These have to be before any include that sets types so the large file
|
||||
versions of the types are set in the includes */
|
||||
|
||||
# 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 */
|
||||
# define __USE_LARGEFILE64
|
||||
#endif /* LARGE_FILE_SUPPORT */
|
||||
|
||||
|
||||
#include <sys/types.h> /* off_t, time_t, dev_t, ... */
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef NO_OFF_T
|
||||
typedef long zoff_t;
|
||||
#else
|
||||
typedef off_t zoff_t;
|
||||
#endif
|
||||
#define ZOFF_T_DEFINED
|
||||
typedef struct stat z_stat;
|
||||
#define Z_STAT_DEFINED
|
||||
|
||||
#ifndef COHERENT
|
||||
# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
|
||||
#else /* COHERENT */
|
||||
# ifdef _I386
|
||||
# include <fcntl.h> /* Coherent 4.0.x, Mark Williams C */
|
||||
# else
|
||||
# include <sys/fcntl.h> /* Coherent 3.10, Mark Williams C */
|
||||
# endif
|
||||
# define SHORT_SYMS
|
||||
# ifndef __COHERENT__ /* Coherent 4.2 has tzset() */
|
||||
# define tzset settz
|
||||
# endif
|
||||
#endif /* ?COHERENT */
|
||||
|
||||
#ifndef NO_PARAM_H
|
||||
# ifdef NGROUPS_MAX
|
||||
# undef NGROUPS_MAX /* SCO bug: defined again in <sys/param.h> */
|
||||
# endif
|
||||
# ifdef BSD
|
||||
# define TEMP_BSD /* may be defined again in <sys/param.h> */
|
||||
# undef BSD
|
||||
# endif
|
||||
# include <sys/param.h> /* conflict with <sys/types.h>, some systems? */
|
||||
# ifdef TEMP_BSD
|
||||
# undef TEMP_BSD
|
||||
# ifndef BSD
|
||||
# define BSD
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !NO_PARAM_H */
|
||||
|
||||
#ifdef __osf__
|
||||
# define DIRENT
|
||||
# ifdef BSD
|
||||
# undef BSD
|
||||
# endif
|
||||
#endif /* __osf__ */
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# include <unistd.h>
|
||||
# define DIRENT
|
||||
# define HAVE_TERMIOS_H
|
||||
# ifndef timezone
|
||||
# define timezone _timezone
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BSD
|
||||
# include <sys/time.h>
|
||||
# include <sys/timeb.h>
|
||||
# if (defined(_AIX) || defined(__GLIBC__) || defined(__GNU__))
|
||||
# include <time.h>
|
||||
# endif
|
||||
#else
|
||||
# include <time.h>
|
||||
struct tm *gmtime(), *localtime();
|
||||
#endif
|
||||
|
||||
#if (defined(BSD4_4) || (defined(SYSV) && defined(MODERN)))
|
||||
# include <unistd.h> /* this includes utime.h on SGIs */
|
||||
# if (defined(BSD4_4) || defined(linux) || defined(__GLIBC__))
|
||||
# include <utime.h>
|
||||
# define GOT_UTIMBUF
|
||||
# endif
|
||||
# if (!defined(GOT_UTIMBUF) && (defined(__hpux) || defined(__SUNPRO_C)))
|
||||
# include <utime.h>
|
||||
# define GOT_UTIMBUF
|
||||
# endif
|
||||
# if (!defined(GOT_UTIMBUF) && defined(__GNU__))
|
||||
# include <utime.h>
|
||||
# define GOT_UTIMBUF
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(__DGUX__) && !defined(GOT_UTIMBUF))
|
||||
/* DG/UX requires this because of a non-standard struct utimebuf */
|
||||
# include <utime.h>
|
||||
# define GOT_UTIMBUF
|
||||
#endif
|
||||
|
||||
#if (defined(V7) || defined(pyr_bsd))
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
#endif
|
||||
#ifdef V7
|
||||
# define O_RDONLY 0
|
||||
# define O_WRONLY 1
|
||||
# define O_RDWR 2
|
||||
#endif
|
||||
|
||||
#if defined(NO_UNICODE_SUPPORT) && defined(UNICODE_SUPPORT)
|
||||
/* disable Unicode (UTF-8) support when requested */
|
||||
# undef UNICODE_SUPPORT
|
||||
#endif
|
||||
|
||||
#if (defined(_MBCS) && defined(NO_MBCS))
|
||||
/* disable MBCS support when requested */
|
||||
# undef _MBCS
|
||||
#endif
|
||||
|
||||
#if (!defined(NO_SETLOCALE) && !defined(_MBCS))
|
||||
# if (!defined(UNICODE_SUPPORT) || !defined(UTF8_MAYBE_NATIVE))
|
||||
/* enable setlocale here, unless this happens later for UTF-8 and/or
|
||||
* MBCS support */
|
||||
# include <locale.h>
|
||||
# ifndef SETLOCALE
|
||||
# define SETLOCALE(category, locale) setlocale(category, locale)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef NO_SETLOCALE
|
||||
# if (!defined(NO_WORKING_ISPRINT) && !defined(HAVE_WORKING_ISPRINT))
|
||||
/* enable "enhanced" unprintable chars detection in fnfilter() */
|
||||
# define HAVE_WORKING_ISPRINT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef MINIX
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
#if (!defined(HAVE_STRNICMP) & !defined(NO_STRNICMP))
|
||||
# define NO_STRNICMP
|
||||
#endif
|
||||
#ifndef DATE_FORMAT
|
||||
# define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */
|
||||
#endif
|
||||
#define lenEOL 1
|
||||
#ifdef EBCDIC
|
||||
# define PutNativeEOL *q++ = '\n';
|
||||
#else
|
||||
# define PutNativeEOL *q++ = native(LF);
|
||||
#endif
|
||||
#define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
|
||||
#define SCREENWIDTH 80
|
||||
#define SCREENLWRAP 1
|
||||
#define USE_EF_UT_TIME
|
||||
#if (!defined(NO_LCHOWN) || !defined(NO_LCHMOD))
|
||||
# define SET_SYMLINK_ATTRIBS
|
||||
#endif
|
||||
#ifdef MTS
|
||||
# ifdef SET_DIR_ATTRIB
|
||||
# undef SET_DIR_ATTRIB
|
||||
# endif
|
||||
#else /* !MTS */
|
||||
# define SET_DIR_ATTRIB
|
||||
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) /* GRR 970513 */
|
||||
# define TIMESTAMP
|
||||
# endif
|
||||
# define RESTORE_UIDGID
|
||||
#endif /* ?MTS */
|
||||
|
||||
/* Static variables that we have to add to Uz_Globs: */
|
||||
#define SYSTEM_SPECIFIC_GLOBALS \
|
||||
int created_dir, renamed_fullpath;\
|
||||
char *rootpath, *buildpath, *end;\
|
||||
ZCONST char *wildname;\
|
||||
char *dirname, matchname[FILNAMSIZ];\
|
||||
int rootlen, have_dirname, dirnamelen, notfirstcall;\
|
||||
zvoid *wild_dir;
|
||||
|
||||
/* created_dir, and renamed_fullpath are used by both mapname() and */
|
||||
/* checkdir(). */
|
||||
/* rootlen, rootpath, buildpath and end are used by checkdir(). */
|
||||
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
|
||||
/* and notfirstcall are used by do_wild(). */
|
||||
|
||||
#endif /* !__unxcfg_h */
|
||||
105
unix/zipgrep
Executable file
105
unix/zipgrep
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# zipgrep: Use unzip and egrep to search the specified members of a
|
||||
# Zip archive for a string or pattern. Search all members if no members
|
||||
# are specified explicitly. The script attempts to handle egrep's "-h"
|
||||
# and "-l" options internally.
|
||||
#
|
||||
# This script assumes that the desired "unzip" and "egrep" (and "sed")
|
||||
# programs are on the user's PATH.
|
||||
#
|
||||
|
||||
pat=""
|
||||
opt=""
|
||||
while test $# -ne 0; do
|
||||
case "$1" in
|
||||
-e | -f) opt="$opt $1"; shift; pat="$1";;
|
||||
-*) opt="$opt $1";;
|
||||
*) if test -z "$pat"; then
|
||||
pat="$1"
|
||||
else
|
||||
break;
|
||||
fi;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# = 0; then
|
||||
echo usage: `basename "$0"` "[egrep_options] pattern zipfile [members...]"
|
||||
echo Uses unzip and egrep to search the zip members for a string or pattern.
|
||||
exit 1
|
||||
fi
|
||||
zipfile="$1"; shift
|
||||
|
||||
list=0
|
||||
silent=0
|
||||
opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
|
||||
case "$opt" in
|
||||
*l*) list=1; opt=`echo $opt | sed s/l//`
|
||||
esac
|
||||
case "$opt" in
|
||||
*h*) silent=1
|
||||
esac
|
||||
if test -n "$opt"; then
|
||||
opt="-$opt"
|
||||
fi
|
||||
|
||||
status_grep_global=1
|
||||
IFS='
|
||||
'
|
||||
|
||||
# Escape shell-special characters in "pat".
|
||||
pat=` echo "$pat" | \
|
||||
sed -e 's/\\\\/\\\\\\\\/g' -e 's/|/\\\|/g' -e 's/&/\\\&/g' `
|
||||
|
||||
# Use "unzip -Z1" to get a listing of the specified members from the
|
||||
# specified archive. Escape any backslashes in a file name.
|
||||
for i in `unzip -Z1 "$zipfile" ${1+"$@"} | sed -e 's/\\\\/\\\\\\\\/g' `; do
|
||||
if test $list -eq 1; then
|
||||
# "-l": Show only the archive member name, not the matching line(s).
|
||||
unzip -p-L "$zipfile" "$i" | \
|
||||
egrep $opt "$pat" > /dev/null && echo "$i"
|
||||
status_grep=$?
|
||||
elif test $silent -eq 1; then
|
||||
# "-h": Show only the matching line(s), not the archive member name.
|
||||
# ("-s" in "opt" will silence "egrep", stopping all output.)
|
||||
unzip -p-L "$zipfile" "$i" | \
|
||||
egrep $opt "$pat"
|
||||
status_grep=$?
|
||||
else
|
||||
# Escape (or re-escape) shell-special characters in the archive
|
||||
# member name, "i".
|
||||
i=` echo "$i" | \
|
||||
sed -e 's/\\\\/\\\\\\\\/g' -e 's/|/\\\|/g' -e 's/&/\\\&/g' `
|
||||
|
||||
# Globally, send fd 4 to stdout. In the pipeline, send normal
|
||||
# stdout to fd 4, and send grep status to fd 3. Collect fd 3
|
||||
# with ``.
|
||||
exec 4>&1
|
||||
status_grep=` ( \
|
||||
( unzip -p-L "$zipfile" "$i" | \
|
||||
egrep $opt "$pat" 1>&4 ; echo $? >&3 ) 4>&1 | \
|
||||
sed "s|^|${i}:|" 1>&4 \
|
||||
) 3>&1 `
|
||||
fi
|
||||
|
||||
# Save the primary command status. (May be the grep status.)
|
||||
sts=$?
|
||||
# If this grep status was zero, set the global grep status to zero.
|
||||
test "$status_grep" -eq 0 && status_grep_global=0
|
||||
# If this grep status was not zero or one, exit now.
|
||||
test "$status_grep" -gt 1 && exit "$status_grep"
|
||||
|
||||
done
|
||||
|
||||
# If "sts" is good (0), then exit with the global grep status.
|
||||
# Else, when "sts" is bad, exit with the worst status we can find.
|
||||
if test $sts -eq 0 ; then
|
||||
exit $status_grep_global
|
||||
else
|
||||
if test "$status_grep" -gt 1 ; then
|
||||
exit "$status_grep"
|
||||
else
|
||||
exit $sts
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user