mirror of
https://bitbucket.org/seefoe/src.git
synced 2026-09-11 21:45:09 -04:00
sync base with whitengold team repo
This commit is contained in:
+23
-4
@@ -1,13 +1,19 @@
|
||||
cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(swgnge C CXX)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
if(WIN32)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/win32")
|
||||
elseif(UNIX)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
|
||||
endif()
|
||||
|
||||
set(SWG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(SWG_ENGINE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/engine)
|
||||
set(SWG_EXTERNALS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
set(SWG_EXTERNALS_FIND ${CMAKE_CURRENT_SOURCE_DIR}/external/3rd/library)
|
||||
set(SWG_GAME_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/game)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
@@ -26,10 +32,23 @@ find_package(ZLIB REQUIRED)
|
||||
if(WIN32)
|
||||
find_package(Iconv REQUIRED)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1")
|
||||
#Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#add -> /OPT:REF /OPT:ICF (if you want to limit what is in the pdb files)
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /SAFESEH:NO")
|
||||
|
||||
#Standard DEBUG build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 /MTd")
|
||||
|
||||
#Do-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /Zi /MT")
|
||||
#Dont-Build-PDB RELEASE build use the following (by either commenting---uncommenting the line as needed)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 /Oi /Ot /Oy /O2 /GF /Gy /MT")
|
||||
|
||||
#Standard add_definitions as follows
|
||||
add_definitions(-DWIN32 -Dwin32 -D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /MP /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t- /Ob1 /FC)
|
||||
|
||||
add_definitions(-D_USE_32BIT_TIME_T=1 -D_MBCS -DPLATFORM_BASE_SINGLE_THREAD -D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4996 /wd4018 /wd4351 /Zc:wchar_t-)
|
||||
elseif(UNIX)
|
||||
find_package(Curses REQUIRED)
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
# - Find the curses include file and library
|
||||
#
|
||||
# CURSES_FOUND - system has Curses
|
||||
# CURSES_INCLUDE_DIR - the Curses include directory
|
||||
# CURSES_LIBRARIES - The libraries needed to use Curses
|
||||
# CURSES_HAVE_CURSES_H - true if curses.h is available
|
||||
# CURSES_HAVE_NCURSES_H - true if ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available
|
||||
# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake
|
||||
#
|
||||
# Set CURSES_NEED_NCURSES to TRUE before the find_package() command if NCurses
|
||||
# functionality is required.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
||||
|
||||
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
|
||||
# cygwin ncurses stopped providing curses.h symlinks see above
|
||||
# message. Cygwin is an ncurses package, so force ncurses on
|
||||
# cygwin if the curses.h is missing
|
||||
if(CYGWIN)
|
||||
if(NOT EXISTS /usr/include/curses.h)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Not sure the logic is correct here.
|
||||
# If NCurses is required, use the function wsyncup() to check if the library
|
||||
# has NCurses functionality (at least this is where it breaks on NetBSD).
|
||||
# If wsyncup is in curses, use this one.
|
||||
# If not, try to find ncurses and check if this has the symbol.
|
||||
# Once the ncurses library is found, search the ncurses.h header first, but
|
||||
# some web pages also say that even with ncurses there is not always a ncurses.h:
|
||||
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
|
||||
# So at first try ncurses.h, if not found, try to find curses.h under the same
|
||||
# prefix as the library was found, if still not found, try curses.h with the
|
||||
# default search paths.
|
||||
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
|
||||
if( CURSES_NCURSES_HAS_WSYNCUP)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CURSES_USE_NCURSES)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h )
|
||||
find_path(CURSES_CURSES_H_PATH curses.h )
|
||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache wqith these variables set
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
|
||||
CACHE FILEPATH "The curses include path")
|
||||
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library")
|
||||
else()
|
||||
# we need to find ncurses
|
||||
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
find_file(CURSES_HAVE_NCURSES_H ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h
|
||||
ncurses/curses.h)
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload
|
||||
# however if the value of the variable has NOTFOUND in it, then
|
||||
# it is OK to force, and we need to force in order to have it work.
|
||||
# a cache wqith these variables set
|
||||
# only put ncurses include and library into
|
||||
# variables if they are found
|
||||
if(NOT CURSES_NCURSES_INCLUDE_PATH AND CURSES_HAVE_NCURSES_NCURSES_H)
|
||||
get_filename_component(CURSES_NCURSES_INCLUDE_PATH
|
||||
"${CURSES_HAVE_NCURSES_NCURSES_H}" PATH)
|
||||
endif()
|
||||
if(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY)
|
||||
set( FORCE_IT )
|
||||
if(CURSES_INCLUDE_PATH MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}"
|
||||
CACHE FILEPATH "The curses include path" ${FORCE_IT})
|
||||
set( FORCE_IT)
|
||||
if(CURSES_LIBRARY MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library" ${FORCE_IT})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr )
|
||||
|
||||
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_FORM_LIBRARY form )
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache
|
||||
# qith these variables set
|
||||
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
|
||||
CACHE FILEPATH "The curses form library")
|
||||
|
||||
# Need to provide the *_LIBRARIES
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||
|
||||
if(CURSES_EXTRA_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CURSES_FORM_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Proper name is *_INCLUDE_DIR
|
||||
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
|
||||
CURSES_LIBRARY CURSES_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
CURSES_INCLUDE_PATH
|
||||
CURSES_LIBRARY
|
||||
CURSES_CURSES_INCLUDE_PATH
|
||||
CURSES_CURSES_LIBRARY
|
||||
CURSES_NCURSES_INCLUDE_PATH
|
||||
CURSES_NCURSES_LIBRARY
|
||||
CURSES_EXTRA_LIBRARY
|
||||
FORM_LIBRARY
|
||||
CURSES_LIBRARIES
|
||||
CURSES_INCLUDE_DIR
|
||||
CURSES_CURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_WSYNCUP
|
||||
)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
find_path(ICONV_ROOT
|
||||
NAMES include/iconv.h
|
||||
)
|
||||
|
||||
find_path(ICONV_INCLUDE_DIR iconv.h
|
||||
HINTS
|
||||
$ENV{ICONV_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
PATHS
|
||||
${ICONV_ROOT}
|
||||
${ICONV_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(ICONV_LIBRARY
|
||||
NAMES iconv
|
||||
PATH_SUFFIXES lib
|
||||
HINTS
|
||||
$ENV{ICONV_ROOT}
|
||||
${ICONV_ROOT}
|
||||
${ICONV_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_LIBRARY ICONV_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(ICONV_ROOT ICONV_INCLUDE_DIR ICONV_LIBRARY)
|
||||
@@ -0,0 +1,272 @@
|
||||
# - Find JNI java libraries.
|
||||
# This module finds if Java is installed and determines where the
|
||||
# include files and libraries are. It also determines what the name of
|
||||
# the library is. This code sets the following variables:
|
||||
#
|
||||
# JNI_INCLUDE_DIRS = the include dirs to use
|
||||
# JNI_LIBRARIES = the libraries to use
|
||||
# JNI_FOUND = TRUE if JNI headers and libraries were found.
|
||||
# JAVA_AWT_LIBRARY = the path to the jawt library
|
||||
# JAVA_JVM_LIBRARY = the path to the jvm library
|
||||
# JAVA_INCLUDE_PATH = the include path to jni.h
|
||||
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
|
||||
macro(java_append_library_directories _var)
|
||||
# Determine java arch-specific library subdir
|
||||
# Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
|
||||
# 1.6.0_18 + icedtea patches. However, it would be much better to base the
|
||||
# guess on the first part of the GNU config.guess platform triplet.
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(_java_libarch "amd64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
|
||||
set(_java_libarch "i386")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
|
||||
set(_java_libarch "alpha")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
|
||||
# Subdir is "arm" for both big-endian (arm) and little-endian (armel).
|
||||
set(_java_libarch "arm")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
|
||||
# mips* machines are bi-endian mostly so processor does not tell
|
||||
# endianess of the underlying system.
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
||||
set(_java_libarch "ppc64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
|
||||
set(_java_libarch "ppc")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
|
||||
# Both flavours can run on the same processor
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
|
||||
set(_java_libarch "parisc" "parisc64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
|
||||
# s390 binaries can run on s390x machines
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
|
||||
set(_java_libarch "sh")
|
||||
else()
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
# Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
|
||||
# system is non-Linux (where the code above has not been well tested)
|
||||
if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
|
||||
list(APPEND _java_libarch "i386" "amd64" "ppc")
|
||||
endif()
|
||||
|
||||
# Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
|
||||
# current value to a hardcoded list. Remove possible duplicates.
|
||||
list(REMOVE_DUPLICATES _java_libarch)
|
||||
|
||||
foreach(_path ${ARGN})
|
||||
if(_path MATCHES "{libarch}")
|
||||
foreach(_libarch ${_java_libarch})
|
||||
string(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
|
||||
list(APPEND ${_var} "${_newpath}")
|
||||
endforeach()
|
||||
else()
|
||||
list(APPEND ${_var} "${_path}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
get_filename_component(java_install_version
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
|
||||
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
|
||||
)
|
||||
|
||||
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
|
||||
|
||||
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
${_JAVA_HOME}/jre/lib/{libarch}
|
||||
${_JAVA_HOME}/jre/lib
|
||||
${_JAVA_HOME}/jre/bin
|
||||
${_JAVA_HOME}/jre/bin/classic
|
||||
${_JAVA_HOME}/lib
|
||||
${_JAVA_HOME}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/usr/lib/jvm/java/lib
|
||||
/usr/lib/java/jre/lib/{libarch}
|
||||
/usr/lib/jvm/jre/lib/{libarch}
|
||||
/usr/local/lib/java/jre/lib/{libarch}
|
||||
/usr/local/share/java/jre/lib/{libarch}
|
||||
/usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
|
||||
/usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
|
||||
/opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-6-sun/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex
|
||||
/usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch} # fedora
|
||||
# Debian specific paths for default JVM
|
||||
/usr/lib/jvm/default-java/jre/lib/{libarch}
|
||||
/usr/lib/jvm/default-java/jre/lib
|
||||
/usr/lib/jvm/default-java/lib
|
||||
# OpenBSD specific paths for default JVM
|
||||
/usr/local/jdk-1.7.0/jre/lib/{libarch}
|
||||
/usr/local/jre-1.7.0/lib/{libarch}
|
||||
/usr/local/jdk-1.6.0/jre/lib/{libarch}
|
||||
/usr/local/jre-1.6.0/lib/{libarch}
|
||||
)
|
||||
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES)
|
||||
foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES
|
||||
${JAVA_JVM_LIBRARY_DIRECTORIES}
|
||||
"${dir}"
|
||||
"${dir}/client"
|
||||
"${dir}/server"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
|
||||
${_JAVA_HOME}/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/usr/lib/java/include
|
||||
/usr/local/lib/java/include
|
||||
/usr/lib/jvm/java/include
|
||||
/usr/lib/jvm/java-6-sun/include
|
||||
/usr/lib/jvm/java-1.5.0-sun/include
|
||||
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
|
||||
/usr/lib/jvm/java-6-openjdk/include
|
||||
/usr/local/share/java/include
|
||||
/usr/lib/j2sdk1.4-sun/include
|
||||
/usr/lib/j2sdk1.5-sun/include
|
||||
/opt/sun-jdk-1.5.0.04/include
|
||||
# Debian specific path for default JVM
|
||||
/usr/lib/jvm/default-java/include
|
||||
# OpenBSD specific path for default JVM
|
||||
/usr/local/jdk-1.7.0/include
|
||||
/usr/local/jdk-1.6.0/include
|
||||
)
|
||||
|
||||
foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
|
||||
get_filename_component(jpath "${JAVA_PROG}" PATH)
|
||||
foreach(JAVA_INC_PATH ../include ../java/include ../share/java/include)
|
||||
if(EXISTS ${jpath}/${JAVA_INC_PATH})
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(JAVA_LIB_PATH
|
||||
../lib ../jre/lib ../jre/lib/i386
|
||||
../java/lib ../java/jre/lib ../java/jre/lib/i386
|
||||
../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
|
||||
if(EXISTS ${jpath}/${JAVA_LIB_PATH})
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(APPLE)
|
||||
if(EXISTS ~/Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
if(EXISTS /Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
if(EXISTS /System/Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
|
||||
if(JAVA_HAVE_FRAMEWORK)
|
||||
if(NOT JAVA_AWT_LIBRARY)
|
||||
set (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT JAVA_JVM_LIBRARY)
|
||||
set (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT JAVA_AWT_INCLUDE_PATH)
|
||||
if(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
|
||||
set (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If using "-framework JavaVM", prefer its headers *before* the others in
|
||||
# JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
|
||||
#
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
~/Library/Frameworks/JavaVM.framework/Headers
|
||||
/Library/Frameworks/JavaVM.framework/Headers
|
||||
/System/Library/Frameworks/JavaVM.framework/Headers
|
||||
${JAVA_AWT_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
find_library(JAVA_AWT_LIBRARY jawt
|
||||
PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
|
||||
)
|
||||
find_library(JAVA_JVM_LIBRARY NAMES jvm JavaVM
|
||||
PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
# add in the include path
|
||||
find_path(JAVA_INCLUDE_PATH jni.h
|
||||
${JAVA_AWT_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
find_path(JAVA_INCLUDE_PATH2 jni_md.h
|
||||
${JAVA_INCLUDE_PATH}
|
||||
${JAVA_INCLUDE_PATH}/win32
|
||||
${JAVA_INCLUDE_PATH}/linux
|
||||
${JAVA_INCLUDE_PATH}/freebsd
|
||||
${JAVA_INCLUDE_PATH}/openbsd
|
||||
${JAVA_INCLUDE_PATH}/solaris
|
||||
${JAVA_INCLUDE_PATH}/hp-ux
|
||||
${JAVA_INCLUDE_PATH}/alpha
|
||||
)
|
||||
|
||||
find_path(JAVA_AWT_INCLUDE_PATH jawt.h
|
||||
${JAVA_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
|
||||
JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
JAVA_AWT_LIBRARY
|
||||
JAVA_JVM_LIBRARY
|
||||
JAVA_AWT_INCLUDE_PATH
|
||||
JAVA_INCLUDE_PATH
|
||||
JAVA_INCLUDE_PATH2
|
||||
)
|
||||
|
||||
set(JNI_LIBRARIES
|
||||
${JAVA_AWT_LIBRARY}
|
||||
${JAVA_JVM_LIBRARY}
|
||||
)
|
||||
|
||||
set(JNI_INCLUDE_DIRS
|
||||
${JAVA_INCLUDE_PATH}
|
||||
${JAVA_INCLUDE_PATH2}
|
||||
${JAVA_AWT_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
find_path(LIBXML2_ROOT
|
||||
NAMES include/zlib.h
|
||||
)
|
||||
|
||||
find_path(LIBXML2_INCLUDE_DIR libxml/xpath.h
|
||||
HINTS
|
||||
$ENV{LIBXML2_ROOT}
|
||||
PATH_SUFFIXES include include/libxml2 libxml2
|
||||
PATHS
|
||||
${LIBXML2_ROOT}
|
||||
${LIBXML2_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(LIBXML2_LIBRARY
|
||||
NAMES xml2 libxml2
|
||||
PATH_SUFFIXES lib
|
||||
HINTS
|
||||
$ENV{LIBXML2_ROOT}
|
||||
${LIBXML2_ROOT}
|
||||
${LIBXML2_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBXML2_ROOT LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY)
|
||||
@@ -0,0 +1,94 @@
|
||||
###############################################################################
|
||||
#
|
||||
# CMake module to search for Oracle client library (OCI)
|
||||
#
|
||||
# On success, the macro sets the following variables:
|
||||
# ORACLE_FOUND = if the library found
|
||||
# ORACLE_LIBRARY = full path to the library
|
||||
# ORACLE_LIBRARIES = full path to the library
|
||||
# ORACLE_INCLUDE_DIR = where to find the library headers also defined,
|
||||
# but not for general use are
|
||||
# ORACLE_VERSION = version of library which was found, e.g. "1.2.5"
|
||||
#
|
||||
# Copyright (c) 2009-2013 Mateusz Loskot <[email protected]>
|
||||
#
|
||||
# Developed with inspiration from Petr Vanek <[email protected]>
|
||||
# who wrote similar macro for TOra - http://torasql.com/
|
||||
#
|
||||
# Module source: http://github.com/mloskot/workshop/tree/master/cmake/
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
|
||||
# If ORACLE_HOME not defined, assume Oracle libraries not available
|
||||
if(DEFINED ENV{ORACLE_HOME})
|
||||
|
||||
|
||||
set(ORACLE_HOME $ENV{ORACLE_HOME})
|
||||
message("ORACLE_HOME=${ORACLE_HOME}")
|
||||
|
||||
|
||||
find_path(ORACLE_INCLUDE_DIR
|
||||
NAMES oci.h
|
||||
PATHS
|
||||
${ORACLE_HOME}/rdbms/public
|
||||
${ORACLE_HOME}/include
|
||||
${ORACLE_HOME}/sdk/include # Oracle SDK
|
||||
${ORACLE_HOME}/OCI/include) # Oracle XE on Windows
|
||||
|
||||
|
||||
set(ORACLE_OCI_NAMES clntsh libclntsh oci)
|
||||
set(ORACLE_NNZ_NAMES nnz10 libnnz10 nnz11 libnnz11 nnz12 libnnz12 ociw32)
|
||||
set(ORACLE_OCCI_NAMES libocci occi oraocci10 oraocci11 oraocci12)
|
||||
|
||||
|
||||
set(ORACLE_LIB_DIR
|
||||
${ORACLE_HOME}/lib
|
||||
${ORACLE_HOME}/sdk/lib # Oracle SDK
|
||||
${ORACLE_HOME}/sdk/lib/msvc
|
||||
${ORACLE_HOME}/OCI/lib/msvc) # Oracle XE on Windows
|
||||
|
||||
|
||||
find_library(ORACLE_OCI_LIBRARY NAMES ${ORACLE_OCI_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
find_library(ORACLE_OCCI_LIBRARY NAMES ${ORACLE_OCCI_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
find_library(ORACLE_NNZ_LIBRARY NAMES ${ORACLE_NNZ_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
|
||||
|
||||
set(ORACLE_LIBRARY ${ORACLE_OCI_LIBRARY} ${ORACLE_OCCI_LIBRARY} ${ORACLE_NNZ_LIBRARY})
|
||||
|
||||
|
||||
if(APPLE)
|
||||
set(ORACLE_OCIEI_NAMES libociei ociei)
|
||||
|
||||
|
||||
find_library(ORACLE_OCIEI_LIBRARY
|
||||
NAMES libociei ociei
|
||||
PATHS ${ORACLE_LIB_DIR})
|
||||
|
||||
|
||||
if(ORACLE_OCIEI_LIBRARY)
|
||||
set(ORACLE_LIBRARY ${ORACLE_LIBRARY} ${ORACLE_OCIEI_LIBRARY})
|
||||
else(ORACLE_OCIEI_LIBRARY)
|
||||
message(STATUS
|
||||
"libociei.dylib is not found. It may cause crash if you are building BUNDLE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
set(ORACLE_LIBRARIES ${ORACLE_LIBRARY})
|
||||
|
||||
|
||||
endif(DEFINED ENV{ORACLE_HOME})
|
||||
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set ORACLE_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ORACLE DEFAULT_MSG ORACLE_LIBRARY ORACLE_INCLUDE_DIR)
|
||||
|
||||
|
||||
mark_as_advanced(ORACLE_INCLUDE_DIR ORACLE_LIBRARY)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
find_path(PCRE_ROOT
|
||||
NAMES include/pcre.h
|
||||
)
|
||||
|
||||
find_path(PCRE_INCLUDE_DIR pcre.h
|
||||
HINTS
|
||||
$ENV{PCRE_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
PATHS
|
||||
${PCRE_ROOT}
|
||||
${PCRE_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(PCRE_LIBRARY
|
||||
NAMES pcre libpcre
|
||||
PATH_SUFFIXES lib
|
||||
HINTS
|
||||
$ENV{PCRE_ROOT}
|
||||
${PCRE_ROOT}
|
||||
${PCRE_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(PCRE_ROOT PCRE_INCLUDE_DIR PCRE_LIBRARY)
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
find_path(Boost_INCLUDE_DIR
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
PATH_SUFFIXES boost
|
||||
NAMES boost/version.hpp )
|
||||
|
||||
|
||||
find_path(BOOST_ROOT
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
PATH_SUFFIXES boost
|
||||
NAMES boost/version.hpp )
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
|
||||
|
||||
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
|
||||
@@ -0,0 +1,176 @@
|
||||
# - Find the curses include file and library
|
||||
#
|
||||
# CURSES_FOUND - system has Curses
|
||||
# CURSES_INCLUDE_DIR - the Curses include directory
|
||||
# CURSES_LIBRARIES - The libraries needed to use Curses
|
||||
# CURSES_HAVE_CURSES_H - true if curses.h is available
|
||||
# CURSES_HAVE_NCURSES_H - true if ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available
|
||||
# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake
|
||||
#
|
||||
# Set CURSES_NEED_NCURSES to TRUE before the find_package() command if NCurses
|
||||
# functionality is required.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
||||
|
||||
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
|
||||
# cygwin ncurses stopped providing curses.h symlinks see above
|
||||
# message. Cygwin is an ncurses package, so force ncurses on
|
||||
# cygwin if the curses.h is missing
|
||||
if(CYGWIN)
|
||||
if(NOT EXISTS /usr/include/curses.h)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Not sure the logic is correct here.
|
||||
# If NCurses is required, use the function wsyncup() to check if the library
|
||||
# has NCurses functionality (at least this is where it breaks on NetBSD).
|
||||
# If wsyncup is in curses, use this one.
|
||||
# If not, try to find ncurses and check if this has the symbol.
|
||||
# Once the ncurses library is found, search the ncurses.h header first, but
|
||||
# some web pages also say that even with ncurses there is not always a ncurses.h:
|
||||
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
|
||||
# So at first try ncurses.h, if not found, try to find curses.h under the same
|
||||
# prefix as the library was found, if still not found, try curses.h with the
|
||||
# default search paths.
|
||||
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
|
||||
if( CURSES_NCURSES_HAS_WSYNCUP)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CURSES_USE_NCURSES)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h )
|
||||
find_path(CURSES_CURSES_H_PATH curses.h )
|
||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache wqith these variables set
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
|
||||
CACHE FILEPATH "The curses include path")
|
||||
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library")
|
||||
else()
|
||||
# we need to find ncurses
|
||||
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
find_file(CURSES_HAVE_NCURSES_H ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h
|
||||
ncurses/curses.h)
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload
|
||||
# however if the value of the variable has NOTFOUND in it, then
|
||||
# it is OK to force, and we need to force in order to have it work.
|
||||
# a cache wqith these variables set
|
||||
# only put ncurses include and library into
|
||||
# variables if they are found
|
||||
if(NOT CURSES_NCURSES_INCLUDE_PATH AND CURSES_HAVE_NCURSES_NCURSES_H)
|
||||
get_filename_component(CURSES_NCURSES_INCLUDE_PATH
|
||||
"${CURSES_HAVE_NCURSES_NCURSES_H}" PATH)
|
||||
endif()
|
||||
if(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY)
|
||||
set( FORCE_IT )
|
||||
if(CURSES_INCLUDE_PATH MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}"
|
||||
CACHE FILEPATH "The curses include path" ${FORCE_IT})
|
||||
set( FORCE_IT)
|
||||
if(CURSES_LIBRARY MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library" ${FORCE_IT})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr )
|
||||
|
||||
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_FORM_LIBRARY form )
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache
|
||||
# qith these variables set
|
||||
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
|
||||
CACHE FILEPATH "The curses form library")
|
||||
|
||||
# Need to provide the *_LIBRARIES
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||
|
||||
if(CURSES_EXTRA_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CURSES_FORM_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Proper name is *_INCLUDE_DIR
|
||||
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
|
||||
CURSES_LIBRARY CURSES_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
CURSES_INCLUDE_PATH
|
||||
CURSES_LIBRARY
|
||||
CURSES_CURSES_INCLUDE_PATH
|
||||
CURSES_CURSES_LIBRARY
|
||||
CURSES_NCURSES_INCLUDE_PATH
|
||||
CURSES_NCURSES_LIBRARY
|
||||
CURSES_EXTRA_LIBRARY
|
||||
FORM_LIBRARY
|
||||
CURSES_LIBRARIES
|
||||
CURSES_INCLUDE_DIR
|
||||
CURSES_CURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_WSYNCUP
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
find_path(ICONV_ROOT
|
||||
PATH_SUFFIXES libiconv
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
NAMES include/iconv.h
|
||||
)
|
||||
|
||||
find_path(ICONV_INCLUDE_DIR iconv.h
|
||||
HINTS
|
||||
$ENV{ICONV_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
PATHS
|
||||
${ICONV_ROOT}
|
||||
${ICONV_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(ICONV_LIBRARY
|
||||
NAMES libiconv
|
||||
PATHS ${ICONV_ROOT}/lib
|
||||
HINTS
|
||||
$ENV{ICONV_ROOT}
|
||||
${ICONV_ROOT}
|
||||
${ICONV_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ICONV DEFAULT_MSG ICONV_LIBRARY ICONV_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(ICONV_ROOT ICONV_INCLUDE_DIR ICONV_LIBRARY)
|
||||
@@ -0,0 +1,271 @@
|
||||
# - Find JNI java libraries.
|
||||
# This module finds if Java is installed and determines where the
|
||||
# include files and libraries are. It also determines what the name of
|
||||
# the library is. This code sets the following variables:
|
||||
#
|
||||
# JNI_INCLUDE_DIRS = the include dirs to use
|
||||
# JNI_LIBRARIES = the libraries to use
|
||||
# JNI_FOUND = TRUE if JNI headers and libraries were found.
|
||||
# JAVA_AWT_LIBRARY = the path to the jawt library
|
||||
# JAVA_JVM_LIBRARY = the path to the jvm library
|
||||
# JAVA_INCLUDE_PATH = the include path to jni.h
|
||||
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
|
||||
macro(java_append_library_directories _var)
|
||||
# Determine java arch-specific library subdir
|
||||
# Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
|
||||
# 1.6.0_18 + icedtea patches. However, it would be much better to base the
|
||||
# guess on the first part of the GNU config.guess platform triplet.
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(_java_libarch "amd64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
|
||||
set(_java_libarch "i386")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
|
||||
set(_java_libarch "alpha")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
|
||||
# Subdir is "arm" for both big-endian (arm) and little-endian (armel).
|
||||
set(_java_libarch "arm")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
|
||||
# mips* machines are bi-endian mostly so processor does not tell
|
||||
# endianess of the underlying system.
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
||||
set(_java_libarch "ppc64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
|
||||
set(_java_libarch "ppc")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
|
||||
# Both flavours can run on the same processor
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
|
||||
set(_java_libarch "parisc" "parisc64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
|
||||
# s390 binaries can run on s390x machines
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
|
||||
set(_java_libarch "sh")
|
||||
else()
|
||||
set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
# Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
|
||||
# system is non-Linux (where the code above has not been well tested)
|
||||
if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
|
||||
list(APPEND _java_libarch "i386" "amd64" "ppc")
|
||||
endif()
|
||||
|
||||
# Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
|
||||
# current value to a hardcoded list. Remove possible duplicates.
|
||||
list(REMOVE_DUPLICATES _java_libarch)
|
||||
|
||||
foreach(_path ${ARGN})
|
||||
if(_path MATCHES "{libarch}")
|
||||
foreach(_libarch ${_java_libarch})
|
||||
string(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
|
||||
list(APPEND ${_var} "${_newpath}")
|
||||
endforeach()
|
||||
else()
|
||||
list(APPEND ${_var} "${_path}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
get_filename_component(java_install_version
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
|
||||
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
|
||||
)
|
||||
|
||||
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME)
|
||||
|
||||
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
|
||||
${_JAVA_HOME}/jre/lib/{libarch}
|
||||
${_JAVA_HOME}/jre/lib
|
||||
${_JAVA_HOME}/jre/bin
|
||||
${_JAVA_HOME}/jre/bin/classic
|
||||
${_JAVA_HOME}/lib
|
||||
${_JAVA_HOME}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/usr/lib/jvm/java/lib
|
||||
/usr/lib/java/jre/lib/{libarch}
|
||||
/usr/lib/jvm/jre/lib/{libarch}
|
||||
/usr/local/lib/java/jre/lib/{libarch}
|
||||
/usr/local/share/java/jre/lib/{libarch}
|
||||
/usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
|
||||
/usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
|
||||
/opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-6-sun/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex
|
||||
/usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
|
||||
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch} # fedora
|
||||
# Debian specific paths for default JVM
|
||||
/usr/lib/jvm/default-java/jre/lib/{libarch}
|
||||
/usr/lib/jvm/default-java/jre/lib
|
||||
/usr/lib/jvm/default-java/lib
|
||||
# OpenBSD specific paths for default JVM
|
||||
/usr/local/jdk-1.7.0/jre/lib/{libarch}
|
||||
/usr/local/jre-1.7.0/lib/{libarch}
|
||||
/usr/local/jdk-1.6.0/jre/lib/{libarch}
|
||||
/usr/local/jre-1.6.0/lib/{libarch}
|
||||
)
|
||||
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES)
|
||||
foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
|
||||
set(JAVA_JVM_LIBRARY_DIRECTORIES
|
||||
${JAVA_JVM_LIBRARY_DIRECTORIES}
|
||||
"${dir}"
|
||||
"${dir}/client"
|
||||
"${dir}/server"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
#"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
|
||||
${_JAVA_HOME}/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/usr/lib/java/include
|
||||
/usr/local/lib/java/include
|
||||
/usr/lib/jvm/java/include
|
||||
/usr/lib/jvm/java-6-sun/include
|
||||
/usr/lib/jvm/java-1.5.0-sun/include
|
||||
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
|
||||
/usr/lib/jvm/java-6-openjdk/include
|
||||
/usr/local/share/java/include
|
||||
/usr/lib/j2sdk1.4-sun/include
|
||||
/usr/lib/j2sdk1.5-sun/include
|
||||
/opt/sun-jdk-1.5.0.04/include
|
||||
# Debian specific path for default JVM
|
||||
/usr/lib/jvm/default-java/include
|
||||
# OpenBSD specific path for default JVM
|
||||
/usr/local/jdk-1.7.0/include
|
||||
/usr/local/jdk-1.6.0/include
|
||||
)
|
||||
|
||||
foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
|
||||
get_filename_component(jpath "${JAVA_PROG}" PATH)
|
||||
foreach(JAVA_INC_PATH ../include ../java/include ../share/java/include)
|
||||
if(EXISTS ${jpath}/${JAVA_INC_PATH})
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(JAVA_LIB_PATH
|
||||
../lib ../jre/lib ../jre/lib/i386
|
||||
../java/lib ../java/jre/lib ../java/jre/lib/i386
|
||||
../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
|
||||
if(EXISTS ${jpath}/${JAVA_LIB_PATH})
|
||||
set(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(APPLE)
|
||||
if(EXISTS ~/Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
if(EXISTS /Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
if(EXISTS /System/Library/Frameworks/JavaVM.framework)
|
||||
set(JAVA_HAVE_FRAMEWORK 1)
|
||||
endif()
|
||||
|
||||
if(JAVA_HAVE_FRAMEWORK)
|
||||
if(NOT JAVA_AWT_LIBRARY)
|
||||
set (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT JAVA_JVM_LIBRARY)
|
||||
set (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT JAVA_AWT_INCLUDE_PATH)
|
||||
if(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
|
||||
set (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If using "-framework JavaVM", prefer its headers *before* the others in
|
||||
# JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
|
||||
#
|
||||
set(JAVA_AWT_INCLUDE_DIRECTORIES
|
||||
~/Library/Frameworks/JavaVM.framework/Headers
|
||||
/Library/Frameworks/JavaVM.framework/Headers
|
||||
/System/Library/Frameworks/JavaVM.framework/Headers
|
||||
${JAVA_AWT_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
find_library(JAVA_AWT_LIBRARY jawt
|
||||
PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
|
||||
)
|
||||
find_library(JAVA_JVM_LIBRARY NAMES jvm JavaVM
|
||||
PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
# add in the include path
|
||||
find_path(JAVA_INCLUDE_PATH jni.h
|
||||
${JAVA_AWT_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
find_path(JAVA_INCLUDE_PATH2 jni_md.h
|
||||
${JAVA_INCLUDE_PATH}
|
||||
${JAVA_INCLUDE_PATH}/win32
|
||||
${JAVA_INCLUDE_PATH}/linux
|
||||
${JAVA_INCLUDE_PATH}/freebsd
|
||||
${JAVA_INCLUDE_PATH}/openbsd
|
||||
${JAVA_INCLUDE_PATH}/solaris
|
||||
${JAVA_INCLUDE_PATH}/hp-ux
|
||||
${JAVA_INCLUDE_PATH}/alpha
|
||||
)
|
||||
|
||||
find_path(JAVA_AWT_INCLUDE_PATH jawt.h
|
||||
${JAVA_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
|
||||
JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
JAVA_AWT_LIBRARY
|
||||
JAVA_JVM_LIBRARY
|
||||
JAVA_AWT_INCLUDE_PATH
|
||||
JAVA_INCLUDE_PATH
|
||||
JAVA_INCLUDE_PATH2
|
||||
)
|
||||
|
||||
set(JNI_LIBRARIES
|
||||
${JAVA_AWT_LIBRARY}
|
||||
${JAVA_JVM_LIBRARY}
|
||||
)
|
||||
|
||||
set(JNI_INCLUDE_DIRS
|
||||
${JAVA_INCLUDE_PATH}
|
||||
${JAVA_INCLUDE_PATH2}
|
||||
${JAVA_AWT_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
find_path(LIBXML2_ROOT
|
||||
|
||||
PATH_SUFFIXES libxml2
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
NAMES include/zlib.h
|
||||
)
|
||||
|
||||
find_path(LIBXML2_INCLUDE_DIR libxml/xpath.h
|
||||
HINTS
|
||||
$ENV{LIBXML2_ROOT}
|
||||
PATH_SUFFIXES include include/libxml libxml2
|
||||
PATHS
|
||||
${LIBXML2_ROOT}
|
||||
${LIBXML2_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(LIBXML2_LIBRARY
|
||||
NAMES libxml2-win32-debug xml2 libxml2
|
||||
PATH_SUFFIXES lib
|
||||
HINTS
|
||||
$ENV{LIBXML2_ROOT}
|
||||
${LIBXML2_ROOT}
|
||||
${LIBXML2_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBXML2_ROOT LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY)
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
find_path(ORACLE_ROOT
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
PATH_SUFFIXES OCI
|
||||
NAMES include/oci.h )
|
||||
|
||||
find_path(ORACLE_INCLUDE_DIR
|
||||
PATHS ${SWG_EXTERNALS_FIND}/OCI/include
|
||||
NAMES oci.h )
|
||||
|
||||
find_path(BOOST_ROOT
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
PATH_SUFFIXES boost
|
||||
NAMES boost/version.hpp )
|
||||
|
||||
set(ORACLE_OCI_NAMES clntsh libclntsh oci)
|
||||
set(ORACLE_NNZ_NAMES nnz10 libnnz10 nnz11 libnnz11 nnz12 libnnz12 ociw32)
|
||||
set(ORACLE_OCCI_NAMES libocci occi oraocci10 oraocci11 oraocci12)
|
||||
|
||||
set(ORACLE_LIB_DIR
|
||||
${ORACLE_ROOT}/lib/msvc)
|
||||
|
||||
|
||||
find_library(ORACLE_LIBRARY NAMES ${ORACLE_OCI_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
find_library(ORACLE_OCCI_LIBRARY NAMES ${ORACLE_OCCI_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
find_library(ORACLE_NNZ_LIBRARY NAMES ${ORACLE_NNZ_NAMES} PATHS ${ORACLE_LIB_DIR})
|
||||
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ORACLE ORACLE_ROOT DEFAULT_MSG ORACLE_LIBRARY ORACLE_INCLUDE_DIR BOOST_ROOT)
|
||||
|
||||
mark_as_advanced(ORACLE_INCLUDE_DIR ORACLE_LIBRARY BOOST_ROOT ORACLE_ROOT)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
find_path(PCRE_ROOT
|
||||
PATHS ${SWG_EXTERNALS_FIND}
|
||||
PATH_SUFFIXES pcre/4.1/win32
|
||||
NAMES include/pcre.h
|
||||
)
|
||||
|
||||
find_path(PCRE_INCLUDE_DIR pcre.h
|
||||
HINTS
|
||||
$ENV{PCRE_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
PATHS
|
||||
${PCRE_ROOT}
|
||||
${PCRE_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(PCRE_LIBRARY
|
||||
NAMES pcre libpcre
|
||||
PATHS ${PCRE_ROOT}
|
||||
PATH_SUFFIXES lib
|
||||
HINTS
|
||||
$ENV{PCRE_ROOT}
|
||||
${PCRE_ROOT}
|
||||
${PCRE_LIBRARYDIR}
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(PCRE_ROOT PCRE_INCLUDE_DIR PCRE_LIBRARY)
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
find_path(ZLIB_INCLUDE_DIR
|
||||
PATHS ${SWG_EXTERNALS_FIND}/Zlib/include
|
||||
NAMES zlib.h )
|
||||
|
||||
|
||||
find_library(ZLIB_LIBRARY
|
||||
NAMES zlib
|
||||
PATHS ${SWG_EXTERNALS_FIND}/Zlib/lib/win32)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
|
||||
|
||||
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
CHAR_LIT = 258,
|
||||
STR_LIT = 259,
|
||||
IDENTIFIER = 260,
|
||||
LIT = 261,
|
||||
FLOAT_LIT = 262,
|
||||
INT32 = 263,
|
||||
INT16 = 264,
|
||||
INT8 = 265,
|
||||
UINT32 = 266,
|
||||
UINT16 = 267,
|
||||
UINT8 = 268,
|
||||
FLOAT = 269,
|
||||
DOUBLE = 270,
|
||||
STRING = 271,
|
||||
WSTRING = 272,
|
||||
LABELHASH = 273,
|
||||
FORM = 274,
|
||||
CHUNK = 275,
|
||||
PRAGMA = 276,
|
||||
PRAGMA_DRIVE = 277,
|
||||
PRAGMA_DIR = 278,
|
||||
PRAGMA_FNAME = 279,
|
||||
PRAGMA_EXT = 280,
|
||||
ENUMSTRUCT = 281,
|
||||
INCLUDESOURCE = 282,
|
||||
INCLUDEBIN = 283,
|
||||
INCLUDEIFF = 284,
|
||||
SIN = 285,
|
||||
COS = 286,
|
||||
TAN = 287,
|
||||
ACOS = 288,
|
||||
ASIN = 289,
|
||||
ATAN = 290,
|
||||
POUND = 291,
|
||||
SHIFTRIGHT = 292,
|
||||
SHIFTLEFT = 293,
|
||||
RAISEDPOWER = 294
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 137 "/swg/whitengold/src/engine/client/application/Miff/src/linux/parser.yac"
|
||||
|
||||
long ltype;
|
||||
double dtype;
|
||||
char *stype;
|
||||
char chtype;
|
||||
|
||||
int tokentype;
|
||||
|
||||
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 100 "/swg/whitengold/src/engine/client/application/Miff/src/parser.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
|
||||
extern int timeclock;
|
||||
|
||||
|
||||
int yyerror; /* Yyerror and yycost are set by guards. */
|
||||
int yycost; /* If yyerror is set to a nonzero value by a */
|
||||
/* guard, the reduction with which the guard */
|
||||
/* is associated is not performed, and the */
|
||||
/* error recovery mechanism is invoked. */
|
||||
/* Yycost indicates the cost of performing */
|
||||
/* the reduction given the attributes of the */
|
||||
/* symbols. */
|
||||
|
||||
|
||||
/* YYMAXDEPTH indicates the size of the parser's state and value */
|
||||
/* stacks. */
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
#define YYMAXDEPTH 500
|
||||
#endif
|
||||
|
||||
/* YYMAXRULES must be at least as large as the number of rules that */
|
||||
/* could be placed in the rule queue. That number could be determined */
|
||||
/* from the grammar and the size of the stack, but, as yet, it is not. */
|
||||
|
||||
#ifndef YYMAXRULES
|
||||
#define YYMAXRULES 100
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXBACKUP
|
||||
#define YYMAXBACKUP 100
|
||||
#endif
|
||||
|
||||
|
||||
short yyss[YYMAXDEPTH]; /* the state stack */
|
||||
YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */
|
||||
YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */
|
||||
short yyrq[YYMAXRULES]; /* the rule queue */
|
||||
int yychar; /* the lookahead symbol */
|
||||
|
||||
YYSTYPE yylval; /* the semantic value of the */
|
||||
/* lookahead symbol */
|
||||
|
||||
YYSTYPE yytval; /* the semantic value for the state */
|
||||
/* at the top of the state stack. */
|
||||
|
||||
YYSTYPE yyval; /* the variable used to return */
|
||||
/* semantic values from the action */
|
||||
/* routines */
|
||||
|
||||
YYLTYPE yylloc; /* location data for the lookahead */
|
||||
/* symbol */
|
||||
|
||||
YYLTYPE yytloc; /* location data for the state at the */
|
||||
/* top of the state stack */
|
||||
|
||||
|
||||
int yynunlexed;
|
||||
short yyunchar[YYMAXBACKUP];
|
||||
YYSTYPE yyunval[YYMAXBACKUP];
|
||||
YYLTYPE yyunloc[YYMAXBACKUP];
|
||||
|
||||
short *yygssp; /* a pointer to the top of the state */
|
||||
/* stack; only set during error */
|
||||
/* recovery. */
|
||||
|
||||
YYSTYPE *yygvsp; /* a pointer to the top of the value */
|
||||
/* stack; only set during error */
|
||||
/* recovery. */
|
||||
|
||||
YYLTYPE *yyglsp; /* a pointer to the top of the */
|
||||
/* location stack; only set during */
|
||||
/* error recovery. */
|
||||
|
||||
|
||||
/* Yyget is an interface between the parser and the lexical analyzer. */
|
||||
/* It is costly to provide such an interface, but it avoids requiring */
|
||||
/* the lexical analyzer to be able to back up the scan. */
|
||||
|
||||
yyget()
|
||||
{
|
||||
if (yynunlexed > 0)
|
||||
{
|
||||
yynunlexed--;
|
||||
yychar = yyunchar[yynunlexed];
|
||||
yylval = yyunval[yynunlexed];
|
||||
yylloc = yyunloc[yynunlexed];
|
||||
}
|
||||
else if (yychar <= 0)
|
||||
yychar = 0;
|
||||
else
|
||||
{
|
||||
yychar = yylex();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else yychar = YYTRANSLATE(yychar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
yyunlex(chr, val, loc)
|
||||
int chr;
|
||||
YYSTYPE val;
|
||||
YYLTYPE loc;
|
||||
{
|
||||
yyunchar[yynunlexed] = chr;
|
||||
yyunval[yynunlexed] = val;
|
||||
yyunloc[yynunlexed] = loc;
|
||||
yynunlexed++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
yyrestore(first, last)
|
||||
register short *first;
|
||||
register short *last;
|
||||
{
|
||||
register short *ssp;
|
||||
register short *rp;
|
||||
register int symbol;
|
||||
register int state;
|
||||
register int tvalsaved;
|
||||
|
||||
ssp = yygssp;
|
||||
yyunlex(yychar, yylval, yylloc);
|
||||
|
||||
tvalsaved = 0;
|
||||
while (first != last)
|
||||
{
|
||||
symbol = yystos[*ssp];
|
||||
if (symbol < YYNTBASE)
|
||||
{
|
||||
yyunlex(symbol, yytval, yytloc);
|
||||
tvalsaved = 1;
|
||||
ssp--;
|
||||
}
|
||||
|
||||
ssp--;
|
||||
|
||||
if (first == yyrq)
|
||||
first = yyrq + YYMAXRULES;
|
||||
|
||||
first--;
|
||||
|
||||
for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
|
||||
{
|
||||
if (symbol < YYNTBASE)
|
||||
state = yytable[yypact[*ssp] + symbol];
|
||||
else
|
||||
{
|
||||
state = yypgoto[symbol - YYNTBASE] + *ssp;
|
||||
|
||||
if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
|
||||
state = yytable[state];
|
||||
else
|
||||
state = yydefgoto[symbol - YYNTBASE];
|
||||
}
|
||||
|
||||
*++ssp = state;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! tvalsaved && ssp > yyss)
|
||||
{
|
||||
yyunlex(yystos[*ssp], yytval, yytloc);
|
||||
ssp--;
|
||||
}
|
||||
|
||||
yygssp = ssp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
yyparse()
|
||||
{
|
||||
register int yystate;
|
||||
register int yyn;
|
||||
register short *yyssp;
|
||||
register short *yyrq0;
|
||||
register short *yyptr;
|
||||
register YYSTYPE *yyvsp;
|
||||
|
||||
int yylen;
|
||||
YYLTYPE *yylsp;
|
||||
short *yyrq1;
|
||||
short *yyrq2;
|
||||
|
||||
yystate = 0;
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs - 1;
|
||||
yylsp = yyls - 1;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
|
||||
yychar = yylex();
|
||||
if (yychar < 0)
|
||||
yychar = 0;
|
||||
else yychar = YYTRANSLATE(yychar);
|
||||
|
||||
yynewstate:
|
||||
|
||||
if (yyssp >= yyss + YYMAXDEPTH - 1)
|
||||
{
|
||||
yyabort("Parser Stack Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
yyresume:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
yyn += yychar;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yystate = yyn;
|
||||
|
||||
yyptr = yyrq2;
|
||||
while (yyptr != yyrq1)
|
||||
{
|
||||
yyn = *yyptr++;
|
||||
yylen = yyr2[yyn];
|
||||
yyvsp -= yylen;
|
||||
yylsp -= yylen;
|
||||
|
||||
yyguard(yyn, yyvsp, yylsp);
|
||||
if (yyerror)
|
||||
goto yysemerr;
|
||||
|
||||
yyaction(yyn, yyvsp, yylsp);
|
||||
*++yyvsp = yyval;
|
||||
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->timestamp = timeclock;
|
||||
yylsp->first_line = yytloc.first_line;
|
||||
yylsp->first_column = yytloc.first_column;
|
||||
yylsp->last_line = (yylsp-1)->last_line;
|
||||
yylsp->last_column = (yylsp-1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp+yylen-1)->last_line;
|
||||
yylsp->last_column = (yylsp+yylen-1)->last_column;
|
||||
}
|
||||
|
||||
if (yyptr == yyrq + YYMAXRULES)
|
||||
yyptr = yyrq;
|
||||
}
|
||||
|
||||
if (yystate == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
yyrq2 = yyptr;
|
||||
yyrq1 = yyrq0;
|
||||
|
||||
*++yyvsp = yytval;
|
||||
*++yylsp = yytloc;
|
||||
yytval = yylval;
|
||||
yytloc = yylloc;
|
||||
yyget();
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
yyreduce:
|
||||
|
||||
*yyrq0++ = yyn;
|
||||
|
||||
if (yyrq0 == yyrq + YYMAXRULES)
|
||||
yyrq0 = yyrq;
|
||||
|
||||
if (yyrq0 == yyrq2)
|
||||
{
|
||||
yyabort("Parser Rule Queue Overflow");
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
yyssp -= yyr2[yyn];
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yysemerr:
|
||||
*--yyptr = yyn;
|
||||
yyrq2 = yyptr;
|
||||
yyvsp += yyr2[yyn];
|
||||
|
||||
yyerrlab:
|
||||
|
||||
yygssp = yyssp;
|
||||
yygvsp = yyvsp;
|
||||
yyglsp = yylsp;
|
||||
yyrestore(yyrq0, yyrq2);
|
||||
yyrecover();
|
||||
yystate = *yygssp;
|
||||
yyssp = yygssp;
|
||||
yyvsp = yygvsp;
|
||||
yyrq0 = yyrq;
|
||||
yyrq1 = yyrq0;
|
||||
yyrq2 = yyrq0;
|
||||
goto yyresume;
|
||||
}
|
||||
|
||||
$
|
||||
@@ -0,0 +1,136 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: InputFileHandler.cpp [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for input files (standard flat text files)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:53:31 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
// FUNCTION: InputFileHandler() constructor
|
||||
// : ~InputFileHandler() destructor
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//========================================================== include files ==
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "InputFileHandler.h"
|
||||
|
||||
#include "sharedFile/TreeFile.h"
|
||||
//#include "sharedFile/Iff.h"
|
||||
|
||||
//================================================= static vars assignment ==
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
InputFileHandler::InputFileHandler(const char *infilename)
|
||||
{
|
||||
TreeFile::addSearchAbsolute(0); // search current working directory
|
||||
|
||||
file = TreeFile::open(infilename, AbstractFile::PriorityData, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
InputFileHandler::~InputFileHandler(void)
|
||||
{
|
||||
if(file)
|
||||
delete file;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// reads a file stream into specified buffer of the size passed
|
||||
//
|
||||
// Return Value:
|
||||
// actual size read (signed int)
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
// Treefile::read()
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
const int InputFileHandler::read(
|
||||
void *sourceBuffer, // pointer to the buffer
|
||||
int bufferSize // number of BYTES to be read
|
||||
)
|
||||
{
|
||||
int retVal = -1; // assume fileHandle is NOT valid
|
||||
|
||||
if (file)
|
||||
retVal = file->read(sourceBuffer, bufferSize);
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Deletes a file
|
||||
//
|
||||
// Return Value:
|
||||
// whatever DeleteFile() returns
|
||||
// if fileHandle != -1, it assumes that the fileHandle passed belonged to
|
||||
// this filename, and therefore, it will attempt to close the file and
|
||||
// set it to 0.
|
||||
//
|
||||
// Remarks:
|
||||
// calls DeleteFile() found in windows.h
|
||||
// InputFileHandler does NOT have any way to validate that the handle
|
||||
// passed belongs to the filename that it wants to be deleted. So use
|
||||
// it with caution
|
||||
//
|
||||
// See Also:
|
||||
// windows.h
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/13/99 [HAI] - created
|
||||
//
|
||||
int InputFileHandler::deleteFile(
|
||||
const char *filename,
|
||||
bool deleteHandleFlag
|
||||
)
|
||||
{
|
||||
if (deleteHandleFlag && file)
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
}
|
||||
return(DeleteFile(filename));
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef __INPUTFILEHANDLER_H__
|
||||
#define __INPUTFILEHANDLER_H__
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: InputFileHandler.h [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for input files (flat text files)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:55:15 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//============================================================== #includes ==
|
||||
|
||||
//========================================================= class typedefs ==
|
||||
|
||||
//====================================================== class definitions ==
|
||||
|
||||
class AbstractFile;
|
||||
|
||||
class InputFileHandler
|
||||
{
|
||||
//------------------------------
|
||||
//--- public var & functions ---
|
||||
//------------------------------
|
||||
public: // functions
|
||||
InputFileHandler(const char *infilename);
|
||||
~InputFileHandler(void);
|
||||
|
||||
const int read(void *sourceBuffer, int bufferSize);
|
||||
int deleteFile(const char * filename, bool deleteHandleFlag = false);
|
||||
|
||||
public: // vars
|
||||
|
||||
|
||||
//-------------------------------
|
||||
//--- member vars declaration ---
|
||||
//-------------------------------
|
||||
protected: // vars
|
||||
AbstractFile *file;
|
||||
|
||||
private: // vars
|
||||
|
||||
//-----------------------------------
|
||||
//--- member function declaration ---
|
||||
//-----------------------------------
|
||||
protected: // functions
|
||||
|
||||
private: // functions
|
||||
void close(void); // close the input file called by destructor
|
||||
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
//========================================================= inline methods ==
|
||||
//===========================================================================
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
#pragma message("InputFileHandler.h included more then once!")
|
||||
#endif
|
||||
#endif // ifndef __H__
|
||||
@@ -0,0 +1,164 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: OutputFileHandler.cpp
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for Output file (IFF file)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:52:42 PM
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "OutputFileHandler.h"
|
||||
|
||||
#include "sharedFile/Iff.h"
|
||||
|
||||
//===========================================================================
|
||||
// Constructor
|
||||
|
||||
OutputFileHandler::OutputFileHandler(const char *filename)
|
||||
{
|
||||
outputIFF = new Iff(MAXIFFDATASIZE);
|
||||
outFilename = NULL;
|
||||
|
||||
setCurrentFilename(filename);
|
||||
}
|
||||
|
||||
void OutputFileHandler::setCurrentFilename(const char *filename)
|
||||
{
|
||||
if (outFilename)
|
||||
delete [] outFilename;
|
||||
|
||||
outFilename = new char[strlen(filename)+1];
|
||||
strcpy(outFilename, filename);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Destructor
|
||||
|
||||
OutputFileHandler::~OutputFileHandler(void)
|
||||
{
|
||||
if (outputIFF && outFilename)
|
||||
{
|
||||
delete outputIFF;
|
||||
delete [] outFilename;
|
||||
}
|
||||
|
||||
outputIFF = NULL;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// begins a new FORM in the IFF
|
||||
//
|
||||
// Return Value:
|
||||
// bool - true == success
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertForm()
|
||||
|
||||
void OutputFileHandler::insertForm(
|
||||
const char *tag
|
||||
)
|
||||
{
|
||||
Tag formTag = convertStrToTag(tag);
|
||||
outputIFF->insertForm(formTag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// begins a new CHUNK in the IFF
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertChunk()
|
||||
|
||||
void OutputFileHandler::insertChunk(
|
||||
const char *tag
|
||||
)
|
||||
{
|
||||
Tag chunkTag = convertStrToTag(tag);
|
||||
outputIFF->insertChunk(chunkTag);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// converts string (4 bytes) form into Tag format
|
||||
//
|
||||
// Return Value:
|
||||
// Tag
|
||||
//
|
||||
// Remarks:
|
||||
// currently, this code is machine dependant code (non portable) and it assumes little endian
|
||||
//
|
||||
// See Also:
|
||||
// Tag
|
||||
|
||||
Tag OutputFileHandler::convertStrToTag(
|
||||
const char *str
|
||||
)
|
||||
{
|
||||
// prepare for hack-o-rama. It is byte order dependant, thus not portable ^_^
|
||||
Tag retVal = str[3] + (str[2] * 0x100) + (str[1] * 0x10000) + (str[0] * 0x1000000);
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// adds new chunk data into the current chunk it is in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::insertChunkData()
|
||||
//
|
||||
|
||||
void OutputFileHandler::insertChunkData(
|
||||
void *data,
|
||||
int length
|
||||
)
|
||||
{
|
||||
outputIFF->insertChunkData(data, length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// exits current FORM section we are in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::exitForm()
|
||||
|
||||
void OutputFileHandler::exitForm(void)
|
||||
{
|
||||
outputIFF->exitForm();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// exits current CHUNK we are in
|
||||
//
|
||||
// See Also:
|
||||
// Iff::exitChunk()
|
||||
|
||||
void OutputFileHandler::exitChunk(void)
|
||||
{
|
||||
outputIFF->exitChunk();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Calls Iff:write()
|
||||
//
|
||||
// Return Value:
|
||||
//
|
||||
// True if the Iff was successfully written, otherwise false
|
||||
//
|
||||
// See Also:
|
||||
// Iff::write()
|
||||
|
||||
bool OutputFileHandler::writeBuffer(void)
|
||||
{
|
||||
if (outputIFF && outFilename)
|
||||
return outputIFF->write(outFilename, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#ifndef __OUTPUTFILEHANDLER_H__
|
||||
#define __OUTPUTFILEHANDLER_H__
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: OutputFileHandler.h [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: file handler for output files (IFF file format)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/13/99 4:55:56 PM
|
||||
//
|
||||
// HISTORY: 1/13/99 [HAI] - File created
|
||||
// :
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//============================================================== #includes ==
|
||||
|
||||
//========================================================= class typedefs ==
|
||||
#include "sharedFile/Iff.h"
|
||||
|
||||
//====================================================== class definitions ==
|
||||
class OutputFileHandler
|
||||
{
|
||||
//------------------------------
|
||||
//--- public var & functions ---
|
||||
//------------------------------
|
||||
public: // functions
|
||||
OutputFileHandler(const char *filename);
|
||||
~OutputFileHandler(void);
|
||||
bool writeBuffer(void);
|
||||
|
||||
void insertForm(const char *tagName);
|
||||
void insertChunk(const char *tagName);
|
||||
void insertChunkData(void *data, int length);
|
||||
void exitForm(void);
|
||||
void exitChunk(void);
|
||||
|
||||
void setCurrentFilename(const char *fname);
|
||||
|
||||
public: // vars
|
||||
|
||||
|
||||
//-------------------------------
|
||||
//--- member vars declaration ---
|
||||
//-------------------------------
|
||||
protected: // vars
|
||||
Iff * outputIFF;
|
||||
char *outFilename;
|
||||
|
||||
enum{
|
||||
MAXIFFDATASIZE = 8192 // allocate 8K of memory for a starter
|
||||
};
|
||||
|
||||
private: // vars
|
||||
|
||||
//-----------------------------------
|
||||
//--- member function declaration ---
|
||||
//-----------------------------------
|
||||
protected: // functions
|
||||
|
||||
private: // functions
|
||||
Tag convertStrToTag(const char *str);
|
||||
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
//========================================================= inline methods ==
|
||||
//===========================================================================
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
#pragma message("OutputFileHandler.h included more then once!")
|
||||
#endif
|
||||
#endif // ifndef __H__
|
||||
@@ -0,0 +1,698 @@
|
||||
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
||||
#line 3 "bison.simple"
|
||||
|
||||
/* Skeleton output parser for bison,
|
||||
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
#define MSDOS 1
|
||||
|
||||
#ifndef alloca
|
||||
#ifdef __GNUC__
|
||||
#define alloca __builtin_alloca
|
||||
#else /* not GNU C. */
|
||||
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
|
||||
#include <alloca.h>
|
||||
#else /* not sparc */
|
||||
#if defined (MSDOS) && !defined (__TURBOC__)
|
||||
#include <malloc.h>
|
||||
#else /* not MSDOS, or __TURBOC__ */
|
||||
#if defined(_AIX)
|
||||
#include <malloc.h>
|
||||
#pragma alloca
|
||||
#else /* not MSDOS, __TURBOC__, or _AIX */
|
||||
#ifdef __hpux
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
void *alloca (unsigned int);
|
||||
};
|
||||
#else /* not __cplusplus */
|
||||
void *alloca ();
|
||||
#endif /* not __cplusplus */
|
||||
#endif /* __hpux */
|
||||
#endif /* not _AIX */
|
||||
#endif /* not MSDOS, or __TURBOC__ */
|
||||
#endif /* not sparc. */
|
||||
#endif /* not GNU C. */
|
||||
#endif /* alloca not defined. */
|
||||
|
||||
#ifdef MSDOS
|
||||
#define alloca(n) malloc(n)
|
||||
#endif
|
||||
|
||||
/* This is the parser code that is written into each bison parser
|
||||
when the %semantic_parser declaration is not specified in the grammar.
|
||||
It was written by Richard Stallman by simplifying the hairy parser
|
||||
used when %semantic_parser is specified. */
|
||||
|
||||
/* Note: there must be only one dollar sign in this file.
|
||||
It is replaced by the list of actions, each action
|
||||
as one case of the switch. */
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY -2
|
||||
#define YYEOF 0
|
||||
#define YYACCEPT return(0)
|
||||
#define YYABORT return(1)
|
||||
#define YYERROR goto yyerrlab1
|
||||
/* Like YYERROR except do call yyerror.
|
||||
This remains here temporarily to ease the
|
||||
transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
#define YYFAIL goto yyerrlab
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
#define YYBACKUP(token, value) \
|
||||
do \
|
||||
if (yychar == YYEMPTY && yylen == 1) \
|
||||
{ yychar = (token), yylval = (value); \
|
||||
yychar1 = YYTRANSLATE (yychar); \
|
||||
YYPOPSTACK; \
|
||||
goto yybackup; \
|
||||
} \
|
||||
else \
|
||||
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
|
||||
while (0)
|
||||
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
|
||||
#ifndef YYPURE
|
||||
#define YYLEX yylex()
|
||||
#endif
|
||||
|
||||
#ifdef YYPURE
|
||||
#ifdef YYLSP_NEEDED
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval, &yylloc)
|
||||
#endif
|
||||
#else /* not YYLSP_NEEDED */
|
||||
#ifdef YYLEX_PARAM
|
||||
#define YYLEX yylex(&yylval, YYLEX_PARAM)
|
||||
#else
|
||||
#define YYLEX yylex(&yylval)
|
||||
#endif
|
||||
#endif /* not YYLSP_NEEDED */
|
||||
#endif
|
||||
|
||||
/* If nonreentrant, generate the variables here */
|
||||
|
||||
#ifndef YYPURE
|
||||
|
||||
int yychar; /* the lookahead symbol */
|
||||
YYSTYPE yylval; /* the semantic value of the */
|
||||
/* lookahead symbol */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc; /* location data for the lookahead */
|
||||
/* symbol */
|
||||
#endif
|
||||
|
||||
int yynerrs; /* number of parse errors so far */
|
||||
#endif /* not YYPURE */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
int yydebug = 1; /* nonzero means print parse trace */
|
||||
/* Since this is uninitialized, it does not stop multiple parsers
|
||||
from coexisting. */
|
||||
#endif
|
||||
|
||||
/* YYINITDEPTH indicates the initial size of the parser's stacks */
|
||||
|
||||
#ifndef YYINITDEPTH
|
||||
#define YYINITDEPTH 200
|
||||
#endif
|
||||
|
||||
/* YYMAXDEPTH is the maximum size the stacks can grow to
|
||||
(effective only if the built-in stack extension method is used). */
|
||||
|
||||
#if YYMAXDEPTH == 0
|
||||
#undef YYMAXDEPTH
|
||||
#endif
|
||||
|
||||
#ifndef YYMAXDEPTH
|
||||
#define YYMAXDEPTH 10000
|
||||
#endif
|
||||
|
||||
/* Prevent warning if -Wstrict-prototypes. */
|
||||
#ifdef __GNUC__
|
||||
int yyparse (void);
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
||||
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
|
||||
#else /* not GNU C or C++ */
|
||||
#ifndef __cplusplus
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (to, from, count)
|
||||
char *to;
|
||||
char *from;
|
||||
int count;
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#else /* __cplusplus */
|
||||
|
||||
/* This is the most reliable way to avoid incompatibilities
|
||||
in available built-in functions on various systems. */
|
||||
static void
|
||||
__yy_memcpy (char *to, char *from, int count)
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#line 196 "bison.simple"
|
||||
|
||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||
into yyparse. The argument should have type void *.
|
||||
It should actually point to an object.
|
||||
Grammar actions can access the variable by casting it
|
||||
to the proper pointer type. */
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#ifdef __cplusplus
|
||||
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#else /* not __cplusplus */
|
||||
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
||||
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
||||
#endif /* not __cplusplus */
|
||||
#else /* not YYPARSE_PARAM */
|
||||
#define YYPARSE_PARAM_ARG
|
||||
#define YYPARSE_PARAM_DECL
|
||||
#endif /* not YYPARSE_PARAM */
|
||||
|
||||
int
|
||||
yyparse(YYPARSE_PARAM_ARG)
|
||||
YYPARSE_PARAM_DECL
|
||||
{
|
||||
register int yystate;
|
||||
register int yyn;
|
||||
register short *yyssp;
|
||||
register YYSTYPE *yyvsp;
|
||||
int yyerrstatus; /* number of tokens to shift before error messages enabled */
|
||||
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
|
||||
|
||||
short yyssa[YYINITDEPTH]; /* the state stack */
|
||||
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
|
||||
|
||||
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
|
||||
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
|
||||
YYLTYPE *yyls = yylsa;
|
||||
YYLTYPE *yylsp;
|
||||
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
|
||||
#else
|
||||
#define YYPOPSTACK (yyvsp--, yyssp--)
|
||||
#endif
|
||||
|
||||
int yystacksize = YYINITDEPTH;
|
||||
|
||||
#ifdef YYPURE
|
||||
int yychar;
|
||||
YYSTYPE yylval;
|
||||
int yynerrs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE yylloc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
YYSTYPE yyval; /* the variable used to return */
|
||||
/* semantic values from the action */
|
||||
/* routines */
|
||||
|
||||
int yylen;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Starting parse\n");
|
||||
#endif
|
||||
|
||||
yystate = 0;
|
||||
yyerrstatus = 0;
|
||||
yynerrs = 0;
|
||||
yychar = YYEMPTY; /* Cause a token to be read. */
|
||||
|
||||
/* Initialize stack pointers.
|
||||
Waste one element of value and location stack
|
||||
so that they stay on the same level as the state stack.
|
||||
The wasted elements are never initialized. */
|
||||
|
||||
yyssp = yyss - 1;
|
||||
yyvsp = yyvs;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls;
|
||||
#endif
|
||||
|
||||
/* Push a new state, which is found in yystate . */
|
||||
/* In all cases, when you get here, the value and location stacks
|
||||
have just been pushed. so pushing a state here evens the stacks. */
|
||||
yynewstate:
|
||||
|
||||
*++yyssp = yystate;
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
{
|
||||
/* Give user a chance to reallocate the stack */
|
||||
/* Use copies of these so that the &'s don't force the real ones into memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
short *yyss1 = yyss;
|
||||
#ifdef YYLSP_NEEDED
|
||||
YYLTYPE *yyls1 = yyls;
|
||||
#endif
|
||||
|
||||
/* Get the current used size of the three stacks, in elements. */
|
||||
int size = yyssp - yyss + 1;
|
||||
|
||||
#ifdef yyoverflow
|
||||
/* Each stack pointer address is followed by the size of
|
||||
the data in use in that stack, in bytes. */
|
||||
#ifdef YYLSP_NEEDED
|
||||
/* This used to be a conditional around just the two extra args,
|
||||
but that might be undefined if yyoverflow is a macro. */
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yyls1, size * sizeof (*yylsp),
|
||||
&yystacksize);
|
||||
#else
|
||||
yyoverflow("parser stack overflow",
|
||||
&yyss1, size * sizeof (*yyssp),
|
||||
&yyvs1, size * sizeof (*yyvsp),
|
||||
&yystacksize);
|
||||
#endif
|
||||
|
||||
yyss = yyss1; yyvs = yyvs1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = yyls1;
|
||||
#endif
|
||||
#else /* no yyoverflow */
|
||||
/* Extend the stack our own way. */
|
||||
if (yystacksize >= YYMAXDEPTH)
|
||||
{
|
||||
yyerror("parser stack overflow");
|
||||
return 2;
|
||||
}
|
||||
yystacksize *= 2;
|
||||
if (yystacksize > YYMAXDEPTH)
|
||||
yystacksize = YYMAXDEPTH;
|
||||
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
|
||||
__yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
|
||||
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
|
||||
__yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
|
||||
#ifdef YYLSP_NEEDED
|
||||
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
|
||||
__yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
|
||||
#endif
|
||||
#endif /* no yyoverflow */
|
||||
|
||||
yyssp = yyss + size - 1;
|
||||
yyvsp = yyvs + size - 1;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp = yyls + size - 1;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
|
||||
#endif
|
||||
|
||||
if (yyssp >= yyss + yystacksize - 1)
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Entering state %d\n", yystate);
|
||||
#endif
|
||||
|
||||
goto yybackup;
|
||||
yybackup:
|
||||
|
||||
/* Do appropriate processing given the current state. */
|
||||
/* Read a lookahead token if we need one and don't already have one. */
|
||||
/* yyresume: */
|
||||
|
||||
/* First try to decide what to do without reference to lookahead token. */
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yydefault;
|
||||
|
||||
/* Not known => get a lookahead token if don't already have one. */
|
||||
|
||||
/* yychar is either YYEMPTY or YYEOF
|
||||
or a valid token in external form. */
|
||||
|
||||
if (yychar == YYEMPTY)
|
||||
{
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Reading a token: ");
|
||||
#endif
|
||||
yychar = YYLEX;
|
||||
}
|
||||
|
||||
/* Convert token to internal form (in yychar1) for indexing tables with */
|
||||
|
||||
if (yychar <= 0) /* This means end of input. */
|
||||
{
|
||||
yychar1 = 0;
|
||||
yychar = YYEOF; /* Don't call YYLEX any more */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Now at end of input.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
yychar1 = YYTRANSLATE(yychar);
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
|
||||
/* Give the individual parser a way to print the precise meaning
|
||||
of a token, for further debugging info. */
|
||||
#ifdef YYPRINT
|
||||
YYPRINT (stderr, yychar, yylval);
|
||||
#endif
|
||||
fprintf (stderr, ")\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
yyn += yychar1;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
|
||||
goto yydefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
|
||||
/* yyn is what to do for this token type in this state.
|
||||
Negative => reduce, -yyn is rule number.
|
||||
Positive => shift, yyn is new state.
|
||||
New state is final state => don't bother to shift,
|
||||
just return success.
|
||||
0, or most negative number => error. */
|
||||
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
/* Shift the lookahead token. */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
/* Discard the token being shifted unless it is eof. */
|
||||
if (yychar != YYEOF)
|
||||
yychar = YYEMPTY;
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
/* count tokens shifted since error; after three, turn off error status. */
|
||||
if (yyerrstatus) yyerrstatus--;
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
|
||||
/* Do the default action for the current state. */
|
||||
yydefault:
|
||||
|
||||
yyn = yydefact[yystate];
|
||||
if (yyn == 0)
|
||||
goto yyerrlab;
|
||||
|
||||
/* Do a reduction. yyn is the number of a rule to reduce with. */
|
||||
yyreduce:
|
||||
yylen = yyr2[yyn];
|
||||
if (yylen > 0)
|
||||
yyval = yyvsp[1-yylen]; /* implement default value of the action */
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf (stderr, "Reducing via rule %d (line %d), ",
|
||||
yyn, yyrline[yyn]);
|
||||
|
||||
/* Print the symbols being reduced, and their result. */
|
||||
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
|
||||
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
|
||||
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
||||
}
|
||||
#endif
|
||||
|
||||
$ /* the action file gets copied in in place of this dollarsign */
|
||||
#line 498 "bison.simple"
|
||||
|
||||
yyvsp -= yylen;
|
||||
yyssp -= yylen;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp -= yylen;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
*++yyvsp = yyval;
|
||||
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp++;
|
||||
if (yylen == 0)
|
||||
{
|
||||
yylsp->first_line = yylloc.first_line;
|
||||
yylsp->first_column = yylloc.first_column;
|
||||
yylsp->last_line = (yylsp-1)->last_line;
|
||||
yylsp->last_column = (yylsp-1)->last_column;
|
||||
yylsp->text = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yylsp->last_line = (yylsp+yylen-1)->last_line;
|
||||
yylsp->last_column = (yylsp+yylen-1)->last_column;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now "shift" the result of the reduction.
|
||||
Determine what state that goes to,
|
||||
based on the state we popped back to
|
||||
and the rule number reduced by. */
|
||||
|
||||
yyn = yyr1[yyn];
|
||||
|
||||
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
||||
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
||||
yystate = yytable[yystate];
|
||||
else
|
||||
yystate = yydefgoto[yyn - YYNTBASE];
|
||||
|
||||
goto yynewstate;
|
||||
|
||||
yyerrlab: /* here on detecting error */
|
||||
|
||||
if (! yyerrstatus)
|
||||
/* If not already recovering from an error, report this error. */
|
||||
{
|
||||
++yynerrs;
|
||||
|
||||
#ifdef YYERROR_VERBOSE
|
||||
yyn = yypact[yystate];
|
||||
|
||||
if (yyn > YYFLAG && yyn < YYLAST)
|
||||
{
|
||||
int size = 0;
|
||||
char *msg;
|
||||
int x, count;
|
||||
|
||||
count = 0;
|
||||
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
size += strlen(yytname[x]) + 15, count++;
|
||||
msg = (char *) malloc(size + 15);
|
||||
if (msg != 0)
|
||||
{
|
||||
strcpy(msg, "parse error");
|
||||
|
||||
if (count < 5)
|
||||
{
|
||||
count = 0;
|
||||
for (x = (yyn < 0 ? -yyn : 0);
|
||||
x < (sizeof(yytname) / sizeof(char *)); x++)
|
||||
if (yycheck[x + yyn] == x)
|
||||
{
|
||||
strcat(msg, count == 0 ? ", expecting `" : " or `");
|
||||
strcat(msg, yytname[x]);
|
||||
strcat(msg, "'");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
yyerror(msg);
|
||||
free(msg);
|
||||
}
|
||||
else
|
||||
yyerror ("parse error; also virtual memory exceeded");
|
||||
}
|
||||
else
|
||||
#endif /* YYERROR_VERBOSE */
|
||||
yyerror("parse error");
|
||||
}
|
||||
|
||||
goto yyerrlab1;
|
||||
yyerrlab1: /* here on error raised explicitly by an action */
|
||||
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* if just tried and failed to reuse lookahead token after an error, discard it. */
|
||||
|
||||
/* return failure if at end of input */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
|
||||
#endif
|
||||
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token
|
||||
after shifting the error token. */
|
||||
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this */
|
||||
|
||||
goto yyerrhandle;
|
||||
|
||||
yyerrdefault: /* current state does not do anything special for the error token. */
|
||||
|
||||
#if 0
|
||||
/* This is wrong; only states that explicitly want error tokens
|
||||
should shift them. */
|
||||
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
||||
if (yyn) goto yydefault;
|
||||
#endif
|
||||
|
||||
yyerrpop: /* pop the current state because it cannot handle the error token */
|
||||
|
||||
if (yyssp == yyss) YYABORT;
|
||||
yyvsp--;
|
||||
yystate = *--yyssp;
|
||||
#ifdef YYLSP_NEEDED
|
||||
yylsp--;
|
||||
#endif
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
{
|
||||
short *ssp1 = yyss - 1;
|
||||
fprintf (stderr, "Error: state stack now");
|
||||
while (ssp1 != yyssp)
|
||||
fprintf (stderr, " %d", *++ssp1);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
yyerrhandle:
|
||||
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn += YYTERROR;
|
||||
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
|
||||
goto yyerrdefault;
|
||||
|
||||
yyn = yytable[yyn];
|
||||
if (yyn < 0)
|
||||
{
|
||||
if (yyn == YYFLAG)
|
||||
goto yyerrpop;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
}
|
||||
else if (yyn == 0)
|
||||
goto yyerrpop;
|
||||
|
||||
if (yyn == YYFINAL)
|
||||
YYACCEPT;
|
||||
|
||||
#if YYDEBUG != 0
|
||||
if (yydebug)
|
||||
fprintf(stderr, "Shifting error token, ");
|
||||
#endif
|
||||
|
||||
*++yyvsp = yylval;
|
||||
#ifdef YYLSP_NEEDED
|
||||
*++yylsp = yylloc;
|
||||
#endif
|
||||
|
||||
yystate = yyn;
|
||||
goto yynewstate;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// NOTE: this makes it more convinient for me to make the help screen fancier...
|
||||
// blah... not that anybody cares...
|
||||
|
||||
printf("\
|
||||
Usage:\n\
|
||||
mIFF {-%c <filename>|--%s=<filename>}\n\
|
||||
[{-%c <filename>|--%s=<filename>} | {-%c|--%s}]\n\
|
||||
[{-%c|--%s}] [{-%c|--%s}] [{-%c|--%s}]\n\n",
|
||||
SNAME_INPUT_FILE, LNAME_INPUT_FILE,
|
||||
SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE,
|
||||
SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET,
|
||||
SNAME_CCCP, LNAME_CCCP,
|
||||
SNAME_VERBOSE, LNAME_VERBOSE,
|
||||
SNAME_DEBUG, LNAME_DEBUG);
|
||||
printf("\
|
||||
mIFF {-%c|--%s}\n\n", SNAME_HELP, LNAME_HELP);
|
||||
|
||||
printf("\
|
||||
Parameters:\n\
|
||||
-%c <filename>,--%s=<filename>\n\
|
||||
[required] specifies the input path for IFF source file.\n", SNAME_INPUT_FILE, LNAME_INPUT_FILE);
|
||||
printf("\
|
||||
-%c <filename>,--%s=<filename>\n\
|
||||
[optional] specifies the pathname for the generated \n\
|
||||
IFF data file. Note that if neither this nor the following \n\
|
||||
option are specified, a default output filename of the source\n\
|
||||
file's base name with extension \".iff\" will be used.\n", SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] specifies the generated output filename should be \n\
|
||||
taken from the #pragma options within the source file. \n\
|
||||
Allowable #pragma options are: \n\
|
||||
#pragma drive \"<drive letter>:\"\n\
|
||||
#pragma directory \"<directory name>\"\n\
|
||||
#pragma filename \"<filename>\"\n\
|
||||
#pragma extension \"<extension>\"\n", SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] use CCCP rather than CPP.\n", SNAME_CCCP, LNAME_CCCP);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] display more information during execution.\n", SNAME_VERBOSE, LNAME_VERBOSE);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[optional] enable debug mode (save intermediate files).\n", SNAME_DEBUG, LNAME_DEBUG);
|
||||
printf("\
|
||||
-%c,--%s\n\
|
||||
[very optional] this help screen.\n", SNAME_HELP, LNAME_HELP);
|
||||
printf("\
|
||||
Examples:\n\
|
||||
mIFF -%c foo.bar\n\
|
||||
this will generate an iff file foo.iff (default if no parm specified)\n\
|
||||
in the current working directory. Even if foo.bar contains #pragma, \n\
|
||||
it will create foo.iff because -%c was not specified.\n", SNAME_INPUT_FILE, SNAME_PRAGMA_TARGET);
|
||||
printf("\
|
||||
mIFF -%c \"C:\\my project\\myData\\foo.iff\" --%s=foo.bar\n\
|
||||
notice that if you have space in your dirname, use \" to encapsulate \n\
|
||||
it.\n", SNAME_OUTPUT_FILE, LNAME_INPUT_FILE);
|
||||
printf("\
|
||||
mIFF -%c foo.bar --%s\n\
|
||||
will generate output file specified by #pragma statements \n\
|
||||
within file foo.bar.\n", SNAME_INPUT_FILE, LNAME_PRAGMA_TARGET);
|
||||
@@ -0,0 +1,961 @@
|
||||
//===========================================================================
|
||||
//
|
||||
// FILENAME: mIFF.cpp [C:\Projects\new\tools\src\miff\src\]
|
||||
// COPYRIGHT: (C) 1999 BY Bootprint Entertainment
|
||||
//
|
||||
// DESCRIPTION: make IFF (Console version)
|
||||
// AUTHOR: Hideki Ikeda
|
||||
// DATE: 1/07/99 12:57:20 PM
|
||||
//
|
||||
// HISTORY: 1/07/99 [HAI] - File created
|
||||
// : 1/07/99 [HAI] - v1.0 introductory version
|
||||
// : 1/12/99 [HAI] - v1.1 switched from DOS to Engine library
|
||||
// : - first attempt was to setup the main entry
|
||||
// : point via ConsoleEntryPoint() via callback
|
||||
// : 1/29/99 [HAI] - changed the parameter in MIFFMessage to allow
|
||||
// : output even in non-verbose mode (for error
|
||||
// : message purpose.
|
||||
// : 05/07/99 [HAI]- added MIFFallocString() and MIFFfreeString()
|
||||
// : to work with memory manager. they are allocated
|
||||
// : in the lexical analyzer for IDENTIFIERS and STR_LIT
|
||||
// : deleted after parser parses the rule.
|
||||
//
|
||||
// FUNCTION: main()
|
||||
// : evaluateArgs()
|
||||
// : help()
|
||||
// : handleError()
|
||||
// : preprocessSource()
|
||||
// : MIFFMessage()
|
||||
// : callbackFunction()
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
//========================================================== include files ==
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFoundation/CommandLine.h"
|
||||
#include "sharedFoundation/Crc.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedMemoryManager/MemoryManager.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include "InputFileHandler.h"
|
||||
#include "OutputFileHandler.h"
|
||||
|
||||
#include <string.h> // for memset()
|
||||
#include <stdio.h> // FILE stuff
|
||||
#include <direct.h> // for getcwd()
|
||||
#include <stdlib.h> // for tolower()
|
||||
#include <process.h> // for system()
|
||||
|
||||
//================================================= static vars assignment ==
|
||||
const int entryPointVersion = 1; // constantly check DataEntryPoint.h to see if this value has changed
|
||||
|
||||
OutputFileHandler *outfileHandler = NULL;
|
||||
const int bufferSize = 16 * 1024 * 1024;
|
||||
const int maxStringSize = 256;
|
||||
const char version[] = "1.3 September 18, 2000";
|
||||
|
||||
// vars set by pragmas or via command line
|
||||
char drive[4]; // should be no more then 2 char "C:"
|
||||
char directory[maxStringSize];
|
||||
char filename[maxStringSize];
|
||||
char extension[8]; // we'll truncate if the extension is more then 8 chars...
|
||||
char inFileName[maxStringSize];
|
||||
|
||||
// switches to be sent to mIFF Compiler
|
||||
char sourceBuffer[bufferSize];
|
||||
char outFileName[(maxStringSize * 2) + 8]; // x2 to combine filename, dir, and ext
|
||||
bool usePragma = false;
|
||||
bool useCCCP = false;
|
||||
bool verboseMode = false; // default to non-verbose mode
|
||||
bool debugMode = false; // set this on and the preprocessed source file (mIFF.$$$) won't be deleted
|
||||
|
||||
static bool runningUnderNT;
|
||||
|
||||
enum errorType {
|
||||
ERR_FILENOTFOUND = -1,
|
||||
ERR_ARGSTOOFEW = -2,
|
||||
ERR_BUFFERTOOSMALL = -3,
|
||||
ERR_UNKNOWNDIR = -4,
|
||||
ERR_PREPROCESS = -5,
|
||||
ERR_MULTIPLEINFILE = -6,
|
||||
ERR_PARSER = -7,
|
||||
ERR_ENGINE = -8,
|
||||
|
||||
ERR_HELPREQUEST = -9,
|
||||
ERR_OPTIONS = -10,
|
||||
|
||||
ERR_WRITEERROR = -11,
|
||||
|
||||
ERR_NONE = 0
|
||||
};
|
||||
char err_msg[512];
|
||||
errorType errorFlag = ERR_NONE; // assume no error (default)
|
||||
|
||||
|
||||
// long and short name definitions for command line options
|
||||
|
||||
static const char * const LNAME_HELP = "help";
|
||||
static const char * const LNAME_INPUT_FILE = "inputfile";
|
||||
static const char * const LNAME_OUTPUT_FILE = "outputfile";
|
||||
static const char * const LNAME_PRAGMA_TARGET = "pragmatarget";
|
||||
static const char * const LNAME_CCCP = "cccp";
|
||||
static const char * const LNAME_VERBOSE = "verbose";
|
||||
static const char * const LNAME_DEBUG = "debug";
|
||||
|
||||
static const char SNAME_HELP = 'h';
|
||||
static const char SNAME_INPUT_FILE = 'i';
|
||||
static const char SNAME_OUTPUT_FILE = 'o';
|
||||
static const char SNAME_PRAGMA_TARGET = 'p';
|
||||
static const char SNAME_CCCP = 'c';
|
||||
static const char SNAME_VERBOSE = 'v';
|
||||
static const char SNAME_DEBUG = 'd';
|
||||
|
||||
// following is the command line option spec tree needed for command line processing
|
||||
static CommandLine::OptionSpec optionSpecArray[] =
|
||||
{
|
||||
OP_BEGIN_SWITCH(OP_NODE_REQUIRED),
|
||||
|
||||
// help
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_HELP, LNAME_HELP, OP_ARG_NONE, OP_MULTIPLE_DENIED),
|
||||
|
||||
// real options
|
||||
OP_BEGIN_SWITCH_NODE(OP_MULTIPLE_DENIED),
|
||||
OP_BEGIN_LIST(),
|
||||
// input filename required
|
||||
OP_SINGLE_LIST_NODE(SNAME_INPUT_FILE, LNAME_INPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED, OP_NODE_REQUIRED),
|
||||
|
||||
// optional, mutually exclusive output file specification options
|
||||
// if none specified, generate derive output filename from input filename
|
||||
OP_BEGIN_LIST_NODE(OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
OP_BEGIN_SWITCH(OP_NODE_OPTIONAL),
|
||||
// specify output filename on command line
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_OUTPUT_FILE, LNAME_OUTPUT_FILE, OP_ARG_REQUIRED, OP_MULTIPLE_DENIED),
|
||||
|
||||
// use pragma target for output filename
|
||||
OP_SINGLE_SWITCH_NODE(SNAME_PRAGMA_TARGET, LNAME_PRAGMA_TARGET, OP_ARG_NONE, OP_MULTIPLE_DENIED),
|
||||
OP_END_SWITCH(),
|
||||
OP_END_LIST_NODE(),
|
||||
|
||||
// if specified, use cccp instead of cpp
|
||||
OP_SINGLE_LIST_NODE(SNAME_CCCP, LNAME_CCCP, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
|
||||
// if specified, be verbose
|
||||
OP_SINGLE_LIST_NODE(SNAME_VERBOSE, LNAME_VERBOSE, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
|
||||
// if specified, enter debug info
|
||||
OP_SINGLE_LIST_NODE(SNAME_DEBUG, LNAME_DEBUG, OP_ARG_NONE, OP_MULTIPLE_DENIED, OP_NODE_OPTIONAL),
|
||||
OP_END_LIST(),
|
||||
OP_END_SWITCH_NODE(),
|
||||
|
||||
OP_END_SWITCH()
|
||||
};
|
||||
static const int optionSpecCount = sizeof(optionSpecArray) / sizeof(optionSpecArray[0]);
|
||||
|
||||
//================================================= function prototypes ==
|
||||
int main(int argc, char *argv[]);
|
||||
static errorType evaluateArgs(void);
|
||||
static void help(void);
|
||||
static void handleError(errorType error);
|
||||
static int preprocessSource(char *sourceName);
|
||||
static void callbackFunction(void);
|
||||
static errorType loadInputToBuffer(void *destAddr, int maxBufferSize);
|
||||
|
||||
// functions called by parser.yac and parser.lex
|
||||
extern "C" void MIFFMessage(char *msg, int forceOut);
|
||||
extern "C" void MIFFSetError(void);
|
||||
extern "C" void MIFFSetIFFName(const char *newFileName);
|
||||
extern "C" void MIFFinsertForm(const char *formName);
|
||||
extern "C" void MIFFinsertChunk(const char *chunkName);
|
||||
extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize);
|
||||
extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize);
|
||||
extern "C" void MIFFexitChunk(void);
|
||||
extern "C" void MIFFexitForm(void);
|
||||
extern "C" unsigned long MIFFgetLabelHash(char *inputStream);
|
||||
|
||||
// external functions found in parser.lex file
|
||||
extern "C" void MIFFCompile(char *inputStream, char *inputFname);
|
||||
extern "C" void MIFFCompileInit(char *inputStream, char *inputFname);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// main entry point from console call
|
||||
//
|
||||
// Return Value:
|
||||
// errorType - see enumeration; 0 if no errors
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
int main( int argc, // number of args in commandline
|
||||
char * argv[] // list of pointers to strings
|
||||
)
|
||||
{
|
||||
memset(sourceBuffer, 0, bufferSize);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(4096);
|
||||
|
||||
SetupSharedFoundation::Data SetupSharedFoundationData (SetupSharedFoundation::Data::D_console);
|
||||
SetupSharedFoundationData.useWindowHandle = false;
|
||||
SetupSharedFoundationData.argc = argc;
|
||||
SetupSharedFoundationData.argv = argv;
|
||||
SetupSharedFoundationData.demoMode = true;
|
||||
SetupSharedFoundation::install (SetupSharedFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
TreeFile::addSearchAbsolute(0);
|
||||
TreeFile::addSearchPath (".", 0);
|
||||
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(callbackFunction);
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
SetupSharedThread::remove();
|
||||
return static_cast<int> (errorFlag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// callback function for Engine's console entry point
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// this is like a substitute of main()
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/12/99 [HAI] - created
|
||||
//
|
||||
static void callbackFunction(void)
|
||||
{
|
||||
outfileHandler = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
// check if we're running under NT
|
||||
OSVERSIONINFO osInfo;
|
||||
Zero(osInfo);
|
||||
|
||||
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
|
||||
const BOOL getVersionResult = GetVersionEx(&osInfo);
|
||||
if (getVersionResult)
|
||||
runningUnderNT = (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
if (runningUnderNT)
|
||||
DEBUG_REPORT_LOG(true, ("MIFF: running under Windows NT platform\n"));
|
||||
else
|
||||
DEBUG_REPORT_LOG(true, ("MIFF: running under non-NT Windows platform\n"));
|
||||
|
||||
#endif
|
||||
|
||||
errorFlag = evaluateArgs();
|
||||
if (ERR_NONE == errorFlag)
|
||||
{
|
||||
outfileHandler = new OutputFileHandler(outFileName);
|
||||
MIFFCompile(sourceBuffer, inFileName);
|
||||
}
|
||||
else
|
||||
handleError(errorFlag);
|
||||
|
||||
if (outfileHandler)
|
||||
{
|
||||
// only write output IF there was no error
|
||||
if (ERR_NONE == errorFlag)
|
||||
{
|
||||
if (!outfileHandler->writeBuffer())
|
||||
{
|
||||
fprintf(stderr, "MIFF: failed to write output file \"%s\"\n", outFileName);
|
||||
errorFlag = ERR_WRITEERROR;
|
||||
}
|
||||
}
|
||||
delete outfileHandler;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Evaluates the command line and sets up the environment variables required for mIFF to function
|
||||
//
|
||||
// Return Value:
|
||||
// errorType
|
||||
//
|
||||
// Remarks:
|
||||
// argc's and argv's are substituted with CommandLine::functions()
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static errorType evaluateArgs(void)
|
||||
{
|
||||
errorType retVal = ERR_NONE;
|
||||
|
||||
// parse the commandline
|
||||
const CommandLine::MatchCode mc = CommandLine::parseOptions(optionSpecArray, optionSpecCount);
|
||||
if (mc != CommandLine::MC_MATCH)
|
||||
{
|
||||
// -TF- add call to retrieve command line error buffer for display (as soon as it is written!)
|
||||
printf("WARNING: usage error detected, printing help.\n");
|
||||
help();
|
||||
return ERR_OPTIONS;
|
||||
}
|
||||
else if (CommandLine::getOccurrenceCount(SNAME_HELP))
|
||||
{
|
||||
// user specified help
|
||||
help();
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
// at this point, we can assume a valid combination of options has been specified on the commandline
|
||||
|
||||
|
||||
// setup input filename
|
||||
strcpy(inFileName, CommandLine::getOptionString(SNAME_INPUT_FILE));
|
||||
|
||||
|
||||
// handle output filename spec
|
||||
if (CommandLine::getOccurrenceCount(SNAME_OUTPUT_FILE))
|
||||
{
|
||||
strcpy(outFileName, CommandLine::getOptionString(SNAME_OUTPUT_FILE));
|
||||
}
|
||||
else if (CommandLine::getOccurrenceCount(SNAME_PRAGMA_TARGET))
|
||||
{
|
||||
// use pragma target within iff source for output filename
|
||||
usePragma = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no output option specified on commandline, derive from input filename
|
||||
char *terminator;
|
||||
|
||||
// start with input file pathname
|
||||
strcpy(outFileName, inFileName);
|
||||
|
||||
// try to terminate at rightmost '.'
|
||||
terminator = strrchr(outFileName, '.');
|
||||
if (terminator)
|
||||
*terminator = 0;
|
||||
|
||||
// append the default iff extension
|
||||
strcat(outFileName, ".iff");
|
||||
}
|
||||
|
||||
|
||||
// handle options (get them out of the way, as we use them later)
|
||||
useCCCP = (CommandLine::getOccurrenceCount(SNAME_CCCP) != 0);
|
||||
verboseMode = (CommandLine::getOccurrenceCount(SNAME_VERBOSE) != 0);
|
||||
debugMode = (CommandLine::getOccurrenceCount(SNAME_DEBUG) != 0);
|
||||
|
||||
|
||||
// preprocess the input file
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
sprintf(err_msg,"Now compiling %s...\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// preprocessSource returned an error...
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
if (retVal != ERR_NONE)
|
||||
return retVal;
|
||||
|
||||
return retVal;
|
||||
|
||||
#if 0
|
||||
|
||||
errorType retVal = ERR_NONE; // assume no error has been found
|
||||
bool outPathUsed = false; // flag to monitor if -o flag was used, if so, we can ignore -d, -p, -e, -f
|
||||
bool inFileEntered = false;
|
||||
int argc = CommandLine::getPlainCount();
|
||||
|
||||
// get default values from DOS
|
||||
char currentDir[maxStringSize];
|
||||
if (NULL == getcwd(currentDir, maxStringSize)) // get current working directory
|
||||
{
|
||||
retVal = ERR_UNKNOWNDIR;
|
||||
return(retVal);
|
||||
}
|
||||
drive[0] = currentDir[0]; // drive letter
|
||||
drive[1] = 0; // and null terminate it
|
||||
strcpy(extension, "IFF"); // default to uppercase .IFF
|
||||
strcpy(directory, ¤tDir[2]); // get everything after the Drive: including the first backslash
|
||||
filename[0] = 0;
|
||||
|
||||
// see specs.txt for requests
|
||||
// scan for any argv's that has '-' in the argv[n][0]'s character
|
||||
for (int index = 0; index < argc; index++) // note: if using argv[] rather then CommandLine::getPlainString() then start with 1 rather then 0
|
||||
{
|
||||
if ('-' == CommandLine::getPlainString(index)[0])
|
||||
{
|
||||
// we've found a parameter switch
|
||||
switch (tolower(CommandLine::getPlainString(index)[1])) // assume non case sensitive switches
|
||||
{
|
||||
case 'i': // install via #pragma
|
||||
{
|
||||
usePragma = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c': // use CCCP instead of CPP
|
||||
useCCCP = true;
|
||||
break;
|
||||
|
||||
case 'v': // don't show any debug message
|
||||
verboseMode = true;
|
||||
break;
|
||||
|
||||
case '$':
|
||||
debugMode = true;
|
||||
break;
|
||||
|
||||
case 'o': // target output file name and path (complete path)
|
||||
{
|
||||
index++; // next param
|
||||
outPathUsed = true;
|
||||
strcpy(outFileName, CommandLine::getPlainString(index));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 'd': // target drive letter (-p must be present)
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(drive, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the drive letter arg that SHOULD follow the -d option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p': // target pathname
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(directory, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the pathname arg that follows the -p option
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f': // target filename
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(filename, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the filename arg that follows the -f
|
||||
break;
|
||||
}
|
||||
|
||||
case 'e': // target extension
|
||||
{
|
||||
if (!outPathUsed)
|
||||
{
|
||||
index++; // next param
|
||||
strcpy(extension, CommandLine::getPlainString(index));
|
||||
}
|
||||
else
|
||||
index++; // skip the extension arg that follows the -e
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h': // help!
|
||||
case '?':
|
||||
{
|
||||
help();
|
||||
index = argc; // force to exit
|
||||
retVal = ERR_HELPREQUEST;
|
||||
return(retVal); // special case, ONLY time I call return() in the middle of the function (because I check for argc < 2 at the end of the code)
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
sprintf(err_msg, "\nUnknown parameter %s, use -h to seek help...\n", CommandLine::getPlainString(index));
|
||||
MIFFMessage(err_msg, 1);
|
||||
index = argc; // force to exit
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we found an arg that doesn't start with '-' so let's assume it's a filename
|
||||
if (!inFileEntered)
|
||||
{
|
||||
strcpy(inFileName, CommandLine::getPlainString(index));
|
||||
inFileEntered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = ERR_MULTIPLEINFILE;
|
||||
index = argc;
|
||||
}
|
||||
|
||||
// now construct the DEFAULT filename for this file by scanning backwards to front and only extracting the filename (no extension, no path)
|
||||
if (ERR_NONE == retVal)
|
||||
{
|
||||
char sourceName[maxStringSize];
|
||||
strcpy(sourceName, inFileName); // make a duplicate for us to play with
|
||||
for (int strIndex = strlen(sourceName); strIndex > 0; strIndex--)
|
||||
{
|
||||
if ('.' == sourceName[strIndex])
|
||||
sourceName[strIndex] = 0; // put a stopper here... we are assuming that '.' indicates extension! I'm going to assume that the person is just testing me if s/he decides to use filename like "foo.bar.psych" which will truncate to "foo"
|
||||
if ('\\' == sourceName[strIndex])
|
||||
break; // get out, for we've reached the path name...
|
||||
}
|
||||
|
||||
// ok, by here, strIndex should point to either beginning of the string, or where the first '\' was found scanning backwards
|
||||
strcpy(filename, &sourceName[strIndex]); // ta-da-!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inFileEntered)
|
||||
{
|
||||
if (0 == preprocessSource(inFileName))
|
||||
{
|
||||
if (verboseMode)
|
||||
{
|
||||
// using err_msg as my temp buffer...
|
||||
sprintf(err_msg,"Now compiling %s\n", inFileName);
|
||||
MIFFMessage(err_msg, 0);
|
||||
}
|
||||
|
||||
if (ERR_NONE == retVal)
|
||||
retVal = loadInputToBuffer(sourceBuffer, bufferSize);
|
||||
}
|
||||
else // preprocessSource returned an error...
|
||||
{
|
||||
retVal = ERR_PREPROCESS;
|
||||
}
|
||||
}
|
||||
else // inFileEntered == false
|
||||
{
|
||||
MIFFMessage("Missing input filename in command line!", 1);
|
||||
}
|
||||
|
||||
// construct a outFileName[] based on drive[], directory[], filename[], and extension[]
|
||||
if (!outPathUsed && (ERR_NONE == retVal))
|
||||
{
|
||||
if (inFileName[0]) // make sure the user has entered a input filename
|
||||
sprintf(outFileName,"%s:%s\\%s.%s", drive, directory, filename, extension);
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
retVal = ERR_ARGSTOOFEW; // we can do this because we know -h was not entered...
|
||||
|
||||
return(retVal);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// reads the tmeporary files spit out by CCCP and stuffs the plain text into source buffer
|
||||
//
|
||||
// Return Value:
|
||||
// errorType
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/14/99 [HAI] - created
|
||||
//
|
||||
static errorType loadInputToBuffer(
|
||||
void * dest, // destination address of where you want the date to be read
|
||||
int maxBufferSize // maximum destination data pool size
|
||||
)
|
||||
{
|
||||
errorType retVal = ERR_NONE;
|
||||
InputFileHandler *inFileHandler = new InputFileHandler("mIFF.$$$");
|
||||
if (inFileHandler)
|
||||
{
|
||||
int sizeRead = inFileHandler->read(dest, maxBufferSize);
|
||||
if (sizeRead >= maxBufferSize)
|
||||
{
|
||||
retVal = ERR_BUFFERTOOSMALL;
|
||||
}
|
||||
else
|
||||
{
|
||||
reinterpret_cast<char *>(dest)[sizeRead] = 0; // so stupid... but if you don't zero-terminate at exact spot, YYInput may chokes because of extra grammer that may exist...
|
||||
}
|
||||
if (!debugMode)
|
||||
inFileHandler->deleteFile("mIFF.$$$", true); // no need for temp file now...
|
||||
|
||||
// we've successfully read the file, now close it...
|
||||
delete inFileHandler;
|
||||
}
|
||||
else // inFileName is NULL
|
||||
{
|
||||
retVal = ERR_FILENOTFOUND;
|
||||
}
|
||||
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// help function called by main upon -h switch
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// #include's mIFF.dox
|
||||
// make sure to update the version when modified.
|
||||
// Notice that help() does NOT go thru MIFFMessage() because we want it to
|
||||
// print out whether it's verbose mode or not...
|
||||
//
|
||||
// See Also:
|
||||
// mIFF.dox
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static void help(void)
|
||||
{
|
||||
printf("\nmIFF v%s (DOS version) - Bootprint Ent. (c) 1999\n", version);
|
||||
printf("Hideki Ikeda\n");
|
||||
#include "mIFF.dox"
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// upon exit from main(), if error has been found, it calls here to inform the user of the type of errors it has encounted.
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// use -q switch to suppress error messages - but in shell, return value can be used to determine the handling
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [HAI] - created
|
||||
//
|
||||
static void handleError(errorType error)
|
||||
{
|
||||
if (ERR_NONE == error)
|
||||
return;
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case ERR_NONE:
|
||||
break;
|
||||
|
||||
case ERR_FILENOTFOUND:
|
||||
MIFFMessage("ERROR: INPUT File not found!\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_ARGSTOOFEW:
|
||||
MIFFMessage("ERROR: Not enough arguments. Use -h for help.\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_BUFFERTOOSMALL:
|
||||
MIFFMessage("ERROR: Internally allocated buffer for reading\nsource code is too small, increase buffer and re-compile\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_UNKNOWNDIR:
|
||||
MIFFMessage("ERROR: Directory unknown...\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_PREPROCESS:
|
||||
MIFFMessage("ERROR: Possible problems running the GNU C Preprocessor.\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_MULTIPLEINFILE:
|
||||
MIFFMessage("ERROR: There can only be ONE inputfile name.\nPerhaps you've forgotten the -o option flag\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_ENGINE:
|
||||
MIFFMessage("ERROR: Engine returned a non-zero value...\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_PARSER:
|
||||
MIFFMessage("ERROR: Parser error\n", 1);
|
||||
break;
|
||||
|
||||
case ERR_HELPREQUEST:
|
||||
break;
|
||||
|
||||
case ERR_OPTIONS:
|
||||
MIFFMessage("ERROR: Failed to handle command line options\n", 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
MIFFMessage("ERROR: Unknown error, you suck!\n", 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// gotta write all these externs because you can't call C++ class based non-static
|
||||
// functions from C... So we will use here as the bridge between the two
|
||||
// languages
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Message output handler called by ALL external "C" functions
|
||||
//
|
||||
// Return Value:
|
||||
// none
|
||||
//
|
||||
// Remarks:
|
||||
// all the messages that are displayed are channeled thru this function. Note the -q quiet mode suppresses all messages.
|
||||
// this is an extern "C" function
|
||||
//
|
||||
// See Also:
|
||||
// yyerror()
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [] - created
|
||||
//
|
||||
extern "C" void MIFFMessage(char *message, // null terminated string to be displayed
|
||||
int forceOutput) // if non-zero, it will print out even in quiet mode (for ERRORs)
|
||||
{
|
||||
if (forceOutput)
|
||||
fprintf(stdout, "%s\n", message);
|
||||
else if (verboseMode)
|
||||
fprintf(stdout, "%s\n", message);
|
||||
OutputDebugString(message);
|
||||
OutputDebugString("\n");
|
||||
}
|
||||
|
||||
// Only call this via parser!!!
|
||||
extern "C" void MIFFSetError(void)
|
||||
{
|
||||
errorFlag = ERR_PARSER;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// validation of the filename passed are legal.
|
||||
//
|
||||
// Return Value:
|
||||
// bool usePragma - whether #pragma is ignored or not
|
||||
//
|
||||
// Remarks:
|
||||
// if -i switch is used then #pragma's are expected
|
||||
// this is an extern "C" function
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [ ] - created
|
||||
//
|
||||
extern "C" int validateTargetFilename( char *targetFileName, // pointer to where we can store the string filename
|
||||
unsigned maxTargetBufSize // size of the filename string buffer
|
||||
)
|
||||
{
|
||||
if (strlen(outFileName) > maxTargetBufSize)
|
||||
MIFFMessage("Internal error, increase string buffer size in parser.yac and recompile!", 1);
|
||||
|
||||
strcpy(targetFileName, outFileName);
|
||||
|
||||
return(usePragma);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// function calls CCCP or CPP via shell to preprocess the source code for #include's and #define's via C-Compatible Compiler Preprocessor
|
||||
//
|
||||
// Return Value:
|
||||
// shell return value (4DOS is very generous on returning different values, while DOS just returns 0 all the time)
|
||||
//
|
||||
// Remarks:
|
||||
// use -c switch to use CCCP rather then CPP in your search path
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
//
|
||||
// Revisions and History:
|
||||
// 1/07/99 [ ] - created
|
||||
//
|
||||
static int preprocessSource(char *sourceName)
|
||||
{
|
||||
char shellCommand[512];
|
||||
int retVal = 0;
|
||||
|
||||
memset(shellCommand, 0, sizeof(shellCommand));
|
||||
|
||||
// if (!runningUnderNT)
|
||||
{
|
||||
|
||||
if (verboseMode)
|
||||
MIFFMessage("Preprocessing... via CCCP", 0);
|
||||
|
||||
// CCCP parameters:
|
||||
// -nostdinc -nostdinc++ - do NOT search for standard include directory; without this, your
|
||||
// puter would be just twiddling its thumb because CCCP can't find it...
|
||||
// -pedantic - issue warnings (use pedantic-errors if you want it as errors)
|
||||
// required by the ANSI C standard in certain cases such as comments that
|
||||
// follow the #else/#endif
|
||||
// -dD - output #defines (for the purpose of error msg I parse)
|
||||
// -H - display the name of the header/included files (verbose mode)
|
||||
// -P - originally, I had this... so it won't show the # line_num "filename" ???
|
||||
if (!useCCCP && verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else if (!useCCCP && !verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cpp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else if (useCCCP && verboseMode)
|
||||
{
|
||||
sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD -H %s mIFF.$$$", sourceName);
|
||||
}
|
||||
else
|
||||
sprintf(shellCommand, "cccp.exe -nostdinc -nostdinc++ -pedantic -Wall -dD %s mIFF.$$$", sourceName);
|
||||
}
|
||||
// else
|
||||
{
|
||||
// running under NT. Use the MSVC cl since it deals with long filenames on fat16/fat32 partitions correctly
|
||||
// and ccp and cccp don't
|
||||
// sprintf(shellCommand, "cl /nologo /W4 /EP %s > mIFF.$$$", sourceName);
|
||||
}
|
||||
|
||||
retVal = system(shellCommand);
|
||||
if (2 == retVal) // actually, I think 4DOS reports 2 for cannot find file, but DOS returns a 0...
|
||||
{
|
||||
REPORT_LOG(true, ("failed to execute following shell command (%d):\n", retVal));
|
||||
REPORT_LOG(true, (" %s\n", shellCommand));
|
||||
MIFFMessage("\n\nERROR: Cannot find preprocessor (either CCCP.EXE, CPP.EXE or CL.EXE (under NT) in the search path...\n", 1);
|
||||
MIFFMessage("Please make sure the preprocessor is in your search path!\n", 1);
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
extern "C" void MIFFSetIFFName(const char *newFileName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->setCurrentFilename(newFileName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertForm(const char *formName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertForm(formName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertChunk(const char *chunkName)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertChunk(chunkName);
|
||||
}
|
||||
|
||||
extern "C" void MIFFinsertChunkData(void * buffer, unsigned bufferSize)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->insertChunkData(buffer, bufferSize);
|
||||
}
|
||||
|
||||
extern "C" int MIFFloadRawData(char *fname, void * buffer, unsigned maxBufferSize)
|
||||
{
|
||||
int sizeRead = -1;
|
||||
|
||||
if (ERR_NONE != errorFlag)
|
||||
return(sizeRead); // should be -1
|
||||
|
||||
InputFileHandler * inFileName = new InputFileHandler(fname);
|
||||
if (inFileName)
|
||||
{
|
||||
sizeRead = inFileName->read(buffer, maxBufferSize);
|
||||
if (static_cast<unsigned>(sizeRead) >= maxBufferSize)
|
||||
{
|
||||
handleError(ERR_BUFFERTOOSMALL);
|
||||
sizeRead = -1;
|
||||
}
|
||||
delete inFileName;
|
||||
}
|
||||
|
||||
return(sizeRead);
|
||||
}
|
||||
|
||||
extern "C" void MIFFexitChunk(void)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->exitChunk();
|
||||
}
|
||||
extern "C" void MIFFexitForm(void)
|
||||
{
|
||||
if (ERR_NONE != errorFlag)
|
||||
return;
|
||||
|
||||
if (outfileHandler)
|
||||
outfileHandler->exitForm();
|
||||
}
|
||||
|
||||
extern "C" char * MIFFallocString(int sizeOfString)
|
||||
{
|
||||
return(new char[sizeOfString]);
|
||||
}
|
||||
|
||||
extern "C" void MIFFfreeString(char * pointer)
|
||||
{
|
||||
delete [] pointer;
|
||||
}
|
||||
|
||||
extern "C" unsigned long MIFFgetLabelHash(char * inputStream)
|
||||
{
|
||||
return (unsigned long)Crc::calculate(inputStream);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//============================================================ End-of-file ==
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,517 @@
|
||||
%option full
|
||||
|
||||
%{
|
||||
/*-----------------------------------------------------------------------------**
|
||||
** FILE: parser.lex **
|
||||
** (c) 1998 - Bootprint GTInteractive **
|
||||
** **
|
||||
** DESCRIPTION: lexical analyzer for mIFF **
|
||||
** **
|
||||
** AUTHOR: Hideki Ikeda **
|
||||
** **
|
||||
** HISTORY: **
|
||||
** **
|
||||
** Notes: companion to parser.yac **
|
||||
**-----------------------------------------------------------------------------*/
|
||||
/* Disable compiler warnings (we want warning level 4) for anything that flex spits out */
|
||||
#pragma warning (disable: 4127) /* conditional expression is constant - ie. while(1) */
|
||||
#pragma warning (disable: 4131) /* usage of old-style declarator */
|
||||
#pragma warning (disable: 4098) /* void function returning a vlue - this is because yyterminate() is defined as return() */
|
||||
#pragma warning (disable: 4505) /* unreferenced local function has been removed (to be direct: yyunput()) */
|
||||
|
||||
/* include files */
|
||||
#include "parser.h" /* NOTE: make sure this matches what Bison/yacc spits out */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*--------------------------------**
|
||||
** exteranl prototype declaration **
|
||||
**--------------------------------*/
|
||||
void MIFFMessage(char *message, int forceOutput);
|
||||
void MIFFSetError(void);
|
||||
char * MIFFallocString(int sizeOfString);
|
||||
void MIFFfreeString(char * pointer);
|
||||
|
||||
int yyparse();
|
||||
|
||||
/* prototype declaration */
|
||||
int MIFFYYInput(char *buf,int max_size);
|
||||
void initParser(void);
|
||||
void count(void);
|
||||
void yyerror(char *err);
|
||||
void open_brace(void);
|
||||
void close_brace(void);
|
||||
int count_brace(void);
|
||||
|
||||
void printString(char *str);
|
||||
|
||||
/* global vars that has to be pre-declared because it's referenced by the lexical analyzer */
|
||||
int initialCompile = 0;
|
||||
int globalErrorFlag = 0;
|
||||
char inFileName[512]; /* keep track of source file name for error message */
|
||||
|
||||
#undef YY_INPUT
|
||||
#define YY_INPUT(buf,result,max_size) (result = MIFFYYInput(buf,max_size))
|
||||
|
||||
#define SPACE_COUNT_FOR_TAB (8)
|
||||
|
||||
%}
|
||||
|
||||
DIGIT [0-9]
|
||||
HEXDIGIT [0-9a-fA-F]
|
||||
LETTER [A-z_]
|
||||
FLOATSYM (f|F|l|L)
|
||||
INTSYM (u|U|l|L)*
|
||||
EXP (e|E)(\+|-)?
|
||||
|
||||
%%
|
||||
"//"[^\n]*\n {
|
||||
/* don't do count(); */
|
||||
}
|
||||
|
||||
"#define"[^\n]*\n {
|
||||
/* don't you love regular expression? [^\n]* everything but \n, and then end with \n */
|
||||
/* don't do count(); just like comments */
|
||||
/* return(DEFINE); <-- note: #define's are ignored in parser for they are handled via preprocessors CCCP */
|
||||
}
|
||||
|
||||
\"([^\"]|(\\\"))*\" {
|
||||
/* start with " then ( [^\"] | (\\\") )* which means either anything but " OR \" of multiple encounter, and then close with " */
|
||||
/* case for "string" literals */
|
||||
char *s; // allocate space for string and pass the string pointer rather then yytext
|
||||
|
||||
count();
|
||||
s = MIFFallocString(strlen(yytext) + 1);
|
||||
strcpy(s, yytext+1); /* strip off the double quotes */
|
||||
s[strlen(yytext+1)-1] = 0; /* strip off the ending double quotes */
|
||||
yylval.stype = s;
|
||||
return(STR_LIT);
|
||||
}
|
||||
|
||||
"form" |
|
||||
"FORM" {
|
||||
count();
|
||||
return(FORM);
|
||||
}
|
||||
|
||||
"chunk" |
|
||||
"CHUNK" {
|
||||
count();
|
||||
return(CHUNK);
|
||||
}
|
||||
|
||||
"int32" {
|
||||
count();
|
||||
return(INT32);
|
||||
}
|
||||
"int16" {
|
||||
count();
|
||||
return(INT16);
|
||||
}
|
||||
"int8" {
|
||||
count();
|
||||
return(INT8);
|
||||
}
|
||||
"uint32" {
|
||||
count();
|
||||
return(UINT32);
|
||||
}
|
||||
"uint16" {
|
||||
count();
|
||||
return(UINT16);
|
||||
}
|
||||
"uint8" {
|
||||
count();
|
||||
return(UINT8);
|
||||
}
|
||||
"float" {
|
||||
count();
|
||||
return(FLOAT);
|
||||
}
|
||||
"double" {
|
||||
count();
|
||||
return(DOUBLE);
|
||||
}
|
||||
"string" |
|
||||
"cstring" |
|
||||
"CString" {
|
||||
count();
|
||||
return(STRING);
|
||||
}
|
||||
"wstring" |
|
||||
"WString" {
|
||||
count();
|
||||
return(WSTRING);
|
||||
}
|
||||
"labelhash" {
|
||||
count();
|
||||
return(LABELHASH);
|
||||
}
|
||||
|
||||
"sin" {
|
||||
count();
|
||||
return(SIN);
|
||||
}
|
||||
"cos" {
|
||||
count();
|
||||
return(COS);
|
||||
}
|
||||
"tan" {
|
||||
count();
|
||||
return(TAN);
|
||||
}
|
||||
"asin" {
|
||||
count();
|
||||
return(ASIN);
|
||||
}
|
||||
"acos" {
|
||||
count();
|
||||
return(ACOS);
|
||||
}
|
||||
"atan" {
|
||||
count();
|
||||
return(ATAN);
|
||||
}
|
||||
|
||||
"enum" {
|
||||
count();
|
||||
return(ENUMSTRUCT);
|
||||
}
|
||||
|
||||
"includeIFF" |
|
||||
"includeiff" {
|
||||
count();
|
||||
return(INCLUDEIFF);
|
||||
}
|
||||
"include" {
|
||||
count();
|
||||
return(INCLUDEBIN);
|
||||
}
|
||||
"#include" {
|
||||
count();
|
||||
return(INCLUDESOURCE);
|
||||
}
|
||||
"#pragma" {
|
||||
count();
|
||||
return(PRAGMA);
|
||||
}
|
||||
"drive" {
|
||||
count();
|
||||
return(PRAGMA_DRIVE);
|
||||
}
|
||||
"directory" {
|
||||
count();
|
||||
return(PRAGMA_DIR);
|
||||
}
|
||||
"filename" {
|
||||
count();
|
||||
return(PRAGMA_FNAME);
|
||||
}
|
||||
"extension" {
|
||||
count();
|
||||
return(PRAGMA_EXT);
|
||||
}
|
||||
|
||||
{LETTER}({LETTER}|{DIGIT})* {
|
||||
/* label identifiers */
|
||||
char *s; // allocate space for string and pass the string pointer rather then yytext
|
||||
|
||||
count();
|
||||
s = MIFFallocString(strlen(yytext) + 1);
|
||||
strcpy(s, yytext);
|
||||
yylval.stype = s;
|
||||
return(IDENTIFIER);
|
||||
}
|
||||
|
||||
{DIGIT}*"."{DIGIT}+{FLOATSYM}? {
|
||||
/* handle numericals (floats) */
|
||||
/*
|
||||
* {DIGIT}*"."{DIGIT}+{FLOATSYM}? means zero or more digits . one or more digit and with/without f at the end
|
||||
*/
|
||||
count();
|
||||
/* make sure to store it to dtype, and use strtod to convert to double */
|
||||
yylval.dtype = strtod((char *) yytext, (char **) 0);
|
||||
return(FLOAT_LIT);
|
||||
}
|
||||
|
||||
0[xX]{HEXDIGIT}+{INTSYM}? |
|
||||
0{DIGIT}+{INTSYM}? |
|
||||
{DIGIT}+{INTSYM}? {
|
||||
/* handle numericals ( hex, ints) */
|
||||
/*
|
||||
* 0[xX]{HEXDIGIT}+{INTSYM}? means start with 0, then X one or more digit and you can put int symbol if you want
|
||||
* 0{DIGIT}+{INTSYM}? means start with 0, one ore more digit and w/or w/o int symbol
|
||||
* {DIGIT}+{INTSYM}? means one or more digit and w/or w/o int symbol
|
||||
*/
|
||||
count();
|
||||
/* make sure to store it to ltype (long), and use strtod to convert to unsigned long */
|
||||
yylval.ltype = strtoul((char *) yytext, (char **) 0, 0);
|
||||
return(LIT);
|
||||
}
|
||||
|
||||
'(\\.|[^\\'])+' {
|
||||
/* handle 'x' - single character */
|
||||
count();
|
||||
yylval.chtype = yytext[1];
|
||||
return(CHAR_LIT);
|
||||
}
|
||||
|
||||
"#" {
|
||||
/* #'s are used for informing the parser which file and line number it is processing (debug purpose) */
|
||||
count();
|
||||
return(POUND);
|
||||
}
|
||||
|
||||
">>" {
|
||||
count();
|
||||
return(SHIFTRIGHT);
|
||||
}
|
||||
"<<" {
|
||||
count();
|
||||
return(SHIFTLEFT);
|
||||
}
|
||||
"^^" {
|
||||
count();
|
||||
return(RAISEDPOWER);
|
||||
}
|
||||
|
||||
"[" |
|
||||
"]" |
|
||||
"^" |
|
||||
";" |
|
||||
"," |
|
||||
":" |
|
||||
"=" |
|
||||
"(" |
|
||||
")" |
|
||||
"." |
|
||||
"&" |
|
||||
"!" |
|
||||
"~" |
|
||||
"-" |
|
||||
"+" |
|
||||
"*" |
|
||||
"/" |
|
||||
"%" |
|
||||
"<" |
|
||||
">" |
|
||||
"|" |
|
||||
"?" {
|
||||
/* valid operators */
|
||||
count();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
|
||||
"{" {
|
||||
count();
|
||||
open_brace();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
"}" {
|
||||
count();
|
||||
close_brace();
|
||||
yylval.stype = yytext;
|
||||
return(* yylval.stype);
|
||||
}
|
||||
|
||||
[ \t\n\r]+ {
|
||||
/* white spaces and newlines are ignored */
|
||||
count();
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
/* do a count on bracket matching... */
|
||||
if (0 == count_brace())
|
||||
{
|
||||
if (!initialCompile && !globalErrorFlag)
|
||||
MIFFMessage("mIFF successfully compiled!\n", 0);
|
||||
}
|
||||
|
||||
yyterminate(); /* tell yyparse() it's time to quit! DO NOT comment or delete this line! */
|
||||
}
|
||||
|
||||
. {
|
||||
/* anything that's not a rule from above goes here */
|
||||
count();
|
||||
yyerror((char *) yytext);
|
||||
}
|
||||
%%
|
||||
|
||||
/*--------------------**
|
||||
** C supporting codes **
|
||||
**--------------------*/
|
||||
|
||||
/*------------------**
|
||||
** static variables **
|
||||
**------------------*/
|
||||
static char *MIFFInputStream;
|
||||
int column = 0;
|
||||
int line_num = 1;
|
||||
int line_num2 = 1;
|
||||
char error_line_buffer[4096];
|
||||
long brace_counter = 0;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------**
|
||||
** Initialize all the static variables before all calls to MIFFCompile **
|
||||
**---------------------------------------------------------------------*/
|
||||
void initParser(void)
|
||||
{
|
||||
line_num = 1;
|
||||
column = 0;
|
||||
|
||||
brace_counter = 0;
|
||||
error_line_buffer[0] = 0;
|
||||
|
||||
globalErrorFlag = 0;
|
||||
|
||||
memset(inFileName, 0, 512); /* make sure to change this size if the char array gets bigger... */
|
||||
}
|
||||
|
||||
/*-------------------------------------------------**
|
||||
** generate a dialog box to MFC to report an error **
|
||||
**-------------------------------------------------*/
|
||||
void yyerror(char *err) /* called by yyparse() */
|
||||
{
|
||||
char myString[256];
|
||||
|
||||
if (!initialCompile)
|
||||
{
|
||||
/* spit it out in MSDev error format */
|
||||
sprintf(myString, "\n%s(%d) : yyERROR : %s\n>>%s<<", inFileName, line_num, err, error_line_buffer);
|
||||
MIFFMessage(myString, 1);
|
||||
globalErrorFlag = 1;
|
||||
MIFFSetError(); /* set global error flag for shell as well */
|
||||
yyterminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------**
|
||||
** our version of YY_INPUT **
|
||||
**-------------------------*/
|
||||
int MIFFYYInput(char *buf,int max_size)
|
||||
{
|
||||
int len = strlen(MIFFInputStream);
|
||||
int n = max_size < len ? max_size : len;
|
||||
if (n > 0)
|
||||
{
|
||||
memcpy(buf,MIFFInputStream,n);
|
||||
MIFFInputStream += n;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------**
|
||||
** line and column counter for error searching during compile **
|
||||
**------------------------------------------------------------*/
|
||||
void count()
|
||||
{
|
||||
int i;
|
||||
static char *elb = error_line_buffer;
|
||||
for (i = 0; yytext[i] != '\0'; i++)
|
||||
{
|
||||
if (yytext[i] == '\n')
|
||||
{
|
||||
column = 0;
|
||||
line_num++;
|
||||
elb = error_line_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
*elb++ = yytext[i];
|
||||
if (yytext[i] == '\t')
|
||||
column += SPACE_COUNT_FOR_TAB - (column & (SPACE_COUNT_FOR_TAB - 1));
|
||||
else
|
||||
column++;
|
||||
}
|
||||
*elb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------**
|
||||
** sets up current line number and filename the error came from **
|
||||
**--------------------------------------------------------------*/
|
||||
void setCurrentLineNumber(int lineNum, char * fileName, int mysteryNum)
|
||||
{
|
||||
line_num = lineNum;
|
||||
strcpy(inFileName, fileName);
|
||||
line_num2 = mysteryNum;
|
||||
}
|
||||
|
||||
/*----------------------------------------------**
|
||||
** MIFFCompile called by CMIFFView::OnCompile() **
|
||||
**----------------------------------------------*/
|
||||
void MIFFCompile(char *inputStream, char *inputFileName)
|
||||
{
|
||||
MIFFInputStream = inputStream;
|
||||
yyrestart(0);
|
||||
initParser();
|
||||
initialCompile = 0;
|
||||
strcpy(inFileName, inputFileName);
|
||||
yyparse();
|
||||
}
|
||||
|
||||
void MIFFCompileInit(char *inputStream, char *inputFileName)
|
||||
{
|
||||
MIFFInputStream = inputStream;
|
||||
yyrestart(0);
|
||||
initParser();
|
||||
initialCompile = 1;
|
||||
strcpy(inFileName, inputFileName);
|
||||
yyparse();
|
||||
}
|
||||
|
||||
/*---------------------------------------**
|
||||
** matching of open/close brace checking **
|
||||
**---------------------------------------*/
|
||||
void open_brace(void)
|
||||
{
|
||||
brace_counter++;
|
||||
}
|
||||
|
||||
void close_brace(void)
|
||||
{
|
||||
brace_counter--;
|
||||
}
|
||||
|
||||
/*
|
||||
* what: count_brace():
|
||||
* return: 0 == all braces matched
|
||||
*/
|
||||
int count_brace(void)
|
||||
{
|
||||
if (0 == brace_counter) /* things are fine... */
|
||||
return(0);
|
||||
|
||||
/* if this is called, we should have 0 brace counter if not, we have a mis-match*/
|
||||
if (brace_counter > 0)
|
||||
{
|
||||
/* a mismatch */
|
||||
yyerror("There are more OPEN brackets then closed");
|
||||
}
|
||||
else if (brace_counter < 0)
|
||||
{
|
||||
yyerror("There are more CLOSED brackets then open");
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------**
|
||||
** FLEX.SLK requires this prototype function so I'm forced to do this... **
|
||||
**-----------------------------------------------------------------------*/
|
||||
int yywrap()
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
void printString(char *str)
|
||||
{
|
||||
char ts[256];
|
||||
sprintf(ts, "%s - %s", str, yytext);
|
||||
MIFFMessage(ts, 0);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,9 +9,9 @@ add_subdirectory(PlanetServer)
|
||||
add_subdirectory(ServerConsole)
|
||||
add_subdirectory(TaskManager)
|
||||
add_subdirectory(TransferServer)
|
||||
add_subdirectory(CommoditiesServer)
|
||||
|
||||
if(NOT WIN32)
|
||||
add_subdirectory(CommoditiesServer)
|
||||
add_subdirectory(CustomerServiceServer)
|
||||
add_subdirectory(LoginPing)
|
||||
add_subdirectory(StationPlayersCollector)
|
||||
|
||||
+4
@@ -21,6 +21,10 @@ namespace NAMESPACE
|
||||
|
||||
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;
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#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
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
////////////////////////////////////////
|
||||
// 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
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
////////////////////////////////////////
|
||||
// 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
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
BIN
Binary file not shown.
@@ -102,7 +102,7 @@ void CharacterCreationTracker::handleCreateNewCharacter(const ConnectionCreateCh
|
||||
}
|
||||
|
||||
if (creationRecord == m_creations.end())
|
||||
creationRecord = m_creations.insert(std::make_pair<StationId,CreationRecord*>(msg.getStationId(),new CreationRecord)).first;
|
||||
creationRecord = m_creations.insert(std::pair<StationId,CreationRecord*>(msg.getStationId(),new CreationRecord)).first;
|
||||
|
||||
// - determine starting location
|
||||
static std::string tutorialPlanetName("tutorial");
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// CentralServerPrecompiledHeader.cpp
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#include "FirstCentralServer.h"
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "FirstCentralServer.h"
|
||||
#include "ConfigCentralServer.h"
|
||||
#include "CentralServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
//_____________________________________________________________________
|
||||
/*
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance, // handle to current instance
|
||||
HINSTANCE hPrevInstance, // handle to previous instance
|
||||
LPSTR lpCmdLine, // pointer to command line
|
||||
int nCmdShow // show state of window
|
||||
)
|
||||
*/
|
||||
int main(int argc, char ** argv)
|
||||
{ //lint !e1065 //WinMain conflicts with clib
|
||||
int i = 0;
|
||||
|
||||
// UNREF(hPrevInstance);
|
||||
// UNREF(nCmdShow);
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
// setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
ConfigCentralServer::install();
|
||||
|
||||
cmdLine = "";
|
||||
// now, the real command line
|
||||
for(i = 0; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
CentralServer::getInstance().setCommandLine(cmdLine);
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(CentralServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "FirstChatServer.h"
|
||||
#include "ConfigChatServer.h"
|
||||
#include "ChatServer.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
//setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
//-- setup game server
|
||||
ConfigChatServer::install ();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(ChatServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -26,7 +26,9 @@ set(SHARED_SOURCES
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SOURCES "")
|
||||
set(PLATFORM_SOURCES
|
||||
win32/WinMain.cpp
|
||||
)
|
||||
else()
|
||||
set(PLATFORM_SOURCES
|
||||
linux/main.cpp
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedGame/CommoditiesAdvancedSearchAttribute.h"
|
||||
#include "sharedGame/ConfigSharedGame.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/DataTableManager.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "LocalizationManager.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
ConfigSharedGame::install();
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
ConfigCommodityServer::install();
|
||||
|
||||
const bool displayBadStringIds = ConfigSharedGame::getDisplayBadStringIds ();
|
||||
const bool debugStringIds = ConfigSharedGame::getDebugStringIds ();
|
||||
Unicode::NarrowString defaultLocale(ConfigSharedGame::getDefaultLocale ());
|
||||
Unicode::UnicodeNarrowStringVector localeVector;
|
||||
localeVector.push_back(defaultLocale);
|
||||
|
||||
LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, NULL, displayBadStringIds);
|
||||
ExitChain::add(LocalizationManager::remove, "LocalizationManager::remove");
|
||||
|
||||
DataTableManager::install();
|
||||
CommoditiesAdvancedSearchAttribute::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(CommodityServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstConnectionServer.h"
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "FirstConnectionServer.h"
|
||||
#include "ConfigConnectionServer.h"
|
||||
#include "ConnectionServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/PerThreadData.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// setupFoundationData.hInstance = hInstance;
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSharedRandom::install(int(time(NULL)));
|
||||
|
||||
//-- setup game server
|
||||
ConfigConnectionServer::install ();
|
||||
|
||||
ConnectionServer::install();
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(ConnectionServer::run);
|
||||
ConnectionServer::remove();
|
||||
ConfigConnectionServer::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
PerThreadData::threadRemove();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// LoggingServerApiWrapper.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
// This is a wrapper cpp to workaround PCH and RSP's. While a DSP
|
||||
// may exclude a single file from using precompiled headers, the
|
||||
// dsp builder has no way (I know of) to honor this behavior.
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstLogServer.h"
|
||||
//#include "LoggingServerApi.cpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// WinMain.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstLogServer.h"
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "LogServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.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.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install(setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
//-- setup server
|
||||
LogServer::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LogServer::run);
|
||||
|
||||
LogServer::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -89,7 +89,7 @@ void ConfigLoginServer::install(void)
|
||||
KEY_BOOL (validateStationKey, false);
|
||||
KEY_BOOL (doSessionLogin, false);
|
||||
KEY_BOOL (doConsumption, false);
|
||||
KEY_STRING (sessionServers, "sdlogin-test:3004");
|
||||
KEY_STRING (sessionServers, "localhost:3004");
|
||||
KEY_INT (sessionType, SESSION_TYPE_STARWARS);
|
||||
KEY_BOOL (developmentMode, true);
|
||||
KEY_INT (databaseThreads, 1);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstLoginServer.h"
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "FirstLoginServer.h"
|
||||
#include "ConfigLoginServer.h"
|
||||
#include "LoginServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedCompression::install();
|
||||
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedRandom::install(time(NULL));
|
||||
|
||||
//-- setup game server
|
||||
ConfigLoginServer::install ();
|
||||
|
||||
//-- run game
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(LoginServer::run);
|
||||
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
#include "ConfigMetricsServer.h"
|
||||
#include "MetricsServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
// command line hack
|
||||
std::string cmdLine;
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
cmdLine += argv[i];
|
||||
if(i + 1 < argc)
|
||||
{
|
||||
cmdLine += " ";
|
||||
}
|
||||
}
|
||||
|
||||
setupFoundationData.commandLine = cmdLine.c_str();
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
{
|
||||
//SetupSharedObject::Data data;
|
||||
//SetupSharedObject::setupDefaultGameData(data);
|
||||
//SetupSharedObject::install(data);
|
||||
}
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(true, 32);
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast?
|
||||
|
||||
//Os::setProgramName("MetricsServer");
|
||||
//setup the server
|
||||
ConfigMetricsServer::install();
|
||||
|
||||
//set command line
|
||||
cmdLine = setupFoundationData.commandLine;
|
||||
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);
|
||||
MetricsServer::setCommandLine(cmdLine);
|
||||
|
||||
|
||||
//-- run game
|
||||
NetworkHandler::install();
|
||||
MetricsServer::install();
|
||||
MetricsServer::run();
|
||||
MetricsServer::remove();
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstPlanetServer.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstPlanetServer.h"
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "FirstPlanetServer.h"
|
||||
#include "ConfigPlanetServer.h"
|
||||
#include "PlanetServer.h"
|
||||
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/SetupSharedUtility.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
//_____________________________________________________________________
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedRandom::install(int(time(NULL)));
|
||||
|
||||
SetupSharedUtility::Data sharedUtilityData;
|
||||
SetupSharedUtility::setupGameData (sharedUtilityData);
|
||||
SetupSharedUtility::install (sharedUtilityData);
|
||||
|
||||
//-- setup server
|
||||
ConfigPlanetServer::install ();
|
||||
|
||||
char tmp[92];
|
||||
sprintf(tmp, "PlanetServer:%d", Os::getProcessId());
|
||||
SetupSharedLog::install(tmp);
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(PlanetServer::run);
|
||||
|
||||
SetupSharedLog::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
@@ -0,0 +1,59 @@
|
||||
// main.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstServerConsole.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "ServerConsole.h"
|
||||
#include "ConfigServerConsole.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
setupFoundationData.createWindow = false;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultClientSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
ConfigServerConsole::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(ServerConsole::run);
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// ConsoleInput.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTaskManager.h"
|
||||
#include "Console.h"
|
||||
#include <conio.h>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const char Console::getNextChar()
|
||||
{
|
||||
char result = 0;
|
||||
if(_kbhit())
|
||||
result = static_cast<char>(_getche());
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "FirstTaskManager.h"
|
||||
|
||||
namespace EnvironmentVariable
|
||||
{
|
||||
bool addToEnvironmentVariable(const char* key, const char* value)
|
||||
{
|
||||
bool retval = false;
|
||||
char oldValue[256];
|
||||
DWORD tmp = GetEnvironmentVariable(key, oldValue, sizeof(oldValue));
|
||||
if (tmp != 0)
|
||||
{
|
||||
std::string s(oldValue);
|
||||
s += ";";
|
||||
s += value;
|
||||
|
||||
//Bad things happen if the first character happens to be ; (ie from an empty environment string)
|
||||
const char* newValue = s.c_str();
|
||||
if (newValue[0] == ';')
|
||||
++newValue;
|
||||
|
||||
retval = (SetEnvironmentVariable(key, newValue) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = (SetEnvironmentVariable(key, value) != 0);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
bool setEnvironmentVariable(const char* key, const char* value)
|
||||
{
|
||||
return (SetEnvironmentVariable(key, value) != 0);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,153 @@
|
||||
#include "FirstTaskManager.h"
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "ProcessSpawner.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "TaskManager.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
uint32 ProcessSpawner::prefix;
|
||||
std::map<uint32, HANDLE> procById;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool tokenize (const std::string & str, std::vector<std::string> & result)
|
||||
{
|
||||
size_t end_pos = 0;
|
||||
size_t start_pos = 0;
|
||||
|
||||
result.clear ();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (end_pos >= str.size ())
|
||||
break;
|
||||
|
||||
start_pos = str.find_first_not_of (' ', end_pos);
|
||||
|
||||
if (start_pos == str.npos)
|
||||
break;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
if (str [start_pos] == '\"')
|
||||
{
|
||||
if (++start_pos >= str.size ())
|
||||
break;
|
||||
end_pos = str.find_first_of ('\"', start_pos);
|
||||
}
|
||||
else
|
||||
end_pos = str.find_first_of (' ', start_pos);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
if (start_pos == end_pos)
|
||||
break;
|
||||
|
||||
if (end_pos == str.npos)
|
||||
{
|
||||
result.push_back (str.substr (start_pos));
|
||||
break;
|
||||
}
|
||||
else
|
||||
result.push_back (str.substr (start_pos, end_pos - start_pos));
|
||||
|
||||
++start_pos;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 ProcessSpawner::execute(const std::string & processName, const std::vector<std::string> & parameters)
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
char cmd[1024] = {"\0"};
|
||||
std::string cmdLine;
|
||||
|
||||
cmdLine = processName.c_str();
|
||||
cmdLine += " ";
|
||||
std::vector<std::string>::const_iterator i;
|
||||
for(i = parameters.begin(); i != parameters.end(); ++i)
|
||||
{
|
||||
cmdLine += (*i).c_str();
|
||||
cmdLine += " ";
|
||||
}
|
||||
|
||||
_snprintf(cmd, 1024, "%s.exe", processName.c_str());
|
||||
// _snprintf(cmd, 1024, "%s", processName.c_str());
|
||||
memset(&si, 0, sizeof(si));
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
si.cb = sizeof(si);
|
||||
|
||||
const int result = CreateProcess(cmd, const_cast<char *>(cmdLine.c_str()), NULL, NULL, false, 0, 0, 0, &si, &pi);
|
||||
UNREF (result);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (!result)
|
||||
{
|
||||
DWORD iErr = GetLastError();
|
||||
char * errStr = strerror(iErr);
|
||||
DEBUG_REPORT_LOG(true, ("ProcessSpawner: %s - %s\n", cmd, errStr));
|
||||
}
|
||||
#endif
|
||||
|
||||
procById.insert(std::pair<uint32, HANDLE>(pi.dwProcessId, pi.hProcess));
|
||||
return pi.dwProcessId;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
uint32 ProcessSpawner::execute(const std::string & cmd)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
size_t firstArg = cmd.find_first_of(" ");
|
||||
std::string processName;
|
||||
if(firstArg < cmd.size())
|
||||
{
|
||||
std::string a = cmd.substr(firstArg + 1);
|
||||
tokenize(a, args);
|
||||
processName = cmd.substr(0, firstArg);
|
||||
}
|
||||
else
|
||||
{
|
||||
processName = cmd;
|
||||
}
|
||||
return execute(processName, args);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ProcessSpawner::isProcessActive(uint32 pid)
|
||||
{
|
||||
bool result = false;
|
||||
std::map<uint32, HANDLE>::const_iterator f = procById.find(pid);
|
||||
if(f != procById.end())
|
||||
{
|
||||
DWORD exitCode;
|
||||
GetExitCodeProcess((*f).second, &exitCode);
|
||||
result = (exitCode == STILL_ACTIVE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ProcessSpawner::kill(uint32 pid)
|
||||
{
|
||||
HANDLE p = OpenProcess(PROCESS_TERMINATE, false, (DWORD)pid);
|
||||
if(p)
|
||||
TerminateProcess(p, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ProcessSpawner::forceCore(const unsigned long pid)
|
||||
{
|
||||
ProcessSpawner::kill(pid);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
// TaskManagerSysInfo.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTaskManager.h"
|
||||
#include "TaskManagerSysInfo.h"
|
||||
#pragma warning ( disable : 4201)
|
||||
#include <windows.h>
|
||||
#include <tlhelp32.h>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TaskManagerSysInfo::TaskManagerSysInfo() :
|
||||
averageScore()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TaskManagerSysInfo::TaskManagerSysInfo(const TaskManagerSysInfo &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TaskManagerSysInfo::~TaskManagerSysInfo()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TaskManagerSysInfo & TaskManagerSysInfo::operator = (const TaskManagerSysInfo & rhs)
|
||||
{
|
||||
if(this != &rhs)
|
||||
{
|
||||
// make assignments if right hand side is not this instance
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const float TaskManagerSysInfo::getScore() const
|
||||
{
|
||||
std::list<float>::const_iterator i;
|
||||
float avg = 0.0f;
|
||||
for(i = averageScore.begin(); i != averageScore.end(); ++i)
|
||||
{
|
||||
avg += (*i);
|
||||
}
|
||||
avg = avg / averageScore.size();
|
||||
return avg;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void TaskManagerSysInfo::update()
|
||||
{
|
||||
static int64 activeTime[2] = {0};
|
||||
static int64 currentTime[2] = {0};
|
||||
|
||||
float currentScore = 0.0f;
|
||||
activeTime[0] = activeTime[1];
|
||||
currentTime[0] = currentTime[1];
|
||||
activeTime[1] = 0;
|
||||
|
||||
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
|
||||
double procAvg = 0.0f;
|
||||
|
||||
MEMORYSTATUS memStat;
|
||||
GlobalMemoryStatus(&memStat);
|
||||
|
||||
currentScore = static_cast<float>(static_cast<float>(memStat.dwMemoryLoad) * 0.005f);
|
||||
if(hProcessSnap != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
PROCESSENTRY32 pe32 = {0};
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||
if (Process32First(hProcessSnap, &pe32))
|
||||
{
|
||||
do
|
||||
{
|
||||
HANDLE proc = OpenProcess(PROCESS_QUERY_INFORMATION, false, pe32.th32ProcessID);
|
||||
// some stuf with the enumerated processes
|
||||
FILETIME createTime = {0};
|
||||
FILETIME exitTime = {0};
|
||||
FILETIME kernelTime = {0};
|
||||
FILETIME userTime = {0};
|
||||
GetProcessTimes(proc, &createTime, &exitTime, &kernelTime, &userTime);
|
||||
int64 totals;
|
||||
|
||||
// SDK docs say:
|
||||
// It is not recommended that you add and subtract values
|
||||
// from the FILETIME structure to obtain relative times. Instead, you should
|
||||
// Copy the resulting FILETIME structure to a ULARGE_INTEGER structure.
|
||||
// Use normal 64-bit arithmetic on the ULARGE_INTEGER value.
|
||||
int64 c;
|
||||
int64 e;
|
||||
int64 k;
|
||||
int64 u;
|
||||
memcpy(&c, &createTime, sizeof(int64));
|
||||
memcpy(&e, &exitTime, sizeof(int64));
|
||||
memcpy(&k, &kernelTime, sizeof(int64));
|
||||
memcpy(&u, &userTime, sizeof(int64));
|
||||
|
||||
totals = k + u;
|
||||
|
||||
FILETIME fst;
|
||||
SYSTEMTIME st;
|
||||
GetSystemTime(&st);
|
||||
SystemTimeToFileTime(&st, &fst);
|
||||
|
||||
int64 runTime;
|
||||
memcpy(&runTime, &fst, sizeof(int64));
|
||||
runTime = runTime - c;
|
||||
|
||||
if(c || e || k || u)
|
||||
{
|
||||
activeTime[1] += k + e;
|
||||
}
|
||||
|
||||
}
|
||||
while (Process32Next(hProcessSnap, &pe32));
|
||||
}
|
||||
}
|
||||
|
||||
FILETIME fst;
|
||||
SYSTEMTIME st;
|
||||
GetSystemTime(&st);
|
||||
SystemTimeToFileTime(&st, &fst);
|
||||
memcpy(¤tTime[1], &fst, sizeof(int64));
|
||||
int64 timeSlice = currentTime[1] - currentTime[0];
|
||||
int64 activeSlice = activeTime[1] - activeTime[0];
|
||||
procAvg = static_cast<double>(static_cast<double>(activeSlice) / timeSlice);
|
||||
//REPORT_LOG(true, ("%f\n", procAvg));
|
||||
currentScore = currentScore + static_cast<float>(procAvg * 0.5);
|
||||
|
||||
averageScore.insert(averageScore.end(), currentScore);
|
||||
|
||||
if(averageScore.size() > 100)
|
||||
averageScore.erase(averageScore.begin());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "FirstTaskManager.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedRandom/SetupSharedRandom.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "TaskManager.h"
|
||||
#include "ConfigTaskManager.h"
|
||||
|
||||
//=====================================================================
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = false;
|
||||
setupFoundationData.clockUsesSleep = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
SetupSharedRandom::install(static_cast<uint32>(time(NULL))); //lint !e1924 !e64 // NULL is a C-Style cast?
|
||||
|
||||
ConfigTaskManager::install();
|
||||
|
||||
TaskManager::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(TaskManager::run);
|
||||
|
||||
TaskManager::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
@@ -0,0 +1,60 @@
|
||||
// main.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTransferServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "TransferServer.h"
|
||||
#include "ConfigTransferServer.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.createWindow = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
//Os::setProgramName("TransferServer");
|
||||
ConfigTransferServer::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(TransferServer::run);
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@@ -36,7 +36,7 @@ sub main
|
||||
|
||||
if ($opt_windows == 1)
|
||||
{
|
||||
open (FILELIST,"bash -c \"ls ${opt_ddldirectory}/*.tab\"|"); #dir /f /b ${opt_ddldirectory}\\*.tab|");
|
||||
open (FILELIST,"c:\cygwin\bin\bash -c \"c:\cygwin\bin\ls ${opt_ddldirectory}/*.tab\"|"); #dir /f /b ${opt_ddldirectory}\\*.tab|");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,7 +287,8 @@ sub output
|
||||
|
||||
if ($opt_windows == 1)
|
||||
{
|
||||
system ("copy ${filename}.make_encoder_temporary_file $filename");
|
||||
#system ("copy ${filename}.make_encoder_temporary_file $filename");
|
||||
system ("copy d:\\whitengold\\src\\game\\server\\application\\SwgDatabaseServer\\src\\shared\\generated\\Schema_h.template $filename");
|
||||
system ("del ${filename}.make_encoder_temporary_file");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstServerDatabase.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverDatabase/FirstServerDatabase.h"
|
||||
|
||||
@@ -460,12 +460,12 @@ bool ConsoleCommandParserServer::performParsing (const NetworkId & userId, const
|
||||
//-----------------------------------------------------------------
|
||||
else if (isAbbrev( argv[0], "dumpMemToFile"))
|
||||
{
|
||||
std::string fileName(Unicode::wideToNarrow(argv[1]));
|
||||
std::string leakStr(Unicode::wideToNarrow(argv[2]));
|
||||
bool leak = (leakStr == "true" || leakStr == "1");
|
||||
|
||||
MemoryManager::reportToFile(fileName.c_str(), leak);
|
||||
result += getErrorMessage (argv[0], ERR_SUCCESS);
|
||||
//std::string fileName(Unicode::wideToNarrow(argv[1]));
|
||||
//std::string leakStr(Unicode::wideToNarrow(argv[2]));
|
||||
//bool leak = (leakStr == "true" || leakStr == "1");
|
||||
//
|
||||
//MemoryManager::reportToFile(fileName.c_str(), leak);
|
||||
//result += getErrorMessage (argv[0], ERR_SUCCESS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
@@ -242,10 +242,7 @@ Client::Client(ConnectionServerConnection & connection, const NetworkId & charac
|
||||
connectToEmitter(connection, "ConnectionServerConnectionDestroyed");
|
||||
|
||||
// Check god permissions
|
||||
if ( ConfigServerGame::getAdminGodToAll()
|
||||
|| ( (!ConfigServerGame::getUseSecureLoginForGodAccess() || m_isSecure)
|
||||
&& AdminAccountManager::isAdminAccount(Unicode::toLower(accountName), m_godLevel)
|
||||
&& (!ConfigServerGame::getUseIPForGodAccess() || AdminAccountManager::isInternalIp(ipAddr))))
|
||||
if (AdminAccountManager::isAdminAccount(Unicode::toLower(accountName), m_godLevel))
|
||||
{
|
||||
m_godValidated = true;
|
||||
if (ConfigServerGame::getAdminGodToAll())
|
||||
|
||||
@@ -126,7 +126,7 @@ void ConfigServerGame::install(void)
|
||||
KEY_BOOL (adminGodToAll, false);
|
||||
KEY_INT (adminGodToAllGodLevel, 50);
|
||||
KEY_BOOL (useSecureLoginForGodAccess, false);
|
||||
KEY_BOOL (useIPForGodAccess, true);
|
||||
KEY_BOOL (useIPForGodAccess, false);
|
||||
KEY_BOOL (adminPersistAllCreates, false);
|
||||
KEY_BOOL (buildCluster, false);
|
||||
KEY_INT (requestSceneWarpTimeoutSeconds, 60);
|
||||
|
||||
@@ -693,8 +693,8 @@ void GameServer::createProxyOnAllServers(ServerObject *object)
|
||||
void GameServer::debugIO (void)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DebugMonitor::flushOutput();
|
||||
DebugMonitor::clearScreen();
|
||||
// DebugMonitor::flushOutput();
|
||||
// DebugMonitor::clearScreen();
|
||||
DebugFlags::callReportRoutines();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,762 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Packager.cpp
|
||||
// copyright (c) 2002 Sony Online Entertainment
|
||||
//
|
||||
// Edit Packager_cpp.template. Do not edit Packager.cpp
|
||||
//
|
||||
// To change the contents of the addMemebersToPackage functions,
|
||||
// edit package_data.txt.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/TangibleObject.h"
|
||||
|
||||
#include "serverGame/BattlefieldMarkerObject.h"
|
||||
#include "serverGame/BuildingObject.h"
|
||||
#include "serverGame/CellObject.h"
|
||||
#include "serverGame/CityObject.h"
|
||||
#include "serverGame/CommandQueue.h"
|
||||
#include "serverGame/CreatureObject.h"
|
||||
#include "serverGame/DraftSchematicObject.h"
|
||||
#include "serverGame/FactoryObject.h"
|
||||
#include "serverGame/GroupObject.h"
|
||||
#include "serverGame/GuildObject.h"
|
||||
#include "serverGame/HarvesterInstallationObject.h"
|
||||
#include "serverGame/InstallationObject.h"
|
||||
#include "serverGame/IntangibleObject.h"
|
||||
#include "serverGame/ManufactureSchematicObject.h"
|
||||
#include "serverGame/ManufactureInstallationObject.h"
|
||||
#include "serverGame/MissionObject.h"
|
||||
#include "serverGame/PlanetObject.h"
|
||||
#include "serverGame/PlayerQuestObject.h"
|
||||
#include "serverGame/PlayerObject.h"
|
||||
#include "serverGame/ResourceContainerObject.h"
|
||||
#include "serverGame/ResourcePoolObject.h"
|
||||
#include "serverGame/ResourceTypeObject.h"
|
||||
#include "serverGame/ServerObject.h"
|
||||
#include "serverGame/ShipObject.h"
|
||||
#include "serverGame/StaticObject.h"
|
||||
#include "serverGame/TangibleObject.h"
|
||||
#include "serverGame/UniverseObject.h"
|
||||
#include "serverGame/VehicleObject.h"
|
||||
#include "serverGame/WeaponObject.h"
|
||||
#include "serverScript/GameScriptObject.h"
|
||||
#include "sharedFoundation/DynamicVariableList.h"
|
||||
#include "sharedObject/ContainedByProperty.h"
|
||||
#include "sharedObject/SlottedContainmentProperty.h"
|
||||
|
||||
|
||||
//!!!BEGIN GENERATED PACKAGEADD
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void BattlefieldMarkerObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_regionName);
|
||||
addServerVariable (m_battlefieldParticipants);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void BuildingObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_allowed);
|
||||
addServerVariable (m_banned);
|
||||
addServerVariable (m_isPublic);
|
||||
addServerVariable (m_maintenanceCost);
|
||||
addServerVariable (m_timeLastChecked);
|
||||
addServerVariable (m_cityId);
|
||||
addServerVariable_np (m_contentsLoaded);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void CellObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_allowed);
|
||||
addServerVariable (m_banned);
|
||||
addSharedVariable (m_isPublic);
|
||||
addSharedVariable (m_cellNumber);
|
||||
addSharedVariable_np (m_cellLabel);
|
||||
addSharedVariable_np (m_labelLocationOffset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void CityObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_cities);
|
||||
addServerVariable (m_citizens);
|
||||
addServerVariable (m_structures);
|
||||
addServerVariable_np (m_citiesInfo);
|
||||
addServerVariable_np (m_citizensInfo);
|
||||
addServerVariable_np (m_structuresInfo);
|
||||
addServerVariable_np (m_citizenToCityId);
|
||||
addServerVariable_np (m_pgcRatingInfo);
|
||||
addServerVariable_np (m_pgcRatingChroniclerId);
|
||||
addServerVariable_np (m_gcwRegionDefenderCities);
|
||||
addServerVariable_np (m_gcwRegionDefenderCitiesCount);
|
||||
addServerVariable_np (m_gcwRegionDefenderCitiesVersion);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void CreatureObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_attributes);
|
||||
addServerVariable (m_baseRunSpeed);
|
||||
addServerVariable (m_baseWalkSpeed);
|
||||
addServerVariable (m_persistedBuffs);
|
||||
addServerVariable (m_wsX);
|
||||
addServerVariable (m_wsY);
|
||||
addServerVariable (m_wsZ);
|
||||
addSharedVariable (m_posture);
|
||||
addSharedVariable (m_rank);
|
||||
addSharedVariable (m_masterId);
|
||||
addSharedVariable (m_scaleFactor);
|
||||
addSharedVariable (m_shockWounds);
|
||||
addSharedVariable (m_states);
|
||||
addAuthClientServerVariable (m_maxAttributes);
|
||||
addAuthClientServerVariable (m_skills);
|
||||
addServerVariable_np (m_notifyRegions);
|
||||
addServerVariable_np (m_missionCriticalObjectSet);
|
||||
addServerVariable_np (m_attributeModList);
|
||||
addServerVariable_np (m_baseSlopeModPercent);
|
||||
addServerVariable_np (m_cachedCurrentAttributeModValues);
|
||||
addServerVariable_np (m_cachedMaxAttributeModValues);
|
||||
getCommandQueue()->addToPackage(m_serverPackage_np);
|
||||
addServerVariable_np (m_cover);
|
||||
addServerVariable_np (m_currentAttitude);
|
||||
addServerVariable_np (m_isStatic);
|
||||
addServerVariable_np (m_lastBehavior);
|
||||
addServerVariable_np (m_lastMonitorReportPosition);
|
||||
addServerVariable_np (m_locomotion);
|
||||
addServerVariable_np (m_maxMentalStates);
|
||||
addServerVariable_np (m_mentalStateDecays);
|
||||
addServerVariable_np (m_mentalStatesToward);
|
||||
addServerVariable_np (m_monitoredCreatureMovements);
|
||||
addServerVariable_np (m_performanceWatchTarget);
|
||||
addServerVariable_np (m_stopWalkRun);
|
||||
addServerVariable_np (m_timeToUpdateGuildWarPvpStatus);
|
||||
addServerVariable_np (m_guildWarEnabled);
|
||||
addServerVariable_np (m_militiaOfCityId);
|
||||
addServerVariable_np (m_locatedInCityId);
|
||||
addServerVariable_np (m_invulnerabilityTimer);
|
||||
addServerVariable_np (m_allowSARegen);
|
||||
addServerVariable_np (m_inviterForPendingGroup);
|
||||
addServerVariable_np (m_timedMod);
|
||||
addServerVariable_np (m_timedModDuration);
|
||||
addServerVariable_np (m_timedModUpdateTime);
|
||||
addSharedVariable_np (m_level);
|
||||
addSharedVariable_np (m_levelHealthGranted);
|
||||
addSharedVariable_np (m_animatingSkillData);
|
||||
addSharedVariable_np (m_animationMood);
|
||||
addSharedVariable_np (m_currentWeapon);
|
||||
addSharedVariable_np (m_group);
|
||||
addSharedVariable_np (m_groupInviter);
|
||||
addSharedVariable_np (m_guildId);
|
||||
addSharedVariable_np (m_lookAtTarget);
|
||||
addSharedVariable_np (m_intendedTarget);
|
||||
addSharedVariable_np (m_mood);
|
||||
addSharedVariable_np (m_performanceStartTime);
|
||||
addSharedVariable_np (m_performanceType);
|
||||
addSharedVariable_np (m_totalAttributes);
|
||||
addSharedVariable_np (m_totalMaxAttributes);
|
||||
addSharedVariable_np (m_wearableData);
|
||||
addSharedVariable_np (m_alternateAppearanceSharedObjectTemplateName);
|
||||
addSharedVariable_np (m_coverVisibility);
|
||||
addSharedVariable_np (m_buffs);
|
||||
addSharedVariable_np (m_clientUsesAnimationLocomotion);
|
||||
addSharedVariable_np (m_difficulty);
|
||||
addSharedVariable_np (m_hologramType);
|
||||
addSharedVariable_np (m_visibleOnMapAndRadar);
|
||||
addSharedVariable_np (m_isBeast);
|
||||
addSharedVariable_np (m_forceShowHam);
|
||||
addSharedVariable_np (m_wearableAppearanceData);
|
||||
addSharedVariable_np (m_decoyOrigin);
|
||||
addAuthClientServerVariable_np (m_accelPercent);
|
||||
addAuthClientServerVariable_np (m_accelScale);
|
||||
addAuthClientServerVariable_np (m_attribBonus);
|
||||
addAuthClientServerVariable_np (m_modMap);
|
||||
addAuthClientServerVariable_np (m_movementPercent);
|
||||
addAuthClientServerVariable_np (m_movementScale);
|
||||
addAuthClientServerVariable_np (m_performanceListenTarget);
|
||||
addAuthClientServerVariable_np (m_runSpeed);
|
||||
addAuthClientServerVariable_np (m_slopeModAngle);
|
||||
addAuthClientServerVariable_np (m_slopeModPercent);
|
||||
addAuthClientServerVariable_np (m_turnScale);
|
||||
addAuthClientServerVariable_np (m_walkSpeed);
|
||||
addAuthClientServerVariable_np (m_waterModPercent);
|
||||
addAuthClientServerVariable_np (m_groupMissionCriticalObjectSet);
|
||||
addAuthClientServerVariable_np (m_commands);
|
||||
addAuthClientServerVariable_np (m_totalLevelXp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void FactoryObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable_np (m_craftingCount);
|
||||
addServerVariable_np (m_craftingSchematic);
|
||||
addServerVariable_np (m_attributes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void GroupObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable_np (m_groupPOBShipAndOwners);
|
||||
addServerVariable_np (m_groupMemberLevels);
|
||||
addServerVariable_np (m_groupMemberProfessions);
|
||||
addServerVariable_np (m_allMembers);
|
||||
addServerVariable_np (m_nonPCMembers);
|
||||
addSharedVariable_np (m_groupMembers);
|
||||
addSharedVariable_np (m_groupShipFormationMembers);
|
||||
addSharedVariable_np (m_groupName);
|
||||
addSharedVariable_np (m_groupLevel);
|
||||
addSharedVariable_np (m_formationNameCrc);
|
||||
addSharedVariable_np (m_lootMaster);
|
||||
addSharedVariable_np (m_lootRule);
|
||||
addSharedVariable_np (m_groupPickupTimer);
|
||||
addSharedVariable_np (m_groupPickupLocation);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void GuildObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_names);
|
||||
addServerVariable (m_leaders);
|
||||
addServerVariable (m_members);
|
||||
addServerVariable (m_enemies);
|
||||
addSharedVariable (m_abbrevs);
|
||||
addServerVariable_np (m_guildsInfo);
|
||||
addServerVariable_np (m_membersInfo);
|
||||
addServerVariable_np (m_fullMembers);
|
||||
addServerVariable_np (m_sponsoredMembers);
|
||||
addServerVariable_np (m_guildLeaders);
|
||||
addServerVariable_np (m_gcwRegionDefenderBonus);
|
||||
addServerVariable_np (m_gcwImperialScorePercentileHistoryCountThisGalaxy);
|
||||
addServerVariable_np (m_gcwGroupImperialScorePercentileHistoryCountThisGalaxy);
|
||||
addServerVariable_np (m_gcwGroupCategoryImperialScoreRawThisGalaxy);
|
||||
addServerVariable_np (m_gcwGroupImperialScoreRawThisGalaxy);
|
||||
addServerVariable_np (m_gcwImperialScoreOtherGalaxies);
|
||||
addServerVariable_np (m_gcwRebelScoreOtherGalaxies);
|
||||
addServerVariable_np (m_gcwRegionDefenderGuilds);
|
||||
addServerVariable_np (m_gcwRegionDefenderGuildsCount);
|
||||
addServerVariable_np (m_gcwRegionDefenderGuildsVersion);
|
||||
addSharedVariable_np (m_gcwImperialScorePercentileThisGalaxy);
|
||||
addSharedVariable_np (m_gcwGroupImperialScorePercentileThisGalaxy);
|
||||
addSharedVariable_np (m_gcwImperialScorePercentileHistoryThisGalaxy);
|
||||
addSharedVariable_np (m_gcwGroupImperialScorePercentileHistoryThisGalaxy);
|
||||
addSharedVariable_np (m_gcwImperialScorePercentileOtherGalaxies);
|
||||
addSharedVariable_np (m_gcwGroupImperialScorePercentileOtherGalaxies);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void HarvesterInstallationObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_installedEfficiency);
|
||||
addServerVariable (m_resourceType);
|
||||
addServerVariable (m_maxExtractionRate);
|
||||
addServerVariable (m_currentExtractionRate);
|
||||
addServerVariable (m_maxHopperAmount);
|
||||
addServerVariable (m_hopperResource);
|
||||
addServerVariable (m_hopperAmount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void InstallationObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_installationType);
|
||||
addServerVariable (m_tickCount);
|
||||
addServerVariable (m_activateStartTime);
|
||||
addSharedVariable (m_activated);
|
||||
addSharedVariable (m_power);
|
||||
addSharedVariable (m_powerRate);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void IntangibleObject::addMembersToPackages()
|
||||
{
|
||||
addSharedVariable (m_count);
|
||||
addServerVariable_np (m_crcs);
|
||||
addServerVariable_np (m_positions);
|
||||
addServerVariable_np (m_headings);
|
||||
addServerVariable_np (m_scripts);
|
||||
addServerVariable_np (m_player);
|
||||
addServerVariable_np (m_objects);
|
||||
addServerVariable_np (m_center);
|
||||
addServerVariable_np (m_radius);
|
||||
addServerVariable_np (m_creator);
|
||||
addServerVariable_np (m_theaterName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void ManufactureInstallationObject::addMembersToPackages()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void ManufactureSchematicObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_draftSchematic);
|
||||
addServerVariable (m_creatorId);
|
||||
addServerVariable (m_creatorName);
|
||||
addSharedVariable (m_attributes);
|
||||
addSharedVariable (m_itemsPerContainer);
|
||||
addSharedVariable (m_manufactureTime);
|
||||
addServerVariable_np (m_factories);
|
||||
addServerVariable_np (m_resourceMaxAttributes);
|
||||
addSharedVariable_np (m_appearanceData);
|
||||
addSharedVariable_np (m_customAppearance);
|
||||
addSharedVariable_np (m_draftSchematicSharedTemplate);
|
||||
addSharedVariable_np (m_isCrafting);
|
||||
addSharedVariable_np (m_schematicChangedSignal);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void MissionObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_rootScriptName);
|
||||
addServerVariable (m_missionHolderId);
|
||||
addSharedVariable (m_difficulty);
|
||||
addSharedVariable (m_endLocation);
|
||||
addSharedVariable (m_missionCreator);
|
||||
addSharedVariable (m_reward);
|
||||
addSharedVariable (m_startLocation);
|
||||
addSharedVariable (m_targetAppearance);
|
||||
addSharedVariable (m_description);
|
||||
addSharedVariable (m_title);
|
||||
addSharedVariable (m_status);
|
||||
addSharedVariable (m_missionType);
|
||||
addSharedVariable (m_targetName);
|
||||
addSharedVariable (m_waypoint);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void PlanetObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_planetName);
|
||||
addServerVariable_np (m_travelPointList);
|
||||
addServerVariable_np (m_weatherIndex);
|
||||
addServerVariable_np (m_windVelocityX);
|
||||
addServerVariable_np (m_windVelocityY);
|
||||
addServerVariable_np (m_windVelocityZ);
|
||||
addServerVariable_np (m_mapLocationMapStatic);
|
||||
addServerVariable_np (m_mapLocationMapDynamic);
|
||||
addServerVariable_np (m_mapLocationMapPersist);
|
||||
addServerVariable_np (m_mapLocationVersionStatic);
|
||||
addServerVariable_np (m_mapLocationVersionDynamic);
|
||||
addServerVariable_np (m_mapLocationVersionPersist);
|
||||
addServerVariable_np (m_collectionServerFirst);
|
||||
addServerVariable_np (m_collectionServerFirstUpdateNumber);
|
||||
addServerVariable_np (m_connectedCharacterLfgData);
|
||||
addServerVariable_np (m_connectedCharacterLfgDataFactionalPresence);
|
||||
addServerVariable_np (m_connectedCharacterLfgDataFactionalPresenceGrid);
|
||||
addServerVariable_np (m_connectedCharacterBiographyData);
|
||||
addServerVariable_np (m_currentEvents);
|
||||
addServerVariable_np (m_gcwImperialScore);
|
||||
addServerVariable_np (m_gcwRebelScore);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void PlayerObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_stationId);
|
||||
addServerVariable (m_houseId);
|
||||
addServerVariable (m_accountNumLots);
|
||||
addServerVariable (m_accountMaxLotsAdjustment);
|
||||
addServerVariable (m_accountIsOutcast);
|
||||
addServerVariable (m_accountCheaterLevel);
|
||||
addServerVariable (m_forceRegenRate);
|
||||
addServerVariable (m_currentGcwRating);
|
||||
addServerVariable (m_maxGcwImperialRating);
|
||||
addServerVariable (m_maxGcwRebelRating);
|
||||
addServerVariable (m_nextGcwRatingCalcTime);
|
||||
addSharedVariable (m_matchMakingCharacterProfileId);
|
||||
addSharedVariable (m_matchMakingPersonalProfileId);
|
||||
addSharedVariable (m_skillTitle);
|
||||
addSharedVariable (m_bornDate);
|
||||
addSharedVariable (m_playedTime);
|
||||
addSharedVariable (m_roleIconChoice);
|
||||
addSharedVariable (m_skillTemplate);
|
||||
addSharedVariable (m_currentGcwPoints);
|
||||
addSharedVariable (m_currentPvpKills);
|
||||
addSharedVariable (m_lifetimeGcwPoints);
|
||||
addSharedVariable (m_lifetimePvpKills);
|
||||
addSharedVariable (m_collections);
|
||||
addSharedVariable (m_collections2);
|
||||
addSharedVariable (m_showBackpack);
|
||||
addSharedVariable (m_showHelmet);
|
||||
addServerVariable_np (m_craftingTool);
|
||||
addServerVariable_np (m_forceRegenValue);
|
||||
addServerVariable_np (m_theaterDatatable);
|
||||
addServerVariable_np (m_theaterPosition);
|
||||
addServerVariable_np (m_theaterScene);
|
||||
addServerVariable_np (m_theaterScript);
|
||||
addServerVariable_np (m_theaterNumObjects);
|
||||
addServerVariable_np (m_theaterRadius);
|
||||
addServerVariable_np (m_theaterCreator);
|
||||
addServerVariable_np (m_theaterName);
|
||||
addServerVariable_np (m_theaterId);
|
||||
addServerVariable_np (m_theaterLocationType);
|
||||
addServerVariable_np (m_sessionStartPlayTime);
|
||||
addServerVariable_np (m_sessionLastActiveTime);
|
||||
addServerVariable_np (m_sessionActivePlayTimeDuration);
|
||||
addServerVariable_np (m_aggroImmuneStartTime);
|
||||
addServerVariable_np (m_aggroImmuneDuration);
|
||||
addServerVariable_np (m_isFromLogin);
|
||||
addServerVariable_np (m_sessionActivity);
|
||||
addServerVariable_np (m_chatSpamSpatialNumCharacters);
|
||||
addServerVariable_np (m_chatSpamNonSpatialNumCharacters);
|
||||
addServerVariable_np (m_chatSpamTimeEndInterval);
|
||||
addServerVariable_np (m_chatSpamNextTimeToSyncWithChatServer);
|
||||
addServerVariable_np (m_currentGcwRegion);
|
||||
addSharedVariable_np (m_privledgedTitle);
|
||||
addSharedVariable_np (m_currentGcwRank);
|
||||
addSharedVariable_np (m_currentGcwRankProgress);
|
||||
addSharedVariable_np (m_maxGcwImperialRank);
|
||||
addSharedVariable_np (m_maxGcwRebelRank);
|
||||
addSharedVariable_np (m_gcwRatingActualCalcTime);
|
||||
addSharedVariable_np (m_citizenshipCity);
|
||||
addSharedVariable_np (m_citizenshipType);
|
||||
addSharedVariable_np (m_cityGcwDefenderRegion);
|
||||
addSharedVariable_np (m_guildGcwDefenderRegion);
|
||||
addSharedVariable_np (m_squelchedById);
|
||||
addSharedVariable_np (m_squelchedByName);
|
||||
addSharedVariable_np (m_squelchExpireTime);
|
||||
addSharedVariable_np (m_environmentFlags);
|
||||
addSharedVariable_np (m_defaultAttackOverride);
|
||||
addFirstParentAuthClientServerVariable (m_experiencePoints);
|
||||
addFirstParentAuthClientServerVariable (m_waypoints);
|
||||
addFirstParentAuthClientServerVariable (m_forcePower);
|
||||
addFirstParentAuthClientServerVariable (m_maxForcePower);
|
||||
addFirstParentAuthClientServerVariable (m_completedQuests);
|
||||
addFirstParentAuthClientServerVariable (m_activeQuests);
|
||||
addFirstParentAuthClientServerVariable (m_currentQuest);
|
||||
addFirstParentAuthClientServerVariable (m_quests);
|
||||
addFirstParentAuthClientServerVariable (m_workingSkill);
|
||||
addFirstParentAuthClientServerVariable_np (m_craftingLevel);
|
||||
addFirstParentAuthClientServerVariable_np (m_craftingStage);
|
||||
addFirstParentAuthClientServerVariable_np (m_craftingStation);
|
||||
addFirstParentAuthClientServerVariable_np (m_draftSchematics);
|
||||
addFirstParentAuthClientServerVariable_np (m_craftingComponentBioLink);
|
||||
addFirstParentAuthClientServerVariable_np (m_experimentPoints);
|
||||
addFirstParentAuthClientServerVariable_np (m_expModified);
|
||||
addFirstParentAuthClientServerVariable_np (m_friendList);
|
||||
addFirstParentAuthClientServerVariable_np (m_ignoreList);
|
||||
addFirstParentAuthClientServerVariable_np (m_spokenLanguage);
|
||||
addFirstParentAuthClientServerVariable_np (m_food);
|
||||
addFirstParentAuthClientServerVariable_np (m_maxFood);
|
||||
addFirstParentAuthClientServerVariable_np (m_drink);
|
||||
addFirstParentAuthClientServerVariable_np (m_maxDrink);
|
||||
addFirstParentAuthClientServerVariable_np (m_meds);
|
||||
addFirstParentAuthClientServerVariable_np (m_maxMeds);
|
||||
addFirstParentAuthClientServerVariable_np (m_groupWaypoints);
|
||||
addFirstParentAuthClientServerVariable_np (m_playerHateList);
|
||||
addFirstParentAuthClientServerVariable_np (m_killMeter);
|
||||
addFirstParentAuthClientServerVariable_np (m_accountNumLotsOverLimitSpam);
|
||||
addFirstParentAuthClientServerVariable_np (m_petId);
|
||||
addFirstParentAuthClientServerVariable_np (m_petCommandList);
|
||||
addFirstParentAuthClientServerVariable_np (m_petToggledCommands);
|
||||
addFirstParentAuthClientServerVariable_np (m_guildRank);
|
||||
addFirstParentAuthClientServerVariable_np (m_citizenRank);
|
||||
addFirstParentAuthClientServerVariable_np (m_galacticReserveDeposit);
|
||||
addFirstParentAuthClientServerVariable_np (m_pgcRatingCount);
|
||||
addFirstParentAuthClientServerVariable_np (m_pgcRatingTotal);
|
||||
addFirstParentAuthClientServerVariable_np (m_pgcLastRatingTime);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void PlayerQuestObject::addMembersToPackages()
|
||||
{
|
||||
addSharedVariable (m_title);
|
||||
addSharedVariable (m_description);
|
||||
addSharedVariable (m_creator);
|
||||
addSharedVariable (m_totalTasks);
|
||||
addSharedVariable (m_difficulty);
|
||||
addSharedVariable (m_taskTitle1);
|
||||
addSharedVariable (m_taskDescription1);
|
||||
addSharedVariable (m_taskTitle2);
|
||||
addSharedVariable (m_taskDescription2);
|
||||
addSharedVariable (m_taskTitle3);
|
||||
addSharedVariable (m_taskDescription3);
|
||||
addSharedVariable (m_taskTitle4);
|
||||
addSharedVariable (m_taskDescription4);
|
||||
addSharedVariable (m_taskTitle5);
|
||||
addSharedVariable (m_taskDescription5);
|
||||
addSharedVariable (m_taskTitle6);
|
||||
addSharedVariable (m_taskDescription6);
|
||||
addSharedVariable (m_taskTitle7);
|
||||
addSharedVariable (m_taskDescription7);
|
||||
addSharedVariable (m_taskTitle8);
|
||||
addSharedVariable (m_taskDescription8);
|
||||
addSharedVariable (m_taskTitle9);
|
||||
addSharedVariable (m_taskDescription9);
|
||||
addSharedVariable (m_taskTitle10);
|
||||
addSharedVariable (m_taskDescription10);
|
||||
addSharedVariable (m_taskTitle11);
|
||||
addSharedVariable (m_taskDescription11);
|
||||
addSharedVariable (m_taskTitle12);
|
||||
addSharedVariable (m_taskDescription12);
|
||||
addSharedVariable_np (m_tasks);
|
||||
addSharedVariable_np (m_taskCounters);
|
||||
addSharedVariable_np (m_taskStatus);
|
||||
addSharedVariable_np (m_waypoints);
|
||||
addSharedVariable_np (m_rewards);
|
||||
addSharedVariable_np (m_creatorName);
|
||||
addSharedVariable_np (m_completed);
|
||||
addSharedVariable_np (m_recipe);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void ResourceContainerObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_source);
|
||||
addSharedVariable (m_quantity);
|
||||
addSharedVariable (m_resourceType);
|
||||
addSharedVariable_np (m_maxQuantity);
|
||||
addSharedVariable_np (m_parentName);
|
||||
addSharedVariable_np (m_resourceName);
|
||||
addSharedVariable_np (m_resourceNameId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void ServerObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_cacheVersion);
|
||||
addServerVariable (m_loadContents);
|
||||
;
|
||||
m_objVars.addToPackage(m_serverPackage,m_serverPackage_np);
|
||||
addServerVariable (m_persisted);
|
||||
addServerVariable (m_playerControlled);
|
||||
addServerVariable (m_sceneId);
|
||||
m_scriptObject->addToPackage(m_serverPackage);
|
||||
addServerVariable (m_conversionId);
|
||||
addServerVariable (m_staticItemName);
|
||||
addServerVariable (m_staticItemVersion);
|
||||
addSharedVariable (m_complexity);
|
||||
addSharedVariable (m_nameStringId);
|
||||
addSharedVariable (m_objectName);
|
||||
addSharedVariable (m_volume);
|
||||
addAuthClientServerVariable (m_bankBalance);
|
||||
addAuthClientServerVariable (m_cashBalance);
|
||||
addServerVariable_np (m_attributesAttained);
|
||||
addServerVariable_np (m_attributesInterested);
|
||||
addServerVariable_np (m_proxyServerProcessIds);
|
||||
addServerVariable_np (m_transformSequence);
|
||||
addServerVariable_np (m_triggerVolumeInfo);
|
||||
addServerVariable_np (m_contentsLoaded);
|
||||
addServerVariable_np (m_contentsRequested);
|
||||
addServerVariable_np (m_messageTos);
|
||||
addServerVariable_np (m_defaultAlterTime);
|
||||
addServerVariable_np (m_observersCount);
|
||||
addServerVariable_np (m_includeInBuildout);
|
||||
addServerVariable_np (m_broadcastListeners);
|
||||
addServerVariable_np (m_broadcastBroadcasters);
|
||||
addSharedVariable_np (m_authServerProcessId);
|
||||
addSharedVariable_np (m_descriptionStringId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void ShipObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_componentCrc);
|
||||
addSharedVariable (m_slideDampener);
|
||||
addSharedVariable (m_currentChassisHitPoints);
|
||||
addSharedVariable (m_maximumChassisHitPoints);
|
||||
addSharedVariable (m_chassisType);
|
||||
addSharedVariable (m_componentArmorHitpointsMaximum);
|
||||
addSharedVariable (m_componentArmorHitpointsCurrent);
|
||||
addSharedVariable (m_componentHitpointsCurrent);
|
||||
addSharedVariable (m_componentHitpointsMaximum);
|
||||
addSharedVariable (m_componentFlags);
|
||||
addSharedVariable (m_shieldHitpointsFrontMaximum);
|
||||
addSharedVariable (m_shieldHitpointsBackMaximum);
|
||||
addAuthClientServerVariable (m_componentEfficiencyGeneral);
|
||||
addAuthClientServerVariable (m_componentEfficiencyEnergy);
|
||||
addAuthClientServerVariable (m_componentEnergyMaintenanceRequirement);
|
||||
addAuthClientServerVariable (m_componentMass);
|
||||
addAuthClientServerVariable (m_componentNames);
|
||||
addAuthClientServerVariable (m_componentCreators);
|
||||
addAuthClientServerVariable (m_weaponDamageMaximum);
|
||||
addAuthClientServerVariable (m_weaponDamageMinimum);
|
||||
addAuthClientServerVariable (m_weaponEffectivenessShields);
|
||||
addAuthClientServerVariable (m_weaponEffectivenessArmor);
|
||||
addAuthClientServerVariable (m_weaponEnergyPerShot);
|
||||
addAuthClientServerVariable (m_weaponRefireRate);
|
||||
addAuthClientServerVariable (m_weaponAmmoCurrent);
|
||||
addAuthClientServerVariable (m_weaponAmmoMaximum);
|
||||
addAuthClientServerVariable (m_weaponAmmoType);
|
||||
addAuthClientServerVariable (m_chassisComponentMassMaximum);
|
||||
addAuthClientServerVariable (m_shieldRechargeRate);
|
||||
addAuthClientServerVariable (m_capacitorEnergyMaximum);
|
||||
addAuthClientServerVariable (m_capacitorEnergyRechargeRate);
|
||||
addAuthClientServerVariable (m_engineAccelerationRate);
|
||||
addAuthClientServerVariable (m_engineDecelerationRate);
|
||||
addAuthClientServerVariable (m_enginePitchAccelerationRate);
|
||||
addAuthClientServerVariable (m_engineYawAccelerationRate);
|
||||
addAuthClientServerVariable (m_engineRollAccelerationRate);
|
||||
addAuthClientServerVariable (m_enginePitchRateMaximum);
|
||||
addAuthClientServerVariable (m_engineYawRateMaximum);
|
||||
addAuthClientServerVariable (m_engineRollRateMaximum);
|
||||
addAuthClientServerVariable (m_engineSpeedMaximum);
|
||||
addAuthClientServerVariable (m_reactorEnergyGenerationRate);
|
||||
addAuthClientServerVariable (m_boosterEnergyMaximum);
|
||||
addAuthClientServerVariable (m_boosterEnergyRechargeRate);
|
||||
addAuthClientServerVariable (m_boosterEnergyConsumptionRate);
|
||||
addAuthClientServerVariable (m_boosterAcceleration);
|
||||
addAuthClientServerVariable (m_boosterSpeedMaximum);
|
||||
addAuthClientServerVariable (m_droidInterfaceCommandSpeed);
|
||||
addAuthClientServerVariable (m_installedDroidControlDevice);
|
||||
addAuthClientServerVariable (m_cargoHoldContentsMaximum);
|
||||
addAuthClientServerVariable (m_cargoHoldContentsCurrent);
|
||||
addAuthClientServerVariable (m_cargoHoldContents);
|
||||
addServerVariable_np (m_engineSpeedRotationFactorMaximum);
|
||||
addServerVariable_np (m_engineSpeedRotationFactorMinimum);
|
||||
addServerVariable_np (m_engineSpeedRotationFactorOptimal);
|
||||
addSharedVariable_np (m_shipId);
|
||||
addSharedVariable_np (m_shipActualAccelerationRate);
|
||||
addSharedVariable_np (m_shipActualDecelerationRate);
|
||||
addSharedVariable_np (m_shipActualPitchAccelerationRate);
|
||||
addSharedVariable_np (m_shipActualYawAccelerationRate);
|
||||
addSharedVariable_np (m_shipActualRollAccelerationRate);
|
||||
addSharedVariable_np (m_shipActualPitchRateMaximum);
|
||||
addSharedVariable_np (m_shipActualYawRateMaximum);
|
||||
addSharedVariable_np (m_shipActualRollRateMaximum);
|
||||
addSharedVariable_np (m_shipActualSpeedMaximum);
|
||||
addSharedVariable_np (m_pilotLookAtTarget);
|
||||
addSharedVariable_np (m_pilotLookAtTargetSlot);
|
||||
addSharedVariable_np (m_targetableSlotBitfield);
|
||||
addSharedVariable_np (m_componentCrcForClient);
|
||||
addSharedVariable_np (m_wingName);
|
||||
addSharedVariable_np (m_typeName);
|
||||
addSharedVariable_np (m_difficulty);
|
||||
addSharedVariable_np (m_faction);
|
||||
addSharedVariable_np (m_shieldHitpointsFrontCurrent);
|
||||
addSharedVariable_np (m_shieldHitpointsBackCurrent);
|
||||
addSharedVariable_np (m_guildId);
|
||||
addAuthClientServerVariable_np (m_chassisComponentMassCurrent);
|
||||
addAuthClientServerVariable_np (m_chassisSpeedMaximumModifier);
|
||||
addAuthClientServerVariable_np (m_capacitorEnergyCurrent);
|
||||
addAuthClientServerVariable_np (m_boosterEnergyCurrent);
|
||||
addAuthClientServerVariable_np (m_weaponEfficiencyRefireRate);
|
||||
addAuthClientServerVariable_np (m_cargoHoldContentsResourceTypeInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void StaticObject::addMembersToPackages()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void TangibleObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_customAppearance);
|
||||
addServerVariable (m_locationTargets);
|
||||
addServerVariable (m_ownerId);
|
||||
addServerVariable (m_creatorId);
|
||||
addServerVariable (m_sourceDraftSchematic);
|
||||
addSharedVariable (m_pvpFaction);
|
||||
addSharedVariable (m_pvpType);
|
||||
addSharedVariable (m_appearanceData);
|
||||
addSharedVariable (m_components);
|
||||
addSharedVariable (m_condition);
|
||||
addSharedVariable (m_count);
|
||||
addSharedVariable (m_damageTaken);
|
||||
addSharedVariable (m_maxHitPoints);
|
||||
addSharedVariable (m_visible);
|
||||
addServerVariable_np (m_pvpEnemies);
|
||||
addServerVariable_np (m_pvpMercenaryFaction);
|
||||
addServerVariable_np (m_pvpMercenaryType);
|
||||
addServerVariable_np (m_pvpFutureType);
|
||||
addServerVariable_np (m_hateOverTime);
|
||||
addServerVariable_np (m_pvpRegionCrc);
|
||||
addServerVariable_np (m_conversations);
|
||||
addServerVariable_np (m_hideFromClient);
|
||||
addServerVariable_np (m_combatStartTime);
|
||||
addServerVariable_np (m_attackableOverride);
|
||||
addServerVariable_np (m_passiveReveal);
|
||||
addSharedVariable_np (m_inCombat);
|
||||
addSharedVariable_np (m_passiveRevealPlayerCharacter);
|
||||
addSharedVariable_np (m_mapColorOverride);
|
||||
addSharedVariable_np (m_accessList);
|
||||
addSharedVariable_np (m_guildAccessList);
|
||||
addSharedVariable_np (m_effectsMap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void UniverseObject::addMembersToPackages()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void VehicleObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_bogus);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generated function. Do not edit.
|
||||
*/
|
||||
void WeaponObject::addMembersToPackages()
|
||||
{
|
||||
addServerVariable (m_minDamage);
|
||||
addServerVariable (m_maxDamage);
|
||||
addServerVariable (m_woundChance);
|
||||
addServerVariable (m_attackCost);
|
||||
addServerVariable (m_damageRadius);
|
||||
addSharedVariable (m_attackSpeed);
|
||||
addSharedVariable (m_accuracy);
|
||||
addSharedVariable (m_minRange);
|
||||
addSharedVariable (m_maxRange);
|
||||
addSharedVariable (m_damageType);
|
||||
addSharedVariable (m_elementalType);
|
||||
addSharedVariable (m_elementalValue);
|
||||
addServerVariable_np (m_isDefaultWeapon);
|
||||
addSharedVariable_np (m_weaponType);
|
||||
}
|
||||
|
||||
//!!!END GENERATED PACKAGEADD
|
||||
@@ -0,0 +1,10 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstServerGame.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstServerKeyShare.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverKeyShare/FirstServerKeyShare.h"
|
||||
@@ -0,0 +1,9 @@
|
||||
// FirstServerMetrics.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverMetrics/FirstServerMetrics.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
#include "serverNetworkMessages/FirstServerNetworkMessages.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstServerPathfinding.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverPathfinding/FirstServerPathfinding.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
#include "serverScript/FirstServerScript.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
#include "serverUtility/FirstServerUtility.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "FirstTemplateCompiler.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "sharedFoundationTypes/FoundationTypes.h"
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
+1
@@ -0,0 +1 @@
|
||||
#include "FirstTemplateDefinitionCompiler.h"
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
#include "sharedFoundationTypes/FoundationTypes.h"
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstSharedCollision.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedCollision/FirstSharedCollision.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstCommandParser.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedCommandParser/FirstSharedCommandParser.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstCompression.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedCompression/FirstSharedCompression.h"
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstServerDatabaseInterface.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDatabaseInterface/FirstSharedDatabaseInterface.h"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/* SQLC_Defs.h
|
||||
*
|
||||
* This file includes common definitions needed by the other SQLClasses header files.
|
||||
* (Don't include this file directly -- files that require it will include it.)
|
||||
*
|
||||
* Note that this file is specific to each OS, because what header files are
|
||||
* needed varies in each OS. In particular, Unix versions don't want windows.h.
|
||||
*
|
||||
* ODBC versions: includes definitions of ODBC datatypes needed by the various
|
||||
* SQLClasses
|
||||
*/
|
||||
|
||||
#ifndef _SQLC_DEFS_H
|
||||
#define _SQLC_DEFS_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <sqltypes.h>
|
||||
|
||||
#endif
|
||||
@@ -169,14 +169,14 @@ void Report::puts(const char *buffer)
|
||||
}
|
||||
|
||||
// fatal strings should be made very obvious, so pop up a message box
|
||||
if ((flags & RF_dialog) && Os::isMainThread())
|
||||
{
|
||||
const char *title = "Report";
|
||||
if (flags & RF_fatal)
|
||||
title = "Fatal Report";
|
||||
//if ((flags & RF_dialog) && Os::isMainThread())
|
||||
//{
|
||||
// const char *title = "Report";
|
||||
// if (flags & RF_fatal)
|
||||
// title = "Fatal Report";
|
||||
|
||||
MessageBox(NULL, buffer, title, MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
// MessageBox(NULL, buffer, title, MB_OK | MB_ICONEXCLAMATION);
|
||||
//}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,670 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DebugHelp.cpp
|
||||
// copyright 2000 Verant Interactive
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedDebug/DebugHelp.h"
|
||||
|
||||
#include "sharedFoundation/WindowsWrapper.h"
|
||||
|
||||
#include <dbghelp.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
// ======================================================================
|
||||
// This was done to keep the header file from having to include <windows.h> or <dbghelp.h>
|
||||
|
||||
namespace DebugHelpNamespace
|
||||
{
|
||||
static HINSTANCE library;
|
||||
static HANDLE process;
|
||||
|
||||
struct CallbackData
|
||||
{
|
||||
const char *name;
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
typedef DWORD (__stdcall *SymSetOptionsFP)(IN DWORD SymOptions);
|
||||
typedef BOOL (__stdcall *SymInitializeFP)(IN HANDLE hProcess, IN PSTR UserSearchPath, IN BOOL fInvadeProcess);
|
||||
typedef BOOL (__stdcall *SymCleanupFP)(IN HANDLE hProcess);
|
||||
|
||||
typedef BOOL (__stdcall *StackWalk64FP)(DWORD MachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 StackFrame, PVOID ContextRecord, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
|
||||
typedef BOOL (__stdcall *SymGetModuleInfo64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PIMAGEHLP_MODULE64 ModuleInfo);
|
||||
typedef DWORD64 (__stdcall *SymLoadModule64FP)(IN HANDLE hProcess, IN HANDLE hFile, IN PSTR ImageName, IN PSTR ModuleName, IN DWORD64 BaseOfDll, IN DWORD SizeOfDll);
|
||||
typedef BOOL (__stdcall *SymGetSymFromAddr64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD64 pdwDisplacement, OUT PIMAGEHLP_SYMBOL64 Symbol);
|
||||
typedef BOOL (__stdcall *SymGetLineFromAddr64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr, OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE64 Line);
|
||||
typedef PVOID (__stdcall *SymFunctionTableAccess64FP)(HANDLE hProcess, DWORD64 AddrBase);
|
||||
typedef DWORD64 (__stdcall *SymGetModuleBase64FP)(IN HANDLE hProcess, IN DWORD64 dwAddr);
|
||||
typedef BOOL (__stdcall *SymEnumerateModules64FP)(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, PVOID UserContext);
|
||||
typedef BOOL (__stdcall *EnumerateLoadedModules64FP)(IN HANDLE hProcess, IN PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, IN PVOID UserContext);
|
||||
typedef BOOL (__stdcall *MiniDumpWriteDumpFP)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
|
||||
static SymSetOptionsFP symSetOptions;
|
||||
static SymInitializeFP symInitialize;
|
||||
static SymCleanupFP symCleanup;
|
||||
static StackWalk64FP stackWalk64;
|
||||
static SymGetModuleInfo64FP symGetModuleInfo64;
|
||||
static SymLoadModule64FP symLoadModule64;
|
||||
static SymGetSymFromAddr64FP symGetSymFromAddr64;
|
||||
static SymGetLineFromAddr64FP symGetLineFromAddr64;
|
||||
static SymFunctionTableAccess64FP symFunctionTableAccess64;
|
||||
static SymGetModuleBase64FP symGetModuleBase64;
|
||||
static SymEnumerateModules64FP symEnumerateModules64;
|
||||
static EnumerateLoadedModules64FP enumerateLoadedModules64;
|
||||
static MiniDumpWriteDumpFP miniDumpWriteDump;
|
||||
static CRITICAL_SECTION criticalSection;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//BOOL CALLBACK loadSymbolsForDllCallback(PTSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
typedef unsigned long int ub4; /* unsigned 4-byte quantities */
|
||||
typedef unsigned char ub1; /* unsigned 1-byte quantities */
|
||||
|
||||
#define hashsize(n) ((ub4)1<<(n))
|
||||
#define hashmask(n) (hashsize(n)-1)
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------
|
||||
mix -- mix 3 32-bit values reversibly.
|
||||
For every delta with one or two bits set, and the deltas of all three
|
||||
high bits or all three low bits, whether the original value of a,b,c
|
||||
is almost all zero or is uniformly distributed,
|
||||
* If mix() is run forward or backward, at least 32 bits in a,b,c
|
||||
have at least 1/4 probability of changing.
|
||||
* If mix() is run forward, every bit of c will change between 1/3 and
|
||||
2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
|
||||
mix() was built out of 36 single-cycle latency instructions in a
|
||||
structure that could supported 2x parallelism, like so:
|
||||
a -= b;
|
||||
a -= c; x = (c>>13);
|
||||
b -= c; a ^= x;
|
||||
b -= a; x = (a<<8);
|
||||
c -= a; b ^= x;
|
||||
c -= b; x = (b>>13);
|
||||
...
|
||||
Unfortunately, superscalar Pentiums and Sparcs can't take advantage
|
||||
of that parallelism. They've also turned some of those single-cycle
|
||||
latency instructions into multi-cycle latency instructions. Still,
|
||||
this is the fastest good hash I could find. There were about 2^^68
|
||||
to choose from. I only looked at a billion or so.
|
||||
--------------------------------------------------------------------
|
||||
*/
|
||||
#define mix(a,b,c) \
|
||||
{ \
|
||||
a -= b; a -= c; a ^= (c>>13); \
|
||||
b -= c; b -= a; b ^= (a<<8); \
|
||||
c -= a; c -= b; c ^= (b>>13); \
|
||||
a -= b; a -= c; a ^= (c>>12); \
|
||||
b -= c; b -= a; b ^= (a<<16); \
|
||||
c -= a; c -= b; c ^= (b>>5); \
|
||||
a -= b; a -= c; a ^= (c>>3); \
|
||||
b -= c; b -= a; b ^= (a<<10); \
|
||||
c -= a; c -= b; c ^= (b>>15); \
|
||||
}
|
||||
|
||||
/*
|
||||
--------------------------------------------------------------------
|
||||
hash() -- hash a variable-length key into a 32-bit value
|
||||
k : the key (the unaligned variable-length array of bytes)
|
||||
len : the length of the key, counting by bytes
|
||||
initval : can be any 4-byte value
|
||||
Returns a 32-bit value. Every bit of the key affects every bit of
|
||||
the return value. Every 1-bit and 2-bit delta achieves avalanche.
|
||||
About 6*len+35 instructions.
|
||||
|
||||
The best hash table sizes are powers of 2. There is no need to do
|
||||
mod a prime (mod is sooo slow!). If you need less than 32 bits,
|
||||
use a bitmask. For example, if you need only 10 bits, do
|
||||
h = (h & hashmask(10));
|
||||
In which case, the hash table should have hashsize(10) elements.
|
||||
|
||||
If you are hashing n strings (ub1 **)k, do it like this:
|
||||
for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
|
||||
|
||||
By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
|
||||
code any way you wish, private, educational, or commercial. It's free.
|
||||
|
||||
See http://burtleburtle.net/bob/hash/evahash.html
|
||||
Use for hash table lookup, or anything where one collision in 2^^32 is
|
||||
acceptable. Do NOT use for cryptographic purposes.
|
||||
--------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// k; /* the key */
|
||||
// length; /* the length of the key */
|
||||
// initval; /* the previous hash, or an arbitrary value */
|
||||
#if 0
|
||||
static ub4 hash(ub1 *k, const ub4 length, const ub4 initval)
|
||||
{
|
||||
ub4 a, b, c, len;
|
||||
|
||||
/* Set up the internal state */
|
||||
len = length;
|
||||
a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
|
||||
c = initval; /* the previous hash value */
|
||||
|
||||
/*---------------------------------------- handle most of the key */
|
||||
while (len >= 12)
|
||||
{
|
||||
a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
|
||||
b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
|
||||
c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
|
||||
mix(a,b,c);
|
||||
k += 12; len -= 12;
|
||||
}
|
||||
|
||||
/*------------------------------------- handle the last 11 bytes */
|
||||
c += length;
|
||||
switch(len) /* all the case statements fall through */
|
||||
{
|
||||
case 11: c+=((ub4)k[10]<<24);
|
||||
case 10: c+=((ub4)k[9]<<16);
|
||||
case 9 : c+=((ub4)k[8]<<8);
|
||||
/* the first byte of c is reserved for the length */
|
||||
case 8 : b+=((ub4)k[7]<<24);
|
||||
case 7 : b+=((ub4)k[6]<<16);
|
||||
case 6 : b+=((ub4)k[5]<<8);
|
||||
case 5 : b+=k[4];
|
||||
case 4 : a+=((ub4)k[3]<<24);
|
||||
case 3 : a+=((ub4)k[2]<<16);
|
||||
case 2 : a+=((ub4)k[1]<<8);
|
||||
case 1 : a+=k[0];
|
||||
/* case 0: nothing left to add */
|
||||
}
|
||||
mix(a,b,c);
|
||||
/*-------------------------------------------- report the result */
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
|
||||
// version optimized for 4 byte input.
|
||||
static ub4 hash_DWORD(const DWORD in, const ub4 initval)
|
||||
{
|
||||
ub1 *const k = (ub1 *)∈
|
||||
ub4 a, b, c, len;
|
||||
|
||||
/* Set up the internal state */
|
||||
len = 4;
|
||||
a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
|
||||
c = initval; /* the previous hash value */
|
||||
|
||||
/*------------------------------------- handle the last 11 bytes */
|
||||
c += 4;
|
||||
a+=((ub4)k[3]<<24);
|
||||
a+=((ub4)k[2]<<16);
|
||||
a+=((ub4)k[1]<<8);
|
||||
a+=k[0];
|
||||
|
||||
mix(a,b,c);
|
||||
|
||||
/*-------------------------------------------- report the result */
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
struct BaseAddressLookup
|
||||
{
|
||||
DWORD64 keyAddress; // key
|
||||
DWORD64 baseAddress; // value
|
||||
};
|
||||
|
||||
static BaseAddressLookup * s_baseAddressCache;
|
||||
static inline unsigned _baseAddressCachePageBits() { return 8; }
|
||||
static inline unsigned _baseAddressCacheBits() { return _baseAddressCachePageBits() + 12; }
|
||||
static inline unsigned _baseAddressCacheSize() { return 1 << (_baseAddressCacheBits()); }
|
||||
static inline unsigned _baseAddressCacheElements() { return _baseAddressCacheSize() / sizeof(*s_baseAddressCache); }
|
||||
static inline unsigned _baseAddressCacheMask() { return _baseAddressCacheElements() - 1; }
|
||||
|
||||
static int s_baseAddressCacheMisses;
|
||||
static int s_baseAddressCacheHits;
|
||||
|
||||
static int s_baseAddressElements;
|
||||
static int s_baseAddressUsed;
|
||||
|
||||
/*
|
||||
static void _baseAddressCacheAnalyze()
|
||||
{
|
||||
s_baseAddressElements=0;
|
||||
s_baseAddressUsed=0;
|
||||
|
||||
unsigned i;
|
||||
const unsigned count = _baseAddressCacheElements();
|
||||
for (i=0;i<count;i++)
|
||||
{
|
||||
const BaseAddressLookup *lookup = s_baseAddressCache + i;
|
||||
s_baseAddressElements++;
|
||||
if (lookup->baseAddress)
|
||||
{
|
||||
s_baseAddressUsed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static DWORD64 _baseAddressLookup(DWORD64 addr)
|
||||
{
|
||||
BaseAddressLookup *lookup;
|
||||
|
||||
unsigned long bits = _baseAddressCacheBits();
|
||||
|
||||
DWORD *addr32 = (DWORD *)&addr;
|
||||
unsigned long hash32 = hash_DWORD(addr32[0], addr32[1]);
|
||||
unsigned long hash = (hash32>>(32-bits)) ^ hash32;
|
||||
|
||||
unsigned long mask = _baseAddressCacheMask();
|
||||
|
||||
unsigned long index = hash & mask;
|
||||
lookup = s_baseAddressCache + index;
|
||||
if (lookup->keyAddress==addr)
|
||||
{
|
||||
s_baseAddressCacheHits++;
|
||||
//DEBUG_FATAL(symGetModuleBase64(process, addr) != lookup->baseAddress, ("Cache failure.\n"));
|
||||
return lookup->baseAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_baseAddressCacheMisses++;
|
||||
|
||||
DWORD64 baseAddress = symGetModuleBase64(process, addr);
|
||||
|
||||
lookup->keyAddress=addr;
|
||||
lookup->baseAddress=baseAddress;
|
||||
|
||||
return baseAddress;
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD64 __stdcall getModuleBase(HANDLE hProcess, DWORD64 dwAddr)
|
||||
{
|
||||
UNREF(hProcess);
|
||||
DEBUG_FATAL(hProcess!=process, ("Wrong process handle for module base lookup.\n"));
|
||||
return _baseAddressLookup(dwAddr);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
struct FunctionTableLookup
|
||||
{
|
||||
DWORD64 keyAddress; // key
|
||||
PVOID functionTable; // value
|
||||
};
|
||||
|
||||
static FunctionTableLookup * s_functionTableCache;
|
||||
static inline unsigned _functionTableCachePageBits() { return 4; }
|
||||
static inline unsigned _functionTableCacheBits() { return _functionTableCachePageBits() + 12; }
|
||||
static inline unsigned _functionTableCacheSize() { return 1 << (_functionTableCacheBits()); }
|
||||
static inline unsigned _functionTableCacheElements() { return _functionTableCacheSize() / sizeof(*s_functionTableCache); }
|
||||
static inline unsigned _functionTableCacheMask() { return _functionTableCacheElements() - 1; }
|
||||
|
||||
static int s_functionTableCacheMisses;
|
||||
static int s_functionTableCacheHits;
|
||||
|
||||
|
||||
static PVOID _functionTableLookup(DWORD64 addr)
|
||||
{
|
||||
FunctionTableLookup *lookup;
|
||||
|
||||
unsigned long bits = _functionTableCacheBits();
|
||||
|
||||
DWORD *addr32 = (DWORD *)&addr;
|
||||
unsigned long hash32 = hash_DWORD(addr32[0], addr32[1]);
|
||||
unsigned long hash = (hash32>>(32-bits)) ^ hash32;
|
||||
|
||||
unsigned long mask = _functionTableCacheMask();
|
||||
|
||||
unsigned long index = hash & mask;
|
||||
lookup = s_functionTableCache + index;
|
||||
if (lookup->keyAddress==addr)
|
||||
{
|
||||
s_functionTableCacheHits++;
|
||||
//DEBUG_FATAL(symFunctionTableAccess64(process, addr) != lookup->functionTable, ("Cache failure.\n"));
|
||||
return lookup->functionTable;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_functionTableCacheMisses++;
|
||||
PVOID functionTable = symFunctionTableAccess64(process, addr);
|
||||
lookup->keyAddress=addr;
|
||||
lookup->functionTable=functionTable;
|
||||
|
||||
return functionTable;
|
||||
}
|
||||
}
|
||||
|
||||
static PVOID __stdcall functionTableAccess(HANDLE hProcess, DWORD64 dwAddr)
|
||||
{
|
||||
UNREF(hProcess);
|
||||
DEBUG_FATAL(hProcess!=process, ("Wrong process handle for module base lookup.\n"));
|
||||
return _functionTableLookup(DWORD(dwAddr));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
}
|
||||
using namespace DebugHelpNamespace;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
BOOL CALLBACK loadSymbolsForDllCallback(PSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext)
|
||||
{
|
||||
if (!library)
|
||||
return false;
|
||||
|
||||
CallbackData *callbackData = reinterpret_cast<CallbackData *>(UserContext);
|
||||
|
||||
// see if this is the right file module and if we can load its symbol information
|
||||
if (_stricmp(ModuleName, callbackData->name) == 0 && symLoadModule64(process, NULL, ModuleName, 0, ModuleBase, ModuleSize) != 0)
|
||||
{
|
||||
callbackData->loaded = true;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void DebugHelp::install()
|
||||
{
|
||||
DEBUG_FATAL(library, ("DebugHelp already installed"));
|
||||
|
||||
library = LoadLibrary("dbghelp_6.3.17.0.dll");
|
||||
if (library)
|
||||
{
|
||||
process = GetCurrentProcess();
|
||||
|
||||
#define GPA(a, b) a = reinterpret_cast<b##FP>(GetProcAddress(library, #b)); DEBUG_FATAL(!a, ("GetProcAddress failed for " #b))
|
||||
GPA(symSetOptions, SymSetOptions);
|
||||
GPA(symInitialize, SymInitialize);
|
||||
GPA(symCleanup, SymCleanup);
|
||||
GPA(stackWalk64, StackWalk64);
|
||||
GPA(symGetModuleInfo64, SymGetModuleInfo64);
|
||||
GPA(symLoadModule64, SymLoadModule64);
|
||||
GPA(symGetSymFromAddr64, SymGetSymFromAddr64);
|
||||
GPA(symGetLineFromAddr64, SymGetLineFromAddr64);
|
||||
GPA(symFunctionTableAccess64, SymFunctionTableAccess64);
|
||||
GPA(symGetModuleBase64, SymGetModuleBase64);
|
||||
GPA(symEnumerateModules64, SymEnumerateModules64);
|
||||
GPA(enumerateLoadedModules64, EnumerateLoadedModules64);
|
||||
GPA(miniDumpWriteDump, MiniDumpWriteDump);
|
||||
#undef GPA
|
||||
|
||||
IGNORE_RETURN(symSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES));
|
||||
|
||||
// get the path to the executable
|
||||
char executableDirectory[MAX_PATH * 2];
|
||||
const DWORD result = GetModuleFileName(NULL, executableDirectory, sizeof(executableDirectory));
|
||||
FATAL(result == 0, ("GetModuleFileName failed"));
|
||||
char * const slash = strrchr(executableDirectory, '\\');
|
||||
DEBUG_FATAL(!slash, ("Executable path does not contain a slash"));
|
||||
*slash = '\0';
|
||||
|
||||
const BOOL result1 = symInitialize(process, executableDirectory, TRUE);
|
||||
UNREF(result1);
|
||||
DEBUG_FATAL(!result1, ("SymInitialize failed"));
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
s_baseAddressCache = (BaseAddressLookup *)VirtualAlloc(0, _baseAddressCacheSize(), MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
s_functionTableCache = (FunctionTableLookup *)VirtualAlloc(0, _functionTableCacheSize(), MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Initialize the critical section one time only.
|
||||
InitializeCriticalSection(&criticalSection);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DebugHelp::remove()
|
||||
{
|
||||
if (s_baseAddressCache)
|
||||
{
|
||||
VirtualFree(s_baseAddressCache, 0, MEM_RELEASE);
|
||||
s_baseAddressCache=0;
|
||||
}
|
||||
|
||||
if (s_functionTableCache)
|
||||
{
|
||||
VirtualFree(s_functionTableCache, 0, MEM_RELEASE);
|
||||
s_functionTableCache=0;
|
||||
}
|
||||
|
||||
if (library)
|
||||
{
|
||||
IGNORE_RETURN(symCleanup(process));
|
||||
IGNORE_RETURN(FreeLibrary(library));
|
||||
library = NULL;
|
||||
process = NULL;
|
||||
symSetOptions = NULL;
|
||||
symInitialize = NULL;
|
||||
symCleanup = NULL;
|
||||
stackWalk64 = NULL;
|
||||
symGetModuleInfo64 = NULL;
|
||||
symLoadModule64 = NULL;
|
||||
symGetSymFromAddr64 = NULL;
|
||||
symGetLineFromAddr64 = NULL;
|
||||
symFunctionTableAccess64 = NULL;
|
||||
symGetModuleBase64 = NULL;
|
||||
symEnumerateModules64 = NULL;
|
||||
enumerateLoadedModules64 = NULL;
|
||||
}
|
||||
|
||||
// Release resources used by the critical section object.
|
||||
DeleteCriticalSection(&criticalSection);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool DebugHelp::loadSymbolsForDll(const char *name)
|
||||
{
|
||||
if (!library)
|
||||
return false;
|
||||
|
||||
CallbackData callbackData = { name, false };
|
||||
enumerateLoadedModules64(process, (PENUMLOADED_MODULES_CALLBACK64)loadSymbolsForDllCallback, reinterpret_cast<void *>(&callbackData));
|
||||
return callbackData.loaded;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
#pragma warning (disable: 4740 4748)
|
||||
void DebugHelp::getCallStack(uint32 *callStack, int sizeOfCallStack)
|
||||
{
|
||||
{
|
||||
for (int i = 0; i < sizeOfCallStack; ++i)
|
||||
callStack[i] = 0;
|
||||
}
|
||||
|
||||
if (!library)
|
||||
return;
|
||||
|
||||
CONTEXT context;
|
||||
Zero(context);
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
|
||||
// GetThreadContext returns invalid data when called from within the same thread
|
||||
//if (!GetThreadContext(GetCurrentThread(), &context))
|
||||
// return;
|
||||
|
||||
EnterCriticalSection(&criticalSection);
|
||||
__asm
|
||||
{
|
||||
call GetEIP
|
||||
GetEIP:
|
||||
pop eax
|
||||
mov context.Eip, eax
|
||||
mov context.Esp, esp
|
||||
mov context.Ebp, ebp
|
||||
}
|
||||
LeaveCriticalSection(&criticalSection);
|
||||
|
||||
STACKFRAME64 stackFrame;
|
||||
Zero(stackFrame);
|
||||
stackFrame.AddrPC.Mode = AddrModeFlat;
|
||||
stackFrame.AddrPC.Offset = context.Eip;
|
||||
stackFrame.AddrStack.Offset = context.Esp;
|
||||
stackFrame.AddrStack.Mode = AddrModeFlat;
|
||||
stackFrame.AddrFrame.Offset = context.Ebp;
|
||||
stackFrame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
for (int i = 0; i < sizeOfCallStack; ++i, ++callStack)
|
||||
{
|
||||
if (stackWalk64(IMAGE_FILE_MACHINE_I386, process, process, &stackFrame, &context, NULL, functionTableAccess, getModuleBase, NULL))
|
||||
{
|
||||
const DWORD64 Offset = stackFrame.AddrPC.Offset;
|
||||
*callStack = DWORD(Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DebugHelp::reportCallStack(int const maxStackDepth)
|
||||
{
|
||||
// look up the call stack information
|
||||
int const callStackOffset = 2;
|
||||
int const callStackSize = callStackOffset + maxStackDepth;
|
||||
uint32 * callStack = static_cast<uint32 *>(_alloca((callStackOffset + maxStackDepth) * sizeof(uint32)));
|
||||
getCallStack(callStack, callStackOffset + maxStackDepth);
|
||||
|
||||
// look up the caller's file and line
|
||||
if (callStack[callStackOffset])
|
||||
{
|
||||
char lib[4 * 1024] = { '\0' };
|
||||
char file[4 * 1024] = { '\0' };
|
||||
int line = 0;
|
||||
for (int i = callStackOffset; i < callStackSize; ++i)
|
||||
{
|
||||
if (callStack[i])
|
||||
{
|
||||
if (lookupAddress(callStack[i], lib, file, sizeof(file), line))
|
||||
REPORT_LOG(true, ("\t%s(%d) : caller %d\n", file, line, i-callStackOffset));
|
||||
else
|
||||
REPORT_LOG(true, ("\tunknown(0x%08X) : caller %d\n", static_cast<int>(callStack[i]), i-callStackOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool DebugHelp::lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line)
|
||||
{
|
||||
UNREF(libName);
|
||||
|
||||
if (!library)
|
||||
return false;
|
||||
|
||||
// make sure the image is loaded
|
||||
IMAGEHLP_MODULE64 imageHelpModule;
|
||||
Zero(imageHelpModule);
|
||||
imageHelpModule.SizeOfStruct = sizeof(imageHelpModule);
|
||||
if (!symGetModuleInfo64(process, address, &imageHelpModule))
|
||||
return false;
|
||||
|
||||
// look up the symbol
|
||||
const int MaxNameLength = 256;
|
||||
char buffer[sizeof(IMAGEHLP_SYMBOL64) + MaxNameLength];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
IMAGEHLP_SYMBOL64 *imageHelpSymbol = reinterpret_cast<IMAGEHLP_SYMBOL64*>(buffer);
|
||||
imageHelpSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
|
||||
imageHelpSymbol->Address = address;
|
||||
imageHelpSymbol->MaxNameLength = MaxNameLength;
|
||||
{
|
||||
DWORD64 displacement = 0;
|
||||
if (!symGetSymFromAddr64(process, address, &displacement, imageHelpSymbol))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// look up the source file name and line number
|
||||
IMAGEHLP_LINE64 imageHelpLine;
|
||||
Zero(imageHelpLine);
|
||||
imageHelpLine.SizeOfStruct = sizeof(imageHelpLine);
|
||||
{
|
||||
DWORD displacement = 0;
|
||||
if (!symGetLineFromAddr64(process, address, &displacement, &imageHelpLine))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// return the results
|
||||
strncpy(fileName, imageHelpLine.FileName, static_cast<uint>(fileNameLength));
|
||||
line = static_cast<int>(imageHelpLine.LineNumber);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool DebugHelp::writeMiniDump(char const *miniDumpFileName, PEXCEPTION_POINTERS exceptionPointers)
|
||||
{
|
||||
if (!miniDumpWriteDump)
|
||||
return false;
|
||||
|
||||
char buffer[256];
|
||||
if (!miniDumpFileName)
|
||||
{
|
||||
// get the program name
|
||||
char programName[512];
|
||||
DWORD result = GetModuleFileName(NULL, programName, sizeof(programName));
|
||||
if (result == 0)
|
||||
return false;
|
||||
|
||||
// get the file name without the path
|
||||
const char *shortProgramName = strrchr(programName, '\\');
|
||||
if (shortProgramName)
|
||||
++shortProgramName;
|
||||
else
|
||||
shortProgramName = programName;
|
||||
|
||||
// lop off the extension
|
||||
char *dot = const_cast<char *>(strchr(shortProgramName, '.'));
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
|
||||
// create a reasonable minidump filename
|
||||
snprintf(buffer, sizeof(buffer), "%s_%d.mdmp", shortProgramName, static_cast<int>(GetCurrentProcessId()));
|
||||
miniDumpFileName = buffer;
|
||||
}
|
||||
|
||||
// create the file
|
||||
HANDLE const file = CreateFile(miniDumpFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
|
||||
// create the exception information
|
||||
MINIDUMP_EXCEPTION_INFORMATION exceptionInformationData;
|
||||
MINIDUMP_EXCEPTION_INFORMATION *exceptionInformation = 0;
|
||||
if (exceptionPointers)
|
||||
{
|
||||
exceptionInformationData.ThreadId = GetCurrentThreadId();
|
||||
exceptionInformationData.ExceptionPointers = exceptionPointers;
|
||||
exceptionInformationData.ClientPointers = true;
|
||||
exceptionInformation = &exceptionInformationData;
|
||||
}
|
||||
|
||||
// @todo make the minidump style modifiable
|
||||
BOOL const result = miniDumpWriteDump(process, GetCurrentProcessId(), file, MiniDumpNormal, exceptionInformation, NULL, NULL);
|
||||
|
||||
// close the file
|
||||
CloseHandle(file);
|
||||
|
||||
return result ? true : false;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,35 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DebugHelp.h
|
||||
// copyright 2000 Verant Interactive
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef DEBUG_HELP_H
|
||||
#define DEBUG_HELP_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
typedef unsigned long uint32;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class DebugHelp
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
static void remove();
|
||||
|
||||
static bool loadSymbolsForDll(const char *name);
|
||||
|
||||
static void getCallStack(uint32 *callStack, int sizeOfCallStack);
|
||||
static void reportCallStack(int const maxStackDepth = 4);
|
||||
static bool lookupAddress(uint32 address, char *libName, char *fileName, int fileNameLength, int &line);
|
||||
|
||||
static bool writeMiniDump(char const *miniDumpFileName=0, PEXCEPTION_POINTERS exceptionPointers=0);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,321 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DebugMonitor.cpp
|
||||
// copyright 1998 Bootprint Entertainment
|
||||
// copyright 2001-2004 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedDebug/DebugMonitor.h"
|
||||
|
||||
#if PRODUCTION == 0
|
||||
|
||||
#include "sharedDebug/DebugFlags.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace DebugMonitorNamespace
|
||||
{
|
||||
typedef void (*ChangedWindowCallback)(int x, int y, int width, int height);
|
||||
|
||||
typedef bool (*InstallFunction)(int x, int y, int width, int height);
|
||||
typedef void (*RemoveFunction)();
|
||||
typedef void (*ShowFunction)();
|
||||
typedef void (*HideFunction)();
|
||||
typedef void (*SetChangedWindowCallback)(ChangedWindowCallback);
|
||||
typedef void (*SetBehindWindowFunction)(HWND window);
|
||||
typedef void (*ClearScreenFunction)();
|
||||
typedef void (*ClearToCursorFunction)();
|
||||
typedef void (*GotoXYFunction)(int x, int y);
|
||||
typedef void (*PrintFunction)(const char *string);
|
||||
|
||||
void changedWindowCallback(int x, int y, int width, int height);
|
||||
|
||||
HINSTANCE dll;
|
||||
HKEY registryKey = HKEY_CLASSES_ROOT;
|
||||
RemoveFunction removeFunction;
|
||||
ShowFunction showFunction;
|
||||
HideFunction hideFunction;
|
||||
SetBehindWindowFunction setBehindWindowFunction;
|
||||
ClearScreenFunction clearScreenFunction;
|
||||
ClearToCursorFunction clearToCursorFunction;
|
||||
GotoXYFunction gotoXYFunction;
|
||||
PrintFunction printFunction;
|
||||
|
||||
bool noClear;
|
||||
|
||||
int GetRegistryValue(char const * name, int defaultValue)
|
||||
{
|
||||
int value;
|
||||
DWORD type = 0;
|
||||
DWORD size = sizeof(DWORD);
|
||||
LONG result = RegQueryValueEx(registryKey, name, NULL, &type, reinterpret_cast<LPBYTE>(&value), &size);
|
||||
if (result != ERROR_SUCCESS || type != REG_DWORD && size != sizeof(int))
|
||||
value = defaultValue;
|
||||
return value;
|
||||
}
|
||||
|
||||
void SetRegistryValue(char const * name, int value)
|
||||
{
|
||||
RegSetValueEx(registryKey, name, NULL, REG_DWORD, reinterpret_cast<const LPBYTE>(&value), sizeof(int));
|
||||
}
|
||||
}
|
||||
using namespace DebugMonitorNamespace;
|
||||
|
||||
// ======================================================================
|
||||
// Install the debug monitor subsystem
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
// This routine will first attempt to install the selected debug monitor.
|
||||
|
||||
void DebugMonitor::install()
|
||||
{
|
||||
dll = LoadLibrary("debugWindow.dll");
|
||||
if (dll)
|
||||
{
|
||||
InstallFunction installFunction = reinterpret_cast<InstallFunction>(GetProcAddress(dll, "install"));
|
||||
|
||||
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Sony Online Entertainment\\DebugWindow", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ®istryKey, NULL);
|
||||
|
||||
int const x = ConfigFile::getKeyInt("SharedDebug", "debugWindowX", GetRegistryValue("x", 0));
|
||||
int const y = ConfigFile::getKeyInt("SharedDebug", "debugWindowY", GetRegistryValue("y", 0));
|
||||
int const width = ConfigFile::getKeyInt("SharedDebug", "debugWindowWidth", GetRegistryValue("width", 80));
|
||||
int const height = ConfigFile::getKeyInt("SharedDebug", "debugWindowHeight", GetRegistryValue("height", 50));
|
||||
|
||||
if (installFunction && installFunction(x, y, width, height))
|
||||
{
|
||||
showFunction = reinterpret_cast<ShowFunction>(GetProcAddress(dll, "showWindow"));
|
||||
hideFunction = reinterpret_cast<ShowFunction>(GetProcAddress(dll, "hideWindow"));
|
||||
removeFunction = reinterpret_cast<RemoveFunction>(GetProcAddress(dll, "remove"));
|
||||
setBehindWindowFunction = reinterpret_cast<SetBehindWindowFunction>(GetProcAddress(dll, "setBehindWindow"));
|
||||
clearScreenFunction = reinterpret_cast<ClearScreenFunction>(GetProcAddress(dll, "clearScreen"));
|
||||
clearToCursorFunction = reinterpret_cast<ClearToCursorFunction>(GetProcAddress(dll, "clearToCursor"));
|
||||
gotoXYFunction = reinterpret_cast<GotoXYFunction>(GetProcAddress(dll, "gotoXY"));
|
||||
printFunction = reinterpret_cast<PrintFunction>(GetProcAddress(dll, "print"));
|
||||
|
||||
SetChangedWindowCallback setChangedWindowCallback = reinterpret_cast<SetChangedWindowCallback>(GetProcAddress(dll, "setChangedWindowCallback"));
|
||||
if (setChangedWindowCallback)
|
||||
(*setChangedWindowCallback)(changedWindowCallback);
|
||||
|
||||
DebugFlags::registerFlag(noClear, "SharedDebug", "noDebugMonitorClear");
|
||||
|
||||
if (ConfigFile::getKeyBool("SharedDebug", "debugWindow", false))
|
||||
show();
|
||||
}
|
||||
else
|
||||
{
|
||||
installFunction = NULL;
|
||||
const BOOL result = FreeLibrary(dll);
|
||||
dll = NULL;
|
||||
UNREF(result);
|
||||
DEBUG_FATAL(!result, ("FreeLibrary failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Remove the debug monitor subsystem.
|
||||
*/
|
||||
|
||||
void DebugMonitor::remove()
|
||||
{
|
||||
if (removeFunction)
|
||||
removeFunction();
|
||||
|
||||
removeFunction = NULL;
|
||||
setBehindWindowFunction = NULL;
|
||||
clearScreenFunction = NULL;
|
||||
clearToCursorFunction = NULL;
|
||||
gotoXYFunction = NULL;
|
||||
printFunction = NULL;
|
||||
|
||||
if (dll)
|
||||
{
|
||||
const BOOL result = FreeLibrary(dll);
|
||||
UNREF(result);
|
||||
DEBUG_FATAL(!result, ("FreeLibrary failed"));
|
||||
dll = NULL;
|
||||
|
||||
if (registryKey != HKEY_CLASSES_ROOT)
|
||||
{
|
||||
RegCloseKey(registryKey);
|
||||
registryKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DebugMonitorNamespace::changedWindowCallback(int const x, int const y, int const width, int const height)
|
||||
{
|
||||
SetRegistryValue("x", x);
|
||||
SetRegistryValue("y", y);
|
||||
SetRegistryValue("width", width);
|
||||
SetRegistryValue("height", height);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DebugMonitor::show()
|
||||
{
|
||||
if (showFunction)
|
||||
(*showFunction)();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void DebugMonitor::hide()
|
||||
{
|
||||
if (hideFunction)
|
||||
(*hideFunction)();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Set the debug window's z-order.
|
||||
*/
|
||||
|
||||
void DebugMonitor::setBehindWindow(HWND window)
|
||||
{
|
||||
if (setBehindWindowFunction)
|
||||
setBehindWindowFunction(window);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Clear the debug monitor and home the cursor.
|
||||
*
|
||||
* If the mono monitor is not installed, this routine does nothing.
|
||||
*
|
||||
* This routine will clear the contents of the debug monitor, reset the screen
|
||||
* offset to 0, and move the cursor to the upper left corner of the screen.
|
||||
*
|
||||
* @see DebugMonitor::home(), DebugMonitor::clearToCursor()
|
||||
*/
|
||||
|
||||
void DebugMonitor::clearScreen()
|
||||
{
|
||||
if (noClear)
|
||||
return;
|
||||
|
||||
if (clearScreenFunction)
|
||||
clearScreenFunction();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Clear the debug monitor to the current cursor position and home the cursor.
|
||||
*
|
||||
* If the debug monitor is not installed, this routine does nothing.
|
||||
*
|
||||
* This routine will clear the contents of the debug monitor only up to the
|
||||
* cursor position. If the cursor is not very far down on the screen,
|
||||
* this routine may be significantly more efficient clearing the screen.
|
||||
*
|
||||
* It will also move the cursor to the upper left corner of the screen.
|
||||
*
|
||||
* @see DebugMonitor::clearScreen(), DebugMonitor::home()
|
||||
*/
|
||||
|
||||
void DebugMonitor::clearToCursor()
|
||||
{
|
||||
if (clearToCursorFunction)
|
||||
clearToCursorFunction();
|
||||
else
|
||||
clearScreen();
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// Move the cursor to the upper left hand corner of the mono monitor screen
|
||||
//
|
||||
// Remarks:
|
||||
//
|
||||
// If the debug monitor is not installed, this routine does nothing.
|
||||
//
|
||||
// All printing happens at the cursor position.
|
||||
//
|
||||
// This routine is identical to calling gotoXY(0,0);
|
||||
//
|
||||
// See Also:
|
||||
//
|
||||
// DebugMonitor::gotoXY()
|
||||
|
||||
void DebugMonitor::home()
|
||||
{
|
||||
gotoXY(0,0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Position the cursor on the debug monitor screen.
|
||||
*
|
||||
* If the debug monitor is not installed, this routine does nothing.
|
||||
*
|
||||
* All printing happens at the cursor position.
|
||||
*
|
||||
* @param x New X position for the cursor
|
||||
* @param y New Y position for the cursor
|
||||
*/
|
||||
|
||||
void DebugMonitor::gotoXY(int x, int y)
|
||||
{
|
||||
if (gotoXYFunction)
|
||||
gotoXYFunction(x, y);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Display a string on the debug monitor.
|
||||
*
|
||||
* If the debug monitor is not installed, this routine does nothing.
|
||||
*
|
||||
* Printing occurs from the cursor position.
|
||||
*
|
||||
* Newline characters '\n' will cause the cursor position to advance to the
|
||||
* beginning of the next line. If the cursor is already on the last line of
|
||||
* the screen, the screen will scroll up one line and the cursor will move to
|
||||
* the beginning of the last line.
|
||||
*
|
||||
* The backspace character '\b' will cause the cursor to move one character
|
||||
* backwards. If at the beginning of the line, the cursor will move to the
|
||||
* end of the previous line. If already on the first line of the screen, the
|
||||
* cursor position and screen contents will be unchanged.
|
||||
*
|
||||
* All other characters are placed directly into the text frame buffer.
|
||||
* After each character, the cursor will be logically advanced one
|
||||
* character forward. If the cursor was on the last column, it will advance
|
||||
* to the next line. If the cursor was already on the last line, the screen
|
||||
* will be scrolled up one line and the cursor will move to the beginning of
|
||||
* the last line.
|
||||
*
|
||||
* @param string String to display on the debug monitor
|
||||
*/
|
||||
|
||||
void DebugMonitor::print(const char *string)
|
||||
{
|
||||
if (printFunction)
|
||||
printFunction(string);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Ensure all changes to the DebugMonitor have taken effect by the time
|
||||
* this function returns.
|
||||
*
|
||||
* Note: some platforms may do nothing here. The Win32 platform does not
|
||||
* require flushing. The Linux platform does. Call it assuming
|
||||
* that it is needed. It will be a no-op when not required.
|
||||
*/
|
||||
|
||||
void DebugMonitor::flushOutput()
|
||||
{
|
||||
// Win32 debug monitors don't need to do anything here.
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// DebugMonitor.h
|
||||
//
|
||||
// Portions copyright 1998 Bootprint Entertainment
|
||||
// Portions copyright 2002-2004 Sony Online Entertainment
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_DebugMonitor_H
|
||||
#define INCLUDED_DebugMonitor_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/Production.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#if PRODUCTION == 0
|
||||
|
||||
class DebugMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
static void remove();
|
||||
|
||||
static void setBehindWindow(HWND window);
|
||||
|
||||
static void show();
|
||||
static void hide();
|
||||
|
||||
static void clearScreen();
|
||||
static void clearToCursor();
|
||||
|
||||
static void home();
|
||||
static void gotoXY(int x, int y);
|
||||
static void print(const char *string);
|
||||
|
||||
static void flushOutput();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstDebug.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "shareddebug/FirstSharedDebug.h"
|
||||
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// PerformanceTimer.cpp
|
||||
// Copyright 2000-2004 Sony Online Entertainment
|
||||
//
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "shareddebug/FirstSharedDebug.h"
|
||||
#include "shareddebug/PerformanceTimer.h"
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
__int64 PerformanceTimer::ms_frequency;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void PerformanceTimer::install()
|
||||
{
|
||||
BOOL result = QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&ms_frequency));
|
||||
FATAL(!result, ("PerformanceTimer::install QPF failed"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
PerformanceTimer::PerformanceTimer() :
|
||||
m_startTime (0),
|
||||
m_stopTime (0)
|
||||
{
|
||||
DEBUG_FATAL (ms_frequency == 0.f, ("PerformanceTimer not installed"));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
PerformanceTimer::~PerformanceTimer()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void PerformanceTimer::start()
|
||||
{
|
||||
//-- get the current time
|
||||
BOOL result = QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&m_startTime));
|
||||
DEBUG_FATAL(!result, ("PerformanceTimer::start QPC failed"));
|
||||
UNREF (result);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void PerformanceTimer::resume()
|
||||
{
|
||||
__int64 delta = m_stopTime - m_startTime;
|
||||
start();
|
||||
m_startTime -= delta;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void PerformanceTimer::stop ()
|
||||
{
|
||||
//-- get the current time
|
||||
BOOL result = QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&m_stopTime));
|
||||
DEBUG_FATAL(!result, ("PerformanceTimer::stop QPC failed"));
|
||||
UNREF (result);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
float PerformanceTimer::getElapsedTime() const
|
||||
{
|
||||
return static_cast<float> (m_stopTime - m_startTime) / static_cast<float> (ms_frequency);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
float PerformanceTimer::getSplitTime() const
|
||||
{
|
||||
__int64 currentTime;
|
||||
BOOL result = QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(¤tTime));
|
||||
UNREF(result);
|
||||
DEBUG_FATAL(!result, ("PerformanceTimer::getSplitTime QPC failed"));
|
||||
|
||||
return static_cast<float> (currentTime - m_startTime) / static_cast<float> (ms_frequency);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void PerformanceTimer::logElapsedTime(const char* string) const
|
||||
{
|
||||
UNREF (string);
|
||||
|
||||
#ifdef _DEBUG
|
||||
static char buffer [1000];
|
||||
sprintf (buffer, "%s : %1.5f seconds\n", string ? string : "null", getElapsedTime());
|
||||
DEBUG_REPORT_LOG_PRINT (true, ("%s", buffer));
|
||||
DEBUG_OUTPUT_CHANNEL("Foundation\\PerformanceTimer", ("%s", buffer));
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// PerformanceTimer.h
|
||||
// Copyright 2000-2004 Sony Online Entertainment
|
||||
//
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#ifndef INCLUDED_PerformanceTimer_H
|
||||
#define INCLUDED_PerformanceTimer_H
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
class PerformanceTimer
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
public:
|
||||
|
||||
DLLEXPORT PerformanceTimer();
|
||||
DLLEXPORT ~PerformanceTimer();
|
||||
|
||||
void DLLEXPORT start();
|
||||
void DLLEXPORT resume();
|
||||
void DLLEXPORT stop();
|
||||
|
||||
float DLLEXPORT getElapsedTime() const;
|
||||
float getSplitTime() const; // Get the time since the timer was started without stopping the timer.
|
||||
void logElapsedTime(const char* string) const;
|
||||
|
||||
private:
|
||||
|
||||
PerformanceTimer(PerformanceTimer const &);
|
||||
PerformanceTimer & operator=(PerformanceTimer const &);
|
||||
|
||||
private:
|
||||
|
||||
static __int64 ms_frequency;
|
||||
|
||||
private:
|
||||
|
||||
__int64 m_startTime;
|
||||
__int64 m_stopTime;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ProfilerTimer.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "shareddebug/FirstSharedDebug.h"
|
||||
#include "shareddebug/ProfilerTimer.h"
|
||||
|
||||
#include "shareddebug/DebugFlags.h"
|
||||
#include "sharedFoundation/WindowsWrapper.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace ProfilerTimerNamespace
|
||||
{
|
||||
ProfilerTimer::Type ms_qpcFrequency;
|
||||
float ms_floatQpcFrequency;
|
||||
__int64 ms_rdtsc;
|
||||
__int64 ms_qpc;
|
||||
bool ms_useRdtsc;
|
||||
|
||||
}
|
||||
using namespace ProfilerTimerNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
static __int64 __declspec(naked) __stdcall readTimeStampCounter()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
rdtsc;
|
||||
ret;
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void ProfilerTimer::install()
|
||||
{
|
||||
IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&ms_qpc)));
|
||||
ms_rdtsc = readTimeStampCounter();
|
||||
|
||||
IGNORE_RETURN(QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&ms_qpcFrequency)));
|
||||
ms_floatQpcFrequency = static_cast<float>(ms_qpcFrequency);
|
||||
|
||||
DebugFlags::registerFlag(ms_useRdtsc, "SharedDebug/Profiler", "useRdtsc");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ProfilerTimer::getTime(Type &time)
|
||||
{
|
||||
if (ms_useRdtsc)
|
||||
time = readTimeStampCounter();
|
||||
else
|
||||
IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&time)));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void ProfilerTimer::getCalibratedTime(Type &time, Type &frequency)
|
||||
{
|
||||
if (ms_useRdtsc)
|
||||
{
|
||||
__int64 qpc;
|
||||
IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&qpc)));
|
||||
__int64 rdtsc = readTimeStampCounter();
|
||||
|
||||
float const t = static_cast<float>(qpc - ms_qpc) / ms_floatQpcFrequency;
|
||||
frequency = static_cast<__int64>(static_cast<float>(rdtsc - ms_rdtsc) / t);
|
||||
|
||||
time = rdtsc;
|
||||
ms_qpc = qpc;
|
||||
ms_rdtsc = time;
|
||||
}
|
||||
else
|
||||
{
|
||||
IGNORE_RETURN(QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER *>(&time)));
|
||||
frequency = ms_qpcFrequency;
|
||||
}
|
||||
}
|
||||
|
||||
void ProfilerTimer::getFrequency(Type &frequency)
|
||||
{
|
||||
frequency = ms_qpcFrequency;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,29 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ProfilerTimer.h
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_ProfilerTimer_H
|
||||
#define INCLUDED_ProfilerTimer_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class ProfilerTimer
|
||||
{
|
||||
public:
|
||||
|
||||
typedef __int64 Type;
|
||||
|
||||
public:
|
||||
|
||||
static void install();
|
||||
static void getTime(Type &time);
|
||||
static void getCalibratedTime(Type &time, Type &frequency);
|
||||
static void getFrequency(Type &frequency);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,142 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// VTune.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedDebug/FirstSharedDebug.h"
|
||||
#include "sharedDebug/VTune.h"
|
||||
|
||||
#if PRODUCTION == 0
|
||||
|
||||
#include "sharedDebug/DebugFlags.h"
|
||||
|
||||
#include <vtune/vtuneapi.h>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
HMODULE VTune::ms_module;
|
||||
VTune::PauseFunction VTune::ms_pauseFunction;
|
||||
VTune::ResumeFunction VTune::ms_resumeFunction;
|
||||
VTune::State VTune::ms_state;
|
||||
bool VTune::ms_resumeNextFrame;
|
||||
bool VTune::ms_pauseNextFrame;
|
||||
bool VTune::ms_debugReport;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void VTune::install()
|
||||
{
|
||||
DEBUG_FATAL(ms_module, ("vtune already installed"));
|
||||
|
||||
ms_module = LoadLibrary("VTuneAPI");
|
||||
if (!ms_module)
|
||||
return;
|
||||
|
||||
ms_pauseFunction = reinterpret_cast<PauseFunction>(GetProcAddress(ms_module, "VTPause"));
|
||||
ms_resumeFunction = reinterpret_cast<PauseFunction>(GetProcAddress(ms_module, "VTResume"));
|
||||
ms_state = S_default;
|
||||
|
||||
#if PRODUCTION == 0
|
||||
DebugFlags::registerFlag(ms_debugReport, "SharedDebug", "vtuneState", debugReport);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::remove()
|
||||
{
|
||||
if (ms_module)
|
||||
{
|
||||
FreeLibrary(ms_module);
|
||||
ms_pauseFunction = 0;
|
||||
ms_resumeFunction = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::debugReport()
|
||||
{
|
||||
switch (ms_state)
|
||||
{
|
||||
case S_default:
|
||||
REPORT_PRINT(true, ("Vtune state unknown\n"));
|
||||
break;
|
||||
|
||||
case S_sampling:
|
||||
REPORT_PRINT(true, ("Vtune is sampling\n"));
|
||||
break;
|
||||
|
||||
case S_paused:
|
||||
REPORT_PRINT(true, ("Vtune is NOT sampling\n"));
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_FATAL(true, ("bad case"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::resume()
|
||||
{
|
||||
if (ms_module && ms_resumeFunction)
|
||||
{
|
||||
MessageBeep(MB_OK);
|
||||
(*ms_resumeFunction)();
|
||||
ms_state = S_sampling;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::pause()
|
||||
{
|
||||
if (ms_module && ms_pauseFunction)
|
||||
{
|
||||
(*ms_pauseFunction)();
|
||||
MessageBeep(MB_ICONEXCLAMATION);
|
||||
ms_state = S_paused;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::pauseNextFrame()
|
||||
{
|
||||
ms_pauseNextFrame = true;
|
||||
ms_resumeNextFrame = false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::resumeNextFrame()
|
||||
{
|
||||
ms_pauseNextFrame = false;
|
||||
ms_resumeNextFrame = true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void VTune::beginFrame()
|
||||
{
|
||||
if (ms_pauseNextFrame)
|
||||
{
|
||||
pause();
|
||||
ms_pauseNextFrame = false;
|
||||
}
|
||||
|
||||
if (ms_resumeNextFrame)
|
||||
{
|
||||
resume();
|
||||
ms_resumeNextFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // PRODUCTION == 0
|
||||
@@ -0,0 +1,65 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// VTune.h
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_VTune_H
|
||||
#define INCLUDED_VTune_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/Production.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#if PRODUCTION == 0
|
||||
|
||||
class VTune
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
static void resume();
|
||||
static void pause();
|
||||
|
||||
static void resumeNextFrame();
|
||||
static void pauseNextFrame();
|
||||
static void beginFrame();
|
||||
|
||||
private:
|
||||
|
||||
static void remove();
|
||||
static void debugReport();
|
||||
|
||||
private:
|
||||
|
||||
enum State
|
||||
{
|
||||
S_default,
|
||||
S_sampling,
|
||||
S_paused
|
||||
};
|
||||
|
||||
typedef void (__cdecl *PauseFunction)(void);
|
||||
typedef void (__cdecl *ResumeFunction)(void);
|
||||
|
||||
private:
|
||||
|
||||
static HMODULE ms_module;
|
||||
static PauseFunction ms_pauseFunction;
|
||||
static ResumeFunction ms_resumeFunction;
|
||||
static State ms_state;
|
||||
static bool ms_resumeNextFrame;
|
||||
static bool ms_pauseNextFrame;
|
||||
static bool ms_debugReport;
|
||||
};
|
||||
|
||||
#endif // PRODUCTION == 0
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -123,8 +123,8 @@ FileStreamer::File *FileStreamer::open(const char *fileName, bool randomAccess)
|
||||
reportModDirectory(fileName, "appearance/", "Appearance") ||
|
||||
reportModDirectory(fileName, "music/", "Music") ||
|
||||
reportModDirectory(fileName, "sound/", "Sound") ||
|
||||
reportModDirectory(fileName, "camera/", "Camera") ||
|
||||
reportModDirectory(fileName, "shader/", "Shader");
|
||||
reportModDirectory(fileName, "camera/", "Camera"); // ||
|
||||
//reportModDirectory(fileName, "shader/", "Shader");
|
||||
#endif
|
||||
|
||||
// return the opened file
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstFile.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFile/FirstSharedFile.h"
|
||||
@@ -0,0 +1,195 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// OsFile.cpp
|
||||
// Copyright 2002, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFile/FirstSharedFile.h"
|
||||
#include "sharedFile/OsFile.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "sharedDebug/PerformanceTimer.h"
|
||||
#endif
|
||||
|
||||
namespace OsFileNamespace
|
||||
{
|
||||
float ms_time;
|
||||
}
|
||||
using namespace OsFileNamespace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
void OsFile::install()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
float OsFile::getSpentTime()
|
||||
{
|
||||
float const result = ms_time;
|
||||
ms_time = 0.0f;
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool OsFile::exists(const char *fileName)
|
||||
{
|
||||
NOT_NULL(fileName);
|
||||
DWORD attributes = GetFileAttributes(fileName);
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
const DWORD INVALID_FILE_ATTRIBUTES = 0xffffffff;
|
||||
#endif
|
||||
return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int OsFile::getFileSize(const char *fileName)
|
||||
{
|
||||
NOT_NULL(fileName);
|
||||
|
||||
#ifdef _DEBUG
|
||||
PerformanceTimer t;
|
||||
t.start();
|
||||
#endif
|
||||
|
||||
HANDLE handle = CreateFile(fileName, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
int const size = GetFileSize(handle, NULL);
|
||||
CloseHandle(handle);
|
||||
|
||||
#ifdef _DEBUG
|
||||
t.stop();
|
||||
ms_time += t.getElapsedTime();
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
OsFile *OsFile::open(const char *fileName, bool randomAccess)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
PerformanceTimer t;
|
||||
t.start();
|
||||
#endif
|
||||
|
||||
// attempt to open the file
|
||||
HANDLE handle = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | (randomAccess ? FILE_FLAG_RANDOM_ACCESS : 0), NULL);
|
||||
|
||||
// check to make sure the file opened sucessfully
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
#ifdef _DEBUG
|
||||
t.stop();
|
||||
ms_time += t.getElapsedTime();
|
||||
#endif
|
||||
|
||||
return new OsFile(handle);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
OsFile::OsFile(HANDLE handle)
|
||||
: m_handle(handle),
|
||||
m_offset(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
OsFile::~OsFile()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
PerformanceTimer t;
|
||||
t.start();
|
||||
#endif
|
||||
|
||||
CloseHandle(m_handle);
|
||||
|
||||
#ifdef _DEBUG
|
||||
t.stop();
|
||||
ms_time+= t.getElapsedTime();
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int OsFile::length() const
|
||||
{
|
||||
return GetFileSize(m_handle, NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void OsFile::seek(int newFilePosition)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
PerformanceTimer t;
|
||||
t.start();
|
||||
#endif
|
||||
|
||||
if (m_offset != newFilePosition)
|
||||
{
|
||||
const DWORD result = SetFilePointer(m_handle, newFilePosition, NULL, FILE_BEGIN);
|
||||
DEBUG_FATAL(static_cast<int>(result) != newFilePosition, ("SetFilePointer failed"));
|
||||
UNREF(result);
|
||||
m_offset = newFilePosition;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
t.stop();
|
||||
ms_time += t.getElapsedTime();
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int OsFile::read(void *destinationBuffer, int numberOfBytes)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
PerformanceTimer t;
|
||||
t.start();
|
||||
#endif
|
||||
|
||||
DWORD amountReadDword;
|
||||
BOOL result = ReadFile(m_handle, destinationBuffer, static_cast<uint>(numberOfBytes), &amountReadDword, NULL);
|
||||
|
||||
// miles crasher hack
|
||||
#if 0
|
||||
FATAL(!result, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
|
||||
#else
|
||||
if(!result)
|
||||
{
|
||||
if(GetLastError() == 998) // access violation - buffer coming from miles hosed
|
||||
{
|
||||
WARNING(true,("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FATAL(true, ("FileStreamerThread::processRead ReadFile failed to read '%d' bytes with error '%d'", static_cast<uint>(numberOfBytes), GetLastError()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// end miles crasher hack
|
||||
|
||||
#ifdef _DEBUG
|
||||
t.stop();
|
||||
ms_time += t.getElapsedTime();
|
||||
#endif
|
||||
|
||||
m_offset += static_cast<int>(amountReadDword);
|
||||
return static_cast<int>(amountReadDword);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,48 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// OsFile.h
|
||||
// Copyright 2002, Sony Online Entertainment Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_OsFile_H
|
||||
#define INCLUDED_OsFile_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class OsFile
|
||||
{
|
||||
public:
|
||||
|
||||
static void install();
|
||||
|
||||
static float getSpentTime();
|
||||
|
||||
static bool exists(const char *fileName);
|
||||
static int getFileSize(const char *fileName);
|
||||
static OsFile *open(const char *fileName, bool randomAccess=false);
|
||||
|
||||
public:
|
||||
|
||||
~OsFile();
|
||||
|
||||
int length() const;
|
||||
int tell() const;
|
||||
void seek(int newFilePosition);
|
||||
int read(void *destinationBuffer, int numberOfBytes);
|
||||
|
||||
private:
|
||||
|
||||
OsFile(HANDLE handle);
|
||||
OsFile(const char *fileName);
|
||||
|
||||
private:
|
||||
|
||||
HANDLE m_handle;
|
||||
int m_offset;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ByteOrder.cpp
|
||||
// copyright (c) 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedFoundation/ByteOrder.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
// I'm using the arguments, but the compiler can't tell that
|
||||
#pragma warning(disable: 4100)
|
||||
|
||||
__declspec(naked) ulong ntohl(ulong netLong)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
bswap eax
|
||||
ret
|
||||
}
|
||||
} //lint !e533 !e715 // function should return a value, argument not referenced
|
||||
|
||||
__declspec(naked) ulong htonl(ulong hostLong)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
bswap eax
|
||||
ret
|
||||
}
|
||||
} //lint !e533 !e715 // function should return a value, argument not referenced
|
||||
|
||||
__declspec(naked) ushort ntohs(ushort netShort)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
bswap eax
|
||||
shr eax, 16
|
||||
ret
|
||||
}
|
||||
} //lint !e533 !e715 // function should return a value, argument not referenced
|
||||
|
||||
__declspec(naked) ushort htons(ushort hostShort)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, [esp+4]
|
||||
bswap eax
|
||||
shr eax, 16
|
||||
ret
|
||||
}
|
||||
} //lint !e533 !e715 // function should return a value, argument not referenced
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,22 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ByteOrder.h
|
||||
// copyright 1998 Bootprint Entertainment
|
||||
// copyright 2001 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef BYTE_ORDER_H
|
||||
#define BYTE_ORDER_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
ulong __cdecl ntohl(ulong netLong);
|
||||
ushort __cdecl ntohs(ushort netShort);
|
||||
|
||||
ulong __cdecl htonl(ulong hostLong);
|
||||
ushort __cdecl htons(ushort hostShort);
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user