aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile.am25
-rw-r--r--contrib/cleanup/tab2spaces.sh2
-rw-r--r--contrib/cleanup/whitespace.sh2
-rw-r--r--contrib/extractor/CMakeLists.txt26
-rw-r--r--contrib/extractor/Makefile471
-rw-r--r--contrib/extractor/README.linux12
-rw-r--r--contrib/extractor/System.cpp832
-rw-r--r--contrib/extractor/VC71_ad.vcproj10
-rw-r--r--contrib/extractor/VC80_ad.vcproj10
-rw-r--r--contrib/extractor/VC90_ad.vcproj10
-rw-r--r--contrib/extractor/ad.exebin158720 -> 163840 bytes
-rw-r--r--contrib/extractor/adt.cpp539
-rw-r--r--contrib/extractor/adt.h141
-rw-r--r--contrib/extractor/dbcfile.cpp31
-rw-r--r--contrib/extractor/dbcfile.h2
-rw-r--r--contrib/extractor/libmpq/CMakeLists.txt13
-rw-r--r--contrib/extractor/libmpq/Makefile17
-rw-r--r--contrib/extractor/libmpq/mpq.cpp2
-rw-r--r--contrib/extractor/loadlib/CMakeLists.txt13
-rw-r--r--contrib/extractor/loadlib/adt.cpp131
-rw-r--r--contrib/extractor/loadlib/adt.h289
-rw-r--r--contrib/extractor/loadlib/loadlib.cpp64
-rw-r--r--contrib/extractor/loadlib/loadlib.h57
-rw-r--r--contrib/extractor/loadlib/wdt.cpp62
-rw-r--r--contrib/extractor/loadlib/wdt.h68
-rw-r--r--contrib/extractor/mpq_libmpq.h2
-rw-r--r--contrib/mysql_to_pgsql/CMakeLists.txt21
-rw-r--r--contrib/mysql_to_pgsql/README14
-rw-r--r--contrib/mysql_to_pgsql/cmake/FindMySQL.cmake74
-rw-r--r--contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake82
-rw-r--r--contrib/mysql_to_pgsql/src/defines.h184
-rw-r--r--contrib/mysql_to_pgsql/src/main.cpp339
-rw-r--r--contrib/vmap_assembler/vmap_assembler.cpp58
-rw-r--r--contrib/vmap_debugger/ModelContainerView.cpp4
-rw-r--r--contrib/vmap_extract_assembler_bin/vmap_assembler.exebin184320 -> 295424 bytes
-rw-r--r--contrib/vmap_extract_assembler_bin/vmapextract_v2.exebin233472 -> 223232 bytes
-rw-r--r--contrib/vmap_extractor_v2/doc/MoPaQ_0.9.txt318
-rw-r--r--contrib/vmap_extractor_v2/doc/MoPaQ_1.0.txt421
-rw-r--r--contrib/vmap_extractor_v2/stormdll/StormDll.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormdll/StormDll.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp137
-rw-r--r--contrib/vmap_extractor_v2/stormlib/Makefile58
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SCommon.cpp31
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SCommon.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SCompression.cpp37
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp9
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp15
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp9
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp15
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp17
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp29
-rw-r--r--contrib/vmap_extractor_v2/stormlib/SListFile.cpp17
-rw-r--r--contrib/vmap_extractor_v2/stormlib/StormDll.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/StormLib.h47
-rw-r--r--contrib/vmap_extractor_v2/stormlib/StormPort.h49
-rw-r--r--contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp3
-rw-r--r--contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp131
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/Makefile205
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c132
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c306
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c56
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c234
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h173
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h33
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/compress.c95
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c10
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c56
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c18
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c114
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c10
-rw-r--r--contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp447
-rw-r--r--contrib/vmap_extractor_v2/stormlib/huffman/huff.h53
-rw-r--r--contrib/vmap_extractor_v2/stormlib/pklib/explode.c20
-rw-r--r--contrib/vmap_extractor_v2/stormlib/pklib/implode.c18
-rw-r--r--contrib/vmap_extractor_v2/stormlib/pklib/pklib.h31
-rw-r--r--contrib/vmap_extractor_v2/stormlib/wave/wave.cpp15
-rw-r--r--contrib/vmap_extractor_v2/stormlib/wave/wave.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/Makefile175
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/Makefile.in175
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/adler32.c6
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/compress.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/configure212
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c10
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp13
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h5
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp7
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/Makefile25
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c562
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c116
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c1532
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h103
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c38
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h59
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/Makefile14
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c460
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/crc32.c4
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/deflate.c208
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/deflate.h7
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/example.c80
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/gzio.c310
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infblock.c4
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infblock.h3
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h3
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inffast.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inffast.h3
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inflate.c4
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h3
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infutil.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/infutil.h5
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/maketree.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c20
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/trees.c78
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/trees.h1
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/zconf.h59
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/zlib.h31
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/zutil.c2
-rw-r--r--contrib/vmap_extractor_v2/stormlib/zlib/zutil.h3
-rw-r--r--contrib/vmap_extractor_v2/stormlibdll/DllMain.c2
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/adtfile.cpp68
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/adtfile.h56
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp7
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/dbcfile.h1
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/model.cpp156
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/model.h37
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/modelheaders.h286
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/mpq.cpp80
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/mpq.h28
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/vec3d.h15
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp162
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp19
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/wdtfile.h1
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/wmo.cpp149
-rw-r--r--contrib/vmap_extractor_v2/vmapextract/wmo.h16
145 files changed, 6050 insertions, 6379 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
new file mode 100644
index 00000000000..d89f48418db
--- /dev/null
+++ b/contrib/Makefile.am
@@ -0,0 +1,25 @@
+# Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+#
+# Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+## Process this file with automake to produce Makefile.in
+
+## Sub-directories to parse
+SUBDIRS = extractor
+
+## Additional files to include when running 'make dist'
+# Nothing yet.
diff --git a/contrib/cleanup/tab2spaces.sh b/contrib/cleanup/tab2spaces.sh
new file mode 100644
index 00000000000..1022be7905c
--- /dev/null
+++ b/contrib/cleanup/tab2spaces.sh
@@ -0,0 +1,2 @@
+# Be sure to specify files instead of * when running the script.
+perl -p -i -e "s/\t/ /g" *
diff --git a/contrib/cleanup/whitespace.sh b/contrib/cleanup/whitespace.sh
new file mode 100644
index 00000000000..a351e25359b
--- /dev/null
+++ b/contrib/cleanup/whitespace.sh
@@ -0,0 +1,2 @@
+# Be sure to specify files instead of * when running the script.
+perl -p -i -e "s/ +$//g" *
diff --git a/contrib/extractor/CMakeLists.txt b/contrib/extractor/CMakeLists.txt
new file mode 100644
index 00000000000..9052903b1ed
--- /dev/null
+++ b/contrib/extractor/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright (C) 2005-2009 MaNGOS project <http://getmangos.com/>
+#
+# This file is free software; as a special exception the author 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.
+
+cmake_minimum_required (VERSION 2.6)
+project (MANGOS_MAP_EXTRACTOR)
+
+add_subdirectory (libmpq)
+add_subdirectory (loadlib)
+
+include_directories (${MANGOS_MAP_EXTRACTOR_SOURCE_DIR}/libmpq)
+include_directories (${MANGOS_MAP_EXTRACTOR_SOURCE_DIR}/loadlib)
+
+link_directories (${MANGOS_MAP_EXTRACTOR_SOURCE_DIR}/libmpq)
+link_directories (${MANGOS_MAP_EXTRACTOR_SOURCE_DIR}/loadlib)
+
+add_executable (ad dbcfile.cpp mpq_libmpq.cpp System.cpp)
+
+target_link_libraries (ad libmpq)
+target_link_libraries (ad loadlib)
diff --git a/contrib/extractor/Makefile b/contrib/extractor/Makefile
deleted file mode 100644
index 55eb35f336a..00000000000
--- a/contrib/extractor/Makefile
+++ /dev/null
@@ -1,471 +0,0 @@
-# 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.
-
-
-# Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
-#
-# Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-SOURCES = $(ad_SOURCES)
-
-srcdir = .
-top_srcdir = .
-
-pkgdatadir = $(datadir)/mangos
-pkglibdir = $(libdir)/mangos
-pkgincludedir = $(includedir)/mangos
-top_builddir = ../..
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = /usr/bin/ginstall -c
-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 = i686-pc-linux-gnu
-host_triplet = i686-pc-linux-gnu
-bin_PROGRAMS = ad$(EXEEXT)
-subdir = contrib/extractor
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS)
-am_ad_OBJECTS = System.$(OBJEXT) adt.$(OBJEXT) dbcfile.$(OBJEXT) \
- mpq_libmpq.$(OBJEXT)
-ad_OBJECTS = $(am_ad_OBJECTS)
-ad_DEPENDENCIES =
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CXXFLAGS) $(CXXFLAGS)
-CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-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 = $(ad_SOURCES)
-DIST_SOURCES = $(ad_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL =
-ALLOCA =
-AMDEP_FALSE = #
-AMDEP_TRUE =
-AMTAR = ${SHELL} /home/wow/MaNGOS/trunk/missing --run tar
-AR = ar
-AUTOCONF = ${SHELL} /home/wow/MaNGOS/trunk/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/wow/MaNGOS/trunk/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/wow/MaNGOS/trunk/missing --run automake-1.9
-AWK = gawk
-CC = gcc
-CCDEPMODE = depmode=gcc3
-CFLAGS = -g -O3
-COMPILER_OPTIONS = -g -O3
-CPP = gcc -E
-CPPFLAGS =
-CXX = g++
-CXXCPP = g++ -E
-CXXDEPMODE = depmode=gcc3
-CXXFLAGS = -g -O3
-CYGPATH_W = echo
-DEFS = -DHAVE_CONFIG_H
-DEPDIR = .deps
-ECHO = echo
-ECHO_C =
-ECHO_N = -n
-ECHO_T =
-EGREP = grep -E
-EXEEXT =
-EXTRA_COMPILER_OPTIONS =
-EXTRA_LINKER_OPTIONS =
-F77 =
-FFLAGS =
-INCLUDES = -I$(srcdir)
-INSTALL_DATA = ${INSTALL} -m 644
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_SCRIPT = ${INSTALL}
-INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
-LDFLAGS =
-LIBOBJS =
-LIBS = -lz -lpthread
-LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LINKER_OPTIONS = -static
-LN_S = ln -s
-LTLIBOBJS =
-LT_AGE = 2
-LT_CURRENT = 2
-LT_RELEASE = 2.3.2
-LT_REVISION = 3
-MAINT = #
-MAINTAINER_MODE_FALSE =
-MAINTAINER_MODE_TRUE = #
-MAKEINFO =
-MANGOSD_CONFIG = /home/wow/server/etc/mangosd.conf
-MANGOSD_CONFIGDIR = /home/wow/server/etc
-MANGOSD_DATA = /home/wow/server/share/mangos
-OBJEXT = o
-PACKAGE = mangos
-PACKAGE_BUGREPORT = http://www.mangosproject.org/
-PACKAGE_NAME = MaNGOS
-PACKAGE_STRING = MaNGOS 0.2-SVN
-PACKAGE_TARNAME = mangos
-PACKAGE_VERSION = 0.2-SVN
-PATH_SEPARATOR = :
-RANLIB = ranlib
-SET_MAKE =
-SHELL = /bin/sh
-STRIP = strip
-VERSION = 0.2-SVN
-ac_ct_AR = ar
-ac_ct_CC = gcc
-ac_ct_CXX = g++
-ac_ct_F77 =
-ac_ct_RANLIB = ranlib
-ac_ct_STRIP = strip
-am__fastdepCC_FALSE = #
-am__fastdepCC_TRUE =
-am__fastdepCXX_FALSE = #
-am__fastdepCXX_TRUE =
-am__include = include
-am__leading_dot = .
-am__quote =
-am__tar = ${AMTAR} chof - "$$tardir"
-am__untar = ${AMTAR} xf -
-bindir = ${exec_prefix}/bin
-build = i686-pc-linux-gnu
-build_alias =
-build_cpu = i686
-build_os = linux-gnu
-build_vendor = pc
-datadir = ${prefix}/share
-exec_prefix = ${prefix}
-host = i686-pc-linux-gnu
-host_alias =
-host_cpu = i686
-host_os = linux-gnu
-host_vendor = pc
-includedir = ${prefix}/include
-infodir = ${prefix}/info
-install_sh = /home/wow/MaNGOS/trunk/install-sh
-libdir = ${exec_prefix}/lib
-libexecdir = ${exec_prefix}/libexec
-localstatedir = ${prefix}/var
-mandir = ${prefix}/man
-mkdir_p = mkdir -p --
-oldincludedir = /usr/include
-prefix = /home/wow/server
-program_transform_name = s,x,x,
-sbindir = ${exec_prefix}/sbin
-sharedstatedir = ${prefix}/com
-
-# use our configured sysconfdir
-sysconfdir = /home/wow/server/etc
-target_alias =
-ad_SOURCES = \
- System.cpp \
- adt.h \
- adt.cpp \
- dbcfile.cpp \
- dbcfile.h \
- mpq_libmpq.cpp \
- mpq_libmpq.h
-
-ad_LDADD = libmpq/libmpq.a
-add_LDFLAGS = -L$(srcdir) -L$(srcdir)/libmpq
-
-all: create-dir all-am
-
-.SUFFIXES:
-.SUFFIXES: .cpp .lo .o .obj
-
-.PRECIOUS: Makefile
-
-install-binPROGRAMS: $(bin_PROGRAMS)
- @$(NORMAL_INSTALL)
- test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- if test -f $$p \
- || test -f $$p1 \
- ; then \
- f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
- else :; fi; \
- done
-
-uninstall-binPROGRAMS:
- @$(NORMAL_UNINSTALL)
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
- rm -f "$(DESTDIR)$(bindir)/$$f"; \
- done
-
-clean-binPROGRAMS:
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
-ad$(EXEEXT): $(ad_OBJECTS) $(ad_DEPENDENCIES)
- @rm -f ad$(EXEEXT)
- $(CXXLINK) $(ad_LDFLAGS) $(ad_OBJECTS) $(ad_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-.cpp.o:
- if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
- then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-# source='$<' object='$@' libtool=no \
-# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-# $(CXXCOMPILE) -c -o $@ $<
-
-.cpp.obj:
- if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
- then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-# source='$<' object='$@' libtool=no \
-# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cpp.lo:
- if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
- then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-# source='$<' object='$@' libtool=yes \
-# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
-# $(LTCXXCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
- -rm .deps/*
-
-distclean-libtool:
- -rm -f libtool
-uninstall-info-am:
-
-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 $(PROGRAMS);
-installdirs:
- for dir in "$(DESTDIR)$(bindir)"; 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:
-
-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."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
-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-exec-am: install-binPROGRAMS
-
-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-binPROGRAMS uninstall-info-am
-
-create-dir:
- mkdir -p ".deps"
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
- clean-generic 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-binPROGRAMS install-data install-data-am install-exec \
- install-exec-am install-info install-info-am install-man \
- install-strip 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-binPROGRAMS uninstall-info-am
-
-# 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/contrib/extractor/README.linux b/contrib/extractor/README.linux
index 52b907391b8..1986831e751 100644
--- a/contrib/extractor/README.linux
+++ b/contrib/extractor/README.linux
@@ -1,7 +1,7 @@
-= Trinity Core -- Linux instructions for extractor =
+Linux instructions
+------------------
-Copyright (C) Trinity Core (http://www.trinitycore.org)
-
-1: Configure and build MaNGOS.
-2: cd contrib/extractor/libmpq && make && cd .. && make
-3: run ad \ No newline at end of file
+1. install cmake
+2. cmake -i
+3. make
+4. ./ad
diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp
index a1641699163..b656a6ab535 100644
--- a/contrib/extractor/System.cpp
+++ b/contrib/extractor/System.cpp
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <deque>
#include <set>
+#include <cstdlib>
#ifdef WIN32
#include "direct.h"
@@ -13,37 +14,78 @@
#include "dbcfile.h"
#include "mpq_libmpq.h"
-extern unsigned int iRes;
-extern ArchiveSet gOpenArchives;
+#include "loadlib/adt.h"
+#include "loadlib/wdt.h"
+#include <fcntl.h>
-bool ConvertADT(char*,char*);
+#if defined( __GNUC__ )
+ #define _open open
+ #define _close close
+ #ifndef O_BINARY
+ #define O_BINARY 0
+ #endif
+#else
+ #include <io.h>
+#endif
-typedef struct{
- char name[64];
- unsigned int id;
-}map_id;
+#ifdef O_LARGEFILE
+ #define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE)
+#else
+ #define OPEN_FLAGS (O_RDONLY | O_BINARY)
+#endif
+extern ArchiveSet gOpenArchives;
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
+typedef struct
+{
+ char name[64];
+ uint32 id;
+} map_id;
-map_id * map_ids;
-uint16 * areas;
-char output_path[128]=".";
-char input_path[128]=".";
+map_id *map_ids;
+uint16 *areas;
+uint16 *LiqType;
+char output_path[128] = ".";
+char input_path[128] = ".";
+uint32 maxAreaId = 0;
+//**************************************************
+// Extractor options
+//**************************************************
enum Extract
{
EXTRACT_MAP = 1,
EXTRACT_DBC = 2
};
-int extract = EXTRACT_MAP | EXTRACT_DBC;
+
+// Select data for extract
+int CONF_extract = EXTRACT_MAP | EXTRACT_DBC;
+// This option allow limit minimum height to some value (Allow save some memory)
+bool CONF_allow_height_limit = true;
+float CONF_use_minHeight = -500.0f;
+
+// This option allow use float to int conversion
+bool CONF_allow_float_to_int = true;
+float CONF_float_to_int8_limit = 2.0f; // Max accuracy = val/256
+float CONF_float_to_int16_limit = 2048.0f; // Max accuracy = val/65536
+float CONF_flat_height_delta_limit = 0.005f; // If max - min less this value - surface is flat
+float CONF_flat_liquid_delta_limit = 0.001f; // If max - min less this value - liquid surface is flat
+
+// List MPQ for extract from
+char *CONF_mpq_list[]={
+ "common.MPQ",
+ "common-2.MPQ",
+ "lichking.MPQ",
+ "expansion.MPQ",
+ "patch.MPQ",
+ "patch-2.MPQ",
+ "patch-3.MPQ",
+ "patch-4.MPQ",
+ "patch-5.MPQ",
+};
static char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
#define LANG_COUNT 12
-#define ADT_RES 64
-
void CreateDir( const std::string& Path )
{
#ifdef WIN32
@@ -55,9 +97,10 @@ void CreateDir( const std::string& Path )
bool FileExists( const char* FileName )
{
- if(FILE* fp = fopen( FileName, "rb" ))
+ int fp = _open(FileName, OPEN_FLAGS);
+ if(fp != -1)
{
- fclose(fp);
+ _close(fp);
return true;
}
@@ -66,47 +109,54 @@ bool FileExists( const char* FileName )
void Usage(char* prg)
{
- printf("Usage:\n%s -[var] [value]\n-i set input path\n-o set output path\n-r set resolution\n-e extract only MAP(1)/DBC(2) - standard: both(3)\nExample: %s -r 256 -i \"c:\\games\\game\"",
- prg,prg);
+ printf(
+ "Usage:\n"\
+ "%s -[var] [value]\n"\
+ "-i set input path\n"\
+ "-o set output path\n"\
+ "-e extract only MAP(1)/DBC(2) - standard: both(3)\n"\
+ "-f height stored as int (less map size but lost some accuracy) 1 by default\n"\
+ "Example: %s -f 0 -i \"c:\\games\\game\"", prg, prg);
exit(1);
}
void HandleArgs(int argc, char * arg[])
{
- for(int c=1;c<argc;c++)
+ for(int c = 1; c < argc; ++c)
{
- //i - input path
- //o - output path
- //r - resolution, array of (r * r) heights will be created
- //e - extract only MAP(1)/DBC(2) - standard both(3)
+ // i - input path
+ // o - output path
+ // e - extract only MAP(1)/DBC(2) - standard both(3)
+ // f - use float to int conversion
+ // h - limit minimum height
if(arg[c][0] != '-')
Usage(arg[0]);
switch(arg[c][1])
{
case 'i':
- if(c+1<argc)//all ok
- strcpy(input_path,arg[(c++) +1]);
+ if(c + 1 < argc) // all ok
+ strcpy(input_path, arg[(c++) + 1]);
else
Usage(arg[0]);
break;
case 'o':
- if(c+1<argc)//all ok
- strcpy(output_path,arg[(c++) +1]);
+ if(c + 1 < argc) // all ok
+ strcpy(output_path, arg[(c++) + 1]);
else
Usage(arg[0]);
break;
- case 'r':
- if(c+1<argc)//all ok
- iRes=atoi(arg[(c++) +1]);
+ case 'f':
+ if(c + 1 < argc) // all ok
+ CONF_allow_float_to_int=atoi(arg[(c++) + 1])!=0;
else
Usage(arg[0]);
break;
case 'e':
- if(c+1<argc)//all ok
+ if(c + 1 < argc) // all ok
{
- extract=atoi(arg[(c++) +1]);
- if(!(extract > 0 && extract < 4))
+ CONF_extract=atoi(arg[(c++) + 1]);
+ if(!(CONF_extract > 0 && CONF_extract < 4))
Usage(arg[0]);
}
else
@@ -120,14 +170,19 @@ uint32 ReadMapDBC()
{
printf("Read Map.dbc file... ");
DBCFile dbc("DBFilesClient\\Map.dbc");
- dbc.open();
- uint32 map_count=dbc.getRecordCount();
- map_ids=new map_id[map_count];
- for(unsigned int x=0;x<map_count;x++)
+ if(!dbc.open())
{
- map_ids[x].id=dbc.getRecord(x).getUInt(0);
- strcpy(map_ids[x].name,dbc.getRecord(x).getString(1));
+ printf("Fatal error: Invalid Map.dbc file format!\n");
+ exit(1);
+ }
+
+ size_t map_count = dbc.getRecordCount();
+ map_ids = new map_id[map_count];
+ for(uint32 x = 0; x < map_count; ++x)
+ {
+ map_ids[x].id = dbc.getRecord(x).getUInt(0);
+ strcpy(map_ids[x].name, dbc.getRecord(x).getString(1));
}
printf("Done! (%u maps loaded)\n", map_count);
return map_count;
@@ -135,60 +190,689 @@ uint32 ReadMapDBC()
void ReadAreaTableDBC()
{
- printf("Read AreaTable.dbc file... ");
+ printf("Read AreaTable.dbc file...");
DBCFile dbc("DBFilesClient\\AreaTable.dbc");
- dbc.open();
- unsigned int area_count=dbc.getRecordCount();
- uint32 maxid = dbc.getMaxId();
- areas=new uint16[maxid + 1];
- memset(areas, 0xff, sizeof(areas));
- for(unsigned int x=0; x<area_count;++x)
+ if(!dbc.open())
+ {
+ printf("Fatal error: Invalid AreaTable.dbc file format!\n");
+ exit(1);
+ }
+
+ size_t area_count = dbc.getRecordCount();
+ size_t maxid = dbc.getMaxId();
+ areas = new uint16[maxid + 1];
+ memset(areas, 0xff, (maxid + 1) * sizeof(uint16));
+
+ for(uint32 x = 0; x < area_count; ++x)
areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
+ maxAreaId = dbc.getMaxId();
+
printf("Done! (%u areas loaded)\n", area_count);
}
+void ReadLiquidTypeTableDBC()
+{
+ printf("Read LiquidType.dbc file...");
+ DBCFile dbc("DBFilesClient\\LiquidType.dbc");
+ if(!dbc.open())
+ {
+ printf("Fatal error: Invalid LiquidType.dbc file format!\n");
+ exit(1);
+ }
+
+ size_t LiqType_count = dbc.getRecordCount();
+ size_t LiqType_maxid = dbc.getMaxId();
+ LiqType = new uint16[LiqType_maxid + 1];
+ memset(LiqType, 0xff, (LiqType_maxid + 1) * sizeof(uint16));
+
+ for(uint32 x = 0; x < LiqType_count; ++x)
+ LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
+
+ printf("Done! (%u LiqTypes loaded)\n", LiqType_count);
+}
+
+//
+// Adt file convertor function and data
+//
+
+// Map file format data
+#define MAP_MAGIC 'SPAM'
+#define MAP_VERSION_MAGIC '0.1w'
+#define MAP_AREA_MAGIC 'AERA'
+#define MAP_HEIGTH_MAGIC 'TGHM'
+#define MAP_LIQUID_MAGIC 'QILM'
+
+struct map_fileheader{
+ uint32 mapMagic;
+ uint32 versionMagic;
+ uint32 areaMapOffset;
+ uint32 areaMapSize;
+ uint32 heightMapOffset;
+ uint32 heightMapSize;
+ uint32 liquidMapOffset;
+ uint32 liquidMapSize;
+};
+
+#define MAP_AREA_NO_AREA 0x0001
+struct map_areaHeader{
+ uint32 fourcc;
+ uint16 flags;
+ uint16 gridArea;
+};
+
+#define MAP_HEIGHT_NO_HIGHT 0x0001
+#define MAP_HEIGHT_AS_INT16 0x0002
+#define MAP_HEIGHT_AS_INT8 0x0004
+
+struct map_heightHeader{
+ uint32 fourcc;
+ uint32 flags;
+ float gridHeight;
+ float gridMaxHeight;
+};
+
+#define MAP_LIQUID_TYPE_NO_WATER 0x00
+#define MAP_LIQUID_TYPE_WATER 0x01
+#define MAP_LIQUID_TYPE_OCEAN 0x02
+#define MAP_LIQUID_TYPE_MAGMA 0x04
+#define MAP_LIQUID_TYPE_SLIME 0x08
+
+#define MAP_LIQUID_TYPE_DARK_WATER 0x10
+#define MAP_LIQUID_TYPE_WMO_WATER 0x20
+
+
+#define MAP_LIQUID_NO_TYPE 0x0001
+#define MAP_LIQUID_NO_HIGHT 0x0002
+
+struct map_liquidHeader{
+ uint32 fourcc;
+ uint16 flags;
+ uint16 liquidType;
+ uint8 offsetX;
+ uint8 offsetY;
+ uint8 width;
+ uint8 height;
+ float liquidLevel;
+};
+
+float selectUInt8StepStore(float maxDiff)
+{
+ return 255 / maxDiff;
+}
+
+float selectUInt16StepStore(float maxDiff)
+{
+ return 65535 / maxDiff;
+}
+// Temporary grid data store
+uint16 area_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+
+float V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
+float V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
+uint16 uint16_V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
+uint16 uint16_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
+uint8 uint8_V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
+uint8 uint8_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
+
+uint8 liquid_type[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
+float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
+
+bool ConvertADT(char *filename, char *filename2, int cell_y, int cell_x)
+{
+ ADT_file adt;
+
+ if (!adt.loadFile(filename))
+ return false;
+
+ adt_MCIN *cells = adt.a_grid->getMCIN();
+ if (!cells)
+ {
+ printf("Can't find cells in '%s'\n", filename);
+ return false;
+ }
+
+ memset(liquid_show, 0, sizeof(liquid_show));
+ memset(liquid_type, 0, sizeof(liquid_type));
+
+ // Prepare map header
+ map_fileheader map;
+ map.mapMagic = MAP_MAGIC;
+ map.versionMagic = MAP_VERSION_MAGIC;
+
+ // Get area flags data
+ for (int i=0;i<ADT_CELLS_PER_GRID;i++)
+ {
+ for(int j=0;j<ADT_CELLS_PER_GRID;j++)
+ {
+ adt_MCNK * cell = cells->getMCNK(i,j);
+ uint32 areaid = cell->areaid;
+ if(areaid && areaid <= maxAreaId)
+ {
+ if(areas[areaid] != 0xffff)
+ {
+ area_flags[i][j] = areas[areaid];
+ continue;
+ }
+ printf("File: filename\nCan't find area flag for areaid %u [%d, %d].\n", filename, areaid, cell->ix, cell->iy);
+ }
+ area_flags[i][j] = 0xffff;
+ }
+ }
+ //============================================
+ // Try pack area data
+ //============================================
+ bool fullAreaData = false;
+ uint32 areaflag = area_flags[0][0];
+ for (int y=0;y<ADT_CELLS_PER_GRID;y++)
+ {
+ for(int x=0;x<ADT_CELLS_PER_GRID;x++)
+ {
+ if(area_flags[y][x]!=areaflag)
+ {
+ fullAreaData = true;
+ break;
+ }
+ }
+ }
+
+ map.areaMapOffset = sizeof(map);
+ map.areaMapSize = sizeof(map_areaHeader);
+
+ map_areaHeader areaHeader;
+ areaHeader.fourcc = MAP_AREA_MAGIC;
+ areaHeader.flags = 0;
+ if (fullAreaData)
+ {
+ areaHeader.gridArea = 0;
+ map.areaMapSize+=sizeof(area_flags);
+ }
+ else
+ {
+ areaHeader.flags |= MAP_AREA_NO_AREA;
+ areaHeader.gridArea = (uint16)areaflag;
+ }
+
+ //
+ // Get Height map from grid
+ //
+ for (int i=0;i<ADT_CELLS_PER_GRID;i++)
+ {
+ for(int j=0;j<ADT_CELLS_PER_GRID;j++)
+ {
+ adt_MCNK * cell = cells->getMCNK(i,j);
+ if (!cell)
+ continue;
+ // Height values for triangles stored in order:
+ // 1 2 3 4 5 6 7 8 9
+ // 10 11 12 13 14 15 16 17
+ // 18 19 20 21 22 23 24 25 26
+ // 27 28 29 30 31 32 33 34
+ // . . . . . . . .
+ // For better get height values merge it to V9 and V8 map
+ // V9 height map:
+ // 1 2 3 4 5 6 7 8 9
+ // 18 19 20 21 22 23 24 25 26
+ // . . . . . . . .
+ // V8 height map:
+ // 10 11 12 13 14 15 16 17
+ // 27 28 29 30 31 32 33 34
+ // . . . . . . . .
+
+ // Set map height as grid height
+ for (int y=0; y <= ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x <= ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ V9[cy][cx]=cell->ypos;
+ }
+ }
+ for (int y=0; y < ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x < ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ V8[cy][cx]=cell->ypos;
+ }
+ }
+ // Get custom height
+ adt_MCVT *v = cell->getMCVT();
+ if (!v)
+ continue;
+ // get V9 height map
+ for (int y=0; y <= ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x <= ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ V9[cy][cx]+=v->height_map[y*(ADT_CELL_SIZE*2+1)+x];
+ }
+ }
+ // get V8 height map
+ for (int y=0; y < ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x < ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ V8[cy][cx]+=v->height_map[y*(ADT_CELL_SIZE*2+1)+ADT_CELL_SIZE+1+x];
+ }
+ }
+ }
+ }
+ //============================================
+ // Try pack height data
+ //============================================
+ float maxHeight = -20000;
+ float minHeight = 20000;
+ for (int y=0; y<ADT_GRID_SIZE; y++)
+ {
+ for(int x=0;x<ADT_GRID_SIZE;x++)
+ {
+ float h = V8[y][x];
+ if (maxHeight < h) maxHeight = h;
+ if (minHeight > h) minHeight = h;
+ }
+ }
+ for (int y=0; y<=ADT_GRID_SIZE; y++)
+ {
+ for(int x=0;x<=ADT_GRID_SIZE;x++)
+ {
+ float h = V9[y][x];
+ if (maxHeight < h) maxHeight = h;
+ if (minHeight > h) minHeight = h;
+ }
+ }
+
+ // Check for allow limit minimum height (not store height in deep ochean - allow save some memory)
+ if (CONF_allow_height_limit && minHeight < CONF_use_minHeight)
+ {
+ for (int y=0; y<ADT_GRID_SIZE; y++)
+ for(int x=0;x<ADT_GRID_SIZE;x++)
+ if (V8[y][x] < CONF_use_minHeight)
+ V8[y][x] = CONF_use_minHeight;
+ for (int y=0; y<=ADT_GRID_SIZE; y++)
+ for(int x=0;x<=ADT_GRID_SIZE;x++)
+ if (V9[y][x] < CONF_use_minHeight)
+ V9[y][x] = CONF_use_minHeight;
+ if (minHeight < CONF_use_minHeight)
+ minHeight = CONF_use_minHeight;
+ if (maxHeight < CONF_use_minHeight)
+ maxHeight = CONF_use_minHeight;
+ }
+
+ map.heightMapOffset = map.areaMapOffset + map.areaMapSize;
+ map.heightMapSize = sizeof(map_heightHeader);
+
+ map_heightHeader heightHeader;
+ heightHeader.fourcc = MAP_HEIGTH_MAGIC;
+ heightHeader.flags = 0;
+ heightHeader.gridHeight = minHeight;
+ heightHeader.gridMaxHeight = maxHeight;
+
+ if (maxHeight == minHeight)
+ heightHeader.flags |=MAP_HEIGHT_NO_HIGHT;
+
+ // Not need store if flat surface
+ if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_height_delta_limit)
+ heightHeader.flags |=MAP_HEIGHT_NO_HIGHT;
+
+ // Try store as packed in uint16 or uint8 values
+ if (!(heightHeader.flags&MAP_HEIGHT_NO_HIGHT))
+ {
+ float step;
+ // Try Store as uint values
+ if (CONF_allow_float_to_int)
+ {
+ float diff = maxHeight - minHeight;
+ if (diff < CONF_float_to_int8_limit) // As uint8 (max accuracy = CONF_float_to_int8_limit/256)
+ {
+ heightHeader.flags|=MAP_HEIGHT_AS_INT8;
+ step = selectUInt8StepStore(diff);
+ }
+ else if (diff<CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
+ {
+ heightHeader.flags|=MAP_HEIGHT_AS_INT16;
+ step = selectUInt16StepStore(diff);
+ }
+ }
+
+ // Pack it to int values if need
+ if (heightHeader.flags&MAP_HEIGHT_AS_INT8)
+ {
+ for (int y=0; y<ADT_GRID_SIZE; y++)
+ for(int x=0;x<ADT_GRID_SIZE;x++)
+ uint8_V8[y][x] = uint8((V8[y][x] - minHeight) * step + 0.5f);
+ for (int y=0; y<=ADT_GRID_SIZE; y++)
+ for(int x=0;x<=ADT_GRID_SIZE;x++)
+ uint8_V9[y][x] = uint8((V9[y][x] - minHeight) * step + 0.5f);
+ map.heightMapSize+= sizeof(uint8_V9) + sizeof(uint8_V8);
+ }
+ else if (heightHeader.flags&MAP_HEIGHT_AS_INT16)
+ {
+ for (int y=0; y<ADT_GRID_SIZE; y++)
+ for(int x=0;x<ADT_GRID_SIZE;x++)
+ uint16_V8[y][x] = uint16((V8[y][x] - minHeight) * step + 0.5f);
+ for (int y=0; y<=ADT_GRID_SIZE; y++)
+ for(int x=0;x<=ADT_GRID_SIZE;x++)
+ uint16_V9[y][x] = uint16((V9[y][x] - minHeight) * step + 0.5f);
+ map.heightMapSize+= sizeof(uint16_V9) + sizeof(uint16_V8);
+ }
+ else
+ map.heightMapSize+= sizeof(V9) + sizeof(V8);
+ }
+
+ // Get liquid map for grid (in WOTLK used MH2O chunk)
+ adt_MH2O * h2o = adt.a_grid->getMH2O();
+ if (h2o)
+ {
+ for (int i=0;i<ADT_CELLS_PER_GRID;i++)
+ {
+ for(int j=0;j<ADT_CELLS_PER_GRID;j++)
+ {
+ adt_liquid_header *h = h2o->getLiquidData(i,j);
+ if (!h)
+ continue;
+
+ int count = 0;
+ uint64 show = h2o->getLiquidShowMap(h);
+ for (int y=0; y < h->height;y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y + h->yOffset;
+ for (int x=0; x < h->width; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x + h->xOffset;
+ if (show & 1)
+ {
+ liquid_show[cy][cx] = true;
+ ++count;
+ }
+ show>>=1;
+ }
+ }
+
+ uint32 type = LiqType[h->liquidType];
+ switch (type)
+ {
+ case LIQUID_TYPE_WATER: liquid_type[i][j] |= MAP_LIQUID_TYPE_WATER; break;
+ case LIQUID_TYPE_OCEAN: liquid_type[i][j] |= MAP_LIQUID_TYPE_OCEAN; break;
+ case LIQUID_TYPE_MAGMA: liquid_type[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
+ case LIQUID_TYPE_SLIME: liquid_type[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
+ default:
+ printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, filename, i, j);
+ break;
+ }
+ // Dark water detect
+ if (type == LIQUID_TYPE_OCEAN)
+ {
+ uint8 *lm = h2o->getLiquidLightMap(h);
+ if (!lm)
+ liquid_type[i][j]|=MAP_LIQUID_TYPE_DARK_WATER;
+ }
+
+ if (!count && liquid_type[i][j])
+ printf("Wrong liquid detect in MH2O chunk");
+
+ float *height = h2o->getLiquidHeightMap(h);
+ int pos = 0;
+ for (int y=0; y<=h->height;y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y + h->yOffset;
+ for (int x=0; x<= h->width; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x + h->xOffset;
+ if (height)
+ liquid_height[cy][cx] = height[pos];
+ else
+ liquid_height[cy][cx] = h->heightLevel1;
+ pos++;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // Get from MCLQ chunk (old)
+ for (int i=0;i<ADT_CELLS_PER_GRID;i++)
+ {
+ for(int j=0;j<ADT_CELLS_PER_GRID;j++)
+ {
+ adt_MCNK *cell = cells->getMCNK(i, j);
+ if (!cell)
+ continue;
+
+ adt_MCLQ *liquid = cell->getMCLQ();
+ int count = 0;
+ if (!liquid || cell->sizeMCLQ <= 8)
+ continue;
+
+ for (int y=0; y < ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x < ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ if (liquid->flags[y][x] != 0x0F)
+ {
+ liquid_show[cy][cx] = true;
+ if (liquid->flags[y][x]&(1<<7))
+ liquid_type[i][j]|=MAP_LIQUID_TYPE_DARK_WATER;
+ ++count;
+ }
+ }
+ }
+
+ uint32 c_flag = cell->flags;
+ if(c_flag & (1<<2))
+ liquid_type[i][j]|=MAP_LIQUID_TYPE_WATER; // water
+ if(c_flag & (1<<3))
+ liquid_type[i][j]|=MAP_LIQUID_TYPE_OCEAN; // ochean
+ if(c_flag & (1<<4))
+ liquid_type[i][j]|=MAP_LIQUID_TYPE_MAGMA; // magma/slime
+
+ if (!count && liquid_type[i][j])
+ printf("Wrong liquid detect in MCLQ chunk");
+
+ for (int y=0; y <= ADT_CELL_SIZE; y++)
+ {
+ int cy = i*ADT_CELL_SIZE + y;
+ for (int x=0; x<= ADT_CELL_SIZE; x++)
+ {
+ int cx = j*ADT_CELL_SIZE + x;
+ liquid_height[cy][cx] = liquid->liquid[y][x].height;
+ }
+ }
+ }
+ }
+ }
+
+ //============================================
+ // Pack liquid data
+ //============================================
+ uint8 type = liquid_type[0][0];
+ bool fullType = false;
+ for (int y=0;y<ADT_CELLS_PER_GRID;y++)
+ {
+ for(int x=0;x<ADT_CELLS_PER_GRID;x++)
+ {
+ if (liquid_type[y][x]!=type)
+ {
+ fullType = true;
+ y = ADT_CELLS_PER_GRID;
+ break;
+ }
+ }
+ }
+
+ map_liquidHeader liquidHeader;
+
+ // no water data (if all grid have 0 liquid type)
+ if (type == 0 && !fullType)
+ {
+ // No liquid data
+ map.liquidMapOffset = 0;
+ map.liquidMapSize = 0;
+ }
+ else
+ {
+ int minX = 255, minY = 255;
+ int maxX = 0, maxY = 0;
+ maxHeight = -20000;
+ minHeight = 20000;
+ for (int y=0; y<ADT_GRID_SIZE; y++)
+ {
+ for(int x=0; x<ADT_GRID_SIZE; x++)
+ {
+ if (liquid_show[y][x])
+ {
+ if (minX > x) minX = x;
+ if (maxX < x) maxX = x;
+ if (minY > y) minY = y;
+ if (maxY < y) maxY = y;
+ float h = liquid_height[y][x];
+ if (maxHeight < h) maxHeight = h;
+ if (minHeight > h) minHeight = h;
+ }
+ else
+ liquid_height[y][x] = CONF_use_minHeight;
+ }
+ }
+ map.liquidMapOffset = map.heightMapOffset + map.heightMapSize;
+ map.liquidMapSize = sizeof(map_liquidHeader);
+ liquidHeader.fourcc = MAP_LIQUID_MAGIC;
+ liquidHeader.flags = 0;
+ liquidHeader.liquidType = 0;
+ liquidHeader.offsetX = minX;
+ liquidHeader.offsetY = minY;
+ liquidHeader.width = maxX - minX + 1;
+ liquidHeader.height = maxY - minY + 1;
+ liquidHeader.liquidLevel = minHeight;
+
+ if (maxHeight == minHeight)
+ liquidHeader.flags|=MAP_LIQUID_NO_HIGHT;
+
+ // Not need store if flat surface
+ if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_liquid_delta_limit)
+ liquidHeader.flags|=MAP_LIQUID_NO_HIGHT;
+
+ if (!fullType)
+ liquidHeader.flags|=MAP_LIQUID_NO_TYPE;
+
+ if (liquidHeader.flags&MAP_LIQUID_NO_TYPE)
+ liquidHeader.liquidType = type;
+ else
+ map.liquidMapSize+=sizeof(liquid_type);
+
+ if (!(liquidHeader.flags&MAP_LIQUID_NO_HIGHT))
+ map.liquidMapSize+=sizeof(float)*liquidHeader.width*liquidHeader.height;
+ }
+
+ // Ok all data prepared - store it
+ FILE *output=fopen(filename2, "wb");
+ if(!output)
+ {
+ printf("Can't create the output file '%s'\n", filename2);
+ return false;
+ }
+ fwrite(&map, sizeof(map), 1, output);
+ // Store area data
+ fwrite(&areaHeader, sizeof(areaHeader), 1, output);
+ if (!(areaHeader.flags&MAP_AREA_NO_AREA))
+ fwrite(area_flags, sizeof(area_flags), 1, output);
+
+ // Store height data
+ fwrite(&heightHeader, sizeof(heightHeader), 1, output);
+ if (!(heightHeader.flags&MAP_HEIGHT_NO_HIGHT))
+ {
+ if (heightHeader.flags&MAP_HEIGHT_AS_INT16)
+ {
+ fwrite(uint16_V9, sizeof(uint16_V9), 1, output);
+ fwrite(uint16_V8, sizeof(uint16_V8), 1, output);
+ }
+ else if (heightHeader.flags&MAP_HEIGHT_AS_INT8)
+ {
+ fwrite(uint8_V9, sizeof(uint8_V9), 1, output);
+ fwrite(uint8_V8, sizeof(uint8_V8), 1, output);
+ }
+ else
+ {
+ fwrite(V9, sizeof(V9), 1, output);
+ fwrite(V8, sizeof(V8), 1, output);
+ }
+ }
+
+ // Store liquid data if need
+ if (map.liquidMapOffset)
+ {
+ fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
+ if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
+ fwrite(liquid_type, sizeof(liquid_type), 1, output);
+ if (!(liquidHeader.flags&MAP_LIQUID_NO_HIGHT))
+ {
+ for (int y=0; y<liquidHeader.height;y++)
+ fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
+ }
+ }
+ fclose(output);
+
+ return true;
+}
+
void ExtractMapsFromMpq()
{
char mpq_filename[1024];
char output_filename[1024];
+ char mpq_map_name[1024];
printf("Extracting maps...\n");
uint32 map_count = ReadMapDBC();
ReadAreaTableDBC();
-
- unsigned int total=map_count*ADT_RES*ADT_RES;
- unsigned int done=0;
+ ReadLiquidTypeTableDBC();
std::string path = output_path;
path += "/maps/";
CreateDir(path);
- for(unsigned int x = 0; x < ADT_RES; ++x)
+ printf("Convert map files\n");
+ for(uint32 z = 0; z < map_count; ++z)
{
- for(unsigned int y = 0; y < ADT_RES; ++y)
+ printf("Extract %s (%d/%d) \n", map_ids[z].name, z+1, map_count);
+ // Loadup map grid data
+ sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
+ WDT_file wdt;
+ if (!wdt.loadFile(mpq_map_name, false))
{
- for(unsigned int z = 0; z < map_count; ++z)
+// printf("Error loading %s map wdt data\n", map_ids[z].name);
+ continue;
+ }
+
+ for(uint32 y = 0; y < WDT_MAP_SIZE; ++y)
+ {
+ for(uint32 x = 0; x < WDT_MAP_SIZE; ++x)
{
- sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y);
- sprintf(output_filename,"%s/maps/%03u%02u%02u.map",output_path,map_ids[z].id,y,x);
- ConvertADT(mpq_filename,output_filename);
- done++;
+ if (!wdt.main->adt_list[y][x].exist)
+ continue;
+ sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
+ sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
+ ConvertADT(mpq_filename, output_filename, y, x);
}
- //draw progess bar
- printf("Processing........................%d%%\r",(100*done)/total);
+ // draw progress bar
+ printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
}
}
-
delete [] areas;
delete [] map_ids;
}
-//bool WMO(char* filename);
-
void ExtractDBCFiles(int locale, bool basicLocale)
{
printf("Extracting dbc files...\n");
@@ -222,7 +906,7 @@ void ExtractDBCFiles(int locale, bool basicLocale)
string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));
- FILE *output=fopen(filename.c_str(), "wb");
+ FILE *output = fopen(filename.c_str(), "wb");
if(!output)
{
printf("Can't create the output file '%s'\n", filename.c_str());
@@ -260,18 +944,10 @@ void LoadLocaleMPQFiles(int const locale)
void LoadCommonMPQFiles()
{
char filename[512];
-
- sprintf(filename,"%s/Data/common.MPQ", input_path);
- new MPQArchive(filename);
- sprintf(filename,"%s/Data/expansion.MPQ", input_path);
- new MPQArchive(filename);
- for(int i = 1; i < 5; ++i)
+ int count = sizeof(CONF_mpq_list)/sizeof(char*);
+ for(int i = 0; i < count; ++i)
{
- char ext[3] = "";
- if(i > 1)
- sprintf(ext, "-%i", i);
-
- sprintf(filename,"%s/Data/patch%s.MPQ", input_path, ext);
+ sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]);
if(FileExists(filename))
new MPQArchive(filename);
}
@@ -303,7 +979,7 @@ int main(int argc, char * arg[])
//Open MPQs
LoadLocaleMPQFiles(i);
- if((extract & EXTRACT_DBC) == 0)
+ if((CONF_extract & EXTRACT_DBC) == 0)
{
FirstLocale = i;
break;
@@ -329,7 +1005,7 @@ int main(int argc, char * arg[])
return 0;
}
- if (extract & EXTRACT_MAP)
+ if (CONF_extract & EXTRACT_MAP)
{
printf("Using locale: %s\n", langs[FirstLocale]);
diff --git a/contrib/extractor/VC71_ad.vcproj b/contrib/extractor/VC71_ad.vcproj
index fd2d16120e8..541540ceaa2 100644
--- a/contrib/extractor/VC71_ad.vcproj
+++ b/contrib/extractor/VC71_ad.vcproj
@@ -213,7 +213,15 @@
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
- RelativePath=".\adt.cpp"
+ RelativePath=".\loadlib\loadlib.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\loadlib\adt.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\loadlib\wdt.cpp"
>
</File>
<File
diff --git a/contrib/extractor/VC80_ad.vcproj b/contrib/extractor/VC80_ad.vcproj
index fedab5b89eb..a20ff016ca8 100644
--- a/contrib/extractor/VC80_ad.vcproj
+++ b/contrib/extractor/VC80_ad.vcproj
@@ -218,7 +218,7 @@
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
- RelativePath=".\adt.cpp"
+ RelativePath=".\loadlib\adt.cpp"
>
</File>
<File
@@ -226,6 +226,10 @@
>
</File>
<File
+ RelativePath=".\loadlib\loadlib.cpp"
+ >
+ </File>
+ <File
RelativePath=".\mpq_libmpq.cpp"
>
</File>
@@ -253,6 +257,10 @@
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath=".\loadlib\wdt.cpp"
+ >
+ </File>
<Filter
Name="libmpq"
>
diff --git a/contrib/extractor/VC90_ad.vcproj b/contrib/extractor/VC90_ad.vcproj
index 59fdf6d21f1..9a039a0fbb0 100644
--- a/contrib/extractor/VC90_ad.vcproj
+++ b/contrib/extractor/VC90_ad.vcproj
@@ -216,7 +216,15 @@
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
- RelativePath=".\adt.cpp"
+ RelativePath=".\loadlib\loadlib.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\loadlib\adt.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\loadlib\wdt.cpp"
>
</File>
<File
diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe
index f0a7e4408ce..208eb2da030 100644
--- a/contrib/extractor/ad.exe
+++ b/contrib/extractor/ad.exe
Binary files differ
diff --git a/contrib/extractor/adt.cpp b/contrib/extractor/adt.cpp
index a8f640a63bc..fcbfc95a072 100644
--- a/contrib/extractor/adt.cpp
+++ b/contrib/extractor/adt.cpp
@@ -15,16 +15,14 @@
#include "adt.h"
#include "mpq_libmpq.h"
-//#include <windows.h>
-unsigned int iRes=256;
-extern uint16*areas;
+extern uint16 *areas;
+extern uint16 *LiqType;
+extern uint32 maxAreaId;
vec wmoc;
-Cell * cell;
-uint32 wmo_count;
+Cell *cell;
mcell *mcells;
-
int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888};
int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000};
@@ -35,168 +33,154 @@ bool LoadADT(char* filename)
if(mf.isEof())
{
- //printf("No such file.\n");
+ //printf("No such file %s\n", filename);
return false;
}
- mcells=new mcell;
- wmoc.x =65*TILESIZE;
- wmoc.z =65*TILESIZE;
+ MapLiqFlag = new uint8[256];
+ for(uint32 j = 0; j < 256; ++j)
+ MapLiqFlag[j] = 0; // no water
+
+ MapLiqHeight = new float[16384];
+ for(uint32 j = 0; j < 16384; ++j)
+ MapLiqHeight[j] = -999999; // no water
+
+ mcells = new mcell;
+
+ wmoc.x = 65 * TILESIZE;
+ wmoc.z = 65 * TILESIZE;
size_t mcnk_offsets[256], mcnk_sizes[256];
- wmo_count=0;
- bool found=false;
- //uint32 fs=mf.getSize()-3;
- //while (mf.getPos()<fs)
+ chunk_num = 0;
+ k = 0;
+ m = 0;
while (!mf.isEof())
{
uint32 fourcc;
- mf.read(&fourcc,4);
+ mf.read(&fourcc, 4);
mf.read(&size, 4);
size_t nextpos = mf.getPos() + size;
- switch(fourcc)
+
+ //if(fourcc==0x4d484452) // MHDR header
+ //if(fourcc==0x4d564552) // MVER
+ if(fourcc == 0x4d43494e) // MCIN
{
- case 0x4d43494e: // MCIN
+ for (uint32 i = 0; i < 256; ++i)
{
- //printf("Found chunks info\n");
- // mapchunk offsets/sizes
- for (int i=0; i<256; i++)
- {
- mf.read(&mcnk_offsets[i],4);
- mf.read(&mcnk_sizes[i],4);
- mf.seekRelative(8);
- }
- break;
+ mf.read(&mcnk_offsets[i], 4);
+ mf.read(&mcnk_sizes[i], 4);
+ mf.seekRelative(8);
}
- case 0x4d4f4446: // MODF
+ }
+ //if(fourcc == 0x4d544558) // MTEX textures (strings)
+ //if(fourcc == 0x4d4d4458) // MMDX m2 models (strings)
+ //if(fourcc == 0x4d4d4944) // MMID offsets for strings in MMDX
+ //if(fourcc == 0x4d574d4f) // MWMO
+ //if(fourcc == 0x4d574944) // MWID offsets for strings in MWMO
+ //if(fourcc == 0x4d444446) // MDDF
+ //if(fourcc == 0x4d4f4446) // MODF
+ if(fourcc == 0x4d48324f) // MH2O new in WotLK
+ {
+ // çäåñ?íàäî çàïîìíèò?áàçîâó?ïîçèöè??ôàéë?òê âñ?ñìåùåí? áóäó?îò íåãî
+ uint32 base_pos = mf.getPos();
+ uint32 header_pos = 0;
+ MH2O_offsData *LiqOffsData = new MH2O_offsData;
+ MH2O_Data1 *LiqChunkData1 = new MH2O_Data1;
+ float *ChunkLiqHeight = new float[81];
+ for(chunk_num = 0; chunk_num < 256; ++chunk_num)
{
- /*
- if(size)
+ mf.read(LiqOffsData, 0x0C);
+ header_pos = mf.getPos();
+ if(LiqOffsData->offsData1 != 0) // åñëè äàííûå ?Data1 ?âîäå åñòü, òî èõ íàäî êîíâåðòèðîâàòü
{
- //printf("\nwmo count %d\n",size/64);
- wmo_count =size/64;
- for (int i=0; i<wmo_count; i++)
+ // ïåðåõî?ïî ñìåùåíèþ èç offsData1 ÎÒ ×À?êóñê?
+ mf.seek(base_pos + LiqOffsData->offsData1);
+ mf.read(LiqChunkData1, 0x18); // ñ÷èòûâàå?ñàìè äàííûå ?ñòðóêòóð?òèïà MH2O_Data1
+ // çàíîñè?äàííûå ôëàã?äëÿ êóñê?
+ if(LiqType[LiqChunkData1->LiquidTypeId] == 0xffff)
+ printf("\nCan't find Liquid type for map %s\nchunk %d\n", filename, chunk_num);
+ else if(LiqType[LiqChunkData1->LiquidTypeId] == LIQUID_TYPE_WATER || LiqType[LiqChunkData1->LiquidTypeId] == LIQUID_TYPE_OCEAN)
+ MapLiqFlag[chunk_num] |= 1; // water/ocean
+ else if(LiqType[LiqChunkData1->LiquidTypeId] == LIQUID_TYPE_MAGMA || LiqType[LiqChunkData1->LiquidTypeId] == LIQUID_TYPE_SLIME)
+ MapLiqFlag[chunk_num] |= 2; // magma/slime
+ // ïðåäâàðèòåëüíî çàïîëíÿåì âåñü êóñî?äàííûì?- íå?âîäû
+ for(int j = 0; j < 81; ++j)
+ {
+ ChunkLiqHeight[j] = -999999; // no liquid/water
+ }
+ // òåïåðü âû÷èñëÿåì òå ÷ò??âîäî??ïåðåçàïèñûâàåì èõ ?êóñê?
+ for(int b = 0; b <= LiqChunkData1->height; ++b)
{
- int id;
- mf.read(&id, 4);
- WMO *wmo = (WMO*)wmomanager.items[wmomanager.get(wmos[id])];
- WMOInstance inst(wmo, mf);
- wmois.push_back(inst);
+ for(int c = LiqChunkData1->xOffset; c <= (LiqChunkData1->xOffset + LiqChunkData1->width); ++c)
+ {
+ int n = (9 * (LiqChunkData1->yOffset + b)) + c;
+ ChunkLiqHeight[n] = LiqChunkData1->heightLevel1;
+ }
}
+ mf.seek(header_pos); // ?íå çàáûòü âåðíóòüñÿ íà èñõîäíóþ ïîçèöè?èìåííî ?ÕÈÄÅÐÅ
+ }
+ else // åñëè äàííûõ ?Data1 íå? òî íàäî çàïîëíèò?âåñü êóñî? íî äàííûì?- íå?âîäû
+ {
+ for(int j = 0; j < 81; ++j)
+ ChunkLiqHeight[j] = -999999; // no liquid/water
+ }
- }*/
- break;
- }
- case 0x4d574d4f: // MWMO
- {
- /*
- if (size)
+ if(!(chunk_num % 16))
+ m = 1024 * (chunk_num / 16); // ñìåùåíèå ïî ?äà?êóñêîâ ?ïåðåêðûòèå?= 1024
+ k = m + (chunk_num % 16) * 8; // óñòàíàâëèâàåìñÿ íà íà÷àëüíû?èíäåêñ äëÿ çàïîëíåí? ?äà
+ // çàíîñè?äàííûå êóñê??ìàññèâ äëÿ êàðò? ?ïåðåêðûòèå??îáðåçàíèåì êóñêîâ òê äàííûõ 81
+ // ýò?àíàëîã ñòàðîã?îáðåçàíèÿ ãðàíè÷íû?ïðàâûõ-áîêîâû??íèæíèõ äàííûõ
+ for(int p = 0; p < 72; p += 9) // íèæíèå 8 íå çàíîñè?òê îí?äóáëèðóåòñÿ ñëåä êóñêîì
{
- char *buf = new char[size];
- mf.read(buf, size);
- char *p=buf;
- while (p<buf+size)
+ for(int s = 0; s < 8; ++s) // 9 çíà÷åíèå ?ñòðîêå íå çàíîñè?òê îí?äóáëèðóåòñÿ ñëåä êóñêîì, ??ïðâû?áîêîâû?îáðåçàåò? äëÿ 128?28
{
- std::string path(p);
- p+=strlen(p)+1;
- fixname(path);
-
- wmomanager.add(path);
- wmos.push_back(path);
+ MapLiqHeight[k] = ChunkLiqHeight[p + s];
+ ++k;
}
- delete[] buf;
- }*/
- break;
- }
- case 0x4d564552: // MVER
- case 0x4d484452: // MHDR header
- case 0x4d434e4b: // MCNK
- case 0x4d544558: // MTEX textures (strings)
- case 0x4d4d4458: // MMDX m2 models (strings)
- case 0x4d4d4944: // MMID offsets for strings in MMDX
- case 0x4d574944: // MWID offsets for strings in MWMO
- case 0x4d444446: // MDDF
- case 0x4d46424f: // MFBO new in BC
- case 0x4d48324f: // MH2O new in WotLK
- break;
- default:
- {
- // mf.seekRelative(-3);
- printf("Unhandled map chunk: %u\n",fourcc);
- break;
+ k = k + 120;
+ }
}
+ delete LiqOffsData;
+ delete LiqChunkData1;
+ delete []ChunkLiqHeight;
+
}
+ //case 0x4d434e4b: // MCNK
+ //case 0x4d46424f: // MFBO new in BC
+ //case 0x4d545846: // MTXF new in WotLK
mf.seek(nextpos);
}
//printf("Loading chunks info\n");
// read individual map chunks
- for (int j=0; j<16; j++)
- for (int i=0; i<16; i++)
+ chunk_num = 0;
+ k = 0;
+ m = 0;
+ for (int j = 0; j < 16; ++j)
+ {
+ for (int i = 0; i < 16; ++i)
{
- mf.seek((int)mcnk_offsets[j*16+i]);
- LoadMapChunk(mf,&(mcells->ch[i][j]));
+ mf.seek((int)mcnk_offsets[j * 16 + i]);
+ LoadMapChunk(mf, &(mcells->ch[i][j]));
+ ++chunk_num;
}
-
- /*
- for(uint32 t=0;t<wmo_count ;t++)
- {
- wmois[t].draw();
- }*/
-
+ }
mf.close();
return true;
}
-struct MapChunkHeader {
- uint32 flags;
- uint32 ix;
- uint32 iy;
- uint32 nLayers;
- uint32 nDoodadRefs;
- uint32 ofsHeight;
- uint32 ofsNormal;
- uint32 ofsLayer;
- uint32 ofsRefs;
- uint32 ofsAlpha;
- uint32 sizeAlpha;
- uint32 ofsShadow;
- uint32 sizeShadow;
- uint32 areaid;
- uint32 nMapObjRefs;
- uint32 holes;
- uint16 s1;
- uint16 s2;
- uint32 d1;
- uint32 d2;
- uint32 d3;
- uint32 predTex;
- uint32 nEffectDoodad;
- uint32 ofsSndEmitters;
- uint32 nSndEmitters;
- uint32 ofsLiquid;
- uint32 sizeLiquid;
- float zpos;
- float xpos;
- float ypos;
- uint32 textureId;
- uint32 props;
- uint32 effectId;
-};
-
bool isHole(int holes, int i, int j)
{
- int testi = i/2;
- int testj = j/4;
- if(testi>3) testi = 3;
- if(testj>3) testj = 3;
- return (holes & holetab_h[testi] & holetab_v[testj])!=0;
+ int testi = i / 2;
+ int testj = j / 4;
+ if(testi > 3) testi = 3;
+ if(testj > 3) testj = 3;
+ return (holes & holetab_h[testi] & holetab_v[testj]) != 0;
}
-inline
-void LoadMapChunk(MPQFile & mf, chunk*_chunk)
+inline void LoadMapChunk(MPQFile &mf, chunk *_chunk)
{
float h;
uint32 fourcc;
@@ -207,298 +191,191 @@ void LoadMapChunk(MPQFile & mf, chunk*_chunk)
mf.read(&size, 4);
size_t lastpos = mf.getPos() + size;
- mf.read(&header, 0x80);
- _chunk->area_id =header.areaid ;
- _chunk->flag =0;
+ mf.read(&header, 0x80); // what if header size got changed?
+ _chunk->area_id = header.areaid;
float xbase = header.xpos;
float ybase = header.ypos;
float zbase = header.zpos;
- zbase = TILESIZE*32-zbase;
- xbase = TILESIZE*32-xbase;
- if(wmoc.x >xbase)wmoc.x =xbase;
- if(wmoc.z >zbase)wmoc.z =zbase;
+ zbase = TILESIZE * 32 - zbase;
+ xbase = TILESIZE * 32 - xbase;
+ if(wmoc.x > xbase) wmoc.x = xbase;
+ if(wmoc.z > zbase) wmoc.z = zbase;
int chunkflags = header.flags;
- float zmin=999999999.0f;
- float zmax=-999999999.0f;
- //must be there, bl!zz uses some crazy format
- int nTextures;
+ //printf("LMC: flags %X\n", chunkflags);
+ float zmin = 999999999.0f;
+ float zmax = -999999999.0f;
+ // must be there, bl!zz uses some crazy format
while (mf.getPos() < lastpos)
{
- mf.read(&fourcc,4);
+ mf.read(&fourcc, 4);
mf.read(&size, 4);
- //if(size!=580)
- // printf("\n sz=%d",size);
- size_t nextpos = mf.getPos() + size;
- if(fourcc==0x4d435654) // MCVT
+ size_t nextpos = mf.getPos() + size;
+ if(fourcc == 0x4d435654) // MCVT
{
- for (int j=0; j<17; j++)
- for (int i=0; i<((j%2)?8:9); i++)
+ for (int j = 0; j < 17; ++j)
+ {
+ for (int i = 0; i < ((j % 2) ? 8 : 9); ++i)
{
- mf.read(&h,4);
- float z=h+ybase;
- if (j%2)
+ mf.read(&h, 4);
+ float z = h + ybase;
+ if (j % 2)
{
- if(isHole(header.holes,i,j))
- _chunk->v8[i][j/2] = -1000;
+ if(isHole(header.holes, i, j))
+ _chunk->v8[i][j / 2] = -1000;
else
- _chunk->v8[i][j/2] = z;
+ _chunk->v8[i][j / 2] = z;
}
else
{
- if(isHole(header.holes,i,j))
- _chunk->v9[i][j/2] = -1000;
+ if(isHole(header.holes, i, j))
+ _chunk->v9[i][j / 2] = -1000;
else
- _chunk->v9[i][j/2] = z;
+ _chunk->v9[i][j / 2] = z;
}
- if(z>zmax)zmax=z;
- //if(z<zmin)zmin=z;
+ if(z > zmax) zmax = z;
+ //if(z < zmin) zmin = z;
}
+ }
}
- else if(fourcc==0x4d434e52) // MCNR
+ else if(fourcc == 0x4d434e52) // MCNR
{
- nextpos = mf.getPos() + 0x1C0; // size fix
+ nextpos = mf.getPos() + 0x1C0; // size fix
}
- else if(fourcc==0x4d434c51) // MCLQ
+ else if(fourcc == 0x4d434c51) // íå áóäå?ó÷èòûâàò?åñëè óæ?áûëè äàííûå ?MH2O, ïåðåñòðàõîâê?:) // MCLQ
{
// liquid / water level
- //bool haswater;
char fcc1[5];
- mf.read(fcc1,4);
+ mf.read(fcc1, 4);
flipcc(fcc1);
- fcc1[4]=0;
+ fcc1[4] = 0;
+ float *ChunkLiqHeight = new float[81];
- if (!strcmp(fcc1,"MCSE"))
+ if (!strcmp(fcc1, "MCSE"))
{
- for(int i=0;i<9;i++)
- for(int j=0;j<9;j++)
- _chunk->waterlevel[i][j]=-999999; // no liquid/water
+ for(int j = 0; j < 81; ++j)
+ {
+ ChunkLiqHeight[j] = -999999; // no liquid/water
+ }
}
else
{
float maxheight;
mf.read(&maxheight, 4);
+ for(int j = 0; j < 81; ++j)
+ {
+ LiqData liq;
+ mf.read(&liq, 8);
- for(int j=0;j<9;j++)
- for(int i=0;i<9;i++)
- {
- mf.read(&h, 4);
- mf.read(&h, 4);
- if(h > maxheight)
- _chunk->waterlevel[i][j]=-999999;
- else
- _chunk->waterlevel[i][j]=h;
- }
+ if(liq.height > maxheight)
+ ChunkLiqHeight[j] = -999999;
+ else
+ ChunkLiqHeight[j] = h;
+ }
if(chunkflags & 4 || chunkflags & 8)
- _chunk->flag |=1;
+ MapLiqFlag[chunk_num] |= 1; // water
if(chunkflags & 16)
- _chunk->flag |=2;
-
+ MapLiqFlag[chunk_num] |= 2; // magma/slime
+ }
+ // àïîëíå?òà?æå êà??MH2O
+ if(!(chunk_num % 16))
+ m = 1024 * (chunk_num / 16);
+ k = m + (chunk_num % 16) * 8;
+
+ for(int p = 0; p < 72; p += 9)
+ {
+ for(int s = 0; s < 8; ++s)
+ {
+ MapLiqHeight[k] = ChunkLiqHeight[p + s];
+ ++k;
+ }
+ k = k + 120;
}
+ delete []ChunkLiqHeight;
break;
}
- else if (fourcc==0x4d434c59) // MCLY
- {
- // texture info
- nTextures = (int)size;
- }
- else if (fourcc==0x4d43414c) // MCAL
- {
- if (nTextures<=0)
- continue;
- }
-
mf.seek(nextpos);
}
}
-double solve (vec *v,vec *p)
+inline void TransformData()
{
- double a = v[0].y *(v[1].z - v[2].z) + v[1].y *(v[2].z - v[0].z) + v[2].y *(v[0].z - v[1].z);
- double b = v[0].z *(v[1].x - v[2].x) + v[1].z *(v[2].x - v[0].x) + v[2].z *(v[0].x - v[1].x);
- double c = v[0].x *(v[1].y - v[2].y) + v[1].x *(v[2].y - v[0].y) + v[2].x *(v[0].y - v[1].y);
- double d = v[0].x *(v[1].y*v[2].z - v[2].y*v[1].z) + v[1].x* (v[2].y*v[0].z - v[0].y*v[2].z) + v[2].x* (v[0].y*v[1].z - v[1].y*v[0].z);
- //-d
-
- //plane equation ax+by+cz+d=0
- return ((a*p->x+c*p->z-d)/b);
-}
-
-inline
-double GetZ(double x,double z)
-{
- vec v[3];
- vec p;
-
- //bool inWMO=false;
+ cell = new Cell;
- //if(!inWMO)
+ for(uint32 x = 0; x < 128; ++x)
{
- //find out quadrant
- int xc=(int)(x/UNITSIZE);
- int zc=(int)(z/UNITSIZE);
- if(xc>127)xc=127;
- if(zc>127)zc=127;
-
- double lx=x-xc*UNITSIZE;
- double lz=z-zc*UNITSIZE;
- p.x=lx;
- p.z=lz;
-
- v[0].x=UNITSIZE/2;
- v[0].y =cell->v8[xc][zc];
- v[0].z=UNITSIZE/2;
-
- if(lx>lz)
+ for(uint32 y = 0; y < 128; ++y)
{
- v[1].x=UNITSIZE;
- v[1].y =cell->v9[xc+1][zc];
- v[1].z=0;
- }
- else
- {
- v[1].x=0.0;
- v[1].y =cell->v9[xc][zc+1];
- v[1].z=UNITSIZE;
- }
-
- if(lz>UNITSIZE-lx)
- {
- v[2].x=UNITSIZE;
- v[2].y =cell->v9[xc+1][zc+1];
- v[2].z=UNITSIZE;
- }
- else
- {
- v[2].x=0;
- v[2].y=cell->v9[xc][zc];
- v[2].z=0;
+ cell->v8[y][x] = (float)mcells->ch[x / 8][y / 8].v8[x % 8][y % 8];
+ cell->v9[y][x] = (float)mcells->ch[x / 8][y / 8].v9[x % 8][y % 8];
}
- return -solve(v,&p);
+ // extra 1 point on bounds
+ cell->v9[128][x] = (float)mcells->ch[x / 8][15].v9[x % 8][8];
+ // x == y
+ cell->v9[x][128] = (float)mcells->ch[15][x / 8].v9[8][x % 8];
}
-}
-
-inline
-void TransformWaterData()
-{
- cell= new Cell;
- for(int x=0;x<128;x++)
- for(int y=0;y<128;y++)
- cell->v9[x][y] = mcells->ch[x/8][y/8].waterlevel[x%8][y%8];
-
- //and the last 1
- cell->v9[128][128] = mcells->ch[15][15].waterlevel[8][8];
-}
-
-inline
-void TransformData()
-{
- cell= new Cell;
-
- for(int x=0;x<128;x++)
- {
- for(int y=0;y<128;y++)
- {
- cell->v8[y][x] = (float)mcells->ch[x/8][y/8].v8[x%8][y%8];
- cell->v9[y][x] = (float)mcells->ch[x/8][y/8].v9[x%8][y%8];
- }
-
- //extra 1 point on bounds
- cell->v9[128][x] = (float)mcells->ch[x/8][15].v9[x%8][8];
- //x==y
- cell->v9[x][128] = (float)mcells->ch[15][x/8].v9[8][x%8];
- }
-
- //and the last 1
+ // and the last 1
cell->v9[128][128] = (float)mcells->ch[15][15].v9[8][8];
delete mcells;
}
-const char MAP_MAGIC[] = "MAP_2.50";
+const char MAP_MAGIC[] = "MAP_3.00";
-bool ConvertADT(char * filename,char * filename2)
+bool ConvertADT(char *filename, char *filename2)
{
- //if(!strstr(filename,"oth_32_48"))return false;
if(!LoadADT(filename))
return false;
- FILE *output=fopen(filename2,"wb");
+ FILE *output=fopen(filename2, "wb");
if(!output)
{
- printf("Can't create the output file '%s'\n",filename2);
+ printf("Can't create the output file '%s'\n", filename2);
+ delete [] MapLiqHeight;
+ delete [] MapLiqFlag;
return false;
}
// write magic header
- fwrite(MAP_MAGIC,1,8,output);
+ fwrite(MAP_MAGIC, 1, 8, output);
- for(unsigned int x=0;x<16;x++)
+ for(uint32 x = 0; x < 16; ++x)
{
- for(unsigned int y=0;y<16;y++)
+ for(uint32 y = 0; y < 16; ++y)
{
- if(mcells->ch[y][x].area_id && mcells->ch[y][x].area_id < 0x102D)
+ if(mcells->ch[y][x].area_id && mcells->ch[y][x].area_id <= maxAreaId)
{
- if(areas[mcells->ch[y][x].area_id]==0xffff)
- printf("\nCan't find area flag for areaid %u.\n",mcells->ch[y][x].area_id);
+ if(areas[mcells->ch[y][x].area_id] == 0xffff)
+ printf("\nCan't find area flag for areaid %u.\n", mcells->ch[y][x].area_id);
- fwrite(&areas[mcells->ch[y][x].area_id],1,2,output);
+ fwrite(&areas[mcells->ch[y][x].area_id], 1, 2, output);
}
else
{
- uint16 flag=0xffff;
- fwrite(&flag,1,2,output);
+ uint16 flag = 0xffff;
+ fwrite(&flag, 1, 2, output);
}
}
}
- for(unsigned int x=0;x<16;x++)
- for(unsigned int y=0;y<16;y++)
- fwrite(&mcells->ch[y][x].flag,1,1,output);
-
- TransformWaterData();
+ fwrite(MapLiqFlag, 1, 256, output);
+ delete [] MapLiqFlag;
- for(unsigned int x=0;x<128;x++)
- for(unsigned int y=0;y<128;y++)
- fwrite(&cell->v9[y][x],1,sizeof(float),output);
+ fwrite(MapLiqHeight, sizeof(float), 16384, output);
+ delete [] MapLiqHeight;
- delete cell;
TransformData();
- /*
- for(unsigned int x=0;x<iRes;x++)
- for(unsigned int y=0;y<iRes;y++)
- {
- float z=(float)GetZ(
- (((double)(y))*TILESIZE)/((double)(iRes-1)),
- (((double)(x))*TILESIZE)/((double)(iRes-1)));
-
- fwrite(&z,1,sizeof(z),output);
- }*/
fwrite(&cell->v9, 1, sizeof(cell->v9), output);
fwrite(&cell->v8, 1, sizeof(cell->v8), output);
fclose(output);
delete cell;
-/*
- for (std::vector<std::string>::iterator it = wmos.begin(); it != wmos.end(); ++it)
- wmomanager.delbyname(*it);
-
- wmos.clear();
- wmois.clear();
-
- for (std::vector<model>::iterator it = wmomodel.begin(); it != wmomodel.end(); ++it)
- {
- it->tr.clear();
-
- }
- //printf("\n %d \n",in);
- wmomodel.clear();
- //polygons.clear();*/
+
return true;
}
diff --git a/contrib/extractor/adt.h b/contrib/extractor/adt.h
index 9af85b14d8c..516ed88a86e 100644
--- a/contrib/extractor/adt.h
+++ b/contrib/extractor/adt.h
@@ -9,47 +9,122 @@ typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
class Liquid;
-typedef struct {
-float x;
-float y;
-float z;
-}svec;
-
-typedef struct {
-double x;
-double y;
-double z;
-}vec;
-
-typedef struct{
+typedef struct
+{
+ float x;
+ float y;
+ float z;
+} svec;
+
+typedef struct
+{
+ double x;
+ double y;
+ double z;
+} vec;
+
+typedef struct
+{
vec v[3];
-}triangle;
+} triangle;
+
+typedef struct
+{
+ float v9[16 * 8 + 1][16 * 8 + 1];
+ float v8[16 * 8][16 * 8];
+} Cell;
+
+typedef struct
+{
+ double v9[9][9];
+ double v8[8][8];
+ uint16 area_id;
+} chunk;
-typedef struct{
-float v9[16*8+1][16*8+1];
-float v8[16*8][16*8];
-}Cell;
+typedef struct
+{
+ chunk ch[16][16];
+} mcell;
-typedef struct{
-double v9[9][9];
-double v8[8][8];
-uint16 area_id;
-//Liquid *lq;
-float waterlevel[9][9];
-uint8 flag;
-}chunk;
+struct MapChunkHeader
+{
+ uint32 flags;
+ uint32 ix;
+ uint32 iy;
+ uint32 nLayers;
+ uint32 nDoodadRefs;
+ uint32 ofsHeight;
+ uint32 ofsNormal;
+ uint32 ofsLayer;
+ uint32 ofsRefs;
+ uint32 ofsAlpha;
+ uint32 sizeAlpha;
+ uint32 ofsShadow;
+ uint32 sizeShadow;
+ uint32 areaid;
+ uint32 nMapObjRefs;
+ uint32 holes;
+ uint16 s1;
+ uint16 s2;
+ uint32 d1;
+ uint32 d2;
+ uint32 d3;
+ uint32 predTex;
+ uint32 nEffectDoodad;
+ uint32 ofsSndEmitters;
+ uint32 nSndEmitters;
+ uint32 ofsLiquid; // not use in WotLK
+ uint32 sizeLiquid; // not use in WotLK
+ float zpos;
+ float xpos;
+ float ypos;
+ uint32 textureId; // new offsColorValues in WotLK
+ uint32 props;
+ uint32 effectId;
+};
-class WMO;
-class WMOManager;
-void fixname(std::string &name);
+typedef struct
+{
+ uint32 offsData1;
+ uint32 used;
+ uint32 offsData2;
+} MH2O_offsData;
typedef struct
{
-chunk ch[16][16];
-}mcell;
+ uint16 LiquidTypeId;
+ uint16 type;
+ float heightLevel1;
+ float heightLevel2;
+ uint8 xOffset;
+ uint8 yOffset;
+ uint8 width;
+ uint8 height;
+ uint32 ofsData2a;
+ uint32 ofsData2b;
+} MH2O_Data1;
+
+typedef struct
+{
+ uint16 unk1;
+ uint16 unk2;
+ float height;
+} LiqData;
+
+enum LiquidType
+{
+ LIQUID_TYPE_WATER = 0,
+ LIQUID_TYPE_OCEAN = 1,
+ LIQUID_TYPE_MAGMA = 2,
+ LIQUID_TYPE_SLIME = 3
+};
+
class MPQFile;
-void LoadMapChunk(MPQFile &,chunk*);
-bool LoadWMO(char* filename);
+
+float *MapLiqHeight;
+uint8 *MapLiqFlag;
+uint32 k, m, chunk_num;
+void LoadMapChunk(MPQFile &, chunk*);
#endif
diff --git a/contrib/extractor/dbcfile.cpp b/contrib/extractor/dbcfile.cpp
index dbe379d27f7..dd58ac1b4a6 100644
--- a/contrib/extractor/dbcfile.cpp
+++ b/contrib/extractor/dbcfile.cpp
@@ -9,29 +9,42 @@ DBCFile::DBCFile(const std::string &filename):
{
}
-void DBCFile::open()
+bool DBCFile::open()
{
MPQFile f(filename.c_str());
char header[4];
unsigned int na,nb,es,ss;
- f.read(header,4); // Number of records
- assert(header[0]=='W' && header[1]=='D' && header[2]=='B' && header[3] == 'C');
- f.read(&na,4); // Number of records
- f.read(&nb,4); // Number of fields
- f.read(&es,4); // Size of a record
- f.read(&ss,4); // String size
+ if(f.read(header,4)!=4) // Number of records
+ return false;
+
+ if(header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3]!='C')
+ return false;
+
+ if(f.read(&na,4)!=4) // Number of records
+ return false;
+ if(f.read(&nb,4)!=4) // Number of fields
+ return false;
+ if(f.read(&es,4)!=4) // Size of a record
+ return false;
+ if(f.read(&ss,4)!=4) // String size
+ return false;
recordSize = es;
recordCount = na;
fieldCount = nb;
stringSize = ss;
- assert(fieldCount*4 == recordSize);
+ if(fieldCount*4 != recordSize)
+ return false;
data = new unsigned char[recordSize*recordCount+stringSize];
stringTable = data + recordSize*recordCount;
- f.read(data,recordSize*recordCount+stringSize);
+
+ size_t data_size = recordSize*recordCount+stringSize;
+ if(f.read(data,data_size)!=data_size)
+ return false;
f.close();
+ return true;
}
DBCFile::~DBCFile()
{
diff --git a/contrib/extractor/dbcfile.h b/contrib/extractor/dbcfile.h
index 7d709e80948..aef61df7aaa 100644
--- a/contrib/extractor/dbcfile.h
+++ b/contrib/extractor/dbcfile.h
@@ -10,7 +10,7 @@ public:
~DBCFile();
// Open database. It must be openened before it can be used.
- void open();
+ bool open();
// Database exceptions
class Exception
diff --git a/contrib/extractor/libmpq/CMakeLists.txt b/contrib/extractor/libmpq/CMakeLists.txt
new file mode 100644
index 00000000000..c00120c6e48
--- /dev/null
+++ b/contrib/extractor/libmpq/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2005-2009 MaNGOS project <http://getmangos.com/>
+#
+# This file is free software; as a special exception the author 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.
+
+add_library (libmpq common.cpp explode.cpp extract.cpp huffman.cpp mpq.cpp parser.cpp wave.cpp )
+# link libmpq with zlib
+target_link_libraries (libmpq z)
diff --git a/contrib/extractor/libmpq/Makefile b/contrib/extractor/libmpq/Makefile
deleted file mode 100644
index eb1965e29f1..00000000000
--- a/contrib/extractor/libmpq/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-CC = g++
-AR = ar
-objects = common.o explode.o extract.o huffman.o wave.o mpq.o parser.o
-zlib_objects = ../../../dep/src/zlib/*.o #adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o inftrees.o inffast.o
-
-all: libmpq.a libmpq.so
-
-clean:
- rm -f libmpq.a libmpq.so *.o
-
-libmpq.a: $(objects) $(zlib_objects)
- $(AR) cru $@ $+
-libmpq.so: $(objects) $(zlib_objects)
- $(CC) -fPIC -o $@ $+
-
-%.o:%.cpp
- $(CC) -I../ -c $+
diff --git a/contrib/extractor/libmpq/mpq.cpp b/contrib/extractor/libmpq/mpq.cpp
index eddd92ac483..a59d3dff2f1 100644
--- a/contrib/extractor/libmpq/mpq.cpp
+++ b/contrib/extractor/libmpq/mpq.cpp
@@ -199,7 +199,7 @@ int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype) {
/*
* This function returns some useful file information.
*/
-int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int unsigned number) {
+int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number) {
int blockindex = number; //-1;
int i = 0;
mpq_block *mpq_b = NULL;
diff --git a/contrib/extractor/loadlib/CMakeLists.txt b/contrib/extractor/loadlib/CMakeLists.txt
new file mode 100644
index 00000000000..5680c61d424
--- /dev/null
+++ b/contrib/extractor/loadlib/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2005-2009 MaNGOS project <http://getmangos.com/>
+#
+# This file is free software; as a special exception the author 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.
+
+add_library (loadlib loadlib.cpp adt.cpp wdt.cpp)
+# link loadlib with zlib
+target_link_libraries (loadlib z)
diff --git a/contrib/extractor/loadlib/adt.cpp b/contrib/extractor/loadlib/adt.cpp
new file mode 100644
index 00000000000..fde70681113
--- /dev/null
+++ b/contrib/extractor/loadlib/adt.cpp
@@ -0,0 +1,131 @@
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "adt.h"
+
+// Helper
+int holetab_h[4] = {0x1111, 0x2222, 0x4444, 0x8888};
+int holetab_v[4] = {0x000F, 0x00F0, 0x0F00, 0xF000};
+
+bool isHole(int holes, int i, int j)
+{
+ int testi = i / 2;
+ int testj = j / 4;
+ if(testi > 3) testi = 3;
+ if(testj > 3) testj = 3;
+ return (holes & holetab_h[testi] & holetab_v[testj]) != 0;
+}
+
+//
+// Adt file loader class
+//
+ADT_file::ADT_file()
+{
+ a_grid = 0;
+}
+
+ADT_file::~ADT_file()
+{
+ free();
+}
+
+void ADT_file::free()
+{
+ a_grid = 0;
+ FileLoader::free();
+}
+
+//
+// Adt file check function
+//
+bool ADT_file::prepareLoadedData()
+{
+ // Check parent
+ if (!FileLoader::prepareLoadedData())
+ return false;
+
+ // Check and prepare MHDR
+ a_grid = (adt_MHDR *)(GetData()+8+version->size);
+ if (!a_grid->prepareLoadedData())
+ return false;
+
+ return true;
+}
+
+bool adt_MHDR::prepareLoadedData()
+{
+ if (fcc != 'MHDR')
+ return false;
+
+ if (size!=sizeof(adt_MHDR)-8)
+ return false;
+
+ // Check and prepare MCIN
+ if (offsMCIN && !getMCIN()->prepareLoadedData())
+ return false;
+
+ // Check and prepare MH2O
+ if (offsMH2O && !getMH2O()->prepareLoadedData())
+ return false;
+
+ return true;
+}
+
+bool adt_MCIN::prepareLoadedData()
+{
+ if (fcc != 'MCIN')
+ return false;
+
+ // Check cells data
+ for (int i=0; i<ADT_CELLS_PER_GRID;i++)
+ for (int j=0; j<ADT_CELLS_PER_GRID;j++)
+ if (cells[i][j].offsMCNK && !getMCNK(i,j)->prepareLoadedData())
+ return false;
+
+ return true;
+}
+
+bool adt_MH2O::prepareLoadedData()
+{
+ if (fcc != 'MH2O')
+ return false;
+
+ // Check liquid data
+// for (int i=0; i<ADT_CELLS_PER_GRID;i++)
+// for (int j=0; j<ADT_CELLS_PER_GRID;j++)
+
+ return true;
+}
+
+bool adt_MCNK::prepareLoadedData()
+{
+ if (fcc != 'MCNK')
+ return false;
+
+ // Check height map
+ if (offsMCVT && !getMCVT()->prepareLoadedData())
+ return false;
+ // Check liquid data
+ if (offsMCLQ && !getMCLQ()->prepareLoadedData())
+ return false;
+
+ return true;
+}
+
+bool adt_MCVT::prepareLoadedData()
+{
+ if (fcc != 'MCVT')
+ return false;
+
+ if (size != sizeof(adt_MCVT)-8)
+ return false;
+
+ return true;
+}
+
+bool adt_MCLQ::prepareLoadedData()
+{
+ if (fcc != 'MCLQ')
+ return false;
+
+ return true;
+} \ No newline at end of file
diff --git a/contrib/extractor/loadlib/adt.h b/contrib/extractor/loadlib/adt.h
new file mode 100644
index 00000000000..725c5b994ee
--- /dev/null
+++ b/contrib/extractor/loadlib/adt.h
@@ -0,0 +1,289 @@
+#ifndef ADT_H
+#define ADT_H
+
+#include "loadlib.h"
+
+#define TILESIZE (533.33333f)
+#define CHUNKSIZE ((TILESIZE) / 16.0f)
+#define UNITSIZE (CHUNKSIZE / 8.0f)
+
+enum LiquidType
+{
+ LIQUID_TYPE_WATER = 0,
+ LIQUID_TYPE_OCEAN = 1,
+ LIQUID_TYPE_MAGMA = 2,
+ LIQUID_TYPE_SLIME = 3
+};
+
+//**************************************************************************************
+// ADT file class
+//**************************************************************************************
+#define ADT_CELLS_PER_GRID 16
+#define ADT_CELL_SIZE 8
+#define ADT_GRID_SIZE (ADT_CELLS_PER_GRID*ADT_CELL_SIZE)
+
+//
+// Adt file height map chunk
+//
+class adt_MCVT
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+public:
+ float height_map[(ADT_CELL_SIZE+1)*(ADT_CELL_SIZE+1)+ADT_CELL_SIZE*ADT_CELL_SIZE];
+
+ bool prepareLoadedData();
+};
+
+//
+// Adt file liquid map chunk (old)
+//
+class adt_MCLQ
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+public:
+ float height1;
+ float height2;
+ struct liquid_data{
+ uint32 light;
+ float height;
+ } liquid[ADT_CELL_SIZE+1][ADT_CELL_SIZE+1];
+
+ // 1<<0 - ochen
+ // 1<<1 - lava/slime
+ // 1<<2 - water
+ // 1<<6 - all water
+ // 1<<7 - dark water
+ // == 0x0F - not show liquid
+ uint8 flags[ADT_CELL_SIZE][ADT_CELL_SIZE];
+ uint8 data[84];
+ bool prepareLoadedData();
+};
+
+//
+// Adt file cell chunk
+//
+class adt_MCNK
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+public:
+ uint32 flags;
+ uint32 ix;
+ uint32 iy;
+ uint32 nLayers;
+ uint32 nDoodadRefs;
+ uint32 offsMCVT; // height map
+ uint32 offsMCNR; // Normal vectors for each vertex
+ uint32 offsMCLY; // Texture layer definitions
+ uint32 offsMCRF; // A list of indices into the parent file's MDDF chunk
+ uint32 offsMCAL; // Alpha maps for additional texture layers
+ uint32 sizeMCAL;
+ uint32 offsMCSH; // Shadow map for static shadows on the terrain
+ uint32 sizeMCSH;
+ uint32 areaid;
+ uint32 nMapObjRefs;
+ uint32 holes;
+ uint16 s[2];
+ uint32 data1;
+ uint32 data2;
+ uint32 data3;
+ uint32 predTex;
+ uint32 nEffectDoodad;
+ uint32 offsMCSE;
+ uint32 nSndEmitters;
+ uint32 offsMCLQ; // Liqid level (old)
+ uint32 sizeMCLQ; //
+ float zpos;
+ float xpos;
+ float ypos;
+ uint32 offsMCCV; // offsColorValues in WotLK
+ uint32 props;
+ uint32 effectId;
+
+ bool prepareLoadedData();
+ adt_MCVT *getMCVT()
+ {
+ if (offsMCVT)
+ return (adt_MCVT *)((uint8 *)this + offsMCVT);
+ return 0;
+ }
+ adt_MCLQ *getMCLQ()
+ {
+ if (offsMCLQ)
+ return (adt_MCLQ *)((uint8 *)this + offsMCLQ);
+ return 0;
+ }
+};
+
+//
+// Adt file grid chunk
+//
+class adt_MCIN
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+public:
+ struct adt_CELLS{
+ uint32 offsMCNK;
+ uint32 size;
+ uint32 flags;
+ uint32 asyncId;
+ } cells[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+
+ bool prepareLoadedData();
+ // offset from begin file (used this-84)
+ adt_MCNK *getMCNK(int x, int y)
+ {
+ if (cells[x][y].offsMCNK)
+ return (adt_MCNK *)((uint8 *)this + cells[x][y].offsMCNK - 84);
+ return 0;
+ }
+};
+
+#define ADT_LIQUID_HEADER_FULL_LIGHT 0x01
+#define ADT_LIQUID_HEADER_NO_HIGHT 0x02
+
+struct adt_liquid_header{
+ uint16 liquidType; // Index from LiquidType.dbc
+ uint16 formatFlags;
+ float heightLevel1;
+ float heightLevel2;
+ uint8 xOffset;
+ uint8 yOffset;
+ uint8 width;
+ uint8 height;
+ uint32 offsData2a;
+ uint32 offsData2b;
+};
+
+//
+// Adt file liquid data chunk (new)
+//
+class adt_MH2O
+{
+public:
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+
+ struct adt_LIQUID{
+ uint32 offsData1;
+ uint32 used;
+ uint32 offsData2;
+ } liquid[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
+
+ bool prepareLoadedData();
+
+ adt_liquid_header *getLiquidData(int x, int y)
+ {
+ if (liquid[x][y].used && liquid[x][y].offsData1)
+ return (adt_liquid_header *)((uint8*)this + 8 + liquid[x][y].offsData1);
+ return 0;
+ }
+
+ float *getLiquidHeightMap(adt_liquid_header *h)
+ {
+ if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
+ return 0;
+ if (h->offsData2b)
+ return (float *)((uint8*)this + 8 + h->offsData2b);
+ return 0;
+ }
+
+ uint8 *getLiquidLightMap(adt_liquid_header *h)
+ {
+ if (h->formatFlags&ADT_LIQUID_HEADER_FULL_LIGHT)
+ return 0;
+ if (h->offsData2b)
+ {
+ if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
+ return (uint8 *)((uint8*)this + 8 + h->offsData2b);
+ return (uint8 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
+ }
+ return 0;
+ }
+
+ uint32 *getLiquidFullLightMap(adt_liquid_header *h)
+ {
+ if (!(h->formatFlags&ADT_LIQUID_HEADER_FULL_LIGHT))
+ return 0;
+ if (h->offsData2b)
+ {
+ if (h->formatFlags & ADT_LIQUID_HEADER_NO_HIGHT)
+ return (uint32 *)((uint8*)this + 8 + h->offsData2b);
+ return (uint32 *)((uint8*)this + 8 + h->offsData2b + (h->width+1)*(h->height+1)*4);
+ }
+ return 0;
+ }
+
+ uint64 getLiquidShowMap(adt_liquid_header *h)
+ {
+ if (h->offsData2a)
+ return *((uint64 *)((uint8*)this + 8 + h->offsData2a));
+ else
+ return 0xFFFFFFFFFFFFFFFFLL;
+ }
+
+};
+
+//
+// Adt file header chunk
+//
+class adt_MHDR
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+
+ uint32 pad;
+ uint32 offsMCIN; // MCIN
+ uint32 offsTex; // MTEX
+ uint32 offsModels; // MMDX
+ uint32 offsModelsIds; // MMID
+ uint32 offsMapObejcts; // MWMO
+ uint32 offsMapObejctsIds; // MWID
+ uint32 offsDoodsDef; // MDDF
+ uint32 offsObjectsDef; // MODF
+ uint32 offsMFBO; // MFBO
+ uint32 offsMH2O; // MH2O
+ uint32 data1;
+ uint32 data2;
+ uint32 data3;
+ uint32 data4;
+ uint32 data5;
+public:
+ bool prepareLoadedData();
+ adt_MCIN *getMCIN(){ return (adt_MCIN *)((uint8 *)&pad+offsMCIN);}
+ adt_MH2O *getMH2O(){ return offsMH2O ? (adt_MH2O *)((uint8 *)&pad+offsMH2O) : 0;}
+
+};
+
+class ADT_file : public FileLoader{
+public:
+ bool prepareLoadedData();
+ ADT_file();
+ ~ADT_file();
+ void free();
+
+ adt_MHDR *a_grid;
+};
+
+#endif
diff --git a/contrib/extractor/loadlib/loadlib.cpp b/contrib/extractor/loadlib/loadlib.cpp
new file mode 100644
index 00000000000..ed5bd9acb71
--- /dev/null
+++ b/contrib/extractor/loadlib/loadlib.cpp
@@ -0,0 +1,64 @@
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "loadlib.h"
+#include "../mpq_libmpq.h"
+
+class MPQFile;
+
+FileLoader::FileLoader()
+{
+ data = 0;
+ data_size = 0;
+ version = 0;
+}
+
+FileLoader::~FileLoader()
+{
+ free();
+}
+
+bool FileLoader::loadFile(char *filename, bool log)
+{
+ free();
+ MPQFile mf(filename);
+ if(mf.isEof())
+ {
+ if (log)
+ printf("No such file %s\n", filename);
+ return false;
+ }
+
+ data_size = mf.getSize();
+
+ data = new uint8 [data_size];
+ if (data)
+ {
+ mf.read(data, data_size);
+ mf.close();
+ if (prepareLoadedData())
+ return true;
+ }
+ printf("Error loading %s", filename);
+ mf.close();
+ free();
+ return false;
+}
+
+bool FileLoader::prepareLoadedData()
+{
+ // Check version
+ version = (file_MVER *) data;
+ if (version->fcc != 'MVER')
+ return false;
+ if (version->ver != FILE_FORMAT_VERSION)
+ return false;
+ return true;
+}
+
+void FileLoader::free()
+{
+ if (data) delete[] data;
+ data = 0;
+ data_size = 0;
+ version = 0;
+} \ No newline at end of file
diff --git a/contrib/extractor/loadlib/loadlib.h b/contrib/extractor/loadlib/loadlib.h
new file mode 100644
index 00000000000..6acfd107ec7
--- /dev/null
+++ b/contrib/extractor/loadlib/loadlib.h
@@ -0,0 +1,57 @@
+#ifndef LOAD_LIB_H
+#define LOAD_LIB_H
+
+#ifdef WIN32
+typedef __int64 int64;
+typedef long int32;
+typedef short int16;
+typedef char int8;
+typedef unsigned __int64 uint64;
+typedef unsigned long uint32;
+typedef unsigned short uint16;
+typedef unsigned char uint8;
+#else
+#include <stdint.h>
+#ifndef uint64_t
+#include <linux/types.h>
+#endif
+typedef int64_t int64;
+typedef long int32;
+typedef short int16;
+typedef char int8;
+typedef uint64_t uint64;
+typedef unsigned long uint32;
+typedef unsigned short uint16;
+typedef unsigned char uint8;
+#endif
+
+#define FILE_FORMAT_VERSION 18
+
+//
+// File version chunk
+//
+struct file_MVER
+{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+ uint32 size;
+ uint32 ver;
+};
+
+class FileLoader{
+ uint8 *data;
+ uint32 data_size;
+public:
+ virtual bool prepareLoadedData();
+ uint8 *GetData() {return data;}
+ uint32 GetDataSize() {return data_size;}
+
+ file_MVER *version;
+ FileLoader();
+ ~FileLoader();
+ bool loadFile(char *filename, bool log = true);
+ virtual void free();
+};
+#endif
diff --git a/contrib/extractor/loadlib/wdt.cpp b/contrib/extractor/loadlib/wdt.cpp
new file mode 100644
index 00000000000..dedefbb64e5
--- /dev/null
+++ b/contrib/extractor/loadlib/wdt.cpp
@@ -0,0 +1,62 @@
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "wdt.h"
+
+bool wdt_MWMO::prepareLoadedData()
+{
+ if (fcc != 'MWMO')
+ return false;
+ return true;
+}
+
+bool wdt_MPHD::prepareLoadedData()
+{
+ if (fcc != 'MPHD')
+ return false;
+ return true;
+}
+
+bool wdt_MAIN::prepareLoadedData()
+{
+ if (fcc != 'MAIN')
+ return false;
+ return true;
+}
+
+WDT_file::WDT_file()
+{
+ mphd = 0;
+ main = 0;
+ wmo = 0;
+}
+
+WDT_file::~WDT_file()
+{
+ free();
+}
+
+void WDT_file::free()
+{
+ mphd = 0;
+ main = 0;
+ wmo = 0;
+ FileLoader::free();
+}
+
+bool WDT_file::prepareLoadedData()
+{
+ // Check parent
+ if (!FileLoader::prepareLoadedData())
+ return false;
+
+ mphd = (wdt_MPHD *)((uint8*)version+version->size+8);
+ if (!mphd->prepareLoadedData())
+ return false;
+ main = (wdt_MAIN *)((uint8*)mphd + mphd->size+8);
+ if (!main->prepareLoadedData())
+ return false;
+ wmo = (wdt_MWMO *)((uint8*)main+ main->size+8);
+ if (!wmo->prepareLoadedData())
+ return false;
+ return true;
+} \ No newline at end of file
diff --git a/contrib/extractor/loadlib/wdt.h b/contrib/extractor/loadlib/wdt.h
new file mode 100644
index 00000000000..fcee8ac64f2
--- /dev/null
+++ b/contrib/extractor/loadlib/wdt.h
@@ -0,0 +1,68 @@
+#ifndef WDT_H
+#define WDT_H
+#include "loadlib.h"
+
+//**************************************************************************************
+// WDT file class and structures
+//**************************************************************************************
+#define WDT_MAP_SIZE 64
+
+class wdt_MWMO{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+public:
+ uint32 size;
+ bool prepareLoadedData();
+};
+
+class wdt_MPHD{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+public:
+ uint32 size;
+
+ uint32 data1;
+ uint32 data2;
+ uint32 data3;
+ uint32 data4;
+ uint32 data5;
+ uint32 data6;
+ uint32 data7;
+ uint32 data8;
+ bool prepareLoadedData();
+};
+
+class wdt_MAIN{
+ union{
+ uint32 fcc;
+ char fcc_txt[4];
+ };
+public:
+ uint32 size;
+
+ struct adtData{
+ uint32 exist;
+ uint32 data1;
+ } adt_list[64][64];
+
+ bool prepareLoadedData();
+};
+
+class WDT_file : public FileLoader{
+public:
+ bool prepareLoadedData();
+
+ WDT_file();
+ ~WDT_file();
+ void free();
+
+ wdt_MPHD *mphd;
+ wdt_MAIN *main;
+ wdt_MWMO *wmo;
+};
+
+#endif \ No newline at end of file
diff --git a/contrib/extractor/mpq_libmpq.h b/contrib/extractor/mpq_libmpq.h
index 97b7b75035b..d61cda7f919 100644
--- a/contrib/extractor/mpq_libmpq.h
+++ b/contrib/extractor/mpq_libmpq.h
@@ -4,6 +4,7 @@
#ifndef MPQ_H
#define MPQ_H
+#include "loadlib/loadlib.h"
#include "libmpq/mpq.h"
#include <string.h>
#include <ctype.h>
@@ -13,7 +14,6 @@
using namespace std;
-typedef unsigned int uint32;
class MPQArchive
{
diff --git a/contrib/mysql_to_pgsql/CMakeLists.txt b/contrib/mysql_to_pgsql/CMakeLists.txt
new file mode 100644
index 00000000000..490a023e4ec
--- /dev/null
+++ b/contrib/mysql_to_pgsql/CMakeLists.txt
@@ -0,0 +1,21 @@
+SET(CMAKE_VERBOSE_MAKEFILE ON)
+cmake_minimum_required (VERSION 2.6)
+
+INCLUDE(cmake/FindMySQL.cmake)
+INCLUDE(cmake/FindPostgreSQL.cmake)
+
+MESSAGE("-- Check PostgreSQL")
+FIND_PGSQL()
+ADD_DEFINITIONS(-DDO_POSTGRESQL)
+
+MESSAGE("-- Check MySQL")
+FIND_MYSQL()
+ADD_DEFINITIONS(-DDO_MYSQL)
+
+INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${PGSQL_INCLUDE_DIR})
+
+ADD_EXECUTABLE (mysql2pgsql src/main.cpp)
+
+TARGET_LINK_LIBRARIES(mysql2pgsql ${PGSQL_LIBRARIES})
+TARGET_LINK_LIBRARIES(mysql2pgsql ${MYSQL_LIBRARIES})
diff --git a/contrib/mysql_to_pgsql/README b/contrib/mysql_to_pgsql/README
new file mode 100644
index 00000000000..bf7083fb663
--- /dev/null
+++ b/contrib/mysql_to_pgsql/README
@@ -0,0 +1,14 @@
+Using cmake on a Windows
+------------------
+ 1. install cmake (http://www.cmake.org/cmake/resources/software.html)
+ 2. cmake -i
+ 3. Project.sln
+ 4. {Debug/Release}/mysql2pgsql.exe
+
+Using cmake on a Unix/Linux
+------------------
+ 1. install cmake
+ 2. cmake -i
+ 3. make
+ 4. ./mysql2pgsql
+
diff --git a/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake b/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake
new file mode 100644
index 00000000000..e7d158de275
--- /dev/null
+++ b/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake
@@ -0,0 +1,74 @@
+# - Find mysqlclient
+# Find the native MySQL includes and library
+#
+# MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
+# MYSQL_LIBRARIES - List of libraries when using MySQL.
+# MYSQL_FOUND - True if MySQL found.
+MACRO(FIND_MYSQL)
+
+IF (MYSQL_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(MySQL_FIND_QUIETLY TRUE)
+ENDIF (MYSQL_INCLUDE_DIR)
+
+FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 6.0;Location]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.1;Location]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.0;Location]/include"
+ /usr/local/mysql/include
+ /usr/local/include/mysql
+ /usr/local/include
+ /usr/include/mysql
+ /usr/include
+ /usr/mysql/include
+)
+
+IF(MSVC)
+ SET(MYSQL_NAMES libmysql)
+ELSE(MSVC)
+ SET(MYSQL_NAMES mysqlclient mysqlclient_r)
+ENDIF(MSVC)
+SET(MYSQL_SEARCH_LIB_PATHS
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 6.0;Location]/lib/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/lib/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.1;Location]/lib/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.0;Location]/lib/opt"
+ /usr/local/mysql/lib
+ /usr/local/lib/mysql
+ /usr/local/lib
+ /usr/lib/mysql
+ /usr/lib
+)
+FIND_LIBRARY(MYSQL_LIBRARY
+ NAMES ${MYSQL_NAMES}
+ PATHS ${MYSQL_SEARCH_LIB_PATHS}
+)
+
+IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+ SET(MYSQL_FOUND TRUE)
+ SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
+ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+ SET(MYSQL_FOUND FALSE)
+ SET( MYSQL_LIBRARIES )
+ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+
+IF (MYSQL_FOUND)
+ IF (NOT MySQL_FIND_QUIETLY)
+ MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
+ ENDIF (NOT MySQL_FIND_QUIETLY)
+ELSE (MYSQL_FOUND)
+ IF (MySQL_FIND_REQUIRED)
+ MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
+ MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
+ ENDIF (MySQL_FIND_REQUIRED)
+ENDIF (MYSQL_FOUND)
+
+MARK_AS_ADVANCED(
+ MYSQL_LIBRARY
+ MYSQL_INCLUDE_DIR
+)
+
+ENDMACRO(FIND_MYSQL) \ No newline at end of file
diff --git a/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake b/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake
new file mode 100644
index 00000000000..06a1adc9e7a
--- /dev/null
+++ b/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake
@@ -0,0 +1,82 @@
+# - Find libpq
+# Find the native PostgreSQL includes and library
+#
+# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc.
+# PGSQL_LIBRARIES - List of libraries when using PGSQL.
+# PGSQL_FOUND - True if PGSQL found.
+
+MACRO(FIND_PGSQL)
+IF (PGSQL_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(PostgreSQL_FIND_QUIETLY TRUE)
+ENDIF (PGSQL_INCLUDE_DIR)
+
+# the registry settings checked are in order:
+# - for pgInstaller 8.2.x postgresql version
+# - for pgInstaller 8.3.x postgresql version
+SET(PGSQL_WIN_BASE
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]")
+
+IF(PGSQL_WIN_BASE)
+ IF(MSVC)
+ SET(PGSQL_SEARCH_LIB_PATHS "${PGSQL_WIN_BASE}/lib/ms")
+ ELSE(MSVC)
+ SET(PGSQL_SEARCH_LIB_PATHS "${PGSQL_WIN_BASE}/lib")
+ ENDIF(MSVC)
+ENDIF(PGSQL_WIN_BASE)
+
+FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]/include"
+ /usr/local/pgsql/include
+ /usr/local/postgresql/include
+ /usr/local/include/pgsql
+ /usr/local/include/postgresql
+ /usr/local/include
+ /usr/include/pgsql
+ /usr/include/postgresql
+ /usr/include
+ /usr/pgsql/include
+ /usr/postgresql/include
+)
+
+SET(PGSQL_NAMES pq libpq)
+SET(PGSQL_SEARCH_LIB_PATHS
+ ${PGSQL_SEARCH_LIB_PATHS}
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]/lib"
+ /usr/local/pgsql/lib
+ /usr/local/lib
+ /usr/lib
+)
+FIND_LIBRARY(PGSQL_LIBRARY
+ NAMES ${PGSQL_NAMES}
+ PATHS ${PGSQL_SEARCH_LIB_PATHS}
+)
+
+IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
+ SET(PGSQL_FOUND TRUE)
+ SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} )
+ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
+ SET(PGSQL_FOUND FALSE)
+ SET( PGSQL_LIBRARIES )
+ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
+
+IF (PGSQL_FOUND)
+ IF (NOT PostgreSQL_FIND_QUIETLY)
+ MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}")
+ ENDIF (NOT PostgreSQL_FIND_QUIETLY)
+ELSE (PGSQL_FOUND)
+ IF (PostgreSQL_FIND_REQUIRED)
+ MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.")
+ MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library")
+ ENDIF (PostgreSQL_FIND_REQUIRED)
+ENDIF (PGSQL_FOUND)
+
+MARK_AS_ADVANCED(
+ PGSQL_LIBRARY
+ PGSQL_INCLUDE_DIR
+)
+ENDMACRO(FIND_PGSQL)
+
diff --git a/contrib/mysql_to_pgsql/src/defines.h b/contrib/mysql_to_pgsql/src/defines.h
new file mode 100644
index 00000000000..ed151bf5fae
--- /dev/null
+++ b/contrib/mysql_to_pgsql/src/defines.h
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _DEFINES_
+#define _DEFINES_
+
+#ifdef WIN32
+#include <winsock2.h>
+#pragma warning(disable:4996)
+#endif
+
+#include <libpq-fe.h>
+#include <mysql.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#include <sstream>
+#include <cstdlib>
+#include <string.h>
+using namespace std;
+
+
+#ifdef WIN32
+typedef unsigned __int64 uint64;
+typedef unsigned int uint32;
+#else
+#include <stdint.h>
+#ifndef uint64_t
+#include <linux/types.h>
+#endif
+typedef uint64_t uint64;
+typedef unsigned int uint32;
+#endif
+
+struct sField
+{
+ string name; // field name
+ string def; // field default data
+ string type; // field type
+ uint32 flags; // filed flags, see field flags;
+};
+typedef vector<sField> T_Table;
+typedef vector<string> T_TableList;
+typedef map< string, T_Table > TDataBase;
+
+static
+void pg_notice(void *arg, const char *message)
+{
+ /// Do nothing
+ //printf("%s\n", message);
+}
+
+inline
+string ConvertNativeType(enum_field_types mysqlType, uint32 length)
+{
+
+ switch (mysqlType)
+ {
+ case FIELD_TYPE_TIMESTAMP:
+ return "timestamp";
+ case FIELD_TYPE_BIT:
+ return "bit(1)";
+ case FIELD_TYPE_DATETIME:
+ return "date";
+ case FIELD_TYPE_YEAR:
+ case FIELD_TYPE_BLOB:
+ case FIELD_TYPE_SET:
+ case FIELD_TYPE_NULL:
+ case FIELD_TYPE_ENUM:
+ return "text";
+ case FIELD_TYPE_TINY:
+ case FIELD_TYPE_SHORT:
+ case FIELD_TYPE_INT24:
+ return "integer";
+ case FIELD_TYPE_LONGLONG:
+ case FIELD_TYPE_LONG:
+ {
+ string temp;
+ char str[10];
+ temp = "numeric";
+ if (length)
+ {
+ temp.append("(");
+ sprintf(str,"%d",length);
+ temp.append(str);
+ temp.append(")");
+ }
+ return temp;
+ }
+ case FIELD_TYPE_DECIMAL:
+ case FIELD_TYPE_FLOAT:
+ case FIELD_TYPE_DOUBLE:
+ return "float";
+ case FIELD_TYPE_STRING:
+ {
+ string temp;
+ char str[10];
+ temp = "char";
+ if (length)
+ {
+ temp.append("(");
+ sprintf(str,"%d",length);
+ temp.append(str);
+ temp.append(")");
+ }
+ return temp;
+ }
+ case FIELD_TYPE_VAR_STRING:
+ {
+ string temp;
+ char str[10];
+ temp = "varchar";
+ if (length)
+ {
+ temp.append("(");
+ sprintf(str,"%d",length);
+ temp.append(str);
+ temp.append(")");
+ }
+ return temp;
+ }
+ default:
+ return "text";
+ }
+ return "text";
+}
+
+inline
+bool IsNeeedEscapeString(enum_field_types mysqlType)
+{
+ switch(mysqlType)
+ {
+ case FIELD_TYPE_VAR_STRING:
+ case FIELD_TYPE_STRING:
+ case FIELD_TYPE_TINY_BLOB:
+ case FIELD_TYPE_MEDIUM_BLOB:
+ case FIELD_TYPE_LONG_BLOB:
+ case FIELD_TYPE_BLOB:
+ return true;
+ default:
+ return false;
+ }
+ return false;
+}
+
+inline
+void PG_Exec_str(string sql, PGconn *mPGconn)
+{
+ PGresult *res = PQexec (mPGconn, sql.c_str());
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ printf( "SQL: %s", sql.c_str() );
+ printf( "SQL %s", PQerrorMessage(mPGconn) );
+ }
+}
+
+void PG_Escape_Str(string& str)
+{
+ if(str.empty())
+ return;
+ char* buf = new char[str.size()*2+1];
+ PQescapeString(buf,str.c_str(),str.size());
+ str = buf;
+ delete[] buf;
+}
+
+#endif
+
diff --git a/contrib/mysql_to_pgsql/src/main.cpp b/contrib/mysql_to_pgsql/src/main.cpp
new file mode 100644
index 00000000000..8ca6772de20
--- /dev/null
+++ b/contrib/mysql_to_pgsql/src/main.cpp
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "defines.h"
+
+int main(int argc, char* argv[])
+{
+ char sPGhost[26], sPGport[26], sPGdb[26], sPGuser[26], sPGpass[26];
+ printf("Postgres connection settings\n Host>");
+ scanf("%s",sPGhost);
+ printf(" Port>");
+ scanf("%s",sPGport);
+ printf(" Base>");
+ scanf("%s",sPGdb);
+ printf(" User>");
+ scanf("%s",sPGuser);
+ printf(" Pass>");
+ scanf("%s",sPGpass);
+
+ ///////////////////////////////
+ ///////PGSQL Connect///////////
+ ///////////////////////////////
+ PGconn *mPGconn=NULL;
+ mPGconn = PQsetdbLogin(sPGhost,sPGport, NULL, NULL, sPGdb, sPGuser, sPGpass);
+
+ if (PQstatus(mPGconn) != CONNECTION_OK)
+ {
+ printf("Could not connect to Postgre database at [%s]: \n %s\n",sPGhost, PQerrorMessage(mPGconn));
+ PQfinish(mPGconn);
+ return 1;
+ }
+ else
+ {
+ printf("Connected to Postgre database at [%s]\n", sPGhost);
+ printf(" PostgreSQL server ver: [%d]\n\n",PQserverVersion(mPGconn));
+ }
+
+ /// Set dummy notice processor
+ PQsetNoticeProcessor(mPGconn, pg_notice, mPGconn);
+
+ ///////////////////////////////
+ ///////MySQL Connect///////////
+ ///////////////////////////////
+ MYSQL *mysqlInit;
+ mysqlInit = mysql_init(NULL);
+ if (!mysqlInit)
+ {
+ printf( "Could not initialize Mysql connection\n" );
+ return 1;
+ }
+
+ char sMYhost[26], sMYdb[26], sMYuser[26], sMYpass[26];
+ int iMYport;
+ printf("Mysql connection settings \n Host>");
+ scanf("%s",sMYhost);
+ printf(" Port>");
+ scanf("%d",&iMYport);
+ printf(" Base>");
+ scanf("%s",sMYdb);
+ printf(" User>");
+ scanf("%s",sMYuser);
+ printf(" Pass>");
+ scanf("%s",sMYpass);
+
+ mysql_options(mysqlInit,MYSQL_SET_CHARSET_NAME,"utf8");
+
+ MYSQL *mMysql;
+ mMysql = mysql_real_connect(mysqlInit, sMYhost, sMYuser, sMYpass, sMYdb, iMYport, NULL, 0);
+
+ if (mMysql)
+ {
+ printf( "Connected to MySQL database at [%s] \n", sMYhost);
+ printf( " MySQL client library: [%s] \n", mysql_get_client_info());
+ printf( " MySQL server ver: [%s] \n\n", mysql_get_server_info( mMysql));
+ }
+ else
+ {
+ printf("Could not connect to MySQL database at [%s]:\n %s\n", sMYhost ,mysql_error(mysqlInit));
+ mysql_close(mysqlInit);
+ return 1;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
+ MYSQL_RES *result = NULL;
+ MYSQL_ROW row;
+ MYSQL_FIELD *fields = NULL;
+ uint64 rowCount = 0;
+ uint32 fieldCount =0;
+ result = mysql_list_tables( mMysql , NULL );
+ rowCount = mysql_num_rows(result);
+
+ /***********************/
+ /* get list of tables */
+ /***********************/
+ T_TableList mTableList;
+ mTableList.reserve((size_t)rowCount);
+ while( (row = mysql_fetch_row(result)) !=NULL )
+ {
+ for (uint32 i = 0;i<mysql_num_fields(result);i++)
+ {
+ mTableList.push_back(row[i]);
+ }
+ }
+ mysql_free_result(result);
+
+ /****************************************/
+ /* convert filed type and default type */
+ /****************************************/
+ T_Table m_Table;
+ TDataBase m_DataBase_Map;
+ m_DataBase_Map.clear();
+ for (uint32 j=0; j<mTableList.size();++j)
+ {
+ result = mysql_list_fields(mMysql, mTableList[j].c_str(), NULL);
+ fieldCount = mysql_num_fields(result);
+ fields = mysql_fetch_fields(result);
+
+ for (uint32 i=0; i<fieldCount;++i)
+ {
+ sField mfield;
+ mfield.name = fields[i].name;
+ if (!fields[i].def)
+ {
+ mfield.def = "NULL";
+ }
+ else if (!strcmp(fields[i].def,"0000-00-00 00:00:00"))
+ {
+ /// Convert MySQL Default timestamp to PGSQL Default timestamp
+ mfield.def.append("'1970-01-01 00:00:00'");
+ }
+ else
+ {
+ /// Append '
+ mfield.def.append("'");
+ mfield.def.append(fields[i].def);;
+ mfield.def.append("'");
+ }
+ mfield.type = ConvertNativeType(fields[i].type,fields[i].length);
+ mfield.flags = fields[i].flags;
+ m_Table.push_back(mfield);
+ }
+ m_DataBase_Map[mTableList[j]] = m_Table;
+ m_Table.clear();
+ mysql_free_result(result);
+ }
+
+ /******************************************/
+ /* Conversion of the layout of the tables */
+ /******************************************/
+
+ uint32 count = 0;
+ TDataBase::const_iterator citr;
+ for (citr = m_DataBase_Map.begin(); citr != m_DataBase_Map.end(); ++citr)
+ {
+ ostringstream sql_str;
+ sql_str<<"DROP TABLE IF EXISTS "<<(*citr).first.c_str()<<";\n";
+ sql_str<<"CREATE TABLE "<<(*citr).first.c_str()<<"(\n";
+
+ T_Table::const_iterator v_iter;
+ ostringstream prim_key_str;
+ ostringstream index_str;
+ for (v_iter = (*citr).second.begin();
+ v_iter != (*citr).second.end();
+ ++v_iter)
+ {
+ sql_str<<" "<<(*v_iter).name;
+ if (((*v_iter).flags & AUTO_INCREMENT_FLAG)!=0)
+ {
+ /// AUTO_INCREMENT fields not have "default" data
+ sql_str<<" bigserial";
+ }
+ else
+ {
+ sql_str<<" "<<(*v_iter).type;
+ sql_str<<" default "<<(*v_iter).def;
+ }
+ /// IF column have PRIMARY KEY flag then use column in PRIMARY KEY
+ if (IS_PRI_KEY( (*v_iter).flags )!=0)
+ {
+ if( prim_key_str.str().size())
+ prim_key_str << ", ";
+ else
+ {
+ prim_key_str << "ALTER TABLE ";
+ prim_key_str << (*citr).first.c_str();
+ prim_key_str << " ADD CONSTRAINT pk_";
+ prim_key_str << (*citr).first.c_str();
+ prim_key_str << "_";
+ prim_key_str << (*v_iter).name;
+ prim_key_str << " PRIMARY KEY (";
+ }
+ prim_key_str<<(*v_iter).name;
+ }
+ else if (((*v_iter).flags & MULTIPLE_KEY_FLAG)!=0)
+ {
+ /// IF column have INDEX flag then create INDEX
+ index_str << "CREATE INDEX idx_";
+ index_str << (*citr).first.c_str();
+ index_str << "_";
+ index_str << (*v_iter).name;
+ index_str << " ON ";
+ index_str << (*citr).first.c_str();
+ index_str << " USING btree (";
+ index_str << (*v_iter).name;
+ index_str << ");\n";
+ }
+ else if (((*v_iter).flags & UNIQUE_KEY_FLAG)!=0)
+ {
+ /// IF column have UNIQUE INDEX flag then create INDEX
+ index_str << "CREATE UNIQUE INDEX uidx_";
+ index_str << (*citr).first.c_str();
+ index_str << "_";
+ index_str << (*v_iter).name;
+ index_str << " ON ";
+ index_str << (*citr).first.c_str();
+ index_str << " USING btree (";
+ index_str << (*v_iter).name;
+ index_str << ");\n";
+ }
+ /// don't output "," for last column
+ if(v_iter + 1 != (*citr).second.end())
+ sql_str<< ",\n";
+ else
+ sql_str<< "\n";
+ }
+ sql_str<< ")\n";
+
+ /// Out Table structure
+ PG_Exec_str(sql_str.str(),mPGconn);
+
+ /// out PRIMARY KEY
+ if(prim_key_str.str().size())
+ {
+ prim_key_str<<")";
+ PG_Exec_str(prim_key_str.str(),mPGconn);
+ }
+
+ /// out INDEX's
+ if (index_str.str().size())
+ PG_Exec_str(index_str.str(),mPGconn);
+
+ ++count;
+ printf("Convert [%d] tables...\r",count);
+ }
+ printf("Completed the conversion of [%d] tables!\n", count);
+
+ /****************/
+ /* Copying data */
+ /****************/
+
+ count = 0;
+ for (uint32 j=0; j<mTableList.size();++j)
+ {
+ ostringstream sql_str;
+ sql_str << "SELECT * FROM ";
+ sql_str << mTableList[j].c_str();
+
+ if (mysql_query(mysqlInit,sql_str.str().c_str()) )
+ continue;
+ if (!(result = mysql_store_result(mysqlInit)))
+ continue;
+
+ while ((row = mysql_fetch_row(result))!=NULL)
+ {
+ ostringstream insert_str;
+ insert_str << "INSERT INTO ";
+ insert_str << mTableList[j].c_str();
+ insert_str << " VALUES (";
+
+ fieldCount = mysql_num_fields(result);
+ fields = mysql_fetch_fields(result);
+ for (uint32 i = 0 ; i < fieldCount ; ++i)
+ {
+ if (!row[i])
+ insert_str << "NULL";
+ else
+ {
+ if (IsNeeedEscapeString(fields[i].type))
+ {
+ string field_str = row[i];
+ PG_Escape_Str(field_str);
+ insert_str << "E'";
+ insert_str << field_str.c_str();
+ insert_str << "'";
+ }
+ else if (!strcmp(row[i],"0000-00-00 00:00:00"))
+ {
+ /// Convert MySQL timestamp to PGSQL timestamp
+ insert_str << "'1970-01-01 00:00:00'";
+ }
+ else
+ {
+ insert_str << "'";
+ insert_str << row[i];
+ insert_str << "'";
+ }
+ }
+
+ /// don't output "," for last column
+ if(i + 1 != fieldCount )
+ insert_str<< ",";
+ else
+ insert_str<< ")\n";
+ }
+ PG_Exec_str(insert_str.str(), mPGconn);
+ }
+ mysql_free_result(result);
+ ++count;
+ printf("Copied data from [%d] tables...\r",count);
+ }
+ printf("Finished copying the data from [%d] tables!\n",count);
+ mTableList.clear();
+ m_DataBase_Map.clear();
+
+ /// Close connections
+ mysql_close(mMysql);
+ PQfinish(mPGconn);
+
+ printf("end\n");
+ return 0;
+
+}
+
diff --git a/contrib/vmap_assembler/vmap_assembler.cpp b/contrib/vmap_assembler/vmap_assembler.cpp
index bf720099788..e6a3089f328 100644
--- a/contrib/vmap_assembler/vmap_assembler.cpp
+++ b/contrib/vmap_assembler/vmap_assembler.cpp
@@ -78,42 +78,44 @@ bool readConfigFile(char *pConffile, VMAP::TileAssembler* pTa)
//=======================================================
int main(int argc, char* argv[])
{
- if(argc == 3 || argc == 4)
+ if(argc != 3 && argc != 4)
{
- bool ok = true;
- char *src = argv[1];
- char *dest = argv[2];
- char *conffile = NULL;
- if(argc >= 4) {
- conffile = argv[3];
- }
- VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest));
- ta->setModelNameFilterMethod(modelNameFilter);
+ printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
+ return 1;
+ }
- /*
- All the names in the list are considered to be world maps or huge instances.
- These maps will be spilt into tiles in the vmap assemble process
- */
- if(conffile != NULL) {
- ok = readConfigFile(conffile, ta);
- if(!ok) {
- printf("Can not open file config file: %s\n", conffile);
- }
- }
- if(ok) { ok = ta->convertWorld(); }
- if(ok) {
- printf("Ok, all done\n");
- } else {
- printf("exit with errors\n");
+ char *src = argv[1];
+ char *dest = argv[2];
+ char *conffile = NULL;
+ if(argc >= 4)
+ conffile = argv[3];
+
+ VMAP::TileAssembler* ta = new VMAP::TileAssembler(std::string(src), std::string(dest));
+ ta->setModelNameFilterMethod(modelNameFilter);
+
+ /*
+ All the names in the list are considered to be world maps or huge instances.
+ These maps will be spilt into tiles in the vmap assemble process
+ */
+ if(conffile != NULL)
+ {
+ if(!readConfigFile(conffile, ta))
+ {
+ printf("Can not open file config file: %s\n", conffile);
+ delete ta;
return 1;
}
- delete ta;
}
- else
+
+ if(!ta->convertWorld())
{
- printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv[0]);
+ printf("exit with errors\n");
+ delete ta;
return 1;
}
+
+ delete ta;
+ printf("Ok, all done\n");
return 0;
}
diff --git a/contrib/vmap_debugger/ModelContainerView.cpp b/contrib/vmap_debugger/ModelContainerView.cpp
index f9b19c2a1fd..fbfa565696f 100644
--- a/contrib/vmap_debugger/ModelContainerView.cpp
+++ b/contrib/vmap_debugger/ModelContainerView.cpp
@@ -451,7 +451,7 @@ namespace VMAP
//====================================================================
- Vector3 ModelContainerView::convertPositionToTrinityRep(float x, float y, float z) const {
+ Vector3 ModelContainerView::convertPositionToMangosRep(float x, float y, float z) const {
float pos[3];
pos[0] = z;
pos[1] = x;
@@ -490,7 +490,7 @@ namespace VMAP
#if 0
i_App->defaultController.getPosition();
Vector3 pos = i_App->defaultController.getPosition();
- Vector3 pos2 = convertPositionToTrinityRep(pos.x, pos.y, pos.z);
+ Vector3 pos2 = convertPositionToMangosRep(pos.x, pos.y, pos.z);
//Vector3 pos3 = iVMapManager->convertPositionToInternalRep(pos2.x, pos2.y, pos2.z);
//pos3 = iVMapManager->convertPositionToInternalRep(pos2.x, pos2.y, pos2.z);
diff --git a/contrib/vmap_extract_assembler_bin/vmap_assembler.exe b/contrib/vmap_extract_assembler_bin/vmap_assembler.exe
index 5cb08f770aa..9c8b5f2d3fb 100644
--- a/contrib/vmap_extract_assembler_bin/vmap_assembler.exe
+++ b/contrib/vmap_extract_assembler_bin/vmap_assembler.exe
Binary files differ
diff --git a/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe b/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe
index c38b6e64f64..213705f6cdf 100644
--- a/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe
+++ b/contrib/vmap_extract_assembler_bin/vmapextract_v2.exe
Binary files differ
diff --git a/contrib/vmap_extractor_v2/doc/MoPaQ_0.9.txt b/contrib/vmap_extractor_v2/doc/MoPaQ_0.9.txt
deleted file mode 100644
index ce8d8f70166..00000000000
--- a/contrib/vmap_extractor_v2/doc/MoPaQ_0.9.txt
+++ /dev/null
@@ -1,318 +0,0 @@
-THE MOPAQ ARCHIVE FORMAT
-v0.9 (Thursday, June 30, 2005)
-by Justin Olbrantz(Quantam)
-
-Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quoting
-in other works is freely allowed, as long as the source and author of the quote is stated.
-
-TABLE OF CONTENTS
-1. Introduction to the MoPaQ Format
-2. The MoPaQ Format
- 2.1 General Archive Layout
- 2.2 Archive Header
- 2.3 Block Table
- 2.4 Hash Table
- 2.5 File Data
- 2.6 Listfile
- 2.7 Extended Attributes
- 2.8 Weak (Old) Digital Signature
- 2.9 Strong (New) Digital Signature
-3. Algorithm Source Code
- 3.1 Encryption/Decryption
- 3.2 Hashing
- 3.3 Conversion of FILETIME and time_t
-
-1. INTRODUCTION TO THE MOPAQ FORMAT
-The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard
-Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be
-a read-only game archive format, and excels at this role.
-
-The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked.
-The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked.
-
-2. THE MOPAQ FORMAT
-All numbers in the MoPaQ format are in little endian. Data types are listed either as int (integer, the number of bits specified),
-byte (8 bits), and char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise.
-Structure members are listed in the following general form:
-offset from the beginning of the structure: data type(array size) member name : member description
-
-2.1 GENERAL ARCHIVE LAYOUT
-- Archive Header
-- File Data
-- File Data - Special Files
-- Hash Table
-- Block Table
-- Strong Digital signature
-
-This is the usual archive format, and is not absolutely essential. Some archives have been observed placing the hash table
-and file table after the archive header, and before the file data.
-
-2.2 ARCHIVE HEADER
-00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah.
-04h: int32 HeaderSize : Size of the archive header. Should be 32.
-08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present.
-This size is used, among other things, for determining the region to hash in computing the digital signature.
-0Ch: int16 Unknown : Unknown
-0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector
-in the archive. The size of each logical sector the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate
-that this should always be 3 (4096 byte sectors).
-10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive.
-14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive.
-18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16.
-1Ch: int32 BlockTableEntries : Number of entries in the block table.
-
-The archive header is the first structure in the archive, at archive offset 0, but the archive does not need to be at offset
-0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not
-at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the
-archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer
-versions (due to the strong digital signature not being considered a part of the archive).
-
-2.3 BLOCK TABLE
-The block table contains entries for each region in the archive. Regions may be either files or empty space, which may be
-overwritten by new files (typically this space is from deleted file data). The block table is encrypted, using the hash
-of "(block table)" as the key. Each entry is structured as follows:
-
-00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive. Meaningless if the block size is 0.
-04h: int32 BlockSize : Size of the block in the archive.
-08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file, otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data.
-0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified:
- 80000000h: Block is a file, and follows the file data format; otherwise, block is free space, and may be overwritten. If the block is not a file, all other flags should be cleared.
- 01000000h: File is stored as a single unit, rather than split into sectors.
- 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted.
- 00010000h: File is encrypted.
- 00000200h: File is compressed. Mutually exclusive to file imploded.
- 00000100h: File is imploded. Mutually exclusive to file compressed.
-
-2.4 HASH TABLE
-Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows:
-
-00h: int32 FilePathHashA : The hash of the file path, using method A.
-04h: int32 FilePathHashB : The hash of the file path, using method B.
-08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral.
-0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed.
-0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values:
- FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file.
- FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file.
-
-2.5 FILE DATA
-00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector's data, relative to the beginning of the file data. Not present if this information is calculatable (see details below).
-immediately following SectorOffsetTable: SectorData : Data of each sector in the file, packed end to end (see details below).
-
-Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may be smaller than this, depending on the size of the file data. This sector size is the size of the raw file data; if the file is compressed, the compressed sector will be smaller or the same size as the uncompressed sector size. Individual sectors in a compressed file may be stored uncompressed; this occurs if and only if the sector could not be compressed by the algorithm used (if the compressed sector size was greater than or equal to the size of the raw data), and is indicated by the sector's compressed size in SectorOffsetTable being equal to the uncompressed size of the sector (which may be calculated from the FileSize).
-
-If the sector is compressed (but not imploded), a bit mask byte of the compression algorithm(s) used to compress the sector is appended to the beginning of the compressed sector data. This additional byte counts towards the total size of the sector; if the size of the sector (including this byte) exceeds or matches the uncompressed size of the sector data, the sector will be stored uncompressed, and this byte omitted. Multiple compression algorithms may be used on the same sector; in this case, successive compression occurs in the order the algorithms are listed below, and decompression occurs in the opposite order. For implimentations of all of these algorithms, see StormLib.
- 40h: IMA ADPCM mono
- 80h: IMA ADPCM stereo
- 01h: Huffman encoded
- 02h: Deflated (see ZLib)
- 08h: Imploded (see PKWare Data Compression Library)
- 10h: BZip2 compressed (see BZip2)
-
-If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which
-contains the entire file.
-
-If the file is encrypted, each sector (after compression and appendage of the compression type byte, if applicable)
-is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the
-directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is
-adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset)
-XOR FileSize) (StormLib - an open-source implementation of the MoPaQ reading and writing functions,
-by Ladislav Zezula - incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the
-0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1.
-
-The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize.
-This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors
-is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the
-SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously.
-Note that the SectorOffsetTable will always be present if the file is compressed/imploded and the file is not stored as
-a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the
-archive's sector size).
-
-2.6 LISTFILE
-The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive.
-The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)",
-and is simply a non-Unix-style text file with one file path on each line, lines terminated with the bytes 0Dh 0Ah. The file
-"(listfile)" may not be listed in the listfile.
-
-2.7 EXTENDED ATTRIBUTES
-The extended attributes are optional file attributes for files in the block table. These attributes were added at times after
-the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes.
-If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although
-the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the
-blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file,
-in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other
-structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some
-archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This
-file is structured as follows:
-
-00h: int32 Version : Specifies the extended attributes format version. For now, must be 100.
-04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive:
- 00000001h: File CRC32s.
- 00000002h: File timestamps.
- 00000004h: File MD5s.
-08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the
-archive does not have CRC32s. immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block
-in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps.
-immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive.
-Omitted if the archive does not have MD5s.
-
-2.8 WEAK DIGITAL SIGNATURE
-The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation of the RSASSA-PKCS1-v1_5
-digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) RSA key (for more information about this
-protocol, see the RSA Labs PKCS1 specification). The public key and exponent are stored in a resource in Storm. The signature
-is stored uncompressed, unencrypted in the file "(signature)" in the archive. The archive is hashed from the beginning of the
-archive (ArchiveOffset in the containing file) to the end of the archive (the length indicated by ArchiveSize); the signature
-file is added to the archive before signing, and the space occupied by the file is considered to be all binary 0s during
-signing/verification. This file is structured as follows:
-
-00h: int32 Unknown : Must be 0.
-04h: int32 Unknown : must be 0.
-08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored in little-endian order.
-
-2.9 STRONG DIGITAL SIGNATURE
-The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and
-a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well.
-The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize
-bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format:
-
-00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards).
-04h: int2048 Signature : The digital signature, stored in little-endian format.
-
-When the Signature field is decrypted with the public key and exponent, and the result stored in little-endian order, it is structured as follows:
-
-00h: byte Padding : Must be 0Bh.
-01h: byte(235) Padding : Must be BBh.
-ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 format.
-
-3. ALGORITHM SOURCE CODE
-3.1 ENCRYPTION/DECRYPTION
-I believe this was derived at some point from code in StormLib. Assumes the long type to be 32 bits, and the machine to be little endian order.
-
-unsigned long dwCryptTable[0x500];
-
-void InitializeCryptTable()
-{
- unsigned long seed = 0x00100001;
- unsigned long index1 = 0;
- unsigned long index2 = 0;
- int i;
-
- for (index1 = 0; index1 < 0x100; index1++)
- {
- for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100)
- {
- unsigned long temp1, temp2;
-
- seed = (seed * 125 + 3) % 0x2AAAAB;
- temp1 = (seed & 0xFFFF) << 0x10;
-
- seed = (seed * 125 + 3) % 0x2AAAAB;
- temp2 = (seed & 0xFFFF);
-
- dwCryptTable[index2] = (temp1 | temp2);
- }
- }
-}
-
-void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey)
-{
- unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer;
- unsigned long seed = 0xEEEEEEEE;
- unsigned long ch;
-
- assert(lpbyBuffer);
-
- dwLength /= sizeof(unsigned long);
-
- while(dwLength-- > 0)
- {
- seed += dwCryptTable[0x400 + (dwKey & 0xFF)];
- ch = *lpdwBuffer ^ (dwKey + seed);
-
- dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B);
- seed = *lpdwBuffer + seed + (seed << 5) + 3;
-
- *lpdwBuffer++ = ch;
- }
-}
-
-void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey)
-{
- unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer;
- unsigned long seed = 0xEEEEEEEE;
- unsigned long ch;
-
- assert(lpbyBuffer);
-
- dwLength /= sizeof(unsigned long);
-
- while(dwLength-- > 0)
- {
- seed += dwCryptTable[0x400 + (dwKey & 0xFF)];
- ch = *lpdwBuffer ^ (dwKey + seed);
-
- dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B);
- seed = ch + seed + (seed << 5) + 3;
-
- *lpdwBuffer++ = ch;
- }
-}
-
-3.2 HASHING
-Based on code from StormLib.
-
-// Different types of hashes to make with HashString
-#define MPQ_HASH_TABLE_OFFSET 0
-#define MPQ_HASH_NAME_A 1
-#define MPQ_HASH_NAME_B 2
-#define MPQ_HASH_FILE_KEY 3
-
-unsigned long HashString(const char *lpszString, unsigned long dwHashType)
-{
- unsigned long seed1 = 0x7FED7FED;
- unsigned long seed2 = 0xEEEEEEEE;
- int ch;
-
- while (*lpszString != 0)
- {
- ch = toupper(*lpszString++);
-
- seed1 = dwCryptTable[(dwHashType * 0xFF) + ch] ^ (seed1 + seed2);
- seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3;
- }
- return seed1;
-}
-
-3.3 CONVERSION OF FILETIME AND time_t
-
-#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970
-
-bool GetTimeFromFileTime(FILETIME &fileTime, time_t &time)
-{
- // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601
- unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime;
-
- if (nTime < EPOCH_OFFSET)
- return false;
-
- nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970
- nTime /= 10000000ULL; // Convert 100 ns to sec
-
- time = (time_t)nTime;
-
- // Test for overflow (FILETIME is 64 bits, time_t is 32 bits)
- if ((nTime - (unsigned long long)time) > 0)
- return false;
-
- return true;
-}
-
-void GetFileTimeFromTime(time_t &time, FILETIME &fileTime)
-{
- unsigned long long nTime = (unsigned long long)time;
-
- nTime *= 10000000ULL;
- nTime += EPOCH_OFFSET;
-
- fileTime.dwLowDateTime = (DWORD)nTime;
- fileTime.dwHighDateTime = (DWORD)(nTime >> 32);
-}
diff --git a/contrib/vmap_extractor_v2/doc/MoPaQ_1.0.txt b/contrib/vmap_extractor_v2/doc/MoPaQ_1.0.txt
deleted file mode 100644
index 6a21eca5472..00000000000
--- a/contrib/vmap_extractor_v2/doc/MoPaQ_1.0.txt
+++ /dev/null
@@ -1,421 +0,0 @@
-THE MOPAQ ARCHIVE FORMAT
-v1.0 (Friday, September 1, 2006)
-by Justin Olbrantz(Quantam)
-
-Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quotation in other works is freely allowed, as long as the source and author of the quote are stated.
-
-TABLE OF CONTENTS
-1. Introduction to the MoPaQ Format
-2. The MoPaQ Format
- 2.1 General Archive Layout
- 2.2 Archive Header
- 2.3 Block Table
- 2.4 Extended Block Table
- 2.5 Hash Table
- 2.6 File Data
- 2.7 Listfile
- 2.8 Extended Attributes
- 2.9 Weak (Old) Digital Signature
- 2.10 Strong (New) Digital Signature
-3. Algorithm Source Code
- 3.1 Encryption/Decryption
- 3.2 Hashing and File Key Computation
- 3.3 Finding Files
- 3.4 Deleting Files
- 3.5 Conversion of FILETIME and time_t
- 3.6 Forming a 64-bit Large Archive Offset from 32-bit and 16-bit Components
-4. Revision History
-
-1. INTRODUCTION TO THE MOPAQ FORMAT
-The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be a read-only game archive format, and excels at this role.
-
-The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked. The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked.
-
-StormLib - mentioned several times in this specification - is an open-source MoPaQ reading and writing library written by Ladislav Zezula (no affiliation with Blizzard Entertainment). While it's a bit dated, and does not support all of the newer MoPaQ features, it contains source code to the more exotic compression methods used by MoPaQ, such as the PKWare implode algorithm, MoPaQ's huffman compression algorithm, and the IMA ADPCM compression used by MoPaQ.
-
-2. THE MOPAQ FORMAT
-All numbers in the MoPaQ format are in little endian byte order; signed numbers use the two's complement system. Data types are listed either as int (integer, the number of bits specified), byte (8 bits), or char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise. Structure members are listed in the following general form:
-offset from the beginning of the structure: data type(array size) member name : member description
-
-2.1 GENERAL ARCHIVE LAYOUT
-- Archive Header
-- File Data
-- File Data - Special Files
-- Hash Table
-- Block Table
-- Extended Block Table
-- Strong Digital signature
-
-This is the usual archive format, but it is not mandatory. Some archives have been observed placing the hash table and file table after the archive header, and before the file data.
-
-2.2 ARCHIVE HEADER
-00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah.
-04h: int32 HeaderSize : Size of the archive header.
-08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present. This size is used, among other things, for determining the region to hash in computing the digital signature. This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive is calculated as the size from the beginning of the archive to the end of the hash table, block table, or extended block table (whichever is largest).
-0Ch: int16 FormatVersion : MoPaQ format version. MPQAPI will not open archives where this is negative. Known versions:
- 0000h: Original format. HeaderSize should be 20h, and large archives are not supported.
- 0001h: Burning Crusade format. Header size should be 2Ch, and large archives are supported.
-0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors).
-10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive.
-14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive.
-18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for the original MoPaQ format, or less than 2^20 for the Burning Crusade format.
-1Ch: int32 BlockTableEntries : Number of entries in the block table.
-Fields only present in the Burning Crusade format and later:
-20h: int64 ExtendedBlockTableOffset : Offset to the beginning of the extended block table, relative to the beginning of the archive.
-28h: int16 HashTableOffsetHigh : High 16 bits of the hash table offset for large archives.
-2Ah: int16 BlockTableOffsetHigh : High 16 bits of the block table offset for large archives.
-
-The archive header is the first structure in the archive, at archive offset 0; however, the archive does not need to be at offset 0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer versions (due to the strong digital signature not being considered a part of the archive).
-
-2.3 BLOCK TABLE
-The block table contains entries for each region in the archive. Regions may be either files, empty space, which may be overwritten by new files (typically this space is from deleted file data), or unused block table entries. Empty space entries should have BlockOffset and BlockSize nonzero, and FileSize and Flags zero; unused block table entries should have BlockSize, FileSize, and Flags zero. The block table is encrypted, using the hash of "(block table)" as the key. Each entry is structured as follows:
-
-00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive.
-04h: int32 BlockSize : Size of the block in the archive.
-08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file; otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data.
-0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified:
- 80000000h: Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.
- 01000000h: File is stored as a single unit, rather than split into sectors.
- 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted.
- 00010000h: File is encrypted.
- 00000200h: File is compressed. File cannot be imploded.
- 00000100h: File is imploded. File cannot be compressed.
-
-2.4 EXTENDED BLOCK TABLE
-The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). The table contains the upper bits of the archive offsets for each block in the block table. It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size.
-
-As of the Burning Crusade Friends and Family beta, this table is not encrypted.
-
-2.5 HASH TABLE
-Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows:
-
-00h: int32 FilePathHashA : The hash of the file path, using method A.
-04h: int32 FilePathHashB : The hash of the file path, using method B.
-08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral.
-0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed.
-0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values:
- FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file.
- FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file.
-
-2.6 FILE DATA
-The data for each file is composed of the following structure:
-00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector, relative to the beginning of the file data. The last entry contains the file size, making it possible to easily calculate the size of any given sector. This table is not present if this information can be calculated (see details below).
-immediately following SectorOffsetTable: SECTOR Sectors(SectorsInFile) : Data of each sector in the file, packed end to end (see details below).
-
-Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may contain less than this, depending on the size of the entire file's data. If the file is compressed or imploded, the sector will be smaller or the same size as the file data it contains. Individual sectors in a compressed or imploded file may be stored uncompressed; this occurs if and only if the file data the sector contains could not be compressed by the algorithm(s) used (if the compressed sector size was greater than or equal to the size of the file data), and is indicated by the sector's size in SectorOffsetTable being equal to the size of the file data in the sector (which may be calculated from the FileSize).
-
-The format of each sector depends on the kind of sector it is. Uncompressed sectors are simply the the raw file data contained in the sector. Imploded sectors are the raw compressed data following compression with the implode algorithm (these sectors can only be in imploded files). Compressed sectors (only found in compressed - not imploded - files) are compressed with one or more compression algorithms, and have the following structure:
-00h: byte CompressionMask : Mask of the compression types applied to this sector. If multiple compression types are used, they are applied in the order listed below, and decompression is performed in the opposite order. This byte counts towards the total sector size, meaning that the sector will be stored uncompressed if the data cannot be compressed by at least two bytes; as well, this byte is encrypted with the sector data, if applicable. The following compression types are defined (for implementations of these algorithms, see StormLib):
- 40h: IMA ADPCM mono
- 80h: IMA ADPCM stereo
- 01h: Huffman encoded
- 02h: Deflated (see ZLib)
- 08h: Imploded (see PKWare Data Compression Library)
- 10h: BZip2 compressed (see BZip2)
-01h: byte(SectorSize - 1) SectorData : The compressed data for the sector.
-
-If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which contains the entire file data.
-
-If the file is encrypted, each sector (after compression/implosion, if applicable) is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset) XOR FileSize) (StormLib incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the 0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1.
-
-The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize. This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously. However, the SectorOffsetTable will be present if the file is compressed/imploded and the file is not stored as a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the archive's sector size).
-
-2.7 LISTFILE
-The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive. The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)" (default language and platform), and is simply a text file with file paths separated by ';', 0Dh, 0Ah, or some combination of these. The file "(listfile)" may not be listed in the listfile.
-
-2.8 EXTENDED ATTRIBUTES
-The extended attributes are optional file attributes for files in the block table. These attributes were added at times after the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes. If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file (default language and platform), in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This file is structured as follows:
-
-00h: int32 Version : Specifies the extended attributes format version. For now, must be 100.
-04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive:
- 00000001h: File CRC32s.
- 00000002h: File timestamps.
- 00000004h: File MD5s.
-08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have CRC32s.
-immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps.
-immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have MD5s.
-
-2.9 WEAK DIGITAL SIGNATURE
-The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation of the RSASSA-PKCS1-v1_5 digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) RSA key (for more information about this protocol, see the RSA Labs PKCS1 specification). The public key and exponent are stored in a resource in Storm, the private key is stored in a separate file, whose filename is passed to MPQAPI (the private key is not stored in MPQAPI). The signature is stored uncompressed, unencrypted in the file "(signature)" (default language and platform) in the archive. The archive is hashed from the beginning of the archive (ArchiveOffset in the containing file) to the end of the archive (the length indicated by ArchiveSize, or calculated in the Burning Crusade MoPaQ format); the signature file is added to the archive before signing, and the space occupied by the file is considered to be all binary 0s during signing/verification. This file is structured as follows:
-
-00h: int32 Unknown : Must be 0.
-04h: int32 Unknown : Must be 0.
-08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored in little-endian order. The structure of this, when decrypted, follows the RSASSA-PKCS1-v1_5 specification; this format is rather icky to work with (I wrote a program to verify this signature using nothing but an MD5 function and huge integer functions; it wasn't pleasant), and best left to an encryption library such as Cryto++.
-
-2.10 STRONG DIGITAL SIGNATURE
-The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well. The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format:
-
-00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards).
-04h: int2048 Signature : The digital signature, stored in little-endian format.
-
-When the Signature field is decrypted with the public key and exponent, and the resulting large integer is stored in little-endian order, it is structured as follows:
-
-00h: byte Padding : Must be 0Bh.
-01h: byte(235) Padding : Must be BBh.
-ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 byte order.
-
-3. ALGORITHM SOURCE CODE
-All of the sample code here assumes little endian machine byte order, that the short type is 16 bits, that the long type is 32 bits, and that the long long type is 64 bits. Adjustments must be made if these assumptions are not correct on a given platform. All code not credited otherwise was written by myself in the writing of this specification.
-
-3.1 ENCRYPTION/DECRYPTION
-Based on code from StormLib.
-
-unsigned long dwCryptTable[0x500];
-
-// The encryption and hashing functions use a number table in their procedures. This table must be initialized before the functions are called the first time.
-void InitializeCryptTable()
-{
- unsigned long seed = 0x00100001;
- unsigned long index1 = 0;
- unsigned long index2 = 0;
- int i;
-
- for (index1 = 0; index1 < 0x100; index1++)
- {
- for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100)
- {
- unsigned long temp1, temp2;
-
- seed = (seed * 125 + 3) % 0x2AAAAB;
- temp1 = (seed & 0xFFFF) << 0x10;
-
- seed = (seed * 125 + 3) % 0x2AAAAB;
- temp2 = (seed & 0xFFFF);
-
- dwCryptTable[index2] = (temp1 | temp2);
- }
- }
-}
-
-void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey)
-{
- assert(lpbyBuffer);
-
- unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer;
- unsigned long seed = 0xEEEEEEEE;
- unsigned long ch;
-
- dwLength /= sizeof(unsigned long);
-
- while(dwLength-- > 0)
- {
- seed += dwCryptTable[0x400 + (dwKey & 0xFF)];
- ch = *lpdwBuffer ^ (dwKey + seed);
-
- dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B);
- seed = *lpdwBuffer + seed + (seed << 5) + 3;
-
- *lpdwBuffer++ = ch;
- }
-}
-
-void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey)
-{
- assert(lpbyBuffer);
-
- unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer;
- unsigned long seed = 0xEEEEEEEEL;
- unsigned long ch;
-
- dwLength /= sizeof(unsigned long);
-
- while(dwLength-- > 0)
- {
- seed += dwCryptTable[0x400 + (dwKey & 0xFF)];
- ch = *lpdwBuffer ^ (dwKey + seed);
-
- dwKey = ((~dwKey << 0x15) + 0x11111111L) | (dwKey >> 0x0B);
- seed = ch + seed + (seed << 5) + 3;
-
- *lpdwBuffer++ = ch;
- }
-}
-
-3.2 HASHING AND FILE KEY COMPUTATION
-These functions may have been derived from StormLib code at some point in the very distant past. It was so long ago that I don't remember for certain.
-
-// Different types of hashes to make with HashString
-#define MPQ_HASH_TABLE_OFFSET 0
-#define MPQ_HASH_NAME_A 1
-#define MPQ_HASH_NAME_B 2
-#define MPQ_HASH_FILE_KEY 3
-
-// Based on code from StormLib.
-unsigned long HashString(const char *lpszString, unsigned long dwHashType)
-{
- assert(lpszString);
- assert(dwHashType <= MPQ_HASH_FILE_KEY);
-
- unsigned long seed1 = 0x7FED7FEDL;
- unsigned long seed2 = 0xEEEEEEEEL;
- int ch;
-
- while (*lpszString != 0)
- {
- ch = toupper(*lpszString++);
-
- seed1 = dwCryptTable[(dwHashType * 0x100) + ch] ^ (seed1 + seed2);
- seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3;
- }
- return seed1;
-}
-
-#define BLOCK_OFFSET_ADJUSTED_KEY 0x00020000L
-
-unsigned long ComputeFileKey(const char *lpszFilePath, const BlockTableEntry &blockEntry, unsigned long nArchiveOffset)
-{
- assert(lpszFilePath);
-
- // Find the file name part of the path
- const char *lpszFileName = strrchr(lpszFilePath, '\\');
- if (lpszFileName)
- lpszFileName++; // Skip the \
- else
- lpszFileName = lpszFilePath;
-
- // Hash the name to get the base key
- unsigned long nFileKey = HashString(lpszFileName, MPQ_HASH_FILE_KEY);
-
- // Offset-adjust the key if necessary
- if (blockEntry.Flags & BLOCK_OFFSET_ADJUSTED_KEY)
- nFileKey = (nFileKey + blockEntry.BlockOffset) ^ blockEntry.FileSize;
-
- return nFileKey;
-}
-
-3.3 FINDING FILES
-
-#define MPQ_HASH_ENTRY_EMPTY 0xFFFFFFFFL
-#define MPQ_HASH_ENTRY_DELETED 0xFFFFFFFEL
-
-bool FindFileInHashTable(const HashTableEntry *lpHashTable, unsigned long nHashTableSize, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform, unsigned long &iFileHashEntry)
-{
- assert(lpHashTable);
- assert(nHashTableSize);
- assert(lpszFilePath);
-
- // Find the home entry in the hash table for the file
- unsigned long iInitEntry = HashString(lpszFilePath, MPQ_HASH_TABLE_OFFSET) & (nHashTableSize - 1);
-
- // Is there anything there at all?
- if (lpHashTable[iInitEntry].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY)
- return false;
-
- // Compute the hashes to compare the hash table entry against
- unsigned long nNameHashA = HashString(lpszFilePath, MPQ_HASH_NAME_A),
- nNameHashB = HashString(lpszFilePath, MPQ_HASH_NAME_B),
- iCurEntry = iInitEntry;
-
- // Check each entry in the hash table till a termination point is reached
- do
- {
- if (lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_DELETED)
- {
- if (lpHashTable[iCurEntry].FilePathHashA == nNameHashA
- && lpHashTable[iCurEntry].FilePathHashB == nNameHashB
- && lpHashTable[iCurEntry].Language == nLang
- && lpHashTable[iCurEntry].Platform == nPlatform)
- {
- iFileHashEntry = iCurEntry;
-
- return true;
- }
- }
-
- iCurEntry = (iCurEntry + 1) & (nHashTableSize - 1);
- } while (iCurEntry != iInitEntry && lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_EMPTY);
-
- return false;
-}
-
-3.4 DELETING FILES
-
-bool DeleteFile(HashTableEntry *lpHashTable, unsigned long nHashTableSize, BlockTableEntry *lpBlockTable, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform)
-{
- assert(lpHashTable);
- assert(nHashTableSize);
- assert(lpBlockTable);
-
- // Find the file in the hash table
- unsigned long iFileHashEntry;
-
- if (!FindFileInHashTable(lpHashTable, nHashTableSize, lpszFilePath, nLang, nPlatform, iFileHashEntry))
- return false;
-
- // Get the block table index before we nuke the hash table entry
- unsigned long iFileBlockEntry = lpHashTable[iFileHashEntry].FileBlockIndex;
-
- // Delete the file's entry in the hash table
- memset(&lpHashTable[iFileHashEntry], 0xFF, sizeof(HashTableEntry));
-
- // If the next entry is empty, mark this one as empty; otherwise, mark this as deleted.
- if (lpHashTable[(iFileHashEntry + 1) & (nHashTableSize - 1)].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY)
- lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_EMPTY;
- else
- lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_DELETED;
-
- // If the block occupies space, mark the block as free space; otherwise, clear the block table entry.
- if (lpBlockTable[iFileBlockEntry].BlockSize > 0)
- {
- lpBlockTable[iFileBlockEntry].FileSize = 0;
- lpBlockTable[iFileBlockEntry].Flags = 0;
- }
- else
- memset(&lpBlockTable[iFileBlockEntry], 0, sizeof(BlockTableEntry);
-
- return true;
-}
-
-3.5 CONVERSION OF FILETIME AND time_t
-This code assumes that the base ("zero") date for time_t is 01/01/1970. This is true on Windows, Unix System V systems, and Mac OS X. It is unknown whether this is true on all other platforms. You'll need to research this yourself, if you plan on porting it somewhere else.
-
-#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970
-
-bool GetTimeFromFileTime(const FILETIME &fileTime, time_t &time)
-{
- // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601
- unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime;
-
- if (nTime < EPOCH_OFFSET)
- return false;
-
- nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970
- nTime /= 10000000ULL; // Convert 100 ns to sec
-
- time = (time_t)nTime;
-
- // Test for overflow (FILETIME is 64 bits, time_t is 32 bits)
- if ((nTime - (unsigned long long)time) > 0)
- return false;
-
- return true;
-}
-
-void GetFileTimeFromTime(const time_t &time, FILETIME &fileTime)
-{
- unsigned long long nTime = (unsigned long long)time;
-
- nTime *= 10000000ULL;
- nTime += EPOCH_OFFSET;
-
- fileTime.dwLowDateTime = (DWORD)nTime;
- fileTime.dwHighDateTime = (DWORD)(nTime >> 32);
-}
-
-3.6 FORMING A 64-BIT LARGE ARCHIVE OFFSET FROM 32-BIT AND 16-BIT COMPONENTS
-unsigned long long MakeLargeArchiveOffset(unsigned long nOffsetLow, unsigned short nOffsetHigh)
-{
- return ((unsigned long long)nOffsetHigh << 32) + (unsigned long long)nOffsetLow;
-}
-
-4. REVISION HISTORY
-1.0
- - Updated to include most of the changes found in the Burning Crusade Friends and Family beta
-
-0.91.
- - Updated several structure member descriptions
- - Listed the full set of characters that can separate list file entries
- - Noted that (attributes), (listfile), and (signature) use the default language and platform codes
- - Redid part of the file data specs to clarify the format of sectors
- - Enhanced descriptions of the different kinds of block table entries
- - Added ComputeFileKey, FindFileInHashTable, and DeleteFile source \ No newline at end of file
diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp b/contrib/vmap_extractor_v2/stormdll/StormDll.cpp
index c0772e9b2da..2031180c7e3 100644
--- a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp
+++ b/contrib/vmap_extractor_v2/stormdll/StormDll.cpp
@@ -115,4 +115,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbI
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
-
diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.h b/contrib/vmap_extractor_v2/stormdll/StormDll.h
index 6be20e59bd7..6d67820a22f 100644
--- a/contrib/vmap_extractor_v2/stormdll/StormDll.h
+++ b/contrib/vmap_extractor_v2/stormdll/StormDll.h
@@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb
#endif
#endif // __STORM_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp b/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp
index 7fd3c855f1c..665e5d38e49 100644
--- a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp
@@ -3,9 +3,9 @@
* Description: GfxDecode -- functions for reading Diablo's GFX files
* Author: Marko Friedemann <marko.friedemann@bmx-chemnitz.de>
* Created at: Son Jan 27 15:20:43 CET 2002
-* Computer: hangloose.flachland-chemnitz.de
+* Computer: hangloose.flachland-chemnitz.de
* System: Linux 2.4.16 on i686
-*
+*
* Copyright (c) 2002 BMX-Chemnitz.DE All rights reserved.
*
* ---------------------------------------------------------------------
@@ -60,12 +60,12 @@ static const uint16_t c_RampOffsetRight[17] = {
2, // __ before this, there are 2 Pixels
14, // + 12 --__ 4^2 - 2
34, // + 20 --__ 6^2 - 2
- 62, // + 28 this area --__ 8^2 - 2
+ 62, // + 28 this area --__ 8^2 - 2
98, // + 36 is always --__ 10^2 - 2 pattern anyone? ;)
- 142, // + 44 colored --__
+ 142, // + 44 colored --__
194, // + 52 --__
254, // + 60 lower ramp ends here --__ (-30 == 224)
- 318, // + 64 upper ramp might be missing __--
+ 318, // + 64 upper ramp might be missing __--
374, // + 56 __-- |
422, // + 48 this area __-- | note that this
462, // + 40 is always __-- | "drawing"
@@ -133,7 +133,7 @@ class FrameBuf
cerr << "\n +++ at (" << uCols << "," << uRows << "), see for yourself *** \n\n";
uColorNum = TRANS_COL; // sane setting to avoid segfaults
}
-
+
memcpy(pCurrRow + 4*uCols, pPalette + 4*uColorNum, 4*sizeof(uint8_t));
if (++uCols == uXSize)
addLine();
@@ -147,18 +147,18 @@ class FrameBuf
vector <uint8_t *>::reverse_iterator vri;
// allocate a buffer to hold the actual image size
uint8_t *tmp = new uint8_t[4*uXSize*uRows];
-
+
// the lines are upside down inside the vector, use reverse iterator
for (i=0, vri=vecData.rbegin(); vri!=vecData.rend(); vri++, i++)
memcpy(tmp+4*uXSize*i, *vri, 4*uXSize*sizeof(uint8_t));
-
+
*upYSize = uRows; // set height
-
+
if (uCols > 0) {
cerr << "\n*** there seemed to be an error (last line does not match boundary, " << uCols << " pixels left)";
cerr << "\n +++ this is often caused by specifying an invalid width, see for yourself *** \n\n";
}
-
+
return tmp;
}
};
@@ -183,17 +183,17 @@ uint8_t *celDecodeBlocks(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framesta
if (!pFrame->bHasBlocks) // sanity check
return NULL;
-
+
while (uFilePos < framestart[pFrame->uFrameNum+1]) {
cRead = pFileBuf[uFilePos++];
-
+
if ((uFilePos == framestart[pFrame->uFrameNum]+1))
// TODO: what is this 0x0A 0x00 stuff all about?
if ((cRead == 0x0A) && (pFileBuf[uFilePos] == 0x00)) {
uFilePos += 9;
cRead = pFileBuf[uFilePos++];
}
-
+
if (cRead > 0x7F)
// transparent block (complement, 256-val)
for (i=0; i<256-cRead; i++)
@@ -220,10 +220,10 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar
uint32_t uFilePos=0;
uint16_t uBlockLen=0, i=0, j=0;
bool bFirstLonger=false;
-
+
if (!pFrame->bHasRamps) // sanity check
return NULL;
-
+
if (pFrame->uXSize != 32) // only used in that case
return NULL;
@@ -265,7 +265,7 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar
pFrame->addPixel(pFileBuf[uFilePos++]);
}
}
-
+
// now read the last 0x00 pair and fill up
uBlockLen = (uFrameLen == c_2RampSize ? 30 : 2); // one or two ramps?
uFilePos = framestart[pFrame->uFrameNum] + (bLeft ? c_RampOffsetLeft[i] : c_RampOffsetRight[i]) + 2;
@@ -276,16 +276,16 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar
for (j=0; j<pFrame->uXSize - uBlockLen; j++)
pFrame->addPixel(pFileBuf[uFilePos++]);
}
-
+
// now the rest of the file (plain)
while (uFilePos < framestart[pFrame->uFrameNum+1])
pFrame->addPixel(pFileBuf[uFilePos++]);
-
+
// the uppermost line is emtpy when 2 ramps are used
if (uFrameLen == c_2RampSize)
for (j=0; j<pFrame->uXSize; j++)
pFrame->addPixel(TRANS_COL);
-
+
return pFrame->getData();
}
@@ -308,17 +308,17 @@ uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestar
* Comments: dirty hack, started from scratch @ 2000-10-11
* cleanly rewritten during incorporation into ladiks StormLib
* status: structured hack ;)
- *
+ *
* It took me approx. 6 days to understand the format basics (hex viewer)
* For this I had a little help from a dos tool ("ddecode", from
- * www.cowlevel.com, binary only, no sources) which, however, gave
+ * www.cowlevel.com, binary only, no sources) which, however, gave
* me the general idea what the pictures are actually supposed to look like.
- *
+ *
* The fine adjustments, however, took quite some time and a little luck.
* After I had written to various people (mickyk and ladik), which could
* not help me, but wished best luck (thanks, btw, it helped ;)), I tried
* some reverse engineering which was not succesful in the end.
- *
+ *
* I then had incidentally a new idea of what could be going on @ 2002-01-23.
* It just came to my mind that I could retry some actual painting in
* reverse order (had done that before to no avail) and when looking closer
@@ -334,48 +334,48 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
uint32_t *framestart=NULL, frames=0, uFilePos=0;
uint16_t i, tmpWord=0;
uint8_t cRead=0, *data;
-
+
memcpy(&frames, pFileBuf, sizeof(uint32_t));
uFilePos += sizeof(uint32_t);
-
+
if (pFileBuf == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (palette == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uFrameNum > frames-1) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uYSize == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
// in case we want to know the rightmost pixels column (usable eg. for fonts)
if (uMaxX != NULL)
*uMaxX = 0;
-
+
// get the frame offsets
framestart = new uint32_t[frames+1];
for (i=0; i<frames+1; i++) {
memcpy(&framestart[i], pFileBuf+uFilePos, sizeof(uint32_t));
uFilePos += sizeof(uint32_t);
}
-
+
/****** block size *************************************************
* depends on the image width
******************************/
-
+
double erg = rint(sqrt(pow(2, rint(log((double)(framestart[uFrameNum+1] - framestart[uFrameNum])) / log(2.0)))));
pFrame = new FrameBuf(palette, uFrameNum, uXSize, uYSize, uMaxX, max((uint16_t)min((int)erg, 0x7F), uXSize));
-
+
/****** ramp detection -- AFAIK only needed for 32x32 tiles ********
* here I use hard coded constants because this is the only simple
* way to get the detection done; plus this stuff is only to be
@@ -385,7 +385,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
uint32_t uFrameLen = framestart[uFrameNum+1] - framestart[uFrameNum];
if ((uXSize == 32) && ((uFrameLen == c_2RampSize) || (uFrameLen == c_1RampSize))) {
- // use the static arrays for the check
+ // use the static arrays for the check
for (i=0; i<(uFrameLen == c_2RampSize ? 16 : 8); i++) {
memcpy(&tmpWord, pFileBuf+framestart[uFrameNum]+c_RampOffsetLeft[i], sizeof(uint16_t));
if (tmpWord != 0)
@@ -400,7 +400,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
}
pFrame->bHasRamps = (i==(uFrameLen == c_2RampSize ? 16 : 8)); // bRampsLeft stays false in this case
}
-
+
if (pFrame->bHasRamps) { // decode ramps and be off (if appropriate)
data = celDecodeRamps(pFileBuf, pFrame, framestart, bRampsLeft);
delete pFrame;
@@ -408,25 +408,25 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
return data;
}
}
-
+
/*********** block detection ***************************************
* 0x0A as start byte seems to be sufficient (though I still dunno
* what the trailing 10 bytes mean); in any other case we act as if
* blocks were to be used and check afterwards if the image looks
* OK (that is, the last line has no pixels in it)
******************************************************************/
-
+
cRead = pFileBuf[framestart[uFrameNum]];
if (cRead == 0x0A) // sufficient
pFrame->bHasBlocks = true;
// if width == 32 && framelen == 32*32, assume plain
else if ((uXSize != 32) || (uFrameLen != 32*32)) { // check needed
- uFilePos=framestart[uFrameNum];
+ uFilePos=framestart[uFrameNum];
i=0;
// rush through the frame
while (uFilePos < framestart[uFrameNum+1]) {
cRead = pFileBuf[uFilePos++];
-
+
// transparency blocks
while (cRead > 0x7F) {
i += 256-cRead;
@@ -436,7 +436,7 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
else
cRead = 0;
}
-
+
// colored pixel block
if (uFilePos < framestart[uFrameNum+1]) {
if (cRead < pFrame->uMaxBlock + 1) {
@@ -453,19 +453,19 @@ uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t u
if (i%uXSize == 0) // looks as if we got it right
pFrame->bHasBlocks=true;
}
-
+
if (pFrame->bHasBlocks) { // use block decoder if appropriate
data = celDecodeBlocks(pFileBuf, pFrame, framestart);
delete pFrame;
delete[] framestart;
return data;
}
-
+
// plain mode (#3), read each color index and write the pixel
uFilePos=framestart[uFrameNum];
while (uFilePos < framestart[uFrameNum+1])
pFrame->addPixel(pFileBuf[uFilePos++]);
-
+
// cleanup, return image data and height
data = pFrame->getData();
delete pFrame;
@@ -496,7 +496,7 @@ uint16_t WINAPI cl2GetFrameCount(uint8_t *pFileBuf)
*
* ---------------------------------------------------------------
* Comments: dirty hack, started from scratch @ 2000-10-12
- *
+ *
* The format basics are similar to .cel, with the main difference
* that the values read have reverse interpretation. In .cel a value
* greater than 0x7F means transparency, while in .cl2 this means
@@ -507,7 +507,7 @@ uint16_t WINAPI cl2GetFrameCount(uint8_t *pFileBuf)
* .cl2 only uses the block scheme, so there is no detection
* necessary in order to get it right. The only thing still unknown
* is that 0x0A 0x00 stuff...
- *
+ *
* TODO: learn what 0x0A 0x00 means
***********************************************************************/
BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uDirNum, WORD *uYSize)
@@ -516,27 +516,27 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD
uint32_t frames=0, *framestart=NULL, uFilePos=0;
uint16_t i, fc;
uint8_t cRead=0, **data=NULL;
-
+
if (pFileBuf == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (palette == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uDirNum > 7) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uYSize == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
// get direction offsets
uint32_t dirstart[8];
for (i=0; i<8; i++) {
@@ -545,23 +545,23 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD
}
uFilePos = dirstart[uDirNum];
-
+
memcpy(&frames, pFileBuf+uFilePos, sizeof(uint32_t));
uFilePos += sizeof(uint32_t);
-
+
data = new uint8_t*[frames];
-
+
// get frame offsets
framestart = new uint32_t[frames+1];
for (i=0; i<frames+1; i++) {
memcpy(&framestart[i], pFileBuf+uFilePos, sizeof(uint32_t));
uFilePos += sizeof(uint32_t);
}
-
- // get frame data
+
+ // get frame data
for (fc=0; fc<frames; fc++) {
pFrame = new FrameBuf(palette, 0, uXSize, uYSize, NULL, 0);
-
+
uFilePos = dirstart[uDirNum] + framestart[fc];
while (uFilePos < dirstart[uDirNum] + framestart[fc+1]) {
@@ -583,12 +583,12 @@ BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uD
for (i=0; i < 256-cRead; i++)
pFrame->addPixel(pFileBuf[uFilePos++]);
}
-
+
// got the frame data, save it
data[fc] = pFrame->getData();
delete pFrame;
}
-
+
delete[] framestart;
return data;
}
@@ -616,7 +616,7 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
uint16_t i=0;
uint8_t *data, *palette;
uint8_t uColorNum=0, uCount=0;
-
+
struct pcx_header_t {
uint8_t id;
uint8_t version;
@@ -635,17 +635,17 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
uint16_t colortype;
uint8_t pad[58];
} pcxHeader;
-
+
if (pFileBuf == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uXSize == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
-
+
if (uYSize == NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
@@ -655,12 +655,12 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
memcpy(&pcxHeader, pFileBuf, sizeof(struct pcx_header_t));
*uXSize = (pcxHeader.x1 - pcxHeader.x0 + 1);
*uYSize = (pcxHeader.y1 - pcxHeader.y0 + 1);
-
+
if ((pcxHeader.version != 2) && (pcxHeader.version != 5)) {
cerr << "cannot handle pcx v" << pcxHeader.version << "\n";
return NULL;
}
-
+
// get palette
palette = new uint8_t[256*4];
if (pFileBuf[uFileSize - 768 - 1] != 0x0C) {
@@ -672,7 +672,7 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
palette[i*4+3] = 0xFF;
}
memset(palette+uTransColor*4, 0, 4*sizeof(uint8_t)); // transparent black
-
+
// start right after the header
uFilePos = sizeof(struct pcx_header_t);
data = new uint8_t[*uXSize * *uYSize * 4];
@@ -684,15 +684,14 @@ BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD
uColorNum = pFileBuf[uFilePos++];
} else
uCount = 1;
-
+
// draw count pixels with color val
for (i=0; i<uCount; i++)
memcpy(data+(uDataRead++)*4, palette+uColorNum*4, 4*sizeof(uint8_t));
}
-
+
// cleanup
delete[] palette;
-
+
return data;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/Makefile b/contrib/vmap_extractor_v2/stormlib/Makefile
deleted file mode 100644
index e3b19e36d6f..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-########################################################################
-#
-# Makefile for compiling StormLib under linux
-#
-# Author: Marko Friedemann <marko.friedemann@bmx-chemnitz.de>
-# Created at: Mon Jan 29 18:26:01 CEST 2001
-# Computer: whiplash.flachland-chemnitz.de
-# System: Linux 2.4.0 on i686
-#
-# Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved.
-#
-########################################################################
-
-FILES.cpp = SCommon.cpp SCompression.cpp SFileCompactArchive.cpp \
- SFileCreateArchiveEx.cpp SFileExtractFile.cpp SFileFindFile.cpp \
- SListFile.cpp SFileOpenArchive.cpp SFileOpenFileEx.cpp SFileReadFile.cpp \
- StormPortLinux.cpp wave/wave.cpp huffman/huff.cpp \
- pklib/crc32.cpp pklib/explode.cpp pklib/implode.cpp
-FILES.o = $(FILES.cpp:.cpp=.o)
-
-LIB = libStorm.so
-
-CXX = g++
-CFLAGS = -Wall -s -D__SYS_ZLIB
-I_FLAGS =
-LDFLAGS = -lz -lbz2
-
-all: $(LIB)
-
-$(LIB): $(FILES.o)
- $(LD) -shared $(LDFLAGS) -o $(LIB) $(FILES.o)
-
-%.o: %.cpp
- $(CXX) $(CFLAGS) -c $< -o $@
-
-clean:
- $(RM) $(FILES.o) $(LIB)
-
-new: clean all
-
-mrproper: clean
- $(RM) Makefile.deps
-
-mrnew: mrproper new
-
-install: $(LIB)
- install $(I_FLAGS) $(LIB) /usr/local/lib
- mkdir -p /usr/local/include/StormLib
- cp Storm.h /usr/local/include/StormLib
- cp StormPort.h /usr/local/include/StormLib
- ldconfig
-
-deps:
- $(CXX) -MM $(CFLAGS) $(FILES.cpp) > Makefile.deps
-
--include Makefile.deps
-
-.PHONY: all clean new mrpoper mrnew install deps
diff --git a/contrib/vmap_extractor_v2/stormlib/SCommon.cpp b/contrib/vmap_extractor_v2/stormlib/SCommon.cpp
index f7e29ab7a24..393310f675d 100644
--- a/contrib/vmap_extractor_v2/stormlib/SCommon.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SCommon.cpp
@@ -26,7 +26,7 @@ USHORT wPlatform = 0; // File platform
//-----------------------------------------------------------------------------
// Compression types
-//
+//
// Data compressions
//
// Can be combination of MPQ_COMPRESSION_PKWARE, MPQ_COMPRESSION_BZIP2
@@ -261,16 +261,16 @@ DWORD DetectFileSeed2(DWORD * pdwBlock, UINT nDwords, ...)
DWORD saveSeed1;
DWORD dwTemp;
DWORD i, j;
-
+
// We need at least two DWORDS to detect the seed
if(nDwords < 0x02 || nDwords > 0x10)
return 0;
-
+
va_start(argList, nDwords);
for(i = 0; i < nDwords; i++)
dwDecrypted[i] = va_arg(argList, DWORD);
va_end(argList);
-
+
dwTemp = (*pdwBlock ^ dwDecrypted[0]) - 0xEEEEEEEE;
for(i = 0; i < 0x100; i++) // Try all 255 possibilities
{
@@ -427,7 +427,7 @@ TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName)
// If filename is given by index, we have to search all hash entries for the right index.
if(dwIndex <= ha->pHeader->dwBlockTableSize)
{
- // Pass all the hash entries and find the
+ // Pass all the hash entries and find the
for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++)
{
if(pHash->dwBlockIndex == dwIndex)
@@ -441,7 +441,7 @@ TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName)
dwName1 = DecryptName1(szFileName);
dwName2 = DecryptName2(szFileName);
pHash = pHash0 = ha->pHashTable + dwIndex;
-
+
// Look for hash index
while(pHash->dwBlockIndex != HASH_ENTRY_FREE)
{
@@ -562,7 +562,7 @@ BOOL IsValidMpqHandle(TMPQArchive * ha)
return FALSE;
if(ha->pHeader == NULL || IsBadReadPtr(ha->pHeader, sizeof(TMPQHeader)))
return FALSE;
-
+
return (ha->pHeader->dwID == ID_MPQ);
}
@@ -620,7 +620,7 @@ int AddFileToArchive(
{
if(nFileType == SFILE_TYPE_DATA)
nCmpFirst = nCmpNext = nDataCmp;
-
+
if(nFileType == SFILE_TYPE_WAVE)
{
nCmpNext = uWaveCmpType[dwQuality];
@@ -721,7 +721,7 @@ int AddFileToArchive(
// Get pointers to both block entries of the file
pBlockEx = ha->pExtBlockTable + pHash->dwBlockIndex;
pBlock = ha->pBlockTable + pHash->dwBlockIndex;
-
+
// Save the file size info
pBlockEx->wFilePosHigh = (USHORT)RelativePos.HighPart;
pBlock->dwFilePos = RelativePos.LowPart;
@@ -735,7 +735,7 @@ int AddFileToArchive(
if(dwFlags & MPQ_FILE_ENCRYPTED)
{
dwSeed1 = DecryptFileSeed(szArchivedName);
-
+
if(dwFlags & MPQ_FILE_FIXSEED)
dwSeed1 = (dwSeed1 + pBlock->dwFilePos) ^ pBlock->dwFSize;
}
@@ -785,7 +785,7 @@ int AddFileToArchive(
memset(pdwBlockPos, 0, dwBlockPosLen);
pdwBlockPos[0] = dwBlockPosLen;
-
+
// Write the block positions
BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks);
WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL);
@@ -852,7 +852,7 @@ int AddFileToArchive(
EncryptMPQBlock((DWORD *)pbToWrite, dwOutLength, dwSeed1 + nBlock);
BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD));
}
-
+
// Write the block
WriteFile(ha->hFile, pbToWrite, dwOutLength, &dwTransferred, NULL);
if(dwTransferred != dwOutLength)
@@ -876,10 +876,10 @@ int AddFileToArchive(
// If file is encrypted, block positions are also encrypted
if(dwFlags & MPQ_FILE_ENCRYPTED)
EncryptMPQBlock(pdwBlockPos, dwBlockPosLen, dwSeed1 - 1);
-
+
// Set the position back to the block table
SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN);
-
+
// Write block positions to the archive
BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks);
WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL);
@@ -1015,7 +1015,7 @@ int SaveMPQTables(TMPQArchive * ha)
// Encrypt the block table and write it to the file
EncryptBlockTable((DWORD *)pbBuffer, (BYTE *)"(block table)", dwBytes >> 2);
-
+
// Convert to little endian for file save
BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD));
WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL);
@@ -1072,4 +1072,3 @@ void FreeMPQArchive(TMPQArchive *& ha)
ha = NULL;
}
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SCommon.h b/contrib/vmap_extractor_v2/stormlib/SCommon.h
index b038c7f04dd..b53be0ae2a8 100644
--- a/contrib/vmap_extractor_v2/stormlib/SCommon.h
+++ b/contrib/vmap_extractor_v2/stormlib/SCommon.h
@@ -86,4 +86,3 @@ int SListFileSaveToMpq(TMPQArchive * ha);
#endif // __SCOMMON_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp b/contrib/vmap_extractor_v2/stormlib/SCompression.cpp
index 7162cd04f50..612ef2cc262 100644
--- a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SCompression.cpp
@@ -2,7 +2,7 @@
/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */
/*---------------------------------------------------------------------------*/
/* This module serves as a bridge between StormLib code and (de)compression */
-/* functions. All (de)compression calls go (and should only go) through this */
+/* functions. All (de)compression calls go (and should only go) through this */
/* module. No system headers should be included in this module to prevent */
/* compile-time problems. */
/*---------------------------------------------------------------------------*/
@@ -19,7 +19,7 @@
#include <string.h>
// Include functions from Pkware Data Compression Library
-#include "pklib/pklib.h"
+#include "pklib/pklib.h"
// Include functions from zlib
#ifndef __SYS_ZLIB
@@ -29,10 +29,10 @@
#endif
// Include functions from Huffmann compression
-#include "huffman/huff.h"
+#include "huffman/huff.h"
// Include functions from WAVe compression
-#include "wave/wave.h"
+#include "wave/wave.h"
// Include functions from BZip2 compression library
#ifndef __SYS_BZLIB
@@ -57,7 +57,7 @@ typedef struct
// Table of compression functions
typedef int (*COMPRESS)(char *, int *, char *, int, int *, int);
-typedef struct
+typedef struct
{
unsigned long dwMask; // Compression mask
COMPRESS Compress; // Compression function
@@ -81,7 +81,7 @@ typedef struct
// Function loads data from the input buffer. Used by Pklib's "implode"
// and "explode" function as user-defined callback
// Returns number of bytes loaded
-//
+//
// char * buf - Pointer to a buffer where to store loaded data
// unsigned int * size - Max. number of bytes to read
// void * param - Custom pointer, parameter of implode/explode
@@ -95,7 +95,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param)
// Check the case when not enough data available
if(nToRead > nMaxAvail)
nToRead = nMaxAvail;
-
+
// Load data and increment offsets
memcpy(buf, pInfo->pInBuff + pInfo->nInPos, nToRead);
pInfo->nInPos += nToRead;
@@ -105,7 +105,7 @@ static unsigned int ReadInputData(char * buf, unsigned int * size, void * param)
// Function for store output data. Used by Pklib's "implode" and "explode"
// as user-defined callback
-//
+//
// char * buf - Pointer to data to be written
// unsigned int * size - Number of bytes to write
// void * param - Custom pointer, parameter of implode/explode
@@ -272,7 +272,7 @@ int Compress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int
{
// Call zlib to compress the data
nResult = deflate(&z, Z_FINISH);
-
+
if(nResult == Z_OK || nResult == Z_STREAM_END)
*pdwOutLength = z.total_out;
@@ -359,7 +359,7 @@ int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer,
// Do the decompression
explode(ReadInputData, WriteOutputData, work_buf, &Info);
-
+
// Fix: If PKLIB is unable to decompress the data, they are uncompressed
if(Info.nOutPos == 0)
{
@@ -487,7 +487,7 @@ int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncom
int dwInSize = dwInLength;
int dwEntries = (sizeof(cmp_table) / sizeof(TCompressTable));
int nResult = 1;
- int i;
+ int i;
// Check for valid parameters
if(!pdwOutLength || *pdwOutLength < dwInLength || !pbCompressed || !pbUncompressed)
@@ -523,7 +523,7 @@ int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncom
{
if(uCompressions2 & cmp_table[i].dwMask)
{
- // Set the right output buffer
+ // Set the right output buffer
dwCompressCount--;
pbOutput = (dwCompressCount & 1) ? pbTempBuff : pbCompressed;
@@ -611,7 +611,7 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu
int dwCount = 0; // Counter for every use
int dwEntries = (sizeof(dcmp_table) / sizeof(TDecompressTable));
int nResult = 1;
- int i;
+ int i;
// If the input length is the same as output, do nothing.
if(dwInLength == dwOutLength)
@@ -623,11 +623,11 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu
*pdwOutLength = dwInLength;
return 1;
}
-
+
// Get applied compression types and decrement data length
- fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++;
+ fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++;
dwInLength--;
-
+
// Search decompression table type and get all types of compression
for(i = 0; i < dwEntries; i++)
{
@@ -681,13 +681,13 @@ int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBu
{
if(pbWorkBuff != pbOutBuffer)
memcpy(pbOutBuffer, pbInBuffer, dwOutLength);
-
+
}
// Delete temporary buffer, if necessary
if(pbTempBuff != NULL)
FREEMEM(pbTempBuff);
-
+
*pdwOutLength = dwOutLength;
return nResult;
}
@@ -713,4 +713,3 @@ int WINAPI SCompSetDataCompression(int nDataCompression)
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp
index b5a8530f61e..9510b15ae1f 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp
@@ -143,7 +143,7 @@ static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, DWORD
SFileCloseFile(hFile);
}
- // If the file is encrypted, we have to check
+ // If the file is encrypted, we have to check
// If we can apply the file decryption seed
if(dwFlags & MPQ_FILE_ENCRYPTED && dwSeed == 0)
{
@@ -269,7 +269,7 @@ static int CopyMpqFileBlocks(
DecryptMPQBlock(pdwBlockPos, dwBytes, dwSeed1 - 1);
if(pdwBlockPos[0] != dwBytes)
nError = ERROR_FILE_CORRUPT;
-
+
memcpy(pdwBlockPos2, pdwBlockPos, dwBytes);
EncryptMPQBlock(pdwBlockPos2, dwBytes, dwSeed2 - 1);
}
@@ -315,7 +315,7 @@ static int CopyMpqFileBlocks(
}
// If necessary, re-encrypt the block
- // Note: Recompression is not necessary here. Unlike encryption,
+ // Note: Recompression is not necessary here. Unlike encryption,
// the compression does not depend on the position of the file in MPQ.
if((pBlock->dwFlags & MPQ_FILE_ENCRYPTED) && dwSeed1 != dwSeed2)
{
@@ -583,7 +583,7 @@ BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bR
TempPos.LowPart = pBlock->dwFilePos;
if(TempPos.QuadPart < FirstFilePos.QuadPart)
FirstFilePos = TempPos;
-
+
pBlockEx++;
pBlock++;
}
@@ -689,4 +689,3 @@ BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bR
CompactCB = NULL;
return (nError == ERROR_SUCCESS);
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp
index 58f33e459ca..2410920fc93 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp
@@ -20,7 +20,7 @@
//-----------------------------------------------------------------------------
// Local tables
-static DWORD PowersOfTwo[] =
+static DWORD PowersOfTwo[] =
{
0x0000002, 0x0000004, 0x0000008,
0x0000010, 0x0000020, 0x0000040, 0x0000080,
@@ -52,7 +52,7 @@ static DWORD PowersOfTwo[] =
//
// MPQ_CREATE_ARCHIVE_V1 - Creates MPQ archive version 1
// MPQ_CREATE_ARCHIVE_V2 - Creates MPQ archive version 2
-//
+//
// dwHashTableSize - Size of the hash table (only if creating a new archive).
// Must be between 2^4 (= 16) and 2^18 (= 262 144)
//
@@ -118,7 +118,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi
dwHashTableSize = HASH_TABLE_SIZE_MIN;
if(dwHashTableSize > HASH_TABLE_SIZE_MAX)
dwHashTableSize = HASH_TABLE_SIZE_MAX;
-
+
// Round the hash table size up to the nearest power of two
for(nIndex = 0; PowersOfTwo[nIndex] != 0; nIndex++)
{
@@ -249,7 +249,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi
BSWAP_TMPQHEADER(ha->pHeader);
WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwTransferred, NULL);
BSWAP_TMPQHEADER(ha->pHeader);
-
+
if(dwTransferred != ha->pHeader->dwHeaderSize)
nError = ERROR_DISK_FULL;
@@ -273,7 +273,7 @@ BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposi
CloseHandle(hFile);
SetLastError(nError);
}
-
+
// Return the values
*phMPQ = (HANDLE)ha;
return (nError == ERROR_SUCCESS);
@@ -355,7 +355,7 @@ BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * sz
SetLastError(nError);
return (nError == ERROR_SUCCESS);
}
-
+
// Adds a data file into the archive
// TODO: Test for archives > 4GB
BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags)
@@ -375,7 +375,7 @@ BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szAr
//
// This function removes a file from the archive. The file content
// remains there, only the entries in the hash table and in the block
-// table are updated.
+// table are updated.
// TODO: Test for archives > 4GB
BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope)
@@ -528,4 +528,3 @@ BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * s
return (nError == ERROR_SUCCESS);
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp
index d6afc19426b..7f16cde0171 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp
@@ -61,4 +61,3 @@ BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char *
SetLastError(nError);
return (BOOL)(nError == ERROR_SUCCESS);
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp
index ff8ab2688fd..41dbeba900c 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp
@@ -67,7 +67,7 @@ BOOL CheckWildCard(const char * szString, const char * szWildCard)
// The next N characters must not agree
nMustNotMatch |= 0x70000000;
break;
-
+
case '?': // Means "One or no character"
while(*szWildCard == '?')
{
@@ -111,7 +111,7 @@ BOOL CheckWildCard(const char * szString, const char * szWildCard)
{
if((nResult = _strnicmp(szString, szWildCard, nMustMatch)) == 0)
break;
-
+
szString++;
nMustNotMatch--;
}
@@ -207,7 +207,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DA
{
if(!IsValidMpqHandle(ha))
nError = ERROR_INVALID_PARAMETER;
-
+
if(szMask == NULL || lpFindFileData == NULL)
nError = ERROR_INVALID_PARAMETER;
@@ -245,7 +245,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DA
FreeMPQSearch(hs);
SetLastError(nError);
}
-
+
// Return the result value
return (HANDLE)hs;
}
@@ -289,4 +289,3 @@ BOOL WINAPI SFileFindClose(HANDLE hFind)
FreeMPQSearch(hs);
return TRUE;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp
index b4a84e2d6ab..cadb4e023a2 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp
@@ -74,7 +74,7 @@ static int RelocateMpqTablePositions(TMPQArchive * ha)
TempSize.QuadPart = ha->ExtBlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlockEx));
if(TempSize.QuadPart > ha->MpqSize.QuadPart)
ha->MpqSize = TempSize;
-
+
// MPQ size does not include the bytes before MPQ header
ha->MpqSize.QuadPart -= ha->MpqPos.QuadPart;
return ERROR_SUCCESS;
@@ -122,7 +122,7 @@ BOOL SFileOpenArchiveEx(
DWORD dwBlockTableSize = 0; // Block table size.
DWORD dwTransferred; // Number of bytes read
DWORD dwBytes = 0; // Number of bytes to read
- int nError = ERROR_SUCCESS;
+ int nError = ERROR_SUCCESS;
// Check the right parameters
if(nError == ERROR_SUCCESS)
@@ -142,7 +142,7 @@ BOOL SFileOpenArchiveEx(
if(hFile == INVALID_HANDLE_VALUE)
nError = GetLastError();
}
-
+
// Allocate the MPQhandle
if(nError == ERROR_SUCCESS)
{
@@ -241,7 +241,7 @@ BOOL SFileOpenArchiveEx(
break;
}
- // If a MPQ shunt already has been found,
+ // If a MPQ shunt already has been found,
// and no MPQ header was at potision pointed by the shunt,
// then the archive is corrupt
if(ha->pShunt != NULL)
@@ -327,7 +327,7 @@ BOOL SFileOpenArchiveEx(
nError = ERROR_BAD_FORMAT;
break;
}
-
+
// Remember the highest block table entry
if(pHash->dwBlockIndex > dwMaxBlockIndex)
dwMaxBlockIndex = pHash->dwBlockIndex;
@@ -437,7 +437,7 @@ BOOL SFileOpenArchiveEx(
}
}
- // If the user didn't specified otherwise,
+ // If the user didn't specified otherwise,
// include the internal listfile to the TMPQArchive structure
if((dwFlags & MPQ_OPEN_NO_LISTFILE) == 0)
{
@@ -479,7 +479,7 @@ BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwF
BOOL WINAPI SFileCloseArchive(HANDLE hMPQ)
{
TMPQArchive * ha = (TMPQArchive *)hMPQ;
-
+
if(!IsValidMpqHandle(ha))
{
SetLastError(ERROR_INVALID_PARAMETER);
@@ -495,4 +495,3 @@ BOOL WINAPI SFileCloseArchive(HANDLE hMPQ)
return TRUE;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp
index aae55cc6899..dae312144eb 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp
@@ -25,7 +25,7 @@ static BOOL OpenLocalFile(const char * szFileName, HANDLE * phFile)
if(hFile != INVALID_HANDLE_VALUE)
{
// Allocate and initialize file handle
- size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName);
+ size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName);
if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) != NULL)
{
memset(hf, 0, nHandleSize);
@@ -62,7 +62,7 @@ static void FreeMPQFile(TMPQFile *& hf)
/*****************************************************************************/
//-----------------------------------------------------------------------------
-// SFileEnumLocales enums all locale versions within MPQ.
+// SFileEnumLocales enums all locale versions within MPQ.
// Functions fills all available language identifiers on a file into the buffer
// pointed by plcLocales. There must be enough entries to copy the localed,
// otherwise the function returns ERROR_INSUFFICIENT_BUFFER.
@@ -220,7 +220,7 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch
size_t nHandleSize = 0; // Memory space necessary to allocate TMPQHandle
int nError = ERROR_SUCCESS;
-#ifdef _DEBUG
+#ifdef _DEBUG
// Due to increasing numbers of files in MPQs, I had to change the behavior
// of opening by file index. Now, the SFILE_OPEN_BY_INDEX value of dwSearchScope
// must be entered. This check will allow to find code places that are incompatible
@@ -321,13 +321,13 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch
hf->pBlock = pBlock;
hf->nBlocks = (hf->pBlock->dwFSize + ha->dwBlockSize - 1) / ha->dwBlockSize;
hf->pHash = pHash;
-
+
hf->MpqFilePos.HighPart = pBlockEx->wFilePosHigh;
hf->MpqFilePos.LowPart = pBlock->dwFilePos;
hf->MpqFilePos.QuadPart += ha->MpqPos.QuadPart;
hf->dwHashIndex = dwHashIndex;
- hf->dwFileIndex = dwBlockIndex;
+ hf->dwFileIndex = dwBlockIndex;
// Allocate buffers for decompression.
if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED)
@@ -337,11 +337,11 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch
// As for newer MPQs, there may be one additional entry in the block table
// (if the MPQ_FILE_HAS_EXTRA flag is set).
// Allocate the buffer to include this DWORD as well
-
+
if((hf->pdwBlockPos = ALLOCMEM(DWORD, hf->nBlocks + 2)) == NULL)
nError = ERROR_NOT_ENOUGH_MEMORY;
}
-
+
// Decrypt file seed. Cannot be used if the file is given by index
if(dwSearchScope != SFILE_OPEN_BY_INDEX)
{
@@ -386,7 +386,7 @@ BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearch
BOOL WINAPI SFileCloseFile(HANDLE hFile)
{
TMPQFile * hf = (TMPQFile *)hFile;
-
+
if(!IsValidFileHandle(hf))
{
SetLastError(ERROR_INVALID_PARAMETER);
@@ -401,4 +401,3 @@ BOOL WINAPI SFileCloseFile(HANDLE hFile)
FreeMPQFile(hf);
return TRUE;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp
index 288d63e9049..27fd1e0f085 100644
--- a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp
@@ -154,8 +154,8 @@ static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer
}
}
- // Set file pointer, if necessary
- if(ha->FilePointer.QuadPart != FilePos.QuadPart)
+ // Set file pointer, if necessary
+ if(ha->FilePointer.QuadPart != FilePos.QuadPart)
{
SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN);
}
@@ -245,7 +245,7 @@ static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer
// TODO: Test for archives > 4GB
static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead)
{
- TMPQArchive * ha = hf->ha;
+ TMPQArchive * ha = hf->ha;
DWORD dwBytesRead = 0;
if(ha->FilePointer.QuadPart != hf->MpqFilePos.QuadPart)
@@ -311,7 +311,7 @@ static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE *
// TODO: Test for archives > 4GB
static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead)
{
- TMPQArchive * ha = hf->ha;
+ TMPQArchive * ha = hf->ha;
TMPQBlock * pBlock = hf->pBlock; // Pointer to file block
DWORD dwBytesRead = 0; // Number of bytes read from the file
DWORD dwBlockPos; // Position in the file aligned to the whole blocks
@@ -359,7 +359,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer,
// Copy data from block buffer into target buffer
memcpy(pbBuffer, ha->pbBlockBuffer + ha->dwBuffPos, dwToCopy);
-
+
// Update pointers
dwToRead -= dwToCopy;
dwBytesRead += dwToCopy;
@@ -374,7 +374,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer,
// Load the whole ("middle") blocks only if there are more or equal one block
if(dwToRead > ha->dwBlockSize)
- {
+ {
DWORD dwBlockBytes = dwToRead & ~(ha->dwBlockSize - 1);
dwLoaded = ReadMPQBlocks(hf, dwBlockPos, pbBuffer, dwBlockBytes);
@@ -419,7 +419,7 @@ static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer,
dwBytesRead += dwToCopy;
ha->dwBuffPos = dwToCopy;
}
-
+
// Return what we've read
return dwBytesRead;
}
@@ -456,7 +456,7 @@ BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD *
SetLastError(ERROR_HANDLE_EOF);
return FALSE;
}
-
+
if(pdwRead != NULL)
*pdwRead = dwTransferred;
return TRUE;
@@ -498,7 +498,7 @@ BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD *
DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh)
{
TMPQFile * hf = (TMPQFile *)hFile;
-
+
if(pdwFilePosHigh != NULL)
*pdwFilePosHigh = 0;
@@ -525,7 +525,7 @@ DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh)
DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh)
{
TMPQFile * hf = (TMPQFile *)hFile;
-
+
if(pdwFileSizeHigh != NULL)
*pdwFileSizeHigh = 0;
@@ -604,7 +604,7 @@ DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosH
//-----------------------------------------------------------------------------
// Tries to retrieve the file name
-static TID2Ext id2ext[] =
+static TID2Ext id2ext[] =
{
{0x1A51504D, "mpq"}, // MPQ archive header ID ('MPQ\x1A')
{0x46464952, "wav"}, // WAVE header 'RIFF'
@@ -623,7 +623,7 @@ static TID2Ext id2ext[] =
{0x3032444D, "m2"}, // WoW ??? .m2
{0x43424457, "dbc"}, // ??? .dbc
{0x47585053, "bls"}, // WoW pixel shaders
- {0, NULL} // Terminator
+ {0, NULL} // Terminator
};
// TODO: Test for archives > 4GB
@@ -646,7 +646,7 @@ BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName)
if(hf == NULL || szFileName == NULL)
nError = ERROR_INVALID_PARAMETER;
}
-
+
// If the file name is already filled, return it.
if(nError == ERROR_SUCCESS && *hf->szFileName != 0)
{
@@ -665,7 +665,7 @@ BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName)
if(nError == ERROR_SUCCESS)
{
dwFirstBytes[0] = dwFirstBytes[1] = 0;
- dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT);
+ dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT);
if(!SFileReadFile(hFile, &dwFirstBytes, sizeof(dwFirstBytes), NULL))
nError = GetLastError();
BSWAP_ARRAY32_UNSIGNED(dwFirstBytes, sizeof(dwFirstBytes) / sizeof(DWORD));
@@ -824,4 +824,3 @@ DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType)
SetLastError(ERROR_INVALID_PARAMETER);
return 0xFFFFFFFF;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp b/contrib/vmap_extractor_v2/stormlib/SListFile.cpp
index 385e6e8ac40..c3723d17dcd 100644
--- a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/SListFile.cpp
@@ -71,7 +71,7 @@ static size_t ReadLine(TListFileCache * pCache, char * szLine, int nMaxChars)
{
char * szLineBegin = szLine;
char * szLineEnd = szLine + nMaxChars - 1;
-
+
__BeginLoading:
// Skip newlines, spaces, tabs and another non-printable stuff
@@ -156,7 +156,7 @@ int SListFileAddNode(TMPQArchive * ha, const char * szFileName)
dwName2 = pHash->dwName2;
if((DWORD_PTR)ha->pListFile[dwHashIndex] <= LISTFILE_ENTRY_DELETED)
return ERROR_SUCCESS;
-
+
// Create the listfile node and insert it into the listfile table
nLength = strlen(szFileName);
pNode = (TFileNode *)ALLOCMEM(char, sizeof(TFileNode) + nLength);
@@ -310,8 +310,8 @@ int SListFileSaveToMpq(TMPQArchive * ha)
szBuffer[nLength + 0] = 0x0D;
szBuffer[nLength + 1] = 0x0A;
WriteFile(hFile, szBuffer, (DWORD)(nLength + 2), &dwTransferred, NULL);
- }
-
+ }
+
// Add the listfile into the archive.
SFileSetLocale(LANG_NEUTRAL);
nError = AddFileToArchive(ha, hFile, LISTFILE_NAME, MPQ_FILE_COMPRESS_PKWARE | MPQ_FILE_ENCRYPTED | MPQ_FILE_REPLACEEXISTING, 0, SFILE_TYPE_DATA, NULL);
@@ -329,7 +329,7 @@ int SListFileSaveToMpq(TMPQArchive * ha)
// File functions
// Adds a listfile into the MPQ archive.
-// Note that the function does not remove the
+// Note that the function does not remove the
// TODO: Test for archives > 4GB
int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile)
{
@@ -359,7 +359,7 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile)
if(nError == ERROR_SUCCESS)
{
- dwCacheSize =
+ dwCacheSize =
dwFileSize = SFileGetFileSize(hListFile, NULL);
// Try to allocate memory for the complete file. If it fails,
@@ -443,7 +443,7 @@ HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char *
if(nError == ERROR_SUCCESS)
{
- dwCacheSize =
+ dwCacheSize =
dwFileSize = SFileGetFileSize(hListFile, NULL);
// Try to allocate memory for the complete file. If it fails,
@@ -493,7 +493,7 @@ HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char *
// If some mask entered, check it
if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask))
- break;
+ break;
}
}
@@ -559,4 +559,3 @@ BOOL SListFileFindClose(HANDLE hFind)
return FALSE;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/StormDll.h b/contrib/vmap_extractor_v2/stormlib/StormDll.h
index 6be20e59bd7..6d67820a22f 100644
--- a/contrib/vmap_extractor_v2/stormlib/StormDll.h
+++ b/contrib/vmap_extractor_v2/stormlib/StormDll.h
@@ -65,4 +65,3 @@ BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pb
#endif
#endif // __STORM_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/StormLib.h b/contrib/vmap_extractor_v2/stormlib/StormLib.h
index e3b9381b9f1..eeb8daa6468 100644
--- a/contrib/vmap_extractor_v2/stormlib/StormLib.h
+++ b/contrib/vmap_extractor_v2/stormlib/StormLib.h
@@ -55,7 +55,7 @@
//
// The library type is encoded in the library name as the following
// StormLibXYZ.lib
-//
+//
// X - D for Debug version, R for Release version
// Y - A for ANSI version, U for Unicode version (Unicode version does not exist yet)
// Z - S for static C library, D for multithreaded DLL C-library
@@ -63,15 +63,15 @@
#if defined(_MSC_VER) && !defined (__STORMLIB_SELF__)
#ifdef _DEBUG // DEBUG VERSIONS
- #ifdef _DLL
+ #ifdef _DLL
#pragma comment(lib, "StormLibDAD.lib") // Debug Ansi Dynamic version
- #else
+ #else
#pragma comment(lib, "StormLibDAS.lib") // Debug Ansi Static version
#endif
#else // RELEASE VERSIONS
#ifdef _DLL
#pragma comment(lib, "StormLibRAD.lib") // Release Ansi Dynamic version
- #else
+ #else
#pragma comment(lib, "StormLibRAS.lib") // Release Ansi Static version
#endif
#endif
@@ -109,7 +109,7 @@
#define MPQ_FILE_COMPRESS_PKWARE 0x00000100 // Compression made by PKWARE Data Compression Library
#define MPQ_FILE_COMPRESS_MULTI 0x00000200 // Multiple compressions
#define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed
-#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted
+#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted
#define MPQ_FILE_FIXSEED 0x00020000 // File decrypt seed has to be fixed
#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam)
#define MPQ_FILE_DUMMY_FILE 0x02000000 // The file is only 1 byte long and its name is a hash
@@ -132,8 +132,8 @@
#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression
#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression
#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression
-#define MPQ_COMPRESSION_WAVE_MONO 0x40 //
-#define MPQ_COMPRESSION_WAVE_STEREO 0x80 //
+#define MPQ_COMPRESSION_WAVE_MONO 0x40 //
+#define MPQ_COMPRESSION_WAVE_STEREO 0x80 //
// Constants for SFileAddWave
@@ -168,7 +168,7 @@
#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used
#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total)
#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used
-
+
#define LISTFILE_NAME "(listfile)" // Name of internal listfile
#define SIGNATURE_NAME "(signature)" // Name of internal signature
#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file
@@ -213,10 +213,10 @@ struct TMPQShunt
struct TMPQHeader
{
// The ID_MPQ ('MPQ\x1A') signature
- DWORD dwID;
+ DWORD dwID;
// Size of the archive header
- DWORD dwHeaderSize;
+ DWORD dwHeaderSize;
// Size of MPQ archive
// This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive
@@ -235,14 +235,14 @@ struct TMPQHeader
// Offset to the beginning of the hash table, relative to the beginning of the archive.
DWORD dwHashTablePos;
-
+
// Offset to the beginning of the block table, relative to the beginning of the archive.
DWORD dwBlockTablePos;
-
+
// Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for
// the original MoPaQ format, or less than 2^20 for the Burning Crusade format.
DWORD dwHashTableSize;
-
+
// Number of entries in the block table
DWORD dwBlockTableSize;
};
@@ -267,7 +267,7 @@ struct TMPQHash
{
// The hash of the file path, using method A.
DWORD dwName1;
-
+
// The hash of the file path, using method B.
DWORD dwName2;
@@ -303,16 +303,16 @@ struct TMPQBlock
{
// Offset of the beginning of the block, relative to the beginning of the archive.
DWORD dwFilePos;
-
+
// Compressed file size
DWORD dwCSize;
-
+
// Only valid if the block is a file; otherwise meaningless, and should be 0.
// If the file is compressed, this is the size of the uncompressed file data.
- DWORD dwFSize;
-
+ DWORD dwFSize;
+
// Flags for the file. See MPQ_FILE_XXXX constants
- DWORD dwFlags;
+ DWORD dwFlags;
};
@@ -333,7 +333,7 @@ struct TFileNode
// There can be more files that have the same name.
// (e.g. multiple language files). We don't want to
// have an entry for each of them, so the entries will be referenced.
- // When a number of node references reaches zero,
+ // When a number of node references reaches zero,
// the node will be deleted
size_t nLength; // File name length
@@ -372,7 +372,7 @@ struct TMPQArchive
TMPQHash * pHashTable; // Hash table
TMPQBlock * pBlockTable; // Block table
TMPQBlockEx * pExtBlockTable; // Extended block table
-
+
TMPQShunt Shunt; // MPQ shunt. Valid only when ID_MPQ_SHUNT has been found
TMPQHeader2 Header; // MPQ header
@@ -520,8 +520,8 @@ int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile);
// Archive creating and editing
BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ);
-BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags);
-BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
+BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags);
+BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX);
BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char * szNewFileName);
BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale);
@@ -577,4 +577,3 @@ BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT
BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize);
#endif // __STORMLIB_H_
-
diff --git a/contrib/vmap_extractor_v2/stormlib/StormPort.h b/contrib/vmap_extractor_v2/stormlib/StormPort.h
index eb8b1e6d0d0..6254f84e725 100644
--- a/contrib/vmap_extractor_v2/stormlib/StormPort.h
+++ b/contrib/vmap_extractor_v2/stormlib/StormPort.h
@@ -20,7 +20,7 @@
/* 12.11.03 1.02 Dan Macintosh compatibility */
/* 24.07.04 1.03 Sam Mac OS X compatibility */
/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */
-/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */
+/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */
/*****************************************************************************/
#ifndef __STORMPORT_H__
@@ -35,9 +35,9 @@
#define _CRT_NON_CONFORMING_SWPRINTFS
#endif
- #include <assert.h>
- #include <stdio.h>
- #include <windows.h>
+ #include <assert.h>
+ #include <stdio.h>
+ #include <windows.h>
#define PLATFORM_LITTLE_ENDIAN 1
#ifdef WIN64
@@ -50,20 +50,20 @@
#endif
-// Defines for Mac Carbon
+// Defines for Mac Carbon
#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac Carbon API
// Macintosh using Carbon
#include <Carbon/Carbon.h> // Mac OS X
#define _stricmp strcasecmp // Case insensitive strcmp has a different name on this platform.
#define _strnicmp strncasecmp
-
+
typedef void * LPCSTR;
typedef unsigned long * LPDWORD;
typedef long * PLONG;
typedef void * LPVOID;
typedef unsigned int UINT;
-
+
#define PKEXPORT
#define __SYS_ZLIB
#define __SYS_BZLIB
@@ -120,17 +120,17 @@
typedef void * LPOVERLAPPED; // Unsupported on Linux
typedef char TCHAR;
typedef unsigned long LCID;
-
+
typedef void * LPCSTR;
typedef unsigned long * LPDWORD;
typedef long * PLONG;
typedef void * LPVOID;
typedef unsigned int UINT;
-
+
typedef struct _FILETIME
- {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
+ {
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
}
FILETIME, *PFILETIME;
@@ -152,7 +152,7 @@
LONGLONG QuadPart;
}
LARGE_INTEGER, *PLARGE_INTEGER;
-
+
// Some Windows-specific defines
#ifndef MAX_PATH
#define MAX_PATH 1024
@@ -167,24 +167,24 @@
#endif
#define VOID void
- #define WINAPI
+ #define WINAPI
#define FILE_BEGIN SEEK_SET
#define FILE_CURRENT SEEK_CUR
#define FILE_END SEEK_END
-
+
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
#define OPEN_ALWAYS 4
-
+
#define FILE_SHARE_READ 0x00000001L
#define GENERIC_WRITE 0x40000000
#define GENERIC_READ 0x80000000
-
+
#define FILE_FLAG_DELETE_ON_CLOSE 1 // Sam: Added these two defines so it would compile.
#define FILE_FLAG_SEQUENTIAL_SCAN 2
-
+
#define ERROR_SUCCESS 0
#define ERROR_INVALID_FUNCTION 1
#define ERROR_FILE_NOT_FOUND 2
@@ -204,22 +204,22 @@
#define ERROR_PARAMETER_QUOTA_EXCEEDED 1283
#define ERROR_FILE_CORRUPT 1392
#define ERROR_INSUFFICIENT_BUFFER 4999
-
+
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
-
+
#ifndef min
#define min(a, b) ((a < b) ? a : b)
#endif
-
+
#ifndef max
#define max(a, b) ((a > b) ? a : b)
#endif
-
+
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
-
+
extern int globalerr;
-
+
void SetLastError(int err);
int GetLastError();
char *ErrString(int err);
@@ -276,4 +276,3 @@
#endif
#endif // __STORMPORT_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp
index 09eeef58949..afbbd985a7f 100644
--- a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp
@@ -97,7 +97,7 @@ DWORD GetFileSize(HANDLE hFile, DWORD *ulOffSetHigh)
struct stat fileinfo;
fstat((int)hFile, &fileinfo);
-
+
return fileinfo.st_size;
}
@@ -166,4 +166,3 @@ BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName)
}
#endif
-
diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp
index 0904ab30f76..2477333ae02 100644
--- a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp
@@ -1,7 +1,7 @@
/********************************************************************
*
* Description: implementation for StormLib - Macintosh port
-*
+*
* these are function wraps to execute Windows API calls
* as native Macintosh file calls (open/close/read/write/...)
* requires Mac OS X
@@ -15,7 +15,7 @@
*
********************************************************************/
-#ifndef _WIN32 || _WIN64
+#ifndef _WIN32
#include "StormPort.h"
#include "StormLib.h"
@@ -45,14 +45,14 @@ static OSErr FSGetFullPath(const FSRef *ref, UInt8 *fullPath, UInt32 fullPathLen
OSErr result;
result = FSRefMakePath(ref, fullPath, fullPathLength);
-
+
return result;
}
static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref)
{
OSErr result;
-
+
result = FSPathMakeRef((UInt8 *)fullPath, ref, NULL); // Create an FSRef from the path
return result;
}
@@ -61,7 +61,7 @@ static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref)
/*****************************************************************************/
-static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName,
+static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName,
UniCharCount nameLength, FSRef *ref)
{
FSCatalogInfo theCatInfo;
@@ -71,7 +71,7 @@ static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileT
((FileInfo *)&theCatInfo.finderInfo)->finderFlags = 0;
SetPt(&((FileInfo *)&theCatInfo.finderInfo)->location, 0, 0);
((FileInfo *)&theCatInfo.finderInfo)->reservedField = 0;
-
+
theErr = FSCreateFileUnicode(parentRef, nameLength, fileName, kFSCatInfoFinderInfo, &theCatInfo, ref, NULL);
return theErr;
}
@@ -84,11 +84,11 @@ static OSErr FSOpenDFCompat(FSRef *ref, char permission, short *refNum)
HFSUniStr255 forkName;
OSErr theErr;
Boolean isFolder, wasChanged;
-
+
theErr = FSResolveAliasFile(ref, TRUE, &isFolder, &wasChanged);
if (theErr != noErr)
return theErr;
-
+
FSGetDataForkName(&forkName);
theErr = FSOpenFork(ref, forkName.length, forkName.unicode, permission, refNum);
return theErr;
@@ -209,7 +209,7 @@ void ConvertTMPQShunt(void *shunt)
void ConvertTMPQHeader(void *header)
{
TMPQHeader2 * theHeader = (TMPQHeader2 *)header;
-
+
theHeader->dwID = SwapULong(theHeader->dwID);
theHeader->dwHeaderSize = SwapULong(theHeader->dwHeaderSize);
theHeader->dwArchiveSize = SwapULong(theHeader->dwArchiveSize);
@@ -271,7 +271,7 @@ int GetLastError()
********************************************************************/
char *ErrString(int err)
{
- switch (err)
+ switch (err)
{
case ERROR_INVALID_FUNCTION:
return "function not implemented";
@@ -324,7 +324,7 @@ void GetTempPath(DWORD szTempLength, char * szTemp) // I think I'll change this
else
szTemp[0] = '\0';
strcat(szTemp, "/");
-
+
SetLastError(theErr);
}
@@ -347,7 +347,7 @@ void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWO
strcpy(szLFName, lpTempFolderPath);
strcat(szLFName, lpFileName);
strcat(szLFName, tmp);
-
+
if ((fHandle = CreateFile(szLFName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
// OK we found it!
break;
@@ -364,16 +364,16 @@ BOOL DeleteFile(const char * lpFileName)
{
OSErr theErr;
FSRef theFileRef;
-
+
theErr = FSLocationFromFullPath(lpFileName, &theFileRef);
if (theErr != noErr)
{
SetLastError(theErr);
return FALSE;
}
-
+
theErr = FSDeleteObject(&theFileRef);
-
+
SetLastError(theErr);
return theErr == noErr;
@@ -390,7 +390,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName)
FSRef fromFileRef;
FSRef toFileRef;
FSRef parentFolderRef;
-
+
// Get the path to the old file
theErr = FSLocationFromFullPath(lpFromFileName, &fromFileRef);
if (theErr != noErr)
@@ -398,7 +398,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName)
SetLastError(theErr);
return false;
}
-
+
// Get the path to the new folder for the file
char folderName[strlen(lpToFileName)];
CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8);
@@ -409,7 +409,7 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName)
CFRelease(fileURL);
CFRelease(folderURL);
CFRelease(folderPathCFString);
-
+
// Move the old file
theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef);
if (theErr != noErr)
@@ -417,19 +417,19 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName)
SetLastError(theErr);
return false;
}
-
+
// Get a CFString for the new file name
CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8);
fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE);
CFRelease(newFileNameCFString);
newFileNameCFString = CFURLCopyLastPathComponent(fileURL);
CFRelease(fileURL);
-
+
// Convert CFString to Unicode and rename the file
- UniChar unicodeFileName[256];
- CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)),
+ UniChar unicodeFileName[256];
+ CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)),
unicodeFileName);
- theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName,
+ theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName,
kTextEncodingUnknown, NULL);
if (theErr != noErr)
{
@@ -437,9 +437,9 @@ BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName)
CFRelease(newFileNameCFString);
return false;
}
-
+
CFRelease(newFileNameCFString);
-
+
SetLastError(theErr);
return true;
}
@@ -470,7 +470,7 @@ HANDLE CreateFile( const char *sFileName, /* file name */
char permission;
static OSType gCreator;
static OSType gType;
-
+
theErr = FSLocationFromFullPath(sFileName, &theFileRef);
if (theErr == fnfErr)
{ // Create the FSRef for the parent directory.
@@ -484,23 +484,23 @@ HANDLE CreateFile( const char *sFileName, /* file name */
CFRelease(fileURL);
CFRelease(folderURL);
CFRelease(folderPathCFString);
- }
+ }
if (theErr != noErr)
{
SetLastError(theErr);
if (ulCreation == OPEN_EXISTING || theErr != fnfErr)
return INVALID_HANDLE_VALUE;
}
-
+
if (ulCreation != OPEN_EXISTING)
{ /* We create the file */
UniChar unicodeFileName[256];
CFStringRef filePathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8);
CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, filePathCFString, kCFURLPOSIXPathStyle, FALSE);
CFStringRef fileNameCFString = CFURLCopyLastPathComponent(fileURL);
- CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)),
+ CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)),
unicodeFileName);
- theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName,
+ theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName,
CFStringGetLength(fileNameCFString), &theFileRef);
CFRelease(fileNameCFString);
CFRelease(filePathCFString);
@@ -522,7 +522,7 @@ HANDLE CreateFile( const char *sFileName, /* file name */
permission = fsRdWrPerm;
}
theErr = FSOpenDFCompat(&theFileRef, permission, &fileRef);
-
+
SetLastError(theErr);
if (theErr == noErr)
@@ -537,14 +537,14 @@ HANDLE CreateFile( const char *sFileName, /* file name */
BOOL CloseHandle( HANDLE hFile ) /* handle to object */
{
OSErr theErr;
-
+
if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE))
return FALSE;
theErr = FSCloseFork((short)(int)hFile);
-
+
SetLastError(theErr);
-
+
return theErr != noErr;
}
@@ -562,19 +562,19 @@ DWORD GetFileSize( HANDLE hFile, /* handle to file */
SetLastError(theErr);
return -1u;
}
-
+
theErr = FSGetForkSize((short)(int)hFile, &fileLength);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
if (ulOffSetHigh != NULL)
*ulOffSetHigh = fileLength >> 32;
SetLastError(theErr);
-
+
return fileLength;
}
@@ -593,81 +593,81 @@ DWORD SetFilePointer( HANDLE hFile, /* handle to file */
if (ulMethod == FILE_CURRENT)
{
SInt64 bytesToMove;
-
+
if (pOffSetHigh != NULL)
bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow;
else
bytesToMove = lOffSetLow;
-
+
SInt64 newPos;
-
+
theErr = FSSetForkPosition((short)(int)hFile, fsFromMark, bytesToMove);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
theErr = FSGetForkPosition((short)(int)hFile, &newPos);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
if (pOffSetHigh != NULL)
*pOffSetHigh = newPos >> 32;
-
+
SetLastError(theErr);
return newPos;
}
else if (ulMethod == FILE_BEGIN)
{
SInt64 bytesToMove;
-
+
if (pOffSetHigh != NULL)
bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow;
else
bytesToMove = lOffSetLow;
-
+
theErr = FSSetForkPosition((short)(int)hFile, fsFromStart, bytesToMove);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
SetLastError(theErr);
return lOffSetLow;
}
else
{
SInt64 bytesToMove;
-
+
if (pOffSetHigh != NULL)
bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow;
else
bytesToMove = lOffSetLow;
-
+
SInt64 newPos;
-
+
theErr = FSSetForkPosition((short)(int)hFile, fsFromLEOF, bytesToMove);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
theErr = FSGetForkPosition((short)(int)hFile, &newPos);
if (theErr != noErr)
{
SetLastError(theErr);
return -1u;
}
-
+
if (pOffSetHigh != NULL)
*pOffSetHigh = newPos >> 32;
-
+
SetLastError(theErr);
return newPos;
}
@@ -679,11 +679,11 @@ DWORD SetFilePointer( HANDLE hFile, /* handle to file */
BOOL SetEndOfFile( HANDLE hFile ) /* handle to file */
{
OSErr theErr;
-
+
theErr = FSSetForkSize((short)(int)hFile, fsAtMark, 0);
-
+
SetLastError(theErr);
-
+
return theErr == noErr;
}
@@ -701,13 +701,13 @@ BOOL ReadFile( HANDLE hFile, /* handle to file */
ByteCount nbCharsRead;
OSErr theErr;
-
+
nbCharsRead = ulLen;
theErr = FSReadFork((short)(int)hFile, fsAtMark, 0, nbCharsRead, pBuffer, &nbCharsRead);
*ulRead = nbCharsRead;
-
+
SetLastError(theErr);
-
+
return theErr == noErr;
}
@@ -725,13 +725,13 @@ BOOL WriteFile( HANDLE hFile, /* handle to file */
ByteCount nbCharsToWrite;
OSErr theErr;
-
- nbCharsToWrite = ulLen;
+
+ nbCharsToWrite = ulLen;
theErr = FSWriteFork((short)(int)hFile, fsAtMark, 0, nbCharsToWrite, pBuffer, &nbCharsToWrite);
*ulWritten = nbCharsToWrite;
-
+
SetLastError(theErr);
-
+
return theErr == noErr;
}
@@ -744,15 +744,15 @@ BOOL IsBadReadPtr(const void * ptr, int size)
return FALSE;
}
-// Returns attributes of a file. Actually, it doesn't, it just checks if
+// Returns attributes of a file. Actually, it doesn't, it just checks if
// the file exists, since that's all StormLib uses it for
DWORD GetFileAttributes(const char * szFileName)
{
FSRef theRef;
OSErr theErr;
-
+
theErr = FSLocationFromFullPath(szFileName, &theRef);
-
+
if (theErr != noErr)
return -1u;
else
@@ -760,4 +760,3 @@ DWORD GetFileAttributes(const char * szFileName)
}
#endif
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile b/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile
deleted file mode 100644
index eea329a626e..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile
+++ /dev/null
@@ -1,205 +0,0 @@
-
-SHELL=/bin/sh
-
-# To assist in cross-compiling
-CC=gcc
-AR=ar
-RANLIB=ranlib
-LDFLAGS=
-
-BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O -g $(BIGFILES)
-
-# Where you want it installed when you do 'make install'
-PREFIX=/usr
-
-
-OBJS= blocksort.o \
- huffman.o \
- crctable.o \
- randtable.o \
- compress.o \
- decompress.o \
- bzlib.o
-
-all: libbz2.a bzip2 bzip2recover test
-
-bzip2: libbz2.a bzip2.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
-
-bzip2recover: bzip2recover.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
-
-libbz2.a: $(OBJS)
- rm -f libbz2.a
- $(AR) cq libbz2.a $(OBJS)
- @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
- -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \
- echo $(RANLIB) libbz2.a ; \
- $(RANLIB) libbz2.a ; \
- fi
-
-check: test
-test: bzip2
- @cat words1
- ./bzip2 -1 < sample1.ref > sample1.rb2
- ./bzip2 -2 < sample2.ref > sample2.rb2
- ./bzip2 -3 < sample3.ref > sample3.rb2
- ./bzip2 -d < sample1.bz2 > sample1.tst
- ./bzip2 -d < sample2.bz2 > sample2.tst
- ./bzip2 -ds < sample3.bz2 > sample3.tst
- cmp sample1.bz2 sample1.rb2
- cmp sample2.bz2 sample2.rb2
- cmp sample3.bz2 sample3.rb2
- cmp sample1.tst sample1.ref
- cmp sample2.tst sample2.ref
- cmp sample3.tst sample3.ref
- @cat words3
-
-install: bzip2 bzip2recover
- if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
- if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
- if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
- if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
- if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
- cp -f bzip2 $(PREFIX)/bin/bzip2
- cp -f bzip2 $(PREFIX)/bin/bunzip2
- cp -f bzip2 $(PREFIX)/bin/bzcat
- cp -f bzip2recover $(PREFIX)/bin/bzip2recover
- chmod a+x $(PREFIX)/bin/bzip2
- chmod a+x $(PREFIX)/bin/bunzip2
- chmod a+x $(PREFIX)/bin/bzcat
- chmod a+x $(PREFIX)/bin/bzip2recover
- cp -f bzip2.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzip2.1
- cp -f bzlib.h $(PREFIX)/include
- chmod a+r $(PREFIX)/include/bzlib.h
- cp -f libbz2.a $(PREFIX)/lib
- chmod a+r $(PREFIX)/lib/libbz2.a
- cp -f bzgrep $(PREFIX)/bin/bzgrep
- ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
- ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
- chmod a+x $(PREFIX)/bin/bzgrep
- cp -f bzmore $(PREFIX)/bin/bzmore
- ln $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
- chmod a+x $(PREFIX)/bin/bzmore
- cp -f bzdiff $(PREFIX)/bin/bzdiff
- ln $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
- chmod a+x $(PREFIX)/bin/bzdiff
- cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzgrep.1
- chmod a+r $(PREFIX)/man/man1/bzmore.1
- chmod a+r $(PREFIX)/man/man1/bzdiff.1
- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
- echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
- echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
- echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
-
-clean:
- rm -f *.o libbz2.a bzip2 bzip2recover \
- sample1.rb2 sample2.rb2 sample3.rb2 \
- sample1.tst sample2.tst sample3.tst
-
-blocksort.o: blocksort.c
- @cat words0
- $(CC) $(CFLAGS) -c blocksort.c
-huffman.o: huffman.c
- $(CC) $(CFLAGS) -c huffman.c
-crctable.o: crctable.c
- $(CC) $(CFLAGS) -c crctable.c
-randtable.o: randtable.c
- $(CC) $(CFLAGS) -c randtable.c
-compress.o: compress.c
- $(CC) $(CFLAGS) -c compress.c
-decompress.o: decompress.c
- $(CC) $(CFLAGS) -c decompress.c
-bzlib.o: bzlib.c
- $(CC) $(CFLAGS) -c bzlib.c
-bzip2.o: bzip2.c
- $(CC) $(CFLAGS) -c bzip2.c
-bzip2recover.o: bzip2recover.c
- $(CC) $(CFLAGS) -c bzip2recover.c
-
-
-distclean: clean
- rm -f manual.ps manual.html manual.pdf
-
-DISTNAME=bzip2-1.0.3
-dist: check manual
- rm -f $(DISTNAME)
- ln -sf . $(DISTNAME)
- tar cvf $(DISTNAME).tar \
- $(DISTNAME)/blocksort.c \
- $(DISTNAME)/huffman.c \
- $(DISTNAME)/crctable.c \
- $(DISTNAME)/randtable.c \
- $(DISTNAME)/compress.c \
- $(DISTNAME)/decompress.c \
- $(DISTNAME)/bzlib.c \
- $(DISTNAME)/bzip2.c \
- $(DISTNAME)/bzip2recover.c \
- $(DISTNAME)/bzlib.h \
- $(DISTNAME)/bzlib_private.h \
- $(DISTNAME)/Makefile \
- $(DISTNAME)/LICENSE \
- $(DISTNAME)/bzip2.1 \
- $(DISTNAME)/bzip2.1.preformatted \
- $(DISTNAME)/bzip2.txt \
- $(DISTNAME)/words0 \
- $(DISTNAME)/words1 \
- $(DISTNAME)/words2 \
- $(DISTNAME)/words3 \
- $(DISTNAME)/sample1.ref \
- $(DISTNAME)/sample2.ref \
- $(DISTNAME)/sample3.ref \
- $(DISTNAME)/sample1.bz2 \
- $(DISTNAME)/sample2.bz2 \
- $(DISTNAME)/sample3.bz2 \
- $(DISTNAME)/dlltest.c \
- $(DISTNAME)/manual.html \
- $(DISTNAME)/manual.pdf \
- $(DISTNAME)/manual.ps \
- $(DISTNAME)/README \
- $(DISTNAME)/README.COMPILATION.PROBLEMS \
- $(DISTNAME)/README.XML.STUFF \
- $(DISTNAME)/CHANGES \
- $(DISTNAME)/libbz2.def \
- $(DISTNAME)/libbz2.dsp \
- $(DISTNAME)/dlltest.dsp \
- $(DISTNAME)/makefile.msc \
- $(DISTNAME)/Y2K_INFO \
- $(DISTNAME)/unzcrash.c \
- $(DISTNAME)/spewG.c \
- $(DISTNAME)/mk251.c \
- $(DISTNAME)/bzdiff \
- $(DISTNAME)/bzdiff.1 \
- $(DISTNAME)/bzmore \
- $(DISTNAME)/bzmore.1 \
- $(DISTNAME)/bzgrep \
- $(DISTNAME)/bzgrep.1 \
- $(DISTNAME)/Makefile-libbz2_so \
- $(DISTNAME)/bz-common.xsl \
- $(DISTNAME)/bz-fo.xsl \
- $(DISTNAME)/bz-html.xsl \
- $(DISTNAME)/bzip.css \
- $(DISTNAME)/entities.xml \
- $(DISTNAME)/manual.xml \
- $(DISTNAME)/format.pl \
- $(DISTNAME)/xmlproc.sh
- gzip -v $(DISTNAME).tar
-
-# For rebuilding the manual from sources on my SuSE 9.1 box
-
-MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \
- entities.xml manual.xml
-
-manual: manual.html manual.ps manual.pdf
-
-manual.ps: $(MANUAL_SRCS)
- ./xmlproc.sh -ps manual.xml
-
-manual.pdf: $(MANUAL_SRCS)
- ./xmlproc.sh -pdf manual.xml
-
-manual.html: $(MANUAL_SRCS)
- ./xmlproc.sh -html manual.xml
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c b/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c
index 4c09446422a..906124b97e6 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c
@@ -74,11 +74,11 @@
/*---------------------------------------------*/
/*---------------------------------------------*/
-static
+static
__inline__
-void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
+void fallbackSimpleSort ( UInt32* fmap,
+ UInt32* eclass,
+ Int32 lo,
Int32 hi )
{
Int32 i, j, tmp;
@@ -137,9 +137,9 @@ void fallbackSimpleSort ( UInt32* fmap,
static
-void fallbackQSort3 ( UInt32* fmap,
+void fallbackQSort3 ( UInt32* fmap,
UInt32* eclass,
- Int32 loSt,
+ Int32 loSt,
Int32 hiSt )
{
Int32 unLo, unHi, ltLo, gtHi, n, m;
@@ -164,9 +164,9 @@ void fallbackQSort3 ( UInt32* fmap,
}
/* Random partitioning. Median of 3 sometimes fails to
- avoid bad cases. Median of 9 seems to help but
+ avoid bad cases. Median of 9 seems to help but
looks rather expensive. This too seems to work but
- is cheaper. Guidance for the magic constants
+ is cheaper. Guidance for the magic constants
7621 and 32768 is taken from Sedgewick's algorithms
book, chapter 35.
*/
@@ -183,10 +183,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) {
if (unLo > unHi) break;
n = (Int32)eclass[fmap[unLo]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unLo], fmap[ltLo]);
- ltLo++; unLo++;
- continue;
+ if (n == 0) {
+ fswap(fmap[unLo], fmap[ltLo]);
+ ltLo++; unLo++;
+ continue;
};
if (n > 0) break;
unLo++;
@@ -194,10 +194,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) {
if (unLo > unHi) break;
n = (Int32)eclass[fmap[unHi]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unHi], fmap[gtHi]);
- gtHi--; unHi--;
- continue;
+ if (n == 0) {
+ fswap(fmap[unHi], fmap[gtHi]);
+ gtHi--; unHi--;
+ continue;
};
if (n < 0) break;
unHi--;
@@ -256,8 +256,8 @@ void fallbackQSort3 ( UInt32* fmap,
#define UNALIGNED_BH(zz) ((zz) & 0x01f)
static
-void fallbackSort ( UInt32* fmap,
- UInt32* eclass,
+void fallbackSort ( UInt32* fmap,
+ UInt32* eclass,
UInt32* bhtab,
Int32 nblock,
Int32 verb )
@@ -298,7 +298,7 @@ void fallbackSort ( UInt32* fmap,
--*/
/*-- set sentinel bits for block-end detection --*/
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < 32; i++) {
SET_BH(nblock + 2*i);
CLEAR_BH(nblock + 2*i + 1);
}
@@ -307,7 +307,7 @@ void fallbackSort ( UInt32* fmap,
H = 1;
while (1) {
- if (verb >= 4)
+ if (verb >= 4)
VPrintf1 ( " depth %6d has ", H );
j = 0;
@@ -321,7 +321,7 @@ void fallbackSort ( UInt32* fmap,
r = -1;
while (1) {
- /*-- find the next non-singleton bucket --*/
+ /*-- find the next non-singleton bucket --*/
k = r + 1;
while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
if (ISSET_BH(k)) {
@@ -352,14 +352,14 @@ void fallbackSort ( UInt32* fmap,
}
}
- if (verb >= 4)
+ if (verb >= 4)
VPrintf1 ( "%6d unresolved strings\n", nNotDone );
H *= 2;
if (H > nblock || nNotDone == 0) break;
}
- /*--
+ /*--
Reconstruct the original block in
eclass8 [0 .. nblock-1], since the
previous phase destroyed it.
@@ -391,9 +391,9 @@ void fallbackSort ( UInt32* fmap,
/*---------------------------------------------*/
static
__inline__
-Bool mainGtU ( UInt32 i1,
+Bool mainGtU ( UInt32 i1,
UInt32 i2,
- UChar* block,
+ UChar* block,
UInt16* quadrant,
UInt32 nblock,
Int32* budget )
@@ -533,8 +533,8 @@ void mainSimpleSort ( UInt32* ptr,
UChar* block,
UInt16* quadrant,
Int32 nblock,
- Int32 lo,
- Int32 hi,
+ Int32 lo,
+ Int32 hi,
Int32 d,
Int32* budget )
{
@@ -558,8 +558,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -572,8 +572,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -586,8 +586,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -625,13 +625,13 @@ void mainSimpleSort ( UInt32* ptr,
} \
}
-static
+static
__inline__
UChar mmed3 ( UChar a, UChar b, UChar c )
{
UChar t;
if (a > b) { t = a; a = b; b = t; };
- if (b > c) {
+ if (b > c) {
b = c;
if (a > b) b = a;
}
@@ -669,8 +669,8 @@ void mainQSort3 ( UInt32* ptr,
UChar* block,
UInt16* quadrant,
Int32 nblock,
- Int32 loSt,
- Int32 hiSt,
+ Int32 loSt,
+ Int32 hiSt,
Int32 dSt,
Int32* budget )
{
@@ -693,14 +693,14 @@ void mainQSort3 ( UInt32* ptr,
AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 );
mpop ( lo, hi, d );
- if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
+ if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
d > MAIN_QSORT_DEPTH_THRESH) {
mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
if (*budget < 0) return;
continue;
}
- med = (Int32)
+ med = (Int32)
mmed3 ( block[ptr[ lo ]+d],
block[ptr[ hi ]+d],
block[ptr[ (lo+hi)>>1 ]+d] );
@@ -712,9 +712,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) {
if (unLo > unHi) break;
n = ((Int32)block[ptr[unLo]+d]) - med;
- if (n == 0) {
- mswap(ptr[unLo], ptr[ltLo]);
- ltLo++; unLo++; continue;
+ if (n == 0) {
+ mswap(ptr[unLo], ptr[ltLo]);
+ ltLo++; unLo++; continue;
};
if (n > 0) break;
unLo++;
@@ -722,9 +722,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) {
if (unLo > unHi) break;
n = ((Int32)block[ptr[unHi]+d]) - med;
- if (n == 0) {
- mswap(ptr[unHi], ptr[gtHi]);
- gtHi--; unHi--; continue;
+ if (n == 0) {
+ mswap(ptr[unHi], ptr[gtHi]);
+ gtHi--; unHi--; continue;
};
if (n < 0) break;
unHi--;
@@ -795,9 +795,9 @@ void mainQSort3 ( UInt32* ptr,
#define CLEARMASK (~(SETMASK))
static
-void mainSort ( UInt32* ptr,
+void mainSort ( UInt32* ptr,
UChar* block,
- UInt16* quadrant,
+ UInt16* quadrant,
UInt32* ftab,
Int32 nblock,
Int32 verb,
@@ -925,7 +925,7 @@ void mainSort ( UInt32* ptr,
/*--
Step 1:
Complete the big bucket [ss] by quicksorting
- any unsorted small buckets [ss, j], for j != ss.
+ any unsorted small buckets [ss, j], for j != ss.
Hopefully previous pointer-scanning phases have already
completed many of the small buckets [ss, j], so
we don't have to sort them at all.
@@ -941,10 +941,10 @@ void mainSort ( UInt32* ptr,
VPrintf4 ( " qsort [0x%x, 0x%x] "
"done %d this %d\n",
ss, j, numQSorted, hi - lo + 1 );
- mainQSort3 (
- ptr, block, quadrant, nblock,
- lo, hi, BZ_N_RADIX, budget
- );
+ mainQSort3 (
+ ptr, block, quadrant, nblock,
+ lo, hi, BZ_N_RADIX, budget
+ );
numQSorted += (hi - lo + 1);
if (*budget < 0) return;
}
@@ -976,16 +976,16 @@ void mainSort ( UInt32* ptr,
for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
k = ptr[j]-1; if (k < 0) k += nblock;
c1 = block[k];
- if (!bigDone[c1])
+ if (!bigDone[c1])
ptr[ copyEnd[c1]-- ] = k;
}
}
AssertH ( (copyStart[ss]-1 == copyEnd[ss])
- ||
+ ||
/* Extremely rare case missing in bzip2-1.0.0 and 1.0.1.
- Necessity for this case is demonstrated by compressing
- a sequence of approximately 48.5 million of character
+ Necessity for this case is demonstrated by compressing
+ a sequence of approximately 48.5 million of character
251; 1.0.0/1.0.1 will then die here. */
(copyStart[ss] == 0 && copyEnd[ss] == nblock-1),
1007 )
@@ -1002,7 +1002,7 @@ void mainSort ( UInt32* ptr,
updating for the last bucket is pointless.
The quadrant array provides a way to incrementally
- cache sort orderings, as they appear, so as to
+ cache sort orderings, as they appear, so as to
make subsequent comparisons in fullGtU() complete
faster. For repetitive blocks this makes a big
difference (but not big enough to be able to avoid
@@ -1012,9 +1012,9 @@ void mainSort ( UInt32* ptr,
for 0 <= i < nblock and 0 <= j <= nblock
- if block[i] != block[j],
+ if block[i] != block[j],
- then the relative values of quadrant[i] and
+ then the relative values of quadrant[i] and
quadrant[j] are meaningless.
else {
@@ -1077,7 +1077,7 @@ void mainSort ( UInt32* ptr,
*/
void BZ2_blockSort ( EState* s )
{
- UInt32* ptr = s->ptr;
+ UInt32* ptr = s->ptr;
UChar* block = s->block;
UInt32* ftab = s->ftab;
Int32 nblock = s->nblock;
@@ -1101,8 +1101,8 @@ void BZ2_blockSort ( EState* s )
quadrant = (UInt16*)(&(block[i]));
/* (wfact-1) / 3 puts the default-factor-30
- transition point at very roughly the same place as
- with v0.1 and v0.9.0.
+ transition point at very roughly the same place as
+ with v0.1 and v0.9.0.
Not that it particularly matters any more, since the
resulting compressed stream is now the same regardless
of whether or not we use the main sort or fallback sort.
@@ -1113,14 +1113,14 @@ void BZ2_blockSort ( EState* s )
budget = budgetInit;
mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
- if (verb >= 3)
+ if (verb >= 3)
VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
budgetInit - budget,
- nblock,
+ nblock,
(float)(budgetInit - budget) /
- (float)(nblock==0 ? 1 : nblock) );
+ (float)(nblock==0 ? 1 : nblock) );
if (budget < 0) {
- if (verb >= 2)
+ if (verb >= 2)
VPrintf0 ( " too repetitive; using fallback"
" sorting algorithm\n" );
fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c
index 2e54697670a..79f87a51986 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c
@@ -16,16 +16,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -64,12 +64,12 @@
/*--
WARNING:
- This program and library (attempts to) compress data by
- performing several non-trivial transformations on it.
- Unless you are 100% familiar with *all* the algorithms
- contained herein, and with the consequences of modifying them,
- you should NOT meddle with the compression or decompression
- machinery. Incorrect changes can and very likely *will*
+ This program and library (attempts to) compress data by
+ performing several non-trivial transformations on it.
+ Unless you are 100% familiar with *all* the algorithms
+ contained herein, and with the consequences of modifying them,
+ you should NOT meddle with the compression or decompression
+ machinery. Incorrect changes can and very likely *will*
lead to disasterous loss of data.
DISCLAIMER:
@@ -84,8 +84,8 @@
of various special cases in the code which occur with very low
but non-zero probability make it impossible to rule out the
possibility of bugs remaining in the program. DO NOT COMPRESS
- ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED
- TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL
+ ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED
+ TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL
NOT BE RECOVERABLE.
That is not to say this program is inherently unreliable.
@@ -93,9 +93,9 @@
has been carefully constructed and extensively tested.
PATENTS:
- To the best of my knowledge, bzip2/libbzip2 does not use any
- patented algorithms. However, I do not have the resources
- available to carry out a full patent search. Therefore I cannot
+ To the best of my knowledge, bzip2/libbzip2 does not use any
+ patented algorithms. However, I do not have the resources
+ available to carry out a full patent search. Therefore I cannot
give any guarantee of the above statement.
--*/
@@ -257,7 +257,7 @@ typedef int Int32;
typedef unsigned int UInt32;
typedef short Int16;
typedef unsigned short UInt16;
-
+
#define True ((Bool)1)
#define False ((Bool)0)
@@ -321,7 +321,7 @@ static void* myMalloc ( Int32 );
/*---------------------------------------------------*/
typedef
- struct { UChar b[8]; }
+ struct { UChar b[8]; }
UInt64;
@@ -364,7 +364,7 @@ Bool uInt64_isZero ( UInt64* n )
/* Divide *n by 10, and return the remainder. */
-static
+static
Int32 uInt64_qrm10 ( UInt64* n )
{
UInt32 rem, tmp;
@@ -395,7 +395,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n )
nBuf++;
} while (!uInt64_isZero(&n_copy));
outbuf[nBuf] = 0;
- for (i = 0; i < nBuf; i++)
+ for (i = 0; i < nBuf; i++)
outbuf[i] = buf[nBuf-i-1];
}
@@ -405,7 +405,7 @@ void uInt64_toAscii ( char* outbuf, UInt64* n )
/*---------------------------------------------------*/
/*---------------------------------------------*/
-static
+static
Bool myfeof ( FILE* f )
{
Int32 c = fgetc ( f );
@@ -416,7 +416,7 @@ Bool myfeof ( FILE* f )
/*---------------------------------------------*/
-static
+static
void compressStream ( FILE *stream, FILE *zStream )
{
BZFILE* bzf = NULL;
@@ -432,8 +432,8 @@ void compressStream ( FILE *stream, FILE *zStream )
if (ferror(stream)) goto errhandler_io;
if (ferror(zStream)) goto errhandler_io;
- bzf = BZ2_bzWriteOpen ( &bzerr, zStream,
- blockSize100k, verbosity, workFactor );
+ bzf = BZ2_bzWriteOpen ( &bzerr, zStream,
+ blockSize100k, verbosity, workFactor );
if (bzerr != BZ_OK) goto errhandler;
if (verbosity >= 2) fprintf ( stderr, "\n" );
@@ -448,7 +448,7 @@ void compressStream ( FILE *stream, FILE *zStream )
}
- BZ2_bzWriteClose64 ( &bzerr, bzf, 0,
+ BZ2_bzWriteClose64 ( &bzerr, bzf, 0,
&nbytes_in_lo32, &nbytes_in_hi32,
&nbytes_out_lo32, &nbytes_out_hi32 );
if (bzerr != BZ_OK) goto errhandler;
@@ -468,34 +468,34 @@ void compressStream ( FILE *stream, FILE *zStream )
if (verbosity >= 1) {
if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) {
- fprintf ( stderr, " no data compressed.\n");
+ fprintf ( stderr, " no data compressed.\n");
} else {
- Char buf_nin[32], buf_nout[32];
- UInt64 nbytes_in, nbytes_out;
- double nbytes_in_d, nbytes_out_d;
- uInt64_from_UInt32s ( &nbytes_in,
- nbytes_in_lo32, nbytes_in_hi32 );
- uInt64_from_UInt32s ( &nbytes_out,
- nbytes_out_lo32, nbytes_out_hi32 );
- nbytes_in_d = uInt64_to_double ( &nbytes_in );
- nbytes_out_d = uInt64_to_double ( &nbytes_out );
- uInt64_toAscii ( buf_nin, &nbytes_in );
- uInt64_toAscii ( buf_nout, &nbytes_out );
- fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, "
- "%5.2f%% saved, %s in, %s out.\n",
- nbytes_in_d / nbytes_out_d,
- (8.0 * nbytes_out_d) / nbytes_in_d,
- 100.0 * (1.0 - nbytes_out_d / nbytes_in_d),
- buf_nin,
- buf_nout
- );
+ Char buf_nin[32], buf_nout[32];
+ UInt64 nbytes_in, nbytes_out;
+ double nbytes_in_d, nbytes_out_d;
+ uInt64_from_UInt32s ( &nbytes_in,
+ nbytes_in_lo32, nbytes_in_hi32 );
+ uInt64_from_UInt32s ( &nbytes_out,
+ nbytes_out_lo32, nbytes_out_hi32 );
+ nbytes_in_d = uInt64_to_double ( &nbytes_in );
+ nbytes_out_d = uInt64_to_double ( &nbytes_out );
+ uInt64_toAscii ( buf_nin, &nbytes_in );
+ uInt64_toAscii ( buf_nout, &nbytes_out );
+ fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, "
+ "%5.2f%% saved, %s in, %s out.\n",
+ nbytes_in_d / nbytes_out_d,
+ (8.0 * nbytes_out_d) / nbytes_in_d,
+ 100.0 * (1.0 - nbytes_out_d / nbytes_in_d),
+ buf_nin,
+ buf_nout
+ );
}
}
return;
errhandler:
- BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1,
+ BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1,
&nbytes_in_lo32, &nbytes_in_hi32,
&nbytes_out_lo32, &nbytes_out_hi32 );
switch (bzerr) {
@@ -517,7 +517,7 @@ void compressStream ( FILE *stream, FILE *zStream )
/*---------------------------------------------*/
-static
+static
Bool uncompressStream ( FILE *zStream, FILE *stream )
{
BZFILE* bzf = NULL;
@@ -539,8 +539,8 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
while (True) {
- bzf = BZ2_bzReadOpen (
- &bzerr, zStream, verbosity,
+ bzf = BZ2_bzReadOpen (
+ &bzerr, zStream, verbosity,
(int)smallMode, unused, nUnused
);
if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
@@ -584,19 +584,19 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
if (verbosity >= 2) fprintf ( stderr, "\n " );
return True;
- trycat:
+ trycat:
if (forceOverwrite) {
rewind(zStream);
while (True) {
- if (myfeof(zStream)) break;
- nread = fread ( obuf, sizeof(UChar), 5000, zStream );
- if (ferror(zStream)) goto errhandler_io;
- if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream );
- if (ferror(stream)) goto errhandler_io;
+ if (myfeof(zStream)) break;
+ nread = fread ( obuf, sizeof(UChar), 5000, zStream );
+ if (ferror(zStream)) goto errhandler_io;
+ if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream );
+ if (ferror(stream)) goto errhandler_io;
}
goto closeok;
}
-
+
errhandler:
BZ2_bzReadClose ( &bzerr_dummy, bzf );
switch (bzerr) {
@@ -618,10 +618,10 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
return False;
} else {
if (noisy)
- fprintf ( stderr,
+ fprintf ( stderr,
"\n%s: %s: trailing garbage after EOF ignored\n",
progName, inName );
- return True;
+ return True;
}
default:
panic ( "decompress:unexpected error" );
@@ -633,7 +633,7 @@ Bool uncompressStream ( FILE *zStream, FILE *stream )
/*---------------------------------------------*/
-static
+static
Bool testStream ( FILE *zStream )
{
BZFILE* bzf = NULL;
@@ -652,8 +652,8 @@ Bool testStream ( FILE *zStream )
while (True) {
- bzf = BZ2_bzReadOpen (
- &bzerr, zStream, verbosity,
+ bzf = BZ2_bzReadOpen (
+ &bzerr, zStream, verbosity,
(int)smallMode, unused, nUnused
);
if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
@@ -686,7 +686,7 @@ Bool testStream ( FILE *zStream )
errhandler:
BZ2_bzReadClose ( &bzerr_dummy, bzf );
- if (verbosity == 0)
+ if (verbosity == 0)
fprintf ( stderr, "%s: %s: ", progName, inName );
switch (bzerr) {
case BZ_CONFIG_ERROR:
@@ -707,14 +707,14 @@ Bool testStream ( FILE *zStream )
case BZ_DATA_ERROR_MAGIC:
if (zStream != stdin) fclose(zStream);
if (streamNo == 1) {
- fprintf ( stderr,
+ fprintf ( stderr,
"bad magic number (file not created by bzip2)\n" );
return False;
} else {
if (noisy)
- fprintf ( stderr,
+ fprintf ( stderr,
"trailing garbage after EOF ignored\n" );
- return True;
+ return True;
}
default:
panic ( "test:unexpected error" );
@@ -738,7 +738,7 @@ void setExit ( Int32 v )
/*---------------------------------------------*/
-static
+static
void cadvise ( void )
{
if (noisy)
@@ -753,26 +753,26 @@ void cadvise ( void )
/*---------------------------------------------*/
-static
+static
void showFileNames ( void )
{
if (noisy)
fprintf (
stderr,
"\tInput file = %s, output file = %s\n",
- inName, outName
+ inName, outName
);
}
/*---------------------------------------------*/
-static
+static
void cleanUpAndFail ( Int32 ec )
{
IntNative retVal;
struct MY_STAT statBuf;
- if ( srcMode == SM_F2F
+ if ( srcMode == SM_F2F
&& opMode != OM_TEST
&& deleteOutputOnInterrupt ) {
@@ -784,7 +784,7 @@ void cleanUpAndFail ( Int32 ec )
retVal = MY_STAT ( inName, &statBuf );
if (retVal == 0) {
if (noisy)
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: Deleting output file %s, if it exists.\n",
progName, outName );
if (outputHandleJustInCase != NULL)
@@ -805,7 +805,7 @@ void cleanUpAndFail ( Int32 ec )
fprintf ( stderr,
"%s: `%s' may be incomplete.\n",
progName, outName );
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: I suggest doing an integrity test (bzip2 -tv)"
" of it.\n",
progName );
@@ -813,7 +813,7 @@ void cleanUpAndFail ( Int32 ec )
}
if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) {
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: WARNING: some files have not been processed:\n"
"%s: %d specified on command line, %d not processed yet.\n\n",
progName, progName,
@@ -825,7 +825,7 @@ void cleanUpAndFail ( Int32 ec )
/*---------------------------------------------*/
-static
+static
void panic ( Char* s )
{
fprintf ( stderr,
@@ -840,7 +840,7 @@ void panic ( Char* s )
/*---------------------------------------------*/
-static
+static
void crcError ( void )
{
fprintf ( stderr,
@@ -853,14 +853,14 @@ void crcError ( void )
/*---------------------------------------------*/
-static
+static
void compressedStreamEOF ( void )
{
if (noisy) {
fprintf ( stderr,
- "\n%s: Compressed file ends unexpectedly;\n\t"
- "perhaps it is corrupted? *Possible* reason follows.\n",
- progName );
+ "\n%s: Compressed file ends unexpectedly;\n\t"
+ "perhaps it is corrupted? *Possible* reason follows.\n",
+ progName );
perror ( progName );
showFileNames();
cadvise();
@@ -870,7 +870,7 @@ void compressedStreamEOF ( void )
/*---------------------------------------------*/
-static
+static
void ioError ( void )
{
fprintf ( stderr,
@@ -884,7 +884,7 @@ void ioError ( void )
/*---------------------------------------------*/
-static
+static
void mySignalCatcher ( IntNative n )
{
fprintf ( stderr,
@@ -895,11 +895,11 @@ void mySignalCatcher ( IntNative n )
/*---------------------------------------------*/
-static
+static
void mySIGSEGVorSIGBUScatcher ( IntNative n )
{
if (opMode == OM_Z)
- fprintf (
+ fprintf (
stderr,
"\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n"
"\n"
@@ -920,7 +920,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
"\n",
progName );
else
- fprintf (
+ fprintf (
stderr,
"\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n"
"\n"
@@ -951,7 +951,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
/*---------------------------------------------*/
-static
+static
void outOfMemory ( void )
{
fprintf ( stderr,
@@ -963,7 +963,7 @@ void outOfMemory ( void )
/*---------------------------------------------*/
-static
+static
void configError ( void )
{
fprintf ( stderr,
@@ -983,11 +983,11 @@ void configError ( void )
/* All rather crufty. The main problem is that input files
are stat()d multiple times before use. This should be
- cleaned up.
+ cleaned up.
*/
/*---------------------------------------------*/
-static
+static
void pad ( Char *s )
{
Int32 i;
@@ -998,8 +998,8 @@ void pad ( Char *s )
/*---------------------------------------------*/
-static
-void copyFileName ( Char* to, Char* from )
+static
+void copyFileName ( Char* to, Char* from )
{
if ( strlen(from) > FILE_NAME_LEN-10 ) {
fprintf (
@@ -1019,7 +1019,7 @@ void copyFileName ( Char* to, Char* from )
/*---------------------------------------------*/
-static
+static
Bool fileExists ( Char* name )
{
FILE *tmp = fopen ( name, "rb" );
@@ -1059,7 +1059,7 @@ FILE* fopen_output_safely ( Char* name, const char* mode )
/*--
if in doubt, return True
--*/
-static
+static
Bool notAStandardFile ( Char* name )
{
IntNative i;
@@ -1076,9 +1076,9 @@ Bool notAStandardFile ( Char* name )
/*--
rac 11/21/98 see if file has hard links to it
--*/
-static
+static
Int32 countHardLinks ( Char* name )
-{
+{
IntNative i;
struct MY_STAT statBuf;
@@ -1109,14 +1109,14 @@ Int32 countHardLinks ( Char* name )
It sounds pretty fragile to me. Whether this carries across
robustly to arbitrary Unix-like platforms (or even works robustly
- on this one, RedHat 7.2) is unknown to me. Nevertheless ...
+ on this one, RedHat 7.2) is unknown to me. Nevertheless ...
*/
#if BZ_UNIX
-static
+static
struct MY_STAT fileMetaInfo;
#endif
-static
+static
void saveInputFileMetaInfo ( Char *srcName )
{
# if BZ_UNIX
@@ -1128,7 +1128,7 @@ void saveInputFileMetaInfo ( Char *srcName )
}
-static
+static
void applySavedMetaInfoToOutputFile ( Char *dstName )
{
# if BZ_UNIX
@@ -1153,7 +1153,7 @@ void applySavedMetaInfoToOutputFile ( Char *dstName )
/*---------------------------------------------*/
-static
+static
Bool containsDubiousChars ( Char* name )
{
# if BZ_UNIX
@@ -1162,7 +1162,7 @@ Bool containsDubiousChars ( Char* name )
*/
return False;
# else /* ! BZ_UNIX */
- /* On non-unix (Win* platforms), wildcard characters are not allowed in
+ /* On non-unix (Win* platforms), wildcard characters are not allowed in
* filenames.
*/
for (; *name != '\0'; name++)
@@ -1175,12 +1175,12 @@ Bool containsDubiousChars ( Char* name )
/*---------------------------------------------*/
#define BZ_N_SUFFIX_PAIRS 4
-Char* zSuffix[BZ_N_SUFFIX_PAIRS]
+Char* zSuffix[BZ_N_SUFFIX_PAIRS]
= { ".bz2", ".bz", ".tbz2", ".tbz" };
-Char* unzSuffix[BZ_N_SUFFIX_PAIRS]
+Char* unzSuffix[BZ_N_SUFFIX_PAIRS]
= { "", "", ".tar", ".tar" };
-static
+static
Bool hasSuffix ( Char* s, Char* suffix )
{
Int32 ns = strlen(s);
@@ -1190,8 +1190,8 @@ Bool hasSuffix ( Char* s, Char* suffix )
return False;
}
-static
-Bool mapSuffix ( Char* name,
+static
+Bool mapSuffix ( Char* name,
Char* oldSuffix, Char* newSuffix )
{
if (!hasSuffix(name,oldSuffix)) return False;
@@ -1202,7 +1202,7 @@ Bool mapSuffix ( Char* name,
/*---------------------------------------------*/
-static
+static
void compress ( Char *name )
{
FILE *inStr;
@@ -1216,18 +1216,18 @@ void compress ( Char *name )
panic ( "compress: bad modes\n" );
switch (srcMode) {
- case SM_I2O:
+ case SM_I2O:
copyFileName ( inName, "(stdin)" );
- copyFileName ( outName, "(stdout)" );
+ copyFileName ( outName, "(stdout)" );
break;
- case SM_F2F:
+ case SM_F2F:
copyFileName ( inName, name );
copyFileName ( outName, name );
- strcat ( outName, ".bz2" );
+ strcat ( outName, ".bz2" );
break;
- case SM_F2O:
+ case SM_F2O:
copyFileName ( inName, name );
- copyFileName ( outName, "(stdout)" );
+ copyFileName ( outName, "(stdout)" );
break;
}
@@ -1247,7 +1247,7 @@ void compress ( Char *name )
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
if (hasSuffix(inName, zSuffix[i])) {
if (noisy)
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: Input file %s already has %s suffix.\n",
progName, inName, zSuffix[i] );
setExit(1);
@@ -1273,12 +1273,12 @@ void compress ( Char *name )
}
if ( srcMode == SM_F2F && fileExists ( outName ) ) {
if (forceOverwrite) {
- remove(outName);
+ remove(outName);
} else {
- fprintf ( stderr, "%s: Output file %s already exists.\n",
- progName, outName );
- setExit(1);
- return;
+ fprintf ( stderr, "%s: Output file %s already exists.\n",
+ progName, outName );
+ setExit(1);
+ return;
}
}
if ( srcMode == SM_F2F && !forceOverwrite &&
@@ -1383,7 +1383,7 @@ void compress ( Char *name )
/*---------------------------------------------*/
-static
+static
void uncompress ( Char *name )
{
FILE *inStr;
@@ -1400,22 +1400,22 @@ void uncompress ( Char *name )
cantGuess = False;
switch (srcMode) {
- case SM_I2O:
+ case SM_I2O:
copyFileName ( inName, "(stdin)" );
- copyFileName ( outName, "(stdout)" );
+ copyFileName ( outName, "(stdout)" );
break;
- case SM_F2F:
+ case SM_F2F:
copyFileName ( inName, name );
copyFileName ( outName, name );
for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++)
if (mapSuffix(outName,zSuffix[i],unzSuffix[i]))
- goto zzz;
+ goto zzz;
cantGuess = True;
strcat ( outName, ".out" );
break;
- case SM_F2O:
+ case SM_F2O:
copyFileName ( inName, name );
- copyFileName ( outName, "(stdout)" );
+ copyFileName ( outName, "(stdout)" );
break;
}
@@ -1452,14 +1452,14 @@ void uncompress ( Char *name )
}
if ( /* srcMode == SM_F2F implied && */ cantGuess ) {
if (noisy)
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: Can't guess original name for %s -- using %s\n",
progName, inName, outName );
/* just a warning, no return */
- }
+ }
if ( srcMode == SM_F2F && fileExists ( outName ) ) {
if (forceOverwrite) {
- remove(outName);
+ remove(outName);
} else {
fprintf ( stderr, "%s: Output file %s already exists.\n",
progName, outName );
@@ -1581,7 +1581,7 @@ void uncompress ( Char *name )
/*---------------------------------------------*/
-static
+static
void testf ( Char *name )
{
FILE *inStr;
@@ -1670,7 +1670,7 @@ void testf ( Char *name )
/*---------------------------------------------*/
-static
+static
void license ( void )
{
fprintf ( stderr,
@@ -1695,7 +1695,7 @@ void license ( void )
/*---------------------------------------------*/
-static
+static
void usage ( Char *fullProgName )
{
fprintf (
@@ -1739,11 +1739,11 @@ void usage ( Char *fullProgName )
/*---------------------------------------------*/
-static
+static
void redundant ( Char* flag )
{
- fprintf (
- stderr,
+ fprintf (
+ stderr,
"%s: %s is redundant in versions 0.9.5 and above\n",
progName, flag );
}
@@ -1755,8 +1755,8 @@ void redundant ( Char* flag )
implement a linked list of command-line arguments,
into which main() copies argv[1 .. argc-1].
- The purpose of this exercise is to facilitate
- the expansion of wildcard characters * and ? in
+ The purpose of this exercise is to facilitate
+ the expansion of wildcard characters * and ? in
filenames for OSs which don't know how to do it
themselves, like MSDOS, Windows 95 and NT.
@@ -1773,7 +1773,7 @@ typedef
/*---------------------------------------------*/
-static
+static
void *myMalloc ( Int32 n )
{
void* p;
@@ -1785,7 +1785,7 @@ void *myMalloc ( Int32 n )
/*---------------------------------------------*/
-static
+static
Cell *mkCell ( void )
{
Cell *c;
@@ -1798,7 +1798,7 @@ Cell *mkCell ( void )
/*---------------------------------------------*/
-static
+static
Cell *snocString ( Cell *root, Char *name )
{
if (root == NULL) {
@@ -1816,8 +1816,8 @@ Cell *snocString ( Cell *root, Char *name )
/*---------------------------------------------*/
-static
-void addFlagsFromEnvVar ( Cell** argList, Char* varName )
+static
+void addFlagsFromEnvVar ( Cell** argList, Char* varName )
{
Int32 i, j, k;
Char *envbase, *p;
@@ -1894,7 +1894,7 @@ IntNative main ( IntNative argc, Char *argv[] )
if (*tmp == PATH_SEP) progName = tmp + 1;
- /*-- Copy flags from env var BZIP2, and
+ /*-- Copy flags from env var BZIP2, and
expand filename wildcards in arg list.
--*/
argList = NULL;
@@ -1977,7 +1977,7 @@ IntNative main ( IntNative argc, Char *argv[] )
}
}
}
-
+
/*-- And again ... --*/
for (aa = argList; aa != NULL; aa = aa->link) {
if (ISFLAG("--")) break;
@@ -1991,7 +1991,7 @@ IntNative main ( IntNative argc, Char *argv[] )
if (ISFLAG("--quiet")) noisy = False; else
if (ISFLAG("--version")) license(); else
if (ISFLAG("--license")) license(); else
- if (ISFLAG("--exponential")) workFactor = 1; else
+ if (ISFLAG("--exponential")) workFactor = 1; else
if (ISFLAG("--repetitive-best")) redundant(aa->name); else
if (ISFLAG("--repetitive-fast")) redundant(aa->name); else
if (ISFLAG("--fast")) blockSize100k = 1; else
@@ -2007,7 +2007,7 @@ IntNative main ( IntNative argc, Char *argv[] )
}
if (verbosity > 4) verbosity = 4;
- if (opMode == OM_Z && smallMode && blockSize100k > 2)
+ if (opMode == OM_Z && smallMode && blockSize100k > 2)
blockSize100k = 2;
if (opMode == OM_TEST && srcMode == SM_F2O) {
@@ -2041,7 +2041,7 @@ IntNative main ( IntNative argc, Char *argv[] )
compress ( aa->name );
}
}
- }
+ }
else
if (opMode == OM_UNZ) {
@@ -2055,13 +2055,13 @@ IntNative main ( IntNative argc, Char *argv[] )
if (aa->name[0] == '-' && decode) continue;
numFilesProcessed++;
uncompress ( aa->name );
- }
+ }
}
- if (unzFailsExist) {
- setExit(2);
+ if (unzFailsExist) {
+ setExit(2);
exit(exitValue);
}
- }
+ }
else {
testFailsExist = False;
@@ -2070,11 +2070,11 @@ IntNative main ( IntNative argc, Char *argv[] )
} else {
decode = True;
for (aa = argList; aa != NULL; aa = aa->link) {
- if (ISFLAG("--")) { decode = False; continue; }
+ if (ISFLAG("--")) { decode = False; continue; }
if (aa->name[0] == '-' && decode) continue;
numFilesProcessed++;
testf ( aa->name );
- }
+ }
}
if (testFailsExist && noisy) {
fprintf ( stderr,
@@ -2087,7 +2087,7 @@ IntNative main ( IntNative argc, Char *argv[] )
}
}
- /* Free the argument list memory to mollify leak detectors
+ /* Free the argument list memory to mollify leak detectors
(eg) Purify, Checker. Serves no other useful purpose.
*/
aa = argList;
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c
index d1b8da845db..5cd405dd4cb 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c
@@ -5,7 +5,7 @@
/*-----------------------------------------------------------*/
/*--
- This program is bzip2recover, a program to attempt data
+ This program is bzip2recover, a program to attempt data
salvage from damaged files created by the accompanying
bzip2-1.0.3 program.
@@ -18,16 +18,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -107,7 +107,7 @@ MaybeUInt64 bytesIn = 0;
#define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */
-
+
/*---------------------------------------------------*/
/*--- I/O errors ---*/
@@ -160,7 +160,7 @@ void tooManyBlocks ( Int32 max_handled_blocks )
fprintf ( stderr,
"%s: and cannot be handled. To fix, increase\n",
progName );
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
progName );
exit ( 1 );
@@ -344,7 +344,7 @@ Int32 main ( Int32 argc, Char** argv )
strcpy ( progName, argv[0] );
inFileName[0] = outFileName[0] = 0;
- fprintf ( stderr,
+ fprintf ( stderr,
"bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.\n" );
if (argc != 2) {
@@ -352,18 +352,18 @@ Int32 main ( Int32 argc, Char** argv )
progName, progName );
switch (sizeof(MaybeUInt64)) {
case 8:
- fprintf(stderr,
+ fprintf(stderr,
"\trestrictions on size of recovered file: None\n");
break;
case 4:
- fprintf(stderr,
+ fprintf(stderr,
"\trestrictions on size of recovered file: 512 MB\n");
- fprintf(stderr,
+ fprintf(stderr,
"\tto circumvent, recompile with MaybeUInt64 as an\n"
"\tunsigned 64-bit int.\n");
break;
default:
- fprintf(stderr,
+ fprintf(stderr,
"\tsizeof(MaybeUInt64) is not 4 or 8 -- "
"configuration error.\n");
break;
@@ -372,7 +372,7 @@ Int32 main ( Int32 argc, Char** argv )
}
if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
- fprintf ( stderr,
+ fprintf ( stderr,
"%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n",
progName, (int)strlen(argv[1]) );
exit(1);
@@ -404,7 +404,7 @@ Int32 main ( Int32 argc, Char** argv )
(bitsRead - bStart[currBlock]) >= 40) {
bEnd[currBlock] = bitsRead-1;
if (currBlock > 0)
- fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
+ fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
" to " MaybeUInt64_FMT " (incomplete)\n",
currBlock, bStart[currBlock], bEnd[currBlock] );
} else
@@ -413,10 +413,10 @@ Int32 main ( Int32 argc, Char** argv )
}
buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1);
- if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI
+ if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI
&& buffLo == BLOCK_HEADER_LO)
- ||
- ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI
+ ||
+ ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI
&& buffLo == BLOCK_ENDMARK_LO)
) {
if (bitsRead > 49) {
@@ -425,8 +425,8 @@ Int32 main ( Int32 argc, Char** argv )
bEnd[currBlock] = 0;
}
if (currBlock > 0 &&
- (bEnd[currBlock] - bStart[currBlock]) >= 130) {
- fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
+ (bEnd[currBlock] - bStart[currBlock]) >= 130) {
+ fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT
" to " MaybeUInt64_FMT "\n",
rbCtr+1, bStart[currBlock], bEnd[currBlock] );
rbStart[rbCtr] = bStart[currBlock];
@@ -472,7 +472,7 @@ Int32 main ( Int32 argc, Char** argv )
if (b == 2) break;
buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1);
- if (bitsRead == 47+rbStart[wrBlock])
+ if (bitsRead == 47+rbStart[wrBlock])
blockCRC = (buffHi << 16) | (buffLo >> 16);
if (outFile != NULL && bitsRead >= rbStart[wrBlock]
@@ -494,11 +494,11 @@ Int32 main ( Int32 argc, Char** argv )
wrBlock++;
} else
if (bitsRead == rbStart[wrBlock]) {
- /* Create the output file name, correctly handling leading paths.
+ /* Create the output file name, correctly handling leading paths.
(31.10.2001 by Sergey E. Kusikov) */
Char* split;
Int32 ofs, k;
- for (k = 0; k < BZ_MAX_FILENAME; k++)
+ for (k = 0; k < BZ_MAX_FILENAME; k++)
outFileName[k] = 0;
strcpy (outFileName, inFileName);
split = strrchr (outFileName, BZ_SPLIT_SYM);
@@ -506,8 +506,8 @@ Int32 main ( Int32 argc, Char** argv )
split = outFileName;
} else {
++split;
- }
- /* Now split points to the start of the basename. */
+ }
+ /* Now split points to the start of the basename. */
ofs = split - outFileName;
sprintf (split, "rec%5d", wrBlock+1);
for (p = split; *p != 0; p++) if (*p == ' ') *p = '0';
@@ -525,9 +525,9 @@ Int32 main ( Int32 argc, Char** argv )
exit(1);
}
bsWr = bsOpenWriteStream ( outFile );
- bsPutUChar ( bsWr, BZ_HDR_B );
- bsPutUChar ( bsWr, BZ_HDR_Z );
- bsPutUChar ( bsWr, BZ_HDR_h );
+ bsPutUChar ( bsWr, BZ_HDR_B );
+ bsPutUChar ( bsWr, BZ_HDR_Z );
+ bsPutUChar ( bsWr, BZ_HDR_h );
bsPutUChar ( bsWr, BZ_HDR_0 + 9 );
bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 );
bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 );
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c
index 785306827fb..3d405f9322a 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -86,7 +86,7 @@
#ifndef BZ_NO_STDIO
void BZ2_bz__AssertH__fail ( int errcode )
{
- fprintf(stderr,
+ fprintf(stderr,
"\n\nbzip2/libbzip2: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, %s.\n"
"Please report it to me at: jseward@bzip.org. If this happened\n"
@@ -191,8 +191,8 @@ Bool isempty_RL ( EState* s )
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit)
- ( bz_stream* strm,
+int BZ_API(BZ2_bzCompressInit)
+ ( bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor )
@@ -202,7 +202,7 @@ int BZ_API(BZ2_bzCompressInit)
if (!bz_config_ok()) return BZ_CONFIG_ERROR;
- if (strm == NULL ||
+ if (strm == NULL ||
blockSize100k < 1 || blockSize100k > 9 ||
workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR;
@@ -345,7 +345,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- no input? --*/
if (s->strm->avail_in == 0) break;
progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+ ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++;
s->strm->avail_in--;
s->strm->total_in_lo32++;
@@ -363,7 +363,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- flush/finish end? --*/
if (s->avail_in_expect == 0) break;
progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+ ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++;
s->strm->avail_in--;
s->strm->total_in_lo32++;
@@ -409,18 +409,18 @@ Bool handle_compress ( bz_stream* strm )
Bool progress_in = False;
Bool progress_out = False;
EState* s = strm->state;
-
+
while (True) {
if (s->state == BZ_S_OUTPUT) {
progress_out |= copy_output_until_stop ( s );
if (s->state_out_pos < s->numZ) break;
- if (s->mode == BZ_M_FINISHING &&
+ if (s->mode == BZ_M_FINISHING &&
s->avail_in_expect == 0 &&
isempty_RL(s)) break;
prepare_new_block ( s );
s->state = BZ_S_INPUT;
- if (s->mode == BZ_M_FLUSHING &&
+ if (s->mode == BZ_M_FLUSHING &&
s->avail_in_expect == 0 &&
isempty_RL(s)) break;
}
@@ -469,9 +469,9 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
if (action == BZ_RUN) {
progress = handle_compress ( strm );
return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
- }
+ }
else
- if (action == BZ_FLUSH) {
+ if (action == BZ_FLUSH) {
s->avail_in_expect = strm->avail_in;
s->mode = BZ_M_FLUSHING;
goto preswitch;
@@ -482,12 +482,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
s->mode = BZ_M_FINISHING;
goto preswitch;
}
- else
+ else
return BZ_PARAM_ERROR;
case BZ_M_FLUSHING:
if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
+ if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm );
if (s->avail_in_expect > 0 || !isempty_RL(s) ||
@@ -497,7 +497,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
case BZ_M_FINISHING:
if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
+ if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm );
if (!progress) return BZ_SEQUENCE_ERROR;
@@ -524,7 +524,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
if (s->ftab != NULL) BZFREE(s->ftab);
BZFREE(strm->state);
- strm->state = NULL;
+ strm->state = NULL;
return BZ_OK;
}
@@ -535,8 +535,8 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
/*---------------------------------------------------*/
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit)
- ( bz_stream* strm,
+int BZ_API(BZ2_bzDecompressInit)
+ ( bz_stream* strm,
int verbosity,
int small )
{
@@ -601,34 +601,34 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False;
-
+
/* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1)
return True;
-
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
}
@@ -665,7 +665,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
}
s_state_out_len_eq_one:
{
- if (cs_avail_out == 0) {
+ if (cs_avail_out == 0) {
c_state_out_len = 1; goto return_notr;
};
*( (UChar*)(cs_next_out) ) = c_state_out_ch;
@@ -673,7 +673,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
cs_next_out++;
cs_avail_out--;
}
- }
+ }
/* Only caused by corrupt data stream? */
if (c_nblock_used > s_save_nblockPP)
return True;
@@ -681,25 +681,25 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/* can a new run be started? */
if (c_nblock_used == s_save_nblockPP) {
c_state_out_len = 0; goto return_notr;
- };
+ };
c_state_out_ch = c_k0;
BZ_GET_FAST_C(k1); c_nblock_used++;
- if (k1 != c_k0) {
- c_k0 = k1; goto s_state_out_len_eq_one;
+ if (k1 != c_k0) {
+ c_k0 = k1; goto s_state_out_len_eq_one;
};
- if (c_nblock_used == s_save_nblockPP)
+ if (c_nblock_used == s_save_nblockPP)
goto s_state_out_len_eq_one;
-
+
c_state_out_len = 2;
BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; };
-
+
c_state_out_len = 3;
BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; };
-
+
BZ_GET_FAST_C(k1); c_nblock_used++;
c_state_out_len = ((Int32)k1) + 4;
BZ_GET_FAST_C(c_k0); c_nblock_used++;
@@ -767,37 +767,37 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
}
-
+
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False;
/* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1)
return True;
-
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
}
@@ -816,30 +816,30 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
}
-
+
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return False;
/* Only caused by corrupt data stream? */
if (s->nblock_used > s->save_nblock+1)
return True;
-
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
BZ_GET_SMALL(k1); s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
BZ_GET_SMALL(s->k0); s->nblock_used++;
@@ -868,14 +868,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
if (corrupt) return BZ_DATA_ERROR;
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
BZ_FINALISE_CRC ( s->calculatedBlockCRC );
- if (s->verbosity >= 3)
- VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
+ if (s->verbosity >= 3)
+ VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
s->calculatedBlockCRC );
if (s->verbosity >= 2) VPrintf0 ( "]" );
if (s->calculatedBlockCRC != s->storedBlockCRC)
return BZ_DATA_ERROR;
- s->calculatedCombinedCRC
- = (s->calculatedCombinedCRC << 1) |
+ s->calculatedCombinedCRC
+ = (s->calculatedCombinedCRC << 1) |
(s->calculatedCombinedCRC >> 31);
s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
s->state = BZ_X_BLKHDR_1;
@@ -887,7 +887,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
Int32 r = BZ2_decompress ( s );
if (r == BZ_STREAM_END) {
if (s->verbosity >= 3)
- VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x",
+ VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x",
s->storedCombinedCRC, s->calculatedCombinedCRC );
if (s->calculatedCombinedCRC != s->storedCombinedCRC)
return BZ_DATA_ERROR;
@@ -934,7 +934,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
if (bzf != NULL) bzf->lastErr = eee; \
}
-typedef
+typedef
struct {
FILE* handle;
Char buf[BZ_MAX_UNUSED];
@@ -958,10 +958,10 @@ static Bool myfeof ( FILE* f )
/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen)
- ( int* bzerror,
- FILE* f,
- int blockSize100k,
+BZFILE* BZ_API(BZ2_bzWriteOpen)
+ ( int* bzerror,
+ FILE* f,
+ int blockSize100k,
int verbosity,
int workFactor )
{
@@ -993,23 +993,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
bzf->strm.opaque = NULL;
if (workFactor == 0) workFactor = 30;
- ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
+ ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
verbosity, workFactor );
if (ret != BZ_OK)
{ BZ_SETERR(ret); free(bzf); return NULL; };
bzf->strm.avail_in = 0;
bzf->initialisedOk = True;
- return bzf;
+ return bzf;
}
/*---------------------------------------------------*/
void BZ_API(BZ2_bzWrite)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
+ ( int* bzerror,
+ BZFILE* b,
+ void* buf,
int len )
{
Int32 n, n2, ret;
@@ -1038,7 +1038,7 @@ void BZ_API(BZ2_bzWrite)
if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+ n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle );
if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; };
@@ -1052,20 +1052,20 @@ void BZ_API(BZ2_bzWrite)
/*---------------------------------------------------*/
void BZ_API(BZ2_bzWriteClose)
- ( int* bzerror,
- BZFILE* b,
+ ( int* bzerror,
+ BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out )
{
- BZ2_bzWriteClose64 ( bzerror, b, abandon,
+ BZ2_bzWriteClose64 ( bzerror, b, abandon,
nbytes_in, NULL, nbytes_out, NULL );
}
void BZ_API(BZ2_bzWriteClose64)
- ( int* bzerror,
- BZFILE* b,
+ ( int* bzerror,
+ BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
@@ -1097,7 +1097,7 @@ void BZ_API(BZ2_bzWriteClose64)
if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+ n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle );
if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; };
@@ -1129,9 +1129,9 @@ void BZ_API(BZ2_bzWriteClose64)
/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen)
- ( int* bzerror,
- FILE* f,
+BZFILE* BZ_API(BZ2_bzReadOpen)
+ ( int* bzerror,
+ FILE* f,
int verbosity,
int small,
void* unused,
@@ -1142,7 +1142,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
BZ_SETERR(BZ_OK);
- if (f == NULL ||
+ if (f == NULL ||
(small != 0 && small != 1) ||
(verbosity < 0 || verbosity > 4) ||
(unused == NULL && nUnused != 0) ||
@@ -1153,7 +1153,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
bzf = malloc ( sizeof(bzFile) );
- if (bzf == NULL)
+ if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
BZ_SETERR(BZ_OK);
@@ -1165,7 +1165,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
bzf->strm.bzalloc = NULL;
bzf->strm.bzfree = NULL;
bzf->strm.opaque = NULL;
-
+
while (nUnused > 0) {
bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
unused = ((void*)( 1 + ((UChar*)(unused)) ));
@@ -1180,7 +1180,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
bzf->strm.next_in = bzf->buf;
bzf->initialisedOk = True;
- return bzf;
+ return bzf;
}
@@ -1203,10 +1203,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
+int BZ_API(BZ2_bzRead)
+ ( int* bzerror,
+ BZFILE* b,
+ void* buf,
int len )
{
Int32 n, ret;
@@ -1228,11 +1228,11 @@ int BZ_API(BZ2_bzRead)
while (True) {
- if (ferror(bzf->handle))
+ if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; };
if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
- n = fread ( bzf->buf, sizeof(UChar),
+ n = fread ( bzf->buf, sizeof(UChar),
BZ_MAX_UNUSED, bzf->handle );
if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; };
@@ -1246,7 +1246,7 @@ int BZ_API(BZ2_bzRead)
if (ret != BZ_OK && ret != BZ_STREAM_END)
{ BZ_SETERR(ret); return 0; };
- if (ret == BZ_OK && myfeof(bzf->handle) &&
+ if (ret == BZ_OK && myfeof(bzf->handle) &&
bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
{ BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
@@ -1255,7 +1255,7 @@ int BZ_API(BZ2_bzRead)
return len - bzf->strm.avail_out; };
if (bzf->strm.avail_out == 0)
{ BZ_SETERR(BZ_OK); return len; };
-
+
}
return 0; /*not reached*/
@@ -1263,10 +1263,10 @@ int BZ_API(BZ2_bzRead)
/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused)
- ( int* bzerror,
- BZFILE* b,
- void** unused,
+void BZ_API(BZ2_bzReadGetUnused)
+ ( int* bzerror,
+ BZFILE* b,
+ void** unused,
int* nUnused )
{
bzFile* bzf = (bzFile*)b;
@@ -1289,30 +1289,30 @@ void BZ_API(BZ2_bzReadGetUnused)
/*---------------------------------------------------*/
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
- ( char* dest,
+int BZ_API(BZ2_bzBuffToBuffCompress)
+ ( char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
+ int blockSize100k,
+ int verbosity,
int workFactor )
{
bz_stream strm;
int ret;
- if (dest == NULL || destLen == NULL ||
+ if (dest == NULL || destLen == NULL ||
source == NULL ||
blockSize100k < 1 || blockSize100k > 9 ||
verbosity < 0 || verbosity > 4 ||
- workFactor < 0 || workFactor > 250)
+ workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR;
if (workFactor == 0) workFactor = 30;
strm.bzalloc = NULL;
strm.bzfree = NULL;
strm.opaque = NULL;
- ret = BZ2_bzCompressInit ( &strm, blockSize100k,
+ ret = BZ2_bzCompressInit ( &strm, blockSize100k,
verbosity, workFactor );
if (ret != BZ_OK) return ret;
@@ -1326,7 +1326,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
if (ret != BZ_STREAM_END) goto errhandler;
/* normal termination */
- *destLen -= strm.avail_out;
+ *destLen -= strm.avail_out;
BZ2_bzCompressEnd ( &strm );
return BZ_OK;
@@ -1341,10 +1341,10 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress)
- ( char* dest,
+int BZ_API(BZ2_bzBuffToBuffDecompress)
+ ( char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
int small,
int verbosity )
@@ -1352,10 +1352,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
bz_stream strm;
int ret;
- if (dest == NULL || destLen == NULL ||
+ if (dest == NULL || destLen == NULL ||
source == NULL ||
(small != 0 && small != 1) ||
- verbosity < 0 || verbosity > 4)
+ verbosity < 0 || verbosity > 4)
return BZ_PARAM_ERROR;
strm.bzalloc = NULL;
@@ -1385,11 +1385,11 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
} else {
BZ2_bzDecompressEnd ( &strm );
return BZ_OUTBUFF_FULL;
- };
+ };
errhandler:
BZ2_bzDecompressEnd ( &strm );
- return ret;
+ return ret;
}
@@ -1442,7 +1442,7 @@ BZFILE * bzopen_or_bzdopen
int verbosity = 0;
int workFactor = 30;
int smallMode = 0;
- int nUnused = 0;
+ int nUnused = 0;
if (mode == NULL) return NULL;
while (*mode) {
@@ -1482,7 +1482,7 @@ BZFILE * bzopen_or_bzdopen
if (writing) {
/* Guard against total chaos and anarchy -- JRS */
if (blockSize100k < 1) blockSize100k = 1;
- if (blockSize100k > 9) blockSize100k = 9;
+ if (blockSize100k > 9) blockSize100k = 9;
bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
verbosity,workFactor);
} else {
@@ -1561,7 +1561,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
{
int bzerr;
FILE *fp = ((bzFile *)b)->handle;
-
+
if (b==NULL) {return;}
if(((bzFile*)b)->writing){
BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
@@ -1579,7 +1579,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
/*---------------------------------------------------*/
/*--
- return last error code
+ return last error code
--*/
static char *bzerrorstrings[] = {
"OK"
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h
index 25b2d140eb2..323724394a2 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -85,7 +85,7 @@ extern "C" {
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
-typedef
+typedef
struct {
char *next_in;
unsigned int avail_in;
@@ -102,7 +102,7 @@ typedef
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
- }
+ }
bz_stream;
@@ -137,34 +137,34 @@ typedef
/*-- Core (low-level) library functions --*/
-BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
- bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor
+BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
+ bz_stream* strm,
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN int BZ_API(BZ2_bzCompress) (
- bz_stream* strm,
- int action
+BZ_EXTERN int BZ_API(BZ2_bzCompress) (
+ bz_stream* strm,
+ int action
);
-BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
- bz_stream* strm
+BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
+ bz_stream* strm
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
- bz_stream *strm,
- int verbosity,
+BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
+ bz_stream *strm,
+ int verbosity,
int small
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
- bz_stream* strm
+BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
+ bz_stream* strm
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
- bz_stream *strm
+BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
+ bz_stream *strm
);
@@ -176,64 +176,64 @@ BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
typedef void BZFILE;
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
- int* bzerror,
- FILE* f,
- int verbosity,
+BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
+ int* bzerror,
+ FILE* f,
+ int verbosity,
int small,
- void* unused,
- int nUnused
+ void* unused,
+ int nUnused
);
-BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
- int* bzerror,
- BZFILE* b
+BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
+ int* bzerror,
+ BZFILE* b
);
-BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
- int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused
+BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
+ int* bzerror,
+ BZFILE* b,
+ void** unused,
+ int* nUnused
);
-BZ_EXTERN int BZ_API(BZ2_bzRead) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
+BZ_EXTERN int BZ_API(BZ2_bzRead) (
+ int* bzerror,
+ BZFILE* b,
+ void* buf,
+ int len
);
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
- int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor
+BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
+ int* bzerror,
+ FILE* f,
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN void BZ_API(BZ2_bzWrite) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
+BZ_EXTERN void BZ_API(BZ2_bzWrite) (
+ int* bzerror,
+ BZFILE* b,
+ void* buf,
+ int len
);
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out
+BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
+ int* bzerror,
+ BZFILE* b,
+ int abandon,
+ unsigned int* nbytes_in,
+ unsigned int* nbytes_out
);
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
+BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
+ int* bzerror,
+ BZFILE* b,
+ int abandon,
+ unsigned int* nbytes_in_lo32,
+ unsigned int* nbytes_in_hi32,
+ unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
#endif
@@ -241,23 +241,23 @@ BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
/*-- Utility functions --*/
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
- char* dest,
+BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
+ char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
- char* dest,
+BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
+ char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int small,
- int verbosity
+ int small,
+ int verbosity
);
@@ -285,17 +285,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
-
+
BZ_EXTERN int BZ_API(BZ2_bzread) (
- BZFILE* b,
- void* buf,
- int len
+ BZFILE* b,
+ void* buf,
+ int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
- BZFILE* b,
- void* buf,
- int len
+ BZFILE* b,
+ void* buf,
+ int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
@@ -307,7 +307,7 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) (
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
- BZFILE *b,
+ BZFILE *b,
int *errnum
);
#endif
@@ -321,4 +321,3 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
/*-------------------------------------------------------------*/
/*--- end bzlib.h ---*/
/*-------------------------------------------------------------*/
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h
index 85b20c6e8a6..ca76fe62b3b 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -91,7 +91,7 @@ typedef unsigned short UInt16;
#ifndef __GNUC__
#define __inline__ /* */
-#endif
+#endif
#ifndef BZ_NO_STDIO
extern void BZ2_bz__AssertH__fail ( int errcode );
@@ -143,7 +143,7 @@ extern void bz_internal_error ( int errcode );
#define BZ_HDR_Z 0x5a /* 'Z' */
#define BZ_HDR_h 0x68 /* 'h' */
#define BZ_HDR_0 0x30 /* '0' */
-
+
/*-- Constants for the back end. --*/
#define BZ_MAX_ALPHA_SIZE 258
@@ -303,19 +303,19 @@ typedef
/*-- externs for compression. --*/
-extern void
+extern void
BZ2_blockSort ( EState* );
-extern void
+extern void
BZ2_compressBlock ( EState*, Bool );
-extern void
+extern void
BZ2_bsInitWrite ( EState* );
-extern void
+extern void
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-extern void
+extern void
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
@@ -459,7 +459,7 @@ typedef
Int32 save_N;
Int32 save_curr;
Int32 save_zt;
- Int32 save_zn;
+ Int32 save_zn;
Int32 save_zvec;
Int32 save_zj;
Int32 save_gSel;
@@ -509,13 +509,13 @@ typedef
/*-- externs for decompression. --*/
-extern Int32
+extern Int32
BZ2_indexIntoF ( Int32, Int32* );
-extern Int32
+extern Int32
BZ2_decompress ( DState* );
-extern void
+extern void
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
Int32, Int32, Int32 );
@@ -535,4 +535,3 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
/*-------------------------------------------------------------*/
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c
index c328ef137fd..156056fb376 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -66,7 +66,7 @@
0.9.0a/b -- no changes in this file.
0.9.0c
- * changed setting of nGroups in sendMTFValues() so as to
+ * changed setting of nGroups in sendMTFValues() so as to
do a bit better on small files
--*/
@@ -169,11 +169,11 @@ void generateMTFValues ( EState* s )
Int32 wr;
Int32 EOB;
- /*
+ /*
After sorting (eg, here),
s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
and
- ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
+ ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
holds the original block data.
The first thing to do is generate the MTF values,
@@ -188,7 +188,7 @@ void generateMTFValues ( EState* s )
(UChar*) (&((UChar*)s->arr2)[s->nblock])
These storage aliases are set up in bzCompressInit(),
- except for the last one, which is arranged in
+ except for the last one, which is arranged in
compressBlock().
*/
UInt32* ptr = s->ptr;
@@ -211,7 +211,7 @@ void generateMTFValues ( EState* s )
ll_i = s->unseqToSeq[block[j]];
AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
- if (yy[0] == ll_i) {
+ if (yy[0] == ll_i) {
zPend++;
} else {
@@ -219,11 +219,11 @@ void generateMTFValues ( EState* s )
zPend--;
while (True) {
if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
+ mtfv[wr] = BZ_RUNB; wr++;
+ s->mtfFreq[BZ_RUNB]++;
} else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
+ mtfv[wr] = BZ_RUNA; wr++;
+ s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
@@ -257,11 +257,11 @@ void generateMTFValues ( EState* s )
zPend--;
while (True) {
if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
+ mtfv[wr] = BZ_RUNB; wr++;
+ s->mtfFreq[BZ_RUNB]++;
} else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
+ mtfv[wr] = BZ_RUNA; wr++;
+ s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
@@ -304,7 +304,7 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3)
VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
- "%d+2 syms in use\n",
+ "%d+2 syms in use\n",
s->nblock, s->nMTF, s->nInUse );
alphaSize = s->nInUse+2;
@@ -321,7 +321,7 @@ void sendMTFValues ( EState* s )
nGroups = 6;
/*--- Generate an initial set of coding tables ---*/
- {
+ {
Int32 nPart, remF, tFreq, aFreq;
nPart = nGroups;
@@ -336,8 +336,8 @@ void sendMTFValues ( EState* s )
aFreq += s->mtfFreq[ge];
}
- if (ge > gs
- && nPart != nGroups && nPart != 1
+ if (ge > gs
+ && nPart != nGroups && nPart != 1
&& ((nGroups-nPart) % 2 == 1)) {
aFreq -= s->mtfFreq[ge];
ge--;
@@ -346,21 +346,21 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3)
VPrintf5( " initial group %d, [%d .. %d], "
"has %d syms (%4.1f%%)\n",
- nPart, gs, ge, aFreq,
+ nPart, gs, ge, aFreq,
(100.0 * (float)aFreq) / (float)(s->nMTF) );
-
+
for (v = 0; v < alphaSize; v++)
- if (v >= gs && v <= ge)
+ if (v >= gs && v <= ge)
s->len[nPart-1][v] = BZ_LESSER_ICOST; else
s->len[nPart-1][v] = BZ_GREATER_ICOST;
-
+
nPart--;
gs = ge+1;
remF -= aFreq;
}
}
- /*---
+ /*---
Iterate up to BZ_N_ITERS times to improve the tables.
---*/
for (iter = 0; iter < BZ_N_ITERS; iter++) {
@@ -373,14 +373,14 @@ void sendMTFValues ( EState* s )
/*---
Set up an auxiliary length table which is used to fast-track
- the common case (nGroups == 6).
+ the common case (nGroups == 6).
---*/
if (nGroups == 6) {
for (v = 0; v < alphaSize; v++) {
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
- }
+ }
}
nSelectors = 0;
@@ -390,10 +390,10 @@ void sendMTFValues ( EState* s )
/*--- Set group start & end marks. --*/
if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
+ ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
- /*--
+ /*--
Calculate the cost of this group as coded
by each of the coding tables.
--*/
@@ -429,7 +429,7 @@ void sendMTFValues ( EState* s )
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
} else {
- /*--- slow version which correctly handles all situations ---*/
+ /*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
UInt16 icv = mtfv[i];
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
@@ -448,7 +448,7 @@ void sendMTFValues ( EState* s )
s->selector[nSelectors] = bt;
nSelectors++;
- /*--
+ /*--
Increment the symbol frequencies for the selected table.
--*/
if (nGroups == 6 && 50 == ge-gs+1) {
@@ -470,7 +470,7 @@ void sendMTFValues ( EState* s )
# undef BZ_ITUR
} else {
- /*--- slow version which correctly handles all situations ---*/
+ /*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++)
s->rfreq[bt][ mtfv[i] ]++;
}
@@ -478,7 +478,7 @@ void sendMTFValues ( EState* s )
gs = ge+1;
}
if (s->verbosity >= 3) {
- VPrintf2 ( " pass %d: size is %d, grp uses are ",
+ VPrintf2 ( " pass %d: size is %d, grp uses are ",
iter+1, totc/8 );
for (t = 0; t < nGroups; t++)
VPrintf1 ( "%d ", fave[t] );
@@ -488,10 +488,10 @@ void sendMTFValues ( EState* s )
/*--
Recompute the tables based on the accumulated frequencies.
--*/
- /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
+ /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
comment in huffman.c for details. */
for (t = 0; t < nGroups; t++)
- BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
+ BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
alphaSize, 17 /*20*/ );
}
@@ -531,19 +531,19 @@ void sendMTFValues ( EState* s )
}
AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
AssertH ( !(minLen < 1), 3005 );
- BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
+ BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
minLen, maxLen, alphaSize );
}
/*--- Transmit the mapping table. ---*/
- {
+ {
Bool inUse16[16];
for (i = 0; i < 16; i++) {
inUse16[i] = False;
for (j = 0; j < 16; j++)
if (s->inUse[i * 16 + j]) inUse16[i] = True;
}
-
+
nBytes = s->numZ;
for (i = 0; i < 16; i++)
if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
@@ -554,7 +554,7 @@ void sendMTFValues ( EState* s )
if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
}
- if (s->verbosity >= 3)
+ if (s->verbosity >= 3)
VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
}
@@ -562,7 +562,7 @@ void sendMTFValues ( EState* s )
nBytes = s->numZ;
bsW ( s, 3, nGroups );
bsW ( s, 15, nSelectors );
- for (i = 0; i < nSelectors; i++) {
+ for (i = 0; i < nSelectors; i++) {
for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
bsW(s,1,0);
}
@@ -591,14 +591,14 @@ void sendMTFValues ( EState* s )
gs = 0;
while (True) {
if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
+ ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
AssertH ( s->selector[selCtr] < nGroups, 3006 );
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
UInt16 mtfv_i;
- UChar* s_len_sel_selCtr
+ UChar* s_len_sel_selCtr
= &(s->len[s->selector[selCtr]][0]);
Int32* s_code_sel_selCtr
= &(s->code[s->selector[selCtr]][0]);
@@ -623,7 +623,7 @@ void sendMTFValues ( EState* s )
# undef BZ_ITAH
} else {
- /*--- slow version which correctly handles all situations ---*/
+ /*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
bsW ( s,
s->len [s->selector[selCtr]] [mtfv[i]],
@@ -631,7 +631,6 @@ void sendMTFValues ( EState* s )
}
}
-
gs = ge+1;
selCtr++;
}
@@ -680,8 +679,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
/*-- Now the block's CRC, so it is in a known place. --*/
bsPutUInt32 ( s, s->blockCRC );
- /*--
- Now a single bit indicating (non-)randomisation.
+ /*--
+ Now a single bit indicating (non-)randomisation.
As of version 0.9.5, we use a better sorting algorithm
which makes randomisation unnecessary. So always set
the randomised bit to 'no'. Of course, the decoder
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c
index 7b394805429..b6dadfc62f2 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c
index 855b98bb631..81c3d2cc3f4 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -167,7 +167,7 @@ Int32 BZ2_decompress ( DState* s )
Int32 N;
Int32 curr;
Int32 zt;
- Int32 zn;
+ Int32 zn;
Int32 zvec;
Int32 zj;
Int32 gSel;
@@ -221,7 +221,7 @@ Int32 BZ2_decompress ( DState* s )
N = s->save_N;
curr = s->save_curr;
zt = s->save_zt;
- zn = s->save_zn;
+ zn = s->save_zn;
zvec = s->save_zvec;
zj = s->save_zj;
gSel = s->save_gSel;
@@ -244,14 +244,14 @@ Int32 BZ2_decompress ( DState* s )
if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
- if (s->blockSize100k < (BZ_HDR_0 + 1) ||
+ if (s->blockSize100k < (BZ_HDR_0 + 1) ||
s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
s->blockSize100k -= BZ_HDR_0;
if (s->smallDecompress) {
s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = BZALLOC(
- ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
+ s->ll4 = BZALLOC(
+ ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
);
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else {
@@ -277,7 +277,7 @@ Int32 BZ2_decompress ( DState* s )
s->currBlockNo++;
if (s->verbosity >= 2)
VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
-
+
s->storedBlockCRC = 0;
GET_UCHAR(BZ_X_BCRC_1, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
@@ -300,14 +300,14 @@ Int32 BZ2_decompress ( DState* s )
if (s->origPtr < 0)
RETURN(BZ_DATA_ERROR);
- if (s->origPtr > 10 + 100000*s->blockSize100k)
+ if (s->origPtr > 10 + 100000*s->blockSize100k)
RETURN(BZ_DATA_ERROR);
/*--- Receive the mapping table ---*/
for (i = 0; i < 16; i++) {
GET_BIT(BZ_X_MAPPING_1, uc);
- if (uc == 1)
- s->inUse16[i] = True; else
+ if (uc == 1)
+ s->inUse16[i] = True; else
s->inUse16[i] = False;
}
@@ -343,7 +343,7 @@ Int32 BZ2_decompress ( DState* s )
{
UChar pos[BZ_N_GROUPS], tmp, v;
for (v = 0; v < nGroups; v++) pos[v] = v;
-
+
for (i = 0; i < nSelectors; i++) {
v = s->selectorMtf[i];
tmp = pos[v];
@@ -376,10 +376,10 @@ Int32 BZ2_decompress ( DState* s )
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i];
}
- BZ2_hbCreateDecodeTables (
- &(s->limit[t][0]),
- &(s->base[t][0]),
- &(s->perm[t][0]),
+ BZ2_hbCreateDecodeTables (
+ &(s->limit[t][0]),
+ &(s->base[t][0]),
+ &(s->perm[t][0]),
&(s->len[t][0]),
minLen, maxLen, alphaSize
);
@@ -471,23 +471,23 @@ Int32 BZ2_decompress ( DState* s )
s->mtfa[(z)-3] = s->mtfa[(z)-4];
nn -= 4;
}
- while (nn > 0) {
- s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
+ while (nn > 0) {
+ s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
};
s->mtfa[pp] = uc;
- } else {
+ } else {
/* general case */
lno = nn / MTFL_SIZE;
off = nn % MTFL_SIZE;
pp = s->mtfbase[lno] + off;
uc = s->mtfa[pp];
- while (pp > s->mtfbase[lno]) {
- s->mtfa[pp] = s->mtfa[pp-1]; pp--;
+ while (pp > s->mtfbase[lno]) {
+ s->mtfa[pp] = s->mtfa[pp-1]; pp--;
};
s->mtfbase[lno]++;
while (lno > 0) {
s->mtfbase[lno]--;
- s->mtfa[s->mtfbase[lno]]
+ s->mtfa[s->mtfbase[lno]]
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
lno--;
}
@@ -569,7 +569,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_SMALL(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+ BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_SMALL(s->k0); s->nblock_used++;
}
@@ -588,7 +588,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_FAST(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+ BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_FAST(s->k0); s->nblock_used++;
}
@@ -657,7 +657,7 @@ Int32 BZ2_decompress ( DState* s )
s->save_gBase = gBase;
s->save_gPerm = gPerm;
- return retVal;
+ return retVal;
}
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c
index 2049906ea53..eb86bb61a59 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c
@@ -19,7 +19,7 @@
#ifdef _WIN32
-#define BZ2_LIBNAME "libbz2-1.0.2.DLL"
+#define BZ2_LIBNAME "libbz2-1.0.2.DLL"
#include <windows.h>
static int BZ2DLLLoaded = 0;
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c b/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c
index 871eed4f23e..5bf190be9a1 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -100,7 +100,7 @@
/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len,
+void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 *freq,
Int32 alphaSize,
Int32 maxLen )
@@ -114,7 +114,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
- Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
+ Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
@@ -136,7 +136,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
}
AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-
+
while (nHeap > 1) {
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
@@ -159,7 +159,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
len[i-1] = j;
if (j > maxLen) tooLong = True;
}
-
+
if (! tooLong) break;
/* 17 Oct 04: keep-going condition for the following loop used
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c
index b8e74070f82..940462d693d 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -63,58 +63,58 @@
/*---------------------------------------------*/
-Int32 BZ2_rNums[512] = {
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+Int32 BZ2_rNums[512] = {
+ 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+ 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+ 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+ 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+ 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+ 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+ 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+ 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+ 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+ 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+ 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+ 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+ 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+ 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+ 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+ 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+ 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+ 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+ 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+ 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+ 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+ 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+ 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+ 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+ 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+ 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+ 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+ 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+ 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+ 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+ 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+ 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+ 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+ 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+ 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+ 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+ 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+ 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+ 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+ 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+ 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+ 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+ 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+ 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+ 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+ 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+ 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+ 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+ 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+ 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+ 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c b/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c
index 6caca9baa94..7934e765818 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c
@@ -4,7 +4,7 @@
support for large files (> 2GB) in a reasonable amount of time.
I suggest you use the undocumented --exponential option to
bzip2 when compressing the resulting file; this saves a bit of
- time. Note: *don't* bother with --exponential when compressing
+ time. Note: *don't* bother with --exponential when compressing
Real Files; it'll just waste a lot of CPU time :-)
(but is otherwise harmless).
*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c b/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c
index 623aacc9f3f..f0f17fcca53 100644
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c
+++ b/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c
@@ -1,11 +1,11 @@
/* A test program written to test robustness to decompression of
- corrupted data. Usage is
+ corrupted data. Usage is
unzcrash filename
and the program will read the specified file, compress it (in memory),
and then repeatedly decompress it, each time with a different bit of
the compressed data inverted, so as to test all possible one-bit errors.
- This should not cause any invalid memory accesses. If it does,
+ This should not cause any invalid memory accesses. If it does,
I want to know about it!
p.s. As you can see from the above description, the process is
@@ -100,9 +100,9 @@ int main ( int argc, char** argv )
return 1;
} else {
for (i = 0; i < nOut; i++)
- if (inbuf[i] != outbuf[i]) {
- fprintf(stderr, "mismatch at %d\n", i );
- return 1;
+ if (inbuf[i] != outbuf[i]) {
+ fprintf(stderr, "mismatch at %d\n", i );
+ return 1;
}
if (i == nOut) fprintf(stderr, "really ok!\n" );
}
diff --git a/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp b/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp
index d4410dc9beb..612fcb08386 100644
--- a/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/huffman/huff.cpp
@@ -14,10 +14,10 @@
/* 19.11.03 1.01 Dan Big endian handling */
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/*****************************************************************************/
-
+
#include <assert.h>
#include <string.h>
-
+
#include "huff.h"
// Special for Mac - we have to know if normal pointer greater or less
@@ -29,10 +29,10 @@ static long mul = 1;
#define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0)
#define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0)
-
+
//-----------------------------------------------------------------------------
// Methods of the THTreeItem struct
-
+
// 1501DB70
THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast)
{
@@ -40,83 +40,83 @@ THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast)
pLast = this + 1;
return pLast;
}
-
+
// Gets previous Huffman tree item (?)
THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value)
{
if(PTR_INVALID(prev))
return PTR_NOT(prev);
-
+
if(value == -1 || PTR_INVALID(value))
value = (long)(this - next->prev);
return prev + value;
-
+
// OLD VERSION
// if(PTR_INT(value) < 0)
// value = PTR_INT((item - item->next->prev));
// return (THTreeItem *)((char *)prev + value);
}
-
+
// 1500F5E0
void THTreeItem::ClearItemLinks()
{
next = prev = NULL;
}
-
+
// 1500BC90
void THTreeItem::RemoveItem()
{
THTreeItem * pTemp; // EDX
-
+
if(next != NULL)
{
pTemp = prev;
-
+
if(PTR_INVALID_OR_NULL(pTemp))
pTemp = PTR_NOT(pTemp);
else
pTemp += (this - next->prev);
-
+
pTemp->next = next;
next->prev = prev;
next = prev = NULL;
}
}
-
+
/*
// OLD VERSION : Removes item from the tree (?)
static void RemoveItem(THTreeItem * item)
{
THTreeItem * next = item->next; // ESI
THTreeItem * prev = item->prev; // EDX
-
+
if(next == NULL)
return;
-
+
if(PTR_INT(prev) < 0)
prev = PTR_NOT(prev);
else
// ??? usually item == next->prev, so what is it ?
prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev)));
-
+
// Remove HTree item from the chain
prev->next = next; // Sets the 'first' pointer
next->prev = item->prev;
-
+
// Invalidate pointers
item->next = NULL;
item->prev = NULL;
}
*/
-
+
//-----------------------------------------------------------------------------
// TOutputStream functions
-
+
void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits)
{
dwBitBuff |= (dwBuff << nBits);
nBits += nPutBits;
-
+
// Flush completed bytes
while(nBits >= 8)
{
@@ -125,20 +125,20 @@ void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits)
*pbOutPos++ = (unsigned char)dwBitBuff;
dwOutSize--;
}
-
+
dwBitBuff >>= 8;
nBits -= 8;
}
}
-
+
//-----------------------------------------------------------------------------
// TInputStream functions
-
+
// Gets one bit from input stream
unsigned long TInputStream::GetBit()
{
unsigned long dwBit = (dwBitBuff & 1);
-
+
dwBitBuff >>= 1;
if(--nBits == 0)
{
@@ -147,8 +147,8 @@ unsigned long TInputStream::GetBit()
nBits = 32;
}
return dwBit;
-}
-
+}
+
// Gets 7 bits from the stream
unsigned long TInputStream::Get7Bits()
{
@@ -158,32 +158,32 @@ unsigned long TInputStream::Get7Bits()
pbInBuffer += sizeof(unsigned short);
nBits += 16;
}
-
+
// Get 7 bits from input stream
return (dwBitBuff & 0x7F);
}
-
+
// Gets the whole byte from the input stream.
unsigned long TInputStream::Get8Bits()
{
unsigned long dwOneByte;
-
+
if(nBits <= 8)
{
dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits;
pbInBuffer += sizeof(unsigned short);
nBits += 16;
}
-
+
dwOneByte = (dwBitBuff & 0xFF);
dwBitBuff >>= 8;
nBits -= 8;
return dwOneByte;
}
-
+
//-----------------------------------------------------------------------------
// Functions for huffmann tree items
-
+
// Inserts item into the tree (?)
static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2)
{
@@ -191,7 +191,7 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w
THTreeItem * prev = item->prev; // ESI - prev to the first item
THTreeItem * prev2; // Pointer to previous item
LONG_PTR next2; // Pointer to the next item
-
+
// The same code like in RemoveItem(item);
if(next != 0) // If the first item already has next one
{
@@ -199,20 +199,20 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w
prev = PTR_NOT(prev);
else
prev += (item - next->prev);
-
+
// 150083C1
// Remove the item from the tree
prev->next = next;
next->prev = prev;
-
+
// Invalidate 'prev' and 'next' pointer
item->next = 0;
item->prev = 0;
}
-
+
if(item2 == NULL) // EDX - If the second item is not entered,
item2 = PTR_PTR(&itemPtr[1]); // take the first tree item
-
+
switch(where)
{
case SWITCH_ITEMS : // Switch the two items
@@ -221,68 +221,68 @@ static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long w
item2->next->prev = item;
item2->next = item; // Set the first item
return;
-
+
case INSERT_ITEM: // Insert as the last item
item->next = item2; // Set next item (or pointer to pointer to first item)
item->prev = item2->prev; // Set prev item (or last item in the tree)
-
+
next2 = PTR_INT(itemPtr[0]);// Usually NULL
prev2 = item2->prev; // Prev item to the second (or last tree item)
-
+
if(PTR_INVALID(prev2))
{
prev2 = PTR_NOT(prev);
-
+
prev2->next = item;
item2->prev = item; // Next after last item
return;
}
-
+
if(PTR_INVALID(next2))
next2 = (long)(item2 - item2->next->prev);
// next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev));
-
+
// prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ???
prev2 += next2;
prev2->next = item;
item2->prev = item; // Set the next/last item
return;
-
+
default:
return;
}
}
-
+
//-----------------------------------------------------------------------------
// THuffmannTree class functions
-
+
THuffmannTree::THuffmannTree()
{
// We have to check if the "this" pointer is less than zero
if((LONG_PTR)this < 0)
mul = -1;
}
-
+
void THuffmannTree::InitTree(bool bCompression)
{
THTreeItem * pItem;
unsigned int nCount;
-
+
// Clear links for all the items in the tree
for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--)
pItem->ClearItemLinks();
-
+
pItem3050 = NULL;
pItem3054 = PTR_PTR(&pItem3054);
pItem3058 = PTR_NOT(pItem3054);
-
+
pItem305C = NULL;
pFirst = PTR_PTR(&pFirst);
pLast = PTR_NOT(pFirst);
-
+
offs0004 = 1;
nItems = 0;
-
+
// Clear all TQDecompress items. Do this only if preparing for decompression
if(bCompression == false)
{
@@ -290,7 +290,7 @@ void THuffmannTree::InitTree(bool bCompression)
qd3474[nCount].offs00 = 0;
}
}
-
+
// Builds Huffman tree. Called with the first 8 bits loaded from input stream
void THuffmannTree::BuildTree(unsigned int nCmpType)
{
@@ -299,55 +299,55 @@ void THuffmannTree::BuildTree(unsigned int nCmpType)
unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630
THTreeItem * child1;
unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i
-
+
// Loop while pointer has a valid value
while(PTR_VALID(pLast)) // ESI - Last entry
{
THTreeItem * temp; // EAX
-
+
if(pLast->next != NULL) // ESI->next
pLast->RemoveItem();
// EDI = &offs3054
pItem3058 = PTR_PTR(&pItem3054);// [EDI+4]
pLast->prev = pItem3058; // EAX
-
+
temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050));
-
+
temp->next = pLast;
pItem3054 = pLast;
}
-
+
// Clear all pointers in HTree item array
memset(items306C, 0, sizeof(items306C));
-
+
maxByte = 0; // Greatest character found init to zero.
itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array
-
+
// Ensure we have low 8 bits only
nCmpType &= 0xFF;
byteArray = Table1502A630 + nCmpType * 258; // EDI also
-
+
for(i = 0; i < 0x100; i++, itemPtr++)
{
THTreeItem * item = pItem3058; // Item to be created
THTreeItem * pItem3 = pItem3058;
unsigned char oneByte = byteArray[i];
-
+
// Skip all the bytes which are zero.
if(byteArray[i] == 0)
continue;
-
+
// If not valid pointer, take the first available item in the array
if(PTR_INVALID_OR_NULL(item))
item = &items0008[nItems++];
-
+
// Insert this item as the top of the tree
InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL);
-
+
item->parent = NULL; // Invalidate child and parent
item->child = NULL;
*itemPtr = item; // Store pointer into pointer array
-
+
item->dcmpByte = i; // Store counter
item->byteValue = oneByte; // Store byte value
if(oneByte >= maxByte)
@@ -355,7 +355,7 @@ void THuffmannTree::BuildTree(unsigned int nCmpType)
maxByte = oneByte;
continue;
}
-
+
// Find the first item which has byte value greater than current one byte
if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item
{
@@ -372,35 +372,35 @@ void THuffmannTree::BuildTree(unsigned int nCmpType)
}
}
pItem3 = NULL;
-
+
// 15006B09
_15006B09:
if(item->next != NULL)
item->RemoveItem();
-
+
// 15006B15
if(pItem3 == NULL)
pItem3 = PTR_PTR(&pFirst);
-
+
// 15006B1F
item->next = pItem3->next;
item->prev = pItem3->next->prev;
pItem3->next->prev = item;
pItem3->next = item;
}
-
+
// 15006B4A
for(; i < 0x102; i++)
{
THTreeItem ** itemPtr = &items306C[i]; // EDI
-
+
// 15006B59
THTreeItem * item = pItem3058; // ESI
if(PTR_INVALID_OR_NULL(item))
item = &items0008[nItems++];
-
+
InsertItem(&pItem305C, item, INSERT_ITEM, NULL);
-
+
// 15006B89
item->dcmpByte = i;
item->byteValue = 1;
@@ -408,42 +408,42 @@ void THuffmannTree::BuildTree(unsigned int nCmpType)
item->child = NULL;
*itemPtr++ = item;
}
-
+
// 15006BAA
if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item
{
THTreeItem * child2; // EBP
THTreeItem * item; // ESI
-
+
// 15006BB8
while(PTR_VALID(child2 = child1->prev))
{
if(PTR_INVALID_OR_NULL(item = pItem3058))
item = &items0008[nItems++];
-
+
// 15006BE3
InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL);
-
+
// 15006BF3
item->parent = NULL;
item->child = NULL;
-
+
//EDX = child2->byteValue + child1->byteValue;
//EAX = child1->byteValue;
//ECX = maxByte; // The greatest character (0xFF usually)
-
+
item->byteValue = child1->byteValue + child2->byteValue; // 0x02
item->child = child1; // Prev item in the
child1->parent = item;
child2->parent = item;
-
+
// EAX = item->byteValue;
if(item->byteValue >= maxByte)
maxByte = item->byteValue;
else
{
THTreeItem * pItem2 = child2->prev; // EDI
-
+
// 15006C2D
while(PTR_VALID(pItem2))
{
@@ -452,22 +452,22 @@ void THuffmannTree::BuildTree(unsigned int nCmpType)
pItem2 = pItem2->prev;
}
pItem2 = NULL;
-
+
_15006C3B:
if(item->next != 0)
{
THTreeItem * temp4 = item->GetPrevItem(-1);
-
+
temp4->next = item->next; // The first item changed
item->next->prev = item->prev; // First->prev changed to negative value
item->next = NULL;
item->prev = NULL;
}
-
+
// 15006C62
if(pItem2 == NULL)
pItem2 = PTR_PTR(&pFirst);
-
+
item->next = pItem2->next; // Set item with 0x100 byte value
item->prev = pItem2->next->prev; // Set item with 0x17 byte value
pItem2->next->prev = item; // Changed prev of item with
@@ -489,48 +489,48 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex)
THTreeItem * pItem1 = pItem3058; // ESI
THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX
THTreeItem * temp; // EAX
-
+
// Prepare the first item to insert to the tree
if(PTR_INT(pItem1) <= 0)
pItem1 = &items0008[nItems++];
-
+
// If item has any next item, remove it from the chain
if(pItem1->next != NULL)
{
THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX
-
+
temp->next = pItem1->next;
pItem1->next->prev = pItem1->prev;
pItem1->next = NULL;
pItem1->prev = NULL;
}
-
+
pItem1->next = PTR_PTR(&pFirst);
pItem1->prev = pLast;
temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C));
-
+
// 150068E9
temp->next = pItem1;
pLast = pItem1;
-
+
pItem1->parent = NULL;
pItem1->child = NULL;
-
+
// 150068F6
pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index
pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value
pItem1->parent = pSaveLast; // Set parent to last item
items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array
-
+
// Prepare the second item to insert into the tree
if(PTR_INT((pItem1 = pItem3058)) <= 0)
pItem1 = &items0008[nItems++];
-
+
// 1500692E
if(pItem1->next != NULL)
{
temp = pItem1->GetPrevItem(-1); // EAX
-
+
temp->next = pItem1->next;
pItem1->next->prev = pItem1->prev;
pItem1->next = NULL;
@@ -540,11 +540,11 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex)
pItem1->next = PTR_PTR(&pFirst);
pItem1->prev = pLast;
temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C));
-
+
// 15006968
temp->next = pItem1;
pLast = pItem1;
-
+
// 1500696E
pItem1->child = NULL;
pItem1->dcmpByte = dwIndex;
@@ -552,45 +552,45 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex)
pItem1->parent = pSaveLast;
pSaveLast->child = pItem1;
items306C[dwIndex] = pItem1;
-
+
do
{
THTreeItem * pItem2 = pItem1;
THTreeItem * pItem3;
unsigned long byteValue;
-
+
// 15006993
byteValue = ++pItem1->byteValue;
-
+
// Pass through all previous which have its value greater than byteValue
while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX
{
if(pItem3->byteValue >= byteValue)
goto _150069AE;
-
+
pItem2 = pItem2->prev;
}
// 150069AC
pItem3 = NULL;
-
+
_150069AE:
if(pItem2 == pItem1)
continue;
-
+
// 150069B2
// Switch pItem2 with item
InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1);
InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3);
-
+
// 150069D0
// Switch parents of pItem1 and pItem2
temp = pItem2->parent->child;
if(pItem1 == pItem1->parent->child)
pItem1->parent->child = pItem2;
-
+
if(pItem2 == temp)
pItem2->parent->child = pItem1;
-
+
// 150069ED
// Switch parents of pItem1 and pItem3
temp = pItem1->parent;
@@ -600,7 +600,7 @@ void THuffmannTree::ModifyTree(unsigned long dwIndex)
}
while(PTR_INT((pItem1 = pItem1->parent)) > 0);
}
-
+
void THuffmannTree::UninitTree()
{
while(PTR_INT(pLast) > 0)
@@ -608,11 +608,11 @@ void THuffmannTree::UninitTree()
pItem = pItem305C->Call1501DB70(pLast);
pItem->RemoveItem();
}
-
+
for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058)
pItem->RemoveItem();
PTR_PTR(&pItem3054)->RemoveItem();
-
+
for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--)
{
pItem--;
@@ -621,7 +621,7 @@ void THuffmannTree::UninitTree()
}
}
*/
-
+
THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
{
THTreeItem * pItem1 = pItem3058; // EDX
@@ -629,7 +629,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
THTreeItem * pNext;
THTreeItem * pPrev;
THTreeItem ** ppItem;
-
+
if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL)
{
if((pItem2 = &items0008[nItems++]) != NULL)
@@ -639,7 +639,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
}
else
pItem1 = pItem2;
-
+
pNext = pItem1->next;
if(pNext != NULL)
{
@@ -648,23 +648,23 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
pPrev = PTR_NOT(pPrev);
else
pPrev += (pItem1 - pItem1->next->prev);
-
+
pPrev->next = pNext;
pNext->prev = pPrev;
pItem1->next = NULL;
pItem1->prev = NULL;
}
-
+
ppItem = &pFirst; // esi
if(nValue > 1)
{
// ecx = pFirst->next;
pItem1->next = *ppItem;
pItem1->prev = (*ppItem)->prev;
-
+
(*ppItem)->prev = pItem2;
*ppItem = pItem1;
-
+
pItem2->parent = NULL;
pItem2->child = NULL;
}
@@ -679,7 +679,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
pPrev = PTR_NOT(pPrev);
pPrev->next = pItem1;
pPrev->prev = pItem2;
-
+
pItem2->parent = NULL;
pItem2->child = NULL;
}
@@ -689,7 +689,7 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
pPrev += (THTreeItem *)ppItem - (*ppItem)->prev;
else
pPrev += PTR_INT(pItem305C);
-
+
pPrev->next = pItem1;
ppItem[1] = pItem2;
pItem2->parent = NULL;
@@ -698,18 +698,18 @@ THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue)
}
return pItem2;
}
-
+
void THuffmannTree::Call1500E820(THTreeItem * pItem)
{
THTreeItem * pItem1; // edi
THTreeItem * pItem2 = NULL; // eax
THTreeItem * pItem3; // edx
THTreeItem * pPrev; // ebx
-
+
for(; pItem != NULL; pItem = pItem->parent)
{
pItem->byteValue++;
-
+
for(pItem1 = pItem; ; pItem1 = pPrev)
{
pPrev = pItem1->prev;
@@ -718,14 +718,14 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem)
pPrev = NULL;
break;
}
-
+
if(pPrev->byteValue >= pItem->byteValue)
break;
}
-
+
if(pItem1 == pItem)
continue;
-
+
if(pItem1->next != NULL)
{
pItem2 = pItem1->GetPrevItem(-1);
@@ -734,7 +734,7 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem)
pItem1->next = NULL;
pItem1->prev = NULL;
}
-
+
pItem2 = pItem->next;
pItem1->next = pItem2;
pItem1->prev = pItem2->prev;
@@ -748,30 +748,30 @@ void THuffmannTree::Call1500E820(THTreeItem * pItem)
pItem->next = NULL;
pItem->prev = NULL;
}
-
+
if(pPrev == NULL)
pPrev = PTR_PTR(&pFirst);
-
+
pItem2 = pPrev->next;
pItem->next = pItem2;
pItem->prev = pItem2->prev;
pItem2->prev = pItem;
pPrev->next = pItem;
-
+
pItem3 = pItem1->parent->child;
pItem2 = pItem->parent;
if(pItem2->child == pItem)
pItem2->child = pItem1;
if(pItem3 == pItem1)
pItem1->parent->child = pItem;
-
+
pItem2 = pItem->parent;
pItem->parent = pItem1->parent;
pItem1->parent = pItem2;
offs0004++;
}
}
-
+
// 1500E920
unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType)
{
@@ -782,14 +782,14 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
unsigned long dwBitBuff;
unsigned int nBits;
unsigned int nBit;
-
+
BuildTree(nCmpType);
bIsCmp0 = (nCmpType == 0);
-
+
// Store the compression type into output buffer
os->dwBitBuff |= (nCmpType << os->nBits);
os->nBits += 8;
-
+
// Flush completed bytes
while(os->nBits >= 8)
{
@@ -798,22 +798,22 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
*os->pbOutPos++ = (unsigned char)os->dwBitBuff;
os->dwOutSize--;
}
-
+
os->dwBitBuff >>= 8;
os->nBits -= 8;
}
-
+
for(; nInLength != 0; nInLength--)
{
unsigned char bOneByte = *pbInBuffer++;
-
+
if((pItem1 = items306C[bOneByte]) == NULL)
{
pItem2 = items306C[0x101]; // ecx
pItem3 = pItem2->parent; // eax
dwBitBuff = 0;
nBits = 0;
-
+
for(; pItem3 != NULL; pItem3 = pItem3->parent)
{
nBit = (pItem3->child != pItem2) ? 1 : 0;
@@ -822,11 +822,11 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
pItem2 = pItem3;
}
os->PutBits(dwBitBuff, nBits);
-
+
// Store the loaded byte into output stream
os->dwBitBuff |= (bOneByte << os->nBits);
os->nBits += 8;
-
+
// Flush the whole byte(s)
while(os->nBits >= 8)
{
@@ -838,34 +838,34 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
os->dwBitBuff >>= 8;
os->nBits -= 8;
}
-
+
pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast;
pItem2 = Call1500E740(1);
pItem2->dcmpByte = pItem1->dcmpByte;
pItem2->byteValue = pItem1->byteValue;
pItem2->parent = pItem1;
items306C[pItem2->dcmpByte] = pItem2;
-
+
pItem2 = Call1500E740(1);
pItem2->dcmpByte = bOneByte;
pItem2->byteValue = 0;
pItem2->parent = pItem1;
items306C[pItem2->dcmpByte] = pItem2;
pItem1->child = pItem2;
-
+
Call1500E820(pItem2);
-
+
if(bIsCmp0 != 0)
{
Call1500E820(items306C[bOneByte]);
continue;
}
-
+
for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent)
{
pItem1->byteValue++;
pItem2 = pItem1;
-
+
for(;;)
{
pItem3 = pItem2->prev;
@@ -878,19 +878,19 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
break;
pItem2 = pItem3;
}
-
+
if(pItem2 != pItem1)
{
InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1);
InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3);
-
+
pItem3 = pItem2->parent->child;
if(pItem1->parent->child == pItem1)
pItem1->parent->child = pItem2;
-
+
if(pItem3 == pItem2)
pItem2->parent->child = pItem1;
-
+
pTemp = pItem1->parent;
pItem1->parent = pItem2->parent;
pItem2->parent = pTemp;
@@ -912,13 +912,13 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
}
os->PutBits(dwBitBuff, nBits);
}
-
+
// 1500EB98
if(bIsCmp0 != 0)
Call1500E820(items306C[bOneByte]); // 1500EB9D
// 1500EBAF
} // for(; nInLength != 0; nInLength--)
-
+
// 1500EBB8
pItem1 = items306C[0x100];
dwBitBuff = 0;
@@ -930,10 +930,10 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
nBits++;
pItem1 = pItem2;
}
-
+
// 1500EBE6
os->PutBits(dwBitBuff, nBits);
-
+
// 1500EBEF
// Flush the remaining bits
while(os->nBits != 0)
@@ -946,10 +946,10 @@ unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pb
os->dwBitBuff >>= 8;
os->nBits -= ((os->nBits > 8) ? 8 : os->nBits);
}
-
+
return (unsigned int)(os->pbOutPos - os->pbOutBuffer);
}
-
+
// Decompression using Huffman tree (1500E450)
unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is)
{
@@ -962,29 +962,29 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
unsigned int n8Bits; // 8 bits loaded from input stream
unsigned int n7Bits; // 7 bits loaded from input stream
bool bHasQdEntry;
-
+
// Test the output length. Must not be NULL.
if(dwOutLength == 0)
return 0;
-
+
// Get the compression type from the input stream
n8Bits = is->Get8Bits();
-
+
// Build the Huffman tree
- BuildTree(n8Bits);
+ BuildTree(n8Bits);
bIsCmp0 = (n8Bits == 0) ? 1 : 0;
-
+
for(;;)
{
n7Bits = is->Get7Bits(); // Get 7 bits from input stream
-
+
// Try to use quick decompression. Check TQDecompress array for corresponding item.
// If found, ise the result byte instead.
qd = &qd3474[n7Bits];
-
+
// If there is a quick-pass possible (ebx)
bHasQdEntry = (qd->offs00 >= offs0004) ? true : false;
-
+
// If we can use quick decompress, use it.
if(bHasQdEntry)
{
@@ -1004,21 +1004,21 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
pItem1 = pFirst->next->prev;
if(PTR_INVALID_OR_NULL(pItem1))
pItem1 = NULL;
-_1500E549:
+_1500E549:
nBitCount = 0;
pItem2 = NULL;
-
+
do
{
pItem1 = pItem1->child; // Move down by one level
if(is->GetBit()) // If current bit is set, move to previous
pItem1 = pItem1->prev;
-
+
if(++nBitCount == 7) // If we are at 7th bit, save current HTree item.
pItem2 = pItem1;
}
while(pItem1->child != NULL); // Walk until tree has no deeper level
-
+
if(bHasQdEntry == false)
{
if(nBitCount > 7)
@@ -1031,7 +1031,7 @@ _1500E549:
{
unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount));
unsigned long nAdd = (1 << nBitCount);
-
+
for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd)
{
qd->offs00 = offs0004;
@@ -1042,46 +1042,46 @@ _1500E549:
}
nDcmpByte = pItem1->dcmpByte;
}
-
+
if(nDcmpByte == 0x101) // Huffman tree needs to be modified
{
n8Bits = is->Get8Bits();
pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast;
-
+
pItem2 = Call1500E740(1);
pItem2->parent = pItem1;
pItem2->dcmpByte = pItem1->dcmpByte;
pItem2->byteValue = pItem1->byteValue;
items306C[pItem2->dcmpByte] = pItem2;
-
+
pItem2 = Call1500E740(1);
pItem2->parent = pItem1;
pItem2->dcmpByte = n8Bits;
pItem2->byteValue = 0;
items306C[pItem2->dcmpByte] = pItem2;
-
+
pItem1->child = pItem2;
Call1500E820(pItem2);
if(bIsCmp0 == 0)
Call1500E820(items306C[n8Bits]);
-
+
nDcmpByte = n8Bits;
}
-
+
if(nDcmpByte == 0x100)
break;
-
+
*pbOutPos++ = (unsigned char)nDcmpByte;
if(--dwOutLength == 0)
break;
-
+
if(bIsCmp0)
Call1500E820(items306C[nDcmpByte]);
}
-
+
return (unsigned int)(pbOutPos - pbOutBuffer);
}
-
+
/* OLD VERSION
unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is)
{
@@ -1094,38 +1094,38 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
THTreeItem * temp; // For every use
unsigned long dcmpByte = 0; // Decompressed byte value
bool bFlag = 0;
-
+
// Test the output length. Must not be NULL.
if(dwOutLength == 0)
return 0;
-
+
// If too few bits in input bit buffer, we have to load next 16 bits
is->EnsureHasMoreThan8Bits();
-
+
// Get 8 bits from input stream
oneByte = is->Get8Bits();
-
+
// Build the Huffman tree
- BuildTree(oneByte);
-
+ BuildTree(oneByte);
+
bIsCmp0 = (oneByte == 0) ? 1 : 0;
outPtr = pbOutBuffer; // Copy pointer to output data
-
+
for(;;)
{
TQDecompress * qd; // For quick decompress
unsigned long sevenBits = is->Get7Bits();// 7 bits from input stream
-
+
// Try to use quick decompression. Check TQDecompress array for corresponding item.
// If found, ise the result byte instead.
qd = &qd3474[sevenBits];
-
+
// If there is a quick-pass possible
hasQDEntry = (qd->offs00 == offs0004) ? 1 : 0;
-
+
// Start passing the Huffman tree. Set item to tree root item
pItem1 = pFirst;
-
+
// If we can use quick decompress, use it.
bFlag = 1;
if(hasQDEntry == 1)
@@ -1152,22 +1152,22 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
if(PTR_INT(pItem1) <= 0)
pItem1 = NULL;
}
-
+
if(bFlag == 1)
{
// Walk through Huffman Tree
bitCount = 0; // Clear bit counter
do
{
- pItem1 = pItem1->child;
+ pItem1 = pItem1->child;
if(is->GetBit() != 0) // If current bit is set, move to previous
pItem1 = pItem1->prev; // item in current level
-
+
if(++bitCount == 7) // If we are at 7th bit, store current HTree item.
itemAt7 = pItem1; // Store Huffman tree item
}
while(pItem1->child != NULL); // Walk until tree has no deeper level
-
+
// If quick decompress entry is not filled yet, fill it.
if(hasQDEntry == 0)
{
@@ -1178,19 +1178,19 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
qd->item = itemAt7; // Store item at 7th bit
}
// If we passed less than 7 bits, fill entry and bit count multipliers
- else
+ else
{
unsigned long index = sevenBits & (0xFFFFFFFF >> (32 - bitCount)); // Index for quick-decompress entry
unsigned long addIndex = (1 << bitCount); // Add value for index
-
+
qd = &qd3474[index];
-
+
do
{
qd->offs00 = offs0004;
qd->bitCount = bitCount;
qd->dcmpByte = pItem1->dcmpByte;
-
+
index += addIndex;
qd += addIndex;
}
@@ -1199,21 +1199,21 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
}
dcmpByte = pItem1->dcmpByte;
}
-
+
if(dcmpByte == 0x101) // Huffman tree needs to be modified
{
// Check if there is enough bits in the buffer
is->EnsureHasMoreThan8Bits();
-
+
// Get 8 bits from the buffer
oneByte = is->Get8Bits();
-
+
// Modify Huffman tree
ModifyTree(oneByte);
-
+
// Get lastly added tree item
pItem1 = items306C[oneByte];
-
+
if(bIsCmp0 == 0 && pItem1 != NULL)
{
// 15006F15
@@ -1222,32 +1222,32 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
THTreeItem * pItem2 = pItem1;
THTreeItem * pItem3;
unsigned long byteValue;
-
+
byteValue = ++pItem1->byteValue;
-
+
while(PTR_INT((pItem3 = pItem2->prev)) > 0)
{
if(pItem3->byteValue >= byteValue)
goto _15006F30;
-
+
pItem2 = pItem2->prev;
}
pItem3 = NULL;
-
+
_15006F30:
if(pItem2 == pItem1)
continue;
-
+
InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1);
InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3);
-
+
temp = pItem2->parent->child;
if(pItem1 == pItem1->parent->child)
pItem1->parent->child = pItem2;
-
+
if(pItem2 == temp)
pItem2->parent->child = pItem1;
-
+
// Switch parents of pItem1 and pItem3
temp = pItem1->parent;
pItem1->parent = pItem2->parent;
@@ -1258,7 +1258,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
}
dcmpByte = oneByte;
}
-
+
if(dcmpByte != 0x100) // Not at the end of data ?
{
*outPtr++ = (unsigned char)dcmpByte;
@@ -1266,7 +1266,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
{
if(bIsCmp0 != 0)
Call1500E820(items306C[pItem1->byteValue]);
- }
+ }
else
break;
}
@@ -1276,7 +1276,7 @@ unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigne
return (unsigned long)(outPtr - pbOutBuffer);
}
*/
-
+
// Table for (de)compression. Every compression type has 258 entries
unsigned char THuffmannTree::Table1502A630[] =
{
@@ -1298,7 +1298,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00,
-
+
// Data for compression type 0x01
0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05,
0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02,
@@ -1317,7 +1317,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B,
0x00, 0x00,
-
+
// Data for compression type 0x02
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1336,7 +1336,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
-
+
// Data for compression type 0x03
0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03,
0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01,
@@ -1355,7 +1355,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01,
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11,
0x00, 0x00,
-
+
// Data for compression type 0x04
0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1374,7 +1374,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
-
+
// Data for compression type 0x05
0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82,
0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37,
@@ -1393,7 +1393,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
-
+
// Data for compression type 0x06
0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1412,7 +1412,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
-
+
// Data for compression type 0x07
0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -1431,7 +1431,7 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
-
+
// Data for compression type 0x08
0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10,
0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12,
@@ -1450,5 +1450,4 @@ unsigned char THuffmannTree::Table1502A630[] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
-};
-
+}; \ No newline at end of file
diff --git a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h b/contrib/vmap_extractor_v2/stormlib/huffman/huff.h
index af7cdc14539..f06aa771acd 100644
--- a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h
+++ b/contrib/vmap_extractor_v2/stormlib/huffman/huff.h
@@ -9,67 +9,67 @@
/* 03.05.03 2.00 Lad Added compression */
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/*****************************************************************************/
-
+
#ifndef __HUFFMAN_H__
#define __HUFFMAN_H__
#include "../StormPort.h"
-
+
//-----------------------------------------------------------------------------
// Defines
-
-#define INSERT_ITEM 1
+
+#define INSERT_ITEM 1
#define SWITCH_ITEMS 2 // Switch the item1 and item2
-
+
#define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr))
#define PTR_PTR(ptr) ((THTreeItem *)(ptr))
#define PTR_INT(ptr) (LONG_PTR)(ptr)
-
+
#ifndef NULL
#define NULL 0
#endif
-
+
//-----------------------------------------------------------------------------
// Structures and classes
-
+
// Input stream for Huffmann decompression
class TInputStream
{
public:
-
+
unsigned long GetBit();
unsigned long Get7Bits();
unsigned long Get8Bits();
-
+
unsigned char * pbInBuffer; // 00 - Input data
unsigned long dwBitBuff; // 04 - Input bit buffer
unsigned int nBits; // 08 - Number of bits remaining in 'dwValue'
};
-
+
// Output stream for Huffmann compression
class TOutputStream
{
public:
-
+
void PutBits(unsigned long dwBuff, unsigned int nPutBits);
-
+
unsigned char * pbOutBuffer; // 00 : Output buffer
unsigned long dwOutSize; // 04 : Size of output buffer
unsigned char * pbOutPos; // 08 : Current output position
unsigned long dwBitBuff; // 0C : Bit buffer
unsigned long nBits; // 10 : Number of bits in the bit buffer
};
-
+
// Huffmann tree item (?)
struct THTreeItem
{
public:
-
+
THTreeItem * Call1501DB70(THTreeItem * pLast);
THTreeItem * GetPrevItem(LONG_PTR value);
void ClearItemLinks();
void RemoveItem();
-
+
THTreeItem * next; // 00 - Pointer to next THTreeItem
THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none)
unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value
@@ -78,7 +78,7 @@ struct THTreeItem
THTreeItem * child; // 14 - Pointer to child THTreeItem
int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive
};
-
+
// Structure used for quick decompress. The 'bitCount' contains number of bits
// and byte value contains result decompressed byte value.
// After each walk through Huffman tree are filled all entries which are
@@ -96,48 +96,47 @@ struct TQDecompress
THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7
};
};
-
+
// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert
// for the decompression, I do not know actually if the class is really a Hufmann
// tree. If someone knows the decompression details, please let me know
class THuffmannTree
{
public:
-
+
THuffmannTree();
void InitTree(bool bCompression);
void BuildTree(unsigned int nCmpType);
// void ModifyTree(unsigned long dwIndex);
// void UninitTree();
-
+
// void Call15007010(Bit32 dwInLength, THTreeItem * item);
THTreeItem * Call1500E740(unsigned int nValue);
void Call1500E820(THTreeItem * pItem);
unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType);
unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is);
-
+
unsigned long bIsCmp0; // 0000 - 1 if compression type 0
unsigned long offs0004; // 0004 - Some flag
THTreeItem items0008[0x203]; // 0008 - HTree items
-
+
//- Sometimes used as HTree item -----------
THTreeItem * pItem3050; // 3050 - Always NULL (?)
THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item
THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid)
-
+
//- Sometimes used as HTree item -----------
THTreeItem * pItem305C; // 305C - Usually NULL
THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item
THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid)
unsigned long nItems; // 3068 - Number of used HTree items
-
+
//-------------------------------------------
THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array
TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression
int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive
-
+
static unsigned char Table1502A630[];// Some table
};
-
+
#endif // __HUFFMAN_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c b/contrib/vmap_extractor_v2/stormlib/pklib/explode.c
index 8e6825dfcd1..a5b41e3dcf9 100644
--- a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c
+++ b/contrib/vmap_extractor_v2/stormlib/pklib/explode.c
@@ -18,7 +18,7 @@
//-----------------------------------------------------------------------------
// Tables
-static unsigned char DistBits[] =
+static unsigned char DistBits[] =
{
0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
@@ -26,7 +26,7 @@ static unsigned char DistBits[] =
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08
};
-static unsigned char DistCode[] =
+static unsigned char DistCode[] =
{
0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A,
0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C,
@@ -75,7 +75,7 @@ static unsigned char ChBitsAsc[] =
0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D
};
-static unsigned short ChCodeAsc[] =
+static unsigned short ChCodeAsc[] =
{
0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0,
0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0,
@@ -108,7 +108,7 @@ static unsigned short ChCodeAsc[] =
0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900,
0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600,
0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200,
- 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
+ 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
};
//-----------------------------------------------------------------------------
@@ -266,11 +266,11 @@ static unsigned long DecodeLit(TDcmpStruct * pWork)
{
// Skip current bit in the buffer
if(WasteBits(pWork, 1))
- return 0x306;
+ return 0x306;
// The next bits are position in buffers
value = pWork->position2[(pWork->bit_buff & 0xFF)];
-
+
// Get number of bits to skip
if(WasteBits(pWork, pWork->LenBits[value]))
return 0x306;
@@ -337,7 +337,7 @@ static unsigned long DecodeLit(TDcmpStruct * pWork)
}
//-----------------------------------------------------------------------------
-// Retrieves the number of bytes to move back
+// Retrieves the number of bytes to move back
static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long dwLength)
{
@@ -402,7 +402,7 @@ static unsigned long Expand(TDcmpStruct * pWork)
}
else
pWork->out_buff[pWork->outputPos++] = (unsigned char)oneByte;
-
+
// If number of extracted bytes has reached 1/2 of output buffer,
// flush output buffer.
if(pWork->outputPos >= 0x2000)
@@ -453,7 +453,7 @@ unsigned int explode(
pWork->in_pos = 3; // Position in input buffer
// Test for the valid dictionary size
- if(4 > pWork->dsize_bits || pWork->dsize_bits > 6)
+ if(4 > pWork->dsize_bits || pWork->dsize_bits > 6)
return CMP_INVALID_DICTSIZE;
pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction
@@ -475,6 +475,6 @@ unsigned int explode(
GenDecodeTabs(0x40, pWork->DistBits, DistCode, pWork->position1);
if(Expand(pWork) != 0x306)
return CMP_NO_ERROR;
-
+
return CMP_ABORT;
}
diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c b/contrib/vmap_extractor_v2/stormlib/pklib/implode.c
index 2ffa0f62764..68d5301cc8d 100644
--- a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c
+++ b/contrib/vmap_extractor_v2/stormlib/pklib/implode.c
@@ -28,7 +28,7 @@
//-----------------------------------------------------------------------------
// Tables
-static unsigned char DistBits[] =
+static unsigned char DistBits[] =
{
0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
@@ -36,7 +36,7 @@ static unsigned char DistBits[] =
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08
};
-static unsigned char DistCode[] =
+static unsigned char DistCode[] =
{
0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A,
0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C,
@@ -79,7 +79,7 @@ static unsigned char ChBitsAsc[] =
0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D
};
-static unsigned short ChCodeAsc[] =
+static unsigned short ChCodeAsc[] =
{
0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0,
0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0,
@@ -112,7 +112,7 @@ static unsigned short ChCodeAsc[] =
0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900,
0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600,
0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200,
- 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
+ 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000
};
//-----------------------------------------------------------------------------
@@ -215,7 +215,7 @@ static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit
{
pWork->out_bytes++;
bit_buff >>= (8 - out_bits);
-
+
pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff;
pWork->out_bits &= 7;
}
@@ -341,7 +341,7 @@ static unsigned long FindRep(TCmpStruct * pWork, unsigned char * srcbuff)
esi = nreps;
pin27CC = pWork->work_buff + pin49D0[0] + nreps;
esp14 = pin27CC;
-
+
for(;;) // 0040268B
{
esi = pWork->offs09BC[esi];
@@ -473,7 +473,7 @@ static void WriteCmpData(TCmpStruct * pWork)
//
switch(esp20)
{
- case 0:
+ case 0:
SortBuffer(pWork, uncmp_begin, uncmp_end + 1);
esp20++;
if(pWork->dsize_bytes != 0x1000)
@@ -590,7 +590,7 @@ unsigned int PKEXPORT implode(
// Initialize the work buffer. This is not in the Pklib,
// but it seems to be a bug. Storm always pre-fills the data with zeros,
// and always compresses one block only. So the bug will not appear.
- // But when a larger data block (size > 0x1000) is compressed,
+ // But when a larger data block (size > 0x1000) is compressed,
// it may fail.
memset(pWork, 0, sizeof(TCmpStruct));
@@ -650,7 +650,7 @@ unsigned int PKEXPORT implode(
for(i = 0; i < 0x10; i++)
{
- int nCount2 = 0; // EBX
+ int nCount2 = 0; // EBX
if((1 << ExLenBits[i]) == 0)
continue;
diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h b/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h
index d4c405b240d..881262e3839 100644
--- a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h
+++ b/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h
@@ -29,7 +29,7 @@
// Define calling convention
#ifndef PKEXPORT
-#define PKEXPORT //__cdecl // Use for normal __cdecl calling
+#define PKEXPORT //__cdecl // Use for normal __cdecl calling
#endif
//#define PKEXPORT __stdcall
//#define PKEXPORT __fastcall
@@ -40,8 +40,8 @@
// Compression structure
typedef struct
{
- unsigned int offs0000; // 0000 :
- unsigned int out_bytes; // 0004 : # bytes available in out_buff
+ unsigned int offs0000; // 0000 :
+ unsigned int out_bytes; // 0004 : # bytes available in out_buff
unsigned int out_bits; // 0008 : # of bits available in the last out byte
unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000
unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000
@@ -49,23 +49,23 @@ typedef struct
unsigned int dsize_bytes; // 0018 : Dictionary size in bytes
unsigned char dist_bits[0x40]; // 001C : Distance bits
unsigned char dist_codes[0x40]; // 005C : Distance codes
- unsigned char nChBits[0x306]; // 009C :
- unsigned short nChCodes[0x306]; // 03A2 :
- unsigned short offs09AE; // 09AE :
+ unsigned char nChBits[0x306]; // 009C :
+ unsigned short nChCodes[0x306]; // 03A2 :
+ unsigned short offs09AE; // 09AE :
void * param; // 09B0 : User parameter
unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4
void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8
unsigned short offs09BC[0x204]; // 09BC :
- unsigned long offs0DC4; // 0DC4 :
+ unsigned long offs0DC4; // 0DC4 :
unsigned short offs0DC8[0x900]; // 0DC8 :
- unsigned short offs1FC8; // 1FC8 :
+ unsigned short offs1FC8; // 1FC8 :
char out_buff[0x802]; // 1FCA : Output (compressed) data
unsigned char work_buff[0x2204]; // 27CC : Work buffer
// + DICT_OFFSET => Dictionary
// + UNCMP_OFFSET => Uncompressed data
- unsigned short offs49D0[0x2000]; // 49D0 :
+ unsigned short offs49D0[0x2000]; // 49D0 :
} TCmpStruct;
#define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer
@@ -91,15 +91,15 @@ typedef struct
unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed
unsigned char position1[0x100]; // 2A34 - Positions in buffers
unsigned char position2[0x100]; // 2B34 - Positions in buffers
- unsigned char offs2C34[0x100]; // 2C34 - Buffer for
- unsigned char offs2D34[0x100]; // 2D34 - Buffer for
- unsigned char offs2E34[0x80]; // 2EB4 - Buffer for
- unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for
- unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for
+ unsigned char offs2C34[0x100]; // 2C34 - Buffer for
+ unsigned char offs2D34[0x100]; // 2D34 - Buffer for
+ unsigned char offs2E34[0x80]; // 2EB4 - Buffer for
+ unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for
+ unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for
unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length
unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length
unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block
- unsigned short LenBase[0x10]; // 3114 - Buffer for
+ unsigned short LenBase[0x10]; // 3114 - Buffer for
} TDcmpStruct;
#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer
@@ -135,4 +135,3 @@ unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *
#endif
#endif // __PKLIB_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp b/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp
index 1400fad37de..936525f4eae 100644
--- a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp
@@ -35,8 +35,8 @@ static long Table1503F120[] =
{
0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006,
0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007,
- 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007,
- 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008
+ 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007,
+ 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008
};
static long Table1503F1A0[] =
@@ -112,10 +112,10 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe
nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer);
nLength = (nLength < 0) ? 0 : nLength;
-
+
nIndex = nChannels - 1; // edi
nWordsRemains = dwInLength / 2; // eax
-
+
// ebx - nChannels
// ecx - pwOutPos
for(int chnl = nChannels; chnl < nWordsRemains; chnl++)
@@ -184,7 +184,7 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe
}
if(dwBit == dwStopBit)
break;
-
+
nTableValue >>= 1;
}
@@ -205,7 +205,7 @@ int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffe
SInt32Array2[nIndex] = nValue;
*out.pb++ = (unsigned char)(dwBitBuff | ebx);
nTableValue = Table1503F120[dwBitBuff & 0x1F];
- SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue;
+ SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue;
if(SInt32Array1[nIndex] < 0)
SInt32Array1[nIndex] = 0;
else if(SInt32Array1[nIndex] > 0x58)
@@ -280,7 +280,7 @@ int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char *
SInt32Array1[nIndex] += 8;
if(SInt32Array1[nIndex] > 0x58)
SInt32Array1[nIndex] = 0x58;
-
+
if(nChannels == 2)
nIndex = (nIndex == 0) ? 1 : 0;
break;
@@ -354,4 +354,3 @@ int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char *
}
return (int)(out.pb - pbOutBuffer);
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.h b/contrib/vmap_extractor_v2/stormlib/wave/wave.h
index bc116b91ce7..81b5add9cfc 100644
--- a/contrib/vmap_extractor_v2/stormlib/wave/wave.h
+++ b/contrib/vmap_extractor_v2/stormlib/wave/wave.h
@@ -20,4 +20,3 @@ int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBu
int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels);
#endif // __WAVE_H__
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile b/contrib/vmap_extractor_v2/stormlib/zlib/Makefile
deleted file mode 100644
index 531562b2ef1..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile
+++ /dev/null
@@ -1,175 +0,0 @@
-# Makefile for zlib
-# Copyright (C) 1995-2002 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-# ./configure; make test
-# The call of configure is optional if you don't have special requirements
-# If you wish to build zlib as a shared library, use: ./configure -s
-
-# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
-# make install
-# To install in $HOME instead of /usr/local, use:
-# make install prefix=$HOME
-
-CC=cc
-
-CFLAGS=-O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-# -Wstrict-prototypes -Wmissing-prototypes
-
-LDFLAGS=-L. -lz
-LDSHARED=$(CC)
-CPP=$(CC) -E
-
-VER=1.1.4
-LIBS=libz.a
-SHAREDLIB=libz.so
-
-AR=ar rc
-RANLIB=ranlib
-TAR=tar
-SHELL=/bin/sh
-
-prefix = /usr/local
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-includedir = ${prefix}/include
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
-
-OBJA =
-# to use the asm code: make OBJA=match.o
-
-TEST_OBJS = example.o minigzip.o
-
-DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \
- algorithm.txt zlib.3 zlib.html \
- msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
- nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \
- contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \
- contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \
- contrib/asm[56]86/*.S contrib/iostream/*.cpp \
- contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
- contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \
- contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
- contrib/delphi*/*.???
-
-all: example minigzip
-
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
- echo ' *** minigzip test FAILED ***' ; \
- if ./example; then \
- echo ' *** zlib test OK ***'; \
- else \
- echo ' *** zlib test FAILED ***'; \
- fi
-
-libz.a: $(OBJS) $(OBJA)
- $(AR) $@ $(OBJS) $(OBJA)
- -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
-
-match.o: match.S
- $(CPP) match.S > _match.s
- $(CC) -c _match.s
- mv _match.o match.o
- rm -f _match.s
-
-$(SHAREDLIB).$(VER): $(OBJS)
- $(LDSHARED) -o $@ $(OBJS)
- rm -f $(SHAREDLIB) $(SHAREDLIB).1
- ln -s $@ $(SHAREDLIB)
- ln -s $@ $(SHAREDLIB).1
-
-example: example.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip: minigzip.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-install: $(LIBS)
- -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi
- -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
- cp zlib.h zconf.h $(includedir)
- chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
- cp $(LIBS) $(libdir)
- cd $(libdir); chmod 755 $(LIBS)
- -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
- cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
- rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
- ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
- ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
- (ldconfig || true) >/dev/null 2>&1; \
- fi
-# The ranlib in install is needed on NeXTSTEP which checks file times
-# ldconfig is for Linux
-
-uninstall:
- cd $(includedir); \
- v=$(VER); \
- if test -f zlib.h; then \
- v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
- rm -f zlib.h zconf.h; \
- fi; \
- cd $(libdir); rm -f libz.a; \
- if test -f $(SHAREDLIB).$$v; then \
- rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
- fi
-
-clean:
- rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
- _match.s maketree
-
-distclean: clean
-
-zip:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c contrib/minizip/test.zip
- v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- zip -ul9 zlib$$v $(DISTFILES)
- mv Makefile~ Makefile
-
-dist:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c contrib/minizip/test.zip
- d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- rm -f $$d.tar.gz; \
- if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
- files=""; \
- for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
- cd ..; \
- GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
- if test ! -d $$d; then rm -f $$d; fi
- mv Makefile~ Makefile
-
-tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
-infcodes.o: zutil.h zlib.h zconf.h
-infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h
-inffast.o: infblock.h infcodes.h infutil.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h infblock.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.in b/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.in
deleted file mode 100644
index 531562b2ef1..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.in
+++ /dev/null
@@ -1,175 +0,0 @@
-# Makefile for zlib
-# Copyright (C) 1995-2002 Jean-loup Gailly.
-# For conditions of distribution and use, see copyright notice in zlib.h
-
-# To compile and test, type:
-# ./configure; make test
-# The call of configure is optional if you don't have special requirements
-# If you wish to build zlib as a shared library, use: ./configure -s
-
-# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
-# make install
-# To install in $HOME instead of /usr/local, use:
-# make install prefix=$HOME
-
-CC=cc
-
-CFLAGS=-O
-#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
-#CFLAGS=-g -DDEBUG
-#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
-# -Wstrict-prototypes -Wmissing-prototypes
-
-LDFLAGS=-L. -lz
-LDSHARED=$(CC)
-CPP=$(CC) -E
-
-VER=1.1.4
-LIBS=libz.a
-SHAREDLIB=libz.so
-
-AR=ar rc
-RANLIB=ranlib
-TAR=tar
-SHELL=/bin/sh
-
-prefix = /usr/local
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-includedir = ${prefix}/include
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
- zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
-
-OBJA =
-# to use the asm code: make OBJA=match.o
-
-TEST_OBJS = example.o minigzip.o
-
-DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \
- algorithm.txt zlib.3 zlib.html \
- msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \
- nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \
- contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \
- contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \
- contrib/asm[56]86/*.S contrib/iostream/*.cpp \
- contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \
- contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \
- contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \
- contrib/delphi*/*.???
-
-all: example minigzip
-
-test: all
- @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
- echo hello world | ./minigzip | ./minigzip -d || \
- echo ' *** minigzip test FAILED ***' ; \
- if ./example; then \
- echo ' *** zlib test OK ***'; \
- else \
- echo ' *** zlib test FAILED ***'; \
- fi
-
-libz.a: $(OBJS) $(OBJA)
- $(AR) $@ $(OBJS) $(OBJA)
- -@ ($(RANLIB) $@ || true) >/dev/null 2>&1
-
-match.o: match.S
- $(CPP) match.S > _match.s
- $(CC) -c _match.s
- mv _match.o match.o
- rm -f _match.s
-
-$(SHAREDLIB).$(VER): $(OBJS)
- $(LDSHARED) -o $@ $(OBJS)
- rm -f $(SHAREDLIB) $(SHAREDLIB).1
- ln -s $@ $(SHAREDLIB)
- ln -s $@ $(SHAREDLIB).1
-
-example: example.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip: minigzip.o $(LIBS)
- $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-install: $(LIBS)
- -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi
- -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi
- cp zlib.h zconf.h $(includedir)
- chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
- cp $(LIBS) $(libdir)
- cd $(libdir); chmod 755 $(LIBS)
- -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
- cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
- rm -f $(SHAREDLIB) $(SHAREDLIB).1; \
- ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \
- ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \
- (ldconfig || true) >/dev/null 2>&1; \
- fi
-# The ranlib in install is needed on NeXTSTEP which checks file times
-# ldconfig is for Linux
-
-uninstall:
- cd $(includedir); \
- v=$(VER); \
- if test -f zlib.h; then \
- v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \
- rm -f zlib.h zconf.h; \
- fi; \
- cd $(libdir); rm -f libz.a; \
- if test -f $(SHAREDLIB).$$v; then \
- rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \
- fi
-
-clean:
- rm -f *.o *~ example minigzip libz.a libz.so* foo.gz so_locations \
- _match.s maketree
-
-distclean: clean
-
-zip:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c contrib/minizip/test.zip
- v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- zip -ul9 zlib$$v $(DISTFILES)
- mv Makefile~ Makefile
-
-dist:
- mv Makefile Makefile~; cp -p Makefile.in Makefile
- rm -f test.c ztest*.c contrib/minizip/test.zip
- d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\
- rm -f $$d.tar.gz; \
- if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \
- files=""; \
- for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \
- cd ..; \
- GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \
- if test ! -d $$d; then rm -f $$d; fi
- mv Makefile~ Makefile
-
-tags:
- etags *.[ch]
-
-depend:
- makedepend -- $(CFLAGS) -- *.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h
-infcodes.o: zutil.h zlib.h zconf.h
-infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h
-inffast.o: zutil.h zlib.h zconf.h inftrees.h
-inffast.o: infblock.h infcodes.h infutil.h inffast.h
-inflate.o: zutil.h zlib.h zconf.h infblock.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c b/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c
index d74de704d62..fae88b65593 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c
@@ -1,6 +1,6 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
@@ -34,12 +34,12 @@ uLong ZEXPORT adler32(adler, buf, len)
len -= k;
while (k >= 16) {
DO16(buf);
- buf += 16;
+ buf += 16;
k -= 16;
}
if (k != 0) do {
s1 += *buf++;
- s2 += s1;
+ s2 += s1;
} while (--k);
s1 %= BASE;
s2 %= BASE;
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/compress.c b/contrib/vmap_extractor_v2/stormlib/zlib/compress.c
index c44f8ba9dfa..814bd9d6061 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/compress.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/compress.c
@@ -1,6 +1,6 @@
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/configure b/contrib/vmap_extractor_v2/stormlib/zlib/configure
deleted file mode 100644
index e8942359bc1..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/zlib/configure
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/bin/sh
-# configure script for zlib. This script is needed only if
-# you wish to build a shared library and your system supports them,
-# of if you need special compiler, flags or install directory.
-# Otherwise, you can just use directly "make test; make install"
-#
-# To create a shared library, use "configure --shared"; by default a static
-# library is created. If the primitive shared library support provided here
-# does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
-#
-# To impose specific compiler or flags or install directory, use for example:
-# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
-# or for csh/tcsh users:
-# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
-# LDSHARED is the command to be used to create a shared library
-
-# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
-# If you have problems, try without defining CC and CFLAGS before reporting
-# an error.
-
-LIBS=libz.a
-SHAREDLIB=libz.so
-VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
-AR=${AR-"ar rc"}
-RANLIB=${RANLIB-"ranlib"}
-prefix=${prefix-/usr/local}
-exec_prefix=${exec_prefix-'${prefix}'}
-libdir=${libdir-'${exec_prefix}/lib'}
-includedir=${includedir-'${prefix}/include'}
-shared_ext='.so'
-shared=0
-gcc=0
-old_cc="$CC"
-old_cflags="$CFLAGS"
-
-while test $# -ge 1
-do
-case "$1" in
- -h* | --h*)
- echo 'usage:'
- echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
- echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
- exit 0;;
- -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
- -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
- -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
- -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
- -p* | --p*) prefix="$2"; shift; shift;;
- -e* | --e*) exec_prefix="$2"; shift; shift;;
- -l* | --l*) libdir="$2"; shift; shift;;
- -i* | --i*) includedir="$2"; shift; shift;;
- -s* | --s*) shared=1; shift;;
- esac
-done
-
-test=ztest$$
-cat > $test.c <<EOF
-extern int getchar();
-int hello() {return getchar();}
-EOF
-
-test -z "$CC" && echo Checking for gcc...
-cc=${CC-gcc}
-cflags=${CFLAGS-"-O3"}
-# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
-case "$cc" in
- *gcc*) gcc=1;;
-esac
-
-if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
- CC="$cc"
- SFLAGS=${CFLAGS-"-fPIC -O3"}
- CFLAGS="$cflags"
- case `(uname -s || echo unknown) 2>/dev/null` in
- Linux | linux) LDSHARED=${LDSHARED-"gcc -shared -Wl,-soname,libz.so.1"};;
- *) LDSHARED=${LDSHARED-"gcc -shared"};;
- esac
-else
- # find system name and corresponding cc options
- CC=${CC-cc}
- case `(uname -sr || echo unknown) 2>/dev/null` in
- HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
- CFLAGS=${CFLAGS-"-O"}
-# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
- LDSHARED=${LDSHARED-"ld -b"}
- shared_ext='.sl'
- SHAREDLIB='libz.sl';;
- IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
- CFLAGS=${CFLAGS-"-ansi -O2"}
- LDSHARED=${LDSHARED-"cc -shared"};;
- OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
- CFLAGS=${CFLAGS-"-O -std1"}
- LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
- OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
- CFLAGS=${CFLAGS-"-O -std1"}
- LDSHARED=${LDSHARED-"cc -shared"};;
- QNX*) SFLAGS=${CFLAGS-"-4 -O"}
- CFLAGS=${CFLAGS-"-4 -O"}
- LDSHARED=${LDSHARED-"cc"}
- RANLIB=${RANLIB-"true"}
- AR="cc -A";;
- SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
- CFLAGS=${CFLAGS-"-O3"}
- LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
- SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
- CFLAGS=${CFLAGS-"-fast -xcg89"}
- LDSHARED=${LDSHARED-"cc -G"};;
- SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
- CFLAGS=${CFLAGS-"-O2"}
- LDSHARED=${LDSHARED-"ld"};;
- UNIX_System_V\ 4.2.0)
- SFLAGS=${CFLAGS-"-KPIC -O"}
- CFLAGS=${CFLAGS-"-O"}
- LDSHARED=${LDSHARED-"cc -G"};;
- UNIX_SV\ 4.2MP)
- SFLAGS=${CFLAGS-"-Kconform_pic -O"}
- CFLAGS=${CFLAGS-"-O"}
- LDSHARED=${LDSHARED-"cc -G"};;
- # send working options for other systems to support@gzip.org
- *) SFLAGS=${CFLAGS-"-O"}
- CFLAGS=${CFLAGS-"-O"}
- LDSHARED=${LDSHARED-"cc -shared"};;
- esac
-fi
-
-if test $shared -eq 1; then
- echo Checking for shared library support...
- # we must test in two steps (cc then ld), required at least on SunOS 4.x
- if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
- test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
- CFLAGS="$SFLAGS"
- LIBS="$SHAREDLIB.$VER"
- echo Building shared library $SHAREDLIB.$VER with $CC.
- elif test -z "$old_cc" -a -z "$old_cflags"; then
- echo No shared library suppport.
- shared=0;
- else
- echo 'No shared library suppport; try without defining CC and CFLAGS'
- shared=0;
- fi
-fi
-if test $shared -eq 0; then
- LDSHARED="$CC"
- echo Building static library $LIBS version $VER with $CC.
-fi
-
-cat > $test.c <<EOF
-#include <unistd.h>
-int main() { return 0; }
-EOF
-if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
- CFLAGS="$CFLAGS -DHAVE_UNISTD_H"
- echo "Checking for unistd.h... Yes."
-else
- echo "Checking for unistd.h... No."
-fi
-
-cat > $test.c <<EOF
-#include <errno.h>
-int main() { return 0; }
-EOF
-if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
- echo "Checking for errno.h... Yes."
-else
- echo "Checking for errno.h... No."
- CFLAGS="$CFLAGS -DNO_ERRNO_H"
-fi
-
-cat > $test.c <<EOF
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-caddr_t hello() {
- return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
-}
-EOF
-if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
- CFLAGS="$CFLAGS -DUSE_MMAP"
- echo Checking for mmap support... Yes.
-else
- echo Checking for mmap support... No.
-fi
-
-CPP=${CPP-"$CC -E"}
-case $CFLAGS in
- *ASMV*)
- if test "`nm $test.o | grep _hello`" = ""; then
- CPP="$CPP -DNO_UNDERLINE"
- echo Checking for underline in external names... No.
- else
- echo Checking for underline in external names... Yes.
- fi;;
-esac
-
-rm -f $test.[co] $test$shared_ext
-
-# udpate Makefile
-sed < Makefile.in "
-/^CC *=/s%=.*%=$CC%
-/^CFLAGS *=/s%=.*%=$CFLAGS%
-/^CPP *=/s%=.*%=$CPP%
-/^LDSHARED *=/s%=.*%=$LDSHARED%
-/^LIBS *=/s%=.*%=$LIBS%
-/^SHAREDLIB *=/s%=.*%=$SHAREDLIB%
-/^AR *=/s%=.*%=$AR%
-/^RANLIB *=/s%=.*%=$RANLIB%
-/^VER *=/s%=.*%=$VER%
-/^prefix *=/s%=.*%=$prefix%
-/^exec_prefix *=/s%=.*%=$exec_prefix%
-/^libdir *=/s%=.*%=$libdir%
-/^includedir *=/s%=.*%=$includedir%
-" > Makefile
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c
index 4ee6051aeb0..d853bb7ce8a 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c
@@ -20,7 +20,7 @@
/* if your C compiler don't add underline before function name,
- define ADD_UNDERLINE_ASMFUNC */
+ define ADD_UNDERLINE_ASMFUNC */
#ifdef ADD_UNDERLINE_ASMFUNC
#define longest_match_7fff _longest_match_7fff
#endif
@@ -46,15 +46,15 @@ uInt longest_match(
deflate_state *s,
IPos cur_match) /* current match */
{
- static uInt iIsPPro=2;
+ static uInt iIsPPro=2;
if ((s->w_mask == 0x7fff) && (iIsPPro==0))
return longest_match_7fff(s,cur_match);
- if (iIsPPro==2)
- iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0;
+ if (iIsPPro==2)
+ iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0;
- return longest_match_c(s,cur_match);
+ return longest_match_c(s,cur_match);
}
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp
index 25b15e30a8c..f5dea59b762 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp
@@ -15,4 +15,3 @@ USEUNIT("trees.c");
// To add a file to the library use the Project menu 'Add to Project'.
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp
index 0673927e015..bf6953ba198 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp
@@ -20,4 +20,3 @@ USEUNIT("zutil.c");
// To add a file to the library use the Project menu 'Add to Project'.
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp
index 0458f5447cb..7372f6b985f 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp
@@ -40,4 +40,3 @@ int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return 1;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp
index e416a1c7649..7d265b3b5c0 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp
@@ -22,4 +22,3 @@ int main() {
return 0;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp
index 2959b3b349b..a690bbefceb 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp
@@ -17,7 +17,7 @@ gzfilebuf::~gzfilebuf() {
}
gzfilebuf *gzfilebuf::open( const char *name,
- int io_mode ) {
+ int io_mode ) {
if ( is_open() )
return NULL;
@@ -58,7 +58,7 @@ gzfilebuf *gzfilebuf::open( const char *name,
}
gzfilebuf *gzfilebuf::attach( int file_descriptor,
- int io_mode ) {
+ int io_mode ) {
if ( is_open() )
return NULL;
@@ -151,7 +151,7 @@ int gzfilebuf::underflow() {
if ( out_waiting() ) {
if ( flushbuf() == EOF )
- return EOF;
+ return EOF;
}
}
@@ -180,11 +180,11 @@ int gzfilebuf::overflow( int c ) {
setg(0,0,0);
} else {
if (in_avail()) {
- return EOF;
+ return EOF;
}
if (out_waiting()) {
if (flushbuf() == EOF)
- return EOF;
+ return EOF;
}
}
@@ -287,7 +287,7 @@ gzfilebuf *gzfilestream_common::rdbuf() {
return &buffer;
}
-
+
gzifstream::gzifstream() :
ios( gzfilestream_common::rdbuf() )
{
@@ -327,4 +327,3 @@ gzofstream::gzofstream( int fd, int io_mode ) :
}
gzofstream::~gzofstream() { }
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h
index 81ff4e26258..c87fa08e9d1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h
@@ -99,9 +99,9 @@ private:
};
template<class T> gzofstream &operator<<(gzofstream &s,
- const gzomanip<T> &m) {
+ const gzomanip<T> &m) {
return (*m.func)(s, m.val);
-
+
}
inline gzofstream &setcompressionlevel( gzofstream &s, int l ) {
@@ -140,4 +140,3 @@ inline gzomanip<int> setcompressionstrategy(int l)
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h
index a69b189a16f..43d2332b79b 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h
@@ -305,4 +305,3 @@ inline ostream& operator<<(ozstream& zs, const T& x) {
}
#endif
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp
index b2fc9e66902..5bbd56c3ad8 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp
@@ -4,9 +4,9 @@
#include <iomanip.h>
void main() {
- char h[256] = "Hello";
- char* g = "Goodbye";
- ozstream out("temp.gz");
+ char h[256] = "Hello";
+ char* g = "Goodbye";
+ ozstream out("temp.gz");
out < "This works well" < h < g;
out.close();
@@ -23,4 +23,3 @@ void main() {
delete[] x; delete[] y;
}
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/Makefile b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/Makefile
deleted file mode 100644
index a1dfc161437..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-CC=cc
-CFLAGS=-O -I../..
-
-UNZ_OBJS = miniunz.o unzip.o ../../libz.a
-ZIP_OBJS = minizip.o zip.o ../../libz.a
-
-.c.o:
- $(CC) -c $(CFLAGS) $*.c
-
-all: miniunz minizip
-
-miniunz: $(UNZ_OBJS)
- $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
-
-minizip: $(ZIP_OBJS)
- $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
-
-test: miniunz minizip
- ./minizip test readme.txt
- ./miniunz -l test.zip
- mv readme.txt readme.old
- ./miniunz test.zip
-
-clean:
- /bin/rm -f *.o *~ minizip miniunz
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c
index 741e8dca566..f3b7832878f 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c
@@ -34,9 +34,9 @@
dosdate : the new date at the MSDos format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
void change_file_date(filename,dosdate,tmu_date)
- const char *filename;
- uLong dosdate;
- tm_unz tmu_date;
+ const char *filename;
+ uLong dosdate;
+ tm_unz tmu_date;
{
#ifdef WIN32
HANDLE hFile;
@@ -75,17 +75,17 @@ void change_file_date(filename,dosdate,tmu_date)
As I don't know well Unix, I wait feedback for the unix portion */
int mymkdir(dirname)
- const char* dirname;
+ const char* dirname;
{
int ret=0;
#ifdef WIN32
- ret = mkdir(dirname);
+ ret = mkdir(dirname);
#else
#ifdef unix
- ret = mkdir (dirname,0775);
+ ret = mkdir (dirname,0775);
#endif
#endif
- return ret;
+ return ret;
}
int makedir (newdir)
@@ -93,14 +93,14 @@ int makedir (newdir)
{
char *buffer ;
char *p;
- int len = strlen(newdir);
+ int len = strlen(newdir);
- if (len <= 0)
+ if (len <= 0)
return 0;
buffer = (char*)malloc(len+1);
strcpy(buffer,newdir);
-
+
if (buffer[len-1] == '/') {
buffer[len-1] = '\0';
}
@@ -135,104 +135,104 @@ int makedir (newdir)
void do_banner()
{
- printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n");
- printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
+ printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n");
+ printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
}
void do_help()
-{
- printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ;
+{
+ printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ;
}
int do_list(uf)
- unzFile uf;
+ unzFile uf;
{
- uLong i;
- unz_global_info gi;
- int err;
+ uLong i;
+ unz_global_info gi;
+ int err;
- err = unzGetGlobalInfo (uf,&gi);
- if (err!=UNZ_OK)
- printf("error %d with zipfile in unzGetGlobalInfo \n",err);
+ err = unzGetGlobalInfo (uf,&gi);
+ if (err!=UNZ_OK)
+ printf("error %d with zipfile in unzGetGlobalInfo \n",err);
printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
- for (i=0;i<gi.number_entry;i++)
- {
- char filename_inzip[256];
- unz_file_info file_info;
- uLong ratio=0;
- const char *string_method;
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
- break;
- }
- if (file_info.uncompressed_size>0)
- ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
-
- if (file_info.compression_method==0)
- string_method="Stored";
- else
- if (file_info.compression_method==Z_DEFLATED)
- {
- uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
- if (iLevel==0)
- string_method="Defl:N";
- else if (iLevel==1)
- string_method="Defl:X";
- else if ((iLevel==2) || (iLevel==3))
- string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
- }
- else
- string_method="Unkn. ";
-
- printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
- file_info.uncompressed_size,string_method,file_info.compressed_size,
- ratio,
- (uLong)file_info.tmu_date.tm_mon + 1,
+ for (i=0;i<gi.number_entry;i++)
+ {
+ char filename_inzip[256];
+ unz_file_info file_info;
+ uLong ratio=0;
+ const char *string_method;
+ err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
+ break;
+ }
+ if (file_info.uncompressed_size>0)
+ ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
+
+ if (file_info.compression_method==0)
+ string_method="Stored";
+ else
+ if (file_info.compression_method==Z_DEFLATED)
+ {
+ uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
+ if (iLevel==0)
+ string_method="Defl:N";
+ else if (iLevel==1)
+ string_method="Defl:X";
+ else if ((iLevel==2) || (iLevel==3))
+ string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
+ }
+ else
+ string_method="Unkn. ";
+
+ printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
+ file_info.uncompressed_size,string_method,file_info.compressed_size,
+ ratio,
+ (uLong)file_info.tmu_date.tm_mon + 1,
(uLong)file_info.tmu_date.tm_mday,
- (uLong)file_info.tmu_date.tm_year % 100,
- (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
- (uLong)file_info.crc,filename_inzip);
- if ((i+1)<gi.number_entry)
- {
- err = unzGoToNextFile(uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGoToNextFile\n",err);
- break;
- }
- }
- }
-
- return 0;
+ (uLong)file_info.tmu_date.tm_year % 100,
+ (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
+ (uLong)file_info.crc,filename_inzip);
+ if ((i+1)<gi.number_entry)
+ {
+ err = unzGoToNextFile(uf);
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzGoToNextFile\n",err);
+ break;
+ }
+ }
+ }
+
+ return 0;
}
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
- unzFile uf;
- const int* popt_extract_without_path;
+ unzFile uf;
+ const int* popt_extract_without_path;
int* popt_overwrite;
{
- char filename_inzip[256];
- char* filename_withoutpath;
- char* p;
+ char filename_inzip[256];
+ char* filename_withoutpath;
+ char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;
+
+ unz_file_info file_info;
+ uLong ratio=0;
+ err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
- unz_file_info file_info;
- uLong ratio=0;
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
-
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
- return err;
- }
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
+ return err;
+ }
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
@@ -242,71 +242,71 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
return UNZ_INTERNALERROR;
}
- p = filename_withoutpath = filename_inzip;
- while ((*p) != '\0')
- {
- if (((*p)=='/') || ((*p)=='\\'))
- filename_withoutpath = p+1;
- p++;
- }
-
- if ((*filename_withoutpath)=='\0')
- {
- if ((*popt_extract_without_path)==0)
- {
- printf("creating directory: %s\n",filename_inzip);
- mymkdir(filename_inzip);
- }
- }
- else
- {
- const char* write_filename;
- int skip=0;
-
- if ((*popt_extract_without_path)==0)
- write_filename = filename_inzip;
- else
- write_filename = filename_withoutpath;
-
- err = unzOpenCurrentFile(uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzOpenCurrentFile\n",err);
- }
-
- if (((*popt_overwrite)==0) && (err==UNZ_OK))
- {
- char rep;
- FILE* ftestexist;
- ftestexist = fopen(write_filename,"rb");
- if (ftestexist!=NULL)
- {
- fclose(ftestexist);
- do
- {
- char answer[128];
- printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
- scanf("%1s",answer);
- rep = answer[0] ;
- if ((rep>='a') && (rep<='z'))
- rep -= 0x20;
- }
- while ((rep!='Y') && (rep!='N') && (rep!='A'));
- }
-
- if (rep == 'N')
- skip = 1;
-
- if (rep == 'A')
- *popt_overwrite=1;
- }
-
- if ((skip==0) && (err==UNZ_OK))
- {
- fout=fopen(write_filename,"wb");
+ p = filename_withoutpath = filename_inzip;
+ while ((*p) != '\0')
+ {
+ if (((*p)=='/') || ((*p)=='\\'))
+ filename_withoutpath = p+1;
+ p++;
+ }
+
+ if ((*filename_withoutpath)=='\0')
+ {
+ if ((*popt_extract_without_path)==0)
+ {
+ printf("creating directory: %s\n",filename_inzip);
+ mymkdir(filename_inzip);
+ }
+ }
+ else
+ {
+ const char* write_filename;
+ int skip=0;
+
+ if ((*popt_extract_without_path)==0)
+ write_filename = filename_inzip;
+ else
+ write_filename = filename_withoutpath;
+
+ err = unzOpenCurrentFile(uf);
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzOpenCurrentFile\n",err);
+ }
+
+ if (((*popt_overwrite)==0) && (err==UNZ_OK))
+ {
+ char rep;
+ FILE* ftestexist;
+ ftestexist = fopen(write_filename,"rb");
+ if (ftestexist!=NULL)
+ {
+ fclose(ftestexist);
+ do
+ {
+ char answer[128];
+ printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
+ scanf("%1s",answer);
+ rep = answer[0] ;
+ if ((rep>='a') && (rep<='z'))
+ rep -= 0x20;
+ }
+ while ((rep!='Y') && (rep!='N') && (rep!='A'));
+ }
+
+ if (rep == 'N')
+ skip = 1;
+
+ if (rep == 'A')
+ *popt_overwrite=1;
+ }
+
+ if ((skip==0) && (err==UNZ_OK))
+ {
+ fout=fopen(write_filename,"wb");
/* some zipfile don't contain directory alone before file */
- if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
+ if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip))
{
char c=*(filename_withoutpath-1);
@@ -316,94 +316,94 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite)
fout=fopen(write_filename,"wb");
}
- if (fout==NULL)
- {
- printf("error opening %s\n",write_filename);
- }
- }
-
- if (fout!=NULL)
- {
- printf(" extracting: %s\n",write_filename);
-
- do
- {
- err = unzReadCurrentFile(uf,buf,size_buf);
- if (err<0)
- {
- printf("error %d with zipfile in unzReadCurrentFile\n",err);
- break;
- }
- if (err>0)
- if (fwrite(buf,err,1,fout)!=1)
- {
- printf("error in writing extracted file\n");
+ if (fout==NULL)
+ {
+ printf("error opening %s\n",write_filename);
+ }
+ }
+
+ if (fout!=NULL)
+ {
+ printf(" extracting: %s\n",write_filename);
+
+ do
+ {
+ err = unzReadCurrentFile(uf,buf,size_buf);
+ if (err<0)
+ {
+ printf("error %d with zipfile in unzReadCurrentFile\n",err);
+ break;
+ }
+ if (err>0)
+ if (fwrite(buf,err,1,fout)!=1)
+ {
+ printf("error in writing extracted file\n");
err=UNZ_ERRNO;
- break;
- }
- }
- while (err>0);
- fclose(fout);
- if (err==0)
- change_file_date(write_filename,file_info.dosDate,
- file_info.tmu_date);
- }
+ break;
+ }
+ }
+ while (err>0);
+ fclose(fout);
+ if (err==0)
+ change_file_date(write_filename,file_info.dosDate,
+ file_info.tmu_date);
+ }
if (err==UNZ_OK)
{
- err = unzCloseCurrentFile (uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzCloseCurrentFile\n",err);
- }
+ err = unzCloseCurrentFile (uf);
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzCloseCurrentFile\n",err);
+ }
}
else
- unzCloseCurrentFile(uf); /* don't lose the error */
- }
+ unzCloseCurrentFile(uf); /* don't lose the error */
+ }
- free(buf);
+ free(buf);
return err;
}
int do_extract(uf,opt_extract_without_path,opt_overwrite)
- unzFile uf;
- int opt_extract_without_path;
+ unzFile uf;
+ int opt_extract_without_path;
int opt_overwrite;
{
- uLong i;
- unz_global_info gi;
- int err;
- FILE* fout=NULL;
+ uLong i;
+ unz_global_info gi;
+ int err;
+ FILE* fout=NULL;
- err = unzGetGlobalInfo (uf,&gi);
- if (err!=UNZ_OK)
- printf("error %d with zipfile in unzGetGlobalInfo \n",err);
+ err = unzGetGlobalInfo (uf,&gi);
+ if (err!=UNZ_OK)
+ printf("error %d with zipfile in unzGetGlobalInfo \n",err);
- for (i=0;i<gi.number_entry;i++)
- {
+ for (i=0;i<gi.number_entry;i++)
+ {
if (do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite) != UNZ_OK)
break;
- if ((i+1)<gi.number_entry)
- {
- err = unzGoToNextFile(uf);
- if (err!=UNZ_OK)
- {
- printf("error %d with zipfile in unzGoToNextFile\n",err);
- break;
- }
- }
- }
-
- return 0;
+ if ((i+1)<gi.number_entry)
+ {
+ err = unzGoToNextFile(uf);
+ if (err!=UNZ_OK)
+ {
+ printf("error %d with zipfile in unzGoToNextFile\n",err);
+ break;
+ }
+ }
+ }
+
+ return 0;
}
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite)
- unzFile uf;
- const char* filename;
- int opt_extract_without_path;
+ unzFile uf;
+ const char* filename;
+ int opt_extract_without_path;
int opt_overwrite;
{
int err = UNZ_OK;
@@ -422,87 +422,87 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite)
int main(argc,argv)
- int argc;
- char *argv[];
+ int argc;
+ char *argv[];
{
- const char *zipfilename=NULL;
+ const char *zipfilename=NULL;
const char *filename_to_extract=NULL;
- int i;
- int opt_do_list=0;
- int opt_do_extract=1;
- int opt_do_extract_withoutpath=0;
- int opt_overwrite=0;
- char filename_try[512];
- unzFile uf=NULL;
-
- do_banner();
- if (argc==1)
- {
- do_help();
- exit(0);
- }
- else
- {
- for (i=1;i<argc;i++)
- {
- if ((*argv[i])=='-')
- {
- const char *p=argv[i]+1;
-
- while ((*p)!='\0')
- {
- char c=*(p++);;
- if ((c=='l') || (c=='L'))
- opt_do_list = 1;
- if ((c=='v') || (c=='V'))
- opt_do_list = 1;
- if ((c=='x') || (c=='X'))
- opt_do_extract = 1;
- if ((c=='e') || (c=='E'))
- opt_do_extract = opt_do_extract_withoutpath = 1;
- if ((c=='o') || (c=='O'))
- opt_overwrite=1;
- }
- }
- else
+ int i;
+ int opt_do_list=0;
+ int opt_do_extract=1;
+ int opt_do_extract_withoutpath=0;
+ int opt_overwrite=0;
+ char filename_try[512];
+ unzFile uf=NULL;
+
+ do_banner();
+ if (argc==1)
+ {
+ do_help();
+ exit(0);
+ }
+ else
+ {
+ for (i=1;i<argc;i++)
+ {
+ if ((*argv[i])=='-')
+ {
+ const char *p=argv[i]+1;
+
+ while ((*p)!='\0')
+ {
+ char c=*(p++);;
+ if ((c=='l') || (c=='L'))
+ opt_do_list = 1;
+ if ((c=='v') || (c=='V'))
+ opt_do_list = 1;
+ if ((c=='x') || (c=='X'))
+ opt_do_extract = 1;
+ if ((c=='e') || (c=='E'))
+ opt_do_extract = opt_do_extract_withoutpath = 1;
+ if ((c=='o') || (c=='O'))
+ opt_overwrite=1;
+ }
+ }
+ else
{
- if (zipfilename == NULL)
- zipfilename = argv[i];
+ if (zipfilename == NULL)
+ zipfilename = argv[i];
else if (filename_to_extract==NULL)
filename_to_extract = argv[i] ;
}
- }
- }
-
- if (zipfilename!=NULL)
- {
- strcpy(filename_try,zipfilename);
- uf = unzOpen(zipfilename);
- if (uf==NULL)
- {
- strcat(filename_try,".zip");
- uf = unzOpen(filename_try);
- }
- }
-
- if (uf==NULL)
- {
- printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
- exit (1);
- }
+ }
+ }
+
+ if (zipfilename!=NULL)
+ {
+ strcpy(filename_try,zipfilename);
+ uf = unzOpen(zipfilename);
+ if (uf==NULL)
+ {
+ strcat(filename_try,".zip");
+ uf = unzOpen(filename_try);
+ }
+ }
+
+ if (uf==NULL)
+ {
+ printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
+ exit (1);
+ }
printf("%s opened\n",filename_try);
- if (opt_do_list==1)
- return do_list(uf);
- else if (opt_do_extract==1)
+ if (opt_do_list==1)
+ return do_list(uf);
+ else if (opt_do_extract==1)
{
if (filename_to_extract == NULL)
- return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite);
+ return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite);
else
return do_extract_onefile(uf,filename_to_extract,
opt_do_extract_withoutpath,opt_overwrite);
}
- unzCloseCurrentFile(uf);
+ unzCloseCurrentFile(uf);
- return 0; /* to avoid warning */
+ return 0; /* to avoid warning */
}
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c
index 2d32452a9ad..5e492d209b1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/minizip.c
@@ -55,7 +55,7 @@ uLong filetime(f, tmzip, dt)
struct stat s; /* results of stat() */
struct tm* filedate;
time_t tm_t=0;
-
+
if (strcmp(f,"-")!=0)
{
char name[MAXFILENAME];
@@ -98,10 +98,10 @@ uLong filetime(f, tmzip, dt)
int check_exist_file(filename)
const char* filename;
{
- FILE* ftestexist;
+ FILE* ftestexist;
int ret = 1;
- ftestexist = fopen(filename,"rb");
- if (ftestexist==NULL)
+ ftestexist = fopen(filename,"rb");
+ if (ftestexist==NULL)
ret = 0;
else
fclose(ftestexist);
@@ -110,59 +110,59 @@ int check_exist_file(filename)
void do_banner()
{
- printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n");
- printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
+ printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n");
+ printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n");
}
void do_help()
-{
- printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ;
+{
+ printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ;
}
int main(argc,argv)
- int argc;
- char *argv[];
+ int argc;
+ char *argv[];
{
- int i;
- int opt_overwrite=0;
+ int i;
+ int opt_overwrite=0;
int opt_compress_level=Z_DEFAULT_COMPRESSION;
int zipfilenamearg = 0;
- char filename_try[MAXFILENAME];
+ char filename_try[MAXFILENAME];
int zipok;
int err=0;
int size_buf=0;
void* buf=NULL,
- do_banner();
- if (argc==1)
- {
- do_help();
- exit(0);
+ do_banner();
+ if (argc==1)
+ {
+ do_help();
+ exit(0);
return 0;
- }
- else
- {
- for (i=1;i<argc;i++)
- {
- if ((*argv[i])=='-')
- {
- const char *p=argv[i]+1;
-
- while ((*p)!='\0')
- {
- char c=*(p++);;
- if ((c=='o') || (c=='O'))
- opt_overwrite = 1;
+ }
+ else
+ {
+ for (i=1;i<argc;i++)
+ {
+ if ((*argv[i])=='-')
+ {
+ const char *p=argv[i]+1;
+
+ while ((*p)!='\0')
+ {
+ char c=*(p++);;
+ if ((c=='o') || (c=='O'))
+ opt_overwrite = 1;
if ((c>='0') && (c<='9'))
opt_compress_level = c-'0';
- }
- }
- else
- if (zipfilenamearg == 0)
+ }
+ }
+ else
+ if (zipfilenamearg == 0)
zipfilenamearg = i ;
- }
- }
+ }
+ }
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
@@ -172,15 +172,15 @@ int main(argc,argv)
return ZIP_INTERNALERROR;
}
- if (zipfilenamearg==0)
+ if (zipfilenamearg==0)
zipok=0;
else
- {
+ {
int i,len;
int dot_found=0;
zipok = 1 ;
- strcpy(filename_try,argv[zipfilenamearg]);
+ strcpy(filename_try,argv[zipfilenamearg]);
len=strlen(filename_try);
for (i=0;i<len;i++)
if (filename_try[i]=='.')
@@ -191,21 +191,21 @@ int main(argc,argv)
if (opt_overwrite==0)
if (check_exist_file(filename_try)!=0)
- {
+ {
char rep;
- do
- {
- char answer[128];
- printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try);
- scanf("%1s",answer);
- rep = answer[0] ;
- if ((rep>='a') && (rep<='z'))
- rep -= 0x20;
- }
- while ((rep!='Y') && (rep!='N'));
+ do
+ {
+ char answer[128];
+ printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try);
+ scanf("%1s",answer);
+ rep = answer[0] ;
+ if ((rep>='a') && (rep<='z'))
+ rep -= 0x20;
+ }
+ while ((rep!='Y') && (rep!='N'));
if (rep=='N')
zipok = 0;
- }
+ }
}
if (zipok==1)
@@ -218,7 +218,7 @@ int main(argc,argv)
printf("error opening %s\n",filename_try);
err= ZIP_ERRNO;
}
- else
+ else
printf("creating %s\n",filename_try);
for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
@@ -230,7 +230,7 @@ int main(argc,argv)
const char* filenameinzip = argv[i];
zip_fileinfo zi;
- zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
+ zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
zi.tmz_date.tm_mday = zi.tmz_date.tm_min = zi.tmz_date.tm_year = 0;
zi.dosDate = 0;
zi.internal_fa = 0;
@@ -275,7 +275,7 @@ int main(argc,argv)
printf("error in writing %s in the zipfile\n",
filenameinzip);
}
-
+
}
} while ((err == ZIP_OK) && (size_read>0));
@@ -283,7 +283,7 @@ int main(argc,argv)
if (err<0)
err=ZIP_ERRNO;
else
- {
+ {
err = zipCloseFileInZip(zf);
if (err!=ZIP_OK)
printf("error in closing %s in the zipfile\n",
@@ -298,5 +298,5 @@ int main(argc,argv)
free(buf);
exit(0);
- return 0; /* to avoid warning */
+ return 0; /* to avoid warning */
}
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c
index e41da922fea..ff71a474da1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c
@@ -1,4 +1,4 @@
-/* unzip.c -- IO on .zip files using zlib
+/* unzip.c -- IO on .zip files using zlib
Version 0.15 beta, Mar 19th, 1998,
Read unzip.h for more info
@@ -83,23 +83,23 @@ typedef struct unz_file_info_internal_s
when reading and decompress it */
typedef struct
{
- char *read_buffer; /* internal buffer for compressed data */
- z_stream stream; /* zLib stream structure for inflate */
-
- uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
- uLong stream_initialised; /* flag set if stream structure is initialised*/
-
- uLong offset_local_extrafield;/* offset of the local extra field */
- uInt size_local_extrafield;/* size of the local extra field */
- uLong pos_local_extrafield; /* position in the local extra field in read*/
-
- uLong crc32; /* crc32 of all data uncompressed */
- uLong crc32_wait; /* crc32 we must obtain after decompress all */
- uLong rest_read_compressed; /* number of byte to be decompressed */
- uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
- FILE* file; /* io structore of the zipfile */
- uLong compression_method; /* compression method (0==store) */
- uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+ char *read_buffer; /* internal buffer for compressed data */
+ z_stream stream; /* zLib stream structure for inflate */
+
+ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
+ uLong stream_initialised; /* flag set if stream structure is initialised*/
+
+ uLong offset_local_extrafield;/* offset of the local extra field */
+ uInt size_local_extrafield;/* size of the local extra field */
+ uLong pos_local_extrafield; /* position in the local extra field in read*/
+
+ uLong crc32; /* crc32 of all data uncompressed */
+ uLong crc32_wait; /* crc32 we must obtain after decompress all */
+ uLong rest_read_compressed; /* number of byte to be decompressed */
+ uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
+ FILE* file; /* io structore of the zipfile */
+ uLong compression_method; /* compression method (0==store) */
+ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
} file_in_zip_read_info_s;
@@ -107,22 +107,22 @@ typedef struct
*/
typedef struct
{
- FILE* file; /* io structore of the zipfile */
- unz_global_info gi; /* public global information */
- uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
- uLong num_file; /* number of the current file in the zipfile*/
- uLong pos_in_central_dir; /* pos of the current file in the central dir*/
- uLong current_file_ok; /* flag about the usability of the current file*/
- uLong central_pos; /* position of the beginning of the central dir*/
-
- uLong size_central_dir; /* size of the central directory */
- uLong offset_central_dir; /* offset of start of central directory with
- respect to the starting disk number */
-
- unz_file_info cur_file_info; /* public info about the current file in zip*/
- unz_file_info_internal cur_file_info_internal; /* private info about it*/
+ FILE* file; /* io structore of the zipfile */
+ unz_global_info gi; /* public global information */
+ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+ uLong num_file; /* number of the current file in the zipfile*/
+ uLong pos_in_central_dir; /* pos of the current file in the central dir*/
+ uLong current_file_ok; /* flag about the usability of the current file*/
+ uLong central_pos; /* position of the beginning of the central dir*/
+
+ uLong size_central_dir; /* size of the central directory */
+ uLong offset_central_dir; /* offset of start of central directory with
+ respect to the starting disk number */
+
+ unz_file_info cur_file_info; /* public info about the current file in zip*/
+ unz_file_info_internal cur_file_info_internal; /* private info about it*/
file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
- file if we are decompressing it */
+ file if we are decompressing it */
} unz_s;
@@ -134,11 +134,11 @@ typedef struct
local int unzlocal_getByte(fin,pi)
- FILE *fin;
- int *pi;
+ FILE *fin;
+ int *pi;
{
unsigned char c;
- int err = fread(&c, 1, 1, fin);
+ int err = fread(&c, 1, 1, fin);
if (err==1)
{
*pi = (int)c;
@@ -146,7 +146,7 @@ local int unzlocal_getByte(fin,pi)
}
else
{
- if (ferror(fin))
+ if (ferror(fin))
return UNZ_ERRNO;
else
return UNZ_EOF;
@@ -155,10 +155,10 @@ local int unzlocal_getByte(fin,pi)
/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets
+ Reads a long in LSB order from the given gz_stream. Sets
*/
local int unzlocal_getShort (fin,pX)
- FILE* fin;
+ FILE* fin;
uLong *pX;
{
uLong x ;
@@ -167,11 +167,11 @@ local int unzlocal_getShort (fin,pX)
err = unzlocal_getByte(fin,&i);
x = (uLong)i;
-
+
if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8;
-
+
if (err==UNZ_OK)
*pX = x;
else
@@ -180,7 +180,7 @@ local int unzlocal_getShort (fin,pX)
}
local int unzlocal_getLong (fin,pX)
- FILE* fin;
+ FILE* fin;
uLong *pX;
{
uLong x ;
@@ -189,7 +189,7 @@ local int unzlocal_getLong (fin,pX)
err = unzlocal_getByte(fin,&i);
x = (uLong)i;
-
+
if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8;
@@ -201,7 +201,7 @@ local int unzlocal_getLong (fin,pX)
if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<24;
-
+
if (err==UNZ_OK)
*pX = x;
else
@@ -212,26 +212,26 @@ local int unzlocal_getLong (fin,pX)
/* My own strcmpi / strcasecmp */
local int strcmpcasenosensitive_internal (fileName1,fileName2)
- const char* fileName1;
- const char* fileName2;
+ const char* fileName1;
+ const char* fileName2;
{
- for (;;)
- {
- char c1=*(fileName1++);
- char c2=*(fileName2++);
- if ((c1>='a') && (c1<='z'))
- c1 -= 0x20;
- if ((c2>='a') && (c2<='z'))
- c2 -= 0x20;
- if (c1=='\0')
- return ((c2=='\0') ? 0 : -1);
- if (c2=='\0')
- return 1;
- if (c1<c2)
- return -1;
- if (c1>c2)
- return 1;
- }
+ for (;;)
+ {
+ char c1=*(fileName1++);
+ char c2=*(fileName2++);
+ if ((c1>='a') && (c1<='z'))
+ c1 -= 0x20;
+ if ((c2>='a') && (c2<='z'))
+ c2 -= 0x20;
+ if (c1=='\0')
+ return ((c2=='\0') ? 0 : -1);
+ if (c2=='\0')
+ return 1;
+ if (c1<c2)
+ return -1;
+ if (c1>c2)
+ return 1;
+ }
}
@@ -245,7 +245,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
#endif
-/*
+/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
@@ -255,18 +255,18 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
*/
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
- const char* fileName1;
- const char* fileName2;
- int iCaseSensitivity;
+ const char* fileName1;
+ const char* fileName2;
+ int iCaseSensitivity;
{
- if (iCaseSensitivity==0)
- iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
+ if (iCaseSensitivity==0)
+ iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
- if (iCaseSensitivity==1)
- return strcmp(fileName1,fileName2);
+ if (iCaseSensitivity==1)
+ return strcmp(fileName1,fileName2);
- return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
+ return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
+}
#define BUFREADCOMMENT (0x400)
@@ -275,161 +275,161 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit
the global comment)
*/
local uLong unzlocal_SearchCentralDir(fin)
- FILE *fin;
+ FILE *fin;
{
- unsigned char* buf;
- uLong uSizeFile;
- uLong uBackRead;
- uLong uMaxBack=0xffff; /* maximum size of global comment */
- uLong uPosFound=0;
-
- if (fseek(fin,0,SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ftell( fin );
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackRead<uMaxBack)
- {
- uLong uReadSize,uReadPos ;
- int i;
- if (uBackRead+BUFREADCOMMENT>uMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+ unsigned char* buf;
+ uLong uSizeFile;
+ uLong uBackRead;
+ uLong uMaxBack=0xffff; /* maximum size of global comment */
+ uLong uPosFound=0;
+
+ if (fseek(fin,0,SEEK_END) != 0)
+ return 0;
+
+
+ uSizeFile = ftell( fin );
+
+ if (uMaxBack>uSizeFile)
+ uMaxBack = uSizeFile;
+
+ buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+ if (buf==NULL)
+ return 0;
+
+ uBackRead = 4;
+ while (uBackRead<uMaxBack)
+ {
+ uLong uReadSize,uReadPos ;
+ int i;
+ if (uBackRead+BUFREADCOMMENT>uMaxBack)
+ uBackRead = uMaxBack;
+ else
+ uBackRead+=BUFREADCOMMENT;
+ uReadPos = uSizeFile-uBackRead ;
+
+ uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
- if (fseek(fin,uReadPos,SEEK_SET)!=0)
- break;
+ if (fseek(fin,uReadPos,SEEK_SET)!=0)
+ break;
- if (fread(buf,(uInt)uReadSize,1,fin)!=1)
- break;
+ if (fread(buf,(uInt)uReadSize,1,fin)!=1)
+ break;
for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- TRYFREE(buf);
- return uPosFound;
+ if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+ ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+ {
+ uPosFound = uReadPos+i;
+ break;
+ }
+
+ if (uPosFound!=0)
+ break;
+ }
+ TRYFREE(buf);
+ return uPosFound;
}
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
- "zlib/zlib109.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
+ "zlib/zlib109.zip".
+ If the zipfile cannot be opened (file don't exist or in not valid), the
+ return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
+ of this unzip package.
*/
extern unzFile ZEXPORT unzOpen (path)
- const char *path;
+ const char *path;
{
- unz_s us;
- unz_s *s;
- uLong central_pos,uL;
- FILE * fin ;
+ unz_s us;
+ unz_s *s;
+ uLong central_pos,uL;
+ FILE * fin ;
- uLong number_disk; /* number of the current dist, used for
- spaning ZIP, unsupported, always 0*/
- uLong number_disk_with_CD; /* number the the disk with central dir, used
- for spaning ZIP, unsupported, always 0*/
- uLong number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
+ uLong number_disk; /* number of the current dist, used for
+ spaning ZIP, unsupported, always 0*/
+ uLong number_disk_with_CD; /* number the the disk with central dir, used
+ for spaning ZIP, unsupported, always 0*/
+ uLong number_entry_CD; /* total number of entries in
+ the central dir
+ (same than number_entry on nospan) */
- int err=UNZ_OK;
+ int err=UNZ_OK;
if (unz_copyright[0]!=' ')
return NULL;
fin=fopen(path,"rb");
- if (fin==NULL)
- return NULL;
-
- central_pos = unzlocal_SearchCentralDir(fin);
- if (central_pos==0)
- err=UNZ_ERRNO;
-
- if (fseek(fin,central_pos,SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
- /* the signature, already checked */
- if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of this disk */
- if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir on this disk */
- if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir */
- if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((number_entry_CD!=us.gi.number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=UNZ_BADZIPFILE;
-
- /* size of the central directory */
- if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* zipfile comment length */
- if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
- (err==UNZ_OK))
- err=UNZ_BADZIPFILE;
-
- if (err!=UNZ_OK)
- {
- fclose(fin);
- return NULL;
- }
-
- us.file=fin;
- us.byte_before_the_zipfile = central_pos -
- (us.offset_central_dir+us.size_central_dir);
- us.central_pos = central_pos;
+ if (fin==NULL)
+ return NULL;
+
+ central_pos = unzlocal_SearchCentralDir(fin);
+ if (central_pos==0)
+ err=UNZ_ERRNO;
+
+ if (fseek(fin,central_pos,SEEK_SET)!=0)
+ err=UNZ_ERRNO;
+
+ /* the signature, already checked */
+ if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* number of this disk */
+ if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* number of the disk with the start of the central directory */
+ if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* total number of entries in the central dir on this disk */
+ if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* total number of entries in the central dir */
+ if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if ((number_entry_CD!=us.gi.number_entry) ||
+ (number_disk_with_CD!=0) ||
+ (number_disk!=0))
+ err=UNZ_BADZIPFILE;
+
+ /* size of the central directory */
+ if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* offset of start of central directory with respect to the
+ starting disk number */
+ if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* zipfile comment length */
+ if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
+ (err==UNZ_OK))
+ err=UNZ_BADZIPFILE;
+
+ if (err!=UNZ_OK)
+ {
+ fclose(fin);
+ return NULL;
+ }
+
+ us.file=fin;
+ us.byte_before_the_zipfile = central_pos -
+ (us.offset_central_dir+us.size_central_dir);
+ us.central_pos = central_pos;
us.pfile_in_zip_read = NULL;
+
-
- s=(unz_s*)ALLOC(sizeof(unz_s));
- *s=us;
- unzGoToFirstFile((unzFile)s);
- return (unzFile)s;
+ s=(unz_s*)ALLOC(sizeof(unz_s));
+ *s=us;
+ unzGoToFirstFile((unzFile)s);
+ return (unzFile)s;
}
@@ -439,19 +439,19 @@ extern unzFile ZEXPORT unzOpen (path)
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzClose (file)
- unzFile file;
+ unzFile file;
{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
- fclose(s->file);
- TRYFREE(s);
- return UNZ_OK;
+ fclose(s->file);
+ TRYFREE(s);
+ return UNZ_OK;
}
@@ -460,15 +460,15 @@ extern int ZEXPORT unzClose (file)
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
- unzFile file;
- unz_global_info *pglobal_info;
+ unzFile file;
+ unz_global_info *pglobal_info;
{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- *pglobal_info=s->gi;
- return UNZ_OK;
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ *pglobal_info=s->gi;
+ return UNZ_OK;
}
@@ -495,14 +495,14 @@ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
*/
local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
unz_file_info *pfile_info,
- unz_file_info_internal
+ unz_file_info_internal
*pfile_info_internal,
char *szFileName,
- uLong fileNameBufferSize,
+ uLong fileNameBufferSize,
void *extraField,
- uLong extraFieldBufferSize,
+ uLong extraFieldBufferSize,
char *szComment,
- uLong commentBufferSize));
+ uLong commentBufferSize));
local int unzlocal_GetCurrentFileInfoInternal (file,
pfile_info,
@@ -510,156 +510,156 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
szFileName, fileNameBufferSize,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
- unzFile file;
- unz_file_info *pfile_info;
- unz_file_info_internal *pfile_info_internal;
- char *szFileName;
- uLong fileNameBufferSize;
- void *extraField;
- uLong extraFieldBufferSize;
- char *szComment;
- uLong commentBufferSize;
+ unzFile file;
+ unz_file_info *pfile_info;
+ unz_file_info_internal *pfile_info_internal;
+ char *szFileName;
+ uLong fileNameBufferSize;
+ void *extraField;
+ uLong extraFieldBufferSize;
+ char *szComment;
+ uLong commentBufferSize;
{
- unz_s* s;
- unz_file_info file_info;
- unz_file_info_internal file_info_internal;
- int err=UNZ_OK;
- uLong uMagic;
- long lSeek=0;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
-
- /* we check the magic */
- if (err==UNZ_OK)
- if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x02014b50)
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
- err=UNZ_ERRNO;
-
- unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
- if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
- err=UNZ_ERRNO;
+ unz_s* s;
+ unz_file_info file_info;
+ unz_file_info_internal file_info_internal;
+ int err=UNZ_OK;
+ uLong uMagic;
+ long lSeek=0;
- if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
+ err=UNZ_ERRNO;
- if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
- if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
+ /* we check the magic */
+ if (err==UNZ_OK)
+ if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if (uMagic!=0x02014b50)
+ err=UNZ_BADZIPFILE;
- if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
+ err=UNZ_ERRNO;
- if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
+ err=UNZ_ERRNO;
- if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
+ err=UNZ_ERRNO;
- if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
- err=UNZ_ERRNO;
-
- lSeek+=file_info.size_filename;
- if ((err==UNZ_OK) && (szFileName!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_filename<fileNameBufferSize)
- {
- *(szFileName+file_info.size_filename)='\0';
- uSizeRead = file_info.size_filename;
- }
- else
- uSizeRead = fileNameBufferSize;
-
- if ((file_info.size_filename>0) && (fileNameBufferSize>0))
- if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek -= uSizeRead;
- }
-
-
- if ((err==UNZ_OK) && (extraField!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_extra<extraFieldBufferSize)
- uSizeRead = file_info.size_file_extra;
- else
- uSizeRead = extraFieldBufferSize;
-
- if (lSeek!=0)
- if (fseek(s->file,lSeek,SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
- if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek += file_info.size_file_extra - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_extra;
-
-
- if ((err==UNZ_OK) && (szComment!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_comment<commentBufferSize)
- {
- *(szComment+file_info.size_file_comment)='\0';
- uSizeRead = file_info.size_file_comment;
- }
- else
- uSizeRead = commentBufferSize;
-
- if (lSeek!=0)
- if (fseek(s->file,lSeek,SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- if ((file_info.size_file_comment>0) && (commentBufferSize>0))
- if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek+=file_info.size_file_comment - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_comment;
+ if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
+ err=UNZ_ERRNO;
- if ((err==UNZ_OK) && (pfile_info!=NULL))
- *pfile_info=file_info;
+ if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
+ err=UNZ_ERRNO;
- if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
- *pfile_info_internal=file_info_internal;
+ unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
- return err;
+ if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ lSeek+=file_info.size_filename;
+ if ((err==UNZ_OK) && (szFileName!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_filename<fileNameBufferSize)
+ {
+ *(szFileName+file_info.size_filename)='\0';
+ uSizeRead = file_info.size_filename;
+ }
+ else
+ uSizeRead = fileNameBufferSize;
+
+ if ((file_info.size_filename>0) && (fileNameBufferSize>0))
+ if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
+ err=UNZ_ERRNO;
+ lSeek -= uSizeRead;
+ }
+
+
+ if ((err==UNZ_OK) && (extraField!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_file_extra<extraFieldBufferSize)
+ uSizeRead = file_info.size_file_extra;
+ else
+ uSizeRead = extraFieldBufferSize;
+
+ if (lSeek!=0)
+ if (fseek(s->file,lSeek,SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+ if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
+ err=UNZ_ERRNO;
+ lSeek += file_info.size_file_extra - uSizeRead;
+ }
+ else
+ lSeek+=file_info.size_file_extra;
+
+
+ if ((err==UNZ_OK) && (szComment!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_file_comment<commentBufferSize)
+ {
+ *(szComment+file_info.size_file_comment)='\0';
+ uSizeRead = file_info.size_file_comment;
+ }
+ else
+ uSizeRead = commentBufferSize;
+
+ if (lSeek!=0)
+ if (fseek(s->file,lSeek,SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+ if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
+ err=UNZ_ERRNO;
+ lSeek+=file_info.size_file_comment - uSizeRead;
+ }
+ else
+ lSeek+=file_info.size_file_comment;
+
+ if ((err==UNZ_OK) && (pfile_info!=NULL))
+ *pfile_info=file_info;
+
+ if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
+ *pfile_info_internal=file_info_internal;
+
+ return err;
}
@@ -674,19 +674,19 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
szFileName, fileNameBufferSize,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
- unzFile file;
- unz_file_info *pfile_info;
- char *szFileName;
- uLong fileNameBufferSize;
- void *extraField;
- uLong extraFieldBufferSize;
- char *szComment;
- uLong commentBufferSize;
+ unzFile file;
+ unz_file_info *pfile_info;
+ char *szFileName;
+ uLong fileNameBufferSize;
+ void *extraField;
+ uLong extraFieldBufferSize;
+ char *szComment;
+ uLong commentBufferSize;
{
- return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
- szFileName,fileNameBufferSize,
- extraField,extraFieldBufferSize,
- szComment,commentBufferSize);
+ return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
+ szFileName,fileNameBufferSize,
+ extraField,extraFieldBufferSize,
+ szComment,commentBufferSize);
}
/*
@@ -694,20 +694,20 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToFirstFile (file)
- unzFile file;
+ unzFile file;
{
- int err=UNZ_OK;
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- s->pos_in_central_dir=s->offset_central_dir;
- s->num_file=0;
- err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
+ int err=UNZ_OK;
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ s->pos_in_central_dir=s->offset_central_dir;
+ s->num_file=0;
+ err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
}
@@ -717,27 +717,27 @@ extern int ZEXPORT unzGoToFirstFile (file)
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzGoToNextFile (file)
- unzFile file;
+ unzFile file;
{
- unz_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
- if (s->num_file+1==s->gi.number_entry)
- return UNZ_END_OF_LIST_OF_FILE;
-
- s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
- s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
- s->num_file++;
- err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
+ unz_s* s;
+ int err;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_END_OF_LIST_OF_FILE;
+ if (s->num_file+1==s->gi.number_entry)
+ return UNZ_END_OF_LIST_OF_FILE;
+
+ s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
+ s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
+ s->num_file++;
+ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
}
@@ -750,48 +750,48 @@ extern int ZEXPORT unzGoToNextFile (file)
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
- unzFile file;
- const char *szFileName;
- int iCaseSensitivity;
+ unzFile file;
+ const char *szFileName;
+ int iCaseSensitivity;
{
- unz_s* s;
- int err;
+ unz_s* s;
+ int err;
+
+ uLong num_fileSaved;
+ uLong pos_in_central_dirSaved;
- uLong num_fileSaved;
- uLong pos_in_central_dirSaved;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- num_fileSaved = s->num_file;
- pos_in_central_dirSaved = s->pos_in_central_dir;
-
- err = unzGoToFirstFile(file);
-
- while (err == UNZ_OK)
- {
- char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
- unzGetCurrentFileInfo(file,NULL,
- szCurrentFileName,sizeof(szCurrentFileName)-1,
- NULL,0,NULL,0);
- if (unzStringFileNameCompare(szCurrentFileName,
- szFileName,iCaseSensitivity)==0)
- return UNZ_OK;
- err = unzGoToNextFile(file);
- }
-
- s->num_file = num_fileSaved ;
- s->pos_in_central_dir = pos_in_central_dirSaved ;
- return err;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_END_OF_LIST_OF_FILE;
+
+ num_fileSaved = s->num_file;
+ pos_in_central_dirSaved = s->pos_in_central_dir;
+
+ err = unzGoToFirstFile(file);
+
+ while (err == UNZ_OK)
+ {
+ char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
+ unzGetCurrentFileInfo(file,NULL,
+ szCurrentFileName,sizeof(szCurrentFileName)-1,
+ NULL,0,NULL,0);
+ if (unzStringFileNameCompare(szCurrentFileName,
+ szFileName,iCaseSensitivity)==0)
+ return UNZ_OK;
+ err = unzGoToNextFile(file);
+ }
+
+ s->num_file = num_fileSaved ;
+ s->pos_in_central_dir = pos_in_central_dirSaved ;
+ return err;
}
@@ -803,182 +803,182 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
(filename and size of extra field data)
*/
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
- poffset_local_extrafield,
- psize_local_extrafield)
- unz_s* s;
- uInt* piSizeVar;
- uLong *poffset_local_extrafield;
- uInt *psize_local_extrafield;
+ poffset_local_extrafield,
+ psize_local_extrafield)
+ unz_s* s;
+ uInt* piSizeVar;
+ uLong *poffset_local_extrafield;
+ uInt *psize_local_extrafield;
{
- uLong uMagic,uData,uFlags;
- uLong size_filename;
- uLong size_extra_field;
- int err=UNZ_OK;
+ uLong uMagic,uData,uFlags;
+ uLong size_filename;
+ uLong size_extra_field;
+ int err=UNZ_OK;
- *piSizeVar = 0;
- *poffset_local_extrafield = 0;
- *psize_local_extrafield = 0;
+ *piSizeVar = 0;
+ *poffset_local_extrafield = 0;
+ *psize_local_extrafield = 0;
- if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
- s->byte_before_the_zipfile,SEEK_SET)!=0)
- return UNZ_ERRNO;
+ if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
+ s->byte_before_the_zipfile,SEEK_SET)!=0)
+ return UNZ_ERRNO;
- if (err==UNZ_OK)
- if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x04034b50)
- err=UNZ_BADZIPFILE;
+ if (err==UNZ_OK)
+ if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if (uMagic!=0x04034b50)
+ err=UNZ_BADZIPFILE;
- if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
+ err=UNZ_ERRNO;
/*
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
- err=UNZ_BADZIPFILE;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
+ err=UNZ_BADZIPFILE;
*/
- if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
- err=UNZ_ERRNO;
+ if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
+ err=UNZ_ERRNO;
- if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
- err=UNZ_BADZIPFILE;
+ if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
+ err=UNZ_BADZIPFILE;
if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
- err=UNZ_ERRNO;
+ if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
+ err=UNZ_ERRNO;
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
+ if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
+ if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
+ if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
- if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
- err=UNZ_BADZIPFILE;
+ if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
+ err=UNZ_BADZIPFILE;
- *piSizeVar += (uInt)size_filename;
+ *piSizeVar += (uInt)size_filename;
- if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
- err=UNZ_ERRNO;
- *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
- SIZEZIPLOCALHEADER + size_filename;
- *psize_local_extrafield = (uInt)size_extra_field;
+ if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
+ err=UNZ_ERRNO;
+ *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
+ SIZEZIPLOCALHEADER + size_filename;
+ *psize_local_extrafield = (uInt)size_extra_field;
- *piSizeVar += (uInt)size_extra_field;
+ *piSizeVar += (uInt)size_extra_field;
- return err;
+ return err;
}
-
+
/*
Open for reading data the current file in the zipfile.
If there is no error and the file is opened, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFile (file)
- unzFile file;
+ unzFile file;
{
- int err=UNZ_OK;
- int Store;
- uInt iSizeVar;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uLong offset_local_extrafield; /* offset of the local extra field */
- uInt size_local_extrafield; /* size of the local extra field */
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_PARAMERROR;
+ int err=UNZ_OK;
+ int Store;
+ uInt iSizeVar;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ uLong offset_local_extrafield; /* offset of the local extra field */
+ uInt size_local_extrafield; /* size of the local extra field */
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_PARAMERROR;
if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);
- if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
- &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
- return UNZ_BADZIPFILE;
-
- pfile_in_zip_read_info = (file_in_zip_read_info_s*)
- ALLOC(sizeof(file_in_zip_read_info_s));
- if (pfile_in_zip_read_info==NULL)
- return UNZ_INTERNALERROR;
-
- pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
- pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
- pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
- pfile_in_zip_read_info->pos_local_extrafield=0;
-
- if (pfile_in_zip_read_info->read_buffer==NULL)
- {
- TRYFREE(pfile_in_zip_read_info);
- return UNZ_INTERNALERROR;
- }
-
- pfile_in_zip_read_info->stream_initialised=0;
-
- if ((s->cur_file_info.compression_method!=0) &&
+ if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
+ &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
+ return UNZ_BADZIPFILE;
+
+ pfile_in_zip_read_info = (file_in_zip_read_info_s*)
+ ALLOC(sizeof(file_in_zip_read_info_s));
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_INTERNALERROR;
+
+ pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
+ pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
+ pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
+ pfile_in_zip_read_info->pos_local_extrafield=0;
+
+ if (pfile_in_zip_read_info->read_buffer==NULL)
+ {
+ TRYFREE(pfile_in_zip_read_info);
+ return UNZ_INTERNALERROR;
+ }
+
+ pfile_in_zip_read_info->stream_initialised=0;
+
+ if ((s->cur_file_info.compression_method!=0) &&
(s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
- Store = s->cur_file_info.compression_method==0;
+ err=UNZ_BADZIPFILE;
+ Store = s->cur_file_info.compression_method==0;
- pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
- pfile_in_zip_read_info->crc32=0;
- pfile_in_zip_read_info->compression_method =
+ pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
+ pfile_in_zip_read_info->crc32=0;
+ pfile_in_zip_read_info->compression_method =
s->cur_file_info.compression_method;
- pfile_in_zip_read_info->file=s->file;
- pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
+ pfile_in_zip_read_info->file=s->file;
+ pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
pfile_in_zip_read_info->stream.total_out = 0;
- if (!Store)
- {
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
- pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-
- err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
- if (err == Z_OK)
- pfile_in_zip_read_info->stream_initialised=1;
+ if (!Store)
+ {
+ pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+ pfile_in_zip_read_info->stream.zfree = (free_func)0;
+ pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+
+ err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
+ if (err == Z_OK)
+ pfile_in_zip_read_info->stream_initialised=1;
/* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte
* after the compressed stream in order to complete decompression and
- * return Z_STREAM_END.
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+ * return Z_STREAM_END.
+ * In unzip, i don't wait absolutely Z_STREAM_END because I known the
* size of both compressed and uncompressed data
*/
- }
- pfile_in_zip_read_info->rest_read_compressed =
+ }
+ pfile_in_zip_read_info->rest_read_compressed =
s->cur_file_info.compressed_size ;
- pfile_in_zip_read_info->rest_read_uncompressed =
+ pfile_in_zip_read_info->rest_read_uncompressed =
s->cur_file_info.uncompressed_size ;
+
+ pfile_in_zip_read_info->pos_in_zipfile =
+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+ iSizeVar;
+
+ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- iSizeVar;
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
- s->pfile_in_zip_read = pfile_in_zip_read_info;
+ s->pfile_in_zip_read = pfile_in_zip_read_info;
return UNZ_OK;
}
@@ -994,126 +994,126 @@ extern int ZEXPORT unzOpenCurrentFile (file)
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
- unzFile file;
- voidp buf;
- unsigned len;
+ unzFile file;
+ voidp buf;
+ unsigned len;
{
- int err=UNZ_OK;
- uInt iRead = 0;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ int err=UNZ_OK;
+ uInt iRead = 0;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
- if ((pfile_in_zip_read_info->read_buffer == NULL))
- return UNZ_END_OF_LIST_OF_FILE;
- if (len==0)
- return 0;
- pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
+ if ((pfile_in_zip_read_info->read_buffer == NULL))
+ return UNZ_END_OF_LIST_OF_FILE;
+ if (len==0)
+ return 0;
- pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+ pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
- if (len>pfile_in_zip_read_info->rest_read_uncompressed)
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+ pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+ if (len>pfile_in_zip_read_info->rest_read_uncompressed)
+ pfile_in_zip_read_info->stream.avail_out =
+ (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
- while (pfile_in_zip_read_info->stream.avail_out>0)
- {
- if ((pfile_in_zip_read_info->stream.avail_in==0) &&
+ while (pfile_in_zip_read_info->stream.avail_out>0)
+ {
+ if ((pfile_in_zip_read_info->stream.avail_in==0) &&
(pfile_in_zip_read_info->rest_read_compressed>0))
- {
- uInt uReadThis = UNZ_BUFSIZE;
- if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
- uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
- if (uReadThis == 0)
- return UNZ_EOF;
- if (fseek(pfile_in_zip_read_info->file,
- pfile_in_zip_read_info->pos_in_zipfile +
+ {
+ uInt uReadThis = UNZ_BUFSIZE;
+ if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+ uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
+ if (uReadThis == 0)
+ return UNZ_EOF;
+ if (fseek(pfile_in_zip_read_info->file,
+ pfile_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
- return UNZ_ERRNO;
- if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
+ return UNZ_ERRNO;
+ if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
pfile_in_zip_read_info->file)!=1)
- return UNZ_ERRNO;
- pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
- pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+ return UNZ_ERRNO;
+ pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
- pfile_in_zip_read_info->stream.next_in =
+ pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+
+ pfile_in_zip_read_info->stream.next_in =
(Bytef*)pfile_in_zip_read_info->read_buffer;
- pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
- }
+ pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
+ }
- if (pfile_in_zip_read_info->compression_method==0)
- {
- uInt uDoCopy,i ;
- if (pfile_in_zip_read_info->stream.avail_out <
+ if (pfile_in_zip_read_info->compression_method==0)
+ {
+ uInt uDoCopy,i ;
+ if (pfile_in_zip_read_info->stream.avail_out <
pfile_in_zip_read_info->stream.avail_in)
- uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
- else
- uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
- for (i=0;i<uDoCopy;i++)
- *(pfile_in_zip_read_info->stream.next_out+i) =
+ uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
+ else
+ uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
+
+ for (i=0;i<uDoCopy;i++)
+ *(pfile_in_zip_read_info->stream.next_out+i) =
*(pfile_in_zip_read_info->stream.next_in+i);
-
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
- pfile_in_zip_read_info->stream.next_out,
- uDoCopy);
- pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
- pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
- pfile_in_zip_read_info->stream.next_out += uDoCopy;
- pfile_in_zip_read_info->stream.next_in += uDoCopy;
+
+ pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
+ pfile_in_zip_read_info->stream.next_out,
+ uDoCopy);
+ pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
+ pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+ pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+ pfile_in_zip_read_info->stream.next_out += uDoCopy;
+ pfile_in_zip_read_info->stream.next_in += uDoCopy;
pfile_in_zip_read_info->stream.total_out += uDoCopy;
- iRead += uDoCopy;
- }
- else
- {
- uLong uTotalOutBefore,uTotalOutAfter;
- const Bytef *bufBefore;
- uLong uOutThis;
- int flush=Z_SYNC_FLUSH;
-
- uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
- bufBefore = pfile_in_zip_read_info->stream.next_out;
-
- /*
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
- pfile_in_zip_read_info->stream.avail_out) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- flush = Z_FINISH;
- */
- err=inflate(&pfile_in_zip_read_info->stream,flush);
-
- uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->crc32 =
+ iRead += uDoCopy;
+ }
+ else
+ {
+ uLong uTotalOutBefore,uTotalOutAfter;
+ const Bytef *bufBefore;
+ uLong uOutThis;
+ int flush=Z_SYNC_FLUSH;
+
+ uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+ bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+ /*
+ if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+ pfile_in_zip_read_info->stream.avail_out) &&
+ (pfile_in_zip_read_info->rest_read_compressed == 0))
+ flush = Z_FINISH;
+ */
+ err=inflate(&pfile_in_zip_read_info->stream,flush);
+
+ uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+ uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+ pfile_in_zip_read_info->crc32 =
crc32(pfile_in_zip_read_info->crc32,bufBefore,
(uInt)(uOutThis));
- pfile_in_zip_read_info->rest_read_uncompressed -=
+ pfile_in_zip_read_info->rest_read_uncompressed -=
uOutThis;
- iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
- if (err==Z_STREAM_END)
- return (iRead==0) ? UNZ_EOF : iRead;
- if (err!=Z_OK)
- break;
- }
- }
-
- if (err==Z_OK)
- return iRead;
- return err;
+ iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+ if (err==Z_STREAM_END)
+ return (iRead==0) ? UNZ_EOF : iRead;
+ if (err!=Z_OK)
+ break;
+ }
+ }
+
+ if (err==Z_OK)
+ return iRead;
+ return err;
}
@@ -1121,42 +1121,42 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
Give the current position in uncompressed data
*/
extern z_off_t ZEXPORT unztell (file)
- unzFile file;
+ unzFile file;
{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
- return (z_off_t)pfile_in_zip_read_info->stream.total_out;
+ return (z_off_t)pfile_in_zip_read_info->stream.total_out;
}
/*
- return 1 if the end of file was reached, 0 elsewhere
+ return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzeof (file)
- unzFile file;
+ unzFile file;
{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- return 1;
- else
- return 0;
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+ if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+ return 1;
+ else
+ return 0;
}
@@ -1169,51 +1169,51 @@ extern int ZEXPORT unzeof (file)
if buf==NULL, it return the size of the local extra field that can be read
if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
+ buf.
+ the return value is the number of bytes copied in buf, or (if <0)
+ the error code
*/
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
- unzFile file;
- voidp buf;
- unsigned len;
+ unzFile file;
+ voidp buf;
+ unsigned len;
{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uInt read_now;
- uLong size_to_read;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ uInt read_now;
+ uLong size_to_read;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
- pfile_in_zip_read_info->pos_local_extrafield);
-
- if (buf==NULL)
- return (int)size_to_read;
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
- if (len>size_to_read)
- read_now = (uInt)size_to_read;
- else
- read_now = (uInt)len ;
+ size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
+ pfile_in_zip_read_info->pos_local_extrafield);
- if (read_now==0)
- return 0;
+ if (buf==NULL)
+ return (int)size_to_read;
+
+ if (len>size_to_read)
+ read_now = (uInt)size_to_read;
+ else
+ read_now = (uInt)len ;
- if (fseek(pfile_in_zip_read_info->file,
- pfile_in_zip_read_info->offset_local_extrafield +
- pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
- return UNZ_ERRNO;
+ if (read_now==0)
+ return 0;
+
+ if (fseek(pfile_in_zip_read_info->file,
+ pfile_in_zip_read_info->offset_local_extrafield +
+ pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
+ return UNZ_ERRNO;
- if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
- return UNZ_ERRNO;
+ if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
+ return UNZ_ERRNO;
- return (int)read_now;
+ return (int)read_now;
}
/*
@@ -1221,39 +1221,39 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzCloseCurrentFile (file)
- unzFile file;
+ unzFile file;
{
- int err=UNZ_OK;
+ int err=UNZ_OK;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- {
- if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
- err=UNZ_CRCERROR;
- }
+ if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+ {
+ if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
+ err=UNZ_CRCERROR;
+ }
- TRYFREE(pfile_in_zip_read_info->read_buffer);
- pfile_in_zip_read_info->read_buffer = NULL;
- if (pfile_in_zip_read_info->stream_initialised)
- inflateEnd(&pfile_in_zip_read_info->stream);
+ TRYFREE(pfile_in_zip_read_info->read_buffer);
+ pfile_in_zip_read_info->read_buffer = NULL;
+ if (pfile_in_zip_read_info->stream_initialised)
+ inflateEnd(&pfile_in_zip_read_info->stream);
- pfile_in_zip_read_info->stream_initialised = 0;
- TRYFREE(pfile_in_zip_read_info);
+ pfile_in_zip_read_info->stream_initialised = 0;
+ TRYFREE(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL;
- return err;
+ return err;
}
@@ -1263,32 +1263,32 @@ extern int ZEXPORT unzCloseCurrentFile (file)
return the number of byte copied or an error code <0
*/
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
- unzFile file;
- char *szComment;
- uLong uSizeBuf;
+ unzFile file;
+ char *szComment;
+ uLong uSizeBuf;
{
- int err=UNZ_OK;
- unz_s* s;
- uLong uReadThis ;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
+ int err=UNZ_OK;
+ unz_s* s;
+ uLong uReadThis ;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
- uReadThis = uSizeBuf;
- if (uReadThis>s->gi.size_comment)
- uReadThis = s->gi.size_comment;
+ uReadThis = uSizeBuf;
+ if (uReadThis>s->gi.size_comment)
+ uReadThis = s->gi.size_comment;
- if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
- return UNZ_ERRNO;
+ if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
+ return UNZ_ERRNO;
- if (uReadThis>0)
+ if (uReadThis>0)
{
*szComment='\0';
- if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
- return UNZ_ERRNO;
+ if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
+ return UNZ_ERRNO;
}
- if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
- *(szComment+s->gi.size_comment)='\0';
- return (int)uReadThis;
+ if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
+ *(szComment+s->gi.size_comment)='\0';
+ return (int)uReadThis;
}
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h
index 44bd2b493c1..76692cb703c 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h
@@ -1,4 +1,4 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
+/* unzip.h -- IO for uncompress .zip files using zlib
Version 0.15 beta, Mar 19th, 1998,
Copyright (C) 1998 Gilles Vollant
@@ -33,7 +33,7 @@
*/
-/* for more info about .ZIP format, see
+/* for more info about .ZIP format, see
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip */
@@ -52,7 +52,7 @@ extern "C" {
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
@@ -69,23 +69,23 @@ typedef voidp unzFile;
#define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */
-typedef struct tm_unz_s
+typedef struct tm_unz_s
{
- uInt tm_sec; /* seconds after the minute - [0,59] */
- uInt tm_min; /* minutes after the hour - [0,59] */
- uInt tm_hour; /* hours since midnight - [0,23] */
- uInt tm_mday; /* day of the month - [1,31] */
- uInt tm_mon; /* months since January - [0,11] */
- uInt tm_year; /* years - [1980..2044] */
+ uInt tm_sec; /* seconds after the minute - [0,59] */
+ uInt tm_min; /* minutes after the hour - [0,59] */
+ uInt tm_hour; /* hours since midnight - [0,23] */
+ uInt tm_mday; /* day of the month - [1,31] */
+ uInt tm_mon; /* months since January - [0,11] */
+ uInt tm_year; /* years - [1980..2044] */
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info_s
{
- uLong number_entry; /* total number of entries in
- the central dir on this disk */
- uLong size_comment; /* size of the global comment of the zipfile */
+ uLong number_entry; /* total number of entries in
+ the central dir on this disk */
+ uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
@@ -98,8 +98,8 @@ typedef struct unz_file_info_s
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
- uLong compressed_size; /* compressed size 4 bytes */
- uLong uncompressed_size; /* uncompressed size 4 bytes */
+ uLong compressed_size; /* compressed size 4 bytes */
+ uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
@@ -112,15 +112,15 @@ typedef struct unz_file_info_s
} unz_file_info;
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
- const char* fileName2,
- int iCaseSensitivity));
+ const char* fileName2,
+ int iCaseSensitivity));
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
- or strcasecmp)
+ or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
- (like 1 on Unix, 2 on Windows)
+ (like 1 on Unix, 2 on Windows)
*/
@@ -128,11 +128,11 @@ extern unzFile ZEXPORT unzOpen OF((const char *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
- "zlib/zlib111.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
+ "zlib/zlib111.zip".
+ If the zipfile cannot be opened (file don't exist or in not valid), the
+ return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
+ of this unzip package.
*/
extern int ZEXPORT unzClose OF((unzFile file));
@@ -143,7 +143,7 @@ extern int ZEXPORT unzClose OF((unzFile file));
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
- unz_global_info *pglobal_info));
+ unz_global_info *pglobal_info));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
@@ -151,8 +151,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
- char *szComment,
- uLong uSizeBuf));
+ char *szComment,
+ uLong uSizeBuf));
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
@@ -176,9 +176,9 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file));
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
-extern int ZEXPORT unzLocateFile OF((unzFile file,
- const char *szFileName,
- int iCaseSensitivity));
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+ const char *szFileName,
+ int iCaseSensitivity));
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -190,24 +190,24 @@ extern int ZEXPORT unzLocateFile OF((unzFile file,
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
- unz_file_info *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
+ unz_file_info *pfile_info,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize));
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
- the current file
+ the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
- (fileNameBufferSize is the size of the buffer)
+ (fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
- (extraFieldBufferSize is the size of the buffer).
- This is the Central-header version of the extra field
+ (extraFieldBufferSize is the size of the buffer).
+ This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
- (commentBufferSize is the size of the buffer)
+ (commentBufferSize is the size of the buffer)
*/
/***************************************************************************/
@@ -227,10 +227,10 @@ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
-
-extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
- voidp buf,
- unsigned len));
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+ voidp buf,
+ unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
@@ -249,12 +249,12 @@ extern z_off_t ZEXPORT unztell OF((unzFile file));
extern int ZEXPORT unzeof OF((unzFile file));
/*
- return 1 if the end of file was reached, 0 elsewhere
+ return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
- voidp buf,
- unsigned len));
+ voidp buf,
+ unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
@@ -263,9 +263,9 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
if buf==NULL, it return the size of the local extra field
if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
+ buf.
+ the return value is the number of bytes copied in buf, or (if <0)
+ the error code
*/
#ifdef __cplusplus
@@ -273,4 +273,3 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
#endif
#endif /* _unz_H */
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c
index 25abe71f88c..0cae64ab7b1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c
@@ -1,4 +1,4 @@
-/* zip.c -- IO on .zip files using zlib
+/* zip.c -- IO on .zip files using zlib
Version 0.15 beta, Mar 19th, 1998,
Read zip.h for more info
@@ -99,11 +99,11 @@ typedef struct linkedlist_data_s
typedef struct
{
- z_stream stream; /* zLib stream structure for inflate */
+ z_stream stream; /* zLib stream structure for inflate */
int stream_initialised; /* 1 is stream is initialised */
uInt pos_in_buffered_data; /* last written byte in buffered_data */
- uLong pos_local_header; /* offset of the local header of the file
+ uLong pos_local_header; /* offset of the local header of the file
currenty writing */
char* central_header; /* central header data for the current file */
uLong size_centralheader; /* size of the central header for cur file */
@@ -166,7 +166,7 @@ local void free_linkedlist(ll)
local int add_data_in_datablock(ll,buf,len)
- linkedlist_data* ll;
+ linkedlist_data* ll;
const void* buf;
uLong len;
{
@@ -222,7 +222,7 @@ local int add_data_in_datablock(ll,buf,len)
local int write_datablock(fout,ll)
FILE * fout;
- linkedlist_data* ll;
+ linkedlist_data* ll;
{
linkedlist_datablock_internal* ldi;
ldi = ll->first_block;
@@ -322,7 +322,7 @@ extern zipFile ZEXPORT zipOpen (pathname, append)
return (zipFile)zi;
}
-extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
+extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level)
@@ -390,7 +390,7 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
zi->ci.stream_initialised = 0;
zi->ci.pos_in_buffered_data = 0;
zi->ci.pos_local_header = ftell(zi->filezip);
- zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
+ zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
size_extrafield_global + size_comment;
zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);
@@ -410,12 +410,12 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
if (zipfi==NULL)
- ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
+ ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
else
- ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
+ ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
if (zipfi==NULL)
- ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
+ ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
else
ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);
@@ -568,10 +568,10 @@ extern int ZEXPORT zipCloseFileInZip (file)
return ZIP_PARAMERROR;
zi = (zip_internal*)file;
- if (zi->in_opened_file_inzip == 0)
+ if (zi->in_opened_file_inzip == 0)
return ZIP_PARAMERROR;
zi->ci.stream.avail_in = 0;
-
+
if (zi->ci.method == Z_DEFLATED)
while (err==ZIP_OK)
{
@@ -618,22 +618,22 @@ extern int ZEXPORT zipCloseFileInZip (file)
if (err==ZIP_OK)
{
long cur_pos_inzip = ftell(zi->filezip);
- if (fseek(zi->filezip,
+ if (fseek(zi->filezip,
zi->ci.pos_local_header + 14,SEEK_SET)!=0)
- err = ZIP_ERRNO;
+ err = ZIP_ERRNO;
if (err==ZIP_OK)
err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */
if (err==ZIP_OK) /* compressed size, unknown */
- err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4);
+ err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4);
if (err==ZIP_OK) /* uncompressed size, unknown */
err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4);
- if (fseek(zi->filezip,
+ if (fseek(zi->filezip,
cur_pos_inzip,SEEK_SET)!=0)
- err = ZIP_ERRNO;
+ err = ZIP_ERRNO;
}
zi->number_entry ++;
@@ -701,8 +701,8 @@ extern int ZEXPORT zipClose (file, global_comment)
if (err==ZIP_OK) /* size of the central directory */
err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4);
- if (err==ZIP_OK) /* offset of start of central directory with respect to the
- starting disk number */
+ if (err==ZIP_OK) /* offset of start of central directory with respect to the
+ starting disk number */
err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4);
if (err==ZIP_OK) /* zipfile comment length */
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h
index f6ed94c180f..678260b330b 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h
@@ -1,4 +1,4 @@
-/* zip.h -- IO for compress .zip files using zlib
+/* zip.h -- IO for compress .zip files using zlib
Version 0.15 alpha, Mar 19th, 1998,
Copyright (C) 1998 Gilles Vollant
@@ -36,7 +36,7 @@
*/
-/* for more info about .ZIP format, see
+/* for more info about .ZIP format, see
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip
@@ -56,7 +56,7 @@ extern "C" {
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
-typedef struct TagzipFile__ { int unused; } zipFile__;
+typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
@@ -68,19 +68,19 @@ typedef voidp zipFile;
#define ZIP_INTERNALERROR (-104)
/* tm_zip contain date/time info */
-typedef struct tm_zip_s
+typedef struct tm_zip_s
{
- uInt tm_sec; /* seconds after the minute - [0,59] */
- uInt tm_min; /* minutes after the hour - [0,59] */
- uInt tm_hour; /* hours since midnight - [0,23] */
- uInt tm_mday; /* day of the month - [1,31] */
- uInt tm_mon; /* months since January - [0,11] */
- uInt tm_year; /* years - [1980..2044] */
+ uInt tm_sec; /* seconds after the minute - [0,59] */
+ uInt tm_min; /* minutes after the hour - [0,59] */
+ uInt tm_hour; /* hours since midnight - [0,23] */
+ uInt tm_mday; /* day of the month - [1,31] */
+ uInt tm_mon; /* months since January - [0,11] */
+ uInt tm_year; /* years - [1980..2044] */
} tm_zip;
typedef struct
{
- tm_zip tmz_date; /* date in understandable format */
+ tm_zip tmz_date; /* date in understandable format */
uLong dosDate; /* if dos_date == 0, tmu_date is used */
/* uLong flag; */ /* general purpose bit flag 2 bytes */
@@ -91,27 +91,27 @@ typedef struct
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
/*
Create a zipfile.
- pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on
- an Unix computer "zlib/zlib111.zip".
- if the file pathname exist and append=1, the zip will be created at the end
- of the file. (useful if the file contain a self extractor code)
- If the zipfile cannot be opened, the return value is NULL.
+ pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on
+ an Unix computer "zlib/zlib111.zip".
+ if the file pathname exist and append=1, the zip will be created at the end
+ of the file. (useful if the file contain a self extractor code)
+ If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
- of this zip package.
+ of this zip package.
*/
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
- const char* filename,
- const zip_fileinfo* zipfi,
- const void* extrafield_local,
- uInt size_extrafield_local,
- const void* extrafield_global,
- uInt size_extrafield_global,
- const char* comment,
- int method,
- int level));
+ const char* filename,
+ const zip_fileinfo* zipfi,
+ const void* extrafield_local,
+ uInt size_extrafield_local,
+ const void* extrafield_global,
+ uInt size_extrafield_global,
+ const char* comment,
+ int method,
+ int level));
/*
Open a file in the ZIP for writing.
filename : the filename in zip (if NULL, '-' without quote will be used
@@ -126,8 +126,8 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
*/
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
- const voidp buf,
- unsigned len));
+ const voidp buf,
+ unsigned len));
/*
Write data in the zipfile
*/
@@ -138,7 +138,7 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
*/
extern int ZEXPORT zipClose OF((zipFile file,
- const char* global_comment));
+ const char* global_comment));
/*
Close the zipfile
*/
@@ -148,4 +148,3 @@ extern int ZEXPORT zipClose OF((zipFile file,
#endif
#endif /* _zip_H */
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/Makefile b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/Makefile
deleted file mode 100644
index 409b4bdeaae..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-CC=cc
-CFLAGS=-g
-
-untgz: untgz.o ../../libz.a
- $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz
-
-untgz.o: untgz.c ../../zlib.h
- $(CC) $(CFLAGS) -c -I../.. untgz.c
-
-../../libz.a:
- cd ../..; make
-
-clean:
- rm -f untgz untgz.o *~
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c
index bfde094c044..4a431ff3163 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c
@@ -39,37 +39,37 @@
/* Values used in typeflag field. */
-#define REGTYPE '0' /* regular file */
-#define AREGTYPE '\0' /* regular file */
-#define LNKTYPE '1' /* link */
-#define SYMTYPE '2' /* reserved */
-#define CHRTYPE '3' /* character special */
-#define BLKTYPE '4' /* block special */
-#define DIRTYPE '5' /* directory */
-#define FIFOTYPE '6' /* FIFO special */
-#define CONTTYPE '7' /* reserved */
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE '\0' /* regular file */
+#define LNKTYPE '1' /* link */
+#define SYMTYPE '2' /* reserved */
+#define CHRTYPE '3' /* character special */
+#define BLKTYPE '4' /* block special */
+#define DIRTYPE '5' /* directory */
+#define FIFOTYPE '6' /* FIFO special */
+#define CONTTYPE '7' /* reserved */
#define BLOCKSIZE 512
struct tar_header
-{ /* byte offset */
- char name[100]; /* 0 */
- char mode[8]; /* 100 */
- char uid[8]; /* 108 */
- char gid[8]; /* 116 */
- char size[12]; /* 124 */
- char mtime[12]; /* 136 */
- char chksum[8]; /* 148 */
- char typeflag; /* 156 */
- char linkname[100]; /* 157 */
- char magic[6]; /* 257 */
- char version[2]; /* 263 */
- char uname[32]; /* 265 */
- char gname[32]; /* 297 */
- char devmajor[8]; /* 329 */
- char devminor[8]; /* 337 */
- char prefix[155]; /* 345 */
- /* 500 */
+{ /* byte offset */
+ char name[100]; /* 0 */
+ char mode[8]; /* 100 */
+ char uid[8]; /* 108 */
+ char gid[8]; /* 116 */
+ char size[12]; /* 124 */
+ char mtime[12]; /* 136 */
+ char chksum[8]; /* 148 */
+ char typeflag; /* 156 */
+ char linkname[100]; /* 157 */
+ char magic[6]; /* 257 */
+ char version[2]; /* 263 */
+ char uname[32]; /* 265 */
+ char gname[32]; /* 297 */
+ char devmajor[8]; /* 329 */
+ char devminor[8]; /* 337 */
+ char prefix[155]; /* 345 */
+ /* 500 */
};
union tar_buffer {
@@ -79,21 +79,21 @@ union tar_buffer {
enum { TGZ_EXTRACT = 0, TGZ_LIST };
-static char *TGZfname OF((const char *));
-void TGZnotfound OF((const char *));
+static char *TGZfname OF((const char *));
+void TGZnotfound OF((const char *));
-int getoct OF((char *, int));
-char *strtime OF((time_t *));
-int ExprMatch OF((char *,char *));
+int getoct OF((char *, int));
+char *strtime OF((time_t *));
+int ExprMatch OF((char *,char *));
-int makedir OF((char *));
-int matchname OF((int,int,char **,char *));
+int makedir OF((char *));
+int matchname OF((int,int,char **,char *));
-void error OF((const char *));
-int tar OF((gzFile, int, int, int, char **));
+void error OF((const char *));
+int tar OF((gzFile, int, int, int, char **));
-void help OF((int));
-int main OF((int, char **));
+void help OF((int));
+int main OF((int, char **));
char *prog;
@@ -108,7 +108,7 @@ static char *TGZfname OF((const char *fname))
{
static char buffer[1024];
int origlen,i;
-
+
strcpy(buffer,fname);
origlen = strlen(buffer);
@@ -142,14 +142,14 @@ int getoct(char *p,int width)
{
int result = 0;
char c;
-
+
while (width --)
{
c = *p++;
if (c == ' ')
- continue;
+ continue;
if (c == 0)
- break;
+ break;
result = result * 8 + (c - '0');
}
return result;
@@ -162,8 +162,8 @@ char *strtime (time_t *t)
local = localtime(t);
sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d",
- local->tm_mday, local->tm_mon+1, local->tm_year+1900,
- local->tm_hour, local->tm_min, local->tm_sec);
+ local->tm_mday, local->tm_mon+1, local->tm_year+1900,
+ local->tm_hour, local->tm_min, local->tm_sec);
return result;
}
@@ -177,30 +177,30 @@ int ExprMatch(char *string,char *expr)
while (1)
{
if (ISSPECIAL(*expr))
- {
- if (*expr == '/')
- {
- if (*string != '\\' && *string != '/')
- return 0;
- string ++; expr++;
- }
- else if (*expr == '*')
- {
- if (*expr ++ == 0)
- return 1;
- while (*++string != *expr)
- if (*string == 0)
- return 0;
- }
- }
+ {
+ if (*expr == '/')
+ {
+ if (*string != '\\' && *string != '/')
+ return 0;
+ string ++; expr++;
+ }
+ else if (*expr == '*')
+ {
+ if (*expr ++ == 0)
+ return 1;
+ while (*++string != *expr)
+ if (*string == 0)
+ return 0;
+ }
+ }
else
- {
- if (*string != *expr)
- return 0;
- if (*expr++ == 0)
- return 1;
- string++;
- }
+ {
+ if (*string != *expr)
+ return 0;
+ if (*expr++ == 0)
+ return 1;
+ string++;
+ }
}
}
@@ -216,7 +216,7 @@ int makedir (char *newdir)
char *buffer = strdup(newdir);
char *p;
int len = strlen(buffer);
-
+
if (len <= 0) {
free(buffer);
return 0;
@@ -234,19 +234,19 @@ int makedir (char *newdir)
while (1)
{
char hold;
-
+
while(*p && *p != '\\' && *p != '/')
- p++;
+ p++;
hold = *p;
*p = 0;
if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT))
- {
- fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer);
- free(buffer);
- return 0;
- }
+ {
+ fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer);
+ free(buffer);
+ return 0;
+ }
if (hold == 0)
- break;
+ break;
*p++ = hold;
}
free(buffer);
@@ -255,7 +255,7 @@ int makedir (char *newdir)
int matchname (int arg,int argc,char **argv,char *fname)
{
- if (arg == argc) /* no arguments given (untgz tgzarchive) */
+ if (arg == argc) /* no arguments given (untgz tgzarchive) */
return 1;
while (arg < argc)
@@ -278,144 +278,144 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
FILE *outfile = NULL;
char fname[BLOCKSIZE];
time_t tartime;
-
+
if (action == TGZ_LIST)
printf(" day time size file\n"
- " ---------- -------- --------- -------------------------------------\n");
+ " ---------- -------- --------- -------------------------------------\n");
while (1)
{
len = gzread(in, &buffer, BLOCKSIZE);
if (len < 0)
- error (gzerror(in, &err));
+ error (gzerror(in, &err));
/*
* Always expect complete blocks to process
* the tar information.
*/
if (len != BLOCKSIZE)
- error("gzread: incomplete block read");
-
+ error("gzread: incomplete block read");
+
/*
* If we have to get a tar header
*/
if (getheader == 1)
- {
- /*
- * if we met the end of the tar
- * or the end-of-tar block,
- * we are done
- */
- if ((len == 0) || (buffer.header.name[0]== 0)) break;
-
- tartime = (time_t)getoct(buffer.header.mtime,12);
- strcpy(fname,buffer.header.name);
-
- switch (buffer.header.typeflag)
- {
- case DIRTYPE:
- if (action == TGZ_LIST)
- printf(" %s <dir> %s\n",strtime(&tartime),fname);
- if (action == TGZ_EXTRACT)
- makedir(fname);
- break;
- case REGTYPE:
- case AREGTYPE:
- remaining = getoct(buffer.header.size,12);
- if (action == TGZ_LIST)
- printf(" %s %9d %s\n",strtime(&tartime),remaining,fname);
- if (action == TGZ_EXTRACT)
- {
- if ((remaining) && (matchname(arg,argc,argv,fname)))
- {
- outfile = fopen(fname,"wb");
- if (outfile == NULL) {
- /* try creating directory */
- char *p = strrchr(fname, '/');
- if (p != NULL) {
- *p = '\0';
- makedir(fname);
- *p = '/';
- outfile = fopen(fname,"wb");
- }
- }
- fprintf(stderr,
- "%s %s\n",
- (outfile) ? "Extracting" : "Couldn't create",
- fname);
- }
- else
- outfile = NULL;
- }
- /*
- * could have no contents
- */
- getheader = (remaining) ? 0 : 1;
- break;
- default:
- if (action == TGZ_LIST)
- printf(" %s <---> %s\n",strtime(&tartime),fname);
- break;
- }
- }
+ {
+ /*
+ * if we met the end of the tar
+ * or the end-of-tar block,
+ * we are done
+ */
+ if ((len == 0) || (buffer.header.name[0]== 0)) break;
+
+ tartime = (time_t)getoct(buffer.header.mtime,12);
+ strcpy(fname,buffer.header.name);
+
+ switch (buffer.header.typeflag)
+ {
+ case DIRTYPE:
+ if (action == TGZ_LIST)
+ printf(" %s <dir> %s\n",strtime(&tartime),fname);
+ if (action == TGZ_EXTRACT)
+ makedir(fname);
+ break;
+ case REGTYPE:
+ case AREGTYPE:
+ remaining = getoct(buffer.header.size,12);
+ if (action == TGZ_LIST)
+ printf(" %s %9d %s\n",strtime(&tartime),remaining,fname);
+ if (action == TGZ_EXTRACT)
+ {
+ if ((remaining) && (matchname(arg,argc,argv,fname)))
+ {
+ outfile = fopen(fname,"wb");
+ if (outfile == NULL) {
+ /* try creating directory */
+ char *p = strrchr(fname, '/');
+ if (p != NULL) {
+ *p = '\0';
+ makedir(fname);
+ *p = '/';
+ outfile = fopen(fname,"wb");
+ }
+ }
+ fprintf(stderr,
+ "%s %s\n",
+ (outfile) ? "Extracting" : "Couldn't create",
+ fname);
+ }
+ else
+ outfile = NULL;
+ }
+ /*
+ * could have no contents
+ */
+ getheader = (remaining) ? 0 : 1;
+ break;
+ default:
+ if (action == TGZ_LIST)
+ printf(" %s <---> %s\n",strtime(&tartime),fname);
+ break;
+ }
+ }
else
- {
- unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining;
-
- if ((action == TGZ_EXTRACT) && (outfile != NULL))
- {
- if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes)
- {
- fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname);
- fclose(outfile);
- unlink(fname);
- }
- }
- remaining -= bytes;
- if (remaining == 0)
- {
- getheader = 1;
- if ((action == TGZ_EXTRACT) && (outfile != NULL))
- {
+ {
+ unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining;
+
+ if ((action == TGZ_EXTRACT) && (outfile != NULL))
+ {
+ if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes)
+ {
+ fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname);
+ fclose(outfile);
+ unlink(fname);
+ }
+ }
+ remaining -= bytes;
+ if (remaining == 0)
+ {
+ getheader = 1;
+ if ((action == TGZ_EXTRACT) && (outfile != NULL))
+ {
#ifdef WIN32
- HANDLE hFile;
- FILETIME ftm,ftLocal;
- SYSTEMTIME st;
- struct tm localt;
-
- fclose(outfile);
-
- localt = *localtime(&tartime);
-
- hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING, 0, NULL);
-
- st.wYear = (WORD)localt.tm_year+1900;
- st.wMonth = (WORD)localt.tm_mon;
- st.wDayOfWeek = (WORD)localt.tm_wday;
- st.wDay = (WORD)localt.tm_mday;
- st.wHour = (WORD)localt.tm_hour;
- st.wMinute = (WORD)localt.tm_min;
- st.wSecond = (WORD)localt.tm_sec;
- st.wMilliseconds = 0;
- SystemTimeToFileTime(&st,&ftLocal);
- LocalFileTimeToFileTime(&ftLocal,&ftm);
- SetFileTime(hFile,&ftm,NULL,&ftm);
- CloseHandle(hFile);
-
- outfile = NULL;
+ HANDLE hFile;
+ FILETIME ftm,ftLocal;
+ SYSTEMTIME st;
+ struct tm localt;
+
+ fclose(outfile);
+
+ localt = *localtime(&tartime);
+
+ hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING, 0, NULL);
+
+ st.wYear = (WORD)localt.tm_year+1900;
+ st.wMonth = (WORD)localt.tm_mon;
+ st.wDayOfWeek = (WORD)localt.tm_wday;
+ st.wDay = (WORD)localt.tm_mday;
+ st.wHour = (WORD)localt.tm_hour;
+ st.wMinute = (WORD)localt.tm_min;
+ st.wSecond = (WORD)localt.tm_sec;
+ st.wMilliseconds = 0;
+ SystemTimeToFileTime(&st,&ftLocal);
+ LocalFileTimeToFileTime(&ftLocal,&ftm);
+ SetFileTime(hFile,&ftm,NULL,&ftm);
+ CloseHandle(hFile);
+
+ outfile = NULL;
#else
- struct utimbuf settime;
+ struct utimbuf settime;
- settime.actime = settime.modtime = tartime;
+ settime.actime = settime.modtime = tartime;
- fclose(outfile);
- outfile = NULL;
- utime(fname,&settime);
+ fclose(outfile);
+ outfile = NULL;
+ utime(fname,&settime);
#endif
- }
- }
+ }
+ }
+ }
}
- }
-
+
if (gzclose(in) != Z_OK)
error("failed gzclose");
@@ -428,8 +428,8 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
void help(int exitval)
{
fprintf(stderr,
- "untgz v 0.1\n"
- " an sample application of zlib 1.0.4\n\n"
+ "untgz v 0.1\n"
+ " an sample application of zlib 1.0.4\n\n"
"Usage : untgz TGZfile to extract all files\n"
" untgz TGZfile fname ... to extract selected files\n"
" untgz -l TGZfile to list archive contents\n"
@@ -446,50 +446,50 @@ void error(const char *msg)
/* ====================================================================== */
-int _CRT_glob = 0; /* disable globbing of the arguments */
+int _CRT_glob = 0; /* disable globbing of the arguments */
int main(int argc,char **argv)
{
- int action = TGZ_EXTRACT;
- int arg = 1;
- char *TGZfile;
- gzFile *f;
-
+ int action = TGZ_EXTRACT;
+ int arg = 1;
+ char *TGZfile;
+ gzFile *f;
+
prog = strrchr(argv[0],'\\');
if (prog == NULL)
{
- prog = strrchr(argv[0],'/');
- if (prog == NULL)
- {
- prog = strrchr(argv[0],':');
- if (prog == NULL)
- prog = argv[0];
- else
- prog++;
- }
- else
- prog++;
+ prog = strrchr(argv[0],'/');
+ if (prog == NULL)
+ {
+ prog = strrchr(argv[0],':');
+ if (prog == NULL)
+ prog = argv[0];
+ else
+ prog++;
+ }
+ else
+ prog++;
}
else
prog++;
-
+
if (argc == 1)
help(0);
if (strcmp(argv[arg],"-l") == 0)
{
- action = TGZ_LIST;
- if (argc == ++arg)
- help(0);
+ action = TGZ_LIST;
+ if (argc == ++arg)
+ help(0);
}
else if (strcmp(argv[arg],"-h") == 0)
{
- help(0);
+ help(0);
}
if ((TGZfile = TGZfname(argv[arg])) == NULL)
- TGZnotfound(argv[arg]);
+ TGZnotfound(argv[arg]);
++arg;
if ((action == TGZ_LIST) && (arg != argc))
@@ -502,20 +502,20 @@ int main(int argc,char **argv)
{
case TGZ_LIST:
case TGZ_EXTRACT:
- f = gzopen(TGZfile,"rb");
- if (f == NULL)
- {
- fprintf(stderr,"%s: Couldn't gzopen %s\n",
- prog,
- TGZfile);
- return 1;
- }
- exit(tar(f, action, arg, argc, argv));
+ f = gzopen(TGZfile,"rb");
+ if (f == NULL)
+ {
+ fprintf(stderr,"%s: Couldn't gzopen %s\n",
+ prog,
+ TGZfile);
+ return 1;
+ }
+ exit(tar(f, action, arg, argc, argv));
break;
-
+
default:
- error("Unknown option!");
- exit(1);
+ error("Unknown option!");
+ exit(1);
}
return 0;
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c b/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c
index 797f4f982fa..60deca2ddf4 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c
@@ -1,6 +1,6 @@
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
@@ -51,7 +51,7 @@ local void make_crc_table()
poly = 0L;
for (n = 0; n < sizeof(p)/sizeof(Byte); n++)
poly |= 1L << (31 - p[n]);
-
+
for (n = 0; n < 256; n++)
{
c = (uLong)n;
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c
index 11568941c4c..16ebdade3f1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c
@@ -1,6 +1,6 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
@@ -194,13 +194,13 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size)
int stream_size;
{
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
+ Z_DEFAULT_STRATEGY, version, stream_size);
/* To do: ignore strm->next_in if we use it as window */
}
/* ========================================================================= */
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
+ version, stream_size)
z_streamp strm;
int level;
int method;
@@ -221,14 +221,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
if (version == Z_NULL || version[0] != my_version[0] ||
stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
+ return Z_VERSION_ERROR;
}
if (strm == Z_NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL;
if (strm->zalloc == Z_NULL) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
+ strm->zalloc = zcalloc;
+ strm->opaque = (voidpf)0;
}
if (strm->zfree == Z_NULL) strm->zfree = zcfree;
@@ -243,7 +243,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
}
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
windowBits < 9 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
+ strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
return Z_STREAM_ERROR;
}
s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
@@ -306,9 +306,9 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
if (length < MIN_MATCH) return Z_OK;
if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
+ length = MAX_DIST(s);
#ifndef USE_DICT_HEAD
- dictionary += dictLength - length; /* use the tail of the dictionary */
+ dictionary += dictLength - length; /* use the tail of the dictionary */
#endif
}
zmemcpy(s->window, dictionary, length);
@@ -322,7 +322,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
s->ins_h = s->window[0];
UPDATE_HASH(s, s->ins_h, s->window[1]);
for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
+ INSERT_STRING(s, n, hash_head);
}
if (hash_head) hash_head = 0; /* to make compiler happy */
return Z_OK;
@@ -333,7 +333,7 @@ int ZEXPORT deflateReset (strm)
z_streamp strm;
{
deflate_state *s;
-
+
if (strm == Z_NULL || strm->state == Z_NULL ||
strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR;
@@ -372,23 +372,23 @@ int ZEXPORT deflateParams(strm, level, strategy)
s = strm->state;
if (level == Z_DEFAULT_COMPRESSION) {
- level = 6;
+ level = 6;
}
if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
- return Z_STREAM_ERROR;
+ return Z_STREAM_ERROR;
}
func = configuration_table[s->level].func;
if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
+ /* Flush the last buffer: */
+ err = deflate(strm, Z_PARTIAL_FLUSH);
}
if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
+ s->level = level;
+ s->max_lazy_match = configuration_table[level].max_lazy;
+ s->good_match = configuration_table[level].good_length;
+ s->nice_match = configuration_table[level].nice_length;
+ s->max_chain_length = configuration_table[level].max_chain;
}
s->strategy = strategy;
return err;
@@ -405,7 +405,7 @@ local void putShortMSB (s, b)
{
put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff));
-}
+}
/* =========================================================================
* Flush as much pending output as possible. All deflate() output goes
@@ -441,14 +441,14 @@ int ZEXPORT deflate (strm, flush)
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
+ flush > Z_FINISH || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
if (strm->next_out == Z_NULL ||
(strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
+ (s->status == FINISH_STATE && flush != Z_FINISH)) {
ERR_RETURN(strm, Z_STREAM_ERROR);
}
if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
@@ -465,40 +465,40 @@ int ZEXPORT deflate (strm, flush)
if (level_flags > 3) level_flags = 3;
header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
+ if (s->strstart != 0) header |= PRESET_DICT;
header += 31 - (header % 31);
s->status = BUSY_STATE;
putShortMSB(s, header);
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = 1L;
+ /* Save the adler32 of the preset dictionary: */
+ if (s->strstart != 0) {
+ putShortMSB(s, (uInt)(strm->adler >> 16));
+ putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ }
+ strm->adler = 1L;
}
/* Flush as much pending output as possible */
if (s->pending != 0) {
flush_pending(strm);
if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
+ /* Since avail_out is 0, deflate will be called again with
+ * more output space, but possibly with both pending and
+ * avail_in equal to zero. There won't be anything to do,
+ * but this is not an error situation so make sure we
+ * return OK instead of BUF_ERROR at next call of deflate:
*/
- s->last_flush = -1;
- return Z_OK;
- }
+ s->last_flush = -1;
+ return Z_OK;
+ }
/* Make sure there is something to do and avoid duplicate consecutive
* flushes. For repeated and useless calls with Z_FINISH, we keep
* returning Z_STREAM_END instead of Z_BUFF_ERROR.
*/
} else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
+ flush != Z_FINISH) {
ERR_RETURN(strm, Z_BUF_ERROR);
}
@@ -513,24 +513,24 @@ int ZEXPORT deflate (strm, flush)
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
- bstate = (*(configuration_table[s->level].func))(s, flush);
+ bstate = (*(configuration_table[s->level].func))(s, flush);
if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
}
if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
+ if (strm->avail_out == 0) {
+ s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
+ }
+ return Z_OK;
+ /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
+ * of deflate should use the same flush parameter to make sure
+ * that the flush is complete. So we don't have to output an
+ * empty block here, this will be done at next call. This also
+ * ensures that for a very small output buffer, we emit at most
+ * one empty block.
+ */
+ }
if (bstate == block_done) {
if (flush == Z_PARTIAL_FLUSH) {
_tr_align(s);
@@ -544,10 +544,10 @@ int ZEXPORT deflate (strm, flush)
}
}
flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
+ if (strm->avail_out == 0) {
+ s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
+ return Z_OK;
+ }
}
}
Assert(strm->avail_out > 0, "bug2");
@@ -576,7 +576,7 @@ int ZEXPORT deflateEnd (strm)
status = strm->state->status;
if (status != INIT_STATE && status != BUSY_STATE &&
- status != FINISH_STATE) {
+ status != FINISH_STATE) {
return Z_STREAM_ERROR;
}
@@ -903,10 +903,10 @@ local uInt longest_match(s, cur_match)
*/
do {
} while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
@@ -933,10 +933,10 @@ local void check_match(s, start, match, length)
if (zmemcmp(s->window + match,
s->window + start, length) != EQUAL) {
fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
+ start, match, length);
do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
+ fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
+ } while (--length != 0);
z_error("invalid match");
}
if (z_verbose > 1) {
@@ -995,23 +995,23 @@ local void fill_window(s)
later. (Using level 0 permanently is not an optimal usage of
zlib, so we don't care about this pathological case.)
*/
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
+ n = s->hash_size;
+ p = &s->head[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ } while (--n);
+
+ n = wsize;
#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
+ p = &s->prev[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ /* If n is not on any hash chain, prev[n] is garbage but
+ * its value will never be used.
+ */
+ } while (--n);
#endif
more += wsize;
}
@@ -1056,8 +1056,8 @@ local void fill_window(s)
_tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (eof)); \
+ (ulg)((long)s->strstart - s->block_start), \
+ (eof)); \
s->block_start = s->strstart; \
flush_pending(s->strm); \
Tracev((stderr,"[FLUSH]")); \
@@ -1098,32 +1098,32 @@ local block_state deflate_stored(s, flush)
if (s->lookahead <= 1) {
Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
+ s->block_start >= (long)s->w_size, "slide too late");
fill_window(s);
if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
if (s->lookahead == 0) break; /* flush the current block */
}
- Assert(s->block_start >= 0L, "block gone");
+ Assert(s->block_start >= 0L, "block gone");
- s->strstart += s->lookahead;
- s->lookahead = 0;
+ s->strstart += s->lookahead;
+ s->lookahead = 0;
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
+ /* Emit a stored block if pending_buf will be full: */
+ max_start = s->block_start + max_block_size;
if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
+ /* strstart == 0 is possible when wraparound on 16-bit machine */
+ s->lookahead = (uInt)(s->strstart - max_start);
+ s->strstart = (uInt)max_start;
FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
+ }
+ /* Flush if we may have to slide, otherwise block_start may become
* negative and the data will be gone:
*/
if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
FLUSH_BLOCK(s, 0);
- }
+ }
}
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
@@ -1152,8 +1152,8 @@ local block_state deflate_fast(s, flush)
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
+ return need_more;
+ }
if (s->lookahead == 0) break; /* flush the current block */
}
@@ -1199,10 +1199,10 @@ local block_state deflate_fast(s, flush)
* always MIN_MATCH bytes ahead.
*/
} while (--s->match_length != 0);
- s->strstart++;
+ s->strstart++;
} else
#endif
- {
+ {
s->strstart += s->match_length;
s->match_length = 0;
s->ins_h = s->window[s->strstart];
@@ -1219,7 +1219,7 @@ local block_state deflate_fast(s, flush)
Tracevv((stderr,"%c", s->window[s->strstart]));
_tr_tally_lit (s, s->window[s->strstart], bflush);
s->lookahead--;
- s->strstart++;
+ s->strstart++;
}
if (bflush) FLUSH_BLOCK(s, 0);
}
@@ -1249,8 +1249,8 @@ local block_state deflate_slow(s, flush)
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
+ return need_more;
+ }
if (s->lookahead == 0) break; /* flush the current block */
}
@@ -1297,7 +1297,7 @@ local block_state deflate_slow(s, flush)
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
_tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
+ s->prev_length - MIN_MATCH, bflush);
/* Insert in hash table all strings up to the end of the match.
* strstart-1 and strstart are already inserted. If there is not
@@ -1323,8 +1323,8 @@ local block_state deflate_slow(s, flush)
* is longer, truncate the previous match to a single literal.
*/
Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
+ _tr_tally_lit(s, s->window[s->strstart-1], bflush);
+ if (bflush) {
FLUSH_BLOCK_ONLY(s, 0);
}
s->strstart++;
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h
index 1f5d73ce85d..b99a48a5214 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h
@@ -1,6 +1,6 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2002 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -269,7 +269,7 @@ typedef struct internal_state {
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
+ int eof));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
@@ -312,8 +312,7 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
+ flush = _tr_tally(s, distance, length)
#endif
#endif
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/example.c b/contrib/vmap_extractor_v2/stormlib/zlib/example.c
index 83e5d8f0341..e7e3673333e 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/example.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/example.c
@@ -1,6 +1,6 @@
/* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
@@ -37,22 +37,22 @@ const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */
void test_compress OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
-void test_gzio OF((const char *out, const char *in,
- Byte *uncompr, int uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
+void test_gzio OF((const char *out, const char *in,
+ Byte *uncompr, int uncomprLen));
void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen,
- Byte *uncompr, uLong uncomprLen));
+ Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[]));
/* ===========================================================================
@@ -75,7 +75,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad uncompress\n");
- exit(1);
+ exit(1);
} else {
printf("uncompress(): %s\n", (char *)uncompr);
}
@@ -103,11 +103,11 @@ void test_gzio(out, in, uncompr, uncomprLen)
gzputc(file, 'h');
if (gzputs(file, "ello") != 4) {
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
- exit(1);
+ exit(1);
}
if (gzprintf(file, ", %s!", "hello") != 8) {
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
- exit(1);
+ exit(1);
}
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
gzclose(file);
@@ -121,36 +121,36 @@ void test_gzio(out, in, uncompr, uncomprLen)
uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen);
if (uncomprLen != len) {
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
- exit(1);
+ exit(1);
}
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
- exit(1);
+ exit(1);
} else {
printf("gzread(): %s\n", (char *)uncompr);
}
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
- fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
- (long)pos, (long)gztell(file));
- exit(1);
+ fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
+ (long)pos, (long)gztell(file));
+ exit(1);
}
if (gzgetc(file) != ' ') {
- fprintf(stderr, "gzgetc error\n");
- exit(1);
+ fprintf(stderr, "gzgetc error\n");
+ exit(1);
}
gzgets(file, (char*)uncompr, uncomprLen);
uncomprLen = strlen((char*)uncompr);
if (uncomprLen != 6) { /* "hello!" */
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
- exit(1);
+ exit(1);
}
if (strcmp((char*)uncompr, hello+7)) {
fprintf(stderr, "bad gzgets after gzseek\n");
- exit(1);
+ exit(1);
} else {
printf("gzgets() after gzseek: %s\n", (char *)uncompr);
}
@@ -231,7 +231,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad inflate\n");
- exit(1);
+ exit(1);
} else {
printf("inflate(): %s\n", (char *)uncompr);
}
@@ -266,7 +266,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) {
fprintf(stderr, "deflate not greedy\n");
- exit(1);
+ exit(1);
}
/* Feed in already compressed data and switch to no compression: */
@@ -286,7 +286,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
- exit(1);
+ exit(1);
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
@@ -316,7 +316,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
for (;;) {
d_stream.next_out = uncompr; /* discard the output */
- d_stream.avail_out = (uInt)uncomprLen;
+ d_stream.avail_out = (uInt)uncomprLen;
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate");
@@ -327,7 +327,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
- exit(1);
+ exit(1);
} else {
printf("large_inflate(): OK\n");
}
@@ -407,7 +407,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
if (err != Z_DATA_ERROR) {
fprintf(stderr, "inflate should report DATA_ERROR\n");
/* Because of incorrect adler32 */
- exit(1);
+ exit(1);
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
@@ -433,7 +433,7 @@ void test_dict_deflate(compr, comprLen)
CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream,
- (const Bytef*)dictionary, sizeof(dictionary));
+ (const Bytef*)dictionary, sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary");
dictId = c_stream.adler;
@@ -446,7 +446,7 @@ void test_dict_deflate(compr, comprLen)
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
- exit(1);
+ exit(1);
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
@@ -480,14 +480,14 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
for (;;) {
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
- if (err == Z_NEED_DICT) {
- if (d_stream.adler != dictId) {
- fprintf(stderr, "unexpected dictionary");
- exit(1);
- }
- err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
- sizeof(dictionary));
- }
+ if (err == Z_NEED_DICT) {
+ if (d_stream.adler != dictId) {
+ fprintf(stderr, "unexpected dictionary");
+ exit(1);
+ }
+ err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
+ sizeof(dictionary));
+ }
CHECK_ERR(err, "inflate with dict");
}
@@ -496,7 +496,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad inflate with dict\n");
- exit(1);
+ exit(1);
} else {
printf("inflate with dictionary: %s\n", (char *)uncompr);
}
@@ -530,13 +530,13 @@ int main(argc, argv)
*/
if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n");
- exit(1);
+ exit(1);
}
test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : TESTFILE),
(argc > 2 ? argv[2] : TESTFILE),
- uncompr, (int)uncomprLen);
+ uncompr, (int)uncomprLen);
test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen);
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c b/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c
index 36a371cdebc..09e0a20b8ce 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c
@@ -112,17 +112,17 @@ local gzFile gz_open (path, mode, fd)
if (*p == 'r') s->mode = 'r';
if (*p == 'w' || *p == 'a') s->mode = 'w';
if (*p >= '0' && *p <= '9') {
- level = *p - '0';
- } else if (*p == 'f') {
- strategy = Z_FILTERED;
- } else if (*p == 'h') {
- strategy = Z_HUFFMAN_ONLY;
- } else {
- *m++ = *p; /* copy the mode */
- }
+ level = *p - '0';
+ } else if (*p == 'f') {
+ strategy = Z_FILTERED;
+ } else if (*p == 'h') {
+ strategy = Z_HUFFMAN_ONLY;
+ } else {
+ *m++ = *p; /* copy the mode */
+ }
} while (*p++ && m != fmode + sizeof(fmode));
if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
+
if (s->mode == 'w') {
#ifdef NO_DEFLATE
err = Z_STREAM_ERROR;
@@ -163,17 +163,17 @@ local gzFile gz_open (path, mode, fd)
*/
fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
- s->startpos = 10L;
- /* We use 10L instead of ftell(s->file) to because ftell causes an
+ s->startpos = 10L;
+ /* We use 10L instead of ftell(s->file) to because ftell causes an
* fflush on some systems. This version of the library doesn't use
* startpos anyway in write mode, so this initialization is not
* necessary.
*/
} else {
- check_header(s); /* skip the .gz header */
- s->startpos = (ftell(s->file) - s->stream.avail_in);
+ check_header(s); /* skip the .gz header */
+ s->startpos = (ftell(s->file) - s->stream.avail_in);
}
-
+
return (gzFile)s;
}
@@ -218,11 +218,11 @@ int ZEXPORT gzsetparams (file, level, strategy)
/* Make room to allow flushing */
if (s->stream.avail_out == 0) {
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- }
- s->stream.avail_out = Z_BUFSIZE;
+ s->stream.next_out = s->outbuf;
+ if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
+ s->z_err = Z_ERRNO;
+ }
+ s->stream.avail_out = Z_BUFSIZE;
}
return deflateParams (&(s->stream), level, strategy);
@@ -238,14 +238,14 @@ local int get_byte(s)
{
if (s->z_eof) return EOF;
if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) s->z_err = Z_ERRNO;
- return EOF;
- }
- s->stream.next_in = s->inbuf;
+ errno = 0;
+ s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
+ if (s->stream.avail_in == 0) {
+ s->z_eof = 1;
+ if (ferror(s->file)) s->z_err = Z_ERRNO;
+ return EOF;
+ }
+ s->stream.next_in = s->inbuf;
}
s->stream.avail_in--;
return *(s->stream.next_in)++;
@@ -270,41 +270,41 @@ local void check_header(s)
/* Check the gzip magic header */
for (len = 0; len < 2; len++) {
- c = get_byte(s);
- if (c != gz_magic[len]) {
- if (len != 0) s->stream.avail_in++, s->stream.next_in--;
- if (c != EOF) {
- s->stream.avail_in++, s->stream.next_in--;
- s->transparent = 1;
- }
- s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
- return;
- }
+ c = get_byte(s);
+ if (c != gz_magic[len]) {
+ if (len != 0) s->stream.avail_in++, s->stream.next_in--;
+ if (c != EOF) {
+ s->stream.avail_in++, s->stream.next_in--;
+ s->transparent = 1;
+ }
+ s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
+ return;
+ }
}
method = get_byte(s);
flags = get_byte(s);
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
+ s->z_err = Z_DATA_ERROR;
+ return;
}
/* Discard time, xflags and OS code: */
for (len = 0; len < 6; len++) (void)get_byte(s);
if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(s);
- len += ((uInt)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
+ len = (uInt)get_byte(s);
+ len += ((uInt)get_byte(s))<<8;
+ /* len is garbage if EOF but the loop below will quit anyway */
+ while (len-- != 0 && get_byte(s) != EOF) ;
}
if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
+ while ((c = get_byte(s)) != 0 && c != EOF) ;
}
if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
+ while ((c = get_byte(s)) != 0 && c != EOF) ;
}
if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
+ for (len = 0; len < 2; len++) (void)get_byte(s);
}
s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
}
@@ -323,21 +323,21 @@ local int destroy (s)
TRYFREE(s->msg);
if (s->stream.state != NULL) {
- if (s->mode == 'w') {
+ if (s->mode == 'w') {
#ifdef NO_DEFLATE
- err = Z_STREAM_ERROR;
+ err = Z_STREAM_ERROR;
#else
- err = deflateEnd(&(s->stream));
+ err = deflateEnd(&(s->stream));
#endif
- } else if (s->mode == 'r') {
- err = inflateEnd(&(s->stream));
- }
+ } else if (s->mode == 'r') {
+ err = inflateEnd(&(s->stream));
+ }
}
if (s->file != NULL && fclose(s->file)) {
#ifdef ESPIPE
- if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
+ if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
#endif
- err = Z_ERRNO;
+ err = Z_ERRNO;
}
if (s->z_err < 0) err = s->z_err;
@@ -372,69 +372,69 @@ int ZEXPORT gzread (file, buf, len)
while (s->stream.avail_out != 0) {
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- uInt n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- next_out += n;
- s->stream.next_out = next_out;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
- s->file);
- }
- len -= s->stream.avail_out;
- s->stream.total_in += (uLong)len;
- s->stream.total_out += (uLong)len;
+ if (s->transparent) {
+ /* Copy first the lookahead bytes: */
+ uInt n = s->stream.avail_in;
+ if (n > s->stream.avail_out) n = s->stream.avail_out;
+ if (n > 0) {
+ zmemcpy(s->stream.next_out, s->stream.next_in, n);
+ next_out += n;
+ s->stream.next_out = next_out;
+ s->stream.next_in += n;
+ s->stream.avail_out -= n;
+ s->stream.avail_in -= n;
+ }
+ if (s->stream.avail_out > 0) {
+ s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
+ s->file);
+ }
+ len -= s->stream.avail_out;
+ s->stream.total_in += (uLong)len;
+ s->stream.total_out += (uLong)len;
if (len == 0) s->z_eof = 1;
- return (int)len;
- }
+ return (int)len;
+ }
if (s->stream.avail_in == 0 && !s->z_eof) {
errno = 0;
s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
s->z_eof = 1;
- if (ferror(s->file)) {
- s->z_err = Z_ERRNO;
- break;
- }
+ if (ferror(s->file)) {
+ s->z_err = Z_ERRNO;
+ break;
+ }
}
s->stream.next_in = s->inbuf;
}
s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
- start = s->stream.next_out;
+ if (s->z_err == Z_STREAM_END) {
+ /* Check CRC and original size */
+ s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
+ start = s->stream.next_out;
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
+ if (getLong(s) != s->crc) {
+ s->z_err = Z_DATA_ERROR;
+ } else {
+ (void)getLong(s);
/* The uncompressed length returned by above getlong() may
* be different from s->stream.total_out) in case of
- * concatenated .gz files. Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- uLong total_in = s->stream.total_in;
- uLong total_out = s->stream.total_out;
-
- inflateReset(&(s->stream));
- s->stream.total_in = total_in;
- s->stream.total_out = total_out;
- s->crc = crc32(0L, Z_NULL, 0);
- }
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
+ * concatenated .gz files. Check for such files:
+ */
+ check_header(s);
+ if (s->z_err == Z_OK) {
+ uLong total_in = s->stream.total_in;
+ uLong total_out = s->stream.total_out;
+
+ inflateReset(&(s->stream));
+ s->stream.total_in = total_in;
+ s->stream.total_out = total_out;
+ s->crc = crc32(0L, Z_NULL, 0);
+ }
+ }
+ }
+ if (s->z_err != Z_OK || s->z_eof) break;
}
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
@@ -543,21 +543,21 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
#else /* not ANSI C */
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
+ a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
gzFile file;
const char *format;
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
+ a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
char buf[Z_PRINTF_BUFSIZE];
int len;
#ifdef HAS_snprintf
snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
#else
sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
#endif
len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */
if (len <= 0) return 0;
@@ -623,14 +623,14 @@ local int do_flush (file, flush)
if (done) break;
s->z_err = deflate(&(s->stream), flush);
- /* Ignore the second of two consecutive flushes: */
- if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
+ /* Ignore the second of two consecutive flushes: */
+ if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
/* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
+ * all the available space in the output buffer:
*/
done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
+
if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
}
return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
@@ -665,84 +665,84 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
gz_stream *s = (gz_stream*)file;
if (s == NULL || whence == SEEK_END ||
- s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
- return -1L;
+ s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
+ return -1L;
}
-
+
if (s->mode == 'w') {
#ifdef NO_DEFLATE
- return -1L;
+ return -1L;
#else
- if (whence == SEEK_SET) {
- offset -= s->stream.total_in;
- }
- if (offset < 0) return -1L;
-
- /* At this point, offset is the number of zero bytes to write. */
- if (s->inbuf == Z_NULL) {
- s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
- zmemzero(s->inbuf, Z_BUFSIZE);
- }
- while (offset > 0) {
- uInt size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (uInt)offset;
-
- size = gzwrite(file, s->inbuf, size);
- if (size == 0) return -1L;
-
- offset -= size;
- }
- return (z_off_t)s->stream.total_in;
+ if (whence == SEEK_SET) {
+ offset -= s->stream.total_in;
+ }
+ if (offset < 0) return -1L;
+
+ /* At this point, offset is the number of zero bytes to write. */
+ if (s->inbuf == Z_NULL) {
+ s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
+ zmemzero(s->inbuf, Z_BUFSIZE);
+ }
+ while (offset > 0) {
+ uInt size = Z_BUFSIZE;
+ if (offset < Z_BUFSIZE) size = (uInt)offset;
+
+ size = gzwrite(file, s->inbuf, size);
+ if (size == 0) return -1L;
+
+ offset -= size;
+ }
+ return (z_off_t)s->stream.total_in;
#endif
}
/* Rest of function is for reading only */
/* compute absolute position */
if (whence == SEEK_CUR) {
- offset += s->stream.total_out;
+ offset += s->stream.total_out;
}
if (offset < 0) return -1L;
if (s->transparent) {
- /* map to fseek */
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
+ /* map to fseek */
+ s->stream.avail_in = 0;
+ s->stream.next_in = s->inbuf;
if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
- s->stream.total_in = s->stream.total_out = (uLong)offset;
- return offset;
+ s->stream.total_in = s->stream.total_out = (uLong)offset;
+ return offset;
}
/* For a negative seek, rewind and use positive seek */
if ((uLong)offset >= s->stream.total_out) {
- offset -= s->stream.total_out;
+ offset -= s->stream.total_out;
} else if (gzrewind(file) < 0) {
- return -1L;
+ return -1L;
}
/* offset is now the number of bytes to skip. */
if (offset != 0 && s->outbuf == Z_NULL) {
- s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
+ s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
}
while (offset > 0) {
- int size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (int)offset;
+ int size = Z_BUFSIZE;
+ if (offset < Z_BUFSIZE) size = (int)offset;
- size = gzread(file, s->outbuf, (uInt)size);
- if (size <= 0) return -1L;
- offset -= size;
+ size = gzread(file, s->outbuf, (uInt)size);
+ if (size <= 0) return -1L;
+ offset -= size;
}
return (z_off_t)s->stream.total_out;
}
/* ===========================================================================
- Rewinds input file.
+ Rewinds input file.
*/
int ZEXPORT gzrewind (file)
gzFile file;
{
gz_stream *s = (gz_stream*)file;
-
+
if (s == NULL || s->mode != 'r') return -1;
s->z_err = Z_OK;
@@ -750,10 +750,10 @@ int ZEXPORT gzrewind (file)
s->stream.avail_in = 0;
s->stream.next_in = s->inbuf;
s->crc = crc32(0L, Z_NULL, 0);
-
+
if (s->startpos == 0) { /* not a compressed file */
- rewind(s->file);
- return 0;
+ rewind(s->file);
+ return 0;
}
(void) inflateReset(&s->stream);
@@ -779,7 +779,7 @@ int ZEXPORT gzeof (file)
gzFile file;
{
gz_stream *s = (gz_stream*)file;
-
+
return (s == NULL || s->mode != 'r') ? 0 : s->z_eof;
}
@@ -829,7 +829,7 @@ int ZEXPORT gzclose (file)
if (s->mode == 'w') {
#ifdef NO_DEFLATE
- return Z_STREAM_ERROR;
+ return Z_STREAM_ERROR;
#else
err = do_flush (file, Z_FINISH);
if (err != Z_OK) return destroy((gz_stream*)file);
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c
index 4e4e2e15d96..dd7a6d40a8d 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c
@@ -1,6 +1,6 @@
/* infblock.c -- interpret and process block types to last block
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
@@ -393,7 +393,7 @@ uInt n;
/* Returns true if inflate is currently at the end of a block generated
- * by Z_SYNC_FLUSH or Z_FULL_FLUSH.
+ * by Z_SYNC_FLUSH or Z_FULL_FLUSH.
* IN assertion: s != Z_NULL
*/
int inflate_blocks_sync_point(s)
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h
index 0754c173476..173b2267ade 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h
@@ -1,6 +1,6 @@
/* infblock.h -- header to use infblock.c
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -37,4 +37,3 @@ extern void inflate_set_dictionary OF((
extern int inflate_blocks_sync_point OF((
inflate_blocks_statef *s));
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c
index 0af7a5be75c..9abe5412b9c 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c
@@ -1,6 +1,6 @@
/* infcodes.c -- process literals and length/distance pairs
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h
index 7e237254d41..46821a02be6 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h
@@ -1,6 +1,6 @@
/* infcodes.h -- header to use infcodes.c
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -25,4 +25,3 @@ extern void inflate_codes_free OF((
inflate_codes_statef *,
z_streamp ));
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c
index 4e918dbdc67..aa7f1d4d2ad 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c
@@ -1,6 +1,6 @@
/* inffast.c -- process literals and length/distance pairs fast
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h
index ba2d3a85c49..a31a4bbb058 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h
@@ -1,6 +1,6 @@
/* inffast.h -- header to use inffast.c
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -15,4 +15,3 @@ extern int inflate_fast OF((
inflate_huft *,
inflate_blocks_statef *,
z_streamp ));
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h
index 708d69016ea..77f7e763145 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h
@@ -149,4 +149,3 @@ local inflate_huft fixed_td[] = {
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
};
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c
index 3ac2efb900d..dfb2e867d81 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c
@@ -1,6 +1,6 @@
/* inflate.c -- zlib interface to inflate modules
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
@@ -44,7 +44,7 @@ struct internal_state {
/* mode independent information */
int nowrap; /* flag for no wrapper */
uInt wbits; /* log2(window size) (8..15, defaults to 15) */
- inflate_blocks_statef
+ inflate_blocks_statef
*blocks; /* current inflate_blocks state */
};
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c
index a64a23ff61d..4c32ca30d99 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c
@@ -1,6 +1,6 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h
index abd115caf7a..04b73b7296a 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h
@@ -1,6 +1,6 @@
/* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -56,4 +56,3 @@ extern int inflate_trees_fixed OF((
inflate_huft * FAR *, /* literal/length tree result */
inflate_huft * FAR *, /* distance tree result */
z_streamp)); /* for memory allocation */
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c
index b3189642085..9a076221f2a 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c
@@ -1,6 +1,6 @@
/* inflate_util.c -- data and routines common to blocks and codes
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h
index 404a8042ebb..4401df82fc8 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h
@@ -1,6 +1,6 @@
/* infutil.h -- types and macros common to blocks and codes
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
@@ -41,7 +41,7 @@ struct inflate_blocks_state {
inflate_huft *tb; /* bit length decoding tree */
} trees; /* if DTREE, decoding info for trees */
struct {
- inflate_codes_statef
+ inflate_codes_statef
*codes;
} decode; /* if CODES, current state */
} sub; /* submode */
@@ -96,4 +96,3 @@ extern int inflate_flush OF((
struct internal_state {int dummy;}; /* for buggy compilers */
#endif
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c b/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c
index 6eea67ed6da..a16d4b14608 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c
@@ -1,6 +1,6 @@
/* maketree.c -- make inffixed.h table for decoding fixed codes
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c b/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c
index c71e743a548..97b7c2d93b2 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/minigzip.c
@@ -1,6 +1,6 @@
/* minigzip.c -- simulate gzip using the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
@@ -147,7 +147,7 @@ int gz_compress_mmap(in, out)
if (buf_len <= 0) return Z_ERRNO;
/* Now do the actual mmap: */
- buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
+ buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
if (buf == (caddr_t)(-1)) return Z_ERRNO;
/* Compress the whole file at once: */
@@ -179,8 +179,8 @@ void gz_uncompress(in, out)
if (len == 0) break;
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
- error("failed fwrite");
- }
+ error("failed fwrite");
+ }
}
if (fclose(out)) error("failed fclose");
@@ -282,16 +282,16 @@ int main(argc, argv)
while (argc > 0) {
if (strcmp(*argv, "-d") == 0)
- uncompr = 1;
+ uncompr = 1;
else if (strcmp(*argv, "-f") == 0)
- outmode[3] = 'f';
+ outmode[3] = 'f';
else if (strcmp(*argv, "-h") == 0)
- outmode[3] = 'h';
+ outmode[3] = 'h';
else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
- (*argv)[2] == 0)
- outmode[2] = (*argv)[1];
+ (*argv)[2] == 0)
+ outmode[2] = (*argv)[1];
else
- break;
+ break;
argc--, argv++;
}
if (argc == 0) {
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c b/contrib/vmap_extractor_v2/stormlib/zlib/trees.c
index d4da040ae9d..0a984056738 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/trees.c
@@ -1,6 +1,6 @@
/* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-2002 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
@@ -335,42 +335,42 @@ void gen_trees_header()
Assert (header != NULL, "Can't open trees.h");
fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
+ "/* header created automatically with -DGEN_TREES_H */\n\n");
fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
+ fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
+ static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
}
fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
+ fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
+ static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
}
fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
for (i = 0; i < DIST_CODE_LEN; i++) {
- fprintf(header, "%2u%s", _dist_code[i],
- SEPARATOR(i, DIST_CODE_LEN-1, 20));
+ fprintf(header, "%2u%s", _dist_code[i],
+ SEPARATOR(i, DIST_CODE_LEN-1, 20));
}
fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
+ fprintf(header, "%2u%s", _length_code[i],
+ SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
}
fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
+ fprintf(header, "%1u%s", base_length[i],
+ SEPARATOR(i, LENGTH_CODES-1, 20));
}
fprintf(header, "local const int base_dist[D_CODES] = {\n");
for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
+ fprintf(header, "%5u%s", base_dist[i],
+ SEPARATOR(i, D_CODES-1, 10));
}
fclose(header);
@@ -930,39 +930,39 @@ void _tr_flush_block(s, buf, stored_len, eof)
/* Build the Huffman trees unless a stored block is forced */
if (s->level > 0) {
- /* Check if the file is ascii or binary */
- if (s->data_type == Z_UNKNOWN) set_data_type(s);
+ /* Check if the file is ascii or binary */
+ if (s->data_type == Z_UNKNOWN) set_data_type(s);
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
+ /* Construct the literal and distance trees */
+ build_tree(s, (tree_desc *)(&(s->l_desc)));
+ Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
+ build_tree(s, (tree_desc *)(&(s->d_desc)));
+ Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
+ /* At this point, opt_len and static_len are the total bit lengths of
+ * the compressed block data, excluding the tree representations.
+ */
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
+ /* Build the bit length tree for the above two trees, and get the index
+ * in bl_order of the last bit length code to send.
+ */
+ max_blindex = build_bl_tree(s);
- /* Determine the best encoding. Compute first the block length in bytes*/
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
+ /* Determine the best encoding. Compute first the block length in bytes*/
+ opt_lenb = (s->opt_len+3+7)>>3;
+ static_lenb = (s->static_len+3+7)>>3;
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
+ Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
+ opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
+ s->last_lit));
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+ if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
} else {
Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
+ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
}
#ifdef FORCE_STORED
@@ -1199,7 +1199,7 @@ local void copy_block(s, buf, len, header)
s->last_eob_len = 8; /* enough lookahead for inflate */
if (header) {
- put_short(s, (ush)len);
+ put_short(s, (ush)len);
put_short(s, (ush)~len);
#ifdef DEBUG
s->bits_sent += 2*16;
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/trees.h b/contrib/vmap_extractor_v2/stormlib/zlib/trees.h
index ba8cd78357b..72facf900f7 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/trees.h
@@ -126,4 +126,3 @@ local const int base_dist[D_CODES] = {
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c b/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c
index fdd495ff4ba..a287714f5de 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c
@@ -1,6 +1,6 @@
/* uncompr.c -- decompress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h b/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h
index a22b4b058e6..eb0ae2e1a0c 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h
@@ -1,6 +1,6 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
@@ -13,39 +13,39 @@
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
+# define deflateInit_ z_deflateInit_
+# define deflate z_deflate
+# define deflateEnd z_deflateEnd
+# define inflateInit_ z_inflateInit_
+# define inflate z_inflate
+# define inflateEnd z_inflateEnd
+# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define inflateInit2_ z_inflateInit2_
+# define deflateCopy z_deflateCopy
+# define deflateReset z_deflateReset
+# define deflateParams z_deflateParams
+# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
+# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
-# define inflateReset z_inflateReset
-# define compress z_compress
-# define compress2 z_compress2
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
+# define inflateReset z_inflateReset
+# define compress z_compress
+# define compress2 z_compress2
+# define uncompress z_uncompress
+# define adler32 z_adler32
+# define crc32 z_crc32
# define get_crc_table z_get_crc_table
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
+# define Byte z_Byte
+# define uInt z_uInt
+# define uLong z_uLong
+# define Bytef z_Bytef
+# define charf z_charf
+# define intf z_intf
+# define uIntf z_uIntf
+# define uLongf z_uLongf
+# define voidpf z_voidpf
+# define voidp z_voidp
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
@@ -277,4 +277,3 @@ typedef uLong FAR uLongf;
#endif
#endif /* _ZCONF_H */
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h
index 4f6380eeb9c..52cb529f6f3 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h
@@ -39,7 +39,7 @@ extern "C" {
#define ZLIB_VERSION "1.1.4"
-/*
+/*
The 'zlib' compression library provides in-memory compression and
decompression functions, including integrity checks of the uncompressed
data. This version of the library supports only one compression method
@@ -175,7 +175,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void));
This check is automatically made by deflateInit and inflateInit.
*/
-/*
+/*
ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
Initializes the internal stream state for compression. The fields
@@ -253,7 +253,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
more input data, until it returns with Z_STREAM_END or an error. After
deflate has returned Z_STREAM_END, the only possible operations on the
stream are deflateReset or deflateEnd.
-
+
Z_FINISH can be used immediately after deflateInit if all the compression
is to be done in a single step. In this case, avail_out must be at least
0.1% larger than avail_in plus 12 bytes. If deflate does not return
@@ -290,7 +290,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
*/
-/*
+/*
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
Initializes the internal stream state for decompression. The fields
@@ -359,7 +359,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
If a preset dictionary is needed at this point (see inflateSetDictionary
below), inflate sets strm-adler to the adler32 checksum of the
- dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
+ dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
it sets strm->adler to the adler32 checksum of all output produced
so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
an error code as described below. At the end of the stream, inflate()
@@ -397,7 +397,7 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
The following functions are needed only in some special applications.
*/
-/*
+/*
ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int level,
int method,
@@ -440,7 +440,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
method). msg is set to null if there is no error message. deflateInit2 does
not perform any compression: this will be done by deflate().
*/
-
+
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary,
uInt dictLength));
@@ -507,8 +507,8 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
*/
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
+ int level,
+ int strategy));
/*
Dynamically update the compression level and compression strategy. The
interpretation of level and strategy is as in deflateInit2. This can be
@@ -527,7 +527,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
if strm->avail_out was zero.
*/
-/*
+/*
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
int windowBits));
@@ -570,7 +570,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
*/
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
+/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
available input is skipped. No output is provided.
@@ -701,8 +701,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
gzread returns the number of uncompressed bytes actually read (0 for
end of file, -1 for error). */
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- const voidp buf, unsigned len));
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+ const voidp buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes actually written
@@ -755,8 +755,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
*/
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-/*
+ z_off_t offset, int whence));
+/*
Sets the starting position for the next gzread or gzwrite on the
given compressed file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
@@ -891,4 +891,3 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
#endif
#endif /* _ZLIB_H */
-
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c
index b3189642085..9a076221f2a 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c
@@ -1,6 +1,6 @@
/* inflate_util.c -- data and routines common to blocks and codes
* Copyright (C) 1995-2002 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
+ * For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h
index c11cd2ef1f5..718ebc15be1 100644
--- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h
+++ b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h
@@ -208,7 +208,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
- uInt len));
+ uInt len));
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
@@ -218,4 +218,3 @@ void zcfree OF((voidpf opaque, voidpf ptr));
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* _Z_UTIL_H */
-
diff --git a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c b/contrib/vmap_extractor_v2/stormlibdll/DllMain.c
index d5ef37fc106..cbfa84a08a8 100644
--- a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c
+++ b/contrib/vmap_extractor_v2/stormlibdll/DllMain.c
@@ -20,5 +20,5 @@ DWORD WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved)
UNREFERENCED_PARAMETER(dwReason);
UNREFERENCED_PARAMETER(lpReserved);
- return TRUE;
+ return TRUE;
}
diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
index f624a3263cd..49717c04748 100644
--- a/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.cpp
@@ -1,5 +1,6 @@
#include "adtfile.h"
+#include <algorithm>
char * GetPlainName(char * FileName)
{
@@ -12,7 +13,8 @@ char * GetPlainName(char * FileName)
void fixnamen(char *name, size_t len)
{
- for (size_t i=0; i<len-3; i++) {
+ for (size_t i=0; i<len-3; i++)
+ {
if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1]))
{
name[i] |= 0x20;
@@ -22,6 +24,7 @@ void fixnamen(char *name, size_t len)
}
}
}
+
void fixname2(char *name, size_t len)
{
for (size_t i=0; i<len-3; i++)
@@ -38,7 +41,6 @@ ADTFile::ADTFile(char* filename): ADT(filename)
bool ADTFile::init(char *map_id)
{
-
if(ADT.isEof ())
return false;
@@ -68,8 +70,7 @@ bool ADTFile::init(char *map_id)
return false;
}
-
- while (!ADT.isEof ())
+ while (!ADT.isEof())
{
char fourcc[5];
ADT.read(&fourcc,4);
@@ -77,18 +78,16 @@ bool ADTFile::init(char *map_id)
flipcc(fourcc);
fourcc[4] = 0;
- size_t nextpos = ADT.getPos () + size;
+ size_t nextpos = ADT.getPos() + size;
- if (!strcmp(fourcc,"MCIN"))//MCIN
+ if (!strcmp(fourcc,"MCIN"))
{
-
}
else if (!strcmp(fourcc,"MTEX"))
{
}
else if (!strcmp(fourcc,"MMDX"))
{
-
if (size)
{
char *buf = new char[size];
@@ -104,35 +103,39 @@ bool ADTFile::init(char *map_id)
fixname2(s,strlen(s));
p=p+strlen(p)+1;
ModelInstansName[t++] = s;
- path.erase(path.length()-2,2);
- path.append("2");
- char* szLocalFile[512];
- sprintf((char*)szLocalFile, ".\\buildings\\%s", s);
- FILE * output = fopen((char*)szLocalFile,"rb");
- if(!output)
+
+ // < 3.1.0 ADT MMDX section store filename.mdx filenames for corresponded .m2 file
+ std::string ext3 = path.size() >= 4 ? path.substr(path.size()-4,4) : "";
+ std::transform( ext3.begin(), ext3.end(), ext3.begin(), ::tolower );
+ if(ext3 == ".mdx")
{
+ // replace .mdx -> .m2
+ path.erase(path.length()-2,2);
+ path.append("2");
+ }
+ // >= 3.1.0 ADT MMDX section store filename.m2 filenames for corresponded .m2 file
+ // nothing do
+ char szLocalFile[MAX_PATH];
+ sprintf(szLocalFile, ".\\buildings\\%s", s);
+ FILE * output = fopen(szLocalFile,"rb");
+ if(!output)
+ {
Model * m2 = new Model(path);
if(m2->open())
- {
- m2->ConvertToVMAPModel((char*)szLocalFile);
- }
+ m2->ConvertToVMAPModel(szLocalFile);
delete m2;
-
}
else
- fclose(output);
+ fclose(output);
}
-
delete[] buf;
}
-
}
else if (!strcmp(fourcc,"MWMO"))
{
if (size)
{
-
char *buf = new char[size];
ADT.read(buf, size);
char *p=buf;
@@ -148,23 +151,21 @@ bool ADTFile::init(char *map_id)
WmoInstansName[q++] = s;
}
delete[] buf;
-
}
-
}
//======================
else if (!strcmp(fourcc,"MDDF"))
{
if (size)
{
- nMDX = (int)size / 36;
- for (int i=0; i<nMDX; i++)
+ nMDX = (int)size / 36;
+ for (int i=0; i<nMDX; ++i)
{
int id;
ADT.read(&id, 4);
ModelInstance inst(ADT,ModelInstansName[id].c_str(),map_id, dirfile);//!!!!!!!!!!!
}
- delete[] ModelInstansName;
+ delete[] ModelInstansName;
}
}
else if (!strcmp(fourcc,"MODF"))
@@ -172,7 +173,7 @@ bool ADTFile::init(char *map_id)
if (size)
{
nWMO = (int)size / 64;
- for (int i=0; i<nWMO; i++)
+ for (int i=0; i<nWMO; ++i)
{
int id;
ADT.read(&id, 4);
@@ -187,14 +188,14 @@ bool ADTFile::init(char *map_id)
{
if (size)
{
- nMDX = (int)size / 36;
- for (int i=0; i<nMDX; i++)
+ nMDX = (int)size / 36;
+ for (int i=0; i<nMDX; ++i)
{
int id;
ADT.read(&id, 4);
ModelInstance inst(ADT,ModelInstansName[id].c_str(),AdtMapNumber.c_str(), dirfile);
}
- delete[] ModelInstansName;
+ delete[] ModelInstansName;
}
}
else if (!strcmp(fourcc,"MODF"))
@@ -202,7 +203,7 @@ bool ADTFile::init(char *map_id)
if (size)
{
nWMO = (int)size / 64;
- for (int i=0; i<nWMO; i++)
+ for (int i=0; i<nWMO; ++i)
{
int id;
ADT.read(&id, 4);
@@ -223,6 +224,3 @@ ADTFile::~ADTFile()
{
ADT.close();
}
-
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/adtfile.h b/contrib/vmap_extractor_v2/vmapextract/adtfile.h
index 959e1a05f7f..0ce5851ab79 100644
--- a/contrib/vmap_extractor_v2/vmapextract/adtfile.h
+++ b/contrib/vmap_extractor_v2/vmapextract/adtfile.h
@@ -17,43 +17,48 @@ typedef unsigned int uint32;
class Liquid;
-typedef struct {
-float x;
-float y;
-float z;
+typedef struct
+{
+ float x;
+ float y;
+ float z;
}svec;
-typedef struct {
-double x;
-double y;
-double z;
-}vec;
+struct vec
+{
+ double x;
+ double y;
+ double z;
+};
-typedef struct{
+struct triangle
+{
vec v[3];
+};
-}triangle;
-
-typedef struct{
-float v9[16*8+1][16*8+1];
-float v8[16*8][16*8];
+typedef struct
+{
+ float v9[16*8+1][16*8+1];
+ float v8[16*8][16*8];
}Cell;
-typedef struct{
-double v9[9][9];
-double v8[8][8];
-uint16 area_id;
-//Liquid *lq;
-float waterlevel[9][9];
-uint8 flag;
+typedef struct
+{
+ double v9[9][9];
+ double v8[8][8];
+ uint16 area_id;
+ //Liquid *lq;
+ float waterlevel[9][9];
+ uint8 flag;
}chunk;
typedef struct
{
-chunk ch[16][16];
+ chunk ch[16][16];
}mcell;
-struct MapChunkHeader {
+struct MapChunkHeader
+{
uint32 flags;
uint32 ix;
uint32 iy;
@@ -119,7 +124,4 @@ private:
void fixnamen(char *name, size_t len);
//void fixMapNamen(char *name, size_t len);
-
#endif
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp b/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp
index 909f7afd570..52eb18c42b7 100644
--- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.cpp
@@ -22,8 +22,8 @@ bool DBCFile::open()
f.read(header,4); // File Header
- if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C') {
-
+ if (header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3] != 'C')
+ {
f.close();
data = NULL;
printf("Critical Error: An error occured while trying to read the DBCFile %s.", filename.c_str());
@@ -67,10 +67,9 @@ DBCFile::Iterator DBCFile::begin()
assert(data);
return Iterator(*this, data);
}
+
DBCFile::Iterator DBCFile::end()
{
assert(data);
return Iterator(*this, stringTable);
}
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
index 4106342a2cc..002e7eeeb20 100644
--- a/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
+++ b/contrib/vmap_extractor_v2/vmapextract/dbcfile.h
@@ -137,4 +137,3 @@ private:
};
#endif
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/model.cpp b/contrib/vmap_extractor_v2/vmapextract/model.cpp
index 2bf5e8b5200..9605e3320ab 100644
--- a/contrib/vmap_extractor_v2/vmapextract/model.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/model.cpp
@@ -1,11 +1,7 @@
-//#include "common.h"
#include "model.h"
-//#include "world.h"
#include <cassert>
#include <algorithm>
-//int globalTime = 0;
-
Model::Model(std::string &filename) : filename(filename)
{
}
@@ -24,125 +20,33 @@ bool Model::open()
}
memcpy(&header, f.getBuffer(), sizeof(ModelHeader));
- if(header.nBoundingTriangles > 0) {
-
-#if 0
- animated = isAnimated(f);
- if(animated)
- {
- f.close();
- return false;
- }
-#endif
- trans = 1.0f;
- origVertices = (ModelVertex*)(f.getBuffer() + header.ofsVertices);
-
- vertices = new Vec3D[header.nVertices];
- normals = new Vec3D[header.nVertices];
-
- for (size_t i=0; i<header.nVertices; i++)
- {
- origVertices[i].pos = fixCoordSystem(origVertices[i].pos);
- origVertices[i].normal = fixCoordSystem(origVertices[i].normal);
- vertices[i] = origVertices[i].pos;
- normals[i] = origVertices[i].normal.normalize();
- }
-
- ModelView *view = (ModelView*)(f.getBuffer() + header.ofsViews);
-
- uint16 *indexLookup = (uint16*)(f.getBuffer() + view->ofsIndex);
- uint16 *triangles = (uint16*)(f.getBuffer() + view->ofsTris);
-
- nIndices = view->nTris;
- indices = new uint16[nIndices];
- for (size_t i = 0; i<nIndices; i++)
+ if(header.nBoundingTriangles > 0)
+ {
+ f.seek(0);
+ f.seekRelative(header.ofsBoundingVertices);
+ vertices = new Vec3D[header.nBoundingVertices];
+ f.read(vertices,header.nBoundingVertices*12);
+ for (uint32 i=0; i<header.nBoundingVertices; i++)
{
- indices[i] = indexLookup[triangles[i]];
+ vertices[i] = fixCoordSystem(vertices[i]);
}
+ f.seek(0);
+ f.seekRelative(header.ofsBoundingTriangles);
+ indices = new uint16[header.nBoundingTriangles];
+ f.read(indices,header.nBoundingTriangles*2);
f.close();
- } else {
+ }
+ else
+ {
//printf("not included %s\n", filename.c_str());
+ f.close();
return false;
}
return true;
-
-}
-
-bool Model::isAnimated(MPQFile &f)
-{
- // see if we have any animated bones
- ModelBoneDef *bo = (ModelBoneDef*)(f.getBuffer() + header.ofsBones);
-
- animGeometry = false;
- animBones = false;
- ind = false;
-
- ModelVertex *verts = (ModelVertex*)(f.getBuffer() + header.ofsVertices);
- for (size_t i=0; i<header.nVertices && !animGeometry; i++) {
- for (size_t b=0; b<4; b++) {
- if (verts[i].weights[b]>0) {
- ModelBoneDef &bb = bo[verts[i].bones[b]];
- if (bb.translation.type || bb.rotation.type || bb.scaling.type || (bb.flags&8)) {
- if (bb.flags&8) {
- // if we have billboarding, the model will need per-instance animation
- ind = true;
- }
- animGeometry = true;
- break;
- }
- }
- }
- }
-
- if (animGeometry) animBones = true;
- else {
- for (size_t i=0; i<header.nBones; i++) {
- ModelBoneDef &bb = bo[i];
- if (bb.translation.type || bb.rotation.type || bb.scaling.type) {
- animBones = true;
- break;
- }
- }
- }
-
- animTextures = header.nTexAnims > 0;
-
- bool animMisc = header.nCameras>0 || // why waste time, pretty much all models with cameras need animation
- header.nLights>0 || // same here
- header.nParticleEmitters>0 ||
- header.nRibbonEmitters>0;
-
- if (animMisc) animBones = true;
-
- // animated colors
- if (header.nColors) {
- ModelColorDef *cols = (ModelColorDef*)(f.getBuffer() + header.ofsColors);
- for (size_t i=0; i<header.nColors; i++) {
- if (cols[i].color.type!=0 || cols[i].opacity.type!=0) {
- animMisc = true;
- break;
- }
- }
- }
-
- // animated opacity
- if (header.nTransparency && !animMisc) {
- ModelTransDef *trs = (ModelTransDef*)(f.getBuffer() + header.ofsTransparency);
- for (size_t i=0; i<header.nTransparency; i++) {
- if (trs[i].trans.type!=0) {
- animMisc = true;
- break;
- }
- }
- }
-
- // guess not...
- return animGeometry || animTextures || animMisc;
}
bool Model::ConvertToVMAPModel(char * outfilename)
{
-
int N[] = {0x00000000};
FILE * output=fopen(outfilename,"wb");
if(!output)
@@ -151,7 +55,8 @@ bool Model::ConvertToVMAPModel(char * outfilename)
return false;
}
fwrite("VMAP002",8,1,output);
- int nVertices = header.nVertices;
+ uint32 nVertices = 0;
+ nVertices = header.nBoundingVertices;
fwrite(&nVertices, sizeof(int), 1, output);
uint32 nofgroups = 1;
fwrite(&nofgroups,sizeof(uint32), 1, output);
@@ -162,15 +67,16 @@ bool Model::ConvertToVMAPModel(char * outfilename)
wsize = sizeof(branches) + sizeof(uint32) * branches;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&branches,sizeof(branches), 1, output);
- uint32 nIdexes = (uint32) nIndices;
- fwrite(&nIndices,sizeof(uint32), 1, output);
+ uint32 nIndexes = 0;
+ nIndexes = header.nBoundingTriangles;
+ fwrite(&nIndexes,sizeof(uint32), 1, output);
fwrite("INDX",4, 1, output);
- wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
+ wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
fwrite(&wsize, sizeof(int), 1, output);
- fwrite(&nIdexes, sizeof(uint32), 1, output);
- if(nIdexes >0)
+ fwrite(&nIndexes, sizeof(uint32), 1, output);
+ if(nIndexes >0)
{
- fwrite(indices, sizeof(unsigned short), nIdexes, output);
+ fwrite(indices, sizeof(unsigned short), nIndexes, output);
}
fwrite("VERT",4, 1, output);
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
@@ -178,7 +84,7 @@ bool Model::ConvertToVMAPModel(char * outfilename)
fwrite(&nVertices, sizeof(int), 1, output);
if(nVertices >0)
{
- for(int vpos=0; vpos <nVertices; ++vpos)
+ for(uint32 vpos=0; vpos <nVertices; ++vpos)
{
float sy = vertices[vpos].y;
vertices[vpos].y = vertices[vpos].z;
@@ -189,7 +95,6 @@ bool Model::ConvertToVMAPModel(char * outfilename)
delete[] vertices;
delete[] indices;
- delete[] normals;
fclose(output);
@@ -226,18 +131,17 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
sprintf(tempname, ".\\buildings\\%s", ModelInstName);
FILE *input;
input = fopen(tempname, "r+b");
+
if(!input)
- {
return;
- }
+
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fclose(input);
+
if(nVertices == 0)
- {
return;
- }
if(pDirfile)
{
@@ -246,7 +150,6 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
int realx2 = (int) ((float) pos.x / 533.333333f);
int realy2 = (int) ((float) pos.z / 533.333333f);
-
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
MapName,
ModelInstName,
@@ -259,4 +162,3 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName,const char*Map
);
}
}
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/model.h b/contrib/vmap_extractor_v2/vmapextract/model.h
index d655587bfab..2bcb20b1172 100644
--- a/contrib/vmap_extractor_v2/vmapextract/model.h
+++ b/contrib/vmap_extractor_v2/vmapextract/model.h
@@ -4,7 +4,6 @@
#include "vec3d.h"
#include "mpq.h"
#include "modelheaders.h"
-//#include "quaternion.h"
#include <vector>
class Model;
@@ -12,38 +11,19 @@ class WMOInstance;
Vec3D fixCoordSystem(Vec3D v);
-
-
-
class Model
{
public:
ModelHeader header;
- ModelAnimation *anims;
- int *globalSequences;
-
-public:
- bool animGeometry,animTextures,animBones;
- bool animated;
-
- bool isAnimated(MPQFile &f);
- ModelVertex *origVertices;
- Vec3D *vertices, *normals;
- uint16 *indices;
+ uint32 offsBB_vertices, offsBB_indices;
+ Vec3D *BB_vertices, *vertices;
+ uint16 *BB_indices, *indices;
size_t nIndices;
bool open();
bool ConvertToVMAPModel(char * outfilename);
-public:
-
bool ok;
- bool ind;
-
- float rad;
- float trans;
- bool animcalc;
- int anim, animtime;
Model(std::string &filename);
~Model();
@@ -53,21 +33,15 @@ private:
char outfilename;
};
-class ModelInstance
+class ModelInstance
{
public:
Model *model;
int id;
-
Vec3D pos, rot;
unsigned int d1, scale;
-
- float frot,w,sc;
-
- int light;
- Vec3D ldir;
- Vec3D lcol;
+ float w,sc;
ModelInstance() {}
ModelInstance(MPQFile &f,const char* ModelInstName,const char*MapName, FILE *pDirfile);
@@ -75,4 +49,3 @@ public:
};
#endif
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
index 09dc24f14ab..445ab3843e1 100644
--- a/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
+++ b/contrib/vmap_extractor_v2/vmapextract/modelheaders.h
@@ -10,296 +10,72 @@ typedef int int32;
#pragma pack(push,1)
-struct ModelHeader {
+struct ModelHeader
+{
char id[4];
uint8 version[4];
uint32 nameLength;
uint32 nameOfs;
uint32 type;
-
uint32 nGlobalSequences;
uint32 ofsGlobalSequences;
uint32 nAnimations;
uint32 ofsAnimations;
- uint32 nC;
- uint32 ofsC;
- uint32 nD;
- uint32 ofsD;
+ uint32 nAnimationLookup;
+ uint32 ofsAnimationLookup;
uint32 nBones;
uint32 ofsBones;
- uint32 nF;
- uint32 ofsF;
-
+ uint32 nKeyBoneLookup;
+ uint32 ofsKeyBoneLookup;
uint32 nVertices;
uint32 ofsVertices;
uint32 nViews;
- uint32 ofsViews;
-
uint32 nColors;
uint32 ofsColors;
-
uint32 nTextures;
uint32 ofsTextures;
-
- uint32 nTransparency; // H
+ uint32 nTransparency;
uint32 ofsTransparency;
- uint32 nI; // always unused ?
- uint32 ofsI;
- uint32 nTexAnims; // J
- uint32 ofsTexAnims;
- uint32 nK;
- uint32 ofsK;
-
- uint32 nTexFlags;
- uint32 ofsTexFlags;
- uint32 nY;
- uint32 ofsY;
-
+ uint32 nTextureanimations;
+ uint32 ofsTextureanimations;
+ uint32 nTexReplace;
+ uint32 ofsTexReplace;
+ uint32 nRenderFlags;
+ uint32 ofsRenderFlags;
+ uint32 nBoneLookupTable;
+ uint32 ofsBoneLookupTable;
uint32 nTexLookup;
uint32 ofsTexLookup;
-
- uint32 nTexUnitLookup; // L
- uint32 ofsTexUnitLookup;
- uint32 nTransparencyLookup; // M
- uint32 ofsTransparencyLookup;
+ uint32 nTexUnits;
+ uint32 ofsTexUnits;
+ uint32 nTransLookup;
+ uint32 ofsTransLookup;
uint32 nTexAnimLookup;
uint32 ofsTexAnimLookup;
-
float floats[14];
-
uint32 nBoundingTriangles;
uint32 ofsBoundingTriangles;
uint32 nBoundingVertices;
uint32 ofsBoundingVertices;
uint32 nBoundingNormals;
uint32 ofsBoundingNormals;
-
- uint32 nO;
- uint32 ofsO;
- uint32 nP;
- uint32 ofsP;
- uint32 nQ;
- uint32 ofsQ;
- uint32 nLights; // R
+ uint32 nAttachments;
+ uint32 ofsAttachments;
+ uint32 nAttachLookup;
+ uint32 ofsAttachLookup;
+ uint32 nAttachments_2;
+ uint32 ofsAttachments_2;
+ uint32 nLights;
uint32 ofsLights;
- uint32 nCameras; // S
+ uint32 nCameras;
uint32 ofsCameras;
- uint32 nT;
- uint32 ofsT;
- uint32 nRibbonEmitters; // U
+ uint32 nCameraLookup;
+ uint32 ofsCameraLookup;
+ uint32 nRibbonEmitters;
uint32 ofsRibbonEmitters;
- uint32 nParticleEmitters; // V
+ uint32 nParticleEmitters;
uint32 ofsParticleEmitters;
-
-};
-
-// block B - animations
-struct ModelAnimation {
- uint32 animID;
- uint32 timeStart;
- uint32 timeEnd;
-
- float moveSpeed;
-
- uint32 loopType;
- uint32 flags;
- uint32 d1;
- uint32 d2;
- uint32 playSpeed; // note: this can't be play speed because it's 0 for some models
-
- Vec3D boxA, boxB;
- float rad;
-
- int16 s[2];
-};
-
-
-// sub-block in block E - animation data
-struct AnimationBlock {
- int16 type; // interpolation type (0=none, 1=linear, 2=hermite)
- int16 seq; // global sequence id or -1
- uint32 nRanges;
- uint32 ofsRanges;
- uint32 nTimes;
- uint32 ofsTimes;
- uint32 nKeys;
- uint32 ofsKeys;
-};
-
-// block E - bones
-struct ModelBoneDef {
- int32 animid;
- int32 flags;
- int16 parent; // parent bone index
- int16 geoid;
- // new int added to the bone definitions. Added in WoW 2.0
- int32 unknown;
- AnimationBlock translation;
- AnimationBlock rotation;
- AnimationBlock scaling;
- Vec3D pivot;
-};
-
-struct ModelTexAnimDef {
- AnimationBlock trans, rot, scale;
-};
-
-struct ModelVertex {
- Vec3D pos;
- uint8 weights[4];
- uint8 bones[4];
- Vec3D normal;
- Vec2D texcoords;
- int unk1, unk2; // always 0,0 so this is probably unused
-};
-
-struct ModelView {
- uint32 nIndex, ofsIndex; // Vertices in this model (index into vertices[])
- uint32 nTris, ofsTris; // indices
- uint32 nProps, ofsProps; // additional vtx properties
- uint32 nSub, ofsSub; // materials/renderops/submeshes
- uint32 nTex, ofsTex; // material properties/textures
- int32 lod; // LOD bias?
-};
-
-
-/// One material + render operation
-struct ModelGeoset {
- uint16 d1; // mesh part id?
- uint16 d2; // ?
- uint16 vstart; // first vertex
- uint16 vcount; // num vertices
- uint16 istart; // first index
- uint16 icount; // num indices
- uint16 d3; // number of bone indices
- uint16 d4; // offset into bone index list
- uint16 d5; // ?
- uint16 d6; // root bone?
- Vec3D v;
- float unknown[4]; // Added in WoW 2.0?
-};
-
-/// A texture unit (sub of material)
-struct ModelTexUnit{
- // probably the texture units
- // size always >=number of materials it seems
- uint16 flags; // Flags
- uint16 order; // ?
- uint16 op; // Material this texture is part of (index into mat)
- uint16 op2; // Always same as above?
- int16 colorIndex; // color or -1
- uint16 flagsIndex; // more flags...
- uint16 texunit; // Texture unit (0 or 1)
- uint16 d4; // ? (seems to be always 1)
- uint16 textureid; // Texture id (index into global texture list)
- uint16 texunit2; // copy of texture unit value?
- uint16 transid; // transparency id (index into transparency list)
- uint16 texanimid; // texture animation id
-};
-
-// block X - render flags
-struct ModelRenderFlags {
- uint16 flags;
- uint16 blend;
-};
-
-// block G - color defs
-struct ModelColorDef {
- AnimationBlock color;
- AnimationBlock opacity;
-};
-
-// block H - transp defs
-struct ModelTransDef {
- AnimationBlock trans;
-};
-
-struct ModelTextureDef {
- uint32 type;
- uint32 flags;
- uint32 nameLen;
- uint32 nameOfs;
-};
-
-struct ModelLightDef {
- int16 type;
- int16 bone;
- Vec3D pos;
- AnimationBlock ambColor;
- AnimationBlock ambIntensity;
- AnimationBlock color;
- AnimationBlock intensity;
- AnimationBlock attStart;
- AnimationBlock attEnd;
- AnimationBlock unk1;
-};
-
-struct ModelCameraDef {
- int32 id;
- float fov, farclip, nearclip;
- AnimationBlock transPos;
- Vec3D pos;
- AnimationBlock transTarget;
- Vec3D target;
- AnimationBlock rot;
-};
-
-
-struct ModelParticleParams {
- float mid;
- uint32 colors[3];
- float sizes[3];
- int16 d[10];
- float unk[3];
- float scales[3];
- float slowdown;
- float rotation;
- float f2[16];
-};
-
-struct ModelParticleEmitterDef {
- int32 id;
- int32 flags;
- Vec3D pos;
- int16 bone;
- int16 texture;
- int32 nZero1;
- int32 ofsZero1;
- int32 nZero2;
- int32 ofsZero2;
- int16 blend;
- int16 type;
- int16 s1;
- int16 s2;
- int16 cols;
- int16 rows;
- AnimationBlock params[10];
- ModelParticleParams p;
- AnimationBlock unk;
};
-
-struct ModelRibbonEmitterDef {
- int32 id;
- int32 bone;
- Vec3D pos;
- int32 nTextures;
- int32 ofsTextures;
- int32 nUnknown;
- int32 ofsUnknown;
- AnimationBlock color;
- AnimationBlock opacity;
- AnimationBlock above;
- AnimationBlock below;
- float res, length, unk;
- int16 s1, s2;
- AnimationBlock unk1;
- AnimationBlock unk2;
-};
-
-
#pragma pack(pop)
-
-
#endif
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp b/contrib/vmap_extractor_v2/vmapextract/mpq.cpp
index cd9d62869aa..0d72f06a7da 100644
--- a/contrib/vmap_extractor_v2/vmapextract/mpq.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/mpq.cpp
@@ -3,24 +3,16 @@
#include "Stormlib.h"
#define __STORMLIB_SELF__
-typedef std::vector<MPQArchive*> ArchiveSet;
-ArchiveSet gOpenArchives;
+MPQArchiveSet gOpenArchives;
+
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MPQArchive::MPQArchive(const char* filename)
{
BOOL succ = SFileOpenArchive(filename, 0, 0,&hMPQ);
if (succ)
- {
- MPQArchive*ar = (MPQArchive*)(hMPQ);
printf("Opening %s\n", filename);
- gOpenArchives.push_back(ar);
- succ = true;
-
- }
else
- {
printf("Error!!!Not open archive %s\n", filename);
- }
}
void MPQArchive::close()
@@ -28,41 +20,57 @@ void MPQArchive::close()
SFileCloseArchive(hMPQ);
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+bool MPQArchiveSet::Open( std::vector<std::string> const& archiveNames )
+{
+ for (size_t i=0; i < archiveNames.size(); ++i)
+ {
+ MPQArchive mpqarch(archiveNames[i].c_str());
+ if(mpqarch.isOpen())
+ archives.push_back(mpqarch);
+ }
+
+ return !archives.empty();
+}
+
+MPQArchiveSet::~MPQArchiveSet()
+{
+ // close archives
+ for (ArchiveSet::iterator ar_itr = archives.begin(); ar_itr != archives.end(); ++ar_itr)
+ ar_itr->close();
+}
+
MPQFile::MPQFile(const char* filename):
eof(false),
buffer(0),
pointer(0),
size(0)
{
- for(ArchiveSet::iterator i=gOpenArchives.begin(); i!=gOpenArchives.end();++i)
+ for(ArchiveSet::const_iterator i=gOpenArchives.archives.begin(); i!=gOpenArchives.archives.end();++i)
{
-
- HANDLE hFile = "";
- MPQArchive*(hMPQ) = *i;
- BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
- if (succ)
- {
- DWORD s = SFileGetFileSize(hFile, 0);
- if (!s)
- {
- eof = true;
- buffer = 0;
+ HANDLE hFile = "";
+ hMPQ = i->hMPQ;
+ BOOL succ = SFileOpenFileEx(hMPQ,filename,0, &hFile);
+ if (succ)
+ {
+ DWORD s = SFileGetFileSize(hFile, 0);
+ if (!s)
+ {
+ eof = true;
+ buffer = 0;
+ return;
+ }
+ size = (size_t)s;
+ buffer = new char[s];
+ SFileReadFile(hFile, buffer, s, 0, 0);
+ SFileCloseFile(hFile);
+
+ eof = false;
return;
- }
- size = (size_t)s;
- buffer = new char[s];
- SFileReadFile(hFile, buffer, s, 0, 0);
- SFileCloseFile(hFile);
-
- eof = false;
- return;
- }
+ }
}
eof = true;
buffer = 0;
-
}
MPQFile::~MPQFile()
@@ -73,7 +81,7 @@ MPQFile::~MPQFile()
size_t MPQFile::read(void* dest, size_t bytes)
{
if (eof)
- return 0;
+ return 0;
size_t rpos = pointer + bytes;
if (rpos > size)
@@ -109,7 +117,7 @@ void MPQFile::seekRelative(int offset)
void MPQFile::close()
{
if (buffer)
- delete[] buffer;
+ delete[] buffer;
buffer = 0;
eof = true;
}
@@ -133,5 +141,3 @@ char* MPQFile::getPointer()
{
return buffer + pointer;
}
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/mpq.h b/contrib/vmap_extractor_v2/vmapextract/mpq.h
index dc51998ba25..0d1d1485135 100644
--- a/contrib/vmap_extractor_v2/vmapextract/mpq.h
+++ b/contrib/vmap_extractor_v2/vmapextract/mpq.h
@@ -15,16 +15,30 @@ using namespace std;
typedef unsigned int uint32;
-
class MPQArchive
{
+ public:
+ HANDLE hMPQ;
+ MPQArchive(const char* filename);
+ void close();
+ bool isOpen() const { return hMPQ != 0; }
+};
-public:
- HANDLE hMPQ;
- MPQArchive(const char* filename);
- void close();
+typedef std::vector<MPQArchive> ArchiveSet;
+
+class MPQArchiveSet
+{
+ public:
+ MPQArchiveSet() {}
+ ~MPQArchiveSet();
+
+ bool Open(std::vector<std::string> const& archiveNames);
+
+ ArchiveSet archives;
};
+extern MPQArchiveSet gOpenArchives;
+
class MPQFile
{
HANDLE hFile;
@@ -63,8 +77,4 @@ inline void flipcc(char *fcc)
fcc[2]=t;
}
-
-
#endif
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/vec3d.h b/contrib/vmap_extractor_v2/vmapextract/vec3d.h
index c6d2ae57ed2..40513552181 100644
--- a/contrib/vmap_extractor_v2/vmapextract/vec3d.h
+++ b/contrib/vmap_extractor_v2/vmapextract/vec3d.h
@@ -4,9 +4,8 @@
#include <iostream>
#include <cmath>
-
-
-class Vec3D {
+class Vec3D
+{
public:
float x,y,z;
@@ -112,11 +111,11 @@ public:
{
return (float*)this;
}
-
};
-class Vec2D {
+class Vec2D
+{
public:
float x,y;
@@ -213,10 +212,8 @@ public:
{
return (float*)this;
}
-
};
-
inline void rotate(float x0, float y0, float *x, float *y, float angle)
{
float xa = *x - x0, ya = *y - y0;
@@ -224,8 +221,4 @@ inline void rotate(float x0, float y0, float *x, float *y, float angle)
*y = xa*sinf(angle) + ya*cosf(angle) + y0;
}
-
-
#endif
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
index cc16c9a7176..a96a404f62d 100644
--- a/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/vmapexport.cpp
@@ -44,7 +44,8 @@
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
-typedef struct{
+typedef struct
+{
char name[64];
unsigned int id;
}map_id;
@@ -86,9 +87,10 @@ static const char * GetPlainName(const char * szFileName)
szFileName = szTemp + 1;
return szFileName;
}
-//------------------------------------------------------------------------------
+
static void ShowProcessedFile(const char * szFileName)
{
+/* not truncate file names in output
char szLine[80];
size_t nLength = strlen(szFileName);
@@ -99,16 +101,14 @@ static void ShowProcessedFile(const char * szFileName)
nLength = sizeof(szLine)-1;
memcpy(szLine, szFileName, nLength);
printf("\r%s\n", szLine);
+*/
+ printf("\r%s\n", szFileName);
}
-
-//----------------------------------------------------------------------------------------------------------------------------------------------------------------------
-int ExtractWmo(const std::vector<std::string>& pArchiveNames)
+int ExtractWmo()
{
-
char* szListFile = "";
char szLocalFile[MAX_PATH] = "";
- HANDLE hMpq = "";
BOOL bResult = FALSE;
//const char* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
@@ -116,21 +116,14 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
int nError = ERROR_SUCCESS;
if(szListFile == NULL || *szListFile == 0)
szListFile = NULL;
- //char tmp[1024];
- //for (size_t i=0; i<4; i++)
- for (size_t i=0; i<pArchiveNames.size(); i++)
- {
-
- //sprintf(tmp,"%s\\%s", input_path, ParsArchiveNames[i]);
- //if(!SFileOpenArchive(tmp, 0, 0, &hMpq))
- if(!SFileOpenArchive(pArchiveNames[i].c_str(), 0, 0, &hMpq))
- printf("NOT open!!! %s\n",pArchiveNames[i].c_str());
+ for (ArchiveSet::const_iterator ar_itr = gOpenArchives.archives.begin(); ar_itr != gOpenArchives.archives.end(); ++ar_itr)
+ {
// Copy files from archive
if(nError == ERROR_SUCCESS)
{
SFILE_FIND_DATA wf;
- HANDLE hFind = SFileFindFirstFile(hMpq,"*.wmo*", &wf, szListFile);
+ HANDLE hFind = SFileFindFirstFile(ar_itr->hMPQ,"*.wmo*", &wf, szListFile);
bResult = TRUE;
while(hFind != NULL && bResult == TRUE)
@@ -149,7 +142,7 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
{
char cpy[4];
strncpy((char*)cpy,rchr,4);
- for (int i=0;i<4;i++)
+ for (int i=0;i<4; ++i)
{
int m = cpy[i];
if(isdigit(m))
@@ -167,17 +160,17 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
bResult = SFileFindNextFile(hFind, &wf);
continue;
}
- FILE *output=fopen(szLocalFile,"wb");
+ FILE *output=fopen(szLocalFile,"wb");
froot->ConvertToVMAPRootWmo(output);
int Wmo_nVertices = 0;
if(froot->nGroups !=0)
{
- for (int i=0; i<froot->nGroups; i++)
+ for (int i=0; i<froot->nGroups; ++i)
{
- char temp[512];
+ char temp[MAX_PATH];
strcpy(temp, wf.cFileName);
temp[strlen(wf.cFileName)-4] = 0;
- char groupFileName[512];
+ char groupFileName[MAX_PATH];
sprintf(groupFileName,"%s_%03d.wmo",temp, i);
printf("%s\n",groupFileName);
//printf("GroupWmo!\n");
@@ -196,7 +189,9 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
fwrite(&Wmo_nVertices,sizeof(int),1,output);
fclose(output);
}
- } else {
+ }
+ else
+ {
fclose(n);
}
wf.dwFileFlags &= ~MPQ_FILE_HAS_EXTRA;
@@ -210,39 +205,34 @@ int ExtractWmo(const std::vector<std::string>& pArchiveNames)
// Close the search handle
if(hFind != NULL)
SFileFindClose(hFind);
-
}
}
- // Close both archives
- if(hMpq != NULL)
- //SFileCloseArchive(hMpq);
- if(nError == ERROR_SUCCESS)
- printf("\nExtract wmo complete (No errors)\n");
- return nError;
+ if(nError == ERROR_SUCCESS)
+ printf("\nExtract wmo complete (No errors)\n");
+ return nError;
}
void ExtractMapsFromMpq()
{
-
}
-//-----------------------------------------------------------------------------
+
void ParsMapFiles()
{
char fn[512];
char id_filename[64];
char id[10];
- for (unsigned int i=0; i<map_count; i++)
+ for (unsigned int i=0; i<map_count; ++i)
{
sprintf(id,"%03u",map_ids[i].id);
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
WDTFile WDT(fn,map_ids[i].name);
if(WDT.init(id))
{
- for (int x=0; x<64; x++)
+ for (int x=0; x<64; ++x)
{
- for (int y=0; y<64; y++)
+ for (int y=0; y<64; ++y)
{
if (ADTFile*ADT = WDT.GetMap(x,y))
{
@@ -250,7 +240,6 @@ void ParsMapFiles()
ADT->init(id_filename);
delete ADT;
}
-
}
}
}
@@ -259,31 +248,28 @@ void ParsMapFiles()
#if 0
void ParsMapFiles()
{
-
char fn[512];
- for (unsigned int i=0; i<map_count; i++)
+ for (unsigned int i=0; i<map_count; ++i)
{
sprintf(fn,"World\\Maps\\%s\\%s.wdt", map_ids[i].name, map_ids[i].name);
WDTFile WDT(fn,map_ids[i].name);
if(WDT.init())
{
- for (int x=0; x<64; x++)
+ for (int x=0; x<64; ++x)
{
- for (int y=0; y<64; y++)
+ for (int y=0; y<64; ++y)
{
if (ADTFile*ADT = WDT.GetMap(x,y))
{
ADT->init();
delete ADT;
}
-
}
}
}
}
}
#endif
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void getGamePath()
{
@@ -307,8 +293,6 @@ void getGamePath()
#endif
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
{
int i;
@@ -338,7 +322,7 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
}
matches.reverse();
- for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); i++)
+ for (std::list<std::string>::iterator i = matches.begin(); i != matches.end(); ++i)
{
pArchiveNames.push_back(i->c_str());
}
@@ -348,11 +332,8 @@ bool scan_patches(char* scanmatch, std::vector<std::string>& pArchiveNames)
return(true);
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
-bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
- //srand((unsigned int)time(0));
-
+bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
+{
if(!hasInputPathParam)
getGamePath();
@@ -408,11 +389,12 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
// now, scan for the patch levels in the core dir
printf("Loading patch levels from data directory.\n");
sprintf(path, "%spatch", input_path);
- if (!scan_patches(path, pArchiveNames)) return(false);
+ if (!scan_patches(path, pArchiveNames))
+ return(false);
// now, scan for the patch levels in locale dirs
printf("Loading patch levels from locale directories.\n");
- for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
+ for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
{
printf("Locale: %s\n", i->c_str());
sprintf(path, "%s%s\\patch-%s", input_path, i->c_str(), i->c_str());
@@ -421,6 +403,10 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
// open expansion and common files
printf("Opening data files from data directory.\n");
+ sprintf(path, "%slichking.mpq", input_path);
+ pArchiveNames.push_back(path);
+ sprintf(path, "%scommon-2.mpq", input_path);
+ pArchiveNames.push_back(path);
sprintf(path, "%sexpansion.mpq", input_path);
pArchiveNames.push_back(path);
sprintf(path, "%scommon.mpq", input_path);
@@ -429,9 +415,11 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
// open locale expansion and common files
printf("Opening data files from locale directories.\n");
- for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); i++)
+ for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i)
{
printf("Locale: %s\n", i->c_str());
+ sprintf(path, "%s%s\\lichking-locale-%s.mpq", input_path, i->c_str(), i->c_str());
+ pArchiveNames.push_back(path);
sprintf(path, "%s%s\\expansion-locale-%s.mpq", input_path, i->c_str(), i->c_str());
pArchiveNames.push_back(path);
sprintf(path, "%s%s\\locale-%s.mpq", input_path, i->c_str(), i->c_str());
@@ -440,8 +428,6 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) {
}
return true;
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-// return false it normal processing can not proceed
bool processArgv(int argc, char ** argv, char*versionString)
{
@@ -449,29 +435,43 @@ bool processArgv(int argc, char ** argv, char*versionString)
hasInputPathParam = false;
bool preciseVectorData = false;
- for(int i=1; i< argc; ++i) {
- if(strcmp("-s",argv[i]) == 0) {
+ for(int i=1; i< argc; ++i)
+ {
+ if(strcmp("-s",argv[i]) == 0)
+ {
preciseVectorData = false;
- } else if(strcmp("-d",argv[i]) == 0) {
- if((i+1)<argc) {
+ }
+ else if(strcmp("-d",argv[i]) == 0)
+ {
+ if((i+1)<argc)
+ {
hasInputPathParam = true;
strcpy(input_path, argv[i+1]);
if (input_path[strlen(input_path) - 1] != '\\' || input_path[strlen(input_path) - 1] != '/')
strcat(input_path, "\\");
++i;
- } else {
+ }
+ else
+ {
result = false;
}
- } else if(strcmp("-?",argv[1]) == 0) {
+ }
+ else if(strcmp("-?",argv[1]) == 0)
+ {
result = false;
- } else if(strcmp("-l",argv[i]) == 0) {
+ }
+ else if(strcmp("-l",argv[i]) == 0)
+ {
preciseVectorData = true;
- } else {
+ }
+ else
+ {
result = false;
break;
}
}
- if(!result) {
+ if(!result)
+ {
printf("Extract %s.\n",versionString);
printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n");
@@ -484,7 +484,7 @@ bool processArgv(int argc, char ** argv, char*versionString)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Main
-//
+//
// The program must be run with two command line arguments
//
// Arg1 - The source MPQ name (for testing reading and file find)
@@ -523,28 +523,33 @@ int main(int argc, char ** argv)
if(nError == ERROR_ALREADY_EXISTS)
nError = ERROR_SUCCESS;
}
- //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- // patch goes first -> fake priority handling
- std::vector<MPQArchive*> archives;
- //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ // prepare archive name list
std::vector<std::string> archiveNames;
-
fillArchiveNameVector(archiveNames);
- for (size_t i=0; i<archiveNames.size(); i++) {
- archives.push_back(new MPQArchive(archiveNames[i].c_str()));
+ if(!gOpenArchives.Open(archiveNames))
+ {
+ printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path);
+ return 1;
}
- ExtractWmo(archiveNames);
- //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ // extract data
+ ExtractWmo();
+
+ //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//map.dbc
if(nError == ERROR_SUCCESS)
{
DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc");
- dbc->open();
+ if(!dbc->open())
+ {
+ delete dbc;
+ printf("FATAL ERROR: Map.dbc not found in data file.\n");
+ return 1;
+ }
map_count=dbc->getRecordCount ();
map_ids=new map_id[map_count];
- for(unsigned int x=0;x<map_count;x++)
+ for(unsigned int x=0;x<map_count;++x)
{
map_ids[x].id=dbc->getRecord (x).getUInt(0);
strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
@@ -558,10 +563,11 @@ int main(int argc, char ** argv)
}
clreol();
- if(nError != ERROR_SUCCESS) {
+ if(nError != ERROR_SUCCESS)
+ {
printf("ERROR: Extract %s. Work NOT complete.\n Precise vector data=%d.\nPress any key.\n",versionString, preciseVectorData);
_getch();
}
+
printf("Extract %s. Work complete. No errors.",versionString);
}
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp
index 290d0b2feeb..697f9b33b5b 100644
--- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.cpp
@@ -3,7 +3,6 @@
#include "wdtfile.h"
#include "adtfile.h"
-
char * wdtGetPlainName(char * FileName)
{
char * szTemp;
@@ -20,17 +19,15 @@ WDTFile::WDTFile(char* file_name, char* file_name1):WDT(file_name)
bool WDTFile::init(char *map_id)
{
-
if (WDT.isEof())
{
- //printf("Can't find WDT file.\n");
- return false;
+ //printf("Can't find WDT file.\n");
+ return false;
}
char fourcc[5];
size_t size;
-
const char dirname[] = "buildings\\dir";
FILE *dirfile;
dirfile = fopen(dirname, "ab");
@@ -40,7 +37,6 @@ bool WDTFile::init(char *map_id)
return false;
}
-
while (!WDT.isEof())
{
WDT.read(fourcc,4);
@@ -75,8 +71,7 @@ bool WDTFile::init(char *map_id)
delete[] buf;
}
}
- else
- if (!strcmp(fourcc,"MODF"))
+ else if (!strcmp(fourcc,"MODF"))
{
// global wmo instance data
if (size)
@@ -87,13 +82,13 @@ bool WDTFile::init(char *map_id)
fake_mapname = "65 65 ";
//gWMO_mapname = fake_mapname + filename;
gWMO_mapname = fake_mapname + std::string(map_id);
- for (int i=0; i<gnWMO; i++)
+ for (int i=0; i<gnWMO; ++i)
{
int id;
WDT.read(&id, 4);
WMOInstance inst(WDT,gWmoInstansName[id].c_str(),gWMO_mapname.c_str(), dirfile);
}
- delete[] gWmoInstansName;
+ delete[] gWmoInstansName;
}
}
WDT.seek((int)nextpos);
@@ -111,11 +106,11 @@ WDTFile::~WDTFile(void)
ADTFile* WDTFile::GetMap(int x, int z)
{
- if(!(x>=0 && z >= 0 && x<64 && z<64)) return NULL;
+ if(!(x>=0 && z >= 0 && x<64 && z<64))
+ return NULL;
char name[512];
sprintf(name,"World\\Maps\\%s\\%s_%d_%d.adt", filename.c_str(), filename.c_str(), x, z);
return new ADTFile(name);
}
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h
index e9dcc77562d..0baef22f185 100644
--- a/contrib/vmap_extractor_v2/vmapextract/wdtfile.h
+++ b/contrib/vmap_extractor_v2/vmapextract/wdtfile.h
@@ -28,4 +28,3 @@ private:
};
#endif
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp
index f1868ccf64a..4817e14c85b 100644
--- a/contrib/vmap_extractor_v2/vmapextract/wmo.cpp
+++ b/contrib/vmap_extractor_v2/vmapextract/wmo.cpp
@@ -6,15 +6,12 @@
using namespace std;
-
WMORoot::WMORoot(std::string &filename) : filename(filename)
{
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
bool WMORoot::open()
{
-
MPQFile f(filename.c_str());
if(f.isEof ())
{
@@ -27,7 +24,7 @@ bool WMORoot::open()
bbcorn1[3] = 0;
bbcorn2[3]= 0;
- while (!f.isEof ())
+ while (!f.isEof())
{
f.read(fourcc,4);
f.read(&size, 4);
@@ -39,7 +36,6 @@ bool WMORoot::open()
if (!strcmp(fourcc,"MOHD"))//header
{
-
f.read(&nTextures, 4);
f.read(&nGroups, 4);
f.read(&nP, 4);
@@ -56,55 +52,42 @@ bool WMORoot::open()
/*
else if (!strcmp(fourcc,"MOTX"))
{
-
}
else if (!strcmp(fourcc,"MOMT"))
{
-
}
else if (!strcmp(fourcc,"MOGN"))
{
-
}
else if (!strcmp(fourcc,"MOGI"))
{
-
}
else if (!strcmp(fourcc,"MOLT"))
{
-
}
else if (!strcmp(fourcc,"MODN"))
{
-
}
else if (!strcmp(fourcc,"MODS"))
{
-
}
else if (!strcmp(fourcc,"MODD"))
{
-
}
else if (!strcmp(fourcc,"MOSB"))
{
-
}
else if (!strcmp(fourcc,"MOPV"))
{
-
}
else if (!strcmp(fourcc,"MOPT"))
{
-
}
else if (!strcmp(fourcc,"MOPR"))
{
-
}
else if (!strcmp(fourcc,"MFOG"))
{
-
}
*/
f.seek((int)nextpos);
@@ -112,7 +95,6 @@ bool WMORoot::open()
f.close ();
return true;
}
-//---------------------------------------------------------------------------
bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
{
@@ -125,16 +107,14 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile)
return true;
}
-//----------------------------------------------------------------------------
WMORoot::~WMORoot()
{
}
-//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WMOGroup::WMOGroup(std::string &filename) : filename(filename)
{
}
-//---------------------------------------------------------------------------
+
bool WMOGroup::open()
{
MPQFile f(filename.c_str());
@@ -147,7 +127,7 @@ bool WMOGroup::open()
char fourcc[5];
bbcorn1[3] = 0;
bbcorn2[3] = 0;
- while (!f.isEof ())
+ while (!f.isEof())
{
f.read(fourcc,4);
f.read(&size, 4);
@@ -188,7 +168,6 @@ bool WMOGroup::open()
{
MOVI = new uint16[size/2];
f.read(MOVI, size);
-
}
else if (!strcmp(fourcc,"MOVT"))
{
@@ -222,26 +201,26 @@ bool WMOGroup::open()
LiquEx = new float[sizeof(float) * 3 * noVer];
int p = 0;
- for (int j=0; j<hlq.yverts; j++)
+ for (int j=0; j<hlq.yverts; ++j)
{
- for (int i=0; i<hlq.xverts; i++)
+ for (int i=0; i<hlq.xverts; ++i)
{
LiquEx[p++] = hlq.pos_x + tilesize * i;
LiquEx[p++] = hlq.pos_z;
LiquEx[p++] = ydir * (hlq.pos_y + tilesize * j);
}
}
-
}
f.seek((int)nextpos);
}
- f.close ();
+ f.close();
return true;
}
-//----------------------------------------------------------------------------
+
int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
{
- if(pPreciseVectorData) {
+ if(pPreciseVectorData)
+ {
fwrite(&liquflags,sizeof(uint32),1,output);
char GRP[] = "GRP ";
fwrite(GRP,1,4,output);
@@ -262,20 +241,54 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
uint32 nIdexes = nTriangles * 3;
- if(fwrite("INDX",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
+ if(fwrite("INDX",4, 1, output) != 1)
+ {
+ printf("Error while writing file nbraches ID");
+ exit(0);
+ }
int wsize = sizeof(uint32) + sizeof(unsigned short) * nIdexes;
- if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
- if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1) { printf("Error while writing file nIndexes"); exit(0); }
- if(nIdexes >0) {
- if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes) { printf("Error while writing file indexarray"); exit(0); }
+ if(fwrite(&wsize, sizeof(int), 1, output) != 1)
+ {
+ printf("Error while writing file wsize");
+ // no need to exit?
+ }
+ if(fwrite(&nIdexes, sizeof(uint32), 1, output) != 1)
+ {
+ printf("Error while writing file nIndexes");
+ exit(0);
+ }
+ if(nIdexes >0)
+ {
+ if(fwrite(MOVI, sizeof(unsigned short), nIdexes, output) != nIdexes)
+ {
+ printf("Error while writing file indexarray");
+ exit(0);
+ }
}
- if(fwrite("VERT",4, 1, output) != 1) { printf("Error while writing file nbraches ID"); exit(0); }
+ if(fwrite("VERT",4, 1, output) != 1)
+ {
+ printf("Error while writing file nbraches ID");
+ exit(0);
+ }
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
- if(fwrite(&wsize, sizeof(int), 1, output) != 1) { printf("Error while writing file wsize"); }
- if(fwrite(&nVertices, sizeof(int), 1, output) != 1) { printf("Error while writing file nVertices"); exit(0); }
- if(nVertices >0) {
- if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices) { printf("Error while writing file vectors"); exit(0); }
+ if(fwrite(&wsize, sizeof(int), 1, output) != 1)
+ {
+ printf("Error while writing file wsize");
+ // no need to exit?
+ }
+ if(fwrite(&nVertices, sizeof(int), 1, output) != 1)
+ {
+ printf("Error while writing file nVertices");
+ exit(0);
+ }
+ if(nVertices >0)
+ {
+ if(fwrite(MOVT, sizeof(float)*3, nVertices, output) != nVertices)
+ {
+ printf("Error while writing file vectors");
+ exit(0);
+ }
}
if(LiquEx_size != 0)
@@ -287,7 +300,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
}
return nTriangles;
- } else {
+ }
+ else
+ {
//printf("Convert GroupWmo...\n");
//-------GRP -------------------------------------
fwrite(&liquflags,sizeof(uint32),1,output);
@@ -315,7 +330,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
IndexExTr = new int[mopy_size];
for (int i=0; i<mopy_size; i+=2)
{
- if ((int)MOPY[i]==0x00000008 ||(int)MOPY[i]==0x00000009 ||(int)MOPY[i]==0x00000020 ||(int)MOPY[i]==0x00000021 ||(int)MOPY[i]==0x00000022 ||(int)MOPY[i]==0x00000048 ||(int)MOPY[i]==0x00000049 ||(int)MOPY[i]==0x00000060 ||(int)MOPY[i]==0x00000061 ||(int)MOPY[i]==0x00000062 ||(int)MOPY[i]==0x0000000A ||(int)MOPY[i]==0x0000004A)
+ // Skip no collision triangles
+ if ((int)MOPY[i]&WMO_MATERIAL_NO_COLLISION)
+ continue;
+ // Use only this triangles
+ if ((int)MOPY[i]&(WMO_MATERIAL_HINT|WMO_MATERIAL_COLLIDE_HIT))
{
MopyEx[n] = MOPY[i];
MopyEx[(n+1)] = MOPY[(i+1)];
@@ -332,11 +351,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
//---------MOVI-----------
MoviEx = new uint16[IndexExTr_size*3];
int m = 0;
- for (int i=0; i<IndexExTr_size; i++)
+ for (int i=0; i<IndexExTr_size; ++i)
{
int n = 0;
n = IndexExTr[i]*3;
- for (int x=0; x<3; x++)
+ for (int x=0; x<3; ++x)
{
MoviEx[m] = MOVI[n];
n++;
@@ -346,15 +365,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
delete [] MOVI;
MoviExSort = new uint16[IndexExTr_size*3];
- for(int y=0; y<IndexExTr_size*3; y++)
+ for(int y=0; y<IndexExTr_size*3; ++y)
{
MoviExSort[y]=MoviEx[y];
}
uint16 hold;
- for (int pass = 1; pass < IndexExTr_size*3; pass++)
+ for (int pass = 1; pass < IndexExTr_size*3; ++pass)
{
- for (int i=0; i < IndexExTr_size*3-1; i++)
+ for (int i=0; i < IndexExTr_size*3-1; ++i)
{
if (MoviExSort[i] > MoviExSort[i+1])
{
@@ -370,7 +389,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
}
// double delet
uint16 s = 0;
- for (int i=0; i < IndexExTr_size*3; i++)
+ for (int i=0; i < IndexExTr_size*3; ++i)
{
if (MoviExSort[i]!=65535)
{
@@ -379,24 +398,22 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
}
}
MovtExSort = new uint16[s];
- for (int i=0; i < s; i++)
+ for (int i=0; i < s; ++i)
{
MovtExSort[i] = MoviExSort[i];
}
- for (int i=0; i < IndexExTr_size*3; i++)
+ for (int i=0; i < IndexExTr_size*3; ++i)
{
uint16 b = MoviEx[i];
- for (uint16 x = 0; x < s; x++)
+ for (uint16 x = 0; x < s; ++x)
{
if(MoviExSort[x] == b)
{
-
MoviEx[i] = x;
break;
}
}
-
}
int INDX[] = {0x58444E49,IndexExTr_size*6+4,IndexExTr_size*3};
fwrite(INDX,4,3,output);
@@ -410,11 +427,11 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, bool pPreciseVectorData)
//-----MOVT----------
int d = 0;
MovtEx = new float[s*3];
- for (uint16 i=0; i<s; i++)
+ for (uint16 i=0; i<s; ++i)
{
int c=0;//!!!!data in MovtExSort[i] more uint16 in great group wmo files!!!!
c = MovtExSort[i]*3;
- for (int y=0; y<3; y++)
+ for (int y=0; y<3; ++y)
{
MovtEx[d] = MOVT[c];
c++;
@@ -482,25 +499,24 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
//-----------add_in _dir_file----------------
char tempname[512];
- // const char dirname[] = "buildings\\dir";
+ // const char dirname[] = "buildings\\dir";
sprintf(tempname, "buildings\\%s", WmoInstName);
FILE *input;
input = fopen(tempname, "r+b");
+
if(!input)
- {
return;
- }
+
fseek(input, 8, SEEK_SET); // get the correct no of vertices
int nVertices;
fread(&nVertices, sizeof (int), 1, input);
fclose(input);
+
if(nVertices == 0)
- {
return;
- }
- /* FILE *dirfile;
+ /* FILE *dirfile;
dirfile = fopen(dirname, "ab");
if(!dirfile)
{
@@ -512,7 +528,11 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
x = pos.x;
z = pos.z;
if(x==0 && z == 0)
- { x = 533.33333f*32; z = 533.33333f*32; }
+ {
+ x = 533.33333f*32;
+ z = 533.33333f*32;
+ }
+
fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n",
MapName,
WmoInstName,
@@ -525,8 +545,3 @@ WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName,const char*MapName,
// fclose(dirfile);
}
-
-
-
-
-
diff --git a/contrib/vmap_extractor_v2/vmapextract/wmo.h b/contrib/vmap_extractor_v2/vmapextract/wmo.h
index 832f9265434..3000050c170 100644
--- a/contrib/vmap_extractor_v2/vmapextract/wmo.h
+++ b/contrib/vmap_extractor_v2/vmapextract/wmo.h
@@ -10,6 +10,14 @@
#include <set>
#include "mpq.h"
+// MOPY flags
+#define WMO_MATERIAL_NOCAMCOLLIDE 0x01
+#define WMO_MATERIAL_DETAIL 0x02
+#define WMO_MATERIAL_NO_COLLISION 0x04
+#define WMO_MATERIAL_HINT 0x08
+#define WMO_MATERIAL_RENDER 0x10
+#define WMO_MATERIAL_COLLIDE_HIT 0x20
+#define WMO_MATERIAL_WALL_SURFACE 0x40
class WMOInstance;
class WMOManager;
@@ -35,13 +43,11 @@ public:
private:
std::string filename;
char outfilename;
-
};
class WMOGroup
{
public:
-
int offsize,flag,flag1,Xid,Xid2,Xid3,zero1,Xflag,nTexture,GroupID;
int mopy_size,moba_size,hlq_xverts,hlq_yverts;
int MopyEx_size,IndexExTr_size,LiquEx_size;
@@ -74,10 +80,9 @@ public:
private:
std::string filename;
char outfilename;
-
};
-struct WMOLiquidHeader
+struct WMOLiquidHeader
{
int xverts, yverts, xtiles, ytiles;
float pos_x;
@@ -86,7 +91,7 @@ struct WMOLiquidHeader
short type;
};
-class WMOInstance
+class WMOInstance
{
static std::set<int> ids;
public:
@@ -105,4 +110,3 @@ public:
};
#endif
-