Skip to content

Commit

Permalink
This commit was generated by cvs2svn to compensate for changes in r97…
Browse files Browse the repository at this point in the history
…, which

included commits to RCS files with non-trunk default branches.
  • Loading branch information
gdraheim committed Aug 18, 2003
1 parent b7d3739 commit bb2adbf
Show file tree
Hide file tree
Showing 5 changed files with 485 additions and 0 deletions.
50 changes: 50 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 39 additions & 0 deletions bins/Makefile.am
Original file line number Diff line number Diff line change
@@ -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 $@`)
105 changes: 105 additions & 0 deletions bins/zziplib.m4
Original file line number Diff line number Diff line change
@@ -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
])
134 changes: 134 additions & 0 deletions bins/zziptest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Author:
* Guido Draheim <[email protected]>
* Tomi Ollila <[email protected]>
*
* 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 <stdio.h>

#if defined _MSC_VER /* Win32*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define sleep Sleep
#endif

#include <zzip/lib.h>

#ifdef ZZIP_HAVE_UNISTD_H
#include <unistd.h> /* 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:
*/
Loading

0 comments on commit bb2adbf

Please sign in to comment.