From bb2adbfb3788829e8469b9dc5e6a03e1b4c841d7 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Mon, 18 Aug 2003 13:24:39 +0000 Subject: [PATCH] This commit was generated by cvs2svn to compensate for changes in r97, which included commits to RCS files with non-trunk default branches. --- TODO | 50 +++++++++++++++ bins/Makefile.am | 39 ++++++++++++ bins/zziplib.m4 | 105 +++++++++++++++++++++++++++++++ bins/zziptest.c | 134 ++++++++++++++++++++++++++++++++++++++++ zziplib.spec | 157 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 485 insertions(+) create mode 100644 TODO create mode 100644 bins/Makefile.am create mode 100644 bins/zziplib.m4 create mode 100644 bins/zziptest.c create mode 100644 zziplib.spec diff --git a/TODO b/TODO new file mode 100644 index 0000000..aa3e76e --- /dev/null +++ b/TODO @@ -0,0 +1,50 @@ + +- Check the CRC value at the end of read... and add more error codes. + +- Do more test. Currently use only with tested "friendly" archives. + inflate interface code needs most testing. + +- Sligthly More documentation. With the generation of man pages and + multiple pages for the website, it does already look acceptable. + It should still get better of course - kinda newbie friendly *g* + +KNOWN PROBLEMS + +The win32 compilers need each a different config.h derivate that +matches both the headers shipped with the compiler and installed +with updates of the SDK. There is no autoconfigure on win32 as +that - unless you install some unix tools along. + +The sparc-sun-solaris2.* will utter warnings for "char subscript" +which is caused by isdigit() from ctype.h - this will NOT FIX as +it is only in the example source code and we want to keep those +lean and mean to make them easy to adopt by developers. + +The hppa1.1-hp-hpux10.20 did show spurious problems of making +shared libraries - this may well fix with an update of the +libtool package, the libtool 1.4 is dated 2001/04/24 + +There are spurious reports of users on win32 platforms that tell +of some problems with a specific zip file they have but it was +not possible so far to recreate an environment abroad to show +the problem too. One can not say if that is due some general +instability out of DLL hell, or if there is a bug hiding somewhere. +Please send all those zip files to the maintainer, perhaps it +can help to find the real cause (I doubt it is in zziplib, but..) + +TESTED PLATFORMS +sparc-sun-solaris2.6/gcc2.95.3 +sparc-sun-solaris2.8/gcc2.95.3 +hppa1.1-hp-hpux10.20 +i686-mandrake-linux-9.0/gcc3.2 +i686-mandrake-linux-9.1/gcc3.2.2 +i686-debian-linux-2.2/gcc2.95.2 +i386-unknown-freebsd4.7/gcc2.95.4 (formerly with wrapwrap) +powerpc-apple-darwin5.5 (formerly with wrapwrap) +alphaev67-unknown-linux-gnu/gcc2.95.4 (that's a 64bit platform) +i386-ms-win32/msvc6 +i386-ms-win32/msvc7 +i386-ms-win32/mingw+msys +... and probably a lot of others not known to the maintainer. + +* 10.82 - wrapwrap autodected disabled, the ssize_t usage should do it now. diff --git a/bins/Makefile.am b/bins/Makefile.am new file mode 100644 index 0000000..8348eb8 --- /dev/null +++ b/bins/Makefile.am @@ -0,0 +1,39 @@ +AUTOMAKE_OPTIONS = 1.4 foreign +AUTOTOOL_VERSION=autoconf-2.52 automake-1.5 libtool-1.4.2 +DEFAULT_INCLUDES = # nothing - no default of -I. -I$(srcdir) +DEFS = @DEFS@ -I$(top_builddir) -I$(top_srcdir) # also for automake 1.4 + +bin_PROGRAMS = zzcat zzdir zzxorcat zzxordir zzxorcopy unzzip +noinst_PROGRAMS = zziptest zzobfuscated zzip +aclocaldir = $(datadir)/aclocal +aclocal_DATA = zziplib.m4 +# +VERSION_INFO=@VERSION_INFO@ +RELEASE_INFO=@RELEASE_INFO@ +THREAD_SAFE=@THREAD_SAFE@ +# + +WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt + +EXTRA_DIST = $(aclocal_DATA) +CLEANFILES = $(WCC10_CLEAN) + +unzzip_LDFLAGS = @ZZIPLIB_LDFLAGS@ +unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzip_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zziptest_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzcat_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzdir_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzdir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzxorcat_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzxordir_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz +zzobfuscated_LDFLAGS = @ZZIPLIB_LDFLAGS@ +zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz + +../zzip/libzzip.la : @top_srcdir@/zzip/*.c + (cd ../zzip && $(MAKE) `basename $@`) diff --git a/bins/zziplib.m4 b/bins/zziplib.m4 new file mode 100644 index 0000000..4029ca5 --- /dev/null +++ b/bins/zziplib.m4 @@ -0,0 +1,105 @@ +dnl this macro has been copied from /usr/share/aclocal/pkg.m4 +dnl modified to check only for zziplib. You are advised to use +dnl pgkconfig macro directly instead. It is only installed to +dnl the convenience of software makers who do not want to have +dnl yet another package dependency when building zziplib-based +dnl projects. In general, you can include in your configure.ac +dnl some line like +dnl PKG_CHECK_ZZIPLIB([ZZIP],[0.10.75]) +dnl in order to get the two autoconf/automake subst variables +dnl named ZZIP_CFLAGS and ZZIP_LIBS respectivly. + +dnl PKG_CHECK_ZZIPLIB(ZZIP, minversion, action-if, action-not) +dnl defines ZZIP_LIBS, ZZIP_CFLAGS, see pkg-config man page +dnl also defines ZZIP_PKG_ERRORS on error +AC_DEFUN([PKG_CHECK_ZZIPLIB], [# checking for zziplib cflags/libs $2 + succeeded=no + + if test -z "$PKG_CONFIG"; then + AC_PATH_PROG([PKG_CONFIG],[pkg-config],[no]) + fi + + if test "$PKG_CONFIG" = "no" ; then + dnl we stick in an extra section that takes advantage of `zzip-config` + dnl script that might be there and carry cflags/libs info as well. + AC_PATH_PROG([ZZIP_CONFIG], [zzip-config], [no]) + if test "$ZZIP_CONFIG" = "no" ; then + echo "*** Neither config spec could be found - there was no archaic" + echo "*** zzip-config script around and no pkg-config script in the" + echo "*** PATH. Make sure that either one is in your path, or set" + echo "*** set the PKG_CONFIG environment variable to the full" + echo "*** path to pkg-config. See http://zziplib.sf.net - or see" + echo "*** http://www.freedesktop.org/software/pkgconfig for more." + else + AC_MSG_CHECKING($1_LIBS) + $1_LIBS=`$ZZIP_CONFIG --libs 2>/dev/null` + AC_MSG_RESULT($[]$1_LIBS) + + if test ".$[]$1_LIBS" != "." ; then + AC_MSG_CHECKING($1_CFLAGS) + $1_CFLAGS=`$ZZIP_CONFIG --cflags 2>/dev/null` + AC_MSG_RESULT($[]$1_CFLAGS) + succeeded="yes" + else + AC_MSG_CHECKING($1_CFLAGS) + $1_CFLAGS=`$ZZIP_CONFIG --cflags 2>&1` + AC_MSG_RESULT([(detecting errors...)]) + AC_MSG_WARN([... there is a problem with zzip-config]) + AC_MSG_WARN([... $[]$1_CFLAGS]) + AC_MSG_WARN([... inference of library requirements from prefix]) + succeeded=`echo $ZZIP_CONFIG | sed -e 's,/[^/]*,,'` # dirname + $1_CFLAGS="" + $1_LIBS="" + if test "/$succeeded" != "//usr" ; then + test -d "$succeeded/include" && $1_CFLAGS="-I$succeeded/include " + test -d "$succeeded/lib" && $1_LIBS="-L$succeeded/lib " + fi + $1_LIBS="$[]$1_LIBS -lzzip -lz" + succeeded="yes" + AC_MSG_CHECKING($1_CFLAGS... guessed) + AC_MSG_RESULT($[]$1_CFLAGS) + AC_MSG_CHECKING($1_LIBS... guessed) + AC_MSG_RESULT($[]$1_LIBS) + fi + fi + else + PKG_CONFIG_MIN_VERSION=0.9.0 + if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then + AC_MSG_CHECKING(for zziplib[]ifelse([$2],,,[ >= $2])) + + if $PKG_CONFIG --exists "zziplib[]ifelse([$2],,,[ >= $2])" ; then + AC_MSG_RESULT(yes) + succeeded=yes + + AC_MSG_CHECKING($1_CFLAGS) + $1_CFLAGS=`$PKG_CONFIG --cflags "zziplib[]ifelse([$2],,,[ >= $2])"` + AC_MSG_RESULT($$1_CFLAGS) + + AC_MSG_CHECKING($1_LIBS) + $1_LIBS=`$PKG_CONFIG --libs "zziplib[]ifelse([$2],,,[ >= $2])"` + AC_MSG_RESULT($$1_LIBS) + else + $1_CFLAGS="" + $1_LIBS="" + ## If we have a custom action on failure, don't print errors, but + ## do set a variable so people can do so. + $1_PKG_ERRORS=`$PKG_CONFIG dnl + --errors-to-stdout --print-errors "zziplib[]ifelse([$2],,,[ >= $2])"` + ifelse([$4], ,echo $$1_PKG_ERRORS,) + fi + + AC_SUBST($1_CFLAGS) + AC_SUBST($1_LIBS) + else + echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." + echo "*** See http://www.freedesktop.org/software/pkgconfig" + fi + fi + + if test $succeeded = yes; then + ifelse([$3], , :, [$3]) + else + succeeded="zziplib[]ifelse([$2],,,[ >= $2])" + ifelse([$4], ,[AC_MSG_ERROR([Library requirements ($succeeded) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])], [$4]) + fi +]) diff --git a/bins/zziptest.c b/bins/zziptest.c new file mode 100644 index 0000000..19cb999 --- /dev/null +++ b/bins/zziptest.c @@ -0,0 +1,134 @@ +/* + * Author: + * Guido Draheim + * Tomi Ollila + * + * Copyright (c) 1999,2000,2001,2002,2003 Guido Draheim + * All rights reserved, + * use under the restrictions of the + * Lesser GNU General Public License + * or alternatively the restrictions + * of the Mozilla Public License 1.1 + */ + +#include + +#if defined _MSC_VER /* Win32*/ +#define WIN32_LEAN_AND_MEAN +#include +#define sleep Sleep +#endif + +#include + +#ifdef ZZIP_HAVE_UNISTD_H +#include /* sleep */ +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +int main(int argc, char ** argv) +{ + ZZIP_DIR * dir; + const char * name = "test.zip"; + zzip_error_t rv; + int i; + + if (argc > 1 && argv[1] != NULL) + { + name = argv[1]; + argv++; argc--; + } + + printf("Opening zip file `%s'... ", name); + { int fd = open (name, O_RDONLY|O_BINARY); + if (fd == -1) { perror ("could not open input file"); return 0; } + if (! (dir = zzip_dir_fdopen(fd, &rv))) + { + printf("error %d.\n", rv); + return 0; + } + } printf("OK.\n"); + +#if 1 + printf("{check...\n"); + { struct zzip_dir_hdr * hdr = dir->hdr0; + + if (hdr == NULL) + { printf ("could not find first header in dir_hdr"); } + else + { + while (1) + { + printf("\ncompression method: %d", hdr->d_compr); + if (hdr->d_compr == 0) printf(" (stored)"); + else if (hdr->d_compr == 8) printf(" (deflated)"); + else printf(" (unknown)"); + printf("\ncrc32: %x\n", hdr->d_crc32); + printf("compressed size: %d\n", hdr->d_csize); + printf("uncompressed size: %d\n", hdr->d_usize); + printf("offset of file in archive: %d\n", hdr->d_off); + printf("filename: %s\n\n", hdr->d_name); + + if (hdr->d_reclen == 0) break; + (char *)hdr += hdr->d_reclen; + sleep(1); + } + } + } printf ("\n}\n"); +#endif +#if 1 + { printf("{contents...\n"); + for (i = 0; i < 2; i++) + { + ZZIP_DIRENT* d; + + while((d=zzip_readdir(dir))) + { + printf(" name \"%s\", compr %d, size %d, ratio %2d\n", + d->d_name, d->d_compr, d->st_size, + 100 - (d->d_csize|1)*100/(d->st_size|1)); + } + printf(" %d. time ---------------\n", i + 1); + zzip_rewinddir(dir); + } + printf("}...OK\n"); + } +#endif + + { ZZIP_FILE * fp; + char buf[17]; + const char * name = argv[1]? argv[1]: "readme"; + + + printf("Opening file `%s' in zip archive... ", name); + fp = zzip_file_open(dir, (char *)name, ZZIP_CASEINSENSITIVE); + + if (! fp) + { printf("error %d: %s\n", zzip_error(dir), zzip_strerror_of(dir)); } + else + { + printf("OK.\n"); + printf("Contents of the file:\n"); + + while (0 < (i = zzip_file_read(fp, buf, 16))) + { + buf[i] = '\0'; + /*printf("\n*** read %d ***\n", i); fflush(stdout); */ + printf("%s", buf); + /*write(1, buf, i);*/ /* Windows does not have write !!! */ + } + if (i < 0) printf("error %d\n", zzip_error(dir)); + } + } + + return 0; +} + +/* + * Local variables: + * c-file-style: "stroustrup" + * End: + */ diff --git a/zziplib.spec b/zziplib.spec new file mode 100644 index 0000000..f5c19c4 --- /dev/null +++ b/zziplib.spec @@ -0,0 +1,157 @@ +%define lib lib010 +Summary: ZZipLib - libZ-based ZIP-access Library +Name: zziplib +Version: 0.13.23 +Release: 1mdk +Serial: 1 +Copyright: LGPL +Group: Development/Libraries +URL: http://zziplib.sf.net +Vendor: Guido Draheim +Source0: http://prdownloads.sf.net/%{name}/%{name}-%{version}.tar.bz2 +BuildRoot: /var/tmp/%{name}-%{version}-%{release} + +Distribution: Original +Packager: Guido Draheim +Requires: zlib1 +BuildRequires: zlib1-devel +BuildRequires: libSDL1.2-devel + +#Begin3 +# Author1: too@iki.fi (Tomi Ollila) +# Author2: guidod@gmx.de (Guido Draheim) +# Maintained-by: guidod@gmx.de (Guido Draheim) +# Primary-Site: zziplib.sf.net +# Keywords: zip zlib inflate archive gamedata +# Platforms: zlib posix +# Copying-Policy: Lesser GPL Version 2 +#End + +%package %lib +Summary: ZZipLib - Documentation Files +Group: Development/Libraries +Provides: zziplib +Provides: libzzip0 +Provides: libzzip-0.so.10 + +%package doc +Summary: ZZipLib - Documentation Files +Group: Development/Libraries + +%package devel +Summary: ZZipLib - Development Files +Group: Development/Libraries +Requires: zziplib-%lib = %version +# Requires: pkgconfig (not yet) + +%description + : zziplib provides read access to zipped files in a zip-archive, + : using compression based solely on free algorithms provided by zlib. + +%description %lib + : zziplib provides read access to zipped files in a zip-archive, + : using compression based solely on free algorithms provided by zlib. + zziplib provides an additional API to transparently access files + being either real files or zipped files with the same filepath argument. + This is handy to package many files being shared data into a single + zip file - as it is sometimes used with gamedata or script repositories. + The library itself is fully multithreaded, and it is namespace clean + using the zzip_ prefix for its exports and declarations. + +%description doc + : zziplib provides read access to zipped files in a zip-archive, + : using compression based solely on free algorithms provided by zlib. + these are the (html) docs, mostly generated actually. + +%description devel + : zziplib provides read access to zipped files in a zip-archive, + : using compression based solely on free algorithms provided by zlib. + these are the header files needed to develop programs using zziplib. + there are test binaries to hint usage of the library in user programs. + +%prep +#' +%setup +# fixing relink problems during install too +LDFLAGS="-L%buildroot%_libdir" \ +CFLAGS="$RPM_OPT_FLAGS" \ +sh configure --prefix=%{_prefix} --enable-sdl --disable-builddir \ + --with-docdir=%{_docdir} --mandir=%{_mandir} TIMEOUT=9 +cp -a zzip zzip64 + +%build +%define _FILE_OFFSET64 -D_ZZIP_LARGEFILE -D_FILE_OFFSET_BITS=64 +%define _RELEASEINFO64 "RELEASE_INFO=-release 0-64" +%define _CFLAGS_OFFSET64 "AM_CFLAGS=%_FILE_OFFSET64" +make +(cd zzip64 && make %_CFLAGS_OFFSET64 %_RELEASEINFO64) +make doc + +%install +rm -rf %{buildroot} +(cd zzip64 && make install %_RELEASEINFO64 DESTDIR=%{buildroot}) +(cd %buildroot/%_libdir && mv libzzip.so libzzip64.so) +(cd %buildroot/%_libdir && mv libzzip.a libzzip64.a) +(cd %buildroot/%_libdir && \ +sed -e 's/zzip.so/zzip64.so/' -e 's/zzip.a/zzip64.a/' libzzip.la >libzzip64.la) +(cd %buildroot/%_libdir/pkgconfig && \ +sed -e 's/largefile=/largefile= %_FILE_OFFSET64/' \ + -e 's/-lzzip/-lzzip64/' -e 's/zziplib/zziplib64/' zziplib.pc >zziplib64.pc) + +make install DESTDIR=%{buildroot} +(cd %buildroot/%_libdir && mv libzzip.so libzzip32.so) +(cd %buildroot/%_libdir && mv libzzip.a libzzip32.a) +(cd %buildroot/%_libdir && ln -s libzzip32.so libzzip.so) +(cd %buildroot/%_libdir && ln -s libzzip32.a libzzip.a) +(cd %buildroot/%_libdir && \ +sed -e 's/zzip.so/zzip32.so/' -e 's/zzip.a/zzip32.a/' libzzip.la >libzzip32.la) +(cd %buildroot/%_libdir/pkgconfig && \ +sed -e 's/-lzzip/-lzzip32/' -e 's/zziplib/zziplib32/' zziplib.pc >zziplib32.pc) + +# the 12.8x and 11.8x and 10.8x packages are all the same actually +(cd %buildroot/%_libdir && \ +(for i in libzzip*.so.1? ; do : \ +; v10=`echo $i | sed -e "s/.so.../.so.10/"` \ +; v11=`echo $i | sed -e "s/.so.../.so.11/"` \ +; v12=`echo $i | sed -e "s/.so.../.so.12/"` \ +; test ! -e $v10 && test -e $v12 && ln -s $v12 $v10 \ +; test ! -e $v12 && test -e $v10 && ln -s $v10 $v12 \ +; ln -s $v10 $v11 || true; done)) + +make install-doc DESTDIR=%{buildroot} +make install-man3 DESTDIR=%{buildroot} + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%clean +rm -rf %{buildroot} + +%files %lib + %defattr(-,root,root) + %{_libdir}/lib*.so.* + +%files doc + %defattr(-,root,root) + %{_datadir}/groups/* +%dir %{_datadir}/omf/%{name} + %{_datadir}/omf/%{name}/* +%post doc +test ! -f /usr/bin/scrollkeeper-update || /usr/bin/scrollkeeper-update +%postun doc +test ! -f /usr/bin/scrollkeeper-update || /usr/bin/scrollkeeper-update + +%files devel + %defattr(-,root,root) + %{_bindir}/* +%dir %{_includedir}/zzip + %{_includedir}/zzip/* + %{_includedir}/*.h + %{_libdir}/lib*.so + %{_libdir}/lib*.a + %{_libdir}/lib*.la + %{_libdir}/pkgconfig/* +%dir %{_datadir}/%{name} + %{_datadir}/%{name}/* + %{_datadir}/aclocal/%{name}*.m4 + %{_mandir}/man3/* -- 2.40.0