This commit is contained in:
DarthArgus
2016-06-04 16:20:26 -07:00
parent 20ec585266
commit 4e59befe09
4921 changed files with 30 additions and 2712356 deletions
-5
View File
@@ -1,5 +0,0 @@
AUTOMAKE_OPTIONS=foreign
SUBDIRS=shared server .
include $(engine_dir)/../make_include/engine.include
-13
View File
@@ -1,13 +0,0 @@
#!/bin/sh
if ! test -d config; then
mkdir config;
fi
aclocal && libtoolize --force && automake --force --foreign --add-missing --copy && autoconf
SUBDIRS=
for d in $SUBDIRS; do
cd $d && ./bootstrap && cd ..
done
-198
View File
@@ -1,198 +0,0 @@
###############################################################################
#
# Master Makefile for Engine
#
# This file invokes the makefiles for specific engine projects as needed.
#
# Organization:
# Targets
# Definitions and includes
# Application build rules (all applications build required libs implicitly)
# Special targets (e.g. clean, publish, dependcheck)
#
# Typically used targets:
# make engine_debug Builds the debug version of all libs/applications
# make engine_release Builds the release version of all libs/applications
# make noGameServer_<debug/release> Builds everything except the SwgGameServer and
# SwgDatabaseServer procs. (libgameServer.a is
# enormous, so excluding it is sometimes a good
# idea, if you do not really need to rebuild it.)
# make <servername> Builds a server process and any libraries needed by that process.
# e.g. make GameServer_d
###############################################################################
noGameServer_debug: CentralServer_d \
ConnectionServer_d \
LoginServer_d \
ServerConsole_d \
PlanetServer_d \
TaskManager_d \
ChatServer_d \
LogServer_d \
MetricsServer_d \
LoginPing_d \
CustomerServiceServer_d \
CommoditiesServer_d \
noGameServer_release: CentralServer_r \
ConnectionServer_r \
LoginServer_r \
ServerConsole_r \
PlanetServer_r \
TaskManager_r \
ChatServer_r \
LogServer_r \
MetricsServer_r \
LoginPing_r \
CustomerServiceServer_r \
CommoditiesServer_r \
engine_debug: noGameServer_debug \
engine_release: noGameServer_release \
SwgGameServer_r \
SwgDatabaseServer_r \
###############################################################################
# Definitions and includes
###############################################################################
SRCDIR =../../..
SERVER_ENGINE_DIR =$(SRCDIR)/engine/server/application
SHARED_ENGINE_DIR =$(SRCDIR)/engine/shared/application
SERVER_GAME_DIR =$(SRCDIR)/game/server/application
###############################################################################
# Rules to invoke the makefiles for specific applications
###############################################################################
debug_libs:
+@make -C $(SERVER_ENGINE_DIR)/PhonyApp/build/linux debug
CentralServer_d:
+@make -C $(SERVER_ENGINE_DIR)/CentralServer/build/linux debug
CentralServer_r:
+@make -C $(SERVER_ENGINE_DIR)/CentralServer/build/linux release
ConnectionServer_d:
+@make -C $(SERVER_ENGINE_DIR)/ConnectionServer/build/linux debug
ConnectionServer_r:
+@make -C $(SERVER_ENGINE_DIR)/ConnectionServer/build/linux release
LoginServer_d:
+@make -C $(SERVER_ENGINE_DIR)/LoginServer/build/linux debug
LoginServer_r:
+@make -C $(SERVER_ENGINE_DIR)/LoginServer/build/linux release
ServerConsole_d:
+@make -C $(SERVER_ENGINE_DIR)/ServerConsole/build/linux debug
ServerConsole_r:
+@make -C $(SERVER_ENGINE_DIR)/ServerConsole/build/linux release
PlanetServer_d:
+@make -C $(SERVER_ENGINE_DIR)/PlanetServer/build/linux debug
PlanetServer_r:
+@make -C $(SERVER_ENGINE_DIR)/PlanetServer/build/linux release
TaskManager_d:
+@make -C $(SERVER_ENGINE_DIR)/TaskManager/build/linux debug
TaskManager_r:
+@make -C $(SERVER_ENGINE_DIR)/TaskManager/build/linux release
ChatServer_d:
+@make -C $(SERVER_ENGINE_DIR)/ChatServer/build/linux debug
ChatServer_r:
+@make -C $(SERVER_ENGINE_DIR)/ChatServer/build/linux release
CustomerServiceServer_d:
+@make -C $(SERVER_ENGINE_DIR)/CustomerServiceServer/build/linux debug
CustomerServiceServer_r:
+@make -C $(SERVER_ENGINE_DIR)/CustomerServiceServer/build/linux release
LoginPing_d:
+@make -C $(SERVER_ENGINE_DIR)/LoginPing/build/linux debug
LoginPing_r:
+@make -C $(SERVER_ENGINE_DIR)/LoginPing/build/linux release
MetricsServer_d:
+@make -C $(SERVER_ENGINE_DIR)/MetricsServer/build/linux debug
MetricsServer_r:
+@make -C $(SERVER_ENGINE_DIR)/MetricsServer/build/linux release
LogServer_d:
+@make -C $(SERVER_ENGINE_DIR)/LogServer/build/linux debug
LogServer_r:
+@make -C $(SERVER_ENGINE_DIR)/LogServer/build/linux release
TemplateCompiler_d:
+@make -C $(SHARED_ENGINE_DIR)/TemplateCompiler/build/linux debug
TemplateCompiler_r:
+@make -C $(SHARED_ENGINE_DIR)/TemplateCompiler/build/linux release
DataTableTool_d:
+@make -C $(SHARED_ENGINE_DIR)/DataTableTool/build/linux debug
DataTableTool_r:
+@make -C $(SHARED_ENGINE_DIR)/DataTableTool/build/linux release
GameServer_d:
+@make -C $(SERVER_ENGINE_DIR)/GameServer/build/linux debug
GameServer_r:
+@make -C $(SERVER_ENGINE_DIR)/GameServer/build/linux release
CommoditiesServer_d:
@echo " BOGUS CommoditiesServer_d rule, ignoring..."
# [ ! -f $(SRCDIR)/../dev/linux/CommoditiesServer_d ] || \
# chmod u+w $(SRCDIR)/../dev/linux/CommoditiesServer_d
# cp $(SRCDIR)/../exe/linux/CommoditiesServer_d $(SRCDIR)/../dev/linux
CommoditiesServer_r:
[ ! -f $(SRCDIR)/../dev/linux/CommoditiesServer_r ] || \
chmod u+w $(SRCDIR)/../dev/linux/CommoditiesServer_r
cp $(SRCDIR)/../exe/linux/CommoditiesServer_r $(SRCDIR)/../dev/linux
###############################################################################
# Special targets
###############################################################################
clean:
+@make -C $(SERVER_ENGINE_DIR)/LoginServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/ServerConsole/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/CentralServer/build/linux clean
+@make -C $(SERVER_GAME_DIR)/SwgGameServer/build/linux clean
+@make -C $(SERVER_GAME_DIR)/SwgDatabaseServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/ConnectionServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/TaskManager/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/PlanetServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/ChatServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/CustomerServiceServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/LogServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/MetricsServer/build/linux clean
+@make -C $(SERVER_ENGINE_DIR)/LoginPing/build/linux clean
lint:
+@make -C $(SERVER_ENGINE_DIR)/LoginServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/ServerConsole/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/CentralServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/SwgGameServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/SwgDatabaseServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/ConnectionServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/TaskManager/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/PlanetServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/ChatServer/build/linux lint
+@make -C $(SERVER_ENGINE_DIR)/LogServer/build/linux lint
@@ -925,10 +925,6 @@
<Project>{eaa23f07-4419-4aed-83d2-06654119b6f6}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\server\library\swgServerNetworkMessages\build\win32\swgServerNetworkMessages.vcxproj">
<Project>{950e9cf2-cd44-476c-826a-bb7869241f5b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\shared\library\swgSharedNetworkMessages\build\win32\swgSharedNetworkMessages.vcxproj">
<Project>{fcc0f2b5-aade-4454-aff2-4d91365b4883}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -345,10 +345,6 @@
<Project>{eaa23f07-4419-4aed-83d2-06654119b6f6}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\server\library\swgServerNetworkMessages\build\win32\swgServerNetworkMessages.vcxproj">
<Project>{950e9cf2-cd44-476c-826a-bb7869241f5b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\shared\library\swgSharedNetworkMessages\build\win32\swgSharedNetworkMessages.vcxproj">
<Project>{fcc0f2b5-aade-4454-aff2-4d91365b4883}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -392,10 +392,6 @@
<Project>{b97963ef-49e4-477e-85ff-e7fee7c626d7}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\server\library\swgServerNetworkMessages\build\win32\swgServerNetworkMessages.vcxproj">
<Project>{950e9cf2-cd44-476c-826a-bb7869241f5b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\shared\library\swgSharedNetworkMessages\build\win32\swgSharedNetworkMessages.vcxproj">
<Project>{fcc0f2b5-aade-4454-aff2-4d91365b4883}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -1,76 +0,0 @@
# Experimental makefile for Miff-Unix
INCLUDE_DIRS = \
-I../../../../../shared/library/sharedCompression/include/public \
-I../../../../../shared/library/sharedDebug/include/public \
-I../../../../../shared/library/sharedFile/include/public \
-I../../../../../shared/library/sharedFoundation/include/public \
-I../../../../../shared/library/sharedFoundationTypes/include/public \
-I../../../../../shared/library/sharedMemoryManager/include/public \
-I../../../../../shared/library/sharedThread/include/public \
-I../../../../../../external/3rd/library/stlport453/stlport \
-I../../../../../../external/ours/library/fileInterface/include/public
GPP_FLAGS = -g -Wall -Wno-unused -Wno-unknown-pragmas -Werror -Wno-ctor-dtor-privacy -D_DEBUG -D__STL_NO_BAD_ALLOC -DLINUX $(INCLUDE_DIRS) # Always builds with debugging info
GCC_FLAGS = -w #no warnings for code generated by yacc -- it's not our fault
LIBS = \
../../../../../../compile/linux/sharedCompression/debug/libsharedCompression_d.a \
../../../../../../compile/linux/sharedDebug/debug/libsharedDebug_d.a \
../../../../../../compile/linux/sharedFile/debug/libsharedFile_d.a \
../../../../../../compile/linux/sharedFoundation/debug/libsharedFoundation_d.a \
../../../../../../compile/linux/sharedMath/debug/libsharedMath_d.a \
../../../../../../compile/linux/sharedMemoryManager/debug/libsharedMemoryManager_d.a \
../../../../../../compile/linux/sharedRandom/debug/libsharedRandom_d.a \
../../../../../../compile/linux/sharedSynchronization/debug/libsharedSynchronization_d.a \
../../../../../../compile/linux/sharedThread/debug/libsharedThread_d.a \
../../../../../../external/3rd/library/stlport453/lib/libstlport_gcc.a \
../../../../../../external/ours/library/fileInterface/build/linux/output/debug/libfileInterface.a \
../../../../../../external/ours/library/archive/build/linux/output/debug/libarchive.a \
../../../../../../external/ours/library/unicode/compile/linux/Debug/libunicode.a \
../../../../../../external/ours/library/unicodeArchive/build/linux/output/debug/libunicodeArchive.a \
../../../../../../external/ours/library/localization/compile/linux/Debug/libLocalization.a \
../../../../../../external/ours/library/localizationArchive/compile/linux/Debug/libLocalizationArchive.a \
-lncurses -lz -ldl
SRCDIR = ../../src/linux
OBJDIR = ../../src/linux
OBJS = $(addprefix $(OBJDIR)/, lex_yy.o parser.o miff.o InputFileHandler.o OutputFileHandler.o)
miff: $(OBJS) $(LIBS)
g++ $(OBJS) $(LIBS) -lpthread -g -o miff
$(OBJDIR)/lex_yy.o: $(SRCDIR)/lex_yy.c $(SRCDIR)/parser.h
gcc $(GCC_FLAGS) $(SRCDIR)/lex_yy.c -c -g -o $(OBJDIR)/lex_yy.o
$(OBJDIR)/parser.o: $(SRCDIR)/parser.c $(SRCDIR)/parser.h
gcc $(GCC_FLAGS) $(SRCDIR)/parser.c -c -g -o $(OBJDIR)/parser.o
$(OBJDIR)/miff.o: $(SRCDIR)/miff.cpp
g++ $(GPP_FLAGS) $(SRCDIR)/miff.cpp -c -g -o $(OBJDIR)/miff.o
$(OBJDIR)/InputFileHandler.o: $(SRCDIR)/InputFileHandler.cpp
g++ $(GPP_FLAGS) $(SRCDIR)/InputFileHandler.cpp -c -g -o $(OBJDIR)/InputFileHandler.o
$(OBJDIR)/OutputFileHandler.o: $(SRCDIR)/OutputFileHandler.cpp
g++ $(GPP_FLAGS) $(SRCDIR)/OutputFileHandler.cpp -c -g -o $(OBJDIR)/OutputFileHandler.o
$(SRCDIR)/lex_yy.c: $(SRCDIR)/parser.lex
flex -w -o$(SRCDIR)/lex_yy.c $(SRCDIR)/parser.lex
$(SRCDIR)/parser.c $(SRCDIR)/parser.h: $(SRCDIR)/parser.yac
bison -d -o$(SRCDIR)/parser.c $(SRCDIR)/parser.yac
clean:
rm -f $(OBJS) $(SRCDIR)/parser.c $(SRCDIR)/parser.h $(SRCDIR)/lex_yy.c .depend
include .depend
.depend:
@echo Generating dependencies for miff
@touch .depend
@g++ -MM $(GPP_FLAGS) $(INCLUDE_DIRS) $(SRCDIR)/miff.cpp -c -g >> .depend
@g++ -MM $(GPP_FLAGS) $(INCLUDE_DIRS) $(SRCDIR)/InputFileHandler.cpp -c -g >> .depend
@g++ -MM $(GPP_FLAGS) $(INCLUDE_DIRS) $(SRCDIR)/OutputFileHandler.cpp -c -g >> .depend
@@ -693,10 +693,6 @@
<Project>{b97963ef-49e4-477e-85ff-e7fee7c626d7}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\server\library\swgServerNetworkMessages\build\win32\swgServerNetworkMessages.vcxproj">
<Project>{950e9cf2-cd44-476c-826a-bb7869241f5b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\shared\library\swgSharedNetworkMessages\build\win32\swgSharedNetworkMessages.vcxproj">
<Project>{fcc0f2b5-aade-4454-aff2-4d91365b4883}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -1267,10 +1267,6 @@
<Project>{eaa23f07-4419-4aed-83d2-06654119b6f6}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\server\library\swgServerNetworkMessages\build\win32\swgServerNetworkMessages.vcxproj">
<Project>{950e9cf2-cd44-476c-826a-bb7869241f5b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\game\shared\library\swgSharedNetworkMessages\build\win32\swgSharedNetworkMessages.vcxproj">
<Project>{fcc0f2b5-aade-4454-aff2-4d91365b4883}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -1,57 +0,0 @@
DEBUG_PLATFORM_CPP_FLAGS =-DLINUX -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DTRUE=TRUE $(PERSONAL_FLAGS)
DEBUG_PLATFORM_CPP_FLAGS =-DLINUX -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DTRUE=TRUE $(PERSONAL_FLAGS)
include ../../../../../build/linux/platformDefs.mak
include ../../../../../build/shared_unix/defs.mak
OUTPUT = remoteDebugTool
DEBUG_LINK_FLAGS += -lpthread -lodbc -L/usr/lib/qt-3.0.3/lib -lqui -ldl
RELEASE_LINK_FLAGS += -lpthread -lodbc -L/usr/lib/qt-3.0.3/lib -lqui -ldl
INCLUDE_DIRS = \
../../src/shared \
../../include/private \
../../include/public \
$(ARCHIVE_INCLUDE_PATH) \
$(DEBUG_INCLUDE_PATH) \
$(FILE_INCLUDE_PATH) \
$(FOUNDATION_INCLUDE_PATH) \
$(FOUNDATION_TYPES_INCLUDE_PATH) \
$(SYNCHRONIZATION_INCLUDE_PATH) \
$(THREAD_INCLUDE_PATH) \
$(UTILITY_INCLUDE_PATH) \
$(SHARED_NETWORK_INCLUDE_PATH) \
$(CLIENT_REMOTE_DEBUG_INCLUDE_PATH) \
$(STL_INCLUDE_PATH) \
$(COMMON_ENGINE_LIBRARY_INCLUDES) \
/usr/lib/qt-3.0.3/include \
DEBUG_LINK_LIBRARIES = \
$(CLIENT_REMOTE_DEBUG_DEBUG_LIB) \
$(COMMON_ENGINE_DEBUG_LIBS) \
$(UNICODE_DEBUG_LIB)
DEBUG_SHARED_LIBRARIES = \
RELEASE_LINK_LIBRARIES = \
$(CLIENT_REMOTE_DEBUG_RELEASE_LIB) \
$(COMMON_ENGINE_RELEASE_LIBS) \
$(UNICODE_RELEASE_LIB)
RELEASE_SHARED_LIBRARIES = \
SHARED_SRC_LIST = $(shell find $$PWD/../../src/shared -name "*.cpp")
PLATFORM_SRC_LIST =
SRC_LIST = $(SHARED_SRC_LIST) $(PLATFORM_SRC_LIST)
debug_custom_step:
release_custom_step:
depend_custom_step:
%.moc: %.h
moc -o $@ $<
include ../../../../../build/shared_unix/application.mak
@@ -1,3 +0,0 @@
PLATFORM =linux
include ../shared_unix/shared_unix.mak
-414
View File
@@ -1,414 +0,0 @@
AC_PREREQ(2.53)
AC_INIT(engine, 1.0.0, [email protected])
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug\[=yes\|no\] ], [defines _DEBUG and enables debugging features]), AC_DEFINE(_DEBUG) CXXFLAGS="$CXXFLAGS -g", [])
# todo - when using gcc-3, pick more optimizations for use
AC_ARG_ENABLE([optimized], AC_HELP_STRING([--enable-optimized\[=yes\|no\] ], [enables optimizations]), CXXFLAGS="$CXXFLAGS -O2", [])
case $target in
*-linux-*)
platform=[linux];
AC_DEFINE(LINUX)
AC_DEFINE(_REENTRANT)
AC_DEFINE(_XOPEN_SOURCE, 500)
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(linux)
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(_USING_STL)
AC_DEFINE(__STL_NO_BAD_ALLOC)
esac
AC_SUBST(platform)
AM_INIT_AUTOMAKE
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
# setup common CXXFLAGS if none were specified in the environment
#if ! test $CXXFLAGS; then
# CXXFLAGS = -g -Wall -Wno-unused -Werror -Wno-ctor-dtor-privacy -Wno-unknown-pragmas -Wchar-subscripts -Wformat -Wimplicit -Wmultichar -Wparentheses -Wreturn-type -Wswitch -Weffc++
#fi
AC_DEFUN([REQUIRE_PACKAGE], [if ! test $$3; then AC_ARG_WITH([$1], AC_HELP_STRING([--with-$1=path/to/$1], [where to find $1]), AC_SUBST($3, $withval), AC_SUBST($3, $2)) AC_CHECK_FILE($4, [], AC_MSG_ERROR([$1 is required but was not found in $$3])) fi])
REQUIRE_PACKAGE(engine, [`pwd`], engine_dir, [$engine_dir/shared/library/sharedFoundation/include/public/sharedFoundation/FirstSharedFoundation.h]) AC_SUBST(engine_dir)
REQUIRE_PACKAGE(stlport, [`pwd`/../external/3rd/library/stlport453], stlport_dir, [$stlport_dir/stlport/algorithm]) AC_SUBST(stlport_dir)
REQUIRE_PACKAGE(archive, [`pwd`/../external/ours/library/archive], archive_dir, [$archive_dir/include/Archive/Archive.h]) AC_SUBST(archive_dir)
REQUIRE_PACKAGE(localization, [`pwd`/../external/ours/library/localization], localization_dir, [$localization_dir/include/FirstLocalization.h]) AC_SUBST(localization_dir)
REQUIRE_PACKAGE(crypto, [`pwd`/../external/ours/library/crypto], crypto_dir, [$crypto_dir/include/FirstCrypto.h]) AC_SUBST(crypto_dir)
REQUIRE_PACKAGE(localizationArchive, [`pwd`/../external/ours/library/localizationArchive], localizationArchive_dir, [$localizationArchive_dir/include/public/localizationArchive/FirstLocalizationArchive.h]) AC_SUBST(localizationArchive_dir)
REQUIRE_PACKAGE(fileInterface, [`pwd`/../external/ours/library/fileInterface], fileInterface_dir, [$fileInterface_dir/include/public/fileInterface/FirstFileInterface.h]) AC_SUBST(fileInterface_dir)
REQUIRE_PACKAGE(unicode, [`pwd`/../external/ours/library/unicode], unicode_dir, [$unicode_dir/include/Unicode.h]) AC_SUBST(unicode_dir)
REQUIRE_PACKAGE(unicodeArchive, [`pwd`/../external/ours/library/unicodeArchive], unicodeArchive_dir, [$unicodeArchive_dir/include/public/unicodeArchive/FirstUnicodeArchive.h]) AC_SUBST(unicodeArchive_dir)
REQUIRE_PACKAGE(udplibrary, [`pwd`/../external/3rd/library/udplibrary], udplibrary_dir, [$udplibrary_dir/UdpLibrary.hpp]) AC_SUBST(udplibrary_dir)
REQUIRE_PACKAGE(oracle, [`pwd`/../external/3rd/library/oracle], oracle_dir, [$oracle_dir/include/oci.h]) AC_SUBST(oracle_dir)
REQUIRE_PACKAGE(libxml, [`pwd`/../external/3rd/library/libxml], libxml_dir, [$libxml_dir/libxml.h]) AC_SUBST(libxml_dir)
AC_MSG_WARN([engine has a forward dependency on game])
REQUIRE_PACKAGE(game, [`pwd`/../game], game_dir, [$game_dir/shared/library/swgSharedUtility/include/public/swgSharedUtility/FirstSwgSharedUtility.h]) AC_SUBST(game_dir)
REQUIRE_PACKAGE(singleton, [`pwd`/../external/ours/library/singleton], singleton_dir, [$singleton_dir/include/Singleton/Singleton.h]) AC_SUBST(singleton_dir)
REQUIRE_PACKAGE(boost, [`pwd`/../external/3rd/library/boost], boost_dir, [$boost_dir/boost/smart_ptr.hpp]) AC_SUBST(boost_dir)
REQUIRE_PACKAGE(pcre, [`pwd`/../external/3rd/library/pcre/4.1/$platform], pcre_dir, [$pcre_dir/include/pcre/pcre.h]) AC_SUBST(pcre_dir)
REQUIRE_PACKAGE(perforce, [`pwd`/../external/3rd/library/perforce], perforce_dir, [$perforce_dir/include/clientapi.h]) AC_SUBST(perforce_dir)
REQUIRE_PACKAGE(soePlatform, [`pwd`/../external/3rd/library/soePlatform], soePlatform_dir, [$soePlatform_dir/Base/Base.h]) AC_SUBST(soePlatform_dir)
REQUIRE_PACKAGE(platform, [`pwd`/../external/3rd/library/platform], platform_dir, [$platform_dir/MonAPI2/MonitorAPI.h]) AC_SUBST(platform_dir)
# AC_DEFUN([ENGINE_AUTOMAKE], [AC_MSG_NOTICE([creating $1.in]) ; automake $1])
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedDebug/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedFile/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedFoundation/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedRegex/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedLog/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedMemoryManager/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedNetwork/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedSynchronization/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/library/sharedThread/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/TemplateCompiler/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/ArmorExporterTool/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/DataTableTool/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/TemplateDefinitionCompiler/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/WeaponExporterTool/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/shared/application/CoreWeaponExporterTool/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/CentralServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/ChatServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/ConnectionServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/CustomerServiceServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/LoginPing/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/LoginServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/LogServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/MetricsServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/PlanetServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/TaskManager/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/application/TransferServer/src/$platform/Makefile)
# ENGINE_AUTOMAKE($engine_dir/server/library/serverUtility/src/$platform/Makefile)
AC_OUTPUT(Makefile \
shared/Makefile \
shared/library/Makefile \
shared/library/sharedCollision/Makefile \
shared/library/sharedCollision/src/Makefile \
shared/library/sharedCollision/src/shared/Makefile \
shared/library/sharedCollision/src/shared/core/Makefile \
shared/library/sharedCollision/src/shared/extent/Makefile \
shared/library/sharedCompression/Makefile \
shared/library/sharedCompression/src/Makefile \
shared/library/sharedCompression/src/shared/Makefile \
shared/library/sharedCommandParser/Makefile \
shared/library/sharedCommandParser/src/Makefile \
shared/library/sharedCommandParser/src/shared/Makefile \
shared/library/sharedDatabaseInterface/Makefile \
shared/library/sharedDatabaseInterface/src/Makefile \
shared/library/sharedDatabaseInterface/src/shared/Makefile \
shared/library/sharedDatabaseInterface/src/shared/core/Makefile \
shared/library/sharedDatabaseInterface/src/shared/logger/Makefile \
shared/library/sharedDatabaseInterface/src/shared/queue/Makefile \
shared/library/sharedDatabaseInterface/src_oci/Makefile \
shared/library/sharedDebug/Makefile \
shared/library/sharedDebug/src/Makefile \
shared/library/sharedDebug/src/shared/Makefile \
shared/library/sharedDebug/src/linux/Makefile \
shared/library/sharedFile/Makefile \
shared/library/sharedFile/src/Makefile \
shared/library/sharedFile/src/shared/Makefile \
shared/library/sharedFile/src/linux/Makefile \
shared/library/sharedFoundation/Makefile \
shared/library/sharedFoundation/src/Makefile \
shared/library/sharedFoundation/src/linux/Makefile \
shared/library/sharedFoundation/src/shared/Makefile \
shared/library/sharedFoundation/src/shared/dynamicVariable/Makefile \
shared/library/sharedFractal/Makefile \
shared/library/sharedFractal/src/Makefile \
shared/library/sharedFractal/src/shared/Makefile \
shared/library/sharedGame/Makefile \
shared/library/sharedGame/src/Makefile \
shared/library/sharedGame/src/shared/Makefile \
shared/library/sharedGame/src/shared/appearance/Makefile \
shared/library/sharedGame/src/shared/collision/Makefile \
shared/library/sharedGame/src/shared/combat/Makefile \
shared/library/sharedGame/src/shared/command/Makefile \
shared/library/sharedGame/src/shared/core/Makefile \
shared/library/sharedGame/src/shared/dynamics/Makefile \
shared/library/sharedGame/src/shared/mount/Makefile \
shared/library/sharedGame/src/shared/object/Makefile \
shared/library/sharedGame/src/shared/objectTemplate/Makefile \
shared/library/sharedGame/src/shared/quest/Makefile \
shared/library/sharedGame/src/shared/space/Makefile \
shared/library/sharedGame/src/shared/sui/Makefile \
shared/library/sharedGame/src/shared/travel/Makefile \
shared/library/sharedImage/Makefile \
shared/library/sharedImage/src/Makefile \
shared/library/sharedImage/src/shared/Makefile \
shared/library/sharedInputMap/Makefile \
shared/library/sharedInputMap/src/Makefile \
shared/library/sharedInputMap/src/shared/Makefile \
shared/library/sharedIoWin/Makefile \
shared/library/sharedIoWin/src/Makefile \
shared/library/sharedIoWin/src/shared/Makefile \
shared/library/sharedLog/Makefile \
shared/library/sharedLog/src/Makefile \
shared/library/sharedLog/src/shared/Makefile \
shared/library/sharedLog/src/linux/Makefile \
shared/library/sharedMath/Makefile \
shared/library/sharedMath/src/Makefile \
shared/library/sharedMath/src/shared/Makefile \
shared/library/sharedMath/src/shared/core/Makefile \
shared/library/sharedMath/src/shared/debug/Makefile \
shared/library/sharedMemoryManager/Makefile \
shared/library/sharedMemoryManager/src/Makefile \
shared/library/sharedMemoryManager/src/linux/Makefile \
shared/library/sharedMemoryManager/src/shared/Makefile \
shared/library/sharedMessageDispatch/Makefile \
shared/library/sharedMessageDispatch/src/Makefile \
shared/library/sharedMessageDispatch/src/shared/Makefile \
shared/library/sharedNetwork/Makefile \
shared/library/sharedNetwork/src/Makefile \
shared/library/sharedNetwork/src/linux/Makefile \
shared/library/sharedNetwork/src/shared/Makefile \
shared/library/sharedNetwork/src/shared/UdpLibraryMT/Makefile \
shared/library/sharedNetworkMessages/Makefile \
shared/library/sharedNetworkMessages/src/Makefile \
shared/library/sharedNetworkMessages/src/shared/Makefile \
shared/library/sharedNetworkMessages/src/shared/chat/Makefile \
shared/library/sharedNetworkMessages/src/shared/clientGameServer/Makefile \
shared/library/sharedNetworkMessages/src/shared/clientLoginServer/Makefile \
shared/library/sharedNetworkMessages/src/shared/common/Makefile \
shared/library/sharedNetworkMessages/src/shared/core/Makefile \
shared/library/sharedNetworkMessages/src/shared/customerService/Makefile \
shared/library/sharedNetworkMessages/src/shared/planetWatch/Makefile \
shared/library/sharedNetworkMessages/src/shared/voicechat/Makefile \
shared/library/sharedObject/Makefile \
shared/library/sharedObject/src/Makefile \
shared/library/sharedObject/src/shared/Makefile \
shared/library/sharedObject/src/shared/appearance/Makefile \
shared/library/sharedObject/src/shared/container/Makefile \
shared/library/sharedObject/src/shared/controller/Makefile \
shared/library/sharedObject/src/shared/core/Makefile \
shared/library/sharedObject/src/shared/customization/Makefile \
shared/library/sharedObject/src/shared/dynamics/Makefile \
shared/library/sharedObject/src/shared/lot/Makefile \
shared/library/sharedObject/src/shared/movement/Makefile \
shared/library/sharedObject/src/shared/object/Makefile \
shared/library/sharedObject/src/shared/portal/Makefile \
shared/library/sharedObject/src/shared/property/Makefile \
shared/library/sharedObject/src/shared/world/Makefile \
shared/library/sharedPathfinding/Makefile \
shared/library/sharedPathfinding/src/Makefile \
shared/library/sharedPathfinding/src/shared/Makefile \
shared/library/sharedRandom/Makefile \
shared/library/sharedRandom/src/Makefile \
shared/library/sharedRandom/src/shared/Makefile \
shared/library/sharedRegex/Makefile \
shared/library/sharedRegex/src/Makefile \
shared/library/sharedRegex/src/linux/Makefile \
shared/library/sharedRegex/src/shared/Makefile \
shared/library/sharedRemoteDebugServer/Makefile \
shared/library/sharedRemoteDebugServer/src/Makefile \
shared/library/sharedRemoteDebugServer/src/shared/Makefile \
shared/library/sharedSkillSystem/Makefile \
shared/library/sharedSkillSystem/src/Makefile \
shared/library/sharedSkillSystem/src/shared/Makefile \
shared/library/sharedSwitcher/Makefile \
shared/library/sharedSwitcher/src/Makefile \
shared/library/sharedSwitcher/src/shared/Makefile \
shared/library/sharedSynchronization/Makefile \
shared/library/sharedSynchronization/src/Makefile \
shared/library/sharedSynchronization/src/linux/Makefile \
shared/library/sharedSynchronization/src/shared/Makefile \
shared/library/sharedTemplate/Makefile \
shared/library/sharedTemplate/src/Makefile \
shared/library/sharedTemplate/src/shared/Makefile \
shared/library/sharedTemplate/src/shared/core/Makefile \
shared/library/sharedTemplate/src/shared/template/Makefile \
shared/library/sharedTemplateDefinition/Makefile \
shared/library/sharedTemplateDefinition/src/Makefile \
shared/library/sharedTemplateDefinition/src/shared/Makefile \
shared/library/sharedTemplateDefinition/src/shared/core/Makefile \
shared/library/sharedTerrain/Makefile \
shared/library/sharedTerrain/src/Makefile \
shared/library/sharedTerrain/src/shared/Makefile \
shared/library/sharedTerrain/src/shared/appearance/Makefile \
shared/library/sharedTerrain/src/shared/core/Makefile \
shared/library/sharedTerrain/src/shared/flora/Makefile \
shared/library/sharedTerrain/src/shared/generator/Makefile \
shared/library/sharedTerrain/src/shared/object/Makefile \
shared/library/sharedThread/Makefile \
shared/library/sharedThread/src/Makefile \
shared/library/sharedThread/src/linux/Makefile \
shared/library/sharedThread/src/shared/Makefile \
shared/library/sharedUtility/Makefile \
shared/library/sharedUtility/src/Makefile \
shared/library/sharedUtility/src/shared/Makefile \
shared/library/sharedXml/Makefile \
shared/library/sharedXml/src/Makefile \
shared/library/sharedXml/src/shared/Makefile \
shared/library/sharedXml/src/shared/core/Makefile \
shared/library/sharedXml/src/shared/tree/Makefile \
shared/application/Makefile \
shared/application/ArmorExporterTool/Makefile \
shared/application/ArmorExporterTool/src/Makefile \
shared/application/ArmorExporterTool/src/shared/Makefile \
shared/application/ArmorExporterTool/src/linux/Makefile \
shared/application/DataTableTool/Makefile \
shared/application/DataTableTool/src/Makefile \
shared/application/DataTableTool/src/shared/Makefile \
shared/application/DataTableTool/src/linux/Makefile \
shared/application/TemplateCompiler/Makefile \
shared/application/TemplateCompiler/src/Makefile \
shared/application/TemplateCompiler/src/shared/Makefile \
shared/application/TemplateCompiler/src/linux/Makefile \
shared/application/TemplateDefinitionCompiler/Makefile \
shared/application/TemplateDefinitionCompiler/src/Makefile \
shared/application/TemplateDefinitionCompiler/src/shared/Makefile \
shared/application/TemplateDefinitionCompiler/src/shared/core/Makefile \
shared/application/TemplateDefinitionCompiler/src/linux/Makefile \
shared/application/WeaponExporterTool/Makefile \
shared/application/WeaponExporterTool/src/Makefile \
shared/application/WeaponExporterTool/src/shared/Makefile \
shared/application/WeaponExporterTool/src/linux/Makefile \
shared/application/CoreWeaponExporterTool/Makefile \
shared/application/CoreWeaponExporterTool/src/Makefile \
shared/application/CoreWeaponExporterTool/src/shared/Makefile \
shared/application/CoreWeaponExporterTool/src/linux/Makefile \
server/Makefile \
server/library/Makefile \
server/library/serverBase/Makefile \
server/library/serverBase/src/Makefile \
server/library/serverBase/src/shared/Makefile \
server/library/serverBase/src/shared/core/Makefile \
server/library/serverDatabase/Makefile \
server/library/serverDatabase/src/Makefile \
server/library/serverDatabase/src/shared/Makefile \
server/library/serverGame/Makefile \
server/library/serverGame/src/Makefile \
server/library/serverGame/src/shared/Makefile \
server/library/serverGame/src/shared/ai/Makefile \
server/library/serverGame/src/shared/behavior/Makefile \
server/library/serverGame/src/shared/city/Makefile \
server/library/serverGame/src/shared/collision/Makefile \
server/library/serverGame/src/shared/command/Makefile \
server/library/serverGame/src/shared/commoditiesMarket/Makefile \
server/library/serverGame/src/shared/console/Makefile \
server/library/serverGame/src/shared/container/Makefile \
server/library/serverGame/src/shared/controller/Makefile \
server/library/serverGame/src/shared/core/Makefile \
server/library/serverGame/src/shared/generated/Makefile \
server/library/serverGame/src/shared/guild/Makefile \
server/library/serverGame/src/shared/metrics/Makefile \
server/library/serverGame/src/shared/network/Makefile \
server/library/serverGame/src/shared/object/Makefile \
server/library/serverGame/src/shared/objectTemplate/Makefile \
server/library/serverGame/src/shared/pvp/Makefile \
server/library/serverGame/src/shared/region/Makefile \
server/library/serverGame/src/shared/region3d/Makefile \
server/library/serverGame/src/shared/resource/Makefile \
server/library/serverGame/src/shared/space/Makefile \
server/library/serverGame/src/shared/stationplayers/Makefile \
server/library/serverGame/src/shared/synchronizedUi/Makefile \
server/library/serverGame/src/shared/trading/Makefile \
server/library/serverKeyShare/Makefile \
server/library/serverKeyShare/src/Makefile \
server/library/serverKeyShare/src/shared/Makefile \
server/library/serverMetrics/Makefile \
server/library/serverMetrics/src/Makefile \
server/library/serverMetrics/src/shared/Makefile \
server/library/serverUtility/Makefile \
server/library/serverUtility/src/Makefile \
server/library/serverUtility/src/linux/Makefile \
server/library/serverUtility/src/shared/Makefile \
server/library/serverNetworkMessages/Makefile \
server/library/serverNetworkMessages/src/Makefile \
server/library/serverNetworkMessages/src/shared/Makefile \
server/library/serverNetworkMessages/src/shared/centralConnectionServer/Makefile \
server/library/serverNetworkMessages/src/shared/centralGameServer/Makefile \
server/library/serverNetworkMessages/src/shared/centralPlanetServer/Makefile \
server/library/serverNetworkMessages/src/shared/centralTaskManager/Makefile \
server/library/serverNetworkMessages/src/shared/commoditiesSwgDatabase/Makefile \
server/library/serverNetworkMessages/src/shared/core/Makefile \
server/library/serverNetworkMessages/src/shared/gameCommoditiesServer/Makefile \
server/library/serverNetworkMessages/src/shared/gameConnectionServer/Makefile \
server/library/serverNetworkMessages/src/shared/gameGameServer/Makefile \
server/library/serverNetworkMessages/src/shared/gamePlanetServer/Makefile \
server/library/serverNetworkMessages/src/shared/gameStationPlayersCollector/Makefile \
server/library/serverNetworkMessages/src/shared/gameTaskManager/Makefile \
server/library/serverNetworkMessages/src/shared/loginCentralServer/Makefile \
server/library/serverNetworkMessages/src/shared/metricsMessages/Makefile \
server/library/serverNetworkMessages/src/shared/transferServer/Makefile \
server/library/serverPathfinding/Makefile \
server/library/serverPathfinding/src/Makefile \
server/library/serverPathfinding/src/shared/Makefile \
server/library/serverScript/Makefile \
server/library/serverScript/src/Makefile \
server/library/serverScript/src/shared/Makefile \
server/application/Makefile \
server/application/CentralServer/Makefile \
server/application/CentralServer/src/Makefile \
server/application/CentralServer/src/linux/Makefile \
server/application/CentralServer/src/shared/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/zip/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/zip/Zip/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/Base/linux/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/TcpLibrary/Makefile \
server/application/CentralServer/src/shared/AuctionTransferGameAPI/ATGenericAPI/Makefile \
server/application/ChatServer/Makefile \
server/application/ChatServer/src/Makefile \
server/application/ChatServer/src/linux/Makefile \
server/application/ChatServer/src/shared/Makefile \
server/application/CommoditiesServer/Makefile \
server/application/CommoditiesServer/src/Makefile \
server/application/CommoditiesServer/src/linux/Makefile \
server/application/CommoditiesServer/src/shared/Makefile \
server/application/ConnectionServer/Makefile \
server/application/ConnectionServer/src/Makefile \
server/application/ConnectionServer/src/linux/Makefile \
server/application/ConnectionServer/src/shared/Makefile \
server/application/CustomerServiceServer/Makefile \
server/application/CustomerServiceServer/src/Makefile \
server/application/CustomerServiceServer/src/linux/Makefile \
server/application/CustomerServiceServer/src/shared/Makefile \
server/application/LoginPing/Makefile \
server/application/LoginPing/src/Makefile \
server/application/LoginPing/src/linux/Makefile \
server/application/LoginPing/src/shared/Makefile \
server/application/LoginServer/Makefile \
server/application/LoginServer/src/Makefile \
server/application/LoginServer/src/linux/Makefile \
server/application/LoginServer/src/shared/Makefile \
server/application/LogServer/Makefile \
server/application/LogServer/src/Makefile \
server/application/LogServer/src/linux/Makefile \
server/application/LogServer/src/shared/Makefile \
server/application/MetricsServer/Makefile \
server/application/MetricsServer/src/Makefile \
server/application/MetricsServer/src/linux/Makefile \
server/application/MetricsServer/src/shared/Makefile \
server/application/PlanetServer/Makefile \
server/application/PlanetServer/src/Makefile \
server/application/PlanetServer/src/linux/Makefile \
server/application/PlanetServer/src/shared/Makefile \
server/application/ServerConsole/Makefile \
server/application/ServerConsole/src/Makefile \
server/application/ServerConsole/src/linux/Makefile \
server/application/ServerConsole/src/shared/Makefile \
server/application/StationPlayersCollector/Makefile \
server/application/StationPlayersCollector/src/Makefile \
server/application/StationPlayersCollector/src/linux/Makefile \
server/application/StationPlayersCollector/src/shared/Makefile \
server/application/TaskManager/Makefile \
server/application/TaskManager/src/Makefile \
server/application/TaskManager/src/linux/Makefile \
server/application/TaskManager/src/shared/Makefile \
server/application/TransferServer/Makefile \
server/application/TransferServer/src/Makefile \
server/application/TransferServer/src/linux/Makefile \
server/application/TransferServer/src/shared/Makefile)
-6
View File
@@ -1,6 +0,0 @@
AUTOMAKE_OPTIONS=foreign
SUBDIRS=library \
application \
.
include $(engine_dir)/../make_include/engine.include
@@ -1,4 +0,0 @@
AUTOMAKE_OPTIONS=foreign
SUBDIRS=src .
include $(engine_dir)/../make_include/engine.include
@@ -1,86 +0,0 @@
DEBUG_PLATFORM_CPP_FLAGS =-DLINUX -D_REENTRANT -D_XOPEN_SOUCE=500 -D_GNU_SOURCE $(PERSONAL_FLAGS)
RELEASE_PLATFORM_CPP_FLAGS =-DLINUX -D_REENTRANT -D_XOPEN_SOUCE=500 -D_GNU_SOURCE $(PERSONAL_FLAGS)
include ../../../../../build/linux/platformDefs.mak
include ../../../../../build/shared_unix/defs.mak
OUTPUT = CentralServer
#######################################################
# standard defines
#######################################################
DEBUG_LINK_FLAGS +=-lpthread -ldl
RELEASE_LINK_FLAGS +=-lpthread -ldl
#######################################################
# includes & linked libraries
#######################################################
INCLUDE_DIRS = \
../../src/linux \
../../src/shared \
../../../../../../engine/shared/library/sharedCommandParser/include/public \
$(COMMON_ENGINE_INCLUDES)
DEBUG_LINK_LIBRARIES = \
$(COMMON_ENGINE_DEBUG_LIBS) \
$(STL_LIB) \
$(ZLIB_LIB)
# TODO: This build system has to pull in all of shared game, which in turn means all of
# skill system and swg shared utility. The autoconf system is able to make a lib out of any directories
# source files, and it appears that Justin narrowed down the dependencies to that level. It is leaner than
# what is here.
# The real solution would be to layer the libs correctly.
DEBUG_SHARED_LIBRARIES= \
$(COMMAND_PARSER_DEBUG_LIB) \
$(COMMON_ENGINE_SHARED_DEBUG_LIBS) \
$(SHARED_GAME_DEBUG_LIB) \
$(SKILL_SYSTEM_DEBUG_LIB) \
$(SWG_SHARED_UTILITY_DEBUG_LIB) \
RELEASE_LINK_LIBRARIES = \
$(COMMAND_PARSER_RELEASE_LIB) \
$(COMMON_ENGINE_RELEASE_LIBS)
RELEASE_SHARED_LIBRARIES= \
$(COMMON_ENGINE_SHARED_RELEASE_LIBS)
#######################################################
# Project depends
# (The makefile for these projects will be
# automatically invoked.)
#######################################################
DEBUG_PROJECT_DEPENDS = \
$(COMMON_ENGINE_DEBUG_DEPENDS)
RELEASE_PROJECT_DEPENDS = \
$(COMMON_ENGINE_RELEASE_DEPENDS)
#######################################################
# Source file list
#######################################################
SHARED_SRC_LIST =$(shell find $$PWD/../../src/shared -name "*.cpp")
PLATFORM_SRC_LIST =$(shell find $$PWD/../../src/linux -name "*.cpp")
SRC_LIST =$(SHARED_SRC_LIST) $(PLATFORM_SRC_LIST)
#######################################################
# Custom build steps
#######################################################
debug_custom_step:
release_custom_step:
depend_custom_step:
#######################################################
# include the common makefile
#######################################################
include ../../../../../build/shared_unix/application.mak
File diff suppressed because it is too large Load Diff
@@ -1,466 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Optimized|Win32">
<Configuration>Optimized</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D5CA7486-D01E-4DCB-883B-8E60F7F64D26}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">
<OutDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\..\..\compile\win32\$(ProjectName)\$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\..\..\..\..\engine\server\library\serverKeyShare\include\public;..\..\..\..\..\..\engine\server\library\serverMetrics\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\shared\library\sharedCompression\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationTypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\src\shared;..\..\src\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_MBCS;DEBUG_LEVEL=2;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>FirstCentralServer.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>$(OutDir)</AssemblerListingLocation>
<ObjectFileName>$(OutDir)</ObjectFileName>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName)_d.pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<UseFullPaths>true</UseFullPaths>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;ws2_32.lib;zlib.lib;mswsock.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)_d.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\zlib\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libcmt;libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName)_d.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">
<ClCompile>
<Optimization>Full</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\..\..\..\..\engine\server\library\serverKeyShare\include\public;..\..\..\..\..\..\engine\server\library\serverMetrics\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\shared\library\sharedCompression\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationTypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\src\shared;..\..\src\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_MBCS;DEBUG_LEVEL=1;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>FirstCentralServer.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>$(OutDir)</AssemblerListingLocation>
<ObjectFileName>$(OutDir)</ObjectFileName>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName)_o.pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<UseFullPaths>true</UseFullPaths>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;ws2_32.lib;zlib.lib;mswsock.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)_o.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\zlib\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libcmt;libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName)_o.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\..\..\..\..\..\engine\server\library\serverKeyShare\include\public;..\..\..\..\..\..\engine\server\library\serverMetrics\include\public;..\..\..\..\..\..\engine\server\library\serverNetworkMessages\include\public;..\..\..\..\..\..\engine\server\library\serverUtility\include\public;..\..\..\..\..\..\engine\shared\library\sharedCompression\include\public;..\..\..\..\..\..\engine\shared\library\sharedCommandParser\include\public;..\..\..\..\..\..\engine\shared\library\sharedDebug\include\public;..\..\..\..\..\..\engine\shared\library\sharedFile\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundation\include\public;..\..\..\..\..\..\engine\shared\library\sharedFoundationTypes\include\public;..\..\..\..\..\..\engine\shared\library\sharedLog\include\public;..\..\..\..\..\..\engine\shared\library\sharedMath\include\public;..\..\..\..\..\..\engine\shared\library\sharedMathArchive\include\public;..\..\..\..\..\..\engine\shared\library\sharedMemoryManager\include\public;..\..\..\..\..\..\engine\shared\library\sharedMessageDispatch\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetwork\include\public;..\..\..\..\..\..\engine\shared\library\sharedNetworkMessages\include\public;..\..\..\..\..\..\engine\shared\library\sharedRandom\include\public;..\..\..\..\..\..\engine\shared\library\sharedSynchronization\include\public;..\..\..\..\..\..\engine\shared\library\sharedThread\include\public;..\..\..\..\..\..\engine\shared\library\sharedUtility\include\public;..\..\..\..\..\..\external\3rd\library\stlport453\stlport;..\..\..\..\..\..\external\ours\library\archive\include;..\..\..\..\..\..\external\ours\library\fileInterface\include\public;..\..\..\..\..\..\external\ours\library\localization\include;..\..\..\..\..\..\external\ours\library\localizationArchive\include\public;..\..\..\..\..\..\external\ours\library\singleton\include;..\..\..\..\..\..\external\ours\library\unicode\include;..\..\..\..\..\..\external\ours\library\unicodeArchive\include\public;..\..\src\shared;..\..\src\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_MBCS;DEBUG_LEVEL=0;_CRT_SECURE_NO_DEPRECATE=1;_USE_32BIT_TIME_T=1;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>FirstCentralServer.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(OutDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>$(OutDir)</AssemblerListingLocation>
<ObjectFileName>$(OutDir)</ObjectFileName>
<ProgramDataBaseFileName>$(OutDir)$(ProjectName)_r.pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<UseFullPaths>true</UseFullPaths>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;ws2_32.lib;zlib.lib;mswsock.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)_r.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32;..\..\..\..\..\..\external\3rd\library\zlib\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName)_r.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\shared\AuctionTransferClient.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericApiCore.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericConnection.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericMessage.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\AuctionTransferAPI.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\AuctionTransferAPICore.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\Base\Archive.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\Base\win32\Platform.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\Character.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\Request.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\Response.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\Clock.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\IPAddress.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpBlockAllocator.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpConnection.cpp" />
<ClCompile Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpManager.cpp" />
<ClCompile Include="..\..\src\shared\CentralCSHandler.cpp" />
<ClCompile Include="..\..\src\shared\CentralServer.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\CentralServerMetricsData.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\CharacterCreationTracker.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ChatServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConfigCentralServer.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConnectionServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleCommandParser.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleCommandParserDatabase.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleCommandParserGame.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleCommandParserLoginServer.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\ConsoleManager.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\CustomerServiceConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\GameServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\LoginServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\PlanetManager.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\PlanetServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\StationPlayersCollectorConnection.cpp" />
<ClCompile Include="..\..\src\shared\TaskConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\TransferServerConnection.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\shared\UniverseManager.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
<ClCompile Include="..\..\src\win32\FirstCentralServer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\src\win32\WinMain.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Optimized|Win32'">MaxSpeed</Optimization>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\shared\AuctionTransferClient.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericApiCore.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericConnection.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\ATGenericAPI\GenericMessage.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\AuctionTransferAPI.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\AuctionTransferAPICore.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\AuctionTransferEnum.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Base\win32\Archive.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Base\win32\Platform.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Base\win32\Types.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Character.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Request.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\Response.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\Clock.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\IPAddress.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpBlockAllocator.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpConnection.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpHandlers.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\TcpLibrary\TcpManager.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\GZipHelper.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\deflate.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\infblock.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\infcodes.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\inffast.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\inffixed.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\inftrees.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\infutil.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\trees.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\zconf.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\zlib.h" />
<ClInclude Include="..\..\src\shared\AuctionTransferGameAPI\zip\Zip\zutil.h" />
<ClInclude Include="..\..\src\shared\CentralCSHandler.h" />
<ClInclude Include="..\..\src\shared\CentralServer.h" />
<ClInclude Include="..\..\src\shared\CentralServerMetricsData.h" />
<ClInclude Include="..\..\src\shared\CharacterCreationTracker.h" />
<ClInclude Include="..\..\src\shared\ChatServerConnection.h" />
<ClInclude Include="..\..\src\shared\ConfigCentralServer.h" />
<ClInclude Include="..\..\src\shared\ConnectionServerConnection.h" />
<ClInclude Include="..\..\src\shared\ConsoleCommandParser.h" />
<ClInclude Include="..\..\src\shared\ConsoleCommandParserDatabase.h" />
<ClInclude Include="..\..\src\shared\ConsoleCommandParserGame.h" />
<ClInclude Include="..\..\src\shared\ConsoleCommandParserLoginServer.h" />
<ClInclude Include="..\..\src\shared\ConsoleConnection.h" />
<ClInclude Include="..\..\src\shared\ConsoleManager.h" />
<ClInclude Include="..\..\src\shared\CustomerServiceConnection.h" />
<ClInclude Include="..\..\src\shared\FirstCentralServer.h" />
<ClInclude Include="..\..\src\shared\GameServerConnection.h" />
<ClInclude Include="..\..\src\shared\LoginServerConnection.h" />
<ClInclude Include="..\..\src\shared\PlanetManager.h" />
<ClInclude Include="..\..\src\shared\PlanetServerConnection.h" />
<ClInclude Include="..\..\src\shared\StationPlayersCollectorConnection.h" />
<ClInclude Include="..\..\src\shared\TaskConnection.h" />
<ClInclude Include="..\..\src\shared\TransferServerConnection.h" />
<ClInclude Include="..\..\src\shared\UniverseManager.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\external\3rd\library\udplibrary\udplibrary.vcxproj">
<Project>{1a7d1159-3474-4520-882f-f1842f0aafae}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\archive\build\win32\archive.vcxproj">
<Project>{52153865-1abf-4fbb-84c4-0fc439716f1e}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\crypto\build\win32\crypto.vcxproj">
<Project>{861a873c-d6ad-4b8a-9bed-0314a8b74b54}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\fileInterface\build\win32\fileInterface.vcxproj">
<Project>{de93996c-cb51-4d61-85a0-a9dfc677445f}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\localizationArchive\build\win32\localizationArchive.vcxproj">
<Project>{a8036ec1-9682-4315-a3d2-6b26c3245d50}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\localization\build\win32\localization.vcxproj">
<Project>{0fb11bc8-3bd1-4471-8dda-da3bc05937b2}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\singleton\build\win32\singleton.vcxproj">
<Project>{d409a18e-f788-4f1b-bad1-ed58ee4d458f}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\unicodeArchive\build\win32\unicodeArchive.vcxproj">
<Project>{41269a52-38b8-4f9a-ae38-1103bb03a10b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\..\external\ours\library\unicode\build\win32\unicode.vcxproj">
<Project>{b97963ef-49e4-477e-85ff-e7fee7c626d7}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedCommandParser\build\win32\sharedCommandParser.vcxproj">
<Project>{20d4d8eb-87ca-4c5f-8ba3-ffc898563c40}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedCompression\build\win32\sharedCompression.vcxproj">
<Project>{6bd52b35-92ca-44e4-995e-2b79c7398183}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedDebug\build\win32\sharedDebug.vcxproj">
<Project>{f3245c29-7760-4956-b1b7-fc483be417cd}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedFile\build\win32\sharedFile.vcxproj">
<Project>{e0f9d922-daa7-475e-a95a-7bc540ed58fe}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedFoundationTypes\build\win32\sharedFoundationTypes.vcxproj">
<Project>{d6cc353f-4fd1-4aeb-a984-e7b2e9ce4e69}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedFoundation\build\win32\sharedFoundation.vcxproj">
<Project>{c595c10e-ada8-429a-896a-8904a46737d3}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedIoWin\build\win32\sharedIoWin.vcxproj">
<Project>{03819289-4e8b-44e9-9f3b-a3243c9797c9}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedLog\build\win32\sharedLog.vcxproj">
<Project>{2ae0cef0-c4f2-4786-a026-8338fb09d61b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedMathArchive\build\win32\sharedMathArchive.vcxproj">
<Project>{0202adb3-5587-4138-a626-52b7db52fbba}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedMath\build\win32\sharedMath.vcxproj">
<Project>{5789ea7c-6596-4dcc-a9fb-dd7582888f90}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedMemoryManager\build\win32\sharedMemoryManager.vcxproj">
<Project>{dc2cd926-8ea3-4add-aa62-a95cca8ac7dd}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedMessageDispatch\build\win32\sharedMessageDispatch.vcxproj">
<Project>{c87164f5-14a9-403c-8bc4-217fd40731ea}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedNetworkMessages\build\win32\sharedNetworkMessages.vcxproj">
<Project>{decf2964-3a66-4fa6-ab27-d4507c5480ea}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedNetwork\build\win32\sharedNetwork.vcxproj">
<Project>{df4d72ef-2341-4462-ab78-b130450511da}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedRandom\build\win32\sharedRandom.vcxproj">
<Project>{2e6982e0-dcb6-4ed9-bfad-d29daeea6ad2}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedSynchronization\build\win32\sharedSynchronization.vcxproj">
<Project>{2fe4e38d-be7d-4e3b-9613-63e9f01855f4}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedThread\build\win32\sharedThread.vcxproj">
<Project>{858f7dce-325a-467c-9dda-2fe40217286f}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\shared\library\sharedUtility\build\win32\sharedUtility.vcxproj">
<Project>{52df0d16-d070-47fc-b987-8d80b027d114}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\library\serverKeyShare\build\win32\serverKeyShare.vcxproj">
<Project>{4f237764-394d-40cb-9314-daeded42e2cd}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\library\SERVERMETRICS\build\win32\serverMetrics.vcxproj">
<Project>{4eff0958-fbc8-4053-971a-7022eb0035e4}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\library\serverNetworkMessages\build\win32\serverNetworkMessages.vcxproj">
<Project>{38df394c-0909-4507-8029-53d960fea464}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\library\serverUtility\build\win32\serverUtility.vcxproj">
<Project>{67bfda04-f26e-497f-a6fe-ee52550c15fe}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,31 +0,0 @@
../../../../../../engine/server/library/serverKeyShare/include/public
../../../../../../engine/server/library/serverMetrics/include/public
../../../../../../engine/server/library/serverNetworkMessages/include/public
../../../../../../engine/server/library/serverUtility/include/public
../../../../../../engine/shared/library/sharedCompression/include/public
../../../../../../engine/shared/library/sharedCommandParser/include/public
../../../../../../engine/shared/library/sharedDebug/include/public
../../../../../../engine/shared/library/sharedFile/include/public
../../../../../../engine/shared/library/sharedFoundation/include/public
../../../../../../engine/shared/library/sharedFoundationTypes/include/public
../../../../../../engine/shared/library/sharedLog/include/public
../../../../../../engine/shared/library/sharedMath/include/public
../../../../../../engine/shared/library/sharedMathArchive/include/public
../../../../../../engine/shared/library/sharedMemoryManager/include/public
../../../../../../engine/shared/library/sharedMessageDispatch/include/public
../../../../../../engine/shared/library/sharedNetwork/include/public
../../../../../../engine/shared/library/sharedNetworkMessages/include/public
../../../../../../engine/shared/library/sharedRandom/include/public
../../../../../../engine/shared/library/sharedSynchronization/include/public
../../../../../../engine/shared/library/sharedThread/include/public
../../../../../../engine/shared/library/sharedUtility/include/public
../../../../../../external/3rd/library/stlport453/stlport
../../../../../../external/ours/library/archive/include
../../../../../../external/ours/library/fileInterface/include/public
../../../../../../external/ours/library/localization/include
../../../../../../external/ours/library/localizationArchive/include/public
../../../../../../external/ours/library/singleton/include
../../../../../../external/ours/library/unicode/include
../../../../../../external/ours/library/unicodeArchive/include/public
../../src/shared
../../src/win32
@@ -1,5 +0,0 @@
winmm.lib
ws2_32.lib
zlib.lib
mswsock.lib
@@ -1,2 +0,0 @@
..\..\..\..\..\..\external\3rd\library\stlport453\lib\win32
..\..\..\..\..\..\external\3rd\library\zlib\lib\win32
@@ -1,2 +0,0 @@
console noPchDirectory copyDev
debugInline
@@ -1,39 +0,0 @@
-i../../library/serverKeyShare/include/public
-i../../library/serverMetrics/include/public
-i../../library/serverNetworkMessages/include/public
-i../../library/serverUtility/include/public
-i../../../../engine/shared/library/sharedCompression/include/public
-i../../../../engine/shared/library/sharedCommandParser/include/public
-i../../../../engine/shared/library/sharedDebug/include/public
-i../../../../engine/shared/library/sharedFile/include/public
-i../../../../engine/shared/library/sharedFoundation/include/public
-i../../../../engine/shared/library/sharedFoundationTypes/include/public
-i../../../../engine/shared/library/sharedLog/include/public
-i../../../../engine/shared/library/sharedMath/include/public
-i../../../../engine/shared/library/sharedMathArchive/include/public
-i../../../../engine/shared/library/sharedMemoryManager/include/public
-i../../../../engine/shared/library/sharedMessageDispatch/include/public
-i../../../../engine/shared/library/sharedNetwork/include/public
-i../../../../engine/shared/library/sharedNetworkMessages/include/public
-i../../../../engine/shared/library/sharedRandom/include/public
-i../../../../engine/shared/library/sharedSynchronization/include/public
-i../../../../engine/shared/library/sharedThread/include/public
-i../../../../engine/shared/library/sharedUtility/include/public
-i../../../../external/3rd/library/stlport453/stlport
-i../../../../external/ours/library/archive/include
-i../../../../external/ours/library/fileInterface/include/public
-i../../../../external/ours/library/localization/include
-i../../../../external/ours/library/localizationArchive/include/public
-i../../../../external/ours/library/singleton/include
-i../../../../external/ours/library/unicode/include
-i../../../../external/ours/library/unicodeArchive/include/public
-isrc/shared
-iinclude/private
-iinclude/public
std.lnt
swg-gen.lnt
swg-stlport.lnt
-e1774
@@ -1,6 +0,0 @@
AUTOMAKE_OPTIONS=foreign
SUBDIRS=shared linux .
include $(engine_dir)/../make_include/engine.include
@@ -1,263 +0,0 @@
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=CentralServer
CentralServer_CXXFLAGS=-I$(srcdir)/../$(platform) \
-I$(srcdir)/../shared \
-I$(archive_dir)/include \
-I$(unicode_dir)/include \
-I$(localization_dir)/include \
-I$(singleton_dir)/include \
-I$(engine_dir)/server/library/serverNetworkMessages/include/public \
-I$(engine_dir)/server/library/serverKeyShare/include/public \
-I$(engine_dir)/shared/library/sharedCompression/include/public \
-I$(engine_dir)/shared/library/sharedDebug/include/public \
-I$(engine_dir)/shared/library/sharedFile/include/public \
-I$(engine_dir)/shared/library/sharedFoundationTypes/include/public \
-I$(engine_dir)/shared/library/sharedFoundation/include/public \
-I$(engine_dir)/shared/library/sharedMemoryManager/include/public \
-I$(engine_dir)/shared/library/sharedMessageDispatch/include/public \
-I$(engine_dir)/shared/library/sharedNetwork/include/public \
-I$(engine_dir)/shared/library/sharedRandom/include/public \
-I$(engine_dir)/shared/library/sharedRegex/include/public \
-I$(engine_dir)/shared/library/sharedTemplate/include/public \
-I$(engine_dir)/shared/library/sharedThread/include/public \
-I$(engine_dir)/shared/library/sharedUtility/include/public \
-I$(stlport_dir)/stlport \
-I$(perforce_dir)/include \
-Wno-ctor-dtor-privacy
CentralServer_SOURCES=main.cpp
CentralServer_LDADD = $(top_builddir)/../engine/shared/library/sharedMemoryManager/libsharedMemoryManager.la \
../shared/libCentralServershared.la \
../shared/AuctionTransferGameAPI/libAuctionTransferGameAPI.la \
../shared/AuctionTransferGameAPI/ATGenericAPI/libAuctionTransferGameAPIATGenericAPI.la \
../shared/AuctionTransferGameAPI/Base/libAuctionTransferGameAPIBase.la \
../shared/AuctionTransferGameAPI/Base/linux/libAuctionTransferGameAPIlinux.la \
../shared/AuctionTransferGameAPI/TcpLibrary/libAuctionTransferGameAPITcpLibrary.la \
../shared/AuctionTransferGameAPI/zip/Zip/libAuctionTransferGameAPIZip.la \
$(top_builddir)/../engine/server/library/serverKeyShare/libserverKeyShare.la \
$(top_builddir)/../engine/shared/library/sharedGame/src/shared/sui/libsharedGamesharedsui.la \
$(top_builddir)/../engine/shared/library/sharedNetwork/libsharedNetwork.la \
$(top_builddir)/../engine/shared/library/sharedLog/libsharedLog.la \
$(top_builddir)/../engine/server/library/serverUtility/libserverUtility.la \
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/common/libsharedNetworkMessagessharedcommon.la \
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/clientGameServer/libsharedNetworkMessagessharedclientGameServer.la \
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/libsharedNetworkMessagesshared.la \
$(top_builddir)/../engine/shared/library/sharedImage/libsharedImage.la \
$(top_builddir)/../engine/shared/library/sharedCommandParser/libsharedCommandParser.la \
$(top_builddir)/../engine/server/library/serverMetrics/libserverMetrics.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/transferServer/libserverNetworkMessagessharedtransferServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameStationPlayersCollector/libserverNetworkMessagessharedgameStationPlayersCollector.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/libserverNetworkMessagesshared.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralPlanetServer/libserverNetworkMessagessharedcentralPlanetServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gamePlanetServer/libserverNetworkMessagessharedgamePlanetServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralConnectionServer/libserverNetworkMessagessharedcentralConnectionServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameGameServer/libserverNetworkMessagessharedgameGameServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralTaskManager/libserverNetworkMessagessharedcentralTaskManager.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/loginCentralServer/libserverNetworkMessagessharedloginCentralServer.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/metricsMessages/libserverNetworkMessagessharedmetricsMessages.la \
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralGameServer/libserverNetworkMessagessharedcentralGameServer.la \
$(top_builddir)/../engine/shared/library/sharedUtility/libsharedUtility.la \
$(top_builddir)/../engine/shared/library/sharedXml/libsharedXml.la \
$(top_builddir)/../engine/shared/library/sharedMessageDispatch/libsharedMessageDispatch.la \
$(top_builddir)/../engine/shared/library/sharedFile/libsharedFile.la \
$(top_builddir)/../engine/shared/library/sharedCompression/libsharedCompression.la \
$(top_builddir)/../engine/shared/library/sharedDebug/libsharedDebug.la \
$(top_builddir)/../game/shared/library/swgSharedUtility/libswgSharedUtility.la \
$(top_builddir)/../engine/shared/library/sharedFoundation/libsharedFoundation.la \
$(top_builddir)/../engine/shared/library/sharedThread/libsharedThread.la \
$(top_builddir)/../engine/shared/library/sharedSynchronization/libsharedSynchronization.la \
$(top_builddir)/../engine/shared/library/sharedMath/libsharedMath.la \
$(top_builddir)/../engine/shared/library/sharedRandom/libsharedRandom.la \
$(top_builddir)/../external/ours/library/localizationArchive/liblocalizationArchive.la \
$(top_builddir)/../external/ours/library/localization/liblocalization.la \
$(top_builddir)/../external/ours/library/unicodeArchive/libunicodeArchive.la \
$(top_builddir)/../external/ours/library/unicode/libunicode.la \
$(top_builddir)/../external/ours/library/fileInterface/libfileInterface.la \
$(top_builddir)/../external/ours/library/crypto/libcrypto.la \
$(top_builddir)/../external/ours/library/archive/libarchive.la \
$(libxml_dir)/libxml2.la \
$(stlport_dir)/lib/libstlport_gcc.a \
$(pcre_dir)/lib/libpcre.a \
$(udplibrary_dir)/output/debug/libudplibrary.a
CentralServer_LDFLAGS=-lpthread -ldl -lz -lm -lncurses
../shared/libCentralServershared.la:
make -C ../shared
../shared/AuctionTransferGameAPI/libAuctionTransferGameAPI.la:
make -C ../shared/AuctionTransferGameAPI
../shared/AuctionTransferGameAPI/ATGericAPI/libAuctionTransferGameAPIATGenericAPI.la:
make -C ../shared/AuctionTransferGameAPI/ATGenericAPI
../shared/AuctionTransferGameAPI/Base/libAuctionTransferGameAPIBase.la:
make -C ../shared/AuctionTransferGameAPI/Base
../shared/AuctionTransferGameAPI/Base/linux/libAuctionTransferGameAPIlinux.la:
make -C ../shared/AuctionTransferGameAPI/Base/linux
../shared/AuctionTransferGameAPI/TcpLibrary/libAuctionTransferGameAPITcpLibrary.la:
make -C ../shared/AuctionTransferGameAPI/TcpLibrary
../shared/AuctionTransferGameAPI/zip/Zip/libAuctionTransferGameAPIZip.la:
make -C ../shared/AuctionTransferGameAPI/zip/Zip
$(top_builddir)/../game/shared/library/swgSharedUtility/libswgSharedUtility.la:
make -C $(top_builddir)/../game/shared/library/swgSharedUtility
$(top_builddir)/../engine/shared/library/sharedSkillSystem/libsharedSkillSystem.la:
make -C $(top_builddir)/../engine/shared/library/sharedSkillSystem
$(top_builddir)/../engine/shared/library/sharedImage/libsharedImage.la:
make -C $(top_builddir)/../engine/shared/library/sharedImage
$(top_builddir)/../engine/shared/library/sharedFractal/libsharedFractal.la:
make -C $(top_builddir)/../engine/shared/library/sharedFractal
$(top_builddir)/../engine/shared/library/sharedTerrain/libsharedTerrain.la:
make -C $(top_builddir)/../engine/shared/library/sharedTerrain
$(top_builddir)/../engine/shared/library/sharedCollision/libsharedCollision.la:
make -C $(top_builddir)/../engine/shared/library/sharedCollision
$(top_builddir)/../engine/shared/library/sharedObject/src/shared/object/libsharedObjectsharedobject.la:
make -C $(top_builddir)/../engine/shared/library/sharedObject/src/shared/object
$(top_builddir)/../engine/shared/library/sharedGame/libsharedGame.la:
make -C $(top_builddir)/../engine/shared/library/sharedGame
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/common/libsharedNetworkMessagessharedcommon.la:
make -C $(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/common
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/clientGameServer/libsharedNetworkMessagessharedclientGameServer.la:
make -C $(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/clientGameServer
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared/libsharedNetworkMessagesshared.la:
make -C $(top_builddir)/../engine/shared/library/sharedNetworkMessages/src/shared
$(top_builddir)/../engine/shared/library/sharedMath/libsharedMath.la:
make -C $(top_builddir)/../engine/shared/library/sharedMath
$(top_builddir)/../engine/shared/library/sharedCommandParser/libsharedCommandParser.la:
make -C $(top_builddir)/../engine/shared/library/sharedCommandParser
$(top_builddir)/../engine/shared/library/sharedRandom/libsharedRandom.la:
make -C $(top_builddir)/../engine/shared/library/sharedRandom
$(top_builddir)/../engine/shared/library/sharedUtility/libsharedUtility.la:
make -C $(top_builddir)/../engine/shared/library/sharedUtility
$(top_builddir)/../engine/shared/library/sharedXml/libsharedXml.la:
make -C $(top_builddir)/../engine/shared/library/sharedXml
$(top_builddir)/../engine/server/library/serverMetrics/libserverMetrics.la:
make -C $(top_builddir)/../engine/server/library/serverMetrics
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralGameServer/libserverNetworkMessagessharedcentralGameServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralGameServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralConnectionServer/libserverNetworkMessagessharedcentralConnectionServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralConnectionServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/loginCentralServer/libserverNetworkMessagessharedloginCentralServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralConnectionServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/libserverNetworkMessagesshared.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/metricsMessages/libserverNetworkMessagessharedmetricsMessages.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/metricsMessages
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/transferServer/libserverNetworkMessagessharedtransferServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/transferServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameStationPlayersCollector/libserverNetworkMessagessharedgameStationPlayersCollector.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameStationPlayersCollector
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralPlanetServer/libserverNetworkMessagessharedcentralPlanetServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralPlanetServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gamePlanetServer/libserverNetworkMessagessharedgamePlanetServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gamePlanetServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameGameServer/libserverNetworkMessagessharedgameGameServer.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/gameGameServer
$(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralTaskManager/libserverNetworkMessagessharedcentralTaskManager.la:
make -C $(top_builddir)/../engine/server/library/serverNetworkMessages/src/shared/centralTaskManager
$(top_builddir)/../engine/server/library/serverUtility/libserverUtility.la:
make -C $(top_builddir)/../engine/server/library/serverUtility
$(top_builddir)/../engine/shared/library/sharedCompression/libsharedCompression.la:
make -C $(top_builddir)/../engine/shared/library/sharedCompression
$(top_builddir)/../engine/shared/library/sharedDebug/libsharedDebug.la:
make -C $(top_builddir)/../engine/shared/library/sharedDebug
$(top_builddir)/../engine/shared/library/sharedFile/libsharedFile.la:
make -C $(top_builddir)/../engine/shared/library/sharedFile
$(top_builddir)/../engine/shared/library/sharedFoundation/libsharedFoundation.la:
make -C $(top_builddir)/../engine/shared/library/sharedFoundation
$(top_builddir)/../engine/shared/library/sharedLog/libsharedLog.la:
make -C $(top_builddir)/../engine/shared/library/sharedLog
$(top_builddir)/../engine/shared/library/sharedMemoryManager/libsharedMemoryManager.la:
make -C $(top_builddir)/../engine/shared/library/sharedMemoryManager
$(top_builddir)/../engine/shared/library/sharedMessageDispatch/libsharedMessageDispatch.la:
make -C $(top_builddir)/../engine/shared/library/sharedMessageDispatch
$(top_builddir)/../engine/shared/library/sharedNetwork/libsharedNetwork.la:
make -C $(top_builddir)/../engine/shared/library/sharedNetwork
$(top_builddir)/../engine/shared/library/sharedNetworkMessages/libsharedNetworkMessages.la:
make -C $(top_builddir)/../engine/shared/library/sharedNetworkMessages
$(top_builddir)/../engine/shared/library/sharedSynchronization/libsharedSynchronization.la:
make -C $(top_builddir)/../engine/shared/library/sharedSynchronization
$(top_builddir)/../engine/shared/library/sharedThread/libsharedThread.la:
make -C $(top_builddir)/../engine/shared/library/sharedThread
$(top_builddir)/../engine/server/library/serverKeyShare/libserverKeyShare.la:
make -C $(top_builddir)/../engine/server/library/serverKeyShare
$(top_builddir)/../external/ours/library/unicodeArchive/libunicodeArchive.la:
make -C $(top_builddir)/../external/ours/library/unicodeArchive
$(top_builddir)/../external/ours/library/unicode/libunicode.la:
make -C $(top_builddir)/../external/ours/library/unicode
$(top_builddir)/../external/ours/library/localizationArchive/liblocalizationArchive.la:
make -C $(top_builddir)/../external/ours/library/localizationArchive
$(top_builddir)/../external/ours/library/localization/liblocalization.la:
make -C $(top_builddir)/../external/ours/library/localization
$(top_builddir)/../external/ours/library/fileInterface/libfileInterface.la:
make -C $(top_builddir)/../external/ours/library/fileInterface
$(top_builddir)/../external/ours/library/crypto/libcrypto.la:
make -C $(top_builddir)/../external/ours/library/crypto
$(top_builddir)/../external/ours/library/archive/libarchive.la:
make -C $(top_builddir)/../external/ours/library/archive
$(udplibrary_dir)/output/debug/libudplibrary.a:
make -C $(udplibrary_dir)
$(stlport_dir)/lib/libstlport_gcc.a:
make -C $(stlport_dir)/src -f gcc-linux.mak
$(top_builddir)/../engine/shared/library/sharedGame/src/shared/sui/libsharedGamesharedsui.la:
cd $(top_builddir)/../engine/shared/library/sharedGame/src/shared/sui && $(MAKE)
include $(engine_dir)/../make_include/engine.include
@@ -1,55 +0,0 @@
#include "sharedFoundation/FirstSharedFoundation.h"
#include "ConfigCentralServer.h"
#include "CentralServer.h"
#include "sharedCompression/SetupSharedCompression.h"
#include "sharedDebug/SetupSharedDebug.h"
#include "sharedFile/SetupSharedFile.h"
#include "sharedFoundation/Os.h"
#include "sharedNetwork/NetworkHandler.h"
#include "sharedFoundation/SetupSharedFoundation.h"
#include "sharedRandom/SetupSharedRandom.h"
#include "sharedThread/SetupSharedThread.h"
// ======================================================================
int main(int argc, char ** argv)
{
SetupSharedThread::install();
SetupSharedDebug::install(1024);
//-- setup foundation
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
setupFoundationData.lpCmdLine = ConvertCommandLine(argc,argv);
SetupSharedFoundation::install(setupFoundationData);
SetupSharedCompression::install();
SetupSharedFile::install(false);
SetupSharedRandom::install(time(0)); //lint !e732
NetworkHandler::install();
Os::setProgramName("CentralServer");
ConfigCentralServer::install();
std::string cmdLine = setupFoundationData.lpCmdLine;
size_t firstArg = cmdLine.find(" ", 0);
size_t lastSlash = 0;
size_t nextSlash = 0;
while(nextSlash < firstArg)
{
nextSlash = cmdLine.find("/", lastSlash);
if(nextSlash == cmdLine.npos || nextSlash >= firstArg) //lint !e1705 static class members may be accessed by the scoping operator (huh?)
break;
lastSlash = nextSlash + 1;
}
cmdLine = cmdLine.substr(lastSlash);
CentralServer::getInstance().setCommandLine(cmdLine);
//-- run game
SetupSharedFoundation::callbackWithExceptionHandling(CentralServer::run);
NetworkHandler::remove();
SetupSharedFoundation::remove();
return 0;
}
@@ -1,58 +0,0 @@
#include "FirstCentralServer.h"
#include "AuctionTransferClient.h"
#include "sharedLog/Log.h"
AuctionTransferClient::AuctionTransferClient(const char *hostName[], const short port[], int count, const char *identifier[], unsigned identifierCount) :
AuctionTransferAPI( hostName, port, count, identifier, identifierCount )
{
}
AuctionTransferClient::~AuctionTransferClient()
{
}
// Connection status callbacks
void AuctionTransferClient::onConnect(const char* host, unsigned short port, const short current, const short max)
{
LOG("AuctionTransferClient", ("onConnect"));
}
void AuctionTransferClient::onDisconnect(const char *host, const short port, const short current, const short max)
{
LOG("AuctionTransferClient", ("onDisconnect"));
}
/*****************************
void AuctionTransferClient::addCoinToAuction( const ExchangeListCreditsMessage& msg )
{
//1. get transaction id from auction system (save msg details for use when get response)
//2. on response: if success:
// 2a. send prepare transaction
// 2b. on response:
// 2bi. if user connected: send VeAuctionCoinReply (with result code) to user's ES
// 2bii. if user not connected: send immediate abort back to auction service
const unsigned uTrack = getNewTransactionID( NULL );
AuctionAssetDetails &details = m_mPendingRequestDetails[ uTrack ];
details.u8Type = AuctionAssetDetails::TYPE_COIN;
details.u32AccountNum = msg.getAccountNum();
details.u32CharDBID = msg.getCharacterId();
details.i64ItemDBID = 0;
details.u32ItemStackCount = 0;
details.i64Credits = msg.getCredits();
details.sAssetXML = ""; ///msg.getAssetXML();
}
**********************/
@@ -1,141 +0,0 @@
#ifndef AUCTIONSTRANFERCLIENT_H
#define AUCTIONSTRANFERCLIENT_H
#ifndef _WIN32
#include "AuctionTransferGameAPI/AuctionTransferAPI.h"
#else
namespace AuctionTransfer
{
class AuctionTransferAPI
{
public:
AuctionTransferAPI( const char *[], const short [], int , const char *[], unsigned )
{};
virtual void process() {};
};
};
#endif
class AuctionTransferClient : public AuctionTransfer::AuctionTransferAPI
{
public:
AuctionTransferClient(const char *hostName[], const short port[], int count, const char *identifier[], unsigned identifierCount);
virtual ~AuctionTransferClient();
// Connection status callbacks
virtual void onConnect(const char* host, unsigned short port, const short current, const short max);
virtual void onDisconnect(const char *host, const short port, const short current, const short max);
// Callbacks that are responses
void onSendPrepareTransaction(unsigned int, unsigned int, void *) {};
void onSendPrepareTransactionCompressed(unsigned int, unsigned int, void *) {};
void onSendCommitTransaction(unsigned int, unsigned int, void *) {};
void onSendAbortTransaction(unsigned int, unsigned int, void *) {};
void onSendAuditAssetTransfer(unsigned int, unsigned int, void *) {};
void onGetNewTransactionID(unsigned int, unsigned int, int64, void *) {};
// Responses to reply requests
void onReplyReceivePrepareTransaction(unsigned int, unsigned int, void *) {};
void onReplyReceiveCommitTransaction(unsigned int, unsigned int, void *) {};
void onReplyReceiveAbortTransaction(unsigned int, unsigned int, void *) {};
void onReplyReceiveGetCharacterList(unsigned int, unsigned int, void *) {};
// house keeping
void onIdentifyHost(unsigned int, unsigned int, void *) {};
// callbacks initiated by auction
void onReceivePrepareTransaction(unsigned int, int64, unsigned int, unsigned int, int64, const char *) {};
void onReceiveCommitTransaction(unsigned int, int64) {};
void onReceiveAbortTransaction(unsigned int, int64) {};
void onReceiveGetCharacterList(unsigned int, unsigned int, const char *) {};
private:
/*************************************************
struct AuctionAssetDetails
{
enum eAssetTypes
{
TYPE_ITEM,
TYPE_COIN,
TYPE_CHARACTER,
TYPE_FOR_IMAGE_UPLOAD
};
AuctionAssetDetails()
: u8Type( TYPE_ITEM ),
u32AccountNum( 0 ),
u32CharDBID( 0 ),
i64ItemDBID( INVALID_EQUID ),
u32ItemStackCount( 0 ),
i64AssetID( 0 )
{}
uns8 u8Type;
uns32 u32AccountNum;
uns32 u32CharDBID;
int64 i64ItemDBID;
uns32 u32ItemStackCount;
int64 i64Copper;
CharString sAssetXML;
int64 i64AssetID;
};
typedef std::map< unsigned, AuctionAssetDetails > PendingRequestMap;
PendingRequestMap m_mPendingRequestDetails;
struct IncomingPrepareDetails
{
int64 i64TransactionID;
int64 i64AssetID;
uns32 u32DestStationID;
uns32 u32DestCharDBID;
};
typedef std::map< unsigned, IncomingPrepareDetails > IncomingPrepareMap;//key=tracking
IncomingPrepareMap m_mPendingIncomingPrepareDetails;
typedef std::map< unsigned, int64 > IncomingCommitMap;//key=tracking, val=transaction
IncomingCommitMap m_mPendingIncomingCommitDetails;
struct TransferDetails
{
TransferDetails()
: i64AssetID( 0 ),
u32DestStationID( 0 ),
u32DestCharDBID( INVALID_EQUID )
{}
int64 i64AssetID;
uns32 u32DestStationID;
uns32 u32DestCharDBID;
//used when committing
std::vector< uns8 > aAssetSerialData;
int32 i32Copper;
};
typedef std::map< int64, TransferDetails > PendingTransferMap;
PendingTransferMap m_mPendingTransferDetails;
**********************************************/
};
#endif
@@ -1,272 +0,0 @@
#include "GenericApiCore.h"
#include "GenericConnection.h"
#include "GenericMessage.h"
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
using namespace std;
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
//----------------------------------------
ServerTrackObject::ServerTrackObject(unsigned mapped_track, unsigned real_track, GenericConnection *con)
: m_mappedTrack(mapped_track), m_realTrack(real_track), m_connection(con)
//----------------------------------------
{
}
//----------------------------------------
GenericAPICore::GenericAPICore(const char *host,
short port,
unsigned reqTimeout,
unsigned reconnectTimeout,
unsigned noDataTimeoutSecs,
unsigned noAckTimeoutSecs,
unsigned incomingBufSizeInKB,
unsigned outgoingBufSizeInKB,
unsigned keepAlive,
unsigned maxRecvMessageSizeInKB)
: m_currTrack(0),
m_reconnectTimeout(0),
m_outCount(0),
m_pendingCount(0),
m_requestTimeout(reqTimeout),
m_currentConnections(0), m_maxConnections(0),
m_suspended(false),
m_nextConnectionIndex(0)
//----------------------------------------
{
GenericConnection *con = new GenericConnection(host, port, this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
m_serverConnections.push_back(con);
}
//----------------------------------------
GenericAPICore::GenericAPICore(const char *game, const char *hosts[],
const short port[],
unsigned arraySize,
unsigned reqTimeout,
unsigned reconnectTimeout,
unsigned noDataTimeoutSecs,
unsigned noAckTimeoutSecs,
unsigned incomingBufSizeInKB,
unsigned outgoingBufSizeInKB,
unsigned keepAlive,
unsigned maxRecvMessageSizeInKB)
: m_currTrack(0),
m_reconnectTimeout(0),
m_outCount(0),
m_pendingCount(0),
m_requestTimeout(reqTimeout),
m_currentConnections(0), m_maxConnections(0),
m_suspended(false),
m_nextConnectionIndex(0),
m_game(game)
//----------------------------------------
{
for (unsigned i=0; i<arraySize; i++)
{
GenericConnection *con = new GenericConnection(hosts[i], port[i], this, reconnectTimeout, noDataTimeoutSecs, noAckTimeoutSecs, incomingBufSizeInKB, outgoingBufSizeInKB, keepAlive, maxRecvMessageSizeInKB);
m_serverConnections.push_back(con);
}
}
//----------------------------------------
GenericAPICore::~GenericAPICore()
//----------------------------------------
{
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
{
GenericConnection *con = *conIter;
delete con;
}
m_serverConnections.clear();
for(map<unsigned, GenericResponse *>::iterator iter = m_pending.begin(); iter != m_pending.end(); ++iter)
{
delete (*iter).second;
}
m_pending.empty();
while(m_outCount > 0)
{
delete m_outboundQueue.front().second;
delete m_outboundQueue.front().first;
m_outboundQueue.pop();
--m_outCount;
}
}
//----------------------------------------
unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res)
//----------------------------------------
{
++m_outCount;
if(m_currTrack == 0)
{
m_currTrack++;
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
m_outboundQueue.push(pair<GenericRequest *, GenericResponse *>(req, res));
return(m_currTrack++);
}
//----------------------------------------
void GenericAPICore::process()
//----------------------------------------
{
GenericRequest *req;
GenericResponse *res;
if (!m_suspended)
{
// Process timeout on pending requests
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(NULL)))
{
--m_outCount;
res = m_outboundQueue.front().second;
m_outboundQueue.pop();
responseCallback(res);
delete res;
delete req;
}
// Process timeout on pending responses
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(NULL)))
{
--m_pendingCount;
m_pending.erase(m_pending.begin());
responseCallback(res);
delete res;
}
while(m_outCount > 0)
{
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
req = out_pair.first;
res = out_pair.second;
GenericConnection *con = NULL;
if (req->getMappedServerTrack() == 0) // request has no originating "owner" server
{
con = getNextActiveConnection(); // it does not matter which server we send this to
}
else
{
ServerTrackObject *stobj = findServer(req->getMappedServerTrack());
if (stobj)
{
con = stobj->getConnection(); // the server connection to respond to
req->setServerTrack(stobj->getRealServerTrack()); // map server track back to REAL server track
//printf("\nUnmapping %d to %d", stobj->getMappedServerTrack(), req->getMappedServerTrack()); //debug
delete stobj;
}
}
if (con != NULL)
{
Base::ByteStream msg;
req->pack(msg);
con->Send(msg);
m_pending.insert(pair<unsigned, GenericResponse *>(res->getTrack(), res));
--m_outCount;
++m_pendingCount;
m_outboundQueue.pop();
delete req;
}
else
{
//no active connections
break; //from while loop
}
}
}
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
{
GenericConnection *con = *conIter;
con->process();
}
}
//----------------------------------------
GenericConnection *GenericAPICore::getNextActiveConnection()
//----------------------------------------
{
unsigned startIndex = m_nextConnectionIndex;
unsigned maxIndex = m_serverConnections.size() - 1;
GenericConnection *con = NULL;
//loop until we find an active connection, or until we get back
// to where we started
do
{
if (m_serverConnections[m_nextConnectionIndex]->isConnected())
{
con = m_serverConnections[m_nextConnectionIndex];
if (m_nextConnectionIndex == maxIndex)
m_nextConnectionIndex = 0;
else
m_nextConnectionIndex++;
}
else if (++m_nextConnectionIndex > maxIndex)
{
//went past end of vector, start back at 0
m_nextConnectionIndex = 0;
}
}while (con == NULL && m_nextConnectionIndex != startIndex);
return con;
}
//----------------------------------------
void GenericAPICore::countOpenConnections()
//----------------------------------------
{
m_currentConnections = 0;
m_maxConnections = m_serverConnections.size();
for (std::vector<GenericConnection *>::iterator conIter = m_serverConnections.begin(); conIter != m_serverConnections.end(); conIter++)
{
GenericConnection *con = *conIter;
if (con->isConnected())
++m_currentConnections;
}
}
//----------------------------------------
ServerTrackObject *GenericAPICore::findServer(unsigned server_track)
//----------------------------------------
{
std::map<unsigned, ServerTrackObject *>::iterator iter = m_serverTracks.find(server_track);
if (iter == m_serverTracks.end())
return NULL;
ServerTrackObject *stobj = (*iter).second;
m_serverTracks.erase(server_track);
return stobj;
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,123 +0,0 @@
#if !defined (GENERICAPICORE_H_)
#define GENERICAPICORE_H_
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
#pragma warning (disable: 4786)
#include <map>
#include <queue>
#include <time.h>
#include "../Base/Archive.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
class GenericRequest;
class GenericResponse;
class GenericConnection;
//----------------------------------------------
class ServerTrackObject
//----------------------------------------------
{
public:
ServerTrackObject(unsigned mapped_track, unsigned real_track, GenericConnection *con);
~ServerTrackObject() { }
inline GenericConnection *getConnection() { return m_connection; }
inline unsigned getRealServerTrack() { return m_realTrack; }
inline unsigned getMappedServerTrack() { return m_mappedTrack; }
private:
unsigned m_mappedTrack;
unsigned m_realTrack;
GenericConnection *m_connection;
};
//----------------------------------------------
class GenericAPICore
//----------------------------------------------
{
public:
friend class GenericConnection;
GenericAPICore::GenericAPICore(const char *host,
short port,
unsigned reqTimeout,
unsigned reconnectTimeout,
unsigned noDataTimeoutSecs = 5,
unsigned noAckTimeoutSecs = 5,
unsigned incomingBufSizeInKB = 32,
unsigned outgoingBufSizeInKB = 32,
unsigned keepAlive = 1,
unsigned maxRecvMessageSizeInKB = 0);
/**
* NOTE: arraySize must be actual size of host and port arrays.
* ALSO: cannot specify a 0 array size.
*/
GenericAPICore(const char *game, const char *hosts[],
const short port[],
unsigned arraySize,
unsigned reqTimeout,
unsigned reconnectTimeout,
unsigned noDataTimeoutSecs = 5,
unsigned noAckTimeoutSecs = 5,
unsigned incomingBufSizeInKB = 32,
unsigned outgoingBufSizeInKB = 32,
unsigned keepAlive = 1,
unsigned maxRecvMessageSizeInKB = 0);
virtual ~GenericAPICore();
void process();
virtual void responseCallback(short type, Base::ByteStream::ReadIterator &iter, GenericConnection *con) = 0;
virtual void responseCallback(GenericResponse *R) = 0;
virtual void OnDisconnect(GenericConnection *con) = 0;
virtual void OnConnect(GenericConnection *con) = 0;
void countOpenConnections();
ServerTrackObject *findServer(unsigned server_track);
void suspendProcessing() { m_suspended = true; }
void resumeProcessing() { m_suspended = false; }
unsigned submitRequest(GenericRequest *req, GenericResponse *res);
GenericConnection *getNextActiveConnection();
std::string &getGameCode() { return m_game; }
void addIdentifier(std::string id) { m_gameIdentifiers.push_back(id);}
protected:
std::vector<GenericConnection *> m_serverConnections;
std::map<unsigned, GenericResponse *> m_pending;
std::queue<std::pair<GenericRequest *, GenericResponse *> > m_outboundQueue;
unsigned m_currTrack;
time_t m_reconnectTimeout;
unsigned m_outCount;
unsigned m_pendingCount;
unsigned m_requestTimeout;
unsigned m_currentConnections; // number currently connected
unsigned m_maxConnections; // number that should be connected
std::map<unsigned, ServerTrackObject *> m_serverTracks;
std::vector<std::string> m_gameIdentifiers;
private:
bool m_suspended;
unsigned m_nextConnectionIndex;
std::string m_game;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,218 +0,0 @@
#include "GenericApiCore.h"
#include "GenericConnection.h"
#include "GenericMessage.h"
#include "../AuctionTransferAPICore.h"
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
#define REQUEST_SET_API 0
#define GAME_RESOURCE 1
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
using namespace std;
using namespace Base;
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB)
: m_bConnected(CON_NONE),
m_apiCore(apiCore),
m_con(NULL),
m_host(host),
m_port(port),
m_lastTrack(123455), //random choice != 1
m_conState(CON_DISCONNECT),
m_reconnectTimeout(reconnectTimeout)
{
TcpManager::TcpParams params;
params.incomingBufferSize = incomingBufSizeInKB * 1024;
params.outgoingBufferSize = outgoingBufSizeInKB * 1024;
params.maxConnections = 1;
params.port = 0;
params.maxRecvMessageSize = maxRecvMessageSizeInKB*1024;
params.keepAliveDelay = keepAlive * 1000;
params.noDataTimeout = noDataTimeoutSecs * 1000;
//params.oldestUnacknowledgedTimeout = noAckTimeoutSecs * 1000;
m_manager = new TcpManager(params);
}
GenericConnection::~GenericConnection()
{
if(m_con)
{
m_con->SetHandler(NULL);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to null, so it wont
m_con->Release();
}
m_manager->Release();
}
void GenericConnection::disconnect()
{
if (m_con)
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
}
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
}
void GenericConnection::OnTerminated(TcpConnection *con)
{
// m_apiCore->OnDisconnect(m_host.c_str(), m_port);
m_apiCore->OnDisconnect(this);
if(m_con)
{
m_con->Release();
m_con = NULL;
}
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
}
void GenericConnection::OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen)
{
short type;
unsigned track;
ByteStream msg(data, dataLen);
ByteStream::ReadIterator iter = msg.begin();
get(iter, type);
get(iter, track);
GenericResponse *res = NULL;
// the following if block is a temporary fix that prevents
// a crash with a game team in which they occasionally find
// themselves receiving a dupe track in consecutive calls to
// OnRoutePacket (which then leads to a callback being called
// twice and data being invalid on the second call -> crash!).
// TODO: resolve this BK
/* if (track != 0 &&
track == m_lastTrack)
{
printf("!!! ERROR !!! Got a duplicate track ID %u\n", track);
return;
}
m_lastTrack = track;
*/
// end temporary fix.
if(track == 0) // notification message from the server, not as a response to a request from this API
{
if (type == ATGAME_REQUEST_CONNECT)
{ // this is a special case, for when we have identified our game code to server
m_bConnected = CON_IDENTIFIED;
m_apiCore->OnConnect(this);
}
else
{
m_apiCore->responseCallback(type, iter, this);
}
}
else
{
map<unsigned, GenericResponse *>::iterator mapIter = m_apiCore->m_pending.find(track);
if(mapIter != m_apiCore->m_pending.end())
{
res = (*mapIter).second;
iter = msg.begin();
res->unpack(iter);
m_apiCore->responseCallback(res);
m_apiCore->m_pendingCount--;
m_apiCore->m_pending.erase(mapIter);
delete res;
}
}
}
void GenericConnection::process()
{
switch(m_conState)
{
case CON_DISCONNECT:
// create connection object, attempting to connect and
// checking for connection in next state, CON_NEGOTIATE
m_con = m_manager->EstablishConnection(m_host.c_str(), m_port);
if(m_con)
{
m_con->SetHandler(this);
m_conState = CON_NEGOTIATE;
m_conTimeout = time(NULL) + m_reconnectTimeout;
}
break;
case CON_NEGOTIATE:
// check for connection
if(m_con->GetStatus() == TcpConnection::StatusConnected)
{
// we're connected
m_conState = CON_CONNECT;
m_bConnected = CON_CONNECTED;
// instead of calling OnConnect() right now, we are going to submit a connection packet
// identifying us
// m_apiCore->OnConnect(this);
Base::ByteStream msg;
put(msg, (short)REQUEST_SET_API);
put(msg, (unsigned)0); // track
put(msg, (unsigned)API_VERSION_CODE);
put(msg, GAME_RESOURCE); // identify us as a game connection resource
// now add in the game identifiers
put(msg, (unsigned)m_apiCore->m_gameIdentifiers.size()); // number of strings to read
for(unsigned index = 0; index < m_apiCore->m_gameIdentifiers.size(); index++)
put(msg, std::string(m_apiCore->m_gameIdentifiers[index]));
Send(msg);
}
else if(time(NULL) > m_conTimeout)
{
// we did not connect
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
}
break;
case CON_CONNECT:
// do nothing
break;
default:
// this should not occur, but we revert to CON_DISCONNECT if it does
m_conState = CON_DISCONNECT;
m_bConnected = CON_NONE;
if (m_con)
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
}
}
m_manager->GiveTime();
}
void GenericConnection::Send(Base::ByteStream &msg)
{
if(m_con && m_con->GetStatus() == TcpConnection::StatusConnected)
{
m_con->Send((const char *)msg.getBuffer(), msg.getSize());
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,88 +0,0 @@
#if !defined (GENERICCONNECTION_H_)
#define GENERICCONNECTION_H_
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
#include "../Base/Archive.h"
#include "../TcpLibrary/TcpManager.h"
#include "../TcpLibrary/TcpConnection.h"
#include "../TcpLibrary/TcpHandlers.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
static const unsigned API_VERSION_CODE = 1;
//////////////////////////////////////////////////////////////////////////////////////////////
// these will never change. They will also be in the enumeration. These are defined here to
// prevent us from having to re-compile and include the enumeration file in this generic code.
#define ATGAME_REQUEST_CONNECT 0
#define ATWEB_REQUEST_CONNECT 10000
//////////////////////////////////////////////////////////////////////////////////////////////
enum eConState
{
CON_DISCONNECT,
CON_NEGOTIATE,
CON_CONNECT
};
enum eConnectStatus
{
CON_NONE,
CON_CONNECTED,
CON_IDENTIFIED
};
class GenericConnection : public TcpConnectionHandler
{
public:
GenericConnection(const char *host,
short port,
GenericAPICore *apiCore,
unsigned reconnectTimeout,
unsigned noDataTimeoutSecs = 5,
unsigned noAckTimeoutSecs = 5,
unsigned incomingBufSizeInKB = 32,
unsigned outgoingBufSizeInKB = 32,
unsigned keepAlive = 1,
unsigned maxRecvMessageSizeInKB = 0);
virtual ~GenericConnection();
virtual void OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen);
virtual void OnTerminated(TcpConnection *con);
void Send(Base::ByteStream &msg);
inline const char *getHost() const { return m_host.c_str(); }
inline const short getPort() const { return m_port; }
inline eConnectStatus isConnected() { return m_bConnected; }
void disconnect();
void process();
private:
eConnectStatus m_bConnected;
GenericAPICore *m_apiCore;
TcpManager *m_manager;
TcpConnection *m_con;
std::string m_host;
short m_port;
unsigned m_lastTrack;
eConState m_conState;
time_t m_conTimeout;
unsigned m_reconnectTimeout;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,44 +0,0 @@
#include "GenericMessage.h"
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
using namespace Base;
//-------------------------------------------
GenericRequest::GenericRequest(short type, unsigned server_track)
: m_type(type), m_server_track(server_track)
//-------------------------------------------
{
}
//-------------------------------------------
GenericResponse::GenericResponse(short type, unsigned result, void *user)
: m_type(type), m_result(result), m_user(user)
//-------------------------------------------
{
}
//-----------------------------------------
void GenericResponse::unpack(ByteStream::ReadIterator &iter)
//-----------------------------------------
{
get(iter, m_type);
get(iter, m_track);
get(iter, m_result);
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,75 +0,0 @@
#if !defined (GENERICMESSAGE_H_)
#define GENERICMESSAGE_H_
//----------------------------------------
//
// WARNING: These files are NOT standard generic API files
// They have been modified for this project.
// Do NOT replace them with generic API files
//
//----------------------------------------
#include <time.h>
#include "../Base/Archive.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
//-------------------------------------------
class GenericRequest
//-------------------------------------------
{
public:
GenericRequest(short type, unsigned server_track = 0);
virtual ~GenericRequest() {};
virtual void pack(Base::ByteStream &msg) = 0;
short getType() const { return m_type; }
void setTimeout(time_t t) { m_timeout = t; }
time_t getTimeout() { return m_timeout; }
void setTrack(unsigned t) { m_track = t; }
unsigned getTrack() const { return m_track; }
inline const unsigned getMappedServerTrack() const { return m_server_track; }
inline void setServerTrack(unsigned track) { m_server_track = track; }
protected:
short m_type;
unsigned m_track;
time_t m_timeout;
unsigned m_server_track;
};
// Basic response message from server. In the case that this response to a request
// submitted from this API, the response would have been generated at request submission
// time, and the timeout value filled in appropriatly
//-------------------------------------------
class GenericResponse
//-------------------------------------------
{
public:
GenericResponse(short type, unsigned result, void *user);
virtual ~GenericResponse() {};
virtual void unpack(Base::ByteStream::ReadIterator &iter);
short getType() const { return m_type; }
void setTimeout(time_t t) { m_timeout = t; }
time_t getTimeout() { return m_timeout; }
void setTrack(unsigned t) { m_track = t; }
unsigned getTrack() const { return m_track; }
unsigned getResult() const { return m_result; }
void setResult(unsigned res) { m_result = res; }
void * getUser() const { return m_user; }
protected:
short m_type;
unsigned m_track;
unsigned m_result;
void *m_user;
time_t m_timeout;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,13 +0,0 @@
AUTOMAKE_OPTIONS=foreign
INCLUDES = \
-I$(top_srcdir)/server/application/CentralServer/src/shared/AuctionTransferGameAPI \
-I$(top_srcdir)/external/3rd/library/platform -I.. \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
libAuctionTransferGameAPIATGenericAPI_la_LDFLAGS = -avoid-version
noinst_LTLIBRARIES = libAuctionTransferGameAPIATGenericAPI.la
libAuctionTransferGameAPIATGenericAPI_la_SOURCES = GenericApiCore.cpp GenericApiCore.h\
GenericConnection.cpp GenericConnection.h GenericMessage.cpp\
GenericMessage.h
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,194 +0,0 @@
#include "AuctionTransferAPI.h"
#include "AuctionTransferAPICore.h"
#include "Request.h"
#include "Response.h"
#include "zip/GZipHelper.h"
#define DEFAULT_HOST "sdt-auctionsys1"
#define DEFAULT_PORT 5901
#define DEFAULT_IDENTIFIER "GAME+UNKNOWN"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPI::AuctionTransferAPI(const char *hostName[], const short port[], int count, const char *identifier[], unsigned identifierCount, unsigned reqTimeout, unsigned maxRecvMessageSizeInKB)
{
m_apiCore = new AuctionTransferAPICore(hostName, port, count, this, identifier, identifierCount, reqTimeout, maxRecvMessageSizeInKB);
}
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPI::AuctionTransferAPI(const char *hostNames, const char *identifiers)
{
std::vector<const char *> hostArray;
std::vector<const char *> identifierArray;
std::vector<short> portArray;
char hostConfig[4096];
char identifierConfig[4096];
if (hostNames == NULL)
hostNames = DEFAULT_HOST;
if(identifiers == NULL)
identifiers = DEFAULT_IDENTIFIER;
// parse the hosts and ports out :
strncpy(hostConfig, hostNames, 4096); hostConfig[4095] = 0;
char *ptr;
if ((ptr = strtok(hostConfig, " ")))
{
do
{
char * host = ptr;
char * portStr = strchr(host, ':');
unsigned short port = DEFAULT_PORT;
if (portStr)
{
*portStr++ = 0;
port = atoi(portStr);
}
if (::strlen(host) && port)
{
hostArray.push_back(host);
portArray.push_back(port);
}
}
while ((ptr = strtok(NULL, " ")) != NULL);
}
strncpy(identifierConfig, identifiers, 4096); identifierConfig[4095] = 0;
// parse the identifiers out
if ((ptr = strtok(identifierConfig, ";")))
{
do
{
char * identifier = ptr;
if (::strlen(identifier))
{
identifierArray.push_back(identifier);
}
}
while ((ptr = strtok(NULL, ";")) != NULL);
}
if (hostArray.empty())
{
hostArray.push_back(DEFAULT_HOST);
portArray.push_back(DEFAULT_PORT);
}
if(identifierArray.empty())
identifierArray.push_back(DEFAULT_IDENTIFIER);
m_apiCore = new AuctionTransferAPICore(&hostArray[0], &portArray[0], hostArray.size(), this, &identifierArray[0], identifierArray.size());
}
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPI::~AuctionTransferAPI()
{
if( m_apiCore)
delete m_apiCore;
}
//////////////////////////////////////////////////////////////////////////////////////
void AuctionTransferAPI::process()
{
m_apiCore->process();
}
//////////////////////////////////////////////////////////////////////////////////////
// Calls and replies
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::replyReceiveAbortTransaction(unsigned trackingNumber, unsigned responseCode, void *user)
{
ReplyRequest *req = new ReplyRequest( GAME_REPLY_RECEIVE_ABORT, trackingNumber, responseCode );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REPLY_RECEIVE_ABORT, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::replyReceiveCommitTransaction(unsigned trackingNumber, unsigned responseCode, void *user)
{
ReplyRequest *req = new ReplyRequest( GAME_REPLY_RECEIVE_COMMIT, trackingNumber, responseCode );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REPLY_RECEIVE_COMMIT, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::replyReceivePrepareTransaction(unsigned trackingNumber, unsigned responseCode, void *user)
{
ReplyRequest *req = new ReplyRequest( GAME_REPLY_RECEIVE_PREPARE_TRANSACTION, trackingNumber, responseCode );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REPLY_RECEIVE_PREPARE_TRANSACTION, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::sendAbortTransaction(long long transactionID, void *user)
{
CommonRequest *req = new CommonRequest( GAME_REQUEST_SEND_ABORT, 0, transactionID );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REQUEST_SEND_ABORT, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::sendCommitTransaction(long long transactionID, void *user)
{
CommonRequest *req = new CommonRequest( GAME_REQUEST_SEND_COMMIT, 0, transactionID );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REQUEST_SEND_COMMIT, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::sendPrepareTransaction(const char *serverIdentifier, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *xmlAsset, void *user, bool compress)
{
RequestTypes requestEnum = GAME_REQUEST_SEND_PREPARE_TRANSACTION;
GenericRequest *req = NULL;
if( compress )
{
requestEnum = GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED;
// compress and create the request here
char *data = (char *)xmlAsset;
CA2GZIP zippedData(data, strlen(xmlAsset));
req = new SendPrepareCompressedRequest( requestEnum, 0, serverIdentifier, transactionID, stationID, characterID, assetID, zippedData.pgzip, zippedData.Length );
}
else
{
req = new SendPrepareRequest( requestEnum, 0, serverIdentifier, transactionID, stationID, characterID, assetID, xmlAsset );
}
return m_apiCore->submitRequest( req, new CommonResponse( requestEnum, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::sendPrepareTransactionCompressed (const char *serverIdentifier, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const unsigned char *zippedXmlAsset, unsigned length, void *user)
{
SendPrepareCompressedRequest *req = new SendPrepareCompressedRequest( GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED, 0, serverIdentifier, transactionID, stationID, characterID, assetID, zippedXmlAsset, length );
return m_apiCore->submitRequest( req, new CommonResponse( GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED, user ));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::replyReceiveGetCharacterList(unsigned trackingNumber, unsigned responseCode, const Character characters[], unsigned numCharacters, void *user)
{
ReplyGetCharacterListRequest *req = new ReplyGetCharacterListRequest(GAME_REPLY_RECEIVE_GET_CHARACTER_LIST, trackingNumber, responseCode, characters, numCharacters);
return m_apiCore->submitRequest(req, new CommonResponse(GAME_REPLY_RECEIVE_GET_CHARACTER_LIST, user));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::identifyHost( const char *serverID[], unsigned idCount, void *user)
{
IdentifyServerRequest *req = new IdentifyServerRequest(REQUEST_SET_SERVER_LIST, 0, serverID, idCount);
return m_apiCore->submitRequest( req, new CommonResponse(REQUEST_SET_SERVER_LIST, user));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::sendAuditAssetTransfer(const char *gameCode, const char *serverCode, long long inGameAssetID, unsigned stationID, const char *event, const char *message, void *user)
{
SendAuditRequest *req = new SendAuditRequest( GAME_SEND_AUDIT_MESSAGE, 0, gameCode, serverCode, inGameAssetID, stationID, event, message );
return m_apiCore->submitRequest(req, new CommonResponse(GAME_SEND_AUDIT_MESSAGE, user));
}
//////////////////////////////////////////////////////////////////////////////////////
unsigned AuctionTransferAPI::getNewTransactionID(void *user)
{
GetIDRequest *req = new GetIDRequest( GAME_REQUEST_GET_TRANSACTION_ID, 0);
return m_apiCore->submitRequest(req, new GetIDResponse( GAME_REQUEST_GET_TRANSACTION_ID, user));
}
}; // namespace
//////////////////////////////////////////////////////////////////////////////////////
@@ -1,92 +0,0 @@
#ifndef AUCTIONTRANSFERAPI_H
#define AUCTIONTRANSFERAPI_H
#pragma warning (disable : 4786)
#include "AuctionTransferEnum.h"
#include "Base/Archive.h"
#include "Character.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
class AuctionTransferAPICore;
//////////////////////////////////////////////////////////////////////////////////////
class AuctionTransferAPI
{
public:
// constructor & destructor
AuctionTransferAPI(const char *hostName[], const short port[], int count, const char *identifier[], unsigned identifierCount, unsigned reqTimeout = 60, unsigned maxRecvMessageSizeInKB = 16000);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// the identifier list does not have one entry for each connection, it is a simple list of world names that
// are handled by this API connection, no matter how many servers are connected to. In the case of EQ2 this
// identifier list will just contain 1 name, the name of the world making the connection.
// the following constructor does the same as the one above, except that the host array is in the format of:
// "hostname1:port1 hostname2:port2"
// and the identifier array would be a semi-colon separated list of world names such as:
// "Guk Befallen" or "GUK"
AuctionTransferAPI(const char *hostNames, const char *identifiers);
virtual ~AuctionTransferAPI();
// connect and disconnect call backs
virtual void onConnect(const char* hostname, unsigned short port, const short current, const short max) = 0;
virtual void onDisconnect(const char *host, const short port, const short current, const short max) = 0;
//processing
void process();
// Requests Generated by API
unsigned sendPrepareTransaction (const char *serverIdentifier, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *xmlAsset, void *user, bool compress = false);
unsigned sendPrepareTransactionCompressed (const char *serverIdentifier, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const unsigned char *zippedXmlAsset, unsigned length, void *user);
unsigned sendCommitTransaction (long long transactionID, void *user);
unsigned sendAbortTransaction (long long transactionID, void *user);
unsigned sendAuditAssetTransfer(const char *gameCode, const char *serverCode, long long inGameAssetID, unsigned stationID, const char *event, const char *message, void *user);
unsigned getNewTransactionID(void *user);
// requests as responses to a call initiated by the auction system
unsigned replyReceivePrepareTransaction (unsigned trackingNumber,unsigned responseCode,void *user);
unsigned replyReceiveCommitTransaction (unsigned trackingNumber, unsigned responseCode, void *user);
unsigned replyReceiveAbortTransaction (unsigned trackingNumber, unsigned responseCode, void *user);
unsigned replyReceiveGetCharacterList(unsigned trackingNumber, unsigned responseCode, const Character characters[], unsigned numCharacters, void *user);
// house keeping routines
unsigned identifyHost( const char *serverID[], unsigned idCount, void *user);
// Callbacks that are repsonses
virtual void onSendPrepareTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onSendPrepareTransactionCompressed (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onSendCommitTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onSendAbortTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onSendAuditAssetTransfer(unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onGetNewTransactionID( unsigned trackingNumber, unsigned responseCode, long long transactionID, void *user) = 0;
// responses to reply requests
virtual void onReplyReceivePrepareTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onReplyReceiveCommitTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onReplyReceiveAbortTransaction (unsigned trackingNumber, unsigned responseCode, void *user) = 0;
virtual void onReplyReceiveGetCharacterList(unsigned trackingNumber, unsigned responseCode, void *user) = 0;
// house keeping callbacks
virtual void onIdentifyHost(unsigned trackingNumber, unsigned responseCode, void *user) = 0;
// Callbacks initiated by the Auction System
virtual void onReceivePrepareTransaction (unsigned trackingNumber, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *newName) = 0;
virtual void onReceiveCommitTransaction (unsigned trackingNumber, long long transactionID) = 0;
virtual void onReceiveAbortTransaction (unsigned trackingNumber, long long transactionID) = 0;
virtual void onReceiveGetCharacterList(unsigned trackingNumber, unsigned stationID, const char *serverID) = 0;
private:
AuctionTransferAPICore *m_apiCore;
};
}; // namespace
//////////////////////////////////////////////////////////////////////////////////////
#endif
@@ -1,181 +0,0 @@
#include "AuctionTransferAPICore.h"
#include "AuctionTransferAPI.h"
#include "Response.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
/*/////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPICore::AuctionTransferAPICore(const char *hostName[], const short port[], int count, AuctionTransferAPI *api, const char *identifier[], unsigned identifierCount)
: GenericAPICore(identifier[0], hostName, port, count, 45, 5, 0, 90, 32, 32),
m_api(api),
m_mappedServerTrack(1000)
//////////////////////////////////////////////////////////////////////////////////////
{
for(unsigned i = 0; i < identifierCount; i++)
addIdentifier(identifier[i]);
}
*/
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPICore::AuctionTransferAPICore(const char *hostName[], const short port[], int count, AuctionTransferAPI *api, const char *identifier[], unsigned identifierCount, unsigned reqTimeout, unsigned maxRecvMessageSizeInKB)
: GenericAPICore(identifier[0], hostName, port, count, reqTimeout, 5, 0, 90, 32, 32, 1, maxRecvMessageSizeInKB),
m_api(api),
m_mappedServerTrack(1000)
//////////////////////////////////////////////////////////////////////////////////////
{
for(unsigned i = 0; i < identifierCount; i++)
addIdentifier(identifier[i]);
}
//////////////////////////////////////////////////////////////////////////////////////
AuctionTransferAPICore::~AuctionTransferAPICore()
//////////////////////////////////////////////////////////////////////////////////////
{
}
//////////////////////////////////////////////////////////////////////////////////////
void AuctionTransferAPICore::OnConnect(GenericConnection *connection)
//////////////////////////////////////////////////////////////////////////////////////
{
countOpenConnections();
m_api->onConnect(connection->getHost(), connection->getPort(), m_currentConnections, m_maxConnections);
}
//////////////////////////////////////////////////////////////////////////////////////
void AuctionTransferAPICore::OnDisconnect(GenericConnection *connection)
//////////////////////////////////////////////////////////////////////////////////////
{
countOpenConnections();
m_api->onDisconnect(connection->getHost(), connection->getPort(), m_currentConnections, m_maxConnections);
}
//////////////////////////////////////////////////////////////////////////////////////
void AuctionTransferAPICore::responseCallback(GenericResponse *response)
//////////////////////////////////////////////////////////////////////////////////////
// these callbacks are a result of a call initiated by the game server.
//////////////////////////////////////////////////////////////////////////////////////
{
switch(response->getType())
{
case GAME_REPLY_RECEIVE_PREPARE_TRANSACTION:
m_api->onReplyReceivePrepareTransaction(response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REPLY_RECEIVE_COMMIT:
m_api->onReplyReceiveCommitTransaction( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REPLY_RECEIVE_ABORT:
m_api->onReplyReceiveAbortTransaction( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REQUEST_SEND_PREPARE_TRANSACTION:
m_api->onSendPrepareTransaction(response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED:
m_api->onSendPrepareTransactionCompressed(response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REQUEST_SEND_COMMIT:
m_api->onSendCommitTransaction( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REQUEST_SEND_ABORT:
m_api->onSendAbortTransaction( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REPLY_RECEIVE_GET_CHARACTER_LIST:
m_api->onReplyReceiveGetCharacterList( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_SEND_AUDIT_MESSAGE:
m_api->onSendAuditAssetTransfer( response->getTrack(),
response->getResult(),
response->getUser());
break;
case REQUEST_SET_SERVER_LIST:
m_api->onIdentifyHost( response->getTrack(),
response->getResult(),
response->getUser());
break;
case GAME_REQUEST_GET_TRANSACTION_ID:
{
GetIDResponse *r = static_cast<GetIDResponse *>(response);
m_api->onGetNewTransactionID( r->getTrack(),
r->getResult(),
r->getNewID(),
r->getUser());
}
break;
default:
break;
}
}
//////////////////////////////////////////////////////////////////////////////////////
void AuctionTransferAPICore::responseCallback(short type, Base::ByteStream::ReadIterator &iter, GenericConnection *connection)
//////////////////////////////////////////////////////////////////////////////////////
// these are the callbacks that are initiated from the Auction System. These callbacks
// will be called to initiate a series of communication between the auction system and
// the game servers.
//////////////////////////////////////////////////////////////////////////////////////
{
unsigned real_server_track;
get(iter, real_server_track);
ServerTrackObject *stobj = new ServerTrackObject(++m_mappedServerTrack, real_server_track, connection);
m_serverTracks.insert(std::pair<unsigned, ServerTrackObject *>(m_mappedServerTrack, stobj));
long long transactionID;
get(iter, transactionID);
switch (type)
{
case GAME_REQUEST_RECEIVE_PREPARE_TRANSACTION:
{
unsigned stationID;
unsigned characterID;
long long assetID;
std::string newName;
get(iter, stationID);
get(iter, characterID);
get(iter, assetID);
get(iter, newName);
m_api->onReceivePrepareTransaction(m_mappedServerTrack, transactionID, stationID, characterID, assetID, newName.c_str());
break;
}
case GAME_REQUEST_RECEIVE_COMMIT:
{
m_api->onReceiveCommitTransaction(m_mappedServerTrack, transactionID);
break;
}
case GAME_REQUEST_RECEIVE_ABORT:
{
m_api->onReceiveAbortTransaction(m_mappedServerTrack, transactionID);
break;
}
case GAME_REQUEST_RECEIVE_GET_CHARACTER_LIST:
{
// this had the stationID read in as the transactionID
std::string serverID;
get(iter, serverID);
m_api->onReceiveGetCharacterList(m_mappedServerTrack, transactionID, serverID.c_str());
}
default:
break;
}
}
}; // namespace AuctionTransfer
//////////////////////////////////////////////////////////////////////////////////////
@@ -1,35 +0,0 @@
#ifndef AUCTIONTRANSFERAPICORE_H
#define AUCTIONTRANSFERAPICORE_H
#include "ATGenericAPI/GenericApiCore.h"
#include "ATGenericAPI/GenericConnection.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
class AuctionTransferAPI;
//////////////////////////////////////////////////////////////////////////////////////
class AuctionTransferAPICore : public GenericAPICore
{
public:
AuctionTransferAPICore(const char *hostName[], const short port[], int count, AuctionTransferAPI *api, const char *identifier[], unsigned identifierCount, unsigned timeout = 60, unsigned maxRecvMessageSizeInKB = 16000);
virtual ~AuctionTransferAPICore();
void OnConnect(GenericConnection *connection);
void OnDisconnect(GenericConnection *connection);
void responseCallback(GenericResponse *response);
void responseCallback(short type, Base::ByteStream::ReadIterator &iter, GenericConnection *connection);
private:
AuctionTransferAPI *m_api;
unsigned m_mappedServerTrack;
};
}; // namespace AuctionTransfer
//////////////////////////////////////////////////////////////////////////////////////
#endif //AUCTIONTRANSFERAPICORE_H
@@ -1,164 +0,0 @@
#ifndef AUCTIONTRANSFERENUM_H
#define AUCTIONTRANSFERENUM_H
#include <map>
#include <string>
#define DEFAULT_TIMEOUTSECS 60
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
enum CloseReason
{
REASON_HOST_UNREACHABLE,
REASON_LOCAL_DISCONNECT,
REASON_REMOTE_DISCONNECT,
REASON_SOCKET_FAILURE,
REASON_DNS_FAILURE
};
enum ResponseCode
{
RESPONSE_FIRST = 0,
RESPONSE_UNKNOWN = RESPONSE_FIRST, // Initial state internally for call denotes no response yet
RESPONSE_ACCEPTED = 1,
RESPONSE_REJECTED,
RESPONSE_FAILURE,
RESPONSE_DUPLICATE,
GAME_API_TIME_OUT, //5
TRANSFER_SERVER_TIME_OUT,
AUCTION_API_TIME_OUT,
RESPONSE_REJECTED_INVALID_XML,
RESPONSE_REJECTED_USER_NOT_REGISTERED,
RESPONSE_REJECTED_UNABLE_TO_VALIDATE_USER, //10
RESPONSE_REJECTED_NO_PAPER_DOLL_IMAGE,
RESPONSE_REJECTED_INVALID_TRANSACTION_ID,
RESPONSE_REJECTED_USER_NOT_AUTHORIZED,
RESPONSE_REJECTED_HOLDING_AREA_FULL,
RESPONSE_REJECTED_HOLDING_AREA_ASSET_TOO_OLD, //15
RESPONSE_REJECTED_CHARACTER_LIMIT_REACHED,
RESPONSE_REJECTED_CHARACTER_NOT_AVAILABLE,
RESPONSE_REJECTED_MAILBOX_FULL,
RESPONSE_REJECTED_GAME_SERVER_DOWN,
RESPONSE_NAME_INVALID, //20
RESPONSE_NAME_TAKEN,
RESPONSE_FAILURE_DATABASE,
RESPONSE_FAILURE_SERVER,
RESPONSE_FAILURE_NETWORK,
RESPONSE_INVALID_ALIGNMENT, //25
RESPONSE_WEB_SERVICE_TIMEOUT,
RESPONSE_REJECTED_EMAIL_NOT_VALIDATED,
//NOTE: THESE ALWAYS STAY AT THE END. IF EVER ADD A VALUE AFTER THE LAST RESPONSE_*, THEN IT NEEDS TO BE ASSIGNED BELOW
RESPONSE_LAST = RESPONSE_REJECTED_EMAIL_NOT_VALIDATED,
RESPONSE_COUNT = RESPONSE_LAST - RESPONSE_FIRST + 1
};
enum RequestTypes
{
REQUEST_SET_API = 0,
REQUEST_SET_SERVER_LIST,
GAME_REQUEST_SEND_PREPARE_TRANSACTION,
GAME_REQUEST_SEND_COMMIT,
GAME_REQUEST_SEND_ABORT,
GAME_REQUEST_RECEIVE_PREPARE_TRANSACTION, //5
GAME_REQUEST_RECEIVE_COMMIT,
GAME_REQUEST_RECEIVE_ABORT,
GAME_REPLY_RECEIVE_PREPARE_TRANSACTION,
GAME_REPLY_RECEIVE_COMMIT,
GAME_REPLY_RECEIVE_ABORT, //10
GAME_REQUEST_RECEIVE_GET_CHARACTER_LIST,
GAME_REPLY_RECEIVE_GET_CHARACTER_LIST,
GAME_SEND_AUDIT_MESSAGE,
GAME_REQUEST_GET_TRANSACTION_ID,
GAME_REQUEST_SEND_PREPARE_TRANSACTION_COMPRESSED,
WEB_REQUEST_SEND_PREPARE_TRANSACTION = 10000,
WEB_REQUEST_SEND_COMMIT,
WEB_REQUEST_SEND_ABORT,
WEB_REQUEST_RECEIVE_PREPARE_TRANSACTION,
WEB_REQUEST_RECEIVE_COMMIT,
WEB_REQUEST_RECEIVE_ABORT, //10005
WEB_REPLY_RECEIVE_PREPARE_TRANSACTION,
WEB_REPLY_RECEIVE_COMMIT,
WEB_REPLY_RECEIVE_ABORT,
WEB_REQUEST_SEND_GET_CHARACTER_LIST,
WEB_REQUEST_SEND_GET_SERVER_LIST, //10010
WEB_REPLY_RECEIVE_AUDIT,
WEB_REQUEST_RECEIVE_GET_TRANSACTION_ID,
WEB_REPLY_RECEIVE_GET_TRANSACTION_ID,
WEB_REQUEST_RECEIVE_PREPARE_TRANSACTION_COMPRESSED,
WEB_REPLY_RECEIVE_PREPARE_TRANSACTION_COMPRESSED
};
#define response_text std::pair<unsigned,const char *>
static const response_text _responseString[RESPONSE_COUNT] =
{
response_text(RESPONSE_UNKNOWN, "RESPONSE_UNKNOWN"),
response_text(RESPONSE_ACCEPTED, "RESPONSE_ACCEPTED"),
response_text(RESPONSE_REJECTED, "RESPONSE_REJECTED"),
response_text(RESPONSE_FAILURE, "RESPONSE_FAILURE"),
response_text(RESPONSE_DUPLICATE, "RESPONSE_DUPLICATE"),
response_text(GAME_API_TIME_OUT, "GAME_API_TIME_OUT"),
response_text(TRANSFER_SERVER_TIME_OUT, "TRANSFER_SERVER_TIME_OUT"),
response_text(AUCTION_API_TIME_OUT, "AUCTION_API_TIME_OUT"),
response_text(RESPONSE_REJECTED_INVALID_XML, "RESPONSE_REJECTED_INVALID_XML"),
response_text(RESPONSE_REJECTED_USER_NOT_REGISTERED, "RESPONSE_REJECTED_USER_NOT_REGISTERED"),
response_text(RESPONSE_REJECTED_UNABLE_TO_VALIDATE_USER, "RESPONSE_REJECTED_UNABLE_TO_VALIDATE_USER"),
response_text(RESPONSE_REJECTED_NO_PAPER_DOLL_IMAGE, "RESPONSE_REJECTED_NO_PAPER_DOLL_IMAGE"),
response_text(RESPONSE_REJECTED_INVALID_TRANSACTION_ID, "RESPONSE_REJECTED_INVALID_TRANSACTION_ID"),
response_text(RESPONSE_REJECTED_USER_NOT_AUTHORIZED, "RESPONSE_REJECTED_USER_NOT_AUTHORIZED"),
response_text(RESPONSE_REJECTED_HOLDING_AREA_FULL, "RESPONSE_REJECTED_HOLDING_AREA_FULL"),
response_text(RESPONSE_REJECTED_HOLDING_AREA_ASSET_TOO_OLD, "RESPONSE_REJECTED_HOLDING_AREA_ASSET_TOO_OLD"),
response_text(RESPONSE_REJECTED_CHARACTER_LIMIT_REACHED, "RESPONSE_REJECTED_CHARACTER_LIMIT_REACHED"),
response_text(RESPONSE_REJECTED_CHARACTER_NOT_AVAILABLE, "RESPONSE_REJECTED_CHARACTER_NOT_AVAILABLE"),
response_text(RESPONSE_REJECTED_MAILBOX_FULL, "RESPONSE_REJECTED_MAILBOX_FULL"),
response_text(RESPONSE_REJECTED_GAME_SERVER_DOWN, "RESPONSE_REJECTED_GAME_SERVER_DOWN"),
response_text(RESPONSE_NAME_INVALID, "RESPONSE_NAME_INVALID"),
response_text(RESPONSE_NAME_TAKEN, "RESPONSE_NAME_TAKEN"),
response_text(RESPONSE_FAILURE_DATABASE, "RESPONSE_FAILURE_DATABASE"),
response_text(RESPONSE_FAILURE_SERVER, "RESPONSE_FAILURE_SERVER"),
response_text(RESPONSE_FAILURE_NETWORK, "RESPONSE_FAILURE_NETWORK"),
response_text(RESPONSE_INVALID_ALIGNMENT, "RESPONSE_INVALID_ALIGNMENT"),
response_text(RESPONSE_WEB_SERVICE_TIMEOUT, "RESPONSE_WEB_SERVICE_TIMEOUT"),
response_text(RESPONSE_REJECTED_EMAIL_NOT_VALIDATED, "RESPONSE_EMAIL_NOT_VALIDATED"),
};
static std::map<unsigned,const char *> ResponseString((const std::map<unsigned,const char *>::value_type *)&_responseString[0],(const std::map<unsigned,const char *>::value_type *)&_responseString[RESPONSE_COUNT]);
static const response_text _responseText[RESPONSE_COUNT] =
{
response_text(RESPONSE_UNKNOWN, "Unknown response code - default."),
response_text(RESPONSE_ACCEPTED, "The operation completed successfully."),
response_text(RESPONSE_REJECTED, "The operation was rejected by by the auction system."),
response_text(RESPONSE_FAILURE, "There was a general failure processing the request."),
response_text(RESPONSE_DUPLICATE, "This transaction was initiated previously."),
response_text(GAME_API_TIME_OUT, "Unable to contact the Auction Transfer Server."),
response_text(TRANSFER_SERVER_TIME_OUT, "The Auction Transfer Server could not Contact the Web Services."),
response_text(AUCTION_API_TIME_OUT, "The SysEng Web Services did not respond."),
response_text(RESPONSE_REJECTED_INVALID_XML, "The XML format was invalid."),
response_text(RESPONSE_REJECTED_USER_NOT_REGISTERED, "The user has not registered in the Auction System yet."),
response_text(RESPONSE_REJECTED_UNABLE_TO_VALIDATE_USER, "The user account was not able to be validated at this time."),
response_text(RESPONSE_REJECTED_NO_PAPER_DOLL_IMAGE, "There was no image uploaded for this character yet."),
response_text(RESPONSE_REJECTED_INVALID_TRANSACTION_ID, "The transaction id is not valid."),
response_text(RESPONSE_REJECTED_USER_NOT_AUTHORIZED, "The station account is not authorized."),
response_text(RESPONSE_REJECTED_HOLDING_AREA_FULL, "The user has too many items in their holding area."),
response_text(RESPONSE_REJECTED_HOLDING_AREA_ASSET_TOO_OLD, "The user has an item in their holding area that is too old."),
response_text(RESPONSE_REJECTED_CHARACTER_LIMIT_REACHED, "Too Many characters in Auctions."),
response_text(RESPONSE_REJECTED_CHARACTER_NOT_AVAILABLE, "The character is not available for this transaction."),
response_text(RESPONSE_REJECTED_MAILBOX_FULL, "The character mailbox is full."),
response_text(RESPONSE_REJECTED_GAME_SERVER_DOWN, "The game server is unable to process the request."),
response_text(RESPONSE_NAME_INVALID, "The new character name is invalid."),
response_text(RESPONSE_NAME_TAKEN, "The new character name is taken."),
response_text(RESPONSE_FAILURE_DATABASE, "There was a database failure during the transaction."),
response_text(RESPONSE_FAILURE_SERVER, "There was a server failure during the transaction."),
response_text(RESPONSE_FAILURE_NETWORK, "There was a network failure during the transaction."),
response_text(RESPONSE_INVALID_ALIGNMENT, "The alignment of the character for this item is incorrect."),
response_text(RESPONSE_WEB_SERVICE_TIMEOUT, "The AppEng web service failed to respond."),
response_text(RESPONSE_REJECTED_EMAIL_NOT_VALIDATED, "The user has not validated their email with the auction system yet."),
};
static std::map<unsigned,const char *> ResponseText((const std::map<unsigned,const char *>::value_type *)&_responseText[0],(const std::map<unsigned,const char *>::value_type *)&_responseText[RESPONSE_COUNT]);
}; //namespace AuctionTransfer
#endif //AUCTIONTRANSFERENUM_H
@@ -1,30 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AuctionTransferGameAPI", "AuctionTransferGameAPI.vcproj", "{CC51D0B0-3994-474D-BD51-5B49919AEBE0}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "TestApp\TestApp.vcproj", "{7AA05E1D-9952-4432-9975-6C00659BC0ED}"
ProjectSection(ProjectDependencies) = postProject
{CC51D0B0-3994-474D-BD51-5B49919AEBE0} = {CC51D0B0-3994-474D-BD51-5B49919AEBE0}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{CC51D0B0-3994-474D-BD51-5B49919AEBE0}.Debug.ActiveCfg = Debug|Win32
{CC51D0B0-3994-474D-BD51-5B49919AEBE0}.Debug.Build.0 = Debug|Win32
{CC51D0B0-3994-474D-BD51-5B49919AEBE0}.Release.ActiveCfg = Release|Win32
{CC51D0B0-3994-474D-BD51-5B49919AEBE0}.Release.Build.0 = Release|Win32
{7AA05E1D-9952-4432-9975-6C00659BC0ED}.Debug.ActiveCfg = Debug|Win32
{7AA05E1D-9952-4432-9975-6C00659BC0ED}.Debug.Build.0 = Debug|Win32
{7AA05E1D-9952-4432-9975-6C00659BC0ED}.Release.ActiveCfg = Release|Win32
{7AA05E1D-9952-4432-9975-6C00659BC0ED}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
@@ -1,326 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="AuctionTransferGameAPI"
ProjectGUID="{CC51D0B0-3994-474D-BD51-5B49919AEBE0}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;EXTERNAL_DISTRO;NAMESPACE=&quot;AuctionTransfer&quot;;USE_TCP_LIBRARY"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="C:\P4\projects\AuctionTransfer\AuctionTransferGameAPI"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;EXTERNAL_DISTRO;NAMESPACE=&quot;AuctionTransfer&quot;;USE_TCP_LIBRARY"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="ws2_32.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\AuctionTransferAPI.cpp">
</File>
<File
RelativePath=".\AuctionTransferAPICore.cpp">
</File>
<File
RelativePath=".\Character.cpp">
</File>
<File
RelativePath=".\Request.cpp">
</File>
<File
RelativePath=".\Response.cpp">
</File>
<Filter
Name="TCP Library"
Filter="">
<File
RelativePath=".\TcpLibrary\Clock.cpp">
</File>
<File
RelativePath=".\TcpLibrary\IPAddress.cpp">
</File>
<File
RelativePath=".\TcpLibrary\TcpBlockAllocator.cpp">
</File>
<File
RelativePath=".\TcpLibrary\TcpConnection.cpp">
</File>
<File
RelativePath=".\TcpLibrary\TcpManager.cpp">
</File>
</Filter>
<Filter
Name="Base"
Filter="">
<File
RelativePath=".\Base\Archive.cpp">
</File>
</Filter>
<Filter
Name="GenericAPI_TCP"
Filter="">
<File
RelativePath=".\ATGenericAPI\GenericApiCore.cpp">
</File>
<File
RelativePath=".\ATGenericAPI\GenericConnection.cpp">
</File>
<File
RelativePath=".\ATGenericAPI\GenericMessage.cpp">
</File>
</Filter>
<Filter
Name="Gzip"
Filter="">
<File
RelativePath=".\zip\Zip\adler32.c">
</File>
<File
RelativePath=".\zip\Zip\compress.c">
</File>
<File
RelativePath=".\zip\Zip\crc32.c">
</File>
<File
RelativePath=".\zip\Zip\deflate.c">
</File>
<File
RelativePath=".\zip\Zip\gzio.c">
</File>
<File
RelativePath=".\zip\Zip\infblock.c">
</File>
<File
RelativePath=".\zip\Zip\infcodes.c">
</File>
<File
RelativePath=".\zip\Zip\inffast.c">
</File>
<File
RelativePath=".\zip\Zip\inflate.c">
</File>
<File
RelativePath=".\zip\Zip\inftrees.c">
</File>
<File
RelativePath=".\zip\Zip\infutil.c">
</File>
<File
RelativePath=".\zip\Zip\maketree.c">
</File>
<File
RelativePath=".\zip\Zip\trees.c">
</File>
<File
RelativePath=".\zip\Zip\uncompr.c">
</File>
<File
RelativePath=".\zip\Zip\zutil.c">
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\AuctionTransferAPI.h">
</File>
<File
RelativePath=".\AuctionTransferAPICore.h">
</File>
<File
RelativePath=".\Character.h">
</File>
<File
RelativePath=".\Request.h">
</File>
<File
RelativePath=".\Response.h">
</File>
<Filter
Name="TCP Library"
Filter="">
<File
RelativePath=".\TcpLibrary\Clock.h">
</File>
<File
RelativePath=".\TcpLibrary\IPAddress.h">
</File>
<File
RelativePath=".\TcpLibrary\TcpBlockAllocator.h">
</File>
<File
RelativePath=".\TcpLibrary\TcpConnection.h">
</File>
<File
RelativePath=".\TcpLibrary\TcpHandlers.h">
</File>
<File
RelativePath=".\TcpLibrary\TcpManager.h">
</File>
</Filter>
<Filter
Name="Base"
Filter="">
<File
RelativePath=".\Base\Archive.h">
</File>
<File
RelativePath=".\Base\Platform.h">
</File>
</Filter>
<Filter
Name="GenericAPI_TCP"
Filter="">
<File
RelativePath=".\ATGenericAPI\GenericApiCore.h">
</File>
<File
RelativePath=".\ATGenericAPI\GenericConnection.h">
</File>
<File
RelativePath=".\ATGenericAPI\GenericMessage.h">
</File>
</Filter>
<Filter
Name="Common"
Filter="">
<File
RelativePath=".\AuctionTransferEnum.h">
</File>
</Filter>
<Filter
Name="Gzip"
Filter="">
<File
RelativePath=".\zip\Zip\deflate.h">
</File>
<File
RelativePath=".\zip\GZipHelper.h">
</File>
<File
RelativePath=".\zip\Zip\infblock.h">
</File>
<File
RelativePath=".\zip\Zip\infcodes.h">
</File>
<File
RelativePath=".\zip\Zip\inffast.h">
</File>
<File
RelativePath=".\zip\Zip\inffixed.h">
</File>
<File
RelativePath=".\zip\Zip\inftrees.h">
</File>
<File
RelativePath=".\zip\Zip\infutil.h">
</File>
<File
RelativePath=".\zip\Zip\trees.h">
</File>
<File
RelativePath=".\zip\Zip\zconf.h">
</File>
<File
RelativePath=".\zip\Zip\zlib.h">
</File>
<File
RelativePath=".\zip\Zip\zutil.h">
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -1,283 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// The author of this code is Justin Randall
//
// I have made modifications to the ByteStream
// and AutoByteStream classes in order to make them suitable
// for use in messaging systems which require objects that
// are copyable and assignable. It is also desirable for
// the ByteStream object to use a flexible allocator system
// that may support multi-threaded programming models.
#include "Archive.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
////////////////////////////////////////////////////////////////////////////////
#if defined(USE_ARCHIVE_MUTEX)
CMutex ByteStreamMutex;
#endif
#if defined (PASCAL_STRING)
#pragma message ("--- Packing pascal style strings ---")
void get(Base::ByteStream::ReadIterator& source, std::string& target)
{
unsigned int size = 0;
Base::get (source, size);
const unsigned char *buf = source.getBuffer();
target.assign((const char *)buf, (const char *)(buf + size));
const unsigned int readSize = size * sizeof(char);
source.advance(readSize);
}
void put(ByteStream& target, const std::string& source)
{
const unsigned int size = source.size();
put(target, size);
target.put(source.data(), size * sizeof (char));
}
#else
#pragma message ("--- Packing c style strings ---")
void get(ByteStream::ReadIterator & source, std::string & target)
{
target = reinterpret_cast<const char *>(source.getBuffer());
source.advance(target.length() + 1);
}
void put(ByteStream & target, const std::string & source)
{
target.put(source.c_str(), source.size()+1);
}
#endif
ByteStream::ReadIterator::ReadIterator() :
readPtr(0),
stream(0)
{
}
ByteStream::ReadIterator::ReadIterator(const ReadIterator & source) :
readPtr(source.readPtr),
stream(source.stream)
{
}
ByteStream::ReadIterator::ReadIterator(const ByteStream & source) :
readPtr(0),
stream(&source)
{
}
ByteStream::ReadIterator::~ReadIterator()
{
stream = 0;
}
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
size(0),
lastPutSize(0)
{
data = Data::getNewData();
beginReadIterator = ReadIterator(*this);
}
ByteStream::ByteStream(const unsigned char * const newBuffer, const unsigned int bufferSize) :
allocatedSize(bufferSize),
data(0),
size(bufferSize),
lastPutSize(0)
{
data = Data::getNewData();
if(data->size < size)
{
delete[] data->buffer;
data->buffer = new unsigned char[size];
data->size = size;
}
memcpy(data->buffer, newBuffer, size);
beginReadIterator = ReadIterator(*this);
}
ByteStream::ByteStream(const ByteStream & source):
allocatedSize(source.getSize()), // only allocate what is really there, be opportinistic when grow()'ing
data(source.data),
size(source.getSize()),
lastPutSize(source.lastPutSize)
{
source.data->ref();
beginReadIterator = ReadIterator(*this);
}
ByteStream::ByteStream(ReadIterator & source) :
allocatedSize(0),
size(0),
lastPutSize(0)
{
data = Data::getNewData();
put(source.getBuffer(), source.getSize());
source.advance(source.getSize());
beginReadIterator = ReadIterator(*this);
}
ByteStream::~ByteStream()
{
data->deref();
allocatedSize = 0;
data = 0; //lint !e672 (data deref insures the data is deleted if no one references it)
size = 0;
}
ByteStream & ByteStream::operator=(const ByteStream & rhs)
{
if(this != &rhs)
{
data->deref(); // deref local data
rhs.data->ref();
allocatedSize = rhs.allocatedSize;
size = rhs.size;
data = rhs.data; //lint !e672 (data is ref counted)
}
return *this;
}
void ByteStream::get(void * target, ReadIterator & readIterator, const unsigned long int targetSize) const
{
assert(readIterator.getReadPosition() + targetSize <= allocatedSize);
memcpy(target, &data->buffer[readIterator.getReadPosition()], targetSize);
}
void ByteStream::put(const void * const source, const unsigned int sourceSize)
{
if(data->getRef() > 1)
{
const unsigned char * const tmp = data->buffer;
data->deref();
data = Data::getNewData();
if(data->size < sourceSize)
{
delete[] data->buffer;
data->buffer = new unsigned char[size];
data->size = size;
}
memcpy(data->buffer, tmp, size);
allocatedSize = size;
}
growToAtLeast(size + sourceSize);
memcpy(&data->buffer[size], source, sourceSize);
size += sourceSize;
if (sourceSize > 0)
lastPutSize = sourceSize;
}
bool ByteStream::overwriteEnd(const void * const source, const unsigned int sourceSize)
{
if(data->getRef() <= 1 &&
lastPutSize == sourceSize &&
sourceSize <= data->size)
{
memcpy(&data->buffer[size-sourceSize], source, sourceSize);
return true;
}
else
{
return false;
}
}
void ByteStream::reAllocate(const unsigned int newSize)
{
allocatedSize = newSize;
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
data->size = newSize;
}
}
////////////////////////////////////////////////////////////////////////////////
AutoByteStream::AutoByteStream() :
members()
{
}
AutoByteStream::~AutoByteStream()
{
}
void AutoByteStream::addVariable(AutoVariableBase & newVariable)
{
members.push_back(&newVariable);
}
const unsigned int AutoByteStream::getItemCount() const
{
return members.size();
}
void AutoByteStream::pack(ByteStream & target) const
{
std::vector<AutoVariableBase *>::const_iterator i;
unsigned short packedSize=static_cast<unsigned short>(members.size());
put(target,packedSize);
for(i = members.begin(); i != members.end(); ++i)
{
(*i)->pack(target);
}
}
void AutoByteStream::unpack(ByteStream::ReadIterator & source)
{
std::vector<AutoVariableBase *>::iterator i;
unsigned short packedSize;
get(source,packedSize);
for(i = members.begin(); i != members.end(); ++i)
{
(*i)->unpack(source);
}
}
////////////////////////////////////////////////////////////////////////////////
AutoVariableBase::AutoVariableBase()
{
}
AutoVariableBase::~AutoVariableBase()
{
}
////////////////////////////////////////////////////////////////////////////////
};
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,746 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// The author of this code is Justin Randall
//
// I have made modifications to the ByteStream
// and AutoByteStream classes in order to make them suitable
// for use in messaging systems which require objects that
// are copyable and assignable. It is also desirable for
// the ByteStream object to use a flexible allocator system
// that may support multi-threaded programming models.
#ifndef BASE_ARCHIVE_H
#define BASE_ARCHIVE_H
#include <assert.h>
#include <string>
#include <vector>
#include "Platform.h"
#if !defined PLATFORM_BASE_SINGLE_THREAD && ( defined _MT || defined _REENTRANT )
# define USE_ARCHIVE_MUTEX
# include "Mutex.h"
#endif
#ifdef WIN32
# include "win32/Archive.h"
#elif linux
# include "linux/Archive.h"
#elif sparc
# include "solaris/Archive.h"
#else
#error /Base/Archive.h: Undefine platform type
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
const unsigned MAX_ARRAY_SIZE = 1024;
////////////////////////////////////////////////////////////////////////////////
#if defined(USE_ARCHIVE_MUTEX)
extern CMutex ByteStreamMutex;
#endif
class ByteStream
{
public:
class ReadIterator
{
public:
ReadIterator();
ReadIterator(const ReadIterator & source);
explicit ReadIterator(const ByteStream & source);
~ReadIterator();
ReadIterator & operator = (const ReadIterator & source);
void advance (const unsigned int distance);
void get (void * target, const unsigned long int readSize);
const unsigned int getSize () const;
const unsigned char * const getBuffer () const;
const unsigned int getReadPosition () const;
private:
unsigned int readPtr;
const ByteStream * stream;
};
private:
class Data
{
friend class ByteStream;
friend class ReadIterator;
public:
~Data();
static Data * getNewData();
const int getRef () const;
void deref ();
void ref ();
protected:
unsigned char * buffer;
unsigned long size;
private:
struct DataFreeList
{
~DataFreeList()
{
std::vector<ByteStream::Data *>::iterator i;
for(i = freeList.begin(); i != freeList.end(); ++i)
{
delete (*i);
}
};
std::vector<Data *> freeList;
};
Data();
//explicit Data(unsigned char * buffer);
static std::vector<Data *> & getDataFreeList();
static void releaseOldData(Data * oldData);
private:
int refCount;
};
friend class ReadIterator;
public:
ByteStream();
ByteStream(const unsigned char * const buffer, const unsigned int bufferSize);
ByteStream(const ByteStream & source);
virtual ~ByteStream();
public:
ByteStream(ReadIterator & source);
ByteStream & operator = (const ByteStream & source);
ByteStream & operator = (ReadIterator & source);
const ReadIterator & begin() const;
void clear();
const unsigned char * const getBuffer() const;
const unsigned int getSize() const;
void put(const void * const source, const unsigned int sourceSize);
bool overwriteEnd(const void * const source, const unsigned int sourceSize);
private:
void get(void * target, ReadIterator & readIterator, const unsigned long int readSize) const;
void growToAtLeast(const unsigned int targetSize);
void reAllocate(const unsigned int newSize);
private:
unsigned int allocatedSize;
ReadIterator beginReadIterator;
Data * data;
unsigned int size;
unsigned int lastPutSize;
};
inline ByteStream::Data::Data() :
buffer(0),
size(0),
refCount(1)
{
}
inline ByteStream::Data::~Data()
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
refCount = 0;
delete[] buffer;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
}
inline void ByteStream::Data::deref()
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
refCount--;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
if(refCount < 1)
releaseOldData(this);
}
inline std::vector<ByteStream::Data *> & ByteStream::Data::getDataFreeList()
{
static DataFreeList freeList;
return freeList.freeList;
}
inline ByteStream::Data * ByteStream::Data::getNewData()
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
Data * result = 0;
if(getDataFreeList().empty())
{
result = new Data;
}
else
{
result = getDataFreeList().back();
getDataFreeList().pop_back();
}
result->refCount = 1;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
return result;
}
inline const int ByteStream::Data::getRef() const
{
return refCount;
}
inline void ByteStream::Data::ref()
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
refCount++;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
}
inline void ByteStream::Data::releaseOldData(ByteStream::Data * oldData)
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
getDataFreeList().push_back(oldData);
oldData->refCount = 0;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
}
inline ByteStream::ReadIterator & ByteStream::ReadIterator::operator = (const ByteStream::ReadIterator & rhs)
{
if(&rhs != this)
{
readPtr = rhs.readPtr;
stream = rhs.stream;
}
return *this;
}
inline void ByteStream::ReadIterator::get(void * target, const unsigned long int readSize)
{
assert(stream);
stream->get(target, *this, readSize);
readPtr += readSize;
}
inline const unsigned int ByteStream::ReadIterator::getSize() const
{
assert(stream);
return stream->getSize() - readPtr;
}
inline const ByteStream::ReadIterator & ByteStream::begin() const
{
return beginReadIterator;
}
inline void ByteStream::ReadIterator::advance(const unsigned int distance)
{
readPtr += distance;
}
inline const unsigned int ByteStream::ReadIterator::getReadPosition() const
{
return readPtr;
}
inline const unsigned char * const ByteStream::ReadIterator::getBuffer() const
{
if(stream)
return &stream->data->buffer[readPtr];
return 0;
}
inline void ByteStream::clear()
{
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Lock();
#endif
size = 0;
#if defined(USE_ARCHIVE_MUTEX)
ByteStreamMutex.Unlock();
#endif
}
inline const unsigned char * const ByteStream::getBuffer() const
{
return data->buffer;
}
inline const unsigned int ByteStream::getSize() const
{
return size;
}
inline void ByteStream::growToAtLeast(const unsigned int targetSize)
{
if(allocatedSize < targetSize)
{
reAllocate(allocatedSize + allocatedSize + targetSize);
}
}
////////////////////////////////////////////////////////////////////////////////
class AutoVariableBase
{
public:
AutoVariableBase();
virtual ~AutoVariableBase();
virtual void pack(ByteStream & target) const = 0;
virtual void unpack(ByteStream::ReadIterator & source) = 0;
};
////////////////////////////////////////////////////////////////////////////////
class AutoByteStream
{
public:
AutoByteStream();
virtual ~AutoByteStream();
void addVariable(AutoVariableBase & newVariable);
virtual const unsigned int getItemCount() const;
virtual void pack(ByteStream & target) const;
virtual void unpack(ByteStream::ReadIterator & source);
protected:
std::vector<AutoVariableBase *> members;
private:
AutoByteStream(const AutoByteStream & source);
};
////////////////////////////////////////////////////////////////////////////////
template<class ValueType>
class AutoVariable : public AutoVariableBase
{
public:
AutoVariable();
explicit AutoVariable(const ValueType & source);
virtual ~AutoVariable();
const ValueType & get() const;
virtual void pack(ByteStream & target) const;
void set(const ValueType & rhs);
virtual void unpack(ByteStream::ReadIterator & source);
private:
ValueType value;
};
template<class ValueType>
AutoVariable<ValueType>::AutoVariable() :
AutoVariableBase(),
value()
{
}
template<class ValueType>
AutoVariable<ValueType>::AutoVariable(const ValueType & source) :
AutoVariableBase(),
value(source)
{
}
template<class ValueType>
AutoVariable<ValueType>::~AutoVariable()
{
}
template<class ValueType>
const ValueType & AutoVariable<ValueType>::get() const
{
return value;
}
template<class ValueType>
void AutoVariable<ValueType>::pack(ByteStream & target) const
{
Base::put(target, value);
}
template<class ValueType>
void AutoVariable<ValueType>::set(const ValueType & rhs)
{
value = rhs;
}
template<class ValueType>
void AutoVariable<ValueType>::unpack(ByteStream::ReadIterator & source)
{
Base::get(source, value);
}
////////////////////////////////////////////////////////////////////////////////
template<class ValueType>
class AutoArray : public AutoVariableBase
{
public:
AutoArray();
AutoArray(const AutoArray & source);
~AutoArray();
const std::vector<ValueType> & get() const;
void set(const std::vector<ValueType> & source);
virtual void pack(ByteStream & target) const;
virtual void unpack(ByteStream::ReadIterator & source);
private:
std::vector<ValueType> array;
};
template<class ValueType>
inline AutoArray<ValueType>::AutoArray()
{
}
template<class ValueType>
inline AutoArray<ValueType>::AutoArray(const AutoArray & source) :
array(source.array)
{
}
template<class ValueType>
inline AutoArray<ValueType>::~AutoArray()
{
}
template<class ValueType>
inline const std::vector<ValueType> & AutoArray<ValueType>::get() const
{
return array;
}
template<class ValueType>
inline void AutoArray<ValueType>::set(const std::vector<ValueType> & source)
{
array = source;
}
template<class ValueType>
inline void AutoArray<ValueType>::pack(ByteStream & target) const
{
unsigned int arraySize = array.size();
Base::put(target, arraySize);
typename std::vector<ValueType>::const_iterator i;
for(i = array.begin(); i != array.end(); ++i)
{
ValueType v = (*i);
Base::put(target, v);
}
}
template<class ValueType>
inline void AutoArray<ValueType>::unpack(ByteStream::ReadIterator & source)
{
unsigned int arraySize;
Base::get(source, arraySize);
ValueType v;
if (arraySize > MAX_ARRAY_SIZE)
arraySize = 0;
for(unsigned int i = 0; i < arraySize; ++i)
{
Base::get(source, v);
array.push_back(v);
}
}
////////////////////////////////////////////////////////////////////////////////
inline void get(ByteStream::ReadIterator & source, ByteStream & target)
{
target.put(source.getBuffer(), source.getSize());
source.advance(source.getSize());
}
inline void get(ByteStream::ReadIterator & source, double & target)
{
source.get(&target, 8);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, float & target)
{
source.get(&target, 4);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, uint64 & target)
{
source.get(&target, 8);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, int64 & target)
{
source.get(&target, 8);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, uint32 & target)
{
source.get(&target, 4);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, int32 & target)
{
source.get(&target, 4);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, uint16 & target)
{
source.get(&target, 2);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, int16 & target)
{
source.get(&target, 2);
target = byteSwap(target);
}
inline void get(ByteStream::ReadIterator & source, uint8 & target)
{
source.get(&target, 1);
}
inline void get(ByteStream::ReadIterator & source, int8 & target)
{
source.get(&target, 1);
}
inline void get(ByteStream::ReadIterator & source, unsigned char * const target, const unsigned int targetSize)
{
source.get(target, targetSize);
}
inline void get(ByteStream::ReadIterator & source, bool & target)
{
source.get(&target, 1);
}
////////////////////////////////////////////////////////////////////////////////
inline void put(ByteStream & target, ByteStream::ReadIterator & source)
{
target.put(source.getBuffer(), source.getSize());
source.advance(source.getSize());
}
inline void put(ByteStream & target, const double value)
{
double temp = byteSwap(value);
target.put(&temp, 8);
}
inline void put(ByteStream & target, const float value)
{
float temp = byteSwap(value);
target.put(&temp, 4);
}
inline void put(ByteStream & target, const uint64 value)
{
uint64 temp = byteSwap(value);
target.put(&temp, 8);
}
inline void put(ByteStream & target, const int64 value)
{
int64 temp = byteSwap(value);
target.put(&temp, 8);
}
inline void put(ByteStream & target, const uint32 value)
{
uint32 temp = byteSwap(value);
target.put(&temp, 4);
}
inline void put(ByteStream & target, const int32 value)
{
int32 temp = byteSwap(value);
target.put(&temp, 4);
}
inline void put(ByteStream & target, const uint16 value)
{
uint16 temp = byteSwap(value);
target.put(&temp, 2);
}
inline void put(ByteStream & target, const int16 value)
{
int16 temp = byteSwap(value);
target.put(&temp, 2);
}
inline void put(ByteStream & target, const uint8 value)
{
target.put(&value, 1);
}
inline void put(ByteStream & target, const int8 value)
{
target.put(&value, 1);
}
inline void put(ByteStream & target, const bool & source)
{
target.put(&source, 1);
}
inline void put(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize)
{
target.put(source, sourceSize);
}
inline void put(ByteStream & target, const ByteStream & source)
{
target.put(source.begin().getBuffer(), source.begin().getSize());
}
void get(ByteStream::ReadIterator & source, std::string & target);
void put(ByteStream & target, const std::string & source);
////////////////////////////////////////////////////////////////////////////////
inline bool overwriteEnd(ByteStream & target, const double value)
{
double temp = byteSwap(value);
return target.overwriteEnd(&temp, 8);
}
inline bool overwriteEnd(ByteStream & target, const float value)
{
float temp = byteSwap(value);
return target.overwriteEnd(&temp, 4);
}
inline bool overwriteEnd(ByteStream & target, const uint64 value)
{
uint64 temp = byteSwap(value);
return target.overwriteEnd(&temp, 8);
}
inline bool overwriteEnd(ByteStream & target, const int64 value)
{
int64 temp = byteSwap(value);
return target.overwriteEnd(&temp, 8);
}
inline bool overwriteEnd(ByteStream & target, const uint32 value)
{
uint32 temp = byteSwap(value);
return target.overwriteEnd(&temp, 4);
}
inline bool overwriteEnd(ByteStream & target, const int32 value)
{
int32 temp = byteSwap(value);
return target.overwriteEnd(&temp, 4);
}
inline bool overwriteEnd(ByteStream & target, const uint16 value)
{
uint16 temp = byteSwap(value);
return target.overwriteEnd(&temp, 2);
}
inline bool overwriteEnd(ByteStream & target, const int16 value)
{
int16 temp = byteSwap(value);
return target.overwriteEnd(&temp, 2);
}
inline bool overwriteEnd(ByteStream & target, const uint8 value)
{
return target.overwriteEnd(&value, 1);
}
inline bool overwriteEnd(ByteStream & target, const int8 value)
{
return target.overwriteEnd(&value, 1);
}
inline bool overwriteEnd(ByteStream & target, const bool & source)
{
return target.overwriteEnd(&source, 1);
}
inline bool overwriteEnd(ByteStream & target, const unsigned char * const source, const unsigned int sourceSize)
{
return target.overwriteEnd(source, sourceSize);
}
////////////////////////////////////////////////////////////////////////////////
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,10 +0,0 @@
AUTOMAKE_OPTIONS=foreign
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
libAuctionTransferGameAPIBase_la_LDFLAGS = -avoid-version
noinst_LTLIBRARIES = libAuctionTransferGameAPIBase.la
libAuctionTransferGameAPIBase_la_SOURCES = Archive.cpp Archive.h Platform.h
SUBDIRS = linux
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,40 +0,0 @@
////////////////////////////////////////
// Mutex.cpp
//
// Purpose:
// 1. Implementation of the CMutex class.
//
// Revisions:
// 07/10/2001 Created
//
#if !defined(_MT)
# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_MT)" )
#else
#include "Mutex.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
CMutex::CMutex()
{
InitializeCriticalSection(&mCriticalSection);
}
CMutex::~CMutex()
{
DeleteCriticalSection(&mCriticalSection);
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // #if defined(_MT)
@@ -1,74 +0,0 @@
////////////////////////////////////////
// Mutex.h
//
// Purpose:
// 1. Declair the CMutex class that encapsulates the functionality of a
// mutually-exclusive device.
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_WIN32_MUTEX_H
#define BASE_WIN32_MUTEX_H
#include "Platform.h"
namespace Base
{
////////////////////////////////////////
// Class:
// CMutex
//
// Purpose:
// Encapsulates the functionality of a mutually-exclusive device.
// This class is valuable for protecting against race conditions
// within threaded applications. The CMutex class can be used to
// only allow a single thread to run within a specified code
// segment at a time.
//
// Public Methods:
// Lock() : Locks the mutex. If the mutex is already locked, the
// operating system will block the calling thread until another
// thread has unlocked the mutex.
// Unlock() : Unlocks the mutex.
//
class CMutex
{
public:
CMutex::CMutex()
{
InitializeCriticalSection(&mCriticalSection);
}
CMutex::~CMutex()
{
DeleteCriticalSection(&mCriticalSection);
}
//CMutex();
//~CMutex();
void Lock();
void Unlock();
private:
CRITICAL_SECTION mCriticalSection;
};
inline void CMutex::Lock()
{
EnterCriticalSection(&mCriticalSection);
}
inline void CMutex::Unlock()
{
LeaveCriticalSection(&mCriticalSection);
}
}
#endif // BASE_WIN32_MUTEX_H
@@ -1,105 +0,0 @@
#ifndef BASE_PLATFORM_H
#define BASE_PLATFORM_H
#include <assert.h>
#ifdef WIN32
#include "win32/Platform.h"
#elif linux
#include "linux/Platform.h"
#elif sparc
#include "solaris/Platform.h"
#else
#error /Base/Platform.h: Undefine platform type
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
template <class T> inline T rotlFixed(T x, unsigned int y)
{
assert(y < sizeof(T)*8);
return (T)((x<<y) | (x>>(sizeof(T)*8-y)));
}
template <class T> inline T rotrFixed(T x, unsigned int y)
{
assert(y < sizeof(T)*8);
return (x>>y) | (x<<(sizeof(T)*8-y));
}
template <class T> inline T rotlMod(T x, unsigned int y)
{
y %= sizeof(T)*8;
return (x<<y) | (x>>(sizeof(T)*8-y));
}
template <class T> inline T rotrMod(T x, unsigned int y)
{
y %= sizeof(T)*8;
return (x>>y) | (x<<(sizeof(T)*8-y));
}
inline uint16 byteReverse16(void * data)
{
uint16 value = *static_cast<uint16 *>(data);
return *static_cast<uint16 *>(data) = rotlFixed(value, 8U);
// return rotlFixed(value, 8U);
}
inline uint32 byteReverse32(void * data)
{
uint32 value = *static_cast<uint32 *>(data);
return *static_cast<uint32 *>(data) = (rotrFixed(value, 8U) & 0xff00ff00) | (rotlFixed(value, 8U) & 0x00ff00ff);
// return (rotrFixed(value, 8U) & 0xff00ff00) | (rotlFixed(value, 8U) & 0x00ff00ff);
}
inline uint64 byteReverse64(void * data)
{
uint64 value = *static_cast<uint64 *>(data);
return *static_cast<uint64 *>(data) = (
uint64((rotrFixed(uint32(value), 8U) & 0xff00ff00) | (rotlFixed(uint32(value), 8U) & 0x00ff00ff)) << 32) |
(rotrFixed(uint32(value>>32), 8U) & 0xff00ff00) | (rotlFixed(uint32(value>>32), 8U) & 0x00ff00ff);
// return (uint64(byteReverse(uint32(value))) << 32) | byteReverse(uint32(value>>32));
}
inline uint32 strlen(const unsigned short * string)
{
if (string == 0)
return 0;
uint32 length=0;
while (*(string+length++) != 0);
return length-1;
}
inline double getTimerLatency(Base::uint64 startTime, Base::uint64 finishTime=0)
{
Base::int64 requestAge;
Base::int64 freq = Base::getTimerFrequency();
Base::uint64 finish = (finishTime ? finishTime : Base::getTimer());
if (finish < startTime)
requestAge = (0 - 1) - startTime - finish;
else
requestAge = finish - startTime;
return (double)requestAge/freq;
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // BASE_PLATFORM_H
@@ -1,44 +0,0 @@
#ifndef BASE_LINUX_ARCHIVE_H
#define BASE_LINUX_ARCHIVE_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
#ifdef PACK_BIG_ENDIAN
inline double byteSwap(double value) { byteReverse(&value); return value; }
inline float byteSwap(float value) { byteReverse(&value); return value; }
inline uint64 byteSwap(uint64 value) { byteReverse(&value); return value; }
inline int64 byteSwap(int64 value) { byteReverse(&value); return value; }
inline uint32 byteSwap(uint32 value) { byteReverse(&value); return value; }
inline int32 byteSwap(int32 value) { byteReverse(&value); return value; }
inline uint16 byteSwap(uint16 value) { byteReverse(&value); return value; }
inline int16 byteSwap(int16 value) { byteReverse(&value); return value; }
#else
inline double byteSwap(double value) { return value; }
inline float byteSwap(float value) { return value; }
inline uint64 byteSwap(uint64 value) { return value; }
inline int64 byteSwap(int64 value) { return value; }
inline uint32 byteSwap(uint32 value) { return value; }
inline int32 byteSwap(int32 value) { return value; }
inline uint16 byteSwap(uint16 value) { return value; }
inline int16 byteSwap(int16 value) { return value; }
#endif
}
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,10 +0,0 @@
AUTOMAKE_OPTIONS=foreign
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
noinst_LTLIBRARIES = libAuctionTransferGameAPIlinux.la
libAuctionTransferGameAPIlinux_la_LDFLAGS = -avoid-version
libAuctionTransferGameAPIlinux_la_SOURCES = Archive.h Platform.cpp Platform.h \
Types.h Mutex.cpp Mutex.h
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,40 +0,0 @@
////////////////////////////////////////
// Mutex.cpp
//
// Purpose:
// 1. Implementation of the CMutex class.
//
// Revisions:
// 07/10/2001 Created
//
#if defined(_REENTRANT)
#include "Mutex.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
CMutex::CMutex()
{
mInitialized = (pthread_mutex_init(&mMutex, 0) == 0);
}
CMutex::~CMutex()
{
if (mInitialized)
pthread_mutex_destroy(&mMutex);
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // #if defined(_REENTRANT)
@@ -1,79 +0,0 @@
////////////////////////////////////////
// Mutex.h
//
// Purpose:
// 1. Declair the CMutex class that encapsulates the functionality of a
// mutually-exclusive device.
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_LINUX_MUTEX_H
#define BASE_LINUX_MUTEX_H
#if !defined(_REENTRANT)
# pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_REENTRANT)" )
#else
#include "Platform.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
////////////////////////////////////////
// Class:
// CMutex
//
// Purpose:
// Encapsulates the functionality of a mutually-exclusive device.
// This class is valuable for protecting against race conditions
// within threaded applications. The CMutex class can be used to
// only allow a single thread to run within a specified code
// segment at a time.
//
// Public Methods:
// Lock() : Locks the mutex. If the mutex is already locked, the
// operating system will block the calling thread until another
// thread has unlocked the mutex.
// Unlock() : Unlocks the mutex.
//
class CMutex
{
public:
CMutex();
~CMutex();
void Lock();
void Unlock();
private:
pthread_mutex_t mMutex;
bool mInitialized;
};
inline void CMutex::Lock(void)
{
if (mInitialized)
pthread_mutex_lock(&mMutex);
}
inline void CMutex::Unlock(void)
{
if (mInitialized)
pthread_mutex_unlock(&mMutex);
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // #if defined(_MT)
#endif // BASE_LINUX_MUTEX_H
@@ -1,55 +0,0 @@
////////////////////////////////////////
// Platform.cpp
//
// Purpose:
// 1. Implementation of the global functionality declaired in Platform.h.
//
// Revisions:
// 07/10/2001 Created
//
#include <ctype.h>
#include "Platform.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
// Implementation of microsoft strlwr extension
// This non-ANSI function is not supported under UNIX
void strlwr(char * s)
{
while (*s)
{
*s = tolower(*s);
s++;
}
}
// Implementation of microsoft strlwr extension
// This non-ANSI function is not supported under UNIX
void strupr(char * s)
{
while (*s)
{
*s = toupper(*s);
s++;
}
}
CTimer::CTimer() :
mTimer(0)
{
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,112 +0,0 @@
////////////////////////////////////////
// Platform.h
//
// Purpose:
// 1. Include relevent system headers that are platform specific.
// 2. Declair global platform specific functionality.
// 3. Include primative type definitions
//
// Global Functions:
// getTimer() : Return the current high resolution clock count.
// getTimerFrequency() : Return the frequency of the high resolution clock.
// sleep() : Voluntarily relinquish timeslice of the calling thread for a
// specified number of milliseconds.
// strlwr() : Alters the contents of a string, making it all lower-case.
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_LINUX_PLATFORM_H
#define BASE_LINUX_PLATFORM_H
#include <errno.h>
#include <assert.h>
#include <sys/errno.h>
#include <pthread.h>
#include <resolv.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include "Types.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
uint64 getTimer(void);
uint64 getTimerFrequency(void);
void sleep(uint32 ms);
inline uint64 getTimer(void)
{
uint64 t;
struct timeval tv;
gettimeofday(&tv, 0);
t = tv.tv_sec;
t = t * 1000000;
t += tv.tv_usec;
return t;
}
inline uint64 getTimerFrequency(void)
{
uint64 f = 1000000;
return f;
}
inline void sleep(uint32 ms)
{
usleep(static_cast<unsigned long>(ms * 1000));
}
void strlwr(char * s);
void strupr(char * s);
class CTimer
{
public:
CTimer();
void Set(uint32 seconds);
void Signal();
bool Expired();
private:
uint32 mTimer;
};
inline void CTimer::Set(uint32 interval)
{
mTimer = (uint32)time(0) + interval;
}
inline void CTimer::Signal()
{
mTimer = 0;
}
inline bool CTimer::Expired()
{
return (mTimer <= (uint32)time(0));
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // BASE_LINUX_PLATFORM_H
@@ -1,42 +0,0 @@
////////////////////////////////////////
// Types.h
//
// Purpose:
// 1. Define integer types that are unambiguous with respect to size
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_LINUX_TYPES_H
#define BASE_LINUX_TYPES_H
#include <sys/bitypes.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
#define INT32_MAX 0x7FFFFFFF
#define INT32_MIN 0x80000000
#define UINT32_MAX 0xFFFFFFFF
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
}
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // BASE_LINUX_TYPES_H
@@ -1,42 +0,0 @@
#ifndef BASE_WIN32_ARCHIVE_H
#define BASE_WIN32_ARCHIVE_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
#ifdef PACK_BIG_ENDIAN
inline double byteSwap(double value) { byteReverse64(&value); return value; }
inline float byteSwap(float value) { byteReverse32(&value); return value; }
inline uint64 byteSwap(uint64 value) { byteReverse64(&value); return value; }
inline int64 byteSwap(int64 value) { byteReverse64(&value); return value; }
inline uint32 byteSwap(uint32 value) { byteReverse32(&value); return value; }
inline int32 byteSwap(int32 value) { byteReverse32(&value); return value; }
inline uint16 byteSwap(uint16 value) { byteReverse16(&value); return value; }
inline int16 byteSwap(int16 value) { byteReverse16(&value); return value; }
#else
inline double byteSwap(double value) { return value; }
inline float byteSwap(float value) { return value; }
inline uint64 byteSwap(uint64 value) { return value; }
inline int64 byteSwap(int64 value) { return value; }
inline uint32 byteSwap(uint32 value) { return value; }
inline int32 byteSwap(int32 value) { return value; }
inline uint16 byteSwap(uint16 value) { return value; }
inline int16 byteSwap(int16 value) { return value; }
#endif
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif
@@ -1,61 +0,0 @@
////////////////////////////////////////
// Mutex.h
//
// Purpose:
// 1. Declair the CMutex class that encapsulates the functionality of a
// mutually-exclusive device.
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_WIN32_MUTEX_H
#define BASE_WIN32_MUTEX_H
#include "Platform.h"
namespace Base
{
////////////////////////////////////////
// Class:
// CMutex
//
// Purpose:
// Encapsulates the functionality of a mutually-exclusive device.
// This class is valuable for protecting against race conditions
// within threaded applications. The CMutex class can be used to
// only allow a single thread to run within a specified code
// segment at a time.
//
// Public Methods:
// Lock() : Locks the mutex. If the mutex is already locked, the
// operating system will block the calling thread until another
// thread has unlocked the mutex.
// Unlock() : Unlocks the mutex.
//
class CMutex
{
public:
CMutex();
~CMutex();
void Lock();
void Unlock();
private:
CRITICAL_SECTION mCriticalSection;
};
inline void CMutex::Lock()
{
EnterCriticalSection(&mCriticalSection);
}
inline void CMutex::Unlock()
{
LeaveCriticalSection(&mCriticalSection);
}
}
#endif // BASE_WIN32_MUTEX_H
@@ -1,31 +0,0 @@
////////////////////////////////////////
// Platform.cpp
//
// Purpose:
// 1. Implementation of the global functionality declaired in Platform.h.
//
// Revisions:
// 07/10/2001 Created
//
#include "Platform.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
CTimer::CTimer() :
mTimer(0)
{
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,98 +0,0 @@
////////////////////////////////////////
// Platform.h
//
// Purpose:
// 1. Include relevent system headers that are platform specific.
// 2. Declair global platform specific functionality.
// 3. Include primative type definitions
//
// Global Functions:
// getTimer() : Return the current high resolution clock count.
// getTimerFrequency() : Return the frequency of the high resolution clock.
// sleep() : Voluntarily relinquish timeslice of the calling thread for a
// specified number of milliseconds.
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_WIN32_PLATFORM_H
#define BASE_WIN32_PLATFORM_H
#include <memory.h>
#include <winsock2.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <direct.h>
#include <stdio.h>
#include <errno.h>
#include "Types.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
uint64 getTimer(void);
uint64 getTimerFrequency(void);
inline uint64 getTimer(void)
{
uint64 result;
if (!QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&result)))
result = 0;
return result;
}
inline uint64 getTimerFrequency(void)
{
uint64 result;
if (!QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&result)))
result = 0;
return result;
}
inline void sleep(uint32 ms)
{
Sleep(ms);
}
class CTimer
{
public:
CTimer();
void Set(uint32 seconds);
void Signal();
bool Expired();
private:
uint32 mTimer;
};
inline void CTimer::Set(uint32 interval)
{
mTimer = (uint32)time(0) + interval;
}
inline void CTimer::Signal()
{
mTimer = 0;
}
inline bool CTimer::Expired()
{
return (mTimer <= (uint32)time(0));
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif BASE_WIN32_PLATFORM_H
@@ -1,42 +0,0 @@
////////////////////////////////////////
// Types.h
//
// Purpose:
// 1. Define integer types that are unambiguous with respect to size
//
// Revisions:
// 07/10/2001 Created
//
#ifndef BASE_WIN32_TYPES_H
#define BASE_WIN32_TYPES_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
#define INT32_MAX 0x7FFFFFFF
#define INT32_MIN 0x80000000
#define UINT32_MAX 0xFFFFFFFF
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif // BASE_WIN32_TYPES_H
@@ -1,44 +0,0 @@
#include "Character.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
void get(ByteStream::ReadIterator & source, AuctionTransfer::Character & target)
{
std::string tmpStr;
unsigned tmpNum;
//name
get(source, tmpStr);
target.setName(tmpStr);
// id
get(source, tmpNum);
target.setID(tmpNum);
// data
get(source, tmpStr);
target.setData(tmpStr);
}
void put(ByteStream & target, const AuctionTransfer::Character &source)
{
put(target, source.getName());
put(target, source.getID());
put(target, source.getData());
}
};
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,70 +0,0 @@
#ifndef CHARACTER_H
#define CHARACTER_H
#include "Base/Archive.h"
namespace AuctionTransfer
{
class Character
{
public:
// constructors
Character()
: m_name(""), m_id(0), m_XMLdata("")
{
}
Character(const std::string &name, unsigned id, const std::string &xmlData)
: m_name(name), m_id(id), m_XMLdata(xmlData)
{
}
Character(const Character &character)
: m_name(character.getName()), m_id(character.getID()), m_XMLdata(character.getData())
{
}
// destructor
~Character()
{
}
// accessor methods
std::string getName() const { return m_name; }
unsigned getID() const { return m_id; }
std::string getData() const { return m_XMLdata; }
void setName(const std::string name) { m_name = name; }
void setID(unsigned id) { m_id = id; }
void setData(const std::string data) { m_XMLdata = data; }
protected:
std::string m_name;
unsigned m_id;
std::string m_XMLdata;
};
}; // namespace AuctionTransfer
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
namespace Base
{
void get(ByteStream::ReadIterator & source, AuctionTransfer::Character & target);
void put(ByteStream & target, const AuctionTransfer::Character & source);
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //CHARACTER_H
@@ -1,13 +0,0 @@
AUTOMAKE_OPTIONS=foreign
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
libAuctionTransferGameAPI_la_LDFLAGS = -avoid-version
noinst_LTLIBRARIES = libAuctionTransferGameAPI.la
libAuctionTransferGameAPI_la_SOURCES = AuctionTransferAPICore.cpp\
AuctionTransferAPICore.h AuctionTransferAPI.cpp AuctionTransferAPI.h\
AuctionTransferEnum.h Character.cpp Character.h Request.cpp Request.h\
Response.cpp Response.h
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
SUBDIRS = zip Base TcpLibrary ATGenericAPI
@@ -1,231 +0,0 @@
#include "Request.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
void put(Base::ByteStream &msg, const Blob &source);
//////////////////////////////////////////////////////////////////////////////////////
Blob::Blob(const unsigned char *data, unsigned len)
: m_data(NULL),
m_len(len)
{
if (m_len > 0)
{
m_data = new unsigned char [m_len];
memcpy(m_data, data, m_len);
}
}
//////////////////////////////////////////////////////////////////////////////////////
Blob::Blob(const Blob &cpy)
: m_data(NULL),
m_len(cpy.m_len)
{
if (m_len > 0)
{
m_data = new unsigned char [m_len];
memcpy(m_data, cpy.m_data, m_len);
}
}
//////////////////////////////////////////////////////////////////////////////////////
Blob::~Blob()
{
if (m_data)
{
delete [] m_data;
}
}
//////////////////////////////////////////////////////////////////////////////////////
Blob & Blob::operator =(const Blob &cpy)
{
if (this != &cpy)
{
//copy
if (m_data)
{
delete [] m_data;
m_data = NULL;
}
m_len = cpy.m_len;
if (m_len > 0)
{
m_data = new unsigned char [m_len];
memcpy(m_data, cpy.m_data, m_len);
}
}
return *this;
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
ReplyRequest::ReplyRequest( RequestTypes type, unsigned serverTrack, unsigned responseCode )
: GenericRequest(type, serverTrack), m_responseCode(responseCode)
{
}
void ReplyRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_server_track);
put(msg, m_responseCode);
}
//////////////////////////////////////////////////////////////////////////////////////
CommonRequest::CommonRequest( RequestTypes type, unsigned serverTrack, long long transactionID )
: GenericRequest(type, serverTrack), m_transactionID(transactionID)
{
}
void CommonRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_transactionID);
}
//////////////////////////////////////////////////////////////////////////////////////
GetIDRequest::GetIDRequest( RequestTypes type, unsigned serverTrack )
: GenericRequest(type, serverTrack)
{
}
void GetIDRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
}
//////////////////////////////////////////////////////////////////////////////////////
SendPrepareCompressedRequest::SendPrepareCompressedRequest(RequestTypes type, unsigned serverTrack, const char *serverID, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const unsigned char *xmlAsset, unsigned length)
: GenericRequest(type, serverTrack),
m_transactionID(transactionID),
m_stationID(stationID),
m_characterID(characterID),
m_assetID(assetID),
m_serverID(serverID),
m_data(xmlAsset, length)
{
}
void SendPrepareCompressedRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_serverID);
put(msg, m_transactionID);
put(msg, m_stationID);
put(msg, m_characterID);
put(msg, m_assetID);
put(msg, m_data);
}
//////////////////////////////////////////////////////////////////////////////////////
SendPrepareRequest::SendPrepareRequest( RequestTypes type, unsigned serverTrack, const char *serverID, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *xml )
: GenericRequest(type, serverTrack),
m_transactionID(transactionID),
m_stationID(stationID),
m_characterID(characterID),
m_assetID(assetID),
m_xml(xml),
m_serverID(serverID)
{
}
void SendPrepareRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_serverID);
put(msg, m_transactionID);
put(msg, m_stationID);
put(msg, m_characterID);
put(msg, m_assetID);
put(msg, m_xml);
}
//////////////////////////////////////////////////////////////////////////////////////
ReplyGetCharacterListRequest::ReplyGetCharacterListRequest(RequestTypes type, unsigned serverTrack, unsigned responseCode, const Character characters[], unsigned numCharacters)
: GenericRequest(type, serverTrack), m_responseCode(responseCode)
{
for(unsigned i = 0; i < numCharacters; i++)
{
m_characters.push_back(characters[i]);
}
}
void ReplyGetCharacterListRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_server_track);
put(msg, m_responseCode);
put(msg, (unsigned)m_characters.size());
for(unsigned i = 0; i < m_characters.size(); i++)
{
put(msg, m_characters[i]);
}
}
//////////////////////////////////////////////////////////////////////////////////////
IdentifyServerRequest::IdentifyServerRequest(RequestTypes type, unsigned serverTrack, const char *serverID[], unsigned numIDs)
: GenericRequest(type, serverTrack)
{
for(unsigned i = 0; i < numIDs; i++)
{
m_serverIDs.push_back(serverID[i]);
}
}
void IdentifyServerRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, (unsigned)m_serverIDs.size());
for(unsigned i = 0; i < m_serverIDs.size(); i++)
{
put(msg, m_serverIDs[i]);
}
}
//////////////////////////////////////////////////////////////////////////////////////
SendAuditRequest::SendAuditRequest( RequestTypes type, unsigned serverTrack, const char *gameCode, const char *serverCode,
long long inGameAssetID, unsigned stationID, const char *event, const char *message)
: GenericRequest(type, serverTrack), m_gameCode(gameCode), m_serverCode(serverCode), m_assetID(inGameAssetID),
m_userID(stationID), m_event(event), m_message(message)
{
}
void SendAuditRequest::pack(Base::ByteStream &msg)
{
put(msg, m_type);
put(msg, m_track);
put(msg, m_gameCode);
put(msg, m_serverCode);
put(msg, m_assetID);
put(msg, m_userID);
put(msg, m_event);
put(msg, m_message);
}
void put(Base::ByteStream &msg, const Blob &source)
{
put(msg, source.getLen());
if (source.getLen() > 0)
{
put(msg, source.getData(), source.getLen());
}
}
}; // namespace
//////////////////////////////////////////////////////////////////////////////////////
@@ -1,147 +0,0 @@
#ifndef REQUEST_H
#define REQUEST_H
#include "ATGenericAPI/GenericMessage.h"
#include "Base/Archive.h"
#include "AuctionTransferEnum.h"
#include "Character.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
class Blob
{
public:
Blob() : m_data(0), m_len(0) {}
Blob(const unsigned char *data, unsigned len);
Blob(const Blob &cpy);
~Blob();
Blob & operator =(const Blob &cpy);
const unsigned char *getData() const { return m_data; }
unsigned getLen() const { return m_len; }
unsigned char *m_data;
unsigned m_len;
};
//////////////////////////////////////////////////////////////////////////////////////
class ReplyRequest: public GenericRequest
{
public:
ReplyRequest(RequestTypes type, unsigned serverTrack, unsigned responseCode);
virtual ~ReplyRequest() {};
void pack(Base::ByteStream &msg);
private:
unsigned m_responseCode;
};
//////////////////////////////////////////////////////////////////////////////////////
class CommonRequest: public GenericRequest
{
public:
CommonRequest(RequestTypes type, unsigned serverTrack, long long transactionID);
virtual ~CommonRequest() {};
void pack(Base::ByteStream &msg);
private:
long long m_transactionID;
};
//////////////////////////////////////////////////////////////////////////////////////
class GetIDRequest: public GenericRequest
{
public:
GetIDRequest(RequestTypes type, unsigned serverTrack);
virtual ~GetIDRequest() {};
void pack(Base::ByteStream &msg);
private:
};
//////////////////////////////////////////////////////////////////////////////////////
class SendPrepareRequest: public GenericRequest
{
public:
SendPrepareRequest(RequestTypes type, unsigned serverTrack, const char *serverID, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const char *xmlAsset);
virtual ~SendPrepareRequest() {};
void pack(Base::ByteStream &msg);
private:
long long m_transactionID;
unsigned m_stationID;
unsigned m_characterID;
long long m_assetID;
std::string m_xml;
std::string m_serverID;
};
//////////////////////////////////////////////////////////////////////////////////////
class SendPrepareCompressedRequest: public GenericRequest
{
public:
SendPrepareCompressedRequest(RequestTypes type, unsigned serverTrack, const char *serverID, long long transactionID, unsigned stationID, unsigned characterID, long long assetID, const unsigned char *xmlAsset, unsigned length);
virtual ~SendPrepareCompressedRequest() {};
void pack(Base::ByteStream &msg);
private:
long long m_transactionID;
unsigned m_stationID;
unsigned m_characterID;
long long m_assetID;
//std::string m_xml;
std::string m_serverID;
Blob m_data;
};
//////////////////////////////////////////////////////////////////////////////////////
class ReplyGetCharacterListRequest: public GenericRequest
{
public:
ReplyGetCharacterListRequest(RequestTypes type, unsigned serverTrack, unsigned responseCode, const Character characters[], unsigned numCharacters);
virtual ~ReplyGetCharacterListRequest() {};
void pack(Base::ByteStream &msg);
private:
unsigned m_responseCode;
std::vector<Character> m_characters;
};
//////////////////////////////////////////////////////////////////////////////////////
class IdentifyServerRequest: public GenericRequest
{
public:
IdentifyServerRequest(RequestTypes type, unsigned serverTrack, const char *serverID[], unsigned numIDs);
virtual ~IdentifyServerRequest() {};
void pack(Base::ByteStream &msg);
private:
std::vector<std::string> m_serverIDs;
};
//////////////////////////////////////////////////////////////////////////////////////
class SendAuditRequest : public GenericRequest
{
public:
SendAuditRequest( RequestTypes type, unsigned serverTrack, const char *gameCode, const char *serverCode,
long long inGameAssetID, unsigned stationID, const char *event, const char *message);
~SendAuditRequest() {};
void pack(Base::ByteStream &msg);
private:
std::string m_gameCode;
std::string m_serverCode;
long long m_assetID;
unsigned m_userID;
std::string m_event;
std::string m_message;
};
}; // namespace
//////////////////////////////////////////////////////////////////////////////////////
#endif //REQUEST_H
@@ -1,17 +0,0 @@
#include "Response.h"
namespace AuctionTransfer
{
GetIDResponse::GetIDResponse(RequestTypes type, void *user)
: GenericResponse( type, TRANSFER_SERVER_TIME_OUT, user), m_transactionID(-1)
{
}
void GetIDResponse::unpack(Base::ByteStream::ReadIterator &iter)
{
get(iter, m_type);
get(iter, m_track);
get(iter, m_result);
get(iter, m_transactionID);
}
};
@@ -1,35 +0,0 @@
#ifndef RESPONSE_H
#define RESPONSE_H
#include "Base/Archive.h"
#include "ATGenericAPI/GenericMessage.h"
#include "AuctionTransferEnum.h"
//////////////////////////////////////////////////////////////////////////////////////
namespace AuctionTransfer
{
class CommonResponse : public GenericResponse
{
public:
CommonResponse(RequestTypes type, void *user) : GenericResponse( type, TRANSFER_SERVER_TIME_OUT, user) {}
virtual ~CommonResponse() {}
};
//////////////////////////////////////////////////////////////////////////////////////
class GetIDResponse : public GenericResponse
{
public:
GetIDResponse(RequestTypes type, void *user);
virtual ~GetIDResponse() {}
long long getNewID() { return m_transactionID; }
virtual void unpack(Base::ByteStream::ReadIterator &iter);
private:
long long m_transactionID;
};
}; // namespace AuctionTransfer
//////////////////////////////////////////////////////////////////////////////////////
#endif //RESPONSE_H
@@ -1,119 +0,0 @@
#include "Clock.h"
#include <time.h>
#ifdef WIN32
#include <winsock.h>
#else //WIN32
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
Clock::Clock()
: m_lastStart(0),
m_totalRunTime(0)
{
}
ClockStamp Clock::getCurTime()
{
#if defined(WIN32)
static int sClockHigh = 0;
static ClockStamp sClockLast = 0;
int high = sClockHigh;
DWORD low = GetTickCount();
ClockStamp holdLast = sClockLast; // this should be interlocked too
ClockStamp ret = ((ClockStamp)high << 32) | low;
// crazy trick to allow threading to work, by putting in a 1000 second fudge factor, we effective say
// that it is ok to time-slice us at a bad point and we will still handle it, provided that our thread
// gets processing time again within 1000 seconds
if (ret < holdLast - 1000000)
{
sClockHigh = high + 1;
ret = ((ClockStamp)high << 32) | low;
}
sClockLast = ret; // this really should be interlocked to be totally safe since it is a 64 bit value, but I don't see a way to do that and am not sure it would mess up anything but the one call anyways
return ret;
#else
struct timeval tv;
int err;
err = gettimeofday(&tv, NULL);
return (static_cast<ClockStamp>(tv.tv_sec) * 1000 + static_cast<ClockStamp>(tv.tv_usec / 1000));
#endif
}
ClockStamp Clock::getElapsedSinceLastStart()
{
if (m_lastStart == 0)
{
//hasn't been started
return 0;
}
ClockStamp elapsed = getCurTime() - m_lastStart;
if (elapsed > 2000000000) // only time differences up to 23 days can be measured with this function
elapsed = 2000000000;
return elapsed;
}
void Clock::start()
{
if (m_lastStart != 0)
{
//already started
return;
}
//set last start to curtime
m_lastStart = getCurTime();
}
void Clock::stop()
{
if (m_lastStart == 0)
{
//need to start before stoping
return;
}
m_totalRunTime += (unsigned)getElapsedSinceLastStart(); //rlsmith - explicit cast to prevent compiler warning
m_lastStart = 0;
}
bool Clock::isDone(unsigned runTime)
{
if (m_lastStart == 0)
{
//never started, so say no
return false;
}
ClockStamp totalElapsed = getElapsedSinceLastStart() + m_totalRunTime;
return (totalElapsed >= runTime);
}
void Clock::reset()
{
m_lastStart = 0;
m_totalRunTime = 0;
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,71 +0,0 @@
#ifndef CLOCK_H
#define CLOCK_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
#if defined(WIN32)
typedef __int64 ClockStamp;
#else
typedef long long ClockStamp;
#endif
/**
* @brief A Clock can be used as a millisecond timer.
*/
class Clock
{
public:
/**
* @brief Creates a clock, must still be started with Clock::start method.
*
* Once created, a clock can be started, and stoped as often as possible.
*/
Clock();
/**
* @brief Starts the timer running.
*/
void start();
/**
* @brief Stops the timer from running (note: can still be started again later).
*/
void stop();
/**
* @brief Tells you if the timer has been in the started state for longer than runTime.
*
* @param runTime The amount of time to test if this timer has ran longer than.
*
* @return 'true' if timer has ran for longer than or equal to runTime, false otherwise.
*/
bool isDone(unsigned runTime);
/**
* @brief Resets this clock (as if it were never started).
*/
void reset();
private:
ClockStamp m_lastStart;
unsigned m_totalRunTime;
ClockStamp getCurTime();
ClockStamp getElapsedSinceLastStart();
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //CLOCK_H
@@ -1,33 +0,0 @@
#include "IPAddress.h"
#if defined(WIN32)
#include <winsock.h>
typedef int socklen_t;
#else // for non-windows platforms (linux)
#include <arpa/inet.h>
#include <sys/socket.h>
#include <string.h>
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
IPAddress::IPAddress(unsigned int ip)
: m_IP(ip)
{
}
char *IPAddress::GetAddress(char *buffer) const
{
struct sockaddr_in addr;
addr.sin_addr.s_addr = m_IP;
strcpy(buffer, inet_ntoa(addr.sin_addr));
return(buffer);
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,51 +0,0 @@
#ifndef TCPIPADDRESS_H
#define TCPIPADDRESS_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
/**
* @brief Container object for IP Address.
*/
class IPAddress
{
public:
/**
* @brief Constructor, sets the ip address if specified.
*/
IPAddress(unsigned int ip = 0);
/**
* @brief Sets the ip address.
*/
void SetAddress(unsigned int ip){ m_IP = ip; }
/**
* @brief Returns the unsigned int representation of this address.
*/
unsigned int GetAddress() const { return m_IP; }
/**
* @brief Used to retreive the the dot-notation represenatatiion of this address.
*
* @param buffer A pointer to the buffer to place the ip address into.
* Must be at least 17 characters long, will be null terminated.
*
* @return A pointer to the buffer the address was placed into.
*/
char *GetAddress(char *buffer) const;
private:
unsigned int m_IP;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //TCPIPADDRESS_H
@@ -1,11 +0,0 @@
AUTOMAKE_OPTIONS=foreign
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
libAuctionTransferGameAPITcpLibrary_la_LDFLAGS = -avoid-version
noinst_LTLIBRARIES = libAuctionTransferGameAPITcpLibrary.la
libAuctionTransferGameAPITcpLibrary_la_SOURCES = Clock.cpp Clock.h IPAddress.cpp IPAddress.h\
TcpBlockAllocator.cpp TcpBlockAllocator.h TcpConnection.cpp\
TcpConnection.h TcpHandlers.h TcpManager.cpp TcpManager.h
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,94 +0,0 @@
#include "TcpBlockAllocator.h"
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
TcpBlockAllocator::TcpBlockAllocator(const unsigned initSize, const unsigned initCount)
: m_freeHead(NULL), m_blockCount(initCount), m_blockSize(initSize), m_numAvailBlocks(0)
{
realloc();
}
TcpBlockAllocator::~TcpBlockAllocator()
{
while(m_freeHead)
{
data_block *tmp = m_freeHead;
m_freeHead = m_freeHead->m_next;
delete[] tmp->m_data;
delete tmp;m_numAvailBlocks--;
}
}
data_block *TcpBlockAllocator::getBlock()
{
data_block *tmp;
if(!m_freeHead)
{
realloc();
}
tmp = m_freeHead;
m_freeHead = m_freeHead->m_next;
tmp->m_next = NULL;
m_numAvailBlocks--;
return(tmp);
}
void TcpBlockAllocator::returnBlock(data_block *b)
{
b->m_usedSize = 0;
b->m_sentSize = 0;
if (m_numAvailBlocks >= m_blockCount)
{
delete[] b->m_data;
delete b;
return;
}
b->m_next = m_freeHead;
m_freeHead = b; m_numAvailBlocks++;
}
void TcpBlockAllocator::realloc()
{
data_block *tmp = NULL, *cursor = NULL;
tmp = new data_block; m_numAvailBlocks++;
cursor = tmp;
memset(cursor, 0, sizeof(data_block));
cursor->m_data = new char[m_blockSize];
cursor->m_totalSize = m_blockSize;
for(unsigned i = 1; i < m_blockCount; i++)
{
cursor->m_next = new data_block; m_numAvailBlocks++;
cursor = cursor->m_next;
memset(cursor, 0, sizeof(data_block));
cursor->m_data = new char[m_blockSize];
cursor->m_totalSize = m_blockSize;
}
if(m_freeHead)
{
cursor->m_next = m_freeHead;
m_freeHead = tmp;
}
else
{
m_freeHead = tmp;
}
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,44 +0,0 @@
#ifndef TCPBLOCKALLOCATOR_H
#define TCPBLOCKALLOCATOR_H
#include <string.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
struct data_block
{
unsigned m_usedSize;
unsigned m_sentSize;
unsigned m_totalSize;
char *m_data;
data_block *m_next;
};
class TcpBlockAllocator
{
public:
TcpBlockAllocator(const unsigned initSize, const unsigned initCount);
~TcpBlockAllocator();
data_block *getBlock();
void returnBlock(data_block *);
private:
void realloc();
data_block *m_freeHead;
unsigned m_blockCount;
unsigned m_blockSize;
unsigned m_numAvailBlocks;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //TCPBLOCKALLOCATOR_H
@@ -1,784 +0,0 @@
#include "TcpConnection.h"
#include "TcpManager.h"
#include "Clock.h"
#include <errno.h>
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
//used when want to open new connection with this socket
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, const IPAddress &destIP, short destPort, unsigned timeout)
: m_nextConnection(NULL),
m_prevConnection(NULL),
m_socket(INVALID_SOCKET),
m_nextKeepAliveConnection(NULL),
m_prevKeepAliveConnection(NULL),
m_aliveListId(tcpManager->m_aliveList.m_listID),
m_nextRecvDataConnection(NULL),
m_prevRecvDataConnection(NULL),
m_recvDataListId(tcpManager->m_dataList.m_listID),
m_manager(tcpManager),
m_status(StatusNegotiating),
m_handler(NULL),
m_destIP(destIP),
m_destPort(destPort),
m_refCount(0),
m_sendAllocator(sendAlloc),
m_head(NULL),
m_tail(NULL),
m_bytesRead(0),
m_bytesNeeded(0),
m_params(params),
m_recvBuff(NULL),
m_connectTimeout(timeout),
m_connectTimer(),
m_wasConRemovedFromMgr(false)
{
//start connection timer
m_connectTimer.start();
memset(&m_addr, 0, sizeof(m_addr));
if (m_params.maxRecvMessageSize != 0)
{
m_recvBuff = new char[m_params.maxRecvMessageSize];
}
m_socket = socket(AF_INET, SOCK_STREAM, 0);
setOptions();
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons(m_destPort);
m_addr.sin_addr.s_addr = m_destIP.GetAddress();
int err = connect(m_socket, (sockaddr *)&m_addr, sizeof(m_addr));
if(err == SOCKET_ERROR)
{
#ifdef WIN32
int sockerr = WSAGetLastError();
if(sockerr != WSAEWOULDBLOCK)
{
//a real error
m_status = StatusDisconnected;
}
else
{
m_status = StatusNegotiating;
}
#else // UNIX
if (errno != EINPROGRESS)
{
m_status = StatusDisconnected;
}
else
{
m_status = StatusNegotiating;
}
#endif
}
else
{
//we are connected, wow
m_status = StatusConnected;
}
}
//used when server mode creates new connection object representing a connect request
TcpConnection::TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, SOCKET socket, const IPAddress &destIP, short destPort)
: m_nextConnection(NULL),
m_prevConnection(NULL),
m_socket(socket),
m_nextKeepAliveConnection(NULL),
m_prevKeepAliveConnection(NULL),
m_aliveListId(tcpManager->m_aliveList.m_listID),
m_nextRecvDataConnection(NULL),
m_prevRecvDataConnection(NULL),
m_recvDataListId(tcpManager->m_dataList.m_listID),
m_manager(tcpManager),
m_status(StatusConnected),
m_handler(NULL),
m_destIP(destIP),
m_destPort(destPort),
m_refCount(0),
m_sendAllocator(sendAlloc),
m_head(NULL),
m_tail(NULL),
m_bytesRead(0),
m_bytesNeeded(0),
m_params(params),
m_recvBuff(NULL),
m_connectTimeout(0),
m_connectTimer(),
m_wasConRemovedFromMgr(false)
{
memset(&m_addr, 0, sizeof(m_addr));
if (m_params.maxRecvMessageSize != 0)
{
m_recvBuff = new char[m_params.maxRecvMessageSize];
}
setOptions();
}
void TcpConnection::setOptions()
{
if (m_socket != INVALID_SOCKET)
{
#if defined(WIN32)
unsigned long isNonBlocking = 1;
int outBufSize = m_params.outgoingBufferSize;
int inBufSize = m_params.incomingBufferSize;
int keepAlive = 1;
int reuseAddr = 1;
struct linger ld;
ld.l_onoff = 0;
ld.l_linger = 0;
if (ioctlsocket(m_socket, FIONBIO, &isNonBlocking) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_SNDBUF, (char *)&outBufSize, sizeof(outBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, (char *)&inBufSize, sizeof(inBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&keepAlive, sizeof(keepAlive)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuseAddr, sizeof(reuseAddr)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_LINGER, (char *)&ld, sizeof(ld)) != 0 )
{
//bummer, but no need to crash now.... ?
}
#else // linux is to remain the default compile mode
unsigned long isNonBlocking = 1;
unsigned long keepAlive = 1;
unsigned long outBufSize = m_params.outgoingBufferSize;
unsigned long inBufSize = m_params.incomingBufferSize;
unsigned long reuseAddr = 1;
struct linger ld;
ld.l_onoff = 0;
ld.l_linger = 0;
if (ioctl(m_socket, FIONBIO, &isNonBlocking) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_SNDBUF, &outBufSize, sizeof(outBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, &inBufSize, sizeof(inBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, &keepAlive, sizeof(keepAlive)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_LINGER, &ld, sizeof(ld)) != 0)
{
//bummer, but no need to crash now.... ?
}
#endif
}
}
int TcpConnection::finishConnect()
{
AddRef();
int returnVal = 0;
/**< returns < 0 if fatal error and connect will not work, =0 if need more time, >0 if connect completed */
switch (m_status)
{
case StatusDisconnected:
{
//something went wrong
Disconnect(false);
returnVal = -1;
}
break;
case StatusNegotiating:
{
#ifdef WIN32
//try to finish connection
fd_set wrSet;
FD_ZERO(&wrSet);
FD_SET(m_socket, &wrSet);
timeval t;
t.tv_sec = 0;
t.tv_usec = 0;
int err = select(m_socket + 1, NULL, &wrSet, NULL, &t);
if (err == 0)
{
//needs more time
returnVal = 0;
}
else if (err == SOCKET_ERROR)
{
//huhoh, let's hope it needs more time
int sockerr = WSAGetLastError();
if (sockerr == WSAEINPROGRESS
|| sockerr == WSAEWOULDBLOCK
|| sockerr == WSAEALREADY
|| sockerr == WSAEINVAL)
{
//yep
returnVal = 0;
}
else
{
Disconnect(false);
returnVal = -1;
}
}
else
{
//check if write bit set for socket
if (FD_ISSET(m_socket, &wrSet))
{
//connection complete
m_status = StatusConnected;
returnVal = 1;
}
else
{
//give it more time??
returnVal = 0;
}
}
#else // not WIN32
int err = connect(m_socket, (sockaddr *)&m_addr, sizeof(m_addr));
if(err == SOCKET_ERROR)
{
if (errno != EINPROGRESS && errno != EALREADY)
{
Disconnect(false);
returnVal = -1;//failure
}
else
{
returnVal = 0;//need to wait
}
}
else
{
m_status = StatusConnected;
returnVal = 1;//connect success
}
#endif
}
break;
case StatusConnected:
{
//wierd, shouldn't be trying to do this here
Disconnect(true);
returnVal = -1;
}
break;
}
if (returnVal == 0 && m_connectTimeout != 0 && m_connectTimer.isDone(m_connectTimeout))
{
Disconnect(false);
returnVal = -1;
}
else if (returnVal ==1/* && m_connectTimeout != 0*/)
{
//need to give, onConnect callback
if (m_manager->m_handler)
m_manager->m_handler->OnConnectRequest(this);
}
Release();
return returnVal;
}
TcpConnection::~TcpConnection()
{
if (m_recvBuff != NULL)
{
delete [] m_recvBuff;
}
while(m_head != NULL)
{
data_block *tmp = m_head;
m_head = m_head->m_next;
m_sendAllocator->returnBlock(tmp);
}
//TODO: need to notify app if are currently connected
}
void TcpConnection::Send(const char *data, unsigned int dataLen)
{
//add msg to buf
int totalLen = dataLen + sizeof(int);
if(m_status == StatusDisconnected)
{
return;
}
if (m_params.keepAliveDelay > 0 && m_aliveListId == m_manager->m_aliveList.m_listID)
{
m_aliveListId = m_manager->m_keepAliveList.m_listID;
if (m_prevKeepAliveConnection != NULL)
m_prevKeepAliveConnection->m_nextKeepAliveConnection = m_nextKeepAliveConnection;
if (m_nextKeepAliveConnection != NULL)
m_nextKeepAliveConnection->m_prevKeepAliveConnection = m_prevKeepAliveConnection;
if (m_manager->m_keepAliveList.m_beginList == this)
m_manager->m_keepAliveList.m_beginList = m_nextKeepAliveConnection;
m_nextKeepAliveConnection = m_manager->m_aliveList.m_beginList;
m_prevKeepAliveConnection = NULL;
if (m_manager->m_aliveList.m_beginList != NULL)
m_manager->m_aliveList.m_beginList->m_prevKeepAliveConnection = this;
m_manager->m_aliveList.m_beginList = this;
}
data_block *work = NULL;
// this connection has no send buffer. Get a block
if(!m_tail)
{
m_head = m_sendAllocator->getBlock();
m_tail = m_head;
}
work = m_tail;
//send message len first
unsigned nLen = htonl(totalLen);
unsigned lenLength = sizeof(int);
unsigned lenIndex = 0;
while(lenIndex < lenLength)
{
if ((lenLength - lenIndex) <= (work->m_totalSize - work->m_usedSize))
{
//size will fit in this block
memcpy(work->m_data + work->m_usedSize, (char *)(&nLen) + lenIndex, lenLength - lenIndex);
work->m_usedSize += (lenLength - lenIndex);
lenIndex += (lenLength - lenIndex);
}
else
{
//size will not fit in this block
memcpy(work->m_data + work->m_usedSize, (char *)(&nLen) + lenIndex, work->m_totalSize - work->m_usedSize);
lenIndex += work->m_totalSize - work->m_usedSize;
work->m_usedSize += work->m_totalSize - work->m_usedSize;
work->m_next = m_sendAllocator->getBlock();
work = work->m_next;
m_tail = work;
}
}
//now send message payload
unsigned messageIndex = 0;
while(messageIndex < dataLen)
{
if((dataLen - messageIndex) <= (work->m_totalSize - work->m_usedSize))
{
// data will fit in this block
memcpy(work->m_data + work->m_usedSize, data + messageIndex, (dataLen - messageIndex));
work->m_usedSize += (dataLen - messageIndex);
messageIndex += (dataLen - messageIndex);
}
else
{
// data will not fit in this block. Fill this block and get another block
memcpy(work->m_data + work->m_usedSize, data + messageIndex, work->m_totalSize - work->m_usedSize);
messageIndex += work->m_totalSize - work->m_usedSize;
work->m_usedSize += work->m_totalSize - work->m_usedSize;
work->m_next = m_sendAllocator->getBlock();
work = work->m_next;
m_tail = work;
}
}
return;
}
void TcpConnection::Disconnect(bool notifyApplication)
{
AddRef();
m_status = StatusDisconnected;
if (!m_wasConRemovedFromMgr)
{
m_manager->removeConnection(this);
m_wasConRemovedFromMgr = true;
}
if(m_socket != INVALID_SOCKET)
{
#if defined(WIN32)
closesocket(m_socket);
#else
close(m_socket);
#endif
m_socket = INVALID_SOCKET;
}
if (notifyApplication && m_handler)
m_handler->OnTerminated(this);
Release();
}
void TcpConnection::AddRef()
{
m_refCount++;
}
void TcpConnection::Release()
{
if (--m_refCount == 0)
{
//make sure manager knows I'm gone
if (m_status != StatusDisconnected)
Disconnect(false);
delete this;
}
}
int TcpConnection::processIncoming()
{
/**< returns < 0 if fatal error and socket has been closed,
=0 if read anything (full or partial message),
>0 if nothing to read now, or would block so shouldn't try again immediately. */
if (m_status != StatusConnected)
{
//wait until connect succeeds
return 1;
}
if (m_params.noDataTimeout > 0 && m_recvDataListId == m_manager->m_dataList.m_listID)
{
m_recvDataListId = m_manager->m_noDataList.m_listID;
if (m_prevRecvDataConnection != NULL)
m_prevRecvDataConnection->m_nextRecvDataConnection = m_nextRecvDataConnection;
if (m_nextRecvDataConnection != NULL)
m_nextRecvDataConnection->m_prevRecvDataConnection = m_prevRecvDataConnection;
if (m_manager->m_noDataList.m_beginList == this)
m_manager->m_noDataList.m_beginList = m_nextRecvDataConnection;
m_nextRecvDataConnection = m_manager->m_dataList.m_beginList;
m_prevRecvDataConnection = NULL;
if (m_manager->m_dataList.m_beginList != NULL)
m_manager->m_dataList.m_beginList->m_prevRecvDataConnection = this;
m_manager->m_dataList.m_beginList = this;
}
int newMsg = 0;
if (m_bytesRead < sizeof(int))
{
//new msg
newMsg = 1;
//printf("socket: %d\n", m_socket);
int ret = recv(m_socket, ((char *)(&m_bytesNeeded) + m_bytesRead),
4 - m_bytesRead, 0);
//fprintf(stderr, "READ: %d\n", ret);
if (ret == 0)
{
//We did a select, so there should be data. Socket was closed.
Disconnect();
return -1;
}
else if (ret == -1)
{
if (translateRecvSocketEror())
{
//fatal error
return -1;
}
else
{
//need to wait
return 1;
}
}
else
{
m_bytesRead += ret;
if (m_bytesRead < 4)
{
return 1;//need to wait
}
else
{
m_bytesNeeded = ntohl(m_bytesNeeded);
//printf("m_bytesNeeded = %i\n", m_bytesNeeded);
if (m_bytesNeeded == sizeof(int))
{
//keepalive, ignore
m_bytesRead = 0;
m_bytesNeeded = 0;
return 0;
}
else if (m_bytesNeeded < sizeof(int))
{
//major protocol violation
Disconnect();
return -1;
}
else if (m_params.maxRecvMessageSize == 0)
{
if (m_recvBuff!=NULL)
delete [] m_recvBuff;
m_recvBuff = new char[m_bytesNeeded-4];
}
else if (m_params.maxRecvMessageSize != 0 && (m_bytesNeeded-4) > m_params.maxRecvMessageSize)
{
//error, maxRecvMeessageSize exceeded, Disconnect
Disconnect();
return -1;
}
}
}
}
int msgBytesRead = m_bytesRead - 4;
int msgBytesNeeded = m_bytesNeeded - 4;
int ret = recv(m_socket, (char *)(m_recvBuff + msgBytesRead),
msgBytesNeeded - msgBytesRead, 0);
if (ret == 0 && !newMsg)
{
//We did a select, so there should be data. Socket was closed.
Disconnect();
return -1;
}
if (ret == -1)
{
if (translateRecvSocketEror())
{
//fatal error
return -1;
}
else
{
//need to wait
return 1;
}
} else
{
m_bytesRead += ret;
}
if (m_bytesRead == m_bytesNeeded)
{
m_bytesRead = 0;
m_bytesNeeded = 0;
if (m_handler)
{
AddRef();//could get deleted during this callback
m_handler->OnRoutePacket(this, (unsigned char *)m_recvBuff, msgBytesNeeded);
if (m_status == StatusDisconnected)
{
Release();
return -1;
}
Release();
}
//entire message received
return 0;
}
else
{
return 1;//couldn't get entire msg
}
}
int TcpConnection::processOutgoing()
{
/**< returns < 0 if fatal error and socket has been closed,
=0 if sent data, call again immediately if want to,
>0 may have sent data, but calling again would do no good because there is either no more data to send, or would block. */
if (m_status != StatusConnected)
{
//wait until connect succeeds
return 0;
}
int sendError = 1;
// If m_head is not null, then this connection has something to send
if(m_head)
{
int amt = ::send(m_socket, m_head->m_data + m_head->m_sentSize, m_head->m_usedSize - m_head->m_sentSize, 0);
if(amt < 0)
{
#ifdef WIN32
switch(WSAGetLastError())
{
case WSAEWOULDBLOCK:
case WSAEINTR:
case WSAEINPROGRESS:
case WSAEALREADY:
case WSA_IO_PENDING:
case WSA_NOT_ENOUGH_MEMORY:
case WSATRY_AGAIN:
//try again
sendError = 1;
break;
default:
//assume broken, Disconnect
Disconnect();
sendError = -1;
break;
}
#else //not WIN32
// error condition, EAGAIN is recoverable, otherwise raise an error condition. Break from loop
switch(errno)
{
case EAGAIN:
//try again
sendError = 1;
break;
default:
//assume broken, Disconnect
Disconnect();
sendError = -1;
break;
}
#endif
}
else if(static_cast<unsigned>(amt) < (m_head->m_usedSize - m_head->m_sentSize))
{
// partial send: trying to do anything more now would be a waste of time. Break from loop
m_head->m_sentSize += amt;
sendError = 1;
}
else if(amt == 0)
{
Disconnect();
sendError = -1;
// client closed connection
}
else
{
// everything was sent from this block. Return it to the pool, advance m_head. Attempt to continue
// sending
data_block *tmp = m_head;
if(m_tail == m_head)
{
m_tail = m_tail->m_next;
m_head = m_head->m_next;
}
else
{
m_head = m_head->m_next;
}
m_sendAllocator->returnBlock(tmp);
sendError = 0;
}
}
return sendError;
}
bool TcpConnection::translateRecvSocketEror()
{
/**< returns false if fatal error and socket has been closed,
true if should try again. */
bool fatalError=false;
#ifdef WIN32
switch(WSAGetLastError())
{
case WSAENOBUFS:
case WSAEINPROGRESS:
case WSAEINTR:
case WSAEWOULDBLOCK:
case WSABASEERR:
fatalError=false;
break;
case WSANOTINITIALISED:
case WSAENETDOWN:
case WSAEFAULT:
case WSAENOTCONN:
case WSAENETRESET:
case WSAENOTSOCK:
case WSAEOPNOTSUPP:
case WSAESHUTDOWN:
case WSAEMSGSIZE:
case WSAEINVAL:
case WSAECONNABORTED:
case WSAETIMEDOUT:
case WSAECONNRESET:
default:
//fatal
fatalError=true;
Disconnect();
break;
}
#else //not WIN32
switch(errno)
{
case EWOULDBLOCK:
case EINTR:
case ETIMEDOUT:
case ENOBUFS:
//try later
fatalError=false;
break;
case EBADF:
case ECONNRESET:
case EFAULT:
case EINVAL:
case ENOTCONN:
case ENOTSOCK:
case EOPNOTSUPP:
case EPIPE:
case EIO:
case ENOMEM:
case ENOSR:
default:
//fatal
fatalError=true;
Disconnect();
break;
}
#endif
return fatalError;
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,157 +0,0 @@
#ifndef TCPCONNECTION_H
#define TCPCONNECTION_H
#include "TcpHandlers.h"
#include "TcpManager.h"
#include "IPAddress.h"
#include "TcpBlockAllocator.h"
#include "Clock.h"
#if defined(WIN32)
#include <winsock2.h>
typedef int socklen_t;
#else // for non-windows platforms (linux)
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
/**
* @brief Manages a single connection.
*/
class TcpConnection
{
public:
/**
* @brief The connection status.
*/
enum Status {
StatusNegotiating, /**< Currently attempting to connect. */
StatusConnected, /**< Currently connected. */
StatusDisconnected /**< Currently disconnected. */
};
/**
* @brief Sets the handler object which will receive callback methods.
*
* To have the TcpConnection call your object directly when packets are received, and when the
* connection is disconnected, you simply need to derive your class
* (multiply if necessary) from TcpConnectionHandler, then you can use
* this method to set the object the TcpConnection will call as appropriate.
* default = NULL (no callbacks made)
*
* @param handler The object which will be called for notifications.
*/
void SetHandler(TcpConnectionHandler *handler){ m_handler = handler; }
/**
* @brief Returns the handler associated with this object.
*/
TcpConnectionHandler *GetHandler(){ return m_handler; }
/**
* @brief Returns the current status of this connection.
*/
Status GetStatus(){ return m_status; }
/**
* @brief Queues a message to be sent on this connection.
*/
void Send(const char *data, unsigned dataLen);
/**
* @brief Disconnects and recycles the socket.
*
* @param notifyApplication primarily used internally, but when set to 'true', it will cause the application
* to be called back via the onTerminated handler due to this call (the callback will not occur if the connection was
* already disconnected)
*/
void Disconnect(bool notifyApplication=true);
/**
* @brief Returns the ip on the other side of this connection.
*/
IPAddress GetDestinationIp(){ return m_destIP; }
/**
* @brief Returns the port on the other side of this conection.
*/
short GetDestinationPort(){ return m_destPort; }
/**
* @brief Standard AddRef/Release scheme
*/
void AddRef();
/**
* @brief Standard AddRef/Release scheme
*/
void Release();
bool wasRemovedFromMgr() { return m_wasConRemovedFromMgr; }
void setRemovedFromMgr() { m_wasConRemovedFromMgr = true; }
protected:
friend class TcpManager;
TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, const IPAddress &destIP, short destPort, unsigned timeout);
int finishConnect();/**< returns < 0 if fatal error and connect will not work, =0 if need more time, >0 if connect completed */
TcpConnection(TcpManager *tcpManager, TcpBlockAllocator *sendAlloc, TcpManager::TcpParams &params, SOCKET socket, const IPAddress &destIP, short destPort);
TcpConnection *m_nextConnection; /**< Double linked list imp. */
TcpConnection *m_prevConnection; /**< Double linked list imp. */
SOCKET m_socket;
int processOutgoing();/**< returns < 0 if fatal error and socket has been closed, =0 if sent data, call again immediately if want to, >0 may have sent data, but calling again would do no good because there is either no more data to send, or would block. */
int processIncoming();/**< returns < 0 if fatal error and socket has been closed, =0 if read anything (full or partial message), >0 if nothing to read now, or would block so shouldn't try again immediately. */
TcpConnection *m_nextKeepAliveConnection; /**< Double linked list imp. */
TcpConnection *m_prevKeepAliveConnection; /**< Double linked list imp. */
int m_aliveListId;
TcpConnection *m_nextRecvDataConnection;
TcpConnection *m_prevRecvDataConnection;
int m_recvDataListId;
private:
~TcpConnection();
void setOptions();
TcpManager *m_manager;
bool translateRecvSocketEror();
Status m_status;
TcpConnectionHandler *m_handler;
IPAddress m_destIP;
short m_destPort;
unsigned m_refCount;
TcpBlockAllocator *m_sendAllocator;
data_block *m_head;
data_block *m_tail;
unsigned m_bytesRead;
unsigned m_bytesNeeded;
TcpManager::TcpParams m_params;
char *m_recvBuff;
sockaddr_in m_addr;
unsigned m_connectTimeout;
Clock m_connectTimer;
bool m_wasConRemovedFromMgr;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //TCPCONNECTION_H
@@ -1,50 +0,0 @@
#ifndef TCPHANDLERS_H
#define TCPHANDLERS_H
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
class TcpConnection;
/**
* @brief Interface used by TcpManager class for notification to application of connection state/etc.
*
* Note: these callbacks will only be made when during a call to TcpManager::giveTime.
*/
class TcpManagerHandler
{
public:
/**
* @brief Callback made when a new connection has been established by the manager.
*/
virtual void OnConnectRequest(TcpConnection *con)=0;
};
/**
* @brief Interface used by TcpConnection class for notification to application of connection state/etc.
*
* Note: these callbacks will only be made when during a call to TcpManager::giveTime.
*/
class TcpConnectionHandler
{
public:
/**
* @brief Callback made when a new message has been received on the specified connection.
*/
virtual void OnRoutePacket(TcpConnection *con, const unsigned char *data, int dataLen)=0;
/**
* @brief Callback made when the specified connection has closed, or been closed.
*/
virtual void OnTerminated(TcpConnection *con)=0;
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //TCPHANDLERS_H
@@ -1,734 +0,0 @@
#include "TcpManager.h"
#include <assert.h>
#include "IPAddress.h"
#include "TcpConnection.h"
#ifndef WIN32
#include <sys/poll.h>
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
TcpManager::TcpParams::TcpParams()
: port(0),
maxConnections(10),
incomingBufferSize(64*1024),
outgoingBufferSize(64*1024),
allocatorBlockSize(8*1024),
allocatorBlockCount(16),
maxRecvMessageSize(0),
keepAliveDelay(0),
noDataTimeout(0)
{
memset(bindAddress, 0, sizeof(bindAddress));
}
TcpManager::TcpParams::TcpParams(const TcpParams &cpy)
: port(cpy.port),
maxConnections(cpy.maxConnections),
incomingBufferSize(cpy.incomingBufferSize),
outgoingBufferSize(cpy.outgoingBufferSize),
allocatorBlockSize(cpy.allocatorBlockSize),
allocatorBlockCount(cpy.allocatorBlockCount),
maxRecvMessageSize(cpy.maxRecvMessageSize),
keepAliveDelay(cpy.keepAliveDelay),
noDataTimeout(cpy.noDataTimeout)
{
}
TcpManager::TcpManager(const TcpParams &params)
: m_handler(NULL),
m_keepAliveList(NULL, 1),
m_aliveList(NULL, 2),
m_noDataList(NULL, 1),
m_dataList(NULL, 2),
m_params(params),
m_refCount(1),
m_connectionList(NULL),
m_connectionListCount(0),
m_socket(INVALID_SOCKET),
m_boundAsServer(false),
m_allocator(params.allocatorBlockSize, params.allocatorBlockCount),
m_keepAliveTimer(),
m_noDataTimer()
{
if (params.keepAliveDelay > 0)
m_keepAliveTimer.start();
if (params.noDataTimeout > 0)
m_noDataTimer.start();
#if defined(WIN32)
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1), &wsaData);
FD_ZERO(&m_permfds);//select only used on win32
#endif
}
TcpManager::~TcpManager()
{
#if defined(WIN32)
WSACleanup();
#endif
if (m_boundAsServer)
{
#if defined(WIN32)
closesocket(m_socket);
#else
close(m_socket);
#endif
}
while (m_connectionList != NULL)
{
TcpConnection *con = m_connectionList;
m_connectionList = m_connectionList->m_nextConnection;
con->Release();
m_connectionListCount--;
}
}
bool TcpManager::BindAsServer()
{
m_socket = socket(AF_INET, SOCK_STREAM, 0);
if (m_socket != INVALID_SOCKET)
{
#if defined(WIN32)
FD_SET(m_socket, &m_permfds);//the socket this server is listening on
unsigned long isNonBlocking = 1;
int outBufSize = m_params.outgoingBufferSize;
int inBufSize = m_params.incomingBufferSize;
int keepAlive = 1;
int reuseAddr = 1;
struct linger ld;
ld.l_onoff = 0;
ld.l_linger = 0;
if (ioctlsocket(m_socket, FIONBIO, &isNonBlocking) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_SNDBUF, (char *)&outBufSize, sizeof(outBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, (char *)&inBufSize, sizeof(inBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&keepAlive, sizeof(keepAlive)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuseAddr, sizeof(reuseAddr)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_LINGER, (char *)&ld, sizeof(ld)) != 0 )
{
return false;
}
#else // linux is to remain the default compile mode
unsigned long isNonBlocking = 1;
unsigned long keepAlive = 1;
unsigned long outBufSize = m_params.outgoingBufferSize;
unsigned long inBufSize = m_params.incomingBufferSize;
unsigned long reuseAddr = 1;
struct linger ld;
ld.l_onoff = 0;
ld.l_linger = 0;
if (ioctl(m_socket, FIONBIO, &isNonBlocking) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_SNDBUF, &outBufSize, sizeof(outBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, &inBufSize, sizeof(inBufSize)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, &keepAlive, sizeof(keepAlive)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) != 0
|| setsockopt(m_socket, SOL_SOCKET, SO_LINGER, &ld, sizeof(ld)) != 0)
{
return false;
}
#endif
}
else
{
return false;
}
struct sockaddr_in addr_loc;
addr_loc.sin_family = AF_INET;
addr_loc.sin_port = htons(m_params.port);
addr_loc.sin_addr.s_addr = htonl(INADDR_ANY);
if (m_params.bindAddress[0] != 0)
{
unsigned long address = inet_addr(m_params.bindAddress);
if (address == INADDR_NONE)
{
struct hostent * lphp;
lphp = gethostbyname(m_params.bindAddress);
if (lphp != NULL)
addr_loc.sin_addr.s_addr = ((struct in_addr *)(lphp->h_addr))->s_addr;
}
else
{
addr_loc.sin_addr.s_addr = address;
}
}
if (bind(m_socket, (struct sockaddr *)&addr_loc, sizeof(addr_loc)) != 0)
{
return false;
}
if (listen(m_socket, 1000) != 0)
{
return false;
}
m_boundAsServer = true;
return true;
}
TcpConnection *TcpManager::acceptClient()
{
TcpConnection *newConn = NULL;
if (m_boundAsServer && m_connectionListCount < m_params.maxConnections)
{
sockaddr_in addr;
int addrLength = sizeof(addr);
SOCKET sock = ::accept(m_socket, (sockaddr *) &addr, (socklen_t *) &addrLength);
if (sock != INVALID_SOCKET)
{
newConn = new TcpConnection(this, &m_allocator, m_params, sock, IPAddress(addr.sin_addr.s_addr), ntohs(addr.sin_port));
addNewConnection(newConn);
if (m_handler != NULL)
{
m_handler->OnConnectRequest(newConn);
}
}
}
return newConn;
}
void TcpManager::SetHandler(TcpManagerHandler *handler)
{
m_handler = handler;
}
SOCKET TcpManager::getMaxFD()
{
#ifdef WIN32
return 0;//this param is not used on win32 for select, only on unix
#else
SOCKET maxfd = 0;
if (m_boundAsServer)
maxfd = m_socket+1;
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
{
next = con->m_nextConnection;
if (con->GetStatus() != TcpConnection::StatusDisconnected && con->m_socket > maxfd)
{
maxfd = con->m_socket + 1;
}
}
return maxfd;
#endif
}
TcpConnection *TcpManager::getConnection(SOCKET fd)
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
{
next = con->m_nextConnection;
if (con->m_socket == fd)
{
return con;
}
}
//if get here ,couldn't find it
return NULL;
}
bool TcpManager::GiveTime(unsigned maxTimeAcceptingConnections,unsigned maxSendTimePerConnection, unsigned maxRecvTimePerConnection)
{
bool processedIncoming = false;
if (maxTimeAcceptingConnections == 0 && maxSendTimePerConnection==0 && maxRecvTimePerConnection==0)
{
//they don't want to do anything now
return processedIncoming;
}
AddRef(); //keep a reference to ourself in case we callback to the application and the application releases us.
//first process outgoing on each connection, and finish establishing connections, if params say to
if (m_connectionListCount != 0 && maxSendTimePerConnection != 0)
{
// Send output from last heartbeat
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
{
con->AddRef();
if (next) next->Release();
next = con->m_nextConnection;
if (next) next->AddRef();
if(con->GetStatus() == TcpConnection::StatusConnected)
{
Clock timer;
timer.start();
while(!timer.isDone(maxSendTimePerConnection))
{
int err = con->processOutgoing();
if (err > 0)
{
//couldn't finish processing last request, don't try more
break;
}
else if (err < 0)
{
break;
}
}
con->Release();
}
else if (con->GetStatus() == TcpConnection::StatusNegotiating)
{
if (con->finishConnect() < 0)
{
con->Release();
continue;
}
con->Release();
}
else //inactive client in client list????
{
removeConnection(con);
con->Release();
continue;
}
}
}
//process incoming messages (including connect requests)
if ((
m_boundAsServer //if in server mode and want to spend time accepting clients
&& maxTimeAcceptingConnections != 0
)
||
(
m_connectionListCount != 0 //if there are connections and want to spend time receiving on them
&& maxRecvTimePerConnection != 0
)
)
{
#ifdef WIN32
SOCKET maxfd = getMaxFD(); //re-calc maxfd every time select on WIN32
//select on all fd's
struct timeval timeout;
fd_set tmpfds;
tmpfds = m_permfds;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
int cnt = select(maxfd, &tmpfds, NULL, NULL, &timeout); // blocks for timeout
if (cnt > 0)
{
if (m_boundAsServer && maxTimeAcceptingConnections != 0)
{//activity on our socket means connect requests
//see if are new incoming clients
if (FD_ISSET(m_socket, &tmpfds))
{
//yep
Clock timer;
timer.start();
while (acceptClient() && !timer.isDone(maxTimeAcceptingConnections))
{
//loop
}
}
}
//process incoming client messages
if (maxRecvTimePerConnection != 0)
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next)
{
con->AddRef();
if (next) next->Release();
next = con->m_nextConnection;
if (next) next->AddRef();
SOCKET fd = con->m_socket;
if (fd == INVALID_SOCKET)
{
//invalid socket in list?, check if is connecting, otherwise, Disconnect and discard
if (con->GetStatus() != TcpConnection::StatusNegotiating)
{
removeConnection(con);
con->Release();
continue;
}
}
if (FD_ISSET(fd, &tmpfds))
{
Clock timer;
timer.start();
while(!timer.isDone(maxRecvTimePerConnection) && con->GetStatus() == TcpConnection::StatusConnected)
{
int err = con->processIncoming();
if (err >= 0)
{
processedIncoming = true;
}
if (err > 0)
{
//couldn't finish processing last request, don't try more
break;
}
else if (err < 0)
{
break;
}
}//while(!timer...)
}//if (FD_ISSET...)
con->Release();
}//for (...)
} //maxRecvTimePerConnection != 0
}//cnt > 0
#else //on UNIX use poll
int numfds = m_connectionListCount;
int idx = 0;
if (m_boundAsServer)
{
numfds++;
idx++;
}
struct pollfd pollfds[numfds];
if (m_boundAsServer)
{
pollfds[0].fd = m_socket;
pollfds[0].events |= POLLIN;
}
TcpConnection *next = NULL;
for (TcpConnection *con = m_connectionList ; con != NULL ; con = next, idx++)
{
next = con->m_nextConnection;
pollfds[idx].fd = con->m_socket;
pollfds[idx].events |= POLLIN;
pollfds[idx].events |= POLLHUP;
}
int cnt = poll(pollfds, numfds, 1);
if(cnt == SOCKET_ERROR)
{
//poll not working?
//TODO: need to notify client somehow, don't think we can assume a fatal error here
}
else if (cnt > 0)
{
for (idx = 0; idx < numfds; idx++)
{
//find corresponding TcpConnection
//TODO: optimize, seriously, this is takes linear time, every time
TcpConnection *con = getConnection(pollfds[idx].fd);
if (pollfds[idx].revents & POLLIN)
{
if (m_boundAsServer && maxTimeAcceptingConnections != 0 && pollfds[idx].fd == m_socket)
{
//new incoming clients
Clock timer;
timer.start();
while (acceptClient() && !timer.isDone(maxTimeAcceptingConnections))
{
//loop
}
continue;//don't try to readmsgs from listening fd
}
//process regular msg(s)
if (con == NULL)
{
close(pollfds[idx].fd);
continue;
}
Clock timer;
timer.start();
con->AddRef();//so it can't get deleted while we are checking it's status
while(!timer.isDone(maxRecvTimePerConnection) && con->GetStatus() == TcpConnection::StatusConnected)
{
int err = con->processIncoming();
if (err >= 0)
{
processedIncoming = true;
}
if (err > 0)
{
//couldn't finish processing last request, don't try more
break;
}
else if (err < 0)
{
break;
}
}//while(!timer....)
con->Release();
}//if(pollfds[...
else if (pollfds[idx].revents & POLLHUP)
{
if (con == NULL)
{
close(pollfds[idx].fd);
continue;
}
//Disconnect client
con->Disconnect();
}
}//for (idx=0....
}//else if (cnt > 0)
#endif
}//wanted to process incoming messages or connect requests
//now process any keepalives, if time to do that
if (m_params.keepAliveDelay > 0 && m_keepAliveTimer.isDone(m_params.keepAliveDelay))
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_keepAliveList.m_beginList ; con != NULL ; con = next)
{
con->AddRef();
if (next) next->Release();
next = con->m_nextKeepAliveConnection;
if (next) next->AddRef();
con->Send(NULL, 0); //note: this request will move the connection from the keepAliveList to the aliveList
con->Release();
}
//now move the complete alive list over to the keepalive list to reset those timers
m_keepAliveList.m_beginList = m_aliveList.m_beginList;
m_aliveList.m_beginList = NULL;
//switch id's for those connections that were in the alive list last go - around
int tmpID = m_aliveList.m_listID;
m_aliveList.m_listID = m_keepAliveList.m_listID;
m_keepAliveList.m_listID = tmpID;
m_keepAliveTimer.reset();
m_keepAliveTimer.start();
}
//now process any noDataCons, if time to do that
if (m_params.noDataTimeout > 0 && m_noDataTimer.isDone(m_params.noDataTimeout))
{
TcpConnection *next = NULL;
for (TcpConnection *con = m_noDataList.m_beginList ; con != NULL ; con = next)
{
con->AddRef();
if (next) next->Release();
next = con->m_nextRecvDataConnection;
if (next) next->AddRef();
//time to disconnect this guy
con->Disconnect();
con->Release();
}
//now move the complete data list over to the nodata list to reset those timers
m_noDataList.m_beginList = m_dataList.m_beginList;
m_dataList.m_beginList = NULL;
//switch id's for those connections that were in the data list last go - around
int tmpID = m_dataList.m_listID;
m_dataList.m_listID = m_noDataList.m_listID;
m_noDataList.m_listID = tmpID;
m_noDataTimer.reset();
m_noDataTimer.start();
}
Release();
return processedIncoming;
}
TcpConnection *TcpManager::EstablishConnection(const char *serverAddress, unsigned short serverPort, unsigned timeout)
{
if (m_boundAsServer)
{
//can't open outgoing connections when in server mode
// use a different TcpManager to do that
return NULL;
}
if (m_connectionListCount >= m_params.maxConnections)
return(NULL);
// get server address
unsigned long address = inet_addr(serverAddress);
if (address == INADDR_NONE)
{
struct hostent * lphp;
lphp = gethostbyname(serverAddress);
if (lphp == NULL)
return(NULL);
address = ((struct in_addr *)(lphp->h_addr))->s_addr;
}
IPAddress destIP(address);
TcpConnection *con = new TcpConnection(this, &m_allocator, m_params, destIP, serverPort, timeout);
con->AddRef();//for the client - to conform to UdpLibrary method
addNewConnection(con);
return con;
}
void TcpManager::addNewConnection(TcpConnection *con)
{
con->AddRef();
#ifdef WIN32 //uses select
if (con->m_socket != INVALID_SOCKET)
FD_SET(con->m_socket, &m_permfds);
#endif
con->m_nextConnection = m_connectionList;
con->m_prevConnection = NULL;
if (m_connectionList != NULL)
m_connectionList->m_prevConnection = con;
m_connectionList = con;
m_connectionListCount++;
con->m_nextKeepAliveConnection = m_aliveList.m_beginList;
con->m_prevKeepAliveConnection = NULL;
if (m_aliveList.m_beginList != NULL)
m_aliveList.m_beginList->m_prevKeepAliveConnection = con;
m_aliveList.m_beginList = con;
con->m_aliveListId = m_keepAliveList.m_listID;//start it out thinking it's already in the alive list, since it is
con->m_nextRecvDataConnection = m_dataList.m_beginList;
con->m_prevRecvDataConnection = NULL;
if (m_dataList.m_beginList != NULL)
m_dataList.m_beginList->m_prevRecvDataConnection = con;
m_dataList.m_beginList = con;
con->m_recvDataListId = m_noDataList.m_listID;//start it out thinking it's already in the data list, since it is
}
void TcpManager::removeConnection(TcpConnection *con)
{
if (!con->wasRemovedFromMgr())
{
con->setRemovedFromMgr();
m_connectionListCount--;
#ifdef WIN32 //select only used on win32
if (con->m_socket != INVALID_SOCKET)
{
FD_CLR(con->m_socket, &m_permfds);
}
#endif
if (con->m_prevConnection != NULL)
con->m_prevConnection->m_nextConnection = con->m_nextConnection;
if (con->m_nextConnection != NULL)
con->m_nextConnection->m_prevConnection = con->m_prevConnection;
if (m_connectionList == con)
m_connectionList = con->m_nextConnection;
con->m_nextConnection = NULL;
con->m_prevConnection = NULL;
if (con->m_prevKeepAliveConnection != NULL)
con->m_prevKeepAliveConnection->m_nextKeepAliveConnection = con->m_nextKeepAliveConnection;
if (con->m_nextKeepAliveConnection != NULL)
con->m_nextKeepAliveConnection->m_prevKeepAliveConnection = con->m_prevKeepAliveConnection;
if (m_aliveList.m_beginList == con)
m_aliveList.m_beginList = con->m_nextKeepAliveConnection;
else if (m_keepAliveList.m_beginList == con)
m_keepAliveList.m_beginList = con->m_nextKeepAliveConnection;
con->m_nextKeepAliveConnection = NULL;
con->m_prevKeepAliveConnection = NULL;
if (con->m_prevRecvDataConnection != NULL)
con->m_prevRecvDataConnection->m_nextRecvDataConnection = con->m_nextRecvDataConnection;
if (con->m_nextRecvDataConnection != NULL)
con->m_nextRecvDataConnection->m_prevRecvDataConnection = con->m_prevRecvDataConnection;
if (m_dataList.m_beginList == con)
m_dataList.m_beginList = con->m_nextRecvDataConnection;
else if (m_noDataList.m_beginList == con)
m_noDataList.m_beginList = con->m_nextRecvDataConnection;
con->m_nextRecvDataConnection = NULL;
con->m_prevRecvDataConnection = NULL;
con->Release();
}
}
void TcpManager::AddRef()
{
m_refCount++;
}
void TcpManager::Release()
{
if (--m_refCount == 0)
delete this;
}
IPAddress TcpManager::GetLocalIp() const
{
struct sockaddr_in addr_self;
memset(&addr_self, 0, sizeof(addr_self));
socklen_t len = sizeof(addr_self);
getsockname(m_socket, (struct sockaddr *)&addr_self, &len);
return(IPAddress(addr_self.sin_addr.s_addr));
}
unsigned int TcpManager::GetLocalPort() const
{
struct sockaddr_in addr_self;
memset(&addr_self, 0, sizeof(addr_self));
socklen_t len = sizeof(addr_self);
getsockname(m_socket, (struct sockaddr *)&addr_self, &len);
return(ntohs(addr_self.sin_port));
}
#ifdef EXTERNAL_DISTRO
};
#endif
@@ -1,287 +0,0 @@
#ifndef TCPMANAGER_H
#define TCPMANAGER_H
#include "TcpHandlers.h"
#include "TcpBlockAllocator.h"
#include "IPAddress.h"
#include "Clock.h"
#if defined(WIN32)
#include <winsock2.h>
typedef int socklen_t;
#else // for non-windows platforms (linux)
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
const int INVALID_SOCKET = 0xFFFFFFFF;
const int SOCKET_ERROR = 0xFFFFFFFF;
typedef int SOCKET;
#endif
#ifdef EXTERNAL_DISTRO
namespace NAMESPACE
{
#endif
class TcpConnection;
struct ConnectionList
{
ConnectionList(TcpConnection *con, int id) : m_beginList(con), m_listID(id) {}
TcpConnection *m_beginList;
int m_listID;
};
/**
* @brief The purpose of the TcpManager is to manage a set of connections that are coming in on a particular port.
*
*/
class TcpManager
{
public:
/** @brief Parameters for the TcpManager. */
struct TcpParams
{
/** @brief Simple constructor sets default values for members. */
TcpParams();
/** @brief Simple copy constructor. */
TcpParams(const TcpParams &cpy);
/**
* @brief Connection port number.
*
* this is the port number that this manager will use for all incoming and outgoing data. On the client side
* this is typically set to 0, which causes the manager object to randomly pick an available port. On the server
* side, this port should be set to a specific value as it will represent the port number that clients will use
* to connect to the server (ie. the listening port). It's generally a good idea to give the user on the client
* side the option of fixing this port number at a specific value as well as it is often necessary for them to
* do so in order to navigate company firewalls which may have specific port numbers open to them for this purpose.
* default = 0
*/
unsigned short port;
/**
* @ brief Server bind ip.
*
*/
char bindAddress[64];
/**
* @brief Maximum number of connections that can be established by this manager.
*
* this is the maximum number of connections that can be established by this manager, any incoming/outgoing connections
* over this limit will be refused. On the client side, this typically only needs to be set to 1, though there
* is little harm in setting this number larger.
* default = 10
*/
unsigned maxConnections;
/**
* @brief The size of the incoming socket buffer.
*
* The client will want to set this fairly small (32k or so), but the server
* will want to set this fairly large (512k)
* default = 64k
*/
unsigned incomingBufferSize;
/**
* @brief The size of the outgoing socket buffer.
*
* The client will want to set this fairly small (32k or so), but the server
* will want to set this fairly large (512k)
* default = 64k
*/
unsigned outgoingBufferSize;
/**
* @brief The block size of a single outgoing buffer memory allocator block.
*
* This param should allways be set at least as high as the maximum message size you
* expect to send (performance will suffer otherwise).
* default = 8K
*/
unsigned allocatorBlockSize;
/**
* @brief The number of block memory allocator 'blocks' created at a time.
*
* This is the number of blocks created for the buffer allocator for each
* TcpConnection opened by this manager. Since the block size should be
* the max size of an outgoing message, the recommended setting is: greater
* than the number of concurrent connections you expect to normally have open.
* default = 1024
*/
unsigned allocatorBlockCount;
/**
* @brief The maximum size that a recvd message is allowed to be.
*
* Really only here for protection, not required. If you set this, you can safeguard
* your client/server from receiving stray oversized messages. If a message on the socket
* specifies it's length at larger than this value, then the message is not read, and the connection
* is terminated. If the value is set to 0, then there is no max message size checking
* on incoming messages (this will also cary a performance hit, since every new message
* recieved will have to have a new buffer created if you don't specify a value here). Be careful
* not to set this too small, if you have messages that could exceed the value you set here
* they will be discarded, and the connection will be terminated without warning.
* default = 0
*/
unsigned maxRecvMessageSize;
unsigned keepAliveDelay;
unsigned noDataTimeout;
};
/**
* @brief
*/
TcpManager(const TcpParams &params);
/**
* @brief Use to specify a handler object to receive callbacks.
*
* To have the TcpManager call your object directly when connection requests come in, you
* simply need to derive your class (multiply if necessary) from TcpManagerHandler, then you can use
* this method to set the object the TcpManager will call as appropriate. The TcpConnection object
* also has a handler mechanism that replaces the other callback functions below, see TcpConnection::SetHandler
* default = NULL (no callbacks made)
*
* @param handler The object which will be called for manager related notifications.
*/
void SetHandler(TcpManagerHandler *handler);
/**
* @brief This function MUST be called on a regular basis in order to give the manager object time to service the socket and give time to various connection objects that may need processing time, etc.
*
* @param maxTimeAcceptingConnections The max amount of time in milliseconds to spend accepting new client connections.
* This parameter is only used if this manager has been bound as a server (bindAsServer).
* If you set this param to 0, it will not attempt to accept any new connections.
*
* @param giveConnectionsTime
* True if every connection opened on this manager is given time in this call, false if
* no connections are given time.
*
* @param maxSendTimePerConnection Max amount of time in milliseconds to spend on each client processing outgoing messages.
* A max of the specified amount of time will be spent on each and every individual connection. If you set
* this parametrer to 0, it will not process any outgoing messages on any clients. Note also that when attempting
* to establish new connections (via the EstablishConnection method), this parameter must be > 0 in order to
* complete the connection process for any connections that were still negotiating.
*
* @param maxRecvTimePerConnection Max amount of time in milliseconds to spend on each client processing incoming messages.
* A max of the specified amount of time will be spent on each and every individual connection. If you set
* this param to 0, it will not process any incoming messages on any clients.
* This is a good way to give the manager processing time for outgoing packets in situations
* where the application does not want to have to worry about processing incoming packets.
*
* @return true if any incoming packets were processed during this time slice, otherwise returns false
*/
bool GiveTime(unsigned maxTimeAcceptingConnections = 5, unsigned maxSendTimePerConnection = 5, unsigned maxRecvTimePerConnection = 5);
/**
* @brief Used to establish a connection to a server that is listening at the specified address and port.
*
* The serverAddress will do a DNS lookup as appropriate. This call will block long enough to resolve
* the DNS lookup, but then will return a TcpConnection object that will be in a StatusNegotiating
* state until the connection is actually established. The application must give the manager
* object time after calling EstablishConnection or else the negotiation process to establish the
* connection will never have time to actually occur. Typically the client establishing the connection
* will call EstablishConnection, then sit in a loop calling TcpManager::GiveTime and checking to see
* if the status of the returned TcpConnection object is changed from StatusNegotiating. This allows
* the application to look for the ESC key or timeout an attempted connection.
*
* @param serverAddress The address of the server to open a connection to.
*
* @param serverPort The port of the server to open a connection to.
*
* @param timeout How long to attempt connecting to the server (in milliseconds).
* Setting the timeout value to something greater than 0 will cause the TcpConnection object to change
* from a StatusNegotiating state to a StatusDisconnected state after the timeout has expired. It will also cause
* the connect-complete callback to be called if the connection is succesfull.
*
* @return A pointer to a TcpConnection object.
* NULL if the manager object has exceeded its maximum number of connections
* or if the serverAddress cannot be resolved to an IP address.
*/
TcpConnection *EstablishConnection(const char *serverAddress, unsigned short serverPort, unsigned timeout = 0);
/**
* @brief Binds this manager as a server which will listen for and accept incoming connections.
*
* @return 'true' if manager is able to bind succesfully, false otherwise.
*/
bool BindAsServer();
/**
* @brief Standard AddRef/Release scheme
*/
void AddRef();
/**
* @brief Standard AddRef/Release scheme
*/
void Release();
/**
* @brief Returns the ip address of this machine. If the machine is multi-homed, this value may be blank.
*/
IPAddress GetLocalIp() const;
/**
* @brief Returns the port the manager is actually using. This value will be the same as is specified in
* Params::port (or if Params::port was set to 0, this will be the dynamically assigned port number)
*/
unsigned int GetLocalPort() const;
protected:
friend class TcpConnection;
void removeConnection(TcpConnection *con);
TcpManagerHandler *m_handler;
ConnectionList m_keepAliveList;
ConnectionList m_aliveList;
ConnectionList m_noDataList;
ConnectionList m_dataList;
private:
~TcpManager();
TcpParams m_params;
int m_refCount;
TcpConnection *m_connectionList;
unsigned m_connectionListCount;
#ifdef WIN32
fd_set m_permfds; /**< Used for select on WIN32 if we are in server mode. Keeps track of all clients connected to us. */
#endif //WIN32
SOCKET m_socket;
bool m_boundAsServer;
TcpBlockAllocator m_allocator;
Clock m_keepAliveTimer;
Clock m_noDataTimer;
void addNewConnection(TcpConnection *con);
SOCKET getMaxFD();
TcpConnection *getConnection(SOCKET fd);
TcpConnection *acceptClient();
};
#ifdef EXTERNAL_DISTRO
};
#endif
#endif //TCPMANAGER_H
@@ -1,472 +0,0 @@
/* version: 1.0, Feb, 2003
Author : Gao Dasheng
Copyright (C) 1995-2002 Gao Dasheng([email protected])
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. 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.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
//////////////////////////////////////////////////////////////////////////////
Introduce:
This file includes two classes CA2GZIP and CGZIP2A which do compressing and
uncompressing in memory. and It 's very easy to use for small data compressing.
Some compress and uncompress codes came from gzip unzip function of zlib 1.1.x.
Usage:
these two classes work used with zlib 1.1.x (http://www.gzip.org/zlib/).
They were tested in Window OS.
Exmaple:
#include "GZipHelper.h"
void main()
{
char plainText[]="Plain text here";
CA2GZIP gzip(plainText,strlen(plainText)); // do compressing here;
LPGZIP pgzip=gzip.pgzip; // pgzip is zipped data pointer, you can use it directly
int len=gzip.Length; // Length is length of zipped data;
CGZIP2A plain(pgzip,len); // do decompressing here
char *pplain=plain.psz; // psz is plain data pointer
int aLen=plain.Length; // Length is length of unzipped data.
}
//////////////////////////////////////////////////////////////////////////////
*/
#ifndef __GZipHelper__
#define __GZipHelper__
#include "Zip/zutil.h"
#define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);}
#define Z_BUFSIZE 4096
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define RESERVED 0xE0 /* bits 5..7: reserved */
typedef unsigned char GZIP;
typedef GZIP* LPGZIP;
static const int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
template< int t_nBufferLength = 1024 ,int t_nLevel=Z_DEFAULT_COMPRESSION,int t_nStrategy=Z_DEFAULT_STRATEGY>
class CA2GZIPT
{
public:
LPGZIP pgzip;
int Length;
public:
CA2GZIPT(char* lpsz,int len=-1):pgzip(0),Length(0)
{
Init(lpsz,len);
}
~CA2GZIPT()
{
if(pgzip!=m_buffer) TRYFREE(pgzip);
}
void Init(char *lpsz,int len=-1)
{
if(lpsz==0)
{
pgzip=0;
Length=0;
return ;
}
if(len==-1)
{
len=(int)strlen(lpsz);
}
m_CurrentBufferSize=t_nBufferLength;
pgzip=m_buffer;
m_zstream.zalloc = (alloc_func)0;
m_zstream.zfree = (free_func)0;
m_zstream.opaque = (voidpf)0;
m_zstream.next_in = Z_NULL;
m_zstream.next_out = Z_NULL;
m_zstream.avail_in = 0;
m_zstream.avail_out = 0;
m_z_err = Z_OK;
m_crc = crc32(0L, Z_NULL, 0);
int err = deflateInit2(&(m_zstream), t_nLevel,Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, t_nStrategy);
m_outbuf = (Byte*)ALLOC(Z_BUFSIZE);
m_zstream.next_out = m_outbuf;
if (err != Z_OK || m_outbuf == Z_NULL)
{
destroy();
return ;
}
m_zstream.avail_out = Z_BUFSIZE;
GZIP header[10]={0x1f,0x8b,Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE};
write(header,10);
m_zstream.next_in = (Bytef*)lpsz;
m_zstream.avail_in = len;
while (m_zstream.avail_in != 0)
{
if (m_zstream.avail_out == 0)
{
m_zstream.next_out = m_outbuf;
this->write(m_outbuf,Z_BUFSIZE);
m_zstream.avail_out = Z_BUFSIZE;
}
m_z_err = deflate(&m_zstream,Z_NO_FLUSH);
if (m_z_err != Z_OK) break;
}
m_crc = crc32(m_crc, (const Bytef *)lpsz, len);
if (finish() != Z_OK) { destroy(); return ;}
putLong(m_crc);
putLong (m_zstream.total_in);
destroy();
}
private:
GZIP m_buffer[t_nBufferLength];
int m_CurrentBufferSize;
z_stream m_zstream;
int m_z_err; /* error code for last stream operation */
Byte *m_outbuf; /* output buffer */
uLong m_crc; /* crc32 of uncompressed data */
int write(LPGZIP buf,int count)
{
if(buf==0) return 0;
if(Length+count>m_CurrentBufferSize)
{
int nTimes=(Length+count)/t_nBufferLength +1;
LPGZIP pTemp=pgzip;
pgzip=static_cast<LPGZIP>( malloc(nTimes*t_nBufferLength));
m_CurrentBufferSize=nTimes*t_nBufferLength;
memcpy(pgzip,pTemp,Length);
if(pTemp!=m_buffer) free(pTemp);
}
memcpy(pgzip+Length,buf,count);
Length+=count;
return count;
}
int finish()
{
uInt len;
int done = 0;
m_zstream.avail_in = 0;
for (;;)
{
len = Z_BUFSIZE - m_zstream.avail_out;
if (len != 0)
{
write(m_outbuf,len);
m_zstream.next_out = m_outbuf;
m_zstream.avail_out = Z_BUFSIZE;
}
if (done) break;
m_z_err = deflate(&(m_zstream), Z_FINISH);
if (len == 0 && m_z_err == Z_BUF_ERROR) m_z_err = Z_OK;
done = (m_zstream.avail_out != 0 || m_z_err == Z_STREAM_END);
if (m_z_err != Z_OK && m_z_err != Z_STREAM_END) break;
}
return m_z_err == Z_STREAM_END ? Z_OK : m_z_err;
}
int destroy()
{
int err = Z_OK;
if (m_zstream.state != NULL) {
err = deflateEnd(&(m_zstream));
}
if (m_z_err < 0) err = m_z_err;
TRYFREE(m_outbuf);
return err;
}
void putLong (uLong x)
{
for(int n = 0; n < 4; n++) {
unsigned char c=(unsigned char)(x & 0xff);
write(&c,1);
x >>= 8;
}
}
};
typedef CA2GZIPT<10> CA2GZIP;
template< int t_nBufferLength = 1024>
class CGZIP2AT
{
public:
char *psz;
int Length;
CGZIP2AT(LPGZIP pgzip,int len):m_gzip(pgzip),m_gziplen(len),psz(0),Length(0),m_pos(0)
{
Init();
}
~CGZIP2AT()
{
if(psz!=m_buffer) TRYFREE(psz);
}
void Init()
{
if(m_gzip==0)
{
psz=0;
Length=0;
return ;
}
m_CurrentBufferSize=t_nBufferLength;
psz=m_buffer;
memset(psz,0,m_CurrentBufferSize+1);
m_zstream.zalloc = (alloc_func)0;
m_zstream.zfree = (free_func)0;
m_zstream.opaque = (voidpf)0;
m_zstream.next_in = m_inbuf = Z_NULL;
m_zstream.next_out = Z_NULL;
m_zstream.avail_in = m_zstream.avail_out = 0;
m_z_err = Z_OK;
m_z_eof = 0;
m_transparent = 0;
m_crc = crc32(0L, Z_NULL, 0);
m_zstream.next_in =m_inbuf = (Byte*)ALLOC(Z_BUFSIZE);
int err = inflateInit2(&(m_zstream), -MAX_WBITS);
if (err != Z_OK || m_inbuf == Z_NULL)
{
destroy();
return;
}
m_zstream.avail_out = Z_BUFSIZE;
check_header();
char outbuf[Z_BUFSIZE];
int nRead;
while(true)
{
nRead=gzread(outbuf,Z_BUFSIZE);
if(nRead<=0) break;
write(outbuf,nRead);
}
destroy();
}
private:
char m_buffer[t_nBufferLength+1];
int m_CurrentBufferSize;
z_stream m_zstream;
int m_z_err; /* error code for last stream operation */
Byte *m_inbuf; /* output buffer */
uLong m_crc; /* crc32 of uncompressed data */
int m_z_eof;
int m_transparent;
int m_pos;
LPGZIP m_gzip;
int m_gziplen;
void check_header()
{
int method; /* method byte */
int flags; /* flags byte */
uInt len;
int c;
/* Check the gzip magic header */
for (len = 0; len < 2; len++) {
c = get_byte();
if (c != gz_magic[len]) {
if (len != 0) m_zstream.avail_in++, m_zstream.next_in--;
if (c != EOF) {
m_zstream.avail_in++, m_zstream.next_in--;
m_transparent = 1;
}
m_z_err =m_zstream.avail_in != 0 ? Z_OK : Z_STREAM_END;
return;
}
}
method = get_byte();
flags = get_byte();
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
m_z_err = Z_DATA_ERROR;
return;
}
/* Discard time, xflags and OS code: */
for (len = 0; len < 6; len++) (void)get_byte();
if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
len = (uInt)get_byte();
len += ((uInt)get_byte())<<8;
/* len is garbage if EOF but the loop below will quit anyway */
while (len-- != 0 && get_byte() != EOF) ;
}
if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
while ((c = get_byte()) != 0 && c != EOF) ;
}
if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
while ((c = get_byte()) != 0 && c != EOF) ;
}
if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
for (len = 0; len < 2; len++) (void)get_byte();
}
m_z_err = m_z_eof ? Z_DATA_ERROR : Z_OK;
}
int get_byte()
{
if (m_z_eof) return EOF;
if (m_zstream.avail_in == 0)
{
errno = 0;
m_zstream.avail_in =read(m_inbuf,Z_BUFSIZE);
if(m_zstream.avail_in == 0)
{
m_z_eof = 1;
return EOF;
}
m_zstream.next_in = m_inbuf;
}
m_zstream.avail_in--;
return *(m_zstream.next_in)++;
}
int read(LPGZIP buf,int size)
{
int nRead=size;
if(m_pos+size>=m_gziplen)
{
nRead=m_gziplen-m_pos;
}
if(nRead<=0) return 0;
memcpy(buf,m_gzip+m_pos,nRead);
m_pos+=nRead;
return nRead;
}
int gzread(char* buf,int len)
{
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
if (m_z_err == Z_DATA_ERROR || m_z_err == Z_ERRNO) return -1;
if (m_z_err == Z_STREAM_END) return 0; /* EOF */
next_out = (Byte*)buf;
m_zstream.next_out = (Bytef*)buf;
m_zstream.avail_out = len;
while (m_zstream.avail_out != 0) {
if (m_transparent)
{
/* Copy first the lookahead bytes: */
uInt n = m_zstream.avail_in;
if (n > m_zstream.avail_out) n = m_zstream.avail_out;
if (n > 0)
{
zmemcpy(m_zstream.next_out,m_zstream.next_in, n);
next_out += n;
m_zstream.next_out = next_out;
m_zstream.next_in += n;
m_zstream.avail_out -= n;
m_zstream.avail_in -= n;
}
if (m_zstream.avail_out > 0) {
m_zstream.avail_out -=read(next_out,m_zstream.avail_out);
}
len -= m_zstream.avail_out;
m_zstream.total_in += (uLong)len;
m_zstream.total_out += (uLong)len;
if (len == 0) m_z_eof = 1;
return (int)len;
}
if (m_zstream.avail_in == 0 && !m_z_eof)
{
errno = 0;
m_zstream.avail_in = read(m_inbuf,Z_BUFSIZE);
if (m_zstream.avail_in == 0)
{
m_z_eof = 1;
}
m_zstream.next_in = m_inbuf;
}
m_z_err = inflate(&(m_zstream), Z_NO_FLUSH);
if (m_z_err == Z_STREAM_END)
{
/* Check CRC and original size */
m_crc = crc32(m_crc, start, (uInt)(m_zstream.next_out - start));
start = m_zstream.next_out;
if (getLong() != m_crc) {
m_z_err = Z_DATA_ERROR;
}else
{
(void)getLong();
check_header();
if (m_z_err == Z_OK)
{
uLong total_in = m_zstream.total_in;
uLong total_out = m_zstream.total_out;
inflateReset(&(m_zstream));
m_zstream.total_in = total_in;
m_zstream.total_out = total_out;
m_crc = crc32(0L, Z_NULL, 0);
}
}
}
if (m_z_err != Z_OK || m_z_eof) break;
}
m_crc = crc32(m_crc, start, (uInt)(m_zstream.next_out - start));
return (int)(len - m_zstream.avail_out);
}
uLong getLong()
{
uLong x = (uLong)get_byte();
int c;
x += ((uLong)get_byte())<<8;
x += ((uLong)get_byte())<<16;
c = get_byte();
if (c == EOF) m_z_err = Z_DATA_ERROR;
x += ((uLong)c)<<24;
return x;
}
int write(char* buf,int count)
{
if(buf==0) return 0;
if(Length+count>m_CurrentBufferSize)
{
int nTimes=(Length+count)/t_nBufferLength +1;
char *pTemp=psz;
psz=static_cast<char*>( malloc(nTimes*t_nBufferLength+1));
m_CurrentBufferSize=nTimes*t_nBufferLength;
memset(psz,0,m_CurrentBufferSize+1);
memcpy(psz,pTemp,Length);
if(pTemp!=m_buffer) free(pTemp);
}
memcpy(psz+Length,buf,count);
Length+=count;
return count;
}
int destroy()
{
int err = Z_OK;
if (m_zstream.state != NULL) {
err = inflateEnd(&(m_zstream));
}
if (m_z_err < 0) err = m_z_err;
TRYFREE(m_inbuf);
return err;
}
};
typedef CGZIP2AT<> CGZIP2A;
#endif
@@ -1,6 +0,0 @@
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
SUBDIRS = Zip
AM_CFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,12 +0,0 @@
INCLUDES = -I$(top_srcdir)/external/3rd/library/platform \
-I$(platform_dir)/utils/Base/
METASOURCES = AUTO
libAuctionTransferGameAPIZip_la_LDFLAGS = -avoid-version
lib_LTLIBRARIES = libAuctionTransferGameAPIZip.la
libAuctionTransferGameAPIZip_la_SOURCES = adler32.c compress.c crc32.c deflate.c deflate.h gzio.c\
infblock.c infblock.h infcodes.c infcodes.h inffast.c inffast.h\
inffixed.h inflate.c inftrees.c inftrees.h infutil.c infutil.h\
maketree.c trees.c trees.h uncompr.c zconf.h zlib.h zutil.c zutil.h
AM_CXXFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
AM_CFLAGS = -DEXTERNAL_DISTRO -DNAMESPACE=AuctionTransfer -DUSE_TCP_LIBRARY
@@ -1,48 +0,0 @@
/* 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
*/
/* @(#) $Id$ */
#include "zlib.h"
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = (adler >> 16) & 0xffff;
int k;
if (buf == Z_NULL) return 1L;
while (len > 0) {
k = len < NMAX ? len : NMAX;
len -= k;
while (k >= 16) {
DO16(buf);
buf += 16;
k -= 16;
}
if (k != 0) do {
s1 += *buf++;
s2 += s1;
} while (--k);
s1 %= BASE;
s2 %= BASE;
}
return (s2 << 16) | s1;
}
@@ -1,68 +0,0 @@
/* 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
*/
/* @(#) $Id$ */
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err;
}
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
@@ -1,162 +0,0 @@
/* 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
*/
/* @(#) $Id$ */
#include "zlib.h"
#define local static
#ifdef DYNAMIC_CRC_TABLE
local int crc_table_empty = 1;
local uLongf crc_table[256];
local void make_crc_table OF((void));
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The table is simply the CRC of all possible eight bit values. This is all
the information needed to generate CRC's on data a byte at a time for all
combinations of CRC register values and incoming bytes.
*/
local void make_crc_table()
{
uLong c;
int n, k;
uLong poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320L) */
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;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[n] = c;
}
crc_table_empty = 0;
}
#else
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
local const uLongf crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
#endif
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
const uLongf * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) make_crc_table();
#endif
return (const uLongf *)crc_table;
}
/* ========================================================================= */
#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO2(buf) DO1(buf); DO1(buf);
#define DO4(buf) DO2(buf); DO2(buf);
#define DO8(buf) DO4(buf); DO4(buf);
/* ========================================================================= */
uLong ZEXPORT crc32(crc, buf, len)
uLong crc;
const Bytef *buf;
uInt len;
{
if (buf == Z_NULL) return 0L;
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif
crc = crc ^ 0xffffffffL;
while (len >= 8)
{
DO8(buf);
len -= 8;
}
if (len) do {
DO1(buf);
} while (--len);
return crc ^ 0xffffffffL;
}
@@ -1,318 +0,0 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2002 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef _DEFLATE_H
#define _DEFLATE_H
#include "zutil.h"
/* ===========================================================================
* Internal compression state.
*/
#define LENGTH_CODES 29
/* number of length codes, not counting the special END_BLOCK code */
#define LITERALS 256
/* number of literal bytes 0..255 */
#define L_CODES (LITERALS+1+LENGTH_CODES)
/* number of Literal or Length codes, including the END_BLOCK code */
#define D_CODES 30
/* number of distance codes */
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
#define HEAP_SIZE (2*L_CODES+1)
/* maximum heap size */
#define MAX_BITS 15
/* All codes must not exceed MAX_BITS bits */
#define INIT_STATE 42
#define BUSY_STATE 113
#define FINISH_STATE 666
/* Stream status */
/* Data structure describing a single value and its code string. */
typedef struct ct_data_s {
union {
ush freq; /* frequency count */
ush code; /* bit string */
} fc;
union {
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
} dl;
} FAR ct_data;
#define Freq fc.freq
#define Code fc.code
#define Dad dl.dad
#define Len dl.len
typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
typedef Pos FAR Posf;
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
* save space in the various tables. IPos is used only for parameter passing.
*/
typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int noheader; /* suppress zlib header and adler32 */
Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
Bytef *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always
* performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
* To do: use the user input buffer as sliding window.
*/
ulg window_size;
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
Posf *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
Posf *head; /* Heads of the hash chains or NIL. */
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
uInt match_length; /* length of best match */
IPos prev_match; /* previous match */
int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
uInt max_chain_length;
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
uInt max_lazy_match;
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
# define max_insert_length max_lazy_match
/* Insert new strings in the hash table only if the match length is not
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/
uInt good_match;
/* Use a faster search when the previous match is longer than this */
int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
struct tree_desc_s l_desc; /* desc. for literal tree */
struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */
ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
uchf *l_buf; /* buffer for literals or lengths */
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - if compression is not successful for the first block, all input
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can
* even emit a stored file instead of a stored block (saving 5 bytes).
* This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
* adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
* a highly compressible string table.) Smaller buffer sizes give
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
uInt last_lit; /* running index in l_buf */
ushf *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
*/
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
ush bi_buf;
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/
/* in trees.c */
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));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = cc; \
s->dyn_ltree[cc].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \
ush dist = (distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
#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)
#endif
#endif
@@ -1,875 +0,0 @@
/* gzio.c -- IO on .gz files
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Compile this file with -DNO_DEFLATE to avoid the compression code.
*/
/* @(#) $Id$ */
#include <stdio.h>
#include "zutil.h"
struct internal_state {int dummy;}; /* for buggy compilers */
#ifndef Z_BUFSIZE
# ifdef MAXSEG_64K
# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
# else
# define Z_BUFSIZE 16384
# endif
#endif
#ifndef Z_PRINTF_BUFSIZE
# define Z_PRINTF_BUFSIZE 4096
#endif
#define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);}
static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
/* gzip flag byte */
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define RESERVED 0xE0 /* bits 5..7: reserved */
typedef struct gz_stream {
z_stream stream;
int z_err; /* error code for last stream operation */
int z_eof; /* set if end of input file */
FILE *file; /* .gz file */
Byte *inbuf; /* input buffer */
Byte *outbuf; /* output buffer */
uLong crc; /* crc32 of uncompressed data */
char *msg; /* error message */
char *path; /* path name for debugging only */
int transparent; /* 1 if input file is not a .gz file */
char mode; /* 'w' or 'r' */
long startpos; /* start of compressed data in file (header skipped) */
} gz_stream;
local gzFile gz_open OF((const char *path, const char *mode, int fd));
local int do_flush OF((gzFile file, int flush));
local int get_byte OF((gz_stream *s));
local void check_header OF((gz_stream *s));
local int destroy OF((gz_stream *s));
local void putLong OF((FILE *file, uLong x));
local uLong getLong OF((gz_stream *s));
/* ===========================================================================
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb"). The file is given either by file descriptor
or path name (if fd == -1).
gz_open return NULL if the file could not be opened or if there was
insufficient memory to allocate the (de)compression state; errno
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR).
*/
local gzFile gz_open (path, mode, fd)
const char *path;
const char *mode;
int fd;
{
int err;
int level = Z_DEFAULT_COMPRESSION; /* compression level */
int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
char *p = (char*)mode;
gz_stream *s;
char fmode[80]; /* copy of mode, without the compression level */
char *m = fmode;
if (!path || !mode) return Z_NULL;
s = (gz_stream *)ALLOC(sizeof(gz_stream));
if (!s) return Z_NULL;
s->stream.zalloc = (alloc_func)0;
s->stream.zfree = (free_func)0;
s->stream.opaque = (voidpf)0;
s->stream.next_in = s->inbuf = Z_NULL;
s->stream.next_out = s->outbuf = Z_NULL;
s->stream.avail_in = s->stream.avail_out = 0;
s->file = NULL;
s->z_err = Z_OK;
s->z_eof = 0;
s->crc = crc32(0L, Z_NULL, 0);
s->msg = NULL;
s->transparent = 0;
s->path = (char*)ALLOC(strlen(path)+1);
if (s->path == NULL) {
return destroy(s), (gzFile)Z_NULL;
}
strcpy(s->path, path); /* do this early for debugging */
s->mode = '\0';
do {
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 */
}
} 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;
#else
err = deflateInit2(&(s->stream), level,
Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
/* windowBits is passed < 0 to suppress zlib header */
s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
#endif
if (err != Z_OK || s->outbuf == Z_NULL) {
return destroy(s), (gzFile)Z_NULL;
}
} else {
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
err = inflateInit2(&(s->stream), -MAX_WBITS);
/* 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. Here the gzip CRC32 ensures that 4 bytes are
* present after the compressed stream.
*/
if (err != Z_OK || s->inbuf == Z_NULL) {
return destroy(s), (gzFile)Z_NULL;
}
}
s->stream.avail_out = Z_BUFSIZE;
errno = 0;
s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
if (s->file == NULL) {
return destroy(s), (gzFile)Z_NULL;
}
if (s->mode == 'w') {
/* Write a very simple .gz header:
*/
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
* 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);
}
return (gzFile)s;
}
/* ===========================================================================
Opens a gzip (.gz) file for reading or writing.
*/
gzFile ZEXPORT gzopen (path, mode)
const char *path;
const char *mode;
{
return gz_open (path, mode, -1);
}
/* ===========================================================================
Associate a gzFile with the file descriptor fd. fd is not dup'ed here
to mimic the behavio(u)r of fdopen.
*/
gzFile ZEXPORT gzdopen (fd, mode)
int fd;
const char *mode;
{
char name[20];
if (fd < 0) return (gzFile)Z_NULL;
sprintf(name, "<fd:%d>", fd); /* for debugging */
return gz_open (name, mode, fd);
}
/* ===========================================================================
* Update the compression level and strategy
*/
int ZEXPORT gzsetparams (file, level, strategy)
gzFile file;
int level;
int strategy;
{
gz_stream *s = (gz_stream*)file;
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
/* 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;
}
return deflateParams (&(s->stream), level, strategy);
}
/* ===========================================================================
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
for end of file.
IN assertion: the stream s has been sucessfully opened for reading.
*/
local int get_byte(s)
gz_stream *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;
}
s->stream.avail_in--;
return *(s->stream.next_in)++;
}
/* ===========================================================================
Check the gzip header of a gz_stream opened for reading. Set the stream
mode to transparent if the gzip magic header is not present; set s->err
to Z_DATA_ERROR if the magic header is present but the rest of the header
is incorrect.
IN assertion: the stream s has already been created sucessfully;
s->stream.avail_in is zero for the first time, but may be non-zero
for concatenated .gz files.
*/
local void check_header(s)
gz_stream *s;
{
int method; /* method byte */
int flags; /* flags byte */
uInt len;
int c;
/* 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;
}
}
method = get_byte(s);
flags = get_byte(s);
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
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) ;
}
if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
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) ;
}
if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
for (len = 0; len < 2; len++) (void)get_byte(s);
}
s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
}
/* ===========================================================================
* Cleanup then free the given gz_stream. Return a zlib error code.
Try freeing in the reverse order of allocations.
*/
local int destroy (s)
gz_stream *s;
{
int err = Z_OK;
if (!s) return Z_STREAM_ERROR;
TRYFREE(s->msg);
if (s->stream.state != NULL) {
if (s->mode == 'w') {
#ifdef NO_DEFLATE
err = Z_STREAM_ERROR;
#else
err = deflateEnd(&(s->stream));
#endif
} 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 */
#endif
err = Z_ERRNO;
}
if (s->z_err < 0) err = s->z_err;
TRYFREE(s->inbuf);
TRYFREE(s->outbuf);
TRYFREE(s->path);
TRYFREE(s);
return err;
}
/* ===========================================================================
Reads the given number of uncompressed bytes from the compressed file.
gzread returns the number of bytes actually read (0 for end of file).
*/
int ZEXPORT gzread (file, buf, len)
gzFile file;
voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
if (s->z_err == Z_STREAM_END) return 0; /* EOF */
next_out = (Byte*)buf;
s->stream.next_out = (Bytef*)buf;
s->stream.avail_out = 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 (len == 0) s->z_eof = 1;
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;
}
}
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 (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;
}
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
return (int)(len - s->stream.avail_out);
}
/* ===========================================================================
Reads one byte from the compressed file. gzgetc returns this byte
or -1 in case of end of file or error.
*/
int ZEXPORT gzgetc(file)
gzFile file;
{
unsigned char c;
return gzread(file, &c, 1) == 1 ? c : -1;
}
/* ===========================================================================
Reads bytes from the compressed file until len-1 characters are
read, or a newline character is read and transferred to buf, or an
end-of-file condition is encountered. The string is then terminated
with a null character.
gzgets returns buf, or Z_NULL in case of error.
The current implementation is not optimized at all.
*/
char * ZEXPORT gzgets(file, buf, len)
gzFile file;
char *buf;
int len;
{
char *b = buf;
if (buf == Z_NULL || len <= 0) return Z_NULL;
while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
*buf = '\0';
return b == buf && len > 0 ? Z_NULL : b;
}
#ifndef NO_DEFLATE
/* ===========================================================================
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of bytes actually written (0 in case of error).
*/
int ZEXPORT gzwrite (file, buf, len)
gzFile file;
const voidp buf;
unsigned len;
{
gz_stream *s = (gz_stream*)file;
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
s->stream.next_in = (Bytef*)buf;
s->stream.avail_in = len;
while (s->stream.avail_in != 0) {
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;
break;
}
s->stream.avail_out = Z_BUFSIZE;
}
s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
if (s->z_err != Z_OK) break;
}
s->crc = crc32(s->crc, (const Bytef *)buf, len);
return (int)(len - s->stream.avail_in);
}
/* ===========================================================================
Converts, formats, and writes the args to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written (0 in case of error).
*/
#ifdef STDC
#include <stdarg.h>
int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
{
char buf[Z_PRINTF_BUFSIZE];
va_list va;
int len;
va_start(va, format);
#ifdef HAS_vsnprintf
(void)vsnprintf(buf, sizeof(buf), format, va);
#else
(void)vsprintf(buf, format, va);
#endif
va_end(va);
len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
if (len <= 0) return 0;
return gzwrite(file, buf, (unsigned)len);
}
#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)
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;
{
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);
#else
sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
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;
return gzwrite(file, buf, len);
}
#endif
/* ===========================================================================
Writes c, converted to an unsigned char, into the compressed file.
gzputc returns the value that was written, or -1 in case of error.
*/
int ZEXPORT gzputc(file, c)
gzFile file;
int c;
{
unsigned char cc = (unsigned char) c; /* required for big endian systems */
return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
}
/* ===========================================================================
Writes the given null-terminated string to the compressed file, excluding
the terminating null character.
gzputs returns the number of characters written, or -1 in case of error.
*/
int ZEXPORT gzputs(file, s)
gzFile file;
const char *s;
{
return gzwrite(file, (char*)s, (unsigned)strlen(s));
}
/* ===========================================================================
Flushes all pending output into the compressed file. The parameter
flush is as in the deflate() function.
*/
local int do_flush (file, flush)
gzFile file;
int flush;
{
uInt len;
int done = 0;
gz_stream *s = (gz_stream*)file;
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
s->stream.avail_in = 0; /* should be zero already anyway */
for (;;) {
len = Z_BUFSIZE - s->stream.avail_out;
if (len != 0) {
if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
s->z_err = Z_ERRNO;
return Z_ERRNO;
}
s->stream.next_out = s->outbuf;
s->stream.avail_out = Z_BUFSIZE;
}
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;
/* deflate has finished flushing only when it hasn't used up
* 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;
}
int ZEXPORT gzflush (file, flush)
gzFile file;
int flush;
{
gz_stream *s = (gz_stream*)file;
int err = do_flush (file, flush);
if (err) return err;
fflush(s->file);
return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
}
#endif /* NO_DEFLATE */
/* ===========================================================================
Sets the starting position for the next gzread or gzwrite on the given
compressed file. The offset represents a number of bytes in the
gzseek returns the resulting offset location as measured in bytes from
the beginning of the uncompressed stream, or -1 in case of error.
SEEK_END is not implemented, returns error.
In this version of the library, gzseek can be extremely slow.
*/
z_off_t ZEXPORT gzseek (file, offset, whence)
gzFile file;
z_off_t offset;
int 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;
}
if (s->mode == 'w') {
#ifdef NO_DEFLATE
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;
#endif
}
/* Rest of function is for reading only */
/* compute absolute position */
if (whence == SEEK_CUR) {
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;
if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
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;
} else if (gzrewind(file) < 0) {
return -1L;
}
/* offset is now the number of bytes to skip. */
if (offset != 0 && s->outbuf == Z_NULL) {
s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
}
while (offset > 0) {
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;
}
return (z_off_t)s->stream.total_out;
}
/* ===========================================================================
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;
s->z_eof = 0;
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;
}
(void) inflateReset(&s->stream);
return fseek(s->file, s->startpos, SEEK_SET);
}
/* ===========================================================================
Returns the starting position for the next gzread or gzwrite on the
given compressed file. This position represents a number of bytes in the
uncompressed data stream.
*/
z_off_t ZEXPORT gztell (file)
gzFile file;
{
return gzseek(file, 0L, SEEK_CUR);
}
/* ===========================================================================
Returns 1 when EOF has previously been detected reading the given
input stream, otherwise zero.
*/
int ZEXPORT gzeof (file)
gzFile file;
{
gz_stream *s = (gz_stream*)file;
return (s == NULL || s->mode != 'r') ? 0 : s->z_eof;
}
/* ===========================================================================
Outputs a long in LSB order to the given file
*/
local void putLong (file, x)
FILE *file;
uLong x;
{
int n;
for (n = 0; n < 4; n++) {
fputc((int)(x & 0xff), file);
x >>= 8;
}
}
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets z_err in case
of error.
*/
local uLong getLong (s)
gz_stream *s;
{
uLong x = (uLong)get_byte(s);
int c;
x += ((uLong)get_byte(s))<<8;
x += ((uLong)get_byte(s))<<16;
c = get_byte(s);
if (c == EOF) s->z_err = Z_DATA_ERROR;
x += ((uLong)c)<<24;
return x;
}
/* ===========================================================================
Flushes all pending output if necessary, closes the compressed file
and deallocates all the (de)compression state.
*/
int ZEXPORT gzclose (file)
gzFile file;
{
int err;
gz_stream *s = (gz_stream*)file;
if (s == NULL) return Z_STREAM_ERROR;
if (s->mode == 'w') {
#ifdef NO_DEFLATE
return Z_STREAM_ERROR;
#else
err = do_flush (file, Z_FINISH);
if (err != Z_OK) return destroy((gz_stream*)file);
putLong (s->file, s->crc);
putLong (s->file, s->stream.total_in);
#endif
}
return destroy((gz_stream*)file);
}
/* ===========================================================================
Returns the error message for the last error which occured on the
given compressed file. errnum is set to zlib error number. If an
error occured in the file system and not in the compression library,
errnum is set to Z_ERRNO and the application may consult errno
to get the exact error code.
*/
const char* ZEXPORT gzerror (file, errnum)
gzFile file;
int *errnum;
{
char *m;
gz_stream *s = (gz_stream*)file;
if (s == NULL) {
*errnum = Z_STREAM_ERROR;
return (const char*)ERR_MSG(Z_STREAM_ERROR);
}
*errnum = s->z_err;
if (*errnum == Z_OK) return (const char*)"";
m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
TRYFREE(s->msg);
s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
strcpy(s->msg, s->path);
strcat(s->msg, ": ");
strcat(s->msg, m);
return (const char*)s->msg;
}
@@ -1,403 +0,0 @@
/* 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
*/
#include "zutil.h"
#include "infblock.h"
#include "inftrees.h"
#include "infcodes.h"
#include "infutil.h"
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
/* simplify the use of the inflate_huft type with some defines */
#define exop word.what.Exop
#define bits word.what.Bits
/* Table for deflate from PKZIP's appnote.txt. */
local const uInt border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/*
Notes beyond the 1.93a appnote.txt:
1. Distance pointers never point before the beginning of the output
stream.
2. Distance pointers can point back across blocks, up to 32k away.
3. There is an implied maximum of 7 bits for the bit length table and
15 bits for the actual data.
4. If only one code exists, then it is encoded using one bit. (Zero
would be more efficient, but perhaps a little confusing.) If two
codes exist, they are coded using one bit each (0 and 1).
5. There is no way of sending zero distance codes--a dummy must be
sent if there are none. (History: a pre 2.0 version of PKZIP would
store blocks with no distance codes, but this was discovered to be
too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
zero distance codes, which is sent as one code of zero bits in
length.
6. There are up to 286 literal/length codes. Code 256 represents the
end-of-block. Note however that the static length tree defines
288 codes just to fill out the Huffman codes. Codes 286 and 287
cannot be used though, since there is no length base or extra bits
defined for them. Similarily, there are up to 30 distance codes.
However, static trees define 32 codes (all 5 bits) to fill out the
Huffman codes, but the last two had better not show up in the data.
7. Unzip can check dynamic Huffman blocks for complete code sets.
The exception is that a single code would not be complete (see #4).
8. The five bits following the block type is really the number of
literal codes sent minus 257.
9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
(1+6+6). Therefore, to output three times the length, you output
three codes (1+1+1), whereas to output four times the same length,
you only need two codes (1+3). Hmm.
10. In the tree reconstruction algorithm, Code = Code + Increment
only if BitLength(i) is not zero. (Pretty obvious.)
11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
12. Note: length code 284 can represent 227-258, but length code 285
really is 258. The last length deserves its own, short code
since it gets used a lot in very redundant files. The length
258 is special since 258 - 3 (the min match length) is 255.
13. The literal/length and distance code bit lengths are read as a
single stream of lengths. It is possible (and advantageous) for
a repeat code (16, 17, or 18) to go across the boundary between
the two sets of lengths.
*/
void inflate_blocks_reset(s, z, c)
inflate_blocks_statef *s;
z_streamp z;
uLongf *c;
{
if (c != Z_NULL)
*c = s->check;
if (s->mode == BTREE || s->mode == DTREE)
ZFREE(z, s->sub.trees.blens);
if (s->mode == CODES)
inflate_codes_free(s->sub.decode.codes, z);
s->mode = TYPE;
s->bitk = 0;
s->bitb = 0;
s->read = s->write = s->window;
if (s->checkfn != Z_NULL)
z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0);
Tracev((stderr, "inflate: blocks reset\n"));
}
inflate_blocks_statef *inflate_blocks_new(z, c, w)
z_streamp z;
check_func c;
uInt w;
{
inflate_blocks_statef *s;
if ((s = (inflate_blocks_statef *)ZALLOC
(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
return s;
if ((s->hufts =
(inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
{
ZFREE(z, s);
return Z_NULL;
}
if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
{
ZFREE(z, s->hufts);
ZFREE(z, s);
return Z_NULL;
}
s->end = s->window + w;
s->checkfn = c;
s->mode = TYPE;
Tracev((stderr, "inflate: blocks allocated\n"));
inflate_blocks_reset(s, z, Z_NULL);
return s;
}
int inflate_blocks(s, z, r)
inflate_blocks_statef *s;
z_streamp z;
int r;
{
uInt t; /* temporary storage */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
Bytef *p; /* input data pointer */
uInt n; /* bytes available there */
Bytef *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
/* copy input/output information to locals (UPDATE macro restores) */
LOAD
/* process input based on current state */
while (1) switch (s->mode)
{
case TYPE:
NEEDBITS(3)
t = (uInt)b & 7;
s->last = t & 1;
switch (t >> 1)
{
case 0: /* stored */
Tracev((stderr, "inflate: stored block%s\n",
s->last ? " (last)" : ""));
DUMPBITS(3)
t = k & 7; /* go to byte boundary */
DUMPBITS(t)
s->mode = LENS; /* get length of stored block */
break;
case 1: /* fixed */
Tracev((stderr, "inflate: fixed codes block%s\n",
s->last ? " (last)" : ""));
{
uInt bl, bd;
inflate_huft *tl, *td;
inflate_trees_fixed(&bl, &bd, &tl, &td, z);
s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
if (s->sub.decode.codes == Z_NULL)
{
r = Z_MEM_ERROR;
LEAVE
}
}
DUMPBITS(3)
s->mode = CODES;
break;
case 2: /* dynamic */
Tracev((stderr, "inflate: dynamic codes block%s\n",
s->last ? " (last)" : ""));
DUMPBITS(3)
s->mode = TABLE;
break;
case 3: /* illegal */
DUMPBITS(3)
s->mode = BAD;
z->msg = (char*)"invalid block type";
r = Z_DATA_ERROR;
LEAVE
}
break;
case LENS:
NEEDBITS(32)
if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
{
s->mode = BAD;
z->msg = (char*)"invalid stored block lengths";
r = Z_DATA_ERROR;
LEAVE
}
s->sub.left = (uInt)b & 0xffff;
b = k = 0; /* dump bits */
Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
break;
case STORED:
if (n == 0)
LEAVE
NEEDOUT
t = s->sub.left;
if (t > n) t = n;
if (t > m) t = m;
zmemcpy(q, p, t);
p += t; n -= t;
q += t; m -= t;
if ((s->sub.left -= t) != 0)
break;
Tracev((stderr, "inflate: stored end, %lu total out\n",
z->total_out + (q >= s->read ? q - s->read :
(s->end - s->read) + (q - s->window))));
s->mode = s->last ? DRY : TYPE;
break;
case TABLE:
NEEDBITS(14)
s->sub.trees.table = t = (uInt)b & 0x3fff;
#ifndef PKZIP_BUG_WORKAROUND
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
{
s->mode = BAD;
z->msg = (char*)"too many length or distance symbols";
r = Z_DATA_ERROR;
LEAVE
}
#endif
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
{
r = Z_MEM_ERROR;
LEAVE
}
DUMPBITS(14)
s->sub.trees.index = 0;
Tracev((stderr, "inflate: table sizes ok\n"));
s->mode = BTREE;
case BTREE:
while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
{
NEEDBITS(3)
s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
DUMPBITS(3)
}
while (s->sub.trees.index < 19)
s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
s->sub.trees.bb = 7;
t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
&s->sub.trees.tb, s->hufts, z);
if (t != Z_OK)
{
r = t;
if (r == Z_DATA_ERROR)
{
ZFREE(z, s->sub.trees.blens);
s->mode = BAD;
}
LEAVE
}
s->sub.trees.index = 0;
Tracev((stderr, "inflate: bits tree ok\n"));
s->mode = DTREE;
case DTREE:
while (t = s->sub.trees.table,
s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
{
inflate_huft *h;
uInt i, j, c;
t = s->sub.trees.bb;
NEEDBITS(t)
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
t = h->bits;
c = h->base;
if (c < 16)
{
DUMPBITS(t)
s->sub.trees.blens[s->sub.trees.index++] = c;
}
else /* c == 16..18 */
{
i = c == 18 ? 7 : c - 14;
j = c == 18 ? 11 : 3;
NEEDBITS(t + i)
DUMPBITS(t)
j += (uInt)b & inflate_mask[i];
DUMPBITS(i)
i = s->sub.trees.index;
t = s->sub.trees.table;
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
(c == 16 && i < 1))
{
ZFREE(z, s->sub.trees.blens);
s->mode = BAD;
z->msg = (char*)"invalid bit length repeat";
r = Z_DATA_ERROR;
LEAVE
}
c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
do {
s->sub.trees.blens[i++] = c;
} while (--j);
s->sub.trees.index = i;
}
}
s->sub.trees.tb = Z_NULL;
{
uInt bl, bd;
inflate_huft *tl, *td;
inflate_codes_statef *c;
bl = 9; /* must be <= 9 for lookahead assumptions */
bd = 6; /* must be <= 9 for lookahead assumptions */
t = s->sub.trees.table;
t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
s->sub.trees.blens, &bl, &bd, &tl, &td,
s->hufts, z);
if (t != Z_OK)
{
if (t == (uInt)Z_DATA_ERROR)
{
ZFREE(z, s->sub.trees.blens);
s->mode = BAD;
}
r = t;
LEAVE
}
Tracev((stderr, "inflate: trees ok\n"));
if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
{
r = Z_MEM_ERROR;
LEAVE
}
s->sub.decode.codes = c;
}
ZFREE(z, s->sub.trees.blens);
s->mode = CODES;
case CODES:
UPDATE
if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
return inflate_flush(s, z, r);
r = Z_OK;
inflate_codes_free(s->sub.decode.codes, z);
LOAD
Tracev((stderr, "inflate: codes end, %lu total out\n",
z->total_out + (q >= s->read ? q - s->read :
(s->end - s->read) + (q - s->window))));
if (!s->last)
{
s->mode = TYPE;
break;
}
s->mode = DRY;
case DRY:
FLUSH
if (s->read != s->write)
LEAVE
s->mode = DONE;
case DONE:
r = Z_STREAM_END;
LEAVE
case BAD:
r = Z_DATA_ERROR;
LEAVE
default:
r = Z_STREAM_ERROR;
LEAVE
}
}
int inflate_blocks_free(s, z)
inflate_blocks_statef *s;
z_streamp z;
{
inflate_blocks_reset(s, z, Z_NULL);
ZFREE(z, s->window);
ZFREE(z, s->hufts);
ZFREE(z, s);
Tracev((stderr, "inflate: blocks freed\n"));
return Z_OK;
}
void inflate_set_dictionary(s, d, n)
inflate_blocks_statef *s;
const Bytef *d;
uInt n;
{
zmemcpy(s->window, d, n);
s->read = s->write = s->window + n;
}
/* Returns true if inflate is currently at the end of a block generated
* by Z_SYNC_FLUSH or Z_FULL_FLUSH.
* IN assertion: s != Z_NULL
*/
int inflate_blocks_sync_point(s)
inflate_blocks_statef *s;
{
return s->mode == LENS;
}
@@ -1,39 +0,0 @@
/* 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
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
struct inflate_blocks_state;
typedef struct inflate_blocks_state FAR inflate_blocks_statef;
extern inflate_blocks_statef * inflate_blocks_new OF((
z_streamp z,
check_func c, /* check function */
uInt w)); /* window size */
extern int inflate_blocks OF((
inflate_blocks_statef *,
z_streamp ,
int)); /* initial return code */
extern void inflate_blocks_reset OF((
inflate_blocks_statef *,
z_streamp ,
uLongf *)); /* check value on output */
extern int inflate_blocks_free OF((
inflate_blocks_statef *,
z_streamp));
extern void inflate_set_dictionary OF((
inflate_blocks_statef *s,
const Bytef *d, /* dictionary */
uInt n)); /* dictionary length */
extern int inflate_blocks_sync_point OF((
inflate_blocks_statef *s));
@@ -1,251 +0,0 @@
/* 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
*/
#include "zutil.h"
#include "inftrees.h"
#include "infblock.h"
#include "infcodes.h"
#include "infutil.h"
#include "inffast.h"
/* simplify the use of the inflate_huft type with some defines */
#define exop word.what.Exop
#define bits word.what.Bits
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
START, /* x: set up for LEN */
LEN, /* i: get length/literal/eob next */
LENEXT, /* i: getting length extra (have base) */
DIST, /* i: get distance next */
DISTEXT, /* i: getting distance extra */
COPY, /* o: copying bytes in window, waiting for space */
LIT, /* o: got literal, waiting for output space */
WASH, /* o: got eob, possibly still output waiting */
END, /* x: got eob and all data flushed */
BADCODE} /* x: got error */
inflate_codes_mode;
/* inflate codes private state */
struct inflate_codes_state {
/* mode */
inflate_codes_mode mode; /* current inflate_codes mode */
/* mode dependent information */
uInt len;
union {
struct {
inflate_huft *tree; /* pointer into tree */
uInt need; /* bits needed */
} code; /* if LEN or DIST, where in tree */
uInt lit; /* if LIT, literal */
struct {
uInt get; /* bits to get for extra */
uInt dist; /* distance back to copy from */
} copy; /* if EXT or COPY, where and how much */
} sub; /* submode */
/* mode independent information */
Byte lbits; /* ltree bits decoded per branch */
Byte dbits; /* dtree bits decoder per branch */
inflate_huft *ltree; /* literal/length/eob tree */
inflate_huft *dtree; /* distance tree */
};
inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
uInt bl, bd;
inflate_huft *tl;
inflate_huft *td; /* need separate declaration for Borland C++ */
z_streamp z;
{
inflate_codes_statef *c;
if ((c = (inflate_codes_statef *)
ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
{
c->mode = START;
c->lbits = (Byte)bl;
c->dbits = (Byte)bd;
c->ltree = tl;
c->dtree = td;
Tracev((stderr, "inflate: codes new\n"));
}
return c;
}
int inflate_codes(s, z, r)
inflate_blocks_statef *s;
z_streamp z;
int r;
{
uInt j; /* temporary storage */
inflate_huft *t; /* temporary pointer */
uInt e; /* extra bits or operation */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
Bytef *p; /* input data pointer */
uInt n; /* bytes available there */
Bytef *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
Bytef *f; /* pointer to copy strings from */
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
/* copy input/output information to locals (UPDATE macro restores) */
LOAD
/* process input and output based on current state */
while (1) switch (c->mode)
{ /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
case START: /* x: set up for LEN */
#ifndef SLOW
if (m >= 258 && n >= 10)
{
UPDATE
r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
LOAD
if (r != Z_OK)
{
c->mode = r == Z_STREAM_END ? WASH : BADCODE;
break;
}
}
#endif /* !SLOW */
c->sub.code.need = c->lbits;
c->sub.code.tree = c->ltree;
c->mode = LEN;
case LEN: /* i: get length/literal/eob next */
j = c->sub.code.need;
NEEDBITS(j)
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
DUMPBITS(t->bits)
e = (uInt)(t->exop);
if (e == 0) /* literal */
{
c->sub.lit = t->base;
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", t->base));
c->mode = LIT;
break;
}
if (e & 16) /* length */
{
c->sub.copy.get = e & 15;
c->len = t->base;
c->mode = LENEXT;
break;
}
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
c->sub.code.tree = t + t->base;
break;
}
if (e & 32) /* end of block */
{
Tracevv((stderr, "inflate: end of block\n"));
c->mode = WASH;
break;
}
c->mode = BADCODE; /* invalid code */
z->msg = (char*)"invalid literal/length code";
r = Z_DATA_ERROR;
LEAVE
case LENEXT: /* i: getting length extra (have base) */
j = c->sub.copy.get;
NEEDBITS(j)
c->len += (uInt)b & inflate_mask[j];
DUMPBITS(j)
c->sub.code.need = c->dbits;
c->sub.code.tree = c->dtree;
Tracevv((stderr, "inflate: length %u\n", c->len));
c->mode = DIST;
case DIST: /* i: get distance next */
j = c->sub.code.need;
NEEDBITS(j)
t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
DUMPBITS(t->bits)
e = (uInt)(t->exop);
if (e & 16) /* distance */
{
c->sub.copy.get = e & 15;
c->sub.copy.dist = t->base;
c->mode = DISTEXT;
break;
}
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
c->sub.code.tree = t + t->base;
break;
}
c->mode = BADCODE; /* invalid code */
z->msg = (char*)"invalid distance code";
r = Z_DATA_ERROR;
LEAVE
case DISTEXT: /* i: getting distance extra */
j = c->sub.copy.get;
NEEDBITS(j)
c->sub.copy.dist += (uInt)b & inflate_mask[j];
DUMPBITS(j)
Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
c->mode = COPY;
case COPY: /* o: copying bytes in window, waiting for space */
f = q - c->sub.copy.dist;
while (f < s->window) /* modulo window size-"while" instead */
f += s->end - s->window; /* of "if" handles invalid distances */
while (c->len)
{
NEEDOUT
OUTBYTE(*f++)
if (f == s->end)
f = s->window;
c->len--;
}
c->mode = START;
break;
case LIT: /* o: got literal, waiting for output space */
NEEDOUT
OUTBYTE(c->sub.lit)
c->mode = START;
break;
case WASH: /* o: got eob, possibly more output */
if (k > 7) /* return unused byte, if any */
{
Assert(k < 16, "inflate_codes grabbed too many bytes")
k -= 8;
n++;
p--; /* can always return one */
}
FLUSH
if (s->read != s->write)
LEAVE
c->mode = END;
case END:
r = Z_STREAM_END;
LEAVE
case BADCODE: /* x: got error */
r = Z_DATA_ERROR;
LEAVE
default:
r = Z_STREAM_ERROR;
LEAVE
}
#ifdef NEED_DUMMY_RETURN
return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
#endif
}
void inflate_codes_free(c, z)
inflate_codes_statef *c;
z_streamp z;
{
ZFREE(z, c);
Tracev((stderr, "inflate: codes free\n"));
}
@@ -1,27 +0,0 @@
/* 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
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
struct inflate_codes_state;
typedef struct inflate_codes_state FAR inflate_codes_statef;
extern inflate_codes_statef *inflate_codes_new OF((
uInt, uInt,
inflate_huft *, inflate_huft *,
z_streamp ));
extern int inflate_codes OF((
inflate_blocks_statef *,
z_streamp ,
int));
extern void inflate_codes_free OF((
inflate_codes_statef *,
z_streamp ));
@@ -1,183 +0,0 @@
/* 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
*/
#include "zutil.h"
#include "inftrees.h"
#include "infblock.h"
#include "infcodes.h"
#include "infutil.h"
#include "inffast.h"
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
/* simplify the use of the inflate_huft type with some defines */
#define exop word.what.Exop
#define bits word.what.Bits
/* macros for bit input with no checking and for returning unused bytes */
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
/* Called with number of bytes left to write in window at least 258
(the maximum string length) and number of input bytes available
at least ten. The ten bytes are six bytes for the longest length/
distance pair plus four bytes for overloading the bit buffer. */
int inflate_fast(bl, bd, tl, td, s, z)
uInt bl, bd;
inflate_huft *tl;
inflate_huft *td; /* need separate declaration for Borland C++ */
inflate_blocks_statef *s;
z_streamp z;
{
inflate_huft *t; /* temporary pointer */
uInt e; /* extra bits or operation */
uLong b; /* bit buffer */
uInt k; /* bits in bit buffer */
Bytef *p; /* input data pointer */
uInt n; /* bytes available there */
Bytef *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
uInt ml; /* mask for literal/length tree */
uInt md; /* mask for distance tree */
uInt c; /* bytes to copy */
uInt d; /* distance back to copy from */
Bytef *r; /* copy source pointer */
/* load input, output, bit values */
LOAD
/* initialize masks */
ml = inflate_mask[bl];
md = inflate_mask[bd];
/* do until not enough input or output space for fast loop */
do { /* assume called with m >= 258 && n >= 10 */
/* get literal/length code */
GRABBITS(20) /* max bits for literal/length code */
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
{
DUMPBITS(t->bits)
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
"inflate: * literal '%c'\n" :
"inflate: * literal 0x%02x\n", t->base));
*q++ = (Byte)t->base;
m--;
continue;
}
do {
DUMPBITS(t->bits)
if (e & 16)
{
/* get extra bits for length */
e &= 15;
c = t->base + ((uInt)b & inflate_mask[e]);
DUMPBITS(e)
Tracevv((stderr, "inflate: * length %u\n", c));
/* decode distance base of block to copy */
GRABBITS(15); /* max bits for distance code */
e = (t = td + ((uInt)b & md))->exop;
do {
DUMPBITS(t->bits)
if (e & 16)
{
/* get extra bits to add to distance base */
e &= 15;
GRABBITS(e) /* get extra bits (up to 13) */
d = t->base + ((uInt)b & inflate_mask[e]);
DUMPBITS(e)
Tracevv((stderr, "inflate: * distance %u\n", d));
/* do the copy */
m -= c;
r = q - d;
if (r < s->window) /* wrap if needed */
{
do {
r += s->end - s->window; /* force pointer in window */
} while (r < s->window); /* covers invalid distances */
e = s->end - r;
if (c > e)
{
c -= e; /* wrapped copy */
do {
*q++ = *r++;
} while (--e);
r = s->window;
do {
*q++ = *r++;
} while (--c);
}
else /* normal copy */
{
*q++ = *r++; c--;
*q++ = *r++; c--;
do {
*q++ = *r++;
} while (--c);
}
}
else /* normal copy */
{
*q++ = *r++; c--;
*q++ = *r++; c--;
do {
*q++ = *r++;
} while (--c);
}
break;
}
else if ((e & 64) == 0)
{
t += t->base;
e = (t += ((uInt)b & inflate_mask[e]))->exop;
}
else
{
z->msg = (char*)"invalid distance code";
UNGRAB
UPDATE
return Z_DATA_ERROR;
}
} while (1);
break;
}
if ((e & 64) == 0)
{
t += t->base;
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
{
DUMPBITS(t->bits)
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
"inflate: * literal '%c'\n" :
"inflate: * literal 0x%02x\n", t->base));
*q++ = (Byte)t->base;
m--;
break;
}
}
else if (e & 32)
{
Tracevv((stderr, "inflate: * end of block\n"));
UNGRAB
UPDATE
return Z_STREAM_END;
}
else
{
z->msg = (char*)"invalid literal/length code";
UNGRAB
UPDATE
return Z_DATA_ERROR;
}
} while (1);
} while (m >= 258 && n >= 10);
/* not enough input or output--restore pointers and return */
UNGRAB
UPDATE
return Z_OK;
}
@@ -1,17 +0,0 @@
/* 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
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
extern int inflate_fast OF((
uInt,
uInt,
inflate_huft *,
inflate_huft *,
inflate_blocks_statef *,
z_streamp ));
@@ -1,151 +0,0 @@
/* inffixed.h -- table for decoding fixed codes
* Generated automatically by the maketree.c program
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
local uInt fixed_bl = 9;
local uInt fixed_bd = 5;
local inflate_huft fixed_tl[] = {
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
};
local inflate_huft fixed_td[] = {
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
};

Some files were not shown because too many files have changed in this diff Show More