summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-0.13.58/zzip
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-0.13.58/zzip')
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile22
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.am142
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.in712
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/__debug.h89
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/__dirent.h393
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/__fnmatch.h28
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/__hints.h189
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/__mmap.h107
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/_config.h248
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.h211
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.sed26
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/autoconf.h45
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/conf.h273
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/dir.c296
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c156
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.c117
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.h343
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.c1032
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.h81
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/format.h233
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.c580
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.h116
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.c161
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.h25
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/lib.h83
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.c394
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.h162
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.c566
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.h120
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.c84
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.h96
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/stat.c122
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/stdint.h45
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/types.h51
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/write.c461
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/zip.c759
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.58/zzip/zzip.h323
-rwxr-xr-xBuild/source/libs/zziplib/zziplib-0.13.58/zzip/zziplib.wpj103
38 files changed, 8994 insertions, 0 deletions
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile
new file mode 100644
index 00000000000..0380cd25c4d
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile
@@ -0,0 +1,22 @@
+
+top_srcdir = ../../../../libs/zziplib
+srcdir = $(top_srcdir)/zzip
+
+CC = gcc
+AR = ar cru
+RANLIB = ranlib
+
+OBJECTS =dir.o err.o fetch.o file.o info.o memdisk.o mmapped.o \
+ plugin.o stat.o write.o zip.o
+
+_CFLAGS = -DHAVE_CONFIG_H -I.. -I../../../../libs/zziplib -I../../../../libs/zlib
+
+XCFLAGS = $(_CFLAGS)
+
+all: $(OBJECTS)
+ $(AR) libzzip.a $(OBJECTS)
+ $(RANLIB) libzzip.a
+
+%.o: $(srcdir)/%.c
+ $(CC) $(CFLAGS) $(XCFLAGS) -c $< -o $@
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.am b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.am
new file mode 100644
index 00000000000..95fb8f17f78
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.am
@@ -0,0 +1,142 @@
+AUTOMAKE_OPTIONS = 1.5 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
+
+lib_LTLIBRARIES = libzzip.la libzzipmmapped.la libzzipfseeko.la
+zzipdir = ${includedir}/zzip
+zzip_HEADERS = $(libzzip_la_headers) \
+ $(libzzipmmapped_la_headers) \
+ $(libzzipfseeko_la_headers)
+noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h
+#
+VERSION_INFO=@VERSION_INFO@
+RELEASE_INFO=@RELEASE_INFO@
+THREAD_SAFE=@THREAD_SAFE@
+#
+
+libzzip_la_SOURCES = \
+ zip.c \
+ file.c \
+ dir.c \
+ stat.c \
+ info.c \
+ err.c \
+ plugin.c \
+ write.c \
+ fetch.c
+libzzip_la_headers = \
+ stdint.h \
+ file.h \
+ plugin.h \
+ lib.h \
+ zzip.h \
+ fetch.h \
+ format.h \
+ info.h \
+ autoconf.h \
+ types.h \
+ conf.h \
+ _config.h \
+ _msvc.h
+libzzip_la_LDFLAGS= @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+libzzip_la_LIBADD= -lz @RESOLVES@
+
+libzzipmmapped_la_SOURCES = mmapped.c memdisk.c fetch.c
+libzzipmmapped_la_headers = mmapped.h memdisk.h fetch.h
+libzzipmmapped_la_LDFLAGS= @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+libzzipmmapped_la_LIBADD= -lz @RESOLVES@
+
+libzzipfseeko_la_SOURCES = fseeko.c fetch.c
+libzzipfseeko_la_headers = fseeko.h fetch.h
+libzzipfseeko_la_LDFLAGS= @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+libzzipfseeko_la_LIBADD= -lz @RESOLVES@
+
+WCC10_DIST = zziplib.wpj
+WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt
+
+EXTRA_DIST = $(WCC10_DIST) _msvc.sed
+CONFIG_CLEAN_FILES = _config.h
+MAINTAINERCLEANFILES = _msvc.h
+CLEANFILES = $(WCC10_CLEAN) *.pc *.omf
+
+# here is some backward compatibility with version 0.10.* of zziplib
+install-data-local : install-zzipHEADERS
+ echo '#ifndef ZZIP_WARNING' > $(DESTDIR)$(includedir)/zzip.h
+ echo '#define ZZIP_WARNING 1' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#ifdef __GNUC__' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#warning do no not use <zzip.h>, update to include <zzip/lib.h>'\
+ >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#else' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#error do no not use <zzip.h>, update to include <zzip/lib.h>'\
+ >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#endif' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#endif' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#include "zzip/lib.h"' >>$(DESTDIR)$(includedir)/zzip.h
+ sed -e 's|zzip.h|zziplib.h|' -e 's|zzip/lib.h|zzip/zzip.h|' \
+ $(DESTDIR)$(includedir)/zzip.h >$(DESTDIR)$(includedir)/zziplib.h
+ sed -e 's|zzip.h|zzip-io.h|' -e 's|zzip/lib.h|zzip/plugin.h|' \
+ $(DESTDIR)$(includedir)/zzip.h >$(DESTDIR)$(includedir)/zzip-io.h
+
+install-exec-local:
+ @ for i in . $(DESTDIR)$(libdir)/libzzip*.so.13 \
+ ; do test -d $$i && continue ; lib=`basename "$$i" .so.13` \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.10" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.10) \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.11" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.11) \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.12" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.12) \
+ ; done ; true
+
+uninstall-local :
+ (cd $(DESTDIR)$(includedir) && rm zziplib.h zzip.h zzip-io.h)
+
+
+# ----------------------------------------------------------------------
+pkgconfigdir=$(libdir)/pkgconfig
+pkgconfig_HEADERS= zzip-zlib-config.pc zziplib.pc \
+ zzipmmapped.pc zzipfseeko.pc
+
+zziplib.pc : Makefile
+ (cd .. && sh config.status zzip/zziplib.pc)
+
+zzip-zlib-config.pc : Makefile
+ @ echo "zlib_libs=@ZLIB_LDIR@ -lz" >$@
+ @ echo "zlib_cflags=@ZLIB_INCL@" >>$@
+ @ echo " " >>$@
+ @ echo "Name: zzip-zlib-config" >>$@
+ @ echo "Version: @ZLIB_VERSION@" >>$@
+ @ echo "Description: ZLib Config (for ZZipLib)" >>$@
+ echo 'Libs: $${zlib_libs}' >>$@
+ echo 'Cflags: $${zlib_cflags}' >>$@
+
+zzipmmapped.pc : zziplib.pc
+ sed -e 's/-lzzip/-lzzipmmapped/' -e 's/zziplib/zzipmmapped/' \
+ zziplib.pc >$@
+zzipfseeko.pc : zziplib.pc
+ sed -e 's/-lzzip/-lzzipfseeko/' -e 's/zziplib/zzipfseeko/' \
+ zziplib.pc >$@
+
+__zziplib.pc : Makefile
+ @ echo "prefix=$(prefix)" >$@
+ @ echo "libdir=$(libdir)" >>$@
+ @ echo "includedir=$(includedir)" >>$@
+ @ echo "largefile=$(LARGEFILE_CFLAGS)" >>$@
+ @ echo "zlib_libs=@ZLIB_LDIR@ -lz" >>$@
+ @ echo "zlib_cflags=@ZLIB_INCL@" >>$@
+ @ echo " " >>$@
+ @ echo "Name: zziplib" >>$@
+ @ echo "Version: $(VERSION)" >>$@
+ @ head $(top_srcdir)/$(PACKAGE).spec \
+ | grep Summary | sed -e s,Summary,Description, >> $@
+ echo 'Requires: zzip-zlib-config' >>$@
+ echo 'Libs: -L$${libdir} -lzzip' >>$@
+ echo 'Cflags: $${largefile} -I$${includedir}' >>$@
+
+# ----------------------------------------------------------------------
+.c.i :
+ $(COMPILE) -E $< >$@
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.in b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.in
new file mode 100644
index 00000000000..695af34ae04
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/Makefile.in
@@ -0,0 +1,712 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = zzip
+DIST_COMMON = $(noinst_HEADERS) $(pkgconfig_HEADERS) \
+ $(srcdir)/Makefile.am $(srcdir)/Makefile.in $(zzip_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
+ $(top_srcdir)/m4/ac_set_default_paths_system.m4 \
+ $(top_srcdir)/m4/ac_sys_largefile_sensitive.m4 \
+ $(top_srcdir)/m4/acx_restrict.m4 \
+ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \
+ $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
+ $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+ $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
+ $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
+ $(top_srcdir)/m4/ax_expand_prefix.m4 \
+ $(top_srcdir)/m4/ax_maintainer_mode_auto_silent.m4 \
+ $(top_srcdir)/m4/ax_not_enable_frame_pointer.m4 \
+ $(top_srcdir)/m4/ax_prefix_config_h.m4 \
+ $(top_srcdir)/m4/ax_set_version_info.m4 \
+ $(top_srcdir)/m4/ax_spec_file.m4 \
+ $(top_srcdir)/m4/ax_spec_package_version.m4 \
+ $(top_srcdir)/m4/ax_warning_default_aclocaldir.m4 \
+ $(top_srcdir)/m4/ax_warning_default_pkgconfig.m4 \
+ $(top_srcdir)/m4/patch_libtool_on_darwin_zsh_overquoting.m4 \
+ $(top_srcdir)/m4/patch_libtool_sys_lib_search_path_spec.m4 \
+ $(top_srcdir)/m4/patch_libtool_to_add_host_cc.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/uses/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \
+ "$(DESTDIR)$(zzipdir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libzzip_la_DEPENDENCIES =
+am_libzzip_la_OBJECTS = zip.lo file.lo dir.lo stat.lo info.lo err.lo \
+ plugin.lo write.lo fetch.lo
+libzzip_la_OBJECTS = $(am_libzzip_la_OBJECTS)
+libzzipfseeko_la_DEPENDENCIES =
+am_libzzipfseeko_la_OBJECTS = fseeko.lo fetch.lo
+libzzipfseeko_la_OBJECTS = $(am_libzzipfseeko_la_OBJECTS)
+libzzipmmapped_la_DEPENDENCIES =
+am_libzzipmmapped_la_OBJECTS = mmapped.lo memdisk.lo fetch.lo
+libzzipmmapped_la_OBJECTS = $(am_libzzipmmapped_la_OBJECTS)
+depcomp = $(SHELL) $(top_srcdir)/uses/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libzzip_la_SOURCES) $(libzzipfseeko_la_SOURCES) \
+ $(libzzipmmapped_la_SOURCES)
+DIST_SOURCES = $(libzzip_la_SOURCES) $(libzzipfseeko_la_SOURCES) \
+ $(libzzipmmapped_la_SOURCES)
+pkgconfigHEADERS_INSTALL = $(INSTALL_HEADER)
+zzipHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(noinst_HEADERS) $(pkgconfig_HEADERS) $(zzip_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CONFIG_FILES = @CONFIG_FILES@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@ -I$(top_builddir) -I$(top_srcdir) # also for automake 1.4
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LARGEFILE_CFLAGS = @LARGEFILE_CFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MKZIP = @MKZIP@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PYTHON = @PYTHON@
+RANLIB = @RANLIB@
+RELEASE_INFO = @RELEASE_INFO@
+RESOLVES = @RESOLVES@
+SDL = @SDL@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+THREAD_SAFE = @THREAD_SAFE@
+VERSION = @VERSION@
+#
+VERSION_INFO = @VERSION_INFO@
+XMLTO = @XMLTO@
+ZIPTESTS = @ZIPTESTS@
+ZLIB_INCL = @ZLIB_INCL@
+ZLIB_LDIR = @ZLIB_LDIR@
+ZLIB_VERSION = @ZLIB_VERSION@
+ZZIPLIB_LDFLAGS = @ZZIPLIB_LDFLAGS@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_AS = @ac_ct_AS@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+aclocaldir = @aclocaldir@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+docdir = @docdir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pkgconfig_libdir = @pkgconfig_libdir@
+pkgconfig_libfile = @pkgconfig_libfile@
+
+# ----------------------------------------------------------------------
+pkgconfigdir = $(libdir)/pkgconfig
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+AUTOMAKE_OPTIONS = 1.5 foreign
+AUTOTOOL_VERSION = autoconf-2.52 automake-1.5 libtool-1.4.2
+DEFAULT_INCLUDES = # nothing - no default of -I. -I$(srcdir)
+lib_LTLIBRARIES = libzzip.la libzzipmmapped.la libzzipfseeko.la
+zzipdir = ${includedir}/zzip
+zzip_HEADERS = $(libzzip_la_headers) \
+ $(libzzipmmapped_la_headers) \
+ $(libzzipfseeko_la_headers)
+
+noinst_HEADERS = __debug.h __hints.h __mmap.h __dirent.h __fnmatch.h
+#
+libzzip_la_SOURCES = \
+ zip.c \
+ file.c \
+ dir.c \
+ stat.c \
+ info.c \
+ err.c \
+ plugin.c \
+ write.c \
+ fetch.c
+
+libzzip_la_headers = \
+ stdint.h \
+ file.h \
+ plugin.h \
+ lib.h \
+ zzip.h \
+ fetch.h \
+ format.h \
+ info.h \
+ autoconf.h \
+ types.h \
+ conf.h \
+ _config.h \
+ _msvc.h
+
+libzzip_la_LDFLAGS = @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+
+libzzip_la_LIBADD = -lz @RESOLVES@
+libzzipmmapped_la_SOURCES = mmapped.c memdisk.c fetch.c
+libzzipmmapped_la_headers = mmapped.h memdisk.h fetch.h
+libzzipmmapped_la_LDFLAGS = @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+
+libzzipmmapped_la_LIBADD = -lz @RESOLVES@
+libzzipfseeko_la_SOURCES = fseeko.c fetch.c
+libzzipfseeko_la_headers = fseeko.h fetch.h
+libzzipfseeko_la_LDFLAGS = @ZZIPLIB_LDFLAGS@ $(RELEASE_INFO) $(VERSION_INFO) \
+ $(THREAD_SAFE)
+
+libzzipfseeko_la_LIBADD = -lz @RESOLVES@
+WCC10_DIST = zziplib.wpj
+WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt
+EXTRA_DIST = $(WCC10_DIST) _msvc.sed
+CONFIG_CLEAN_FILES = _config.h
+MAINTAINERCLEANFILES = _msvc.h
+CLEANFILES = $(WCC10_CLEAN) *.pc *.omf
+pkgconfig_HEADERS = zzip-zlib-config.pc zziplib.pc \
+ zzipmmapped.pc zzipfseeko.pc
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .i .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign zzip/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign zzip/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libzzip.la: $(libzzip_la_OBJECTS) $(libzzip_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libzzip_la_LDFLAGS) $(libzzip_la_OBJECTS) $(libzzip_la_LIBADD) $(LIBS)
+libzzipfseeko.la: $(libzzipfseeko_la_OBJECTS) $(libzzipfseeko_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libzzipfseeko_la_LDFLAGS) $(libzzipfseeko_la_OBJECTS) $(libzzipfseeko_la_LIBADD) $(LIBS)
+libzzipmmapped.la: $(libzzipmmapped_la_OBJECTS) $(libzzipmmapped_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libzzipmmapped_la_LDFLAGS) $(libzzipmmapped_la_OBJECTS) $(libzzipmmapped_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fetch.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseeko.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memdisk.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmapped.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zip.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-pkgconfigHEADERS: $(pkgconfig_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgconfigdir)" || $(mkdir_p) "$(DESTDIR)$(pkgconfigdir)"
+ @list='$(pkgconfig_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(pkgconfigHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+ $(pkgconfigHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+ done
+
+uninstall-pkgconfigHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+ done
+install-zzipHEADERS: $(zzip_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(zzipdir)" || $(mkdir_p) "$(DESTDIR)$(zzipdir)"
+ @list='$(zzip_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(zzipHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(zzipdir)/$$f'"; \
+ $(zzipHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(zzipdir)/$$f"; \
+ done
+
+uninstall-zzipHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(zzip_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(zzipdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(zzipdir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(zzipdir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-data-local install-pkgconfigHEADERS \
+ install-zzipHEADERS
+
+install-exec-am: install-exec-local install-libLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-local uninstall-pkgconfigHEADERS \
+ uninstall-zzipHEADERS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am \
+ install-data-local install-exec install-exec-am \
+ install-exec-local install-info install-info-am \
+ install-libLTLIBRARIES install-man install-pkgconfigHEADERS \
+ install-strip install-zzipHEADERS installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-info-am uninstall-libLTLIBRARIES \
+ uninstall-local uninstall-pkgconfigHEADERS \
+ uninstall-zzipHEADERS
+
+
+# here is some backward compatibility with version 0.10.* of zziplib
+install-data-local : install-zzipHEADERS
+ echo '#ifndef ZZIP_WARNING' > $(DESTDIR)$(includedir)/zzip.h
+ echo '#define ZZIP_WARNING 1' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#ifdef __GNUC__' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#warning do no not use <zzip.h>, update to include <zzip/lib.h>'\
+ >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#else' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#error do no not use <zzip.h>, update to include <zzip/lib.h>'\
+ >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#endif' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#endif' >>$(DESTDIR)$(includedir)/zzip.h
+ echo '#include "zzip/lib.h"' >>$(DESTDIR)$(includedir)/zzip.h
+ sed -e 's|zzip.h|zziplib.h|' -e 's|zzip/lib.h|zzip/zzip.h|' \
+ $(DESTDIR)$(includedir)/zzip.h >$(DESTDIR)$(includedir)/zziplib.h
+ sed -e 's|zzip.h|zzip-io.h|' -e 's|zzip/lib.h|zzip/plugin.h|' \
+ $(DESTDIR)$(includedir)/zzip.h >$(DESTDIR)$(includedir)/zzip-io.h
+
+install-exec-local:
+ @ for i in . $(DESTDIR)$(libdir)/libzzip*.so.13 \
+ ; do test -d $$i && continue ; lib=`basename "$$i" .so.13` \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.10" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.10) \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.11" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.11) \
+ ; echo "$(DESTDIR)$(libdir): ln -s $$lib.so.13 $$lib.so.12" \
+ ; (cd $(DESTDIR)$(libdir) && ln -s $$lib.so.13 $$lib.so.12) \
+ ; done ; true
+
+uninstall-local :
+ (cd $(DESTDIR)$(includedir) && rm zziplib.h zzip.h zzip-io.h)
+
+zziplib.pc : Makefile
+ (cd .. && sh config.status zzip/zziplib.pc)
+
+zzip-zlib-config.pc : Makefile
+ @ echo "zlib_libs=@ZLIB_LDIR@ -lz" >$@
+ @ echo "zlib_cflags=@ZLIB_INCL@" >>$@
+ @ echo " " >>$@
+ @ echo "Name: zzip-zlib-config" >>$@
+ @ echo "Version: @ZLIB_VERSION@" >>$@
+ @ echo "Description: ZLib Config (for ZZipLib)" >>$@
+ echo 'Libs: $${zlib_libs}' >>$@
+ echo 'Cflags: $${zlib_cflags}' >>$@
+
+zzipmmapped.pc : zziplib.pc
+ sed -e 's/-lzzip/-lzzipmmapped/' -e 's/zziplib/zzipmmapped/' \
+ zziplib.pc >$@
+zzipfseeko.pc : zziplib.pc
+ sed -e 's/-lzzip/-lzzipfseeko/' -e 's/zziplib/zzipfseeko/' \
+ zziplib.pc >$@
+
+__zziplib.pc : Makefile
+ @ echo "prefix=$(prefix)" >$@
+ @ echo "libdir=$(libdir)" >>$@
+ @ echo "includedir=$(includedir)" >>$@
+ @ echo "largefile=$(LARGEFILE_CFLAGS)" >>$@
+ @ echo "zlib_libs=@ZLIB_LDIR@ -lz" >>$@
+ @ echo "zlib_cflags=@ZLIB_INCL@" >>$@
+ @ echo " " >>$@
+ @ echo "Name: zziplib" >>$@
+ @ echo "Version: $(VERSION)" >>$@
+ @ head $(top_srcdir)/$(PACKAGE).spec \
+ | grep Summary | sed -e s,Summary,Description, >> $@
+ echo 'Requires: zzip-zlib-config' >>$@
+ echo 'Libs: -L$${libdir} -lzzip' >>$@
+ echo 'Cflags: $${largefile} -I$${includedir}' >>$@
+
+# ----------------------------------------------------------------------
+.c.i :
+ $(COMPILE) -E $< >$@
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__debug.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__debug.h
new file mode 100644
index 00000000000..13c7d895443
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__debug.h
@@ -0,0 +1,89 @@
+#ifndef __ZZIP_INTERNAL_DEBUG_H
+#define __ZZIP_INTERNAL_DEBUG_H
+
+#include <zzip/conf.h>
+#include <zzip/__hints.h>
+
+/* perhaps want to show on syslog(3) ?? */
+
+#ifdef DEBUG
+#include <stdio.h>
+#define DBG1(X1) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ); } ZZIP_END1
+#define DBG2(X1,X2) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ,X2);} ZZIP_END1
+#define DBG3(X1,X2,X3) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ,X2,X3); } ZZIP_END1
+#define DBG4(X1,X2,X3,X4) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ,X2,X3,X4); } ZZIP_END1
+#define DBG5(X1,X2,X3,X4,X5) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ,X2,X3,X4,X5); } ZZIP_END1
+#define DBG6(X1,X2,X3,X4,X5,X6) ZZIP_FOR1 { \
+ fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
+ ,X2,X3,X4,X5,X6); } ZZIP_END1
+
+#else
+#define DBG1(X1) {}
+#define DBG2(X1,X2) {}
+#define DBG3(X1,X2,X3) {}
+#define DBG4(X1,X2,X3,X4) {}
+#define DBG5(X1,X2,X3,X4,X5) {}
+#define DBG6(X1,X2,X3,X4,X5,X6) {}
+#endif
+
+#define HINT1(X1) DBG1("HINT: " X1)
+#define HINT2(X1,X2) DBG2("HINT: " X1,X2)
+#define HINT3(X1,X2,X3) DBG3("HINT: " X1,X2,X3)
+#define HINT4(X1,X2,X3,X4) DBG4("HINT: " X1,X2,X3,X4)
+#define HINT5(X1,X2,X3,X4,X5) DBG5("HINT: " X1,X2,X3,X4,X5)
+#define HINT6(X1,X2,X3,X4,X5,X6) DBG6("HINT: " X1,X2,X3,X4,X5,X6)
+
+#define NOTE1(X1) DBG1("NOTE: " X1)
+#define NOTE2(X1,X2) DBG2("NOTE: " X1,X2)
+#define NOTE3(X1,X2,X3) DBG3("NOTE: " X1,X2,X3)
+#define NOTE4(X1,X2,X3,X4) DBG4("NOTE: " X1,X2,X3,X4)
+#define NOTE5(X1,X2,X3,X4,X5) DBG5("NOTE: " X1,X2,X3,X4,X5)
+#define NOTE6(X1,X2,X3,X4,X5,X6) DBG6("NOTE: " X1,X2,X3,X4,X5,X6)
+
+#define WARN1(X1) DBG1("WARN: " X1)
+#define WARN2(X1,X2) DBG2("WARN: " X1,X2)
+#define WARN3(X1,X2,X3) DBG3("WARN: " X1,X2,X3)
+#define WARN4(X1,X2,X3,X4) DBG4("WARN: " X1,X2,X3,X4)
+#define WARN5(X1,X2,X3,X4,X5) DBG5("WARN: " X1,X2,X3,X4,X5)
+#define WARN6(X1,X2,X3,X4,X5,X6) DBG6("WARN: " X1,X2,X3,X4,X5,X6)
+
+#define FAIL1(X1) DBG1("FAIL: " X1)
+#define FAIL2(X1,X2) DBG2("FAIL: " X1,X2)
+#define FAIL3(X1,X2,X3) DBG3("FAIL: " X1,X2,X3)
+#define FAIL4(X1,X2,X3,X4) DBG4("FAIL: " X1,X2,X3,X4)
+#define FAIL5(X1,X2,X3,X4,X5) DBG5("FAIL: " X1,X2,X3,X4,X5)
+#define FAIL6(X1,X2,X3,X4,X5,X6) DBG6("FAIL: " X1,X2,X3,X4,X5,X6)
+
+
+
+#ifdef DEBUG
+_zzip_inline static void zzip_debug_xbuf (unsigned char* p, int l)
+ /* ZZIP_GNUC_UNUSED */
+{
+# define q(a) ((a&0x7F)<32?32:(a&0x7F))
+ while (l > 0)
+ {
+ fprintf (stderr,
+ "%02x %02x %02x %02x "
+ "%02x %02x %02x %02x "
+ "%c%c%c%c %c%c%c%c\n",
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
+ q(p[0]), q(p[1]), q(p[2]), q(p[3]),
+ q(p[4]), q(p[5]), q(p[6]), q(p[7]));
+ p += 8; l -= 8;
+ }
+# undef q
+}
+#endif
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__dirent.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__dirent.h
new file mode 100644
index 00000000000..fc3e08f03d1
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__dirent.h
@@ -0,0 +1,393 @@
+#ifndef ZZIP_INTERNAL_DIRENT_H
+#define ZZIP_INTERNAL_DIRENT_H
+#include <zzip/conf.h>
+
+/*
+ * DO NOT USE THIS CODE.
+ *
+ * It is an internal header file for zziplib that carries some inline
+ * functions (or just static members) and a few defines, simply to be
+ * able to reuse these across - and have everything in a specific place.
+ *
+ * Copyright (c) 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
+ */
+
+#ifdef ZZIP_HAVE_DIRENT_H
+#define USE_DIRENT 1
+
+#define _zzip_opendir opendir
+#define _zzip_readdir readdir
+#define _zzip_closedir closedir
+#define _zzip_rewinddir rewinddir
+#define _zzip_telldir telldir
+#define _zzip_seekdir seekdir
+#define _zzip_DIR DIR
+
+#include <dirent.h>
+
+#elif defined ZZIP_HAVE_WINBASE_H
+#define USE_DIRENT 2
+
+#define _zzip_opendir win32_opendir
+#define _zzip_readdir win32_readdir
+#define _zzip_closedir win32_closedir
+#define _zzip_rewinddir win32_rewinddir
+#define _zzip_telldir win32_telldir
+#define _zzip_seekdir win32_seekdir
+#define _zzip_DIR DIR
+
+/*
+ * DIRENT.H (formerly DIRLIB.H)
+ *
+ * by M. J. Weinstein Released to public domain 1-Jan-89
+ *
+ * Because I have heard that this feature (opendir, readdir, closedir)
+ * it so useful for programmers coming from UNIX or attempting to port
+ * UNIX code, and because it is reasonably light weight, I have included
+ * it in the Mingw32 package. I have also added an implementation of
+ * rewinddir, seekdir and telldir.
+ * - Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ * This code is distributed in the hope that is will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includeds but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#include <io.h>
+
+struct dirent
+{
+ long d_ino; /* Always zero. */
+ unsigned short d_reclen; /* Always zero. */
+ unsigned short d_namlen; /* Length of name in d_name. */
+ char* d_name; /* File name. */
+ /* NOTE: The name in the dirent structure points to the name in the
+ * finddata_t structure in the DIR. */
+};
+
+/*
+ * This is an internal data structure. Good programmers will not use it
+ * except as an argument to one of the functions below.
+ */
+typedef struct
+{
+ /* disk transfer area for this dir */
+ struct _finddata_t dd_dta;
+
+ /* dirent struct to return from dir (NOTE: this makes this thread
+ * safe as long as only one thread uses a particular DIR struct at
+ * a time) */
+ struct dirent dd_dir;
+
+ /* _findnext handle */
+ long dd_handle;
+
+ /*
+ * Status of search:
+ * 0 = not started yet (next entry to read is first entry)
+ * -1 = off the end
+ * positive = 0 based index of next entry
+ */
+ short dd_stat;
+
+ /* given path for dir with search pattern (struct is extended) */
+ char dd_name[1];
+} DIR;
+
+/*
+ * dirent.c
+ *
+ * Derived from DIRLIB.C by Matt J. Weinstein
+ * This note appears in the DIRLIB.H
+ * DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89
+ *
+ * Updated by Jeremy Bettis <jeremy@hksys.com>
+ * Significantly revised and rewinddir, seekdir and telldir added by Colin
+ * Peters <colin@fu.is.saga-u.ac.jp>
+ */
+
+#include <direct.h>
+#include <errno.h>
+#include <io.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#define win32_SUFFIX "*"
+#define win32_SLASH "\\"
+
+#ifndef S_ISDIR
+#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */
+#endif S_ISDIR
+
+
+/*
+ opendir
+
+ Returns a pointer to a DIR structure appropriately filled in to begin
+ searching a directory.
+*/
+static DIR*
+win32_opendir (const char *szPath)
+{
+ DIR *nd;
+ struct _stat statDir;
+
+ errno = 0;
+
+ if (!szPath) {
+ errno = EFAULT;
+ return (DIR *) 0;
+ }
+
+ if (szPath[0] == '\0') {
+ errno = ENOTDIR;
+ return (DIR *) 0;
+ }
+
+ /* Attempt to determine if the given path really is a directory. */
+ if (_stat (szPath, &statDir)) {
+ /* Error, stat should have set an error value. */
+ return (DIR *) 0;
+ }
+
+ if (!S_ISDIR (statDir.st_mode)) {
+ /* Error, stat reports not a directory. */
+ errno = ENOTDIR;
+ return (DIR *) 0;
+ }
+
+ /* Allocate enough space to store DIR structure and the complete *
+ directory path given. */
+ nd = (DIR *) calloc (1, sizeof (DIR) + strlen (szPath)
+ + strlen (win32_SLASH) + strlen (win32_SUFFIX));
+
+ if (!nd) {
+ /* Error, out of memory. */
+ errno = ENOMEM;
+ return (DIR *) 0;
+ }
+
+ /* Create the search expression. */
+ strcpy (nd->dd_name, szPath);
+
+ /* Add on a slash if the path does not end with one. */
+ if (nd->dd_name[0] != '\0' &&
+ nd->dd_name[strlen (nd->dd_name) - 1] != '/' &&
+ nd->dd_name[strlen (nd->dd_name) - 1] != '\\') {
+ strcat (nd->dd_name, win32_SLASH);
+ }
+
+ /* Add on the search pattern */
+ strcat (nd->dd_name, win32_SUFFIX);
+
+ /* Initialize handle to -1 so that a premature closedir doesn't try * to
+ call _findclose on it. */
+ nd->dd_handle = -1;
+
+ /* Initialize the status. */
+ nd->dd_stat = 0;
+
+ /* Initialize the dirent structure. ino and reclen are invalid under *
+ Win32, and name simply points at the appropriate part of the *
+ findfirst_t structure. */
+ nd->dd_dir.d_ino = 0;
+ nd->dd_dir.d_reclen = 0;
+ nd->dd_dir.d_namlen = 0;
+ nd->dd_dir.d_name = nd->dd_dta.name;
+
+ return nd;
+}
+
+/*
+ readdir
+
+ Return a pointer to a dirent structure filled with the information on the
+ next entry in the directory.
+*/
+static struct dirent *
+win32_readdir (DIR * dirp)
+{
+ errno = 0;
+
+ /* Check for valid DIR struct. */
+ if (!dirp) {
+ errno = EFAULT;
+ return (struct dirent *) 0;
+ }
+
+ if (dirp->dd_dir.d_name != dirp->dd_dta.name) {
+ /* The structure does not seem to be set up correctly. */
+ errno = EINVAL;
+ return (struct dirent *) 0;
+ }
+
+ if (dirp->dd_stat < 0) {
+ /* We have already returned all files in the directory * (or the
+ structure has an invalid dd_stat). */
+ return (struct dirent *) 0;
+ } else if (dirp->dd_stat == 0) {
+ /* We haven't started the search yet. */
+ /* Start the search */
+ dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta));
+
+ if (dirp->dd_handle == -1) {
+ /* Whoops! Seems there are no files in that * directory. */
+ dirp->dd_stat = -1;
+ } else {
+ dirp->dd_stat = 1;
+ }
+ } else {
+ /* Get the next search entry. */
+ if (_findnext (dirp->dd_handle, &(dirp->dd_dta))) {
+ /* We are off the end or otherwise error. */
+ _findclose (dirp->dd_handle);
+ dirp->dd_handle = -1;
+ dirp->dd_stat = -1;
+ } else {
+ /* Update the status to indicate the correct * number. */
+ dirp->dd_stat++;
+ }
+ }
+
+ if (dirp->dd_stat > 0) {
+ /* Successfully got an entry. Everything about the file is * already
+ appropriately filled in except the length of the * file name. */
+ dirp->dd_dir.d_namlen = (unsigned short) strlen (dirp->dd_dir.d_name);
+ return &dirp->dd_dir;
+ }
+
+ return (struct dirent *) 0;
+}
+
+/*
+ closedir
+
+ Frees up resources allocated by opendir.
+*/
+static int
+win32_closedir (DIR * dirp)
+{
+ int rc;
+
+ errno = 0;
+ rc = 0;
+
+ if (!dirp) {
+ errno = EFAULT;
+ return -1;
+ }
+
+ if (dirp->dd_handle != -1) {
+ rc = _findclose (dirp->dd_handle);
+ }
+
+ /* Delete the dir structure. */
+ free (dirp);
+
+ return rc;
+}
+
+/*
+ rewinddir
+
+ Return to the beginning of the directory "stream". We simply call findclose
+ and then reset things like an opendir.
+*/
+static void
+win32_rewinddir (DIR * dirp)
+{
+ errno = 0;
+
+ if (!dirp) {
+ errno = EFAULT;
+ return;
+ }
+
+ if (dirp->dd_handle != -1) {
+ _findclose (dirp->dd_handle);
+ }
+
+ dirp->dd_handle = -1;
+ dirp->dd_stat = 0;
+}
+
+/*
+ telldir
+
+ Returns the "position" in the "directory stream" which can be used with
+ seekdir to go back to an old entry. We simply return the value in stat.
+*/
+static long
+win32_telldir (DIR * dirp)
+{
+ errno = 0;
+
+ if (!dirp) {
+ errno = EFAULT;
+ return -1;
+ }
+ return dirp->dd_stat;
+}
+
+/*
+ seekdir
+
+ Seek to an entry previously returned by telldir. We rewind the directory
+ and call readdir repeatedly until either dd_stat is the position number
+ or -1 (off the end). This is not perfect, in that the directory may
+ have changed while we weren't looking. But that is probably the case with
+ any such system.
+*/
+static void
+win32_seekdir (DIR * dirp, long lPos)
+{
+ errno = 0;
+
+ if (!dirp) {
+ errno = EFAULT;
+ return;
+ }
+
+ if (lPos < -1) {
+ /* Seeking to an invalid position. */
+ errno = EINVAL;
+ return;
+ } else if (lPos == -1) {
+ /* Seek past end. */
+ if (dirp->dd_handle != -1) {
+ _findclose (dirp->dd_handle);
+ }
+ dirp->dd_handle = -1;
+ dirp->dd_stat = -1;
+ } else {
+ /* Rewind and read forward to the appropriate index. */
+ win32_rewinddir (dirp);
+
+ while ((dirp->dd_stat < lPos) && win32_readdir (dirp));
+ }
+}
+
+#else
+#define USE_DIRENT 0
+
+#define _zzip_opendir(_N_) 0
+#define _zzip_readdir(_D_) 0
+#define _zzip_closedir(_D_) /* omit return code */
+#define _zzip_rewinddir(_D_)
+#define _zzip_telldir(_D_) 0
+#define _zzip_seekdir(_D_,_V_) /* omit return code */
+#define _zzip_DIR void*
+
+/* end of DIRENT implementation */
+#endif
+
+/* once */
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__fnmatch.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__fnmatch.h
new file mode 100644
index 00000000000..9759a7423d8
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__fnmatch.h
@@ -0,0 +1,28 @@
+#ifndef __ZZIP_INTERNAL_FNMATCH_H
+#define __ZZIP_INTERNAL_FNMATCH_H
+/** included by fseeko.c, mmapped.c, memdisk.c */
+
+#include <zzip/conf.h>
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#endif
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#define _zzip_fnmatch fnmatch
+# ifdef FNM_CASEFOLD
+# define _zzip_fnmatch_CASEFOLD FNM_CASEFOLD
+# else
+# define _zzip_fnmatch_CASEFOLD 0
+# endif
+#else
+# define _zzip_fnmatch_CASEFOLD 0
+/* if your system does not have fnmatch, we fall back to strcmp: */
+static int _zzip_fnmatch(char* pattern, char* string, int flags)
+{
+ puts ("<zzip:mmapped:strcmp>");
+ return strcmp (pattern, string);
+}
+#endif
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__hints.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__hints.h
new file mode 100644
index 00000000000..ed5b2ad9799
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__hints.h
@@ -0,0 +1,189 @@
+#ifndef __ZZIP_INTERNAL_HINTS_H
+#define __ZZIP_INTERNAL_HINTS_H
+#include <zzip/conf.h>
+
+#ifndef ZZIP_GNUC_ATLEAST
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define ZZIP_GNUC_ATLEAST(_M_,_N_) \
+ ((__GNUC__ << 10) + __GNUC_MINOR__ >= ((_M_) << 10) + (_N_))
+# elif defined __GNUC__
+# define ZZIP_GNUC_ATLEAST(_M_,_N_) \
+ ((__GNUC__ << 10) >= ((_M_) << 10))
+# else
+# define ZZIP_GNUC_ATLEAST(_M_, _N_) 0
+# endif
+#endif
+
+#ifndef ZZIP_GNUC_EXTENSION
+# if ZZIP_GNUC_ATLEAST(2,8)
+# define ZZIP_GNUC_EXTENSION __extension__
+# else
+# define ZZIP_GNUC_EXTENSION
+# endif
+#endif
+
+/* func has no side effects, return value depends only on params and globals */
+#ifndef ZZIP_GNUC_PURE
+# if ZZIP_GNUC_ATLEAST(2,8)
+# define ZZIP_GNUC_PURE __attribute__((__pure__))
+# else
+# define ZZIP_GNUC_PURE
+# endif
+#endif
+
+/* func has no side effects, return value depends only on params */
+#ifndef ZZIP_GNUC_CONST
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_CONST __attribute__((__const__))
+# else
+# define ZZIP_GNUC_CONST
+# endif
+#endif
+
+/* typename / variable / function possibly unused */
+#ifndef ZZIP_GNUC_UNUSED
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_UNUSED __attribute__((__unused__))
+# else
+# define ZZIP_GNUC_UNUSED
+# endif
+#endif
+
+/* obvious. btw, a noreturn-func should return void */
+#ifndef ZZIP_GNUC_NORETURN
+# if ZZIP_GNUC_ATLEAST(2,5)
+# define ZZIP_GNUC_NORETURN __attribute__((__noreturn__))
+# else
+# define ZZIP_GNUC_NORETURN
+# endif
+#endif
+
+/* omit function from profiling with -finstrument-functions */
+#ifndef ZZIP_GNUC_NO_INSTRUMENT
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__))
+# else
+# define ZZIP_GNUC_NO_INSTRUMENT
+# endif
+#endif
+
+/* all pointer args must not be null, and allow optimiztons based on the fact*/
+#ifndef ZZIP_GNUC_NONNULL
+# if ZZIP_GNUC_ATLEAST(3,1)
+# define ZZIP_GNUC_NONNULL __attribute__((nonnull))
+# else
+# define ZZIP_GNUC_NONNULL
+# endif
+#endif
+
+/* the function can not throw - the libc function are usually nothrow */
+#ifndef ZZIP_GNUC_NOTHROW
+# if ZZIP_GNUC_ATLEAST(3,2)
+# define ZZIP_GNUC_NOTHROW __attribute__((nothrow))
+# else
+# define ZZIP_GNUC_NOTHROW
+# endif
+#endif
+
+/* typename / function / variable is obsolete but still listed in headers */
+#ifndef ZZIP_GNUC_DEPRECATED
+# if ZZIP_GNUC_ATLEAST(3,1)
+# define ZZIP_GNUC_DEPRECATED __attribute__((deprecated))
+# else
+# define ZZIP_GNUC_DEPRECATED
+# endif
+#endif
+
+/* resolve references to this function during pre-linking the libary */
+#ifndef ZZIP_GNUC_LIB_PROTECTED
+# if ZZIP_GNUC_ATLEAST(3,1)
+# define ZZIP_GNUC_LIB_PROTECTED __attribute__((visiblity("protected")))
+# else
+# define ZZIP_GNUC_LIB_PROTECTED
+# endif
+#endif
+
+/* func shall only be usable within the same lib (so, no entry in lib symtab)*/
+#ifndef ZZIP_GNUC_LIB_PRIVATE
+# if ZZIP_GNUC_ATLEAST(3,1)
+# define ZZIP_GNUC_LIB_PRIVATE __attribute__((visiblity("hidden")))
+# else
+# define ZZIP_GNUC_LIB_PRIVATE
+# endif
+#endif
+
+/* ... and not even passed as a function pointer reference to outside the lib*/
+#ifndef ZZIP_GNUC_LIB_INTERNAL
+# if ZZIP_GNUC_ATLEAST(3,1)
+# define ZZIP_GNUC_LIB_INTERNAL __attribute__((visiblity("internal")))
+# else
+# define ZZIP_GNUC_LIB_INTERNAL
+# endif
+#endif
+
+
+#ifndef ZZIP_GNUC_FORMAT
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_FORMAT(_X_) __attribute__((__format_arg__(_X_)))
+# else
+# define ZZIP_GNUC_FORMAT(_X_)
+# endif
+#endif
+
+#ifndef ZZIP_GNUC_SCANF
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_SCANF(_S_,_X_) __attribute__((__scanf__(_S_,_X_)))
+# else
+# define ZZIP_GNUC_SCANF(_S_,_X_)
+# endif
+#endif
+
+#ifndef ZZIP_GNUC_PRINTF
+# if ZZIP_GNUC_ATLEAST(2,4)
+# define ZZIP_GNUC_PRINTF(_S_,_X_) __attribute__((__printf__(_S_,_X_)))
+# else
+# define ZZIP_GNUC_PRINTF(_S_,_X_)
+# endif
+#endif
+
+#ifndef ZZIP_FUNCTION
+# if ZZIP_GNUC_ATLEAST(2,6)
+# define ZZIP_FUNC __FUNCTION__
+# define ZZIP_FUNCTION __FUNCTION__
+# elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define ZZIP_FUNC __func__
+# define ZZIP_FUNCTION ""
+# else
+# define ZZIP_FUNC 0
+# define ZZIP_FUNCTION ""
+# endif
+#endif
+
+#ifndef ZZIP_STRING
+#define ZZIP_STRING(_X_) ZZIP_STRING_(_X_)
+#define ZZIP_STRING_(_Y_) #_Y_
+#endif
+
+#ifndef ZZIP_DIM
+#define ZZIP_DIM(_A_) (sizeof(_A_) / sizeof ((_A_)[0]))
+#endif
+
+#if !(defined ZZIP_FOR1 && defined ZZIP_END1)
+# if defined sun || defined __sun__
+# define ZZIP_FOR1 if (1)
+# define ZZIP_END1 else (void)0
+# else
+# define ZZIP_FOR1 do
+# define ZZIP_END1 while (0)
+# endif
+#endif
+
+#ifndef ZZIP_BRANCH_OVER
+# if ZZIP_GNUC_ATLEAST(2,96)
+# define ZZIP_BRANCH_OVER(_X_) __builtin_expect((_X_),0)
+# else
+# define ZZIP_BRANCH_OVER(_X_) (_X_)
+# endif
+#endif
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__mmap.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__mmap.h
new file mode 100644
index 00000000000..121c8bd82f8
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/__mmap.h
@@ -0,0 +1,107 @@
+#ifndef __ZZIP_INTERNAL_MMAP_H
+#define __ZZIP_INTERNAL_MMAP_H
+#include <zzip/types.h>
+
+/*
+ * DO NOT USE THIS CODE.
+ *
+ * It is an internal header file for zziplib that carries some inline
+ * functions (or just static members) and a few defines, simply to be
+ * able to reuse these across - and have everything in a specific place.
+ *
+ * Copyright (c) 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
+ */
+
+#ifdef _USE_MMAP
+#if defined ZZIP_HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#define USE_POSIX_MMAP 1
+#elif defined ZZIP_HAVE_WINBASE_H || defined WIN32
+#include <windows.h>
+#define USE_WIN32_MMAP 1
+#else
+#undef _USE_MMAP
+#endif
+#endif
+
+/* -------------- specify MMAP function imports --------------------------- */
+
+#if defined USE_POSIX_MMAP
+#define USE_MMAP 1
+
+#define _zzip_mmap(user, fd, offs, len) \
+ mmap (0, len, PROT_READ, MAP_SHARED, fd, offs)
+#define _zzip_munmap(user, ptr, len) \
+ munmap (ptr, len)
+#define _zzip_getpagesize(user) getpagesize()
+
+#ifndef MAP_FAILED /* hpux10.20 does not have it */
+#define MAP_FAILED ((void*)(-1))
+#endif
+
+#elif defined USE_WIN32_MMAP
+#define USE_MMAP 1
+#ifndef MAP_FAILED
+#define MAP_FAILED 0
+#endif
+/* we (ab)use the "*user" variable to store the FileMapping handle */
+ /* which assumes (sizeof(long) == sizeof(HANDLE)) */
+
+static size_t win32_getpagesize ()
+{
+ SYSTEM_INFO si; GetSystemInfo (&si);
+ return si.dwAllocationGranularity;
+}
+static void* win32_mmap (long* user, int fd, zzip_off_t offs, size_t len)
+{
+ if (! user || *user != 1) /* || offs % getpagesize() */
+ return 0;
+ {
+ HANDLE hFile = (HANDLE)_get_osfhandle(fd);
+ if (hFile)
+ *user = (int) CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL);
+ if (*user)
+ {
+ char* p = 0;
+ p = MapViewOfFile(*(HANDLE*)user, FILE_MAP_READ, 0, offs, len);
+ if (p) return p + offs;
+ CloseHandle (*(HANDLE*)user); *user = 1;
+ }
+ return MAP_FAILED;
+ }
+}
+static void win32_munmap (long* user, char* fd_map, size_t len)
+{
+ UnmapViewOfFile (fd_map);
+ CloseHandle (*(HANDLE*)user); *user = 1;
+}
+
+#define _zzip_mmap(user, fd, offs, len) \
+ win32_mmap ((long*) &(user), fd, offs, len)
+#define _zzip_munmap(user, ptr, len) \
+ win32_munmap ((long*) &(user), ptr, len)
+#define _zzip_getpagesize(user) win32_getpagesize()
+
+#else /* disable */
+#define USE_MMAP 0
+/* USE_MAP is intentional: we expect the compiler to do some "code removal"
+ * on any source code enclosed in if (USE_MMAP) {...} i.e. the unreachable
+ * branch of an if (0) {....} is not emitted to the final object binary. */
+
+#ifndef MAP_FAILED
+#define MAP_FAILED 0
+#endif
+
+#define _zzip_mmap(user, fd, offs, len) (MAP_FAILED)
+#define _zzip_munmap(user, ptr, len) {}
+#define _zzip_getpagesize(user) 1
+
+#endif /* USE_MMAP defines */
+
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_config.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_config.h
new file mode 100644
index 00000000000..65873ed7143
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_config.h
@@ -0,0 +1,248 @@
+#ifndef _ZZIP__CONFIG_H
+#define _ZZIP__CONFIG_H 1
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+/* #undef ZZIP_HAVE_BYTESWAP_H */
+
+/* TH need this to get the proper definition of _mkdir() in write.c */
+
+/* Define to 1 if you have the <direct.h> header file. */
+#ifndef ZZIP_HAVE_DIRECT_H
+#ifdef WIN32
+#define ZZIP_HAVE_DIRECT_H 1
+#endif
+#endif
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#ifndef ZZIP_HAVE_DIRENT_H
+#define ZZIP_HAVE_DIRENT_H 1
+#endif
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef ZZIP_HAVE_DLFCN_H
+#define ZZIP_HAVE_DLFCN_H 1
+#endif
+
+/*TH Zziplibs's own __fnmatch.h gives a compiler warning because it
+ uses puts() without loading stdio.h, so I prefer not to use it if
+ there is a correct system header, even though the warning is
+ harmless.
+*/
+
+/* Define to 1 if you have the <fnmatch.h> header file. */
+#ifndef ZZIP_HAVE_FNMATCH_H
+#ifndef WIN32
+#define ZZIP_HAVE_FNMATCH_H 1
+#endif
+#endif
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#ifndef ZZIP_HAVE_INTTYPES_H
+#define ZZIP_HAVE_INTTYPES_H 1
+#endif
+
+/* Define to 1 if you have the <io.h> header file. */
+#ifndef ZZIP_HAVE_IO_H
+#ifdef WIN32
+#define ZZIP_HAVE_IO_H 1
+#endif
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef ZZIP_HAVE_MEMORY_H
+#define ZZIP_HAVE_MEMORY_H 1
+#endif
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* #undef ZZIP_HAVE_NDIR_H */
+
+#if defined __sun__ || defined __sun
+/* Define to 1 if you have the <sys/int_types.h> header file. */
+#define ZZIP_HAVE_SYS_INT_TYPES_H 1
+#elif defined(_AIX)
+#else
+/* Define to 1 if you have the <stdint.h> header file. */
+#define ZZIP_HAVE_STDINT_H 1
+#endif
+
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef ZZIP_HAVE_STDLIB_H
+#define ZZIP_HAVE_STDLIB_H 1
+#endif
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#ifndef ZZIP_HAVE_STRCASECMP
+#define ZZIP_HAVE_STRCASECMP 1
+#endif
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef ZZIP_HAVE_STRINGS_H
+#define ZZIP_HAVE_STRINGS_H 1
+#endif
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef ZZIP_HAVE_STRING_H
+#define ZZIP_HAVE_STRING_H 1
+#endif
+
+/* Define to 1 if you have the `strndup' function. */
+#ifndef ZZIP_HAVE_STRNDUP
+#define ZZIP_HAVE_STRNDUP 1
+#endif
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+/* #undef ZZIP_HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+/* undefe ZZIP_HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+/* #undef ZZIP_HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#ifndef ZZIP_HAVE_SYS_PARAM_H
+#define ZZIP_HAVE_SYS_PARAM_H 1
+#endif
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef ZZIP_HAVE_SYS_STAT_H
+#define ZZIP_HAVE_SYS_STAT_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef ZZIP_HAVE_SYS_TYPES_H
+#define ZZIP_HAVE_SYS_TYPES_H 1
+#endif
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef ZZIP_HAVE_UNISTD_H
+#define ZZIP_HAVE_UNISTD_H 1
+#endif
+
+/* Define to 1 if you have the <winbase.h> header file. */
+/* #undef ZZIP_HAVE_WINBASE_H */
+
+/* Define to 1 if you have the <windows.h> header file. */
+/* #undef ZZIP_HAVE_WINDOWS_H */
+
+/* Define to 1 if you have the <winnt.h> header file. */
+/* #undef ZZIP_HAVE_WINNT_H */
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#ifndef ZZIP_HAVE_ZLIB_H
+#define ZZIP_HAVE_ZLIB_H 1
+#endif
+
+/* whether the system defaults to 32bit off_t but can do 64bit when requested
+ */
+#ifndef ZZIP_LARGEFILE_SENSITIVE
+#define ZZIP_LARGEFILE_SENSITIVE 1
+#endif
+
+/* Name of package */
+#ifndef ZZIP_PACKAGE
+#define ZZIP_PACKAGE "zziplib"
+#endif
+
+/* Define to the address where bug reports for this package should be sent. */
+#ifndef ZZIP_PACKAGE_BUGREPORT
+#define ZZIP_PACKAGE_BUGREPORT ""
+#endif
+
+/* Define to the full name of this package. */
+#ifndef ZZIP_PACKAGE_NAME
+#define ZZIP_PACKAGE_NAME ""
+#endif
+
+/* Define to the full name and version of this package. */
+#ifndef ZZIP_PACKAGE_STRING
+#define ZZIP_PACKAGE_STRING ""
+#endif
+
+/* Define to the one symbol short name of this package. */
+#ifndef ZZIP_PACKAGE_TARNAME
+#define ZZIP_PACKAGE_TARNAME ""
+#endif
+
+/* Define to the version of this package. */
+#ifndef ZZIP_PACKAGE_VERSION
+#define ZZIP_PACKAGE_VERSION ""
+#endif
+
+/* The number of bytes in type int */
+#ifndef ZZIP_SIZEOF_INT
+#define ZZIP_SIZEOF_INT 4
+#endif
+
+/* The number of bytes in type long */
+#ifndef ZZIP_SIZEOF_LONG
+#define ZZIP_SIZEOF_LONG 4
+#endif
+
+/* The number of bytes in type short */
+#ifndef ZZIP_SIZEOF_SHORT
+#define ZZIP_SIZEOF_SHORT 2
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef ZZIP_STDC_HEADERS
+#define ZZIP_STDC_HEADERS 1
+#endif
+
+/* Version number of package */
+#ifndef ZZIP_VERSION
+#define ZZIP_VERSION "0.13.47"
+#endif
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef ZZIP_WORDS_BIGENDIAN */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#ifndef ZZIP__FILE_OFFSET_BITS
+#define ZZIP__FILE_OFFSET_BITS 64
+#endif
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef ZZIP__LARGE_FILES */
+
+/* Define to `long long' if <sys/types.h> does not define. */
+#ifndef ZZIP___int64
+#define ZZIP___int64 long long
+#endif
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef _zzip_const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef _zzip_inline */
+#endif
+
+/* Define to `_zzip_off_t' if <sys/types.h> does not define. */
+#ifndef _zzip_off64_t
+#define _zzip_off64_t _zzip_off_t
+#endif
+
+/* Define to `long' if <sys/types.h> does not define. */
+/* #undef _zzip_off_t */
+
+/* Define to equivalent of C99 restrict keyword, or to nothing if this is not
+ supported. Do not define if restrict is supported directly. */
+#ifndef _zzip_restrict
+#define _zzip_restrict
+#endif
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef _zzip_size_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef _zzip_ssize_t */
+
+/* once: _ZZIP__CONFIG_H */
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.h
new file mode 100644
index 00000000000..e852513445c
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.h
@@ -0,0 +1,211 @@
+#ifndef _ZZIP__MSVC_H
+#define _ZZIP__MSVC_H 1
+
+/* zzip/_msvc.h. Generated automatically at end of configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+/* #undef ZZIP_HAVE_BYTESWAP_H */
+
+/* Define to 1 if you have the <direct.h> header file. */
+#ifndef ZZIP_HAVE_DIRECT_H
+#define ZZIP_HAVE_DIRECT_H 1
+#endif
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+/* #undef ZZIP_HAVE_DIRENT_H */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef ZZIP_HAVE_DLFCN_H */
+
+/* Define to 1 if you have the <fnmatch.h> header file. */
+/* #undef ZZIP_HAVE_FNMATCH_H */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+/* #undef ZZIP_HAVE_INTTYPES_H */
+
+/* Define to 1 if you have the <io.h> header file. */
+#ifndef ZZIP_HAVE_IO_H
+#define ZZIP_HAVE_IO_H 1
+#endif
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef ZZIP_HAVE_MEMORY_H
+#define ZZIP_HAVE_MEMORY_H 1
+#endif
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+/* #undef ZZIP_HAVE_NDIR_H */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+/* #undef ZZIP_HAVE_STDINT_H */
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef ZZIP_HAVE_STDLIB_H
+#define ZZIP_HAVE_STDLIB_H 1
+#endif
+
+/* Define to 1 if you have the `strcasecmp' function. */
+/* #undef ZZIP_HAVE_STRCASECMP */
+
+/* Define to 1 if you have the <strings.h> header file. */
+/* #undef ZZIP_HAVE_STRINGS_H */
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef ZZIP_HAVE_STRING_H
+#define ZZIP_HAVE_STRING_H 1
+#endif
+
+/* Define to 1 if you have the `strndup' function. */
+/* #undef ZZIP_HAVE_STRNDUP */
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+/* #undef ZZIP_HAVE_SYS_DIR_H */
+
+/* Define to 1 if you have the <sys/int_types.h> header file. */
+/* #undef ZZIP_HAVE_SYS_INT_TYPES_H */
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+/* #undef ZZIP_HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+/* #undef ZZIP_HAVE_SYS_NDIR_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+/* #undef ZZIP_HAVE_SYS_PARAM_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef ZZIP_HAVE_SYS_STAT_H
+#define ZZIP_HAVE_SYS_STAT_H 1
+#endif
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef ZZIP_HAVE_SYS_TYPES_H
+#define ZZIP_HAVE_SYS_TYPES_H 1
+#endif
+
+/* Define to 1 if you have the <unistd.h> header file. */
+/* #undef ZZIP_HAVE_UNISTD_H */
+
+/* Define to 1 if you have the <winbase.h> header file. */
+#ifndef ZZIP_HAVE_WINBASE_H
+#define ZZIP_HAVE_WINBASE_H 1 /* hmm, is that win32 ? */
+#endif
+
+/* Define to 1 if you have the <windows.h> header file. */
+#ifndef ZZIP_HAVE_WINDOWS_H
+#define ZZIP_HAVE_WINDOWS_H 1 /* yes, this is windows */
+#endif
+
+/* Define to 1 if you have the <winnt.h> header file. */
+#ifndef ZZIP_HAVE_WINNT_H
+#define ZZIP_HAVE_WINNT_H 1 /* is that always true? */
+#endif
+
+/* Define to 1 if you have the <zlib.h> header file. */
+#ifndef ZZIP_HAVE_ZLIB_H
+#define ZZIP_HAVE_ZLIB_H 1 /* you do have it, right? */
+#endif
+
+/* whether the system defaults to 32bit off_t but can do 64bit when requested
+ */
+/* #undef ZZIP_LARGEFILE_SENSITIVE */
+
+/* Name of package */
+#ifndef ZZIP_PACKAGE
+#define ZZIP_PACKAGE "zziplib-msvc" /* yes, make it known */
+#endif
+
+/* Define to the address where bug reports for this package should be sent. */
+/* #undef ZZIP_PACKAGE_BUGREPORT */
+
+/* Define to the full name of this package. */
+/* #undef ZZIP_PACKAGE_NAME */
+
+/* Define to the full name and version of this package. */
+/* #undef ZZIP_PACKAGE_STRING */
+
+/* Define to the one symbol short name of this package. */
+/* #undef ZZIP_PACKAGE_TARNAME */
+
+/* Define to the version of this package. */
+/* #undef ZZIP_PACKAGE_VERSION */
+
+/* The number of bytes in type int */
+#ifndef ZZIP_SIZEOF_INT
+#define ZZIP_SIZEOF_INT 4
+#endif
+
+/* The number of bytes in type long */
+#ifndef ZZIP_SIZEOF_LONG
+#define ZZIP_SIZEOF_LONG 4
+#endif
+
+/* The number of bytes in type short */
+#ifndef ZZIP_SIZEOF_SHORT
+#define ZZIP_SIZEOF_SHORT 2
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef ZZIP_STDC_HEADERS
+#define ZZIP_STDC_HEADERS 1
+#endif
+
+/* Version number of package */
+#ifndef ZZIP_VERSION
+#define ZZIP_VERSION "0.13.x"
+#endif
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef ZZIP_WORDS_BIGENDIAN */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef ZZIP__FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef ZZIP__LARGE_FILES */
+
+/* Define to `long long' if <sys/types.h> does not define. */
+/* #undef ZZIP___int64 */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef _zzip_const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#ifndef _zzip_inline
+#define _zzip_inline __inline
+#endif
+#endif
+
+/* Define to `_zzip_off_t' if <sys/types.h> does not define. */
+#ifndef _zzip_off64_t
+#define _zzip_off64_t __int64
+#endif
+
+/* Define to `long' if <sys/types.h> does not define. */
+#ifndef _zzip_off_t
+#define _zzip_off_t long
+#endif
+
+/* Define to equivalent of C99 restrict keyword, or to nothing if this is not
+ supported. Do not define if restrict is supported directly. */
+#ifndef _zzip_restrict
+#define _zzip_restrict
+#endif
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef _zzip_size_t */
+
+/* Define to `int' if <sys/types.h> does not define. */
+#ifndef _zzip_ssize_t
+#define _zzip_ssize_t int
+#endif
+
+/* once: _ZZIP__MSVC_H */
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.sed b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.sed
new file mode 100644
index 00000000000..ec1fcbba192
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/_msvc.sed
@@ -0,0 +1,26 @@
+s:undef *HAVE_MEMORY_H *$:define HAVE_MEMORY_H 1:
+s:undef *HAVE_STDLIB_H *$:define HAVE_STDLIB_H 1:
+s:undef *HAVE_STRING_H *$:define HAVE_STRING_H 1:
+s:undef *HAVE_SYS_STAT_H *$:define HAVE_SYS_STAT_H 1:
+s:undef *HAVE_SYS_TYPES_H *$:define HAVE_SYS_TYPES_H 1:
+s:undef *HAVE_DIRECT_H *$:define HAVE_DIRECT_H 1:
+s:undef *HAVE_IO_H *$:define HAVE_IO_H 1:
+s:undef *HAVE_WINDOWS_H *$:define HAVE_WINDOWS_H 1 /* yes, this is windows */:
+s:undef *HAVE_WINBASE_H *$:define HAVE_WINBASE_H 1 /* hmm, is that win32 ? */:
+s:undef *HAVE_WINNT_H *$:define HAVE_WINNT_H 1 /* is that always true? */:
+s:undef *HAVE_ZLIB_H *$:define HAVE_ZLIB_H 1 /* you do have it, right? */:
+s:undef *PACKAGE *$:define PACKAGE "zziplib-msvc" /* yes, make it known */:
+s:undef *SIZEOF_INT *$:define SIZEOF_INT 4:
+s:undef *SIZEOF_LONG *$:define SIZEOF_LONG 4:
+s:undef *SIZEOF_SHORT *$:define SIZEOF_SHORT 2:
+s:undef *STDC_HEADERS *$:define STDC_HEADERS 1:
+s:undef *inline *$:define inline __inline:
+s:undef *off_t *$:define off_t long:
+s:undef *off64_t *$:define off64_t __int64:
+s:undef *ssize_t *$:define ssize_t int:
+s:undef restrict *$:define restrict:
+s:undef VERSION:define VERSION "0.13.x":
+s:^ *# *undef.*$:/* & */:
+/Generated automatically .* by autoheader/a\
+/* config values have been automatically set by zzip/_msvc.sed */
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/autoconf.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/autoconf.h
new file mode 100644
index 00000000000..f0d6841454a
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/autoconf.h
@@ -0,0 +1,45 @@
+#ifndef _ZZIP_AUTOCONF_H_
+#define _ZZIP_AUTOCONF_H_ 1
+
+/*
+ * This file is trying to override configure time checks of zzip with
+ * definitions at compile time. This is not used by zzip sources themselves
+ * but it may be really helpful with thirdparty software that happens to
+ * include zzip headers from a central place but running on a different host.
+ */
+
+#include "conf.h" /* <zzip/conf.h> : <zzip/_config.h> */
+
+#if defined HAVE_ENDIAN_H || defined ZZIP_HAVE_ENDIAN_H
+#include <endian.h> /* glibc */
+#elif defined HAVE_SYS_PARAM_H || defined ZZIP_HAVE_SYS_PARAM_H
+#include <sys/param.h> /* solaris */
+#endif
+
+#if defined __BYTE_ORDER
+#define ZZIP_BYTE_ORDER __BYTE_ORDER
+#elif defined BYTE_ORDER
+#define ZZIP_BYTE_ORDER BYTE_ORDER
+#elif defined _LITTLE_ENDIAN
+#define ZZIP_BYTE_ORDER 1234
+#elif defined _BIG_ENDIAN
+#define ZZIP_BYTE_ORDER 4321
+#elif defined __i386__
+#define ZZIP_BYTE_ORDER 1234
+#elif defined WORDS_BIGENDIAN || defined ZZIP_WORDS_BIGENDIAN
+#define ZZIP_BYTE_ORDER 4321
+#else
+#define ZZIP_BYTE_ORDER 1234
+#endif
+
+/* override ZZIP_WORDS_BIGENDIAN : macros ZZIP_GET16 / ZZIP_GET32 */
+#ifdef ZZIP_BYTE_ORDER+0 == 1234
+#undef ZZIP_WORDS_BIGENDIAN
+#endif
+#ifdef ZZIP_BYTE_ORDER+0 == 4321
+#ifndef ZZIP_WORDS_BIGENDIAN
+#define ZZIP_WORDS_BIGENDIAN 1
+#endif
+#endif
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/conf.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/conf.h
new file mode 100644
index 00000000000..c6d7ad6f84d
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/conf.h
@@ -0,0 +1,273 @@
+/*
+ * Here we postprocess autoconf generated prefix-config.h entries.
+ * This is generally for things like "off_t" which is left undefined
+ * in plain config.h if the host system does already have it but we do
+ * need the prefix variant - so we add here a #define _zzip_off_t off_t
+ *
+ * This file is supposed to only carry '#define's.
+ * See <zzip/types.h> for definitions that might be seen by the compiler.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2001,2002,2003,2004 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
+ */
+
+#ifndef _ZZIP_CONF_H
+#define _ZZIP_CONF_H 1
+
+#if !defined ZZIP_OMIT_CONFIG_H
+# if defined _MSC_VER || defined __BORLANDC__ || defined __WATCOMC__
+# include <zzip/_msvc.h>
+# elif defined ZZIP_1_H
+# include "zzip-1.h"
+# elif defined ZZIP_2_H
+# include "zzip-2.h"
+# elif defined ZZIP_3_H
+# include "zzip-3.h"
+# elif defined ZZIP_4_H
+# include "zzip-4.h"
+# elif defined ZZIP_5_H
+# include "zzip-5.h"
+# else /* autoconf generated */
+# include <zzip/_config.h>
+# endif
+#endif
+
+/* especially win32 platforms do not declare off_t so far - see zzip-msvc.h */
+#ifndef _zzip_off_t
+#ifdef ZZIP_off_t
+#define _zzip_off_t ZZIP_off_t
+#else
+#define _zzip_off_t off_t
+#endif
+#endif
+
+#ifndef _zzip_off64_t
+#ifdef ZZIP_off64_t
+#define _zzip_off64_t ZZIP_off64_t
+#else
+#define _zzip_off64_t off64_t
+#endif
+#endif
+
+/* currently unused, all current zziplib-users do have ansi-C94 compilers. */
+#ifndef _zzip_const
+#ifdef ZZIP_const
+#define _zzip_const ZZIP_const
+#else
+#define _zzip_const const
+#endif
+#endif
+#ifdef _AIX
+#define _zzip_inline __inline
+#endif
+#ifndef _zzip_inline
+#ifdef ZZIP_inline
+#define _zzip_inline ZZIP_inline
+#else
+#define _zzip_inline inline
+#endif
+#endif
+#ifndef _zzip_restrict
+#ifdef ZZIP_restrict
+#define _zzip_restrict ZZIP_restrict
+#else
+#define _zzip_restrict restrict
+#endif
+#endif
+#if defined __linux__ && __GNUC__+0 >= 4
+#define zzip__new__ __attribute__((malloc))
+#elif defined __linux__ && __GNUC__+0 >= 3 && __GNUC_MINOR_+0 >= 3
+#define zzip__new__ __attribute__((malloc))
+#else
+#define zzip__new__
+#endif
+
+#ifndef _zzip_size_t
+#ifdef ZZIP_size_t
+#define _zzip_size_t ZZIP_size_t
+#else
+#define _zzip_size_t size_t
+#endif
+#endif
+#ifndef _zzip_ssize_t
+#ifdef ZZIP_ssize_t
+#define _zzip_ssize_t ZZIP_ssize_t
+#else
+#define _zzip_ssize_t ssize_t
+#endif
+#endif
+#ifndef _zzip___int64
+#ifdef ZZIP___int64
+#define _zzip___int64 ZZIP___int64
+#else
+#define _zzip___int64 long long
+#endif
+#endif
+
+/* whether this library shall use a 64bit off_t largefile variant in 64on32: */
+/* (some exported names must be renamed to avoid bad calls after linking) */
+#if defined ZZIP_LARGEFILE_SENSITIVE
+# if _FILE_OFFSET_BITS+0 == 64
+# define ZZIP_LARGEFILE_RENAME
+# elif defined _LARGE_FILES /* used on older AIX to get at 64bit off_t */
+# define ZZIP_LARGEFILE_RENAME
+# elif defined _ZZIP_LARGEFILE /* or simply use this one for zzip64 runs */
+# define ZZIP_LARGEFILE_RENAME
+# endif
+#endif
+
+/* if the environment did not setup these for 64bit off_t largefile... */
+#ifdef ZZIP_LARGEFILE_RENAME
+# ifndef _FILE_OFFSET_BITS
+# ifdef ZZIP__FILE_OFFSET_BITS /* == 64 */
+# define _FILE_OFFSET_BITS ZZIP__FILE_OFFSET_BITS
+# endif
+# endif
+# ifndef _LARGE_FILES
+# ifdef ZZIP__LARGE_FILES /* == 1 */
+# define _LARGE_FILES ZZIP__LARGE_FILES
+# endif
+# endif
+# ifndef _LARGEFILE_SOURCE
+# ifdef ZZIP__LARGEFILE_SOURCE /* == 1 */
+# define _LARGEFILE_SOURCE ZZIP__LARGEFILE_SOURCE
+# endif
+# endif
+#endif
+
+#include <errno.h>
+
+/* mingw32msvc errno : would be in winsock.h */
+#ifndef EREMOTE
+#define EREMOTE ESPIPE
+#endif
+
+#ifndef ELOOP
+#if defined EILSEQ
+#define ELOOP EILSEQ
+#else
+#define ELOOP ENOEXEC
+#endif
+#endif
+
+#if defined __WATCOMC__
+#undef _zzip_inline
+#define _zzip_inline static
+#endif
+
+#if defined _MSC_VER || defined __WATCOMC__
+#include <io.h>
+#endif
+
+#ifdef _MSC_VER
+# if !__STDC__
+# ifndef _zzip_lseek
+# define _zzip_lseek _lseek
+# endif
+# ifndef _zzip_read
+# define _zzip_read _read
+# endif
+# ifndef _zzip_write
+# define _zzip_write _write
+# endif
+# if 0
+# ifndef _zzip_stat
+# define _zzip_stat _stat
+# endif
+# endif
+# endif /* !__STDC__ */
+#endif
+ /*MSVC*/
+
+#if defined _MSC_VER || defined __WATCOMC__
+# ifndef strcasecmp
+# define strcasecmp _stricmp
+# endif
+#endif
+
+# ifndef _zzip_lseek
+# define _zzip_lseek lseek
+# endif
+
+# ifndef _zzip_read
+# define _zzip_read read
+# endif
+
+# ifndef _zzip_write
+# define _zzip_write write
+# endif
+
+# if 0
+# ifndef _zzip_stat
+# define _zzip_stat stat
+# endif
+# endif
+
+
+#if defined __GNUC__ || defined __attribute__
+#define __zzip_attribute__(X) __attribute__(X)
+#else
+#define __zzip_attribute__(X)
+#endif
+
+#if defined ZZIP_EXPORTS || defined ZZIPLIB_EXPORTS
+# undef ZZIP_DLL
+#define ZZIP_DLL 1
+#endif
+
+/* based on zconf.h : */
+/* compile with -DZZIP_DLL for Windows DLL support */
+#if defined ZZIP_DLL
+# if defined _WINDOWS || defined WINDOWS || defined _WIN32
+/*# include <windows.h>*/
+# endif
+# if !defined _zzip_export && defined _MSC_VER && (defined WIN32 || defined _WIN32)
+# define _zzip_export __declspec(dllexport) /*WINAPI*/
+# endif
+# if !defined _zzip_export && defined __BORLANDC__
+# if __BORLANDC__ >= 0x0500 && defined WIN32
+# include <windows.h>
+# define _zzip_export __declspec(dllexport) /*WINAPI*/
+# else
+# if defined _Windows && defined __DLL__
+# define _zzip_export _export
+# endif
+# endif
+# endif
+# if !defined _zzip_export && defined __GNUC__
+# if defined __declspec
+# define _zzip_export extern __declspec(dllexport)
+# else
+# define _zzip_export extern
+# endif
+# endif
+# if !defined _zzip_export && defined __BEOS__
+# define _zzip_export extern __declspec(export)
+# endif
+# if !defined _zzip_export && defined __WATCOMC__
+# define _zzip_export extern __declspec(dllexport)
+# define ZEXPORT __syscall
+# define ZEXTERN extern
+# endif
+#endif
+
+#if !defined _zzip_export
+# if defined __GNUC__ /* || !defined HAVE_LIBZZIP */
+# define _zzip_export extern
+# elif defined __declspec || (defined _MSC_VER && defined ZZIP_DLL)
+# define _zzip_export extern __declspec(dllimport)
+# else
+# define _zzip_export extern
+# endif
+#endif
+
+#endif
+
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/dir.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/dir.c
new file mode 100644
index 00000000000..a84a130486a
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/dir.c
@@ -0,0 +1,296 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * 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 <zzip/lib.h> /* exported... */
+#include <zzip/file.h>
+#include <stddef.h> /*offsetof*/
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#ifdef ZZIP_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#else
+#include <stdio.h>
+#endif
+
+#include <zzip/__dirent.h>
+
+#ifndef offsetof
+#pragma warning had to DEFINE offsetof as it was not in stddef.h
+#define offsetof(T,M) ((unsigned)(& ((T*)0)->M))
+#endif
+
+#ifdef ZZIP_HAVE_SYS_STAT_H
+/* MSVC does have IFbitmask but not the corresponding IStests */
+# if !defined S_ISDIR && defined S_IFDIR
+# define S_ISDIR(_X_) ((_X_) & S_IFDIR)
+# endif
+# if !defined S_ISREG && defined S_IFREG
+# define S_ISREG(_X_) ((_X_) & S_IFREG)
+# endif
+#endif
+
+/**
+ * This function is the equivalent of a => rewinddir(2) for a realdir or
+ * the zipfile in place of a directory. The ZZIP_DIR handle returned from
+ * => zzip_opendir has a flag saying realdir or zipfile. As for a zipfile,
+ * the filenames will include the filesubpath, so take care.
+ */
+void
+zzip_rewinddir(ZZIP_DIR * dir)
+{
+ if (! dir) return;
+
+ if (USE_DIRENT && dir->realdir)
+ {
+ _zzip_rewinddir(dir->realdir);
+ return;
+ }
+
+ if (dir->hdr0)
+ dir->hdr = dir->hdr0;
+ else
+ dir->hdr = 0;
+}
+
+#if ! USE_DIRENT
+#define real_readdir(_X_) 1
+#else
+static int
+real_readdir(ZZIP_DIR* dir)
+{
+ struct stat st = { 0 };
+ char filename[PATH_MAX];
+ struct dirent* dirent = _zzip_readdir(dir->realdir);
+ if (! dirent) return 0;
+
+ dir->dirent.d_name = dirent->d_name;
+ strcpy(filename, dir->realname);
+ strcat(filename, "/");
+ strcat(filename, dirent->d_name);
+
+ if (stat(filename, &st) == -1)
+ return -1;
+
+ dir->dirent.d_csize = dir->dirent.st_size = st.st_size;
+
+ if (st.st_mode)
+ {
+ if (! S_ISREG(st.st_mode))
+ {
+ dir->dirent.d_compr = st.st_mode;
+ dir->dirent.d_compr |= 0x80000000;
+ /* makes it effectively negative,
+ * but can still be fed to S_ISXXX(x) */
+ }else
+ {
+ dir->dirent.d_compr = 0; /* stored */
+ }
+ }else
+ {
+ dir->dirent.d_compr = 0; /* stored */
+ }
+
+ return 1;
+}
+#endif
+
+/**
+ * This function is the equivalent of a => readdir(2) for a realdir
+ * or a zipfile referenced by the ZZIP_DIR returned from => zzip_opendir.
+ *
+ * The ZZIP_DIR handle (as returned by => zzip_opendir) contains a few more
+ * entries than being copied into the ZZIP_DIRENT. The only valid fields in
+ * a ZZIP_DIRENT are d_name (the file name), d_compr (compression), d_csize
+ * (compressed size), st_size (uncompressed size).
+ */
+ZZIP_DIRENT*
+zzip_readdir(ZZIP_DIR * dir)
+{
+ if (! dir) { errno=EBADF; return 0; }
+
+ if (USE_DIRENT && dir->realdir)
+ {
+ if (! real_readdir(dir))
+ return 0;
+ }else
+ {
+ if (! dir->hdr) return 0;
+
+ dir->dirent.d_name = dir->hdr->d_name;
+ dir->dirent.d_compr = dir->hdr->d_compr;
+
+ dir->dirent.d_csize = dir->hdr->d_csize;
+ dir->dirent.st_size = dir->hdr->d_usize;
+
+ if (! dir->hdr->d_reclen) dir->hdr = 0;
+ else dir->hdr = (struct zzip_dir_hdr *)
+ ((char *)dir->hdr + dir->hdr->d_reclen);
+ }
+ return &dir->dirent;
+}
+
+/** => zzip_rewinddir
+ * This function is the equivalent of => telldir(2) for a realdir or zipfile.
+ */
+zzip_off_t
+zzip_telldir(ZZIP_DIR* dir)
+{
+ if (! dir) { errno=EBADF; return -1; }
+
+ if (USE_DIRENT && dir->realdir)
+ {
+ return _zzip_telldir(dir->realdir);
+ }else
+ {
+ return ((zzip_off_t) ((char*) dir->hdr - (char*) dir->hdr0));
+ }
+}
+
+/** => zzip_rewinddir
+ * This function is the equivalent of => seekdir(2) for a realdir or zipfile.
+ */
+void
+zzip_seekdir(ZZIP_DIR* dir, zzip_off_t offset)
+{
+ if (! dir) return;
+
+ if (USE_DIRENT && dir->realdir)
+ {
+ _zzip_seekdir(dir->realdir, offset);
+ }else
+ {
+ dir->hdr = (struct zzip_dir_hdr*)
+ (dir->hdr0 ? (char*) dir->hdr0 + (size_t) offset : 0);
+ }
+}
+
+#if defined ZZIP_LARGEFILE_RENAME && defined EOVERFLOW && defined PIC
+#undef zzip_seekdir /* zzip_seekdir64 */
+#undef zzip_telldir /* zzip_telldir64 */
+
+long zzip_telldir(ZZIP_DIR* dir);
+void zzip_seekdir(ZZIP_DIR* dir, long offset);
+
+/* DLL compatibility layer - so that 32bit code can link with this lib too */
+
+long zzip_telldir(ZZIP_DIR* dir)
+{
+ off_t off = zzip_telldir64 (dir);
+ long offs = off;
+ if (offs != off) { errno = EOVERFLOW; return -1; }
+ return offs;
+}
+
+void zzip_seekdir(ZZIP_DIR* dir, long offset)
+{
+ zzip_seekdir64 (dir, offset);
+}
+#endif
+
+/**
+ * This function is the equivalent of => opendir(3) for a realdir or zipfile.
+ *
+ * This function has some magic - if the given argument-path
+ * is a directory, it will wrap a real => opendir(3) into the ZZIP_DIR
+ * structure. Otherwise it will divert to => zzip_dir_open which
+ * can also attach a ".zip" extension if needed to find the archive.
+ *
+ * the error-code is mapped to => errno(3).
+ */
+ZZIP_DIR*
+zzip_opendir(zzip_char_t* filename)
+{
+ return zzip_opendir_ext_io (filename, 0, 0, 0);
+}
+
+/** => zzip_opendir
+ * This function uses explicit ext and io instead of the internal
+ * defaults, setting them to zero is equivalent to => zzip_opendir
+ */
+ZZIP_DIR*
+zzip_opendir_ext_io(zzip_char_t* filename, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ zzip_error_t e;
+ ZZIP_DIR* dir;
+
+# ifdef ZZIP_HAVE_SYS_STAT_H
+ struct stat st;
+# endif
+
+ if (o_modes & (ZZIP_PREFERZIP|ZZIP_ONLYZIP)) goto try_zzip;
+ try_real:
+
+# ifdef ZZIP_HAVE_SYS_STAT_H
+ if (stat(filename, &st) >= 0 && S_ISDIR(st.st_mode)
+ ){
+ if (USE_DIRENT)
+ {
+ _zzip_DIR* realdir = _zzip_opendir(filename);
+ if (realdir)
+ {
+ if (! (dir = (ZZIP_DIR *)calloc(1, sizeof (*dir))))
+ {
+ _zzip_closedir(realdir);
+ return 0;
+ }else
+ {
+ dir->realdir = realdir;
+ dir->realname = strdup(filename);
+ return dir;
+ }
+ }
+ }
+ return 0;
+ }
+# endif /* HAVE_SYS_STAT_H */
+
+ try_zzip:
+ dir = zzip_dir_open_ext_io (filename, &e, ext, io);
+ if (! dir && (o_modes & ZZIP_PREFERZIP)) goto try_real;
+ if (e) errno = zzip_errno(e);
+ return dir;
+}
+
+/**
+ * This function is the equivalent of => closedir(3) for a realdir or zipfile.
+ *
+ * This function is magic - if the given arg-ZZIP_DIR
+ * is a real directory, it will call the real => closedir(3) and then
+ * free the wrapping ZZIP_DIR structure. Otherwise it will divert
+ * to => zzip_dir_close which will free the ZZIP_DIR structure.
+ */
+int
+zzip_closedir(ZZIP_DIR* dir)
+{
+ if (! dir) { errno = EBADF; return -1; }
+
+ if (USE_DIRENT && dir->realdir)
+ {
+ _zzip_closedir(dir->realdir);
+ free(dir->realname);
+ free(dir);
+ return 0;
+ }else
+ {
+ zzip_dir_close(dir);
+ return 0;
+ }
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c
new file mode 100644
index 00000000000..2f05bb92247
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/err.c
@@ -0,0 +1,156 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@iki.fi>
+ *
+ * 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 <zzip/lib.h> /* exported... */
+#include <zlib.h>
+
+#include <string.h>
+#include <errno.h>
+
+#include <zzip/file.h>
+
+static struct errlistentry { int code; const char* mesg; }
+errlist[] =
+{
+ { ZZIP_NO_ERROR, "No error" },
+ { ZZIP_OUTOFMEM,
+ "could not get temporary memory for internal structures" },
+ { ZZIP_DIR_OPEN, "Failed to open zip-file %s" },
+ { ZZIP_DIR_STAT, "Failed to fstat zip-file %s" },
+ { ZZIP_DIR_SEEK, "Failed to lseek zip-file %s" },
+ { ZZIP_DIR_READ, "Failed to read zip-file %s"},
+ { ZZIP_DIR_TOO_SHORT, "zip-file %s too short" },
+ { ZZIP_DIR_EDH_MISSING, "zip-file central directory not found" },
+ { ZZIP_DIRSIZE, "Directory size too big..." },
+ { ZZIP_ENOENT, "No such file found in zip-file %s" },
+ { ZZIP_UNSUPP_COMPR, "Unsupported compression format" },
+ { ZZIP_CORRUPTED, "Zipfile corrupted" },
+ { ZZIP_UNDEF, "Some undefined error occurred" },
+ { ZZIP_DIR_LARGEFILE, "Directory is largefile variant" },
+ { 0, 0 },
+};
+
+#define errlistSIZE (sizeof(errlist)/sizeof(*errlist))
+
+/**
+ * returns the static string for the given error code. The
+ * error code can be either a normal system error (a
+ * positive error code will flag this), it can be => libz
+ * error code (a small negative error code will flag this)
+ * or it can be an error code from => libzzip, which is an
+ * negative value lower than => ZZIP_ERROR
+ */
+zzip_char_t*
+zzip_strerror(int errcode)
+{
+ if (errcode < ZZIP_ERROR && errcode > ZZIP_ERROR-32)
+ {
+ struct errlistentry* err = errlist;
+ for (; err->mesg ; err++)
+ {
+ if (err->code == errcode)
+ return err->mesg;
+ }
+ errcode = EINVAL;
+ }
+
+ if (errcode < 0)
+ {
+ if (errcode == -1)
+ return strerror(errcode);
+ else
+ return zError(errcode);
+ }
+
+ return strerror (errcode);
+}
+
+/** => zzip_strerror
+ * This function fetches the errorcode from the => DIR-handle and
+ * runs it through => zzip_strerror to obtain the static string
+ * describing the error.
+ */
+zzip_char_t*
+zzip_strerror_of(ZZIP_DIR* dir)
+{
+ if (! dir) return strerror (errno);
+ return zzip_strerror(dir->errcode);
+}
+
+static struct errnolistentry { int code; int e_no; }
+errnolist[] =
+{
+ { Z_STREAM_ERROR, EPIPE },
+ { Z_DATA_ERROR, ESPIPE },
+ { Z_MEM_ERROR, ENOMEM },
+ { Z_BUF_ERROR, EMFILE },
+ { Z_VERSION_ERROR, ENOEXEC },
+
+ { ZZIP_DIR_OPEN, ENOTDIR },
+ { ZZIP_DIR_STAT, EREMOTE },
+ { ZZIP_DIR_SEEK, ESPIPE },
+# ifdef ESTRPIPE
+ { ZZIP_DIR_READ, ESTRPIPE},
+# else
+ { ZZIP_DIR_READ, EPIPE},
+# endif
+ { ZZIP_DIR_TOO_SHORT, ENOEXEC },
+# ifdef ENOMEDIUM
+ { ZZIP_DIR_EDH_MISSING, ENOMEDIUM },
+# else
+ { ZZIP_DIR_EDH_MISSING, EIO },
+# endif
+ { ZZIP_DIRSIZE, EFBIG },
+ { ZZIP_OUTOFMEM, ENOMEM },
+ { ZZIP_ENOENT, ENOENT },
+# ifdef EPFNOSUPPORT
+ { ZZIP_UNSUPP_COMPR, EPFNOSUPPORT },
+# else
+ { ZZIP_UNSUPP_COMPR, EACCES },
+# endif
+# ifdef EILSEQ
+ { ZZIP_CORRUPTED, EILSEQ },
+# else
+ { ZZIP_CORRUPTED, ELOOP },
+# endif
+ { ZZIP_UNDEF, EINVAL },
+ { 0, 0 },
+};
+
+/**
+ * map the error code to a system error code. This is used
+ * for the drop-in replacement functions to return a value
+ * that can be interpreted correctly by code sections that
+ * are unaware of the fact they their => open(2) call had been
+ * diverted to a file inside a zip-archive.
+ */
+int
+zzip_errno(int errcode)
+{
+ if (errcode >= -1) return errno;
+
+ { struct errnolistentry* err = errnolist;
+ for (; err->code ; err++)
+ {
+ if (err->code == errcode)
+ return err->e_no;
+ }
+ }
+ return EINVAL;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.c
new file mode 100644
index 00000000000..23be82376df
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.c
@@ -0,0 +1,117 @@
+#include <zzip/fetch.h>
+
+#if defined ZZIP_WORDS_BIGENDIAN && \
+ defined bswap_16 && defined bswap_32 && defined bswap_64
+# define __ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p))
+# define __ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p))
+# define __ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x)))
+# define __ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x)))
+# define __ZZIP_GET64(__p) bswap_64(*(zzip_off64_t*)(__p))
+# define __ZZIP_SET64(__p,__x) \
+ (*(zzip_off64_t*)(__p) = bswap_64((zzip_off64_t)(__x)))
+#endif
+
+/* ------------------------- fetch helpers --------------------------------- */
+
+/**
+ * Make 32 bit value in host byteorder from little-endian mapped octet-data
+ * (works also on machines which SIGBUS on misaligned data access (eg. 68000))
+ */
+uint32_t __zzip_get32(unsigned char * s)
+{
+#if defined __ZZIP_GET32
+ return __ZZIP_GET32(s);
+#else
+ return ((uint32_t)s[3] << 24) | ((uint32_t)s[2] << 16)
+ | ((uint32_t)s[1] << 8) | ((uint32_t)s[0]);
+#endif
+}
+
+/** => __zzip_get32
+ * This function does the same for a 16 bit value.
+ */
+uint16_t __zzip_get16(unsigned char * s)
+{
+#if defined __ZZIP_GET16
+ return __ZZIP_GET16(s);
+#else
+ return ((uint16_t)s[1] << 8) | ((uint16_t)s[0]);
+#endif
+}
+
+/** => __zzip_get32
+ * This function does the same for an off64_t value.
+ */
+uint64_t __zzip_get64(unsigned char * s)
+{
+#ifdef __GNUC__
+ register uint64_t v
+ = s[7]; v <<= 8;
+ v |= s[6]; v <<= 8;
+ v |= s[5]; v <<= 8;
+ v |= s[4]; v <<= 8;
+ v |= s[3]; v <<= 8;
+ v |= s[2]; v <<= 8;
+ v |= s[1]; v <<= 8;
+ v |= s[0]; return v;
+#else
+ return ((uint64_t)s[7] << 56) | ((uint64_t)s[6] << 48)
+ | ((uint64_t)s[5] << 40) | ((uint64_t)s[4] << 32)
+ | ((uint64_t)s[3] << 24) | ((uint64_t)s[2] << 16)
+ | ((uint64_t)s[1] << 8) | ((uint64_t)s[0]);
+#endif
+}
+
+/** => __zzip_get32
+ * This function pushes a 32bit value at the specified address
+ */
+void __zzip_set32(unsigned char * s, uint32_t v)
+{
+#if defined __ZZIP_SET32
+ return __ZZIP_SET32(s, v);
+#else
+ s[0] = (unsigned char) (v);
+ v >>= 8;
+ s[1] = (unsigned char) (v);
+ v >>= 8;
+ s[2] = (unsigned char) (v);
+ v >>= 8;
+ s[3] = (unsigned char) (v);
+#endif
+}
+
+/** => __zzip_get32
+ * This function does the same for a 16 bit value.
+ */
+void __zzip_set16(unsigned char * s, uint16_t v)
+{
+#if defined __ZZIP_SET16
+ return __ZZIP_SET16(s, v);
+#else
+ s[0] = (unsigned char) (v);
+ v >>= 8;
+ s[1] = (unsigned char) (v);
+#endif
+}
+
+/** => __zzip_get32
+ * This function pushes a off64_t value at the specified address
+ */
+void __zzip_set64(unsigned char * s, uint64_t v)
+{
+ s[0] = (unsigned char) (v);
+ v >>= 8;
+ s[1] = (unsigned char) (v);
+ v >>= 8;
+ s[2] = (unsigned char) (v);
+ v >>= 8;
+ s[3] = (unsigned char) (v);
+ v >>= 8;
+ s[4] = (unsigned char) (v);
+ v >>= 8;
+ s[5] = (unsigned char) (v);
+ v >>= 8;
+ s[6] = (unsigned char) (v);
+ v >>= 8;
+ s[7] = (unsigned char) (v);
+}
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.h
new file mode 100644
index 00000000000..fda6f9067e6
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fetch.h
@@ -0,0 +1,343 @@
+#ifndef _ZZIP_FORMATS_H
+#define _ZZIP_FORMATS_H
+
+#include <zzip/types.h>
+#include <zzip/format.h>
+#include <zzip/stdint.h>
+
+/* linux knows "byteswap.h" giving us an optimized variant */
+#ifdef ZZIP_HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
+/* get 16/32 bits from little-endian zip-file to host byteorder */
+extern uint32_t __zzip_get32(zzip_byte_t * s) __zzip_attribute__((const));
+extern uint16_t __zzip_get16(zzip_byte_t * s) __zzip_attribute__((const));
+extern void __zzip_set32(zzip_byte_t * s, uint32_t v);
+extern void __zzip_set16(zzip_byte_t * s, uint16_t v);
+
+extern uint64_t __zzip_get64(zzip_byte_t * s) __zzip_attribute__((const));
+extern void __zzip_set64(zzip_byte_t * s, uint64_t v);
+
+#ifdef ZZIP_WORDS_BIGENDIAN
+# if defined bswap_16 && defined bswap_32 && defined bswap_64 /* i.e. linux */
+# define ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p))
+# define ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p))
+# define ZZIP_GET64(__p) bswap_64(*(uint64_t*)(__p))
+# define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x)))
+# define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x)))
+# define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = bswap_64((uint64_t)(__x)))
+# else
+# define ZZIP_GET64(__p) (__zzip_get64((__p)))
+# define ZZIP_GET32(__p) (__zzip_get32((__p)))
+# define ZZIP_GET16(__p) (__zzip_get16((__p)))
+# define ZZIP_SET64(__p,__x) (__zzip_set64((__p),(__x)))
+# define ZZIP_SET32(__p,__x) (__zzip_set32((__p),(__x)))
+# define ZZIP_SET16(__p,__x) (__zzip_set16((__p),(__x)))
+# endif
+#else /* little endian is the original zip format byteorder */
+# define ZZIP_GET16(__p) (*(uint16_t*)(__p))
+# define ZZIP_GET32(__p) (*(uint32_t*)(__p))
+# define ZZIP_GET64(__p) (*(uint64_t*)(__p))
+# define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = (uint16_t)(__x))
+# define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = (uint32_t)(__x))
+# define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = (uint64_t)(__x))
+#endif
+
+/* ..................... bitcorrect physical access .................... */
+
+/* zzip_file_header - the local file header */
+#define zzip_file_header_get_magic(__p) ZZIP_GET32((__p)->z_magic)
+#define zzip_file_header_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x))
+#define zzip_file_header_get_flags(__p) ZZIP_GET16((__p)->z_flags)
+#define zzip_file_header_set_flags(__p,__x) ZZIP_SET16((__p)->z_flags,(__x))
+#define zzip_file_header_get_compr(__p) ZZIP_GET16((__p)->z_compr)
+#define zzip_file_header_set_compr(__p,__x) ZZIP_SET16((__p)->z_compr,(__x))
+#define zzip_file_header_get_crc32(__p) ZZIP_GET32((__p)->z_crc32)
+#define zzip_file_header_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x))
+#define zzip_file_header_get_csize(__p) ZZIP_GET32((__p)->z_csize)
+#define zzip_file_header_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x))
+#define zzip_file_header_get_usize(__p) ZZIP_GET32((__p)->z_usize)
+#define zzip_file_header_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x))
+#define zzip_file_header_get_namlen(__p) ZZIP_GET16((__p)->z_namlen)
+#define zzip_file_header_set_namlen(__p,__x) ZZIP_SET16((__p)->z_namlen,(__x))
+#define zzip_file_header_get_extras(__p) ZZIP_GET16((__p)->z_extras)
+#define zzip_file_header_set_extras(__p,__x) ZZIP_SET16((__p)->z_extras,(__x))
+#define zzip_file_header_sizeof_tails(__p) (zzip_file_header_get_namlen(__p)+\
+ zzip_file_header_get_extras(__p) )
+#define zzip_file_header_check_magic(__p) ZZIP_FILE_HEADER_CHECKMAGIC((__p))
+
+/* zzip_file_trailer - data descriptor per file block */
+#define zzip_file_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic)
+#define zzip_file_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x))
+#define zzip_file_header_get_crc32(__p) ZZIP_GET32((__p)->z_crc32)
+#define zzip_file_trailer_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x))
+#define zzip_file_trailer_get_csize(__p) ZZIP_GET32((__p)->z_csize)
+#define zzip_file_trailer_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x))
+#define zzip_file_trailer_get_usize(__p) ZZIP_GET32((__p)->z_usize)
+#define zzip_file_trailer_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x))
+#define zzip_file_trailer_sizeof_tails(__p) 0
+#define zzip_file_trailer_check_magic(__p) ZZIP_FILE_TRAILER_CHECKMAGIC((__p))
+/* zzip_disk_entry (currently named zzip_root_dirent) */
+#define zzip_disk_entry_get_magic(__p) ZZIP_GET32((__p)->z_magic)
+#define zzip_disk_entry_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x))
+#define zzip_disk_entry_get_flags(__p) ZZIP_GET16((__p)->z_flags)
+#define zzip_disk_entry_set_flags(__p,__x) ZZIP_SET16((__p)->z_flags,(__x))
+#define zzip_disk_entry_get_compr(__p) ZZIP_GET16((__p)->z_compr)
+#define zzip_disk_entry_set_compr(__p,__x) ZZIP_SET16((__p)->z_compr,(__x))
+#define zzip_disk_entry_get_crc32(__p) ZZIP_GET32((__p)->z_crc32)
+#define zzip_disk_entry_set_crc32(__p,__x) ZZIP_SET32((__p)->z_crc32,(__x))
+#define zzip_disk_entry_get_csize(__p) ZZIP_GET32((__p)->z_csize)
+#define zzip_disk_entry_set_csize(__p,__x) ZZIP_SET32((__p)->z_csize,(__x))
+#define zzip_disk_entry_get_usize(__p) ZZIP_GET32((__p)->z_usize)
+#define zzip_disk_entry_set_usize(__p,__x) ZZIP_SET32((__p)->z_usize,(__x))
+#define zzip_disk_entry_get_namlen(__p) ZZIP_GET16((__p)->z_namlen)
+#define zzip_disk_entry_set_namlen(__p,__x) ZZIP_SET16((__p)->z_namlen,(__x))
+#define zzip_disk_entry_get_extras(__p) ZZIP_GET16((__p)->z_extras)
+#define zzip_disk_entry_set_extras(__p,__x) ZZIP_SET16((__p)->z_extras,(__x))
+#define zzip_disk_entry_get_comment(__p) ZZIP_GET16((__p)->z_comment)
+#define zzip_disk_entry_set_comment(__p,__x) ZZIP_SET16((__p)->z_comment,(__x))
+#define zzip_disk_entry_get_diskstart(__p) ZZIP_GET16((__p)->z_diskstart)
+#define zzip_disk_entry_set_diskstart(__p,__x) ZZIP_SET16((__p)->z_diskstart,(__x))
+#define zzip_disk_entry_get_filetype(__p) ZZIP_GET16((__p)->z_filetype)
+#define zzip_disk_entry_set_filetype(__p,__x) ZZIP_SET16((__p)->z_filetype,(__x))
+#define zzip_disk_entry_get_filemode(__p) ZZIP_GET32((__p)->z_filemode)
+#define zzip_disk_entry_set_filemode(__p,__x) ZZIP_SET32((__p)->z_filemode,(__x))
+#define zzip_disk_entry_get_offset(__p) ZZIP_GET32((__p)->z_offset)
+#define zzip_disk_entry_set_offset(__p,__x) ZZIP_SET32((__p)->z_offset,(__x))
+#define zzip_disk_entry_sizeof_tails(__p) (zzip_disk_entry_get_namlen(__p) +\
+ zzip_disk_entry_get_extras(__p) +\
+ zzip_disk_entry_get_comment(__p) )
+#define zzip_disk_entry_check_magic(__p) ZZIP_DISK_ENTRY_CHECKMAGIC((__p))
+
+/* zzip_disk_trailer - the zip archive entry point */
+#define zzip_disk_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic)
+#define zzip_disk_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x))
+#define zzip_disk_trailer_get_disk(__p) ZZIP_GET16((__p)->z_disk)
+#define zzip_disk_trailer_set_disk(__p,__x) ZZIP_SET16((__p)->z_disk,(__x))
+#define zzip_disk_trailer_get_finaldisk(__p) ZZIP_GET16((__p)->z_finaldisk)
+#define zzip_disk_trailer_set_finaldisk(__p,__x) ZZIP_SET16((__p)->z_finaldisk,(__x))
+#define zzip_disk_trailer_get_entries(__p) ZZIP_GET16((__p)->z_entries)
+#define zzip_disk_trailer_set_entries(__p,__x) ZZIP_SET16((__p)->z_entries,(__x))
+#define zzip_disk_trailer_get_finalentries(__p) ZZIP_GET16((__p)->z_finalentries)
+#define zzip_disk_trailer_set_finalentries(__p,__x) ZZIP_SET16((__p)->z_finalentries,(__x))
+#define zzip_disk_trailer_get_rootsize(__p) ZZIP_GET32((__p)->z_rootsize)
+#define zzip_disk_trailer_set_rootsize(__p,__x) ZZIP_SET32((__p)->z_rootsize,(__x))
+#define zzip_disk_trailer_get_rootseek(__p) ZZIP_GET32((__p)->z_rootseek)
+#define zzip_disk_trailer_set_rootseek(__p,__x) ZZIP_SET32((__p)->z_rootseek,(__x))
+#define zzip_disk_trailer_get_comment(__p) ZZIP_GET16((__p)->z_comment)
+#define zzip_disk_trailer_set_comment(__p,__x) ZZIP_SET16((__p)->z_comment,(__x))
+#define zzip_disk_trailer_sizeof_tails(__p) ( zzip_disk_entry_get_comment(__p))
+#define zzip_disk_trailer_check_magic(__p) ZZIP_DISK_TRAILER_CHECKMAGIC((__p))
+
+/* extra field should be type + size + data + type + size + data ... */
+#define zzip_extra_block_get_datatype(__p) ZZIP_GET16((zzip_byte_t*)(__p))
+#define zzip_extra_block_set_datatype(__p,__x) ZZIP_SET16((zzip_byte_t*)(__p),__x)
+#define zzip_extra_block_get_datasize(__p) ZZIP_GET16((zzip_byte_t*)(__p)+2)
+#define zzip_extra_block_set_datasize(__p,__x) ZZIP_SET16((zzip_byte_t*)(__p)+2,__x)
+
+/* zzip64_disk_trailer - the zip64 archive entry point */
+#define zzip_disk64_trailer_get_magic(__p) ZZIP_GET32((__p)->z_magic)
+#define zzip_disk64_trailer_set_magic(__p,__x) ZZIP_SET32((__p)->z_magic,(__x))
+#define zzip_disk64_trailer_get_size(__p) ZZIP_GET64((__p)->z_size)
+#define zzip_disk64_trailer_set_size(__p,__x) ZZIP_SET64((__p)->z_size,(__x))
+#define zzip_disk64_trailer_get_disk(__p) ZZIP_GET32((__p)->z_disk)
+#define zzip_disk64_trailer_set_disk(__p,__x) ZZIP_SET32((__p)->z_disk,(__x))
+#define zzip_disk64_trailer_get_finaldisk(__p) ZZIP_GET32((__p)->z_finaldisk)
+#define zzip_disk64_trailer_set_finaldisk(__p,__x) ZZIP_SET32((__p)->z_finaldisk,(__x))
+#define zzip_disk64_trailer_get_entries(__p) ZZIP_GET64((__p)->z_entries)
+#define zzip_disk64_trailer_set_entries(__p,__x) ZZIP_SET64((__p)->z_entries,(__x))
+#define zzip_disk64_trailer_get_finalentries(__p) ZZIP_GET64((__p)->z_finalentries)
+#define zzip_disk64_trailer_set_finalentries(__p,__x) ZZIP_SET64((__p)->z_finalentries,(__x))
+#define zzip_disk64_trailer_get_rootsize(__p) ZZIP_GET64((__p)->z_rootsize)
+#define zzip_disk64_trailer_set_rootsize(__p,__x) ZZIP_SET64((__p)->z_rootsize,(__x))
+#define zzip_disk64_trailer_get_rootseek(__p) ZZIP_GET64((__p)->z_rootseek)
+#define zzip_disk64_trailer_set_rootseek(__p,__x) ZZIP_SET64((__p)->z_rootseek,(__x))
+#define zzip_disk64_trailer_check_magic(__p) ZZIP_DISK64_TRAILER_CHECKMAGIC((__p))
+
+/* .............. some logical typed access wrappers ....................... */
+
+/* zzip_file_header - the local file header */
+#define zzip_file_header_csize(__p) ((zzip_size_t) \
+ zzip_file_header_get_csize(__p))
+#define zzip_file_header_usize(__p) ((zzip_size_t) \
+ zzip_file_header_get_usize(__p))
+#define zzip_file_header_namlen(__p) ((zzip_size_t) \
+ zzip_file_header_get_namlen(__p))
+#define zzip_file_header_extras(__p) ((zzip_size_t) \
+ zzip_file_header_get_extras(__p))
+#define zzip_file_header_sizeof_tail(__p) ((zzip_size_t) \
+ zzip_file_header_sizeof_tails(__p))
+#define zzip_file_header_sizeto_end(__p) ((zzip_size_t) \
+ (zzip_file_header_sizeof_tail(__p) + zzip_file_header_headerlength))
+#define zzip_file_header_skipto_end(__p) ((void*) (__p) + \
+ (zzip_file_header_sizeof_tail(__p) + zzip_file_header_headerlength))
+
+#define zzip_file_header_to_filename(__p) ((char*) \
+ ((char*)(__p) + zzip_file_header_headerlength))
+#define zzip_file_header_to_extras(__p) ((char*) \
+ (zzip_file_header_to_filename(__p) + zzip_file_header_namlen(__p)))
+#define zzip_file_header_to_data(__p) ((zzip_byte_t*) \
+ (zzip_file_header_to_extras(__p) + zzip_file_header_extras(__p)))
+#define zzip_file_header_to_trailer(__p) ((struct zzip_file_trailer*) \
+ (zzip_file_header_to_data(__p) + zzip_file_header_csize(__p)))
+
+/* zzip_file_trailer - data descriptor per file block */
+#define zzip_file_trailer_csize(__p) ((zzip_size_t) \
+ zzip_file_trailer_get_csize(__p))
+#define zzip_file_trailer_usize(__p) ((zzip_size_t) \
+ zzip_file_trailer_get_usize(__p))
+#define zzip_file_trailer_sizeof_tail(__p) ((zzip_size_t) \
+ zzip_file_trailer_sizeof_tails(__p))
+#define zzip_file_trailer_sizeto_end(__p) ((zzip_size_t) \
+ (zzip_file_trailer_sizeof_tail(__p) + zzip_file_trailer_headerlength))
+#define zzip_file_trailer_skipto_end(__p) ((void*) (__p) + \
+ (zzip_file_trailer_sizeof_tail(__p) + zzip_file_trailer_headerlength))
+
+/* zzip_disk_entry (currently named zzip_root_dirent) */
+#define zzip_disk_entry_csize(__p) ((zzip_size_t) \
+ zzip_disk_entry_get_csize(__p))
+#define zzip_disk_entry_usize(__p) ((zzip_size_t) \
+ zzip_disk_entry_get_usize(__p))
+#define zzip_disk_entry_namlen(__p) ((zzip_size_t) \
+ zzip_disk_entry_get_namlen(__p))
+#define zzip_disk_entry_extras(__p) ((zzip_size_t) \
+ zzip_disk_entry_get_extras(__p))
+#define zzip_disk_entry_comment(__p) ((zzip_size_t) \
+ zzip_disk_entry_get_comment(__p))
+#define zzip_disk_entry_diskstart(__p) ((int) \
+ zzip_disk_entry_get_diskstart(__p))
+#define zzip_disk_entry_filetype(__p) ((int) \
+ zzip_disk_entry_get_filetype(__p))
+#define zzip_disk_entry_filemode(__p) ((int) \
+ zzip_disk_entry_get_filemode(__p))
+#define zzip_disk_entry_fileoffset(__p) ((zzip_off_t) \
+ zzip_disk_entry_get_offset(__p))
+#define zzip_disk_entry_sizeof_tail(__p) ((zzip_size_t) \
+ zzip_disk_entry_sizeof_tails(__p))
+#define zzip_disk_entry_sizeto_end(__p) ((zzip_size_t) \
+ (zzip_disk_entry_sizeof_tail(__p) + zzip_disk_entry_headerlength))
+#define zzip_disk_entry_skipto_end(__p) ((zzip_byte_t*) (__p) + \
+ (zzip_disk_entry_sizeof_tail(__p) + zzip_disk_entry_headerlength))
+
+#define zzip_disk_entry_to_filename(__p) ((char*) \
+ ((char*)(__p) + zzip_disk_entry_headerlength))
+#define zzip_disk_entry_to_extras(__p) ((char*) \
+ (zzip_disk_entry_to_filename(__p) + zzip_disk_entry_namlen(__p)))
+#define zzip_disk_entry_to_comment(__p) ((char*) \
+ (zzip_disk_entry_to_extras(__p) + zzip_disk_entry_extras(__p)))
+#define zzip_disk_entry_to_next_entry(__p) ((struct zzip_disk_entry*) \
+ (zzip_disk_entry_to_comment(__p) + zzip_disk_entry_comment(__p)))
+
+/* zzip_disk_trailer - the zip archive entry point */
+#define zzip_disk_trailer_localdisk(__p) ((int) \
+ zzip_disk_trailer_get_disk(__p))
+#define zzip_disk_trailer_finaldisk(__p) ((int) \
+ zzip_disk_trailer_get_finaldisk(__p))
+#define zzip_disk_trailer_localentries(__p) ((int) \
+ zzip_disk_trailer_get_entries(__p))
+#define zzip_disk_trailer_finalentries(__p) ((int) \
+ zzip_disk_trailer_get_finalentries(__p))
+#define zzip_disk_trailer_rootsize(__p) ((zzip_off_t) \
+ zzip_disk_trailer_get_rootsize(__p))
+#define zzip_disk_trailer_rootseek(__p) ((zzip_off_t) \
+ zzip_disk_trailer_get_rootseek(__p))
+#define zzip_disk_trailer_comment(__p) ((zzip_size_t) \
+ zzip_disk_trailer_get_comment(__p))
+#define zzip_disk_trailer_sizeof_tail(__p) ((zzip_size_t) \
+ zzip_disk_trailer_sizeof_tails(__p))
+#define zzip_disk_trailer_sizeto_end(__p) ((zzip_size_t) \
+ (zzip_disk_trailer_sizeof_tail(__p) + zzip_disk_trailer_headerlength))
+#define zzip_disk_trailer_skipto_end(__p) ((void*) (__p) \
+ (zzip_disk_trailer_sizeof_tail(__p) + zzip_disk_trailer_headerlength))
+
+#define zzip_disk_trailer_to_comment(__p) ((char*) \
+ ((char*)(__p) + zzip_disk_trailer_headerlength))
+#define zzip_disk_trailer_to_endoffile(__p) ((void*) \
+ (zzip_disk_trailer_to_comment(__p) + zzip_disk_trailer_comment(__p)))
+
+/* zzip_disk64_trailer - the zip archive entry point */
+#define zzip_disk64_trailer_localdisk(__p) ((int) \
+ zzip_disk64_trailer_get_disk(__p))
+#define zzip_disk64_trailer_finaldisk(__p) ((int) \
+ zzip_disk64_trailer_get_finaldisk(__p))
+#define zzip_disk64_trailer_localentries(__p) ((int) \
+ zzip_disk64_trailer_get_entries(__p))
+#define zzip_disk64_trailer_finalentries(__p) ((int) \
+ zzip_disk64_trailer_get_finalentries(__p))
+#define zzip_disk64_trailer_rootsize(__p) ((zzip_off64_t) \
+ zzip_disk64_trailer_get_rootsize(__p))
+#define zzip_disk64_trailer_rootseek(__p) ((zzip_off64_t) \
+ zzip_disk64_trailer_get_rootseek(__p))
+#define zzip_disk64_trailer_sizeof_tail(__p) ((zzip_size_t) \
+ zzip_disk64_trailer_get_size(__p) - zzip_disk64_trailer_headerlength)
+#define zzip_disk64_trailer_sizeto_end(__p) ((zzip_size_t) \
+ zzip_disk64_trailer_get_size(__p))
+#define zzip_disk64_trailer_skipto_end(__p) ((void*) \
+ ((char*)(__p) + zzip_disk64_sizeto_end(__p)))
+
+/* extra field should be type + size + data + type + size + data ... */
+#define zzip_extra_block_sizeof_tail(__p) ((zzip_size_t) \
+ (zzip_extra_block_get_datasize(__p)))
+#define zzip_extra_block_sizeto_end(__p) ((zzip_size_t) \
+ (zzip_extra_block_sizeof_tail(__p) + zzip_extra_block_headerlength))
+#define zzip_extra_block_skipto_end(__p) ((void*) (__p) \
+ (zzip_extra_block_sizeof_tail(__p) + zzip_extra_block_headerlength))
+
+/* ................... and put these to the next level ................ */
+
+#define zzip_file_header_data_encrypted(__p) \
+ ZZIP_IS_ENCRYPTED( zzip_file_header_get_flags(__p) )
+#define zzip_file_header_data_comprlevel(__p) \
+ ZZIP_IS_COMPRLEVEL( zzip_file_header_get_flags(__p) )
+#define zzip_file_header_data_streamed(__p) \
+ ZZIP_IS_STREAMED( zzip_file_header_get_flags(__p) )
+#define zzip_file_header_data_stored(__p) \
+ ( ZZIP_IS_STORED == zzip_file_header_get_compr(__p) )
+#define zzip_file_header_data_deflated(__p) \
+ ( ZZIP_IS_DEFLATED == zzip_file_header_get_compr(__p) )
+
+#define zzip_disk_entry_data_encrypted(__p) \
+ ZZIP_IS_ENCRYPTED( zzip_disk_entry_get_flags(__p) )
+#define zzip_disk_entry_data_comprlevel(__p) \
+ ZZIP_IS_COMPRLEVEL( zzip_disk_entry_get_flags(__p) )
+#define zzip_disk_entry_data_streamed(__p) \
+ ZZIP_IS_STREAMED( zzip_disk_entry_get_flags(__p) )
+#define zzip_disk_entry_data_stored(__p) \
+ ( ZZIP_IS_STORED == zzip_disk_entry_get_compr(__p) )
+#define zzip_disk_entry_data_deflated(__p) \
+ ( ZZIP_IS_DEFLATED == zzip_disk_entry_get_compr(__p) )
+#define zzip_disk_entry_data_ascii(__p) \
+ ( zzip_disk_entry_get_filetype(__p) & 1)
+
+#define zzip_file_header_data_not_deflated(__p) \
+ (zzip_file_header_data_stored(__p))
+#define zzip_file_header_data_std_deflated(__p) \
+ (zzip_file_header_data_deflated(__p) && \
+ zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_STD_COMPR)
+#define zzip_file_header_data_max_deflated(__p) \
+ (zzip_file_header_data_deflated(__p) && \
+ zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_MAX_COMPR)
+#define zzip_file_header_data_low_deflated(__p) \
+ (zzip_file_header_data_deflated(__p) && \
+ zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_LOW_COMPR)
+#define zzip_file_header_data_min_deflated(__p) \
+ (zzip_file_header_data_deflated(__p) && \
+ zzip_file_header_data_comprlevel(__p) == ZZIP_DEFLATED_MIN_COMPR)
+
+#define zzip_disk_entry_data_not_deflated(__p) \
+ (zzip_disk_entry_data_stored(__p))
+#define zzip_disk_entry_data_std_deflated(__p) \
+ (zzip_disk_entry_data_deflated(__p) && \
+ zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_STD_COMPR)
+#define zzip_disk_entry_data_max_deflated(__p) \
+ (zzip_disk_entry_data_deflated(__p) && \
+ zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_MAX_COMPR)
+#define zzip_disk_entry_data_low_deflated(__p) \
+ (zzip_disk_entry_data_deflated(__p) && \
+ zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_LOW_COMPR)
+#define zzip_disk_entry_data_min_deflated(__p) \
+ (zzip_disk_entry_data_deflated(__p) && \
+ zzip_disk_entry_data_comprlevel(__p) == ZZIP_DEFLATED_MIN_COMPR)
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.c
new file mode 100644
index 00000000000..af3ed07e556
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.c
@@ -0,0 +1,1032 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@iki.fi>
+ *
+ * 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 <zzip/lib.h> /* exported...*/
+#include <zzip/file.h>
+
+#include <string.h>
+#ifdef ZZIP_HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <zzip/format.h>
+#include <zzip/fetch.h>
+#include <zzip/__debug.h>
+
+#if 0
+# if defined ZZIP_HAVE_IO_H
+# include <io.h> /* tell */
+# else
+# define tell(fd) lseek(fd,0,SEEK_CUR)
+# endif
+#else
+#define tells(fd) seeks(fd,0,SEEK_CUR)
+#endif
+
+/**
+ * the direct function of => zzip_close(fp). it will cleanup the
+ * inflate-portion of => zlib and free the structure given.
+ *
+ * it is called quite from the error-cleanup parts
+ * of the various => _open functions.
+ *
+ * the .refcount is decreased and if zero the fp->dir is closed just as well.
+ */
+int
+zzip_file_close(ZZIP_FILE * fp)
+{
+ auto int self;
+ ZZIP_DIR * dir = fp->dir;
+
+ if (fp->method)
+ inflateEnd(&fp->d_stream); /* inflateEnd() can be called many times */
+
+ if (dir->cache.locked == NULL)
+ dir->cache.locked = &self;
+
+ if (fp->buf32k)
+ {
+ if (dir->cache.locked == &self &&
+ dir->cache.buf32k == NULL) dir->cache.buf32k = fp->buf32k;
+ else free(fp->buf32k);
+ }
+
+ if (dir->currentfp == fp)
+ dir->currentfp = NULL;
+
+ dir->refcount--;
+ /* ease to notice possible dangling reference errors */
+ memset(fp, 0, sizeof(*fp));
+
+ if (dir->cache.locked == &self &&
+ dir->cache.fp == NULL) dir->cache.fp = fp;
+ else free(fp);
+
+ if (dir->cache.locked == &self)
+ dir->cache.locked = NULL;
+
+ if (! dir->refcount) return zzip_dir_close(dir); else return 0;
+}
+
+
+static int
+zzip_file_saveoffset(ZZIP_FILE * fp)
+{
+ if (fp)
+ {
+ int fd = fp->dir->fd;
+ zzip_off_t off = fp->io->fd.seeks(fd, 0, SEEK_CUR);
+ if (off < 0)
+ return -1;
+
+ fp->offset = off;
+ }
+ return 0;
+}
+
+# ifndef ZZIP_CHECK_BACKSLASH_DIRSEPARATOR /* NOTE: also default */
+# define ZZIP_CHECK_BACKSLASH_DIRSEPARATOR 0 /* to "NO" on win32 ! */
+# endif
+
+# if !defined strcasecmp && !defined ZZIP_HAVE_STRCASECMP
+# define ZZIP_CHECK_BACKSLASH_DIRSEPARATOR 1
+# endif
+
+#if ! ZZIP_CHECK_BACKSLASH_DIRSEPARATOR+0
+#define dirsep_strrchr(N,C) strrchr(N,C)
+#define dirsep_casecmp strcasecmp
+#else
+#define dirsep_strrchr(N,C) _dirsep_strrchr(N)
+#define dirsep_casecmp _dirsep_casecmp
+static zzip_char_t*
+_dirsep_strrchr (zzip_char_t* name)
+{
+ char* n = strrchr (name, '/');
+ char* m = strrchr (name, '\\');
+ if (m && n && m > n) n = m;
+ return n;
+}
+static int
+_dirsep_casecmp (zzip_char_t* s1, zzip_char_t* s2)
+{
+ /* ASCII tolower - including mapping of backslash in normal slash */
+ static const char mapping[] = "@abcdefghijklmnopqrstuvwxyz[/]^_";
+ int c1, c2;
+ while (*s1 && *s2)
+ {
+ c1 = (int)(unsigned char) *s1;
+ c2 = (int)(unsigned char) *s2;
+ if ((c1&0xE0) == 0x40) c1 = mapping[c1&0x1f];
+ if ((c2&0xE0) == 0x40) c2 = mapping[c2&0x1f];
+ if (c1 != c2)
+ return (c1 - c2);
+ s1++; s2++;
+ }
+
+ return (((int)(unsigned char) *s1) - ((int)(unsigned char) *s2));
+}
+#endif
+
+static int zzip_inflate_init(ZZIP_FILE *, struct zzip_dir_hdr *);
+
+/**
+ * open an => ZZIP_FILE from an already open => ZZIP_DIR handle. Since
+ * we have a chance to reuse a cached => buf32k and => ZZIP_FILE memchunk
+ * this is the best choice to unpack multiple files.
+ *
+ * Note: the zlib supports 2..15 bit windowsize, hence we provide a 32k
+ * memchunk here... just to be safe.
+ */
+ZZIP_FILE *
+zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int o_mode)
+{
+ auto int self;
+ zzip_error_t err = 0;
+ struct zzip_file * fp = 0;
+ struct zzip_dir_hdr * hdr = dir->hdr0;
+ int (*cmp)(zzip_char_t*, zzip_char_t*);
+
+ cmp = (o_mode & ZZIP_CASELESS)? dirsep_casecmp: strcmp;
+
+ if (! dir || !dir->fd || dir->fd == -1 ) return 0;
+
+ if (o_mode & ZZIP_NOPATHS)
+ {
+ register zzip_char_t* n = dirsep_strrchr(name, '/');
+ if (n) name = n + 1;
+ }
+
+ if (hdr)
+ while (1)
+ {
+ register zzip_char_t* hdr_name = hdr->d_name;
+ if (o_mode & ZZIP_NOPATHS)
+ {
+ register zzip_char_t* n = dirsep_strrchr(hdr_name, '/');
+ if (n) hdr_name = n + 1;
+ }
+
+ HINT4("name='%s', compr=%d, size=%d\n",
+ hdr->d_name, hdr->d_compr, hdr->d_usize);
+
+ if (!cmp(hdr_name, name))
+ {
+ switch (hdr->d_compr)
+ {
+ case 0: /* store */
+ case 8: /* inflate */
+ break;
+ default:
+ { err = ZZIP_UNSUPP_COMPR; goto error; }
+ }
+
+ if (dir->cache.locked == NULL)
+ dir->cache.locked = &self;
+
+ if (dir->cache.locked == &self &&
+ dir->cache.fp)
+ {
+ fp = dir->cache.fp; dir->cache.fp = NULL;
+ /* memset(zfp, 0, sizeof *fp); cleared in zzip_file_close() */
+ }else
+ {
+ if (! (fp = (ZZIP_FILE *)calloc(1, sizeof(*fp))))
+ { err = ZZIP_OUTOFMEM; goto error; }
+ }
+
+ fp->dir = dir;
+ fp->io = dir->io;
+ dir->refcount++;
+
+ if (dir->cache.locked == &self &&
+ dir->cache.buf32k)
+ { fp->buf32k = dir->cache.buf32k; dir->cache.buf32k = NULL; }
+ else
+ {
+ if (! (fp->buf32k = (char *)malloc(ZZIP_32K)))
+ { err = ZZIP_OUTOFMEM; goto error; }
+ }
+
+ if (dir->cache.locked == &self)
+ dir->cache.locked = NULL;
+ /*
+ * In order to support simultaneous open files in one zip archive
+ * we'll fix the fd offset when opening new file/changing which
+ * file to read...
+ */
+
+ if (zzip_file_saveoffset(dir->currentfp) < 0)
+ { err = ZZIP_DIR_SEEK; goto error; }
+
+ fp->offset = hdr->d_off;
+ dir->currentfp = fp;
+
+ if (dir->io->fd.seeks(dir->fd, hdr->d_off, SEEK_SET) < 0)
+ { err = ZZIP_DIR_SEEK; goto error; }
+
+ { /* skip local header - should test tons of other info,
+ * but trust that those are correct */
+ zzip_ssize_t dataoff;
+ struct zzip_file_header * p = (void*) fp->buf32k;
+
+ dataoff = dir->io->fd.read(dir->fd, (void*)p, sizeof(*p));
+ if (dataoff < (zzip_ssize_t)sizeof(*p))
+ { err = ZZIP_DIR_READ; goto error; }
+ if (! zzip_file_header_check_magic(p)) /* PK\3\4 */
+ { err = ZZIP_CORRUPTED; goto error; }
+
+ dataoff = zzip_file_header_sizeof_tail(p);
+
+ if (dir->io->fd.seeks(dir->fd, dataoff, SEEK_CUR) < 0)
+ { err = ZZIP_DIR_SEEK; goto error; }
+
+ fp->dataoffset = dir->io->fd.tells(dir->fd);
+ fp->usize = hdr->d_usize;
+ fp->csize = hdr->d_csize;
+ }
+
+ err = zzip_inflate_init (fp, hdr);
+ if (err) { goto error; }
+
+ return fp;
+ }else
+ {
+ if (hdr->d_reclen == 0)
+ break;
+ hdr = (struct zzip_dir_hdr *)((char *)hdr + hdr->d_reclen);
+ }/*cmp name*/
+ }/*forever*/
+ dir->errcode = ZZIP_ENOENT; zzip_errno(ZZIP_ENOENT);
+ return NULL;
+error:
+ if (fp) zzip_file_close(fp);
+ dir->errcode = err; zzip_errno(err);
+ return NULL;
+}
+
+/**
+ * call => inflateInit and setup fp's iterator variables,
+ * used by lowlevel => _open functions.
+ */
+static int
+zzip_inflate_init(ZZIP_FILE * fp, struct zzip_dir_hdr* hdr)
+{
+ int err;
+ fp->method = hdr->d_compr;
+ fp->restlen = hdr->d_usize;
+
+ if (fp->method)
+ {
+ memset(&fp->d_stream, 0, sizeof(fp->d_stream));
+
+ err = inflateInit2(&fp->d_stream, -MAX_WBITS);
+ if (err != Z_OK) { goto error; }
+
+ fp->crestlen = hdr->d_csize;
+ }
+ return 0;
+error:
+ if (fp) zzip_file_close(fp);
+ return err;
+}
+
+/**
+ * This function closes the given ZZIP_FILE handle.
+ *
+ * If the ZZIP_FILE wraps a normal stat'fd then it is just that int'fd
+ * that is being closed and the otherwise empty ZZIP_FILE gets freed.
+ */
+int
+zzip_fclose(ZZIP_FILE * fp)
+{
+ if (! fp) return 0;
+ if (! fp->dir)
+ { int r = fp->io->fd.close(fp->fd); free(fp); return r; } /* stat fd */
+ else return zzip_file_close(fp);
+}
+
+/** => zzip_fclose
+ */
+int
+zzip_close(ZZIP_FILE* fp)
+{
+ return zzip_fclose (fp);
+}
+
+/**
+ * This functions read data from zip-contained file.
+ *
+ * It works like => read(2) and will fill the given buffer with bytes from
+ * the opened file. It will return the number of bytes read, so if the => EOF
+ * is encountered you will be prompted with the number of bytes actually read.
+ *
+ * This is the routines that needs the => buf32k buffer, and it would have
+ * need for much more polishing but it does already work quite well.
+ *
+ * Note: the 32K buffer is rather big. The original inflate-algorithm
+ * required just that but the latest zlib would work just fine with
+ * a smaller buffer.
+ */
+zzip_ssize_t
+zzip_file_read(ZZIP_FILE * fp, char * buf, zzip_size_t len)
+{
+ ZZIP_DIR * dir;
+ zzip_size_t l;
+ zzip_ssize_t rv;
+
+ if (! fp || ! fp->dir) return 0;
+
+ dir = fp->dir;
+ l = fp->restlen > len ? len : fp->restlen;
+ if (fp->restlen == 0)
+ return 0;
+
+ /*
+ * If this is other handle than previous, save current seek pointer
+ * and read the file position of `this' handle.
+ */
+ if (dir->currentfp != fp)
+ {
+ if (zzip_file_saveoffset(dir->currentfp) < 0
+ || fp->io->fd.seeks(dir->fd, fp->offset, SEEK_SET) < 0)
+ { dir->errcode = ZZIP_DIR_SEEK; return -1; }
+ else
+ { dir->currentfp = fp; }
+ }
+
+ /* if more methods is to be supported, change this to `switch ()' */
+ if (fp->method) /* method != 0 == 8, inflate */
+ {
+ fp->d_stream.avail_out = l;
+ fp->d_stream.next_out = (unsigned char *)buf;
+
+ do {
+ int err;
+ zzip_size_t startlen;
+
+ if (fp->crestlen > 0 && fp->d_stream.avail_in == 0)
+ {
+ zzip_size_t cl = ( fp->crestlen < ZZIP_32K ?
+ fp->crestlen : ZZIP_32K );
+ /* zzip_size_t cl = fp->crestlen > 128 ? 128 : fp->crestlen; */
+
+ zzip_ssize_t i = fp->io->fd.read(dir->fd, fp->buf32k, cl);
+ if (i <= 0)
+ {
+ dir->errcode = ZZIP_DIR_READ; /* or ZZIP_DIR_READ_EOF ? */
+ return -1;
+ }
+ fp->crestlen -= i;
+ fp->d_stream.avail_in = i;
+ fp->d_stream.next_in = (unsigned char *)fp->buf32k;
+ }
+
+ startlen = fp->d_stream.total_out;
+ err = inflate(&fp->d_stream, Z_NO_FLUSH);
+
+ if (err == Z_STREAM_END)
+ { fp->restlen = 0; }
+ else
+ if (err == Z_OK)
+ { fp->restlen -= (fp->d_stream.total_out - startlen); }
+ else
+ { dir->errcode = err; return -1; }
+ } while (fp->restlen && fp->d_stream.avail_out);
+
+ return l - fp->d_stream.avail_out;
+ }else
+ { /* method == 0 -- unstore */
+ rv = fp->io->fd.read(dir->fd, buf, l);
+ if (rv > 0)
+ { fp->restlen-= rv; }
+ else
+ if (rv < 0)
+ { dir->errcode = ZZIP_DIR_READ; }
+ return rv;
+ }
+}
+
+/**
+ * This function will read(2) data from a real/zipped file.
+ *
+ * the replacement for => read(2) will fill the given buffer with bytes from
+ * the opened file. It will return the number of bytes read, so if the EOF
+ * is encountered you will be prompted with the number of bytes actually read.
+ *
+ * If the file-handle is wrapping a stat'able file then it will actually just
+ * perform a normal => read(2)-call, otherwise => zzip_file_read is called
+ * to decompress the data stream and any error is mapped to => errno(3).
+ */
+zzip_ssize_t
+zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len)
+{
+ if (! fp) return 0;
+ if (! fp->dir)
+ { return fp->io->fd.read(fp->fd, buf, len); } /* stat fd */
+ else
+ { register zzip_ssize_t v;
+ v = zzip_file_read(fp, buf, len);
+ if (v == -1) { errno = zzip_errno(fp->dir->errcode); }
+ return v;
+ }
+}
+
+/** => zzip_read
+ */
+zzip_size_t
+zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE *file)
+{
+ if (! size) size=1;
+ return zzip_read (file, ptr, size*nmemb)/size;
+}
+
+
+#define ZZIP_WRONLY O_WRONLY
+#define ZZIP_EXCL O_EXCL
+
+#if defined O_SYNC
+#define ZZIP_SYNC O_SYNC
+#else
+#define ZZIP_SYNC 0
+#endif
+
+#if defined O_NONBLOCK
+#define ZZIP_NONBLOCK O_NONBLOCK
+#elif defined O_NDELAY
+#define ZZIP_NOCTTY O_NDELAY
+#else
+#define ZZIP_NOCTTY 0
+#endif
+
+/* ------------------------------------------------------------------- */
+
+/**
+ * This function will => fopen(3) a real/zipped file.
+ *
+ * It has some magic functionality builtin - it will first try to open
+ * the given <em>filename</em> as a normal file. If it does not
+ * exist, the given path to the filename (if any) is split into
+ * its directory-part and the file-part. A ".zip" extension is
+ * then added to the directory-part to create the name of a
+ * zip-archive. That zip-archive (if it exists) is being searched
+ * for the file-part, and if found a zzip-handle is returned.
+ *
+ * Note that if the file is found in the normal fs-directory the
+ * returned structure is mostly empty and the => zzip_read call will
+ * use the libc => read to obtain data. Otherwise a => zzip_file_open
+ * is performed and any error mapped to => errno(3).
+ *
+ * unlike the posix-wrapper => zzip_open the mode-argument is
+ * a string which allows for more freedom to support the extra
+ * zzip modes called ZZIP_CASEINSENSITIVE and ZZIP_IGNOREPATH.
+ * Currently, this => zzip_fopen call will convert the following
+ * characters in the mode-string into their corrsponding mode-bits:
+ * <ul><li><code> "r" : O_RDONLY : </code> read-only
+ * </li><li><code> "b" : O_BINARY : </code> binary (win32 specific)
+ * </li><li><code> "f" : O_NOCTTY : </code> no char device (unix)
+ * </li><li><code> "i" : ZZIP_CASELESS : </code> inside zip file
+ * </li><li><code> "*" : ZZIP_NOPATHS : </code> inside zip file only
+ * </ul> all other modes will be ignored for zip-contained entries
+ * but they are transferred for compatibility and portability,
+ * including these extra sugar bits:
+ * <ul><li><code> "x" : O_EXCL :</code> fail if file did exist
+ * </li><li><code> "s" : O_SYNC :</code> synchronized access
+ * </li><li><code> "n" : O_NONBLOCK :</code> nonblocking access
+ * </li><li><code> "z#" : compression level :</code> for zlib
+ * </li><li><code> "g#" : group access :</code> unix access bits
+ * </li><li><code> "u#" : owner access :</code> unix access bits
+ * </li><li><code> "o#" : world access :</code> unix access bits
+ * </ul>... the access bits are in traditional unix bit format
+ * with 7 = read/write/execute, 6 = read/write, 4 = read-only.
+ *
+ * The default access mode is 0664, and the compression level
+ * is ignored since the lib can not yet write zip files, otherwise
+ * it would be the initialisation value for the zlib deflateInit
+ * where 0 = no-compression, 1 = best-speed, 9 = best-compression.
+ */
+ZZIP_FILE*
+zzip_fopen(zzip_char_t* filename, zzip_char_t* mode)
+{
+ return zzip_freopen (filename, mode, 0);
+}
+
+/** => zzip_fopen
+ *
+ * This function receives an additional argument pointing to
+ * a ZZIP_FILE* being already in use. If this extra argument is
+ * null then this function is identical with calling => zzip_fopen
+ *
+ * Per default, the old file stream is closed and only the internal
+ * structures associated with it are kept. These internal structures
+ * may be reused for the return value, and this is a lot quicker when
+ * the filename matches a zipped file that is incidently in the very
+ * same zip arch as the old filename wrapped in the stream struct.
+ *
+ * That's simply because the zip arch's central directory does not
+ * need to be read again. As an extension for this function, if the
+ * mode-string contains a "q" then the old stream is not closed but
+ * left untouched, instead it is only given as a hint that a new
+ * file handle may share/copy the zip arch structures of the old file
+ * handle if that is possible, i.e when they are in the same zip arch.
+ */
+ZZIP_FILE*
+zzip_freopen(zzip_char_t* filename, zzip_char_t* mode, ZZIP_FILE* stream)
+{
+ int o_flags = 0;
+ int o_modes = 0664;
+ if (!mode) mode = "rb";
+
+# ifndef O_BINARY
+# define O_BINARY 0
+# endif
+# ifndef O_NOCTTY
+# define O_NOCTTY 0
+# endif
+# ifndef O_SYNC
+# define O_SYNC 0
+# endif
+# ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+# endif
+
+ for(; *mode; mode++)
+ {
+ switch (*mode)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ continue; /* ignore if not attached to other info */
+ case 'r': o_flags |= mode[1] == '+' ? O_RDWR : O_RDONLY; break;
+ case 'w': o_flags |= mode[1] == '+' ? O_RDWR : O_WRONLY;
+ o_flags |= O_TRUNC; break;
+ case 'b': o_flags |= O_BINARY; break;
+ case 'f': o_flags |= O_NOCTTY; break;
+ case 'i': o_modes |= ZZIP_CASELESS; break;
+ case '*': o_modes |= ZZIP_NOPATHS; break;
+ case 'x': o_flags |= O_EXCL; break;
+ case 's': o_flags |= O_SYNC; break;
+ case 'n': o_flags |= O_NONBLOCK; break;
+ case 'o': o_modes &=~ 07;
+ o_modes |= ((mode[1] - '0'))&07; continue;
+ case 'g': o_modes &=~ 070;
+ o_modes |= ((mode[1] - '0')<<3)&070; continue;
+ case 'u': o_modes &=~ 0700;
+ o_modes |= ((mode[1] - '0')<<6)&0700; continue;
+ case 'q': o_modes |= ZZIP_FACTORY; break;
+ case 'z': /* compression level */
+ continue; /* currently ignored, just for write mode */
+ }
+ }
+
+ {
+ ZZIP_FILE* fp =
+ zzip_open_shared_io (stream, filename, o_flags, o_modes, 0, 0);
+
+ if (! o_modes&ZZIP_FACTORY && stream)
+ zzip_file_close (stream);
+
+ return fp;
+ }
+}
+
+/**
+ * This function will => open(2) a real/zipped file
+ *
+ * It has some magic functionality builtin - it will first try to open
+ * the given <em>filename</em> as a normal file. If it does not
+ * exist, the given path to the filename (if any) is split into
+ * its directory-part and the file-part. A ".zip" extension is
+ * then added to the directory-part to create the name of a
+ * zip-archive. That zip-archive (if it exists) is being searched
+ * for the file-part, and if found a zzip-handle is returned.
+ *
+ * Note that if the file is found in the normal fs-directory the
+ * returned structure is mostly empty and the => zzip_read call will
+ * use the libc => read to obtain data. Otherwise a => zzip_file_open
+ * is performed and any error mapped to => errno(3).
+ *
+ * There was a possibility to transfer zziplib-specific openmodes
+ * through o_flags but you should please not use them anymore and
+ * look into => zzip_open_ext_io to submit them down. This function
+ * is shallow in that it just extracts the zzipflags and calls <ul><li><code>
+ * zzip_open_ext_io(filename, o_flags, zzipflags|0664, 0, 0) </code></li></ul>
+ * you must stop using this extra functionality (not well known
+ * anyway) since zzip_open might be later usable to open files
+ * for writing in which case the _EXTRAFLAGS will get in conflict.
+ *
+ * compare with => open(2) and => zzip_fopen
+ */
+ZZIP_FILE*
+zzip_open(zzip_char_t* filename, int o_flags)
+{
+ /* backward compatibility */
+ int o_modes = 0664;
+ if (o_flags & ZZIP_CASEINSENSITIVE)
+ { o_flags ^= ZZIP_CASEINSENSITIVE; o_modes |= ZZIP_CASELESS; }
+ if (o_flags & ZZIP_IGNOREPATH)
+ { o_flags ^= ZZIP_IGNOREPATH; o_modes |= ZZIP_NOPATHS; }
+ return zzip_open_ext_io(filename, o_flags, o_modes, 0, 0);
+}
+
+/* ZZIP_ONLYZIP won't work on platforms with sizeof(int) == 16bit */
+#if ZZIP_SIZEOF_INT+0 == 2
+#undef ZZIP_ONLYZIP
+#endif
+
+/** => zzip_open
+ *
+ * This function uses explicit ext and io instead of the internal
+ * defaults, setting them to zero is equivalent to => zzip_open
+ *
+ * note that the two flag types have been split into an o_flags
+ * (for fcntl-like openflags) and o_modes where the latter shall
+ * carry the zzip_flags and possibly accessmodes for unix filesystems.
+ * Since this version of zziplib can not write zipfiles, it is not
+ * yet used for anything else than zzip-specific modeflags.
+ */
+ZZIP_FILE*
+zzip_open_ext_io(zzip_char_t* filename, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ return zzip_open_shared_io (0, filename, o_flags, o_modes, ext, io);
+}
+
+/** => zzip_open
+ *
+ * This function takes an extra stream argument - if a handle has been
+ * then ext/io can be left null and the new stream handle will pick up
+ * the ext/io. This should be used only in specific environment however
+ * since => zzip_file_real does not store any ext-sequence.
+ *
+ * The benefit for this function comes in when the old file handle
+ * was openened from a file within a zip archive. When the new file
+ * is in the same zip archive then the internal zzip_dir structures
+ * will be shared. It is even quicker, as no check needs to be done
+ * anymore trying to guess the zip archive place in the filesystem,
+ * here we just check whether the zip archive's filepath is a prefix
+ * part of the filename to be opened.
+ *
+ * Note that this function is also used by => zzip_freopen that
+ * will unshare the old handle, thereby possibly closing the handle.
+ */
+ZZIP_FILE*
+zzip_open_shared_io (ZZIP_FILE* stream,
+ zzip_char_t* filename, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ if (stream && stream->dir)
+ {
+ if (! ext) ext = stream->dir->fileext;
+ if (! io) io = stream->dir->io;
+ }
+ if (! io) io = zzip_get_default_io ();
+
+ if (o_modes & (ZZIP_PREFERZIP|ZZIP_ONLYZIP)) goto try_zzip;
+ try_real:
+ /* prefer an existing real file */
+ {
+ zzip_plugin_io_t os = (o_modes & ZZIP_ALLOWREAL)
+ ? zzip_get_default_io () : io;
+ int fd = os->fd.open(filename, o_flags); /* io->fd.open */
+ if (fd != -1)
+ {
+ ZZIP_FILE* fp = calloc (1, sizeof(ZZIP_FILE));
+ if (!fp) { os->fd.close(fd); return 0; } /* io->fd.close */
+
+ fp->fd = fd;
+ fp->io = os;
+ return fp;
+ }
+ if (o_modes & ZZIP_PREFERZIP) return 0;
+ }
+ try_zzip:
+
+ /* if the user had it in place of a normal xopen, then
+ * we better defend this lib against illegal usage */
+ if (o_flags & (O_CREAT|O_WRONLY)) { errno = EINVAL; return 0; }
+ if (o_flags & (O_RDWR)) { o_flags ^= O_RDWR; o_flags |= O_RDONLY; }
+
+ /* this is just for backward compatibility -and strictly needed to
+ * prepare ourselves for more options and more options later on... */
+ /*# if (o_modes & ZZIP_CASELESS) { o_flags |= ZZIP_CASEINSENSITIVE; } */
+ /*# if (o_modes & ZZIP_NOPATHS) { o_flags |= ZZIP_IGNOREPATH; } */
+
+ /* see if we can open a file that is a zip file */
+ { char basename[PATH_MAX];
+ char* p;
+ strcpy (basename, filename);
+
+ /* see if we can share the same zip directory */
+ if (stream && stream->dir && stream->dir->realname)
+ {
+ zzip_size_t len = strlen (stream->dir->realname);
+ if (! memcmp (filename, stream->dir->realname, len) &&
+ filename[len] == '/' && filename[len+1])
+ {
+ ZZIP_FILE* fp =
+ zzip_file_open (stream->dir, filename+len+1, o_modes);
+ if (! fp) { errno = zzip_errno (stream->dir->errcode); }
+ return fp;
+ }
+ }
+
+ /* per each slash in filename, check if it there is a zzip around */
+ while ((p = strrchr (basename, '/')))
+ {
+ zzip_error_t e = 0;
+ ZZIP_DIR* dir;
+ ZZIP_FILE* fp;
+ int fd;
+
+ *p = '\0'; /* cut at path separator == possible zipfile basename */
+ fd = __zzip_try_open (basename, o_flags|O_RDONLY|O_BINARY, ext, io);
+ if (fd == -1) { continue; }
+/* found: */
+ /* found zip-file, now try to parse it */
+ dir = zzip_dir_fdopen_ext_io(fd, &e, ext, io);
+ if (e) { errno = zzip_errno(e); io->fd.close(fd); return 0; }
+
+ /* (p - basename) is the lenghtof zzip_dir part of the filename */
+ fp = zzip_file_open(dir, filename + (p - basename) +1, o_modes);
+ if (! fp) { errno = zzip_errno(dir->errcode); }
+ else { if (! dir->realname) dir->realname = strdup (basename); }
+
+ zzip_dir_close(dir);
+ /* note: since (fp) is attached that (dir) will survive */
+ /* but (dir) is implicitly closed on next zzip_close(fp) */
+
+ return fp;
+ } /*again*/
+
+ if (o_modes & ZZIP_PREFERZIP) goto try_real;
+ errno = ENOENT; return 0;
+ }
+}
+
+#if defined ZZIP_LARGEFILE_RENAME && defined EOVERFLOW && defined PIC
+#undef zzip_open_shared_io /* zzip_open_shared_io64 */
+#undef zzip_open_ext_io /* zzip_open_ext_io64 */
+#undef zzip_opendir_ext_io /* zzip_opendir_ext_io64 */
+
+_zzip_export
+ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream,
+ zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+_zzip_export
+ZZIP_FILE * zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+_zzip_export
+ZZIP_DIR * zzip_opendir_ext_io(zzip_char_t* name, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+/* DLL compatibility layer - so that 32bit code can link with this lib too */
+
+_zzip_export
+ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream,
+ zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ if (! io) return zzip_open_shared_io64 (stream, name, o_flags, o_modes,
+ ext, io);
+ errno = EOVERFLOW; return NULL;
+}
+
+_zzip_export
+ZZIP_FILE * zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ if (! io) return zzip_open_ext_io64 (name, o_flags, o_modes, ext, io);
+ errno = EOVERFLOW; return NULL;
+}
+
+_zzip_export
+ZZIP_DIR * zzip_opendir_ext_io(zzip_char_t* name, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ if (! io) return zzip_opendir_ext_io64 (name, o_modes, ext, io);
+ errno = EOVERFLOW; return NULL;
+}
+
+#endif /* ZZIP_LARGEFILE_RENAME && EOVERFLOW && PIC */
+
+/* ------------------------------------------------------------------- */
+
+/**
+ * This function will rewind a real/zipped file.
+ *
+ * It seeks to the beginning of this file's data in the zip,
+ * or the beginning of the file for a stat'fd.
+ */
+int
+zzip_rewind(ZZIP_FILE *fp)
+{
+ ZZIP_DIR *dir;
+ int err;
+
+ if (! fp)
+ return -1;
+
+ if (! fp->dir)
+ { /* stat fd */
+ fp->io->fd.seeks(fp->fd,0,SEEK_SET);
+ return 0;
+ }
+
+ dir = fp->dir;
+ /*
+ * If this is other handle than previous, save current seek pointer
+ */
+ if (dir->currentfp != fp)
+ {
+ if (zzip_file_saveoffset(dir->currentfp) < 0)
+ { dir->errcode = ZZIP_DIR_SEEK; return -1; }
+ else
+ { dir->currentfp = fp; }
+ }
+
+ /* seek to beginning of this file */
+ if (fp->io->fd.seeks(dir->fd, fp->dataoffset, SEEK_SET) < 0)
+ return -1;
+
+ /* reset the inflate init stuff */
+ fp->restlen = fp->usize;
+ fp->offset = fp->dataoffset;
+
+ if (fp->method)
+ { /* method == 8, deflate */
+ err = inflateReset(&fp->d_stream);
+ if (err != Z_OK) { goto error; }
+
+ /* start over at next inflate with a fresh read() */
+ fp->d_stream.avail_in = 0;
+ fp->crestlen = fp->csize;
+ }
+
+ return 0;
+
+ error:
+ if (fp) zzip_file_close(fp);
+ return err;
+}
+
+/**
+ * This function will perform a => lseek(2) operation on a real/zipped file
+ *
+ * It will try to seek to the offset specified by offset, relative to whence,
+ * which is one of SEEK_SET, SEEK_CUR or SEEK_END.
+ *
+ * If the file-handle is wrapping a stat'able file then it will actually just
+ * perform a normal => lseek(2)-call. Otherwise the relative offset
+ * is calculated, negative offsets are transformed into positive ones
+ * by rewinding the file, and then data is read until the offset is
+ * reached. This can make the function terribly slow, but this is
+ * how gzio implements it, so I'm not sure there is a better way
+ * without using the internals of the algorithm.
+ */
+zzip_off_t
+zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence)
+{
+ zzip_off_t cur_pos, rel_ofs, read_size, ofs;
+ ZZIP_DIR *dir;
+
+ if (! fp)
+ return -1;
+
+ if (! fp->dir)
+ { /* stat fd */
+ return fp->io->fd.seeks(fp->fd, offset, whence);
+ }
+
+ cur_pos = zzip_tell(fp);
+
+ /* calculate relative offset */
+ switch (whence)
+ {
+ case SEEK_SET: /* from beginning */
+ rel_ofs = offset - cur_pos;
+ break;
+ case SEEK_CUR: /* from current */
+ rel_ofs = offset;
+ break;
+ case SEEK_END: /* from end */
+ rel_ofs = fp->usize + offset - cur_pos;
+ break;
+ default: /* something wrong */
+ return -1;
+ }
+
+ if (rel_ofs == 0)
+ return cur_pos; /* don't have to move */
+
+ if (rel_ofs < 0)
+ { /* convert backward into forward */
+ if (zzip_rewind(fp) == -1)
+ return -1;
+
+ read_size = cur_pos + rel_ofs;
+ cur_pos = 0;
+ }else
+ { /* amount to read is positive relative offset */
+ read_size = rel_ofs;
+ }
+
+ if (read_size < 0) /* bad offset, before beginning of file */
+ return -1;
+
+ if (read_size + cur_pos > (zzip_off_t)fp->usize) /* bad offset, past EOF */
+ return -1;
+
+ if (read_size == 0) /* nothing to read */
+ return cur_pos;
+
+ dir = fp->dir;
+ /*
+ * If this is other handle than previous, save current seek pointer
+ * and read the file position of `this' handle.
+ */
+ if (dir->currentfp != fp)
+ {
+ if (zzip_file_saveoffset(dir->currentfp) < 0
+ || dir->currentfp->io->fd.seeks(dir->fd, fp->offset, SEEK_SET) < 0)
+ { dir->errcode = ZZIP_DIR_SEEK; return -1; }
+ else
+ { dir->currentfp = fp; }
+ }
+
+ if (fp->method == 0)
+ { /* unstore, just lseek relatively */
+ ofs = fp->io->fd.tells(dir->fd);
+ ofs = fp->io->fd.seeks(dir->fd,read_size,SEEK_CUR);
+ if (ofs > 0)
+ { /* readjust from beginning of file */
+ ofs -= fp->dataoffset;
+ fp->restlen = fp->usize - ofs;
+ }
+ return ofs;
+ }else
+ { /* method == 8, inflate */
+ char *buf;
+ /*FIXME: use a static buffer! */
+ buf = (char *)malloc(ZZIP_32K);
+ if (! buf) return -1;
+
+ while (read_size > 0)
+ {
+ zzip_off_t size = ZZIP_32K;
+ if (read_size < size/*32K*/) size = read_size;
+
+ size = zzip_file_read(fp, buf, (zzip_size_t)size);
+ if (size <= 0) { free(buf); return -1; }
+
+ read_size -= size;
+ }
+
+ free (buf);
+ }
+
+ return zzip_tell(fp);
+}
+
+/**
+ * This function will => tell(2) the current position in a real/zipped file
+ *
+ * It will return the current offset within the real/zipped file,
+ * measured in uncompressed bytes for the zipped-file case.
+ *
+ * If the file-handle is wrapping a stat'able file then it will actually just
+ * perform a normal => tell(2)-call, otherwise the offset is
+ * calculated from the amount of data left and the total uncompressed
+ * size;
+ */
+zzip_off_t
+zzip_tell(ZZIP_FILE * fp)
+{
+ if (! fp)
+ return -1;
+
+ if (! fp->dir) /* stat fd */
+ return fp->io->fd.tells(fp->fd);
+
+ /* current uncompressed offset is uncompressed size - data left */
+ return (fp->usize - fp->restlen);
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.h
new file mode 100644
index 00000000000..fcff276bb23
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/file.h
@@ -0,0 +1,81 @@
+/*
+ * this is an internal header file - the structure contains two off_t
+ * atleast making it LARGEFILE_SENSITIVE on linux2 and solaris systems
+ * whereas about all functions just return a ZZIP_FILE* in zzip/zzip.h
+ *
+ * and so, this structure should be handled version-specific and
+ * subject to change - it had been kept binary-compatible for quite
+ * a while now so perhaps some program sources have errnously taken
+ * advantage of this file.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@tfi.net>
+ *
+ * Copyright (c) 1999,2000,2001,2002 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
+ */
+
+#ifndef _ZZIP_FILE_H /* zzip-file.h */
+#define _ZZIP_FILE_H 1
+
+#ifndef ZZIP_32K
+#ifdef __GNUC__
+/* include zzip/lib.h beforehand in order to suppress the following warning */
+#warning zzip/file.h is an internal header, do not use it freely
+#endif
+#endif
+
+#include <zzip/lib.h>
+#include <zlib.h>
+
+#ifdef ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#else
+#include <stdio.h>
+# ifdef ZZIP_HAVE_SYS_TYPES_H
+# include <sys/types.h>
+# endif
+#endif
+
+#ifdef ZZIP_HAVE_SYS_PARAM_H
+#include <sys/param.h> /* PATH_MAX */
+#endif
+
+#ifndef PATH_MAX
+# ifdef MAX_PATH /* windows */
+# define PATH_MAX MAX_PATH
+# else
+# define PATH_MAX 512
+# endif
+#endif
+/*
+ * ZZIP_FILE structure... currently no need to unionize, since structure needed
+ * for inflate is superset of structure needed for unstore.
+ *
+ * Don't make this public. Instead, create methods for needed operations.
+ */
+
+struct zzip_file
+{
+ struct zzip_dir* dir;
+ int fd;
+ int method;
+ zzip_size_t restlen;
+ zzip_size_t crestlen;
+ zzip_size_t usize;
+ zzip_size_t csize;
+ /* added dataoffset member - data offset from start of zipfile*/
+ zzip_off_t dataoffset;
+ char* buf32k;
+ zzip_off_t offset; /* offset from the start of zipfile... */
+ z_stream d_stream;
+ zzip_plugin_io_t io;
+};
+
+#endif /* _ZZIP_FILE_H */
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/format.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/format.h
new file mode 100644
index 00000000000..fba4000aa76
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/format.h
@@ -0,0 +1,233 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 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
+ *
+ * The information was taken from appnote-981119-iz.zip
+ * at http://www.freesoftware.com/pub/infozip/doc/
+ * which in turn is based on PKWARE's appnote.txt
+ * (newer link: ftp://ftp.info-zip.org/pub/infozip/doc/)
+ */
+#ifndef _ZZIP_FORMAT_H /* zzipformat.h */
+#define _ZZIP_FORMAT_H
+
+#include <zzip/types.h>
+/* we have ICO C 9X types defined */
+
+/*
+ * Overall zipfile format
+ * [local file header + file data stream + checksum descriptor] ...
+ * ... [disk central directory] [disk trailer record]
+ */
+
+# ifdef _MSC_VER
+# pragma pack(push, 1)
+# endif
+
+struct zzip_version
+{
+ zzip_byte_t version[1];
+ zzip_byte_t ostype[1];
+} __zzip_attribute__((packed));
+
+struct zzip_dostime
+{
+ zzip_byte_t time[2];
+ zzip_byte_t date[2];
+} __zzip_attribute__((packed));
+
+#ifdef ZZIP_NEED_PACKED
+/* if your compiler does interesting things about struct packing... */
+typedef zzip_byte_t zzip_version_t[2];
+typedef zzip_byte_t zzip_dostime_t[4];
+#else
+typedef struct zzip_version zzip_version_t;
+typedef struct zzip_dostime zzip_dostime_t;
+#endif
+
+#define ZZIP_CHECKMAGIC(__p,__A,__B,__C,__D) \
+ ( (((zzip_byte_t*)(__p))[0]==(__A)) && \
+ (((zzip_byte_t*)(__p))[1]==(__B)) && \
+ (((zzip_byte_t*)(__p))[2]==(__C)) && \
+ (((zzip_byte_t*)(__p))[3]==(__D)) )
+
+/* A. Local file header */
+struct zzip_file_header
+{
+# define ZZIP_FILE_HEADER_MAGIC 0x04034b50
+# define ZZIP_FILE_HEADER_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\3','\4')
+ zzip_byte_t z_magic[4]; /* local file header signature (0x04034b50) */
+ zzip_version_t z_extract; /* version needed to extract */
+ zzip_byte_t z_flags[2]; /* general purpose bit flag */
+ zzip_byte_t z_compr[2]; /* compression method */
+ zzip_dostime_t z_dostime; /* last mod file time (dos format) */
+ zzip_byte_t z_crc32[4]; /* crc-32 */
+ zzip_byte_t z_csize[4]; /* compressed size */
+ zzip_byte_t z_usize[4]; /* uncompressed size */
+ zzip_byte_t z_namlen[2]; /* filename length (null if stdin) */
+ zzip_byte_t z_extras[2]; /* extra field length */
+ /* followed by filename (of variable size) */
+ /* followed by extra field (of variable size) */
+} __zzip_attribute__((packed));
+#define zzip_file_header_headerlength (4+2+2+2+4+4+4+4+2+2)
+
+/* B. data descriptor
+ * the data descriptor exists only if bit 3 of z_flags is set. It is byte aligned
+ * and immediately follows the last byte of compressed data. It is only used if
+ * the output media of the compressor was not seekable, eg. standard output.
+ */
+struct zzip_file_trailer
+{
+# define ZZIP_FILE_TRAILER_MAGIC 0x08074B50
+# define ZZIP_FILE_TRAILER_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\7','\8')
+ zzip_byte_t z_magic[4]; /* data descriptor signature (0x08074b50) */
+ zzip_byte_t z_crc32[4]; /* crc-32 */
+ zzip_byte_t z_csize[4]; /* compressed size */
+ zzip_byte_t z_usize[4]; /* uncompressed size */
+} __zzip_attribute__((packed));
+#define zzip_file_trailer_headerlength (4+4+4+4)
+
+/* C. central directory structure:
+ [file header] . . . end of central dir record
+*/
+
+/* directory file header
+ * - a single entry including filename, extras and comment may not exceed 64k.
+ */
+
+struct zzip_disk_entry
+{
+# define ZZIP_DISK_ENTRY_MAGIC 0x02014b50
+# define ZZIP_DISK_ENTRY_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\1','\2')
+ zzip_byte_t z_magic[4]; /* central file header signature (0x02014b50) */
+ zzip_version_t z_encoder; /* version made by */
+ zzip_version_t z_extract; /* version need to extract */
+ zzip_byte_t z_flags[2]; /* general purpose bit flag */
+ zzip_byte_t z_compr[2]; /* compression method */
+ zzip_dostime_t z_dostime; /* last mod file time&date (dos format) */
+ zzip_byte_t z_crc32[4]; /* crc-32 */
+ zzip_byte_t z_csize[4]; /* compressed size */
+ zzip_byte_t z_usize[4]; /* uncompressed size */
+ zzip_byte_t z_namlen[2]; /* filename length (null if stdin) */
+ zzip_byte_t z_extras[2]; /* extra field length */
+ zzip_byte_t z_comment[2]; /* file comment length */
+ zzip_byte_t z_diskstart[2]; /* disk number of start (if spanning zip over multiple disks) */
+ zzip_byte_t z_filetype[2]; /* internal file attributes, bit0 = ascii */
+ zzip_byte_t z_filemode[4]; /* extrnal file attributes, eg. msdos attrib byte */
+ zzip_byte_t z_offset[4]; /* relative offset of local file header, seekval if singledisk */
+ /* followed by filename (of variable size) */
+ /* followed by extra field (of variable size) */
+ /* followed by file comment (of variable size) */
+} __zzip_attribute__((packed));
+#define zzip_disk_entry_headerlength (4+2+2+2+2+4+4+4+4+2+2+2+2+2+4+4)
+
+
+struct zzip_root_dirent
+{ /* the old name of the structure above */
+# define ZZIP_ROOT_DIRENT_MAGIC 0x02014b50
+# define ZZIP_ROOT_DIRENT_CHECKMAGIC(__p) ZZIP_DISK_ENTRY_CHECKMAGIC(__p)
+ zzip_byte_t z_magic[4];
+ zzip_version_t z_encoder;
+ zzip_version_t z_extract;
+ zzip_byte_t z_flags[2];
+ zzip_byte_t z_compr[2];
+ zzip_dostime_t z_dostime;
+ zzip_byte_t z_crc32[4];
+ zzip_byte_t z_csize[4];
+ zzip_byte_t z_usize[4];
+ zzip_byte_t z_namlen[2];
+ zzip_byte_t z_extras[2];
+ zzip_byte_t z_comment[2];
+ zzip_byte_t z_diskstart[2];
+ zzip_byte_t z_filetype[2];
+ zzip_byte_t z_filemode[4];
+ zzip_byte_t z_off[4];
+} __zzip_attribute__((packed));
+
+
+/* end of central dir record */
+struct zzip_disk_trailer
+{
+# define ZZIP_DISK_TRAILER_MAGIC 0x06054b50
+# define ZZIP_DISK_TRAILER_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\5','\6')
+ zzip_byte_t z_magic[4]; /* end of central dir signature (0x06054b50) */
+ zzip_byte_t z_disk[2]; /* number of this disk */
+ zzip_byte_t z_finaldisk[2]; /* number of the disk with the start of the central dir */
+ zzip_byte_t z_entries[2]; /* total number of entries in the central dir on this disk */
+ zzip_byte_t z_finalentries[2]; /* total number of entries in the central dir */
+ zzip_byte_t z_rootsize[4]; /* size of the central directory */
+ zzip_byte_t z_rootseek[4]; /* offset of start of central directory with respect to *
+ * the starting disk number */
+ zzip_byte_t z_comment[2]; /* zipfile comment length */
+ /* followed by zipfile comment (of variable size) */
+} __zzip_attribute__((packed));
+#define zzip_disk_trailer_headerlength (4+2+2+2+2+4+4+2)
+
+/* extra field should be type + size + data + type + size + data ... */
+struct zzip_extra_block
+{ /* fetch.h macros do not need this struct */
+ zzip_byte_t z_datatype[2]; /* as input type - a mere <char*> is okay */
+ zzip_byte_t z_datasize[2]; /* being returned by xx_to_extras usually */
+} __zzip_attribute__((packed));
+#define zzip_extra_block_headerlength (2+2)
+
+/* Zip64 end of central dir record */
+struct zzip_disk64_trailer
+{
+# define ZZIP_DISK64_TRAILER_MAGIC 0x06064b50
+# define ZZIP_DISK64_TRAILER_CHECKMAGIC(__p) ZZIP_CHECKMAGIC(__p,'P','K','\6','\6')
+ zzip_byte_t z_magic[4]; /* end of central dir signature (0x06054b50) */
+ zzip_byte_t z_size[8]; /* size of this central directory record */
+ zzip_version_t z_encoder; /* version made by */
+ zzip_version_t z_extract; /* version need to extract */
+ zzip_byte_t z_disk[4]; /* number of this disk */
+ zzip_byte_t z_finaldisk[4]; /* number of the disk with the start of the central dir */
+ zzip_byte_t z_entries[8]; /* total number of entries in the central dir on this disk */
+ zzip_byte_t z_finalentries[8]; /* total number of entries in the central dir */
+ zzip_byte_t z_rootsize[8]; /* size of the central directory */
+ zzip_byte_t z_rootseek[8]; /* offset of start of central directory with respect to *
+ * the starting disk number */
+ /* followed by zip64 extensible data sector (of variable size) */
+} __zzip_attribute__((packed));
+#define zzip_disk64_trailer_headerlength (4+8+2+2+4+4+8+8+8+8)
+
+/* z_flags */
+#define ZZIP_IS_ENCRYPTED(p) ((*(zzip_byte_t*)p)&1)
+#define ZZIP_IS_COMPRLEVEL(p) (((*(zzip_byte_t*)p)>>1)&3)
+#define ZZIP_IS_STREAMED(p) (((*(zzip_byte_t*)p)>>3)&1)
+#define ZZIP_IS_PATCHED(p) (((*(zzip_byte_t*)p)>>5)&1)
+
+/* z_compr */
+#define ZZIP_IS_STORED 0
+#define ZZIP_IS_SHRUNK 1
+#define ZZIP_IS_REDUCEDx1 2
+#define ZZIP_IS_REDUCEDx2 3
+#define ZZIP_IS_REDUCEDx3 4
+#define ZZIP_IS_REDUCEDx4 5
+#define ZZIP_IS_IMPLODED 6
+#define ZZIP_IS_TOKENIZED 7
+#define ZZIP_IS_DEFLATED 8
+#define ZZIP_IS_DEFLATED_BETTER 9
+#define ZZIP_IS_IMPLODED_BETTER 10
+
+/* deflated comprlevel */
+#define ZZIP_DEFLATED_STD_COMPR 0
+#define ZZIP_DEFLATED_MAX_COMPR 1
+#define ZZIP_DEFLATED_LOW_COMPR 2
+#define ZZIP_DEFLATED_MIN_COMPR 3
+
+# ifdef _MSC_VER
+# pragma pack(pop)
+# endif
+
+#endif /* _ZZIPFORMAT_H */
+
+
+
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.c
new file mode 100644
index 00000000000..2207f5dc981
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.c
@@ -0,0 +1,580 @@
+/*
+ * NOTE: this is part of libzzipfseeko (i.e. it is not libzzip).
+ *
+ * These routines are fully independent from the traditional zzip
+ * implementation. They assume a readonly seekable stdio handle
+ * representing a complete zip file. The functions show how to
+ * parse the structure, find files and return a decoded bytestream.
+ *
+ * These routines are a bit simple and really here for documenting
+ * the way to access a zip file. The complexity of zip access comes
+ * from staggered reading of bytes and reposition of a filepointer in
+ * a big archive with lots of files and long compressed datastreams.
+ * Plus varaints of drop-in stdio replacements, obfuscation routines,
+ * auto fileextensions, drop-in dirent replacements, and so on...
+ *
+ * btw, we can _not_ use fgetpos/fsetpos since an fpos_t has no asserted
+ * relation to a linear seek value as specified in zip info headers. In
+ * general it is not a problem if your system has no fseeko/ftello pair
+ * since we can fallback to fseek/ftell which limits the zip disk size
+ * to 2MiBs but the zip-storable seek values are 32bit limited anyway.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2003,2004 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
+ */
+
+#define _LARGEFILE_SOURCE 1
+#define _ZZIP_ENTRY_STRUCT 1
+
+#include <zzip/types.h>
+
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#if defined ZZIP_HAVE_STRING_H
+#include <string.h>
+#elif defined ZZIP_HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include <zlib.h>
+#include <zzip/format.h>
+#include <zzip/fseeko.h>
+#include <zzip/fetch.h>
+#include <zzip/__mmap.h>
+#include <zzip/__fnmatch.h>
+
+#if __STDC_VERSION__+0 > 199900L
+#define ___
+#define ____
+#else
+#define ___ {
+#define ____ }
+#endif
+
+#ifndef ZZIP_HAVE_FSEEKO
+#define fseeko fseek
+#define ftello ftello
+#endif
+
+/* note that the struct zzip_entry inherits the zzip_disk_entry values
+ * and usually carries a copy of its values (in disk format!). To make the
+ * following code more readable, we use a shorthand notation for the
+ * upcast needed in C (not needed in C++) as "disk_(entry)".
+ */
+#ifdef __zzip_entry_extends_zzip_disk_entry
+#define disk_(_entry_) _entry_
+#else
+#define disk_(_entry_) (& (_entry_)->head)
+#endif
+
+/* we try to round all seeks to the pagesize - since we do not use
+ * the sys/mmap interface we have to guess a good value here: */
+#define PAGESIZE 8192
+
+/* ====================================================================== */
+/* helper functions */
+
+/** => zzip_entry_data_offset
+ * This functions read the correspoding struct zzip_file_header from
+ * the zip disk of the given "entry". The returned off_t points to the
+ * end of the file_header where the current fseek pointer has stopped.
+ * This is used to immediatly parse out any filename/extras block following
+ * the file_header. The return value is null on error.
+ */
+static zzip_off_t
+zzip_entry_fread_file_header (ZZIP_ENTRY* entry,
+ struct zzip_file_header* file_header)
+{
+ if (! entry || ! file_header) return 0;
+ ___ zzip_off_t offset = zzip_disk_entry_fileoffset (disk_(entry));
+ if (0 > offset || offset >= entry->disksize) return 0;
+
+ fseeko (entry->diskfile, offset, SEEK_SET);
+ return (fread (file_header, sizeof(*file_header), 1, entry->diskfile)
+ ? offset+sizeof(*file_header) : 0 ); ____;
+}
+
+/** helper functions for (fseeko) zip access api
+ *
+ * This functions returns the seekval offset of the data portion of the
+ * file referenced by the given zzip_entry. It requires an intermediate
+ * check of the file_header structure (i.e. it reads it from disk). After
+ * this call, the contained diskfile readposition is already set to the
+ * data_offset returned here. On error -1 is returned.
+ */
+zzip_off_t
+zzip_entry_data_offset(ZZIP_ENTRY* entry)
+{
+ struct zzip_file_header file_header;
+ if (! entry) return -1;
+ ___ zzip_off_t offset =
+ zzip_entry_fread_file_header (entry, & file_header);
+ if (! offset) return -1;
+ offset += zzip_file_header_sizeof_tails (& file_header);
+ fseeko (entry->diskfile, offset, SEEK_SET);
+ return offset; ____;
+}
+
+/** => zzip_entry_data_offset
+ * This function is a big helper despite its little name: in a zip file the
+ * encoded filenames are usually NOT zero-terminated but for common usage
+ * with libc we need it that way. Secondly, the filename SHOULD be present
+ * in the zip central directory but if not then we fallback to the filename
+ * given in the file_header of each compressed data portion.
+ */
+zzip__new__ char*
+zzip_entry_strdup_name(ZZIP_ENTRY* entry)
+{
+ if (! entry) return 0;
+
+ ___ zzip_size_t len;
+ if ((len = zzip_disk_entry_namlen (disk_(entry)))) {
+ char* name = malloc (len+1);
+ if (! name) return 0;
+ memcpy (name, entry->tail, len);
+ name[len] = '\0';
+ return name;
+ }
+ ___ auto struct zzip_file_header header;
+ if (zzip_entry_fread_file_header (entry, &header)
+ && ( len = zzip_file_header_namlen(&header) )) {
+ char* name = malloc (len+1);
+ if (! name) return 0;
+ fread (name, 1, len, entry->diskfile);
+ name[len] = '\0';
+ return name;
+ }
+ return 0;
+ ____;____;
+}
+
+static int
+prescan_entry(ZZIP_ENTRY* entry)
+{
+ assert (entry);
+ ___ zzip_off_t tailsize = zzip_disk_entry_sizeof_tails (disk_(entry));
+ if (tailsize+1 > entry->tailalloc) {
+ char* newtail = realloc (entry->tail, tailsize+1);
+ if (! newtail) return ENOMEM;
+ entry->tail = newtail;
+ entry->tailalloc = tailsize+1;
+ }
+ fread (entry->tail, 1, tailsize, entry->diskfile);
+ /* name + comment + extras */
+ return 0; ____;
+}
+
+static void
+prescan_clear(ZZIP_ENTRY* entry)
+{
+ assert (entry);
+ if (entry->tail) free (entry->tail);
+ entry->tail = 0; entry->tailalloc = 0;
+}
+
+/* ====================================================================== */
+
+/** => zzip_entry_findfile
+ *
+ * This function is the first call of all the zip access functions here.
+ * It contains the code to find the first entry of the zip central directory.
+ * Here we require the stdio handle to represent a real zip file where the
+ * disk_trailer is _last_ in the file area, so that its position would be at
+ * a fixed offset from the end of the file area if not for the comment field
+ * allowed to be of variable length (which needs us to do a little search
+ * for the disk_tailer). However, in this simple implementation we disregard
+ * any disk_trailer info telling about multidisk archives, so we just return
+ * a pointer to the first entry in the zip central directory of that file.
+ *
+ * For an actual means, we are going to search backwards from the end
+ * of the mmaped block looking for the PK-magic signature of a
+ * disk_trailer. If we see one then we check the rootseek value to
+ * find the first disk_entry of the root central directory. If we find
+ * the correct PK-magic signature of a disk_entry over there then we
+ * assume we are done and we are going to return a pointer to that label.
+ *
+ * The return value is a pointer to the first zzip_disk_entry being checked
+ * to be within the bounds of the file area specified by the arguments. If
+ * no disk_trailer was found then null is returned, and likewise we only
+ * accept a disk_trailer with a seekvalue that points to a disk_entry and
+ * both parts have valid PK-magic parts. Beyond some sanity check we try to
+ * catch a common brokeness with zip archives that still allows us to find
+ * the start of the zip central directory.
+ */
+zzip__new__ ZZIP_ENTRY*
+zzip_entry_findfirst(FILE* disk)
+{
+ if (! disk) return 0;
+ fseeko (disk, 0, SEEK_END);
+ ___ zzip_off_t disksize = ftello (disk);
+ if (disksize < (zzip_off_t) sizeof(struct zzip_disk_trailer)) return 0;
+ /* we read out chunks of 8 KiB in the hope to match disk granularity */
+ ___ zzip_off_t pagesize = PAGESIZE; /* getpagesize() */
+ ___ ZZIP_ENTRY* entry = malloc (sizeof(*entry)); if (! entry) return 0;
+ ___ unsigned char* buffer = malloc (pagesize); if (! buffer) goto nomem;
+
+ assert (pagesize/2 > (zzip_off_t) sizeof (struct zzip_disk_trailer));
+ /* at each step, we will fread a pagesize block which overlaps with the
+ * previous read by means of pagesize/2 step at the end of the while(1) */
+ ___ zzip_off_t mapoffs = disksize &~ (pagesize-1);
+ ___ zzip_off_t mapsize = disksize - mapoffs;
+ if (mapoffs && mapsize < pagesize/2) {
+ mapoffs -= pagesize/2; mapsize += pagesize/2; }
+ while(1) {
+ fseeko (disk, mapoffs, SEEK_SET);
+ fread (buffer, 1, mapsize, disk);
+ ___ unsigned char* p =
+ buffer + mapsize - sizeof(struct zzip_disk_trailer);
+ for (; p >= buffer ; p--)
+ {
+ zzip_off_t root; /* (struct zzip_disk_entry*) */
+ if (zzip_disk_trailer_check_magic(p)) {
+ root = zzip_disk_trailer_rootseek (
+ (struct zzip_disk_trailer*)p);
+ if (root > disksize - (long)sizeof(struct zzip_disk_trailer)) {
+ /* first disk_entry is after the disk_trailer? can't be! */
+ zzip_off_t rootsize = zzip_disk_trailer_rootsize (
+ (struct zzip_disk_trailer*)p);
+ if (rootsize > mapoffs) continue;
+ /* a common brokeness that can be fixed: we just assume the
+ * central directory was written directly before : */
+ root = mapoffs - rootsize;
+ }
+ } else if (zzip_disk64_trailer_check_magic(p)) {
+ if (sizeof(zzip_off_t) < 8) return 0;
+ root = zzip_disk64_trailer_rootseek (
+ (struct zzip_disk64_trailer*)p);
+ } else continue;
+
+ assert (0 <= root && root < mapsize);
+ fseeko (disk, root, SEEK_SET);
+ fread (disk_(entry), 1, sizeof(*disk_(entry)), disk);
+ if (zzip_disk_entry_check_magic(entry)) {
+ free (buffer);
+ entry->headseek = root;
+ entry->diskfile = disk;
+ entry->disksize = disksize;
+ if (prescan_entry(entry)) goto nomem;
+ return entry;
+ }
+ } ____;
+ if (! mapoffs) break; assert (mapsize >= pagesize/2);
+ mapoffs -= pagesize/2; /* mapsize += pagesize/2; */
+ mapsize = pagesize; /* if (mapsize > pagesize) ... */
+ if (disksize - mapoffs > 64*1024) break;
+ }
+ free (buffer);
+ nomem:
+ free (entry); ____;____;____;____;____;____;
+ return 0;
+}
+
+/** => zzip_entry_findfile
+ *
+ * This function takes an existing "entry" in the central root directory
+ * (e.g. from zzip_entry_findfirst) and moves it to point to the next entry.
+ * On error it returns 0, otherwise the old entry. If no further match is
+ * found then null is returned and the entry already free()d. If you want
+ * to stop searching for matches before that case then please call
+ * => zzip_entry_free on the cursor struct ZZIP_ENTRY.
+ */
+zzip__new__ ZZIP_ENTRY*
+zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry)
+{
+ if (! entry) return entry;
+ if (! zzip_disk_entry_check_magic (entry)) goto err;
+ ___ zzip_off_t seek =
+ entry->headseek + zzip_disk_entry_sizeto_end (disk_(entry));
+ if (seek + (zzip_off_t) sizeof(*disk_(entry)) > entry->disksize) goto err;
+
+ fseeko (entry->diskfile, seek, SEEK_SET);
+ fread (disk_(entry), 1, sizeof(*disk_(entry)), entry->diskfile);
+ entry->headseek = seek;
+ if (! zzip_disk_entry_check_magic (entry)) goto err;
+ if (prescan_entry(entry)) goto err;
+ return entry;
+ err:
+ zzip_entry_free (entry);
+ return 0; ____;
+}
+
+/** => zzip_entry_findfile
+ * this function releases the malloc()ed areas needed for zzip_entry, the
+ * pointer is invalid afterwards. This function has #define synonyms of
+ * zzip_entry_findlast(), zzip_entry_findlastfile(), zzip_entry_findlastmatch()
+ */
+int
+zzip_entry_free(ZZIP_ENTRY* entry)
+{
+ if (! entry) return 0;
+ prescan_clear (entry);
+ free (entry);
+ return 1;
+}
+
+/** search for files in the (fseeko) zip central directory
+ *
+ * This function is given a filename as an additional argument, to find the
+ * disk_entry matching a given filename. The compare-function is usually
+ * strcmp or strcasecmp or perhaps strcoll, if null then strcmp is used.
+ * - use null as argument for "old"-entry when searching the first
+ * matching entry, otherwise the last returned value if you look for other
+ * entries with a special "compare" function (if null then a doubled search
+ * is rather useless with this variant of _findfile). If no further entry is
+ * found then null is returned and any "old"-entry gets already free()d.
+ */
+zzip__new__ ZZIP_ENTRY*
+zzip_entry_findfile(FILE* disk, char* filename,
+ ZZIP_ENTRY* _zzip_restrict entry,
+ zzip_strcmp_fn_t compare)
+{
+ if (! filename || ! disk) return 0;
+ entry = ( ! entry ) ? zzip_entry_findfirst (disk)
+ : zzip_entry_findnext (entry);
+ if (! compare) compare = (zzip_strcmp_fn_t)(strcmp);
+
+ for (; entry ; entry = zzip_entry_findnext (entry))
+ { /* filenames within zip files are often not null-terminated! */
+ char* realname = zzip_entry_strdup_name (entry);
+ if (! realname) continue;
+ if (! compare (filename, realname)) {
+ free (realname); return entry;
+ } else {
+ free (realname); continue;
+ }
+ }
+ return 0;
+}
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#define _zzip_fnmatch fnmatch
+# ifdef FNM_CASEFOLD
+# define _zzip_fnmatch_CASEFOLD FNM_CASEFOLD
+# else
+# define _zzip_fnmatch_CASEFOLD 0
+# endif
+#else
+# define _zzip_fnmatch_CASEFOLD 0
+/* if your system does not have fnmatch, we fall back to strcmp: */
+static int _zzip_fnmatch(char* pattern, char* string, int flags)
+{
+ puts ("<zzip:strcmp>");
+ return strcmp (pattern, string);
+}
+#endif
+
+/** => zzip_entry_findfile
+ *
+ * This function uses a compare-function with an additional argument
+ * and it is called just like fnmatch(3) from POSIX.2 AD:1993), i.e.
+ * the argument filespec first and the ziplocal filename second with
+ * the integer-flags put in as third to the indirect call. If the
+ * platform has fnmatch available then null-compare will use that one
+ * and otherwise we fall back to mere strcmp, so if you need fnmatch
+ * searching then please provide an implementation somewhere else.
+ * - use null as argument for "after"-entry when searching the first
+ * matching entry, or the last disk_entry return-value to find the
+ * next entry matching the given filespec. If no further entry is
+ * found then null is returned and any "old"-entry gets already free()d.
+ */
+zzip__new__ ZZIP_ENTRY*
+zzip_entry_findmatch(FILE* disk, char* filespec,
+ ZZIP_ENTRY* _zzip_restrict entry,
+ zzip_fnmatch_fn_t compare, int flags)
+{
+ if (! filespec || ! disk) return 0;
+ entry = ( ! entry ) ? zzip_entry_findfirst (disk)
+ : zzip_entry_findnext (entry);
+ if (! compare) compare = (zzip_fnmatch_fn_t) _zzip_fnmatch;
+
+ for (; entry ; entry = zzip_entry_findnext (entry))
+ { /* filenames within zip files are often not null-terminated! */
+ char* realname = zzip_entry_strdup_name (entry);
+ if (! realname) continue;
+ if (! compare (filespec, realname, flags)) {
+ free (realname); return entry;
+ } else {
+ free (realname); continue;
+ }
+ }
+ return 0;
+}
+
+/* ====================================================================== */
+
+/**
+ * typedef struct zzip_disk_file ZZIP_ENTRY_FILE;
+ */
+struct zzip_entry_file /* : zzip_file_header */
+{
+ struct zzip_file_header header; /* fopen detected header */
+ ZZIP_ENTRY* entry; /* fopen entry */
+ zzip_off_t data; /* for stored blocks */
+ zzip_size_t avail; /* memorized for checks on EOF */
+ zzip_size_t compressed; /* compressed flag and datasize */
+ zzip_size_t dataoff; /* offset from data start */
+ z_stream zlib; /* for inflated blocks */
+ unsigned char buffer[PAGESIZE]; /* work buffer for inflate algorithm */
+};
+
+/** open a file within a zip disk for reading
+ *
+ * This function does take an "entry" argument and copies it (or just takes
+ * it over as owner) to a new ZZIP_ENTRY_FILE handle structure. That
+ * structure contains also a zlib buffer for decoding. This function does
+ * seek to the file_header of the given "entry" and validates it for the
+ * data buffer following it. We do also prefetch some data from the data
+ * buffer thereby trying to match the disk pagesize for faster access later.
+ * The => zzip_entry_fread will then read in chunks of pagesizes which is
+ * the size of the internal readahead buffer. If an error occurs then null
+ * is returned.
+ */
+zzip__new__ ZZIP_ENTRY_FILE*
+zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover)
+{
+ if (! entry) return 0;
+ if (! takeover) {
+ ZZIP_ENTRY* found = malloc (sizeof(*entry));
+ if (! found) return 0;
+ memcpy (found, entry, sizeof(*entry)); /* prescan_copy */
+ found->tail = malloc (found->tailalloc);
+ if (! found->tail) { free (found); return 0; }
+ memcpy (found->tail, entry->tail, entry->tailalloc);
+ entry = found;
+ }
+ ___ ZZIP_ENTRY_FILE* file = malloc(sizeof(*file));
+ if (! file) goto fail1;
+ file->entry = entry;
+ if (! zzip_entry_fread_file_header (entry, &file->header))
+ goto fail2;
+ file->avail = zzip_file_header_usize (&file->header);
+ file->data = zzip_entry_data_offset (entry);
+ file->dataoff = 0;
+
+ if (! file->avail || zzip_file_header_data_stored (&file->header))
+ { file->compressed = 0; return file; }
+
+ file->compressed = zzip_file_header_csize (&file->header);
+ file->zlib.opaque = 0;
+ file->zlib.zalloc = Z_NULL;
+ file->zlib.zfree = Z_NULL;
+
+ ___ zzip_off_t seek = file->data;
+ seek += sizeof(file->buffer); seek -= seek & (sizeof(file->buffer)-1);
+ assert (file->data < seek); /* pre-read to next PAGESIZE boundary... */
+ fseeko (file->entry->diskfile, file->data + file->dataoff, SEEK_SET);
+ file->zlib.next_in = file->buffer;
+ file->zlib.avail_in = fread (file->buffer, 1, seek - file->data,
+ file->entry->diskfile);
+ file->dataoff += file->zlib.avail_in; ____;
+
+ if (! zzip_file_header_data_deflated (&file->header)
+ || inflateInit2 (& file->zlib, -MAX_WBITS) != Z_OK) goto fail2;
+
+ return file;
+ fail2:
+ free (file);
+ fail1:
+ zzip_entry_free (entry);
+ return 0; ____;
+}
+
+/** => zzip_entry_fopen
+ *
+ * This function opens a file found by name, so it does a search into
+ * the zip central directory with => zzip_entry_findfile and whatever
+ * is found first is given to => zzip_entry_fopen
+ */
+zzip__new__ ZZIP_ENTRY_FILE*
+zzip_entry_ffile (FILE* disk, char* filename)
+{
+ ZZIP_ENTRY* entry = zzip_entry_findfile (disk, filename, 0, 0);
+ if (! entry) return 0;
+ return zzip_entry_fopen (entry, 1);
+}
+
+
+/** => zzip_entry_fopen
+ *
+ * This function reads more bytes into the output buffer specified as
+ * arguments. The return value is null on eof or error, the stdio-like
+ * interface can not distinguish between these so you need to check
+ * with => zzip_entry_feof for the difference.
+ */
+zzip_size_t
+zzip_entry_fread (void* ptr, zzip_size_t sized, zzip_size_t nmemb,
+ ZZIP_ENTRY_FILE* file)
+{
+ if (! file) return 0;
+ ___ zzip_size_t size = sized*nmemb;
+ if (! file->compressed) {
+ if (size > file->avail) size = file->avail;
+ fread (ptr, 1, size, file->entry->diskfile);
+ file->dataoff += size;
+ file->avail -= size;
+ return size;
+ }
+
+ file->zlib.avail_out = size;
+ file->zlib.next_out = ptr;
+ ___ zzip_size_t total_old = file->zlib.total_out;
+ while (1) {
+ if (! file->zlib.avail_in) {
+ size = file->compressed - file->dataoff;
+ if (size > sizeof(file->buffer)) size = sizeof(file->buffer);
+ /* fseek (file->data + file->dataoff, file->entry->diskfile); */
+ file->zlib.avail_in = fread (file->buffer, 1, size,
+ file->entry->diskfile);
+ file->zlib.next_in = file->buffer;
+ file->dataoff += file->zlib.avail_in;
+ }
+ if (! file->zlib.avail_in) return 0;
+
+ ___ int err = inflate (& file->zlib, Z_NO_FLUSH);
+ if (err == Z_STREAM_END)
+ file->avail = 0;
+ else if (err == Z_OK)
+ file->avail -= file->zlib.total_out - total_old;
+ else
+ return 0;
+ ____;
+ if (file->zlib.avail_out && ! file->zlib.avail_in) continue;
+ return file->zlib.total_out - total_old;
+ }____;____;
+}
+
+/** => zzip_entry_fopen
+ * This function releases any zlib decoder info needed for decompression
+ * and dumps the ZZIP_ENTRY_FILE struct then.
+ */
+int
+zzip_entry_fclose (ZZIP_ENTRY_FILE* file)
+{
+ if (! file) return 0;
+ if (file->compressed)
+ inflateEnd (& file->zlib);
+ zzip_entry_free (file->entry);
+ free (file);
+ return 0;
+}
+
+/** => zzip_entry_fopen
+ *
+ * This function allows to distinguish an error from an eof condition.
+ * Actually, if we found an error but we did already reach eof then we
+ * just keep on saying that it was an eof, so the app can just continue.
+ */
+int
+zzip_entry_feof (ZZIP_ENTRY_FILE* file)
+{
+ return ! file || ! file->avail;
+}
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.h
new file mode 100644
index 00000000000..cbe40f7db4a
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/fseeko.h
@@ -0,0 +1,116 @@
+#ifndef _ZZIP_FSEEKO_H_
+#define _ZZIP_FSEEKO_H_
+/*
+ * NOTE: this is part of libzzipfseeko (i.e. it is not libzzip).
+ *
+ * simplified zip disk access using fseeko on a stdio FILE handle
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2003,2004 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 <zzip/types.h>
+#include <stdio.h>
+
+typedef struct zzip_entry ZZIP_ENTRY;
+typedef struct zzip_entry_file ZZIP_ENTRY_FILE;
+
+typedef int (*zzip_strcmp_fn_t)(char*, char*);
+typedef int (*zzip_fnmatch_fn_t)(char*, char*, int);
+
+#ifndef zzip_entry_extern
+#define zzip_entry_extern extern
+#endif
+
+zzip_entry_extern zzip_off_t
+zzip_entry_data_offset(ZZIP_ENTRY* entry);
+
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY*
+zzip_entry_findfirst(FILE* file);
+
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY*
+zzip_entry_findnext(ZZIP_ENTRY* _zzip_restrict entry);
+
+#define zzip_entry_findlast zzip_entry_free
+#define zzip_entry_findlastfile zzip_entry_free
+#define zzip_entry_findlastmatch zzip_entry_free
+
+zzip_entry_extern int
+zzip_entry_free(ZZIP_ENTRY* entry);
+
+zzip__new__
+zzip_entry_extern char*
+zzip_entry_strdup_name(ZZIP_ENTRY* entry);
+zzip_entry_extern char*
+zzip_entry_to_data(ZZIP_ENTRY* entry);
+
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY*
+zzip_entry_findfile(FILE* disk, char* filename,
+ ZZIP_ENTRY* _zzip_restrict old,
+ zzip_strcmp_fn_t compare);
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY*
+zzip_entry_findmatch(FILE* disk, char* filespec,
+ ZZIP_ENTRY* _zzip_restrict old,
+ zzip_fnmatch_fn_t compare, int flags);
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY_FILE*
+zzip_entry_fopen (ZZIP_ENTRY* entry, int takeover);
+
+zzip__new__
+zzip_entry_extern ZZIP_ENTRY_FILE*
+zzip_entry_ffile (FILE* disk, char* filename);
+
+zzip_entry_extern _zzip_size_t
+zzip_entry_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
+ ZZIP_ENTRY_FILE* file);
+zzip_entry_extern int
+zzip_entry_fclose (ZZIP_ENTRY_FILE* file);
+int
+zzip_entry_feof (ZZIP_ENTRY_FILE* file);
+
+# ifdef _ZZIP_ENTRY_STRUCT
+# ifdef __cplusplus
+# define __zzip_entry_extends_zzip_disk_entry
+struct zzip_entry : public struct zzip_disk_entry
+{
+ char* _zzip_restrict tail;
+ zzip_off_t tailalloc; /* the allocated size of tail */
+ FILE* diskfile; /* a file reference */
+ zzip_off_t disksize; /* the size of the file */
+ zzip_off_t headseek; /* the offset within the file */
+ zzip_off_t zz_usize;
+ zzip_off_t zz_csize; /* items scanned from header */
+ zzip_off_t zz_offset; /* or zip64 extension block */
+ int zz_diskstart;
+};
+# else
+struct zzip_entry /* : struct zzip_disk_entry */
+{
+ struct zzip_disk_entry head;
+ char* _zzip_restrict tail;
+ zzip_off_t tailalloc; /* the allocated size of tail */
+ FILE* diskfile; /* a file reference */
+ zzip_off_t disksize; /* the size of the file */
+ zzip_off_t headseek; /* the offset within the file */
+ zzip_off_t zz_usize;
+ zzip_off_t zz_csize; /* items scanned from header */
+ zzip_off_t zz_offset; /* or zip64 extension block */
+ int zz_diskstart;
+};
+# endif /* __cplusplus */
+# endif /* _ZZIP_MEM_ENTRY_PRIVATE */
+
+#endif
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.c
new file mode 100644
index 00000000000..144b163d9e8
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.c
@@ -0,0 +1,161 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 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 <zzip/lib.h> /* exported... */
+#include <zzip/file.h>
+#include <zzip/format.h>
+
+#ifdef ZZIP_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#else
+#include <stdlib.h>
+#include <stdio.h>
+#endif
+
+/**
+ * just returns dir->errcode of the ZZIP_DIR handle
+ * see: => zzip_dir_open, => zzip_diropen, => zzip_readdir, => zzip_dir_read
+ */
+int
+zzip_error(ZZIP_DIR * dir)
+{
+ return dir->errcode;
+}
+
+/** => zzip_error
+ * This function just does dir->errcode = errcode
+ */
+void
+zzip_seterror(ZZIP_DIR * dir, int errcode)
+{ dir->errcode = errcode; }
+
+/**
+ * This function will just return fp->dir
+ *
+ * If a ZZIP_FILE is contained within a zip-file that one will be a valid
+ * pointer, otherwise a NULL is returned and the ZZIP_FILE wraps a real file.
+ */
+ZZIP_DIR *
+zzip_dirhandle(ZZIP_FILE * fp)
+{
+ return fp->dir;
+}
+
+/** => zzip_dirhandle
+ * This function will just return dir->fd
+ *
+ * If a ZZIP_DIR does point to a zipfile then the file-descriptor of that
+ * zipfile is returned, otherwise a NULL is returned and the ZZIP_DIR wraps
+ * a real directory DIR (if you have dirent on your system).
+ */
+int
+zzip_dirfd(ZZIP_DIR* dir)
+{
+ return dir->fd;
+}
+
+/**
+ * return static const string of the known compression methods,
+ * otherwise just "zipped" is returned
+ */
+zzip_char_t*
+zzip_compr_str(int compr)
+{
+ switch(compr)
+ {
+ case ZZIP_IS_STORED: return "stored";
+ case ZZIP_IS_SHRUNK: return "shrunk";
+ case ZZIP_IS_REDUCEDx1:
+ case ZZIP_IS_REDUCEDx2:
+ case ZZIP_IS_REDUCEDx3:
+ case ZZIP_IS_REDUCEDx4: return "reduced";
+ case ZZIP_IS_IMPLODED: return "imploded";
+ case ZZIP_IS_TOKENIZED: return "tokenized";
+ case ZZIP_IS_DEFLATED: return "deflated";
+ case ZZIP_IS_DEFLATED_BETTER: return "deflatedX";
+ case ZZIP_IS_IMPLODED_BETTER: return "implodedX";
+ default:
+ if (0 < compr && compr < 256) return "zipped";
+ else
+ {
+# ifdef S_ISDIR
+ if (S_ISDIR(compr)) return "directory";
+# endif
+# ifdef S_ISCHR
+ if (S_ISCHR(compr)) return "is/chr";
+# endif
+# ifdef S_ISBLK
+ if (S_ISBLK(compr)) return "is/blk";
+# endif
+# ifdef S_ISFIFO
+ if (S_ISFIFO(compr)) return "is/fifo";
+# endif
+# ifdef S_ISSOCK
+ if (S_ISSOCK(compr)) return "is/sock";
+# endif
+# ifdef S_ISLNK
+ if (S_ISLNK(compr)) return "is/lnk";
+# endif
+ return "special";
+ }
+ }/*switch*/
+}
+
+/** => zzip_file_real
+ * This function checks if the ZZIP_DIR-handle is wrapping
+ * a real directory or a zip-archive.
+ * Returns 1 for a stat'able directory, and 0 for a handle to zip-archive.
+ */
+int
+zzip_dir_real(ZZIP_DIR* dir)
+{
+ return dir->realdir != 0;
+}
+
+/**
+ * This function checks if the ZZIP_FILE-handle is wrapping
+ * a real file or a zip-contained file.
+ * Returns 1 for a stat'able file, and 0 for a file inside a zip-archive.
+ */
+int
+zzip_file_real(ZZIP_FILE* fp)
+{
+ return fp->dir == 0; /* ie. not dependent on a zip-arch-dir */
+}
+
+/** => zzip_file_real
+ * This function returns the posix DIR* handle (if one exists).
+ * Check before with => zzip_dir_real if the
+ * the ZZIP_DIR points to a real directory.
+ */
+void*
+zzip_realdir(ZZIP_DIR* dir)
+{
+ return dir->realdir;
+}
+
+/** => zzip_file_real
+ * This function returns the posix file descriptor (if one exists).
+ * Check before with => zzip_file_real if the
+ * the ZZIP_FILE points to a real file.
+ */
+int
+zzip_realfd(ZZIP_FILE* fp)
+{
+ return fp->fd;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.h
new file mode 100644
index 00000000000..0ab6edab561
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/info.h
@@ -0,0 +1,25 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 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
+ */
+
+#ifdef ZZIP_USE_INTERNAL
+/* do not make these public, they are for internal use only */
+
+#define ZZIP_error(__dir) __dir->errcode
+#define ZZIP_seterror(__dir, __code) __dir->errcode = __code
+#define ZZIP_dirhandle(__fp) __fp->dir
+#define ZZIP_dirfd(__dir) __dir->fd
+#define ZZIP_dir_real(__dir) __dir->realdir != 0
+#define ZZIP_file_real(__fp) __fp->dir == 0
+#define ZZIP_realdir(__dir) __dir->realdir
+#define ZZIP_reafd(__fp) __fp->fd
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/lib.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/lib.h
new file mode 100644
index 00000000000..b1ad0690042
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/lib.h
@@ -0,0 +1,83 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@iki.fi>
+ *
+ * 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
+ *
+ * This is the private header containing definitions that are not
+ * use by a libzzip user application. Writing an extension lib that
+ * uses libzzip will still want to include this. The extension
+ * write should make way to have the ISO C9X integer types defined.
+ */
+#ifndef _ZZIP_LIB_H /* zzip.h */
+#define _ZZIP_LIB_H
+
+#include <zzip/zzip.h>
+#include <zzip/plugin.h>
+#include <zzip/stdint.h>
+
+/*
+ * this structure cannot be wildly enlarged... (see zzip-zip.c)
+ */
+struct zzip_dir_hdr
+{
+ uint32_t d_usize; /* uncompressed size */
+ uint32_t d_csize; /* compressed size */
+ uint32_t d_crc32; /* the adler32-checksum */
+ uint32_t d_off; /* offset of file in zipfile */
+ uint16_t d_reclen; /* next dir_hdr structure offset */
+ uint16_t d_namlen; /* explicit namelen of d_name */
+ uint8_t d_compr; /* the compression type, 0 = store, 8 = inflate */
+ char d_name[1]; /* the actual name of the entry, may contain DIRSEPs */
+};
+#define _ZZIP_DIRENT_HAVE_D_NAMLEN
+#define _ZZIP_DIRENT_HAVE_D_OFF
+#define _ZZIP_DIRENT_HAVE_D_RECLEN
+
+/*
+ * you shall not use this struct anywhere else than in zziplib sources.
+ */
+struct zzip_dir
+{
+ int fd;
+ int errcode; /* zzip_error_t */
+ long refcount;
+ struct { /* reduce a lot of alloc/deallocations by caching these: */
+ int * volatile locked;
+ struct zzip_file * volatile fp;
+ char * volatile buf32k;
+ } cache;
+ struct zzip_dir_hdr * hdr0; /* zfi; */
+ struct zzip_dir_hdr * hdr; /* zdp; directory pointer, for dirent stuff */
+ struct zzip_file * currentfp; /* last fp used... */
+ struct zzip_dirent dirent;
+ void* realdir; /* e.g. DIR* from posix dirent.h */
+ char* realname;
+ zzip_strings_t* fileext; /* list of fileext to test for */
+ zzip_plugin_io_t io; /* vtable for io routines */
+};
+
+#define ZZIP_32K 32768
+
+/* try to open a zip-basename with default_fileext */
+int __zzip_try_open (zzip_char_t* filename, int filemode,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+ZZIP_DIR *
+zzip_dir_fdopen(int fd, zzip_error_t * errcode_p);
+
+ZZIP_DIR*
+zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errorcode_p,
+ zzip_strings_t* ext, const zzip_plugin_io_t io);
+
+ZZIP_DIR* /*depracated*/
+zzip_dir_alloc_ext_io (zzip_strings_t* ext, const zzip_plugin_io_t io);
+
+#endif /* _ZZIP_H */
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.c
new file mode 100644
index 00000000000..7d66352add8
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.c
@@ -0,0 +1,394 @@
+/*
+ * NOTE: this is part of libzzipmmapped (i.e. it is not libzzip).
+ *
+ * The mem_disk cache will parse the central information of a zip archive
+ * and store it internally. One the one hand it allows to find files
+ * faster - no disk access is required and endian conversion is not
+ * needed. If zzip is compiled with zip extensions then it is about
+ * the only way to build maintainable code around the zip format.
+ *
+ * Note that 64bit support is almost entirely living in extension
+ * blocks as well as different character encodings and file access
+ * control bits that are mostly platform specific.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * 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
+ */
+#define _ZZIP_DISK_FILE_STRUCT 1
+
+#include <zzip/types.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include <zlib.h>
+#include <zzip/format.h>
+#include <zzip/fetch.h>
+#include <zzip/mmapped.h>
+#include <zzip/memdisk.h>
+#include <zzip/__fnmatch.h>
+
+#define ___ {
+#define ____ }
+
+static const char* error[] = {
+ "Ok",
+# define _zzip_mem_disk_open_fail 1
+ "zzip_mem_disk_open: zzip_disk_open did fail",
+# define _zzip_mem_disk_fdopen_fail 2
+ "zzip_mem_disk_fdopen: zzip_disk_mmap did fail"
+};
+
+#define R _zzip_restrict /* a.k.a. allocated */
+
+
+#define ZZIP_EXTRA_zip64 0x0001
+typedef struct _zzip_extra_zip64 { /* ZIP64 extended information extra field */
+ zzip_byte_t z_datatype[2]; /* Tag for this "extra" block type */
+ zzip_byte_t z_datasize[2]; /* Size of this "extra" block */
+ zzip_byte_t z_usize[8]; /* Original uncompressed file size */
+ zzip_byte_t z_csize[8]; /* Size of compressed data */
+ zzip_byte_t z_offset[8]; /* Offset of local header record */
+ zzip_byte_t z_diskstart[4]; /* Number of the disk for file start*/
+} zzip_extra_zip64;
+
+/*forward*/
+
+zzip__new__ static ZZIP_MEM_ENTRY*
+zzip_mem_entry_new(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+zzip__new__ static void
+zzip_mem_entry_free(ZZIP_MEM_ENTRY* _zzip_restrict item);
+
+zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_new(void)
+{
+ return calloc(1, sizeof(ZZIP_MEM_DISK));
+}
+
+/** create new diskdir handle.
+ * wraps underlying zzip_disk_open. */
+zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_open(char* filename)
+{
+ ZZIP_DISK* disk = zzip_disk_open(filename);
+ if (! disk) { perror(error[_zzip_mem_disk_open_fail]); return 0; }
+ ___ ZZIP_MEM_DISK* dir = zzip_mem_disk_new();
+ zzip_mem_disk_load(dir, disk);
+ return dir; ____;
+}
+
+/** create new diskdir handle.
+ * wraps underlying zzip_disk_open. */
+zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_fdopen(int fd)
+{
+ ZZIP_DISK* disk = zzip_disk_mmap(fd);
+ if (! disk) { perror(error[_zzip_mem_disk_fdopen_fail]); return 0; }
+ ___ ZZIP_MEM_DISK* dir = zzip_mem_disk_new();
+ zzip_mem_disk_load(dir, disk);
+ return dir; ____;
+}
+
+/** parse central dir.
+ * creates an internal copy of each entry converted to the local platform.
+ * returns: number of entries, or -1 on error (setting errno)
+ */
+long
+zzip_mem_disk_load(ZZIP_MEM_DISK* dir, ZZIP_DISK* disk)
+{
+ if (! dir || ! disk) { errno=EINVAL; return -1; }
+ if (dir->list) zzip_mem_disk_unload(dir);
+ ___ long count = 0;
+ ___ struct zzip_disk_entry* entry = zzip_disk_findfirst(disk);
+ for (; entry ; entry = zzip_disk_findnext(disk, entry)) {
+ ZZIP_MEM_ENTRY* item = zzip_mem_entry_new(disk, entry);
+ if (! item) goto error;
+ if (dir->last) { dir->last->zz_next = item; } /* chain last */
+ else { dir->list = item; }; dir->last = item; /* to earlier */
+ count++;
+ } ____;
+ dir->disk = disk;
+ return count; ____;
+ error:
+ zzip_mem_disk_unload (dir);
+ return -1;
+}
+
+/** convert a zip disk entry to internal format.
+ * creates a new item parsing the information out of the various places
+ * in the zip archive. This is a good place to extend functionality if
+ * you have a project with extra requirements as you can push more bits
+ * right into the diskdir_entry for later usage in higher layers.
+ * returns: new item, or null on error (setting errno)
+ */
+zzip__new__ ZZIP_MEM_ENTRY*
+zzip_mem_entry_new(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry)
+{
+ if (! disk || ! entry) { errno=EINVAL; return 0; }
+ ___ ZZIP_MEM_ENTRY* item = calloc(1, sizeof(*item));
+ if (! item) return 0; /* errno=ENOMEM; */
+ ___ struct zzip_file_header* header =
+ zzip_disk_entry_to_file_header(disk, entry);
+ /* there is a number of duplicated information in the file header
+ * or the disk entry block. Theoretically some part may be missing
+ * that exists in the other, ... but we will prefer the disk entry.
+ */
+ item->zz_comment = zzip_disk_entry_strdup_comment(disk, entry);
+ item->zz_name = zzip_disk_entry_strdup_name(disk, entry);
+ item->zz_data = zzip_file_header_to_data(header);
+ item->zz_flags = zzip_disk_entry_get_flags(entry);
+ item->zz_compr = zzip_disk_entry_get_compr(entry);
+ item->zz_mktime = zzip_disk_entry_get_mktime(entry);
+ item->zz_crc32 = zzip_disk_entry_get_crc32(entry);
+ item->zz_csize = zzip_disk_entry_get_csize(entry);
+ item->zz_usize = zzip_disk_entry_get_usize(entry);
+ item->zz_diskstart = zzip_disk_entry_get_diskstart(entry);
+ item->zz_filetype = zzip_disk_entry_get_filetype(entry);
+
+ { /* copy the extra blocks to memory as well */
+ int ext1 = zzip_disk_entry_get_extras(entry);
+ char* R ptr1 = zzip_disk_entry_to_extras(entry);
+ int ext2 = zzip_file_header_get_extras(header);
+ char* R ptr2 = zzip_file_header_to_extras(header);
+
+ if (ext1) {
+ void* mem = malloc (ext1+2);
+ item->zz_ext[1] = mem;
+ memcpy (mem, ptr1, ext1);
+ ((char*)(mem))[ext1+0] = 0;
+ ((char*)(mem))[ext1+1] = 0;
+ }
+ if (ext2) {
+ void* mem = malloc (ext2+2);
+ item->zz_ext[2] = mem;
+ memcpy (mem, ptr2, ext2);
+ ((char*)(mem))[ext2+0] = 0;
+ ((char*)(mem))[ext2+1] = 0;
+ }
+ }
+ { /* override sizes/offsets with zip64 values for largefile support */
+ zzip_extra_zip64* block = (zzip_extra_zip64*)
+ zzip_mem_entry_extra_block (item, ZZIP_EXTRA_zip64);
+ if (block) {
+ item->zz_usize = __zzip_get64(block->z_usize);
+ item->zz_csize = __zzip_get64(block->z_csize);
+ item->zz_offset = __zzip_get64(block->z_offset);
+ item->zz_diskstart = __zzip_get32(block->z_diskstart);
+ }
+ }
+ /* NOTE:
+ * All information from the central directory entry is now in memory.
+ * Effectivly that allows us to modify it and write it back to disk.
+ */
+ return item; ____;____;
+}
+
+/* find an extra block for the given datatype code.
+ * We assume that the central directory has been preparsed to memory.
+ */
+ZZIP_EXTRA_BLOCK*
+zzip_mem_entry_extra_block (ZZIP_MEM_ENTRY* entry, short datatype)
+{
+ int i = 2;
+ while (1) {
+ ZZIP_EXTRA_BLOCK* ext = entry->zz_ext[i];
+ if (ext) {
+ while (*(short*)(ext->z_datatype)) {
+ if (datatype == zzip_extra_block_get_datatype (ext)) {
+ return ext;
+ }
+ ___ char* e = (char*) ext;
+ e += zzip_extra_block_headerlength;
+ e += zzip_extra_block_get_datasize (ext);
+ ext = (void*) e; ____;
+ }
+ }
+ if (! i) return 0;
+ i--;
+ }
+}
+
+void
+zzip_mem_entry_free(ZZIP_MEM_ENTRY* _zzip_restrict item)
+{
+ if (item) {
+ if (item->zz_ext[0]) free (item->zz_ext[0]);
+ if (item->zz_ext[1]) free (item->zz_ext[1]);
+ if (item->zz_ext[2]) free (item->zz_ext[2]);
+ if (item->zz_comment) free (item->zz_comment);
+ if (item->zz_name) free (item->zz_name);
+ free (item);
+ }
+}
+
+void
+zzip_mem_disk_unload(ZZIP_MEM_DISK* dir)
+{
+ ZZIP_MEM_ENTRY* item = dir->list;
+ while (item) {
+ ZZIP_MEM_ENTRY* next = item->zz_next;
+ zzip_mem_entry_free(item); item = next;
+ }
+ dir->list = dir->last = 0; dir->disk = 0;
+}
+
+void
+zzip_mem_disk_close(ZZIP_MEM_DISK* _zzip_restrict dir)
+{
+ if (dir) {
+ zzip_mem_disk_unload (dir);
+ zzip_disk_close(dir->disk);
+ free (dir);
+ }
+}
+
+#if 0
+static void foo (short zz_datatype) {
+ switch (zz_datatype) {
+ case 0x0001: /* ZIP64 extended information extra field */
+ case 0x0007: /* AV Info */
+ case 0x0008: /* Reserved for future Unicode file name data (PFS) */
+ case 0x0009: /* OS/2 */
+ case 0x000a: /* NTFS */
+ case 0x000c: /* OpenVMS */
+ case 0x000d: /* Unix */
+ case 0x000e: /* Reserved for file stream and fork descriptors */
+ case 0x000f: /* Patch Descriptor */
+ case 0x0014: /* PKCS#7 Store for X.509 Certificates */
+ case 0x0015: /* X.509 Certificate ID and Signature for file */
+ case 0x0016: /* X.509 Certificate ID for Central Directory */
+ case 0x0017: /* Strong Encryption Header */
+ case 0x0018: /* Record Management Controls */
+ case 0x0019: /* PKCS#7 Encryption Recipient Certificate List */
+ case 0x0065: /* IBM S/390, AS/400 attributes - uncompressed */
+ case 0x0066: /* Reserved for IBM S/390, AS/400 attr - compressed */
+ case 0x07c8: /* Macintosh */
+ case 0x2605: /* ZipIt Macintosh */
+ case 0x2705: /* ZipIt Macintosh 1.3.5+ */
+ case 0x2805: /* ZipIt Macintosh 1.3.5+ */
+ case 0x334d: /* Info-ZIP Macintosh */
+ case 0x4341: /* Acorn/SparkFS */
+ case 0x4453: /* Windows NT security descriptor (binary ACL) */
+ case 0x4704: /* VM/CMS */
+ case 0x470f: /* MVS */
+ case 0x4b46: /* FWKCS MD5 (see below) */
+ case 0x4c41: /* OS/2 access control list (text ACL) */
+ case 0x4d49: /* Info-ZIP OpenVMS */
+ case 0x4f4c: /* Xceed original location extra field */
+ case 0x5356: /* AOS/VS (ACL) */
+ case 0x5455: /* extended timestamp */
+ case 0x554e: /* Xceed unicode extra field */
+ case 0x5855: /* Info-ZIP Unix (original, also OS/2, NT, etc) */
+ case 0x6542: /* BeOS/BeBox */
+ case 0x756e: /* ASi Unix */
+ case 0x7855: /* Info-ZIP Unix (new) */
+ case 0xfd4a: /* SMS/QDOS */
+ }
+}
+#endif
+
+ZZIP_MEM_ENTRY*
+zzip_mem_disk_findfile(ZZIP_MEM_DISK* dir,
+ char* filename, ZZIP_MEM_ENTRY* after,
+ zzip_strcmp_fn_t compare)
+{
+ ZZIP_MEM_ENTRY* entry = (! after ? dir->list : after->zz_next);
+ if (! compare) compare = (zzip_strcmp_fn_t) (strcmp);
+ for (; entry ; entry = entry->zz_next) {
+ if (! compare (filename, entry->zz_name)) {
+ return entry;
+ }
+ }
+ return 0;
+}
+
+ZZIP_MEM_ENTRY*
+zzip_mem_disk_findmatch(ZZIP_MEM_DISK* dir,
+ char* filespec, ZZIP_MEM_ENTRY* after,
+ zzip_fnmatch_fn_t compare, int flags)
+{
+ ZZIP_MEM_ENTRY* entry = (! after ? dir->list : after->zz_next);
+ if (! compare) compare = (zzip_fnmatch_fn_t) _zzip_fnmatch;
+ for (; entry ; entry = entry->zz_next) {
+ if (! compare (filespec, entry->zz_name, flags)) {
+ return entry;
+ }
+ }
+ return 0;
+}
+
+zzip__new__ ZZIP_MEM_DISK_FILE*
+zzip_mem_entry_fopen (ZZIP_MEM_DISK* dir, ZZIP_MEM_ENTRY* entry)
+{
+ /* keep this in sync with zzip_disk_entry_fopen */
+ ZZIP_DISK_FILE* file = malloc(sizeof(ZZIP_MEM_DISK_FILE));
+ if (! file) return file;
+ file->buffer = dir->disk->buffer;
+ file->endbuf = dir->disk->endbuf;
+ file->avail = zzip_mem_entry_usize (entry);
+
+ if (! file->avail || zzip_mem_entry_data_stored (entry))
+ { file->stored = zzip_mem_entry_to_data (entry); return file; }
+
+ file->stored = 0;
+ file->zlib.opaque = 0;
+ file->zlib.zalloc = Z_NULL;
+ file->zlib.zfree = Z_NULL;
+ file->zlib.avail_in = zzip_mem_entry_csize (entry);
+ file->zlib.next_in = zzip_mem_entry_to_data (entry);
+
+ if (! zzip_mem_entry_data_deflated (entry) ||
+ inflateInit2 (& file->zlib, -MAX_WBITS) != Z_OK)
+ { free (file); return 0; }
+
+ return file;
+}
+
+zzip__new__ ZZIP_MEM_DISK_FILE*
+zzip_mem_disk_fopen (ZZIP_MEM_DISK* dir, char* filename)
+{
+ ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfile (dir, filename, 0, 0);
+ if (! entry) return 0; else return zzip_mem_entry_fopen (dir, entry);
+}
+_zzip_size_t
+zzip_mem_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
+ ZZIP_MEM_DISK_FILE* file)
+{
+ return zzip_disk_fread (ptr, size, nmemb, file);
+}
+
+int
+zzip_mem_disk_fclose (ZZIP_MEM_DISK_FILE* file)
+{
+ return zzip_disk_fclose (file);
+}
+
+int
+zzip_mem_disk_feof (ZZIP_MEM_DISK_FILE* file)
+{
+ return zzip_disk_feof (file);
+}
+
+/* convert dostime of entry to unix time_t */
+long zzip_disk_entry_get_mktime(ZZIP_DISK_ENTRY* entry)
+{
+ uint16_t dostime = ZZIP_GET16 (entry->z_dostime.time);
+ uint16_t dosdate = ZZIP_GET16 (entry->z_dostime.date);
+ struct tm date;
+ date.tm_sec = (dostime) & 0x1F; /* bits 0..4 */
+ date.tm_min = (dostime >> 5) & 0x3F; /* bits 5..10 */
+ date.tm_hour = (dostime >> 11); /* bits 11..15 */
+ date.tm_mday = (dosdate) & 0x1F; /* bits 16..20 */
+ date.tm_mon = (dosdate >> 5) & 0xF; /* bits 21..24 */
+ date.tm_year = (dosdate >> 9) + 80; /* bits 25..31 */
+ return mktime (&date); /* well, unix has that function... */
+}
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.h
new file mode 100644
index 00000000000..4403282f730
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/memdisk.h
@@ -0,0 +1,162 @@
+#ifndef __ZZIP_MEMDISK_H
+#define __ZZIP_MEMDISK_H
+
+/* NOTE: this is part of libzzipmmapped (i.e. it is not libzzip). */
+
+#include <zzip/types.h>
+#include <zzip/mmapped.h>
+
+typedef struct _zzip_mem_disk ZZIP_MEM_DISK;
+typedef struct _zzip_mem_entry ZZIP_MEM_ENTRY;
+
+struct _zzip_mem_disk {
+ ZZIP_DISK* disk;
+ ZZIP_MEM_ENTRY* list;
+ ZZIP_MEM_ENTRY* last;
+};
+
+#ifndef zzip_mem_disk_extern
+#define zzip_mem_disk_extern
+#endif
+
+zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_new (void);
+zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_open (char* filename);
+zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
+zzip_mem_disk_fdopen (int fd);
+zzip_mem_disk_extern void
+zzip_mem_disk_close (ZZIP_MEM_DISK* _zzip_restrict dir);
+
+zzip_mem_disk_extern long
+zzip_mem_disk_load (ZZIP_MEM_DISK* dir, ZZIP_DISK* disk);
+zzip_mem_disk_extern void
+zzip_mem_disk_unload (ZZIP_MEM_DISK* dir);
+ZZIP_EXTRA_BLOCK*
+zzip_mem_entry_extra_block (ZZIP_MEM_ENTRY* entry, short datatype);
+
+#ifdef USE_INLINE
+_zzip_inline ZZIP_DISK* zzip_disk (ZZIP_MEM_DISK* dir) { return dir->disk; }
+#else
+#define zzip_disk(_X_) ((_X_)->disk)
+#endif
+
+
+/* these functions are much faster than the orgiinal zzip_disk_ functions */
+
+/* zzip_mem_entry <is similar to> zzip_disk_entry */
+struct _zzip_mem_entry {
+ struct _zzip_mem_entry* zz_next;
+ char* zz_name; /* zero-terminated (from "filename") */
+ zzip_byte_t* zz_data; /* compressed content start (mmap addr) */
+ int zz_flags; /* (from "z_flags") */
+ int zz_compr; /* (from "z_compr") */
+ long zz_mktime; /* (from "z_dostime") */
+ long zz_crc32; /* (from "z_crc32") */
+ zzip_off_t zz_csize; /* (from "z_csize") overridden by zip64 */
+ zzip_off_t zz_usize; /* (from "z_usize") overridden by zip64 */
+ zzip_off_t zz_offset; /* (from "z_offset") overridden by zip64 */
+ int zz_diskstart; /* (from "z_diskstart") rridden by zip64 */
+ int zz_filetype; /* (from "z_filetype") */
+ char* zz_comment; /* zero-terminated (from "comment") */
+ ZZIP_EXTRA_BLOCK* zz_ext[3]; /* terminated by null in z_datatype */
+}; /* the extra blocks are NOT converted */
+
+#define _zzip_mem_disk_findfirst(_d_) ((_d_)->list)
+#define _zzip_mem_disk_findnext(_d_,_e_) (!(_e_)?(_d_)->list:(_e_)->zz_next)
+#define _zzip_mem_entry_findnext(_e_) ((_e_)->zz_next)
+
+#ifndef USE_INLINE
+#define zzip_mem_disk_findfirst _zzip_mem_disk_findfirst
+#define zzip_mem_disk_findnext _zzip_mem_disk_findnext
+#define zzip_mem_entry_findnext _zzip_mem_entry_findnext
+#else
+
+_zzip_inline ZZIP_MEM_ENTRY*
+zzip_mem_disk_findfirst(ZZIP_MEM_DISK* dir) {
+ if (! dir) return 0;
+ return _zzip_mem_disk_findfirst(dir); }
+_zzip_inline ZZIP_MEM_ENTRY*
+zzip_mem_disk_findnext(ZZIP_MEM_DISK* dir, ZZIP_MEM_ENTRY* entry) {
+ if (! dir) return 0;
+ return _zzip_mem_disk_findnext(dir, entry); }
+_zzip_inline ZZIP_MEM_ENTRY*
+zzip_mem_entry_findnext(ZZIP_MEM_ENTRY* entry) {
+ if (! entry) return 0;
+ return _zzip_mem_entry_findnext(entry); }
+#endif
+
+#define _zzip_mem_entry_to_name(_e_) ((_e_)->zz_name)
+#define _zzip_mem_entry_to_comment(_e_) ((_e_)->zz_comment)
+#define _zzip_mem_entry_strdup_name(_e_) (strdup((_e_)->zz_name))
+#define _zzip_mem_entry_to_data(_e_) ((_e_)->zz_data)
+
+#ifndef USE_INLINE
+#define zzip_mem_entry_to_name _zzip_mem_entry_to_name
+#define zzip_mem_entry_to_comment _zzip_mem_entry_to_comment
+#define zzip_mem_entry_strdup_name _zzip_mem_entry_strdup_name
+#define zzip_mem_entry_to_data _zzip_mem_entry_to_data
+#else
+_zzip_inline char*
+zzip_mem_entry_to_name(ZZIP_MEM_ENTRY* entry) {
+ if (! entry) return 0;
+ return _zzip_mem_entry_to_name(entry); }
+_zzip_inline char*
+zzip_mem_entry_to_comment(ZZIP_MEM_ENTRY* entry) {
+ if (! entry) return 0;
+ return _zzip_mem_entry_to_comment(entry); }
+zzip__new__
+_zzip_inline char*
+zzip_mem_entry_strdup_name(ZZIP_MEM_ENTRY* entry) {
+ if (! entry) return 0;
+ return _zzip_mem_entry_strdup_name(entry); }
+_zzip_inline zzip_byte_t*
+zzip_mem_entry_to_data(ZZIP_MEM_ENTRY* entry) {
+ if (! entry) return 0;
+ return _zzip_mem_entry_to_data(entry); }
+#endif
+
+ZZIP_MEM_ENTRY*
+zzip_mem_disk_findfile(ZZIP_MEM_DISK* dir,
+ char* filename, ZZIP_MEM_ENTRY* after,
+ zzip_strcmp_fn_t compare);
+
+ZZIP_MEM_ENTRY*
+zzip_mem_disk_findmatch(ZZIP_MEM_DISK* dir,
+ char* filespec, ZZIP_MEM_ENTRY* after,
+ zzip_fnmatch_fn_t compare, int flags);
+
+/* named access -------------------------------------------------------- */
+#define zzip_mem_entry_usize(_e_) ((_e_)->zz_usize)
+#define zzip_mem_entry_csize(_e_) ((_e_)->zz_csize)
+#define zzip_mem_entry_data_encrypted(_e_) ZZIP_IS_ENCRYPTED((_e_)->zz_flags)
+#define zzip_mem_entry_data_streamed(_e_) ZZIP_IS_STREAMED((_e_)->zz_flags)
+#define zzip_mem_entry_data_comprlevel(_e_) ((_e_)->zz_compr)
+#define zzip_mem_entry_data_stored(_e_) ((_e_)->zz_compr == ZZIP_IS_STORED)
+#define zzip_mem_entry_data_deflated(_e_) ((_e_)->zz_compr == ZZIP_IS_DEFLATED)
+
+/* zzip_mem_disk_file -------------------------------------------------- */
+
+/* since only the header data is being cached, all the real data
+ * operations are actually the same as in mmapped.h - just fopen makes
+ * access to the header data in memory instead of the zip archive.
+ */
+
+typedef ZZIP_DISK_FILE ZZIP_MEM_DISK_FILE;
+
+zzip__new__ ZZIP_MEM_DISK_FILE*
+zzip_mem_entry_fopen (ZZIP_MEM_DISK* dir, ZZIP_MEM_ENTRY* entry);
+zzip__new__ ZZIP_MEM_DISK_FILE*
+zzip_mem_disk_fopen (ZZIP_MEM_DISK* dir, char* filename);
+_zzip_size_t
+zzip_mem_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
+ ZZIP_MEM_DISK_FILE* file);
+int
+zzip_mem_disk_fclose (ZZIP_MEM_DISK_FILE* file);
+int
+zzip_mem_disk_feof (ZZIP_MEM_DISK_FILE* file);
+
+/* convert dostime of entry to unix time_t */
+long zzip_disk_entry_get_mktime(ZZIP_DISK_ENTRY* entry);
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.c
new file mode 100644
index 00000000000..645c4de6d45
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.c
@@ -0,0 +1,566 @@
+/*
+ * NOTE: this is part of libzzipmmapped (i.e. it is not libzzip).
+ *
+ * These routines are fully independent from the traditional zzip
+ * implementation. They assume a readonly mmapped sharedmem block
+ * representing a complete zip file. The functions show how to
+ * parse the structure, find files and return a decoded bytestream.
+ *
+ * These routines are a bit simple and really here for documenting
+ * the way to access a zip file. The complexity of zip access comes
+ * from staggered reading of bytes and reposition of a filepointer in
+ * a big archive with lots of files and long compressed datastreams.
+ * Plus varaints of drop-in stdio replacements, obfuscation routines,
+ * auto fileextensions, drop-in dirent replacements, and so on...
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2003,2004 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
+ */
+
+#ifdef __linux__
+#define _GNU_SOURCE _glibc_developers_are_idiots_to_call_this_gnu_specific_
+#endif
+
+#define _ZZIP_DISK_FILE_STRUCT 1
+
+#include <zzip/types.h>
+
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#if defined ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#elif defined ZZIP_HAVE_IO_H
+#include <io.h>
+#endif
+
+#if defined ZZIP_HAVE_STRING_H
+#include <string.h>
+#endif
+#if defined ZZIP_HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include <zlib.h>
+#include <zzip/mmapped.h>
+#include <zzip/format.h>
+#include <zzip/fetch.h>
+#include <zzip/__mmap.h>
+#include <zzip/__fnmatch.h>
+
+#if __STDC_VERSION__+0 > 199900L
+#define ___
+#define ____
+#else
+#define ___ {
+#define ____ }
+#endif
+
+/** => zzip_disk_mmap
+ * This function does primary initialization of a disk-buffer struct.
+ */
+int
+zzip_disk_init(ZZIP_DISK* disk, void* buffer, zzip_size_t buflen)
+{
+ disk->buffer = (zzip_byte_t*) buffer;
+ disk->endbuf = (zzip_byte_t*) buffer + buflen;
+ disk->reserved = 0;
+ disk->flags = 0;
+ disk->mapped = 0;
+ /* do not touch disk->user */
+ /* do not touch disk->code */
+ return 0;
+}
+
+/** => zzip_disk_mmap
+ * This function allocates a new disk-buffer with => malloc(3)
+ */
+zzip__new__ ZZIP_DISK*
+zzip_disk_new(void)
+{
+ ZZIP_DISK* disk = malloc(sizeof(disk));
+ if (! disk) return disk;
+ zzip_disk_init (disk, 0, 0);
+ return disk;
+}
+
+/** turn a filehandle into a mmapped zip disk archive handle
+ *
+ * This function uses the given file-descriptor to detect the length of the
+ * file and calls the system => mmap(2) to put it in main memory. If it is
+ * successful then a newly allocated ZZIP_DISK* is returned with
+ * disk->buffer pointing to the mapview of the zipdisk content.
+ */
+zzip__new__ ZZIP_DISK*
+zzip_disk_mmap(int fd)
+{
+ struct stat st;
+ if (fstat (fd, &st) || !st.st_size) return 0;
+ ___ ZZIP_DISK* disk = zzip_disk_new (); if (! disk) return 0;
+ disk->buffer = _zzip_mmap (& zzip->mapped, fd, 0, st.st_size);
+ if (disk->buffer == MAP_FAILED) { free (disk); return 0; }
+ disk->endbuf = disk->buffer + st.st_size;
+ return disk; ____;
+}
+
+/** => zzip_disk_mmap
+ * This function is the inverse of => zzip_disk_mmap and using the system
+ * munmap(2) on the buffer area and => free(3) on the ZZIP_DISK structure.
+ */
+int
+zzip_disk_munmap(ZZIP_DISK* disk)
+{
+ if (! disk) return 0;
+ _zzip_munmap (disk->mapped, disk->buffer, disk->endbuf-disk->buffer);
+ free (disk);
+ return 0;
+}
+
+/** => zzip_disk_mmap
+ *
+ * This function opens the given archive by name and turn the filehandle
+ * to => zzip_disk_mmap for bringing it to main memory. If it can not
+ * be => mmap(2)'ed then we slurp the whole file into a newly => malloc(2)'ed
+ * memory block. Only if that fails too then we return null. Since handling
+ * of disk->buffer is ambigous it should not be snatched away please.
+ */
+ZZIP_DISK* zzip__new__
+zzip_disk_open(char* filename)
+{
+# ifndef O_BINARY
+# define O_BINARY 0
+# endif
+ struct stat st;
+ if (stat (filename, &st) || !st.st_size) return 0;
+ ___ int fd = open (filename, O_RDONLY|O_BINARY);
+ if (fd <= 0) return 0;
+ ___ ZZIP_DISK* disk = zzip_disk_mmap (fd);
+ if (disk) return disk;
+ ___ zzip_byte_t* buffer = malloc (st.st_size);
+ if (! buffer) return 0;
+ if ((st.st_size == read (fd, buffer, st.st_size)) &&
+ (disk = zzip_disk_new ()))
+ {
+ disk->buffer = buffer;
+ disk->endbuf = buffer+st.st_size;
+ disk->mapped = -1;
+ }else free (buffer);
+ return disk; ____;____;____;
+}
+
+/** => zzip_disk_mmap
+ *
+ * This function will release all data needed to access a (mmapped)
+ * zip archive, including any malloc()ed blocks, sharedmem mappings
+ * and it dumps the handle struct as well.
+ */
+int
+zzip_disk_close(ZZIP_DISK* disk)
+{
+ if (! disk) return 0;
+ if (disk->mapped != -1) return zzip_disk_munmap (disk);
+ free (disk->buffer);
+ free (disk);
+ return 0;
+}
+
+/* ====================================================================== */
+/* helper functions */
+
+#ifdef ZZIP_HAVE_STRNDUP
+#define _zzip_strndup strndup
+#else
+/* if your system does not have strndup: */
+zzip__new__ static char* _zzip_strndup(char* p, int maxlen)
+{
+ if (! p) return 0;
+ ___ zzip_byte_t* r = malloc (maxlen+1);
+ if (! r) return r;
+ strncpy (r, p, maxlen);
+ r[maxlen] = '\0';
+ return r; ____;
+}
+#endif
+
+#if defined ZZIP_HAVE_STRCASECMP || defined strcasecmp
+#define _zzip_strcasecmp strcasecmp
+#else
+/* if your system does not have strcasecmp: */
+static int _zzip_strcasecmp(char* __zzip_restrict a, char* _zzip_restrict b)
+{
+ if (! a) return (b) ? 1 : 0;
+ if (! b) return -1;
+ while (1)
+ {
+ int v = tolower(*a) - tolower(*b);
+ if (v) return v;
+ if (! *a) return 1;
+ if (! *b) return -1;
+ a++; b++;
+ }
+}
+#endif
+
+/** helper functions for (mmapped) zip access api
+ *
+ * This function augments the other zzip_disk_entry_* helpers: here we move
+ * a disk_entry pointer (as returned by _find* functions) into a pointer to
+ * the data block right after the file_header. Only disk->buffer would be
+ * needed to perform the seek but we check the mmapped range end as well.
+ */
+zzip_byte_t*
+zzip_disk_entry_to_data(ZZIP_DISK* disk, struct zzip_disk_entry* entry)
+{
+ struct zzip_file_header* file =
+ zzip_disk_entry_to_file_header(disk, entry);
+ if (file) return zzip_file_header_to_data (file);
+ return 0;
+}
+
+/** => zzip_disk_entry_to_data
+ * This function does half the job of => zzip_disk_entry_to_data where it
+ * can augment with => zzip_file_header_to_data helper from format/fetch.h
+ */
+struct zzip_file_header*
+zzip_disk_entry_to_file_header(ZZIP_DISK* disk, struct zzip_disk_entry* entry)
+{
+ zzip_byte_t* file_header = /* (struct zzip_file_header*) */
+ (disk->buffer + zzip_disk_entry_fileoffset (entry));
+ if (disk->buffer > file_header || file_header >= disk->endbuf)
+ return 0;
+ return (struct zzip_file_header*) file_header;
+}
+
+/** => zzip_disk_entry_to_data
+ * This function is a big helper despite its little name: in a zip file the
+ * encoded filenames are usually NOT zero-terminated but for common usage
+ * with libc we need it that way. Secondly, the filename SHOULD be present
+ * in the zip central directory but if not then we fallback to the filename
+ * given in the file_header of each compressed data portion.
+ */
+zzip__new__ char*
+zzip_disk_entry_strdup_name(ZZIP_DISK* disk, struct zzip_disk_entry* entry)
+{
+ if (! disk || ! entry) return 0;
+
+ ___ char* name; zzip_size_t len;
+ struct zzip_file_header* file;
+ if ((len = zzip_disk_entry_namlen (entry)))
+ name = zzip_disk_entry_to_filename (entry);
+ else if ((file = zzip_disk_entry_to_file_header (disk, entry)) &&
+ (len = zzip_file_header_namlen (file)))
+ name = zzip_file_header_to_filename (file);
+ else
+ return 0;
+
+ if ((zzip_byte_t*) name < disk->buffer ||
+ (zzip_byte_t*) name+len > disk->endbuf)
+ return 0;
+
+ return _zzip_strndup (name, len); ____;
+}
+
+/** => zzip_disk_entry_to_data
+ * This function is similar creating a reference to a zero terminated
+ * string but it can only exist in the zip central directory entry.
+ */
+zzip__new__ char*
+zzip_disk_entry_strdup_comment(ZZIP_DISK* disk, struct zzip_disk_entry* entry)
+{
+ if (! disk || ! entry) return 0;
+
+ ___ char* text; zzip_size_t len;
+ if ((len = zzip_disk_entry_comment (entry)))
+ text = zzip_disk_entry_to_comment (entry);
+ else
+ return 0;
+
+ if ((zzip_byte_t*) text < disk->buffer ||
+ (zzip_byte_t*) text+len > disk->endbuf)
+ return 0;
+
+ return _zzip_strndup (text, len); ____;
+}
+
+/* ====================================================================== */
+
+/** => zzip_disk_findfile
+ *
+ * This function is the first call of all the zip access functions here.
+ * It contains the code to find the first entry of the zip central directory.
+ * Here we require the mmapped block to represent a real zip file where the
+ * disk_trailer is _last_ in the file area, so that its position would be at
+ * a fixed offset from the end of the file area if not for the comment field
+ * allowed to be of variable length (which needs us to do a little search
+ * for the disk_tailer). However, in this simple implementation we disregard
+ * any disk_trailer info telling about multidisk archives, so we just return
+ * a pointer to the zip central directory.
+ *
+ * For an actual means, we are going to search backwards from the end
+ * of the mmaped block looking for the PK-magic signature of a
+ * disk_trailer. If we see one then we check the rootseek value to
+ * find the first disk_entry of the root central directory. If we find
+ * the correct PK-magic signature of a disk_entry over there then we
+ * assume we are done and we are going to return a pointer to that label.
+ *
+ * The return value is a pointer to the first zzip_disk_entry being checked
+ * to be within the bounds of the file area specified by the arguments. If
+ * no disk_trailer was found then null is returned, and likewise we only
+ * accept a disk_trailer with a seekvalue that points to a disk_entry and
+ * both parts have valid PK-magic parts. Beyond some sanity check we try to
+ * catch a common brokeness with zip archives that still allows us to find
+ * the start of the zip central directory.
+ */
+struct zzip_disk_entry*
+zzip_disk_findfirst(ZZIP_DISK* disk)
+{
+ if (disk->buffer > disk->endbuf-sizeof(struct zzip_disk_trailer))
+ return 0;
+ ___ zzip_byte_t* p = disk->endbuf-sizeof(struct zzip_disk_trailer);
+ for (; p >= disk->buffer ; p--)
+ {
+ zzip_byte_t* root; /* (struct zzip_disk_entry*) */
+ if (zzip_disk_trailer_check_magic(p)) {
+ root = disk->buffer + zzip_disk_trailer_get_rootseek (
+ (struct zzip_disk_trailer*)p);
+ if (root > p)
+ { /* the first disk_entry is after the disk_trailer? can't be! */
+ zzip_size_t rootsize = zzip_disk_trailer_get_rootsize (
+ (struct zzip_disk_trailer*)p);
+ if (disk->buffer+rootsize > p) continue;
+ /* a common brokeness that can be fixed: we just assume the
+ * central directory was written directly before the trailer:*/
+ root = p - rootsize;
+ }
+ } else if (zzip_disk64_trailer_check_magic(p)) {
+ if (sizeof(void*) < 8) return 0; /* EOVERFLOW */
+ root = disk->buffer + zzip_disk64_trailer_get_rootseek (
+ (struct zzip_disk64_trailer*)p);
+ if (root > p) continue;
+ } else continue;
+
+ if (root < disk->buffer) continue;
+ if (zzip_disk_entry_check_magic(root))
+ return (struct zzip_disk_entry*) root;
+ }____;
+ return 0;
+}
+
+/** => zzip_disk_findfile
+ *
+ * This function takes an existing disk_entry in the central root directory
+ * (e.g. from zzip_disk_findfirst) and returns the next entry within in
+ * the given bounds of the mmapped file area.
+ */
+struct zzip_disk_entry*
+zzip_disk_findnext(ZZIP_DISK* disk, struct zzip_disk_entry* entry)
+{
+ if ((zzip_byte_t*)entry < disk->buffer ||
+ (zzip_byte_t*)entry > disk->endbuf-sizeof(entry) ||
+ ! zzip_disk_entry_check_magic (entry) ||
+ zzip_disk_entry_sizeto_end (entry) > 64*1024)
+ return 0;
+ entry = zzip_disk_entry_to_next_entry (entry);
+ if ((zzip_byte_t*)entry > disk->endbuf-sizeof(entry) ||
+ ! zzip_disk_entry_check_magic (entry) ||
+ zzip_disk_entry_sizeto_end (entry) > 64*1024 ||
+ zzip_disk_entry_skipto_end (entry) + sizeof(entry) > disk->endbuf)
+ return 0;
+ else
+ return entry;
+}
+
+/** search for files in the (mmapped) zip central directory
+ *
+ * This function is given a filename as an additional argument, to find the
+ * disk_entry matching a given filename. The compare-function is usually
+ * strcmp or strcasecmp or perhaps strcoll, if null then strcmp is used.
+ * - use null as argument for "after"-entry when searching the first
+ * matching entry, otherwise the last returned value if you look for other
+ * entries with a special "compare" function (if null then a doubled search
+ * is rather useless with this variant of _findfile).
+ */
+struct zzip_disk_entry*
+zzip_disk_findfile(ZZIP_DISK* disk, char* filename,
+ struct zzip_disk_entry* after, zzip_strcmp_fn_t compare)
+{
+ struct zzip_disk_entry* entry = (! after ? zzip_disk_findfirst (disk)
+ : zzip_disk_findnext (disk, after));
+ if (! compare)
+ compare = (zzip_strcmp_fn_t)( (disk->flags&1) ?
+ (_zzip_strcasecmp) : (strcmp));
+ for (; entry ; entry = zzip_disk_findnext (disk, entry))
+ {
+ /* filenames within zip files are often not null-terminated! */
+ char* realname = zzip_disk_entry_strdup_name (disk, entry);
+ if (realname && ! compare(filename, realname))
+ {
+ free (realname);
+ return entry;
+ }
+ free (realname);
+ }
+ return 0;
+}
+
+/** => zzip_disk_findfile
+ *
+ * This function uses a compare-function with an additional argument
+ * and it is called just like fnmatch(3) from POSIX.2 AD:1993), i.e.
+ * the argument filespec first and the ziplocal filename second with
+ * the integer-flags put in as third to the indirect call. If the
+ * platform has fnmatch available then null-compare will use that one
+ * and otherwise we fall back to mere strcmp, so if you need fnmatch
+ * searching then please provide an implementation somewhere else.
+ * - use null as argument for "after"-entry when searching the first
+ * matching entry, or the last disk_entry return-value to find the
+ * next entry matching the given filespec.
+ */
+struct zzip_disk_entry*
+zzip_disk_findmatch(ZZIP_DISK* disk, char* filespec,
+ struct zzip_disk_entry* after,
+ zzip_fnmatch_fn_t compare, int flags)
+{
+ struct zzip_disk_entry* entry = (! after ? zzip_disk_findfirst (disk)
+ : zzip_disk_findnext (disk, after));
+ if (! compare) {
+ compare = (zzip_fnmatch_fn_t) _zzip_fnmatch;
+ if (disk->flags&1) disk->flags |= _zzip_fnmatch_CASEFOLD;
+ }
+ for (; entry ; entry = zzip_disk_findnext (disk, entry))
+ {
+ /* filenames within zip files are often not null-terminated! */
+ char* realname = zzip_disk_entry_strdup_name(disk, entry);
+ if (realname && ! compare(filespec, realname, flags))
+ {
+ free (realname);
+ return entry;
+ }
+ free (realname);
+ }
+ return 0;
+}
+
+/* ====================================================================== */
+
+/** => zzip_disk_fopen
+ *
+ * the ZZIP_DISK_FILE* is rather simple in just encapsulating the
+ * arguments given to this function plus a zlib deflate buffer.
+ * Note that the ZZIP_DISK pointer does already contain the full
+ * mmapped file area of a zip disk, so open()ing a file part within
+ * that area happens to be a lookup of its bounds and encoding. That
+ * information is memorized on the ZZIP_DISK_FILE so that subsequent
+ * _read() operations will be able to get the next data portion or
+ * return an eof condition for that file part wrapped in the zip archive.
+ */
+zzip__new__ ZZIP_DISK_FILE*
+zzip_disk_entry_fopen (ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry)
+{
+ /* keep this in sync with zzip_mem_entry_fopen */
+ struct zzip_file_header* header =
+ zzip_disk_entry_to_file_header (disk, entry);
+ if (! header) return 0;
+ ___ ZZIP_DISK_FILE* file = malloc(sizeof(ZZIP_DISK_FILE));
+ if (! file) return file;
+ file->buffer = disk->buffer;
+ file->endbuf = disk->endbuf;
+ file->avail = zzip_file_header_usize (header);
+
+ if (! file->avail || zzip_file_header_data_stored (header))
+ { file->stored = zzip_file_header_to_data (header); return file; }
+
+ file->stored = 0;
+ file->zlib.opaque = 0;
+ file->zlib.zalloc = Z_NULL;
+ file->zlib.zfree = Z_NULL;
+ file->zlib.avail_in = zzip_file_header_csize (header);
+ file->zlib.next_in = zzip_file_header_to_data (header);
+
+ if (! zzip_file_header_data_deflated (header) ||
+ inflateInit2 (& file->zlib, -MAX_WBITS) != Z_OK)
+ { free (file); return 0; }
+
+ return file; ____;
+}
+
+/** openening a file part wrapped within a (mmapped) zip archive
+ *
+ * This function opens a file found by name, so it does a search into
+ * the zip central directory with => zzip_disk_findfile and whatever
+ * is found first is given to => zzip_disk_entry_fopen
+ */
+zzip__new__ ZZIP_DISK_FILE*
+zzip_disk_fopen (ZZIP_DISK* disk, char* filename)
+{
+ ZZIP_DISK_ENTRY* entry = zzip_disk_findfile (disk, filename, 0, 0);
+ if (! entry) return 0; else return zzip_disk_entry_fopen (disk, entry);
+}
+
+
+/** => zzip_disk_fopen
+ *
+ * This function reads more bytes into the output buffer specified as
+ * arguments. The return value is null on eof or error, the stdio-like
+ * interface can not distinguish between these so you need to check
+ * with => zzip_disk_feof for the difference.
+ */
+zzip_size_t
+zzip_disk_fread (void* ptr, zzip_size_t sized, zzip_size_t nmemb,
+ ZZIP_DISK_FILE* file)
+{
+ zzip_size_t size = sized*nmemb;
+ if (size > file->avail) size = file->avail;
+ if (file->stored)
+ {
+ memcpy (ptr, file->stored, size);
+ file->stored += size;
+ file->avail -= size;
+ return size;
+ }
+
+ file->zlib.avail_out = sized*nmemb;
+ file->zlib.next_out = ptr;
+ ___ zzip_size_t total_old = file->zlib.total_out;
+ ___ int err = inflate (& file->zlib, Z_NO_FLUSH);
+ if (err == Z_STREAM_END)
+ file->avail = 0;
+ else if (err == Z_OK)
+ file->avail -= file->zlib.total_out - total_old;
+ else
+ return 0;
+ return file->zlib.total_out - total_old;
+ ____;____;
+}
+
+/** => zzip_disk_fopen
+ * This function releases any zlib decoder info needed for decompression
+ * and dumps the ZZIP_DISK_FILE* then.
+ */
+int
+zzip_disk_fclose (ZZIP_DISK_FILE* file)
+{
+ if (! file->stored)
+ inflateEnd (& file->zlib);
+ free (file);
+ return 0;
+}
+
+/** => zzip_disk_fopen
+ *
+ * This function allows to distinguish an error from an eof condition.
+ * Actually, if we found an error but we did already reach eof then we
+ * just keep on saying that it was an eof, so the app can just continue.
+ */
+int
+zzip_disk_feof (ZZIP_DISK_FILE* file)
+{
+ return ! file || ! file->avail;
+}
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.h
new file mode 100644
index 00000000000..5f434544800
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/mmapped.h
@@ -0,0 +1,120 @@
+#ifndef _ZZIP_MMAPPED_H_
+#define _ZZIP_MMAPPED_H_
+/*
+ * NOTE: this is part of libzzipmmapped (i.e. it is not libzzip).
+ *
+ * simplified zip disk access using a mmapping of the whole archive.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2003,2004 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 <zzip/types.h>
+
+typedef struct zzip_disk_file ZZIP_DISK_FILE;
+typedef struct zzip_disk ZZIP_DISK;
+/* def struct zzip_disk_entry ZZIP_DISK_ENTRY; */
+
+/* we expose this structure so third party applications can augment
+ * on them. The mmapped zip access usually just needs the two pointers
+ * specifying the mmapped area, whereever you have that from.
+ */
+struct zzip_disk
+{
+ zzip_byte_t* buffer; /* start of mmapped area, the base of all seekvals */
+ zzip_byte_t* endbuf; /* end of mmapped area, i.e. buffer + buflen */
+ void* reserved; /* - for later extensions (might be renamed) */
+ void* user; /* - free for applications (use this!) */
+ long flags; /* bit 0: findfile searches case-insensitive */
+ long mapped; /* used for mmap() wrappers of zzip/__mmap.h */
+ long unused; /* - for later extensions (might be renamed) */
+ long code; /* - free for applications (use this!) */
+};
+
+typedef int (*zzip_strcmp_fn_t)(char*, char*);
+typedef int (*zzip_fnmatch_fn_t)(char*, char*, int);
+
+#define zzip_disk_extern extern
+
+zzip_disk_extern int
+zzip_disk_init(ZZIP_DISK* disk, void* buffer, zzip_size_t buflen);
+
+zzip_disk_extern zzip__new__ ZZIP_DISK*
+zzip_disk_new(void);
+
+zzip_disk_extern zzip__new__ ZZIP_DISK*
+zzip_disk_mmap(int fd);
+
+zzip_disk_extern int
+zzip_disk_munmap(ZZIP_DISK* disk);
+
+zzip_disk_extern zzip__new__ ZZIP_DISK*
+zzip_disk_open(char* filename);
+
+zzip_disk_extern int
+zzip_disk_close(ZZIP_DISK* disk);
+
+
+zzip_disk_extern ZZIP_DISK_ENTRY*
+zzip_disk_findfirst(ZZIP_DISK* disk);
+
+zzip_disk_extern ZZIP_DISK_ENTRY*
+zzip_disk_findnext(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+
+zzip_disk_extern zzip__new__ char*
+zzip_disk_entry_strdup_name(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+zzip_disk_extern zzip__new__ char*
+zzip_disk_entry_strdup_comment(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+zzip_disk_extern struct zzip_file_header*
+zzip_disk_entry_to_file_header(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+zzip_disk_extern zzip_byte_t*
+zzip_disk_entry_to_data(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+
+zzip_disk_extern ZZIP_DISK_ENTRY*
+zzip_disk_findfile(ZZIP_DISK* disk,
+ char* filename, ZZIP_DISK_ENTRY* after,
+ zzip_strcmp_fn_t compare);
+zzip_disk_extern ZZIP_DISK_ENTRY*
+zzip_disk_findmatch(ZZIP_DISK* disk,
+ char* filespec, ZZIP_DISK_ENTRY* after,
+ zzip_fnmatch_fn_t compare, int flags);
+
+
+zzip_disk_extern zzip__new__ ZZIP_DISK_FILE*
+zzip_disk_entry_fopen (ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
+
+zzip_disk_extern zzip__new__ ZZIP_DISK_FILE*
+zzip_disk_fopen (ZZIP_DISK* disk, char* filename);
+
+zzip_disk_extern _zzip_size_t
+zzip_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
+ ZZIP_DISK_FILE* file);
+zzip_disk_extern int
+zzip_disk_fclose (ZZIP_DISK_FILE* file);
+int
+zzip_disk_feof (ZZIP_DISK_FILE* file);
+
+#ifdef _ZZIP_DISK_FILE_STRUCT
+/**
+ * typedef struct zzip_disk_file ZZIP_DISK_FILE;
+ */
+struct zzip_disk_file
+{
+ zzip_byte_t* buffer; /* fopen disk->buffer */
+ zzip_byte_t* endbuf; /* fopen disk->endbuf */
+ zzip_size_t avail; /* memorized for checks on EOF */
+ z_stream zlib; /* for inflated blocks */
+ zzip_byte_t* stored; /* for stored blocks */
+};
+#endif
+
+#endif
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.c
new file mode 100644
index 00000000000..ad17adb6486
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.c
@@ -0,0 +1,84 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Mike Nordell <tamlin-@-algonet-se>
+ *
+ * Copyright (c) 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 <zzip/lib.h>
+#include <zzip/plugin.h>
+
+#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#include <zzip/file.h>
+#include <zzip/format.h>
+
+zzip_off_t
+zzip_filesize(int fd)
+{
+ struct stat st;
+
+ if (fstat(fd, &st) < 0)
+ return -1;
+
+# if defined DEBUG && ! defined _WIN32
+ if (! st.st_size && st.st_blocks > 1) /* seen on some darwin 10.1 machines */
+ fprintf(stderr, "broken fstat(2) ?? st_size=%ld st_blocks=%ld\n",
+ (long) st.st_size, (long) st.st_blocks);
+# endif
+
+ return st.st_size;
+}
+
+static const struct zzip_plugin_io default_io =
+{
+ &open,
+ &close,
+ &_zzip_read,
+ &_zzip_lseek,
+ &zzip_filesize,
+ 1, 1,
+ &_zzip_write
+};
+
+/** => zzip_init_io
+ * This function returns a zzip_plugin_io_t handle to static defaults
+ * wrapping the posix io file functions for actual file access.
+ */
+zzip_plugin_io_t
+zzip_get_default_io()
+{
+ return (zzip_plugin_io_t) &default_io;
+}
+
+/**
+ * This function initializes the users handler struct to default values
+ * being the posix io functions in default configured environments.
+ */
+int zzip_init_io(zzip_plugin_io_handlers_t io, int flags)
+{
+ if (!io) {
+ return ZZIP_ERROR;
+ }
+ memcpy(io, &default_io, sizeof(default_io));
+ io->fd.sys = flags;
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.h
new file mode 100644
index 00000000000..b6ccbe8a66f
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/plugin.h
@@ -0,0 +1,96 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 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
+ *
+ * the interfaces for the plugin_io system
+ *
+ * Using the following you can provide your own file I/O functions to
+ * e.g. read data directly from memory, provide simple
+ * "encryption"/"decryption" of on-disk .zip-files...
+ * Note that this currently only provides a subset of the functionality
+ * in zziplib. It does not attempt to provide any directory functions,
+ * but if your program 1) only uses ordinary on-disk files and you
+ * just want this for file obfuscation, or 2) you only access your
+ * .zip archives using zzip_open & co., this is sufficient.
+ *
+ * Currently the default io are the POSIX functions, except
+ * for 'filesize' that is zziplibs own provided zzip_filesize function,
+ * using standard POSIX fd's. You are however free to replace this with
+ * whatever data type you need, so long as you provide implementations
+ * for all the functions, and the data type fits an int.
+ *
+ * all functions receiving ext_io are able to cope with both arguments
+ * set to zero which will let them default to a ZIP ext and posix io.
+ */
+#ifndef _ZZIP_PLUGIN_H /* zzip-io.h */
+#define _ZZIP_PLUGIN_H 1
+
+#include <zzip/zzip.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* we have renamed zzip_plugin_io.use_mmap to zzip_plugin_io.sys */
+#define ZZIP_PLUGIN_IO_SYS 1
+
+struct zzip_plugin_io { /* use "zzip_plugin_io_handlers" in applications !! */
+ int (*open)(zzip_char_t* name, int flags, ...);
+ int (*close)(int fd);
+ zzip_ssize_t (*read)(int fd, void* buf, zzip_size_t len);
+ zzip_off_t (*seeks)(int fd, zzip_off_t offset, int whence);
+ zzip_off_t (*filesize)(int fd);
+ long sys;
+ long type;
+ zzip_ssize_t (*write)(int fd, _zzip_const void* buf, zzip_size_t len);
+};
+
+typedef union _zzip_plugin_io
+{
+ struct zzip_plugin_io fd;
+ struct { void* padding[8]; } ptr;
+} zzip_plugin_io_handlers;
+
+#define _zzip_plugin_io_handlers zzip_plugin_io_handlers
+/* for backward compatibility, and the following to your application code:
+ * #ifndef _zzip_plugin_io_handlers
+ * #define _zzip_plugin_io_handlers struct zzip_plugin_io
+ */
+typedef zzip_plugin_io_handlers* zzip_plugin_io_handlers_t;
+
+#ifdef ZZIP_LARGEFILE_RENAME
+#define zzip_filesize zzip_filesize64
+#define zzip_get_default_io zzip_get_default_io64
+#define zzip_init_io zzip_init_io64
+#endif
+
+_zzip_export zzip_off_t
+zzip_filesize(int fd);
+
+/* get the default file I/O functions */
+_zzip_export zzip_plugin_io_t zzip_get_default_io(void);
+
+/*
+ * Initializes a zzip_plugin_io_t to the zziplib default io.
+ * This is useful if you only want to override e.g. the 'read' function.
+ * all zzip functions that can receive a zzip_plugin_io_t can
+ * handle a zero pointer in that place and default to posix io.
+ */
+_zzip_export
+int zzip_init_io(zzip_plugin_io_handlers_t io, int flags);
+
+/* zzip_init_io flags : */
+# define ZZIP_IO_USE_MMAP 1
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stat.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stat.c
new file mode 100644
index 00000000000..95bcf0c4051
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stat.c
@@ -0,0 +1,122 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@iki.fi>
+ *
+ * Copyright (c) 1999,2000,2001,2002 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
+ *
+ * Description:
+ * although this file is defining a function called zzip_stat it
+ * will not need a real stat(2) exported by the Operating System.
+ * It will just try to fill the fields of the ZZIP_STAT structure
+ * of
+ */
+
+#include <zzip/lib.h> /* exported...*/
+#include <zzip/file.h>
+#include <string.h>
+#ifdef ZZIP_HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#include <sys/stat.h>
+
+#define ZZIP_USE_INTERNAL
+#include <zzip/info.h>
+
+/**
+ * obtain information about a filename in an opened zip-archive without
+ * opening that file first. Mostly used to obtain the uncompressed
+ * size of a file inside a zip-archive. see => zzip_dir_open.
+ */
+int
+zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name, ZZIP_STAT * zs, int flags)
+{
+ struct zzip_dir_hdr * hdr = dir->hdr0;
+ int (*cmp)(zzip_char_t*, zzip_char_t*);
+
+ cmp = (flags & ZZIP_CASEINSENSITIVE) ? strcasecmp : strcmp;
+
+ if (flags & ZZIP_IGNOREPATH)
+ {
+ char* n = strrchr(name, '/');
+ if (n) name = n + 1;
+ }
+
+ if (hdr)
+ while (1)
+ {
+ register char* hdr_name = hdr->d_name;
+ if (flags & ZZIP_IGNOREPATH)
+ {
+ register char* n = strrchr(hdr_name, '/');
+ if (n) hdr_name = n + 1;
+ }
+
+ if (! cmp(hdr_name, name))
+ break;
+
+ if (! hdr->d_reclen)
+ {
+ dir->errcode = ZZIP_ENOENT;
+ return -1;
+ }
+
+ hdr = (struct zzip_dir_hdr *) ((char *)hdr + hdr->d_reclen);
+ }
+
+ zs->d_compr = hdr->d_compr;
+ zs->d_csize = hdr->d_csize;
+ zs->st_size = hdr->d_usize;
+ zs->d_name = hdr->d_name;
+
+ return 0;
+}
+
+/** => zzip_dir_stat
+ * This function will obtain information about a opened file _within_ a
+ * zip-archive. The file is supposed to be open (otherwise -1 is returned).
+ * The st_size stat-member contains the uncompressed size. The optional
+ * d_name is never set here.
+ */
+int zzip_file_stat (ZZIP_FILE* file, ZZIP_STAT* zs)
+{
+ if (! file) return -1;
+ zs->d_compr = file->method;
+ zs->d_csize = file->csize;
+ zs->st_size = file->usize;
+ zs->d_name = 0;
+ return 0;
+}
+
+/** => zzip_dir_stat
+ * This function will obtain information about a opened file which may be
+ * either real/zipped. The file is supposed to be open (otherwise -1 is
+ * returned). The st_size stat-member contains the uncompressed size.
+ * The optional d_name is never set here. For a real file, we do set the
+ * d_csize := st_size and d_compr := 0 for meaningful defaults.
+ */
+int zzip_fstat (ZZIP_FILE* file, ZZIP_STAT* zs)
+{
+ if (ZZIP_file_real(file))
+ {
+ struct stat st;
+ if (fstat (file->fd, &st) < 0) return -1;
+ zs->st_size = st.st_size;
+ zs->d_csize = st.st_size;
+ zs->d_compr = 0;
+ return 0;
+ }else{
+ return zzip_file_stat (file, zs);
+ }
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stdint.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stdint.h
new file mode 100644
index 00000000000..4552c5b04e0
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/stdint.h
@@ -0,0 +1,45 @@
+#ifndef _ZZIP__STDINT_H /* zzip-stdint.h */
+#define _ZZIP__STDINT_H 1
+/* this file ensures that we have some kind of typedef declarations for
+ unsigned C9X typedefs. The ISO C 9X: 7.18 Integer types file is stdint.h
+ */
+
+#include <zzip/conf.h>
+
+/* enforce use of ifdef'd C9X entries in system headers */
+#define __USE_ANSI 1
+#define __USE_ISOC9X 1
+
+#ifdef ZZIP_HAVE_STDINT_H
+ /* ISO C 9X: 7.18 Integer types <stdint.h> */
+#include <stdint.h>
+#elif defined ZZIP_HAVE_SYS_INT_TYPES_H /*solaris*/
+#include <sys/int_types.h>
+#elif defined ZZIP_HAVE_INTTYPES_H /*freebsd*/
+#include <inttypes.h>
+#else
+ typedef unsigned char uint8_t; typedef signed char int8_t;
+
+# if ZZIP_SIZEOF_INT && ZZIP_SIZEOF_INT == 2
+ typedef unsigned int uint16_t; typedef signed int int16_t;
+# elif ZZIP_SIZEOF_SHORT && ZZIP_SIZEOF_SHORT == 2
+ typedef unsigned short uint16_t; typedef signed short int16_t;
+# else
+# error unable to typedef int16_t from either int or short
+ typedef unsigned short uint16_t; typedef signed short int16_t;
+# endif
+
+# if defined ZZIP_SIZEOF_INT && ZZIP_SIZEOF_INT == 4
+ typedef unsigned int uint32_t; typedef signed int int32_t;
+# elif defined ZZIP_SIZEOF_LONG && ZZIP_SIZEOF_LONG == 4
+ typedef unsigned long uint32_t; typedef signed long int32_t;
+# else
+# error unable to typedef int32_t from either int or long
+ typedef unsigned long uint32_t; typedef signed long int32_t;
+# endif
+
+typedef unsigned _zzip___int64 uint64_t; typedef _zzip___int64 int64_t;
+#endif
+
+#endif /*_ZZIP_STDINT_H*/
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/types.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/types.h
new file mode 100644
index 00000000000..c20f128daa8
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/types.h
@@ -0,0 +1,51 @@
+/*
+ * unlike in <zzip/conf.h> we are allowed to make up typedefs here,
+ * while over there only #defines are allowed
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 2003,2004 Guido Draheim
+ * All rights reserved,
+ * usage allowed under the restrictions of the
+ * Lesser GNU General Public License
+ * or alternatively the restrictions
+ * of the Mozilla Public License 1.1
+ *
+ * if you see "unknown symbol" errors, check first that `-I ..` is part of
+ * your compiler options - a special hint to VC/IDE users who tend to make up
+ * their own workspace files. All includes look like #include <zzip|*.h>, so
+ * you need to add an include path to the dir containing (!!) the ./zzip/ dir
+ */
+
+#ifndef _ZZIP_TYPES_H_
+#define _ZZIP_TYPES_H_
+
+#include <zzip/conf.h>
+#include <fcntl.h>
+#include <stddef.h> /* size_t and friends */
+#ifdef ZZIP_HAVE_SYS_TYPES_H
+#include <sys/types.h> /* bsd (mac) has size_t here */
+#endif
+/* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */
+
+typedef unsigned char zzip_byte_t; // especially zlib decoding data
+
+typedef _zzip_off64_t zzip_off64_t;
+typedef _zzip_off_t zzip_off_t;
+typedef _zzip_size_t zzip_size_t;
+typedef _zzip_ssize_t zzip_ssize_t;
+
+/* in <zzip/format.h> */
+typedef struct zzip_disk64_trailer ZZIP_DISK64_TRAILER;
+typedef struct zzip_disk_trailer ZZIP_DISK_TRAILER;
+typedef struct zzip_file_trailer ZZIP_FILE_TRAILER;
+typedef struct zzip_root_dirent ZZIP_ROOT_DIRENT;
+typedef struct zzip_file_header ZZIP_FILE_HEADER;
+typedef struct zzip_disk_entry ZZIP_DISK_ENTRY;
+typedef struct zzip_extra_block ZZIP_EXTRA_BLOCK;
+
+
+
+#endif
+
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/write.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/write.c
new file mode 100644
index 00000000000..36637ddbcc9
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/write.c
@@ -0,0 +1,461 @@
+/*
+ * The write-support in zziplib is not a full-flegded interface to the
+ * internals that zip file-header or zip archive an contain. It's
+ * primary use goes for savegames or transfer `pack-n-go` archives
+ * where time-stamps are rather unimportant. Here we can create an
+ * archive with filenames and their data portions, possibly obfuscated.
+ *
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ *
+ * Copyright (c) 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
+ */
+
+#define _ZZIP_WRITE_SOURCE
+
+#if defined DDDD || defined DDDDD || defined DDDDDD || defined DDDDDDD
+#define _ZZIP_ENABLE_WRITE
+#else /* per default, we add support for passthrough to posix write */
+#define _ZZIP_POSIX_WRITE
+#endif
+
+#include <zzip/lib.h> /* exported...*/
+#include <zzip/file.h>
+
+#include <string.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#ifdef ZZIP_HAVE_DIRECT_H
+#include <direct.h>
+#endif
+
+#include <zzip/format.h>
+#include <zzip/plugin.h>
+#include <zzip/__debug.h>
+
+#define ___ {
+#define ____ }
+
+#ifndef EROFS
+# ifdef ENOSYS
+#define EROFS ENOSYS
+# else
+#define EROFS EPERM
+#endif
+#endif
+
+/* try real zlib routines for writing ? very experimental, very very ex... */
+#ifndef _ZZIP_ENABLE_WRITE
+#define _ZZIP_TRY 0
+#else
+#define _ZZIP_TRY 1
+#endif
+
+/* btw, is there any system that did define those different ? get away.. */
+# ifndef S_IWGRP
+# define S_IWGRP 00020
+# endif
+# ifndef S_IRWXO
+# define S_IRWXO 00007
+# endif
+
+# ifdef ZZIP_HAVE_DIRECT_H
+# define _mkdir(a,b) mkdir(a)
+# else
+# define _mkdir mkdir
+# endif
+
+/** create a new zip archive for writing
+ *
+ * This function will create a new zip archive. The returned parameter
+ * is a new "zzip dir" handle that should be saved to a variable so it
+ * can be used a base argument for => zzip_mkdir and => zzip_creat calls.
+ * The returned handle represents a zip central directory that must be
+ * saved to disk using => zzip_closedir.
+ *
+ * Returns null on error and sets errno. Remember, according to posix
+ * the => creat(2) call is equivalent to
+ open (path, O_WRONLY | O_CREAT | O_TRUNC, o_mode)
+ * so any previous zip-archive will be overwritten unconditionally and
+ * EEXIST errors from => mkdir(2) are suppressed. (fixme: delete the
+ * given subtree? like suggested by O_TRUNC? not done so far!)
+ */
+ZZIP_DIR*
+zzip_dir_creat(zzip_char_t* name, int o_mode)
+{
+ return zzip_dir_creat_ext_io (name, o_mode, 0, 0);
+}
+
+/** => zzip_dir_creat
+ *
+ * If the third argument "ext" has another special meaning here, as it
+ * is used to ensure that a given zip-file is created with the first entry
+ * of the ext-list appended as an extension unless the file-path already
+ * ends with a file-extension registered in the list. Therefore {"",0}
+ * matches all files and creates them as zip-archives under the given
+ * nonmodified name. (Some magic here? If the path ends in the path
+ * separator then make a real directory even in the presence of ext-list?)
+ *
+ * This function is not yet implemented, check for #def ZZIP_NO_CREAT
+ * Write-support will extend => zzip_closedir with semantics to finalize the
+ * zip-archive by writing the zip-trailer and closing the archive file.
+ */
+ZZIP_DIR*
+zzip_dir_creat_ext_io(zzip_char_t* name, int o_mode,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ if (! io) io = zzip_get_default_io ();
+
+ if (io != zzip_get_default_io())
+ { /* the current io-structure does not contain a "write" entry,
+ * and therefore this parameter is useless. Anyone to expect
+ * some behavior should be warned, so here we let the function
+ * fail bluntly - and leaving the recovery to the application
+ */
+ errno = EINVAL;
+ return 0;
+ }
+
+
+ if (!_ZZIP_TRY)
+ { /* not implemented - however, we respect that a null argument to
+ * zzip_mkdir and zzip_creat works, so we silently still do the mkdir
+ */
+ if (! _mkdir (name, o_mode) || errno == EEXIST)
+ errno = EROFS;
+ return 0;
+ } else {
+# define MAX_EXT_LEN 10
+ ZZIP_DIR* dir = zzip_dir_alloc (ext);
+ int name_len = strlen(name);
+ dir->realname = malloc (name_len+MAX_EXT_LEN);
+ if (! dir->realname) goto error;
+
+ memcpy (dir->realname, name, name_len+1);
+ ___ int fd = __zzip_try_open (
+ dir->realname, O_EXCL|O_TRUNC|O_WRONLY, ext, io);
+ if (fd != -1) { dir->fd = fd; return dir; }
+
+ ___ zzip_strings_t* exx = ext; int exx_len;
+ for (; *exx ; exx++)
+ {
+ if ((exx_len = strlen (*exx)+1) <= name_len &&
+ !memcmp (dir->realname+(name_len-exx_len), *exx, exx_len))
+ break; /* keep unmodified */
+ exx++; if (*exx) continue;
+
+ if (! (exx_len = strlen (*exx)) || exx_len >= MAX_EXT_LEN) break;
+ memcpy (dir->realname+name_len, exx, exx_len); /* append! */
+ }____;
+ fd = io->fd.open (dir->realname, O_CREAT|O_TRUNC|O_WRONLY, o_mode);
+ dir->realname[name_len] = '\0'; /* keep ummodified */
+ if (fd != -1) { dir->fd = fd; return dir; }
+ error:
+ zzip_dir_free (dir); return 0;
+ ____;
+ }
+}
+
+/** create a new archive area for writing
+ *
+ * This function will create a new archive area. This may either be a
+ * a new zip archive or a new directory in the filesystem. The returned
+ * parameter is a new "zzip dir" handle that should be saved to a variable
+ * so it can be used a base argument for => zzip_file_mkdir and
+ * => zzip_file_creat calls. The returned handle wraps both possibilities,
+ * it can be representing a zip central directory that must be
+ * saved to disk using => zzip_closedir or it is just a handle for the
+ * name of the real directory that still must be run through
+ * => zzip_closedir to release the wrapper around the directory name.
+ *
+ * The magic is pushed through the o_mode argument. Using a mode that
+ * has no group-write bit set (S_IWGRP = 0040) then the file is
+ * created as a zip directory. Note that this is unabridged of any
+ * umask value in the system where the argument to this function could
+ * be 0775 but with an umask of 0755 it turns out as 0755 for a real
+ * directory. Using 0755 directly would not create it as a real directory
+ * but as a zip archive handle.
+ *
+ * This function is not yet implemented, check for #def ZZIP_NO_CREAT
+ * Write-support will extend => zzip_closedir with semantics to finalize the
+ * zip-archive by writing the zip-trailer and closing the archive file.
+ *
+ * Returns null on error and sets errno. Remember, according to posix
+ * the => creat(2) call is equivalent to
+ open (path, O_WRONLY | O_CREAT | O_TRUNC, o_mode)
+ * so any previous zip-archive will be overwritten unconditionally and
+ * EEXIST errors from => mkdir(2) are suppressed. (fixme: delete the
+ * given subtree? like suggested by O_TRUNC? not done so far!)
+ */
+ZZIP_DIR*
+zzip_createdir(zzip_char_t* name, int o_mode)
+{
+ if (o_mode & S_IWGRP)
+ {
+ if (-1 == _mkdir(name, o_mode) && errno != EEXIST) /* fail */
+ return 0;
+ return zzip_opendir (name);
+ } else
+ return zzip_dir_creat (name, o_mode);
+}
+
+/** => zzip_file_creat => mkdir(2), creat(2), zzip_dir_creat
+ *
+ * This function has an additional primary argument over the posix
+ * mkdir(2) - if it is null then this function behaves just like
+ * posix mkdir(2). The zzip_dir argument can be set to the result
+ * of a => zzip_createdir which allows for some magic that the
+ * given directory name is created as an entry in the zip archive.
+ *
+ * If the given dir name argument is not within the basepath of
+ * the zip central directory then a real directory is created.
+ * Any EEXIST errors are not suppressed unlike with => zzip_createdir
+ *
+ * Standard usage accepts a global/threaded/modular ZZIP_DIR pointer
+ * for all zip archive operations like in:
+ ZZIP_DIR* zip = zzip_createdir (sysconfpath, 0755, zip);
+ zzip_file_mkdir (zip, filepath[i], 0755);
+ ZZIP_FILE* file = zzip_file_creat (zip, filename[i], 0644);
+ zzip_write (file, buf, len);
+ zzip_close (file); file = 0;
+ zzip_closedir (zip); zip = 0;
+ *
+ * compare with => zzip_mkdir inline macro which allows to
+ * collapse the examples script to
+ #define zzip_savefile myproject_saveconfig
+ #include <zzip/zzip.h>
+ ZZIP_DIR* zzip_savefile = zzip_createdir (sysconfpath, 0755);
+ zzip_mkdir (filepath[i], 0755);
+ ZZIP_FILE* file = zzip_creat(filepath[i], 0644);
+ zzip_write (file, buf, len);
+ zzip_close (file); file = 0;
+ zzip_closedir (zip_savefile);
+ */
+int
+zzip_file_mkdir(ZZIP_DIR* dir, zzip_char_t* name, int o_mode)
+{
+ if (! dir)
+ return _mkdir(name, o_mode);
+
+ if (!_ZZIP_TRY)
+ {/* not implemented */
+ errno = EROFS;
+ return -1;
+ } else {
+ errno = EROFS;
+ return -1;
+ }
+}
+
+/** start next file entry in a zip archive
+ *
+ * This function will create a new file within a zzip archive, the
+ * one given as the primary argument and additionally to the posix
+ * creat(2) - just like zzip_mkdir has an additional argument over
+ * the posix mkdir(2) spec. For this function the primary parameter
+ * can be null as well thereby creating a real file instead of a new
+ * one inside the zip-archive otherwise given. If the primary parameter is
+ * not null but wraps a real directory then all new files are also real.
+ *
+ * This function is not yet implemented, check for #def ZZIP_NO_CREAT
+ *
+ * Returns NULL on an error setting errno, and opening a file _within_
+ * a zip archive using O_RDONLY (and similar stuff) will surely lead to
+ * an error.
+ */
+ZZIP_FILE*
+zzip_file_creat(ZZIP_DIR* dir, zzip_char_t* name, int o_mode)
+{
+ if (! dir)
+ return zzip_open (name, o_mode);
+
+ if (!_ZZIP_TRY)
+ {/* not implemented */
+ errno = EROFS;
+ return 0;
+ } else {
+ errno = EROFS;
+ return 0;
+ }
+}
+
+/** write to zzip storage also: write(2), zlib(3)
+ *
+ * This function will write data to a file descriptor. If the file
+ * descriptor represents a real file then it will be forwarded to
+ * call posix => write(2) directly. If it is a descriptor for a
+ * file within a zip directory then the data will be "deflated"
+ * using => zlib(3) and appended to the zip archive file.
+ */
+zzip_ssize_t
+zzip_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len)
+{
+ if (zzip_file_real(file))
+ return write (zzip_realfd (file), ptr, len);
+ else
+ return zzip_file_write (file, ptr, len);
+}
+
+/** => zzip_write also: zzip_file_creat
+ *
+ * This function will write data to a file descriptor inside a zip
+ * archive. The data will be "deflated" using => zlib(3) compression
+ * and appended to the end of the zip archive file. Only one file
+ * descriptor may be open per zzip_dir archive handle (fifo-like).
+ *
+ * This function is not yet implemented, check for #def ZZIP_NO_CREAT
+ * It returns immediately -1 and sets errno=EROFS for indication.
+ */
+zzip_ssize_t
+zzip_file_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len)
+{
+ if (!_ZZIP_TRY)
+ {/* not implemented */
+ errno = EROFS;
+ return -1;
+ } else {
+ /* add calls to zlib here... */
+ errno = EROFS;
+ return -1;
+ }
+}
+
+/** => zzip_write
+ * This function is the stdc variant for writing and the arguments
+ * are forwarded to => zzip_write - the return value is floored to
+ * null as for STDC spec but there is no zzip_ferror call so far
+ * for the zziplib (later? is it actually needed?).
+ *
+ * This function is not yet implemented, check for #def ZZIP_NO_CREAT
+ * Write-support extends => zzip_close with semantics to write out a
+ * file-trailer to the zip-archive leaving a name/offset marker in
+ * the (still-open) ZZIP_DIR handle.
+ */
+zzip_size_t
+zzip_fwrite(const void* ptr, zzip_size_t len, zzip_size_t multiply,
+ ZZIP_FILE* file)
+{
+ zzip_ssize_t value = zzip_write (file, ptr, len * multiply);
+ if (value == -1)
+ value = 0;
+ return (zzip_size_t) value;
+}
+
+#if 0 /* pure documentation */
+/** create a zipped file/directory also: zzip_dir_creat, mkdir(2)
+ *
+ * This function creates a directory entry in the default zip-archive.
+ * If you did not specify a "#define zzip_savefile somevar"
+ * then the default zip-archive is null and all directories are
+ * created as real directories in the filesystem. This function is
+ * really a preprocessor macro or preferably an inline function
+ * around => zzip_file_mkdir, there is no such symbol generated
+ * into the library. The prototype is modelled after the posix
+ * => mkdir(2) call.
+ #ifndef zzip_savefile
+ #define zzip_savefile 0
+ #endif
+ #define zzip_mkdir(name,mode) \ -
+ zzip_file_mkdir(zzip_savefile,name,mode)
+ *
+ */
+int inline
+zzip_mkdir(zzip_char_t* name, int o_mode)
+{
+ return zzip_file_creat(zzip_savefile, name, mode);
+}
+#endif
+
+#if 0 /* pure documentation */
+/** => zzip_mkdir also: creat(2), zzip_start
+ *
+ * This function creates a file in the default zip-archive.
+ * If you did not specify a "#define zzip_savefile somevar"
+ * then the default zip-archive is null and all files are created
+ * as real files. This function is really a preprocessor macro
+ * or preferably an inline function around => zzip_file_creat,
+ * there is no such symbol generated into the library. The prototype
+ * is modelled after the posix => creat(2) call.
+ #ifndef zzip_savefile
+ #define zzip_savefile 0
+ #endif
+ #define zzip_creat(name,mode) \ -
+ zzip_file_creat(zzip_savefile,name,mode)
+ */
+ZZIP_FILE* inline
+zzip_creat(zzip_char_t* name, int o_mode)
+{
+ return zzip_file_creat(zzip_savefile, name, mode);
+}
+#endif
+
+
+#if 0 /* pure documentation */
+/** start writing to the magic zzip_savefile also: zzip_creat, zzip_write
+ *
+ * open a zip archive for writing via the magic zzip_savefile macro
+ * variable. The name and mode are given to => zzip_createdir and
+ * the result is stored into => zzip_savefile - if the => zzip_savefile
+ * did already have a zzip_dir handle then it is automatically
+ * finalized with => zzip_sync and the handle closed and the
+ * zzip_savefile variable reused for the new zip archive just started
+ * with this call. - This function is really a preprocessor macro
+ * or preferably an inline function around => zzip_dir_create, there
+ * is no such symbol generated into the library.
+ #ifndef zzip_savefile
+ #define zzip_savefile 0
+ #endif
+ #define zzip_start(name,mode,ext) \ -
+ { if (zzip_savefile) zzip_closedir(zzip_savefile); \ -
+ zzip_savefile = zzip_createdir(name,mode,ext); }
+ * This function returns null on error or a zzip_dir handle on
+ * success. It is perfectly okay to continue with a null in the
+ * zzip_savefile variable since it makes subsequent calls to
+ * => zzip_creat and => zzip_mkdir to run as => creat(2) / => mkdir(2)
+ * on the real filesystem.
+ */
+void inline
+zzip_mkfifo(zzip_char_t* name, int o_mode)
+{
+ if (zzip_savefile) zzip_closedir (zzip_savefile);
+ zzip_savefile = zzip_createdir(name, o_mode);
+}
+#endif
+
+#if 0 /* pure documentation */
+/** => zzip_mkfifo also: zzip_closedir, sync(2)
+ *
+ * finalize a zip archive thereby writing the central directory to
+ * the end of the file. If it was a real directory then we do just
+ * nothing - even that the prototype of the call itself is modelled
+ * to be similar to the posix => sync(2) call. This function is
+ * really a preprocessor macro or preferably an inline function
+ * around => zzip_closedir, there is no such symbol generated
+ * into the library.
+ #ifndef zzip_savefile
+ #define zzip_savefile 0
+ #endif
+ #define zzip_sync(name,mode) \ -
+ { zzip_closedir(zzip_savefile); zzip_savefile = 0; }
+ *
+ */
+void inline
+zzip_sync(void)
+{
+ zzip_closedir (zzip_savefile); zzip_savefile = 0;
+}
+#endif
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zip.c b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zip.c
new file mode 100644
index 00000000000..5133a11613b
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zip.c
@@ -0,0 +1,759 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <too@iki.fi>
+ *
+ * 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 <zzip/lib.h> /* archive handling */
+#include <zzip/file.h>
+#include <zzip/format.h>
+#include <zzip/fetch.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#ifdef ZZIP_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#include <zzip/__mmap.h>
+#include <zzip/__debug.h>
+
+#define __sizeof(X) ((zzip_ssize_t)(sizeof(X)))
+
+/* per default, we use a little hack to correct bad z_rootseek parts */
+#define ZZIP_CORRECT_ROOTSEEK 1
+
+#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ >= 4)
+# ifdef DEBUG
+# warning suppress a warning where the compiler should have optimized instead.
+# endif
+#define _255 254
+#else
+#define _255 255
+#endif
+
+#define ZZIP_DISK64_TRAILER
+
+#ifdef ZZIP_DISK64_TRAILER
+struct _disk_trailer {
+ void* zz_tail;
+ void* zz_for_correct_rootseek; // ZZIP_CORRECT_ROOTSEEK
+ zzip_off64_t zz_entries;
+ zzip_off64_t zz_finalentries;
+ zzip_off64_t zz_rootseek;
+ zzip_off64_t zz_rootsize;
+};
+#define _disk_trailer_entries(__p) ((__p)->zz_entries)
+#define _disk_trailer_localentries(__p) ((__p)->zz_entries)
+#define _disk_trailer_finalentries(__p) ((__p)->zz_entries)
+#define _disk_trailer_rootseek(__p) ((__p)->zz_rootseek)
+#define _disk_trailer_rootsize(__p) ((__p)->zz_rootsize)
+#define _disk_trailer_set_rootseek(__p,__v) ((__p)->rootseek = (__v))
+
+#else
+#define _disk_trailer zzip_disk_trailer
+#define _disk_trailer_entries zzip_disk_trailer_entries
+#define _disk_trailer_localentries zzip_disk_trailer_localentries
+#define _disk_trailer_finalentries zzip_disk_trailer_finalentries
+#define _disk_trailer_rootseek zzip_disk_trailer_rootseek
+#define _disk_trailer_rootsize zzip_disk_trailer_rootsize
+#define _disk_trailer_set_rootseek zzip_disk_trailer_set_rootseek
+#define __zzip_fetch_disk_trailer __zzip_find_disk_trailer
+#endif
+
+/* --------------------------- internals -------------------------------- */
+/* internal functions of zziplib, avoid at all cost, changes w/o warning.
+ * we do export them for debugging purpose and special external tools
+ * which know what they do and which can adapt from version to version
+ */
+
+int __zzip_fetch_disk_trailer( int fd, zzip_off_t filesize,
+ struct _disk_trailer * _zzip_restrict trailer,
+ zzip_plugin_io_t io);
+int __zzip_parse_root_directory( int fd,
+ struct _disk_trailer * trailer,
+ struct zzip_dir_hdr ** hdr_return,
+ zzip_plugin_io_t io);
+
+_zzip_inline char* __zzip_aligned4(char* p);
+
+/* ------------------------ harden routines ------------------------------ */
+
+#ifdef ZZIP_HARDEN
+/*
+ * check for inconsistent values in trailer and prefer lower seek value
+ * - we fix values assuming the root directory was written at the end
+ * and it is just before the zip trailer. Therefore, ...
+ */
+_zzip_inline static void __fixup_rootseek(
+ zzip_off_t offset_of_trailer,
+ struct _disk_trailer* trailer)
+{
+ if ( _disk_trailer_rootseek (trailer) >
+ offset_of_trailer - _disk_trailer_rootsize (trailer) &&
+ offset_of_trailer > _disk_trailer_rootsize (trailer))
+ {
+ register zzip_off_t offset;
+ offset = offset_of_trailer - _disk_trailer_rootsize (trailer);
+ _disk_trailer_set_rootseek (trailer, offset);
+ HINT2("new rootseek=%li", (long) _disk_trailer_rootseek (trailer));
+ }
+}
+#define __correct_rootseek(A,B,C)
+
+#elif defined ZZIP_CORRECT_ROOTSEEK
+/* store the seekvalue of the trailer into the "z_magic" field and with
+ * a 64bit off_t we overwrite z_disk/z_finaldisk as well. If you change
+ * anything in zziplib or dump the trailer structure then watch out that
+ * these are still unused, so that this code may still (ab)use those. */
+#define __fixup_rootseek(_offset_of_trailer, _trailer) \
+ *(zzip_off_t*)_trailer = _offset_of_trailer;
+#define __correct_rootseek( _u_rootseek, _u_rootsize, _trailer) \
+ if (_u_rootseek > *(zzip_off_t*)_trailer - _u_rootsize) \
+ _u_rootseek = *(zzip_off_t*)_trailer - _u_rootsize;
+#else
+#define __fixup_rootseek(A,B)
+#define __correct_rootseek(A,B,C)
+#endif
+
+
+#ifdef DEBUG
+_zzip_inline static void __debug_dir_hdr (struct zzip_dir_hdr* hdr)
+{
+ if (sizeof(struct zzip_dir_hdr) > sizeof(struct zzip_disk_entry))
+ { WARN1("internal sizeof-mismatch may break wreakage"); }
+ /* the internal directory structure is never bigger than the
+ * external zip central directory space had been beforehand
+ * (as long as the following assertion holds...)
+ */
+
+ if (((zzip_off_t)hdr)&3)
+ { NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); }
+ /* we assume that if this machine's malloc has returned a non-aligned
+ * memory block, then it is actually safe to access misaligned data, and
+ * since it does only affect the first hdr it should not even bring about
+ * too much of that cpu's speed penalty
+ */
+}
+#else
+#define __debug_dir_hdr(X)
+#endif
+
+/* -------------------------- low-level interface -------------------------- */
+
+#if defined BUFSIZ
+#if BUFSIZ == 1024 || BUFSIZ == 512 || BUFSIZ == 256
+#define ZZIP_BUFSIZ BUFSIZ
+#endif
+#endif
+
+#ifndef ZZIP_BUFSIZ
+#define ZZIP_BUFSIZ 512
+/* #define ZZIP_BUFSIZ 64 */ /* for testing */
+#endif
+
+/**
+ * This function is used by => zzip_file_open. It tries to find
+ * the zip's central directory info that is usually a few
+ * bytes off the end of the file.
+ */
+int
+__zzip_fetch_disk_trailer(int fd, zzip_off_t filesize,
+ struct _disk_trailer * _zzip_restrict trailer,
+ zzip_plugin_io_t io)
+{
+#ifdef DEBUG
+#define return(val) { e=val; HINT2("%s", zzip_strerror(e)); goto cleanup; }
+#else
+#define return(val) { e=val; goto cleanup; }
+#endif
+ register int e;
+
+#ifndef _LOWSTK
+ auto char buffer[2*ZZIP_BUFSIZ];
+ char* buf = buffer;
+#else
+ char* buf = malloc(2*ZZIP_BUFSIZ);
+#endif
+ zzip_off_t offset = 0;
+ zzip_ssize_t maplen = 0; /* mmap(),read(),getpagesize() use size_t !! */
+ char* fd_map = 0;
+
+ if (!trailer)
+ { return(EINVAL); }
+
+ if (filesize < __sizeof(struct zzip_disk_trailer))
+ { return(ZZIP_DIR_TOO_SHORT); }
+
+ if (!buf)
+ { return(ZZIP_OUTOFMEM); }
+
+ offset = filesize; /* a.k.a. old offset */
+ while(1) /* outer loop */
+ {
+ register unsigned char* mapped;
+
+ if (offset <= 0) { return(ZZIP_DIR_EDH_MISSING); }
+
+ /* trailer cannot be farther away than 64K from fileend */
+ if (filesize-offset > 64*1024)
+ { return(ZZIP_DIR_EDH_MISSING); }
+
+ /* the new offset shall overlap with the area after the old offset! */
+ if (USE_MMAP && io->fd.sys)
+ {
+ zzip_off_t mapoff = offset;
+ {
+ zzip_ssize_t pagesize = _zzip_getpagesize (io->fd.sys);
+ if (pagesize < ZZIP_BUFSIZ) goto non_mmap; /* an error? */
+ if (mapoff == filesize && filesize > pagesize)
+ mapoff -= pagesize;
+ if (mapoff < pagesize) {
+ maplen = (zzip_ssize_t)mapoff + pagesize; mapoff = 0;
+ } else {
+ mapoff -= pagesize; maplen = 2*pagesize;
+ if ((zzip_ssize_t)mapoff & (pagesize-1)) { /*only 1. run */
+ pagesize -= (zzip_ssize_t)mapoff & (pagesize-1);
+ mapoff += pagesize;
+ maplen -= pagesize;
+ }
+ }
+ if (mapoff + maplen > filesize) maplen = filesize - mapoff;
+ }
+
+ fd_map = _zzip_mmap(io->fd.sys, fd, mapoff, (zzip_size_t)maplen);
+ if (fd_map == MAP_FAILED) goto non_mmap;
+ mapped = (unsigned char*) fd_map; offset = mapoff; /* success */
+ HINT3("mapped *%p len=%li", fd_map, (long) maplen);
+ } else {
+ non_mmap:
+ fd_map = 0; /* have no mmap */
+ {
+ zzip_off_t pagesize = ZZIP_BUFSIZ;
+ if (offset == filesize && filesize > pagesize)
+ offset -= pagesize;
+ if (offset < pagesize) {
+ maplen = (zzip_ssize_t)offset + pagesize; offset = 0;
+ } else {
+ offset -= pagesize; maplen = 2*pagesize;
+ if ((zzip_ssize_t)offset & (pagesize-1)) { /*on 1st run*/
+ pagesize -= (zzip_ssize_t)offset & (pagesize-1);
+ offset += pagesize;
+ maplen -= pagesize;
+ }
+ }
+ if (offset + maplen > filesize) maplen = filesize - offset;
+ }
+
+ if (io->fd.seeks(fd, offset, SEEK_SET) < 0)
+ { return(ZZIP_DIR_SEEK); }
+ if (io->fd.read(fd, buf, (zzip_size_t)maplen) < maplen)
+ { return(ZZIP_DIR_READ); }
+ mapped = (unsigned char*) buf; /* success */
+ HINT5("offs=$%lx len=%li filesize=%li pagesize=%i",
+ (long)offset, (long)maplen, (long)filesize, ZZIP_BUFSIZ);
+ }
+
+ {/* now, check for the trailer-magic, hopefully near the end of file */
+ register unsigned char* end = mapped + maplen;
+ register unsigned char* tail;
+ for (tail = end-1; (tail >= mapped); tail--)
+ {
+ if ((*tail == 'P') && /* quick pre-check for trailer magic */
+ end-tail >= __sizeof(struct zzip_disk_trailer)-2 &&
+ zzip_disk_trailer_check_magic(tail))
+ {
+# ifndef ZZIP_DISK64_TRAILER
+ /* if the file-comment is not present, it happens
+ that the z_comment field often isn't either */
+ if (end-tail >= __sizeof(*trailer))
+ {
+ memcpy (trailer, tail, sizeof(*trailer));
+ }else{
+ memcpy (trailer, tail, sizeof(*trailer)-2);
+ trailer->z_comment[0] = 0;
+ trailer->z_comment[1] = 0;
+ }
+# else
+ struct zzip_disk_trailer* orig = (struct zzip_disk_trailer*) tail;
+ trailer->zz_tail = tail;
+ trailer->zz_entries = zzip_disk_trailer_localentries (orig);
+ trailer->zz_finalentries = zzip_disk_trailer_finalentries (orig);
+ trailer->zz_rootseek = zzip_disk_trailer_rootseek (orig);
+ trailer->zz_rootsize = zzip_disk_trailer_rootsize (orig);
+# endif
+
+ __fixup_rootseek (offset + tail-mapped, trailer);
+ { return(0); }
+ } else if ((*tail == 'P') &&
+ end-tail >= __sizeof(struct zzip_disk64_trailer)-2 &&
+ zzip_disk64_trailer_check_magic(tail))
+ {
+# ifndef ZZIP_DISK64_TRAILER
+ return(ZZIP_DIR_LARGEFILE);
+# else
+ struct zzip_disk64_trailer* orig = (struct zzip_disk64_trailer*) tail;
+ trailer->zz_tail = tail;
+ trailer->zz_entries = zzip_disk64_trailer_localentries (orig);
+ trailer->zz_finalentries = zzip_disk64_trailer_finalentries (orig);
+ trailer->zz_rootseek = zzip_disk64_trailer_rootseek (orig);
+ trailer->zz_rootsize = zzip_disk64_trailer_rootsize (orig);
+ { return(0); }
+# endif
+ }
+ }
+ }
+
+ if (USE_MMAP && fd_map)
+ {
+ HINT3("unmap *%p len=%li", fd_map, (long) maplen);
+ _zzip_munmap(io->fd.sys, fd_map, (zzip_size_t)maplen);
+ fd_map = 0;
+ }
+ } /*outer loop*/
+
+ cleanup:
+ if (USE_MMAP && fd_map)
+ {
+ HINT3("unmap *%p len=%li", fd_map, (long) maplen);
+ _zzip_munmap(io->fd.sys, fd_map, (zzip_size_t)maplen);
+ }
+# ifdef _LOWSTK
+ free(buf);
+# endif
+# undef return
+ return e;
+}
+
+/*
+ * making pointer alignments to values that can be handled as structures
+ * is tricky. We assume here that an align(4) is sufficient even for
+ * 64 bit machines. Note that binary operations are not usually allowed
+ * to pointer types but we do need only the lower bits in this implementation,
+ * so we can just cast the value to a long value.
+ */
+_zzip_inline char* __zzip_aligned4(char* p)
+{
+#define aligned4 __zzip_aligned4
+ p += ((long)p)&1; /* warnings about truncation of a "pointer" */
+ p += ((long)p)&2; /* to a "long int" may be safely ignored :) */
+ return p;
+}
+
+/**
+ * This function is used by => zzip_file_open, it is usually called after
+ * => __zzip_find_disk_trailer. It will parse the zip's central directory
+ * information and create a zziplib private directory table in
+ * memory.
+ */
+int
+__zzip_parse_root_directory(int fd,
+ struct _disk_trailer * trailer,
+ struct zzip_dir_hdr ** hdr_return,
+ zzip_plugin_io_t io)
+{
+ auto struct zzip_disk_entry dirent;
+ struct zzip_dir_hdr * hdr;
+ struct zzip_dir_hdr * hdr0;
+ uint16_t * p_reclen = 0;
+ unsigned long entries; /* 32bit is enough */
+ zzip_off64_t zz_offset; /* offset from start of root directory */
+ char* fd_map = 0;
+ zzip_off64_t zz_fd_gap = 0;
+ zzip_off64_t zz_entries = _disk_trailer_localentries (trailer);
+ zzip_off64_t zz_rootsize = _disk_trailer_rootsize (trailer);
+ zzip_off64_t zz_rootseek = _disk_trailer_rootseek (trailer);
+ __correct_rootseek (zz_rootseek, zz_rootsize, trailer);
+
+ hdr0 = (struct zzip_dir_hdr*) malloc(zz_rootsize);
+ if (!hdr0)
+ return ZZIP_DIRSIZE;
+ hdr = hdr0; __debug_dir_hdr (hdr);
+
+ if (USE_MMAP && io->fd.sys)
+ {
+ zz_fd_gap = zz_rootseek & (_zzip_getpagesize(io->fd.sys)-1) ;
+ HINT4(" fd_gap=%ld, mapseek=0x%lx, maplen=%ld", (long)(zz_fd_gap),
+ (long)(zz_rootseek-zz_fd_gap), (long)(zz_rootsize+zz_fd_gap));
+ fd_map = _zzip_mmap(io->fd.sys, fd,
+ zz_rootseek-zz_fd_gap, zz_rootsize+zz_fd_gap);
+ /* if mmap failed we will fallback to seek/read mode */
+ if (fd_map == MAP_FAILED) {
+ NOTE2("map failed: %s",strerror(errno));
+ fd_map=0;
+ }else{
+ HINT3("mapped *%p len=%li", fd_map, (long)(zz_rootsize+zz_fd_gap));
+ }
+ }
+
+ for (entries=zz_entries, zz_offset=0; entries; entries--)
+ {
+ register struct zzip_disk_entry * d;
+ uint16_t u_extras, u_comment, u_namlen;
+
+ if (fd_map)
+ { d = (void*)(fd_map+zz_fd_gap+zz_offset); } /* fd_map+fd_gap==u_rootseek */
+ else
+ {
+ if (io->fd.seeks(fd, zz_rootseek+zz_offset, SEEK_SET) < 0)
+ return ZZIP_DIR_SEEK;
+ if (io->fd.read(fd, &dirent, sizeof(dirent)) < __sizeof(dirent))
+ return ZZIP_DIR_READ;
+ d = &dirent;
+ }
+
+ if ((zzip_off64_t)(zz_offset+sizeof(*d)) > zz_rootsize ||
+ (zzip_off64_t)(zz_offset+sizeof(*d)) < 0)
+ { FAIL4("%li's entry stretches beyond root directory (O:%li R:%li)",
+ (long)entries, (long)(zz_offset), (long)zz_rootsize); break;}
+
+# if 0 && defined DEBUG
+ zzip_debug_xbuf ((unsigned char*) d, sizeof(*d) + 8);
+# endif
+
+ u_extras = zzip_disk_entry_get_extras (d);
+ u_comment = zzip_disk_entry_get_comment (d);
+ u_namlen = zzip_disk_entry_get_namlen (d);
+ HINT5("offset=0x%lx, size %ld, dirent *%p, hdr %p\n",
+ (long)(zz_offset+zz_rootseek), (long)zz_rootsize, d, hdr);
+
+ /* writes over the read buffer, Since the structure where data is
+ copied is smaller than the data in buffer this can be done.
+ It is important that the order of setting the fields is considered
+ when filling the structure, so that some data is not trashed in
+ first structure read.
+ at the end the whole copied list of structures is copied into
+ newly allocated buffer */
+ hdr->d_crc32 = zzip_disk_entry_get_crc32 (d);
+ hdr->d_csize = zzip_disk_entry_get_csize (d);
+ hdr->d_usize = zzip_disk_entry_get_usize (d);
+ hdr->d_off = zzip_disk_entry_get_offset (d);
+ hdr->d_compr = zzip_disk_entry_get_compr (d);
+ if (hdr->d_compr > _255) hdr->d_compr = 255;
+
+ if ((zzip_off64_t)(zz_offset+sizeof(*d) + u_namlen) > zz_rootsize ||
+ (zzip_off64_t)(zz_offset+sizeof(*d) + u_namlen) < 0)
+ { FAIL4("%li's name stretches beyond root directory (O:%li N:%li)",
+ (long)entries, (long)(zz_offset), (long)(u_namlen)); break; }
+
+ if (fd_map)
+ { memcpy(hdr->d_name, fd_map+zz_fd_gap + zz_offset+sizeof(*d), u_namlen); }
+ else { io->fd.read(fd, hdr->d_name, u_namlen); }
+ hdr->d_name[u_namlen] = '\0';
+ hdr->d_namlen = u_namlen;
+
+ /* update offset by the total length of this entry -> next entry */
+ zz_offset += sizeof(*d) + u_namlen + u_extras + u_comment;
+
+ if (zz_offset > zz_rootsize)
+ { FAIL3("%li's entry stretches beyond root directory (O:%li)",
+ (long)entries, (long)(zz_offset)); entries--; break; }
+
+ HINT5("file %ld { compr=%d crc32=$%x offset=%d",
+ (long)entries, hdr->d_compr, hdr->d_crc32, hdr->d_off);
+ HINT5("csize=%d usize=%d namlen=%d extras=%d",
+ hdr->d_csize, hdr->d_usize, u_namlen, u_extras);
+ HINT5("comment=%d name='%s' %s <sizeof %d> } ",
+ u_comment, hdr->d_name, "",(int) sizeof(*d));
+
+ p_reclen = &hdr->d_reclen;
+
+ { register char* p = (char*) hdr;
+ register char* q = aligned4 (p + sizeof(*hdr) + u_namlen + 1);
+ *p_reclen = (uint16_t)(q - p);
+ hdr = (struct zzip_dir_hdr*) q;
+ }
+ }/*for*/
+
+ if (USE_MMAP && fd_map)
+ {
+ HINT3("unmap *%p len=%li", fd_map, (long)(zz_rootsize+zz_fd_gap));
+ _zzip_munmap(io->fd.sys, fd_map, zz_rootsize+zz_fd_gap);
+ }
+
+ if (p_reclen)
+ {
+ *p_reclen = 0; /* mark end of list */
+
+ if (hdr_return)
+ *hdr_return = hdr0;
+ } /* else zero (sane) entries */
+ return (entries ? ZZIP_CORRUPTED : 0);
+}
+
+/* ------------------------- high-level interface ------------------------- */
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static zzip_strings_t* zzip_get_default_ext(void)
+{
+ static zzip_strings_t ext [] =
+ {
+ ".zip", ".ZIP", /* common extension */
+# ifdef ZZIP_USE_ZIPLIKES
+ ".pk3", ".PK3", /* ID Software's Quake3 zipfiles */
+ ".jar", ".JAR", /* Java zipfiles */
+# endif
+ 0
+ };
+
+ return ext;
+}
+
+/**
+ * allocate a new ZZIP_DIR handle and do basic
+ * initializations before usage by => zzip_dir_fdopen
+ * => zzip_dir_open => zzip_file_open or through
+ * => zzip_open
+ * (ext==null flags uses { ".zip" , ".ZIP" } )
+ * (io ==null flags use of posix io defaults)
+ */
+ZZIP_DIR*
+zzip_dir_alloc_ext_io (zzip_strings_t* ext, const zzip_plugin_io_t io)
+{
+ ZZIP_DIR* dir;
+ if ((dir = (ZZIP_DIR *)calloc(1, sizeof(*dir))) == NULL)
+ return 0;
+
+ /* dir->fileext is currently unused - so what, still initialize it */
+ dir->fileext = ext ? ext : zzip_get_default_ext();
+ dir->io = io ? io : zzip_get_default_io ();
+ return dir;
+}
+
+/** => zzip_dir_alloc_ext_io
+ * this function is obsolete - it was generally used for implementation
+ * and exported to let other code build on it. It is now advised to
+ * use => zzip_dir_alloc_ext_io now on explicitly, just set that second
+ * argument to zero to achieve the same functionality as the old style.
+ */
+ZZIP_DIR*
+zzip_dir_alloc (zzip_strings_t* fileext)
+{
+ return zzip_dir_alloc_ext_io (fileext, 0);
+}
+
+/**
+ * will free the zzip_dir handle unless there are still
+ * zzip_files attached (that may use its cache buffer).
+ * This is the inverse of => zzip_dir_alloc , and both
+ * are helper functions used implicitly in other zzipcalls
+ * e.g. => zzip_dir_close = zzip_close
+ *
+ * returns zero on sucess
+ * returns the refcount when files are attached.
+ */
+int
+zzip_dir_free(ZZIP_DIR * dir)
+{
+ if (dir->refcount)
+ return (dir->refcount); /* still open files attached */
+
+ if (dir->fd >= 0) dir->io->fd.close(dir->fd);
+ if (dir->hdr0) free(dir->hdr0);
+ if (dir->cache.fp) free(dir->cache.fp);
+ if (dir->cache.buf32k) free(dir->cache.buf32k);
+ if (dir->realname) free(dir->realname);
+ free(dir);
+ return 0;
+}
+
+/** => zzip_dir_free
+ * It will also => free(2) the => ZZIP_DIR-handle given.
+ * the counterpart for => zzip_dir_open
+ * see also => zzip_dir_free
+ */
+int
+zzip_dir_close(ZZIP_DIR * dir)
+{
+ dir->refcount &=~ 0x10000000; /* explicit dir close */
+ return zzip_dir_free(dir);
+}
+
+/**
+ * used by the => zzip_dir_open and zzip_opendir(2) call. Opens the
+ * zip-archive as specified with the fd which points to an
+ * already openend file. This function then search and parse
+ * the zip's central directory.
+ *
+ * NOTE: refcount is zero, so an _open/_close pair will also delete
+ * this _dirhandle
+ */
+ZZIP_DIR *
+zzip_dir_fdopen(int fd, zzip_error_t * errcode_p)
+{
+ return zzip_dir_fdopen_ext_io(fd, errcode_p, 0, 0);
+}
+
+static zzip_error_t __zzip_dir_parse (ZZIP_DIR* dir); /* forward */
+
+/** => zzip_dir_fdopen
+ * this function uses explicit ext and io instead of the internal
+ * defaults, setting these to zero is equivalent to => zzip_dir_fdopen
+ */
+ZZIP_DIR *
+zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errcode_p,
+ zzip_strings_t* ext, const zzip_plugin_io_t io)
+{
+ zzip_error_t rv;
+ ZZIP_DIR * dir;
+
+ if ((dir = zzip_dir_alloc_ext_io (ext, io)) == NULL)
+ { rv = ZZIP_OUTOFMEM; goto error; }
+
+ dir->fd = fd;
+ if ((rv = __zzip_dir_parse (dir)))
+ goto error;
+
+ dir->hdr = dir->hdr0;
+ dir->refcount |= 0x10000000;
+
+ if (errcode_p) *errcode_p = rv;
+ return dir;
+error:
+ if (dir) zzip_dir_free(dir);
+ if (errcode_p) *errcode_p = rv;
+ return NULL;
+}
+
+static zzip_error_t
+__zzip_dir_parse (ZZIP_DIR* dir)
+{
+ zzip_error_t rv;
+ zzip_off_t filesize;
+ struct _disk_trailer trailer;
+ /* if (! dir || dir->fd < 0)
+ * { rv = EINVAL; goto error; }
+ */
+
+ HINT2("------------------ fd=%i", (int) dir->fd);
+ if ((filesize = dir->io->fd.filesize(dir->fd)) < 0)
+ { rv = ZZIP_DIR_STAT; goto error; }
+
+ HINT2("------------------ filesize=%ld", (long) filesize);
+ if ((rv = __zzip_fetch_disk_trailer(dir->fd, filesize, &trailer,
+ dir->io)) != 0)
+ { goto error; }
+
+ HINT5("directory = { entries= %ld/%ld, size= %ld, seek= %ld } ",
+ (long) _disk_trailer_localentries (&trailer),
+ (long) _disk_trailer_finalentries (&trailer),
+ (long) _disk_trailer_rootsize (&trailer),
+ (long) _disk_trailer_rootseek (&trailer));
+
+ if ( (rv = __zzip_parse_root_directory(dir->fd, &trailer, &dir->hdr0,
+ dir->io)) != 0)
+ { goto error; }
+ error:
+ return rv;
+}
+
+/**
+ * will attach a .zip extension and tries to open it
+ * the with => open(2). This is a helper function for
+ * => zzip_dir_open, => zzip_opendir and => zzip_open.
+ */
+int
+__zzip_try_open(zzip_char_t* filename, int filemode,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ auto char file[PATH_MAX];
+ int fd;
+ zzip_size_t len = strlen (filename);
+
+ if (len+4 >= PATH_MAX) return -1;
+ memcpy(file, filename, len+1);
+
+ if (!io) io = zzip_get_default_io();
+ if (!ext) ext = zzip_get_default_ext();
+
+ for ( ; *ext ; ++ext)
+ {
+ strcpy (file+len, *ext);
+ fd = io->fd.open(file, filemode);
+ if (fd != -1) return fd;
+ }
+ return -1;
+}
+
+/**
+ * Opens the zip-archive (if available).
+ * the two ext_io arguments will default to use posix io and
+ * a set of default fileext that can atleast add .zip ext itself.
+ */
+ZZIP_DIR*
+zzip_dir_open(zzip_char_t* filename, zzip_error_t* e)
+{
+ return zzip_dir_open_ext_io (filename, e, 0, 0);
+}
+
+/** => zzip_dir_open
+ * this function uses explicit ext and io instead of the internal
+ * defaults. Setting these to zero is equivalent to => zzip_dir_open
+ */
+ZZIP_DIR*
+zzip_dir_open_ext_io(zzip_char_t* filename, zzip_error_t* e,
+ zzip_strings_t* ext, zzip_plugin_io_t io)
+{
+ int fd;
+
+ if (!io) io = zzip_get_default_io();
+ if (!ext) ext = zzip_get_default_ext();
+
+ fd = io->fd.open(filename, O_RDONLY|O_BINARY);
+ if (fd != -1)
+ { return zzip_dir_fdopen_ext_io(fd, e, ext, io); }
+ else
+ {
+ fd = __zzip_try_open(filename, O_RDONLY|O_BINARY, ext, io);
+ if (fd != -1)
+ { return zzip_dir_fdopen_ext_io(fd, e, ext, io); }
+ else
+ {
+ if (e) { *e = ZZIP_DIR_OPEN; }
+ return 0;
+ }
+ }
+}
+
+/** => zzip_dir_open
+ * fills the dirent-argument with the values and
+ * increments the read-pointer of the dir-argument.
+ *
+ * returns 0 if there no entry (anymore).
+ */
+int
+zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * d )
+{
+ if (! dir || ! dir->hdr || ! d) return 0;
+
+ d->d_compr = dir->hdr->d_compr;
+ d->d_csize = dir->hdr->d_csize;
+ d->st_size = dir->hdr->d_usize;
+ d->d_name = dir->hdr->d_name;
+
+ if (! dir->hdr->d_reclen)
+ { dir->hdr = 0; }
+ else
+ { dir->hdr = (struct zzip_dir_hdr *)((char *)dir->hdr + dir->hdr->d_reclen); }
+
+ return 1;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zzip.h b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zzip.h
new file mode 100644
index 00000000000..eecc4737af1
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zzip.h
@@ -0,0 +1,323 @@
+/*
+ * Author:
+ * Guido Draheim <guidod@gmx.de>
+ * Tomi Ollila <Tomi.Ollila@iki.fi>
+ *
+ * Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
+ * All rights reserved,
+ * usage allowed under the restrictions of the
+ * Lesser GNU General Public License
+ * or alternatively the restrictions
+ * of the Mozilla Public License 1.1
+ *
+ * if you see "unknown symbol" errors, check first that `-I ..` is part of
+ * your compiler options - a special hint to VC/IDE users who tend to make up
+ * their own workspace files. All includes look like #include <zzip|*.h>, so
+ * you need to add an include path to the dir containing (!!) the ./zzip/ dir
+ */
+
+#ifndef _ZZIP_ZZIP_H /* zziplib.h */
+#define _ZZIP_ZZIP_H
+
+#include <zzip/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* the zzip_error_t is also used to pass back ZLIB errors... */
+#define ZZIP_ERROR -4096
+
+typedef enum
+{
+ ZZIP_NO_ERROR = 0, /* no error, may be used if user sets it. */
+ ZZIP_OUTOFMEM = ZZIP_ERROR-20, /* out of memory */
+ ZZIP_DIR_OPEN = ZZIP_ERROR-21, /* failed to open zipfile, see errno for details */
+ ZZIP_DIR_STAT = ZZIP_ERROR-22, /* failed to fstat zipfile, see errno for details */
+ ZZIP_DIR_SEEK = ZZIP_ERROR-23, /* failed to lseek zipfile, see errno for details */
+ ZZIP_DIR_READ = ZZIP_ERROR-24, /* failed to read zipfile, see errno for details */
+ ZZIP_DIR_TOO_SHORT = ZZIP_ERROR-25,
+ ZZIP_DIR_EDH_MISSING = ZZIP_ERROR-26,
+ ZZIP_DIRSIZE = ZZIP_ERROR-27,
+ ZZIP_ENOENT = ZZIP_ERROR-28,
+ ZZIP_UNSUPP_COMPR = ZZIP_ERROR-29,
+ ZZIP_CORRUPTED = ZZIP_ERROR-31,
+ ZZIP_UNDEF = ZZIP_ERROR-32,
+ ZZIP_DIR_LARGEFILE = ZZIP_ERROR-33
+} zzip_error_t;
+
+/*
+ * zzip_open flags.
+ */
+#define ZZIP_CASEINSENSITIVE O_APPEND /* do not use anymore. use CASLESS */
+#define ZZIP_IGNOREPATH O_TRUNC /* do not use anymore. use NOPATHS */
+#define ZZIP_EXTRAFLAGS (ZZIP_CASEINSENSITIVE|ZZIP_IGNOREPATH)
+
+/* zzip_open_ext_io o_modes flags : new style. use these from now on! */
+#define ZZIP_CASELESS (1<<12) /* ignore filename case inside zips */
+#define ZZIP_NOPATHS (1<<13) /* ignore subdir paths, just filename*/
+#define ZZIP_PREFERZIP (1<<14) /* try first zipped file, then real*/
+#define ZZIP_ONLYZIP (1<<16) /* try _only_ zipped file, skip real*/
+#define ZZIP_FACTORY (1<<17) /* old file handle is not closed */
+#define ZZIP_ALLOWREAL (1<<18) /* real files use default_io (magic) */
+#define ZZIP_THREADED (1<<19) /* try to be safe for multithreading */
+
+/*
+ * zzip largefile renames
+ */
+#ifdef ZZIP_LARGEFILE_RENAME
+#define zzip_telldir zzip_telldir64
+#define zzip_seekdir zzip_seekdir64
+#endif
+
+/*
+ * zzip typedefs
+ */
+/* zzip_strings_t ext[] = { ".zip", ".jar", ".pk3", 0 } */
+typedef char _zzip_const * _zzip_const zzip_strings_t;
+typedef char _zzip_const zzip_char_t;
+typedef struct zzip_dir ZZIP_DIR;
+typedef struct zzip_file ZZIP_FILE;
+typedef struct zzip_dirent ZZIP_DIRENT;
+typedef struct zzip_dirent ZZIP_STAT;
+
+struct zzip_dirent
+{
+ int d_compr; /* compression method */
+ int d_csize; /* compressed size */
+ int st_size; /* file size / decompressed size */
+ char * d_name; /* file name / strdupped name */
+};
+
+/*
+ * Getting error strings
+ * zzip/err.c
+ */
+_zzip_export /* error in _opendir : */
+zzip_char_t* zzip_strerror(int errcode);
+_zzip_export /* error in other functions : */
+zzip_char_t* zzip_strerror_of(ZZIP_DIR * dir);
+_zzip_export /* error mapped to errno.h defines : */
+int zzip_errno(int errcode);
+
+
+/*
+ * Functions to grab information from ZZIP_DIR/ZZIP_FILE structure
+ * (if ever needed)
+ * zzip/info.c
+ */
+_zzip_export
+int zzip_error(ZZIP_DIR * dir);
+_zzip_export
+void zzip_seterror(ZZIP_DIR * dir, int errcode);
+_zzip_export
+zzip_char_t* zzip_compr_str(int compr);
+
+_zzip_export
+ZZIP_DIR * zzip_dirhandle(ZZIP_FILE * fp);
+_zzip_export
+int zzip_dirfd(ZZIP_DIR * dir);
+_zzip_export
+int zzip_dir_real(ZZIP_DIR * dir);
+_zzip_export
+int zzip_file_real(ZZIP_FILE * fp);
+_zzip_export
+void* zzip_realdir(ZZIP_DIR * dir);
+_zzip_export
+int zzip_realfd(ZZIP_FILE * fp);
+
+/*
+ * zip handle management
+ * zzip/zip.c
+ */
+_zzip_export
+ZZIP_DIR * zzip_dir_alloc(zzip_strings_t* fileext);
+_zzip_export
+int zzip_dir_free(ZZIP_DIR *);
+
+/*
+ * Opening/closing a zip archive
+ * zzip-zip.c
+ */
+_zzip_export
+ZZIP_DIR * zzip_dir_fdopen(int fd, zzip_error_t * errcode_p);
+_zzip_export
+ZZIP_DIR * zzip_dir_open(zzip_char_t* filename, zzip_error_t * errcode_p);
+_zzip_export
+int zzip_dir_close(ZZIP_DIR * dir);
+_zzip_export
+int zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * dirent);
+
+
+/*
+ * Scanning files in zip archive
+ * zzip/dir.c
+ * zzip/zip.c
+ */
+_zzip_export
+ZZIP_DIR * zzip_opendir(zzip_char_t* filename);
+_zzip_export
+int zzip_closedir(ZZIP_DIR * dir);
+_zzip_export
+ZZIP_DIRENT * zzip_readdir(ZZIP_DIR * dir);
+_zzip_export
+void zzip_rewinddir(ZZIP_DIR * dir);
+_zzip_export
+zzip_off_t zzip_telldir(ZZIP_DIR * dir);
+_zzip_export
+void zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset);
+
+/*
+ * 'opening', 'closing' and reading invidual files in zip archive.
+ * zzip/file.c
+ */
+_zzip_export
+ZZIP_FILE * zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int flags);
+_zzip_export
+int zzip_file_close(ZZIP_FILE * fp);
+_zzip_export
+zzip_ssize_t zzip_file_read(ZZIP_FILE * fp, char* buf, zzip_size_t len);
+
+_zzip_export
+ZZIP_FILE * zzip_open(zzip_char_t* name, int flags);
+_zzip_export
+int zzip_close(ZZIP_FILE * fp);
+_zzip_export
+zzip_ssize_t zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len);
+
+/*
+ * the stdc variant to open/read/close files. - Take note of the freopen()
+ * call as it may reuse an existing preparsed copy of a zip central directory
+ */
+_zzip_export
+ZZIP_FILE* zzip_freopen(zzip_char_t* name, zzip_char_t* mode, ZZIP_FILE*);
+_zzip_export
+ZZIP_FILE* zzip_fopen(zzip_char_t* name, zzip_char_t* mode);
+_zzip_export
+zzip_size_t zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb,
+ ZZIP_FILE * file);
+_zzip_export
+int zzip_fclose(ZZIP_FILE * fp);
+
+/*
+ * seek and tell functions
+ */
+_zzip_export
+int zzip_rewind(ZZIP_FILE *fp);
+_zzip_export
+zzip_off_t zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence);
+_zzip_export
+zzip_off_t zzip_tell(ZZIP_FILE * fp);
+
+/*
+ * reading info of a single file
+ * zzip/stat.c
+ */
+_zzip_export
+int zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name,
+ ZZIP_STAT * zs, int flags);
+_zzip_export
+int zzip_file_stat(ZZIP_FILE * fp, ZZIP_STAT * zs);
+_zzip_export
+int zzip_fstat(ZZIP_FILE * fp, ZZIP_STAT * zs);
+
+#ifdef ZZIP_LARGEFILE_RENAME
+#define zzip_open_shared_io zzip_open_shared_io64
+#define zzip_open_ext_io zzip_open_ext_io64
+#define zzip_opendir_ext_io zzip_opendir_ext_io64
+#define zzip_dir_open_ext_io zzip_dir_open_ext_io64
+#define zzip_plugin_io_t zzip_plugin_io64_t
+#endif
+
+/*
+ * all ext_io functions can be called with a default of ext/io == zero/zero
+ * which will default to a ".zip" extension and posix io of the system.
+ */
+typedef union _zzip_plugin_io _zzip_const * zzip_plugin_io_t;
+
+_zzip_export
+ZZIP_FILE * zzip_open_shared_io(ZZIP_FILE* stream,
+ zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+_zzip_export
+ZZIP_FILE * zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+_zzip_export
+ZZIP_DIR * zzip_opendir_ext_io(zzip_char_t* name, int o_modes,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+_zzip_export
+ZZIP_DIR * zzip_dir_open_ext_io(zzip_char_t* filename,
+ zzip_error_t* errcode_p,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+
+/* zzip_file_open_ext_io => zzip_dir_open_ext_io + zzip_file_open */
+
+#if defined _ZZIP_WRITE_SOURCE
+/* ........................................................................
+ * write support is not yet implemented
+ * zzip/write.c
+ */
+#define ZZIP_NO_CREAT 1
+
+ZZIP_DIR* zzip_dir_creat_ext_io(zzip_char_t* name, int o_mode,
+ zzip_strings_t* ext, zzip_plugin_io_t io);
+ZZIP_DIR* zzip_dir_creat(zzip_char_t* name, int o_mode);
+int zzip_file_mkdir(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
+ZZIP_FILE* zzip_file_creat(ZZIP_DIR* dir, zzip_char_t* name, int o_mode);
+zzip_ssize_t zzip_file_write(ZZIP_FILE* file,
+ const void* ptr, zzip_size_t len);
+
+ZZIP_DIR* zzip_createdir(zzip_char_t* name, int o_mode);
+zzip_ssize_t zzip_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len);
+zzip_size_t zzip_fwrite(const void* ptr, zzip_size_t len,
+ zzip_size_t multiply, ZZIP_FILE* file);
+#ifndef zzip_savefile
+#define zzip_savefile 0
+#define zzip_savefile_is_null
+#endif
+
+#ifdef _ZZIP_NO_INLINE
+#define zzip_mkdir(_name_,_mode_) \
+ zzip_file_mkdir((zzip_savefile),(_name_),(_mode_))
+#define zzip_creat(_name_,_mode_) \
+ zzip_file_creat((zzip_savefile),(_name_),(_mode_))
+#define zzip_sync() \
+ { zzip_closedir((zzip_savefile)); (zzip_savefile) = 0; }
+#define zzip_start(_name_,_mode_,_ext_) \
+ { if ((zzip_savefile)) zzip_closedir((zzip_savefile));
+ zzip_savefile = zzip_dir_creat(_name_, _mode_,_ext_); }
+
+#else
+
+_zzip_inline static int zzip_mkdir(zzip_char_t* name, int o_mode)
+{ return zzip_file_mkdir(zzip_savefile, name, o_mode); }
+_zzip_inline static ZZIP_FILE* zzip_creat(zzip_char_t* name, int o_mode)
+{ return zzip_file_creat(zzip_savefile, name, o_mode); }
+
+#ifndef zzip_savefile_is_null
+_zzip_inline static void zzip_sync(void)
+{ zzip_closedir(zzip_savefile); zzip_savefile = 0; }
+_zzip_inline static void zzip_mkfifo(zzip_char_t* name, int o_mode)
+{ if ((zzip_savefile)) zzip_closedir (zzip_savefile);
+ zzip_savefile = zzip_createdir(_name_,_mode_); }
+#else
+_zzip_inline static void zzip_sync(void) {}
+_zzip_inline static void zzip_mkfifo(zzip_char_t* name, int o_mode) {}
+#endif
+#endif /* _ZZIP_NO_INLINE */
+#endif /* _ZZIP_WRITE_SOURCE */
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* _ZZIPLIB_H */
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zziplib.wpj b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zziplib.wpj
new file mode 100755
index 00000000000..e371b9b38bb
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.58/zzip/zziplib.wpj
@@ -0,0 +1,103 @@
+40
+projectIdent
+0
+VpeMain
+1
+WRect
+0
+0
+7680
+10240
+2
+MProject
+3
+MCommand
+0
+4
+MCommand
+0
+4
+5
+WFileName
+11
+zziplib.tgt
+6
+WFileName
+9
+zzcat.tgt
+7
+WFileName
+9
+zzdir.tgt
+8
+WFileName
+12
+zziptest.tgt
+9
+WVList
+4
+10
+VComponent
+11
+WRect
+0
+0
+5670
+4215
+0
+0
+12
+WFileName
+11
+zziplib.tgt
+0
+0
+13
+VComponent
+14
+WRect
+678
+665
+5670
+4215
+0
+0
+15
+WFileName
+9
+zzcat.tgt
+0
+0
+16
+VComponent
+17
+WRect
+1868
+1467
+5670
+4215
+0
+0
+18
+WFileName
+9
+zzdir.tgt
+0
+0
+19
+VComponent
+20
+WRect
+1356
+1348
+5670
+4215
+0
+0
+21
+WFileName
+12
+zziptest.tgt
+0
+0
+19